1 ;;; gnus-art.el --- article mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
28 (eval-when-compile (require 'cl
))
41 (defgroup gnus-article nil
43 :link
'(custom-manual "(gnus)The Article Buffer")
46 (defgroup gnus-article-treat nil
47 "Treating article parts."
48 :link
'(custom-manual "(gnus)Article Hiding")
51 (defgroup gnus-article-hiding nil
52 "Hiding article parts."
53 :link
'(custom-manual "(gnus)Article Hiding")
56 (defgroup gnus-article-highlight nil
57 "Article highlighting."
58 :link
'(custom-manual "(gnus)Article Highlighting")
62 (defgroup gnus-article-signature nil
64 :link
'(custom-manual "(gnus)Article Signature")
67 (defgroup gnus-article-headers nil
69 :link
'(custom-manual "(gnus)Hiding Headers")
72 (defgroup gnus-article-washing nil
73 "Special commands on articles."
74 :link
'(custom-manual "(gnus)Article Washing")
77 (defgroup gnus-article-emphasis nil
78 "Fontisizing articles."
79 :link
'(custom-manual "(gnus)Article Fontisizing")
82 (defgroup gnus-article-saving nil
84 :link
'(custom-manual "(gnus)Saving Articles")
87 (defgroup gnus-article-mime nil
88 "Worshiping the MIME wonder."
89 :link
'(custom-manual "(gnus)Using MIME")
92 (defgroup gnus-article-buttons nil
93 "Pushable buttons in the article buffer."
94 :link
'(custom-manual "(gnus)Article Buttons")
97 (defgroup gnus-article-various nil
98 "Other article options."
99 :link
'(custom-manual "(gnus)Misc Article")
100 :group
'gnus-article
)
102 (defcustom gnus-ignored-headers
103 '("^Path:" "^Expires:" "^Date-Received:" "^References:" "^Xref:" "^Lines:"
104 "^Relay-Version:" "^Message-ID:" "^Approved:" "^Sender:" "^Received:"
105 "^X-UIDL:" "^MIME-Version:" "^Return-Path:" "^In-Reply-To:"
106 "^Content-Type:" "^Content-Transfer-Encoding:" "^X-WebTV-Signature:"
107 "^X-MimeOLE:" "^X-MSMail-Priority:" "^X-Priority:" "^X-Loop:"
108 "^X-Authentication-Warning:" "^X-MIME-Autoconverted:" "^X-Face:"
109 "^X-Attribution:" "^X-Originating-IP:" "^Delivered-To:"
110 "^NNTP-[-A-Za-z]+:" "^Distribution:" "^X-no-archive:" "^X-Trace:"
111 "^X-Complaints-To:" "^X-NNTP-Posting-Host:" "^X-Orig.*:"
112 "^Abuse-Reports-To:" "^Cache-Post-Path:" "^X-Article-Creation-Date:"
113 "^X-Poster:" "^X-Mail2News-Path:" "^X-Server-Date:" "^X-Cache:"
114 "^Originator:" "^X-Problems-To:" "^X-Auth-User:" "^X-Post-Time:"
115 "^X-Admin:" "^X-UID:" "^Resent-[-A-Za-z]+:" "^X-Mailing-List:"
116 "^Precedence:" "^Original-[-A-Za-z]+:" "^X-filename:" "^X-Orcpt:"
117 "^Old-Received:" "^X-Pgp" "^X-Auth:" "^X-From-Line:"
118 "^X-Gnus-Article-Number:" "^X-Majordomo:" "^X-Url:" "^X-Sender:"
119 "^MBOX-Line" "^Priority:" "^X-Pgp" "^X400-[-A-Za-z]+:"
120 "^Status:" "^X-Gnus-Mail-Source:" "^Cancel-Lock:"
121 "^X-FTN" "^X-EXP32-SerialNo:" "^Encoding:" "^Importance:"
122 "^Autoforwarded:" "^Original-Encoded-Information-Types:" "^X-Ya-Pop3:"
123 "^X-Face-Version:" "^X-Vms-To:" "^X-ML-NAME:" "^X-ML-COUNT:"
124 "^Mailing-List:" "^X-finfo:" "^X-md5sum:" "^X-md5sum-Origin:"
125 "^X-Sun-Charset:" "^X-Accept-Language:" "^X-Envelope-Sender:"
126 "^List-[A-Za-z]+:" "^X-Listprocessor-Version:"
127 "^X-Received:" "^X-Distribute:" "^X-Sequence:" "^X-Juno-Line-Breaks:"
128 "^X-Notes-Item:" "^X-MS-TNEF-Correlator:" "^x-uunet-gateway:"
129 "^X-Received:" "^Content-length:" "X-precedence:")
130 "*All headers that start with this regexp will be hidden.
131 This variable can also be a list of regexps of headers to be ignored.
132 If `gnus-visible-headers' is non-nil, this variable will be ignored."
133 :type
'(choice :custom-show nil
136 :group
'gnus-article-hiding
)
138 (defcustom gnus-visible-headers
139 "^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:"
140 "*All headers that do not match this regexp will be hidden.
141 This variable can also be a list of regexp of headers to remain visible.
142 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
143 :type
'(repeat :value-to-internal
(lambda (widget value
)
144 (custom-split-regexp-maybe value
))
145 :match
(lambda (widget value
)
147 (widget-editable-list-match widget value
)))
149 :group
'gnus-article-hiding
)
151 (defcustom gnus-sorted-header-list
152 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
153 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
154 "*This variable is a list of regular expressions.
155 If it is non-nil, headers that match the regular expressions will
156 be placed first in the article buffer in the sequence specified by
158 :type
'(repeat regexp
)
159 :group
'gnus-article-hiding
)
161 (defcustom gnus-boring-article-headers
'(empty followup-to reply-to
)
162 "Headers that are only to be displayed if they have interesting data.
163 Possible values in this list are `empty', `newsgroups', `followup-to',
164 `reply-to', `date', `long-to', and `many-to'."
165 :type
'(set (const :tag
"Headers with no content." empty
)
166 (const :tag
"Newsgroups with only one group." newsgroups
)
167 (const :tag
"Followup-to identical to newsgroups." followup-to
)
168 (const :tag
"Reply-to identical to from." reply-to
)
169 (const :tag
"Date less than four days old." date
)
170 (const :tag
"Very long To and/or Cc header." long-to
)
171 (const :tag
"Multiple To and/or Cc headers." many-to
))
172 :group
'gnus-article-hiding
)
174 (defcustom gnus-signature-separator
'("^-- $" "^-- *$")
175 "Regexp matching signature separator.
176 This can also be a list of regexps. In that case, it will be checked
177 from head to tail looking for a separator. Searches will be done from
178 the end of the buffer."
179 :type
'(repeat string
)
180 :group
'gnus-article-signature
)
182 (defcustom gnus-signature-limit nil
183 "Provide a limit to what is considered a signature.
184 If it is a number, no signature may not be longer (in characters) than
185 that number. If it is a floating point number, no signature may be
186 longer (in lines) than that number. If it is a function, the function
187 will be called without any parameters, and if it returns nil, there is
188 no signature in the buffer. If it is a string, it will be used as a
189 regexp. If it matches, the text in question is not a signature."
190 :type
'(choice (integer :value
200)
192 (function :value fun
)
193 (regexp :value
".*"))
194 :group
'gnus-article-signature
)
196 (defcustom gnus-hidden-properties
'(invisible t intangible t
)
197 "Property list to use for hiding text."
199 :group
'gnus-article-hiding
)
201 ;; Fixme: This isn't the right thing for mixed graphical and and
202 ;; non-graphical frames in a session.
203 ;; gnus-xmas.el overrides this for XEmacs.
204 (defcustom gnus-article-x-face-command
205 (if (and (fboundp 'image-type-available-p
)
206 (image-type-available-p 'xbm
))
207 'gnus-article-display-xface
208 (if gnus-article-compface-xbm
209 "{ echo '/* Width=48, Height=48 */'; uncompface; } | display -"
210 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
212 "*String or function to be executed to display an X-Face header.
213 If it is a string, the command will be executed in a sub-shell
214 asynchronously. The compressed face will be piped to this command."
215 :type
'(choice string
216 (function-item gnus-article-display-xface
)
219 :group
'gnus-article-washing
)
221 (defcustom gnus-article-x-face-too-ugly nil
222 "Regexp matching posters whose face shouldn't be shown automatically."
223 :type
'(choice regexp
(const nil
))
224 :group
'gnus-article-washing
)
226 (defcustom gnus-article-banner-alist nil
227 "Banner alist for stripping.
229 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( eGroups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
231 :type
'(repeat (cons symbol regexp
))
232 :group
'gnus-article-washing
)
234 (defcustom gnus-emphasis-alist
236 "\\(\\s-\\|^\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\s-\\|[-,;:\"]\\s-\\|[?!.]+\\s-\\|\\s)\\)")
238 '(("_" "_" underline
)
241 ("_/" "/_" underline-italic
)
242 ("_\\*" "\\*_" underline-bold
)
243 ("\\*/" "/\\*" bold-italic
)
244 ("_\\*/" "/\\*_" underline-bold-italic
))))
245 `(("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
246 2 3 gnus-emphasis-underline
)
250 (format format
(car spec
) (cadr spec
))
251 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec
)))))
253 "*Alist that says how to fontify certain phrases.
254 Each item looks like this:
256 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
258 The first element is a regular expression to be matched. The second
259 is a number that says what regular expression grouping used to find
260 the entire emphasized word. The third is a number that says what
261 regexp grouping should be displayed and highlighted. The fourth
262 is the face used for highlighting."
263 :type
'(repeat (list :value
("" 0 0 default
)
265 (integer :tag
"Match group")
266 (integer :tag
"Emphasize group")
268 :group
'gnus-article-emphasis
)
270 (defcustom gnus-emphasize-whitespace-regexp
"^[ \t]+\\|[ \t]*\n"
271 "A regexp to describe whitespace which should not be emphasized.
272 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
273 The former avoids underlining of leading and trailing whitespace,
274 and the latter avoids underlining any whitespace at all."
276 :group
'gnus-article-emphasis
279 (defface gnus-emphasis-bold
'((t (:bold t
)))
280 "Face used for displaying strong emphasized text (*word*)."
281 :group
'gnus-article-emphasis
)
283 (defface gnus-emphasis-italic
'((t (:italic t
)))
284 "Face used for displaying italic emphasized text (/word/)."
285 :group
'gnus-article-emphasis
)
287 (defface gnus-emphasis-underline
'((t (:underline t
)))
288 "Face used for displaying underlined emphasized text (_word_)."
289 :group
'gnus-article-emphasis
)
291 (defface gnus-emphasis-underline-bold
'((t (:bold t
:underline t
)))
292 "Face used for displaying underlined bold emphasized text (_*word*_)."
293 :group
'gnus-article-emphasis
)
295 (defface gnus-emphasis-underline-italic
'((t (:italic t
:underline t
)))
296 "Face used for displaying underlined italic emphasized text (_/word/_)."
297 :group
'gnus-article-emphasis
)
299 (defface gnus-emphasis-bold-italic
'((t (:bold t
:italic t
)))
300 "Face used for displaying bold italic emphasized text (/*word*/)."
301 :group
'gnus-article-emphasis
)
303 (defface gnus-emphasis-underline-bold-italic
304 '((t (:bold t
:italic t
:underline t
)))
305 "Face used for displaying underlined bold italic emphasized text.
306 Esample: (_/*word*/_)."
307 :group
'gnus-article-emphasis
)
309 (defface gnus-emphasis-highlight-words
310 '((t (:background
"black" :foreground
"yellow")))
311 "Face used for displaying highlighted words."
312 :group
'gnus-article-emphasis
)
314 (defcustom gnus-article-time-format
"%a, %b %d %Y %T %Z"
315 "Format for display of Date headers in article bodies.
316 See `format-time-string' for the possible values.
318 The variable can also be function, which should return a complete Date
319 header. The function is called with one argument, the time, which can
320 be fed to `format-time-string'."
321 :type
'(choice string symbol
)
322 :link
'(custom-manual "(gnus)Article Date")
323 :group
'gnus-article-washing
)
326 (autoload 'mail-extract-address-components
"mail-extr"))
328 (defcustom gnus-save-all-headers t
329 "*If non-nil, don't remove any headers before saving."
330 :group
'gnus-article-saving
333 (defcustom gnus-prompt-before-saving
'always
334 "*This variable says how much prompting is to be done when saving articles.
335 If it is nil, no prompting will be done, and the articles will be
336 saved to the default files. If this variable is `always', each and
337 every article that is saved will be preceded by a prompt, even when
338 saving large batches of articles. If this variable is neither nil not
339 `always', there the user will be prompted once for a file name for
340 each invocation of the saving commands."
341 :group
'gnus-article-saving
342 :type
'(choice (item always
)
343 (item :tag
"never" nil
)
344 (sexp :tag
"once" :format
"%t\n" :value t
)))
346 (defcustom gnus-saved-headers gnus-visible-headers
347 "Headers to keep if `gnus-save-all-headers' is nil.
348 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
349 If that variable is nil, however, all headers that match this regexp
350 will be kept while the rest will be deleted before saving."
351 :group
'gnus-article-saving
354 (defcustom gnus-default-article-saver
'gnus-summary-save-in-rmail
355 "A function to save articles in your favourite format.
356 The function must be interactively callable (in other words, it must
357 be an Emacs command).
359 Gnus provides the following functions:
361 * gnus-summary-save-in-rmail (Rmail format)
362 * gnus-summary-save-in-mail (Unix mail format)
363 * gnus-summary-save-in-folder (MH folder)
364 * gnus-summary-save-in-file (article format)
365 * gnus-summary-save-in-vm (use VM's folder format)
366 * gnus-summary-write-to-file (article format -- overwrite)."
367 :group
'gnus-article-saving
368 :type
'(radio (function-item gnus-summary-save-in-rmail
)
369 (function-item gnus-summary-save-in-mail
)
370 (function-item gnus-summary-save-in-folder
)
371 (function-item gnus-summary-save-in-file
)
372 (function-item gnus-summary-save-in-vm
)
373 (function-item gnus-summary-write-to-file
)))
375 (defcustom gnus-rmail-save-name
'gnus-plain-save-name
376 "A function generating a file name to save articles in Rmail format.
377 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
378 :group
'gnus-article-saving
381 (defcustom gnus-mail-save-name
'gnus-plain-save-name
382 "A function generating a file name to save articles in Unix mail format.
383 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
384 :group
'gnus-article-saving
387 (defcustom gnus-folder-save-name
'gnus-folder-save-name
388 "A function generating a file name to save articles in MH folder.
389 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
390 :group
'gnus-article-saving
393 (defcustom gnus-file-save-name
'gnus-numeric-save-name
394 "A function generating a file name to save articles in article format.
395 The function is called with NEWSGROUP, HEADERS, and optional
397 :group
'gnus-article-saving
400 (defcustom gnus-split-methods
401 '((gnus-article-archive-name)
402 (gnus-article-nndoc-name))
403 "*Variable used to suggest where articles are to be saved.
404 For instance, if you would like to save articles related to Gnus in
405 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
406 you could set this variable to something like:
408 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
409 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
411 This variable is an alist where the where the key is the match and the
412 value is a list of possible files to save in if the match is non-nil.
414 If the match is a string, it is used as a regexp match on the
415 article. If the match is a symbol, that symbol will be funcalled
416 from the buffer of the article to be saved with the newsgroup as the
417 parameter. If it is a list, it will be evaled in the same buffer.
419 If this form or function returns a string, this string will be used as
420 a possible file name; and if it returns a non-nil list, that list will
421 be used as possible file names."
422 :group
'gnus-article-saving
423 :type
'(repeat (choice (list :value
(fun) function
)
424 (cons :value
("" "") regexp
(repeat string
))
427 (defcustom gnus-page-delimiter
"^\^L"
428 "*Regexp describing what to use as article page delimiters.
429 The default value is \"^\^L\", which is a form linefeed at the
430 beginning of a line."
432 :group
'gnus-article-various
)
434 (defcustom gnus-article-mode-line-format
"Gnus: %g [%w] %S%m"
435 "*The format specification for the article mode line.
436 See `gnus-summary-mode-line-format' for a closer description.
438 The following additional specs are available:
440 %w The article washing status.
441 %m The number of MIME parts in the article."
443 :group
'gnus-article-various
)
445 (defcustom gnus-article-mode-hook nil
446 "*A hook for Gnus article mode."
448 :group
'gnus-article-various
)
450 (defcustom gnus-article-menu-hook nil
451 "*Hook run after the creation of the article mode menu."
453 :group
'gnus-article-various
)
455 (defcustom gnus-article-prepare-hook nil
456 "*A hook called after an article has been prepared in the article buffer."
458 :group
'gnus-article-various
)
460 (defcustom gnus-article-hide-pgp-hook nil
461 "*A hook called after successfully hiding a PGP signature."
463 :group
'gnus-article-various
)
465 (defcustom gnus-article-button-face
'bold
466 "Face used for highlighting buttons in the article buffer.
468 An article button is a piece of text that you can activate by pressing
469 `RET' or `mouse-2' above it."
471 :group
'gnus-article-buttons
)
473 (defcustom gnus-article-mouse-face
'highlight
474 "Face used for mouse highlighting in the article buffer.
476 Article buttons will be displayed in this face when the cursor is
479 :group
'gnus-article-buttons
)
481 (defcustom gnus-signature-face
'gnus-signature-face
482 "Face used for highlighting a signature in the article buffer.
483 Obsolete; use the face `gnus-signature-face' for customizations instead."
485 :group
'gnus-article-highlight
486 :group
'gnus-article-signature
)
488 (defface gnus-signature-face
491 "Face used for highlighting a signature in the article buffer."
492 :group
'gnus-article-highlight
493 :group
'gnus-article-signature
)
495 (defface gnus-header-from-face
498 (:foreground
"spring green"))
501 (:foreground
"red3"))
504 "Face used for displaying from headers."
505 :group
'gnus-article-headers
506 :group
'gnus-article-highlight
)
508 (defface gnus-header-subject-face
511 (:foreground
"SeaGreen3"))
514 (:foreground
"red4"))
516 (:bold t
:italic t
)))
517 "Face used for displaying subject headers."
518 :group
'gnus-article-headers
519 :group
'gnus-article-highlight
)
521 (defface gnus-header-newsgroups-face
524 (:foreground
"yellow" :italic t
))
527 (:foreground
"MidnightBlue" :italic t
))
530 "Face used for displaying newsgroups headers."
531 :group
'gnus-article-headers
532 :group
'gnus-article-highlight
)
534 (defface gnus-header-name-face
537 (:foreground
"SeaGreen"))
540 (:foreground
"maroon"))
543 "Face used for displaying header names."
544 :group
'gnus-article-headers
545 :group
'gnus-article-highlight
)
547 (defface gnus-header-content-face
550 (:foreground
"forest green" :italic t
))
553 (:foreground
"indianred4" :italic t
))
555 (:italic t
))) "Face used for displaying header content."
556 :group
'gnus-article-headers
557 :group
'gnus-article-highlight
)
559 (defcustom gnus-header-face-alist
560 '(("From" nil gnus-header-from-face
)
561 ("Subject" nil gnus-header-subject-face
)
562 ("Newsgroups:.*," nil gnus-header-newsgroups-face
)
563 ("" gnus-header-name-face gnus-header-content-face
))
564 "*Controls highlighting of article header.
566 An alist of the form (HEADER NAME CONTENT).
568 HEADER is a regular expression which should match the name of an
569 header header and NAME and CONTENT are either face names or nil.
571 The name of each header field will be displayed using the face
572 specified by the first element in the list where HEADER match the
573 header name and NAME is non-nil. Similarly, the content will be
574 displayed by the first non-nil matching CONTENT face."
575 :group
'gnus-article-headers
576 :group
'gnus-article-highlight
577 :type
'(repeat (list (regexp :tag
"Header")
579 (item :tag
"skip" nil
)
580 (face :value default
))
581 (choice :tag
"Content"
582 (item :tag
"skip" nil
)
583 (face :value default
)))))
585 (defcustom gnus-article-decode-hook
586 '(article-decode-charset article-decode-encoded-words
)
587 "*Hook run to decode charsets in articles."
588 :group
'gnus-article-headers
591 (defcustom gnus-display-mime-function
'gnus-display-mime
592 "Function to display MIME articles."
593 :group
'gnus-article-mime
596 (defvar gnus-decode-header-function
'mail-decode-encoded-word-region
597 "Function used to decode headers.")
599 (defvar gnus-article-dumbquotes-map
617 "Table for MS-to-Latin1 translation.")
619 (defcustom gnus-ignored-mime-types nil
620 "List of MIME types that should be ignored by Gnus."
622 :group
'gnus-article-mime
623 :type
'(repeat regexp
))
625 (defcustom gnus-unbuttonized-mime-types
'(".*/.*")
626 "List of MIME types that should not be given buttons when rendered inline."
628 :group
'gnus-article-mime
629 :type
'(repeat regexp
))
631 (defcustom gnus-article-mime-part-function nil
632 "Function called with a MIME handle as the argument.
633 This is meant for people who want to do something automatic based
634 on parts -- for instance, adding Vcard info to a database."
635 :group
'gnus-article-mime
638 (defcustom gnus-mime-multipart-functions nil
639 "An alist of MIME types to functions to display them."
641 :group
'gnus-article-mime
644 (defcustom gnus-article-date-lapsed-new-header nil
645 "Whether the X-Sent and Date headers can coexist.
646 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
647 either replace the old \"Date:\" header (if this variable is nil), or
648 be added below it (otherwise)."
650 :group
'gnus-article-headers
653 (defcustom gnus-article-mime-match-handle-function
'undisplayed-alternative
654 "Function called with a MIME handle as the argument.
655 This is meant for people who want to view first matched part.
656 For `undisplayed-alternative' (default), the first undisplayed
657 part or alternative part is used. For `undisplayed', the first
658 undisplayed part is used. For a function, the first part which
659 the function return `t' is used. For `nil', the first part is
662 :group
'gnus-article-mime
664 (item :tag
"first" :value nil
)
665 (item :tag
"undisplayed" :value undisplayed
)
666 (item :tag
"undisplayed or alternative"
667 :value undisplayed-alternative
)
670 (defcustom gnus-mime-action-alist
671 '(("save to file" . gnus-mime-save-part
)
672 ("display as text" . gnus-mime-inline-part
)
673 ("view the part" . gnus-mime-view-part
)
674 ("pipe to command" . gnus-mime-pipe-part
)
675 ("toggle display" . gnus-article-press-button
)
676 ("view as type" . gnus-mime-view-part-as-type
)
677 ("internalize type" . gnus-mime-internalize-part
)
678 ("externalize type" . gnus-mime-externalize-part
))
679 "An alist of actions that run on the MIME attachment."
681 :group
'gnus-article-mime
682 :type
'(repeat (cons (string :tag
"name")
686 ;;; The treatment variables
689 (defvar gnus-part-display-hook nil
690 "Hook called on parts that are to receive treatment.")
692 (defvar gnus-article-treat-custom
693 '(choice (const :tag
"Off" nil
)
695 (const :tag
"Header" head
)
696 (const :tag
"Last" last
)
697 (integer :tag
"Less")
698 (repeat :tag
"Groups" regexp
)
699 (sexp :tag
"Predicate")))
701 (defvar gnus-article-treat-head-custom
702 '(choice (const :tag
"Off" nil
)
703 (const :tag
"Header" head
)))
705 (defvar gnus-article-treat-types
'("text/plain")
708 (defvar gnus-inhibit-treatment nil
709 "Whether to inhibit treatment.")
711 (defcustom gnus-treat-highlight-signature
'(or last
(typep "text/x-vcard"))
712 "Highlight the signature.
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-highlight-signature
'highlight t
)
719 (defcustom gnus-treat-buttonize
100000
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-custom
)
725 (put 'gnus-treat-buttonize
'highlight t
)
727 (defcustom gnus-treat-buttonize-head
'head
728 "Add buttons to the head.
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-head-custom
)
733 (put 'gnus-treat-buttonize-head
'highlight t
)
735 (defcustom gnus-treat-emphasize
736 (and (or window-system
738 (>= (string-to-number emacs-version
) 21))
741 Valid values are nil, t, `head', `last', an integer or a predicate.
742 See the manual for details."
743 :group
'gnus-article-treat
744 :type gnus-article-treat-custom
)
745 (put 'gnus-treat-emphasize
'highlight t
)
747 (defcustom gnus-treat-strip-cr nil
748 "Remove carriage returns.
749 Valid values are nil, t, `head', `last', an integer or a predicate.
750 See the manual for details."
751 :group
'gnus-article-treat
752 :type gnus-article-treat-custom
)
754 (defcustom gnus-treat-hide-headers
'head
756 Valid values are nil, t, `head', `last', an integer or a predicate.
757 See the manual for details."
758 :group
'gnus-article-treat
759 :type gnus-article-treat-head-custom
)
761 (defcustom gnus-treat-hide-boring-headers nil
762 "Hide boring headers.
763 Valid values are nil, t, `head', `last', an integer or a predicate.
764 See the manual for details."
765 :group
'gnus-article-treat
766 :type gnus-article-treat-head-custom
)
768 (defcustom gnus-treat-hide-signature nil
770 Valid values are nil, t, `head', `last', an integer or a predicate.
771 See the manual for details."
772 :group
'gnus-article-treat
773 :type gnus-article-treat-custom
)
775 (defcustom gnus-treat-fill-article nil
777 Valid values are nil, t, `head', `last', an integer or a predicate.
778 See the manual for details."
779 :group
'gnus-article-treat
780 :type gnus-article-treat-custom
)
782 (defcustom gnus-treat-hide-citation nil
784 Valid values are nil, t, `head', `last', an integer or a predicate.
785 See the manual for details."
786 :group
'gnus-article-treat
787 :type gnus-article-treat-custom
)
789 (defcustom gnus-treat-hide-citation-maybe nil
791 Valid values are nil, t, `head', `last', an integer or a predicate.
792 See the manual for details."
793 :group
'gnus-article-treat
794 :type gnus-article-treat-custom
)
796 (defcustom gnus-treat-strip-list-identifiers
'head
797 "Strip list identifiers from `gnus-list-identifiers`.
798 Valid values are nil, t, `head', `last', an integer or a predicate.
799 See the manual for details."
801 :group
'gnus-article-treat
802 :type gnus-article-treat-custom
)
804 (defcustom gnus-treat-strip-pgp t
805 "Strip PGP signatures.
806 Valid values are nil, t, `head', `last', an integer or a predicate.
807 See the manual for details."
808 :group
'gnus-article-treat
809 :type gnus-article-treat-custom
)
811 (defcustom gnus-treat-strip-pem nil
812 "Strip PEM signatures.
813 Valid values are nil, t, `head', `last', an integer or a predicate.
814 See the manual for details."
815 :group
'gnus-article-treat
816 :type gnus-article-treat-custom
)
818 (defcustom gnus-treat-strip-banner t
819 "Strip banners from articles.
820 The banner to be stripped is specified in the `banner' group parameter.
821 Valid values are nil, t, `head', `last', an integer or a predicate.
822 See the manual for details."
823 :group
'gnus-article-treat
824 :type gnus-article-treat-custom
)
826 (defcustom gnus-treat-highlight-headers
'head
827 "Highlight the headers.
828 Valid values are nil, t, `head', `last', an integer or a predicate.
829 See the manual for details."
830 :group
'gnus-article-treat
831 :type gnus-article-treat-head-custom
)
832 (put 'gnus-treat-highlight-headers
'highlight t
)
834 (defcustom gnus-treat-highlight-citation t
835 "Highlight cited text.
836 Valid values are nil, t, `head', `last', an integer or a predicate.
837 See the manual for details."
838 :group
'gnus-article-treat
839 :type gnus-article-treat-custom
)
840 (put 'gnus-treat-highlight-citation
'highlight t
)
842 (defcustom gnus-treat-date-ut nil
843 "Display the Date in UT (GMT).
844 Valid values are nil, t, `head', `last', an integer or a predicate.
845 See the manual for details."
846 :group
'gnus-article-treat
847 :type gnus-article-treat-head-custom
)
849 (defcustom gnus-treat-date-local nil
850 "Display the Date in the local timezone.
851 Valid values are nil, t, `head', `last', an integer or a predicate.
852 See the manual for details."
853 :group
'gnus-article-treat
854 :type gnus-article-treat-head-custom
)
856 (defcustom gnus-treat-date-lapsed nil
857 "Display the Date header in a way that says how much time has elapsed.
858 Valid values are nil, t, `head', `last', an integer or a predicate.
859 See the manual for details."
860 :group
'gnus-article-treat
861 :type gnus-article-treat-head-custom
)
863 (defcustom gnus-treat-date-original nil
864 "Display the date in the original timezone.
865 Valid values are nil, t, `head', `last', an integer or a predicate.
866 See the manual for details."
867 :group
'gnus-article-treat
868 :type gnus-article-treat-head-custom
)
870 (defcustom gnus-treat-date-iso8601 nil
871 "Display the date in the ISO8601 format.
872 Valid values are nil, t, `head', `last', an integer or a predicate.
873 See the manual for details."
875 :group
'gnus-article-treat
876 :type gnus-article-treat-head-custom
)
878 (defcustom gnus-treat-date-user-defined nil
879 "Display the date in a user-defined format.
880 The format is defined by the `gnus-article-time-format' variable.
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-head-custom
)
886 (defcustom gnus-treat-strip-headers-in-body t
887 "Strip the X-No-Archive header line from the beginning of the body.
888 Valid values are nil, t, `head', `last', an integer or a predicate.
889 See the manual for details."
891 :group
'gnus-article-treat
892 :type gnus-article-treat-custom
)
894 (defcustom gnus-treat-strip-trailing-blank-lines nil
895 "Strip trailing blank lines.
896 Valid values are nil, t, `head', `last', an integer or a predicate.
897 See the manual for details."
898 :group
'gnus-article-treat
899 :type gnus-article-treat-custom
)
901 (defcustom gnus-treat-strip-leading-blank-lines nil
902 "Strip leading blank lines.
903 Valid values are nil, t, `head', `last', an integer or a predicate.
904 See the manual for details."
905 :group
'gnus-article-treat
906 :type gnus-article-treat-custom
)
908 (defcustom gnus-treat-strip-multiple-blank-lines nil
909 "Strip multiple blank lines.
910 Valid values are nil, t, `head', `last', an integer or a predicate.
911 See the manual for details."
912 :group
'gnus-article-treat
913 :type gnus-article-treat-custom
)
915 (defcustom gnus-treat-overstrike t
916 "Treat overstrike highlighting.
917 Valid values are nil, t, `head', `last', an integer or a predicate.
918 See the manual for details."
919 :group
'gnus-article-treat
920 :type gnus-article-treat-custom
)
921 (put 'gnus-treat-overstrike
'highlight t
)
923 (defcustom gnus-treat-display-xface
924 (and (or (and (fboundp 'image-type-available-p
)
925 (image-type-available-p 'xbm
)
926 (string-match "^0x" (shell-command-to-string "uncompface")))
927 (and (featurep 'xemacs
) (featurep 'xface
)))
929 "Display X-Face headers.
930 Valid values are nil, t, `head', `last', an integer or a predicate.
931 See the manual for details."
932 :group
'gnus-article-treat
934 :type gnus-article-treat-head-custom
)
935 (put 'gnus-treat-display-xface
'highlight t
)
937 (defcustom gnus-treat-display-smileys
938 (if (or (and (featurep 'xemacs
)
940 (and (fboundp 'image-type-available-p
)
941 (image-type-available-p 'pbm
)))
944 Valid values are nil, t, `head', `last', an integer or a predicate.
945 See the manual for details."
946 :group
'gnus-article-treat
948 :type gnus-article-treat-custom
)
949 (put 'gnus-treat-display-smileys
'highlight t
)
951 (defcustom gnus-treat-display-picons
(if (featurep 'xemacs
) 'head nil
)
953 Valid values are nil, t, `head', `last', an integer or a predicate.
954 See the manual for details."
955 :group
'gnus-article-treat
956 :type gnus-article-treat-head-custom
)
957 (put 'gnus-treat-display-picons
'highlight t
)
959 (defcustom gnus-treat-capitalize-sentences nil
960 "Capitalize sentence-starting words.
961 Valid values are nil, t, `head', `last', an integer or a predicate.
962 See the manual for details."
964 :group
'gnus-article-treat
965 :type gnus-article-treat-custom
)
967 (defcustom gnus-treat-fill-long-lines nil
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 (defcustom gnus-treat-play-sounds nil
976 Valid values are nil, t, `head', `last', an integer or a predicate.
977 See the manual for details."
979 :group
'gnus-article-treat
980 :type gnus-article-treat-custom
)
982 (defcustom gnus-treat-translate nil
983 "Translate articles from one language to another.
984 Valid values are nil, t, `head', `last', an integer or a predicate.
985 See the manual for details."
987 :group
'gnus-article-treat
988 :type gnus-article-treat-custom
)
990 ;;; Internal variables
992 (defvar article-goto-body-goes-to-point-min-p nil
)
993 (defvar gnus-article-wash-types nil
)
994 (defvar gnus-article-emphasis-alist nil
)
996 (defvar gnus-article-mime-handle-alist-1 nil
)
997 (defvar gnus-treatment-function-alist
998 '((gnus-treat-strip-banner gnus-article-strip-banner
)
999 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body
)
1000 (gnus-treat-highlight-signature gnus-article-highlight-signature
)
1001 (gnus-treat-buttonize gnus-article-add-buttons
)
1002 (gnus-treat-fill-article gnus-article-fill-cited-article
)
1003 (gnus-treat-fill-long-lines gnus-article-fill-long-lines
)
1004 (gnus-treat-strip-cr gnus-article-remove-cr
)
1005 (gnus-treat-emphasize gnus-article-emphasize
)
1006 (gnus-treat-display-xface gnus-article-display-x-face
)
1007 (gnus-treat-hide-headers gnus-article-maybe-hide-headers
)
1008 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers
)
1009 (gnus-treat-hide-signature gnus-article-hide-signature
)
1010 (gnus-treat-hide-citation gnus-article-hide-citation
)
1011 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe
)
1012 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers
)
1013 (gnus-treat-strip-pgp gnus-article-hide-pgp
)
1014 (gnus-treat-strip-pem gnus-article-hide-pem
)
1015 (gnus-treat-highlight-headers gnus-article-highlight-headers
)
1016 (gnus-treat-highlight-citation gnus-article-highlight-citation
)
1017 (gnus-treat-highlight-signature gnus-article-highlight-signature
)
1018 (gnus-treat-date-ut gnus-article-date-ut
)
1019 (gnus-treat-date-local gnus-article-date-local
)
1020 (gnus-treat-date-lapsed gnus-article-date-lapsed
)
1021 (gnus-treat-date-original gnus-article-date-original
)
1022 (gnus-treat-date-user-defined gnus-article-date-user
)
1023 (gnus-treat-date-iso8601 gnus-article-date-iso8601
)
1024 (gnus-treat-strip-trailing-blank-lines
1025 gnus-article-remove-trailing-blank-lines
)
1026 (gnus-treat-strip-leading-blank-lines
1027 gnus-article-strip-leading-blank-lines
)
1028 (gnus-treat-strip-multiple-blank-lines
1029 gnus-article-strip-multiple-blank-lines
)
1030 (gnus-treat-overstrike gnus-article-treat-overstrike
)
1031 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head
)
1032 (gnus-treat-display-smileys gnus-smiley-display
)
1033 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences
)
1034 (gnus-treat-display-picons gnus-article-display-picons
)
1035 (gnus-treat-play-sounds gnus-earcon-display
)))
1037 (defvar gnus-article-mime-handle-alist nil
)
1038 (defvar article-lapsed-timer nil
)
1039 (defvar gnus-article-current-summary nil
)
1041 (defvar gnus-article-mode-syntax-table
1042 (let ((table (copy-syntax-table text-mode-syntax-table
)))
1043 (modify-syntax-entry ?-
"w" table
)
1044 (modify-syntax-entry ?
> ")" table
)
1045 (modify-syntax-entry ?
< "(" table
)
1047 "Syntax table used in article mode buffers.
1048 Initialized from `text-mode-syntax-table.")
1050 (defvar gnus-save-article-buffer nil
)
1052 (defvar gnus-article-mode-line-format-alist
1053 (nconc '((?w
(gnus-article-wash-status) ?s
)
1054 (?m
(gnus-article-mime-part-status) ?s
))
1055 gnus-summary-mode-line-format-alist
))
1057 (defvar gnus-number-of-articles-to-be-saved nil
)
1059 (defvar gnus-inhibit-hiding nil
)
1061 (defsubst gnus-article-hide-text
(b e props
)
1062 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1063 (gnus-add-text-properties-when 'article-type nil b e props
)
1064 (when (memq 'intangible props
)
1066 (max (1- b
) (point-min))
1067 b
'intangible
(cddr (memq 'intangible props
)))))
1069 (defsubst gnus-article-unhide-text
(b e
)
1070 "Remove hidden text properties from region between B and E."
1071 (remove-text-properties b e gnus-hidden-properties
)
1072 (when (memq 'intangible gnus-hidden-properties
)
1073 (put-text-property (max (1- b
) (point-min))
1074 b
'intangible nil
)))
1076 (defun gnus-article-hide-text-type (b e type
)
1077 "Hide text of TYPE between B and E."
1078 (push type gnus-article-wash-types
)
1079 (gnus-article-hide-text
1080 b e
(cons 'article-type
(cons type gnus-hidden-properties
))))
1082 (defun gnus-article-unhide-text-type (b e type
)
1083 "Unhide text of TYPE between B and E."
1084 (setq gnus-article-wash-types
1085 (delq type gnus-article-wash-types
))
1086 (remove-text-properties
1087 b e
(cons 'article-type
(cons type gnus-hidden-properties
)))
1088 (when (memq 'intangible gnus-hidden-properties
)
1089 (put-text-property (max (1- b
) (point-min))
1090 b
'intangible nil
)))
1092 (defun gnus-article-hide-text-of-type (type)
1093 "Hide text of TYPE in the current buffer."
1095 (let ((b (point-min))
1097 (while (setq b
(text-property-any b e
'article-type type
))
1098 (add-text-properties b
(incf b
) gnus-hidden-properties
)))))
1100 (defun gnus-article-delete-text-of-type (type)
1101 "Delete text of TYPE in the current buffer."
1103 (let ((b (point-min)))
1104 (while (setq b
(text-property-any b
(point-max) 'article-type type
))
1106 b
(or (text-property-not-all b
(point-max) 'article-type type
)
1109 (defun gnus-article-delete-invisible-text ()
1110 "Delete all invisible text in the current buffer."
1112 (let ((b (point-min)))
1113 (while (setq b
(text-property-any b
(point-max) 'invisible t
))
1115 b
(or (text-property-not-all b
(point-max) 'invisible t
)
1118 (defun gnus-article-text-type-exists-p (type)
1119 "Say whether any text of type TYPE exists in the buffer."
1120 (text-property-any (point-min) (point-max) 'article-type type
))
1122 (defsubst gnus-article-header-rank
()
1123 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1124 (let ((list gnus-sorted-header-list
)
1127 (when (looking-at (car list
))
1129 (setq list
(cdr list
))
1133 (defun article-hide-headers (&optional arg delete
)
1134 "Hide unwanted headers and possibly sort them as well."
1136 ;; This function might be inhibited.
1137 (unless gnus-inhibit-hiding
1140 (let ((buffer-read-only nil
)
1141 (case-fold-search t
)
1142 (max (1+ (length gnus-sorted-header-list
)))
1143 (ignored (when (not gnus-visible-headers
)
1144 (cond ((stringp gnus-ignored-headers
)
1145 gnus-ignored-headers
)
1146 ((listp gnus-ignored-headers
)
1147 (mapconcat 'identity gnus-ignored-headers
1150 (cond ((stringp gnus-visible-headers
)
1151 gnus-visible-headers
)
1152 ((and gnus-visible-headers
1153 (listp gnus-visible-headers
))
1154 (mapconcat 'identity gnus-visible-headers
"\\|"))))
1155 (inhibit-point-motion-hooks t
)
1157 ;; First we narrow to just the headers.
1158 (article-narrow-to-head)
1159 ;; Hide any "From " lines at the beginning of (mail) articles.
1160 (while (looking-at "From ")
1163 (delete-region (point-min) (point)))
1164 ;; Then treat the rest of the header lines.
1165 ;; Then we use the two regular expressions
1166 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1167 ;; select which header lines is to remain visible in the
1169 (while (re-search-forward "^[^ \t]*:" nil t
)
1171 ;; Mark the rank of the header.
1173 (point) (1+ (point)) 'message-rank
1174 (if (or (and visible
(looking-at visible
))
1176 (not (looking-at ignored
))))
1177 (gnus-article-header-rank)
1180 (message-sort-headers-1)
1181 (when (setq beg
(text-property-any
1182 (point-min) (point-max) 'message-rank
(+ 2 max
)))
1183 ;; We delete the unwanted headers.
1184 (push 'headers gnus-article-wash-types
)
1185 (add-text-properties (point-min) (+ 5 (point-min))
1186 '(article-type headers dummy-invisible t
))
1187 (delete-region beg
(point-max))))))))
1189 (defun article-hide-boring-headers (&optional arg
)
1190 "Toggle hiding of headers that aren't very interesting.
1191 If given a negative prefix, always show; if given a positive prefix,
1193 (interactive (gnus-article-hidden-arg))
1194 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg
))
1195 (not gnus-show-all-headers
))
1198 (let ((buffer-read-only nil
)
1199 (list gnus-boring-article-headers
)
1200 (inhibit-point-motion-hooks t
)
1202 (article-narrow-to-head)
1204 (setq elem
(pop list
))
1205 (goto-char (point-min))
1207 ;; Hide empty headers.
1209 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t
)
1211 (gnus-article-hide-text-type
1212 (progn (beginning-of-line) (point))
1215 (if (re-search-forward "^[^ \t]" nil t
)
1219 ;; Hide boring Newsgroups header.
1220 ((eq elem
'newsgroups
)
1221 (when (equal (gnus-fetch-field "newsgroups")
1222 (gnus-group-real-name
1223 (if (boundp 'gnus-newsgroup-name
)
1226 (gnus-article-hide-header "newsgroups")))
1227 ((eq elem
'followup-to
)
1228 (when (equal (message-fetch-field "followup-to")
1229 (message-fetch-field "newsgroups"))
1230 (gnus-article-hide-header "followup-to")))
1231 ((eq elem
'reply-to
)
1232 (let ((from (message-fetch-field "from"))
1233 (reply-to (message-fetch-field "reply-to")))
1238 (nth 1 (mail-extract-address-components from
))
1239 (nth 1 (mail-extract-address-components reply-to
)))))
1240 (gnus-article-hide-header "reply-to"))))
1242 (let ((date (message-fetch-field "date")))
1244 (< (days-between (current-time-string) date
)
1246 (gnus-article-hide-header "date"))))
1248 (let ((to (message-fetch-field "to"))
1249 (cc (message-fetch-field "cc")))
1250 (when (> (length to
) 1024)
1251 (gnus-article-hide-header "to"))
1252 (when (> (length cc
) 1024)
1253 (gnus-article-hide-header "cc"))))
1257 (goto-char (point-min))
1258 (while (re-search-forward "^to:" nil t
)
1259 (setq to-count
(1+ to-count
)))
1260 (when (> to-count
1)
1261 (while (> to-count
0)
1262 (goto-char (point-min))
1264 (re-search-forward "^to:" nil nil to-count
)
1266 (narrow-to-region (point) (point-max))
1267 (gnus-article-hide-header "to"))
1268 (setq to-count
(1- to-count
))))
1269 (goto-char (point-min))
1270 (while (re-search-forward "^cc:" nil t
)
1271 (setq cc-count
(1+ cc-count
)))
1272 (when (> cc-count
1)
1273 (while (> cc-count
0)
1274 (goto-char (point-min))
1276 (re-search-forward "^cc:" nil nil cc-count
)
1278 (narrow-to-region (point) (point-max))
1279 (gnus-article-hide-header "cc"))
1280 (setq cc-count
(1- cc-count
)))))))))))))
1282 (defun gnus-article-hide-header (header)
1284 (goto-char (point-min))
1285 (when (re-search-forward (concat "^" header
":") nil t
)
1286 (gnus-article-hide-text-type
1287 (progn (beginning-of-line) (point))
1290 (if (re-search-forward "^[^ \t]" nil t
)
1295 (defvar gnus-article-normalized-header-length
40
1296 "Length of normalized headers.")
1298 (defun article-normalize-headers ()
1299 "Make all header lines 40 characters long."
1301 (let ((buffer-read-only nil
)
1305 (article-narrow-to-head)
1308 ((< (setq column
(- (gnus-point-at-eol) (point)))
1309 gnus-article-normalized-header-length
)
1311 (insert (make-string
1312 (- gnus-article-normalized-header-length column
)
1314 ((> column gnus-article-normalized-header-length
)
1315 (gnus-put-text-property
1317 (forward-char gnus-article-normalized-header-length
)
1324 (forward-line 1))))))
1326 (defun article-treat-dumbquotes ()
1327 "Translate M****s*** sm*rtq**t*s into proper text.
1328 Note that this function guesses whether a character is a sm*rtq**t* or
1329 not, so it should only be used interactively.
1331 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1332 in an attempt to provide more quoting characters. If you see
1333 something like \\222 or \\264 where you're expecting some kind of
1334 apostrophe or quotation mark, then try this wash."
1336 (article-translate-strings gnus-article-dumbquotes-map
))
1338 (defun article-translate-characters (from to
)
1339 "Translate all characters in the body of the article according to FROM and TO.
1340 FROM is a string of characters to translate from; to is a string of
1341 characters to translate to."
1343 (when (article-goto-body)
1344 (let ((buffer-read-only nil
)
1345 (x (make-string 225 ?x
))
1347 (while (< (incf i
) (length x
))
1350 (while (< i
(length from
))
1351 (aset x
(aref from i
) (aref to i
))
1353 (translate-region (point) (point-max) x
)))))
1355 (defun article-translate-strings (map)
1356 "Translate all string in the body of the article according to MAP.
1357 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1359 (when (article-goto-body)
1360 (let ((buffer-read-only nil
)
1362 (while (setq elem
(pop map
))
1364 (while (search-forward (car elem
) nil t
)
1365 (replace-match (cadr elem
)))))))))
1367 (defun article-treat-overstrike ()
1368 "Translate overstrikes into bold text."
1371 (when (article-goto-body)
1372 (let ((buffer-read-only nil
))
1373 (while (search-forward "\b" nil t
)
1374 (let ((next (char-after))
1375 (previous (char-after (- (point) 2))))
1376 ;; We do the boldification/underlining by hiding the
1377 ;; overstrikes and putting the proper text property
1381 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike
)
1382 (put-text-property (point) (1+ (point)) 'face
'bold
))
1384 (gnus-article-hide-text-type
1385 (1- (point)) (1+ (point)) 'overstrike
)
1387 (- (point) 2) (1- (point)) 'face
'underline
))
1389 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike
)
1391 (point) (1+ (point)) 'face
'underline
)))))))))
1393 (defun article-fill-long-lines ()
1394 "Fill lines that are wider than the window width."
1397 (let ((buffer-read-only nil
)
1398 (width (window-width (get-buffer-window (current-buffer)))))
1401 (let ((adaptive-fill-mode nil
))
1404 (when (>= (current-column) (min fill-column width
))
1405 (narrow-to-region (point) (gnus-point-at-bol))
1406 (fill-paragraph nil
)
1407 (goto-char (point-max))
1409 (forward-line 1)))))))
1411 (defun article-capitalize-sentences ()
1412 "Capitalize the first word in each sentence."
1415 (let ((buffer-read-only nil
)
1416 (paragraph-start "^[\n\^L]"))
1420 (forward-sentence)))))
1422 (defun article-remove-cr ()
1423 "Remove trailing CRs and then translate remaining CRs into LFs."
1426 (let ((buffer-read-only nil
))
1427 (goto-char (point-min))
1428 (while (re-search-forward "\r+$" nil t
)
1429 (replace-match "" t t
))
1430 (goto-char (point-min))
1431 (while (search-forward "\r" nil t
)
1432 (replace-match "\n" t t
)))))
1434 (defun article-remove-trailing-blank-lines ()
1435 "Remove all trailing blank lines from the article."
1438 (let ((buffer-read-only nil
))
1439 (goto-char (point-max))
1443 (while (and (not (bobp))
1444 (looking-at "^[ \t]*$")
1445 (not (gnus-annotation-in-region-p
1446 (point) (gnus-point-at-eol))))
1451 (defun article-display-x-face (&optional force
)
1452 "Look for an X-Face header and display it if present."
1453 (interactive (list 'force
))
1455 ;; Delete the old process, if any.
1456 (when (process-status "article-x-face")
1457 (delete-process "article-x-face"))
1458 (let ((inhibit-point-motion-hooks t
)
1459 (case-fold-search t
)
1462 (article-narrow-to-head)
1463 (goto-char (point-min))
1464 (setq from
(message-fetch-field "from"))
1465 (goto-char (point-min))
1466 (while (and gnus-article-x-face-command
1469 ;; Check whether this face is censored.
1470 (not gnus-article-x-face-too-ugly
)
1471 (and gnus-article-x-face-too-ugly from
1472 (not (string-match gnus-article-x-face-too-ugly
1474 ;; Has to be present.
1475 (re-search-forward "^X-Face: " nil t
))
1476 ;; This used to try to do multiple faces (`while' instead of
1477 ;; `when' above), but (a) sending multiple EOFs to xv doesn't
1478 ;; work (b) it can crash some versions of Emacs (c) are
1479 ;; multiple faces really something to encourage?
1480 (when (stringp gnus-article-x-face-command
)
1482 ;; We now have the area of the buffer where the X-Face is stored.
1485 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t
))))
1486 ;; We display the face.
1487 (if (symbolp gnus-article-x-face-command
)
1488 ;; The command is a lisp function, so we call it.
1489 (if (gnus-functionp gnus-article-x-face-command
)
1490 (funcall gnus-article-x-face-command beg end
)
1491 (error "%s is not a function" gnus-article-x-face-command
))
1492 ;; The command is a string, so we interpret the command
1493 ;; as a, well, command, and fork it off.
1494 (let ((process-connection-type nil
))
1495 (process-kill-without-query
1497 "article-x-face" nil shell-file-name shell-command-switch
1498 gnus-article-x-face-command
))
1499 (process-send-region "article-x-face" beg end
)
1500 (process-send-eof "article-x-face"))))))))))
1502 (defun article-decode-mime-words ()
1503 "Decode all MIME-encoded words in the article."
1506 (set-buffer gnus-article-buffer
)
1507 (let ((inhibit-point-motion-hooks t
)
1509 (mail-parse-charset gnus-newsgroup-charset
)
1510 (mail-parse-ignored-charsets
1511 (save-excursion (set-buffer gnus-summary-buffer
)
1512 gnus-newsgroup-ignored-charsets
)))
1513 (mail-decode-encoded-word-region (point-min) (point-max)))))
1515 (defun article-decode-charset (&optional prompt
)
1516 "Decode charset-encoded text in the article.
1517 If PROMPT (the prefix), prompt for a coding system to use."
1519 (let ((inhibit-point-motion-hooks t
) (case-fold-search t
)
1521 (mail-parse-charset gnus-newsgroup-charset
)
1522 (mail-parse-ignored-charsets
1523 (save-excursion (condition-case nil
1524 (set-buffer gnus-summary-buffer
)
1526 gnus-newsgroup-ignored-charsets
))
1527 ct cte ctl charset format
)
1530 (article-narrow-to-head)
1531 (setq ct
(message-fetch-field "Content-Type" t
)
1532 cte
(message-fetch-field "Content-Transfer-Encoding" t
)
1533 ctl
(and ct
(ignore-errors
1534 (mail-header-parse-content-type ct
)))
1537 (mm-read-coding-system "Charset to decode: "))
1539 (mail-content-type-get ctl
'charset
)))
1540 format
(and ctl
(mail-content-type-get ctl
'format
)))
1542 (setq cte
(mail-header-strip cte
)))
1543 (if (and ctl
(not (string-match "/" (car ctl
))))
1545 (goto-char (point-max)))
1548 (narrow-to-region (point) (point-max))
1549 (when (and (eq mail-parse-charset
'gnus-decoded
)
1550 (eq (mm-body-7-or-8) '8bit
))
1551 ;; The text code could have been decoded.
1552 (setq charset mail-parse-charset
))
1553 (when (and (or (not ctl
)
1554 (equal (car ctl
) "text/plain"))
1555 (not format
)) ;; article with format will decode later.
1557 charset
(and cte
(intern (downcase
1558 (gnus-strip-whitespace cte
))))
1561 (defun article-decode-encoded-words ()
1562 "Remove encoded-word encoding from headers."
1563 (let ((inhibit-point-motion-hooks t
)
1564 (mail-parse-charset gnus-newsgroup-charset
)
1565 (mail-parse-ignored-charsets
1566 (save-excursion (condition-case nil
1567 (set-buffer gnus-summary-buffer
)
1569 gnus-newsgroup-ignored-charsets
))
1572 (article-narrow-to-head)
1573 (funcall gnus-decode-header-function
(point-min) (point-max)))))
1575 (defun article-de-quoted-unreadable (&optional force
)
1576 "Translate a quoted-printable-encoded article.
1577 If FORCE, decode the article whether it is marked as quoted-printable
1579 (interactive (list 'force
))
1581 (let ((buffer-read-only nil
) type charset
)
1582 (if (gnus-buffer-live-p gnus-original-article-buffer
)
1583 (with-current-buffer gnus-original-article-buffer
1585 (gnus-fetch-field "content-transfer-encoding"))
1586 (let* ((ct (gnus-fetch-field "content-type"))
1589 (mail-header-parse-content-type ct
)))))
1590 (setq charset
(and ctl
1591 (mail-content-type-get ctl
'charset
)))
1592 (if (stringp charset
)
1593 (setq charset
(intern (downcase charset
)))))))
1595 (setq charset gnus-newsgroup-charset
))
1597 (and type
(let ((case-fold-search t
))
1598 (string-match "quoted-printable" type
))))
1600 (quoted-printable-decode-region
1601 (point) (point-max) (mm-charset-to-coding-system charset
))))))
1603 (defun article-de-base64-unreadable (&optional force
)
1604 "Translate a base64 article.
1605 If FORCE, decode the article whether it is marked as base64 not."
1606 (interactive (list 'force
))
1608 (let ((buffer-read-only nil
) type charset
)
1609 (if (gnus-buffer-live-p gnus-original-article-buffer
)
1610 (with-current-buffer gnus-original-article-buffer
1612 (gnus-fetch-field "content-transfer-encoding"))
1613 (let* ((ct (gnus-fetch-field "content-type"))
1616 (mail-header-parse-content-type ct
)))))
1617 (setq charset
(and ctl
1618 (mail-content-type-get ctl
'charset
)))
1619 (if (stringp charset
)
1620 (setq charset
(intern (downcase charset
)))))))
1622 (setq charset gnus-newsgroup-charset
))
1624 (and type
(let ((case-fold-search t
))
1625 (string-match "base64" type
))))
1628 (narrow-to-region (point) (point-max))
1629 (base64-decode-region (point-min) (point-max))
1630 (mm-decode-coding-region
1631 (point-min) (point-max) (mm-charset-to-coding-system charset
)))))))
1636 (defun article-decode-HZ ()
1637 "Translate a HZ-encoded article."
1641 (let ((buffer-read-only nil
))
1642 (rfc1843-decode-region (point-min) (point-max)))))
1644 (defun article-wash-html ()
1645 "Format an html article."
1648 (let ((buffer-read-only nil
)
1650 (if (gnus-buffer-live-p gnus-original-article-buffer
)
1651 (with-current-buffer gnus-original-article-buffer
1652 (let* ((ct (gnus-fetch-field "content-type"))
1655 (mail-header-parse-content-type ct
)))))
1656 (setq charset
(and ctl
1657 (mail-content-type-get ctl
'charset
)))
1658 (if (stringp charset
)
1659 (setq charset
(intern (downcase charset
)))))))
1661 (setq charset gnus-newsgroup-charset
))
1663 (save-window-excursion
1665 (narrow-to-region (point) (point-max))
1667 (let ((w3-strict-width (window-width))
1668 (url-standalone-mode t
))
1670 (w3-region (point-min) (point-max))
1673 (defun article-hide-list-identifiers ()
1674 "Remove list identifies from the Subject header.
1675 The `gnus-list-identifiers' variable specifies what to do."
1679 (let ((inhibit-point-motion-hooks t
)
1681 (article-narrow-to-head)
1682 (let ((regexp (if (stringp gnus-list-identifiers
) gnus-list-identifiers
1683 (mapconcat 'identity gnus-list-identifiers
" *\\|"))))
1685 (goto-char (point-min))
1686 (when (re-search-forward
1687 (concat "^Subject: +\\(\\(\\(Re: +\\)?\\(" regexp
1688 " *\\)\\)+\\(Re: +\\)?\\)")
1690 (let ((s (or (match-string 3) (match-string 5))))
1691 (delete-region (match-beginning 1) (match-end 1))
1693 (goto-char (match-beginning 1))
1696 (defun article-hide-pgp ()
1697 "Remove any PGP headers and signatures in the current article."
1701 (let ((inhibit-point-motion-hooks t
)
1702 buffer-read-only beg end
)
1704 ;; Hide the "header".
1705 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t
)
1706 (push 'pgp gnus-article-wash-types
)
1707 (delete-region (match-beginning 0) (match-end 0))
1708 ;; Remove armor headers (rfc2440 6.2)
1709 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t
)
1712 ;; Hide the actual signature.
1713 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t
)
1714 (setq end
(1+ (match-beginning 0)))
1717 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t
)
1719 ;; Perhaps we shouldn't hide to the end of the buffer
1720 ;; if there is no end to the signature?
1722 ;; Hide "- " PGP quotation markers.
1724 (narrow-to-region beg end
)
1725 (goto-char (point-min))
1726 (while (re-search-forward "^- " nil t
)
1728 (match-beginning 0) (match-end 0)))
1730 (gnus-run-hooks 'gnus-article-hide-pgp-hook
))))))
1732 (defun article-hide-pem (&optional arg
)
1733 "Toggle hiding of any PEM headers and signatures in the current article.
1734 If given a negative prefix, always show; if given a positive prefix,
1736 (interactive (gnus-article-hidden-arg))
1737 (unless (gnus-article-check-hidden-text 'pem arg
)
1739 (let (buffer-read-only end
)
1740 (goto-char (point-min))
1741 ;; Hide the horrendously ugly "header".
1742 (when (and (search-forward
1743 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
1745 (setq end
(1+ (match-beginning 0))))
1746 (push 'pem gnus-article-wash-types
)
1747 (gnus-article-hide-text-type
1749 (if (search-forward "\n\n" nil t
)
1753 ;; Hide the trailer as well
1754 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
1756 (gnus-article-hide-text-type
1757 (match-beginning 0) (match-end 0) 'pem
)))))))
1759 (defun article-strip-banner ()
1760 "Strip the banner specified by the `banner' group parameter."
1764 (let ((inhibit-point-motion-hooks t
)
1765 (banner (gnus-group-find-parameter gnus-newsgroup-name
'banner
))
1766 (gnus-signature-limit nil
)
1767 buffer-read-only beg end
)
1771 ((eq banner
'signature
)
1772 (when (gnus-article-narrow-to-signature)
1775 (delete-region (point) (point-max))))
1777 (if (setq banner
(cdr (assq banner gnus-article-banner-alist
)))
1778 (while (re-search-forward banner nil t
)
1779 (delete-region (match-beginning 0) (match-end 0)))))
1781 (while (re-search-forward banner nil t
)
1782 (delete-region (match-beginning 0) (match-end 0))))))))))
1784 (defun article-babel ()
1785 "Translate article using an online translation service."
1789 (set-buffer gnus-article-buffer
)
1790 (when (article-goto-body)
1791 (let* ((buffer-read-only nil
)
1794 (orig (buffer-substring start end
))
1795 (trans (babel-as-string orig
)))
1797 (narrow-to-region start end
)
1798 (delete-region start end
)
1801 (defun article-hide-signature (&optional arg
)
1802 "Hide the signature in the current article.
1803 If given a negative prefix, always show; if given a positive prefix,
1805 (interactive (gnus-article-hidden-arg))
1806 (unless (gnus-article-check-hidden-text 'signature arg
)
1809 (let ((buffer-read-only nil
))
1810 (when (gnus-article-narrow-to-signature)
1811 (gnus-article-hide-text-type
1812 (point-min) (point-max) 'signature
)))))))
1814 (defun article-strip-headers-in-body ()
1815 "Strip offensive headers from bodies."
1819 (let ((case-fold-search t
))
1820 (when (looking-at "x-no-archive:")
1821 (gnus-delete-line)))))
1823 (defun article-strip-leading-blank-lines ()
1824 "Remove all blank lines from the beginning of the article."
1827 (let ((inhibit-point-motion-hooks t
)
1829 (when (article-goto-body)
1830 (while (and (not (eobp))
1831 (looking-at "[ \t]*$"))
1832 (gnus-delete-line))))))
1834 (defun article-narrow-to-head ()
1835 "Narrow the buffer to the head of the message.
1836 Point is left at the beginning of the narrowed-to region."
1838 (goto-char (point-min))
1839 (if (search-forward "\n\n" nil
1)
1842 (goto-char (point-min)))
1844 (defun article-goto-body ()
1845 "Place point at the start of the body."
1846 (goto-char (point-min))
1848 ;; This variable is only bound when dealing with separate
1850 (article-goto-body-goes-to-point-min-p
1852 ((search-forward "\n\n" nil t
)
1855 (goto-char (point-max))
1858 (defun article-strip-multiple-blank-lines ()
1859 "Replace consecutive blank lines with one empty line."
1862 (let ((inhibit-point-motion-hooks t
)
1864 ;; First make all blank lines empty.
1866 (while (re-search-forward "^[ \t]+$" nil t
)
1867 (unless (gnus-annotation-in-region-p
1868 (match-beginning 0) (match-end 0))
1869 (replace-match "" nil t
)))
1870 ;; Then replace multiple empty lines with a single empty line.
1872 (while (re-search-forward "\n\n\n+" nil t
)
1873 (unless (gnus-annotation-in-region-p
1874 (match-beginning 0) (match-end 0))
1875 (replace-match "\n\n" t t
))))))
1877 (defun article-strip-leading-space ()
1878 "Remove all white space from the beginning of the lines in the article."
1881 (let ((inhibit-point-motion-hooks t
)
1884 (while (re-search-forward "^[ \t]+" nil t
)
1885 (replace-match "" t t
)))))
1887 (defun article-strip-trailing-space ()
1888 "Remove all white space from the end of the lines in the article."
1891 (let ((inhibit-point-motion-hooks t
)
1894 (while (re-search-forward "[ \t]+$" nil t
)
1895 (replace-match "" t t
)))))
1897 (defun article-strip-blank-lines ()
1898 "Strip leading, trailing and multiple blank lines."
1900 (article-strip-leading-blank-lines)
1901 (article-remove-trailing-blank-lines)
1902 (article-strip-multiple-blank-lines))
1904 (defun article-strip-all-blank-lines ()
1905 "Strip all blank lines."
1908 (let ((inhibit-point-motion-hooks t
)
1911 (while (re-search-forward "^[ \t]*\n" nil t
)
1912 (replace-match "" t t
)))))
1914 (defun gnus-article-narrow-to-signature ()
1915 "Narrow to the signature; return t if a signature is found, else nil."
1916 (let ((inhibit-point-motion-hooks t
))
1917 (when (gnus-article-search-signature)
1919 ;; Check whether we have some limits to what we consider
1920 ;; to be a signature.
1921 (let ((limits (if (listp gnus-signature-limit
) gnus-signature-limit
1922 (list gnus-signature-limit
)))
1924 (while (setq limit
(pop limits
))
1925 (if (or (and (integerp limit
)
1926 (< (- (point-max) (point)) limit
))
1928 (< (count-lines (point) (point-max)) limit
))
1929 (and (gnus-functionp limit
)
1931 (and (stringp limit
)
1932 (not (re-search-forward limit nil t
))))
1933 () ; This limit did not succeed.
1937 (narrow-to-region (point) (point-max))
1940 (defun gnus-article-search-signature ()
1941 "Search the current buffer for the signature separator.
1942 Put point at the beginning of the signature separator."
1943 (let ((cur (point)))
1944 (goto-char (point-max))
1945 (if (if (stringp gnus-signature-separator
)
1946 (re-search-backward gnus-signature-separator nil t
)
1947 (let ((seps gnus-signature-separator
))
1949 (not (re-search-backward (car seps
) nil t
)))
1956 (defun gnus-article-hidden-arg ()
1957 "Return the current prefix arg as a number, or 0 if no prefix."
1958 (list (if current-prefix-arg
1959 (prefix-numeric-value current-prefix-arg
)
1962 (defun gnus-article-check-hidden-text (type arg
)
1963 "Return nil if hiding is necessary.
1964 Arg can be nil or a number. Nil and positive means hide, negative
1965 means show, 0 means toggle."
1968 (let ((hide (gnus-article-hidden-text-p type
)))
1974 (gnus-article-show-hidden-text type
)
1977 (if (eq hide
'hidden
)
1979 (gnus-article-show-hidden-text type
)
1983 (defun gnus-article-hidden-text-p (type)
1984 "Say whether the current buffer contains hidden text of type TYPE."
1985 (let ((pos (text-property-any (point-min) (point-max) 'article-type type
)))
1987 (not (get-text-property pos
'invisible
))
1988 (not (get-text-property pos
'dummy-invisible
)))
1990 (text-property-any (1+ pos
) (point-max) 'article-type type
)))
1995 (defun gnus-article-show-hidden-text (type &optional dummy
)
1996 "Show all hidden text of type TYPE.
1997 Originally it is hide instead of DUMMY."
1998 (let ((buffer-read-only nil
)
1999 (inhibit-point-motion-hooks t
))
2000 (gnus-remove-text-properties-when
2002 (point-min) (point-max)
2003 (cons 'article-type
(cons type
2004 gnus-hidden-properties
)))))
2006 (defconst article-time-units
2007 `((year .
,(* 365.25 24 60 60))
2008 (week .
,(* 7 24 60 60))
2009 (day .
,(* 24 60 60))
2013 "Mapping from time units to seconds.")
2015 (defun article-date-ut (&optional type highlight header
)
2016 "Convert DATE date to universal time in the current article.
2017 If TYPE is `local', convert to local time; if it is `lapsed', output
2018 how much time has lapsed since DATE. For `lapsed', the value of
2019 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2020 should replace the \"Date:\" one, or should be added below it."
2021 (interactive (list 'ut t
))
2022 (let* ((header (or header
2023 (message-fetch-field "date")
2025 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2028 ((not gnus-article-date-lapsed-new-header
)
2034 (date (if (vectorp header
) (mail-header-date header
)
2036 (inhibit-point-motion-hooks t
)
2041 (article-narrow-to-head)
2042 (when (re-search-forward tdate-regexp nil t
)
2043 (setq bface
(get-text-property (gnus-point-at-bol) 'face
)
2044 date
(or (get-text-property (gnus-point-at-bol)
2047 eface
(get-text-property (1- (gnus-point-at-eol)) 'face
))
2049 (when (and date
(not (string= date
"")))
2050 (goto-char (point-min))
2051 (let ((buffer-read-only nil
))
2052 ;; Delete any old Date headers.
2053 (while (re-search-forward date-regexp nil t
)
2055 (delete-region (progn (beginning-of-line) (point))
2056 (progn (forward-line 1) (point)))
2057 (delete-region (progn (beginning-of-line) (point))
2058 (progn (end-of-line) (point)))
2059 (setq pos
(point))))
2060 (when (and (not pos
) (re-search-forward tdate-regexp nil t
))
2062 (if pos
(goto-char pos
))
2063 (insert (article-make-date-line date
(or type
'ut
)))
2069 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2070 (put-text-property (match-beginning 1) (1+ (match-end 1))
2071 'original-date date
)
2072 (put-text-property (match-beginning 1) (1+ (match-end 1))
2074 (put-text-property (match-beginning 2) (match-end 2)
2077 (defun article-make-date-line (date type
)
2078 "Return a DATE line of TYPE."
2079 (let ((time (condition-case ()
2083 ;; Convert to the local timezone. We have to slap a
2084 ;; `condition-case' round the calls to the timezone
2085 ;; functions since they aren't particularly resistant to
2088 (let ((tz (car (current-time-zone time
))))
2089 (format "Date: %s %s%02d%02d" (current-time-string time
)
2090 (if (> tz
0) "+" "-") (/ (abs tz
) 3600)
2091 (/ (%
(abs tz
) 3600) 60))))
2092 ;; Convert to Universal Time.
2095 (current-time-string
2096 (let* ((e (parse-time-string date
))
2097 (tm (apply 'encode-time e
))
2099 (ls (- (cadr tm
) (car (current-time-zone time
)))))
2100 (cond ((< ls
0) (list (1- ms
) (+ ls
65536)))
2101 ((> ls
65535) (list (1+ ms
) (- ls
65536)))
2104 ;; Get the original date from the article.
2105 ((eq type
'original
)
2106 (concat "Date: " (if (string-match "\n+$" date
)
2107 (substring date
0 (match-beginning 0))
2109 ;; Let the user define the format.
2111 (if (gnus-functionp gnus-article-time-format
)
2112 (funcall gnus-article-time-format time
)
2115 (format-time-string gnus-article-time-format time
))))
2118 (let ((tz (car (current-time-zone time
))))
2121 (format-time-string "%Y%m%dT%H%M%S" time
)
2122 (format "%s%02d%02d"
2123 (if (> tz
0) "+" "-") (/ (abs tz
) 3600)
2124 (/ (%
(abs tz
) 3600) 60)))))
2125 ;; Do an X-Sent lapsed format.
2127 ;; If the date is seriously mangled, the timezone functions are
2128 ;; liable to bug out, so we ignore all errors.
2129 (let* ((now (current-time))
2130 (real-time (subtract-time now time
))
2131 (real-sec (and real-time
2132 (+ (* (float (car real-time
)) 65536)
2134 (sec (and real-time
(abs real-sec
)))
2144 ;; This is a bit convoluted, but basically we go
2145 ;; through the time units for years, weeks, etc,
2146 ;; and divide things to see whether that results
2147 ;; in positive answers.
2150 (if (zerop (setq num
(ffloor (/ sec
(cdr unit
)))))
2151 ;; The (remaining) seconds are too few to
2152 ;; be divided into this time unit.
2154 ;; It's big enough, so we output it.
2155 (setq sec
(- sec
(* num
(cdr unit
))))
2157 (concat (if prev
", " "") (int-to-string
2159 " " (symbol-name (car unit
))
2160 (if (> num
1) "s" ""))
2162 article-time-units
"")
2163 ;; If dates are odd, then it might appear like the
2164 ;; article was sent in the future.
2167 " in the future"))))))
2169 (error "Unknown conversion type: %s" type
)))))
2171 (defun article-date-local (&optional highlight
)
2172 "Convert the current article date to the local timezone."
2173 (interactive (list t
))
2174 (article-date-ut 'local highlight
))
2176 (defun article-date-original (&optional highlight
)
2177 "Convert the current article date to what it was originally.
2178 This is only useful if you have used some other date conversion
2179 function and want to see what the date was before converting."
2180 (interactive (list t
))
2181 (article-date-ut 'original highlight
))
2183 (defun article-date-lapsed (&optional highlight
)
2184 "Convert the current article date to time lapsed since it was sent."
2185 (interactive (list t
))
2186 (article-date-ut 'lapsed highlight
))
2188 (defun article-update-date-lapsed ()
2189 "Function to be run from a timer to update the lapsed time line."
2190 (let (deactivate-mark)
2195 (set-buffer (window-buffer w
))
2196 (when (eq major-mode
'gnus-article-mode
)
2197 (goto-char (point-min))
2198 (when (re-search-forward "^X-Sent:" nil t
)
2199 (article-date-lapsed t
))))
2202 (defun gnus-start-date-timer (&optional n
)
2203 "Start a timer to update the X-Sent header in the article buffers.
2204 The numerical prefix says how frequently (in seconds) the function
2209 (gnus-stop-date-timer)
2210 (setq article-lapsed-timer
2211 (nnheader-run-at-time 1 n
'article-update-date-lapsed
)))
2213 (defun gnus-stop-date-timer ()
2214 "Stop the X-Sent timer."
2216 (when article-lapsed-timer
2217 (nnheader-cancel-timer article-lapsed-timer
)
2218 (setq article-lapsed-timer nil
)))
2220 (defun article-date-user (&optional highlight
)
2221 "Convert the current article date to the user-defined format.
2222 This format is defined by the `gnus-article-time-format' variable."
2223 (interactive (list t
))
2224 (article-date-ut 'user highlight
))
2226 (defun article-date-iso8601 (&optional highlight
)
2227 "Convert the current article date to ISO8601."
2228 (interactive (list t
))
2229 (article-date-ut 'iso8601 highlight
))
2231 (defun article-show-all ()
2232 "Show all hidden text in the article buffer."
2235 (let ((buffer-read-only nil
))
2236 (gnus-article-unhide-text (point-min) (point-max)))))
2238 (defun article-emphasize (&optional arg
)
2239 "Emphasize text according to `gnus-emphasis-alist'."
2240 (interactive (gnus-article-hidden-arg))
2241 (unless (gnus-article-check-hidden-text 'emphasis arg
)
2245 (with-current-buffer gnus-summary-buffer
2246 gnus-article-emphasis-alist
)
2248 gnus-emphasis-alist
))
2249 (buffer-read-only nil
)
2250 (props (append '(article-type emphasis
)
2251 gnus-hidden-properties
))
2252 regexp elem beg invisible visible face
)
2255 (while (setq elem
(pop alist
))
2257 (setq regexp
(car elem
)
2258 invisible
(nth 1 elem
)
2259 visible
(nth 2 elem
)
2261 (while (re-search-forward regexp nil t
)
2262 (when (and (match-beginning visible
) (match-beginning invisible
))
2263 (push 'emphasis gnus-article-wash-types
)
2264 (gnus-article-hide-text
2265 (match-beginning invisible
) (match-end invisible
) props
)
2266 (gnus-article-unhide-text-type
2267 (match-beginning visible
) (match-end visible
) 'emphasis
)
2268 (gnus-put-text-property-excluding-newlines
2269 (match-beginning visible
) (match-end visible
) 'face face
)
2270 (goto-char (match-end invisible
)))))))))
2272 (defun gnus-article-setup-highlight-words (&optional highlight-words
)
2273 "Setup newsgroup emphasis alist."
2274 (unless gnus-article-emphasis-alist
2275 (let ((name (and gnus-newsgroup-name
2276 (gnus-group-real-name gnus-newsgroup-name
))))
2277 (make-local-variable 'gnus-article-emphasis-alist
)
2278 (setq gnus-article-emphasis-alist
2280 (let ((alist gnus-group-highlight-words-alist
) elem highlight
)
2281 (while (setq elem
(pop alist
))
2282 (when (and name
(string-match (car elem
) name
))
2284 highlight
(copy-sequence (cdr elem
)))))
2286 (copy-sequence highlight-words
)
2287 (if gnus-newsgroup-name
2288 (copy-sequence (gnus-group-find-parameter
2289 gnus-newsgroup-name
'highlight-words t
)))
2290 gnus-emphasis-alist
)))))
2293 (defvar gnus-summary-article-menu
)
2294 (defvar gnus-summary-post-menu
))
2296 ;;; Saving functions.
2298 (defun gnus-article-save (save-buffer file
&optional num
)
2299 "Save the currently selected article."
2300 (unless gnus-save-all-headers
2301 ;; Remove headers according to `gnus-saved-headers'.
2302 (let ((gnus-visible-headers
2303 (or gnus-saved-headers gnus-visible-headers
))
2304 (gnus-article-buffer save-buffer
))
2306 (set-buffer save-buffer
)
2307 (article-hide-headers 1 t
))))
2308 (save-window-excursion
2309 (if (not gnus-default-article-saver
)
2310 (error "No default saver is defined")
2311 ;; !!! Magic! The saving functions all save
2312 ;; `gnus-save-article-buffer' (or so they think), but we
2313 ;; bind that variable to our save-buffer.
2314 (set-buffer gnus-article-buffer
)
2315 (let* ((gnus-save-article-buffer save-buffer
)
2318 ((not gnus-prompt-before-saving
) 'default
)
2319 ((eq gnus-prompt-before-saving
'always
) nil
)
2321 (gnus-number-of-articles-to-be-saved
2322 (when (eq gnus-prompt-before-saving t
)
2324 (set-buffer gnus-article-current-summary
)
2325 (funcall gnus-default-article-saver filename
)))))
2327 (defun gnus-read-save-file-name (prompt &optional filename
2328 function group headers variable
)
2330 (funcall function group headers
(symbol-value variable
)))
2335 ((eq filename
'default
)
2341 (let* ((split-name (gnus-get-split-value gnus-split-methods
))
2344 (if (and gnus-number-of-articles-to-be-saved
2345 (> gnus-number-of-articles-to-be-saved
1))
2346 (format "these %d articles"
2347 gnus-number-of-articles-to-be-saved
)
2350 ;; Let the split methods have their say.
2352 ;; No split name was found.
2355 (concat prompt
" (default "
2356 (file-name-nondirectory default-name
) ") ")
2357 (file-name-directory default-name
)
2359 ;; A single group name is returned.
2360 ((stringp split-name
)
2362 (funcall function split-name headers
2363 (symbol-value variable
)))
2365 (concat prompt
" (default "
2366 (file-name-nondirectory default-name
) ") ")
2367 (file-name-directory default-name
)
2369 ;; A single split name was found
2370 ((= 1 (length split-name
))
2371 (let* ((name (expand-file-name
2372 (car split-name
) gnus-article-save-directory
))
2373 (dir (cond ((file-directory-p name
)
2374 (file-name-as-directory name
))
2375 ((file-exists-p name
) name
)
2376 (t gnus-article-save-directory
))))
2378 (concat prompt
" (default " name
") ")
2380 ;; A list of splits was found.
2382 (setq split-name
(nreverse split-name
))
2384 (let ((file-name-history
2385 (nconc split-name file-name-history
)))
2389 (concat prompt
" (`M-p' for defaults) ")
2390 gnus-article-save-directory
2392 gnus-article-save-directory
)))
2393 (car (push result file-name-history
)))))))
2394 ;; Create the directory.
2395 (gnus-make-directory (file-name-directory file
))
2396 ;; If we have read a directory, we append the default file name.
2397 (when (file-directory-p file
)
2398 (setq file
(expand-file-name (file-name-nondirectory default-name
)
2399 (file-name-as-directory file
))))
2400 ;; Possibly translate some characters.
2401 (nnheader-translate-file-chars file
))))))
2402 (gnus-make-directory (file-name-directory result
))
2403 (set variable result
)))
2405 (defun gnus-article-archive-name (group)
2406 "Return the first instance of an \"Archive-name\" in the current buffer."
2407 (let ((case-fold-search t
))
2408 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t
)
2409 (nnheader-concat gnus-article-save-directory
2410 (match-string 1)))))
2412 (defun gnus-article-nndoc-name (group)
2413 "If GROUP is an nndoc group, return the name of the parent group."
2414 (when (eq (car (gnus-find-method-for-group group
)) 'nndoc
)
2415 (gnus-group-get-parameter group
'save-article-group
)))
2417 (defun gnus-summary-save-in-rmail (&optional filename
)
2418 "Append this article to Rmail file.
2419 Optional argument FILENAME specifies file name.
2420 Directory to save to is default to `gnus-article-save-directory'."
2421 (setq filename
(gnus-read-save-file-name
2422 "Save %s in rmail file:" filename
2423 gnus-rmail-save-name gnus-newsgroup-name
2424 gnus-current-headers
'gnus-newsgroup-last-rmail
))
2425 (gnus-eval-in-buffer-window gnus-save-article-buffer
2429 (gnus-output-to-rmail filename
))))
2432 (defun gnus-summary-save-in-mail (&optional filename
)
2433 "Append this article to Unix mail file.
2434 Optional argument FILENAME specifies file name.
2435 Directory to save to is default to `gnus-article-save-directory'."
2436 (setq filename
(gnus-read-save-file-name
2437 "Save %s in Unix mail file:" filename
2438 gnus-mail-save-name gnus-newsgroup-name
2439 gnus-current-headers
'gnus-newsgroup-last-mail
))
2440 (gnus-eval-in-buffer-window gnus-save-article-buffer
2444 (if (and (file-readable-p filename
)
2445 (mail-file-babyl-p filename
))
2446 (rmail-output-to-rmail-file filename t
)
2447 (gnus-output-to-mail filename
)))))
2450 (defun gnus-summary-save-in-file (&optional filename overwrite
)
2451 "Append this article to file.
2452 Optional argument FILENAME specifies file name.
2453 Directory to save to is default to `gnus-article-save-directory'."
2454 (setq filename
(gnus-read-save-file-name
2455 "Save %s in file:" filename
2456 gnus-file-save-name gnus-newsgroup-name
2457 gnus-current-headers
'gnus-newsgroup-last-file
))
2458 (gnus-eval-in-buffer-window gnus-save-article-buffer
2462 (when (and overwrite
2463 (file-exists-p filename
))
2464 (delete-file filename
))
2465 (gnus-output-to-file filename
))))
2468 (defun gnus-summary-write-to-file (&optional filename
)
2469 "Write this article to a file.
2470 Optional argument FILENAME specifies file name.
2471 The directory to save in defaults to `gnus-article-save-directory'."
2472 (gnus-summary-save-in-file nil t
))
2474 (defun gnus-summary-save-body-in-file (&optional filename
)
2475 "Append this article body to a file.
2476 Optional argument FILENAME specifies file name.
2477 The directory to save in defaults to `gnus-article-save-directory'."
2478 (setq filename
(gnus-read-save-file-name
2479 "Save %s body in file:" filename
2480 gnus-file-save-name gnus-newsgroup-name
2481 gnus-current-headers
'gnus-newsgroup-last-file
))
2482 (gnus-eval-in-buffer-window gnus-save-article-buffer
2486 (when (article-goto-body)
2487 (narrow-to-region (point) (point-max)))
2488 (gnus-output-to-file filename
))))
2491 (defun gnus-summary-save-in-pipe (&optional command
)
2492 "Pipe this article to subprocess."
2494 (cond ((and (eq command
'default
)
2495 gnus-last-shell-command
)
2496 gnus-last-shell-command
)
2501 "Shell command on %s: "
2502 (if (and gnus-number-of-articles-to-be-saved
2503 (> gnus-number-of-articles-to-be-saved
1))
2504 (format "these %d articles"
2505 gnus-number-of-articles-to-be-saved
)
2507 gnus-last-shell-command
))))
2508 (when (string-equal command
"")
2509 (if gnus-last-shell-command
2510 (setq command gnus-last-shell-command
)
2511 (error "A command is required.")))
2512 (gnus-eval-in-buffer-window gnus-article-buffer
2515 (shell-command-on-region (point-min) (point-max) command nil
)))
2516 (setq gnus-last-shell-command command
))
2518 ;;; Article file names when saving.
2520 (defun gnus-capitalize-newsgroup (newsgroup)
2521 "Capitalize NEWSGROUP name."
2522 (when (not (zerop (length newsgroup
)))
2523 (concat (char-to-string (upcase (aref newsgroup
0)))
2524 (substring newsgroup
1))))
2526 (defun gnus-Numeric-save-name (newsgroup headers
&optional last-file
)
2527 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2528 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
2529 Otherwise, it is like ~/News/news/group/num."
2532 (concat (if (gnus-use-long-file-name 'not-save
)
2533 (gnus-capitalize-newsgroup newsgroup
)
2534 (gnus-newsgroup-directory-form newsgroup
))
2535 "/" (int-to-string (mail-header-number headers
)))
2536 gnus-article-save-directory
)))
2538 (string-equal (file-name-directory default
)
2539 (file-name-directory last-file
))
2540 (string-match "^[0-9]+$" (file-name-nondirectory last-file
)))
2542 (or last-file default
))))
2544 (defun gnus-numeric-save-name (newsgroup headers
&optional last-file
)
2545 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2546 If variable `gnus-use-long-file-name' is non-nil, it is
2547 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2550 (concat (if (gnus-use-long-file-name 'not-save
)
2552 (gnus-newsgroup-directory-form newsgroup
))
2553 "/" (int-to-string (mail-header-number headers
)))
2554 gnus-article-save-directory
)))
2556 (string-equal (file-name-directory default
)
2557 (file-name-directory last-file
))
2558 (string-match "^[0-9]+$" (file-name-nondirectory last-file
)))
2560 (or last-file default
))))
2562 (defun gnus-plain-save-name (newsgroup headers
&optional last-file
)
2563 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2564 If variable `gnus-use-long-file-name' is non-nil, it is
2565 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2568 (if (gnus-use-long-file-name 'not-save
)
2570 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup
)))
2571 gnus-article-save-directory
)))
2578 (setq afunc
(car func
)
2581 gfunc
(intern (format "gnus-%s" func
))))
2584 `(lambda (&optional interactive
&rest args
)
2585 ,(documentation afunc t
)
2586 (interactive (list t
))
2588 (set-buffer gnus-article-buffer
)
2590 (call-interactively ',afunc
)
2591 (apply ',afunc args
))))))))
2592 '(article-hide-headers
2593 article-hide-boring-headers
2594 article-treat-overstrike
2595 article-fill-long-lines
2596 article-capitalize-sentences
2598 article-display-x-face
2599 article-de-quoted-unreadable
2600 article-de-base64-unreadable
2603 article-hide-list-identifiers
2605 article-strip-banner
2608 article-hide-signature
2609 article-strip-headers-in-body
2610 article-remove-trailing-blank-lines
2611 article-strip-leading-blank-lines
2612 article-strip-multiple-blank-lines
2613 article-strip-leading-space
2614 article-strip-trailing-space
2615 article-strip-blank-lines
2616 article-strip-all-blank-lines
2618 article-date-iso8601
2619 article-date-original
2621 article-decode-mime-words
2622 article-decode-charset
2623 article-decode-encoded-words
2627 article-treat-dumbquotes
2628 article-normalize-headers
2629 (article-show-all . gnus-article-show-all-headers
))))
2632 ;;; Gnus article mode
2635 (put 'gnus-article-mode
'mode-class
'special
)
2637 (set-keymap-parent gnus-article-mode-map widget-keymap
)
2639 (gnus-define-keys gnus-article-mode-map
2640 " " gnus-article-goto-next-page
2641 "\177" gnus-article-goto-prev-page
2642 [delete] gnus-article-goto-prev-page
2643 [backspace] gnus-article-goto-prev-page
2644 "\C-c^" gnus-article-refer-article
2645 "h" gnus-article-show-summary
2646 "s" gnus-article-show-summary
2647 "\C-c\C-m" gnus-article-mail
2648 "?" gnus-article-describe-briefly
2649 "e" gnus-summary-edit-article
2650 "<" beginning-of-buffer
2652 "\C-c\C-i" gnus-info-find-node
2654 "\C-hk" gnus-article-describe-key
2655 "\C-hc" gnus-article-describe-key-briefly
2657 "\C-d" gnus-article-read-summary-keys
2658 "\M-*" gnus-article-read-summary-keys
2659 "\M-#" gnus-article-read-summary-keys
2660 "\M-^" gnus-article-read-summary-keys
2661 "\M-g" gnus-article-read-summary-keys)
2663 (substitute-key-definition
2664 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
2666 (defvar gnus-article-post-menu nil)
2668 (defun gnus-article-make-menu-bar ()
2669 (gnus-turn-off-edit-menu 'article)
2670 (unless (boundp 'gnus-article-article-menu)
2672 gnus-article-article-menu gnus-article-mode-map ""
2674 ["Scroll forwards" gnus-article-goto-next-page t]
2675 ["Scroll backwards" gnus-article-goto-prev-page t]
2676 ["Show summary" gnus-article-show-summary t]
2677 ["Fetch Message-ID at point" gnus-article-refer-article t]
2678 ["Mail to address at point" gnus-article-mail t]
2679 ["Send a bug report" gnus-bug t]))
2682 gnus-article-treatment-menu gnus-article-mode-map ""
2683 ;; Fixme: this should use :active (and maybe :visible).
2685 ["Hide headers" gnus-article-hide-headers t]
2686 ["Hide signature" gnus-article-hide-signature t]
2687 ["Hide citation" gnus-article-hide-citation t]
2688 ["Treat overstrike" gnus-article-treat-overstrike t]
2689 ["Remove carriage return" gnus-article-remove-cr t]
2690 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
2691 ["Remove base64" gnus-article-de-base64-unreadable t]
2692 ["Treat html" gnus-article-wash-html t]
2693 ["Decode HZ" gnus-article-decode-HZ t]))
2695 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
2697 (when (boundp 'gnus-summary-post-menu)
2699 ((not (keymapp gnus-summary-post-menu))
2700 (setq gnus-article-post-menu gnus-summary-post-menu))
2701 ((not gnus-article-post-menu)
2702 ;; Don't share post menu.
2703 (setq gnus-article-post-menu
2704 (copy-keymap gnus-summary-post-menu))))
2705 (define-key gnus-article-mode-map [menu-bar post]
2706 (cons "Post" gnus-article-post-menu)))
2708 (gnus-run-hooks 'gnus-article-menu-hook)))
2710 ;; Fixme: do something for the Emacs tool bar in Article mode a la
2713 (defun gnus-article-mode ()
2714 "Major mode for displaying an article.
2716 All normal editing commands are switched off.
2718 The following commands are available in addition to all summary mode
2720 \\<gnus-article-mode-map>
2721 \\[gnus-article-next-page]\t Scroll the article one page forwards
2722 \\[gnus-article-prev-page]\t Scroll the article one page backwards
2723 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
2724 \\[gnus-article-show-summary]\t Display the summary buffer
2725 \\[gnus-article-mail]\t Send a reply to the address near point
2726 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
2727 \\[gnus-info-find-node]\t Go to the Gnus info node"
2729 (gnus-simplify-mode-line)
2730 (setq mode-name "Article")
2731 (setq major-mode 'gnus-article-mode)
2732 (make-local-variable 'minor-mode-alist)
2733 (use-local-map gnus-article-mode-map)
2734 (when (gnus-visual-p 'article-menu 'menu)
2735 (gnus-article-make-menu-bar))
2736 (gnus-update-format-specifications nil 'article-mode)
2737 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
2738 (make-local-variable 'gnus-page-broken)
2739 (make-local-variable 'gnus-button-marker-list)
2740 (make-local-variable 'gnus-article-current-summary)
2741 (make-local-variable 'gnus-article-mime-handles)
2742 (make-local-variable 'gnus-article-decoded-p)
2743 (make-local-variable 'gnus-article-mime-handle-alist)
2744 (make-local-variable 'gnus-article-wash-types)
2745 (gnus-set-default-directory)
2746 (buffer-disable-undo)
2747 (setq buffer-read-only t)
2748 (set-syntax-table gnus-article-mode-syntax-table)
2749 (mm-enable-multibyte)
2750 (gnus-run-hooks 'gnus-article-mode-hook))
2752 (defun gnus-article-setup-buffer ()
2753 "Initialize the article buffer."
2754 (let* ((name (if gnus-single-article-buffer "*Article*"
2755 (concat "*Article " gnus-newsgroup-name "*")))
2757 (progn (string-match "\\*Article" name)
2758 (concat " *Original Article"
2759 (substring name (match-end 0))))))
2760 (setq gnus-article-buffer name)
2761 (setq gnus-original-article-buffer original)
2762 (setq gnus-article-mime-handle-alist nil)
2763 ;; This might be a variable local to the summary buffer.
2764 (unless gnus-single-article-buffer
2766 (set-buffer gnus-summary-buffer)
2767 (setq gnus-article-buffer name)
2768 (setq gnus-original-article-buffer original)
2769 (gnus-set-global-variables)))
2770 (gnus-article-setup-highlight-words)
2771 ;; Init original article buffer.
2773 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
2774 (mm-enable-multibyte)
2775 (setq major-mode 'gnus-original-article-mode)
2776 (make-local-variable 'gnus-original-article))
2777 (if (get-buffer name)
2780 (when gnus-article-mime-handles
2781 (mm-destroy-parts gnus-article-mime-handles)
2782 (setq gnus-article-mime-handles nil))
2783 ;; Set it to nil in article-buffer!
2784 (setq gnus-article-mime-handle-alist nil)
2785 (buffer-disable-undo)
2786 (setq buffer-read-only t)
2787 (unless (eq major-mode 'gnus-article-mode)
2788 (gnus-article-mode))
2791 (set-buffer (gnus-get-buffer-create name))
2793 (make-local-variable 'gnus-summary-buffer)
2794 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2795 (current-buffer)))))
2797 ;; Set article window start at LINE, where LINE is the number of lines
2798 ;; from the head of the article.
2799 (defun gnus-article-set-window-start (&optional line)
2801 (get-buffer-window gnus-article-buffer t)
2803 (set-buffer gnus-article-buffer)
2804 (goto-char (point-min))
2807 (gnus-message 6 "Moved to bookmark")
2808 (search-forward "\n\n" nil t)
2812 (defun gnus-article-prepare (article &optional all-headers header)
2813 "Prepare ARTICLE in article mode buffer.
2814 ARTICLE should either be an article number or a Message-ID.
2815 If ARTICLE is an id, HEADER should be the article headers.
2816 If ALL-HEADERS is non-nil, no headers are hidden."
2818 ;; Make sure we start in a summary buffer.
2819 (unless (eq major-mode 'gnus-summary-mode)
2820 (set-buffer gnus-summary-buffer))
2821 (setq gnus-summary-buffer (current-buffer))
2822 (let* ((gnus-article (if header (mail-header-number header) article))
2823 (summary-buffer (current-buffer))
2824 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
2825 (group gnus-newsgroup-name)
2828 (gnus-article-setup-buffer)
2829 (set-buffer gnus-article-buffer)
2830 ;; Deactivate active regions.
2831 (when (and (boundp 'transient-mark-mode)
2832 transient-mark-mode)
2833 (setq mark-active nil))
2834 (if (not (setq result (let ((buffer-read-only nil))
2835 (gnus-request-article-this-buffer
2837 ;; There is no such article.
2839 (when (and (numberp article)
2840 (not (memq article gnus-newsgroup-sparse)))
2841 (setq gnus-article-current
2842 (cons gnus-newsgroup-name article))
2843 (set-buffer gnus-summary-buffer)
2844 (setq gnus-current-article article)
2845 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
2847 (gnus-summary-set-agent-mark article)
2848 (message "Message marked for downloading"))
2849 (gnus-summary-mark-article article gnus-canceled-mark)
2850 (unless (memq article gnus-newsgroup-sparse)
2851 (gnus-error 1 "No such article (may have expired or been canceled)")))))
2852 (if (or (eq result 'pseudo)
2853 (eq result 'nneething))
2856 (set-buffer summary-buffer)
2857 (push article gnus-newsgroup-history)
2858 (setq gnus-last-article gnus-current-article
2859 gnus-current-article 0
2860 gnus-current-headers nil
2861 gnus-article-current nil)
2862 (if (eq result 'nneething)
2863 (gnus-configure-windows 'summary)
2864 (gnus-configure-windows 'article))
2865 (gnus-set-global-variables))
2866 (let ((gnus-article-mime-handle-alist-1
2867 gnus-article-mime-handle-alist))
2868 (gnus-set-mode-line 'article)))
2869 ;; The result from the `request' was an actual article -
2870 ;; or at least some text that is now displayed in the
2872 (when (and (numberp article)
2873 (not (eq article gnus-current-article)))
2874 ;; Seems like a new article has been selected.
2875 ;; `gnus-current-article' must be an article number.
2877 (set-buffer summary-buffer)
2878 (push article gnus-newsgroup-history)
2879 (setq gnus-last-article gnus-current-article
2880 gnus-current-article article
2881 gnus-current-headers
2882 (gnus-summary-article-header gnus-current-article)
2883 gnus-article-current
2884 (cons gnus-newsgroup-name gnus-current-article))
2885 (unless (vectorp gnus-current-headers)
2886 (setq gnus-current-headers nil))
2887 (gnus-summary-goto-subject gnus-current-article)
2888 (when (gnus-summary-show-thread)
2889 ;; If the summary buffer really was folded, the
2890 ;; previous goto may not actually have gone to
2891 ;; the right article, but the thread root instead.
2893 (gnus-summary-goto-subject gnus-current-article))
2894 (gnus-run-hooks 'gnus-mark-article-hook)
2895 (gnus-set-mode-line 'summary)
2896 (when (gnus-visual-p 'article-highlight 'highlight)
2897 (gnus-run-hooks 'gnus-visual-mark-article-hook))
2898 ;; Set the global newsgroup variables here.
2899 (gnus-set-global-variables)
2900 (setq gnus-have-all-headers
2901 (or all-headers gnus-show-all-headers))))
2903 (gnus-configure-windows 'article))
2904 (when (or (numberp article)
2906 (gnus-article-prepare-display)
2908 (goto-char (point-min))
2909 (setq gnus-page-broken
2910 (when gnus-break-pages
2911 (gnus-narrow-to-page)
2913 (let ((gnus-article-mime-handle-alist-1
2914 gnus-article-mime-handle-alist))
2915 (gnus-set-mode-line 'article))
2917 (set-window-point (get-buffer-window (current-buffer)) (point))
2918 (gnus-configure-windows 'article)
2922 (defun gnus-article-prepare-display ()
2923 "Make the current buffer look like a nice article."
2924 ;; Hooks for getting information from the article.
2925 ;; This hook must be called before being narrowed.
2926 (let ((gnus-article-buffer (current-buffer))
2928 (unless (eq major-mode 'gnus-article-mode)
2929 (gnus-article-mode))
2930 (setq buffer-read-only nil
2931 gnus-article-wash-types nil)
2932 (gnus-run-hooks 'gnus-tmp-internal-hook)
2933 (when gnus-display-mime-function
2934 (funcall gnus-display-mime-function))
2935 (gnus-run-hooks 'gnus-article-prepare-hook)))
2938 ;;; Gnus MIME viewing functions
2941 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
2942 "The following specs can be used:
2944 %T MIME type, along with additional info
2945 %n The `name' parameter
2946 %d The description, if any
2947 %l The length of the encoded part
2948 %p The part identifier number
2949 %e Dots if the part isn't displayed")
2951 (defvar gnus-mime-button-line-format-alist
2952 '((?t gnus-tmp-type ?s)
2953 (?T gnus-tmp-type-long ?s)
2954 (?n gnus-tmp-name ?s)
2955 (?d gnus-tmp-description ?s)
2957 (?l gnus-tmp-length ?d)
2958 (?e gnus-tmp-dots ?s)))
2960 (defvar gnus-mime-button-commands
2961 '((gnus-article-press-button "\r" "Toggle Display")
2962 (gnus-mime-view-part "v" "View Interactively...")
2963 (gnus-mime-view-part-as-type "t" "View As Type...")
2964 (gnus-mime-save-part "o" "Save...")
2965 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
2966 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
2967 (gnus-mime-internalize-part "E" "View Internally")
2968 (gnus-mime-externalize-part "e" "View Externally")
2969 (gnus-mime-pipe-part "|" "Pipe To Command...")
2970 (gnus-mime-action-on-part "." "Take action on the part")))
2972 (defun gnus-article-mime-part-status ()
2973 (if gnus-article-mime-handle-alist-1
2974 (format " (%d parts)" (length gnus-article-mime-handle-alist-1))
2977 (defvar gnus-mime-button-map
2978 (let ((map (make-sparse-keymap)))
2979 ;; Not for Emacs 21: fixme better.
2980 ;; (set-keymap-parent map gnus-article-mode-map)
2981 (define-key map gnus-mouse-2 'gnus-article-push-button)
2982 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
2983 (dolist (c gnus-mime-button-commands)
2984 (define-key map (cadr c) (car c)))
2987 (defun gnus-mime-button-menu (event)
2988 "Construct a context-sensitive menu of MIME commands."
2991 (mouse-set-point event)
2992 (gnus-article-check-buffer)
2993 (let ((response (x-popup-menu
2995 ("" ,@(mapcar (lambda (c)
2996 (cons (caddr c) (car c)))
2997 gnus-mime-button-commands))))))
2999 (call-interactively response)))))
3001 (defun gnus-mime-view-all-parts (&optional handles)
3002 "View all the MIME parts."
3004 (save-current-buffer
3005 (set-buffer gnus-article-buffer)
3006 (let ((handles (or handles gnus-article-mime-handles))
3007 (mail-parse-charset gnus-newsgroup-charset)
3008 (mail-parse-ignored-charsets
3009 (save-excursion (set-buffer gnus-summary-buffer)
3010 gnus-newsgroup-ignored-charsets)))
3011 (if (stringp (car handles))
3012 (gnus-mime-view-all-parts (cdr handles))
3013 (mapcar 'mm-display-part handles)))))
3015 (defun gnus-mime-save-part ()
3016 "Save the MIME part under point."
3018 (gnus-article-check-buffer)
3019 (let ((data (get-text-property (point) 'gnus-data)))
3020 (mm-save-part data)))
3022 (defun gnus-mime-pipe-part ()
3023 "Pipe the MIME part under point to a process."
3025 (gnus-article-check-buffer)
3026 (let ((data (get-text-property (point) 'gnus-data)))
3027 (mm-pipe-part data)))
3029 (defun gnus-mime-view-part ()
3030 "Interactively choose a viewing method for the MIME part under point."
3032 (gnus-article-check-buffer)
3033 (let ((data (get-text-property (point) 'gnus-data)))
3034 (push (setq data (copy-sequence data)) gnus-article-mime-handles)
3035 (mm-interactively-view-part data)))
3037 (defun gnus-mime-view-part-as-type-internal ()
3038 (gnus-article-check-buffer)
3039 (let* ((name (mail-content-type-get
3040 (mm-handle-type (get-text-property (point) 'gnus-data))
3042 (def-type (and name (mm-default-file-encoding name))))
3043 (and def-type (cons def-type 0))))
3045 (defun gnus-mime-view-part-as-type (mime-type)
3046 "Choose a MIME media type, and view the part as such."
3048 (list (completing-read
3049 "View as MIME type: "
3050 (mapcar #'list (mailcap-mime-types))
3052 (gnus-mime-view-part-as-type-internal))))
3053 (gnus-article-check-buffer)
3054 (let ((handle (get-text-property (point) 'gnus-data)))
3055 (gnus-mm-display-part
3056 (mm-make-handle (mm-handle-buffer handle)
3057 (cons mime-type (cdr (mm-handle-type handle)))
3058 (mm-handle-encoding handle)
3059 (mm-handle-undisplayer handle)
3060 (mm-handle-disposition handle)
3061 (mm-handle-description handle)
3062 (mm-handle-cache handle)
3063 (mm-handle-id handle)))))
3065 (defun gnus-mime-copy-part (&optional handle)
3066 "Put the the MIME part under point into a new buffer."
3068 (gnus-article-check-buffer)
3069 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3070 (contents (mm-get-part handle))
3071 (base (file-name-nondirectory
3073 (mail-content-type-get (mm-handle-type handle) 'name)
3074 (mail-content-type-get (mm-handle-type handle)
3077 (buffer (generate-new-buffer base)))
3078 (switch-to-buffer buffer)
3080 ;; We do it this way to make `normal-mode' set the appropriate mode.
3083 (setq buffer-file-name (expand-file-name base))
3085 (setq buffer-file-name nil))
3086 (goto-char (point-min))))
3088 (defun gnus-mime-inline-part (&optional handle arg)
3089 "Insert the MIME part under point into the current buffer."
3090 (interactive (list nil current-prefix-arg))
3091 (gnus-article-check-buffer)
3092 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3096 (if (mm-handle-undisplayer handle)
3097 (mm-remove-part handle)
3098 (setq contents (mm-get-part handle))
3101 (setq charset (or (mail-content-type-get
3102 (mm-handle-type handle) 'charset)
3103 gnus-newsgroup-charset)))
3107 gnus-summary-show-article-charset-alist))
3108 (read-coding-system "Charset: ")))))
3110 (mm-insert-inline handle
3112 (setq charset (mm-charset-to-coding-system
3114 (not (eq charset 'ascii)))
3115 (mm-decode-coding-string contents charset)
3119 (defun gnus-mime-externalize-part (&optional handle)
3120 "View the MIME part under point with an external viewer."
3122 (gnus-article-check-buffer)
3123 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3124 (mm-user-display-methods nil)
3125 (mm-inlined-types nil)
3126 (mail-parse-charset gnus-newsgroup-charset)
3127 (mail-parse-ignored-charsets
3128 (save-excursion (set-buffer gnus-summary-buffer)
3129 gnus-newsgroup-ignored-charsets)))
3130 (if (mm-handle-undisplayer handle)
3131 (mm-remove-part handle)
3132 (mm-display-part handle))))
3134 (defun gnus-mime-internalize-part (&optional handle)
3135 "View the MIME part under point with an internal viewer.
3136 In no internal viewer is available, use an external viewer."
3138 (gnus-article-check-buffer)
3139 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3140 (mm-inlined-types '(".*"))
3141 (mm-inline-large-images t)
3142 (mail-parse-charset gnus-newsgroup-charset)
3143 (mail-parse-ignored-charsets
3144 (save-excursion (set-buffer gnus-summary-buffer)
3145 gnus-newsgroup-ignored-charsets)))
3146 (if (mm-handle-undisplayer handle)
3147 (mm-remove-part handle)
3148 (mm-display-part handle))))
3150 (defun gnus-mime-action-on-part (&optional action)
3151 "Do something with the MIME attachment at \(point\)."
3153 (list (completing-read "Action: " gnus-mime-action-alist)))
3154 (gnus-article-check-buffer)
3155 (let ((action-pair (assoc action gnus-mime-action-alist)))
3157 (funcall (cdr action-pair)))))
3160 (defun gnus-article-part-wrapper (n function)
3161 (save-current-buffer
3162 (set-buffer gnus-article-buffer)
3163 (when (> n (length gnus-article-mime-handle-alist))
3164 (error "No such part"))
3165 (gnus-article-goto-part n)
3166 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3167 (funcall function handle))))
3169 (defun gnus-article-pipe-part (n)
3170 "Pipe MIME part N, which is the numerical prefix."
3172 (gnus-article-part-wrapper n 'mm-pipe-part))
3174 (defun gnus-article-save-part (n)
3175 "Save MIME part N, which is the numerical prefix."
3177 (gnus-article-part-wrapper n 'mm-save-part))
3179 (defun gnus-article-interactively-view-part (n)
3180 "View MIME part N interactively, which is the numerical prefix."
3182 (gnus-article-part-wrapper n 'mm-interactively-view-part))
3184 (defun gnus-article-copy-part (n)
3185 "Copy MIME part N, which is the numerical prefix."
3187 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
3189 (defun gnus-article-externalize-part (n)
3190 "View MIME part N externally, which is the numerical prefix."
3192 (gnus-article-part-wrapper n 'gnus-mime-externalize-part))
3194 (defun gnus-article-inline-part (n)
3195 "Inline MIME part N, which is the numerical prefix."
3197 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
3199 (defun gnus-article-mime-match-handle-first (condition)
3201 (let ((alist gnus-article-mime-handle-alist) ihandle n)
3202 (while (setq ihandle (pop alist))
3204 ((functionp condition)
3205 (funcall condition (cdr ihandle)))
3206 ((eq condition 'undisplayed)
3207 (not (or (mm-handle-undisplayer (cdr ihandle))
3208 (equal (mm-handle-media-type (cdr ihandle))
3209 "multipart/alternative"))))
3210 ((eq condition 'undisplayed-alternative)
3211 (not (mm-handle-undisplayer (cdr ihandle))))
3213 (gnus-article-goto-part (car ihandle))
3214 (or (not n) (< (car ihandle) n)))
3215 (setq n (car ihandle))))
3219 (defun gnus-article-view-part (&optional n)
3220 "View MIME part N, which is the numerical prefix."
3222 (save-current-buffer
3223 (set-buffer gnus-article-buffer)
3224 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
3225 gnus-article-mime-match-handle-function)))
3226 (when (> n (length gnus-article-mime-handle-alist))
3227 (error "No such part"))
3228 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3229 (when (gnus-article-goto-part n)
3230 (if (equal (car handle) "multipart/alternative")
3231 (gnus-article-press-button)
3232 (when (eq (gnus-mm-display-part handle) 'internal)
3233 (gnus-set-window-start)))))))
3235 (defsubst gnus-article-mime-total-parts ()
3236 (if (bufferp (car gnus-article-mime-handles))
3238 (1- (length gnus-article-mime-handles))))
3240 (defun gnus-mm-display-part (handle)
3241 "Display HANDLE and fix MIME button."
3242 (let ((id (get-text-property (point) 'gnus-part))
3247 (let ((window (selected-window))
3248 (mail-parse-charset gnus-newsgroup-charset)
3249 (mail-parse-ignored-charsets
3250 (save-excursion (set-buffer gnus-summary-buffer)
3251 gnus-newsgroup-ignored-charsets)))
3254 (let ((win (get-buffer-window (current-buffer) t))
3257 (select-window win))
3260 (if (mm-handle-displayed-p handle)
3261 ;; This will remove the part.
3262 (mm-display-part handle)
3264 (narrow-to-region (point) (1+ (point)))
3265 (mm-display-part handle)
3266 ;; We narrow to the part itself and
3267 ;; then call the treatment functions.
3268 (goto-char (point-min))
3270 (narrow-to-region (point) (point-max))
3273 (gnus-article-mime-total-parts)
3274 (mm-handle-media-type handle)))))
3275 (select-window window))))
3277 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
3278 (gnus-insert-mime-button
3279 handle id (list (mm-handle-displayed-p handle)))
3280 (goto-char point))))
3282 (defun gnus-article-goto-part (n)
3283 "Go to MIME part N."
3284 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
3286 (goto-char point))))
3288 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
3289 (let ((gnus-tmp-name
3290 (or (mail-content-type-get (mm-handle-type handle)
3292 (mail-content-type-get (mm-handle-disposition handle)
3295 (gnus-tmp-type (mm-handle-media-type handle))
3296 (gnus-tmp-description
3297 (mail-decode-encoded-word-string (or (mm-handle-description handle)
3300 (if (if displayed (car displayed)
3301 (mm-handle-displayed-p handle))
3303 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
3305 gnus-tmp-type-long b e)
3306 (when (string-match ".*/" gnus-tmp-name)
3307 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
3308 (setq gnus-tmp-type-long (concat gnus-tmp-type
3309 (and (not (equal gnus-tmp-name ""))
3310 (concat "; " gnus-tmp-name))))
3311 (or (equal gnus-tmp-description "")
3312 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
3317 gnus-mime-button-line-format gnus-mime-button-line-format-alist
3318 `(keymap ,gnus-mime-button-map
3319 ;; Not for Emacs 21: fixme better.
3320 ;; local-map ,gnus-mime-button-map
3321 gnus-callback gnus-mm-display-part
3322 gnus-part ,gnus-tmp-id
3323 article-type annotation
3326 (widget-convert-button
3329 :action 'gnus-widget-press-button
3330 :button-keymap gnus-mime-button-map
3332 (lambda (widget/window &optional overlay pos)
3333 ;; Needed to properly clear the message due to a bug in
3334 ;; wid-edit (XEmacs only).
3335 (if (boundp 'help-echo-owns-message)
3336 (setq help-echo-owns-message t))
3338 "%S: %s the MIME part; %S: more options"
3339 (aref gnus-mouse-2 0)
3340 ;; XEmacs will get a single widget arg; Emacs 21 will get
3341 ;; window, overlay, position.
3342 (if (mm-handle-displayed-p
3344 (with-current-buffer (gnus-overlay-buffer overlay)
3345 (widget-get (widget-at (gnus-overlay-start overlay))
3347 (widget-get widget/window :mime-handle)))
3349 (aref gnus-down-mouse-3 0))))))
3351 (defun gnus-widget-press-button (elems el)
3352 (goto-char (widget-get elems :from))
3353 (gnus-article-press-button))
3355 (defvar gnus-displaying-mime nil)
3357 (defun gnus-display-mime (&optional ihandles)
3358 "Display the MIME parts."
3360 (save-selected-window
3361 (let ((window (get-buffer-window gnus-article-buffer))
3364 (select-window window)
3365 ;; We have to do this since selecting the window
3366 ;; may change the point. So we set the window point.
3367 (set-window-point window point)))
3368 (let* ((handles (or ihandles (mm-dissect-buffer) (mm-uu-dissect)))
3369 buffer-read-only handle name type b e display)
3370 (when (and (not ihandles)
3371 (not gnus-displaying-mime))
3372 ;; Top-level call; we clean up.
3373 (when gnus-article-mime-handles
3374 (mm-destroy-parts gnus-article-mime-handles)
3375 (setq gnus-article-mime-handle-alist nil));; A trick.
3376 (setq gnus-article-mime-handles handles)
3377 ;; We allow users to glean info from the handles.
3378 (when gnus-article-mime-part-function
3379 (gnus-mime-part-function handles)))
3381 (or (not (stringp (car handles)))
3384 (when (and (not ihandles)
3385 (not gnus-displaying-mime))
3386 ;; Clean up for mime parts.
3388 (delete-region (point) (point-max)))
3389 (let ((gnus-displaying-mime t))
3390 (gnus-mime-display-part handles)))
3393 (narrow-to-region (point) (point-max))
3394 (gnus-treat-article nil 1 1)
3397 ;; Highlight the headers.
3401 (narrow-to-region (point-min) (point))
3402 (gnus-treat-article 'head))))))))
3404 (defvar gnus-mime-display-multipart-as-mixed nil)
3406 (defun gnus-mime-display-part (handle)
3409 ((not (stringp (car handle)))
3410 (gnus-mime-display-single handle))
3411 ;; User-defined multipart
3412 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
3413 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
3415 ;; multipart/alternative
3416 ((and (equal (car handle) "multipart/alternative")
3417 (not gnus-mime-display-multipart-as-mixed))
3418 (let ((id (1+ (length gnus-article-mime-handle-alist))))
3419 (push (cons id handle) gnus-article-mime-handle-alist)
3420 (gnus-mime-display-alternative (cdr handle) nil nil id)))
3421 ;; multipart/related
3422 ((and (equal (car handle) "multipart/related")
3423 (not gnus-mime-display-multipart-as-mixed))
3424 ;;;!!!We should find the start part, but we just default
3425 ;;;!!!to the first part.
3426 (gnus-mime-display-part (cadr handle)))
3427 ;; Other multiparts are handled like multipart/mixed.
3429 (gnus-mime-display-mixed (cdr handle)))))
3431 (defun gnus-mime-part-function (handles)
3432 (if (stringp (car handles))
3433 (mapcar 'gnus-mime-part-function (cdr handles))
3434 (funcall gnus-article-mime-part-function handles)))
3436 (defun gnus-mime-display-mixed (handles)
3437 (mapcar 'gnus-mime-display-part handles))
3439 (defun gnus-mime-display-single (handle)
3440 (let ((type (mm-handle-media-type handle))
3441 (ignored gnus-ignored-mime-types)
3448 (when (string-match (pop ignored) type)
3449 (throw 'ignored nil)))
3450 (if (and (setq not-attachment
3451 (and (not (mm-inline-override-p handle))
3452 (or (not (mm-handle-disposition handle))
3453 (equal (car (mm-handle-disposition handle))
3455 (mm-attachment-override-p handle))))
3456 (mm-automatic-display-p handle)
3457 (or (mm-inlined-p handle)
3458 (mm-automatic-external-display-p type)))
3460 (when (equal (mm-handle-media-supertype handle) "text")
3462 (let ((id (1+ (length gnus-article-mime-handle-alist)))
3464 (push (cons id handle) gnus-article-mime-handle-alist)
3465 (when (or (not display)
3466 (not (gnus-unbuttonized-mime-type-p type)))
3467 ;(gnus-article-insert-newline)
3468 (gnus-insert-mime-button
3469 handle id (list (or display (and not-attachment text))))
3470 (gnus-article-insert-newline)
3471 ;(gnus-article-insert-newline)
3479 (let ((mail-parse-charset gnus-newsgroup-charset)
3480 (mail-parse-ignored-charsets
3481 (save-excursion (condition-case ()
3482 (set-buffer gnus-summary-buffer)
3484 gnus-newsgroup-ignored-charsets)))
3485 (mm-display-part handle t))
3486 (goto-char (point-max)))
3487 ((and text not-attachment)
3491 (gnus-article-insert-newline)
3492 (mm-insert-inline handle (mm-get-part handle))
3493 (goto-char (point-max))))
3497 (narrow-to-region beg (point))
3500 (gnus-article-mime-total-parts)
3501 (mm-handle-media-type handle)))))))))
3503 (defun gnus-unbuttonized-mime-type-p (type)
3504 "Say whether TYPE is to be unbuttonized."
3505 (unless gnus-inhibit-mime-unbuttonizing
3507 (let ((types gnus-unbuttonized-mime-types))
3509 (when (string-match (pop types) type)
3510 (throw 'found t)))))))
3512 (defun gnus-article-insert-newline ()
3513 "Insert a newline, but mark it as undeletable."
3514 (gnus-put-text-property
3515 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
3517 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
3518 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
3521 handle buffer-read-only from props begend not-pref)
3522 (save-window-excursion
3525 (narrow-to-region (car ibegend)
3528 (goto-char (car ibegend))
3531 (delete-region (point-min) (point-max))
3532 (mm-remove-parts handles))
3533 (setq begend (list (point-marker)))
3535 (unless (setq not-pref (cadr (member preferred ihandles)))
3536 (setq not-pref (car ihandles)))
3538 (not (gnus-unbuttonized-mime-type-p
3539 "multipart/alternative")))
3540 (gnus-add-text-properties
3543 (insert (format "%d. " id))
3547 (unless ,(not ibegend)
3548 (setq gnus-article-mime-handle-alist
3549 ',gnus-article-mime-handle-alist))
3550 (gnus-mime-display-alternative
3551 ',ihandles ',not-pref ',begend ,id))
3552 ;; Not for Emacs 21: fixme better.
3553 ;; local-map ,gnus-mime-button-map
3554 ,gnus-mouse-face-prop ,gnus-article-mouse-face
3555 face ,gnus-article-button-face
3556 keymap ,gnus-mime-button-map
3559 (widget-convert-button 'link from (point)
3560 :action 'gnus-widget-press-button
3561 :button-keymap gnus-widget-button-keymap)
3563 (while (setq handle (pop handles))
3564 (gnus-add-text-properties
3567 (insert (format "(%c) %-18s"
3568 (if (equal handle preferred) ?* ? )
3569 (mm-handle-media-type handle)))
3573 (unless ,(not ibegend)
3574 (setq gnus-article-mime-handle-alist
3575 ',gnus-article-mime-handle-alist))
3576 (gnus-mime-display-alternative
3577 ',ihandles ',handle ',begend ,id))
3578 ;; Not for Emacs 21: fixme better.
3579 ;; local-map ,gnus-mime-button-map
3580 ,gnus-mouse-face-prop ,gnus-article-mouse-face
3581 face ,gnus-article-button-face
3582 keymap ,gnus-mime-button-map
3585 (widget-convert-button 'link from (point)
3586 :action 'gnus-widget-press-button
3587 :button-keymap gnus-widget-button-keymap)
3591 (if (stringp (car preferred))
3592 (gnus-display-mime preferred)
3593 (let ((mail-parse-charset gnus-newsgroup-charset)
3594 (mail-parse-ignored-charsets
3595 (save-excursion (set-buffer gnus-summary-buffer)
3596 gnus-newsgroup-ignored-charsets)))
3597 (mm-display-part preferred)
3601 (narrow-to-region (car begend) (point-max))
3603 nil (length gnus-article-mime-handle-alist)
3604 (gnus-article-mime-total-parts)
3605 (mm-handle-media-type handle))))))
3606 (goto-char (point-max))
3607 (setcdr begend (point-marker)))))
3609 (goto-char point))))
3611 (defun gnus-article-wash-status ()
3612 "Return a string which display status of article washing."
3614 (set-buffer gnus-article-buffer)
3615 (let ((cite (memq 'cite gnus-article-wash-types))
3616 (headers (memq 'headers gnus-article-wash-types))
3617 (boring (memq 'boring-headers gnus-article-wash-types))
3618 (pgp (memq 'pgp gnus-article-wash-types))
3619 (pem (memq 'pem gnus-article-wash-types))
3620 (signature (memq 'signature gnus-article-wash-types))
3621 (overstrike (memq 'overstrike gnus-article-wash-types))
3622 (emphasis (memq 'emphasis gnus-article-wash-types)))
3623 (format "%c%c%c%c%c%c"
3625 (if (or headers boring) ?h ? )
3626 (if (or pgp pem) ?p ? )
3627 (if signature ?s ? )
3628 (if overstrike ?o ? )
3629 (if emphasis ?e ? )))))
3631 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
3633 (defun gnus-article-maybe-hide-headers ()
3634 "Hide unwanted headers if `gnus-have-all-headers' is nil.
3635 Provided for backwards compatibility."
3636 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
3637 (not (save-excursion (set-buffer gnus-summary-buffer)
3638 gnus-have-all-headers)))
3639 (not gnus-inhibit-hiding))
3640 (gnus-article-hide-headers)))
3644 (defun gnus-output-to-file (file-name)
3645 "Append the current article to a file named FILE-NAME."
3646 (let ((artbuf (current-buffer)))
3648 (insert-buffer-substring artbuf)
3649 ;; Append newline at end of the buffer as separator, and then
3651 (goto-char (point-max))
3653 (mm-append-to-file (point-min) (point-max) file-name)
3656 (defun gnus-narrow-to-page (&optional arg)
3657 "Narrow the article buffer to a page.
3658 If given a numerical ARG, move forward ARG pages."
3660 (setq arg (if arg (prefix-numeric-value arg) 0))
3662 (set-buffer gnus-article-buffer)
3663 (goto-char (point-min))
3665 ;; Remove any old next/prev buttons.
3666 (when (gnus-visual-p 'page-marker)
3667 (let ((buffer-read-only nil))
3668 (gnus-remove-text-with-property 'gnus-prev)
3669 (gnus-remove-text-with-property 'gnus-next)))
3672 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
3674 (re-search-forward page-delimiter nil 'move arg)))
3675 (goto-char (match-end 0)))
3678 (if (re-search-forward page-delimiter nil 'move)
3681 (when (and (gnus-visual-p 'page-marker)
3682 (not (= (point-min) 1)))
3684 (goto-char (point-min))
3685 (gnus-insert-prev-page-button)))
3686 (when (and (gnus-visual-p 'page-marker)
3687 (< (+ (point-max) 2) (buffer-size)))
3689 (goto-char (point-max))
3690 (gnus-insert-next-page-button)))))
3692 ;; Article mode commands
3694 (defun gnus-article-goto-next-page ()
3695 "Show the next page of the article."
3697 (when (gnus-article-next-page)
3698 (goto-char (point-min))
3699 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
3701 (defun gnus-article-goto-prev-page ()
3702 "Show the next page of the article."
3704 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
3705 (gnus-article-prev-page nil)))
3707 (defun gnus-article-next-page (&optional lines)
3708 "Show the next page of the current article.
3709 If end of article, return non-nil. Otherwise return nil.
3710 Argument LINES specifies lines to be scrolled up."
3712 (move-to-window-line -1)
3715 (and (pos-visible-in-window-p) ;Not continuation line.
3717 ;; Nothing in this page.
3718 (if (or (not gnus-page-broken)
3721 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
3723 (gnus-narrow-to-page 1) ;Go to next page.
3725 ;; More in this page.
3726 (let ((scroll-in-place nil))
3730 ;; Long lines may cause an end-of-buffer error.
3731 (goto-char (point-max)))))
3732 (move-to-window-line 0)
3735 (defun gnus-article-prev-page (&optional lines)
3736 "Show previous page of current article.
3737 Argument LINES specifies lines to be scrolled down."
3739 (move-to-window-line 0)
3740 (if (and gnus-page-broken
3742 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
3744 (gnus-narrow-to-page -1) ;Go to previous page.
3745 (goto-char (point-max))
3747 (let ((scroll-in-place nil))
3751 (beginning-of-buffer
3752 (goto-char (point-min))))
3753 (move-to-window-line 0)))))
3755 (defun gnus-article-refer-article ()
3756 "Read article specified by message-id around point."
3758 (let ((point (point)))
3759 (search-forward ">" nil t) ;Move point to end of "<....>".
3760 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
3761 (let ((message-id (match-string 1)))
3763 (set-buffer gnus-summary-buffer)
3764 (gnus-summary-refer-article message-id))
3766 (error "No references around point"))))
3768 (defun gnus-article-show-summary ()
3769 "Reconfigure windows to show summary buffer."
3771 (if (not (gnus-buffer-live-p gnus-summary-buffer))
3772 (error "There is no summary buffer for this article buffer")
3773 (gnus-article-set-globals)
3774 (gnus-configure-windows 'article)
3775 (gnus-summary-goto-subject gnus-current-article)
3776 (gnus-summary-position-point)))
3778 (defun gnus-article-describe-briefly ()
3779 "Describe article mode commands briefly."
3781 (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")))
3783 (defun gnus-article-summary-command ()
3784 "Execute the last keystroke in the summary buffer."
3786 (let ((obuf (current-buffer))
3787 (owin (current-window-configuration))
3789 (switch-to-buffer gnus-article-current-summary 'norecord)
3790 (setq func (lookup-key (current-local-map) (this-command-keys)))
3791 (call-interactively func)
3793 (set-window-configuration owin)
3794 (set-window-point (get-buffer-window (current-buffer)) (point))))
3796 (defun gnus-article-summary-command-nosave ()
3797 "Execute the last keystroke in the summary buffer."
3800 (pop-to-buffer gnus-article-current-summary 'norecord)
3801 (setq func (lookup-key (current-local-map) (this-command-keys)))
3802 (call-interactively func)))
3804 (defun gnus-article-check-buffer ()
3805 "Beep if not in an article buffer."
3806 (unless (equal major-mode 'gnus-article-mode)
3807 (error "Command invoked outside of a Gnus article buffer")))
3809 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
3810 "Read a summary buffer key sequence and execute it from the article buffer."
3812 (gnus-article-check-buffer)
3814 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
3815 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
3816 "=" "^" "\M-^" "|"))
3822 '("n" "Gn" "p" "Gp"))
3825 (set-buffer gnus-article-current-summary)
3826 (let (gnus-pick-mode)
3827 (push (or key last-command-event) unread-command-events)
3828 (setq keys (if (featurep 'xemacs)
3829 (events-to-keys (read-key-sequence nil))
3830 (read-key-sequence nil)))))
3834 (if (or (member keys nosaves)
3835 (member keys nosave-but-article)
3836 (member keys nosave-in-article))
3838 (save-window-excursion
3839 (pop-to-buffer gnus-article-current-summary 'norecord)
3840 ;; We disable the pick minor mode commands.
3841 (let (gnus-pick-mode)
3842 (setq func (lookup-key (current-local-map) keys))))
3846 (unless (member keys nosave-in-article)
3847 (set-buffer gnus-article-current-summary))
3848 (call-interactively func)
3849 (setq new-sum-point (point)))
3850 (when (member keys nosave-but-article)
3851 (pop-to-buffer gnus-article-buffer 'norecord)))
3852 ;; These commands should restore window configuration.
3853 (let ((obuf (current-buffer))
3854 (owin (current-window-configuration))
3856 (summary gnus-article-current-summary)
3857 func in-buffer selected)
3858 (if not-restore-window
3859 (pop-to-buffer summary 'norecord)
3860 (switch-to-buffer summary 'norecord))
3861 (setq in-buffer (current-buffer))
3862 ;; We disable the pick minor mode commands.
3863 (if (and (setq func (let (gnus-pick-mode)
3864 (lookup-key (current-local-map) keys)))
3867 (call-interactively func)
3868 (setq new-sum-point (point))
3869 (when (eq in-buffer (current-buffer))
3870 (setq selected (gnus-summary-select-article))
3872 (unless not-restore-window
3873 (set-window-configuration owin))
3874 (when (eq selected 'old)
3876 (set-window-start (get-buffer-window (current-buffer))
3878 (set-window-point (get-buffer-window (current-buffer))
3880 (let ((win (get-buffer-window gnus-article-current-summary)))
3882 (set-window-point win new-sum-point)))) )
3883 (switch-to-buffer gnus-article-buffer)
3886 (defun gnus-article-describe-key (key)
3887 "Display documentation of the function invoked by KEY. KEY is a string."
3888 (interactive "kDescribe key: ")
3889 (gnus-article-check-buffer)
3890 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
3892 (set-buffer gnus-article-current-summary)
3893 (let (gnus-pick-mode)
3894 (push (elt key 0) unread-command-events)
3895 (setq key (if (featurep 'xemacs)
3896 (events-to-keys (read-key-sequence "Describe key: "))
3897 (read-key-sequence "Describe key: "))))
3899 (describe-key key)))
3901 (defun gnus-article-describe-key-briefly (key &optional insert)
3902 "Display documentation of the function invoked by KEY. KEY is a string."
3903 (interactive "kDescribe key: \nP")
3904 (gnus-article-check-buffer)
3905 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
3907 (set-buffer gnus-article-current-summary)
3908 (let (gnus-pick-mode)
3909 (push (elt key 0) unread-command-events)
3910 (setq key (if (featurep 'xemacs)
3911 (events-to-keys (read-key-sequence "Describe key: "))
3912 (read-key-sequence "Describe key: "))))
3913 (describe-key-briefly key insert))
3914 (describe-key-briefly key insert)))
3916 (defun gnus-article-hide (&optional arg force)
3917 "Hide all the gruft in the current article.
3918 This means that PGP stuff, signatures, cited text and (some)
3919 headers will be hidden.
3920 If given a prefix, show the hidden text instead."
3921 (interactive (append (gnus-article-hidden-arg) (list 'force)))
3922 (gnus-article-hide-headers arg)
3923 (gnus-article-hide-list-identifiers arg)
3924 (gnus-article-hide-pgp arg)
3925 (gnus-article-hide-citation-maybe arg force)
3926 (gnus-article-hide-signature arg))
3928 (defun gnus-article-maybe-highlight ()
3929 "Do some article highlighting if article highlighting is requested."
3930 (when (gnus-visual-p 'article-highlight 'highlight)
3931 (gnus-article-highlight-some)))
3933 (defun gnus-check-group-server ()
3934 ;; Make sure the connection to the server is alive.
3935 (unless (gnus-server-opened
3936 (gnus-find-method-for-group gnus-newsgroup-name))
3937 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
3938 (gnus-request-group gnus-newsgroup-name t)))
3940 (defun gnus-request-article-this-buffer (article group)
3941 "Get an article and insert it into this buffer."
3942 (let (do-update-line sparse-header)
3946 (gnus-kill-all-overlays)
3947 (setq group (or group gnus-newsgroup-name))
3949 ;; Using `gnus-request-article' directly will insert the article into
3950 ;; `nntp-server-buffer' - so we'll save some time by not having to
3951 ;; copy it from the server buffer into the article buffer.
3953 ;; We only request an article by message-id when we do not have the
3954 ;; headers for it, so we'll have to get those.
3955 (when (stringp article)
3956 (gnus-read-header article))
3958 ;; If the article number is negative, that means that this article
3959 ;; doesn't belong in this newsgroup (possibly), so we find its
3960 ;; message-id and request it by id instead of number.
3961 (when (and (numberp article)
3963 (get-buffer gnus-summary-buffer)
3964 (gnus-buffer-exists-p gnus-summary-buffer))
3966 (set-buffer gnus-summary-buffer)
3967 (let ((header (gnus-summary-article-header article)))
3970 ((memq article gnus-newsgroup-sparse)
3971 ;; This is a sparse gap article.
3972 (setq do-update-line article)
3973 (setq article (mail-header-id header))
3974 (setq sparse-header (gnus-read-header article))
3975 (setq gnus-newsgroup-sparse
3976 (delq article gnus-newsgroup-sparse)))
3978 ;; It's a real article.
3979 (setq article (mail-header-id header)))
3981 ;; It is an extracted pseudo-article.
3982 (setq article 'pseudo)
3983 (gnus-request-pseudo-article header))))
3985 (let ((method (gnus-find-method-for-group
3986 gnus-newsgroup-name)))
3987 (when (and (eq (car method) 'nneething)
3989 (let ((dir (expand-file-name
3990 (mail-header-subject header)
3991 (file-name-as-directory
3992 (or (cadr (assq 'nneething-address method))
3994 (when (file-directory-p dir)
3995 (setq article 'nneething)
3996 (gnus-group-enter-directory dir))))))))
3999 ;; Refuse to select canceled articles.
4000 ((and (numberp article)
4002 (get-buffer gnus-summary-buffer)
4003 (gnus-buffer-exists-p gnus-summary-buffer)
4004 (eq (cdr (save-excursion
4005 (set-buffer gnus-summary-buffer)
4006 (assq article gnus-newsgroup-reads)))
4007 gnus-canceled-mark))
4009 ;; We first check `gnus-original-article-buffer'.
4010 ((and (get-buffer gnus-original-article-buffer)
4013 (set-buffer gnus-original-article-buffer)
4014 (and (equal (car gnus-original-article) group)
4015 (eq (cdr gnus-original-article) article))))
4016 (insert-buffer-substring gnus-original-article-buffer)
4018 ;; Check the backlog.
4019 ((and gnus-keep-backlog
4020 (gnus-backlog-request-article group article (current-buffer)))
4022 ;; Check asynchronous pre-fetch.
4023 ((gnus-async-request-fetched-article group article (current-buffer))
4024 (gnus-async-prefetch-next group article gnus-summary-buffer)
4025 (when (and (numberp article) gnus-keep-backlog)
4026 (gnus-backlog-enter-article group article (current-buffer)))
4029 ((and gnus-use-cache
4031 (gnus-cache-request-article article group))
4033 ;; Get the article and put into the article buffer.
4034 ((or (stringp article)
4036 (let ((gnus-override-method gnus-override-method)
4037 (methods (and (stringp article)
4038 gnus-refer-article-method))
4040 (buffer-read-only nil))
4041 (if (or (not (listp methods))
4042 (and (symbolp (car methods))
4043 (assq (car methods) nnoo-definition-alist)))
4044 (setq methods (list methods)))
4045 (when (and (null gnus-override-method)
4047 (setq gnus-override-method (pop methods)))
4049 (when (eq gnus-override-method 'current)
4050 (setq gnus-override-method gnus-current-select-method))
4052 (gnus-kill-all-overlays)
4053 (let ((gnus-newsgroup-name group))
4054 (gnus-check-group-server))
4055 (when (gnus-request-article article group (current-buffer))
4056 (when (numberp article)
4057 (gnus-async-prefetch-next group article
4058 gnus-summary-buffer)
4059 (when gnus-keep-backlog
4060 (gnus-backlog-enter-article
4061 group article (current-buffer))))
4062 (setq result 'article))
4065 (setq gnus-override-method (pop methods))
4066 (setq result 'done))))
4067 (and (eq result 'article) 'article)))
4071 ;; Associate this article with the current summary buffer.
4072 (setq gnus-article-current-summary gnus-summary-buffer)
4074 ;; Take the article from the original article buffer
4075 ;; and place it in the buffer it's supposed to be in.
4076 (when (and (get-buffer gnus-article-buffer)
4077 (equal (buffer-name (current-buffer))
4078 (buffer-name (get-buffer gnus-article-buffer))))
4080 (if (get-buffer gnus-original-article-buffer)
4081 (set-buffer gnus-original-article-buffer)
4082 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
4083 (buffer-disable-undo)
4084 (setq major-mode 'gnus-original-article-mode)
4085 (setq buffer-read-only t))
4086 (let (buffer-read-only)
4088 (insert-buffer-substring gnus-article-buffer))
4089 (setq gnus-original-article (cons group article)))
4092 (run-hooks 'gnus-article-decode-hook)
4093 ;; Mark article as decoded or not.
4094 (setq gnus-article-decoded-p gnus-article-decode-hook))
4096 ;; Update sparse articles.
4097 (when (and do-update-line
4098 (or (numberp article)
4100 (let ((buf (current-buffer)))
4101 (set-buffer gnus-summary-buffer)
4102 (gnus-summary-update-article do-update-line sparse-header)
4103 (gnus-summary-goto-subject do-update-line nil t)
4104 (set-window-point (get-buffer-window (current-buffer) t)
4106 (set-buffer buf))))))
4112 (defcustom gnus-article-edit-mode-hook nil
4113 "Hook run in article edit mode buffers."
4114 :group 'gnus-article-various
4117 (defvar gnus-article-edit-done-function nil)
4119 (defvar gnus-article-edit-mode-map nil)
4121 ;; Should we be using derived.el for this?
4122 (unless gnus-article-edit-mode-map
4123 (setq gnus-article-edit-mode-map (make-sparse-keymap))
4124 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
4126 (gnus-define-keys gnus-article-edit-mode-map
4127 "\C-c\C-c" gnus-article-edit-done
4128 "\C-c\C-k" gnus-article-edit-exit)
4130 (gnus-define-keys (gnus-article-edit-wash-map
4131 "\C-c\C-w" gnus-article-edit-mode-map)
4132 "f" gnus-article-edit-full-stops))
4134 (defun gnus-article-edit-mode ()
4135 "Major mode for editing articles.
4136 This is an extended text-mode.
4138 \\{gnus-article-edit-mode-map}"
4140 (setq major-mode 'gnus-article-edit-mode)
4141 (setq mode-name "Article Edit")
4142 (use-local-map gnus-article-edit-mode-map)
4143 (make-local-variable 'gnus-article-edit-done-function)
4144 (make-local-variable 'gnus-prev-winconf)
4145 (setq buffer-read-only nil)
4146 (buffer-enable-undo)
4148 (gnus-run-hooks 'text-mode-hook 'gnus-article-edit-mode-hook))
4150 (defun gnus-article-edit (&optional force)
4151 "Edit the current article.
4152 This will have permanent effect only in mail groups.
4153 If FORCE is non-nil, allow editing of articles even in read-only
4156 (when (and (not force)
4157 (gnus-group-read-only-p))
4158 (error "The current newsgroup does not support article editing"))
4159 (gnus-article-date-original)
4160 (gnus-article-edit-article
4162 `(lambda (no-highlight)
4164 (gnus-summary-edit-article-done
4165 ,(or (mail-header-references gnus-current-headers) "")
4166 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
4168 (defun gnus-article-edit-article (start-func exit-func)
4169 "Start editing the contents of the current article buffer."
4170 (let ((winconf (current-window-configuration)))
4171 (set-buffer gnus-article-buffer)
4172 (gnus-article-edit-mode)
4173 (funcall start-func)
4174 (gnus-configure-windows 'edit-article)
4175 (setq gnus-article-edit-done-function exit-func)
4176 (setq gnus-prev-winconf winconf)
4177 (gnus-message 6 "C-c C-c to end edits")))
4179 (defun gnus-article-edit-done (&optional arg)
4180 "Update the article edits and exit."
4185 (when (article-goto-body)
4186 (let ((lines (count-lines (point) (point-max)))
4187 (length (- (point-max) (point)))
4188 (case-fold-search t)
4189 (body (copy-marker (point))))
4190 (goto-char (point-min))
4191 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
4192 (delete-region (match-beginning 1) (match-end 1))
4193 (insert (number-to-string length)))
4194 (goto-char (point-min))
4195 (when (re-search-forward
4196 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
4197 (delete-region (match-beginning 1) (match-end 1))
4198 (insert (number-to-string length)))
4199 (goto-char (point-min))
4200 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
4201 (delete-region (match-beginning 1) (match-end 1))
4202 (insert (number-to-string lines)))))))
4203 (let ((func gnus-article-edit-done-function)
4204 (buf (current-buffer))
4205 (start (window-start)))
4206 (gnus-article-edit-exit)
4209 (let ((buffer-read-only nil))
4211 ;; The cache and backlog have to be flushed somewhat.
4212 (when gnus-keep-backlog
4213 (gnus-backlog-remove-article
4214 (car gnus-article-current) (cdr gnus-article-current)))
4215 ;; Flush original article as well.
4217 (when (get-buffer gnus-original-article-buffer)
4218 (set-buffer gnus-original-article-buffer)
4219 (setq gnus-original-article nil)))
4220 (when gnus-use-cache
4221 (gnus-cache-update-article
4222 (car gnus-article-current) (cdr gnus-article-current))))
4224 (set-window-start (get-buffer-window buf) start)
4225 (set-window-point (get-buffer-window buf) (point))))
4227 (defun gnus-article-edit-exit ()
4228 "Exit the article editing without updating."
4230 ;; We remove all text props from the article buffer.
4231 (let ((buf (buffer-substring-no-properties (point-min) (point-max)))
4232 (curbuf (current-buffer))
4234 (window-start (window-start)))
4237 (let ((winconf gnus-prev-winconf))
4239 (set-window-configuration winconf)
4240 ;; Tippy-toe some to make sure that point remains where it was.
4241 (save-current-buffer
4243 (set-window-start (get-buffer-window (current-buffer)) window-start)
4246 (defun gnus-article-edit-full-stops ()
4247 "Interactively repair spacing at end of sentences."
4250 (goto-char (point-min))
4251 (search-forward-regexp "^$" nil t)
4252 (let ((case-fold-search nil))
4253 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
4256 ;;; Article highlights
4259 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
4261 ;;; Internal Variables:
4263 (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\\)\\)"
4264 "Regular expression that matches URLs."
4265 :group 'gnus-article-buttons
4268 (defcustom gnus-button-alist
4269 `(("<\\(url:[>\n\t ]*?\\)?news:[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
4270 0 t gnus-button-message-id 2)
4271 ("\\bnews:\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t gnus-button-message-id 1)
4272 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
4274 gnus-button-fetch-group 4)
4275 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
4276 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
4277 t gnus-button-message-id 3)
4278 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
4279 ("mailto:\\([-a-zA-Z.@_+0-9%]+\\)" 0 t gnus-url-mailto 1)
4280 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
4281 ;; This is how URLs _should_ be embedded in text...
4282 ("<URL: *\\([^<>]*\\)>" 0 t gnus-button-embedded-url 1)
4284 (,gnus-button-url-regexp 0 t browse-url 0))
4285 "*Alist of regexps matching buttons in article bodies.
4287 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
4288 REGEXP: is the string matching text around the button,
4289 BUTTON: is the number of the regexp grouping actually matching the button,
4290 FORM: is a lisp expression which must eval to true for the button to
4292 CALLBACK: is the function to call when the user push this button, and each
4293 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
4295 CALLBACK can also be a variable, in that case the value of that
4296 variable it the real callback function."
4297 :group 'gnus-article-buttons
4298 :type '(repeat (list regexp
4299 (integer :tag "Button")
4301 (function :tag "Callback")
4304 (integer :tag "Regexp group")))))
4306 (defcustom gnus-header-button-alist
4307 `(("^\\(References\\|Message-I[Dd]\\):" "<[^>]+>"
4308 0 t gnus-button-message-id 0)
4309 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
4310 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
4311 0 t gnus-button-mailto 0)
4312 ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t browse-url 0)
4313 ("^Subject:" ,gnus-button-url-regexp 0 t browse-url 0)
4314 ("^[^:]+:" ,gnus-button-url-regexp 0 t browse-url 0)
4315 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
4316 gnus-button-message-id 3))
4317 "*Alist of headers and regexps to match buttons in article heads.
4319 This alist is very similar to `gnus-button-alist', except that each
4320 alist has an additional HEADER element first in each entry:
4322 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
4324 HEADER is a regexp to match a header. For a fuller explanation, see
4325 `gnus-button-alist'."
4326 :group 'gnus-article-buttons
4327 :group 'gnus-article-headers
4328 :type '(repeat (list (regexp :tag "Header")
4330 (integer :tag "Button")
4332 (function :tag "Callback")
4335 (integer :tag "Regexp group")))))
4337 (defvar gnus-button-regexp nil)
4338 (defvar gnus-button-marker-list nil)
4339 ;; Regexp matching any of the regexps from `gnus-button-alist'.
4341 (defvar gnus-button-last nil)
4342 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
4346 (defun gnus-article-push-button (event)
4347 "Check text under the mouse pointer for a callback function.
4348 If the text under the mouse pointer has a `gnus-callback' property,
4349 call it with the value of the `gnus-data' text property."
4351 (set-buffer (window-buffer (posn-window (event-start event))))
4352 (let* ((pos (posn-point (event-start event)))
4353 (data (get-text-property pos 'gnus-data))
4354 (fun (get-text-property pos 'gnus-callback)))
4357 (funcall fun data))))
4359 (defun gnus-article-press-button ()
4360 "Check text at point for a callback function.
4361 If the text at point has a `gnus-callback' property,
4362 call it with the value of the `gnus-data' text property."
4364 (let* ((data (get-text-property (point) 'gnus-data))
4365 (fun (get-text-property (point) 'gnus-callback)))
4367 (funcall fun data))))
4369 (defun gnus-article-highlight (&optional force)
4370 "Highlight current article.
4371 This function calls `gnus-article-highlight-headers',
4372 `gnus-article-highlight-citation',
4373 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
4374 do the highlighting. See the documentation for those functions."
4375 (interactive (list 'force))
4376 (gnus-article-highlight-headers)
4377 (gnus-article-highlight-citation force)
4378 (gnus-article-highlight-signature)
4379 (gnus-article-add-buttons force)
4380 (gnus-article-add-buttons-to-head))
4382 (defun gnus-article-highlight-some (&optional force)
4383 "Highlight current article.
4384 This function calls `gnus-article-highlight-headers',
4385 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
4386 do the highlighting. See the documentation for those functions."
4387 (interactive (list 'force))
4388 (gnus-article-highlight-headers)
4389 (gnus-article-highlight-signature)
4390 (gnus-article-add-buttons))
4392 (defun gnus-article-highlight-headers ()
4393 "Highlight article headers as specified by `gnus-header-face-alist'."
4396 (set-buffer gnus-article-buffer)
4398 (let ((alist gnus-header-face-alist)
4399 (buffer-read-only nil)
4400 (case-fold-search t)
4401 (inhibit-point-motion-hooks t)
4402 entry regexp header-face field-face from hpoints fpoints)
4403 (article-narrow-to-head)
4404 (while (setq entry (pop alist))
4405 (goto-char (point-min))
4406 (setq regexp (concat "^\\("
4407 (if (string-equal "" (nth 0 entry))
4411 header-face (nth 1 entry)
4412 field-face (nth 2 entry))
4413 (while (and (re-search-forward regexp nil t)
4417 (unless (search-forward ":" nil t)
4419 (when (and header-face
4420 (not (memq (point) hpoints)))
4421 (push (point) hpoints)
4422 (gnus-put-text-property from (point) 'face header-face))
4423 (when (and field-face
4424 (not (memq (setq from (point)) fpoints)))
4426 (if (re-search-forward "^[^ \t]" nil t)
4428 (goto-char (point-max)))
4429 (gnus-put-text-property from (point) 'face field-face))))))))
4431 (defun gnus-article-highlight-signature ()
4432 "Highlight the signature in an article.
4433 It does this by highlighting everything after
4434 `gnus-signature-separator' using `gnus-signature-face'."
4437 (set-buffer gnus-article-buffer)
4438 (let ((buffer-read-only nil)
4439 (inhibit-point-motion-hooks t))
4441 (when (and gnus-signature-face
4442 (gnus-article-narrow-to-signature))
4443 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
4444 'face gnus-signature-face)
4446 (gnus-article-search-signature)
4447 (let ((start (match-beginning 0))
4448 (end (set-marker (make-marker) (1+ (match-end 0)))))
4449 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
4452 (defun gnus-button-in-region-p (b e prop)
4453 "Say whether PROP exists in the region."
4454 (text-property-not-all b e prop nil))
4456 (defun gnus-article-add-buttons (&optional force)
4457 "Find external references in the article and make buttons of them.
4458 \"External references\" are things like Message-IDs and URLs, as
4459 specified by `gnus-button-alist'."
4460 (interactive (list 'force))
4462 (set-buffer gnus-article-buffer)
4463 (let ((buffer-read-only nil)
4464 (inhibit-point-motion-hooks t)
4465 (case-fold-search t)
4466 (alist gnus-button-alist)
4468 ;; Remove all old markers.
4469 (let (marker entry new-list)
4470 (while (setq marker (pop gnus-button-marker-list))
4471 (if (or (< marker (point-min)) (>= marker (point-max)))
4472 (push marker new-list)
4474 (when (setq entry (gnus-button-entry))
4475 (put-text-property (match-beginning (nth 1 entry))
4476 (match-end (nth 1 entry))
4477 'gnus-callback nil))
4478 (set-marker marker nil)))
4479 (setq gnus-button-marker-list new-list))
4480 ;; We skip the headers.
4483 (while (setq entry (pop alist))
4484 (setq regexp (car entry))
4486 (while (re-search-forward regexp nil t)
4487 (let* ((start (and entry (match-beginning (nth 1 entry))))
4488 (end (and entry (match-end (nth 1 entry))))
4489 (from (match-beginning 0)))
4490 (when (and (or (eq t (nth 2 entry))
4491 (eval (nth 2 entry)))
4492 (not (gnus-button-in-region-p
4493 start end 'gnus-callback)))
4494 ;; That optional form returned non-nil, so we add the
4496 (gnus-article-add-button
4497 start end 'gnus-button-push
4498 (car (push (set-marker (make-marker) from)
4499 gnus-button-marker-list))))))))))
4501 ;; Add buttons to the head of an article.
4502 (defun gnus-article-add-buttons-to-head ()
4503 "Add buttons to the head of the article."
4506 (set-buffer gnus-article-buffer)
4508 (let ((buffer-read-only nil)
4509 (inhibit-point-motion-hooks t)
4510 (case-fold-search t)
4511 (alist gnus-header-button-alist)
4513 (article-narrow-to-head)
4515 ;; Each alist entry.
4516 (setq entry (car alist)
4518 (goto-char (point-min))
4519 (while (re-search-forward (car entry) nil t)
4520 ;; Each header matching the entry.
4521 (setq beg (match-beginning 0))
4522 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
4523 (match-beginning 0))
4526 (while (re-search-forward (nth 1 entry) end t)
4527 ;; Each match within a header.
4528 (let* ((entry (cdr entry))
4529 (start (match-beginning (nth 1 entry)))
4530 (end (match-end (nth 1 entry)))
4531 (form (nth 2 entry)))
4532 (goto-char (match-end 0))
4534 (gnus-article-add-button
4535 start end (nth 3 entry)
4536 (buffer-substring (match-beginning (nth 4 entry))
4537 (match-end (nth 4 entry)))))))
4538 (goto-char end)))))))
4540 ;;; External functions:
4542 (defun gnus-article-add-button (from to fun &optional data)
4543 "Create a button between FROM and TO with callback FUN and data DATA."
4544 (when gnus-article-button-face
4545 (gnus-overlay-put (gnus-make-overlay from to)
4546 'face gnus-article-button-face))
4547 (gnus-add-text-properties
4549 (nconc (and gnus-article-mouse-face
4550 (list gnus-mouse-face-prop gnus-article-mouse-face))
4551 (list 'gnus-callback fun)
4552 (and data (list 'gnus-data data))))
4553 (widget-convert-button 'link from to :action 'gnus-widget-press-button
4554 :button-keymap gnus-widget-button-keymap))
4556 ;;; Internal functions:
4558 (defun gnus-article-set-globals ()
4560 (set-buffer gnus-summary-buffer)
4561 (gnus-set-global-variables)))
4563 (defun gnus-signature-toggle (end)
4565 (set-buffer gnus-article-buffer)
4566 (let ((buffer-read-only nil)
4567 (inhibit-point-motion-hooks t))
4568 (if (text-property-any end (point-max) 'article-type 'signature)
4569 (gnus-remove-text-properties-when
4570 'article-type 'signature end (point-max)
4571 (cons 'article-type (cons 'signature
4572 gnus-hidden-properties)))
4573 (gnus-add-text-properties-when
4574 'article-type nil end (point-max)
4575 (cons 'article-type (cons 'signature
4576 gnus-hidden-properties)))))))
4578 (defun gnus-button-entry ()
4579 ;; Return the first entry in `gnus-button-alist' matching this place.
4580 (let ((alist gnus-button-alist)
4583 (setq entry (pop alist))
4584 (if (looking-at (car entry))
4589 (defun gnus-button-push (marker)
4590 ;; Push button starting at MARKER.
4593 (let* ((entry (gnus-button-entry))
4594 (inhibit-point-motion-hooks t)
4596 (args (mapcar (lambda (group)
4597 (let ((string (match-string group)))
4598 (gnus-set-text-properties
4599 0 (length string) nil string)
4606 (fboundp (symbol-value fun)))
4607 (apply (symbol-value fun) args))
4609 (gnus-message 1 "You must define `%S' to use this button"
4610 (cons fun args)))))))
4612 (defun gnus-button-message-id (message-id)
4615 (set-buffer gnus-summary-buffer)
4616 (gnus-summary-refer-article message-id)))
4618 (defun gnus-button-fetch-group (address)
4619 "Fetch GROUP specified by ADDRESS."
4620 (if (not (string-match "[:/]" address))
4621 ;; This is just a simple group url.
4622 (gnus-group-read-ephemeral-group address gnus-select-method)
4623 (if (not (string-match "^\\([^:/]+\\)\\(:\\([^/]+\\)/\\)?\\(.*\\)$"
4625 (error "Can't parse %s" address)
4626 (gnus-group-read-ephemeral-group
4627 (match-string 4 address)
4628 `(nntp ,(match-string 1 address)
4629 (nntp-address ,(match-string 1 address))
4630 (nntp-port-number ,(if (match-end 3)
4631 (match-string 3 address)
4634 (defun gnus-url-parse-query-string (query &optional downcase)
4635 (let (retval pairs cur key val)
4636 (setq pairs (split-string query "&"))
4638 (setq cur (car pairs)
4640 (if (not (string-match "=" cur))
4642 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
4643 val (gnus-url-unhex-string (substring cur (match-end 0) nil)))
4645 (setq key (downcase key)))
4646 (setq cur (assoc key retval))
4648 (setcdr cur (cons val (cdr cur)))
4649 (setq retval (cons (list key val) retval)))))
4652 (defun gnus-url-unhex (x)
4659 (defun gnus-url-unhex-string (str &optional allow-newlines)
4660 "Remove %XXX embedded spaces, etc in a url.
4661 If optional second argument ALLOW-NEWLINES is non-nil, then allow the
4662 decoding of carriage returns and line feeds in the string, which is normally
4663 forbidden in URL encoding."
4664 (setq str (or str ""))
4666 (case-fold-search t))
4667 (while (string-match "%[0-9a-f][0-9a-f]" str)
4668 (let* ((start (match-beginning 0))
4669 (ch1 (gnus-url-unhex (elt str (+ start 1))))
4671 (gnus-url-unhex (elt str (+ start 2))))))
4673 tmp (substring str 0 start)
4676 (char-to-string code))
4677 ((or (= code ?\n) (= code ?\r))
4679 (t (char-to-string code))))
4680 str (substring str (match-end 0)))))
4681 (setq tmp (concat tmp str))
4684 (defun gnus-url-mailto (url)
4685 ;; Send mail to someone
4686 (when (string-match "mailto:/*\\(.*\\)" url)
4687 (setq url (substring url (match-beginning 1) nil)))
4688 (let (to args subject func)
4689 (if (string-match (regexp-quote "?") url)
4690 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
4691 args (gnus-url-parse-query-string
4692 (substring url (match-end 0) nil) t))
4693 (setq to (gnus-url-unhex-string url)))
4694 (setq args (cons (list "to" to) args)
4695 subject (cdr-safe (assoc "subject" args)))
4698 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
4701 (message-position-on-field (caar args)))
4702 (insert (mapconcat 'identity (cdar args) ", "))
4703 (setq args (cdr args)))
4706 (message-goto-subject))))
4708 (defun gnus-button-mailto (address)
4710 (set-buffer (gnus-copy-article-buffer))
4711 (message-reply address))
4713 (defalias 'gnus-button-reply 'message-reply)
4715 (defun gnus-button-embedded-url (address)
4716 "Activate ADDRESS with `browse-url'."
4717 (browse-url (gnus-strip-whitespace address)))
4719 ;;; Next/prev buttons in the article buffer.
4721 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
4722 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
4724 (defvar gnus-prev-page-map nil)
4725 (unless gnus-prev-page-map
4726 (setq gnus-prev-page-map (make-sparse-keymap))
4727 (define-key gnus-prev-page-map gnus-mouse-2 'gnus-button-prev-page)
4728 (define-key gnus-prev-page-map "\r" 'gnus-button-prev-page))
4730 (defun gnus-insert-prev-page-button ()
4731 (let ((buffer-read-only nil))
4733 gnus-prev-page-line-format nil
4734 `(gnus-prev t local-map ,gnus-prev-page-map
4735 gnus-callback gnus-article-button-prev-page
4736 article-type annotation))))
4738 (defvar gnus-next-page-map nil)
4739 (unless gnus-next-page-map
4740 (setq gnus-next-page-map (make-keymap))
4741 (suppress-keymap gnus-prev-page-map)
4742 (define-key gnus-next-page-map gnus-mouse-2 'gnus-button-next-page)
4743 (define-key gnus-next-page-map "\r" 'gnus-button-next-page))
4745 (defun gnus-button-next-page ()
4746 "Go to the next page."
4748 (let ((win (selected-window)))
4749 (select-window (get-buffer-window gnus-article-buffer t))
4750 (gnus-article-next-page)
4751 (select-window win)))
4753 (defun gnus-button-prev-page ()
4754 "Go to the prev page."
4756 (let ((win (selected-window)))
4757 (select-window (get-buffer-window gnus-article-buffer t))
4758 (gnus-article-prev-page)
4759 (select-window win)))
4761 (defun gnus-insert-next-page-button ()
4762 (let ((buffer-read-only nil))
4763 (gnus-eval-format gnus-next-page-line-format nil
4765 t local-map ,gnus-next-page-map
4766 gnus-callback gnus-article-button-next-page
4767 article-type annotation))))
4769 (defun gnus-article-button-next-page (arg)
4770 "Go to the next page."
4772 (let ((win (selected-window)))
4773 (select-window (get-buffer-window gnus-article-buffer t))
4774 (gnus-article-next-page)
4775 (select-window win)))
4777 (defun gnus-article-button-prev-page (arg)
4778 "Go to the prev page."
4780 (let ((win (selected-window)))
4781 (select-window (get-buffer-window gnus-article-buffer t))
4782 (gnus-article-prev-page)
4783 (select-window win)))
4785 (defvar gnus-decode-header-methods
4786 '(mail-decode-encoded-word-region)
4787 "List of methods used to decode headers.
4789 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
4790 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
4791 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
4792 whose names match REGEXP.
4795 ((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
4796 mail-decode-encoded-word-region
4797 (\"chinese\" . rfc1843-decode-region))
4800 (defvar gnus-decode-header-methods-cache nil)
4802 (defun gnus-multi-decode-header (start end)
4803 "Apply the functions from `gnus-encoded-word-methods' that match."
4804 (unless (and gnus-decode-header-methods-cache
4805 (eq gnus-newsgroup-name
4806 (car gnus-decode-header-methods-cache)))
4807 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
4810 (nconc gnus-decode-header-methods-cache (list x))
4811 (if (and gnus-newsgroup-name
4812 (string-match (car x) gnus-newsgroup-name))
4813 (nconc gnus-decode-header-methods-cache
4815 gnus-decode-header-methods))
4816 (let ((xlist gnus-decode-header-methods-cache))
4819 (narrow-to-region start end)
4821 (funcall (pop xlist) (point-min) (point-max))))))
4824 ;;; Treatment top-level handling.
4827 (defun gnus-treat-article (condition &optional part-number total-parts type)
4828 (let ((length (- (point-max) (point-min)))
4829 (alist gnus-treatment-function-alist)
4830 (article-goto-body-goes-to-point-min-p t)
4834 (let ((list gnus-article-treat-types))
4836 (when (string-match (pop list) type)
4837 (throw 'found t)))))))
4838 (highlightp (gnus-visual-p 'article-highlight 'highlight))
4840 (gnus-run-hooks 'gnus-part-display-hook)
4841 (while (setq elem (pop alist))
4844 (if (gnus-buffer-live-p gnus-summary-buffer)
4845 (set-buffer gnus-summary-buffer))
4846 (symbol-value (car elem))))
4847 (when (and (or (consp val)
4849 (gnus-treat-predicate val)
4850 (or (not (get (car elem) 'highlight))
4853 (funcall (cadr elem)))))))
4855 ;; Dynamic variables.
4857 (defvar part-number)
4858 (defvar total-parts)
4863 (defun gnus-treat-predicate (val)
4868 (stringp (car val)))
4869 (apply 'gnus-or (mapcar `(lambda (s)
4870 (string-match s ,(or gnus-newsgroup-name "")))
4873 (let ((pred (pop val)))
4876 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
4878 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
4880 (not (gnus-treat-predicate (car val))))
4882 (equal (car val) type))
4884 (error "%S is not a valid predicate" pred)))))
4892 (eq part-number total-parts))
4896 (error "%S is not a valid value" val))))
4902 (run-hooks 'gnus-art-load-hook)
4904 ;;; gnus-art.el ends here