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]+:"
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
597 ;;; The treatment variables
600 (defvar gnus-part-display-hook nil
601 "Hook called on parts that are to receive treatment.")
603 (defvar gnus-article-treat-custom
604 '(choice (const :tag "Off" nil)
606 (const :tag "Header" head)
607 (const :tag "Last" last)
608 (integer :tag "Less")
609 (sexp :tag "Predicate")))
611 (defvar gnus-article-treat-types '("text/plain")
614 (defvar gnus-inhibit-treatment nil
615 "Whether to inhibit treatment.")
617 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
618 "Highlight the signature."
619 :group 'gnus-article-treat
620 :type gnus-article-treat-custom)
622 (defcustom gnus-treat-buttonize t
624 :group 'gnus-article-treat
625 :type gnus-article-treat-custom)
627 (defcustom gnus-treat-buttonize-head 'head
628 "Add buttons to the head."
629 :group 'gnus-article-treat
630 :type gnus-article-treat-custom)
632 (defcustom gnus-treat-emphasize t
634 :group 'gnus-article-treat
635 :type gnus-article-treat-custom)
637 (defcustom gnus-treat-strip-cr nil
638 "Remove carriage returns."
639 :group 'gnus-article-treat
640 :type gnus-article-treat-custom)
642 (defcustom gnus-treat-hide-headers 'head
644 :group 'gnus-article-treat
645 :type gnus-article-treat-custom)
647 (defcustom gnus-treat-hide-boring-headers nil
648 "Hide boring headers."
649 :group 'gnus-article-treat
650 :type gnus-article-treat-custom)
652 (defcustom gnus-treat-hide-signature nil
653 "Hide the signature."
654 :group 'gnus-article-treat
655 :type gnus-article-treat-custom)
657 (defcustom gnus-treat-fill-article nil
659 :group 'gnus-article-treat
660 :type gnus-article-treat-custom)
662 (defcustom gnus-treat-hide-citation nil
664 :group 'gnus-article-treat
665 :type gnus-article-treat-custom)
667 (defcustom gnus-treat-strip-pgp t
668 "Strip PGP signatures."
669 :group 'gnus-article-treat
670 :type gnus-article-treat-custom)
672 (defcustom gnus-treat-strip-pem nil
673 "Strip PEM signatures."
674 :group 'gnus-article-treat
675 :type gnus-article-treat-custom)
677 (defcustom gnus-treat-strip-banner t
678 "Strip banners from articles.
679 The banner to be stripped is specified in the `banner' group parameter."
680 :group 'gnus-article-treat
681 :type gnus-article-treat-custom)
683 (defcustom gnus-treat-highlight-headers 'head
684 "Highlight the headers."
685 :group 'gnus-article-treat
686 :type gnus-article-treat-custom)
688 (defcustom gnus-treat-highlight-citation t
689 "Highlight cited text."
690 :group 'gnus-article-treat
691 :type gnus-article-treat-custom)
693 (defcustom gnus-treat-date-ut nil
694 "Display the Date in UT (GMT)."
695 :group 'gnus-article-treat
696 :type gnus-article-treat-custom)
698 (defcustom gnus-treat-date-local nil
699 "Display the Date in the local timezone."
700 :group 'gnus-article-treat
701 :type gnus-article-treat-custom)
703 (defcustom gnus-treat-date-lapsed nil
704 "Display the Date header in a way that says how much time has elapsed."
705 :group 'gnus-article-treat
706 :type gnus-article-treat-custom)
708 (defcustom gnus-treat-date-original nil
709 "Display the date in the original timezone."
710 :group 'gnus-article-treat
711 :type gnus-article-treat-custom)
713 (defcustom gnus-treat-date-iso8601 nil
714 "Display the date in the ISO8601 format."
715 :group 'gnus-article-treat
716 :type gnus-article-treat-custom)
718 (defcustom gnus-treat-date-user-defined nil
719 "Display the date in a user-defined format.
720 The format is defined by the `gnus-article-time-format' variable."
721 :group 'gnus-article-treat
722 :type gnus-article-treat-custom)
724 (defcustom gnus-treat-strip-trailing-blank-lines nil
725 "Strip trailing blank lines."
726 :group 'gnus-article-treat
727 :type gnus-article-treat-custom)
729 (defcustom gnus-treat-strip-leading-blank-lines nil
730 "Strip leading blank lines."
731 :group 'gnus-article-treat
732 :type gnus-article-treat-custom)
734 (defcustom gnus-treat-strip-multiple-blank-lines nil
735 "Strip multiple blank lines."
736 :group 'gnus-article-treat
737 :type gnus-article-treat-custom)
739 (defcustom gnus-treat-strip-blank-lines nil
740 "Strip all blank lines."
741 :group 'gnus-article-treat
742 :type gnus-article-treat-custom)
744 (defcustom gnus-treat-overstrike t
745 "Treat overstrike highlighting."
746 :group 'gnus-article-treat
747 :type gnus-article-treat-custom)
749 (defcustom gnus-treat-display-xface (if (and gnus-xemacs (featurep 'xface))
751 "Display X-Face headers."
752 :group 'gnus-article-treat
753 :type gnus-article-treat-custom)
755 (defcustom gnus-treat-display-smileys (if (and gnus-xemacs
759 :group 'gnus-article-treat
760 :type gnus-article-treat-custom)
762 (defcustom gnus-treat-display-picons (if gnus-xemacs 'head nil)
764 :group 'gnus-article-treat
765 :type gnus-article-treat-custom)
767 (defcustom gnus-treat-capitalize-sentences nil
768 "Capitalize sentence-starting words."
769 :group 'gnus-article-treat
770 :type gnus-article-treat-custom)
772 (defcustom gnus-treat-fill-long-lines nil
774 :group 'gnus-article-treat
775 :type gnus-article-treat-custom)
777 ;;; Internal variables
779 (defvar article-goto-body-goes-to-point-min-p nil)
781 (defvar gnus-article-mime-handle-alist-1 nil)
782 (defvar gnus-treatment-function-alist
783 '((gnus-treat-strip-banner gnus-article-strip-banner)
784 (gnus-treat-highlight-signature gnus-article-highlight-signature)
785 (gnus-treat-buttonize gnus-article-add-buttons)
786 (gnus-treat-fill-article gnus-article-fill-cited-article)
787 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
788 (gnus-treat-strip-cr gnus-article-remove-cr)
789 (gnus-treat-hide-headers gnus-article-hide-headers)
790 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
791 (gnus-treat-hide-signature gnus-article-hide-signature)
792 (gnus-treat-hide-citation gnus-article-hide-citation)
793 (gnus-treat-strip-pgp gnus-article-hide-pgp)
794 (gnus-treat-strip-pem gnus-article-hide-pem)
795 (gnus-treat-highlight-headers gnus-article-highlight-headers)
796 (gnus-treat-highlight-citation gnus-article-highlight-citation)
797 (gnus-treat-highlight-signature gnus-article-highlight-signature)
798 (gnus-treat-emphasize gnus-article-emphasize)
799 (gnus-treat-date-ut gnus-article-date-ut)
800 (gnus-treat-date-local gnus-article-date-local)
801 (gnus-treat-date-lapsed gnus-article-date-lapsed)
802 (gnus-treat-date-original gnus-article-date-original)
803 (gnus-treat-date-user-defined gnus-article-date-user)
804 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
805 (gnus-treat-strip-trailing-blank-lines
806 gnus-article-remove-trailing-blank-lines)
807 (gnus-treat-strip-leading-blank-lines
808 gnus-article-strip-leading-blank-lines)
809 (gnus-treat-strip-multiple-blank-lines
810 gnus-article-strip-multiple-blank-lines)
811 (gnus-treat-strip-blank-lines gnus-article-strip-blank-lines)
812 (gnus-treat-overstrike gnus-article-treat-overstrike)
813 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
814 (gnus-treat-display-xface gnus-article-display-x-face)
815 (gnus-treat-display-smileys gnus-smiley-display)
816 (gnus-treat-display-picons gnus-article-display-picons)))
818 (defvar gnus-article-mime-handle-alist nil)
819 (defvar article-lapsed-timer nil)
820 (defvar gnus-article-current-summary nil)
822 (defvar gnus-article-mode-syntax-table
823 (let ((table (copy-syntax-table text-mode-syntax-table)))
824 (modify-syntax-entry ?- "w" table)
825 (modify-syntax-entry ?> ")" table)
826 (modify-syntax-entry ?< "(" table)
828 "Syntax table used in article mode buffers.
829 Initialized from `text-mode-syntax-table.")
831 (defvar gnus-save-article-buffer nil)
833 (defvar gnus-article-mode-line-format-alist
834 (nconc '((?w (gnus-article-wash-status) ?s)
835 (?m (gnus-article-mime-part-status) ?s))
836 gnus-summary-mode-line-format-alist))
838 (defvar gnus-number-of-articles-to-be-saved nil)
840 (defvar gnus-inhibit-hiding nil)
842 (defsubst gnus-article-hide-text (b e props)
843 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
844 (add-text-properties b e props)
845 (when (memq 'intangible props)
847 (max (1- b) (point-min))
848 b 'intangible (cddr (memq 'intangible props)))))
850 (defmacro gnus-with-article (article &rest forms)
851 "Select ARTICLE and perform FORMS in the original article buffer.
852 Then replace the article with the result."
854 ;; We don't want the article to be marked as read.
855 (let (gnus-mark-article-hook)
856 (gnus-summary-select-article t t nil ,article))
857 (set-buffer gnus-original-article-buffer)
859 (if (not (gnus-check-backend-function
860 'request-replace-article (car gnus-article-current)))
861 (gnus-message 5 "Read-only group; not replacing")
862 (unless (gnus-request-replace-article
863 ,article (car gnus-article-current)
865 (error "Couldn't replace article")))
866 ;; The cache and backlog have to be flushed somewhat.
867 (when gnus-keep-backlog
868 (gnus-backlog-remove-article
869 (car gnus-article-current) (cdr gnus-article-current)))
871 (gnus-cache-update-article
872 (car gnus-article-current) (cdr gnus-article-current)))))
874 (put 'gnus-with-article 'lisp-indent-function 1)
875 (put 'gnus-with-article 'edebug-form-spec '(form body))
877 (defsubst gnus-article-unhide-text (b e)
878 "Remove hidden text properties from region between B and E."
879 (remove-text-properties b e gnus-hidden-properties)
880 (when (memq 'intangible gnus-hidden-properties)
881 (put-text-property (max (1- b) (point-min))
884 (defun gnus-article-hide-text-type (b e type)
885 "Hide text of TYPE between B and E."
886 (gnus-article-hide-text
887 b e (cons 'article-type (cons type gnus-hidden-properties))))
889 (defun gnus-article-unhide-text-type (b e type)
890 "Unhide text of TYPE between B and E."
891 (remove-text-properties
892 b e (cons 'article-type (cons type gnus-hidden-properties)))
893 (when (memq 'intangible gnus-hidden-properties)
894 (put-text-property (max (1- b) (point-min))
897 (defun gnus-article-hide-text-of-type (type)
898 "Hide text of TYPE in the current buffer."
900 (let ((b (point-min))
902 (while (setq b (text-property-any b e 'article-type type))
903 (add-text-properties b (incf b) gnus-hidden-properties)))))
905 (defun gnus-article-delete-text-of-type (type)
906 "Delete text of TYPE in the current buffer."
908 (let ((b (point-min)))
909 (while (setq b (text-property-any b (point-max) 'article-type type))
911 b (or (text-property-not-all b (point-max) 'article-type type)
914 (defun gnus-article-delete-invisible-text ()
915 "Delete all invisible text in the current buffer."
917 (let ((b (point-min)))
918 (while (setq b (text-property-any b (point-max) 'invisible t))
920 b (or (text-property-not-all b (point-max) 'invisible t)
923 (defun gnus-article-text-type-exists-p (type)
924 "Say whether any text of type TYPE exists in the buffer."
925 (text-property-any (point-min) (point-max) 'article-type type))
927 (defsubst gnus-article-header-rank ()
928 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
929 (let ((list gnus-sorted-header-list)
932 (when (looking-at (car list))
934 (setq list (cdr list))
938 (defun article-hide-headers (&optional arg delete)
939 "Toggle whether to hide unwanted headers and possibly sort them as well.
940 If given a negative prefix, always show; if given a positive prefix,
942 (interactive (gnus-article-hidden-arg))
944 (if (gnus-article-check-hidden-text 'headers arg)
945 ;; Show boring headers as well.
946 (gnus-article-show-hidden-text 'boring-headers)
947 ;; This function might be inhibited.
948 (unless gnus-inhibit-hiding
951 (let ((buffer-read-only nil)
953 (props (nconc (list 'article-type 'headers)
954 gnus-hidden-properties))
955 (max (1+ (length gnus-sorted-header-list)))
956 (ignored (when (not gnus-visible-headers)
957 (cond ((stringp gnus-ignored-headers)
958 gnus-ignored-headers)
959 ((listp gnus-ignored-headers)
960 (mapconcat 'identity gnus-ignored-headers
963 (cond ((stringp gnus-visible-headers)
964 gnus-visible-headers)
965 ((and gnus-visible-headers
966 (listp gnus-visible-headers))
967 (mapconcat 'identity gnus-visible-headers "\\|"))))
968 (inhibit-point-motion-hooks t)
970 ;; First we narrow to just the headers.
972 (goto-char (point-min))
973 ;; Hide any "From " lines at the beginning of (mail) articles.
974 (while (looking-at "From ")
978 (delete-region (point-min) (point))
979 (gnus-article-hide-text (point-min) (point) props)))
980 ;; Then treat the rest of the header lines.
983 (if (search-forward "\n\n" nil t) ; if there's a body
984 (progn (forward-line -1) (point))
986 ;; Then we use the two regular expressions
987 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
988 ;; select which header lines is to remain visible in the
990 (goto-char (point-min))
991 (while (re-search-forward "^[^ \t]*:" nil t)
993 ;; Mark the rank of the header.
995 (point) (1+ (point)) 'message-rank
996 (if (or (and visible (looking-at visible))
998 (not (looking-at ignored))))
999 (gnus-article-header-rank)
1002 (message-sort-headers-1)
1003 (when (setq beg (text-property-any
1004 (point-min) (point-max) 'message-rank (+ 2 max)))
1005 ;; We make the unwanted headers invisible.
1007 (delete-region beg (point-max))
1008 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
1009 (gnus-article-hide-text-type beg (point-max) 'headers))
1010 ;; Work around XEmacs lossage.
1011 (put-text-property (point-min) beg 'invisible nil))))))))
1013 (defun article-hide-boring-headers (&optional arg)
1014 "Toggle hiding of headers that aren't very interesting.
1015 If given a negative prefix, always show; if given a positive prefix,
1017 (interactive (gnus-article-hidden-arg))
1018 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1019 (not gnus-show-all-headers))
1022 (let ((buffer-read-only nil)
1023 (list gnus-boring-article-headers)
1024 (inhibit-point-motion-hooks t)
1026 (nnheader-narrow-to-headers)
1028 (setq elem (pop list))
1029 (goto-char (point-min))
1031 ;; Hide empty headers.
1033 (while (re-search-forward "^[^:]+:[ \t]*\n[^ \t]" nil t)
1035 (gnus-article-hide-text-type
1036 (progn (beginning-of-line) (point))
1039 (if (re-search-forward "^[^ \t]" nil t)
1043 ;; Hide boring Newsgroups header.
1044 ((eq elem 'newsgroups)
1045 (when (equal (gnus-fetch-field "newsgroups")
1046 (gnus-group-real-name
1047 (if (boundp 'gnus-newsgroup-name)
1050 (gnus-article-hide-header "newsgroups")))
1051 ((eq elem 'followup-to)
1052 (when (equal (message-fetch-field "followup-to")
1053 (message-fetch-field "newsgroups"))
1054 (gnus-article-hide-header "followup-to")))
1055 ((eq elem 'reply-to)
1056 (let ((from (message-fetch-field "from"))
1057 (reply-to (message-fetch-field "reply-to")))
1062 (nth 1 (mail-extract-address-components from))
1063 (nth 1 (mail-extract-address-components reply-to)))))
1064 (gnus-article-hide-header "reply-to"))))
1066 (let ((date (message-fetch-field "date")))
1068 (< (days-between (current-time-string) date)
1070 (gnus-article-hide-header "date"))))
1072 (let ((to (message-fetch-field "to")))
1073 (when (> (length to) 1024)
1074 (gnus-article-hide-header "to"))))
1077 (goto-char (point-min))
1078 (while (re-search-forward "^to:" nil t)
1079 (setq to-count (1+ to-count)))
1080 (when (> to-count 1)
1081 (while (> to-count 0)
1082 (goto-char (point-min))
1084 (re-search-forward "^to:" nil nil to-count)
1086 (narrow-to-region (point) (point-max))
1087 (gnus-article-hide-header "to"))
1088 (setq to-count (1- to-count)))))))))))))
1090 (defun gnus-article-hide-header (header)
1092 (goto-char (point-min))
1093 (when (re-search-forward (concat "^" header ":") nil t)
1094 (gnus-article-hide-text-type
1095 (progn (beginning-of-line) (point))
1098 (if (re-search-forward "^[^ \t]" nil t)
1103 (defvar gnus-article-normalized-header-length 40
1104 "Length of normalized headers.")
1106 (defun article-normalize-headers ()
1107 "Make all header lines 40 characters long."
1109 (let ((buffer-read-only nil)
1113 (message-narrow-to-head)
1116 ((< (setq column (- (gnus-point-at-eol) (point)))
1117 gnus-article-normalized-header-length)
1119 (insert (make-string
1120 (- gnus-article-normalized-header-length column)
1122 ((> column gnus-article-normalized-header-length)
1123 (gnus-put-text-property
1125 (forward-char gnus-article-normalized-header-length)
1132 (forward-line 1))))))
1134 (defun article-treat-dumbquotes ()
1135 "Translate M******** sm*rtq**t*s into proper text.
1136 Note that this function guesses whether a character is a sm*rtq**t* or
1137 not, so it should only be used interactively."
1139 (article-translate-strings gnus-article-dumbquotes-map))
1141 (defun article-translate-characters (from to)
1142 "Translate all characters in the body of the article according to FROM and TO.
1143 FROM is a string of characters to translate from; to is a string of
1144 characters to translate to."
1146 (when (article-goto-body)
1147 (let ((buffer-read-only nil)
1148 (x (make-string 225 ?x))
1150 (while (< (incf i) (length x))
1153 (while (< i (length from))
1154 (aset x (aref from i) (aref to i))
1156 (translate-region (point) (point-max) x)))))
1158 (defun article-translate-strings (map)
1159 "Translate all string in the body of the article according to MAP.
1160 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1162 (when (article-goto-body)
1163 (let ((buffer-read-only nil)
1165 (while (setq elem (pop map))
1167 (while (search-forward (car elem) nil t)
1168 (replace-match (cadr elem)))))))))
1170 (defun article-treat-overstrike ()
1171 "Translate overstrikes into bold text."
1174 (when (article-goto-body)
1175 (let ((buffer-read-only nil))
1176 (while (search-forward "\b" nil t)
1177 (let ((next (char-after))
1178 (previous (char-after (- (point) 2))))
1179 ;; We do the boldification/underlining by hiding the
1180 ;; overstrikes and putting the proper text property
1184 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1185 (put-text-property (point) (1+ (point)) 'face 'bold))
1187 (gnus-article-hide-text-type
1188 (1- (point)) (1+ (point)) 'overstrike)
1190 (- (point) 2) (1- (point)) 'face 'underline))
1192 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1194 (point) (1+ (point)) 'face 'underline)))))))))
1196 (defun article-fill-long-lines ()
1197 "Fill lines that are wider than the window width."
1200 (let ((buffer-read-only nil)
1201 (width (window-width (get-buffer-window (current-buffer)))))
1205 (let ((adaptive-fill-mode nil))
1208 (when (>= (current-column) (min fill-column width))
1209 (narrow-to-region (point) (gnus-point-at-bol))
1210 (fill-paragraph nil)
1211 (goto-char (point-max))
1213 (forward-line 1)))))))
1215 (defun article-capitalize-sentences ()
1216 "Capitalize the first word in each sentence."
1219 (let ((buffer-read-only nil)
1220 (paragraph-start "^[\n\^L]"))
1224 (forward-sentence)))))
1226 (defun article-remove-cr ()
1227 "Translate CRLF pairs into LF, and then CR into LF.."
1230 (let ((buffer-read-only nil))
1231 (goto-char (point-min))
1232 (while (search-forward "\r$" nil t)
1233 (replace-match "" t t))
1234 (goto-char (point-min))
1235 (while (search-forward "\r" nil t)
1236 (replace-match "\n" t t)))))
1238 (defun article-remove-trailing-blank-lines ()
1239 "Remove all trailing blank lines from the article."
1242 (let ((buffer-read-only nil))
1243 (goto-char (point-max))
1247 (while (and (not (bobp))
1248 (looking-at "^[ \t]*$")
1249 (not (gnus-annotation-in-region-p
1250 (point) (gnus-point-at-eol))))
1255 (defun article-display-x-face (&optional force)
1256 "Look for an X-Face header and display it if present."
1257 (interactive (list 'force))
1259 ;; Delete the old process, if any.
1260 (when (process-status "article-x-face")
1261 (delete-process "article-x-face"))
1262 (let ((inhibit-point-motion-hooks t)
1263 (case-fold-search t)
1266 (goto-char (point-min))
1267 (setq from (message-fetch-field "from"))
1268 (goto-char (point-min))
1269 (while (and gnus-article-x-face-command
1272 ;; Check whether this face is censored.
1273 (not gnus-article-x-face-too-ugly)
1274 (and gnus-article-x-face-too-ugly from
1275 (not (string-match gnus-article-x-face-too-ugly
1277 ;; Has to be present.
1278 (re-search-forward "^X-Face: " nil t))
1279 ;; This used to try to do multiple faces (`while' instead of
1280 ;; `when' above), but (a) sending multiple EOFs to xv doesn't
1281 ;; work (b) it can crash some versions of Emacs (c) are
1282 ;; multiple faces really something to encourage?
1283 (when (stringp gnus-article-x-face-command)
1285 ;; We now have the area of the buffer where the X-Face is stored.
1288 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
1289 ;; We display the face.
1290 (if (symbolp gnus-article-x-face-command)
1291 ;; The command is a lisp function, so we call it.
1292 (if (gnus-functionp gnus-article-x-face-command)
1293 (funcall gnus-article-x-face-command beg end)
1294 (error "%s is not a function" gnus-article-x-face-command))
1295 ;; The command is a string, so we interpret the command
1296 ;; as a, well, command, and fork it off.
1297 (let ((process-connection-type nil))
1298 (process-kill-without-query
1300 "article-x-face" nil shell-file-name shell-command-switch
1301 gnus-article-x-face-command))
1302 (process-send-region "article-x-face" beg end)
1303 (process-send-eof "article-x-face"))))))))))
1305 (defun article-decode-mime-words ()
1306 "Decode all MIME-encoded words in the article."
1309 (set-buffer gnus-article-buffer)
1310 (let ((inhibit-point-motion-hooks t)
1312 (mail-parse-charset gnus-newsgroup-charset))
1313 (mail-decode-encoded-word-region (point-min) (point-max)))))
1315 (defun article-decode-charset (&optional prompt)
1316 "Decode charset-encoded text in the article.
1317 If PROMPT (the prefix), prompt for a coding system to use."
1321 (message-narrow-to-head)
1322 (let* ((inhibit-point-motion-hooks t)
1323 (case-fold-search t)
1324 (ct (message-fetch-field "Content-Type" t))
1325 (cte (message-fetch-field "Content-Transfer-Encoding" t))
1326 (ctl (and ct (ignore-errors
1327 (mail-header-parse-content-type ct))))
1330 (mm-read-coding-system "Charset to decode: "))
1332 (mail-content-type-get ctl 'charset))))
1333 (mail-parse-charset gnus-newsgroup-charset)
1335 (goto-char (point-max))
1338 (narrow-to-region (point) (point-max))
1339 (when (and (or (not ctl)
1340 (equal (car ctl) "text/plain"))
1343 charset (and cte (intern (downcase
1344 (gnus-strip-whitespace cte))))
1347 (defun article-decode-encoded-words ()
1348 "Remove encoded-word encoding from headers."
1349 (let ((inhibit-point-motion-hooks t)
1350 (mail-parse-charset gnus-newsgroup-charset)
1353 (message-narrow-to-head)
1354 (funcall gnus-decode-header-function (point-min) (point-max)))))
1356 (defun article-de-quoted-unreadable (&optional force)
1357 "Translate a quoted-printable-encoded article.
1358 If FORCE, decode the article whether it is marked as quoted-printable
1360 (interactive (list 'force))
1362 (let ((buffer-read-only nil)
1363 (type (gnus-fetch-field "content-transfer-encoding"))
1364 (charset gnus-newsgroup-charset))
1366 (and type (string-match "quoted-printable" (downcase type))))
1369 (narrow-to-region (point) (point-max))
1370 (quoted-printable-decode-region (point-min) (point-max))
1372 (mm-decode-body charset)))))))
1374 (defun article-hide-pgp (&optional arg)
1375 "Toggle hiding of any PGP headers and signatures in the current article.
1376 If given a negative prefix, always show; if given a positive prefix,
1378 (interactive (gnus-article-hidden-arg))
1379 (unless (gnus-article-check-hidden-text 'pgp arg)
1381 (let ((inhibit-point-motion-hooks t)
1382 buffer-read-only beg end)
1384 (goto-char (point-min))
1385 ;; Hide the "header".
1386 (when (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
1387 (delete-region (1+ (match-beginning 0)) (match-end 0))
1388 ;; PGP 5 and GNU PG add a `Hash: <>' comment, hide that too
1389 (when (looking-at "Hash:.*$")
1390 (delete-region (point) (1+ (gnus-point-at-eol))))
1392 ;; Hide the actual signature.
1393 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
1394 (setq end (1+ (match-beginning 0)))
1397 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
1399 ;; Perhaps we shouldn't hide to the end of the buffer
1400 ;; if there is no end to the signature?
1402 ;; Hide "- " PGP quotation markers.
1404 (narrow-to-region beg end)
1405 (goto-char (point-min))
1406 (while (re-search-forward "^- " nil t)
1408 (match-beginning 0) (match-end 0)))
1410 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
1412 (defun article-hide-pem (&optional arg)
1413 "Toggle hiding of any PEM headers and signatures in the current article.
1414 If given a negative prefix, always show; if given a positive prefix,
1416 (interactive (gnus-article-hidden-arg))
1417 (unless (gnus-article-check-hidden-text 'pem arg)
1419 (let (buffer-read-only end)
1421 (goto-char (point-min))
1422 ;; hide the horrendously ugly "header".
1423 (and (search-forward "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
1426 (setq end (1+ (match-beginning 0)))
1427 (gnus-article-hide-text-type
1429 (if (search-forward "\n\n" nil t)
1433 ;; hide the trailer as well
1434 (and (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
1437 (gnus-article-hide-text-type
1438 (match-beginning 0) (match-end 0) 'pem))))))
1440 (defun article-strip-banner ()
1441 "Strip the banner specified by the `banner' group parameter."
1445 (let ((inhibit-point-motion-hooks t)
1446 (banner (gnus-group-get-parameter gnus-newsgroup-name 'banner))
1447 (gnus-signature-limit nil)
1448 buffer-read-only beg end)
1452 ((eq banner 'signature)
1453 (when (gnus-article-narrow-to-signature)
1456 (delete-region (point) (point-max))))
1458 (while (re-search-forward banner nil t)
1459 (delete-region (match-beginning 0) (match-end 0))))))))))
1461 (defun article-hide-signature (&optional arg)
1462 "Hide the signature in the current article.
1463 If given a negative prefix, always show; if given a positive prefix,
1465 (interactive (gnus-article-hidden-arg))
1466 (unless (gnus-article-check-hidden-text 'signature arg)
1469 (let ((buffer-read-only nil))
1470 (when (gnus-article-narrow-to-signature)
1471 (gnus-article-hide-text-type
1472 (point-min) (point-max) 'signature)))))))
1474 (defun article-strip-leading-blank-lines ()
1475 "Remove all blank lines from the beginning of the article."
1478 (let ((inhibit-point-motion-hooks t)
1480 (when (article-goto-body)
1481 (while (and (not (eobp))
1482 (looking-at "[ \t]*$"))
1483 (gnus-delete-line))))))
1485 (defun article-goto-body ()
1486 "Place point at the start of the body."
1487 (goto-char (point-min))
1489 ;; This variable is only bound when dealing with separate
1491 (article-goto-body-goes-to-point-min-p
1493 ((search-forward "\n\n" nil t)
1496 (goto-char (point-max))
1499 (defun article-strip-multiple-blank-lines ()
1500 "Replace consecutive blank lines with one empty line."
1503 (let ((inhibit-point-motion-hooks t)
1505 ;; First make all blank lines empty.
1507 (while (re-search-forward "^[ \t]+$" nil t)
1508 (unless (gnus-annotation-in-region-p
1509 (match-beginning 0) (match-end 0))
1510 (replace-match "" nil t)))
1511 ;; Then replace multiple empty lines with a single empty line.
1513 (while (re-search-forward "\n\n\n+" nil t)
1514 (unless (gnus-annotation-in-region-p
1515 (match-beginning 0) (match-end 0))
1516 (replace-match "\n\n" t t))))))
1518 (defun article-strip-leading-space ()
1519 "Remove all white space from the beginning of the lines in the article."
1522 (let ((inhibit-point-motion-hooks t)
1525 (while (re-search-forward "^[ \t]+" nil t)
1526 (replace-match "" t t)))))
1528 (defun article-strip-trailing-space ()
1529 "Remove all white space from the end of the lines in the article."
1532 (let ((inhibit-point-motion-hooks t)
1535 (while (re-search-forward "[ \t]+$" nil t)
1536 (replace-match "" t t)))))
1538 (defun article-strip-blank-lines ()
1539 "Strip leading, trailing and multiple blank lines."
1541 (article-strip-leading-blank-lines)
1542 (article-remove-trailing-blank-lines)
1543 (article-strip-multiple-blank-lines))
1545 (defun article-strip-all-blank-lines ()
1546 "Strip all blank lines."
1549 (let ((inhibit-point-motion-hooks t)
1552 (while (re-search-forward "^[ \t]*\n" nil t)
1553 (replace-match "" t t)))))
1555 (defun gnus-article-narrow-to-signature ()
1556 "Narrow to the signature; return t if a signature is found, else nil."
1558 (let ((inhibit-point-motion-hooks t))
1559 (when (gnus-article-search-signature)
1561 ;; Check whether we have some limits to what we consider
1562 ;; to be a signature.
1563 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
1564 (list gnus-signature-limit)))
1566 (while (setq limit (pop limits))
1567 (if (or (and (integerp limit)
1568 (< (- (point-max) (point)) limit))
1570 (< (count-lines (point) (point-max)) limit))
1571 (and (gnus-functionp limit)
1573 (and (stringp limit)
1574 (not (re-search-forward limit nil t))))
1575 () ; This limit did not succeed.
1579 (narrow-to-region (point) (point-max))
1582 (defun gnus-article-search-signature ()
1583 "Search the current buffer for the signature separator.
1584 Put point at the beginning of the signature separator."
1585 (let ((cur (point)))
1586 (goto-char (point-max))
1587 (if (if (stringp gnus-signature-separator)
1588 (re-search-backward gnus-signature-separator nil t)
1589 (let ((seps gnus-signature-separator))
1591 (not (re-search-backward (car seps) nil t)))
1599 (autoload 'w3-display "w3-parse")
1600 (autoload 'w3-do-setup "w3" "" t)
1601 (autoload 'w3-region "w3-display" "" t))
1603 (defun gnus-article-treat-html ()
1606 (let ((cbuf (current-buffer)))
1607 (set-buffer gnus-article-buffer)
1608 (let (buf buffer-read-only b e)
1610 (goto-char (point-min))
1612 (if (search-forward "\n\n" nil t)
1615 (setq e (point-max)))
1617 (insert-buffer-substring gnus-article-buffer b e)
1619 (save-window-excursion
1620 (w3-region (point-min) (point-max))
1621 (setq buf (buffer-substring-no-properties (point-min) (point-max)))))
1623 (delete-region (point-min) (point-max))
1626 (goto-char (point-min))
1627 (set-window-start (get-buffer-window (current-buffer)) (point-min))
1628 (set-buffer cbuf))))
1630 (defun gnus-article-hidden-arg ()
1631 "Return the current prefix arg as a number, or 0 if no prefix."
1632 (list (if current-prefix-arg
1633 (prefix-numeric-value current-prefix-arg)
1636 (defun gnus-article-check-hidden-text (type arg)
1637 "Return nil if hiding is necessary.
1638 Arg can be nil or a number. Nil and positive means hide, negative
1639 means show, 0 means toggle."
1643 (let ((hide (gnus-article-hidden-text-p type)))
1649 (gnus-article-show-hidden-text type))
1651 (if (eq hide 'hidden)
1652 (gnus-article-show-hidden-text type)
1655 (defun gnus-article-hidden-text-p (type)
1656 "Say whether the current buffer contains hidden text of type TYPE."
1657 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
1659 (not (get-text-property pos 'invisible)))
1661 (text-property-any (1+ pos) (point-max) 'article-type type)))
1666 (defun gnus-article-show-hidden-text (type &optional hide)
1667 "Show all hidden text of type TYPE.
1668 If HIDE, hide the text instead."
1670 (let ((buffer-read-only nil)
1671 (inhibit-point-motion-hooks t)
1674 (while (setq beg (text-property-any end (point-max) 'article-type type))
1677 (text-property-not-all beg (point-max) 'article-type type)
1680 (gnus-article-hide-text beg end gnus-hidden-properties)
1681 (gnus-article-unhide-text beg end))
1685 (defconst article-time-units
1686 `((year . ,(* 365.25 24 60 60))
1687 (week . ,(* 7 24 60 60))
1688 (day . ,(* 24 60 60))
1692 "Mapping from time units to seconds.")
1694 (defun article-date-ut (&optional type highlight header)
1695 "Convert DATE date to universal time in the current article.
1696 If TYPE is `local', convert to local time; if it is `lapsed', output
1697 how much time has lapsed since DATE."
1698 (interactive (list 'ut t))
1699 (let* ((header (or header
1700 (mail-header-date (save-excursion
1701 (set-buffer gnus-summary-buffer)
1702 gnus-current-headers))
1703 (message-fetch-field "date")
1705 (date (if (vectorp header) (mail-header-date header)
1707 (date-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
1708 (inhibit-point-motion-hooks t)
1709 bface eface newline)
1710 (when (and date (not (string= date "")))
1713 (nnheader-narrow-to-headers)
1714 (let ((buffer-read-only nil))
1715 ;; Delete any old Date headers.
1716 (if (re-search-forward date-regexp nil t)
1718 (setq bface (get-text-property (gnus-point-at-bol) 'face)
1719 eface (get-text-property (1- (gnus-point-at-eol))
1721 (delete-region (progn (beginning-of-line) (point))
1722 (progn (end-of-line) (point)))
1723 (beginning-of-line))
1724 (goto-char (point-max))
1726 (insert (article-make-date-line date type))
1729 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
1730 (put-text-property (match-beginning 1) (1+ (match-end 1))
1732 (put-text-property (match-beginning 2) (match-end 2)
1736 (insert "\n"))))))))
1738 (defun article-make-date-line (date type)
1739 "Return a DATE line of TYPE."
1740 (let ((time (condition-case ()
1744 ;; Convert to the local timezone. We have to slap a
1745 ;; `condition-case' round the calls to the timezone
1746 ;; functions since they aren't particularly resistant to
1749 (let ((tz (car (current-time-zone))))
1750 (format "Date: %s %s%04d" (current-time-string time)
1751 (if (> tz 0) "+" "-") (abs (/ tz 36)))))
1752 ;; Convert to Universal Time.
1755 (current-time-string
1756 (let* ((e (parse-time-string date))
1757 (tm (apply 'encode-time e))
1759 (ls (- (cadr tm) (car (current-time-zone)))))
1760 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
1761 ((> ls 65535) (list (1+ ms) (- ls 65536)))
1764 ;; Get the original date from the article.
1765 ((eq type 'original)
1766 (concat "Date: " (if (string-match "\n+$" date)
1767 (substring date 0 (match-beginning 0))
1769 ;; Let the user define the format.
1771 (if (gnus-functionp gnus-article-time-format)
1772 (funcall gnus-article-time-format time)
1775 (format-time-string gnus-article-time-format time))))
1780 (format-time-string "%Y%m%dT%H%M%S" time)))
1781 ;; Do an X-Sent lapsed format.
1783 ;; If the date is seriously mangled, the timezone functions are
1784 ;; liable to bug out, so we ignore all errors.
1785 (let* ((now (current-time))
1786 (real-time (subtract-time now time))
1787 (real-sec (and real-time
1788 (+ (* (float (car real-time)) 65536)
1790 (sec (and real-time (abs real-sec)))
1800 ;; This is a bit convoluted, but basically we go
1801 ;; through the time units for years, weeks, etc,
1802 ;; and divide things to see whether that results
1803 ;; in positive answers.
1806 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
1807 ;; The (remaining) seconds are too few to
1808 ;; be divided into this time unit.
1810 ;; It's big enough, so we output it.
1811 (setq sec (- sec (* num (cdr unit))))
1813 (concat (if prev ", " "") (int-to-string
1815 " " (symbol-name (car unit))
1816 (if (> num 1) "s" ""))
1818 article-time-units "")
1819 ;; If dates are odd, then it might appear like the
1820 ;; article was sent in the future.
1823 " in the future"))))))
1825 (error "Unknown conversion type: %s" type)))))
1827 (defun article-date-local (&optional highlight)
1828 "Convert the current article date to the local timezone."
1829 (interactive (list t))
1830 (article-date-ut 'local highlight))
1832 (defun article-date-original (&optional highlight)
1833 "Convert the current article date to what it was originally.
1834 This is only useful if you have used some other date conversion
1835 function and want to see what the date was before converting."
1836 (interactive (list t))
1837 (article-date-ut 'original highlight))
1839 (defun article-date-lapsed (&optional highlight)
1840 "Convert the current article date to time lapsed since it was sent."
1841 (interactive (list t))
1842 (article-date-ut 'lapsed highlight))
1844 (defun article-update-date-lapsed ()
1845 "Function to be run from a timer to update the lapsed time line."
1846 (let (deactivate-mark)
1851 (set-buffer (window-buffer w))
1852 (when (eq major-mode 'gnus-article-mode)
1853 (goto-char (point-min))
1854 (when (re-search-forward "^X-Sent:" nil t)
1855 (article-date-lapsed t))))
1858 (defun gnus-start-date-timer (&optional n)
1859 "Start a timer to update the X-Sent header in the article buffers.
1860 The numerical prefix says how frequently (in seconds) the function
1865 (gnus-stop-date-timer)
1866 (setq article-lapsed-timer
1867 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
1869 (defun gnus-stop-date-timer ()
1870 "Stop the X-Sent timer."
1872 (when article-lapsed-timer
1873 (nnheader-cancel-timer article-lapsed-timer)
1874 (setq article-lapsed-timer nil)))
1876 (defun article-date-user (&optional highlight)
1877 "Convert the current article date to the user-defined format.
1878 This format is defined by the `gnus-article-time-format' variable."
1879 (interactive (list t))
1880 (article-date-ut 'user highlight))
1882 (defun article-date-iso8601 (&optional highlight)
1883 "Convert the current article date to ISO8601."
1884 (interactive (list t))
1885 (article-date-ut 'iso8601 highlight))
1887 (defun article-show-all ()
1888 "Show all hidden text in the article buffer."
1891 (let ((buffer-read-only nil))
1892 (gnus-article-unhide-text (point-min) (point-max)))))
1894 (defun article-emphasize (&optional arg)
1895 "Emphasize text according to `gnus-emphasis-alist'."
1896 (interactive (gnus-article-hidden-arg))
1897 (unless (gnus-article-check-hidden-text 'emphasis arg)
1899 (let ((alist gnus-emphasis-alist)
1900 (buffer-read-only nil)
1901 (props (append '(article-type emphasis)
1902 gnus-hidden-properties))
1903 regexp elem beg invisible visible face)
1906 (while (setq elem (pop alist))
1908 (setq regexp (car elem)
1909 invisible (nth 1 elem)
1910 visible (nth 2 elem)
1912 (while (re-search-forward regexp nil t)
1913 (when (and (match-beginning visible) (match-beginning invisible))
1914 (gnus-article-hide-text
1915 (match-beginning invisible) (match-end invisible) props)
1916 (gnus-article-unhide-text-type
1917 (match-beginning visible) (match-end visible) 'emphasis)
1918 (gnus-put-text-property-excluding-newlines
1919 (match-beginning visible) (match-end visible) 'face face)
1920 (goto-char (match-end invisible)))))))))
1922 (defvar gnus-summary-article-menu)
1923 (defvar gnus-summary-post-menu)
1925 ;;; Saving functions.
1927 (defun gnus-article-save (save-buffer file &optional num)
1928 "Save the currently selected article."
1929 (unless gnus-save-all-headers
1930 ;; Remove headers according to `gnus-saved-headers'.
1931 (let ((gnus-visible-headers
1932 (or gnus-saved-headers gnus-visible-headers))
1933 (gnus-article-buffer save-buffer))
1935 (set-buffer save-buffer)
1936 (article-hide-headers 1 t))))
1937 (save-window-excursion
1938 (if (not gnus-default-article-saver)
1939 (error "No default saver is defined")
1940 ;; !!! Magic! The saving functions all save
1941 ;; `gnus-save-article-buffer' (or so they think), but we
1942 ;; bind that variable to our save-buffer.
1943 (set-buffer gnus-article-buffer)
1944 (let* ((gnus-save-article-buffer save-buffer)
1947 ((not gnus-prompt-before-saving) 'default)
1948 ((eq gnus-prompt-before-saving 'always) nil)
1950 (gnus-number-of-articles-to-be-saved
1951 (when (eq gnus-prompt-before-saving t)
1953 (set-buffer gnus-article-current-summary)
1954 (funcall gnus-default-article-saver filename)))))
1956 (defun gnus-read-save-file-name (prompt &optional filename
1957 function group headers variable)
1959 (funcall function group headers (symbol-value variable)))
1964 ((eq filename 'default)
1970 (let* ((split-name (gnus-get-split-value gnus-split-methods))
1973 (if (and gnus-number-of-articles-to-be-saved
1974 (> gnus-number-of-articles-to-be-saved 1))
1975 (format "these %d articles"
1976 gnus-number-of-articles-to-be-saved)
1979 ;; Let the split methods have their say.
1981 ;; No split name was found.
1984 (concat prompt " (default "
1985 (file-name-nondirectory default-name) ") ")
1986 (file-name-directory default-name)
1988 ;; A single group name is returned.
1989 ((stringp split-name)
1991 (funcall function split-name headers
1992 (symbol-value variable)))
1994 (concat prompt " (default "
1995 (file-name-nondirectory default-name) ") ")
1996 (file-name-directory default-name)
1998 ;; A single split name was found
1999 ((= 1 (length split-name))
2000 (let* ((name (expand-file-name
2001 (car split-name) gnus-article-save-directory))
2002 (dir (cond ((file-directory-p name)
2003 (file-name-as-directory name))
2004 ((file-exists-p name) name)
2005 (t gnus-article-save-directory))))
2007 (concat prompt " (default " name ") ")
2009 ;; A list of splits was found.
2011 (setq split-name (nreverse split-name))
2013 (let ((file-name-history
2014 (nconc split-name file-name-history)))
2018 (concat prompt " (`M-p' for defaults) ")
2019 gnus-article-save-directory
2021 gnus-article-save-directory)))
2022 (car (push result file-name-history)))))))
2023 ;; Create the directory.
2024 (gnus-make-directory (file-name-directory file))
2025 ;; If we have read a directory, we append the default file name.
2026 (when (file-directory-p file)
2027 (setq file (concat (file-name-as-directory file)
2028 (file-name-nondirectory default-name))))
2029 ;; Possibly translate some characters.
2030 (nnheader-translate-file-chars file)))))
2031 (gnus-make-directory (file-name-directory result))
2032 (set variable result)))
2034 (defun gnus-article-archive-name (group)
2035 "Return the first instance of an \"Archive-name\" in the current buffer."
2036 (let ((case-fold-search t))
2037 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
2038 (nnheader-concat gnus-article-save-directory
2039 (match-string 1)))))
2041 (defun gnus-article-nndoc-name (group)
2042 "If GROUP is an nndoc group, return the name of the parent group."
2043 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
2044 (gnus-group-get-parameter group 'save-article-group)))
2046 (defun gnus-summary-save-in-rmail (&optional filename)
2047 "Append this article to Rmail file.
2048 Optional argument FILENAME specifies file name.
2049 Directory to save to is default to `gnus-article-save-directory'."
2050 (setq filename (gnus-read-save-file-name
2051 "Save %s in rmail file:" filename
2052 gnus-rmail-save-name gnus-newsgroup-name
2053 gnus-current-headers 'gnus-newsgroup-last-rmail))
2054 (gnus-eval-in-buffer-window gnus-save-article-buffer
2058 (gnus-output-to-rmail filename))))
2061 (defun gnus-summary-save-in-mail (&optional filename)
2062 "Append this article to Unix mail file.
2063 Optional argument FILENAME specifies file name.
2064 Directory to save to is default to `gnus-article-save-directory'."
2065 (setq filename (gnus-read-save-file-name
2066 "Save %s in Unix mail file:" filename
2067 gnus-mail-save-name gnus-newsgroup-name
2068 gnus-current-headers 'gnus-newsgroup-last-mail))
2069 (gnus-eval-in-buffer-window gnus-save-article-buffer
2073 (if (and (file-readable-p filename)
2074 (mail-file-babyl-p filename))
2075 (rmail-output-to-rmail-file filename t)
2076 (gnus-output-to-mail filename)))))
2079 (defun gnus-summary-save-in-file (&optional filename overwrite)
2080 "Append this article to file.
2081 Optional argument FILENAME specifies file name.
2082 Directory to save to is default to `gnus-article-save-directory'."
2083 (setq filename (gnus-read-save-file-name
2084 "Save %s in file:" filename
2085 gnus-file-save-name gnus-newsgroup-name
2086 gnus-current-headers 'gnus-newsgroup-last-file))
2087 (gnus-eval-in-buffer-window gnus-save-article-buffer
2091 (when (and overwrite
2092 (file-exists-p filename))
2093 (delete-file filename))
2094 (gnus-output-to-file filename))))
2097 (defun gnus-summary-write-to-file (&optional filename)
2098 "Write this article to a file.
2099 Optional argument FILENAME specifies file name.
2100 The directory to save in defaults to `gnus-article-save-directory'."
2101 (gnus-summary-save-in-file nil t))
2103 (defun gnus-summary-save-body-in-file (&optional filename)
2104 "Append this article body to a file.
2105 Optional argument FILENAME specifies file name.
2106 The directory to save in defaults to `gnus-article-save-directory'."
2107 (setq filename (gnus-read-save-file-name
2108 "Save %s body in file:" filename
2109 gnus-file-save-name gnus-newsgroup-name
2110 gnus-current-headers 'gnus-newsgroup-last-file))
2111 (gnus-eval-in-buffer-window gnus-save-article-buffer
2115 (when (article-goto-body)
2116 (narrow-to-region (point) (point-max)))
2117 (gnus-output-to-file filename))))
2120 (defun gnus-summary-save-in-pipe (&optional command)
2121 "Pipe this article to subprocess."
2123 (cond ((and (eq command 'default)
2124 gnus-last-shell-command)
2125 gnus-last-shell-command)
2129 "Shell command on %s: "
2130 (if (and gnus-number-of-articles-to-be-saved
2131 (> gnus-number-of-articles-to-be-saved 1))
2132 (format "these %d articles"
2133 gnus-number-of-articles-to-be-saved)
2135 gnus-last-shell-command))))
2136 (when (string-equal command "")
2137 (setq command gnus-last-shell-command))
2138 (gnus-eval-in-buffer-window gnus-article-buffer
2141 (shell-command-on-region (point-min) (point-max) command nil)))
2142 (setq gnus-last-shell-command command))
2144 ;;; Article file names when saving.
2146 (defun gnus-capitalize-newsgroup (newsgroup)
2147 "Capitalize NEWSGROUP name."
2148 (when (not (zerop (length newsgroup)))
2149 (concat (char-to-string (upcase (aref newsgroup 0)))
2150 (substring newsgroup 1))))
2152 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2153 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2154 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
2155 Otherwise, it is like ~/News/news/group/num."
2158 (concat (if (gnus-use-long-file-name 'not-save)
2159 (gnus-capitalize-newsgroup newsgroup)
2160 (gnus-newsgroup-directory-form newsgroup))
2161 "/" (int-to-string (mail-header-number headers)))
2162 gnus-article-save-directory)))
2164 (string-equal (file-name-directory default)
2165 (file-name-directory last-file))
2166 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2168 (or last-file default))))
2170 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2171 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2172 If variable `gnus-use-long-file-name' is non-nil, it is
2173 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2176 (concat (if (gnus-use-long-file-name 'not-save)
2178 (gnus-newsgroup-directory-form newsgroup))
2179 "/" (int-to-string (mail-header-number headers)))
2180 gnus-article-save-directory)))
2182 (string-equal (file-name-directory default)
2183 (file-name-directory last-file))
2184 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2186 (or last-file default))))
2188 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2189 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2190 If variable `gnus-use-long-file-name' is non-nil, it is
2191 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2194 (if (gnus-use-long-file-name 'not-save)
2195 (gnus-capitalize-newsgroup newsgroup)
2196 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2197 gnus-article-save-directory)))
2199 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2200 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2201 If variable `gnus-use-long-file-name' is non-nil, it is
2202 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2205 (if (gnus-use-long-file-name 'not-save)
2207 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2208 gnus-article-save-directory)))
2215 (setq afunc (car func)
2218 gfunc (intern (format "gnus-%s" func))))
2220 (if (not (fboundp afunc))
2222 `(lambda (&optional interactive &rest args)
2223 ,(documentation afunc t)
2224 (interactive (list t))
2226 (set-buffer gnus-article-buffer)
2228 (call-interactively ',afunc)
2229 (apply ',afunc args))))))))
2230 '(article-hide-headers
2231 article-hide-boring-headers
2232 article-treat-overstrike
2233 article-fill-long-lines
2234 article-capitalize-sentences
2236 article-display-x-face
2237 article-de-quoted-unreadable
2238 article-mime-decode-quoted-printable
2240 article-strip-banner
2242 article-hide-signature
2243 article-remove-trailing-blank-lines
2244 article-strip-leading-blank-lines
2245 article-strip-multiple-blank-lines
2246 article-strip-leading-space
2247 article-strip-trailing-space
2248 article-strip-blank-lines
2249 article-strip-all-blank-lines
2251 article-date-iso8601
2252 article-date-original
2254 article-decode-mime-words
2255 article-decode-charset
2256 article-decode-encoded-words
2260 article-treat-dumbquotes
2261 article-normalize-headers
2262 (article-show-all . gnus-article-show-all-headers))))
2265 ;;; Gnus article mode
2268 (put 'gnus-article-mode 'mode-class 'special)
2270 (set-keymap-parent gnus-article-mode-map widget-keymap)
2272 (gnus-define-keys gnus-article-mode-map
2273 " " gnus-article-goto-next-page
2274 "\177" gnus-article-goto-prev-page
2275 [delete] gnus-article-goto-prev-page
2276 [backspace] gnus-article-goto-prev-page
2277 "\C-c^" gnus-article-refer-article
2278 "h" gnus-article-show-summary
2279 "s" gnus-article-show-summary
2280 "\C-c\C-m" gnus-article-mail
2281 "?" gnus-article-describe-briefly
2282 "e" gnus-article-edit
2283 "<" beginning-of-buffer
2285 "\C-c\C-i" gnus-info-find-node
2288 "\C-d" gnus-article-read-summary-keys
2289 "\M-*" gnus-article-read-summary-keys
2290 "\M-#" gnus-article-read-summary-keys
2291 "\M-^" gnus-article-read-summary-keys
2292 "\M-g" gnus-article-read-summary-keys)
2294 (substitute-key-definition
2295 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
2297 (defun gnus-article-make-menu-bar ()
2298 (gnus-turn-off-edit-menu 'article)
2299 (unless (boundp 'gnus-article-article-menu)
2301 gnus-article-article-menu gnus-article-mode-map ""
2303 ["Scroll forwards" gnus-article-goto-next-page t]
2304 ["Scroll backwards" gnus-article-goto-prev-page t]
2305 ["Show summary" gnus-article-show-summary t]
2306 ["Fetch Message-ID at point" gnus-article-refer-article t]
2307 ["Mail to address at point" gnus-article-mail t]
2308 ["Send a bug report" gnus-bug t]))
2311 gnus-article-treatment-menu gnus-article-mode-map ""
2313 ["Hide headers" gnus-article-hide-headers t]
2314 ["Hide signature" gnus-article-hide-signature t]
2315 ["Hide citation" gnus-article-hide-citation t]
2316 ["Treat overstrike" gnus-article-treat-overstrike t]
2317 ["Remove carriage return" gnus-article-remove-cr t]
2318 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]))
2320 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
2322 (when (boundp 'gnus-summary-post-menu)
2323 (define-key gnus-article-mode-map [menu-bar post]
2324 (cons "Post" gnus-summary-post-menu)))
2326 (gnus-run-hooks 'gnus-article-menu-hook)))
2328 (defun gnus-article-mode ()
2329 "Major mode for displaying an article.
2331 All normal editing commands are switched off.
2333 The following commands are available in addition to all summary mode
2335 \\<gnus-article-mode-map>
2336 \\[gnus-article-next-page]\t Scroll the article one page forwards
2337 \\[gnus-article-prev-page]\t Scroll the article one page backwards
2338 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
2339 \\[gnus-article-show-summary]\t Display the summary buffer
2340 \\[gnus-article-mail]\t Send a reply to the address near point
2341 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
2342 \\[gnus-info-find-node]\t Go to the Gnus info node"
2344 (when (gnus-visual-p 'article-menu 'menu)
2345 (gnus-article-make-menu-bar))
2346 (gnus-simplify-mode-line)
2347 (setq mode-name "Article")
2348 (setq major-mode 'gnus-article-mode)
2349 (make-local-variable 'minor-mode-alist)
2350 (use-local-map gnus-article-mode-map)
2351 (gnus-update-format-specifications nil 'article-mode)
2352 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
2353 (make-local-variable 'gnus-page-broken)
2354 (make-local-variable 'gnus-button-marker-list)
2355 (make-local-variable 'gnus-article-current-summary)
2356 (make-local-variable 'gnus-article-mime-handles)
2357 (make-local-variable 'gnus-article-decoded-p)
2358 (make-local-variable 'gnus-article-mime-handle-alist)
2359 (gnus-set-default-directory)
2360 (buffer-disable-undo)
2361 (setq buffer-read-only t)
2362 (set-syntax-table gnus-article-mode-syntax-table)
2363 (mm-enable-multibyte)
2364 (gnus-run-hooks 'gnus-article-mode-hook))
2366 (defun gnus-article-setup-buffer ()
2367 "Initialize the article buffer."
2368 (let* ((name (if gnus-single-article-buffer "*Article*"
2369 (concat "*Article " gnus-newsgroup-name "*")))
2371 (progn (string-match "\\*Article" name)
2372 (concat " *Original Article"
2373 (substring name (match-end 0))))))
2374 (setq gnus-article-buffer name)
2375 (setq gnus-original-article-buffer original)
2376 (setq gnus-article-mime-handle-alist nil)
2377 ;; This might be a variable local to the summary buffer.
2378 (unless gnus-single-article-buffer
2380 (set-buffer gnus-summary-buffer)
2381 (setq gnus-article-buffer name)
2382 (setq gnus-original-article-buffer original)
2383 (gnus-set-global-variables)))
2384 ;; Init original article buffer.
2386 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
2387 (mm-enable-multibyte)
2388 (setq major-mode 'gnus-original-article-mode)
2389 (make-local-variable 'gnus-original-article))
2390 (if (get-buffer name)
2393 (buffer-disable-undo)
2394 (setq buffer-read-only t)
2395 (unless (eq major-mode 'gnus-article-mode)
2396 (gnus-article-mode))
2399 (set-buffer (gnus-get-buffer-create name))
2401 (make-local-variable 'gnus-summary-buffer)
2402 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2403 (current-buffer)))))
2405 ;; Set article window start at LINE, where LINE is the number of lines
2406 ;; from the head of the article.
2407 (defun gnus-article-set-window-start (&optional line)
2409 (get-buffer-window gnus-article-buffer t)
2411 (set-buffer gnus-article-buffer)
2412 (goto-char (point-min))
2415 (gnus-message 6 "Moved to bookmark")
2416 (search-forward "\n\n" nil t)
2420 (defun gnus-article-prepare (article &optional all-headers header)
2421 "Prepare ARTICLE in article mode buffer.
2422 ARTICLE should either be an article number or a Message-ID.
2423 If ARTICLE is an id, HEADER should be the article headers.
2424 If ALL-HEADERS is non-nil, no headers are hidden."
2426 ;; Make sure we start in a summary buffer.
2427 (unless (eq major-mode 'gnus-summary-mode)
2428 (set-buffer gnus-summary-buffer))
2429 (setq gnus-summary-buffer (current-buffer))
2430 (let* ((gnus-article (if header (mail-header-number header) article))
2431 (summary-buffer (current-buffer))
2432 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
2433 (group gnus-newsgroup-name)
2436 (gnus-article-setup-buffer)
2437 (set-buffer gnus-article-buffer)
2438 ;; Deactivate active regions.
2439 (when (and (boundp 'transient-mark-mode)
2440 transient-mark-mode)
2441 (setq mark-active nil))
2442 (if (not (setq result (let ((buffer-read-only nil))
2443 (gnus-request-article-this-buffer
2445 ;; There is no such article.
2447 (when (and (numberp article)
2448 (not (memq article gnus-newsgroup-sparse)))
2449 (setq gnus-article-current
2450 (cons gnus-newsgroup-name article))
2451 (set-buffer gnus-summary-buffer)
2452 (setq gnus-current-article article)
2453 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
2455 (gnus-summary-set-agent-mark article)
2456 (message "Message marked for downloading"))
2457 (gnus-summary-mark-article article gnus-canceled-mark)
2458 (unless (memq article gnus-newsgroup-sparse)
2460 "No such article (may have expired or been canceled)")))))
2461 (if (or (eq result 'pseudo)
2462 (eq result 'nneething))
2465 (set-buffer summary-buffer)
2466 (push article gnus-newsgroup-history)
2467 (setq gnus-last-article gnus-current-article
2468 gnus-current-article 0
2469 gnus-current-headers nil
2470 gnus-article-current nil)
2471 (if (eq result 'nneething)
2472 (gnus-configure-windows 'summary)
2473 (gnus-configure-windows 'article))
2474 (gnus-set-global-variables))
2475 (let ((gnus-article-mime-handle-alist-1
2476 gnus-article-mime-handle-alist))
2477 (gnus-set-mode-line 'article)))
2478 ;; The result from the `request' was an actual article -
2479 ;; or at least some text that is now displayed in the
2481 (when (and (numberp article)
2482 (not (eq article gnus-current-article)))
2483 ;; Seems like a new article has been selected.
2484 ;; `gnus-current-article' must be an article number.
2486 (set-buffer summary-buffer)
2487 (push article gnus-newsgroup-history)
2488 (setq gnus-last-article gnus-current-article
2489 gnus-current-article article
2490 gnus-current-headers
2491 (gnus-summary-article-header gnus-current-article)
2492 gnus-article-current
2493 (cons gnus-newsgroup-name gnus-current-article))
2494 (unless (vectorp gnus-current-headers)
2495 (setq gnus-current-headers nil))
2496 (gnus-summary-goto-subject gnus-current-article)
2497 (when (gnus-summary-show-thread)
2498 ;; If the summary buffer really was folded, the
2499 ;; previous goto may not actually have gone to
2500 ;; the right article, but the thread root instead.
2502 (gnus-summary-goto-subject gnus-current-article))
2503 (gnus-run-hooks 'gnus-mark-article-hook)
2504 (gnus-set-mode-line 'summary)
2505 (when (gnus-visual-p 'article-highlight 'highlight)
2506 (gnus-run-hooks 'gnus-visual-mark-article-hook))
2507 ;; Set the global newsgroup variables here.
2508 ;; Suggested by Jim Sisolak
2509 ;; <sisolak@trans4.neep.wisc.edu>.
2510 (gnus-set-global-variables)
2511 (setq gnus-have-all-headers
2512 (or all-headers gnus-show-all-headers))))
2513 (when (or (numberp article)
2515 (gnus-article-prepare-display)
2517 (goto-char (point-min))
2518 (setq gnus-page-broken
2519 (when gnus-break-pages
2520 (gnus-narrow-to-page)
2522 (let ((gnus-article-mime-handle-alist-1
2523 gnus-article-mime-handle-alist))
2524 (gnus-set-mode-line 'article))
2525 (gnus-configure-windows 'article)
2527 (set-window-point (get-buffer-window (current-buffer)) (point))
2531 (defun gnus-article-prepare-display ()
2532 "Make the current buffer look like a nice article."
2533 ;; Hooks for getting information from the article.
2534 ;; This hook must be called before being narrowed.
2535 (let ((gnus-article-buffer (current-buffer))
2537 (unless (eq major-mode 'gnus-article-mode)
2538 (gnus-article-mode))
2539 (setq buffer-read-only nil)
2540 (gnus-run-hooks 'gnus-tmp-internal-hook)
2541 (gnus-run-hooks 'gnus-article-prepare-hook)
2542 (when gnus-display-mime-function
2543 (funcall gnus-display-mime-function))))
2546 ;;; Gnus MIME viewing functions
2549 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
2550 "The following specs can be used:
2552 %T MIME type, along with additional info
2553 %n The `name' parameter
2554 %d The description, if any
2555 %l The length of the encoded part
2556 %p The part identifier number
2557 %e Dots if the part isn't displayed")
2559 (defvar gnus-mime-button-line-format-alist
2560 '((?t gnus-tmp-type ?s)
2561 (?T gnus-tmp-type-long ?s)
2562 (?n gnus-tmp-name ?s)
2563 (?d gnus-tmp-description ?s)
2565 (?l gnus-tmp-length ?d)
2566 (?e gnus-tmp-dots ?s)))
2568 (defvar gnus-mime-button-commands
2569 '((gnus-article-press-button "\r" "Toggle Display")
2570 (gnus-mime-view-part "v" "View Interactively...")
2571 (gnus-mime-save-part "o" "Save...")
2572 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
2573 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
2574 (gnus-mime-internalize-part "E" "View Internally")
2575 (gnus-mime-externalize-part "e" "View Externally")
2576 (gnus-mime-pipe-part "|" "Pipe To Command...")))
2578 (defun gnus-article-mime-part-status ()
2579 (if gnus-article-mime-handle-alist-1
2580 (format " (%d parts)" (length gnus-article-mime-handle-alist-1))
2583 (defvar gnus-mime-button-map nil)
2584 (unless gnus-mime-button-map
2585 (setq gnus-mime-button-map (make-sparse-keymap))
2586 (set-keymap-parent gnus-mime-button-map gnus-article-mode-map)
2587 (define-key gnus-mime-button-map gnus-mouse-2 'gnus-article-push-button)
2588 (define-key gnus-mime-button-map gnus-down-mouse-3 'gnus-mime-button-menu)
2590 (define-key gnus-mime-button-map (cadr c) (car c)))
2591 gnus-mime-button-commands))
2593 (defun gnus-mime-button-menu (event)
2594 "Construct a context-sensitive menu of MIME commands."
2597 (let ((pos (event-start event)))
2598 (set-buffer (window-buffer (posn-window pos)))
2599 (goto-char (posn-point pos))
2600 (gnus-article-check-buffer)
2601 (let ((response (x-popup-menu
2603 ("" ,@(mapcar (lambda (c)
2604 (cons (caddr c) (car c)))
2605 gnus-mime-button-commands))))))
2607 (funcall response))))))
2609 (defun gnus-mime-view-all-parts (&optional handles)
2610 "View all the MIME parts."
2612 (save-current-buffer
2613 (set-buffer gnus-article-buffer)
2614 (let ((handles (or handles gnus-article-mime-handles))
2615 (mail-parse-charset gnus-newsgroup-charset))
2616 (if (stringp (car handles))
2617 (gnus-mime-view-all-parts (cdr handles))
2618 (mapcar 'mm-display-part handles)))))
2620 (defun gnus-mime-save-part ()
2621 "Save the MIME part under point."
2623 (gnus-article-check-buffer)
2624 (let ((data (get-text-property (point) 'gnus-data)))
2625 (mm-save-part data)))
2627 (defun gnus-mime-pipe-part ()
2628 "Pipe the MIME part under point to a process."
2630 (gnus-article-check-buffer)
2631 (let ((data (get-text-property (point) 'gnus-data)))
2632 (mm-pipe-part data)))
2634 (defun gnus-mime-view-part ()
2635 "Interactively choose a view method for the MIME part under point."
2637 (gnus-article-check-buffer)
2638 (let ((data (get-text-property (point) 'gnus-data)))
2639 (mm-interactively-view-part data)))
2641 (defun gnus-mime-copy-part (&optional handle)
2642 "Put the the MIME part under point into a new buffer."
2644 (gnus-article-check-buffer)
2645 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
2646 (contents (mm-get-part handle))|
2647 (base (file-name-nondirectory
2649 (mail-content-type-get (mm-handle-type handle) 'name)
2650 (mail-content-type-get (mm-handle-type handle)
2653 (buffer (generate-new-buffer base)))
2654 (switch-to-buffer buffer)
2656 ;; We do it this way to make `normal-mode' set the appropriate mode.
2659 (setq buffer-file-name (expand-file-name base))
2661 (setq buffer-file-name nil))
2662 (goto-char (point-min))))
2664 (defun gnus-mime-inline-part (&optional charset)
2665 "Insert the MIME part under point into the current buffer."
2666 (interactive "P") ; For compatibility reasons we are not using "z".
2667 (gnus-article-check-buffer)
2668 (let* ((data (get-text-property (point) 'gnus-data))
2672 (if (mm-handle-undisplayer data)
2673 (mm-remove-part data)
2674 (setq contents (mm-get-part data))
2677 (unless (symbolp charset)
2678 (setq charset (mm-read-coding-system "Charset: ")))
2679 (setq contents (mm-decode-coding-string contents charset)))
2680 (mm-insert-inline data contents)
2683 (defun gnus-mime-externalize-part (&optional handle)
2684 "View the MIME part under point with an external viewer."
2686 (gnus-article-check-buffer)
2687 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
2688 (mm-user-display-methods nil)
2689 (mm-all-images-fit t)
2690 (mail-parse-charset gnus-newsgroup-charset))
2691 (if (mm-handle-undisplayer handle)
2692 (mm-remove-part handle)
2693 (mm-display-part handle))))
2695 (defun gnus-mime-internalize-part (&optional handle)
2696 "View the MIME part under point with an internal viewer."
2698 (gnus-article-check-buffer)
2699 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
2700 (mm-user-display-methods '((".*" . inline)))
2701 (mm-all-images-fit t)
2702 (mail-parse-charset gnus-newsgroup-charset))
2703 (if (mm-handle-undisplayer handle)
2704 (mm-remove-part handle)
2705 (mm-display-part handle))))
2707 (defun gnus-article-part-wrapper (n function)
2708 (save-current-buffer
2709 (set-buffer gnus-article-buffer)
2710 (when (> n (length gnus-article-mime-handle-alist))
2711 (error "No such part"))
2712 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
2713 (funcall function handle))))
2715 (defun gnus-article-pipe-part (n)
2716 "Pipe MIME part N, which is the numerical prefix."
2718 (gnus-article-part-wrapper n 'mm-pipe-part))
2720 (defun gnus-article-save-part (n)
2721 "Save MIME part N, which is the numerical prefix."
2723 (gnus-article-part-wrapper n 'mm-save-part))
2725 (defun gnus-article-interactively-view-part (n)
2726 "Pipe MIME part N, which is the numerical prefix."
2728 (gnus-article-part-wrapper n 'mm-interactively-view-part))
2730 (defun gnus-article-copy-part (n)
2731 "Pipe MIME part N, which is the numerical prefix."
2733 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
2735 (defun gnus-article-externalize-part (n)
2736 "Pipe MIME part N, which is the numerical prefix."
2738 (gnus-article-part-wrapper n 'gnus-mime-externalize-part))
2740 (defun gnus-article-view-part (n)
2741 "View MIME part N, which is the numerical prefix."
2743 (save-current-buffer
2744 (set-buffer gnus-article-buffer)
2745 (when (> n (length gnus-article-mime-handle-alist))
2746 (error "No such part"))
2747 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
2748 (when (gnus-article-goto-part n)
2749 (if (equal (car handle) "multipart/alternative")
2750 (gnus-article-press-button)
2751 (when (eq (gnus-mm-display-part handle) 'internal)
2752 (gnus-set-window-start)))))))
2754 (defun gnus-mm-display-part (handle)
2755 "Display HANDLE and fix MIME button."
2756 (let ((id (get-text-property (point) 'gnus-part))
2761 (let ((window (selected-window))
2762 (mail-parse-charset gnus-newsgroup-charset))
2765 (let ((win (get-buffer-window (current-buffer) t))
2768 (select-window win))
2771 (if (mm-handle-displayed-p handle)
2772 ;; This will remove the part.
2773 (mm-display-part handle)
2775 (narrow-to-region (point) (1+ (point)))
2776 (mm-display-part handle)
2779 (1- (length gnus-article-mime-handles))
2780 (car (mm-handle-type handle))))))
2781 (select-window window))))
2783 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
2784 (gnus-insert-mime-button
2785 handle id (list (mm-handle-displayed-p handle)))
2786 (goto-char point))))
2788 (defun gnus-article-goto-part (n)
2789 "Go to MIME part N."
2790 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
2792 (goto-char point))))
2794 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
2795 (let ((gnus-tmp-name
2796 (or (mail-content-type-get (mm-handle-type handle)
2798 (mail-content-type-get (mm-handle-disposition handle)
2801 (gnus-tmp-type (car (mm-handle-type handle)))
2802 (gnus-tmp-description
2803 (mail-decode-encoded-word-string (or (mm-handle-description handle)
2806 (if (if displayed (car displayed)
2807 (mm-handle-displayed-p handle))
2809 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
2811 gnus-tmp-type-long b e)
2812 (when (string-match ".*/" gnus-tmp-name)
2813 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
2814 (setq gnus-tmp-type-long (concat gnus-tmp-type
2815 (and (not (equal gnus-tmp-name ""))
2816 (concat "; " gnus-tmp-name))))
2817 (or (equal gnus-tmp-description "")
2818 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
2823 gnus-mime-button-line-format gnus-mime-button-line-format-alist
2824 `(local-map ,gnus-mime-button-map
2825 keymap ,gnus-mime-button-map
2826 gnus-callback gnus-mm-display-part
2827 gnus-part ,gnus-tmp-id
2828 article-type annotation
2831 (widget-convert-button 'link b e
2833 :action 'gnus-widget-press-button
2834 :button-keymap gnus-mime-button-map
2837 ;; Needed to properly clear the message
2838 ;; due to a bug in wid-edit
2839 (setq help-echo-owns-message t)
2841 "Click to %s the MIME part; %s for more options"
2842 (if (mm-handle-displayed-p
2843 (widget-get widget :mime-handle))
2845 (if gnus-xemacs "button3" "mouse-3"))))))
2847 (defun gnus-widget-press-button (elems el)
2848 (goto-char (widget-get elems :from))
2849 (gnus-article-press-button))
2851 (defun gnus-display-mime (&optional ihandles)
2852 "Display the MIME parts."
2854 (save-selected-window
2855 (let ((window (get-buffer-window gnus-article-buffer))
2858 (select-window window)
2859 ;; We have to do this since selecting the window
2860 ;; may change the point. So we set the window point.
2861 (set-window-point window point)))
2862 (let* ((handles (or ihandles (mm-dissect-buffer) (mm-uu-dissect)))
2863 handle name type b e display)
2865 ;; Top-level call; we clean up.
2866 (mm-destroy-parts gnus-article-mime-handles)
2867 (setq gnus-article-mime-handles handles
2868 gnus-article-mime-handle-alist nil)
2869 ;; We allow users to glean info from the handles.
2870 (when gnus-article-mime-part-function
2871 (gnus-mime-part-function handles)))
2873 (or (not (stringp (car handles)))
2877 ;; Clean up for mime parts.
2879 (delete-region (point) (point-max)))
2880 (gnus-mime-display-part handles))
2883 (narrow-to-region (point) (point-max))
2884 (gnus-treat-article nil 1 1)))
2885 ;; Highlight the headers.
2889 (narrow-to-region (point-min) (point))
2890 (gnus-treat-article 'head)))))))
2892 (defvar gnus-mime-display-multipart-as-mixed nil)
2894 (defun gnus-mime-display-part (handle)
2897 ((not (stringp (car handle)))
2898 (gnus-mime-display-single handle))
2899 ;; multipart/alternative
2900 ((and (equal (car handle) "multipart/alternative")
2901 (not gnus-mime-display-multipart-as-mixed))
2902 (let ((id (1+ (length gnus-article-mime-handle-alist))))
2903 (push (cons id handle) gnus-article-mime-handle-alist)
2904 (gnus-mime-display-alternative (cdr handle) nil nil id)))
2905 ;; multipart/related
2906 ((and (equal (car handle) "multipart/related")
2907 (not gnus-mime-display-multipart-as-mixed))
2908 ;;;!!!We should find the start part, but we just default
2909 ;;;!!!to the first part.
2910 (gnus-mime-display-part (cadr handle)))
2911 ;; Other multiparts are handled like multipart/mixed.
2913 (gnus-mime-display-mixed (cdr handle)))))
2915 (defun gnus-mime-part-function (handles)
2916 (if (stringp (car handles))
2917 (mapcar 'gnus-mime-part-function (cdr handles))
2918 (funcall gnus-article-mime-part-function handles)))
2920 (defun gnus-mime-display-mixed (handles)
2921 (mapcar 'gnus-mime-display-part handles))
2923 (defun gnus-mime-display-single (handle)
2924 (let ((type (car (mm-handle-type handle)))
2925 (ignored gnus-ignored-mime-types)
2932 (when (string-match (pop ignored) type)
2933 (throw 'ignored nil)))
2934 (if (and (setq not-attachment
2935 (or (not (mm-handle-disposition handle))
2936 (equal (car (mm-handle-disposition handle))
2938 (mm-attachment-override-p type)))
2939 (mm-automatic-display-p type)
2940 (or (mm-inlinable-part-p type)
2941 (mm-automatic-external-display-p type)))
2943 (when (equal (car (split-string type "/"))
2946 (let ((id (1+ (length gnus-article-mime-handle-alist))))
2947 (push (cons id handle) gnus-article-mime-handle-alist)
2948 (when (or (not display)
2949 (not (gnus-unbuttonized-mime-type-p type)))
2950 (gnus-article-insert-newline)
2951 (gnus-insert-mime-button
2952 handle id (list (or display (and not-attachment text))))
2953 (gnus-article-insert-newline)
2954 (gnus-article-insert-newline)
2956 (let ((beg (point)))
2961 (let ((mail-parse-charset gnus-newsgroup-charset))
2962 (mm-display-part handle t))
2963 (goto-char (point-max)))
2964 ((and text not-attachment)
2967 (gnus-article-insert-newline)
2968 (mm-insert-inline handle (mm-get-part handle))
2969 (goto-char (point-max))))
2973 (narrow-to-region beg (point))
2975 nil (length gnus-article-mime-handle-alist)
2976 (1- (length gnus-article-mime-handles))
2977 (car (mm-handle-type handle))))))))))
2979 (defun gnus-unbuttonized-mime-type-p (type)
2980 "Say whether TYPE is to be unbuttonized."
2981 (unless gnus-inhibit-mime-unbuttonizing
2983 (let ((types gnus-unbuttonized-mime-types))
2985 (when (string-match (pop types) type)
2986 (throw 'found t)))))))
2988 (defun gnus-article-insert-newline ()
2989 "Insert a newline, but mark it as undeletable."
2990 (gnus-put-text-property
2991 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
2993 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
2994 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
2997 handle buffer-read-only from props begend not-pref)
2998 (save-window-excursion
3001 (narrow-to-region (car ibegend)
3004 (goto-char (car ibegend))
3007 (delete-region (point-min) (point-max))
3008 (mm-remove-parts handles))
3009 (setq begend (list (point-marker)))
3011 (unless (setq not-pref (cadr (member preferred ihandles)))
3012 (setq not-pref (car ihandles)))
3014 (not (gnus-unbuttonized-mime-type-p
3015 "multipart/alternative")))
3016 (gnus-add-text-properties
3019 (insert (format "%d. " id))
3023 (unless ,(not ibegend)
3024 (setq gnus-article-mime-handle-alist
3025 ',gnus-article-mime-handle-alist))
3026 (gnus-mime-display-alternative
3027 ',ihandles ',not-pref ',begend ,id))
3028 local-map ,gnus-mime-button-map
3029 ,gnus-mouse-face-prop ,gnus-article-mouse-face
3030 face ,gnus-article-button-face
3031 keymap ,gnus-mime-button-map
3034 (widget-convert-button 'link from (point)
3035 :action 'gnus-widget-press-button
3036 :button-keymap gnus-widget-button-keymap)
3038 (while (setq handle (pop handles))
3039 (gnus-add-text-properties
3042 (insert (format "(%c) %-18s"
3043 (if (equal handle preferred) ?* ? )
3044 (if (stringp (car handle))
3046 (car (mm-handle-type handle)))))
3050 (unless ,(not ibegend)
3051 (setq gnus-article-mime-handle-alist
3052 ',gnus-article-mime-handle-alist))
3053 (gnus-mime-display-alternative
3054 ',ihandles ',handle ',begend ,id))
3055 local-map ,gnus-mime-button-map
3056 ,gnus-mouse-face-prop ,gnus-article-mouse-face
3057 face ,gnus-article-button-face
3058 keymap ,gnus-mime-button-map
3061 (widget-convert-button 'link from (point)
3062 :action 'gnus-widget-press-button
3063 :button-keymap gnus-widget-button-keymap)
3067 (if (stringp (car preferred))
3068 (gnus-display-mime preferred)
3069 (let ((mail-parse-charset gnus-newsgroup-charset))
3070 (mm-display-part preferred)))
3071 (goto-char (point-max))
3072 (setcdr begend (point-marker)))))
3074 (goto-char point))))
3076 (defun gnus-article-wash-status ()
3077 "Return a string which display status of article washing."
3079 (set-buffer gnus-article-buffer)
3080 (let ((cite (gnus-article-hidden-text-p 'cite))
3081 (headers (gnus-article-hidden-text-p 'headers))
3082 (boring (gnus-article-hidden-text-p 'boring-headers))
3083 (pgp (gnus-article-hidden-text-p 'pgp))
3084 (pem (gnus-article-hidden-text-p 'pem))
3085 (signature (gnus-article-hidden-text-p 'signature))
3086 (overstrike (gnus-article-hidden-text-p 'overstrike))
3087 (emphasis (gnus-article-hidden-text-p 'emphasis)))
3088 (format "%c%c%c%c%c%c"
3090 (if (or headers boring) ?h ? )
3091 (if (or pgp pem) ?p ? )
3092 (if signature ?s ? )
3093 (if overstrike ?o ? )
3094 (if emphasis ?e ? )))))
3096 (fset 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
3098 (defun gnus-article-maybe-hide-headers ()
3099 "Hide unwanted headers if `gnus-have-all-headers' is nil.
3100 Provided for backwards compatibility."
3101 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
3102 (not (save-excursion (set-buffer gnus-summary-buffer)
3103 gnus-have-all-headers)))
3104 (not gnus-inhibit-hiding))
3105 (gnus-article-hide-headers)))
3109 (defun gnus-output-to-file (file-name)
3110 "Append the current article to a file named FILE-NAME."
3111 (let ((artbuf (current-buffer)))
3113 (insert-buffer-substring artbuf)
3114 ;; Append newline at end of the buffer as separator, and then
3116 (goto-char (point-max))
3118 (append-to-file (point-min) (point-max) file-name)
3121 (defun gnus-narrow-to-page (&optional arg)
3122 "Narrow the article buffer to a page.
3123 If given a numerical ARG, move forward ARG pages."
3125 (setq arg (if arg (prefix-numeric-value arg) 0))
3127 (set-buffer gnus-article-buffer)
3128 (goto-char (point-min))
3130 ;; Remove any old next/prev buttons.
3131 (when (gnus-visual-p 'page-marker)
3132 (let ((buffer-read-only nil))
3133 (gnus-remove-text-with-property 'gnus-prev)
3134 (gnus-remove-text-with-property 'gnus-next)))
3137 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
3139 (re-search-forward page-delimiter nil 'move arg)))
3140 (goto-char (match-end 0)))
3143 (if (re-search-forward page-delimiter nil 'move)
3146 (when (and (gnus-visual-p 'page-marker)
3147 (not (= (point-min) 1)))
3149 (goto-char (point-min))
3150 (gnus-insert-prev-page-button)))
3151 (when (and (gnus-visual-p 'page-marker)
3152 (< (+ (point-max) 2) (buffer-size)))
3154 (goto-char (point-max))
3155 (gnus-insert-next-page-button)))))
3157 ;; Article mode commands
3159 (defun gnus-article-goto-next-page ()
3160 "Show the next page of the article."
3162 (when (gnus-article-next-page)
3163 (goto-char (point-min))
3164 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
3166 (defun gnus-article-goto-prev-page ()
3167 "Show the next page of the article."
3169 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
3170 (gnus-article-prev-page nil)))
3172 (defun gnus-article-next-page (&optional lines)
3173 "Show the next page of the current article.
3174 If end of article, return non-nil. Otherwise return nil.
3175 Argument LINES specifies lines to be scrolled up."
3177 (move-to-window-line -1)
3180 (and (pos-visible-in-window-p) ;Not continuation line.
3182 ;; Nothing in this page.
3183 (if (or (not gnus-page-broken)
3186 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
3188 (gnus-narrow-to-page 1) ;Go to next page.
3190 ;; More in this page.
3191 (let ((scroll-in-place nil))
3195 ;; Long lines may cause an end-of-buffer error.
3196 (goto-char (point-max)))))
3197 (move-to-window-line 0)
3200 (defun gnus-article-prev-page (&optional lines)
3201 "Show previous page of current article.
3202 Argument LINES specifies lines to be scrolled down."
3204 (move-to-window-line 0)
3205 (if (and gnus-page-broken
3207 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
3209 (gnus-narrow-to-page -1) ;Go to previous page.
3210 (goto-char (point-max))
3212 (let ((scroll-in-place nil))
3216 (beginning-of-buffer
3217 (goto-char (point-min))))
3218 (move-to-window-line 0)))))
3220 (defun gnus-article-refer-article ()
3221 "Read article specified by message-id around point."
3223 (let ((point (point)))
3224 (search-forward ">" nil t) ;Move point to end of "<....>".
3225 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
3226 (let ((message-id (match-string 1)))
3228 (set-buffer gnus-summary-buffer)
3229 (gnus-summary-refer-article message-id))
3231 (error "No references around point"))))
3233 (defun gnus-article-show-summary ()
3234 "Reconfigure windows to show summary buffer."
3236 (if (not (gnus-buffer-live-p gnus-summary-buffer))
3237 (error "There is no summary buffer for this article buffer")
3238 (gnus-article-set-globals)
3239 (gnus-configure-windows 'article)
3240 (gnus-summary-goto-subject gnus-current-article)
3241 (gnus-summary-position-point)))
3243 (defun gnus-article-describe-briefly ()
3244 "Describe article mode commands briefly."
3246 (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")))
3248 (defun gnus-article-summary-command ()
3249 "Execute the last keystroke in the summary buffer."
3251 (let ((obuf (current-buffer))
3252 (owin (current-window-configuration))
3254 (switch-to-buffer gnus-article-current-summary 'norecord)
3255 (setq func (lookup-key (current-local-map) (this-command-keys)))
3256 (call-interactively func)
3258 (set-window-configuration owin)
3259 (set-window-point (get-buffer-window (current-buffer)) (point))))
3261 (defun gnus-article-summary-command-nosave ()
3262 "Execute the last keystroke in the summary buffer."
3265 (pop-to-buffer gnus-article-current-summary 'norecord)
3266 (setq func (lookup-key (current-local-map) (this-command-keys)))
3267 (call-interactively func)))
3269 (defun gnus-article-check-buffer ()
3270 "Beep if not in an article buffer."
3271 (unless (equal major-mode 'gnus-article-mode)
3272 (error "Command invoked outside of a Gnus article buffer")))
3274 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
3275 "Read a summary buffer key sequence and execute it from the article buffer."
3277 (gnus-article-check-buffer)
3279 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
3280 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
3281 "=" "^" "\M-^" "|"))
3287 '("n" "Gn" "p" "Gp"))
3290 (set-buffer gnus-article-current-summary)
3291 (let (gnus-pick-mode)
3292 (push (or key last-command-event) unread-command-events)
3293 (setq keys (read-key-sequence nil))))
3296 (if (or (member keys nosaves)
3297 (member keys nosave-but-article)
3298 (member keys nosave-in-article))
3300 (save-window-excursion
3301 (pop-to-buffer gnus-article-current-summary 'norecord)
3302 ;; We disable the pick minor mode commands.
3303 (let (gnus-pick-mode)
3304 (setq func (lookup-key (current-local-map) keys))))
3307 (unless (member keys nosave-in-article)
3308 (set-buffer gnus-article-current-summary))
3309 (call-interactively func)
3310 (setq new-sum-point (point)))
3311 (when (member keys nosave-but-article)
3312 (pop-to-buffer gnus-article-buffer 'norecord)))
3313 ;; These commands should restore window configuration.
3314 (let ((obuf (current-buffer))
3315 (owin (current-window-configuration))
3317 (summary gnus-article-current-summary)
3318 func in-buffer selected)
3319 (if not-restore-window
3320 (pop-to-buffer summary 'norecord)
3321 (switch-to-buffer summary 'norecord))
3322 (setq in-buffer (current-buffer))
3323 ;; We disable the pick minor mode commands.
3324 (if (setq func (let (gnus-pick-mode)
3325 (lookup-key (current-local-map) keys)))
3327 (call-interactively func)
3328 (setq new-sum-point (point)))
3330 (when (eq in-buffer (current-buffer))
3331 (setq selected (gnus-summary-select-article))
3333 (unless not-restore-window
3334 (set-window-configuration owin))
3335 (unless (or (not (eq selected 'old)) (member keys up-to-top))
3336 (set-window-point (get-buffer-window (current-buffer))
3338 (let ((win (get-buffer-window gnus-article-current-summary)))
3340 (set-window-point win new-sum-point))))))))
3342 (defun gnus-article-hide (&optional arg force)
3343 "Hide all the gruft in the current article.
3344 This means that PGP stuff, signatures, cited text and (some)
3345 headers will be hidden.
3346 If given a prefix, show the hidden text instead."
3347 (interactive (append (gnus-article-hidden-arg) (list 'force)))
3348 (gnus-article-hide-headers arg)
3349 (gnus-article-hide-pgp arg)
3350 (gnus-article-hide-citation-maybe arg force)
3351 (gnus-article-hide-signature arg))
3353 (defun gnus-article-maybe-highlight ()
3354 "Do some article highlighting if article highlighting is requested."
3355 (when (gnus-visual-p 'article-highlight 'highlight)
3356 (gnus-article-highlight-some)))
3358 (defun gnus-check-group-server ()
3359 ;; Make sure the connection to the server is alive.
3360 (unless (gnus-server-opened
3361 (gnus-find-method-for-group gnus-newsgroup-name))
3362 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
3363 (gnus-request-group gnus-newsgroup-name t)))
3365 (defun gnus-request-article-this-buffer (article group)
3366 "Get an article and insert it into this buffer."
3367 (let (do-update-line sparse-header)
3371 (gnus-kill-all-overlays)
3372 (setq group (or group gnus-newsgroup-name))
3374 ;; Using `gnus-request-article' directly will insert the article into
3375 ;; `nntp-server-buffer' - so we'll save some time by not having to
3376 ;; copy it from the server buffer into the article buffer.
3378 ;; We only request an article by message-id when we do not have the
3379 ;; headers for it, so we'll have to get those.
3380 (when (stringp article)
3381 (let ((gnus-override-method gnus-refer-article-method))
3382 (gnus-read-header article)))
3384 ;; If the article number is negative, that means that this article
3385 ;; doesn't belong in this newsgroup (possibly), so we find its
3386 ;; message-id and request it by id instead of number.
3387 (when (and (numberp article)
3389 (get-buffer gnus-summary-buffer)
3390 (gnus-buffer-exists-p gnus-summary-buffer))
3392 (set-buffer gnus-summary-buffer)
3393 (let ((header (gnus-summary-article-header article)))
3396 ((memq article gnus-newsgroup-sparse)
3397 ;; This is a sparse gap article.
3398 (setq do-update-line article)
3399 (setq article (mail-header-id header))
3400 (let ((gnus-override-method gnus-refer-article-method))
3401 (setq sparse-header (gnus-read-header article)))
3402 (setq gnus-newsgroup-sparse
3403 (delq article gnus-newsgroup-sparse)))
3405 ;; It's a real article.
3406 (setq article (mail-header-id header)))
3408 ;; It is an extracted pseudo-article.
3409 (setq article 'pseudo)
3410 (gnus-request-pseudo-article header))))
3412 (let ((method (gnus-find-method-for-group
3413 gnus-newsgroup-name)))
3414 (when (and (eq (car method) 'nneething)
3417 (file-name-as-directory
3418 (or (cadr (assq 'nneething-address method))
3420 (mail-header-subject header))))
3421 (when (file-directory-p dir)
3422 (setq article 'nneething)
3423 (gnus-group-enter-directory dir))))))))
3426 ;; Refuse to select canceled articles.
3427 ((and (numberp article)
3429 (get-buffer gnus-summary-buffer)
3430 (gnus-buffer-exists-p gnus-summary-buffer)
3431 (eq (cdr (save-excursion
3432 (set-buffer gnus-summary-buffer)
3433 (assq article gnus-newsgroup-reads)))
3434 gnus-canceled-mark))
3436 ;; We first check `gnus-original-article-buffer'.
3437 ((and (get-buffer gnus-original-article-buffer)
3440 (set-buffer gnus-original-article-buffer)
3441 (and (equal (car gnus-original-article) group)
3442 (eq (cdr gnus-original-article) article))))
3443 (insert-buffer-substring gnus-original-article-buffer)
3445 ;; Check the backlog.
3446 ((and gnus-keep-backlog
3447 (gnus-backlog-request-article group article (current-buffer)))
3449 ;; Check asynchronous pre-fetch.
3450 ((gnus-async-request-fetched-article group article (current-buffer))
3451 (gnus-async-prefetch-next group article gnus-summary-buffer)
3452 (when (and (numberp article) gnus-keep-backlog)
3453 (gnus-backlog-enter-article group article (current-buffer)))
3456 ((and gnus-use-cache
3458 (gnus-cache-request-article article group))
3460 ;; Get the article and put into the article buffer.
3461 ((or (stringp article) (numberp article))
3462 (let ((gnus-override-method
3463 (and (stringp article) gnus-refer-article-method))
3464 (buffer-read-only nil))
3466 (gnus-kill-all-overlays)
3467 (gnus-check-group-server)
3468 (when (gnus-request-article article group (current-buffer))
3469 (when (numberp article)
3470 (gnus-async-prefetch-next group article gnus-summary-buffer)
3471 (when gnus-keep-backlog
3472 (gnus-backlog-enter-article
3473 group article (current-buffer))))
3478 ;; Associate this article with the current summary buffer.
3479 (setq gnus-article-current-summary gnus-summary-buffer)
3481 ;; Take the article from the original article buffer
3482 ;; and place it in the buffer it's supposed to be in.
3483 (when (and (get-buffer gnus-article-buffer)
3484 (equal (buffer-name (current-buffer))
3485 (buffer-name (get-buffer gnus-article-buffer))))
3487 (if (get-buffer gnus-original-article-buffer)
3488 (set-buffer gnus-original-article-buffer)
3489 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3490 (buffer-disable-undo)
3491 (setq major-mode 'gnus-original-article-mode)
3492 (setq buffer-read-only t))
3493 (let (buffer-read-only)
3495 (insert-buffer-substring gnus-article-buffer))
3496 (setq gnus-original-article (cons group article)))
3499 (run-hooks 'gnus-article-decode-hook)
3500 ;; Mark article as decoded or not.
3501 (setq gnus-article-decoded-p gnus-article-decode-hook))
3503 ;; Update sparse articles.
3504 (when (and do-update-line
3505 (or (numberp article)
3507 (let ((buf (current-buffer)))
3508 (set-buffer gnus-summary-buffer)
3509 (gnus-summary-update-article do-update-line sparse-header)
3510 (gnus-summary-goto-subject do-update-line nil t)
3511 (set-window-point (get-buffer-window (current-buffer) t)
3513 (set-buffer buf))))))
3519 (defcustom gnus-article-edit-mode-hook nil
3520 "Hook run in article edit mode buffers."
3521 :group 'gnus-article-various
3524 (defvar gnus-article-edit-done-function nil)
3526 (defvar gnus-article-edit-mode-map nil)
3528 ;; Should we be using derived.el for this?
3529 (unless gnus-article-edit-mode-map
3530 (setq gnus-article-edit-mode-map (make-sparse-keymap))
3531 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
3533 (gnus-define-keys gnus-article-edit-mode-map
3534 "\C-c\C-c" gnus-article-edit-done
3535 "\C-c\C-k" gnus-article-edit-exit)
3537 (gnus-define-keys (gnus-article-edit-wash-map
3538 "\C-c\C-w" gnus-article-edit-mode-map)
3539 "f" gnus-article-edit-full-stops))
3541 (defun gnus-article-edit-mode ()
3542 "Major mode for editing articles.
3543 This is an extended text-mode.
3545 \\{gnus-article-edit-mode-map}"
3547 (setq major-mode 'gnus-article-edit-mode)
3548 (setq mode-name "Article Edit")
3549 (use-local-map gnus-article-edit-mode-map)
3550 (make-local-variable 'gnus-article-edit-done-function)
3551 (make-local-variable 'gnus-prev-winconf)
3552 (setq buffer-read-only nil)
3553 (buffer-enable-undo)
3555 (gnus-run-hooks 'text-mode-hook 'gnus-article-edit-mode-hook))
3557 (defun gnus-article-edit (&optional force)
3558 "Edit the current article.
3559 This will have permanent effect only in mail groups.
3560 If FORCE is non-nil, allow editing of articles even in read-only
3563 (when (and (not force)
3564 (gnus-group-read-only-p))
3565 (error "The current newsgroup does not support article editing"))
3566 (gnus-article-date-original)
3567 (gnus-article-edit-article
3568 `(lambda (no-highlight)
3569 (gnus-summary-edit-article-done
3570 ,(or (mail-header-references gnus-current-headers) "")
3571 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
3573 (defun gnus-article-edit-article (exit-func)
3574 "Start editing the contents of the current article buffer."
3575 (let ((winconf (current-window-configuration)))
3576 (set-buffer gnus-article-buffer)
3577 (gnus-article-edit-mode)
3578 (gnus-article-delete-text-of-type 'annotation)
3579 (gnus-set-text-properties (point-min) (point-max) nil)
3580 (gnus-configure-windows 'edit-article)
3581 (setq gnus-article-edit-done-function exit-func)
3582 (setq gnus-prev-winconf winconf)
3583 (gnus-message 6 "C-c C-c to end edits")))
3585 (defun gnus-article-edit-done (&optional arg)
3586 "Update the article edits and exit."
3591 (when (article-goto-body)
3592 (let ((lines (count-lines (point) (point-max)))
3593 (length (- (point-max) (point)))
3594 (case-fold-search t)
3595 (body (copy-marker (point))))
3596 (goto-char (point-min))
3597 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
3598 (delete-region (match-beginning 1) (match-end 1))
3599 (insert (number-to-string length)))
3600 (goto-char (point-min))
3601 (when (re-search-forward
3602 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
3603 (delete-region (match-beginning 1) (match-end 1))
3604 (insert (number-to-string length)))
3605 (goto-char (point-min))
3606 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
3607 (delete-region (match-beginning 1) (match-end 1))
3608 (insert (number-to-string lines)))))))
3609 (let ((func gnus-article-edit-done-function)
3610 (buf (current-buffer))
3611 (start (window-start)))
3612 (gnus-article-edit-exit)
3615 (let ((buffer-read-only nil))
3617 ;; The cache and backlog have to be flushed somewhat.
3618 (when gnus-keep-backlog
3619 (gnus-backlog-remove-article
3620 (car gnus-article-current) (cdr gnus-article-current)))
3621 ;; Flush original article as well.
3623 (when (get-buffer gnus-original-article-buffer)
3624 (set-buffer gnus-original-article-buffer)
3625 (setq gnus-original-article nil)))
3626 (when gnus-use-cache
3627 (gnus-cache-update-article
3628 (car gnus-article-current) (cdr gnus-article-current))))
3630 (set-window-start (get-buffer-window buf) start)
3631 (set-window-point (get-buffer-window buf) (point))))
3633 (defun gnus-article-edit-exit ()
3634 "Exit the article editing without updating."
3636 ;; We remove all text props from the article buffer.
3637 (let ((buf (format "%s" (buffer-string)))
3638 (curbuf (current-buffer))
3640 (window-start (window-start)))
3643 (let ((winconf gnus-prev-winconf))
3645 (set-window-configuration winconf)
3646 ;; Tippy-toe some to make sure that point remains where it was.
3647 (save-current-buffer
3649 (set-window-start (get-buffer-window (current-buffer)) window-start)
3652 (defun gnus-article-edit-full-stops ()
3653 "Interactively repair spacing at end of sentences."
3656 (goto-char (point-min))
3657 (search-forward-regexp "^$" nil t)
3658 (let ((case-fold-search nil))
3659 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
3662 ;;; Article highlights
3665 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
3667 ;;; Internal Variables:
3669 (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\\)"
3670 "Regular expression that matches URLs."
3671 :group 'gnus-article-buttons
3674 (defcustom gnus-button-alist
3675 `(("<\\(url:[>\n\t ]*?\\)?news:[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
3676 0 t gnus-button-message-id 2)
3677 ("\\bnews:\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t gnus-button-message-id 1)
3678 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
3680 gnus-button-fetch-group 4)
3681 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
3682 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
3683 t gnus-button-message-id 3)
3684 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
3685 ("mailto:\\([-a-zA-Z.@_+0-9%]+\\)" 0 t gnus-url-mailto 1)
3686 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
3687 ;; This is how URLs _should_ be embedded in text...
3688 ("<URL: *\\([^>]*\\)>" 0 t gnus-button-embedded-url 1)
3690 (,gnus-button-url-regexp 0 t gnus-button-url 0))
3691 "*Alist of regexps matching buttons in article bodies.
3693 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
3694 REGEXP: is the string matching text around the button,
3695 BUTTON: is the number of the regexp grouping actually matching the button,
3696 FORM: is a lisp expression which must eval to true for the button to
3698 CALLBACK: is the function to call when the user push this button, and each
3699 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
3701 CALLBACK can also be a variable, in that case the value of that
3702 variable it the real callback function."
3703 :group 'gnus-article-buttons
3704 :type '(repeat (list regexp
3705 (integer :tag "Button")
3707 (function :tag "Callback")
3710 (integer :tag "Regexp group")))))
3712 (defcustom gnus-header-button-alist
3713 `(("^\\(References\\|Message-I[Dd]\\):" "<[^>]+>"
3714 0 t gnus-button-message-id 0)
3715 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
3716 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
3717 0 t gnus-button-mailto 0)
3718 ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t gnus-button-url 0)
3719 ("^Subject:" ,gnus-button-url-regexp 0 t gnus-button-url 0)
3720 ("^[^:]+:" ,gnus-button-url-regexp 0 t gnus-button-url 0)
3721 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
3722 gnus-button-message-id 3))
3723 "*Alist of headers and regexps to match buttons in article heads.
3725 This alist is very similar to `gnus-button-alist', except that each
3726 alist has an additional HEADER element first in each entry:
3728 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
3730 HEADER is a regexp to match a header. For a fuller explanation, see
3731 `gnus-button-alist'."
3732 :group 'gnus-article-buttons
3733 :group 'gnus-article-headers
3734 :type '(repeat (list (regexp :tag "Header")
3736 (integer :tag "Button")
3738 (function :tag "Callback")
3741 (integer :tag "Regexp group")))))
3743 (defvar gnus-button-regexp nil)
3744 (defvar gnus-button-marker-list nil)
3745 ;; Regexp matching any of the regexps from `gnus-button-alist'.
3747 (defvar gnus-button-last nil)
3748 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
3752 (defun gnus-article-push-button (event)
3753 "Check text under the mouse pointer for a callback function.
3754 If the text under the mouse pointer has a `gnus-callback' property,
3755 call it with the value of the `gnus-data' text property."
3757 (set-buffer (window-buffer (posn-window (event-start event))))
3758 (let* ((pos (posn-point (event-start event)))
3759 (data (get-text-property pos 'gnus-data))
3760 (fun (get-text-property pos 'gnus-callback)))
3763 (funcall fun data))))
3765 (defun gnus-article-press-button ()
3766 "Check text at point for a callback function.
3767 If the text at point has a `gnus-callback' property,
3768 call it with the value of the `gnus-data' text property."
3770 (let* ((data (get-text-property (point) 'gnus-data))
3771 (fun (get-text-property (point) 'gnus-callback)))
3773 (funcall fun data))))
3775 (defun gnus-article-highlight (&optional force)
3776 "Highlight current article.
3777 This function calls `gnus-article-highlight-headers',
3778 `gnus-article-highlight-citation',
3779 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
3780 do the highlighting. See the documentation for those functions."
3781 (interactive (list 'force))
3782 (gnus-article-highlight-headers)
3783 (gnus-article-highlight-citation force)
3784 (gnus-article-highlight-signature)
3785 (gnus-article-add-buttons force)
3786 (gnus-article-add-buttons-to-head))
3788 (defun gnus-article-highlight-some (&optional force)
3789 "Highlight current article.
3790 This function calls `gnus-article-highlight-headers',
3791 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
3792 do the highlighting. See the documentation for those functions."
3793 (interactive (list 'force))
3794 (gnus-article-highlight-headers)
3795 (gnus-article-highlight-signature)
3796 (gnus-article-add-buttons))
3798 (defun gnus-article-highlight-headers ()
3799 "Highlight article headers as specified by `gnus-header-face-alist'."
3802 (set-buffer gnus-article-buffer)
3804 (let ((alist gnus-header-face-alist)
3805 (buffer-read-only nil)
3806 (case-fold-search t)
3807 (inhibit-point-motion-hooks t)
3808 entry regexp header-face field-face from hpoints fpoints)
3809 (message-narrow-to-head)
3810 (while (setq entry (pop alist))
3811 (goto-char (point-min))
3812 (setq regexp (concat "^\\("
3813 (if (string-equal "" (nth 0 entry))
3817 header-face (nth 1 entry)
3818 field-face (nth 2 entry))
3819 (while (and (re-search-forward regexp nil t)
3823 (unless (search-forward ":" nil t)
3825 (when (and header-face
3826 (not (memq (point) hpoints)))
3827 (push (point) hpoints)
3828 (gnus-put-text-property from (point) 'face header-face))
3829 (when (and field-face
3830 (not (memq (setq from (point)) fpoints)))
3832 (if (re-search-forward "^[^ \t]" nil t)
3834 (goto-char (point-max)))
3835 (gnus-put-text-property from (point) 'face field-face))))))))
3837 (defun gnus-article-highlight-signature ()
3838 "Highlight the signature in an article.
3839 It does this by highlighting everything after
3840 `gnus-signature-separator' using `gnus-signature-face'."
3843 (set-buffer gnus-article-buffer)
3844 (let ((buffer-read-only nil)
3845 (inhibit-point-motion-hooks t))
3847 (when (and gnus-signature-face
3848 (gnus-article-narrow-to-signature))
3849 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
3850 'face gnus-signature-face)
3852 (gnus-article-search-signature)
3853 (let ((start (match-beginning 0))
3854 (end (set-marker (make-marker) (1+ (match-end 0)))))
3855 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
3858 (defun gnus-button-in-region-p (b e prop)
3859 "Say whether PROP exists in the region."
3860 (text-property-not-all b e prop nil))
3862 (defun gnus-article-add-buttons (&optional force)
3863 "Find external references in the article and make buttons of them.
3864 \"External references\" are things like Message-IDs and URLs, as
3865 specified by `gnus-button-alist'."
3866 (interactive (list 'force))
3868 (set-buffer gnus-article-buffer)
3869 (let ((buffer-read-only nil)
3870 (inhibit-point-motion-hooks t)
3871 (case-fold-search t)
3872 (alist gnus-button-alist)
3874 ;; Remove all old markers.
3876 (while (setq marker (pop gnus-button-marker-list))
3878 (when (setq entry (gnus-button-entry))
3879 (put-text-property (match-beginning (nth 1 entry))
3880 (match-end (nth 1 entry))
3881 'gnus-callback nil))
3882 (set-marker marker nil)))
3883 ;; We skip the headers.
3886 (while (setq entry (pop alist))
3887 (setq regexp (car entry))
3889 (while (re-search-forward regexp nil t)
3890 (let* ((start (and entry (match-beginning (nth 1 entry))))
3891 (end (and entry (match-end (nth 1 entry))))
3892 (from (match-beginning 0)))
3893 (when (and (or (eq t (nth 2 entry))
3894 (eval (nth 2 entry)))
3895 (not (gnus-button-in-region-p
3896 start end 'gnus-callback)))
3897 ;; That optional form returned non-nil, so we add the
3899 (gnus-article-add-button
3900 start end 'gnus-button-push
3901 (car (push (set-marker (make-marker) from)
3902 gnus-button-marker-list))))))))))
3904 ;; Add buttons to the head of an article.
3905 (defun gnus-article-add-buttons-to-head ()
3906 "Add buttons to the head of the article."
3909 (set-buffer gnus-article-buffer)
3910 (let ((buffer-read-only nil)
3911 (inhibit-point-motion-hooks t)
3912 (case-fold-search t)
3913 (alist gnus-header-button-alist)
3915 (nnheader-narrow-to-headers)
3917 ;; Each alist entry.
3918 (setq entry (car alist)
3920 (goto-char (point-min))
3921 (while (re-search-forward (car entry) nil t)
3922 ;; Each header matching the entry.
3923 (setq beg (match-beginning 0))
3924 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
3925 (match-beginning 0))
3928 (while (re-search-forward (nth 1 entry) end t)
3929 ;; Each match within a header.
3930 (let* ((entry (cdr entry))
3931 (start (match-beginning (nth 1 entry)))
3932 (end (match-end (nth 1 entry)))
3933 (form (nth 2 entry)))
3934 (goto-char (match-end 0))
3936 (gnus-article-add-button
3937 start end (nth 3 entry)
3938 (buffer-substring (match-beginning (nth 4 entry))
3939 (match-end (nth 4 entry)))))))
3943 ;;; External functions:
3945 (defun gnus-article-add-button (from to fun &optional data)
3946 "Create a button between FROM and TO with callback FUN and data DATA."
3947 (when gnus-article-button-face
3948 (gnus-overlay-put (gnus-make-overlay from to)
3949 'face gnus-article-button-face))
3950 (gnus-add-text-properties
3952 (nconc (and gnus-article-mouse-face
3953 (list gnus-mouse-face-prop gnus-article-mouse-face))
3954 (list 'gnus-callback fun)
3955 (and data (list 'gnus-data data))))
3956 (widget-convert-button 'link from to :action 'gnus-widget-press-button
3957 :button-keymap gnus-widget-button-keymap))
3959 ;;; Internal functions:
3961 (defun gnus-article-set-globals ()
3963 (set-buffer gnus-summary-buffer)
3964 (gnus-set-global-variables)))
3966 (defun gnus-signature-toggle (end)
3968 (set-buffer gnus-article-buffer)
3969 (let ((buffer-read-only nil)
3970 (inhibit-point-motion-hooks t))
3971 (if (get-text-property end 'invisible)
3972 (gnus-article-unhide-text end (point-max))
3973 (gnus-article-hide-text end (point-max) gnus-hidden-properties)))))
3975 (defun gnus-button-entry ()
3976 ;; Return the first entry in `gnus-button-alist' matching this place.
3977 (let ((alist gnus-button-alist)
3980 (setq entry (pop alist))
3981 (if (looking-at (car entry))
3986 (defun gnus-button-push (marker)
3987 ;; Push button starting at MARKER.
3990 (let* ((entry (gnus-button-entry))
3991 (inhibit-point-motion-hooks t)
3993 (args (mapcar (lambda (group)
3994 (let ((string (match-string group)))
3995 (gnus-set-text-properties
3996 0 (length string) nil string)
4003 (fboundp (symbol-value fun)))
4004 (apply (symbol-value fun) args))
4006 (gnus-message 1 "You must define `%S' to use this button"
4007 (cons fun args)))))))
4009 (defun gnus-button-message-id (message-id)
4012 (set-buffer gnus-summary-buffer)
4013 (gnus-summary-refer-article message-id)))
4015 (defun gnus-button-fetch-group (address)
4016 "Fetch GROUP specified by ADDRESS."
4017 (if (not (string-match "[:/]" address))
4018 ;; This is just a simple group url.
4019 (gnus-group-read-ephemeral-group address gnus-select-method)
4020 (if (not (string-match "^\\([^:/]+\\)\\(:\\([^/]+\\)/\\)?\\(.*\\)$"
4022 (error "Can't parse %s" address)
4023 (gnus-group-read-ephemeral-group
4024 (match-string 4 address)
4025 `(nntp ,(match-string 1 address)
4026 (nntp-address ,(match-string 1 address))
4027 (nntp-port-number ,(if (match-end 3)
4028 (match-string 3 address)
4031 (defun gnus-url-parse-query-string (query &optional downcase)
4032 (let (retval pairs cur key val)
4033 (setq pairs (split-string query "&"))
4035 (setq cur (car pairs)
4037 (if (not (string-match "=" cur))
4039 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
4040 val (gnus-url-unhex-string (substring cur (match-end 0) nil)))
4042 (setq key (downcase key)))
4043 (setq cur (assoc key retval))
4045 (setcdr cur (cons val (cdr cur)))
4046 (setq retval (cons (list key val) retval)))))
4049 (defun gnus-url-unhex (x)
4056 (defun gnus-url-unhex-string (str &optional allow-newlines)
4057 "Remove %XXX embedded spaces, etc in a url.
4058 If optional second argument ALLOW-NEWLINES is non-nil, then allow the
4059 decoding of carriage returns and line feeds in the string, which is normally
4060 forbidden in URL encoding."
4061 (setq str (or str ""))
4063 (case-fold-search t))
4064 (while (string-match "%[0-9a-f][0-9a-f]" str)
4065 (let* ((start (match-beginning 0))
4066 (ch1 (gnus-url-unhex (elt str (+ start 1))))
4068 (gnus-url-unhex (elt str (+ start 2))))))
4070 tmp (substring str 0 start)
4073 (char-to-string code))
4074 ((or (= code ?\n) (= code ?\r))
4076 (t (char-to-string code))))
4077 str (substring str (match-end 0)))))
4078 (setq tmp (concat tmp str))
4081 (defun gnus-url-mailto (url)
4082 ;; Send mail to someone
4083 (when (string-match "mailto:/*\\(.*\\)" url)
4084 (setq url (substring url (match-beginning 1) nil)))
4085 (let (to args subject func)
4086 (if (string-match (regexp-quote "?") url)
4087 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
4088 args (gnus-url-parse-query-string
4089 (substring url (match-end 0) nil) t))
4090 (setq to (gnus-url-unhex-string url)))
4091 (setq args (cons (list "to" to) args)
4092 subject (cdr-safe (assoc "subject" args)))
4095 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
4098 (message-position-on-field (caar args)))
4099 (insert (mapconcat 'identity (cdar args) ", "))
4100 (setq args (cdr args)))
4103 (message-goto-subject))))
4105 (defun gnus-button-mailto (address)
4107 (set-buffer (gnus-copy-article-buffer))
4108 (message-reply address))
4110 (defun gnus-button-reply (address)
4111 ;; Reply to ADDRESS.
4112 (message-reply address))
4114 (defun gnus-button-url (address)
4116 ;; In Emacs 20, `browse-url-browser-function' may be an alist.
4117 (if (listp browse-url-browser-function)
4118 (browse-url address)
4119 (funcall browse-url-browser-function address)))
4121 (defun gnus-button-embedded-url (address)
4123 ;; In Emacs 20, `browse-url-browser-function' may be an alist.
4124 (if (listp browse-url-browser-function)
4125 (browse-url (gnus-strip-whitespace address))
4126 (funcall browse-url-browser-function (gnus-strip-whitespace address))))
4128 ;;; Next/prev buttons in the article buffer.
4130 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
4131 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
4133 (defvar gnus-prev-page-map nil)
4134 (unless gnus-prev-page-map
4135 (setq gnus-prev-page-map (make-sparse-keymap))
4136 (define-key gnus-prev-page-map gnus-mouse-2 'gnus-button-prev-page)
4137 (define-key gnus-prev-page-map "\r" 'gnus-button-prev-page))
4139 (defun gnus-insert-prev-page-button ()
4140 (let ((buffer-read-only nil))
4142 gnus-prev-page-line-format nil
4143 `(gnus-prev t local-map ,gnus-prev-page-map
4144 gnus-callback gnus-article-button-prev-page
4145 article-type annotation))))
4147 (defvar gnus-next-page-map nil)
4148 (unless gnus-next-page-map
4149 (setq gnus-next-page-map (make-keymap))
4150 (suppress-keymap gnus-prev-page-map)
4151 (define-key gnus-next-page-map gnus-mouse-2 'gnus-button-next-page)
4152 (define-key gnus-next-page-map "\r" 'gnus-button-next-page))
4154 (defun gnus-button-next-page ()
4155 "Go to the next page."
4157 (let ((win (selected-window)))
4158 (select-window (get-buffer-window gnus-article-buffer t))
4159 (gnus-article-next-page)
4160 (select-window win)))
4162 (defun gnus-button-prev-page ()
4163 "Go to the prev page."
4165 (let ((win (selected-window)))
4166 (select-window (get-buffer-window gnus-article-buffer t))
4167 (gnus-article-prev-page)
4168 (select-window win)))
4170 (defun gnus-insert-next-page-button ()
4171 (let ((buffer-read-only nil))
4172 (gnus-eval-format gnus-next-page-line-format nil
4174 t local-map ,gnus-next-page-map
4175 gnus-callback gnus-article-button-next-page
4176 article-type annotation))))
4178 (defun gnus-article-button-next-page (arg)
4179 "Go to the next page."
4181 (let ((win (selected-window)))
4182 (select-window (get-buffer-window gnus-article-buffer t))
4183 (gnus-article-next-page)
4184 (select-window win)))
4186 (defun gnus-article-button-prev-page (arg)
4187 "Go to the prev page."
4189 (let ((win (selected-window)))
4190 (select-window (get-buffer-window gnus-article-buffer t))
4191 (gnus-article-prev-page)
4192 (select-window win)))
4194 (defvar gnus-decode-header-methods
4195 '(mail-decode-encoded-word-region)
4196 "List of methods used to decode headers.
4198 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item is
4199 FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
4200 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
4201 whose names match REGEXP.
4204 ((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
4205 mail-decode-encoded-word-region
4206 (\"chinese\" . rfc1843-decode-region))
4209 (defvar gnus-decode-header-methods-cache nil)
4211 (defun gnus-multi-decode-header (start end)
4212 "Apply the functions from `gnus-encoded-word-methods' that match."
4213 (unless (and gnus-decode-header-methods-cache
4214 (eq gnus-newsgroup-name
4215 (car gnus-decode-header-methods-cache)))
4216 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
4219 (nconc gnus-decode-header-methods-cache (list x))
4220 (if (and gnus-newsgroup-name
4221 (string-match (car x) gnus-newsgroup-name))
4222 (nconc gnus-decode-header-methods-cache
4224 gnus-decode-header-methods))
4225 (let ((xlist gnus-decode-header-methods-cache))
4228 (narrow-to-region start end)
4230 (funcall (pop xlist) (point-min) (point-max))))))
4233 ;;; Treatment top-level handling.
4236 (defun gnus-treat-article (condition &optional part-number total-parts type)
4237 (let ((length (- (point-max) (point-min)))
4238 (alist gnus-treatment-function-alist)
4239 (article-goto-body-goes-to-point-min-p t)
4243 (let ((list gnus-article-treat-types))
4245 (when (string-match (pop list) type)
4246 (throw 'found t)))))))
4248 (when (gnus-visual-p 'article-highlight 'highlight)
4249 (gnus-run-hooks 'gnus-part-display-hook)
4250 (while (setq elem (pop alist))
4251 (setq val (symbol-value (car elem)))
4252 (when (and (or (consp val)
4254 (gnus-treat-predicate val))
4255 (funcall (cadr elem)))))))
4257 ;; Dynamic variables.
4258 (defvar part-number)
4259 (defvar total-parts)
4263 (defun gnus-treat-predicate (val)
4274 (eq part-number total-parts))
4278 (let ((pred (pop val)))
4281 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
4283 (apply 'gnus-and (mapcar 'gnus-tread-predicate val)))
4285 (not (gnus-treat-predicate val)))
4287 (equal (cadr val) type))
4289 (error "%S is not a valid predicate" pred)))))
4291 (error "%S is not a valid value" val))))
4297 (run-hooks 'gnus-art-load-hook)
4299 ;;; gnus-art.el ends here