1 ;;; gnus-art.el --- article mode commands for Gnus
2 ;; Copyright (C) 1996,97,98,99 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))
43 (defgroup gnus-article nil
45 :link '(custom-manual "(gnus)The Article Buffer")
48 (defgroup gnus-article-treat nil
49 "Treating article parts."
50 :link '(custom-manual "(gnus)Article Hiding")
53 (defgroup gnus-article-hiding nil
54 "Hiding article parts."
55 :link '(custom-manual "(gnus)Article Hiding")
58 (defgroup gnus-article-highlight nil
59 "Article highlighting."
60 :link '(custom-manual "(gnus)Article Highlighting")
64 (defgroup gnus-article-signature nil
66 :link '(custom-manual "(gnus)Article Signature")
69 (defgroup gnus-article-headers nil
71 :link '(custom-manual "(gnus)Hiding Headers")
74 (defgroup gnus-article-washing nil
75 "Special commands on articles."
76 :link '(custom-manual "(gnus)Article Washing")
79 (defgroup gnus-article-emphasis nil
80 "Fontisizing articles."
81 :link '(custom-manual "(gnus)Article Fontisizing")
84 (defgroup gnus-article-saving nil
86 :link '(custom-manual "(gnus)Saving Articles")
89 (defgroup gnus-article-mime nil
90 "Worshiping the MIME wonder."
91 :link '(custom-manual "(gnus)Using MIME")
94 (defgroup gnus-article-buttons nil
95 "Pushable buttons in the article buffer."
96 :link '(custom-manual "(gnus)Article Buttons")
99 (defgroup gnus-article-various nil
100 "Other article options."
101 :link '(custom-manual "(gnus)Misc Article")
102 :group 'gnus-article)
104 (defcustom gnus-ignored-headers
105 '("^Path:" "^Expires:" "^Date-Received:" "^References:" "^Xref:" "^Lines:"
106 "^Relay-Version:" "^Message-ID:" "^Approved:" "^Sender:" "^Received:"
107 "^X-UIDL:" "^MIME-Version:" "^Return-Path:" "^In-Reply-To:"
108 "^Content-Type:" "^Content-Transfer-Encoding:" "^X-WebTV-Signature:"
109 "^X-MimeOLE:" "^X-MSMail-Priority:" "^X-Priority:" "^X-Loop:"
110 "^X-Authentication-Warning:" "^X-MIME-Autoconverted:" "^X-Face:"
111 "^X-Attribution:" "^X-Originating-IP:" "^Delivered-To:"
112 "^NNTP-[-A-Za-z]+:" "^Distribution:" "^X-no-archive:" "^X-Trace:"
113 "^X-Complaints-To:" "^X-NNTP-Posting-Host:" "^X-Orig.*:"
114 "^Abuse-Reports-To:" "^Cache-Post-Path:" "^X-Article-Creation-Date:"
115 "^X-Poster:" "^X-Mail2News-Path:" "^X-Server-Date:" "^X-Cache:"
116 "^Originator:" "^X-Problems-To:" "^X-Auth-User:" "^X-Post-Time:"
117 "^X-Admin:" "^X-UID:" "^Resent-[-A-Za-z]+:" "^X-Mailing-List:"
118 "^Precedence:" "^Original-[-A-Za-z]+:" "^X-filename:" "^X-Orcpt:"
119 "^Old-Received:" "^X-Pgp-Fingerprint:" "^X-Pgp-Key-Id:"
120 "^X-Pgp-Public-Key-Url:" "^X-Auth:" "^X-From-Line:"
121 "^X-Gnus-Article-Number:" "^X-Majordomo:" "^X-Url:" "^X-Sender:"
122 "^X-Mailing-List:" "^MBOX-Line" "^Priority:" "^X-Pgp" "^X400-[-A-Za-z]+:"
123 "^Status:" "^X-Gnus-Mail-Source:" "^Cancel-Lock:")
124 "*All headers that start with this regexp will be hidden.
125 This variable can also be a list of regexps of headers to be ignored.
126 If `gnus-visible-headers' is non-nil, this variable will be ignored."
127 :type '(choice :custom-show nil
130 :group 'gnus-article-hiding)
132 (defcustom gnus-visible-headers
133 "^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:"
134 "*All headers that do not match this regexp will be hidden.
135 This variable can also be a list of regexp of headers to remain visible.
136 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
137 :type '(repeat :value-to-internal (lambda (widget value)
138 (custom-split-regexp-maybe value))
139 :match (lambda (widget value)
141 (widget-editable-list-match widget value)))
143 :group 'gnus-article-hiding)
145 (defcustom gnus-sorted-header-list
146 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
147 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
148 "*This variable is a list of regular expressions.
149 If it is non-nil, headers that match the regular expressions will
150 be placed first in the article buffer in the sequence specified by
152 :type '(repeat regexp)
153 :group 'gnus-article-hiding)
155 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
156 "Headers that are only to be displayed if they have interesting data.
157 Possible values in this list are `empty', `newsgroups', `followup-to',
158 `reply-to', `date', `long-to', and `many-to'."
159 :type '(set (const :tag "Headers with no content." empty)
160 (const :tag "Newsgroups with only one group." newsgroups)
161 (const :tag "Followup-to identical to newsgroups." followup-to)
162 (const :tag "Reply-to identical to from." reply-to)
163 (const :tag "Date less than four days old." date)
164 (const :tag "Very long To header." long-to)
165 (const :tag "Multiple To headers." many-to))
166 :group 'gnus-article-hiding)
168 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
169 "Regexp matching signature separator.
170 This can also be a list of regexps. In that case, it will be checked
171 from head to tail looking for a separator. Searches will be done from
172 the end of the buffer."
173 :type '(repeat string)
174 :group 'gnus-article-signature)
176 (defcustom gnus-signature-limit nil
177 "Provide a limit to what is considered a signature.
178 If it is a number, no signature may not be longer (in characters) than
179 that number. If it is a floating point number, no signature may be
180 longer (in lines) than that number. If it is a function, the function
181 will be called without any parameters, and if it returns nil, there is
182 no signature in the buffer. If it is a string, it will be used as a
183 regexp. If it matches, the text in question is not a signature."
184 :type '(choice (integer :value 200)
186 (function :value fun)
187 (regexp :value ".*"))
188 :group 'gnus-article-signature)
190 (defcustom gnus-hidden-properties '(invisible t intangible t)
191 "Property list to use for hiding text."
193 :group 'gnus-article-hiding)
195 (defcustom gnus-article-x-face-command
196 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | display -"
197 "*String or function to be executed to display an X-Face header.
198 If it is a string, the command will be executed in a sub-shell
199 asynchronously. The compressed face will be piped to this command."
200 :type 'string ;Leave function case to Lisp.
201 :group 'gnus-article-washing)
203 (defcustom gnus-article-x-face-too-ugly nil
204 "Regexp matching posters whose face shouldn't be shown automatically."
205 :type '(choice regexp (const nil))
206 :group 'gnus-article-washing)
208 (defcustom gnus-emphasis-alist
210 "\\(\\s-\\|^\\|[-\"]\\|\\s(\\|\\s)\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\s-\\|[-?!.,;:\"]\\|\\s(\\|\\s)\\)")
212 '(("_" "_" underline)
215 ("_/" "/_" underline-italic)
216 ("_\\*" "\\*_" underline-bold)
217 ("\\*/" "/\\*" bold-italic)
218 ("_\\*/" "/\\*_" underline-bold-italic))))
219 `(("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
220 2 3 gnus-emphasis-underline)
224 (format format (car spec) (cadr spec))
225 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
227 "*Alist that says how to fontify certain phrases.
228 Each item looks like this:
230 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
232 The first element is a regular expression to be matched. The second
233 is a number that says what regular expression grouping used to find
234 the entire emphasized word. The third is a number that says what
235 regexp grouping should be displayed and highlighted. The fourth
236 is the face used for highlighting."
237 :type '(repeat (list :value ("" 0 0 default)
239 (integer :tag "Match group")
240 (integer :tag "Emphasize group")
242 :group 'gnus-article-emphasis)
244 (defface gnus-emphasis-bold '((t (:bold t)))
245 "Face used for displaying strong emphasized text (*word*)."
246 :group 'gnus-article-emphasis)
248 (defface gnus-emphasis-italic '((t (:italic t)))
249 "Face used for displaying italic emphasized text (/word/)."
250 :group 'gnus-article-emphasis)
252 (defface gnus-emphasis-underline '((t (:underline t)))
253 "Face used for displaying underlined emphasized text (_word_)."
254 :group 'gnus-article-emphasis)
256 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
257 "Face used for displaying underlined bold emphasized text (_*word*_)."
258 :group 'gnus-article-emphasis)
260 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
261 "Face used for displaying underlined italic emphasized text (_*word*_)."
262 :group 'gnus-article-emphasis)
264 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
265 "Face used for displaying bold italic emphasized text (/*word*/)."
266 :group 'gnus-article-emphasis)
268 (defface gnus-emphasis-underline-bold-italic
269 '((t (:bold t :italic t :underline t)))
270 "Face used for displaying underlined bold italic emphasized text.
271 Esample: (_/*word*/_)."
272 :group 'gnus-article-emphasis)
274 (defface gnus-emphasis-highlight-words
275 '((t (:background "black" :foreground "yellow")))
276 "Face used for displaying highlighted words."
277 :group 'gnus-article-emphasis)
279 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
280 "Format for display of Date headers in article bodies.
281 See `format-time-string' for the possible values.
283 The variable can also be function, which should return a complete Date
284 header. The function is called with one argument, the time, which can
285 be fed to `format-time-string'."
286 :type '(choice string symbol)
287 :link '(custom-manual "(gnus)Article Date")
288 :group 'gnus-article-washing)
291 (autoload 'mail-extract-address-components "mail-extr"))
293 (defcustom gnus-save-all-headers t
294 "*If non-nil, don't remove any headers before saving."
295 :group 'gnus-article-saving
298 (defcustom gnus-prompt-before-saving 'always
299 "*This variable says how much prompting is to be done when saving articles.
300 If it is nil, no prompting will be done, and the articles will be
301 saved to the default files. If this variable is `always', each and
302 every article that is saved will be preceded by a prompt, even when
303 saving large batches of articles. If this variable is neither nil not
304 `always', there the user will be prompted once for a file name for
305 each invocation of the saving commands."
306 :group 'gnus-article-saving
307 :type '(choice (item always)
308 (item :tag "never" nil)
309 (sexp :tag "once" :format "%t\n" :value t)))
311 (defcustom gnus-saved-headers gnus-visible-headers
312 "Headers to keep if `gnus-save-all-headers' is nil.
313 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
314 If that variable is nil, however, all headers that match this regexp
315 will be kept while the rest will be deleted before saving."
316 :group 'gnus-article-saving
319 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
320 "A function to save articles in your favourite format.
321 The function must be interactively callable (in other words, it must
322 be an Emacs command).
324 Gnus provides the following functions:
326 * gnus-summary-save-in-rmail (Rmail format)
327 * gnus-summary-save-in-mail (Unix mail format)
328 * gnus-summary-save-in-folder (MH folder)
329 * gnus-summary-save-in-file (article format)
330 * gnus-summary-save-in-vm (use VM's folder format)
331 * gnus-summary-write-to-file (article format -- overwrite)."
332 :group 'gnus-article-saving
333 :type '(radio (function-item gnus-summary-save-in-rmail)
334 (function-item gnus-summary-save-in-mail)
335 (function-item gnus-summary-save-in-folder)
336 (function-item gnus-summary-save-in-file)
337 (function-item gnus-summary-save-in-vm)
338 (function-item gnus-summary-write-to-file)))
340 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
341 "A function generating a file name to save articles in Rmail format.
342 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
343 :group 'gnus-article-saving
346 (defcustom gnus-mail-save-name 'gnus-plain-save-name
347 "A function generating a file name to save articles in Unix mail format.
348 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
349 :group 'gnus-article-saving
352 (defcustom gnus-folder-save-name 'gnus-folder-save-name
353 "A function generating a file name to save articles in MH folder.
354 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
355 :group 'gnus-article-saving
358 (defcustom gnus-file-save-name 'gnus-numeric-save-name
359 "A function generating a file name to save articles in article format.
360 The function is called with NEWSGROUP, HEADERS, and optional
362 :group 'gnus-article-saving
365 (defcustom gnus-split-methods
366 '((gnus-article-archive-name)
367 (gnus-article-nndoc-name))
368 "*Variable used to suggest where articles are to be saved.
369 For instance, if you would like to save articles related to Gnus in
370 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
371 you could set this variable to something like:
373 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
374 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
376 This variable is an alist where the where the key is the match and the
377 value is a list of possible files to save in if the match is non-nil.
379 If the match is a string, it is used as a regexp match on the
380 article. If the match is a symbol, that symbol will be funcalled
381 from the buffer of the article to be saved with the newsgroup as the
382 parameter. If it is a list, it will be evaled in the same buffer.
384 If this form or function returns a string, this string will be used as
385 a possible file name; and if it returns a non-nil list, that list will
386 be used as possible file names."
387 :group 'gnus-article-saving
388 :type '(repeat (choice (list :value (fun) function)
389 (cons :value ("" "") regexp (repeat string))
392 (defcustom gnus-page-delimiter "^\^L"
393 "*Regexp describing what to use as article page delimiters.
394 The default value is \"^\^L\", which is a form linefeed at the
395 beginning of a line."
397 :group 'gnus-article-various)
399 (defcustom gnus-article-mode-line-format "Gnus: %g %S%m"
400 "*The format specification for the article mode line.
401 See `gnus-summary-mode-line-format' for a closer description.
403 The following additional specs are available:
405 %w The article washing status.
406 %m The number of MIME parts in the article."
408 :group 'gnus-article-various)
410 (defcustom gnus-article-mode-hook nil
411 "*A hook for Gnus article mode."
413 :group 'gnus-article-various)
415 (defcustom gnus-article-menu-hook nil
416 "*Hook run after the creation of the article mode menu."
418 :group 'gnus-article-various)
420 (defcustom gnus-article-prepare-hook nil
421 "*A hook called after an article has been prepared in the article buffer."
423 :group 'gnus-article-various)
425 (defcustom gnus-article-hide-pgp-hook nil
426 "*A hook called after successfully hiding a PGP signature."
428 :group 'gnus-article-various)
430 (defcustom gnus-article-button-face 'bold
431 "Face used for highlighting buttons in the article buffer.
433 An article button is a piece of text that you can activate by pressing
434 `RET' or `mouse-2' above it."
436 :group 'gnus-article-buttons)
438 (defcustom gnus-article-mouse-face 'highlight
439 "Face used for mouse highlighting in the article buffer.
441 Article buttons will be displayed in this face when the cursor is
444 :group 'gnus-article-buttons)
446 (defcustom gnus-signature-face 'gnus-signature-face
447 "Face used for highlighting a signature in the article buffer.
448 Obsolete; use the face `gnus-signature-face' for customizations instead."
450 :group 'gnus-article-highlight
451 :group 'gnus-article-signature)
453 (defface gnus-signature-face
456 "Face used for highlighting a signature in the article buffer."
457 :group 'gnus-article-highlight
458 :group 'gnus-article-signature)
460 (defface gnus-header-from-face
463 (:foreground "spring green"))
466 (:foreground "red3"))
469 "Face used for displaying from headers."
470 :group 'gnus-article-headers
471 :group 'gnus-article-highlight)
473 (defface gnus-header-subject-face
476 (:foreground "SeaGreen3"))
479 (:foreground "red4"))
481 (:bold t :italic t)))
482 "Face used for displaying subject headers."
483 :group 'gnus-article-headers
484 :group 'gnus-article-highlight)
486 (defface gnus-header-newsgroups-face
489 (:foreground "yellow" :italic t))
492 (:foreground "MidnightBlue" :italic t))
495 "Face used for displaying newsgroups headers."
496 :group 'gnus-article-headers
497 :group 'gnus-article-highlight)
499 (defface gnus-header-name-face
502 (:foreground "SeaGreen"))
505 (:foreground "maroon"))
508 "Face used for displaying header names."
509 :group 'gnus-article-headers
510 :group 'gnus-article-highlight)
512 (defface gnus-header-content-face
515 (:foreground "forest green" :italic t))
518 (:foreground "indianred4" :italic t))
520 (:italic t))) "Face used for displaying header content."
521 :group 'gnus-article-headers
522 :group 'gnus-article-highlight)
524 (defcustom gnus-header-face-alist
525 '(("From" nil gnus-header-from-face)
526 ("Subject" nil gnus-header-subject-face)
527 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
528 ("" gnus-header-name-face gnus-header-content-face))
529 "*Controls highlighting of article header.
531 An alist of the form (HEADER NAME CONTENT).
533 HEADER is a regular expression which should match the name of an
534 header header and NAME and CONTENT are either face names or nil.
536 The name of each header field will be displayed using the face
537 specified by the first element in the list where HEADER match the
538 header name and NAME is non-nil. Similarly, the content will be
539 displayed by the first non-nil matching CONTENT face."
540 :group 'gnus-article-headers
541 :group 'gnus-article-highlight
542 :type '(repeat (list (regexp :tag "Header")
544 (item :tag "skip" nil)
545 (face :value default))
546 (choice :tag "Content"
547 (item :tag "skip" nil)
548 (face :value default)))))
550 (defcustom gnus-article-decode-hook
551 '(article-decode-charset article-decode-encoded-words)
552 "*Hook run to decode charsets in articles."
553 :group 'gnus-article-headers
556 (defcustom gnus-display-mime-function 'gnus-display-mime
557 "Function to display MIME articles."
558 :group 'gnus-article-mime
561 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
562 "Function used to decode headers.")
564 (defvar gnus-article-dumbquotes-map
582 "Table for MS-to-Latin1 translation.")
584 (defcustom gnus-ignored-mime-types nil
585 "List of MIME types that should be ignored by Gnus."
586 :group 'gnus-article-mime
587 :type '(repeat regexp))
589 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
590 "List of MIME types that should not be given buttons when rendered."
591 :group 'gnus-article-mime
592 :type '(repeat regexp))
594 (defcustom gnus-article-mime-part-function nil
595 "Function called with a MIME handle as the argument.
596 This is meant for people who want to do something automatic based
597 on parts -- for instance, adding Vcard info to a database."
598 :group 'gnus-article-mime
601 (defcustom gnus-mime-multipart-functions nil
602 "An alist of MIME types to functions to display them.")
604 (defcustom gnus-article-date-lapsed-new-header nil
605 "Whether the X-Sent and Date headers can coexist.
606 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
607 either replace the old \"Date:\" header (if this variable is nil), or
608 be added below it (otherwise)."
609 :group 'gnus-article-headers
613 ;;; The treatment variables
616 (defvar gnus-part-display-hook nil
617 "Hook called on parts that are to receive treatment.")
619 (defvar gnus-article-treat-custom
620 '(choice (const :tag "Off" nil)
622 (const :tag "Header" head)
623 (const :tag "Last" last)
624 (integer :tag "Less")
625 (repeat :tag "Groups" regexp)
626 (sexp :tag "Predicate")))
628 (defvar gnus-article-treat-head-custom
629 '(choice (const :tag "Off" nil)
630 (const :tag "Header" head)))
632 (defvar gnus-article-treat-types '("text/plain")
635 (defvar gnus-inhibit-treatment nil
636 "Whether to inhibit treatment.")
638 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
639 "Highlight the signature.
640 Valid values are nil, t, `head', `last', an integer or a predicate.
641 See the manual for details."
642 :group 'gnus-article-treat
643 :type gnus-article-treat-custom)
644 (put 'gnus-treat-highlight-signature 'highlight t)
646 (defcustom gnus-treat-buttonize t
648 Valid values are nil, t, `head', `last', an integer or a predicate.
649 See the manual for details."
650 :group 'gnus-article-treat
651 :type gnus-article-treat-custom)
652 (put 'gnus-treat-buttonize 'highlight t)
654 (defcustom gnus-treat-buttonize-head 'head
655 "Add buttons to the head.
656 Valid values are nil, t, `head', `last', an integer or a predicate.
657 See the manual for details."
658 :group 'gnus-article-treat
659 :type gnus-article-treat-head-custom)
660 (put 'gnus-treat-buttonize-head 'highlight t)
662 (defcustom gnus-treat-emphasize t
664 Valid values are nil, t, `head', `last', an integer or a predicate.
665 See the manual for details."
666 :group 'gnus-article-treat
667 :type gnus-article-treat-custom)
668 (put 'gnus-treat-emphasize 'highlight t)
670 (defcustom gnus-treat-strip-cr nil
671 "Remove carriage returns.
672 Valid values are nil, t, `head', `last', an integer or a predicate.
673 See the manual for details."
674 :group 'gnus-article-treat
675 :type gnus-article-treat-custom)
677 (defcustom gnus-treat-hide-headers 'head
679 Valid values are nil, t, `head', `last', an integer or a predicate.
680 See the manual for details."
681 :group 'gnus-article-treat
682 :type gnus-article-treat-head-custom)
684 (defcustom gnus-treat-hide-boring-headers nil
685 "Hide boring headers.
686 Valid values are nil, t, `head', `last', an integer or a predicate.
687 See the manual for details."
688 :group 'gnus-article-treat
689 :type gnus-article-treat-head-custom)
691 (defcustom gnus-treat-hide-signature nil
693 Valid values are nil, t, `head', `last', an integer or a predicate.
694 See the manual for details."
695 :group 'gnus-article-treat
696 :type gnus-article-treat-custom)
698 (defcustom gnus-treat-fill-article nil
700 Valid values are nil, t, `head', `last', an integer or a predicate.
701 See the manual for details."
702 :group 'gnus-article-treat
703 :type gnus-article-treat-custom)
705 (defcustom gnus-treat-hide-citation nil
707 Valid values are nil, t, `head', `last', an integer or a predicate.
708 See the manual for details."
709 :group 'gnus-article-treat
710 :type gnus-article-treat-custom)
712 (defcustom gnus-treat-strip-pgp t
713 "Strip PGP signatures.
714 Valid values are nil, t, `head', `last', an integer or a predicate.
715 See the manual for details."
716 :group 'gnus-article-treat
717 :type gnus-article-treat-custom)
719 (defcustom gnus-treat-strip-pem nil
720 "Strip PEM signatures.
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)
726 (defcustom gnus-treat-strip-banner t
727 "Strip banners from articles.
728 The banner to be stripped is specified in the `banner' group parameter.
729 Valid values are nil, t, `head', `last', an integer or a predicate.
730 See the manual for details."
731 :group 'gnus-article-treat
732 :type gnus-article-treat-custom)
734 (defcustom gnus-treat-highlight-headers 'head
735 "Highlight the headers.
736 Valid values are nil, t, `head', `last', an integer or a predicate.
737 See the manual for details."
738 :group 'gnus-article-treat
739 :type gnus-article-treat-head-custom)
740 (put 'gnus-treat-highlight-headers 'highlight t)
742 (defcustom gnus-treat-highlight-citation t
743 "Highlight cited text.
744 Valid values are nil, t, `head', `last', an integer or a predicate.
745 See the manual for details."
746 :group 'gnus-article-treat
747 :type gnus-article-treat-custom)
748 (put 'gnus-treat-highlight-citation 'highlight t)
750 (defcustom gnus-treat-date-ut nil
751 "Display the Date in UT (GMT).
752 Valid values are nil, t, `head', `last', an integer or a predicate.
753 See the manual for details."
754 :group 'gnus-article-treat
755 :type gnus-article-treat-head-custom)
757 (defcustom gnus-treat-date-local nil
758 "Display the Date in the local timezone.
759 Valid values are nil, t, `head', `last', an integer or a predicate.
760 See the manual for details."
761 :group 'gnus-article-treat
762 :type gnus-article-treat-head-custom)
764 (defcustom gnus-treat-date-lapsed nil
765 "Display the Date header in a way that says how much time has elapsed.
766 Valid values are nil, t, `head', `last', an integer or a predicate.
767 See the manual for details."
768 :group 'gnus-article-treat
769 :type gnus-article-treat-head-custom)
771 (defcustom gnus-treat-date-original nil
772 "Display the date in the original timezone.
773 Valid values are nil, t, `head', `last', an integer or a predicate.
774 See the manual for details."
775 :group 'gnus-article-treat
776 :type gnus-article-treat-head-custom)
778 (defcustom gnus-treat-date-iso8601 nil
779 "Display the date in the ISO8601 format.
780 Valid values are nil, t, `head', `last', an integer or a predicate.
781 See the manual for details."
782 :group 'gnus-article-treat
783 :type gnus-article-treat-head-custom)
785 (defcustom gnus-treat-date-user-defined nil
786 "Display the date in a user-defined format.
787 The format is defined by the `gnus-article-time-format' variable.
788 Valid values are nil, t, `head', `last', an integer or a predicate.
789 See the manual for details."
790 :group 'gnus-article-treat
791 :type gnus-article-treat-head-custom)
793 (defcustom gnus-treat-strip-headers-in-body t
794 "Strip the X-No-Archive header line from the beginning of the body.
795 Valid values are nil, t, `head', `last', an integer or a predicate.
796 See the manual for details."
797 :group 'gnus-article-treat
798 :type gnus-article-treat-custom)
800 (defcustom gnus-treat-strip-trailing-blank-lines nil
801 "Strip trailing blank lines.
802 Valid values are nil, t, `head', `last', an integer or a predicate.
803 See the manual for details."
804 :group 'gnus-article-treat
805 :type gnus-article-treat-custom)
807 (defcustom gnus-treat-strip-leading-blank-lines nil
808 "Strip leading blank lines.
809 Valid values are nil, t, `head', `last', an integer or a predicate.
810 See the manual for details."
811 :group 'gnus-article-treat
812 :type gnus-article-treat-custom)
814 (defcustom gnus-treat-strip-multiple-blank-lines nil
815 "Strip multiple blank lines.
816 Valid values are nil, t, `head', `last', an integer or a predicate.
817 See the manual for details."
818 :group 'gnus-article-treat
819 :type gnus-article-treat-custom)
821 (defcustom gnus-treat-strip-blank-lines nil
822 "Strip all blank lines.
823 Valid values are nil, t, `head', `last', an integer or a predicate.
824 See the manual for details."
825 :group 'gnus-article-treat
826 :type gnus-article-treat-custom)
828 (defcustom gnus-treat-overstrike t
829 "Treat overstrike highlighting.
830 Valid values are nil, t, `head', `last', an integer or a predicate.
831 See the manual for details."
832 :group 'gnus-article-treat
833 :type gnus-article-treat-custom)
834 (put 'gnus-treat-overstrike 'highlight t)
836 (defcustom gnus-treat-display-xface (if (and gnus-xemacs (featurep 'xface))
838 "Display X-Face headers.
839 Valid values are nil, t, `head', `last', an integer or a predicate.
840 See the manual for details."
841 :group 'gnus-article-treat
842 :type gnus-article-treat-head-custom)
843 (put 'gnus-treat-display-xface 'highlight t)
845 (defcustom gnus-treat-display-smileys (if (and gnus-xemacs
849 Valid values are nil, t, `head', `last', an integer or a predicate.
850 See the manual for details."
851 :group 'gnus-article-treat
852 :type gnus-article-treat-custom)
853 (put 'gnus-treat-display-smileys 'highlight t)
855 (defcustom gnus-treat-display-picons (if gnus-xemacs 'head nil)
857 Valid values are nil, t, `head', `last', an integer or a predicate.
858 See the manual for details."
859 :group 'gnus-article-treat
860 :type gnus-article-treat-head-custom)
861 (put 'gnus-treat-display-picons 'highlight t)
863 (defcustom gnus-treat-capitalize-sentences nil
864 "Capitalize sentence-starting words.
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-custom)
870 (defcustom gnus-treat-fill-long-lines nil
872 Valid values are nil, t, `head', `last', an integer or a predicate.
873 See the manual for details."
874 :group 'gnus-article-treat
875 :type gnus-article-treat-custom)
877 (defcustom gnus-treat-play-sounds nil
879 Valid values are nil, t, `head', `last', an integer or a predicate.
880 See the manual for details."
881 :group 'gnus-article-treat
882 :type gnus-article-treat-custom)
884 (defcustom gnus-treat-translate nil
885 "Translate articles from one language to another.
886 Valid values are nil, t, `head', `last', an integer or a predicate.
887 See the manual for details."
888 :group 'gnus-article-treat
889 :type gnus-article-treat-custom)
891 ;;; Internal variables
893 (defvar article-goto-body-goes-to-point-min-p nil)
894 (defvar gnus-article-wash-types nil)
896 (defvar gnus-article-mime-handle-alist-1 nil)
897 (defvar gnus-treatment-function-alist
898 '((gnus-treat-strip-banner gnus-article-strip-banner)
899 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
900 (gnus-treat-highlight-signature gnus-article-highlight-signature)
901 (gnus-treat-buttonize gnus-article-add-buttons)
902 (gnus-treat-fill-article gnus-article-fill-cited-article)
903 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
904 (gnus-treat-strip-cr gnus-article-remove-cr)
905 (gnus-treat-emphasize gnus-article-emphasize)
906 (gnus-treat-display-xface gnus-article-display-x-face)
907 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
908 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
909 (gnus-treat-hide-signature gnus-article-hide-signature)
910 (gnus-treat-hide-citation gnus-article-hide-citation)
911 (gnus-treat-strip-pgp gnus-article-hide-pgp)
912 (gnus-treat-strip-pem gnus-article-hide-pem)
913 (gnus-treat-highlight-headers gnus-article-highlight-headers)
914 (gnus-treat-highlight-citation gnus-article-highlight-citation)
915 (gnus-treat-highlight-signature gnus-article-highlight-signature)
916 (gnus-treat-date-ut gnus-article-date-ut)
917 (gnus-treat-date-local gnus-article-date-local)
918 (gnus-treat-date-lapsed gnus-article-date-lapsed)
919 (gnus-treat-date-original gnus-article-date-original)
920 (gnus-treat-date-user-defined gnus-article-date-user)
921 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
922 (gnus-treat-strip-trailing-blank-lines
923 gnus-article-remove-trailing-blank-lines)
924 (gnus-treat-strip-leading-blank-lines
925 gnus-article-strip-leading-blank-lines)
926 (gnus-treat-strip-multiple-blank-lines
927 gnus-article-strip-multiple-blank-lines)
928 (gnus-treat-strip-blank-lines gnus-article-strip-blank-lines)
929 (gnus-treat-overstrike gnus-article-treat-overstrike)
930 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
931 (gnus-treat-display-smileys gnus-smiley-display)
932 (gnus-treat-display-picons gnus-article-display-picons)
933 (gnus-treat-play-sounds gnus-earcon-display)))
935 (defvar gnus-article-mime-handle-alist nil)
936 (defvar article-lapsed-timer nil)
937 (defvar gnus-article-current-summary nil)
939 (defvar gnus-article-mode-syntax-table
940 (let ((table (copy-syntax-table text-mode-syntax-table)))
941 (modify-syntax-entry ?- "w" table)
942 (modify-syntax-entry ?> ")" table)
943 (modify-syntax-entry ?< "(" table)
945 "Syntax table used in article mode buffers.
946 Initialized from `text-mode-syntax-table.")
948 (defvar gnus-save-article-buffer nil)
950 (defvar gnus-article-mode-line-format-alist
951 (nconc '((?w (gnus-article-wash-status) ?s)
952 (?m (gnus-article-mime-part-status) ?s))
953 gnus-summary-mode-line-format-alist))
955 (defvar gnus-number-of-articles-to-be-saved nil)
957 (defvar gnus-inhibit-hiding nil)
959 (defsubst gnus-article-hide-text (b e props)
960 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
961 (add-text-properties b e props)
962 (when (memq 'intangible props)
964 (max (1- b) (point-min))
965 b 'intangible (cddr (memq 'intangible props)))))
966 (defsubst gnus-article-unhide-text (b e)
967 "Remove hidden text properties from region between B and E."
968 (remove-text-properties b e gnus-hidden-properties)
969 (when (memq 'intangible gnus-hidden-properties)
970 (put-text-property (max (1- b) (point-min))
973 (defun gnus-article-hide-text-type (b e type)
974 "Hide text of TYPE between B and E."
975 (push type gnus-article-wash-types)
976 (gnus-article-hide-text
977 b e (cons 'article-type (cons type gnus-hidden-properties))))
979 (defun gnus-article-unhide-text-type (b e type)
980 "Unhide text of TYPE between B and E."
981 (setq gnus-article-wash-types
982 (delq type gnus-article-wash-types))
983 (remove-text-properties
984 b e (cons 'article-type (cons type gnus-hidden-properties)))
985 (when (memq 'intangible gnus-hidden-properties)
986 (put-text-property (max (1- b) (point-min))
989 (defun gnus-article-hide-text-of-type (type)
990 "Hide text of TYPE in the current buffer."
992 (let ((b (point-min))
994 (while (setq b (text-property-any b e 'article-type type))
995 (add-text-properties b (incf b) gnus-hidden-properties)))))
997 (defun gnus-article-delete-text-of-type (type)
998 "Delete text of TYPE in the current buffer."
1000 (let ((b (point-min)))
1001 (while (setq b (text-property-any b (point-max) 'article-type type))
1003 b (or (text-property-not-all b (point-max) 'article-type type)
1006 (defun gnus-article-delete-invisible-text ()
1007 "Delete all invisible text in the current buffer."
1009 (let ((b (point-min)))
1010 (while (setq b (text-property-any b (point-max) 'invisible t))
1012 b (or (text-property-not-all b (point-max) 'invisible t)
1015 (defun gnus-article-text-type-exists-p (type)
1016 "Say whether any text of type TYPE exists in the buffer."
1017 (text-property-any (point-min) (point-max) 'article-type type))
1019 (defsubst gnus-article-header-rank ()
1020 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1021 (let ((list gnus-sorted-header-list)
1024 (when (looking-at (car list))
1026 (setq list (cdr list))
1030 (defun article-hide-headers (&optional arg delete)
1031 "Hide unwanted headers and possibly sort them as well."
1033 ;; This function might be inhibited.
1034 (unless gnus-inhibit-hiding
1037 (let ((buffer-read-only nil)
1038 (case-fold-search t)
1039 (max (1+ (length gnus-sorted-header-list)))
1040 (ignored (when (not gnus-visible-headers)
1041 (cond ((stringp gnus-ignored-headers)
1042 gnus-ignored-headers)
1043 ((listp gnus-ignored-headers)
1044 (mapconcat 'identity gnus-ignored-headers
1047 (cond ((stringp gnus-visible-headers)
1048 gnus-visible-headers)
1049 ((and gnus-visible-headers
1050 (listp gnus-visible-headers))
1051 (mapconcat 'identity gnus-visible-headers "\\|"))))
1052 (inhibit-point-motion-hooks t)
1054 ;; First we narrow to just the headers.
1055 (article-narrow-to-head)
1056 ;; Hide any "From " lines at the beginning of (mail) articles.
1057 (while (looking-at "From ")
1060 (delete-region (point-min) (point)))
1061 ;; Then treat the rest of the header lines.
1062 ;; Then we use the two regular expressions
1063 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1064 ;; select which header lines is to remain visible in the
1066 (while (re-search-forward "^[^ \t]*:" nil t)
1068 ;; Mark the rank of the header.
1070 (point) (1+ (point)) 'message-rank
1071 (if (or (and visible (looking-at visible))
1073 (not (looking-at ignored))))
1074 (gnus-article-header-rank)
1077 (message-sort-headers-1)
1078 (when (setq beg (text-property-any
1079 (point-min) (point-max) 'message-rank (+ 2 max)))
1080 ;; We delete the unwanted headers.
1081 (add-text-properties (point-min) (+ 5 (point-min))
1082 '(article-type headers dummy-invisible t))
1083 (delete-region beg (point-max))))))))
1085 (defun article-hide-boring-headers (&optional arg)
1086 "Toggle hiding of headers that aren't very interesting.
1087 If given a negative prefix, always show; if given a positive prefix,
1089 (interactive (gnus-article-hidden-arg))
1090 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1091 (not gnus-show-all-headers))
1094 (let ((buffer-read-only nil)
1095 (list gnus-boring-article-headers)
1096 (inhibit-point-motion-hooks t)
1098 (article-narrow-to-head)
1100 (setq elem (pop list))
1101 (goto-char (point-min))
1103 ;; Hide empty headers.
1105 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1107 (gnus-article-hide-text-type
1108 (progn (beginning-of-line) (point))
1111 (if (re-search-forward "^[^ \t]" nil t)
1115 ;; Hide boring Newsgroups header.
1116 ((eq elem 'newsgroups)
1117 (when (equal (gnus-fetch-field "newsgroups")
1118 (gnus-group-real-name
1119 (if (boundp 'gnus-newsgroup-name)
1122 (gnus-article-hide-header "newsgroups")))
1123 ((eq elem 'followup-to)
1124 (when (equal (message-fetch-field "followup-to")
1125 (message-fetch-field "newsgroups"))
1126 (gnus-article-hide-header "followup-to")))
1127 ((eq elem 'reply-to)
1128 (let ((from (message-fetch-field "from"))
1129 (reply-to (message-fetch-field "reply-to")))
1134 (nth 1 (mail-extract-address-components from))
1135 (nth 1 (mail-extract-address-components reply-to)))))
1136 (gnus-article-hide-header "reply-to"))))
1138 (let ((date (message-fetch-field "date")))
1140 (< (days-between (current-time-string) date)
1142 (gnus-article-hide-header "date"))))
1144 (let ((to (message-fetch-field "to")))
1145 (when (> (length to) 1024)
1146 (gnus-article-hide-header "to"))))
1149 (goto-char (point-min))
1150 (while (re-search-forward "^to:" nil t)
1151 (setq to-count (1+ to-count)))
1152 (when (> to-count 1)
1153 (while (> to-count 0)
1154 (goto-char (point-min))
1156 (re-search-forward "^to:" nil nil to-count)
1158 (narrow-to-region (point) (point-max))
1159 (gnus-article-hide-header "to"))
1160 (setq to-count (1- to-count)))))))))))))
1162 (defun gnus-article-hide-header (header)
1164 (goto-char (point-min))
1165 (when (re-search-forward (concat "^" header ":") nil t)
1166 (gnus-article-hide-text-type
1167 (progn (beginning-of-line) (point))
1170 (if (re-search-forward "^[^ \t]" nil t)
1175 (defvar gnus-article-normalized-header-length 40
1176 "Length of normalized headers.")
1178 (defun article-normalize-headers ()
1179 "Make all header lines 40 characters long."
1181 (let ((buffer-read-only nil)
1185 (article-narrow-to-head)
1188 ((< (setq column (- (gnus-point-at-eol) (point)))
1189 gnus-article-normalized-header-length)
1191 (insert (make-string
1192 (- gnus-article-normalized-header-length column)
1194 ((> column gnus-article-normalized-header-length)
1195 (gnus-put-text-property
1197 (forward-char gnus-article-normalized-header-length)
1204 (forward-line 1))))))
1206 (defun article-treat-dumbquotes ()
1207 "Translate M******** sm*rtq**t*s into proper text.
1208 Note that this function guesses whether a character is a sm*rtq**t* or
1209 not, so it should only be used interactively."
1211 (article-translate-strings gnus-article-dumbquotes-map))
1213 (defun article-translate-characters (from to)
1214 "Translate all characters in the body of the article according to FROM and TO.
1215 FROM is a string of characters to translate from; to is a string of
1216 characters to translate to."
1218 (when (article-goto-body)
1219 (let ((buffer-read-only nil)
1220 (x (make-string 225 ?x))
1222 (while (< (incf i) (length x))
1225 (while (< i (length from))
1226 (aset x (aref from i) (aref to i))
1228 (translate-region (point) (point-max) x)))))
1230 (defun article-translate-strings (map)
1231 "Translate all string in the body of the article according to MAP.
1232 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1234 (when (article-goto-body)
1235 (let ((buffer-read-only nil)
1237 (while (setq elem (pop map))
1239 (while (search-forward (car elem) nil t)
1240 (replace-match (cadr elem)))))))))
1242 (defun article-treat-overstrike ()
1243 "Translate overstrikes into bold text."
1246 (when (article-goto-body)
1247 (let ((buffer-read-only nil))
1248 (while (search-forward "\b" nil t)
1249 (let ((next (char-after))
1250 (previous (char-after (- (point) 2))))
1251 ;; We do the boldification/underlining by hiding the
1252 ;; overstrikes and putting the proper text property
1256 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1257 (put-text-property (point) (1+ (point)) 'face 'bold))
1259 (gnus-article-hide-text-type
1260 (1- (point)) (1+ (point)) 'overstrike)
1262 (- (point) 2) (1- (point)) 'face 'underline))
1264 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1266 (point) (1+ (point)) 'face 'underline)))))))))
1268 (defun article-fill-long-lines ()
1269 "Fill lines that are wider than the window width."
1272 (let ((buffer-read-only nil)
1273 (width (window-width (get-buffer-window (current-buffer)))))
1276 (let ((adaptive-fill-mode nil))
1279 (when (>= (current-column) (min fill-column width))
1280 (narrow-to-region (point) (gnus-point-at-bol))
1281 (fill-paragraph nil)
1282 (goto-char (point-max))
1284 (forward-line 1)))))))
1286 (defun article-capitalize-sentences ()
1287 "Capitalize the first word in each sentence."
1290 (let ((buffer-read-only nil)
1291 (paragraph-start "^[\n\^L]"))
1295 (forward-sentence)))))
1297 (defun article-remove-cr ()
1298 "Remove trailing CRs and then translate remaining CRs into LFs."
1301 (let ((buffer-read-only nil))
1302 (goto-char (point-min))
1303 (while (re-search-forward "\r+$" nil t)
1304 (replace-match "" t t))
1305 (goto-char (point-min))
1306 (while (search-forward "\r" nil t)
1307 (replace-match "\n" t t)))))
1309 (defun article-remove-trailing-blank-lines ()
1310 "Remove all trailing blank lines from the article."
1313 (let ((buffer-read-only nil))
1314 (goto-char (point-max))
1318 (while (and (not (bobp))
1319 (looking-at "^[ \t]*$")
1320 (not (gnus-annotation-in-region-p
1321 (point) (gnus-point-at-eol))))
1326 (defun article-display-x-face (&optional force)
1327 "Look for an X-Face header and display it if present."
1328 (interactive (list 'force))
1330 ;; Delete the old process, if any.
1331 (when (process-status "article-x-face")
1332 (delete-process "article-x-face"))
1333 (let ((inhibit-point-motion-hooks t)
1334 (case-fold-search t)
1337 (article-narrow-to-head)
1338 (goto-char (point-min))
1339 (setq from (message-fetch-field "from"))
1340 (goto-char (point-min))
1341 (while (and gnus-article-x-face-command
1344 ;; Check whether this face is censored.
1345 (not gnus-article-x-face-too-ugly)
1346 (and gnus-article-x-face-too-ugly from
1347 (not (string-match gnus-article-x-face-too-ugly
1349 ;; Has to be present.
1350 (re-search-forward "^X-Face: " nil t))
1351 ;; This used to try to do multiple faces (`while' instead of
1352 ;; `when' above), but (a) sending multiple EOFs to xv doesn't
1353 ;; work (b) it can crash some versions of Emacs (c) are
1354 ;; multiple faces really something to encourage?
1355 (when (stringp gnus-article-x-face-command)
1357 ;; We now have the area of the buffer where the X-Face is stored.
1360 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
1361 ;; We display the face.
1362 (if (symbolp gnus-article-x-face-command)
1363 ;; The command is a lisp function, so we call it.
1364 (if (gnus-functionp gnus-article-x-face-command)
1365 (funcall gnus-article-x-face-command beg end)
1366 (error "%s is not a function" gnus-article-x-face-command))
1367 ;; The command is a string, so we interpret the command
1368 ;; as a, well, command, and fork it off.
1369 (let ((process-connection-type nil))
1370 (process-kill-without-query
1372 "article-x-face" nil shell-file-name shell-command-switch
1373 gnus-article-x-face-command))
1374 (process-send-region "article-x-face" beg end)
1375 (process-send-eof "article-x-face"))))))))))
1377 (defun article-decode-mime-words ()
1378 "Decode all MIME-encoded words in the article."
1381 (set-buffer gnus-article-buffer)
1382 (let ((inhibit-point-motion-hooks t)
1384 (mail-parse-charset gnus-newsgroup-charset))
1385 (mail-decode-encoded-word-region (point-min) (point-max)))))
1387 (defun article-decode-charset (&optional prompt)
1388 "Decode charset-encoded text in the article.
1389 If PROMPT (the prefix), prompt for a coding system to use."
1393 (article-narrow-to-head)
1394 (let* ((inhibit-point-motion-hooks t)
1395 (case-fold-search t)
1396 (ct (message-fetch-field "Content-Type" t))
1397 (cte (message-fetch-field "Content-Transfer-Encoding" t))
1398 (ctl (and ct (ignore-errors
1399 (mail-header-parse-content-type ct))))
1402 (mm-read-coding-system "Charset to decode: "))
1404 (mail-content-type-get ctl 'charset))))
1405 (mail-parse-charset gnus-newsgroup-charset)
1407 (when (memq charset gnus-newsgroup-ignored-charsets)
1409 (goto-char (point-max))
1412 (narrow-to-region (point) (point-max))
1413 (when (and (or (not ctl)
1414 (equal (car ctl) "text/plain"))
1417 charset (and cte (intern (downcase
1418 (gnus-strip-whitespace cte))))
1421 (defun article-decode-encoded-words ()
1422 "Remove encoded-word encoding from headers."
1423 (let ((inhibit-point-motion-hooks t)
1424 (mail-parse-charset gnus-newsgroup-charset)
1427 (article-narrow-to-head)
1428 (funcall gnus-decode-header-function (point-min) (point-max)))))
1430 (defun article-de-quoted-unreadable (&optional force)
1431 "Translate a quoted-printable-encoded article.
1432 If FORCE, decode the article whether it is marked as quoted-printable
1434 (interactive (list 'force))
1436 (let ((buffer-read-only nil)
1437 (type (gnus-fetch-field "content-transfer-encoding"))
1438 (charset gnus-newsgroup-charset))
1440 (and type (string-match "quoted-printable" (downcase type))))
1443 (narrow-to-region (point) (point-max))
1444 (quoted-printable-decode-region (point-min) (point-max))
1446 (mm-decode-body charset)))))))
1448 (defun article-hide-pgp ()
1449 "Remove any PGP headers and signatures in the current article."
1453 (let ((inhibit-point-motion-hooks t)
1454 buffer-read-only beg end)
1456 ;; Hide the "header".
1457 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
1458 (push 'pgp gnus-article-wash-types)
1459 (delete-region (match-beginning 0) (match-end 0))
1460 ;; PGP 5 and GNU PG add a `Hash: <>' comment, hide that too
1461 (when (looking-at "Hash:.*$")
1462 (delete-region (point) (1+ (gnus-point-at-eol))))
1464 ;; Hide the actual signature.
1465 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
1466 (setq end (1+ (match-beginning 0)))
1469 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
1471 ;; Perhaps we shouldn't hide to the end of the buffer
1472 ;; if there is no end to the signature?
1474 ;; Hide "- " PGP quotation markers.
1476 (narrow-to-region beg end)
1477 (goto-char (point-min))
1478 (while (re-search-forward "^- " nil t)
1480 (match-beginning 0) (match-end 0)))
1482 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
1484 (defun article-hide-pem (&optional arg)
1485 "Toggle hiding of any PEM headers and signatures in the current article.
1486 If given a negative prefix, always show; if given a positive prefix,
1488 (interactive (gnus-article-hidden-arg))
1489 (unless (gnus-article-check-hidden-text 'pem arg)
1491 (let (buffer-read-only end)
1492 (goto-char (point-min))
1493 ;; Hide the horrendously ugly "header".
1494 (when (and (search-forward
1495 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
1497 (setq end (1+ (match-beginning 0))))
1498 (push 'pem gnus-article-wash-types)
1499 (gnus-article-hide-text-type
1501 (if (search-forward "\n\n" nil t)
1505 ;; Hide the trailer as well
1506 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
1508 (gnus-article-hide-text-type
1509 (match-beginning 0) (match-end 0) 'pem)))))))
1511 (defun article-strip-banner ()
1512 "Strip the banner specified by the `banner' group parameter."
1516 (let ((inhibit-point-motion-hooks t)
1517 (banner (gnus-group-get-parameter gnus-newsgroup-name 'banner))
1518 (gnus-signature-limit nil)
1519 buffer-read-only beg end)
1523 ((eq banner 'signature)
1524 (when (gnus-article-narrow-to-signature)
1527 (delete-region (point) (point-max))))
1529 (while (re-search-forward banner nil t)
1530 (delete-region (match-beginning 0) (match-end 0))))))))))
1532 (defun article-babel-prompt ()
1533 "Prompt for a babel translation."
1535 (completing-read "Translate from: "
1536 babel-translations nil t
1537 (car (car babel-translations))
1540 (defun article-babel (translation)
1541 "Translate article according to TRANSLATION using babelfish."
1542 (interactive (list (article-babel-prompt)))
1545 (set-buffer gnus-article-buffer)
1546 (when (article-goto-body)
1547 (let* ((buffer-read-only nil)
1550 (msg (buffer-substring start end)))
1552 (narrow-to-region start end)
1553 (delete-region start end)
1554 (babel-fetch msg (cdr (assoc translation babel-translations)))
1556 (narrow-to-region start (point-max))
1559 (defun article-hide-signature (&optional arg)
1560 "Hide the signature in the current article.
1561 If given a negative prefix, always show; if given a positive prefix,
1563 (interactive (gnus-article-hidden-arg))
1564 (unless (gnus-article-check-hidden-text 'signature arg)
1567 (let ((buffer-read-only nil))
1568 (when (gnus-article-narrow-to-signature)
1569 (gnus-article-hide-text-type
1570 (point-min) (point-max) 'signature)))))))
1572 (defun article-strip-headers-in-body ()
1573 "Strip offensive headers from bodies."
1577 (let ((case-fold-search t))
1578 (when (looking-at "x-no-archive:")
1579 (gnus-delete-line)))))
1581 (defun article-strip-leading-blank-lines ()
1582 "Remove all blank lines from the beginning of the article."
1585 (let ((inhibit-point-motion-hooks t)
1587 (when (article-goto-body)
1588 (while (and (not (eobp))
1589 (looking-at "[ \t]*$"))
1590 (gnus-delete-line))))))
1592 (defun article-narrow-to-head ()
1593 "Narrow the buffer to the head of the message.
1594 Point is left at the beginning of the narrowed-to region."
1596 (goto-char (point-min))
1597 (if (search-forward "\n\n" nil 1)
1600 (goto-char (point-min)))
1602 (defun article-goto-body ()
1603 "Place point at the start of the body."
1604 (goto-char (point-min))
1606 ;; This variable is only bound when dealing with separate
1608 (article-goto-body-goes-to-point-min-p
1610 ((search-forward "\n\n" nil t)
1613 (goto-char (point-max))
1616 (defun article-strip-multiple-blank-lines ()
1617 "Replace consecutive blank lines with one empty line."
1620 (let ((inhibit-point-motion-hooks t)
1622 ;; First make all blank lines empty.
1624 (while (re-search-forward "^[ \t]+$" nil t)
1625 (unless (gnus-annotation-in-region-p
1626 (match-beginning 0) (match-end 0))
1627 (replace-match "" nil t)))
1628 ;; Then replace multiple empty lines with a single empty line.
1630 (while (re-search-forward "\n\n\n+" nil t)
1631 (unless (gnus-annotation-in-region-p
1632 (match-beginning 0) (match-end 0))
1633 (replace-match "\n\n" t t))))))
1635 (defun article-strip-leading-space ()
1636 "Remove all white space from the beginning of the lines in the article."
1639 (let ((inhibit-point-motion-hooks t)
1642 (while (re-search-forward "^[ \t]+" nil t)
1643 (replace-match "" t t)))))
1645 (defun article-strip-trailing-space ()
1646 "Remove all white space from the end of the lines in the article."
1649 (let ((inhibit-point-motion-hooks t)
1652 (while (re-search-forward "[ \t]+$" nil t)
1653 (replace-match "" t t)))))
1655 (defun article-strip-blank-lines ()
1656 "Strip leading, trailing and multiple blank lines."
1658 (article-strip-leading-blank-lines)
1659 (article-remove-trailing-blank-lines)
1660 (article-strip-multiple-blank-lines))
1662 (defun article-strip-all-blank-lines ()
1663 "Strip all blank lines."
1666 (let ((inhibit-point-motion-hooks t)
1669 (while (re-search-forward "^[ \t]*\n" nil t)
1670 (replace-match "" t t)))))
1672 (defun gnus-article-narrow-to-signature ()
1673 "Narrow to the signature; return t if a signature is found, else nil."
1674 (let ((inhibit-point-motion-hooks t))
1675 (when (gnus-article-search-signature)
1677 ;; Check whether we have some limits to what we consider
1678 ;; to be a signature.
1679 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
1680 (list gnus-signature-limit)))
1682 (while (setq limit (pop limits))
1683 (if (or (and (integerp limit)
1684 (< (- (point-max) (point)) limit))
1686 (< (count-lines (point) (point-max)) limit))
1687 (and (gnus-functionp limit)
1689 (and (stringp limit)
1690 (not (re-search-forward limit nil t))))
1691 () ; This limit did not succeed.
1695 (narrow-to-region (point) (point-max))
1698 (defun gnus-article-search-signature ()
1699 "Search the current buffer for the signature separator.
1700 Put point at the beginning of the signature separator."
1701 (let ((cur (point)))
1702 (goto-char (point-max))
1703 (if (if (stringp gnus-signature-separator)
1704 (re-search-backward gnus-signature-separator nil t)
1705 (let ((seps gnus-signature-separator))
1707 (not (re-search-backward (car seps) nil t)))
1714 (defun gnus-article-hidden-arg ()
1715 "Return the current prefix arg as a number, or 0 if no prefix."
1716 (list (if current-prefix-arg
1717 (prefix-numeric-value current-prefix-arg)
1720 (defun gnus-article-check-hidden-text (type arg)
1721 "Return nil if hiding is necessary.
1722 Arg can be nil or a number. Nil and positive means hide, negative
1723 means show, 0 means toggle."
1726 (let ((hide (gnus-article-hidden-text-p type)))
1732 (gnus-article-show-hidden-text type))
1734 (if (eq hide 'hidden)
1735 (gnus-article-show-hidden-text type)
1738 (defun gnus-article-hidden-text-p (type)
1739 "Say whether the current buffer contains hidden text of type TYPE."
1740 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
1742 (not (get-text-property pos 'invisible))
1743 (not (get-text-property pos 'dummy-invisible)))
1745 (text-property-any (1+ pos) (point-max) 'article-type type)))
1750 (defun gnus-article-show-hidden-text (type &optional hide)
1751 "Show all hidden text of type TYPE.
1752 If HIDE, hide the text instead."
1754 (let ((buffer-read-only nil)
1755 (inhibit-point-motion-hooks t)
1758 (while (setq beg (text-property-any end (point-max) 'article-type type))
1761 (text-property-not-all beg (point-max) 'article-type type)
1764 (gnus-article-hide-text beg end gnus-hidden-properties)
1765 (gnus-article-unhide-text beg end))
1769 (defconst article-time-units
1770 `((year . ,(* 365.25 24 60 60))
1771 (week . ,(* 7 24 60 60))
1772 (day . ,(* 24 60 60))
1776 "Mapping from time units to seconds.")
1778 (defun article-date-ut (&optional type highlight header)
1779 "Convert DATE date to universal time in the current article.
1780 If TYPE is `local', convert to local time; if it is `lapsed', output
1781 how much time has lapsed since DATE. For `lapsed', the value of
1782 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
1783 should replace the \"Date:\" one, or should be added below it."
1784 (interactive (list 'ut t))
1785 (let* ((header (or header
1786 (mail-header-date (save-excursion
1787 (set-buffer gnus-summary-buffer)
1788 gnus-current-headers))
1789 (message-fetch-field "date")
1791 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
1794 ((not gnus-article-date-lapsed-new-header)
1800 (date (if (vectorp header) (mail-header-date header)
1802 (inhibit-point-motion-hooks t)
1805 (when (and date (not (string= date "")))
1808 (article-narrow-to-head)
1809 (when (re-search-forward tdate-regexp nil t)
1810 (setq bface (get-text-property (gnus-point-at-bol) 'face)
1811 eface (get-text-property (1- (gnus-point-at-eol))
1814 (goto-char (point-min))
1815 (let ((buffer-read-only nil))
1816 ;; Delete any old Date headers.
1817 (while (re-search-forward date-regexp nil t)
1819 (delete-region (progn (beginning-of-line) (point))
1820 (progn (end-of-line) (point)))
1821 (delete-region (progn (beginning-of-line) (point))
1822 (progn (forward-line 1) (point))))
1824 (if (re-search-forward tdate-regexp nil t)
1826 (insert (article-make-date-line date type))
1832 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
1833 (put-text-property (match-beginning 1) (1+ (match-end 1))
1835 (put-text-property (match-beginning 2) (match-end 2)
1838 (defun article-make-date-line (date type)
1839 "Return a DATE line of TYPE."
1840 (let ((time (condition-case ()
1844 ;; Convert to the local timezone. We have to slap a
1845 ;; `condition-case' round the calls to the timezone
1846 ;; functions since they aren't particularly resistant to
1849 (let ((tz (car (current-time-zone))))
1850 (format "Date: %s %s%04d" (current-time-string time)
1851 (if (> tz 0) "+" "-") (abs (/ tz 36)))))
1852 ;; Convert to Universal Time.
1855 (current-time-string
1856 (let* ((e (parse-time-string date))
1857 (tm (apply 'encode-time e))
1859 (ls (- (cadr tm) (car (current-time-zone)))))
1860 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
1861 ((> ls 65535) (list (1+ ms) (- ls 65536)))
1864 ;; Get the original date from the article.
1865 ((eq type 'original)
1866 (concat "Date: " (if (string-match "\n+$" date)
1867 (substring date 0 (match-beginning 0))
1869 ;; Let the user define the format.
1871 (if (gnus-functionp gnus-article-time-format)
1872 (funcall gnus-article-time-format time)
1875 (format-time-string gnus-article-time-format time))))
1880 (format-time-string "%Y%m%dT%H%M%S" time)))
1881 ;; Do an X-Sent lapsed format.
1883 ;; If the date is seriously mangled, the timezone functions are
1884 ;; liable to bug out, so we ignore all errors.
1885 (let* ((now (current-time))
1886 (real-time (subtract-time now time))
1887 (real-sec (and real-time
1888 (+ (* (float (car real-time)) 65536)
1890 (sec (and real-time (abs real-sec)))
1900 ;; This is a bit convoluted, but basically we go
1901 ;; through the time units for years, weeks, etc,
1902 ;; and divide things to see whether that results
1903 ;; in positive answers.
1906 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
1907 ;; The (remaining) seconds are too few to
1908 ;; be divided into this time unit.
1910 ;; It's big enough, so we output it.
1911 (setq sec (- sec (* num (cdr unit))))
1913 (concat (if prev ", " "") (int-to-string
1915 " " (symbol-name (car unit))
1916 (if (> num 1) "s" ""))
1918 article-time-units "")
1919 ;; If dates are odd, then it might appear like the
1920 ;; article was sent in the future.
1923 " in the future"))))))
1925 (error "Unknown conversion type: %s" type)))))
1927 (defun article-date-local (&optional highlight)
1928 "Convert the current article date to the local timezone."
1929 (interactive (list t))
1930 (article-date-ut 'local highlight))
1932 (defun article-date-original (&optional highlight)
1933 "Convert the current article date to what it was originally.
1934 This is only useful if you have used some other date conversion
1935 function and want to see what the date was before converting."
1936 (interactive (list t))
1937 (article-date-ut 'original highlight))
1939 (defun article-date-lapsed (&optional highlight)
1940 "Convert the current article date to time lapsed since it was sent."
1941 (interactive (list t))
1942 (article-date-ut 'lapsed highlight))
1944 (defun article-update-date-lapsed ()
1945 "Function to be run from a timer to update the lapsed time line."
1946 (let (deactivate-mark)
1951 (set-buffer (window-buffer w))
1952 (when (eq major-mode 'gnus-article-mode)
1953 (goto-char (point-min))
1954 (when (re-search-forward "^X-Sent:" nil t)
1955 (article-date-lapsed t))))
1958 (defun gnus-start-date-timer (&optional n)
1959 "Start a timer to update the X-Sent header in the article buffers.
1960 The numerical prefix says how frequently (in seconds) the function
1965 (gnus-stop-date-timer)
1966 (setq article-lapsed-timer
1967 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
1969 (defun gnus-stop-date-timer ()
1970 "Stop the X-Sent timer."
1972 (when article-lapsed-timer
1973 (nnheader-cancel-timer article-lapsed-timer)
1974 (setq article-lapsed-timer nil)))
1976 (defun article-date-user (&optional highlight)
1977 "Convert the current article date to the user-defined format.
1978 This format is defined by the `gnus-article-time-format' variable."
1979 (interactive (list t))
1980 (article-date-ut 'user highlight))
1982 (defun article-date-iso8601 (&optional highlight)
1983 "Convert the current article date to ISO8601."
1984 (interactive (list t))
1985 (article-date-ut 'iso8601 highlight))
1987 (defun article-show-all ()
1988 "Show all hidden text in the article buffer."
1991 (let ((buffer-read-only nil))
1992 (gnus-article-unhide-text (point-min) (point-max)))))
1994 (defun article-emphasize (&optional arg)
1995 "Emphasize text according to `gnus-emphasis-alist'."
1996 (interactive (gnus-article-hidden-arg))
1997 (unless (gnus-article-check-hidden-text 'emphasis arg)
1999 (let ((alist (or gnus-newsgroup-emphasis-alist gnus-emphasis-alist))
2000 (buffer-read-only nil)
2001 (props (append '(article-type emphasis)
2002 gnus-hidden-properties))
2003 regexp elem beg invisible visible face)
2006 (while (setq elem (pop alist))
2008 (setq regexp (car elem)
2009 invisible (nth 1 elem)
2010 visible (nth 2 elem)
2012 (while (re-search-forward regexp nil t)
2013 (when (and (match-beginning visible) (match-beginning invisible))
2014 (gnus-article-hide-text
2015 (match-beginning invisible) (match-end invisible) props)
2016 (gnus-article-unhide-text-type
2017 (match-beginning visible) (match-end visible) 'emphasis)
2018 (gnus-put-text-property-excluding-newlines
2019 (match-beginning visible) (match-end visible) 'face face)
2020 (goto-char (match-end invisible)))))))))
2022 (defvar gnus-summary-article-menu)
2023 (defvar gnus-summary-post-menu)
2025 ;;; Saving functions.
2027 (defun gnus-article-save (save-buffer file &optional num)
2028 "Save the currently selected article."
2029 (unless gnus-save-all-headers
2030 ;; Remove headers according to `gnus-saved-headers'.
2031 (let ((gnus-visible-headers
2032 (or gnus-saved-headers gnus-visible-headers))
2033 (gnus-article-buffer save-buffer))
2035 (set-buffer save-buffer)
2036 (article-hide-headers 1 t))))
2037 (save-window-excursion
2038 (if (not gnus-default-article-saver)
2039 (error "No default saver is defined")
2040 ;; !!! Magic! The saving functions all save
2041 ;; `gnus-save-article-buffer' (or so they think), but we
2042 ;; bind that variable to our save-buffer.
2043 (set-buffer gnus-article-buffer)
2044 (let* ((gnus-save-article-buffer save-buffer)
2047 ((not gnus-prompt-before-saving) 'default)
2048 ((eq gnus-prompt-before-saving 'always) nil)
2050 (gnus-number-of-articles-to-be-saved
2051 (when (eq gnus-prompt-before-saving t)
2053 (set-buffer gnus-article-current-summary)
2054 (funcall gnus-default-article-saver filename)))))
2056 (defun gnus-read-save-file-name (prompt &optional filename
2057 function group headers variable)
2059 (funcall function group headers (symbol-value variable)))
2064 ((eq filename 'default)
2070 (let* ((split-name (gnus-get-split-value gnus-split-methods))
2073 (if (and gnus-number-of-articles-to-be-saved
2074 (> gnus-number-of-articles-to-be-saved 1))
2075 (format "these %d articles"
2076 gnus-number-of-articles-to-be-saved)
2079 ;; Let the split methods have their say.
2081 ;; No split name was found.
2084 (concat prompt " (default "
2085 (file-name-nondirectory default-name) ") ")
2086 (file-name-directory default-name)
2088 ;; A single group name is returned.
2089 ((stringp split-name)
2091 (funcall function split-name headers
2092 (symbol-value variable)))
2094 (concat prompt " (default "
2095 (file-name-nondirectory default-name) ") ")
2096 (file-name-directory default-name)
2098 ;; A single split name was found
2099 ((= 1 (length split-name))
2100 (let* ((name (expand-file-name
2101 (car split-name) gnus-article-save-directory))
2102 (dir (cond ((file-directory-p name)
2103 (file-name-as-directory name))
2104 ((file-exists-p name) name)
2105 (t gnus-article-save-directory))))
2107 (concat prompt " (default " name ") ")
2109 ;; A list of splits was found.
2111 (setq split-name (nreverse split-name))
2113 (let ((file-name-history
2114 (nconc split-name file-name-history)))
2118 (concat prompt " (`M-p' for defaults) ")
2119 gnus-article-save-directory
2121 gnus-article-save-directory)))
2122 (car (push result file-name-history)))))))
2123 ;; Create the directory.
2124 (gnus-make-directory (file-name-directory file))
2125 ;; If we have read a directory, we append the default file name.
2126 (when (file-directory-p file)
2127 (setq file (concat (file-name-as-directory file)
2128 (file-name-nondirectory default-name))))
2129 ;; Possibly translate some characters.
2130 (nnheader-translate-file-chars file)))))
2131 (gnus-make-directory (file-name-directory result))
2132 (set variable result)))
2134 (defun gnus-article-archive-name (group)
2135 "Return the first instance of an \"Archive-name\" in the current buffer."
2136 (let ((case-fold-search t))
2137 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
2138 (nnheader-concat gnus-article-save-directory
2139 (match-string 1)))))
2141 (defun gnus-article-nndoc-name (group)
2142 "If GROUP is an nndoc group, return the name of the parent group."
2143 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
2144 (gnus-group-get-parameter group 'save-article-group)))
2146 (defun gnus-summary-save-in-rmail (&optional filename)
2147 "Append this article to Rmail file.
2148 Optional argument FILENAME specifies file name.
2149 Directory to save to is default to `gnus-article-save-directory'."
2150 (setq filename (gnus-read-save-file-name
2151 "Save %s in rmail file:" filename
2152 gnus-rmail-save-name gnus-newsgroup-name
2153 gnus-current-headers 'gnus-newsgroup-last-rmail))
2154 (gnus-eval-in-buffer-window gnus-save-article-buffer
2158 (gnus-output-to-rmail filename))))
2161 (defun gnus-summary-save-in-mail (&optional filename)
2162 "Append this article to Unix mail file.
2163 Optional argument FILENAME specifies file name.
2164 Directory to save to is default to `gnus-article-save-directory'."
2165 (setq filename (gnus-read-save-file-name
2166 "Save %s in Unix mail file:" filename
2167 gnus-mail-save-name gnus-newsgroup-name
2168 gnus-current-headers 'gnus-newsgroup-last-mail))
2169 (gnus-eval-in-buffer-window gnus-save-article-buffer
2173 (if (and (file-readable-p filename)
2174 (mail-file-babyl-p filename))
2175 (rmail-output-to-rmail-file filename t)
2176 (gnus-output-to-mail filename)))))
2179 (defun gnus-summary-save-in-file (&optional filename overwrite)
2180 "Append this article to file.
2181 Optional argument FILENAME specifies file name.
2182 Directory to save to is default to `gnus-article-save-directory'."
2183 (setq filename (gnus-read-save-file-name
2184 "Save %s in file:" filename
2185 gnus-file-save-name gnus-newsgroup-name
2186 gnus-current-headers 'gnus-newsgroup-last-file))
2187 (gnus-eval-in-buffer-window gnus-save-article-buffer
2191 (when (and overwrite
2192 (file-exists-p filename))
2193 (delete-file filename))
2194 (gnus-output-to-file filename))))
2197 (defun gnus-summary-write-to-file (&optional filename)
2198 "Write this article to a file.
2199 Optional argument FILENAME specifies file name.
2200 The directory to save in defaults to `gnus-article-save-directory'."
2201 (gnus-summary-save-in-file nil t))
2203 (defun gnus-summary-save-body-in-file (&optional filename)
2204 "Append this article body to a file.
2205 Optional argument FILENAME specifies file name.
2206 The directory to save in defaults to `gnus-article-save-directory'."
2207 (setq filename (gnus-read-save-file-name
2208 "Save %s body in file:" filename
2209 gnus-file-save-name gnus-newsgroup-name
2210 gnus-current-headers 'gnus-newsgroup-last-file))
2211 (gnus-eval-in-buffer-window gnus-save-article-buffer
2215 (when (article-goto-body)
2216 (narrow-to-region (point) (point-max)))
2217 (gnus-output-to-file filename))))
2220 (defun gnus-summary-save-in-pipe (&optional command)
2221 "Pipe this article to subprocess."
2223 (cond ((and (eq command 'default)
2224 gnus-last-shell-command)
2225 gnus-last-shell-command)
2229 "Shell command on %s: "
2230 (if (and gnus-number-of-articles-to-be-saved
2231 (> gnus-number-of-articles-to-be-saved 1))
2232 (format "these %d articles"
2233 gnus-number-of-articles-to-be-saved)
2235 gnus-last-shell-command))))
2236 (when (string-equal command "")
2237 (setq command gnus-last-shell-command))
2238 (gnus-eval-in-buffer-window gnus-article-buffer
2241 (shell-command-on-region (point-min) (point-max) command nil)))
2242 (setq gnus-last-shell-command command))
2244 ;;; Article file names when saving.
2246 (defun gnus-capitalize-newsgroup (newsgroup)
2247 "Capitalize NEWSGROUP name."
2248 (when (not (zerop (length newsgroup)))
2249 (concat (char-to-string (upcase (aref newsgroup 0)))
2250 (substring newsgroup 1))))
2252 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2253 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2254 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
2255 Otherwise, it is like ~/News/news/group/num."
2258 (concat (if (gnus-use-long-file-name 'not-save)
2259 (gnus-capitalize-newsgroup newsgroup)
2260 (gnus-newsgroup-directory-form newsgroup))
2261 "/" (int-to-string (mail-header-number headers)))
2262 gnus-article-save-directory)))
2264 (string-equal (file-name-directory default)
2265 (file-name-directory last-file))
2266 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2268 (or last-file default))))
2270 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2271 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2272 If variable `gnus-use-long-file-name' is non-nil, it is
2273 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2276 (concat (if (gnus-use-long-file-name 'not-save)
2278 (gnus-newsgroup-directory-form newsgroup))
2279 "/" (int-to-string (mail-header-number headers)))
2280 gnus-article-save-directory)))
2282 (string-equal (file-name-directory default)
2283 (file-name-directory last-file))
2284 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2286 (or last-file default))))
2288 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2289 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2290 If variable `gnus-use-long-file-name' is non-nil, it is
2291 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2294 (if (gnus-use-long-file-name 'not-save)
2295 (gnus-capitalize-newsgroup newsgroup)
2296 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2297 gnus-article-save-directory)))
2299 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2300 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2301 If variable `gnus-use-long-file-name' is non-nil, it is
2302 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2305 (if (gnus-use-long-file-name 'not-save)
2307 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2308 gnus-article-save-directory)))
2315 (setq afunc (car func)
2318 gfunc (intern (format "gnus-%s" func))))
2320 (if (not (fboundp afunc))
2322 `(lambda (&optional interactive &rest args)
2323 ,(documentation afunc t)
2324 (interactive (list t))
2326 (set-buffer gnus-article-buffer)
2328 (call-interactively ',afunc)
2329 (apply ',afunc args))))))))
2330 '(article-hide-headers
2331 article-hide-boring-headers
2332 article-treat-overstrike
2333 article-fill-long-lines
2334 article-capitalize-sentences
2336 article-display-x-face
2337 article-de-quoted-unreadable
2338 article-mime-decode-quoted-printable
2340 article-strip-banner
2343 article-hide-signature
2344 article-strip-headers-in-body
2345 article-remove-trailing-blank-lines
2346 article-strip-leading-blank-lines
2347 article-strip-multiple-blank-lines
2348 article-strip-leading-space
2349 article-strip-trailing-space
2350 article-strip-blank-lines
2351 article-strip-all-blank-lines
2353 article-date-iso8601
2354 article-date-original
2356 article-decode-mime-words
2357 article-decode-charset
2358 article-decode-encoded-words
2362 article-treat-dumbquotes
2363 article-normalize-headers
2364 (article-show-all . gnus-article-show-all-headers))))
2367 ;;; Gnus article mode
2370 (put 'gnus-article-mode 'mode-class 'special)
2372 (set-keymap-parent gnus-article-mode-map widget-keymap)
2374 (gnus-define-keys gnus-article-mode-map
2375 " " gnus-article-goto-next-page
2376 "\177" gnus-article-goto-prev-page
2377 [delete] gnus-article-goto-prev-page
2378 [backspace] gnus-article-goto-prev-page
2379 "\C-c^" gnus-article-refer-article
2380 "h" gnus-article-show-summary
2381 "s" gnus-article-show-summary
2382 "\C-c\C-m" gnus-article-mail
2383 "?" gnus-article-describe-briefly
2384 "e" gnus-article-edit
2385 "<" beginning-of-buffer
2387 "\C-c\C-i" gnus-info-find-node
2390 "\C-d" gnus-article-read-summary-keys
2391 "\M-*" gnus-article-read-summary-keys
2392 "\M-#" gnus-article-read-summary-keys
2393 "\M-^" gnus-article-read-summary-keys
2394 "\M-g" gnus-article-read-summary-keys)
2396 (substitute-key-definition
2397 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
2399 (defun gnus-article-make-menu-bar ()
2400 (gnus-turn-off-edit-menu 'article)
2401 (unless (boundp 'gnus-article-article-menu)
2403 gnus-article-article-menu gnus-article-mode-map ""
2405 ["Scroll forwards" gnus-article-goto-next-page t]
2406 ["Scroll backwards" gnus-article-goto-prev-page t]
2407 ["Show summary" gnus-article-show-summary t]
2408 ["Fetch Message-ID at point" gnus-article-refer-article t]
2409 ["Mail to address at point" gnus-article-mail t]
2410 ["Send a bug report" gnus-bug t]))
2413 gnus-article-treatment-menu gnus-article-mode-map ""
2415 ["Hide headers" gnus-article-hide-headers t]
2416 ["Hide signature" gnus-article-hide-signature t]
2417 ["Hide citation" gnus-article-hide-citation t]
2418 ["Treat overstrike" gnus-article-treat-overstrike t]
2419 ["Remove carriage return" gnus-article-remove-cr t]
2420 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]))
2422 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
2424 (when (boundp 'gnus-summary-post-menu)
2425 (define-key gnus-article-mode-map [menu-bar post]
2426 (cons "Post" gnus-summary-post-menu)))
2428 (gnus-run-hooks 'gnus-article-menu-hook)))
2430 (defun gnus-article-mode ()
2431 "Major mode for displaying an article.
2433 All normal editing commands are switched off.
2435 The following commands are available in addition to all summary mode
2437 \\<gnus-article-mode-map>
2438 \\[gnus-article-next-page]\t Scroll the article one page forwards
2439 \\[gnus-article-prev-page]\t Scroll the article one page backwards
2440 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
2441 \\[gnus-article-show-summary]\t Display the summary buffer
2442 \\[gnus-article-mail]\t Send a reply to the address near point
2443 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
2444 \\[gnus-info-find-node]\t Go to the Gnus info node"
2446 (when (gnus-visual-p 'article-menu 'menu)
2447 (gnus-article-make-menu-bar))
2448 (gnus-simplify-mode-line)
2449 (setq mode-name "Article")
2450 (setq major-mode 'gnus-article-mode)
2451 (make-local-variable 'minor-mode-alist)
2452 (use-local-map gnus-article-mode-map)
2453 (gnus-update-format-specifications nil 'article-mode)
2454 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
2455 (make-local-variable 'gnus-page-broken)
2456 (make-local-variable 'gnus-button-marker-list)
2457 (make-local-variable 'gnus-article-current-summary)
2458 (make-local-variable 'gnus-article-mime-handles)
2459 (make-local-variable 'gnus-article-decoded-p)
2460 (make-local-variable 'gnus-article-mime-handle-alist)
2461 (make-local-variable 'gnus-article-washed-types)
2462 (gnus-set-default-directory)
2463 (buffer-disable-undo)
2464 (setq buffer-read-only t)
2465 (set-syntax-table gnus-article-mode-syntax-table)
2466 (mm-enable-multibyte)
2467 (gnus-run-hooks 'gnus-article-mode-hook))
2469 (defun gnus-article-setup-buffer ()
2470 "Initialize the article buffer."
2471 (let* ((name (if gnus-single-article-buffer "*Article*"
2472 (concat "*Article " gnus-newsgroup-name "*")))
2474 (progn (string-match "\\*Article" name)
2475 (concat " *Original Article"
2476 (substring name (match-end 0))))))
2477 (setq gnus-article-buffer name)
2478 (setq gnus-original-article-buffer original)
2479 (setq gnus-article-mime-handle-alist nil)
2480 ;; This might be a variable local to the summary buffer.
2481 (unless gnus-single-article-buffer
2483 (set-buffer gnus-summary-buffer)
2484 (setq gnus-article-buffer name)
2485 (setq gnus-original-article-buffer original)
2486 (gnus-set-global-variables)))
2487 ;; Init original article buffer.
2489 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
2490 (mm-enable-multibyte)
2491 (setq major-mode 'gnus-original-article-mode)
2492 (make-local-variable 'gnus-original-article))
2493 (if (get-buffer name)
2496 (buffer-disable-undo)
2497 (setq buffer-read-only t)
2498 (unless (eq major-mode 'gnus-article-mode)
2499 (gnus-article-mode))
2502 (set-buffer (gnus-get-buffer-create name))
2504 (make-local-variable 'gnus-summary-buffer)
2505 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2506 (current-buffer)))))
2508 ;; Set article window start at LINE, where LINE is the number of lines
2509 ;; from the head of the article.
2510 (defun gnus-article-set-window-start (&optional line)
2512 (get-buffer-window gnus-article-buffer t)
2514 (set-buffer gnus-article-buffer)
2515 (goto-char (point-min))
2518 (gnus-message 6 "Moved to bookmark")
2519 (search-forward "\n\n" nil t)
2523 (defun gnus-article-prepare (article &optional all-headers header)
2524 "Prepare ARTICLE in article mode buffer.
2525 ARTICLE should either be an article number or a Message-ID.
2526 If ARTICLE is an id, HEADER should be the article headers.
2527 If ALL-HEADERS is non-nil, no headers are hidden."
2529 ;; Make sure we start in a summary buffer.
2530 (unless (eq major-mode 'gnus-summary-mode)
2531 (set-buffer gnus-summary-buffer))
2532 (setq gnus-summary-buffer (current-buffer))
2533 (let* ((gnus-article (if header (mail-header-number header) article))
2534 (summary-buffer (current-buffer))
2535 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
2536 (group gnus-newsgroup-name)
2539 (gnus-article-setup-buffer)
2540 (set-buffer gnus-article-buffer)
2541 ;; Deactivate active regions.
2542 (when (and (boundp 'transient-mark-mode)
2543 transient-mark-mode)
2544 (setq mark-active nil))
2545 (if (not (setq result (let ((buffer-read-only nil))
2546 (gnus-request-article-this-buffer
2548 ;; There is no such article.
2550 (when (and (numberp article)
2551 (not (memq article gnus-newsgroup-sparse)))
2552 (setq gnus-article-current
2553 (cons gnus-newsgroup-name article))
2554 (set-buffer gnus-summary-buffer)
2555 (setq gnus-current-article article)
2556 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
2558 (gnus-summary-set-agent-mark article)
2559 (message "Message marked for downloading"))
2560 (gnus-summary-mark-article article gnus-canceled-mark)
2561 (unless (memq article gnus-newsgroup-sparse)
2563 "No such article (may have expired or been canceled)")))))
2564 (if (or (eq result 'pseudo)
2565 (eq result 'nneething))
2568 (set-buffer summary-buffer)
2569 (push article gnus-newsgroup-history)
2570 (setq gnus-last-article gnus-current-article
2571 gnus-current-article 0
2572 gnus-current-headers nil
2573 gnus-article-current nil)
2574 (if (eq result 'nneething)
2575 (gnus-configure-windows 'summary)
2576 (gnus-configure-windows 'article))
2577 (gnus-set-global-variables))
2578 (let ((gnus-article-mime-handle-alist-1
2579 gnus-article-mime-handle-alist))
2580 (gnus-set-mode-line 'article)))
2581 ;; The result from the `request' was an actual article -
2582 ;; or at least some text that is now displayed in the
2584 (when (and (numberp article)
2585 (not (eq article gnus-current-article)))
2586 ;; Seems like a new article has been selected.
2587 ;; `gnus-current-article' must be an article number.
2589 (set-buffer summary-buffer)
2590 (push article gnus-newsgroup-history)
2591 (setq gnus-last-article gnus-current-article
2592 gnus-current-article article
2593 gnus-current-headers
2594 (gnus-summary-article-header gnus-current-article)
2595 gnus-article-current
2596 (cons gnus-newsgroup-name gnus-current-article))
2597 (unless (vectorp gnus-current-headers)
2598 (setq gnus-current-headers nil))
2599 (gnus-summary-goto-subject gnus-current-article)
2600 (when (gnus-summary-show-thread)
2601 ;; If the summary buffer really was folded, the
2602 ;; previous goto may not actually have gone to
2603 ;; the right article, but the thread root instead.
2605 (gnus-summary-goto-subject gnus-current-article))
2606 (gnus-run-hooks 'gnus-mark-article-hook)
2607 (gnus-set-mode-line 'summary)
2608 (when (gnus-visual-p 'article-highlight 'highlight)
2609 (gnus-run-hooks 'gnus-visual-mark-article-hook))
2610 ;; Set the global newsgroup variables here.
2611 (gnus-set-global-variables)
2612 (setq gnus-have-all-headers
2613 (or all-headers gnus-show-all-headers))))
2614 (when (or (numberp article)
2616 (gnus-article-prepare-display)
2618 (goto-char (point-min))
2619 (setq gnus-page-broken
2620 (when gnus-break-pages
2621 (gnus-narrow-to-page)
2623 (let ((gnus-article-mime-handle-alist-1
2624 gnus-article-mime-handle-alist))
2625 (gnus-set-mode-line 'article))
2627 (set-window-point (get-buffer-window (current-buffer)) (point))
2628 (gnus-configure-windows 'article)
2632 (defun gnus-article-prepare-display ()
2633 "Make the current buffer look like a nice article."
2634 ;; Hooks for getting information from the article.
2635 ;; This hook must be called before being narrowed.
2636 (let ((gnus-article-buffer (current-buffer))
2638 (unless (eq major-mode 'gnus-article-mode)
2639 (gnus-article-mode))
2640 (setq buffer-read-only nil)
2641 (gnus-run-hooks 'gnus-tmp-internal-hook)
2642 (gnus-run-hooks 'gnus-article-prepare-hook)
2643 (when gnus-display-mime-function
2644 (funcall gnus-display-mime-function))))
2647 ;;; Gnus MIME viewing functions
2650 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
2651 "The following specs can be used:
2653 %T MIME type, along with additional info
2654 %n The `name' parameter
2655 %d The description, if any
2656 %l The length of the encoded part
2657 %p The part identifier number
2658 %e Dots if the part isn't displayed")
2660 (defvar gnus-mime-button-line-format-alist
2661 '((?t gnus-tmp-type ?s)
2662 (?T gnus-tmp-type-long ?s)
2663 (?n gnus-tmp-name ?s)
2664 (?d gnus-tmp-description ?s)
2666 (?l gnus-tmp-length ?d)
2667 (?e gnus-tmp-dots ?s)))
2669 (defvar gnus-mime-button-commands
2670 '((gnus-article-press-button "\r" "Toggle Display")
2671 (gnus-mime-view-part "v" "View Interactively...")
2672 (gnus-mime-save-part "o" "Save...")
2673 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
2674 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
2675 (gnus-mime-internalize-part "E" "View Internally")
2676 (gnus-mime-externalize-part "e" "View Externally")
2677 (gnus-mime-pipe-part "|" "Pipe To Command...")))
2679 (defun gnus-article-mime-part-status ()
2680 (if gnus-article-mime-handle-alist-1
2681 (format " (%d parts)" (length gnus-article-mime-handle-alist-1))
2684 (defvar gnus-mime-button-map nil)
2685 (unless gnus-mime-button-map
2686 (setq gnus-mime-button-map (make-sparse-keymap))
2687 (set-keymap-parent gnus-mime-button-map gnus-article-mode-map)
2688 (define-key gnus-mime-button-map gnus-mouse-2 'gnus-article-push-button)
2689 (define-key gnus-mime-button-map gnus-down-mouse-3 'gnus-mime-button-menu)
2691 (define-key gnus-mime-button-map (cadr c) (car c)))
2692 gnus-mime-button-commands))
2694 (defun gnus-mime-button-menu (event)
2695 "Construct a context-sensitive menu of MIME commands."
2698 (let ((pos (event-start event)))
2699 (set-buffer (window-buffer (posn-window pos)))
2700 (goto-char (posn-point pos))
2701 (gnus-article-check-buffer)
2702 (let ((response (x-popup-menu
2704 ("" ,@(mapcar (lambda (c)
2705 (cons (caddr c) (car c)))
2706 gnus-mime-button-commands))))))
2708 (funcall response))))))
2710 (defun gnus-mime-view-all-parts (&optional handles)
2711 "View all the MIME parts."
2713 (save-current-buffer
2714 (set-buffer gnus-article-buffer)
2715 (let ((handles (or handles gnus-article-mime-handles))
2716 (mail-parse-charset gnus-newsgroup-charset))
2717 (if (stringp (car handles))
2718 (gnus-mime-view-all-parts (cdr handles))
2719 (mapcar 'mm-display-part handles)))))
2721 (defun gnus-mime-save-part ()
2722 "Save the MIME part under point."
2724 (gnus-article-check-buffer)
2725 (let ((data (get-text-property (point) 'gnus-data)))
2726 (mm-save-part data)))
2728 (defun gnus-mime-pipe-part ()
2729 "Pipe the MIME part under point to a process."
2731 (gnus-article-check-buffer)
2732 (let ((data (get-text-property (point) 'gnus-data)))
2733 (mm-pipe-part data)))
2735 (defun gnus-mime-view-part ()
2736 "Interactively choose a view method for the MIME part under point."
2738 (gnus-article-check-buffer)
2739 (let ((data (get-text-property (point) 'gnus-data)))
2740 (mm-interactively-view-part data)))
2742 (defun gnus-mime-copy-part (&optional handle)
2743 "Put the the MIME part under point into a new buffer."
2745 (gnus-article-check-buffer)
2746 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
2747 (contents (mm-get-part handle))|
2748 (base (file-name-nondirectory
2750 (mail-content-type-get (mm-handle-type handle) 'name)
2751 (mail-content-type-get (mm-handle-type handle)
2754 (buffer (generate-new-buffer base)))
2755 (switch-to-buffer buffer)
2757 ;; We do it this way to make `normal-mode' set the appropriate mode.
2760 (setq buffer-file-name (expand-file-name base))
2762 (setq buffer-file-name nil))
2763 (goto-char (point-min))))
2765 (defun gnus-mime-inline-part (&optional handle)
2766 "Insert the MIME part under point into the current buffer."
2768 (gnus-article-check-buffer)
2769 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
2773 (if (mm-handle-undisplayer handle)
2774 (mm-remove-part handle)
2775 (setq contents (mm-get-part handle))
2777 (mm-insert-inline handle contents)
2780 (defun gnus-mime-externalize-part (&optional handle)
2781 "View the MIME part under point with an external viewer."
2783 (gnus-article-check-buffer)
2784 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
2785 (mm-user-display-methods nil)
2786 (mm-all-images-fit t)
2787 (mail-parse-charset gnus-newsgroup-charset))
2788 (if (mm-handle-undisplayer handle)
2789 (mm-remove-part handle)
2790 (mm-display-part handle))))
2792 (defun gnus-mime-internalize-part (&optional handle)
2793 "View the MIME part under point with an internal viewer."
2795 (gnus-article-check-buffer)
2796 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
2797 (mm-user-display-methods '((".*" . inline)))
2798 (mm-all-images-fit t)
2799 (mail-parse-charset gnus-newsgroup-charset))
2800 (if (mm-handle-undisplayer handle)
2801 (mm-remove-part handle)
2802 (mm-display-part handle))))
2804 (defun gnus-article-part-wrapper (n function)
2805 (save-current-buffer
2806 (set-buffer gnus-article-buffer)
2807 (when (> n (length gnus-article-mime-handle-alist))
2808 (error "No such part"))
2809 (gnus-article-goto-part n)
2810 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
2811 (funcall function handle))))
2813 (defun gnus-article-pipe-part (n)
2814 "Pipe MIME part N, which is the numerical prefix."
2816 (gnus-article-part-wrapper n 'mm-pipe-part))
2818 (defun gnus-article-save-part (n)
2819 "Save MIME part N, which is the numerical prefix."
2821 (gnus-article-part-wrapper n 'mm-save-part))
2823 (defun gnus-article-interactively-view-part (n)
2824 "View MIME part N interactively, which is the numerical prefix."
2826 (gnus-article-part-wrapper n 'mm-interactively-view-part))
2828 (defun gnus-article-copy-part (n)
2829 "Copy MIME part N, which is the numerical prefix."
2831 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
2833 (defun gnus-article-externalize-part (n)
2834 "View MIME part N externally, which is the numerical prefix."
2836 (gnus-article-part-wrapper n 'gnus-mime-externalize-part))
2838 (defun gnus-article-inline-part (n)
2839 "Inline MIME part N, which is the numerical prefix."
2841 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
2843 (defun gnus-article-view-part (n)
2844 "View MIME part N, which is the numerical prefix."
2846 (save-current-buffer
2847 (set-buffer gnus-article-buffer)
2848 (when (> n (length gnus-article-mime-handle-alist))
2849 (error "No such part"))
2850 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
2851 (when (gnus-article-goto-part n)
2852 (if (equal (car handle) "multipart/alternative")
2853 (gnus-article-press-button)
2854 (when (eq (gnus-mm-display-part handle) 'internal)
2855 (gnus-set-window-start)))))))
2857 (defun gnus-mm-display-part (handle)
2858 "Display HANDLE and fix MIME button."
2859 (let ((id (get-text-property (point) 'gnus-part))
2864 (let ((window (selected-window))
2865 (mail-parse-charset gnus-newsgroup-charset))
2868 (let ((win (get-buffer-window (current-buffer) t))
2871 (select-window win))
2874 (if (mm-handle-displayed-p handle)
2875 ;; This will remove the part.
2876 (mm-display-part handle)
2878 (narrow-to-region (point) (1+ (point)))
2879 (mm-display-part handle)
2880 ;; We narrow to the part itself and
2881 ;; then call the treatment functions.
2882 (goto-char (point-min))
2884 (narrow-to-region (point) (point-max))
2887 (1- (length gnus-article-mime-handles))
2888 (car (mm-handle-type handle))))))
2889 (select-window window))))
2891 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
2892 (gnus-insert-mime-button
2893 handle id (list (mm-handle-displayed-p handle)))
2894 (goto-char point))))
2896 (defun gnus-article-goto-part (n)
2897 "Go to MIME part N."
2898 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
2900 (goto-char point))))
2902 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
2903 (let ((gnus-tmp-name
2904 (or (mail-content-type-get (mm-handle-type handle)
2906 (mail-content-type-get (mm-handle-disposition handle)
2909 (gnus-tmp-type (car (mm-handle-type handle)))
2910 (gnus-tmp-description
2911 (mail-decode-encoded-word-string (or (mm-handle-description handle)
2914 (if (if displayed (car displayed)
2915 (mm-handle-displayed-p handle))
2917 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
2919 gnus-tmp-type-long b e)
2920 (when (string-match ".*/" gnus-tmp-name)
2921 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
2922 (setq gnus-tmp-type-long (concat gnus-tmp-type
2923 (and (not (equal gnus-tmp-name ""))
2924 (concat "; " gnus-tmp-name))))
2925 (or (equal gnus-tmp-description "")
2926 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
2931 gnus-mime-button-line-format gnus-mime-button-line-format-alist
2932 `(local-map ,gnus-mime-button-map
2933 keymap ,gnus-mime-button-map
2934 gnus-callback gnus-mm-display-part
2935 gnus-part ,gnus-tmp-id
2936 article-type annotation
2939 (widget-convert-button 'link b e
2941 :action 'gnus-widget-press-button
2942 :button-keymap gnus-mime-button-map
2945 ;; Needed to properly clear the message
2946 ;; due to a bug in wid-edit
2947 (setq help-echo-owns-message t)
2949 "Click to %s the MIME part; %s for more options"
2950 (if (mm-handle-displayed-p
2951 (widget-get widget :mime-handle))
2953 (if gnus-xemacs "button3" "mouse-3"))))))
2955 (defun gnus-widget-press-button (elems el)
2956 (goto-char (widget-get elems :from))
2957 (gnus-article-press-button))
2959 (defvar gnus-displaying-mime nil)
2961 (defun gnus-display-mime (&optional ihandles)
2962 "Display the MIME parts."
2964 (save-selected-window
2965 (let ((window (get-buffer-window gnus-article-buffer))
2968 (select-window window)
2969 ;; We have to do this since selecting the window
2970 ;; may change the point. So we set the window point.
2971 (set-window-point window point)))
2972 (let* ((handles (or ihandles (mm-dissect-buffer) (mm-uu-dissect)))
2973 buffer-read-only handle name type b e display)
2974 (when (and (not ihandles)
2975 (not gnus-displaying-mime))
2976 ;; Top-level call; we clean up.
2977 (mm-destroy-parts gnus-article-mime-handles)
2978 (setq gnus-article-mime-handles handles
2979 gnus-article-mime-handle-alist nil)
2980 ;; We allow users to glean info from the handles.
2981 (when gnus-article-mime-part-function
2982 (gnus-mime-part-function handles)))
2984 (or (not (stringp (car handles)))
2987 (when (and (not ihandles)
2988 (not gnus-displaying-mime))
2989 ;; Clean up for mime parts.
2991 (delete-region (point) (point-max)))
2992 (let ((gnus-displaying-mime t))
2993 (gnus-mime-display-part handles)))
2996 (narrow-to-region (point) (point-max))
2997 (gnus-treat-article nil 1 1)
2999 ;; Highlight the headers.
3003 (narrow-to-region (point-min) (point))
3004 (gnus-treat-article 'head)))))))
3006 (defvar gnus-mime-display-multipart-as-mixed nil)
3008 (defun gnus-mime-display-part (handle)
3011 ((not (stringp (car handle)))
3012 (gnus-mime-display-single handle))
3013 ;; User-defined multipart
3014 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
3015 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
3017 ;; multipart/alternative
3018 ((and (equal (car handle) "multipart/alternative")
3019 (not gnus-mime-display-multipart-as-mixed))
3020 (let ((id (1+ (length gnus-article-mime-handle-alist))))
3021 (push (cons id handle) gnus-article-mime-handle-alist)
3022 (gnus-mime-display-alternative (cdr handle) nil nil id)))
3023 ;; multipart/related
3024 ((and (equal (car handle) "multipart/related")
3025 (not gnus-mime-display-multipart-as-mixed))
3026 ;;;!!!We should find the start part, but we just default
3027 ;;;!!!to the first part.
3028 (gnus-mime-display-part (cadr handle)))
3029 ;; Other multiparts are handled like multipart/mixed.
3031 (gnus-mime-display-mixed (cdr handle)))))
3033 (defun gnus-mime-part-function (handles)
3034 (if (stringp (car handles))
3035 (mapcar 'gnus-mime-part-function (cdr handles))
3036 (funcall gnus-article-mime-part-function handles)))
3038 (defun gnus-mime-display-mixed (handles)
3039 (mapcar 'gnus-mime-display-part handles))
3041 (defun gnus-mime-display-single (handle)
3042 (let ((type (car (mm-handle-type handle)))
3043 (ignored gnus-ignored-mime-types)
3050 (when (string-match (pop ignored) type)
3051 (throw 'ignored nil)))
3052 (if (and (setq not-attachment
3053 (or (not (mm-handle-disposition handle))
3054 (equal (car (mm-handle-disposition handle))
3056 (mm-attachment-override-p type)))
3057 (mm-automatic-display-p type)
3058 (or (mm-inlinable-part-p type)
3059 (mm-automatic-external-display-p type)))
3061 (when (equal (car (split-string type "/"))
3064 (let ((id (1+ (length gnus-article-mime-handle-alist))))
3065 (push (cons id handle) gnus-article-mime-handle-alist)
3066 (when (or (not display)
3067 (not (gnus-unbuttonized-mime-type-p type)))
3068 (gnus-article-insert-newline)
3069 (gnus-insert-mime-button
3070 handle id (list (or display (and not-attachment text))))
3071 (gnus-article-insert-newline)
3072 (gnus-article-insert-newline)
3074 (let ((beg (point)))
3079 (let ((mail-parse-charset gnus-newsgroup-charset))
3080 (mm-display-part handle t))
3081 (goto-char (point-max)))
3082 ((and text not-attachment)
3085 (gnus-article-insert-newline)
3086 (mm-insert-inline handle (mm-get-part handle))
3087 (goto-char (point-max))))
3091 (narrow-to-region beg (point))
3093 nil (length gnus-article-mime-handle-alist)
3094 (1- (length gnus-article-mime-handles))
3095 (car (mm-handle-type handle))))))))))
3097 (defun gnus-unbuttonized-mime-type-p (type)
3098 "Say whether TYPE is to be unbuttonized."
3099 (unless gnus-inhibit-mime-unbuttonizing
3101 (let ((types gnus-unbuttonized-mime-types))
3103 (when (string-match (pop types) type)
3104 (throw 'found t)))))))
3106 (defun gnus-article-insert-newline ()
3107 "Insert a newline, but mark it as undeletable."
3108 (gnus-put-text-property
3109 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
3111 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
3112 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
3115 handle buffer-read-only from props begend not-pref)
3116 (save-window-excursion
3119 (narrow-to-region (car ibegend)
3122 (goto-char (car ibegend))
3125 (delete-region (point-min) (point-max))
3126 (mm-remove-parts handles))
3127 (setq begend (list (point-marker)))
3129 (unless (setq not-pref (cadr (member preferred ihandles)))
3130 (setq not-pref (car ihandles)))
3132 (not (gnus-unbuttonized-mime-type-p
3133 "multipart/alternative")))
3134 (gnus-add-text-properties
3137 (insert (format "%d. " id))
3141 (unless ,(not ibegend)
3142 (setq gnus-article-mime-handle-alist
3143 ',gnus-article-mime-handle-alist))
3144 (gnus-mime-display-alternative
3145 ',ihandles ',not-pref ',begend ,id))
3146 local-map ,gnus-mime-button-map
3147 ,gnus-mouse-face-prop ,gnus-article-mouse-face
3148 face ,gnus-article-button-face
3149 keymap ,gnus-mime-button-map
3152 (widget-convert-button 'link from (point)
3153 :action 'gnus-widget-press-button
3154 :button-keymap gnus-widget-button-keymap)
3156 (while (setq handle (pop handles))
3157 (gnus-add-text-properties
3160 (insert (format "(%c) %-18s"
3161 (if (equal handle preferred) ?* ? )
3162 (if (stringp (car handle))
3164 (car (mm-handle-type handle)))))
3168 (unless ,(not ibegend)
3169 (setq gnus-article-mime-handle-alist
3170 ',gnus-article-mime-handle-alist))
3171 (gnus-mime-display-alternative
3172 ',ihandles ',handle ',begend ,id))
3173 local-map ,gnus-mime-button-map
3174 ,gnus-mouse-face-prop ,gnus-article-mouse-face
3175 face ,gnus-article-button-face
3176 keymap ,gnus-mime-button-map
3179 (widget-convert-button 'link from (point)
3180 :action 'gnus-widget-press-button
3181 :button-keymap gnus-widget-button-keymap)
3185 (if (stringp (car preferred))
3186 (gnus-display-mime preferred)
3187 (let ((mail-parse-charset gnus-newsgroup-charset))
3188 (mm-display-part preferred)))
3189 (goto-char (point-max))
3190 (setcdr begend (point-marker)))))
3192 (goto-char point))))
3194 (defun gnus-article-wash-status ()
3195 "Return a string which display status of article washing."
3197 (set-buffer gnus-article-buffer)
3198 (let ((cite (memq 'cite gnus-article-wash-types))
3199 (headers (memq 'headers gnus-article-wash-types))
3200 (boring (memq 'boring-headers gnus-article-wash-types))
3201 (pgp (memq 'pgp gnus-article-wash-types))
3202 (pem (memq 'pem gnus-article-wash-types))
3203 (signature (memq 'signature gnus-article-wash-types))
3204 (overstrike (memq 'overstrike gnus-article-wash-types))
3205 (emphasis (memq 'emphasis gnus-article-wash-types)))
3206 (format "%c%c%c%c%c%c"
3208 (if (or headers boring) ?h ? )
3209 (if (or pgp pem) ?p ? )
3210 (if signature ?s ? )
3211 (if overstrike ?o ? )
3212 (if emphasis ?e ? )))))
3214 (fset 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
3216 (defun gnus-article-maybe-hide-headers ()
3217 "Hide unwanted headers if `gnus-have-all-headers' is nil.
3218 Provided for backwards compatibility."
3219 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
3220 (not (save-excursion (set-buffer gnus-summary-buffer)
3221 gnus-have-all-headers)))
3222 (not gnus-inhibit-hiding))
3223 (gnus-article-hide-headers)))
3227 (defun gnus-output-to-file (file-name)
3228 "Append the current article to a file named FILE-NAME."
3229 (let ((artbuf (current-buffer)))
3231 (insert-buffer-substring artbuf)
3232 ;; Append newline at end of the buffer as separator, and then
3234 (goto-char (point-max))
3236 (append-to-file (point-min) (point-max) file-name)
3239 (defun gnus-narrow-to-page (&optional arg)
3240 "Narrow the article buffer to a page.
3241 If given a numerical ARG, move forward ARG pages."
3243 (setq arg (if arg (prefix-numeric-value arg) 0))
3245 (set-buffer gnus-article-buffer)
3246 (goto-char (point-min))
3248 ;; Remove any old next/prev buttons.
3249 (when (gnus-visual-p 'page-marker)
3250 (let ((buffer-read-only nil))
3251 (gnus-remove-text-with-property 'gnus-prev)
3252 (gnus-remove-text-with-property 'gnus-next)))
3255 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
3257 (re-search-forward page-delimiter nil 'move arg)))
3258 (goto-char (match-end 0)))
3261 (if (re-search-forward page-delimiter nil 'move)
3264 (when (and (gnus-visual-p 'page-marker)
3265 (not (= (point-min) 1)))
3267 (goto-char (point-min))
3268 (gnus-insert-prev-page-button)))
3269 (when (and (gnus-visual-p 'page-marker)
3270 (< (+ (point-max) 2) (buffer-size)))
3272 (goto-char (point-max))
3273 (gnus-insert-next-page-button)))))
3275 ;; Article mode commands
3277 (defun gnus-article-goto-next-page ()
3278 "Show the next page of the article."
3280 (when (gnus-article-next-page)
3281 (goto-char (point-min))
3282 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
3284 (defun gnus-article-goto-prev-page ()
3285 "Show the next page of the article."
3287 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
3288 (gnus-article-prev-page nil)))
3290 (defun gnus-article-next-page (&optional lines)
3291 "Show the next page of the current article.
3292 If end of article, return non-nil. Otherwise return nil.
3293 Argument LINES specifies lines to be scrolled up."
3295 (move-to-window-line -1)
3298 (and (pos-visible-in-window-p) ;Not continuation line.
3300 ;; Nothing in this page.
3301 (if (or (not gnus-page-broken)
3304 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
3306 (gnus-narrow-to-page 1) ;Go to next page.
3308 ;; More in this page.
3309 (let ((scroll-in-place nil))
3313 ;; Long lines may cause an end-of-buffer error.
3314 (goto-char (point-max)))))
3315 (move-to-window-line 0)
3318 (defun gnus-article-prev-page (&optional lines)
3319 "Show previous page of current article.
3320 Argument LINES specifies lines to be scrolled down."
3322 (move-to-window-line 0)
3323 (if (and gnus-page-broken
3325 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
3327 (gnus-narrow-to-page -1) ;Go to previous page.
3328 (goto-char (point-max))
3330 (let ((scroll-in-place nil))
3334 (beginning-of-buffer
3335 (goto-char (point-min))))
3336 (move-to-window-line 0)))))
3338 (defun gnus-article-refer-article ()
3339 "Read article specified by message-id around point."
3341 (let ((point (point)))
3342 (search-forward ">" nil t) ;Move point to end of "<....>".
3343 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
3344 (let ((message-id (match-string 1)))
3346 (set-buffer gnus-summary-buffer)
3347 (gnus-summary-refer-article message-id))
3349 (error "No references around point"))))
3351 (defun gnus-article-show-summary ()
3352 "Reconfigure windows to show summary buffer."
3354 (if (not (gnus-buffer-live-p gnus-summary-buffer))
3355 (error "There is no summary buffer for this article buffer")
3356 (gnus-article-set-globals)
3357 (gnus-configure-windows 'article)
3358 (gnus-summary-goto-subject gnus-current-article)
3359 (gnus-summary-position-point)))
3361 (defun gnus-article-describe-briefly ()
3362 "Describe article mode commands briefly."
3364 (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")))
3366 (defun gnus-article-summary-command ()
3367 "Execute the last keystroke in the summary buffer."
3369 (let ((obuf (current-buffer))
3370 (owin (current-window-configuration))
3372 (switch-to-buffer gnus-article-current-summary 'norecord)
3373 (setq func (lookup-key (current-local-map) (this-command-keys)))
3374 (call-interactively func)
3376 (set-window-configuration owin)
3377 (set-window-point (get-buffer-window (current-buffer)) (point))))
3379 (defun gnus-article-summary-command-nosave ()
3380 "Execute the last keystroke in the summary buffer."
3383 (pop-to-buffer gnus-article-current-summary 'norecord)
3384 (setq func (lookup-key (current-local-map) (this-command-keys)))
3385 (call-interactively func)))
3387 (defun gnus-article-check-buffer ()
3388 "Beep if not in an article buffer."
3389 (unless (equal major-mode 'gnus-article-mode)
3390 (error "Command invoked outside of a Gnus article buffer")))
3392 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
3393 "Read a summary buffer key sequence and execute it from the article buffer."
3395 (gnus-article-check-buffer)
3397 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
3398 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
3399 "=" "^" "\M-^" "|"))
3405 '("n" "Gn" "p" "Gp"))
3408 (set-buffer gnus-article-current-summary)
3409 (let (gnus-pick-mode)
3410 (push (or key last-command-event) unread-command-events)
3411 (setq keys (read-key-sequence nil))))
3414 (if (or (member keys nosaves)
3415 (member keys nosave-but-article)
3416 (member keys nosave-in-article))
3418 (save-window-excursion
3419 (pop-to-buffer gnus-article-current-summary 'norecord)
3420 ;; We disable the pick minor mode commands.
3421 (let (gnus-pick-mode)
3422 (setq func (lookup-key (current-local-map) keys))))
3425 (unless (member keys nosave-in-article)
3426 (set-buffer gnus-article-current-summary))
3427 (call-interactively func)
3428 (setq new-sum-point (point)))
3429 (when (member keys nosave-but-article)
3430 (pop-to-buffer gnus-article-buffer 'norecord)))
3431 ;; These commands should restore window configuration.
3432 (let ((obuf (current-buffer))
3433 (owin (current-window-configuration))
3435 (summary gnus-article-current-summary)
3436 func in-buffer selected)
3437 (if not-restore-window
3438 (pop-to-buffer summary 'norecord)
3439 (switch-to-buffer summary 'norecord))
3440 (setq in-buffer (current-buffer))
3441 ;; We disable the pick minor mode commands.
3442 (if (setq func (let (gnus-pick-mode)
3443 (lookup-key (current-local-map) keys)))
3445 (call-interactively func)
3446 (setq new-sum-point (point)))
3448 (when (eq in-buffer (current-buffer))
3449 (setq selected (gnus-summary-select-article))
3451 (unless not-restore-window
3452 (set-window-configuration owin))
3453 (when (eq selected 'old)
3455 (set-window-start (get-buffer-window (current-buffer))
3457 (set-window-point (get-buffer-window (current-buffer))
3459 (let ((win (get-buffer-window gnus-article-current-summary)))
3461 (set-window-point win new-sum-point))))))))
3463 (defun gnus-article-hide (&optional arg force)
3464 "Hide all the gruft in the current article.
3465 This means that PGP stuff, signatures, cited text and (some)
3466 headers will be hidden.
3467 If given a prefix, show the hidden text instead."
3468 (interactive (append (gnus-article-hidden-arg) (list 'force)))
3469 (gnus-article-hide-headers arg)
3470 (gnus-article-hide-pgp arg)
3471 (gnus-article-hide-citation-maybe arg force)
3472 (gnus-article-hide-signature arg))
3474 (defun gnus-article-maybe-highlight ()
3475 "Do some article highlighting if article highlighting is requested."
3476 (when (gnus-visual-p 'article-highlight 'highlight)
3477 (gnus-article-highlight-some)))
3479 (defun gnus-check-group-server ()
3480 ;; Make sure the connection to the server is alive.
3481 (unless (gnus-server-opened
3482 (gnus-find-method-for-group gnus-newsgroup-name))
3483 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
3484 (gnus-request-group gnus-newsgroup-name t)))
3486 (defun gnus-request-article-this-buffer (article group)
3487 "Get an article and insert it into this buffer."
3488 (let (do-update-line sparse-header)
3492 (gnus-kill-all-overlays)
3493 (setq group (or group gnus-newsgroup-name))
3495 ;; Using `gnus-request-article' directly will insert the article into
3496 ;; `nntp-server-buffer' - so we'll save some time by not having to
3497 ;; copy it from the server buffer into the article buffer.
3499 ;; We only request an article by message-id when we do not have the
3500 ;; headers for it, so we'll have to get those.
3501 (when (stringp article)
3502 (let ((gnus-override-method gnus-refer-article-method))
3503 (gnus-read-header article)))
3505 ;; If the article number is negative, that means that this article
3506 ;; doesn't belong in this newsgroup (possibly), so we find its
3507 ;; message-id and request it by id instead of number.
3508 (when (and (numberp article)
3510 (get-buffer gnus-summary-buffer)
3511 (gnus-buffer-exists-p gnus-summary-buffer))
3513 (set-buffer gnus-summary-buffer)
3514 (let ((header (gnus-summary-article-header article)))
3517 ((memq article gnus-newsgroup-sparse)
3518 ;; This is a sparse gap article.
3519 (setq do-update-line article)
3520 (setq article (mail-header-id header))
3521 (let ((gnus-override-method gnus-refer-article-method))
3522 (setq sparse-header (gnus-read-header article)))
3523 (setq gnus-newsgroup-sparse
3524 (delq article gnus-newsgroup-sparse)))
3526 ;; It's a real article.
3527 (setq article (mail-header-id header)))
3529 ;; It is an extracted pseudo-article.
3530 (setq article 'pseudo)
3531 (gnus-request-pseudo-article header))))
3533 (let ((method (gnus-find-method-for-group
3534 gnus-newsgroup-name)))
3535 (when (and (eq (car method) 'nneething)
3538 (file-name-as-directory
3539 (or (cadr (assq 'nneething-address method))
3541 (mail-header-subject header))))
3542 (when (file-directory-p dir)
3543 (setq article 'nneething)
3544 (gnus-group-enter-directory dir))))))))
3547 ;; Refuse to select canceled articles.
3548 ((and (numberp article)
3550 (get-buffer gnus-summary-buffer)
3551 (gnus-buffer-exists-p gnus-summary-buffer)
3552 (eq (cdr (save-excursion
3553 (set-buffer gnus-summary-buffer)
3554 (assq article gnus-newsgroup-reads)))
3555 gnus-canceled-mark))
3557 ;; We first check `gnus-original-article-buffer'.
3558 ((and (get-buffer gnus-original-article-buffer)
3561 (set-buffer gnus-original-article-buffer)
3562 (and (equal (car gnus-original-article) group)
3563 (eq (cdr gnus-original-article) article))))
3564 (insert-buffer-substring gnus-original-article-buffer)
3566 ;; Check the backlog.
3567 ((and gnus-keep-backlog
3568 (gnus-backlog-request-article group article (current-buffer)))
3570 ;; Check asynchronous pre-fetch.
3571 ((gnus-async-request-fetched-article group article (current-buffer))
3572 (gnus-async-prefetch-next group article gnus-summary-buffer)
3573 (when (and (numberp article) gnus-keep-backlog)
3574 (gnus-backlog-enter-article group article (current-buffer)))
3577 ((and gnus-use-cache
3579 (gnus-cache-request-article article group))
3581 ;; Get the article and put into the article buffer.
3582 ((or (stringp article) (numberp article))
3583 (let ((gnus-override-method
3584 (and (stringp article) gnus-refer-article-method))
3585 (buffer-read-only nil))
3587 (gnus-kill-all-overlays)
3588 (gnus-check-group-server)
3589 (when (gnus-request-article article group (current-buffer))
3590 (when (numberp article)
3591 (gnus-async-prefetch-next group article gnus-summary-buffer)
3592 (when gnus-keep-backlog
3593 (gnus-backlog-enter-article
3594 group article (current-buffer))))
3599 ;; Associate this article with the current summary buffer.
3600 (setq gnus-article-current-summary gnus-summary-buffer)
3602 ;; Take the article from the original article buffer
3603 ;; and place it in the buffer it's supposed to be in.
3604 (when (and (get-buffer gnus-article-buffer)
3605 (equal (buffer-name (current-buffer))
3606 (buffer-name (get-buffer gnus-article-buffer))))
3608 (if (get-buffer gnus-original-article-buffer)
3609 (set-buffer gnus-original-article-buffer)
3610 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3611 (buffer-disable-undo)
3612 (setq major-mode 'gnus-original-article-mode)
3613 (setq buffer-read-only t))
3614 (let (buffer-read-only)
3616 (insert-buffer-substring gnus-article-buffer))
3617 (setq gnus-original-article (cons group article)))
3620 (run-hooks 'gnus-article-decode-hook)
3621 ;; Mark article as decoded or not.
3622 (setq gnus-article-decoded-p gnus-article-decode-hook))
3624 ;; Update sparse articles.
3625 (when (and do-update-line
3626 (or (numberp article)
3628 (let ((buf (current-buffer)))
3629 (set-buffer gnus-summary-buffer)
3630 (gnus-summary-update-article do-update-line sparse-header)
3631 (gnus-summary-goto-subject do-update-line nil t)
3632 (set-window-point (get-buffer-window (current-buffer) t)
3634 (set-buffer buf))))))
3640 (defcustom gnus-article-edit-mode-hook nil
3641 "Hook run in article edit mode buffers."
3642 :group 'gnus-article-various
3645 (defvar gnus-article-edit-done-function nil)
3647 (defvar gnus-article-edit-mode-map nil)
3649 ;; Should we be using derived.el for this?
3650 (unless gnus-article-edit-mode-map
3651 (setq gnus-article-edit-mode-map (make-sparse-keymap))
3652 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
3654 (gnus-define-keys gnus-article-edit-mode-map
3655 "\C-c\C-c" gnus-article-edit-done
3656 "\C-c\C-k" gnus-article-edit-exit)
3658 (gnus-define-keys (gnus-article-edit-wash-map
3659 "\C-c\C-w" gnus-article-edit-mode-map)
3660 "f" gnus-article-edit-full-stops))
3662 (defun gnus-article-edit-mode ()
3663 "Major mode for editing articles.
3664 This is an extended text-mode.
3666 \\{gnus-article-edit-mode-map}"
3668 (setq major-mode 'gnus-article-edit-mode)
3669 (setq mode-name "Article Edit")
3670 (use-local-map gnus-article-edit-mode-map)
3671 (make-local-variable 'gnus-article-edit-done-function)
3672 (make-local-variable 'gnus-prev-winconf)
3673 (setq buffer-read-only nil)
3674 (buffer-enable-undo)
3676 (gnus-run-hooks 'text-mode-hook 'gnus-article-edit-mode-hook))
3678 (defun gnus-article-edit (&optional force)
3679 "Edit the current article.
3680 This will have permanent effect only in mail groups.
3681 If FORCE is non-nil, allow editing of articles even in read-only
3684 (when (and (not force)
3685 (gnus-group-read-only-p))
3686 (error "The current newsgroup does not support article editing"))
3687 (gnus-article-date-original)
3688 (gnus-article-edit-article
3690 `(lambda (no-highlight)
3692 (gnus-summary-edit-article-done
3693 ,(or (mail-header-references gnus-current-headers) "")
3694 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
3696 (defun gnus-article-edit-article (start-func exit-func)
3697 "Start editing the contents of the current article buffer."
3698 (let ((winconf (current-window-configuration)))
3699 (set-buffer gnus-article-buffer)
3700 (gnus-article-edit-mode)
3701 (funcall start-func)
3702 ;;(gnus-article-delete-text-of-type 'annotation)
3703 ;;(gnus-set-text-properties (point-min) (point-max) nil)
3704 (gnus-configure-windows 'edit-article)
3705 (setq gnus-article-edit-done-function exit-func)
3706 (setq gnus-prev-winconf winconf)
3707 (gnus-message 6 "C-c C-c to end edits")))
3709 (defun gnus-article-edit-done (&optional arg)
3710 "Update the article edits and exit."
3715 (when (article-goto-body)
3716 (let ((lines (count-lines (point) (point-max)))
3717 (length (- (point-max) (point)))
3718 (case-fold-search t)
3719 (body (copy-marker (point))))
3720 (goto-char (point-min))
3721 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
3722 (delete-region (match-beginning 1) (match-end 1))
3723 (insert (number-to-string length)))
3724 (goto-char (point-min))
3725 (when (re-search-forward
3726 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
3727 (delete-region (match-beginning 1) (match-end 1))
3728 (insert (number-to-string length)))
3729 (goto-char (point-min))
3730 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
3731 (delete-region (match-beginning 1) (match-end 1))
3732 (insert (number-to-string lines)))))))
3733 (let ((func gnus-article-edit-done-function)
3734 (buf (current-buffer))
3735 (start (window-start)))
3736 (gnus-article-edit-exit)
3739 (let ((buffer-read-only nil))
3741 ;; The cache and backlog have to be flushed somewhat.
3742 (when gnus-keep-backlog
3743 (gnus-backlog-remove-article
3744 (car gnus-article-current) (cdr gnus-article-current)))
3745 ;; Flush original article as well.
3747 (when (get-buffer gnus-original-article-buffer)
3748 (set-buffer gnus-original-article-buffer)
3749 (setq gnus-original-article nil)))
3750 (when gnus-use-cache
3751 (gnus-cache-update-article
3752 (car gnus-article-current) (cdr gnus-article-current))))
3754 (set-window-start (get-buffer-window buf) start)
3755 (set-window-point (get-buffer-window buf) (point))))
3757 (defun gnus-article-edit-exit ()
3758 "Exit the article editing without updating."
3760 ;; We remove all text props from the article buffer.
3761 (let ((buf (format "%s" (buffer-string)))
3762 (curbuf (current-buffer))
3764 (window-start (window-start)))
3767 (let ((winconf gnus-prev-winconf))
3769 (set-window-configuration winconf)
3770 ;; Tippy-toe some to make sure that point remains where it was.
3771 (save-current-buffer
3773 (set-window-start (get-buffer-window (current-buffer)) window-start)
3776 (defun gnus-article-edit-full-stops ()
3777 "Interactively repair spacing at end of sentences."
3780 (goto-char (point-min))
3781 (search-forward-regexp "^$" nil t)
3782 (let ((case-fold-search nil))
3783 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
3786 ;;; Article highlights
3789 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
3791 ;;; Internal Variables:
3793 (defcustom gnus-button-url-regexp "\\b\\(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\\)"
3794 "Regular expression that matches URLs."
3795 :group 'gnus-article-buttons
3798 (defcustom gnus-button-alist
3799 `(("<\\(url:[>\n\t ]*?\\)?news:[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
3800 0 t gnus-button-message-id 2)
3801 ("\\bnews:\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t gnus-button-message-id 1)
3802 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
3804 gnus-button-fetch-group 4)
3805 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
3806 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
3807 t gnus-button-message-id 3)
3808 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
3809 ("mailto:\\([-a-zA-Z.@_+0-9%]+\\)" 0 t gnus-url-mailto 1)
3810 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
3811 ;; This is how URLs _should_ be embedded in text...
3812 ("<URL: *\\([^>]*\\)>" 0 t gnus-button-embedded-url 1)
3814 (,gnus-button-url-regexp 0 t gnus-button-url 0))
3815 "*Alist of regexps matching buttons in article bodies.
3817 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
3818 REGEXP: is the string matching text around the button,
3819 BUTTON: is the number of the regexp grouping actually matching the button,
3820 FORM: is a lisp expression which must eval to true for the button to
3822 CALLBACK: is the function to call when the user push this button, and each
3823 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
3825 CALLBACK can also be a variable, in that case the value of that
3826 variable it the real callback function."
3827 :group 'gnus-article-buttons
3828 :type '(repeat (list regexp
3829 (integer :tag "Button")
3831 (function :tag "Callback")
3834 (integer :tag "Regexp group")))))
3836 (defcustom gnus-header-button-alist
3837 `(("^\\(References\\|Message-I[Dd]\\):" "<[^>]+>"
3838 0 t gnus-button-message-id 0)
3839 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
3840 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
3841 0 t gnus-button-mailto 0)
3842 ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t gnus-button-url 0)
3843 ("^Subject:" ,gnus-button-url-regexp 0 t gnus-button-url 0)
3844 ("^[^:]+:" ,gnus-button-url-regexp 0 t gnus-button-url 0)
3845 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
3846 gnus-button-message-id 3))
3847 "*Alist of headers and regexps to match buttons in article heads.
3849 This alist is very similar to `gnus-button-alist', except that each
3850 alist has an additional HEADER element first in each entry:
3852 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
3854 HEADER is a regexp to match a header. For a fuller explanation, see
3855 `gnus-button-alist'."
3856 :group 'gnus-article-buttons
3857 :group 'gnus-article-headers
3858 :type '(repeat (list (regexp :tag "Header")
3860 (integer :tag "Button")
3862 (function :tag "Callback")
3865 (integer :tag "Regexp group")))))
3867 (defvar gnus-button-regexp nil)
3868 (defvar gnus-button-marker-list nil)
3869 ;; Regexp matching any of the regexps from `gnus-button-alist'.
3871 (defvar gnus-button-last nil)
3872 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
3876 (defun gnus-article-push-button (event)
3877 "Check text under the mouse pointer for a callback function.
3878 If the text under the mouse pointer has a `gnus-callback' property,
3879 call it with the value of the `gnus-data' text property."
3881 (set-buffer (window-buffer (posn-window (event-start event))))
3882 (let* ((pos (posn-point (event-start event)))
3883 (data (get-text-property pos 'gnus-data))
3884 (fun (get-text-property pos 'gnus-callback)))
3887 (funcall fun data))))
3889 (defun gnus-article-press-button ()
3890 "Check text at point for a callback function.
3891 If the text at point has a `gnus-callback' property,
3892 call it with the value of the `gnus-data' text property."
3894 (let* ((data (get-text-property (point) 'gnus-data))
3895 (fun (get-text-property (point) 'gnus-callback)))
3897 (funcall fun data))))
3899 (defun gnus-article-highlight (&optional force)
3900 "Highlight current article.
3901 This function calls `gnus-article-highlight-headers',
3902 `gnus-article-highlight-citation',
3903 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
3904 do the highlighting. See the documentation for those functions."
3905 (interactive (list 'force))
3906 (gnus-article-highlight-headers)
3907 (gnus-article-highlight-citation force)
3908 (gnus-article-highlight-signature)
3909 (gnus-article-add-buttons force)
3910 (gnus-article-add-buttons-to-head))
3912 (defun gnus-article-highlight-some (&optional force)
3913 "Highlight current article.
3914 This function calls `gnus-article-highlight-headers',
3915 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
3916 do the highlighting. See the documentation for those functions."
3917 (interactive (list 'force))
3918 (gnus-article-highlight-headers)
3919 (gnus-article-highlight-signature)
3920 (gnus-article-add-buttons))
3922 (defun gnus-article-highlight-headers ()
3923 "Highlight article headers as specified by `gnus-header-face-alist'."
3926 (set-buffer gnus-article-buffer)
3928 (let ((alist gnus-header-face-alist)
3929 (buffer-read-only nil)
3930 (case-fold-search t)
3931 (inhibit-point-motion-hooks t)
3932 entry regexp header-face field-face from hpoints fpoints)
3933 (article-narrow-to-head)
3934 (while (setq entry (pop alist))
3935 (goto-char (point-min))
3936 (setq regexp (concat "^\\("
3937 (if (string-equal "" (nth 0 entry))
3941 header-face (nth 1 entry)
3942 field-face (nth 2 entry))
3943 (while (and (re-search-forward regexp nil t)
3947 (unless (search-forward ":" nil t)
3949 (when (and header-face
3950 (not (memq (point) hpoints)))
3951 (push (point) hpoints)
3952 (gnus-put-text-property from (point) 'face header-face))
3953 (when (and field-face
3954 (not (memq (setq from (point)) fpoints)))
3956 (if (re-search-forward "^[^ \t]" nil t)
3958 (goto-char (point-max)))
3959 (gnus-put-text-property from (point) 'face field-face))))))))
3961 (defun gnus-article-highlight-signature ()
3962 "Highlight the signature in an article.
3963 It does this by highlighting everything after
3964 `gnus-signature-separator' using `gnus-signature-face'."
3967 (set-buffer gnus-article-buffer)
3968 (let ((buffer-read-only nil)
3969 (inhibit-point-motion-hooks t))
3971 (when (and gnus-signature-face
3972 (gnus-article-narrow-to-signature))
3973 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
3974 'face gnus-signature-face)
3976 (gnus-article-search-signature)
3977 (let ((start (match-beginning 0))
3978 (end (set-marker (make-marker) (1+ (match-end 0)))))
3979 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
3982 (defun gnus-button-in-region-p (b e prop)
3983 "Say whether PROP exists in the region."
3984 (text-property-not-all b e prop nil))
3986 (defun gnus-article-add-buttons (&optional force)
3987 "Find external references in the article and make buttons of them.
3988 \"External references\" are things like Message-IDs and URLs, as
3989 specified by `gnus-button-alist'."
3990 (interactive (list 'force))
3992 (set-buffer gnus-article-buffer)
3993 (let ((buffer-read-only nil)
3994 (inhibit-point-motion-hooks t)
3995 (case-fold-search t)
3996 (alist gnus-button-alist)
3998 ;; Remove all old markers.
4000 (while (setq marker (pop gnus-button-marker-list))
4002 (when (setq entry (gnus-button-entry))
4003 (put-text-property (match-beginning (nth 1 entry))
4004 (match-end (nth 1 entry))
4005 'gnus-callback nil))
4006 (set-marker marker nil)))
4007 ;; We skip the headers.
4010 (while (setq entry (pop alist))
4011 (setq regexp (car entry))
4013 (while (re-search-forward regexp nil t)
4014 (let* ((start (and entry (match-beginning (nth 1 entry))))
4015 (end (and entry (match-end (nth 1 entry))))
4016 (from (match-beginning 0)))
4017 (when (and (or (eq t (nth 2 entry))
4018 (eval (nth 2 entry)))
4019 (not (gnus-button-in-region-p
4020 start end 'gnus-callback)))
4021 ;; That optional form returned non-nil, so we add the
4023 (gnus-article-add-button
4024 start end 'gnus-button-push
4025 (car (push (set-marker (make-marker) from)
4026 gnus-button-marker-list))))))))))
4028 ;; Add buttons to the head of an article.
4029 (defun gnus-article-add-buttons-to-head ()
4030 "Add buttons to the head of the article."
4033 (set-buffer gnus-article-buffer)
4035 (let ((buffer-read-only nil)
4036 (inhibit-point-motion-hooks t)
4037 (case-fold-search t)
4038 (alist gnus-header-button-alist)
4040 (article-narrow-to-head)
4042 ;; Each alist entry.
4043 (setq entry (car alist)
4045 (goto-char (point-min))
4046 (while (re-search-forward (car entry) nil t)
4047 ;; Each header matching the entry.
4048 (setq beg (match-beginning 0))
4049 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
4050 (match-beginning 0))
4053 (while (re-search-forward (nth 1 entry) end t)
4054 ;; Each match within a header.
4055 (let* ((entry (cdr entry))
4056 (start (match-beginning (nth 1 entry)))
4057 (end (match-end (nth 1 entry)))
4058 (form (nth 2 entry)))
4059 (goto-char (match-end 0))
4061 (gnus-article-add-button
4062 start end (nth 3 entry)
4063 (buffer-substring (match-beginning (nth 4 entry))
4064 (match-end (nth 4 entry)))))))
4065 (goto-char end)))))))
4067 ;;; External functions:
4069 (defun gnus-article-add-button (from to fun &optional data)
4070 "Create a button between FROM and TO with callback FUN and data DATA."
4071 (when gnus-article-button-face
4072 (gnus-overlay-put (gnus-make-overlay from to)
4073 'face gnus-article-button-face))
4074 (gnus-add-text-properties
4076 (nconc (and gnus-article-mouse-face
4077 (list gnus-mouse-face-prop gnus-article-mouse-face))
4078 (list 'gnus-callback fun)
4079 (and data (list 'gnus-data data))))
4080 (widget-convert-button 'link from to :action 'gnus-widget-press-button
4081 :button-keymap gnus-widget-button-keymap))
4083 ;;; Internal functions:
4085 (defun gnus-article-set-globals ()
4087 (set-buffer gnus-summary-buffer)
4088 (gnus-set-global-variables)))
4090 (defun gnus-signature-toggle (end)
4092 (set-buffer gnus-article-buffer)
4093 (let ((buffer-read-only nil)
4094 (inhibit-point-motion-hooks t))
4095 (if (get-text-property end 'invisible)
4096 (gnus-article-unhide-text end (point-max))
4097 (gnus-article-hide-text end (point-max) gnus-hidden-properties)))))
4099 (defun gnus-button-entry ()
4100 ;; Return the first entry in `gnus-button-alist' matching this place.
4101 (let ((alist gnus-button-alist)
4104 (setq entry (pop alist))
4105 (if (looking-at (car entry))
4110 (defun gnus-button-push (marker)
4111 ;; Push button starting at MARKER.
4114 (let* ((entry (gnus-button-entry))
4115 (inhibit-point-motion-hooks t)
4117 (args (mapcar (lambda (group)
4118 (let ((string (match-string group)))
4119 (gnus-set-text-properties
4120 0 (length string) nil string)
4127 (fboundp (symbol-value fun)))
4128 (apply (symbol-value fun) args))
4130 (gnus-message 1 "You must define `%S' to use this button"
4131 (cons fun args)))))))
4133 (defun gnus-button-message-id (message-id)
4136 (set-buffer gnus-summary-buffer)
4137 (gnus-summary-refer-article message-id)))
4139 (defun gnus-button-fetch-group (address)
4140 "Fetch GROUP specified by ADDRESS."
4141 (if (not (string-match "[:/]" address))
4142 ;; This is just a simple group url.
4143 (gnus-group-read-ephemeral-group address gnus-select-method)
4144 (if (not (string-match "^\\([^:/]+\\)\\(:\\([^/]+\\)/\\)?\\(.*\\)$"
4146 (error "Can't parse %s" address)
4147 (gnus-group-read-ephemeral-group
4148 (match-string 4 address)
4149 `(nntp ,(match-string 1 address)
4150 (nntp-address ,(match-string 1 address))
4151 (nntp-port-number ,(if (match-end 3)
4152 (match-string 3 address)
4155 (defun gnus-url-parse-query-string (query &optional downcase)
4156 (let (retval pairs cur key val)
4157 (setq pairs (split-string query "&"))
4159 (setq cur (car pairs)
4161 (if (not (string-match "=" cur))
4163 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
4164 val (gnus-url-unhex-string (substring cur (match-end 0) nil)))
4166 (setq key (downcase key)))
4167 (setq cur (assoc key retval))
4169 (setcdr cur (cons val (cdr cur)))
4170 (setq retval (cons (list key val) retval)))))
4173 (defun gnus-url-unhex (x)
4180 (defun gnus-url-unhex-string (str &optional allow-newlines)
4181 "Remove %XXX embedded spaces, etc in a url.
4182 If optional second argument ALLOW-NEWLINES is non-nil, then allow the
4183 decoding of carriage returns and line feeds in the string, which is normally
4184 forbidden in URL encoding."
4185 (setq str (or str ""))
4187 (case-fold-search t))
4188 (while (string-match "%[0-9a-f][0-9a-f]" str)
4189 (let* ((start (match-beginning 0))
4190 (ch1 (gnus-url-unhex (elt str (+ start 1))))
4192 (gnus-url-unhex (elt str (+ start 2))))))
4194 tmp (substring str 0 start)
4197 (char-to-string code))
4198 ((or (= code ?\n) (= code ?\r))
4200 (t (char-to-string code))))
4201 str (substring str (match-end 0)))))
4202 (setq tmp (concat tmp str))
4205 (defun gnus-url-mailto (url)
4206 ;; Send mail to someone
4207 (when (string-match "mailto:/*\\(.*\\)" url)
4208 (setq url (substring url (match-beginning 1) nil)))
4209 (let (to args subject func)
4210 (if (string-match (regexp-quote "?") url)
4211 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
4212 args (gnus-url-parse-query-string
4213 (substring url (match-end 0) nil) t))
4214 (setq to (gnus-url-unhex-string url)))
4215 (setq args (cons (list "to" to) args)
4216 subject (cdr-safe (assoc "subject" args)))
4219 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
4222 (message-position-on-field (caar args)))
4223 (insert (mapconcat 'identity (cdar args) ", "))
4224 (setq args (cdr args)))
4227 (message-goto-subject))))
4229 (defun gnus-button-mailto (address)
4231 (set-buffer (gnus-copy-article-buffer))
4232 (message-reply address))
4234 (defun gnus-button-reply (address)
4235 ;; Reply to ADDRESS.
4236 (message-reply address))
4238 (defun gnus-button-url (address)
4240 ;; In Emacs 20, `browse-url-browser-function' may be an alist.
4241 (if (listp browse-url-browser-function)
4242 (browse-url address)
4243 (funcall browse-url-browser-function address)))
4245 (defun gnus-button-embedded-url (address)
4247 ;; In Emacs 20, `browse-url-browser-function' may be an alist.
4248 (if (listp browse-url-browser-function)
4249 (browse-url (gnus-strip-whitespace address))
4250 (funcall browse-url-browser-function (gnus-strip-whitespace address))))
4252 ;;; Next/prev buttons in the article buffer.
4254 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
4255 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
4257 (defvar gnus-prev-page-map nil)
4258 (unless gnus-prev-page-map
4259 (setq gnus-prev-page-map (make-sparse-keymap))
4260 (define-key gnus-prev-page-map gnus-mouse-2 'gnus-button-prev-page)
4261 (define-key gnus-prev-page-map "\r" 'gnus-button-prev-page))
4263 (defun gnus-insert-prev-page-button ()
4264 (let ((buffer-read-only nil))
4266 gnus-prev-page-line-format nil
4267 `(gnus-prev t local-map ,gnus-prev-page-map
4268 gnus-callback gnus-article-button-prev-page
4269 article-type annotation))))
4271 (defvar gnus-next-page-map nil)
4272 (unless gnus-next-page-map
4273 (setq gnus-next-page-map (make-keymap))
4274 (suppress-keymap gnus-prev-page-map)
4275 (define-key gnus-next-page-map gnus-mouse-2 'gnus-button-next-page)
4276 (define-key gnus-next-page-map "\r" 'gnus-button-next-page))
4278 (defun gnus-button-next-page ()
4279 "Go to the next page."
4281 (let ((win (selected-window)))
4282 (select-window (get-buffer-window gnus-article-buffer t))
4283 (gnus-article-next-page)
4284 (select-window win)))
4286 (defun gnus-button-prev-page ()
4287 "Go to the prev page."
4289 (let ((win (selected-window)))
4290 (select-window (get-buffer-window gnus-article-buffer t))
4291 (gnus-article-prev-page)
4292 (select-window win)))
4294 (defun gnus-insert-next-page-button ()
4295 (let ((buffer-read-only nil))
4296 (gnus-eval-format gnus-next-page-line-format nil
4298 t local-map ,gnus-next-page-map
4299 gnus-callback gnus-article-button-next-page
4300 article-type annotation))))
4302 (defun gnus-article-button-next-page (arg)
4303 "Go to the next page."
4305 (let ((win (selected-window)))
4306 (select-window (get-buffer-window gnus-article-buffer t))
4307 (gnus-article-next-page)
4308 (select-window win)))
4310 (defun gnus-article-button-prev-page (arg)
4311 "Go to the prev page."
4313 (let ((win (selected-window)))
4314 (select-window (get-buffer-window gnus-article-buffer t))
4315 (gnus-article-prev-page)
4316 (select-window win)))
4318 (defvar gnus-decode-header-methods
4319 '(mail-decode-encoded-word-region)
4320 "List of methods used to decode headers.
4322 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item is
4323 FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
4324 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
4325 whose names match REGEXP.
4328 ((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
4329 mail-decode-encoded-word-region
4330 (\"chinese\" . rfc1843-decode-region))
4333 (defvar gnus-decode-header-methods-cache nil)
4335 (defun gnus-multi-decode-header (start end)
4336 "Apply the functions from `gnus-encoded-word-methods' that match."
4337 (unless (and gnus-decode-header-methods-cache
4338 (eq gnus-newsgroup-name
4339 (car gnus-decode-header-methods-cache)))
4340 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
4343 (nconc gnus-decode-header-methods-cache (list x))
4344 (if (and gnus-newsgroup-name
4345 (string-match (car x) gnus-newsgroup-name))
4346 (nconc gnus-decode-header-methods-cache
4348 gnus-decode-header-methods))
4349 (let ((xlist gnus-decode-header-methods-cache))
4352 (narrow-to-region start end)
4354 (funcall (pop xlist) (point-min) (point-max))))))
4357 ;;; Treatment top-level handling.
4360 (defun gnus-treat-article (condition &optional part-number total-parts type)
4361 (let ((length (- (point-max) (point-min)))
4362 (alist gnus-treatment-function-alist)
4363 (article-goto-body-goes-to-point-min-p t)
4367 (let ((list gnus-article-treat-types))
4369 (when (string-match (pop list) type)
4370 (throw 'found t)))))))
4371 (highlightp (gnus-visual-p 'article-highlight 'highlight))
4373 (gnus-run-hooks 'gnus-part-display-hook)
4374 (while (setq elem (pop alist))
4375 (setq val (symbol-value (car elem)))
4376 (when (and (or (consp val)
4378 (gnus-treat-predicate val)
4379 (or (not (get (car elem) 'highlight))
4382 (funcall (cadr elem)))))))
4384 ;; Dynamic variables.
4385 (defvar part-number)
4386 (defvar total-parts)
4390 (defun gnus-treat-predicate (val)
4401 (eq part-number total-parts))
4405 (stringp (car val)))
4406 (apply 'gnus-or (mapcar `(lambda (s)
4407 (string-match s ,(or gnus-newsgroup-name "")))
4410 (let ((pred (pop val)))
4413 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
4415 (apply 'gnus-and (mapcar 'gnus-tread-predicate val)))
4417 (not (gnus-treat-predicate val)))
4419 (equal (cadr val) type))
4421 (error "%S is not a valid predicate" pred)))))
4423 (error "%S is not a valid value" val))))
4429 (run-hooks 'gnus-art-load-hook)
4431 ;;; gnus-art.el ends here