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 | xv -quit -"
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 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
275 "Format for display of Date headers in article bodies.
276 See `format-time-string' for the possible values.
278 The variable can also be function, which should return a complete Date
279 header. The function is called with one argument, the time, which can
280 be fed to `format-time-string'."
281 :type '(choice string symbol)
282 :link '(custom-manual "(gnus)Article Date")
283 :group 'gnus-article-washing)
286 (autoload 'mail-extract-address-components "mail-extr"))
288 (defcustom gnus-save-all-headers t
289 "*If non-nil, don't remove any headers before saving."
290 :group 'gnus-article-saving
293 (defcustom gnus-prompt-before-saving 'always
294 "*This variable says how much prompting is to be done when saving articles.
295 If it is nil, no prompting will be done, and the articles will be
296 saved to the default files. If this variable is `always', each and
297 every article that is saved will be preceded by a prompt, even when
298 saving large batches of articles. If this variable is neither nil not
299 `always', there the user will be prompted once for a file name for
300 each invocation of the saving commands."
301 :group 'gnus-article-saving
302 :type '(choice (item always)
303 (item :tag "never" nil)
304 (sexp :tag "once" :format "%t\n" :value t)))
306 (defcustom gnus-saved-headers gnus-visible-headers
307 "Headers to keep if `gnus-save-all-headers' is nil.
308 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
309 If that variable is nil, however, all headers that match this regexp
310 will be kept while the rest will be deleted before saving."
311 :group 'gnus-article-saving
314 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
315 "A function to save articles in your favourite format.
316 The function must be interactively callable (in other words, it must
317 be an Emacs command).
319 Gnus provides the following functions:
321 * gnus-summary-save-in-rmail (Rmail format)
322 * gnus-summary-save-in-mail (Unix mail format)
323 * gnus-summary-save-in-folder (MH folder)
324 * gnus-summary-save-in-file (article format)
325 * gnus-summary-save-in-vm (use VM's folder format)
326 * gnus-summary-write-to-file (article format -- overwrite)."
327 :group 'gnus-article-saving
328 :type '(radio (function-item gnus-summary-save-in-rmail)
329 (function-item gnus-summary-save-in-mail)
330 (function-item gnus-summary-save-in-folder)
331 (function-item gnus-summary-save-in-file)
332 (function-item gnus-summary-save-in-vm)
333 (function-item gnus-summary-write-to-file)))
335 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
336 "A function generating a file name to save articles in Rmail format.
337 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
338 :group 'gnus-article-saving
341 (defcustom gnus-mail-save-name 'gnus-plain-save-name
342 "A function generating a file name to save articles in Unix mail format.
343 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
344 :group 'gnus-article-saving
347 (defcustom gnus-folder-save-name 'gnus-folder-save-name
348 "A function generating a file name to save articles in MH folder.
349 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
350 :group 'gnus-article-saving
353 (defcustom gnus-file-save-name 'gnus-numeric-save-name
354 "A function generating a file name to save articles in article format.
355 The function is called with NEWSGROUP, HEADERS, and optional
357 :group 'gnus-article-saving
360 (defcustom gnus-split-methods
361 '((gnus-article-archive-name)
362 (gnus-article-nndoc-name))
363 "*Variable used to suggest where articles are to be saved.
364 For instance, if you would like to save articles related to Gnus in
365 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
366 you could set this variable to something like:
368 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
369 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
371 This variable is an alist where the where the key is the match and the
372 value is a list of possible files to save in if the match is non-nil.
374 If the match is a string, it is used as a regexp match on the
375 article. If the match is a symbol, that symbol will be funcalled
376 from the buffer of the article to be saved with the newsgroup as the
377 parameter. If it is a list, it will be evaled in the same buffer.
379 If this form or function returns a string, this string will be used as
380 a possible file name; and if it returns a non-nil list, that list will
381 be used as possible file names."
382 :group 'gnus-article-saving
383 :type '(repeat (choice (list :value (fun) function)
384 (cons :value ("" "") regexp (repeat string))
387 (defcustom gnus-page-delimiter "^\^L"
388 "*Regexp describing what to use as article page delimiters.
389 The default value is \"^\^L\", which is a form linefeed at the
390 beginning of a line."
392 :group 'gnus-article-various)
394 (defcustom gnus-article-mode-line-format "Gnus: %g %S%m"
395 "*The format specification for the article mode line.
396 See `gnus-summary-mode-line-format' for a closer description.
398 The following additional specs are available:
400 %w The article washing status.
401 %m The number of MIME parts in the article."
403 :group 'gnus-article-various)
405 (defcustom gnus-article-mode-hook nil
406 "*A hook for Gnus article mode."
408 :group 'gnus-article-various)
410 (defcustom gnus-article-menu-hook nil
411 "*Hook run after the creation of the article mode menu."
413 :group 'gnus-article-various)
415 (defcustom gnus-article-prepare-hook nil
416 "*A hook called after an article has been prepared in the article buffer."
418 :group 'gnus-article-various)
420 (defcustom gnus-article-hide-pgp-hook nil
421 "*A hook called after successfully hiding a PGP signature."
423 :group 'gnus-article-various)
425 (defcustom gnus-article-button-face 'bold
426 "Face used for highlighting buttons in the article buffer.
428 An article button is a piece of text that you can activate by pressing
429 `RET' or `mouse-2' above it."
431 :group 'gnus-article-buttons)
433 (defcustom gnus-article-mouse-face 'highlight
434 "Face used for mouse highlighting in the article buffer.
436 Article buttons will be displayed in this face when the cursor is
439 :group 'gnus-article-buttons)
441 (defcustom gnus-signature-face 'gnus-signature-face
442 "Face used for highlighting a signature in the article buffer.
443 Obsolete; use the face `gnus-signature-face' for customizations instead."
445 :group 'gnus-article-highlight
446 :group 'gnus-article-signature)
448 (defface gnus-signature-face
451 "Face used for highlighting a signature in the article buffer."
452 :group 'gnus-article-highlight
453 :group 'gnus-article-signature)
455 (defface gnus-header-from-face
458 (:foreground "spring green"))
461 (:foreground "red3"))
464 "Face used for displaying from headers."
465 :group 'gnus-article-headers
466 :group 'gnus-article-highlight)
468 (defface gnus-header-subject-face
471 (:foreground "SeaGreen3"))
474 (:foreground "red4"))
476 (:bold t :italic t)))
477 "Face used for displaying subject headers."
478 :group 'gnus-article-headers
479 :group 'gnus-article-highlight)
481 (defface gnus-header-newsgroups-face
484 (:foreground "yellow" :italic t))
487 (:foreground "MidnightBlue" :italic t))
490 "Face used for displaying newsgroups headers."
491 :group 'gnus-article-headers
492 :group 'gnus-article-highlight)
494 (defface gnus-header-name-face
497 (:foreground "SeaGreen"))
500 (:foreground "maroon"))
503 "Face used for displaying header names."
504 :group 'gnus-article-headers
505 :group 'gnus-article-highlight)
507 (defface gnus-header-content-face
510 (:foreground "forest green" :italic t))
513 (:foreground "indianred4" :italic t))
515 (:italic t))) "Face used for displaying header content."
516 :group 'gnus-article-headers
517 :group 'gnus-article-highlight)
519 (defcustom gnus-header-face-alist
520 '(("From" nil gnus-header-from-face)
521 ("Subject" nil gnus-header-subject-face)
522 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
523 ("" gnus-header-name-face gnus-header-content-face))
524 "*Controls highlighting of article header.
526 An alist of the form (HEADER NAME CONTENT).
528 HEADER is a regular expression which should match the name of an
529 header header and NAME and CONTENT are either face names or nil.
531 The name of each header field will be displayed using the face
532 specified by the first element in the list where HEADER match the
533 header name and NAME is non-nil. Similarly, the content will be
534 displayed by the first non-nil matching CONTENT face."
535 :group 'gnus-article-headers
536 :group 'gnus-article-highlight
537 :type '(repeat (list (regexp :tag "Header")
539 (item :tag "skip" nil)
540 (face :value default))
541 (choice :tag "Content"
542 (item :tag "skip" nil)
543 (face :value default)))))
545 (defcustom gnus-article-decode-hook
546 '(article-decode-charset article-decode-encoded-words)
547 "*Hook run to decode charsets in articles."
548 :group 'gnus-article-headers
551 (defcustom gnus-display-mime-function 'gnus-display-mime
552 "Function to display MIME articles."
553 :group 'gnus-article-mime
556 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
557 "Function used to decode headers.")
559 (defvar gnus-article-dumbquotes-map
577 "Table for MS-to-Latin1 translation.")
579 (defcustom gnus-ignored-mime-types nil
580 "List of MIME types that should be ignored by Gnus."
581 :group 'gnus-article-mime
582 :type '(repeat regexp))
584 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
585 "List of MIME types that should not be given buttons when rendered."
586 :group 'gnus-article-mime
587 :type '(repeat regexp))
589 (defcustom gnus-article-mime-part-function nil
590 "Function called with a MIME handle as the argument.
591 This is meant for people who want to do something automatic based
592 on parts -- for instance, adding Vcard info to a database."
593 :group 'gnus-article-mime
596 (defcustom gnus-mime-multipart-functions nil
597 "An alist of MIME types to functions to display them.")
599 (defcustom gnus-article-date-lapsed-new-header nil
600 "Whether the X-Sent and Date headers can coexist.
601 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
602 either replace the old \"Date:\" header (if this variable is nil), or
603 be added below it (otherwise)."
604 :group 'gnus-article-headers
608 ;;; The treatment variables
611 (defvar gnus-part-display-hook nil
612 "Hook called on parts that are to receive treatment.")
614 (defvar gnus-article-treat-custom
615 '(choice (const :tag "Off" nil)
617 (const :tag "Header" head)
618 (const :tag "Last" last)
619 (integer :tag "Less")
620 (sexp :tag "Predicate")))
622 (defvar gnus-article-treat-head-custom
623 '(choice (const :tag "Off" nil)
624 (const :tag "Header" head)))
626 (defvar gnus-article-treat-types '("text/plain")
629 (defvar gnus-inhibit-treatment nil
630 "Whether to inhibit treatment.")
632 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
633 "Highlight the signature.
634 Valid values are nil, t, `head', `last', an integer or a predicate.
635 See the manual for details."
636 :group 'gnus-article-treat
637 :type gnus-article-treat-custom)
638 (put 'gnus-treat-highlight-signature 'highlight t)
640 (defcustom gnus-treat-buttonize t
642 Valid values are nil, t, `head', `last', an integer or a predicate.
643 See the manual for details."
644 :group 'gnus-article-treat
645 :type gnus-article-treat-custom)
646 (put 'gnus-treat-buttonize 'highlight t)
648 (defcustom gnus-treat-buttonize-head 'head
649 "Add buttons to the head.
650 Valid values are nil, t, `head', `last', an integer or a predicate.
651 See the manual for details."
652 :group 'gnus-article-treat
653 :type gnus-article-treat-head-custom)
654 (put 'gnus-treat-buttonize-head 'highlight t)
656 (defcustom gnus-treat-emphasize t
658 Valid values are nil, t, `head', `last', an integer or a predicate.
659 See the manual for details."
660 :group 'gnus-article-treat
661 :type gnus-article-treat-custom)
662 (put 'gnus-treat-emphasize 'highlight t)
664 (defcustom gnus-treat-strip-cr nil
665 "Remove carriage returns.
666 Valid values are nil, t, `head', `last', an integer or a predicate.
667 See the manual for details."
668 :group 'gnus-article-treat
669 :type gnus-article-treat-custom)
671 (defcustom gnus-treat-hide-headers 'head
673 Valid values are nil, t, `head', `last', an integer or a predicate.
674 See the manual for details."
675 :group 'gnus-article-treat
676 :type gnus-article-treat-head-custom)
678 (defcustom gnus-treat-hide-boring-headers nil
679 "Hide boring headers.
680 Valid values are nil, t, `head', `last', an integer or a predicate.
681 See the manual for details."
682 :group 'gnus-article-treat
683 :type gnus-article-treat-head-custom)
685 (defcustom gnus-treat-hide-signature nil
687 Valid values are nil, t, `head', `last', an integer or a predicate.
688 See the manual for details."
689 :group 'gnus-article-treat
690 :type gnus-article-treat-custom)
692 (defcustom gnus-treat-fill-article nil
694 Valid values are nil, t, `head', `last', an integer or a predicate.
695 See the manual for details."
696 :group 'gnus-article-treat
697 :type gnus-article-treat-custom)
699 (defcustom gnus-treat-hide-citation nil
701 Valid values are nil, t, `head', `last', an integer or a predicate.
702 See the manual for details."
703 :group 'gnus-article-treat
704 :type gnus-article-treat-custom)
706 (defcustom gnus-treat-strip-pgp t
707 "Strip PGP signatures.
708 Valid values are nil, t, `head', `last', an integer or a predicate.
709 See the manual for details."
710 :group 'gnus-article-treat
711 :type gnus-article-treat-custom)
713 (defcustom gnus-treat-strip-pem nil
714 "Strip PEM signatures.
715 Valid values are nil, t, `head', `last', an integer or a predicate.
716 See the manual for details."
717 :group 'gnus-article-treat
718 :type gnus-article-treat-custom)
720 (defcustom gnus-treat-strip-banner t
721 "Strip banners from articles.
722 The banner to be stripped is specified in the `banner' group parameter.
723 Valid values are nil, t, `head', `last', an integer or a predicate.
724 See the manual for details."
725 :group 'gnus-article-treat
726 :type gnus-article-treat-custom)
728 (defcustom gnus-treat-highlight-headers 'head
729 "Highlight the headers.
730 Valid values are nil, t, `head', `last', an integer or a predicate.
731 See the manual for details."
732 :group 'gnus-article-treat
733 :type gnus-article-treat-head-custom)
734 (put 'gnus-treat-highlight-headers 'highlight t)
736 (defcustom gnus-treat-highlight-citation t
737 "Highlight cited text.
738 Valid values are nil, t, `head', `last', an integer or a predicate.
739 See the manual for details."
740 :group 'gnus-article-treat
741 :type gnus-article-treat-custom)
742 (put 'gnus-treat-highlight-citation 'highlight t)
744 (defcustom gnus-treat-date-ut nil
745 "Display the Date in UT (GMT).
746 Valid values are nil, t, `head', `last', an integer or a predicate.
747 See the manual for details."
748 :group 'gnus-article-treat
749 :type gnus-article-treat-head-custom)
751 (defcustom gnus-treat-date-local nil
752 "Display the Date in the local timezone.
753 Valid values are nil, t, `head', `last', an integer or a predicate.
754 See the manual for details."
755 :group 'gnus-article-treat
756 :type gnus-article-treat-head-custom)
758 (defcustom gnus-treat-date-lapsed nil
759 "Display the Date header in a way that says how much time has elapsed.
760 Valid values are nil, t, `head', `last', an integer or a predicate.
761 See the manual for details."
762 :group 'gnus-article-treat
763 :type gnus-article-treat-head-custom)
765 (defcustom gnus-treat-date-original nil
766 "Display the date in the original timezone.
767 Valid values are nil, t, `head', `last', an integer or a predicate.
768 See the manual for details."
769 :group 'gnus-article-treat
770 :type gnus-article-treat-head-custom)
772 (defcustom gnus-treat-date-iso8601 nil
773 "Display the date in the ISO8601 format.
774 Valid values are nil, t, `head', `last', an integer or a predicate.
775 See the manual for details."
776 :group 'gnus-article-treat
777 :type gnus-article-treat-head-custom)
779 (defcustom gnus-treat-date-user-defined nil
780 "Display the date in a user-defined format.
781 The format is defined by the `gnus-article-time-format' variable.
782 Valid values are nil, t, `head', `last', an integer or a predicate.
783 See the manual for details."
784 :group 'gnus-article-treat
785 :type gnus-article-treat-head-custom)
787 (defcustom gnus-treat-strip-headers-in-body t
788 "Strip the X-No-Archive header line from the beginning of the body.
789 Valid values are nil, t, `head', `last', an integer or a predicate.
790 See the manual for details."
791 :group 'gnus-article-treat
792 :type gnus-article-treat-custom)
794 (defcustom gnus-treat-strip-trailing-blank-lines nil
795 "Strip trailing blank lines.
796 Valid values are nil, t, `head', `last', an integer or a predicate.
797 See the manual for details."
798 :group 'gnus-article-treat
799 :type gnus-article-treat-custom)
801 (defcustom gnus-treat-strip-leading-blank-lines nil
802 "Strip leading blank lines.
803 Valid values are nil, t, `head', `last', an integer or a predicate.
804 See the manual for details."
805 :group 'gnus-article-treat
806 :type gnus-article-treat-custom)
808 (defcustom gnus-treat-strip-multiple-blank-lines nil
809 "Strip multiple blank lines.
810 Valid values are nil, t, `head', `last', an integer or a predicate.
811 See the manual for details."
812 :group 'gnus-article-treat
813 :type gnus-article-treat-custom)
815 (defcustom gnus-treat-strip-blank-lines nil
816 "Strip all blank lines.
817 Valid values are nil, t, `head', `last', an integer or a predicate.
818 See the manual for details."
819 :group 'gnus-article-treat
820 :type gnus-article-treat-custom)
822 (defcustom gnus-treat-overstrike t
823 "Treat overstrike highlighting.
824 Valid values are nil, t, `head', `last', an integer or a predicate.
825 See the manual for details."
826 :group 'gnus-article-treat
827 :type gnus-article-treat-custom)
828 (put 'gnus-treat-overstrike 'highlight t)
830 (defcustom gnus-treat-display-xface (if (and gnus-xemacs (featurep 'xface))
832 "Display X-Face headers.
833 Valid values are nil, t, `head', `last', an integer or a predicate.
834 See the manual for details."
835 :group 'gnus-article-treat
836 :type gnus-article-treat-head-custom)
837 (put 'gnus-treat-display-xface 'highlight t)
839 (defcustom gnus-treat-display-smileys (if (and gnus-xemacs
843 Valid values are nil, t, `head', `last', an integer or a predicate.
844 See the manual for details."
845 :group 'gnus-article-treat
846 :type gnus-article-treat-custom)
847 (put 'gnus-treat-display-smileys 'highlight t)
849 (defcustom gnus-treat-display-picons (if gnus-xemacs 'head nil)
851 Valid values are nil, t, `head', `last', an integer or a predicate.
852 See the manual for details."
853 :group 'gnus-article-treat
854 :type gnus-article-treat-head-custom)
855 (put 'gnus-treat-display-picons 'highlight t)
857 (defcustom gnus-treat-capitalize-sentences nil
858 "Capitalize sentence-starting words.
859 Valid values are nil, t, `head', `last', an integer or a predicate.
860 See the manual for details."
861 :group 'gnus-article-treat
862 :type gnus-article-treat-custom)
864 (defcustom gnus-treat-fill-long-lines nil
866 Valid values are nil, t, `head', `last', an integer or a predicate.
867 See the manual for details."
868 :group 'gnus-article-treat
869 :type gnus-article-treat-custom)
871 (defcustom gnus-treat-play-sounds nil
873 Valid values are nil, t, `head', `last', an integer or a predicate.
874 See the manual for details."
875 :group 'gnus-article-treat
876 :type gnus-article-treat-custom)
878 ;;; Internal variables
880 (defvar article-goto-body-goes-to-point-min-p nil)
881 (defvar gnus-article-wash-types nil)
883 (defvar gnus-article-mime-handle-alist-1 nil)
884 (defvar gnus-treatment-function-alist
885 '((gnus-treat-strip-banner gnus-article-strip-banner)
886 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
887 (gnus-treat-highlight-signature gnus-article-highlight-signature)
888 (gnus-treat-buttonize gnus-article-add-buttons)
889 (gnus-treat-fill-article gnus-article-fill-cited-article)
890 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
891 (gnus-treat-strip-cr gnus-article-remove-cr)
892 (gnus-treat-emphasize gnus-article-emphasize)
893 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
894 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
895 (gnus-treat-hide-signature gnus-article-hide-signature)
896 (gnus-treat-hide-citation gnus-article-hide-citation)
897 (gnus-treat-strip-pgp gnus-article-hide-pgp)
898 (gnus-treat-strip-pem gnus-article-hide-pem)
899 (gnus-treat-highlight-headers gnus-article-highlight-headers)
900 (gnus-treat-highlight-citation gnus-article-highlight-citation)
901 (gnus-treat-highlight-signature gnus-article-highlight-signature)
902 (gnus-treat-date-ut gnus-article-date-ut)
903 (gnus-treat-date-local gnus-article-date-local)
904 (gnus-treat-date-lapsed gnus-article-date-lapsed)
905 (gnus-treat-date-original gnus-article-date-original)
906 (gnus-treat-date-user-defined gnus-article-date-user)
907 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
908 (gnus-treat-strip-trailing-blank-lines
909 gnus-article-remove-trailing-blank-lines)
910 (gnus-treat-strip-leading-blank-lines
911 gnus-article-strip-leading-blank-lines)
912 (gnus-treat-strip-multiple-blank-lines
913 gnus-article-strip-multiple-blank-lines)
914 (gnus-treat-strip-blank-lines gnus-article-strip-blank-lines)
915 (gnus-treat-overstrike gnus-article-treat-overstrike)
916 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
917 (gnus-treat-display-xface gnus-article-display-x-face)
918 (gnus-treat-display-smileys gnus-smiley-display)
919 (gnus-treat-display-picons gnus-article-display-picons)
920 (gnus-treat-play-sounds gnus-earcon-display)))
922 (defvar gnus-article-mime-handle-alist nil)
923 (defvar article-lapsed-timer nil)
924 (defvar gnus-article-current-summary nil)
926 (defvar gnus-article-mode-syntax-table
927 (let ((table (copy-syntax-table text-mode-syntax-table)))
928 (modify-syntax-entry ?- "w" table)
929 (modify-syntax-entry ?> ")" table)
930 (modify-syntax-entry ?< "(" table)
932 "Syntax table used in article mode buffers.
933 Initialized from `text-mode-syntax-table.")
935 (defvar gnus-save-article-buffer nil)
937 (defvar gnus-article-mode-line-format-alist
938 (nconc '((?w (gnus-article-wash-status) ?s)
939 (?m (gnus-article-mime-part-status) ?s))
940 gnus-summary-mode-line-format-alist))
942 (defvar gnus-number-of-articles-to-be-saved nil)
944 (defvar gnus-inhibit-hiding nil)
946 (defsubst gnus-article-hide-text (b e props)
947 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
948 (add-text-properties b e props)
949 (when (memq 'intangible props)
951 (max (1- b) (point-min))
952 b 'intangible (cddr (memq 'intangible props)))))
953 (defsubst gnus-article-unhide-text (b e)
954 "Remove hidden text properties from region between B and E."
955 (remove-text-properties b e gnus-hidden-properties)
956 (when (memq 'intangible gnus-hidden-properties)
957 (put-text-property (max (1- b) (point-min))
960 (defun gnus-article-hide-text-type (b e type)
961 "Hide text of TYPE between B and E."
962 (push type gnus-article-wash-types)
963 (gnus-article-hide-text
964 b e (cons 'article-type (cons type gnus-hidden-properties))))
966 (defun gnus-article-unhide-text-type (b e type)
967 "Unhide text of TYPE between B and E."
968 (setq gnus-article-wash-types
969 (delq type gnus-article-wash-types))
970 (remove-text-properties
971 b e (cons 'article-type (cons type gnus-hidden-properties)))
972 (when (memq 'intangible gnus-hidden-properties)
973 (put-text-property (max (1- b) (point-min))
976 (defun gnus-article-hide-text-of-type (type)
977 "Hide text of TYPE in the current buffer."
979 (let ((b (point-min))
981 (while (setq b (text-property-any b e 'article-type type))
982 (add-text-properties b (incf b) gnus-hidden-properties)))))
984 (defun gnus-article-delete-text-of-type (type)
985 "Delete text of TYPE in the current buffer."
987 (let ((b (point-min)))
988 (while (setq b (text-property-any b (point-max) 'article-type type))
990 b (or (text-property-not-all b (point-max) 'article-type type)
993 (defun gnus-article-delete-invisible-text ()
994 "Delete all invisible text in the current buffer."
996 (let ((b (point-min)))
997 (while (setq b (text-property-any b (point-max) 'invisible t))
999 b (or (text-property-not-all b (point-max) 'invisible t)
1002 (defun gnus-article-text-type-exists-p (type)
1003 "Say whether any text of type TYPE exists in the buffer."
1004 (text-property-any (point-min) (point-max) 'article-type type))
1006 (defsubst gnus-article-header-rank ()
1007 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1008 (let ((list gnus-sorted-header-list)
1011 (when (looking-at (car list))
1013 (setq list (cdr list))
1017 (defun article-hide-headers (&optional arg delete)
1018 "Hide unwanted headers and possibly sort them as well."
1020 ;; This function might be inhibited.
1021 (unless gnus-inhibit-hiding
1024 (let ((buffer-read-only nil)
1025 (case-fold-search t)
1026 (max (1+ (length gnus-sorted-header-list)))
1027 (ignored (when (not gnus-visible-headers)
1028 (cond ((stringp gnus-ignored-headers)
1029 gnus-ignored-headers)
1030 ((listp gnus-ignored-headers)
1031 (mapconcat 'identity gnus-ignored-headers
1034 (cond ((stringp gnus-visible-headers)
1035 gnus-visible-headers)
1036 ((and gnus-visible-headers
1037 (listp gnus-visible-headers))
1038 (mapconcat 'identity gnus-visible-headers "\\|"))))
1039 (inhibit-point-motion-hooks t)
1041 ;; First we narrow to just the headers.
1042 (article-narrow-to-head)
1043 ;; Hide any "From " lines at the beginning of (mail) articles.
1044 (while (looking-at "From ")
1047 (delete-region (point-min) (point)))
1048 ;; Then treat the rest of the header lines.
1049 ;; Then we use the two regular expressions
1050 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1051 ;; select which header lines is to remain visible in the
1053 (while (re-search-forward "^[^ \t]*:" nil t)
1055 ;; Mark the rank of the header.
1057 (point) (1+ (point)) 'message-rank
1058 (if (or (and visible (looking-at visible))
1060 (not (looking-at ignored))))
1061 (gnus-article-header-rank)
1064 (message-sort-headers-1)
1065 (when (setq beg (text-property-any
1066 (point-min) (point-max) 'message-rank (+ 2 max)))
1067 ;; We delete the unwanted headers.
1068 (add-text-properties (point-min) (+ 5 (point-min))
1069 '(article-type headers dummy-invisible t))
1070 (delete-region beg (point-max))))))))
1072 (defun article-hide-boring-headers (&optional arg)
1073 "Toggle hiding of headers that aren't very interesting.
1074 If given a negative prefix, always show; if given a positive prefix,
1076 (interactive (gnus-article-hidden-arg))
1077 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1078 (not gnus-show-all-headers))
1081 (let ((buffer-read-only nil)
1082 (list gnus-boring-article-headers)
1083 (inhibit-point-motion-hooks t)
1085 (article-narrow-to-head)
1087 (setq elem (pop list))
1088 (goto-char (point-min))
1090 ;; Hide empty headers.
1092 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1094 (gnus-article-hide-text-type
1095 (progn (beginning-of-line) (point))
1098 (if (re-search-forward "^[^ \t]" nil t)
1102 ;; Hide boring Newsgroups header.
1103 ((eq elem 'newsgroups)
1104 (when (equal (gnus-fetch-field "newsgroups")
1105 (gnus-group-real-name
1106 (if (boundp 'gnus-newsgroup-name)
1109 (gnus-article-hide-header "newsgroups")))
1110 ((eq elem 'followup-to)
1111 (when (equal (message-fetch-field "followup-to")
1112 (message-fetch-field "newsgroups"))
1113 (gnus-article-hide-header "followup-to")))
1114 ((eq elem 'reply-to)
1115 (let ((from (message-fetch-field "from"))
1116 (reply-to (message-fetch-field "reply-to")))
1121 (nth 1 (mail-extract-address-components from))
1122 (nth 1 (mail-extract-address-components reply-to)))))
1123 (gnus-article-hide-header "reply-to"))))
1125 (let ((date (message-fetch-field "date")))
1127 (< (days-between (current-time-string) date)
1129 (gnus-article-hide-header "date"))))
1131 (let ((to (message-fetch-field "to")))
1132 (when (> (length to) 1024)
1133 (gnus-article-hide-header "to"))))
1136 (goto-char (point-min))
1137 (while (re-search-forward "^to:" nil t)
1138 (setq to-count (1+ to-count)))
1139 (when (> to-count 1)
1140 (while (> to-count 0)
1141 (goto-char (point-min))
1143 (re-search-forward "^to:" nil nil to-count)
1145 (narrow-to-region (point) (point-max))
1146 (gnus-article-hide-header "to"))
1147 (setq to-count (1- to-count)))))))))))))
1149 (defun gnus-article-hide-header (header)
1151 (goto-char (point-min))
1152 (when (re-search-forward (concat "^" header ":") nil t)
1153 (gnus-article-hide-text-type
1154 (progn (beginning-of-line) (point))
1157 (if (re-search-forward "^[^ \t]" nil t)
1162 (defvar gnus-article-normalized-header-length 40
1163 "Length of normalized headers.")
1165 (defun article-normalize-headers ()
1166 "Make all header lines 40 characters long."
1168 (let ((buffer-read-only nil)
1172 (article-narrow-to-head)
1175 ((< (setq column (- (gnus-point-at-eol) (point)))
1176 gnus-article-normalized-header-length)
1178 (insert (make-string
1179 (- gnus-article-normalized-header-length column)
1181 ((> column gnus-article-normalized-header-length)
1182 (gnus-put-text-property
1184 (forward-char gnus-article-normalized-header-length)
1191 (forward-line 1))))))
1193 (defun article-treat-dumbquotes ()
1194 "Translate M******** sm*rtq**t*s into proper text.
1195 Note that this function guesses whether a character is a sm*rtq**t* or
1196 not, so it should only be used interactively."
1198 (article-translate-strings gnus-article-dumbquotes-map))
1200 (defun article-translate-characters (from to)
1201 "Translate all characters in the body of the article according to FROM and TO.
1202 FROM is a string of characters to translate from; to is a string of
1203 characters to translate to."
1205 (when (article-goto-body)
1206 (let ((buffer-read-only nil)
1207 (x (make-string 225 ?x))
1209 (while (< (incf i) (length x))
1212 (while (< i (length from))
1213 (aset x (aref from i) (aref to i))
1215 (translate-region (point) (point-max) x)))))
1217 (defun article-translate-strings (map)
1218 "Translate all string in the body of the article according to MAP.
1219 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1221 (when (article-goto-body)
1222 (let ((buffer-read-only nil)
1224 (while (setq elem (pop map))
1226 (while (search-forward (car elem) nil t)
1227 (replace-match (cadr elem)))))))))
1229 (defun article-treat-overstrike ()
1230 "Translate overstrikes into bold text."
1233 (when (article-goto-body)
1234 (let ((buffer-read-only nil))
1235 (while (search-forward "\b" nil t)
1236 (let ((next (char-after))
1237 (previous (char-after (- (point) 2))))
1238 ;; We do the boldification/underlining by hiding the
1239 ;; overstrikes and putting the proper text property
1243 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1244 (put-text-property (point) (1+ (point)) 'face 'bold))
1246 (gnus-article-hide-text-type
1247 (1- (point)) (1+ (point)) 'overstrike)
1249 (- (point) 2) (1- (point)) 'face 'underline))
1251 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1253 (point) (1+ (point)) 'face 'underline)))))))))
1255 (defun article-fill-long-lines ()
1256 "Fill lines that are wider than the window width."
1259 (let ((buffer-read-only nil)
1260 (width (window-width (get-buffer-window (current-buffer)))))
1263 (let ((adaptive-fill-mode nil))
1266 (when (>= (current-column) (min fill-column width))
1267 (narrow-to-region (point) (gnus-point-at-bol))
1268 (fill-paragraph nil)
1269 (goto-char (point-max))
1271 (forward-line 1)))))))
1273 (defun article-capitalize-sentences ()
1274 "Capitalize the first word in each sentence."
1277 (let ((buffer-read-only nil)
1278 (paragraph-start "^[\n\^L]"))
1282 (forward-sentence)))))
1284 (defun article-remove-cr ()
1285 "Remove trailing CRs and then translate remaining CRs into LFs."
1288 (let ((buffer-read-only nil))
1289 (goto-char (point-min))
1290 (while (re-search-forward "\r+$" nil t)
1291 (replace-match "" t t))
1292 (goto-char (point-min))
1293 (while (search-forward "\r" nil t)
1294 (replace-match "\n" t t)))))
1296 (defun article-remove-trailing-blank-lines ()
1297 "Remove all trailing blank lines from the article."
1300 (let ((buffer-read-only nil))
1301 (goto-char (point-max))
1305 (while (and (not (bobp))
1306 (looking-at "^[ \t]*$")
1307 (not (gnus-annotation-in-region-p
1308 (point) (gnus-point-at-eol))))
1313 (defun article-display-x-face (&optional force)
1314 "Look for an X-Face header and display it if present."
1315 (interactive (list 'force))
1317 ;; Delete the old process, if any.
1318 (when (process-status "article-x-face")
1319 (delete-process "article-x-face"))
1320 (let ((inhibit-point-motion-hooks t)
1321 (case-fold-search t)
1324 (article-narrow-to-head)
1325 (goto-char (point-min))
1326 (setq from (message-fetch-field "from"))
1327 (goto-char (point-min))
1328 (while (and gnus-article-x-face-command
1331 ;; Check whether this face is censored.
1332 (not gnus-article-x-face-too-ugly)
1333 (and gnus-article-x-face-too-ugly from
1334 (not (string-match gnus-article-x-face-too-ugly
1336 ;; Has to be present.
1337 (re-search-forward "^X-Face: " nil t))
1338 ;; This used to try to do multiple faces (`while' instead of
1339 ;; `when' above), but (a) sending multiple EOFs to xv doesn't
1340 ;; work (b) it can crash some versions of Emacs (c) are
1341 ;; multiple faces really something to encourage?
1342 (when (stringp gnus-article-x-face-command)
1344 ;; We now have the area of the buffer where the X-Face is stored.
1347 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
1348 ;; We display the face.
1349 (if (symbolp gnus-article-x-face-command)
1350 ;; The command is a lisp function, so we call it.
1351 (if (gnus-functionp gnus-article-x-face-command)
1352 (funcall gnus-article-x-face-command beg end)
1353 (error "%s is not a function" gnus-article-x-face-command))
1354 ;; The command is a string, so we interpret the command
1355 ;; as a, well, command, and fork it off.
1356 (let ((process-connection-type nil))
1357 (process-kill-without-query
1359 "article-x-face" nil shell-file-name shell-command-switch
1360 gnus-article-x-face-command))
1361 (process-send-region "article-x-face" beg end)
1362 (process-send-eof "article-x-face"))))))))))
1364 (defun article-decode-mime-words ()
1365 "Decode all MIME-encoded words in the article."
1368 (set-buffer gnus-article-buffer)
1369 (let ((inhibit-point-motion-hooks t)
1371 (mail-parse-charset gnus-newsgroup-charset))
1372 (mail-decode-encoded-word-region (point-min) (point-max)))))
1374 (defun article-decode-charset (&optional prompt)
1375 "Decode charset-encoded text in the article.
1376 If PROMPT (the prefix), prompt for a coding system to use."
1380 (article-narrow-to-head)
1381 (let* ((inhibit-point-motion-hooks t)
1382 (case-fold-search t)
1383 (ct (message-fetch-field "Content-Type" t))
1384 (cte (message-fetch-field "Content-Transfer-Encoding" t))
1385 (ctl (and ct (ignore-errors
1386 (mail-header-parse-content-type ct))))
1389 (mm-read-coding-system "Charset to decode: "))
1391 (mail-content-type-get ctl 'charset))))
1392 (mail-parse-charset gnus-newsgroup-charset)
1394 (when (memq charset gnus-newsgroup-ignored-charsets)
1396 (goto-char (point-max))
1399 (narrow-to-region (point) (point-max))
1400 (when (and (or (not ctl)
1401 (equal (car ctl) "text/plain"))
1404 charset (and cte (intern (downcase
1405 (gnus-strip-whitespace cte))))
1408 (defun article-decode-encoded-words ()
1409 "Remove encoded-word encoding from headers."
1410 (let ((inhibit-point-motion-hooks t)
1411 (mail-parse-charset gnus-newsgroup-charset)
1414 (article-narrow-to-head)
1415 (funcall gnus-decode-header-function (point-min) (point-max)))))
1417 (defun article-de-quoted-unreadable (&optional force)
1418 "Translate a quoted-printable-encoded article.
1419 If FORCE, decode the article whether it is marked as quoted-printable
1421 (interactive (list 'force))
1423 (let ((buffer-read-only nil)
1424 (type (gnus-fetch-field "content-transfer-encoding"))
1425 (charset gnus-newsgroup-charset))
1427 (and type (string-match "quoted-printable" (downcase type))))
1430 (narrow-to-region (point) (point-max))
1431 (quoted-printable-decode-region (point-min) (point-max))
1433 (mm-decode-body charset)))))))
1435 (defun article-hide-pgp ()
1436 "Remove any PGP headers and signatures in the current article."
1440 (let ((inhibit-point-motion-hooks t)
1441 buffer-read-only beg end)
1443 ;; Hide the "header".
1444 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
1445 (push 'pgp gnus-article-wash-types)
1446 (delete-region (match-beginning 0) (match-end 0))
1447 ;; PGP 5 and GNU PG add a `Hash: <>' comment, hide that too
1448 (when (looking-at "Hash:.*$")
1449 (delete-region (point) (1+ (gnus-point-at-eol))))
1451 ;; Hide the actual signature.
1452 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
1453 (setq end (1+ (match-beginning 0)))
1456 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
1458 ;; Perhaps we shouldn't hide to the end of the buffer
1459 ;; if there is no end to the signature?
1461 ;; Hide "- " PGP quotation markers.
1463 (narrow-to-region beg end)
1464 (goto-char (point-min))
1465 (while (re-search-forward "^- " nil t)
1467 (match-beginning 0) (match-end 0)))
1469 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
1471 (defun article-hide-pem (&optional arg)
1472 "Toggle hiding of any PEM headers and signatures in the current article.
1473 If given a negative prefix, always show; if given a positive prefix,
1475 (interactive (gnus-article-hidden-arg))
1476 (unless (gnus-article-check-hidden-text 'pem arg)
1478 (let (buffer-read-only end)
1479 (goto-char (point-min))
1480 ;; Hide the horrendously ugly "header".
1481 (when (and (search-forward
1482 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
1484 (setq end (1+ (match-beginning 0))))
1485 (push 'pem gnus-article-wash-types)
1486 (gnus-article-hide-text-type
1488 (if (search-forward "\n\n" nil t)
1492 ;; Hide the trailer as well
1493 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
1495 (gnus-article-hide-text-type
1496 (match-beginning 0) (match-end 0) 'pem)))))))
1498 (defun article-strip-banner ()
1499 "Strip the banner specified by the `banner' group parameter."
1503 (let ((inhibit-point-motion-hooks t)
1504 (banner (gnus-group-get-parameter gnus-newsgroup-name 'banner))
1505 (gnus-signature-limit nil)
1506 buffer-read-only beg end)
1510 ((eq banner 'signature)
1511 (when (gnus-article-narrow-to-signature)
1514 (delete-region (point) (point-max))))
1516 (while (re-search-forward banner nil t)
1517 (delete-region (match-beginning 0) (match-end 0))))))))))
1519 (defun article-hide-signature (&optional arg)
1520 "Hide the signature in the current article.
1521 If given a negative prefix, always show; if given a positive prefix,
1523 (interactive (gnus-article-hidden-arg))
1524 (unless (gnus-article-check-hidden-text 'signature arg)
1527 (let ((buffer-read-only nil))
1528 (when (gnus-article-narrow-to-signature)
1529 (gnus-article-hide-text-type
1530 (point-min) (point-max) 'signature)))))))
1532 (defun article-strip-headers-in-body ()
1533 "Strip offensive headers from bodies."
1537 (let ((case-fold-search t))
1538 (when (looking-at "x-no-archive:")
1539 (gnus-delete-line)))))
1541 (defun article-strip-leading-blank-lines ()
1542 "Remove all blank lines from the beginning of the article."
1545 (let ((inhibit-point-motion-hooks t)
1547 (when (article-goto-body)
1548 (while (and (not (eobp))
1549 (looking-at "[ \t]*$"))
1550 (gnus-delete-line))))))
1552 (defun article-narrow-to-head ()
1553 "Narrow the buffer to the head of the message.
1554 Point is left at the beginning of the narrowed-to region."
1556 (goto-char (point-min))
1557 (if (search-forward "\n\n" nil 1)
1560 (goto-char (point-min)))
1562 (defun article-goto-body ()
1563 "Place point at the start of the body."
1564 (goto-char (point-min))
1566 ;; This variable is only bound when dealing with separate
1568 (article-goto-body-goes-to-point-min-p
1570 ((search-forward "\n\n" nil t)
1573 (goto-char (point-max))
1576 (defun article-strip-multiple-blank-lines ()
1577 "Replace consecutive blank lines with one empty line."
1580 (let ((inhibit-point-motion-hooks t)
1582 ;; First make all blank lines empty.
1584 (while (re-search-forward "^[ \t]+$" nil t)
1585 (unless (gnus-annotation-in-region-p
1586 (match-beginning 0) (match-end 0))
1587 (replace-match "" nil t)))
1588 ;; Then replace multiple empty lines with a single empty line.
1590 (while (re-search-forward "\n\n\n+" nil t)
1591 (unless (gnus-annotation-in-region-p
1592 (match-beginning 0) (match-end 0))
1593 (replace-match "\n\n" t t))))))
1595 (defun article-strip-leading-space ()
1596 "Remove all white space from the beginning of the lines in the article."
1599 (let ((inhibit-point-motion-hooks t)
1602 (while (re-search-forward "^[ \t]+" nil t)
1603 (replace-match "" t t)))))
1605 (defun article-strip-trailing-space ()
1606 "Remove all white space from the end of the lines in the article."
1609 (let ((inhibit-point-motion-hooks t)
1612 (while (re-search-forward "[ \t]+$" nil t)
1613 (replace-match "" t t)))))
1615 (defun article-strip-blank-lines ()
1616 "Strip leading, trailing and multiple blank lines."
1618 (article-strip-leading-blank-lines)
1619 (article-remove-trailing-blank-lines)
1620 (article-strip-multiple-blank-lines))
1622 (defun article-strip-all-blank-lines ()
1623 "Strip all blank lines."
1626 (let ((inhibit-point-motion-hooks t)
1629 (while (re-search-forward "^[ \t]*\n" nil t)
1630 (replace-match "" t t)))))
1632 (defun gnus-article-narrow-to-signature ()
1633 "Narrow to the signature; return t if a signature is found, else nil."
1634 (let ((inhibit-point-motion-hooks t))
1635 (when (gnus-article-search-signature)
1637 ;; Check whether we have some limits to what we consider
1638 ;; to be a signature.
1639 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
1640 (list gnus-signature-limit)))
1642 (while (setq limit (pop limits))
1643 (if (or (and (integerp limit)
1644 (< (- (point-max) (point)) limit))
1646 (< (count-lines (point) (point-max)) limit))
1647 (and (gnus-functionp limit)
1649 (and (stringp limit)
1650 (not (re-search-forward limit nil t))))
1651 () ; This limit did not succeed.
1655 (narrow-to-region (point) (point-max))
1658 (defun gnus-article-search-signature ()
1659 "Search the current buffer for the signature separator.
1660 Put point at the beginning of the signature separator."
1661 (let ((cur (point)))
1662 (goto-char (point-max))
1663 (if (if (stringp gnus-signature-separator)
1664 (re-search-backward gnus-signature-separator nil t)
1665 (let ((seps gnus-signature-separator))
1667 (not (re-search-backward (car seps) nil t)))
1674 (defun gnus-article-hidden-arg ()
1675 "Return the current prefix arg as a number, or 0 if no prefix."
1676 (list (if current-prefix-arg
1677 (prefix-numeric-value current-prefix-arg)
1680 (defun gnus-article-check-hidden-text (type arg)
1681 "Return nil if hiding is necessary.
1682 Arg can be nil or a number. Nil and positive means hide, negative
1683 means show, 0 means toggle."
1686 (let ((hide (gnus-article-hidden-text-p type)))
1692 (gnus-article-show-hidden-text type))
1694 (if (eq hide 'hidden)
1695 (gnus-article-show-hidden-text type)
1698 (defun gnus-article-hidden-text-p (type)
1699 "Say whether the current buffer contains hidden text of type TYPE."
1700 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
1702 (not (get-text-property pos 'invisible))
1703 (not (get-text-property pos 'dummy-invisible)))
1705 (text-property-any (1+ pos) (point-max) 'article-type type)))
1710 (defun gnus-article-show-hidden-text (type &optional hide)
1711 "Show all hidden text of type TYPE.
1712 If HIDE, hide the text instead."
1714 (let ((buffer-read-only nil)
1715 (inhibit-point-motion-hooks t)
1718 (while (setq beg (text-property-any end (point-max) 'article-type type))
1721 (text-property-not-all beg (point-max) 'article-type type)
1724 (gnus-article-hide-text beg end gnus-hidden-properties)
1725 (gnus-article-unhide-text beg end))
1729 (defconst article-time-units
1730 `((year . ,(* 365.25 24 60 60))
1731 (week . ,(* 7 24 60 60))
1732 (day . ,(* 24 60 60))
1736 "Mapping from time units to seconds.")
1738 (defun article-date-ut (&optional type highlight header)
1739 "Convert DATE date to universal time in the current article.
1740 If TYPE is `local', convert to local time; if it is `lapsed', output
1741 how much time has lapsed since DATE. For `lapsed', the value of
1742 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
1743 should replace the \"Date:\" one, or should be added below it."
1744 (interactive (list 'ut t))
1745 (let* ((header (or header
1746 (mail-header-date (save-excursion
1747 (set-buffer gnus-summary-buffer)
1748 gnus-current-headers))
1749 (message-fetch-field "date")
1751 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
1754 ((not gnus-article-date-lapsed-new-header)
1760 (date (if (vectorp header) (mail-header-date header)
1762 (inhibit-point-motion-hooks t)
1765 (when (and date (not (string= date "")))
1768 (article-narrow-to-head)
1769 (when (re-search-forward tdate-regexp nil t)
1770 (setq bface (get-text-property (gnus-point-at-bol) 'face)
1771 eface (get-text-property (1- (gnus-point-at-eol))
1774 (goto-char (point-min))
1775 (let ((buffer-read-only nil))
1776 ;; Delete any old Date headers.
1777 (while (re-search-forward date-regexp nil t)
1779 (delete-region (progn (beginning-of-line) (point))
1780 (progn (end-of-line) (point)))
1781 (delete-region (progn (beginning-of-line) (point))
1782 (progn (forward-line 1) (point))))
1784 (insert (article-make-date-line date type))
1790 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
1791 (put-text-property (match-beginning 1) (1+ (match-end 1))
1793 (put-text-property (match-beginning 2) (match-end 2)
1796 (defun article-make-date-line (date type)
1797 "Return a DATE line of TYPE."
1798 (let ((time (condition-case ()
1802 ;; Convert to the local timezone. We have to slap a
1803 ;; `condition-case' round the calls to the timezone
1804 ;; functions since they aren't particularly resistant to
1807 (let ((tz (car (current-time-zone))))
1808 (format "Date: %s %s%04d" (current-time-string time)
1809 (if (> tz 0) "+" "-") (abs (/ tz 36)))))
1810 ;; Convert to Universal Time.
1813 (current-time-string
1814 (let* ((e (parse-time-string date))
1815 (tm (apply 'encode-time e))
1817 (ls (- (cadr tm) (car (current-time-zone)))))
1818 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
1819 ((> ls 65535) (list (1+ ms) (- ls 65536)))
1822 ;; Get the original date from the article.
1823 ((eq type 'original)
1824 (concat "Date: " (if (string-match "\n+$" date)
1825 (substring date 0 (match-beginning 0))
1827 ;; Let the user define the format.
1829 (if (gnus-functionp gnus-article-time-format)
1830 (funcall gnus-article-time-format time)
1833 (format-time-string gnus-article-time-format time))))
1838 (format-time-string "%Y%m%dT%H%M%S" time)))
1839 ;; Do an X-Sent lapsed format.
1841 ;; If the date is seriously mangled, the timezone functions are
1842 ;; liable to bug out, so we ignore all errors.
1843 (let* ((now (current-time))
1844 (real-time (subtract-time now time))
1845 (real-sec (and real-time
1846 (+ (* (float (car real-time)) 65536)
1848 (sec (and real-time (abs real-sec)))
1858 ;; This is a bit convoluted, but basically we go
1859 ;; through the time units for years, weeks, etc,
1860 ;; and divide things to see whether that results
1861 ;; in positive answers.
1864 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
1865 ;; The (remaining) seconds are too few to
1866 ;; be divided into this time unit.
1868 ;; It's big enough, so we output it.
1869 (setq sec (- sec (* num (cdr unit))))
1871 (concat (if prev ", " "") (int-to-string
1873 " " (symbol-name (car unit))
1874 (if (> num 1) "s" ""))
1876 article-time-units "")
1877 ;; If dates are odd, then it might appear like the
1878 ;; article was sent in the future.
1881 " in the future"))))))
1883 (error "Unknown conversion type: %s" type)))))
1885 (defun article-date-local (&optional highlight)
1886 "Convert the current article date to the local timezone."
1887 (interactive (list t))
1888 (article-date-ut 'local highlight))
1890 (defun article-date-original (&optional highlight)
1891 "Convert the current article date to what it was originally.
1892 This is only useful if you have used some other date conversion
1893 function and want to see what the date was before converting."
1894 (interactive (list t))
1895 (article-date-ut 'original highlight))
1897 (defun article-date-lapsed (&optional highlight)
1898 "Convert the current article date to time lapsed since it was sent."
1899 (interactive (list t))
1900 (article-date-ut 'lapsed highlight))
1902 (defun article-update-date-lapsed ()
1903 "Function to be run from a timer to update the lapsed time line."
1904 (let (deactivate-mark)
1909 (set-buffer (window-buffer w))
1910 (when (eq major-mode 'gnus-article-mode)
1911 (goto-char (point-min))
1912 (when (re-search-forward "^X-Sent:" nil t)
1913 (article-date-lapsed t))))
1916 (defun gnus-start-date-timer (&optional n)
1917 "Start a timer to update the X-Sent header in the article buffers.
1918 The numerical prefix says how frequently (in seconds) the function
1923 (gnus-stop-date-timer)
1924 (setq article-lapsed-timer
1925 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
1927 (defun gnus-stop-date-timer ()
1928 "Stop the X-Sent timer."
1930 (when article-lapsed-timer
1931 (nnheader-cancel-timer article-lapsed-timer)
1932 (setq article-lapsed-timer nil)))
1934 (defun article-date-user (&optional highlight)
1935 "Convert the current article date to the user-defined format.
1936 This format is defined by the `gnus-article-time-format' variable."
1937 (interactive (list t))
1938 (article-date-ut 'user highlight))
1940 (defun article-date-iso8601 (&optional highlight)
1941 "Convert the current article date to ISO8601."
1942 (interactive (list t))
1943 (article-date-ut 'iso8601 highlight))
1945 (defun article-show-all ()
1946 "Show all hidden text in the article buffer."
1949 (let ((buffer-read-only nil))
1950 (gnus-article-unhide-text (point-min) (point-max)))))
1952 (defun article-emphasize (&optional arg)
1953 "Emphasize text according to `gnus-emphasis-alist'."
1954 (interactive (gnus-article-hidden-arg))
1955 (unless (gnus-article-check-hidden-text 'emphasis arg)
1957 (let ((alist gnus-emphasis-alist)
1958 (buffer-read-only nil)
1959 (props (append '(article-type emphasis)
1960 gnus-hidden-properties))
1961 regexp elem beg invisible visible face)
1964 (while (setq elem (pop alist))
1966 (setq regexp (car elem)
1967 invisible (nth 1 elem)
1968 visible (nth 2 elem)
1970 (while (re-search-forward regexp nil t)
1971 (when (and (match-beginning visible) (match-beginning invisible))
1972 (gnus-article-hide-text
1973 (match-beginning invisible) (match-end invisible) props)
1974 (gnus-article-unhide-text-type
1975 (match-beginning visible) (match-end visible) 'emphasis)
1976 (gnus-put-text-property-excluding-newlines
1977 (match-beginning visible) (match-end visible) 'face face)
1978 (goto-char (match-end invisible)))))))))
1980 (defvar gnus-summary-article-menu)
1981 (defvar gnus-summary-post-menu)
1983 ;;; Saving functions.
1985 (defun gnus-article-save (save-buffer file &optional num)
1986 "Save the currently selected article."
1987 (unless gnus-save-all-headers
1988 ;; Remove headers according to `gnus-saved-headers'.
1989 (let ((gnus-visible-headers
1990 (or gnus-saved-headers gnus-visible-headers))
1991 (gnus-article-buffer save-buffer))
1993 (set-buffer save-buffer)
1994 (article-hide-headers 1 t))))
1995 (save-window-excursion
1996 (if (not gnus-default-article-saver)
1997 (error "No default saver is defined")
1998 ;; !!! Magic! The saving functions all save
1999 ;; `gnus-save-article-buffer' (or so they think), but we
2000 ;; bind that variable to our save-buffer.
2001 (set-buffer gnus-article-buffer)
2002 (let* ((gnus-save-article-buffer save-buffer)
2005 ((not gnus-prompt-before-saving) 'default)
2006 ((eq gnus-prompt-before-saving 'always) nil)
2008 (gnus-number-of-articles-to-be-saved
2009 (when (eq gnus-prompt-before-saving t)
2011 (set-buffer gnus-article-current-summary)
2012 (funcall gnus-default-article-saver filename)))))
2014 (defun gnus-read-save-file-name (prompt &optional filename
2015 function group headers variable)
2017 (funcall function group headers (symbol-value variable)))
2022 ((eq filename 'default)
2028 (let* ((split-name (gnus-get-split-value gnus-split-methods))
2031 (if (and gnus-number-of-articles-to-be-saved
2032 (> gnus-number-of-articles-to-be-saved 1))
2033 (format "these %d articles"
2034 gnus-number-of-articles-to-be-saved)
2037 ;; Let the split methods have their say.
2039 ;; No split name was found.
2042 (concat prompt " (default "
2043 (file-name-nondirectory default-name) ") ")
2044 (file-name-directory default-name)
2046 ;; A single group name is returned.
2047 ((stringp split-name)
2049 (funcall function split-name headers
2050 (symbol-value variable)))
2052 (concat prompt " (default "
2053 (file-name-nondirectory default-name) ") ")
2054 (file-name-directory default-name)
2056 ;; A single split name was found
2057 ((= 1 (length split-name))
2058 (let* ((name (expand-file-name
2059 (car split-name) gnus-article-save-directory))
2060 (dir (cond ((file-directory-p name)
2061 (file-name-as-directory name))
2062 ((file-exists-p name) name)
2063 (t gnus-article-save-directory))))
2065 (concat prompt " (default " name ") ")
2067 ;; A list of splits was found.
2069 (setq split-name (nreverse split-name))
2071 (let ((file-name-history
2072 (nconc split-name file-name-history)))
2076 (concat prompt " (`M-p' for defaults) ")
2077 gnus-article-save-directory
2079 gnus-article-save-directory)))
2080 (car (push result file-name-history)))))))
2081 ;; Create the directory.
2082 (gnus-make-directory (file-name-directory file))
2083 ;; If we have read a directory, we append the default file name.
2084 (when (file-directory-p file)
2085 (setq file (concat (file-name-as-directory file)
2086 (file-name-nondirectory default-name))))
2087 ;; Possibly translate some characters.
2088 (nnheader-translate-file-chars file)))))
2089 (gnus-make-directory (file-name-directory result))
2090 (set variable result)))
2092 (defun gnus-article-archive-name (group)
2093 "Return the first instance of an \"Archive-name\" in the current buffer."
2094 (let ((case-fold-search t))
2095 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
2096 (nnheader-concat gnus-article-save-directory
2097 (match-string 1)))))
2099 (defun gnus-article-nndoc-name (group)
2100 "If GROUP is an nndoc group, return the name of the parent group."
2101 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
2102 (gnus-group-get-parameter group 'save-article-group)))
2104 (defun gnus-summary-save-in-rmail (&optional filename)
2105 "Append this article to Rmail file.
2106 Optional argument FILENAME specifies file name.
2107 Directory to save to is default to `gnus-article-save-directory'."
2108 (setq filename (gnus-read-save-file-name
2109 "Save %s in rmail file:" filename
2110 gnus-rmail-save-name gnus-newsgroup-name
2111 gnus-current-headers 'gnus-newsgroup-last-rmail))
2112 (gnus-eval-in-buffer-window gnus-save-article-buffer
2116 (gnus-output-to-rmail filename))))
2119 (defun gnus-summary-save-in-mail (&optional filename)
2120 "Append this article to Unix mail file.
2121 Optional argument FILENAME specifies file name.
2122 Directory to save to is default to `gnus-article-save-directory'."
2123 (setq filename (gnus-read-save-file-name
2124 "Save %s in Unix mail file:" filename
2125 gnus-mail-save-name gnus-newsgroup-name
2126 gnus-current-headers 'gnus-newsgroup-last-mail))
2127 (gnus-eval-in-buffer-window gnus-save-article-buffer
2131 (if (and (file-readable-p filename)
2132 (mail-file-babyl-p filename))
2133 (rmail-output-to-rmail-file filename t)
2134 (gnus-output-to-mail filename)))))
2137 (defun gnus-summary-save-in-file (&optional filename overwrite)
2138 "Append this article to file.
2139 Optional argument FILENAME specifies file name.
2140 Directory to save to is default to `gnus-article-save-directory'."
2141 (setq filename (gnus-read-save-file-name
2142 "Save %s in file:" filename
2143 gnus-file-save-name gnus-newsgroup-name
2144 gnus-current-headers 'gnus-newsgroup-last-file))
2145 (gnus-eval-in-buffer-window gnus-save-article-buffer
2149 (when (and overwrite
2150 (file-exists-p filename))
2151 (delete-file filename))
2152 (gnus-output-to-file filename))))
2155 (defun gnus-summary-write-to-file (&optional filename)
2156 "Write this article to a file.
2157 Optional argument FILENAME specifies file name.
2158 The directory to save in defaults to `gnus-article-save-directory'."
2159 (gnus-summary-save-in-file nil t))
2161 (defun gnus-summary-save-body-in-file (&optional filename)
2162 "Append this article body to a file.
2163 Optional argument FILENAME specifies file name.
2164 The directory to save in defaults to `gnus-article-save-directory'."
2165 (setq filename (gnus-read-save-file-name
2166 "Save %s body in file:" filename
2167 gnus-file-save-name gnus-newsgroup-name
2168 gnus-current-headers 'gnus-newsgroup-last-file))
2169 (gnus-eval-in-buffer-window gnus-save-article-buffer
2173 (when (article-goto-body)
2174 (narrow-to-region (point) (point-max)))
2175 (gnus-output-to-file filename))))
2178 (defun gnus-summary-save-in-pipe (&optional command)
2179 "Pipe this article to subprocess."
2181 (cond ((and (eq command 'default)
2182 gnus-last-shell-command)
2183 gnus-last-shell-command)
2187 "Shell command on %s: "
2188 (if (and gnus-number-of-articles-to-be-saved
2189 (> gnus-number-of-articles-to-be-saved 1))
2190 (format "these %d articles"
2191 gnus-number-of-articles-to-be-saved)
2193 gnus-last-shell-command))))
2194 (when (string-equal command "")
2195 (setq command gnus-last-shell-command))
2196 (gnus-eval-in-buffer-window gnus-article-buffer
2199 (shell-command-on-region (point-min) (point-max) command nil)))
2200 (setq gnus-last-shell-command command))
2202 ;;; Article file names when saving.
2204 (defun gnus-capitalize-newsgroup (newsgroup)
2205 "Capitalize NEWSGROUP name."
2206 (when (not (zerop (length newsgroup)))
2207 (concat (char-to-string (upcase (aref newsgroup 0)))
2208 (substring newsgroup 1))))
2210 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2211 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2212 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
2213 Otherwise, it is like ~/News/news/group/num."
2216 (concat (if (gnus-use-long-file-name 'not-save)
2217 (gnus-capitalize-newsgroup newsgroup)
2218 (gnus-newsgroup-directory-form newsgroup))
2219 "/" (int-to-string (mail-header-number headers)))
2220 gnus-article-save-directory)))
2222 (string-equal (file-name-directory default)
2223 (file-name-directory last-file))
2224 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2226 (or last-file default))))
2228 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2229 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2230 If variable `gnus-use-long-file-name' is non-nil, it is
2231 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2234 (concat (if (gnus-use-long-file-name 'not-save)
2236 (gnus-newsgroup-directory-form newsgroup))
2237 "/" (int-to-string (mail-header-number headers)))
2238 gnus-article-save-directory)))
2240 (string-equal (file-name-directory default)
2241 (file-name-directory last-file))
2242 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2244 (or last-file default))))
2246 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2247 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2248 If variable `gnus-use-long-file-name' is non-nil, it is
2249 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2252 (if (gnus-use-long-file-name 'not-save)
2253 (gnus-capitalize-newsgroup newsgroup)
2254 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2255 gnus-article-save-directory)))
2257 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2258 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2259 If variable `gnus-use-long-file-name' is non-nil, it is
2260 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2263 (if (gnus-use-long-file-name 'not-save)
2265 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2266 gnus-article-save-directory)))
2273 (setq afunc (car func)
2276 gfunc (intern (format "gnus-%s" func))))
2278 (if (not (fboundp afunc))
2280 `(lambda (&optional interactive &rest args)
2281 ,(documentation afunc t)
2282 (interactive (list t))
2284 (set-buffer gnus-article-buffer)
2286 (call-interactively ',afunc)
2287 (apply ',afunc args))))))))
2288 '(article-hide-headers
2289 article-hide-boring-headers
2290 article-treat-overstrike
2291 article-fill-long-lines
2292 article-capitalize-sentences
2294 article-display-x-face
2295 article-de-quoted-unreadable
2296 article-mime-decode-quoted-printable
2298 article-strip-banner
2300 article-hide-signature
2301 article-strip-headers-in-body
2302 article-remove-trailing-blank-lines
2303 article-strip-leading-blank-lines
2304 article-strip-multiple-blank-lines
2305 article-strip-leading-space
2306 article-strip-trailing-space
2307 article-strip-blank-lines
2308 article-strip-all-blank-lines
2310 article-date-iso8601
2311 article-date-original
2313 article-decode-mime-words
2314 article-decode-charset
2315 article-decode-encoded-words
2319 article-treat-dumbquotes
2320 article-normalize-headers
2321 (article-show-all . gnus-article-show-all-headers))))
2324 ;;; Gnus article mode
2327 (put 'gnus-article-mode 'mode-class 'special)
2329 (set-keymap-parent gnus-article-mode-map widget-keymap)
2331 (gnus-define-keys gnus-article-mode-map
2332 " " gnus-article-goto-next-page
2333 "\177" gnus-article-goto-prev-page
2334 [delete] gnus-article-goto-prev-page
2335 [backspace] gnus-article-goto-prev-page
2336 "\C-c^" gnus-article-refer-article
2337 "h" gnus-article-show-summary
2338 "s" gnus-article-show-summary
2339 "\C-c\C-m" gnus-article-mail
2340 "?" gnus-article-describe-briefly
2341 "e" gnus-article-edit
2342 "<" beginning-of-buffer
2344 "\C-c\C-i" gnus-info-find-node
2347 "\C-d" gnus-article-read-summary-keys
2348 "\M-*" gnus-article-read-summary-keys
2349 "\M-#" gnus-article-read-summary-keys
2350 "\M-^" gnus-article-read-summary-keys
2351 "\M-g" gnus-article-read-summary-keys)
2353 (substitute-key-definition
2354 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
2356 (defun gnus-article-make-menu-bar ()
2357 (gnus-turn-off-edit-menu 'article)
2358 (unless (boundp 'gnus-article-article-menu)
2360 gnus-article-article-menu gnus-article-mode-map ""
2362 ["Scroll forwards" gnus-article-goto-next-page t]
2363 ["Scroll backwards" gnus-article-goto-prev-page t]
2364 ["Show summary" gnus-article-show-summary t]
2365 ["Fetch Message-ID at point" gnus-article-refer-article t]
2366 ["Mail to address at point" gnus-article-mail t]
2367 ["Send a bug report" gnus-bug t]))
2370 gnus-article-treatment-menu gnus-article-mode-map ""
2372 ["Hide headers" gnus-article-hide-headers t]
2373 ["Hide signature" gnus-article-hide-signature t]
2374 ["Hide citation" gnus-article-hide-citation t]
2375 ["Treat overstrike" gnus-article-treat-overstrike t]
2376 ["Remove carriage return" gnus-article-remove-cr t]
2377 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]))
2379 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
2381 (when (boundp 'gnus-summary-post-menu)
2382 (define-key gnus-article-mode-map [menu-bar post]
2383 (cons "Post" gnus-summary-post-menu)))
2385 (gnus-run-hooks 'gnus-article-menu-hook)))
2387 (defun gnus-article-mode ()
2388 "Major mode for displaying an article.
2390 All normal editing commands are switched off.
2392 The following commands are available in addition to all summary mode
2394 \\<gnus-article-mode-map>
2395 \\[gnus-article-next-page]\t Scroll the article one page forwards
2396 \\[gnus-article-prev-page]\t Scroll the article one page backwards
2397 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
2398 \\[gnus-article-show-summary]\t Display the summary buffer
2399 \\[gnus-article-mail]\t Send a reply to the address near point
2400 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
2401 \\[gnus-info-find-node]\t Go to the Gnus info node"
2403 (when (gnus-visual-p 'article-menu 'menu)
2404 (gnus-article-make-menu-bar))
2405 (gnus-simplify-mode-line)
2406 (setq mode-name "Article")
2407 (setq major-mode 'gnus-article-mode)
2408 (make-local-variable 'minor-mode-alist)
2409 (use-local-map gnus-article-mode-map)
2410 (gnus-update-format-specifications nil 'article-mode)
2411 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
2412 (make-local-variable 'gnus-page-broken)
2413 (make-local-variable 'gnus-button-marker-list)
2414 (make-local-variable 'gnus-article-current-summary)
2415 (make-local-variable 'gnus-article-mime-handles)
2416 (make-local-variable 'gnus-article-decoded-p)
2417 (make-local-variable 'gnus-article-mime-handle-alist)
2418 (make-local-variable 'gnus-article-washed-types)
2419 (gnus-set-default-directory)
2420 (buffer-disable-undo)
2421 (setq buffer-read-only t)
2422 (set-syntax-table gnus-article-mode-syntax-table)
2423 (mm-enable-multibyte)
2424 (gnus-run-hooks 'gnus-article-mode-hook))
2426 (defun gnus-article-setup-buffer ()
2427 "Initialize the article buffer."
2428 (let* ((name (if gnus-single-article-buffer "*Article*"
2429 (concat "*Article " gnus-newsgroup-name "*")))
2431 (progn (string-match "\\*Article" name)
2432 (concat " *Original Article"
2433 (substring name (match-end 0))))))
2434 (setq gnus-article-buffer name)
2435 (setq gnus-original-article-buffer original)
2436 (setq gnus-article-mime-handle-alist nil)
2437 ;; This might be a variable local to the summary buffer.
2438 (unless gnus-single-article-buffer
2440 (set-buffer gnus-summary-buffer)
2441 (setq gnus-article-buffer name)
2442 (setq gnus-original-article-buffer original)
2443 (gnus-set-global-variables)))
2444 ;; Init original article buffer.
2446 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
2447 (mm-enable-multibyte)
2448 (setq major-mode 'gnus-original-article-mode)
2449 (make-local-variable 'gnus-original-article))
2450 (if (get-buffer name)
2453 (buffer-disable-undo)
2454 (setq buffer-read-only t)
2455 (unless (eq major-mode 'gnus-article-mode)
2456 (gnus-article-mode))
2459 (set-buffer (gnus-get-buffer-create name))
2461 (make-local-variable 'gnus-summary-buffer)
2462 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2463 (current-buffer)))))
2465 ;; Set article window start at LINE, where LINE is the number of lines
2466 ;; from the head of the article.
2467 (defun gnus-article-set-window-start (&optional line)
2469 (get-buffer-window gnus-article-buffer t)
2471 (set-buffer gnus-article-buffer)
2472 (goto-char (point-min))
2475 (gnus-message 6 "Moved to bookmark")
2476 (search-forward "\n\n" nil t)
2480 (defun gnus-article-prepare (article &optional all-headers header)
2481 "Prepare ARTICLE in article mode buffer.
2482 ARTICLE should either be an article number or a Message-ID.
2483 If ARTICLE is an id, HEADER should be the article headers.
2484 If ALL-HEADERS is non-nil, no headers are hidden."
2486 ;; Make sure we start in a summary buffer.
2487 (unless (eq major-mode 'gnus-summary-mode)
2488 (set-buffer gnus-summary-buffer))
2489 (setq gnus-summary-buffer (current-buffer))
2490 (let* ((gnus-article (if header (mail-header-number header) article))
2491 (summary-buffer (current-buffer))
2492 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
2493 (group gnus-newsgroup-name)
2496 (gnus-article-setup-buffer)
2497 (set-buffer gnus-article-buffer)
2498 ;; Deactivate active regions.
2499 (when (and (boundp 'transient-mark-mode)
2500 transient-mark-mode)
2501 (setq mark-active nil))
2502 (if (not (setq result (let ((buffer-read-only nil))
2503 (gnus-request-article-this-buffer
2505 ;; There is no such article.
2507 (when (and (numberp article)
2508 (not (memq article gnus-newsgroup-sparse)))
2509 (setq gnus-article-current
2510 (cons gnus-newsgroup-name article))
2511 (set-buffer gnus-summary-buffer)
2512 (setq gnus-current-article article)
2513 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
2515 (gnus-summary-set-agent-mark article)
2516 (message "Message marked for downloading"))
2517 (gnus-summary-mark-article article gnus-canceled-mark)
2518 (unless (memq article gnus-newsgroup-sparse)
2520 "No such article (may have expired or been canceled)")))))
2521 (if (or (eq result 'pseudo)
2522 (eq result 'nneething))
2525 (set-buffer summary-buffer)
2526 (push article gnus-newsgroup-history)
2527 (setq gnus-last-article gnus-current-article
2528 gnus-current-article 0
2529 gnus-current-headers nil
2530 gnus-article-current nil)
2531 (if (eq result 'nneething)
2532 (gnus-configure-windows 'summary)
2533 (gnus-configure-windows 'article))
2534 (gnus-set-global-variables))
2535 (let ((gnus-article-mime-handle-alist-1
2536 gnus-article-mime-handle-alist))
2537 (gnus-set-mode-line 'article)))
2538 ;; The result from the `request' was an actual article -
2539 ;; or at least some text that is now displayed in the
2541 (when (and (numberp article)
2542 (not (eq article gnus-current-article)))
2543 ;; Seems like a new article has been selected.
2544 ;; `gnus-current-article' must be an article number.
2546 (set-buffer summary-buffer)
2547 (push article gnus-newsgroup-history)
2548 (setq gnus-last-article gnus-current-article
2549 gnus-current-article article
2550 gnus-current-headers
2551 (gnus-summary-article-header gnus-current-article)
2552 gnus-article-current
2553 (cons gnus-newsgroup-name gnus-current-article))
2554 (unless (vectorp gnus-current-headers)
2555 (setq gnus-current-headers nil))
2556 (gnus-summary-goto-subject gnus-current-article)
2557 (when (gnus-summary-show-thread)
2558 ;; If the summary buffer really was folded, the
2559 ;; previous goto may not actually have gone to
2560 ;; the right article, but the thread root instead.
2562 (gnus-summary-goto-subject gnus-current-article))
2563 (gnus-run-hooks 'gnus-mark-article-hook)
2564 (gnus-set-mode-line 'summary)
2565 (when (gnus-visual-p 'article-highlight 'highlight)
2566 (gnus-run-hooks 'gnus-visual-mark-article-hook))
2567 ;; Set the global newsgroup variables here.
2568 (gnus-set-global-variables)
2569 (setq gnus-have-all-headers
2570 (or all-headers gnus-show-all-headers))))
2571 (when (or (numberp article)
2573 (gnus-article-prepare-display)
2575 (goto-char (point-min))
2576 (setq gnus-page-broken
2577 (when gnus-break-pages
2578 (gnus-narrow-to-page)
2580 (let ((gnus-article-mime-handle-alist-1
2581 gnus-article-mime-handle-alist))
2582 (gnus-set-mode-line 'article))
2584 (set-window-point (get-buffer-window (current-buffer)) (point))
2585 (gnus-configure-windows 'article)
2589 (defun gnus-article-prepare-display ()
2590 "Make the current buffer look like a nice article."
2591 ;; Hooks for getting information from the article.
2592 ;; This hook must be called before being narrowed.
2593 (let ((gnus-article-buffer (current-buffer))
2595 (unless (eq major-mode 'gnus-article-mode)
2596 (gnus-article-mode))
2597 (setq buffer-read-only nil)
2598 (gnus-run-hooks 'gnus-tmp-internal-hook)
2599 (gnus-run-hooks 'gnus-article-prepare-hook)
2600 (when gnus-display-mime-function
2601 (funcall gnus-display-mime-function))))
2604 ;;; Gnus MIME viewing functions
2607 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
2608 "The following specs can be used:
2610 %T MIME type, along with additional info
2611 %n The `name' parameter
2612 %d The description, if any
2613 %l The length of the encoded part
2614 %p The part identifier number
2615 %e Dots if the part isn't displayed")
2617 (defvar gnus-mime-button-line-format-alist
2618 '((?t gnus-tmp-type ?s)
2619 (?T gnus-tmp-type-long ?s)
2620 (?n gnus-tmp-name ?s)
2621 (?d gnus-tmp-description ?s)
2623 (?l gnus-tmp-length ?d)
2624 (?e gnus-tmp-dots ?s)))
2626 (defvar gnus-mime-button-commands
2627 '((gnus-article-press-button "\r" "Toggle Display")
2628 (gnus-mime-view-part "v" "View Interactively...")
2629 (gnus-mime-save-part "o" "Save...")
2630 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
2631 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
2632 (gnus-mime-internalize-part "E" "View Internally")
2633 (gnus-mime-externalize-part "e" "View Externally")
2634 (gnus-mime-pipe-part "|" "Pipe To Command...")))
2636 (defun gnus-article-mime-part-status ()
2637 (if gnus-article-mime-handle-alist-1
2638 (format " (%d parts)" (length gnus-article-mime-handle-alist-1))
2641 (defvar gnus-mime-button-map nil)
2642 (unless gnus-mime-button-map
2643 (setq gnus-mime-button-map (make-sparse-keymap))
2644 (set-keymap-parent gnus-mime-button-map gnus-article-mode-map)
2645 (define-key gnus-mime-button-map gnus-mouse-2 'gnus-article-push-button)
2646 (define-key gnus-mime-button-map gnus-down-mouse-3 'gnus-mime-button-menu)
2648 (define-key gnus-mime-button-map (cadr c) (car c)))
2649 gnus-mime-button-commands))
2651 (defun gnus-mime-button-menu (event)
2652 "Construct a context-sensitive menu of MIME commands."
2655 (let ((pos (event-start event)))
2656 (set-buffer (window-buffer (posn-window pos)))
2657 (goto-char (posn-point pos))
2658 (gnus-article-check-buffer)
2659 (let ((response (x-popup-menu
2661 ("" ,@(mapcar (lambda (c)
2662 (cons (caddr c) (car c)))
2663 gnus-mime-button-commands))))))
2665 (funcall response))))))
2667 (defun gnus-mime-view-all-parts (&optional handles)
2668 "View all the MIME parts."
2670 (save-current-buffer
2671 (set-buffer gnus-article-buffer)
2672 (let ((handles (or handles gnus-article-mime-handles))
2673 (mail-parse-charset gnus-newsgroup-charset))
2674 (if (stringp (car handles))
2675 (gnus-mime-view-all-parts (cdr handles))
2676 (mapcar 'mm-display-part handles)))))
2678 (defun gnus-mime-save-part ()
2679 "Save the MIME part under point."
2681 (gnus-article-check-buffer)
2682 (let ((data (get-text-property (point) 'gnus-data)))
2683 (mm-save-part data)))
2685 (defun gnus-mime-pipe-part ()
2686 "Pipe the MIME part under point to a process."
2688 (gnus-article-check-buffer)
2689 (let ((data (get-text-property (point) 'gnus-data)))
2690 (mm-pipe-part data)))
2692 (defun gnus-mime-view-part ()
2693 "Interactively choose a view method for the MIME part under point."
2695 (gnus-article-check-buffer)
2696 (let ((data (get-text-property (point) 'gnus-data)))
2697 (mm-interactively-view-part data)))
2699 (defun gnus-mime-copy-part (&optional handle)
2700 "Put the the MIME part under point into a new buffer."
2702 (gnus-article-check-buffer)
2703 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
2704 (contents (mm-get-part handle))|
2705 (base (file-name-nondirectory
2707 (mail-content-type-get (mm-handle-type handle) 'name)
2708 (mail-content-type-get (mm-handle-type handle)
2711 (buffer (generate-new-buffer base)))
2712 (switch-to-buffer buffer)
2714 ;; We do it this way to make `normal-mode' set the appropriate mode.
2717 (setq buffer-file-name (expand-file-name base))
2719 (setq buffer-file-name nil))
2720 (goto-char (point-min))))
2722 (defun gnus-mime-inline-part (&optional handle)
2723 "Insert the MIME part under point into the current buffer."
2725 (gnus-article-check-buffer)
2726 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
2730 (if (mm-handle-undisplayer handle)
2731 (mm-remove-part handle)
2732 (setq contents (mm-get-part handle))
2734 (mm-insert-inline handle contents)
2737 (defun gnus-mime-externalize-part (&optional handle)
2738 "View the MIME part under point with an external viewer."
2740 (gnus-article-check-buffer)
2741 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
2742 (mm-user-display-methods nil)
2743 (mm-all-images-fit t)
2744 (mail-parse-charset gnus-newsgroup-charset))
2745 (if (mm-handle-undisplayer handle)
2746 (mm-remove-part handle)
2747 (mm-display-part handle))))
2749 (defun gnus-mime-internalize-part (&optional handle)
2750 "View the MIME part under point with an internal viewer."
2752 (gnus-article-check-buffer)
2753 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
2754 (mm-user-display-methods '((".*" . inline)))
2755 (mm-all-images-fit t)
2756 (mail-parse-charset gnus-newsgroup-charset))
2757 (if (mm-handle-undisplayer handle)
2758 (mm-remove-part handle)
2759 (mm-display-part handle))))
2761 (defun gnus-article-part-wrapper (n function)
2762 (save-current-buffer
2763 (set-buffer gnus-article-buffer)
2764 (when (> n (length gnus-article-mime-handle-alist))
2765 (error "No such part"))
2766 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
2767 (funcall function handle))))
2769 (defun gnus-article-pipe-part (n)
2770 "Pipe MIME part N, which is the numerical prefix."
2772 (gnus-article-part-wrapper n 'mm-pipe-part))
2774 (defun gnus-article-save-part (n)
2775 "Save MIME part N, which is the numerical prefix."
2777 (gnus-article-part-wrapper n 'mm-save-part))
2779 (defun gnus-article-interactively-view-part (n)
2780 "View MIME part N interactively, which is the numerical prefix."
2782 (gnus-article-part-wrapper n 'mm-interactively-view-part))
2784 (defun gnus-article-copy-part (n)
2785 "Copy MIME part N, which is the numerical prefix."
2787 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
2789 (defun gnus-article-externalize-part (n)
2790 "View MIME part N externally, which is the numerical prefix."
2792 (gnus-article-part-wrapper n 'gnus-mime-externalize-part))
2794 (defun gnus-article-inline-part (n)
2795 "Inline MIME part N, which is the numerical prefix."
2797 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
2799 (defun gnus-article-view-part (n)
2800 "View MIME part N, which is the numerical prefix."
2802 (save-current-buffer
2803 (set-buffer gnus-article-buffer)
2804 (when (> n (length gnus-article-mime-handle-alist))
2805 (error "No such part"))
2806 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
2807 (when (gnus-article-goto-part n)
2808 (if (equal (car handle) "multipart/alternative")
2809 (gnus-article-press-button)
2810 (when (eq (gnus-mm-display-part handle) 'internal)
2811 (gnus-set-window-start)))))))
2813 (defun gnus-mm-display-part (handle)
2814 "Display HANDLE and fix MIME button."
2815 (let ((id (get-text-property (point) 'gnus-part))
2820 (let ((window (selected-window))
2821 (mail-parse-charset gnus-newsgroup-charset))
2824 (let ((win (get-buffer-window (current-buffer) t))
2827 (select-window win))
2830 (if (mm-handle-displayed-p handle)
2831 ;; This will remove the part.
2832 (mm-display-part handle)
2834 (narrow-to-region (point) (1+ (point)))
2835 (mm-display-part handle)
2836 ;; We narrow to the part itself and
2837 ;; then call the treatment functions.
2838 (goto-char (point-min))
2840 (narrow-to-region (point) (point-max))
2843 (1- (length gnus-article-mime-handles))
2844 (car (mm-handle-type handle))))))
2845 (select-window window))))
2847 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
2848 (gnus-insert-mime-button
2849 handle id (list (mm-handle-displayed-p handle)))
2850 (goto-char point))))
2852 (defun gnus-article-goto-part (n)
2853 "Go to MIME part N."
2854 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
2856 (goto-char point))))
2858 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
2859 (let ((gnus-tmp-name
2860 (or (mail-content-type-get (mm-handle-type handle)
2862 (mail-content-type-get (mm-handle-disposition handle)
2865 (gnus-tmp-type (car (mm-handle-type handle)))
2866 (gnus-tmp-description
2867 (mail-decode-encoded-word-string (or (mm-handle-description handle)
2870 (if (if displayed (car displayed)
2871 (mm-handle-displayed-p handle))
2873 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
2875 gnus-tmp-type-long b e)
2876 (when (string-match ".*/" gnus-tmp-name)
2877 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
2878 (setq gnus-tmp-type-long (concat gnus-tmp-type
2879 (and (not (equal gnus-tmp-name ""))
2880 (concat "; " gnus-tmp-name))))
2881 (or (equal gnus-tmp-description "")
2882 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
2887 gnus-mime-button-line-format gnus-mime-button-line-format-alist
2888 `(local-map ,gnus-mime-button-map
2889 keymap ,gnus-mime-button-map
2890 gnus-callback gnus-mm-display-part
2891 gnus-part ,gnus-tmp-id
2892 article-type annotation
2895 (widget-convert-button 'link b e
2897 :action 'gnus-widget-press-button
2898 :button-keymap gnus-mime-button-map
2901 ;; Needed to properly clear the message
2902 ;; due to a bug in wid-edit
2903 (setq help-echo-owns-message t)
2905 "Click to %s the MIME part; %s for more options"
2906 (if (mm-handle-displayed-p
2907 (widget-get widget :mime-handle))
2909 (if gnus-xemacs "button3" "mouse-3"))))))
2911 (defun gnus-widget-press-button (elems el)
2912 (goto-char (widget-get elems :from))
2913 (gnus-article-press-button))
2915 (defvar gnus-displaying-mime nil)
2917 (defun gnus-display-mime (&optional ihandles)
2918 "Display the MIME parts."
2920 (save-selected-window
2921 (let ((window (get-buffer-window gnus-article-buffer))
2924 (select-window window)
2925 ;; We have to do this since selecting the window
2926 ;; may change the point. So we set the window point.
2927 (set-window-point window point)))
2928 (let* ((handles (or ihandles (mm-dissect-buffer) (mm-uu-dissect)))
2929 buffer-read-only handle name type b e display)
2930 (when (and (not ihandles)
2931 (not gnus-displaying-mime))
2932 ;; Top-level call; we clean up.
2933 (mm-destroy-parts gnus-article-mime-handles)
2934 (setq gnus-article-mime-handles handles
2935 gnus-article-mime-handle-alist nil)
2936 ;; We allow users to glean info from the handles.
2937 (when gnus-article-mime-part-function
2938 (gnus-mime-part-function handles)))
2940 (or (not (stringp (car handles)))
2943 (when (and (not ihandles)
2944 (not gnus-displaying-mime))
2945 ;; Clean up for mime parts.
2947 (delete-region (point) (point-max)))
2948 (let ((gnus-displaying-mime t))
2949 (gnus-mime-display-part handles)))
2952 (narrow-to-region (point) (point-max))
2953 (gnus-treat-article nil 1 1)
2955 ;; Highlight the headers.
2959 (narrow-to-region (point-min) (point))
2960 (gnus-treat-article 'head)))))))
2962 (defvar gnus-mime-display-multipart-as-mixed nil)
2964 (defun gnus-mime-display-part (handle)
2967 ((not (stringp (car handle)))
2968 (gnus-mime-display-single handle))
2969 ;; User-defined multipart
2970 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
2971 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
2973 ;; multipart/alternative
2974 ((and (equal (car handle) "multipart/alternative")
2975 (not gnus-mime-display-multipart-as-mixed))
2976 (let ((id (1+ (length gnus-article-mime-handle-alist))))
2977 (push (cons id handle) gnus-article-mime-handle-alist)
2978 (gnus-mime-display-alternative (cdr handle) nil nil id)))
2979 ;; multipart/related
2980 ((and (equal (car handle) "multipart/related")
2981 (not gnus-mime-display-multipart-as-mixed))
2982 ;;;!!!We should find the start part, but we just default
2983 ;;;!!!to the first part.
2984 (gnus-mime-display-part (cadr handle)))
2985 ;; Other multiparts are handled like multipart/mixed.
2987 (gnus-mime-display-mixed (cdr handle)))))
2989 (defun gnus-mime-part-function (handles)
2990 (if (stringp (car handles))
2991 (mapcar 'gnus-mime-part-function (cdr handles))
2992 (funcall gnus-article-mime-part-function handles)))
2994 (defun gnus-mime-display-mixed (handles)
2995 (mapcar 'gnus-mime-display-part handles))
2997 (defun gnus-mime-display-single (handle)
2998 (let ((type (car (mm-handle-type handle)))
2999 (ignored gnus-ignored-mime-types)
3006 (when (string-match (pop ignored) type)
3007 (throw 'ignored nil)))
3008 (if (and (setq not-attachment
3009 (or (not (mm-handle-disposition handle))
3010 (equal (car (mm-handle-disposition handle))
3012 (mm-attachment-override-p type)))
3013 (mm-automatic-display-p type)
3014 (or (mm-inlinable-part-p type)
3015 (mm-automatic-external-display-p type)))
3017 (when (equal (car (split-string type "/"))
3020 (let ((id (1+ (length gnus-article-mime-handle-alist))))
3021 (push (cons id handle) gnus-article-mime-handle-alist)
3022 (when (or (not display)
3023 (not (gnus-unbuttonized-mime-type-p type)))
3024 (gnus-article-insert-newline)
3025 (gnus-insert-mime-button
3026 handle id (list (or display (and not-attachment text))))
3027 (gnus-article-insert-newline)
3028 (gnus-article-insert-newline)
3030 (let ((beg (point)))
3035 (let ((mail-parse-charset gnus-newsgroup-charset))
3036 (mm-display-part handle t))
3037 (goto-char (point-max)))
3038 ((and text not-attachment)
3041 (gnus-article-insert-newline)
3042 (mm-insert-inline handle (mm-get-part handle))
3043 (goto-char (point-max))))
3047 (narrow-to-region beg (point))
3049 nil (length gnus-article-mime-handle-alist)
3050 (1- (length gnus-article-mime-handles))
3051 (car (mm-handle-type handle))))))))))
3053 (defun gnus-unbuttonized-mime-type-p (type)
3054 "Say whether TYPE is to be unbuttonized."
3055 (unless gnus-inhibit-mime-unbuttonizing
3057 (let ((types gnus-unbuttonized-mime-types))
3059 (when (string-match (pop types) type)
3060 (throw 'found t)))))))
3062 (defun gnus-article-insert-newline ()
3063 "Insert a newline, but mark it as undeletable."
3064 (gnus-put-text-property
3065 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
3067 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
3068 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
3071 handle buffer-read-only from props begend not-pref)
3072 (save-window-excursion
3075 (narrow-to-region (car ibegend)
3078 (goto-char (car ibegend))
3081 (delete-region (point-min) (point-max))
3082 (mm-remove-parts handles))
3083 (setq begend (list (point-marker)))
3085 (unless (setq not-pref (cadr (member preferred ihandles)))
3086 (setq not-pref (car ihandles)))
3088 (not (gnus-unbuttonized-mime-type-p
3089 "multipart/alternative")))
3090 (gnus-add-text-properties
3093 (insert (format "%d. " id))
3097 (unless ,(not ibegend)
3098 (setq gnus-article-mime-handle-alist
3099 ',gnus-article-mime-handle-alist))
3100 (gnus-mime-display-alternative
3101 ',ihandles ',not-pref ',begend ,id))
3102 local-map ,gnus-mime-button-map
3103 ,gnus-mouse-face-prop ,gnus-article-mouse-face
3104 face ,gnus-article-button-face
3105 keymap ,gnus-mime-button-map
3108 (widget-convert-button 'link from (point)
3109 :action 'gnus-widget-press-button
3110 :button-keymap gnus-widget-button-keymap)
3112 (while (setq handle (pop handles))
3113 (gnus-add-text-properties
3116 (insert (format "(%c) %-18s"
3117 (if (equal handle preferred) ?* ? )
3118 (if (stringp (car handle))
3120 (car (mm-handle-type handle)))))
3124 (unless ,(not ibegend)
3125 (setq gnus-article-mime-handle-alist
3126 ',gnus-article-mime-handle-alist))
3127 (gnus-mime-display-alternative
3128 ',ihandles ',handle ',begend ,id))
3129 local-map ,gnus-mime-button-map
3130 ,gnus-mouse-face-prop ,gnus-article-mouse-face
3131 face ,gnus-article-button-face
3132 keymap ,gnus-mime-button-map
3135 (widget-convert-button 'link from (point)
3136 :action 'gnus-widget-press-button
3137 :button-keymap gnus-widget-button-keymap)
3141 (if (stringp (car preferred))
3142 (gnus-display-mime preferred)
3143 (let ((mail-parse-charset gnus-newsgroup-charset))
3144 (mm-display-part preferred)))
3145 (goto-char (point-max))
3146 (setcdr begend (point-marker)))))
3148 (goto-char point))))
3150 (defun gnus-article-wash-status ()
3151 "Return a string which display status of article washing."
3153 (set-buffer gnus-article-buffer)
3154 (let ((cite (memq 'cite gnus-article-wash-types))
3155 (headers (memq 'headers gnus-article-wash-types))
3156 (boring (memq 'boring-headers gnus-article-wash-types))
3157 (pgp (memq 'pgp gnus-article-wash-types))
3158 (pem (memq 'pem gnus-article-wash-types))
3159 (signature (memq 'signature gnus-article-wash-types))
3160 (overstrike (memq 'overstrike gnus-article-wash-types))
3161 (emphasis (memq 'emphasis gnus-article-wash-types)))
3162 (format "%c%c%c%c%c%c"
3164 (if (or headers boring) ?h ? )
3165 (if (or pgp pem) ?p ? )
3166 (if signature ?s ? )
3167 (if overstrike ?o ? )
3168 (if emphasis ?e ? )))))
3170 (fset 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
3172 (defun gnus-article-maybe-hide-headers ()
3173 "Hide unwanted headers if `gnus-have-all-headers' is nil.
3174 Provided for backwards compatibility."
3175 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
3176 (not (save-excursion (set-buffer gnus-summary-buffer)
3177 gnus-have-all-headers)))
3178 (not gnus-inhibit-hiding))
3179 (gnus-article-hide-headers)))
3183 (defun gnus-output-to-file (file-name)
3184 "Append the current article to a file named FILE-NAME."
3185 (let ((artbuf (current-buffer)))
3187 (insert-buffer-substring artbuf)
3188 ;; Append newline at end of the buffer as separator, and then
3190 (goto-char (point-max))
3192 (append-to-file (point-min) (point-max) file-name)
3195 (defun gnus-narrow-to-page (&optional arg)
3196 "Narrow the article buffer to a page.
3197 If given a numerical ARG, move forward ARG pages."
3199 (setq arg (if arg (prefix-numeric-value arg) 0))
3201 (set-buffer gnus-article-buffer)
3202 (goto-char (point-min))
3204 ;; Remove any old next/prev buttons.
3205 (when (gnus-visual-p 'page-marker)
3206 (let ((buffer-read-only nil))
3207 (gnus-remove-text-with-property 'gnus-prev)
3208 (gnus-remove-text-with-property 'gnus-next)))
3211 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
3213 (re-search-forward page-delimiter nil 'move arg)))
3214 (goto-char (match-end 0)))
3217 (if (re-search-forward page-delimiter nil 'move)
3220 (when (and (gnus-visual-p 'page-marker)
3221 (not (= (point-min) 1)))
3223 (goto-char (point-min))
3224 (gnus-insert-prev-page-button)))
3225 (when (and (gnus-visual-p 'page-marker)
3226 (< (+ (point-max) 2) (buffer-size)))
3228 (goto-char (point-max))
3229 (gnus-insert-next-page-button)))))
3231 ;; Article mode commands
3233 (defun gnus-article-goto-next-page ()
3234 "Show the next page of the article."
3236 (when (gnus-article-next-page)
3237 (goto-char (point-min))
3238 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
3240 (defun gnus-article-goto-prev-page ()
3241 "Show the next page of the article."
3243 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
3244 (gnus-article-prev-page nil)))
3246 (defun gnus-article-next-page (&optional lines)
3247 "Show the next page of the current article.
3248 If end of article, return non-nil. Otherwise return nil.
3249 Argument LINES specifies lines to be scrolled up."
3251 (move-to-window-line -1)
3254 (and (pos-visible-in-window-p) ;Not continuation line.
3256 ;; Nothing in this page.
3257 (if (or (not gnus-page-broken)
3260 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
3262 (gnus-narrow-to-page 1) ;Go to next page.
3264 ;; More in this page.
3265 (let ((scroll-in-place nil))
3269 ;; Long lines may cause an end-of-buffer error.
3270 (goto-char (point-max)))))
3271 (move-to-window-line 0)
3274 (defun gnus-article-prev-page (&optional lines)
3275 "Show previous page of current article.
3276 Argument LINES specifies lines to be scrolled down."
3278 (move-to-window-line 0)
3279 (if (and gnus-page-broken
3281 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
3283 (gnus-narrow-to-page -1) ;Go to previous page.
3284 (goto-char (point-max))
3286 (let ((scroll-in-place nil))
3290 (beginning-of-buffer
3291 (goto-char (point-min))))
3292 (move-to-window-line 0)))))
3294 (defun gnus-article-refer-article ()
3295 "Read article specified by message-id around point."
3297 (let ((point (point)))
3298 (search-forward ">" nil t) ;Move point to end of "<....>".
3299 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
3300 (let ((message-id (match-string 1)))
3302 (set-buffer gnus-summary-buffer)
3303 (gnus-summary-refer-article message-id))
3305 (error "No references around point"))))
3307 (defun gnus-article-show-summary ()
3308 "Reconfigure windows to show summary buffer."
3310 (if (not (gnus-buffer-live-p gnus-summary-buffer))
3311 (error "There is no summary buffer for this article buffer")
3312 (gnus-article-set-globals)
3313 (gnus-configure-windows 'article)
3314 (gnus-summary-goto-subject gnus-current-article)
3315 (gnus-summary-position-point)))
3317 (defun gnus-article-describe-briefly ()
3318 "Describe article mode commands briefly."
3320 (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")))
3322 (defun gnus-article-summary-command ()
3323 "Execute the last keystroke in the summary buffer."
3325 (let ((obuf (current-buffer))
3326 (owin (current-window-configuration))
3328 (switch-to-buffer gnus-article-current-summary 'norecord)
3329 (setq func (lookup-key (current-local-map) (this-command-keys)))
3330 (call-interactively func)
3332 (set-window-configuration owin)
3333 (set-window-point (get-buffer-window (current-buffer)) (point))))
3335 (defun gnus-article-summary-command-nosave ()
3336 "Execute the last keystroke in the summary buffer."
3339 (pop-to-buffer gnus-article-current-summary 'norecord)
3340 (setq func (lookup-key (current-local-map) (this-command-keys)))
3341 (call-interactively func)))
3343 (defun gnus-article-check-buffer ()
3344 "Beep if not in an article buffer."
3345 (unless (equal major-mode 'gnus-article-mode)
3346 (error "Command invoked outside of a Gnus article buffer")))
3348 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
3349 "Read a summary buffer key sequence and execute it from the article buffer."
3351 (gnus-article-check-buffer)
3353 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
3354 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
3355 "=" "^" "\M-^" "|"))
3361 '("n" "Gn" "p" "Gp"))
3364 (set-buffer gnus-article-current-summary)
3365 (let (gnus-pick-mode)
3366 (push (or key last-command-event) unread-command-events)
3367 (setq keys (read-key-sequence nil))))
3370 (if (or (member keys nosaves)
3371 (member keys nosave-but-article)
3372 (member keys nosave-in-article))
3374 (save-window-excursion
3375 (pop-to-buffer gnus-article-current-summary 'norecord)
3376 ;; We disable the pick minor mode commands.
3377 (let (gnus-pick-mode)
3378 (setq func (lookup-key (current-local-map) keys))))
3381 (unless (member keys nosave-in-article)
3382 (set-buffer gnus-article-current-summary))
3383 (call-interactively func)
3384 (setq new-sum-point (point)))
3385 (when (member keys nosave-but-article)
3386 (pop-to-buffer gnus-article-buffer 'norecord)))
3387 ;; These commands should restore window configuration.
3388 (let ((obuf (current-buffer))
3389 (owin (current-window-configuration))
3391 (summary gnus-article-current-summary)
3392 func in-buffer selected)
3393 (if not-restore-window
3394 (pop-to-buffer summary 'norecord)
3395 (switch-to-buffer summary 'norecord))
3396 (setq in-buffer (current-buffer))
3397 ;; We disable the pick minor mode commands.
3398 (if (setq func (let (gnus-pick-mode)
3399 (lookup-key (current-local-map) keys)))
3401 (call-interactively func)
3402 (setq new-sum-point (point)))
3404 (when (eq in-buffer (current-buffer))
3405 (setq selected (gnus-summary-select-article))
3407 (unless not-restore-window
3408 (set-window-configuration owin))
3409 (when (eq selected 'old)
3411 (set-window-start (get-buffer-window (current-buffer))
3413 (set-window-point (get-buffer-window (current-buffer))
3415 (let ((win (get-buffer-window gnus-article-current-summary)))
3417 (set-window-point win new-sum-point))))))))
3419 (defun gnus-article-hide (&optional arg force)
3420 "Hide all the gruft in the current article.
3421 This means that PGP stuff, signatures, cited text and (some)
3422 headers will be hidden.
3423 If given a prefix, show the hidden text instead."
3424 (interactive (append (gnus-article-hidden-arg) (list 'force)))
3425 (gnus-article-hide-headers arg)
3426 (gnus-article-hide-pgp arg)
3427 (gnus-article-hide-citation-maybe arg force)
3428 (gnus-article-hide-signature arg))
3430 (defun gnus-article-maybe-highlight ()
3431 "Do some article highlighting if article highlighting is requested."
3432 (when (gnus-visual-p 'article-highlight 'highlight)
3433 (gnus-article-highlight-some)))
3435 (defun gnus-check-group-server ()
3436 ;; Make sure the connection to the server is alive.
3437 (unless (gnus-server-opened
3438 (gnus-find-method-for-group gnus-newsgroup-name))
3439 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
3440 (gnus-request-group gnus-newsgroup-name t)))
3442 (defun gnus-request-article-this-buffer (article group)
3443 "Get an article and insert it into this buffer."
3444 (let (do-update-line sparse-header)
3448 (gnus-kill-all-overlays)
3449 (setq group (or group gnus-newsgroup-name))
3451 ;; Using `gnus-request-article' directly will insert the article into
3452 ;; `nntp-server-buffer' - so we'll save some time by not having to
3453 ;; copy it from the server buffer into the article buffer.
3455 ;; We only request an article by message-id when we do not have the
3456 ;; headers for it, so we'll have to get those.
3457 (when (stringp article)
3458 (let ((gnus-override-method gnus-refer-article-method))
3459 (gnus-read-header article)))
3461 ;; If the article number is negative, that means that this article
3462 ;; doesn't belong in this newsgroup (possibly), so we find its
3463 ;; message-id and request it by id instead of number.
3464 (when (and (numberp article)
3466 (get-buffer gnus-summary-buffer)
3467 (gnus-buffer-exists-p gnus-summary-buffer))
3469 (set-buffer gnus-summary-buffer)
3470 (let ((header (gnus-summary-article-header article)))
3473 ((memq article gnus-newsgroup-sparse)
3474 ;; This is a sparse gap article.
3475 (setq do-update-line article)
3476 (setq article (mail-header-id header))
3477 (let ((gnus-override-method gnus-refer-article-method))
3478 (setq sparse-header (gnus-read-header article)))
3479 (setq gnus-newsgroup-sparse
3480 (delq article gnus-newsgroup-sparse)))
3482 ;; It's a real article.
3483 (setq article (mail-header-id header)))
3485 ;; It is an extracted pseudo-article.
3486 (setq article 'pseudo)
3487 (gnus-request-pseudo-article header))))
3489 (let ((method (gnus-find-method-for-group
3490 gnus-newsgroup-name)))
3491 (when (and (eq (car method) 'nneething)
3494 (file-name-as-directory
3495 (or (cadr (assq 'nneething-address method))
3497 (mail-header-subject header))))
3498 (when (file-directory-p dir)
3499 (setq article 'nneething)
3500 (gnus-group-enter-directory dir))))))))
3503 ;; Refuse to select canceled articles.
3504 ((and (numberp article)
3506 (get-buffer gnus-summary-buffer)
3507 (gnus-buffer-exists-p gnus-summary-buffer)
3508 (eq (cdr (save-excursion
3509 (set-buffer gnus-summary-buffer)
3510 (assq article gnus-newsgroup-reads)))
3511 gnus-canceled-mark))
3513 ;; We first check `gnus-original-article-buffer'.
3514 ((and (get-buffer gnus-original-article-buffer)
3517 (set-buffer gnus-original-article-buffer)
3518 (and (equal (car gnus-original-article) group)
3519 (eq (cdr gnus-original-article) article))))
3520 (insert-buffer-substring gnus-original-article-buffer)
3522 ;; Check the backlog.
3523 ((and gnus-keep-backlog
3524 (gnus-backlog-request-article group article (current-buffer)))
3526 ;; Check asynchronous pre-fetch.
3527 ((gnus-async-request-fetched-article group article (current-buffer))
3528 (gnus-async-prefetch-next group article gnus-summary-buffer)
3529 (when (and (numberp article) gnus-keep-backlog)
3530 (gnus-backlog-enter-article group article (current-buffer)))
3533 ((and gnus-use-cache
3535 (gnus-cache-request-article article group))
3537 ;; Get the article and put into the article buffer.
3538 ((or (stringp article) (numberp article))
3539 (let ((gnus-override-method
3540 (and (stringp article) gnus-refer-article-method))
3541 (buffer-read-only nil))
3543 (gnus-kill-all-overlays)
3544 (gnus-check-group-server)
3545 (when (gnus-request-article article group (current-buffer))
3546 (when (numberp article)
3547 (gnus-async-prefetch-next group article gnus-summary-buffer)
3548 (when gnus-keep-backlog
3549 (gnus-backlog-enter-article
3550 group article (current-buffer))))
3555 ;; Associate this article with the current summary buffer.
3556 (setq gnus-article-current-summary gnus-summary-buffer)
3558 ;; Take the article from the original article buffer
3559 ;; and place it in the buffer it's supposed to be in.
3560 (when (and (get-buffer gnus-article-buffer)
3561 (equal (buffer-name (current-buffer))
3562 (buffer-name (get-buffer gnus-article-buffer))))
3564 (if (get-buffer gnus-original-article-buffer)
3565 (set-buffer gnus-original-article-buffer)
3566 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3567 (buffer-disable-undo)
3568 (setq major-mode 'gnus-original-article-mode)
3569 (setq buffer-read-only t))
3570 (let (buffer-read-only)
3572 (insert-buffer-substring gnus-article-buffer))
3573 (setq gnus-original-article (cons group article)))
3576 (run-hooks 'gnus-article-decode-hook)
3577 ;; Mark article as decoded or not.
3578 (setq gnus-article-decoded-p gnus-article-decode-hook))
3580 ;; Update sparse articles.
3581 (when (and do-update-line
3582 (or (numberp article)
3584 (let ((buf (current-buffer)))
3585 (set-buffer gnus-summary-buffer)
3586 (gnus-summary-update-article do-update-line sparse-header)
3587 (gnus-summary-goto-subject do-update-line nil t)
3588 (set-window-point (get-buffer-window (current-buffer) t)
3590 (set-buffer buf))))))
3596 (defcustom gnus-article-edit-mode-hook nil
3597 "Hook run in article edit mode buffers."
3598 :group 'gnus-article-various
3601 (defvar gnus-article-edit-done-function nil)
3603 (defvar gnus-article-edit-mode-map nil)
3605 ;; Should we be using derived.el for this?
3606 (unless gnus-article-edit-mode-map
3607 (setq gnus-article-edit-mode-map (make-sparse-keymap))
3608 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
3610 (gnus-define-keys gnus-article-edit-mode-map
3611 "\C-c\C-c" gnus-article-edit-done
3612 "\C-c\C-k" gnus-article-edit-exit)
3614 (gnus-define-keys (gnus-article-edit-wash-map
3615 "\C-c\C-w" gnus-article-edit-mode-map)
3616 "f" gnus-article-edit-full-stops))
3618 (defun gnus-article-edit-mode ()
3619 "Major mode for editing articles.
3620 This is an extended text-mode.
3622 \\{gnus-article-edit-mode-map}"
3624 (setq major-mode 'gnus-article-edit-mode)
3625 (setq mode-name "Article Edit")
3626 (use-local-map gnus-article-edit-mode-map)
3627 (make-local-variable 'gnus-article-edit-done-function)
3628 (make-local-variable 'gnus-prev-winconf)
3629 (setq buffer-read-only nil)
3630 (buffer-enable-undo)
3632 (gnus-run-hooks 'text-mode-hook 'gnus-article-edit-mode-hook))
3634 (defun gnus-article-edit (&optional force)
3635 "Edit the current article.
3636 This will have permanent effect only in mail groups.
3637 If FORCE is non-nil, allow editing of articles even in read-only
3640 (when (and (not force)
3641 (gnus-group-read-only-p))
3642 (error "The current newsgroup does not support article editing"))
3643 (gnus-article-date-original)
3644 (gnus-article-edit-article
3646 `(lambda (no-highlight)
3648 (gnus-summary-edit-article-done
3649 ,(or (mail-header-references gnus-current-headers) "")
3650 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
3652 (defun gnus-article-edit-article (start-func exit-func)
3653 "Start editing the contents of the current article buffer."
3654 (let ((winconf (current-window-configuration)))
3655 (set-buffer gnus-article-buffer)
3656 (gnus-article-edit-mode)
3657 (funcall start-func)
3658 ;;(gnus-article-delete-text-of-type 'annotation)
3659 ;;(gnus-set-text-properties (point-min) (point-max) nil)
3660 (gnus-configure-windows 'edit-article)
3661 (setq gnus-article-edit-done-function exit-func)
3662 (setq gnus-prev-winconf winconf)
3663 (gnus-message 6 "C-c C-c to end edits")))
3665 (defun gnus-article-edit-done (&optional arg)
3666 "Update the article edits and exit."
3671 (when (article-goto-body)
3672 (let ((lines (count-lines (point) (point-max)))
3673 (length (- (point-max) (point)))
3674 (case-fold-search t)
3675 (body (copy-marker (point))))
3676 (goto-char (point-min))
3677 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
3678 (delete-region (match-beginning 1) (match-end 1))
3679 (insert (number-to-string length)))
3680 (goto-char (point-min))
3681 (when (re-search-forward
3682 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
3683 (delete-region (match-beginning 1) (match-end 1))
3684 (insert (number-to-string length)))
3685 (goto-char (point-min))
3686 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
3687 (delete-region (match-beginning 1) (match-end 1))
3688 (insert (number-to-string lines)))))))
3689 (let ((func gnus-article-edit-done-function)
3690 (buf (current-buffer))
3691 (start (window-start)))
3692 (gnus-article-edit-exit)
3695 (let ((buffer-read-only nil))
3697 ;; The cache and backlog have to be flushed somewhat.
3698 (when gnus-keep-backlog
3699 (gnus-backlog-remove-article
3700 (car gnus-article-current) (cdr gnus-article-current)))
3701 ;; Flush original article as well.
3703 (when (get-buffer gnus-original-article-buffer)
3704 (set-buffer gnus-original-article-buffer)
3705 (setq gnus-original-article nil)))
3706 (when gnus-use-cache
3707 (gnus-cache-update-article
3708 (car gnus-article-current) (cdr gnus-article-current))))
3710 (set-window-start (get-buffer-window buf) start)
3711 (set-window-point (get-buffer-window buf) (point))))
3713 (defun gnus-article-edit-exit ()
3714 "Exit the article editing without updating."
3716 ;; We remove all text props from the article buffer.
3717 (let ((buf (format "%s" (buffer-string)))
3718 (curbuf (current-buffer))
3720 (window-start (window-start)))
3723 (let ((winconf gnus-prev-winconf))
3725 (set-window-configuration winconf)
3726 ;; Tippy-toe some to make sure that point remains where it was.
3727 (save-current-buffer
3729 (set-window-start (get-buffer-window (current-buffer)) window-start)
3732 (defun gnus-article-edit-full-stops ()
3733 "Interactively repair spacing at end of sentences."
3736 (goto-char (point-min))
3737 (search-forward-regexp "^$" nil t)
3738 (let ((case-fold-search nil))
3739 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
3742 ;;; Article highlights
3745 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
3747 ;;; Internal Variables:
3749 (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\\)"
3750 "Regular expression that matches URLs."
3751 :group 'gnus-article-buttons
3754 (defcustom gnus-button-alist
3755 `(("<\\(url:[>\n\t ]*?\\)?news:[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
3756 0 t gnus-button-message-id 2)
3757 ("\\bnews:\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t gnus-button-message-id 1)
3758 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
3760 gnus-button-fetch-group 4)
3761 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
3762 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
3763 t gnus-button-message-id 3)
3764 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
3765 ("mailto:\\([-a-zA-Z.@_+0-9%]+\\)" 0 t gnus-url-mailto 1)
3766 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
3767 ;; This is how URLs _should_ be embedded in text...
3768 ("<URL: *\\([^>]*\\)>" 0 t gnus-button-embedded-url 1)
3770 (,gnus-button-url-regexp 0 t gnus-button-url 0))
3771 "*Alist of regexps matching buttons in article bodies.
3773 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
3774 REGEXP: is the string matching text around the button,
3775 BUTTON: is the number of the regexp grouping actually matching the button,
3776 FORM: is a lisp expression which must eval to true for the button to
3778 CALLBACK: is the function to call when the user push this button, and each
3779 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
3781 CALLBACK can also be a variable, in that case the value of that
3782 variable it the real callback function."
3783 :group 'gnus-article-buttons
3784 :type '(repeat (list regexp
3785 (integer :tag "Button")
3787 (function :tag "Callback")
3790 (integer :tag "Regexp group")))))
3792 (defcustom gnus-header-button-alist
3793 `(("^\\(References\\|Message-I[Dd]\\):" "<[^>]+>"
3794 0 t gnus-button-message-id 0)
3795 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
3796 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
3797 0 t gnus-button-mailto 0)
3798 ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t gnus-button-url 0)
3799 ("^Subject:" ,gnus-button-url-regexp 0 t gnus-button-url 0)
3800 ("^[^:]+:" ,gnus-button-url-regexp 0 t gnus-button-url 0)
3801 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
3802 gnus-button-message-id 3))
3803 "*Alist of headers and regexps to match buttons in article heads.
3805 This alist is very similar to `gnus-button-alist', except that each
3806 alist has an additional HEADER element first in each entry:
3808 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
3810 HEADER is a regexp to match a header. For a fuller explanation, see
3811 `gnus-button-alist'."
3812 :group 'gnus-article-buttons
3813 :group 'gnus-article-headers
3814 :type '(repeat (list (regexp :tag "Header")
3816 (integer :tag "Button")
3818 (function :tag "Callback")
3821 (integer :tag "Regexp group")))))
3823 (defvar gnus-button-regexp nil)
3824 (defvar gnus-button-marker-list nil)
3825 ;; Regexp matching any of the regexps from `gnus-button-alist'.
3827 (defvar gnus-button-last nil)
3828 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
3832 (defun gnus-article-push-button (event)
3833 "Check text under the mouse pointer for a callback function.
3834 If the text under the mouse pointer has a `gnus-callback' property,
3835 call it with the value of the `gnus-data' text property."
3837 (set-buffer (window-buffer (posn-window (event-start event))))
3838 (let* ((pos (posn-point (event-start event)))
3839 (data (get-text-property pos 'gnus-data))
3840 (fun (get-text-property pos 'gnus-callback)))
3843 (funcall fun data))))
3845 (defun gnus-article-press-button ()
3846 "Check text at point for a callback function.
3847 If the text at point has a `gnus-callback' property,
3848 call it with the value of the `gnus-data' text property."
3850 (let* ((data (get-text-property (point) 'gnus-data))
3851 (fun (get-text-property (point) 'gnus-callback)))
3853 (funcall fun data))))
3855 (defun gnus-article-highlight (&optional force)
3856 "Highlight current article.
3857 This function calls `gnus-article-highlight-headers',
3858 `gnus-article-highlight-citation',
3859 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
3860 do the highlighting. See the documentation for those functions."
3861 (interactive (list 'force))
3862 (gnus-article-highlight-headers)
3863 (gnus-article-highlight-citation force)
3864 (gnus-article-highlight-signature)
3865 (gnus-article-add-buttons force)
3866 (gnus-article-add-buttons-to-head))
3868 (defun gnus-article-highlight-some (&optional force)
3869 "Highlight current article.
3870 This function calls `gnus-article-highlight-headers',
3871 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
3872 do the highlighting. See the documentation for those functions."
3873 (interactive (list 'force))
3874 (gnus-article-highlight-headers)
3875 (gnus-article-highlight-signature)
3876 (gnus-article-add-buttons))
3878 (defun gnus-article-highlight-headers ()
3879 "Highlight article headers as specified by `gnus-header-face-alist'."
3882 (set-buffer gnus-article-buffer)
3884 (let ((alist gnus-header-face-alist)
3885 (buffer-read-only nil)
3886 (case-fold-search t)
3887 (inhibit-point-motion-hooks t)
3888 entry regexp header-face field-face from hpoints fpoints)
3889 (article-narrow-to-head)
3890 (while (setq entry (pop alist))
3891 (goto-char (point-min))
3892 (setq regexp (concat "^\\("
3893 (if (string-equal "" (nth 0 entry))
3897 header-face (nth 1 entry)
3898 field-face (nth 2 entry))
3899 (while (and (re-search-forward regexp nil t)
3903 (unless (search-forward ":" nil t)
3905 (when (and header-face
3906 (not (memq (point) hpoints)))
3907 (push (point) hpoints)
3908 (gnus-put-text-property from (point) 'face header-face))
3909 (when (and field-face
3910 (not (memq (setq from (point)) fpoints)))
3912 (if (re-search-forward "^[^ \t]" nil t)
3914 (goto-char (point-max)))
3915 (gnus-put-text-property from (point) 'face field-face))))))))
3917 (defun gnus-article-highlight-signature ()
3918 "Highlight the signature in an article.
3919 It does this by highlighting everything after
3920 `gnus-signature-separator' using `gnus-signature-face'."
3923 (set-buffer gnus-article-buffer)
3924 (let ((buffer-read-only nil)
3925 (inhibit-point-motion-hooks t))
3927 (when (and gnus-signature-face
3928 (gnus-article-narrow-to-signature))
3929 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
3930 'face gnus-signature-face)
3932 (gnus-article-search-signature)
3933 (let ((start (match-beginning 0))
3934 (end (set-marker (make-marker) (1+ (match-end 0)))))
3935 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
3938 (defun gnus-button-in-region-p (b e prop)
3939 "Say whether PROP exists in the region."
3940 (text-property-not-all b e prop nil))
3942 (defun gnus-article-add-buttons (&optional force)
3943 "Find external references in the article and make buttons of them.
3944 \"External references\" are things like Message-IDs and URLs, as
3945 specified by `gnus-button-alist'."
3946 (interactive (list 'force))
3948 (set-buffer gnus-article-buffer)
3949 (let ((buffer-read-only nil)
3950 (inhibit-point-motion-hooks t)
3951 (case-fold-search t)
3952 (alist gnus-button-alist)
3954 ;; Remove all old markers.
3956 (while (setq marker (pop gnus-button-marker-list))
3958 (when (setq entry (gnus-button-entry))
3959 (put-text-property (match-beginning (nth 1 entry))
3960 (match-end (nth 1 entry))
3961 'gnus-callback nil))
3962 (set-marker marker nil)))
3963 ;; We skip the headers.
3966 (while (setq entry (pop alist))
3967 (setq regexp (car entry))
3969 (while (re-search-forward regexp nil t)
3970 (let* ((start (and entry (match-beginning (nth 1 entry))))
3971 (end (and entry (match-end (nth 1 entry))))
3972 (from (match-beginning 0)))
3973 (when (and (or (eq t (nth 2 entry))
3974 (eval (nth 2 entry)))
3975 (not (gnus-button-in-region-p
3976 start end 'gnus-callback)))
3977 ;; That optional form returned non-nil, so we add the
3979 (gnus-article-add-button
3980 start end 'gnus-button-push
3981 (car (push (set-marker (make-marker) from)
3982 gnus-button-marker-list))))))))))
3984 ;; Add buttons to the head of an article.
3985 (defun gnus-article-add-buttons-to-head ()
3986 "Add buttons to the head of the article."
3989 (set-buffer gnus-article-buffer)
3991 (let ((buffer-read-only nil)
3992 (inhibit-point-motion-hooks t)
3993 (case-fold-search t)
3994 (alist gnus-header-button-alist)
3996 (article-narrow-to-head)
3998 ;; Each alist entry.
3999 (setq entry (car alist)
4001 (goto-char (point-min))
4002 (while (re-search-forward (car entry) nil t)
4003 ;; Each header matching the entry.
4004 (setq beg (match-beginning 0))
4005 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
4006 (match-beginning 0))
4009 (while (re-search-forward (nth 1 entry) end t)
4010 ;; Each match within a header.
4011 (let* ((entry (cdr entry))
4012 (start (match-beginning (nth 1 entry)))
4013 (end (match-end (nth 1 entry)))
4014 (form (nth 2 entry)))
4015 (goto-char (match-end 0))
4017 (gnus-article-add-button
4018 start end (nth 3 entry)
4019 (buffer-substring (match-beginning (nth 4 entry))
4020 (match-end (nth 4 entry)))))))
4021 (goto-char end)))))))
4023 ;;; External functions:
4025 (defun gnus-article-add-button (from to fun &optional data)
4026 "Create a button between FROM and TO with callback FUN and data DATA."
4027 (when gnus-article-button-face
4028 (gnus-overlay-put (gnus-make-overlay from to)
4029 'face gnus-article-button-face))
4030 (gnus-add-text-properties
4032 (nconc (and gnus-article-mouse-face
4033 (list gnus-mouse-face-prop gnus-article-mouse-face))
4034 (list 'gnus-callback fun)
4035 (and data (list 'gnus-data data))))
4036 (widget-convert-button 'link from to :action 'gnus-widget-press-button
4037 :button-keymap gnus-widget-button-keymap))
4039 ;;; Internal functions:
4041 (defun gnus-article-set-globals ()
4043 (set-buffer gnus-summary-buffer)
4044 (gnus-set-global-variables)))
4046 (defun gnus-signature-toggle (end)
4048 (set-buffer gnus-article-buffer)
4049 (let ((buffer-read-only nil)
4050 (inhibit-point-motion-hooks t))
4051 (if (get-text-property end 'invisible)
4052 (gnus-article-unhide-text end (point-max))
4053 (gnus-article-hide-text end (point-max) gnus-hidden-properties)))))
4055 (defun gnus-button-entry ()
4056 ;; Return the first entry in `gnus-button-alist' matching this place.
4057 (let ((alist gnus-button-alist)
4060 (setq entry (pop alist))
4061 (if (looking-at (car entry))
4066 (defun gnus-button-push (marker)
4067 ;; Push button starting at MARKER.
4070 (let* ((entry (gnus-button-entry))
4071 (inhibit-point-motion-hooks t)
4073 (args (mapcar (lambda (group)
4074 (let ((string (match-string group)))
4075 (gnus-set-text-properties
4076 0 (length string) nil string)
4083 (fboundp (symbol-value fun)))
4084 (apply (symbol-value fun) args))
4086 (gnus-message 1 "You must define `%S' to use this button"
4087 (cons fun args)))))))
4089 (defun gnus-button-message-id (message-id)
4092 (set-buffer gnus-summary-buffer)
4093 (gnus-summary-refer-article message-id)))
4095 (defun gnus-button-fetch-group (address)
4096 "Fetch GROUP specified by ADDRESS."
4097 (if (not (string-match "[:/]" address))
4098 ;; This is just a simple group url.
4099 (gnus-group-read-ephemeral-group address gnus-select-method)
4100 (if (not (string-match "^\\([^:/]+\\)\\(:\\([^/]+\\)/\\)?\\(.*\\)$"
4102 (error "Can't parse %s" address)
4103 (gnus-group-read-ephemeral-group
4104 (match-string 4 address)
4105 `(nntp ,(match-string 1 address)
4106 (nntp-address ,(match-string 1 address))
4107 (nntp-port-number ,(if (match-end 3)
4108 (match-string 3 address)
4111 (defun gnus-url-parse-query-string (query &optional downcase)
4112 (let (retval pairs cur key val)
4113 (setq pairs (split-string query "&"))
4115 (setq cur (car pairs)
4117 (if (not (string-match "=" cur))
4119 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
4120 val (gnus-url-unhex-string (substring cur (match-end 0) nil)))
4122 (setq key (downcase key)))
4123 (setq cur (assoc key retval))
4125 (setcdr cur (cons val (cdr cur)))
4126 (setq retval (cons (list key val) retval)))))
4129 (defun gnus-url-unhex (x)
4136 (defun gnus-url-unhex-string (str &optional allow-newlines)
4137 "Remove %XXX embedded spaces, etc in a url.
4138 If optional second argument ALLOW-NEWLINES is non-nil, then allow the
4139 decoding of carriage returns and line feeds in the string, which is normally
4140 forbidden in URL encoding."
4141 (setq str (or str ""))
4143 (case-fold-search t))
4144 (while (string-match "%[0-9a-f][0-9a-f]" str)
4145 (let* ((start (match-beginning 0))
4146 (ch1 (gnus-url-unhex (elt str (+ start 1))))
4148 (gnus-url-unhex (elt str (+ start 2))))))
4150 tmp (substring str 0 start)
4153 (char-to-string code))
4154 ((or (= code ?\n) (= code ?\r))
4156 (t (char-to-string code))))
4157 str (substring str (match-end 0)))))
4158 (setq tmp (concat tmp str))
4161 (defun gnus-url-mailto (url)
4162 ;; Send mail to someone
4163 (when (string-match "mailto:/*\\(.*\\)" url)
4164 (setq url (substring url (match-beginning 1) nil)))
4165 (let (to args subject func)
4166 (if (string-match (regexp-quote "?") url)
4167 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
4168 args (gnus-url-parse-query-string
4169 (substring url (match-end 0) nil) t))
4170 (setq to (gnus-url-unhex-string url)))
4171 (setq args (cons (list "to" to) args)
4172 subject (cdr-safe (assoc "subject" args)))
4175 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
4178 (message-position-on-field (caar args)))
4179 (insert (mapconcat 'identity (cdar args) ", "))
4180 (setq args (cdr args)))
4183 (message-goto-subject))))
4185 (defun gnus-button-mailto (address)
4187 (set-buffer (gnus-copy-article-buffer))
4188 (message-reply address))
4190 (defun gnus-button-reply (address)
4191 ;; Reply to ADDRESS.
4192 (message-reply address))
4194 (defun gnus-button-url (address)
4196 ;; In Emacs 20, `browse-url-browser-function' may be an alist.
4197 (if (listp browse-url-browser-function)
4198 (browse-url address)
4199 (funcall browse-url-browser-function address)))
4201 (defun gnus-button-embedded-url (address)
4203 ;; In Emacs 20, `browse-url-browser-function' may be an alist.
4204 (if (listp browse-url-browser-function)
4205 (browse-url (gnus-strip-whitespace address))
4206 (funcall browse-url-browser-function (gnus-strip-whitespace address))))
4208 ;;; Next/prev buttons in the article buffer.
4210 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
4211 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
4213 (defvar gnus-prev-page-map nil)
4214 (unless gnus-prev-page-map
4215 (setq gnus-prev-page-map (make-sparse-keymap))
4216 (define-key gnus-prev-page-map gnus-mouse-2 'gnus-button-prev-page)
4217 (define-key gnus-prev-page-map "\r" 'gnus-button-prev-page))
4219 (defun gnus-insert-prev-page-button ()
4220 (let ((buffer-read-only nil))
4222 gnus-prev-page-line-format nil
4223 `(gnus-prev t local-map ,gnus-prev-page-map
4224 gnus-callback gnus-article-button-prev-page
4225 article-type annotation))))
4227 (defvar gnus-next-page-map nil)
4228 (unless gnus-next-page-map
4229 (setq gnus-next-page-map (make-keymap))
4230 (suppress-keymap gnus-prev-page-map)
4231 (define-key gnus-next-page-map gnus-mouse-2 'gnus-button-next-page)
4232 (define-key gnus-next-page-map "\r" 'gnus-button-next-page))
4234 (defun gnus-button-next-page ()
4235 "Go to the next page."
4237 (let ((win (selected-window)))
4238 (select-window (get-buffer-window gnus-article-buffer t))
4239 (gnus-article-next-page)
4240 (select-window win)))
4242 (defun gnus-button-prev-page ()
4243 "Go to the prev page."
4245 (let ((win (selected-window)))
4246 (select-window (get-buffer-window gnus-article-buffer t))
4247 (gnus-article-prev-page)
4248 (select-window win)))
4250 (defun gnus-insert-next-page-button ()
4251 (let ((buffer-read-only nil))
4252 (gnus-eval-format gnus-next-page-line-format nil
4254 t local-map ,gnus-next-page-map
4255 gnus-callback gnus-article-button-next-page
4256 article-type annotation))))
4258 (defun gnus-article-button-next-page (arg)
4259 "Go to the next page."
4261 (let ((win (selected-window)))
4262 (select-window (get-buffer-window gnus-article-buffer t))
4263 (gnus-article-next-page)
4264 (select-window win)))
4266 (defun gnus-article-button-prev-page (arg)
4267 "Go to the prev page."
4269 (let ((win (selected-window)))
4270 (select-window (get-buffer-window gnus-article-buffer t))
4271 (gnus-article-prev-page)
4272 (select-window win)))
4274 (defvar gnus-decode-header-methods
4275 '(mail-decode-encoded-word-region)
4276 "List of methods used to decode headers.
4278 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item is
4279 FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
4280 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
4281 whose names match REGEXP.
4284 ((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
4285 mail-decode-encoded-word-region
4286 (\"chinese\" . rfc1843-decode-region))
4289 (defvar gnus-decode-header-methods-cache nil)
4291 (defun gnus-multi-decode-header (start end)
4292 "Apply the functions from `gnus-encoded-word-methods' that match."
4293 (unless (and gnus-decode-header-methods-cache
4294 (eq gnus-newsgroup-name
4295 (car gnus-decode-header-methods-cache)))
4296 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
4299 (nconc gnus-decode-header-methods-cache (list x))
4300 (if (and gnus-newsgroup-name
4301 (string-match (car x) gnus-newsgroup-name))
4302 (nconc gnus-decode-header-methods-cache
4304 gnus-decode-header-methods))
4305 (let ((xlist gnus-decode-header-methods-cache))
4308 (narrow-to-region start end)
4310 (funcall (pop xlist) (point-min) (point-max))))))
4313 ;;; Treatment top-level handling.
4316 (defun gnus-treat-article (condition &optional part-number total-parts type)
4317 (let ((length (- (point-max) (point-min)))
4318 (alist gnus-treatment-function-alist)
4319 (article-goto-body-goes-to-point-min-p t)
4323 (let ((list gnus-article-treat-types))
4325 (when (string-match (pop list) type)
4326 (throw 'found t)))))))
4327 (highlightp (gnus-visual-p 'article-highlight 'highlight))
4329 (gnus-run-hooks 'gnus-part-display-hook)
4330 (while (setq elem (pop alist))
4331 (setq val (symbol-value (car elem)))
4332 (when (and (or (consp val)
4334 (gnus-treat-predicate val)
4335 (or (not (get (car elem) 'highlight))
4338 (funcall (cadr elem)))))))
4340 ;; Dynamic variables.
4341 (defvar part-number)
4342 (defvar total-parts)
4346 (defun gnus-treat-predicate (val)
4357 (eq part-number total-parts))
4361 (let ((pred (pop val)))
4364 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
4366 (apply 'gnus-and (mapcar 'gnus-tread-predicate val)))
4368 (not (gnus-treat-predicate val)))
4370 (equal (cadr val) type))
4372 (error "%S is not a valid predicate" pred)))))
4374 (error "%S is not a valid value" val))))
4380 (run-hooks 'gnus-art-load-hook)
4382 ;;; gnus-art.el ends here