1 ;;; gnus-art.el --- article mode commands for Gnus
2 ;; Copyright (C) 1996,97,98 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-hiding nil
49 "Hiding article parts."
50 :link '(custom-manual "(gnus)Article Hiding")
53 (defgroup gnus-article-highlight nil
54 "Article highlighting."
55 :link '(custom-manual "(gnus)Article Highlighting")
59 (defgroup gnus-article-signature nil
61 :link '(custom-manual "(gnus)Article Signature")
64 (defgroup gnus-article-headers nil
66 :link '(custom-manual "(gnus)Hiding Headers")
69 (defgroup gnus-article-washing nil
70 "Special commands on articles."
71 :link '(custom-manual "(gnus)Article Washing")
74 (defgroup gnus-article-emphasis nil
75 "Fontisizing articles."
76 :link '(custom-manual "(gnus)Article Fontisizing")
79 (defgroup gnus-article-saving nil
81 :link '(custom-manual "(gnus)Saving Articles")
84 (defgroup gnus-article-mime nil
85 "Worshiping the MIME wonder."
86 :link '(custom-manual "(gnus)Using MIME")
89 (defgroup gnus-article-buttons nil
90 "Pushable buttons in the article buffer."
91 :link '(custom-manual "(gnus)Article Buttons")
94 (defgroup gnus-article-various nil
95 "Other article options."
96 :link '(custom-manual "(gnus)Misc Article")
99 (defcustom gnus-ignored-headers
100 '("^Path:" "^Expires:" "^Date-Received:" "^References:" "^Xref:" "^Lines:"
101 "^Relay-Version:" "^Message-ID:" "^Approved:" "^Sender:" "^Received:"
102 "^X-UIDL:" "^MIME-Version:" "^Return-Path:" "^In-Reply-To:"
103 "^Content-Type:" "^Content-Transfer-Encoding:" "^X-WebTV-Signature:"
104 "^X-MimeOLE:" "^X-MSMail-Priority:" "^X-Priority:" "^X-Loop:"
105 "^X-Authentication-Warning:" "^X-MIME-Autoconverted:" "^X-Face:"
106 "^X-Attribution:" "^X-Originating-IP:" "^Delivered-To:"
107 "^NNTP-[-A-Za-z]+:" "^Distribution:" "^X-no-archive:" "^X-Trace:"
108 "^X-Complaints-To:" "^X-NNTP-Posting-Host:" "^X-Orig.*:"
109 "^Abuse-Reports-To:" "^Cache-Post-Path:" "^X-Article-Creation-Date:"
110 "^X-Poster:" "^X-Mail2News-Path:" "^X-Server-Date:" "^X-Cache:"
111 "^Originator:" "^X-Problems-To:" "^X-Auth-User:" "^X-Post-Time:"
112 "^X-Admin:" "^X-UID:" "^Resent-[-A-Za-z]+:" "^X-Mailing-List:"
113 "^Precedence:" "^Original-[-A-Za-z]+:" "^X-filename:" "^X-Orcpt:"
114 "^Old-Received:" "^X-Pgp-Fingerprint:" "^X-Pgp-Key-Id:"
115 "^X-Pgp-Public-Key-Url:" "^X-Auth:" "^X-From-Line:"
116 "^X-Gnus-Article-Number:" "^X-Majordomo:" "^X-Url:" "^X-Sender:"
117 "^X-Mailing-List:" "^MBOX-Line" "^Priority:" "^X-Pgp" "^X400-[-A-Za-z]+:"
119 "*All headers that start with this regexp will be hidden.
120 This variable can also be a list of regexps of headers to be ignored.
121 If `gnus-visible-headers' is non-nil, this variable will be ignored."
122 :type '(choice :custom-show nil
125 :group 'gnus-article-hiding)
127 (defcustom gnus-visible-headers
128 "From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:\\|X-Sent:"
129 "*All headers that do not match this regexp will be hidden.
130 This variable can also be a list of regexp of headers to remain visible.
131 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
132 :type '(repeat :value-to-internal (lambda (widget value)
133 (custom-split-regexp-maybe value))
134 :match (lambda (widget value)
136 (widget-editable-list-match widget value)))
138 :group 'gnus-article-hiding)
140 (defcustom gnus-sorted-header-list
141 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
142 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
143 "*This variable is a list of regular expressions.
144 If it is non-nil, headers that match the regular expressions will
145 be placed first in the article buffer in the sequence specified by
147 :type '(repeat regexp)
148 :group 'gnus-article-hiding)
150 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
151 "Headers that are only to be displayed if they have interesting data.
152 Possible values in this list are `empty', `newsgroups', `followup-to',
153 `reply-to', `date', `long-to', and `many-to'."
154 :type '(set (const :tag "Headers with no content." empty)
155 (const :tag "Newsgroups with only one group." newsgroups)
156 (const :tag "Followup-to identical to newsgroups." followup-to)
157 (const :tag "Reply-to identical to from." reply-to)
158 (const :tag "Date less than four days old." date)
159 (const :tag "Very long To header." long-to)
160 (const :tag "Multiple To headers." many-to))
161 :group 'gnus-article-hiding)
163 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
164 "Regexp matching signature separator.
165 This can also be a list of regexps. In that case, it will be checked
166 from head to tail looking for a separator. Searches will be done from
167 the end of the buffer."
168 :type '(repeat string)
169 :group 'gnus-article-signature)
171 (defcustom gnus-signature-limit nil
172 "Provide a limit to what is considered a signature.
173 If it is a number, no signature may not be longer (in characters) than
174 that number. If it is a floating point number, no signature may be
175 longer (in lines) than that number. If it is a function, the function
176 will be called without any parameters, and if it returns nil, there is
177 no signature in the buffer. If it is a string, it will be used as a
178 regexp. If it matches, the text in question is not a signature."
179 :type '(choice (integer :value 200)
181 (function :value fun)
182 (regexp :value ".*"))
183 :group 'gnus-article-signature)
185 (defcustom gnus-hidden-properties '(invisible t intangible t)
186 "Property list to use for hiding text."
188 :group 'gnus-article-hiding)
190 (defcustom gnus-article-x-face-command
191 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
192 "*String or function to be executed to display an X-Face header.
193 If it is a string, the command will be executed in a sub-shell
194 asynchronously. The compressed face will be piped to this command."
195 :type 'string ;Leave function case to Lisp.
196 :group 'gnus-article-washing)
198 (defcustom gnus-article-x-face-too-ugly nil
199 "Regexp matching posters whose face shouldn't be shown automatically."
200 :type '(choice regexp (const nil))
201 :group 'gnus-article-washing)
203 (defcustom gnus-emphasis-alist
205 "\\(\\s-\\|^\\|[-\"]\\|\\s(\\|\\s)\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\s-\\|[-?!.,;:\"]\\|\\s(\\|\\s)\\)")
207 '(("_" "_" underline)
210 ("_/" "/_" underline-italic)
211 ("_\\*" "\\*_" underline-bold)
212 ("\\*/" "/\\*" bold-italic)
213 ("_\\*/" "/\\*_" underline-bold-italic))))
214 `(("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
215 2 3 gnus-emphasis-underline)
219 (format format (car spec) (cadr spec))
220 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
222 "*Alist that says how to fontify certain phrases.
223 Each item looks like this:
225 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
227 The first element is a regular expression to be matched. The second
228 is a number that says what regular expression grouping used to find
229 the entire emphasized word. The third is a number that says what
230 regexp grouping should be displayed and highlighted. The fourth
231 is the face used for highlighting."
232 :type '(repeat (list :value ("" 0 0 default)
234 (integer :tag "Match group")
235 (integer :tag "Emphasize group")
237 :group 'gnus-article-emphasis)
239 (defface gnus-emphasis-bold '((t (:bold t)))
240 "Face used for displaying strong emphasized text (*word*)."
241 :group 'gnus-article-emphasis)
243 (defface gnus-emphasis-italic '((t (:italic t)))
244 "Face used for displaying italic emphasized text (/word/)."
245 :group 'gnus-article-emphasis)
247 (defface gnus-emphasis-underline '((t (:underline t)))
248 "Face used for displaying underlined emphasized text (_word_)."
249 :group 'gnus-article-emphasis)
251 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
252 "Face used for displaying underlined bold emphasized text (_*word*_)."
253 :group 'gnus-article-emphasis)
255 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
256 "Face used for displaying underlined italic emphasized text (_*word*_)."
257 :group 'gnus-article-emphasis)
259 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
260 "Face used for displaying bold italic emphasized text (/*word*/)."
261 :group 'gnus-article-emphasis)
263 (defface gnus-emphasis-underline-bold-italic
264 '((t (:bold t :italic t :underline t)))
265 "Face used for displaying underlined bold italic emphasized text.
266 Esample: (_/*word*/_)."
267 :group 'gnus-article-emphasis)
269 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
270 "Format for display of Date headers in article bodies.
271 See `format-time-string' for the possible values.
273 The variable can also be function, which should return a complete Date
274 header. The function is called with one argument, the time, which can
275 be fed to `format-time-string'."
276 :type '(choice string symbol)
277 :link '(custom-manual "(gnus)Article Date")
278 :group 'gnus-article-washing)
281 (autoload 'mail-extract-address-components "mail-extr"))
283 (defcustom gnus-save-all-headers t
284 "*If non-nil, don't remove any headers before saving."
285 :group 'gnus-article-saving
288 (defcustom gnus-prompt-before-saving 'always
289 "*This variable says how much prompting is to be done when saving articles.
290 If it is nil, no prompting will be done, and the articles will be
291 saved to the default files. If this variable is `always', each and
292 every article that is saved will be preceded by a prompt, even when
293 saving large batches of articles. If this variable is neither nil not
294 `always', there the user will be prompted once for a file name for
295 each invocation of the saving commands."
296 :group 'gnus-article-saving
297 :type '(choice (item always)
298 (item :tag "never" nil)
299 (sexp :tag "once" :format "%t\n" :value t)))
301 (defcustom gnus-saved-headers gnus-visible-headers
302 "Headers to keep if `gnus-save-all-headers' is nil.
303 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
304 If that variable is nil, however, all headers that match this regexp
305 will be kept while the rest will be deleted before saving."
306 :group 'gnus-article-saving
309 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
310 "A function to save articles in your favourite format.
311 The function must be interactively callable (in other words, it must
312 be an Emacs command).
314 Gnus provides the following functions:
316 * gnus-summary-save-in-rmail (Rmail format)
317 * gnus-summary-save-in-mail (Unix mail format)
318 * gnus-summary-save-in-folder (MH folder)
319 * gnus-summary-save-in-file (article format)
320 * gnus-summary-save-in-vm (use VM's folder format)
321 * gnus-summary-write-to-file (article format -- overwrite)."
322 :group 'gnus-article-saving
323 :type '(radio (function-item gnus-summary-save-in-rmail)
324 (function-item gnus-summary-save-in-mail)
325 (function-item gnus-summary-save-in-folder)
326 (function-item gnus-summary-save-in-file)
327 (function-item gnus-summary-save-in-vm)
328 (function-item gnus-summary-write-to-file)))
330 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
331 "A function generating a file name to save articles in Rmail format.
332 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
333 :group 'gnus-article-saving
336 (defcustom gnus-mail-save-name 'gnus-plain-save-name
337 "A function generating a file name to save articles in Unix mail format.
338 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
339 :group 'gnus-article-saving
342 (defcustom gnus-folder-save-name 'gnus-folder-save-name
343 "A function generating a file name to save articles in MH folder.
344 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
345 :group 'gnus-article-saving
348 (defcustom gnus-file-save-name 'gnus-numeric-save-name
349 "A function generating a file name to save articles in article format.
350 The function is called with NEWSGROUP, HEADERS, and optional
352 :group 'gnus-article-saving
355 (defcustom gnus-split-methods
356 '((gnus-article-archive-name)
357 (gnus-article-nndoc-name))
358 "*Variable used to suggest where articles are to be saved.
359 For instance, if you would like to save articles related to Gnus in
360 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
361 you could set this variable to something like:
363 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
364 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
366 This variable is an alist where the where the key is the match and the
367 value is a list of possible files to save in if the match is non-nil.
369 If the match is a string, it is used as a regexp match on the
370 article. If the match is a symbol, that symbol will be funcalled
371 from the buffer of the article to be saved with the newsgroup as the
372 parameter. If it is a list, it will be evaled in the same buffer.
374 If this form or function returns a string, this string will be used as
375 a possible file name; and if it returns a non-nil list, that list will
376 be used as possible file names."
377 :group 'gnus-article-saving
378 :type '(repeat (choice (list :value (fun) function)
379 (cons :value ("" "") regexp (repeat string))
382 (defcustom gnus-page-delimiter "^\^L"
383 "*Regexp describing what to use as article page delimiters.
384 The default value is \"^\^L\", which is a form linefeed at the
385 beginning of a line."
387 :group 'gnus-article-various)
389 (defcustom gnus-article-mode-line-format "Gnus: %g %S"
390 "*The format specification for the article mode line.
391 See `gnus-summary-mode-line-format' for a closer description."
393 :group 'gnus-article-various)
395 (defcustom gnus-article-mode-hook nil
396 "*A hook for Gnus article mode."
398 :group 'gnus-article-various)
400 (defcustom gnus-article-menu-hook nil
401 "*Hook run after the creation of the article mode menu."
403 :group 'gnus-article-various)
405 (defcustom gnus-article-prepare-hook nil
406 "*A hook called after an article has been prepared in the article buffer.
407 If you want to run a special decoding program like nkf, use this hook."
409 :group 'gnus-article-various)
411 (defcustom gnus-article-hide-pgp-hook nil
412 "*A hook called after successfully hiding a PGP signature."
414 :group 'gnus-article-various)
416 (defcustom gnus-article-button-face 'bold
417 "Face used for highlighting buttons in the article buffer.
419 An article button is a piece of text that you can activate by pressing
420 `RET' or `mouse-2' above it."
422 :group 'gnus-article-buttons)
424 (defcustom gnus-article-mouse-face 'highlight
425 "Face used for mouse highlighting in the article buffer.
427 Article buttons will be displayed in this face when the cursor is
430 :group 'gnus-article-buttons)
432 (defcustom gnus-signature-face 'gnus-signature-face
433 "Face used for highlighting a signature in the article buffer.
434 Obsolete; use the face `gnus-signature-face' for customizations instead."
436 :group 'gnus-article-highlight
437 :group 'gnus-article-signature)
439 (defface gnus-signature-face
442 "Face used for highlighting a signature in the article buffer."
443 :group 'gnus-article-highlight
444 :group 'gnus-article-signature)
446 (defface gnus-header-from-face
449 (:foreground "spring green"))
452 (:foreground "red3"))
455 "Face used for displaying from headers."
456 :group 'gnus-article-headers
457 :group 'gnus-article-highlight)
459 (defface gnus-header-subject-face
462 (:foreground "SeaGreen3"))
465 (:foreground "red4"))
467 (:bold t :italic t)))
468 "Face used for displaying subject headers."
469 :group 'gnus-article-headers
470 :group 'gnus-article-highlight)
472 (defface gnus-header-newsgroups-face
475 (:foreground "yellow" :italic t))
478 (:foreground "MidnightBlue" :italic t))
481 "Face used for displaying newsgroups headers."
482 :group 'gnus-article-headers
483 :group 'gnus-article-highlight)
485 (defface gnus-header-name-face
488 (:foreground "SeaGreen"))
491 (:foreground "maroon"))
494 "Face used for displaying header names."
495 :group 'gnus-article-headers
496 :group 'gnus-article-highlight)
498 (defface gnus-header-content-face
501 (:foreground "forest green" :italic t))
504 (:foreground "indianred4" :italic t))
506 (:italic t))) "Face used for displaying header content."
507 :group 'gnus-article-headers
508 :group 'gnus-article-highlight)
510 (defcustom gnus-header-face-alist
511 '(("From" nil gnus-header-from-face)
512 ("Subject" nil gnus-header-subject-face)
513 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
514 ("" gnus-header-name-face gnus-header-content-face))
515 "*Controls highlighting of article header.
517 An alist of the form (HEADER NAME CONTENT).
519 HEADER is a regular expression which should match the name of an
520 header header and NAME and CONTENT are either face names or nil.
522 The name of each header field will be displayed using the face
523 specified by the first element in the list where HEADER match the
524 header name and NAME is non-nil. Similarly, the content will be
525 displayed by the first non-nil matching CONTENT face."
526 :group 'gnus-article-headers
527 :group 'gnus-article-highlight
528 :type '(repeat (list (regexp :tag "Header")
530 (item :tag "skip" nil)
531 (face :value default))
532 (choice :tag "Content"
533 (item :tag "skip" nil)
534 (face :value default)))))
536 (defcustom gnus-article-decode-hook
537 '(article-decode-charset article-decode-encoded-words)
538 "*Hook run to decode charsets in articles."
539 :group 'gnus-article-headers
542 (defcustom gnus-display-mime-function 'gnus-display-mime
543 "Function to display MIME articles."
544 :group 'gnus-article-headers
547 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
548 "Function used to decode headers.")
550 (defvar gnus-article-dumbquotes-map
569 "Table for MS-to-Latin1 translation.")
571 (defcustom gnus-ignored-mime-types nil
572 "List of MIME types that should be ignored by Gnus."
574 :type '(repeat regexp))
576 (defcustom gnus-treat-body-highlight-signature t
577 "Highlight the signature."
579 :type '(choice (const :tag "Off" nil)
581 (const :tag "Last" last)
582 (integer :tag "Less")
583 (sexp :tag "Predicate")))
585 ;;; Internal variables
587 (defvar gnus-treatment-function-alist
588 '((gnus-treat-body-highlight-signature gnus-article-highlight-signature nil)
591 (defvar gnus-article-mime-handle-alist nil)
592 (defvar article-lapsed-timer nil)
593 (defvar gnus-article-current-summary nil)
595 (defvar gnus-article-mode-syntax-table
596 (let ((table (copy-syntax-table text-mode-syntax-table)))
597 (modify-syntax-entry ?- "w" table)
598 (modify-syntax-entry ?> ")" table)
599 (modify-syntax-entry ?< "(" table)
601 "Syntax table used in article mode buffers.
602 Initialized from `text-mode-syntax-table.")
604 (defvar gnus-save-article-buffer nil)
606 (defvar gnus-article-mode-line-format-alist
607 (nconc '((?w (gnus-article-wash-status) ?s))
608 gnus-summary-mode-line-format-alist))
610 (defvar gnus-number-of-articles-to-be-saved nil)
612 (defvar gnus-inhibit-hiding nil)
614 (defsubst gnus-article-hide-text (b e props)
615 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
616 (add-text-properties b e props)
617 (when (memq 'intangible props)
619 (max (1- b) (point-min))
620 b 'intangible (cddr (memq 'intangible props)))))
622 (defsubst gnus-article-unhide-text (b e)
623 "Remove hidden text properties from region between B and E."
624 (remove-text-properties b e gnus-hidden-properties)
625 (when (memq 'intangible gnus-hidden-properties)
626 (put-text-property (max (1- b) (point-min))
629 (defun gnus-article-hide-text-type (b e type)
630 "Hide text of TYPE between B and E."
631 (gnus-article-hide-text
632 b e (cons 'article-type (cons type gnus-hidden-properties))))
634 (defun gnus-article-unhide-text-type (b e type)
635 "Unhide text of TYPE between B and E."
636 (remove-text-properties
637 b e (cons 'article-type (cons type gnus-hidden-properties)))
638 (when (memq 'intangible gnus-hidden-properties)
639 (put-text-property (max (1- b) (point-min))
642 (defun gnus-article-hide-text-of-type (type)
643 "Hide text of TYPE in the current buffer."
645 (let ((b (point-min))
647 (while (setq b (text-property-any b e 'article-type type))
648 (add-text-properties b (incf b) gnus-hidden-properties)))))
650 (defun gnus-article-delete-text-of-type (type)
651 "Delete text of TYPE in the current buffer."
653 (let ((b (point-min)))
654 (while (setq b (text-property-any b (point-max) 'article-type type))
656 b (or (text-property-not-all b (point-max) 'article-type type)
659 (defun gnus-article-delete-invisible-text ()
660 "Delete all invisible text in the current buffer."
662 (let ((b (point-min)))
663 (while (setq b (text-property-any b (point-max) 'invisible t))
665 b (or (text-property-not-all b (point-max) 'invisible t)
668 (defun gnus-article-text-type-exists-p (type)
669 "Say whether any text of type TYPE exists in the buffer."
670 (text-property-any (point-min) (point-max) 'article-type type))
672 (defsubst gnus-article-header-rank ()
673 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
674 (let ((list gnus-sorted-header-list)
677 (when (looking-at (car list))
679 (setq list (cdr list))
683 (defun article-hide-headers (&optional arg delete)
684 "Toggle whether to hide unwanted headers and possibly sort them as well.
685 If given a negative prefix, always show; if given a positive prefix,
687 (interactive (gnus-article-hidden-arg))
689 (if (gnus-article-check-hidden-text 'headers arg)
690 ;; Show boring headers as well.
691 (gnus-article-show-hidden-text 'boring-headers)
692 ;; This function might be inhibited.
693 (unless gnus-inhibit-hiding
696 (let ((buffer-read-only nil)
698 (props (nconc (list 'article-type 'headers)
699 gnus-hidden-properties))
700 (max (1+ (length gnus-sorted-header-list)))
701 (ignored (when (not gnus-visible-headers)
702 (cond ((stringp gnus-ignored-headers)
703 gnus-ignored-headers)
704 ((listp gnus-ignored-headers)
705 (mapconcat 'identity gnus-ignored-headers
708 (cond ((stringp gnus-visible-headers)
709 gnus-visible-headers)
710 ((and gnus-visible-headers
711 (listp gnus-visible-headers))
712 (mapconcat 'identity gnus-visible-headers "\\|"))))
713 (inhibit-point-motion-hooks t)
715 ;; First we narrow to just the headers.
717 (goto-char (point-min))
718 ;; Hide any "From " lines at the beginning of (mail) articles.
719 (while (looking-at "From ")
723 (delete-region (point-min) (point))
724 (gnus-article-hide-text (point-min) (point) props)))
725 ;; Then treat the rest of the header lines.
728 (if (search-forward "\n\n" nil t) ; if there's a body
729 (progn (forward-line -1) (point))
731 ;; Then we use the two regular expressions
732 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
733 ;; select which header lines is to remain visible in the
735 (goto-char (point-min))
736 (while (re-search-forward "^[^ \t]*:" nil t)
738 ;; Mark the rank of the header.
740 (point) (1+ (point)) 'message-rank
741 (if (or (and visible (looking-at visible))
743 (not (looking-at ignored))))
744 (gnus-article-header-rank)
747 (message-sort-headers-1)
748 (when (setq beg (text-property-any
749 (point-min) (point-max) 'message-rank (+ 2 max)))
750 ;; We make the unwanted headers invisible.
752 (delete-region beg (point-max))
753 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
754 (gnus-article-hide-text-type beg (point-max) 'headers))
755 ;; Work around XEmacs lossage.
756 (put-text-property (point-min) beg 'invisible nil))))))))
758 (defun article-hide-boring-headers (&optional arg)
759 "Toggle hiding of headers that aren't very interesting.
760 If given a negative prefix, always show; if given a positive prefix,
762 (interactive (gnus-article-hidden-arg))
763 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
764 (not gnus-show-all-headers))
767 (let ((buffer-read-only nil)
768 (list gnus-boring-article-headers)
769 (inhibit-point-motion-hooks t)
771 (nnheader-narrow-to-headers)
773 (setq elem (pop list))
774 (goto-char (point-min))
776 ;; Hide empty headers.
778 (while (re-search-forward "^[^:]+:[ \t]*\n[^ \t]" nil t)
780 (gnus-article-hide-text-type
781 (progn (beginning-of-line) (point))
784 (if (re-search-forward "^[^ \t]" nil t)
788 ;; Hide boring Newsgroups header.
789 ((eq elem 'newsgroups)
790 (when (equal (gnus-fetch-field "newsgroups")
791 (gnus-group-real-name
792 (if (boundp 'gnus-newsgroup-name)
795 (gnus-article-hide-header "newsgroups")))
796 ((eq elem 'followup-to)
797 (when (equal (message-fetch-field "followup-to")
798 (message-fetch-field "newsgroups"))
799 (gnus-article-hide-header "followup-to")))
801 (let ((from (message-fetch-field "from"))
802 (reply-to (message-fetch-field "reply-to")))
807 (nth 1 (mail-extract-address-components from))
808 (nth 1 (mail-extract-address-components reply-to)))))
809 (gnus-article-hide-header "reply-to"))))
811 (let ((date (message-fetch-field "date")))
813 (< (days-between (current-time-string) date)
815 (gnus-article-hide-header "date"))))
817 (let ((to (message-fetch-field "to")))
818 (when (> (length to) 1024)
819 (gnus-article-hide-header "to"))))
822 (goto-char (point-min))
823 (while (re-search-forward "^to:" nil t)
824 (setq to-count (1+ to-count)))
826 (while (> to-count 0)
827 (goto-char (point-min))
829 (re-search-forward "^to:" nil nil to-count)
831 (narrow-to-region (point) (point-max))
832 (gnus-article-hide-header "to"))
833 (setq to-count (1- to-count)))))))))))))
835 (defun gnus-article-hide-header (header)
837 (goto-char (point-min))
838 (when (re-search-forward (concat "^" header ":") nil t)
839 (gnus-article-hide-text-type
840 (progn (beginning-of-line) (point))
843 (if (re-search-forward "^[^ \t]" nil t)
848 (defun article-treat-dumbquotes ()
849 "Translate M******** sm*rtq**t*s into proper text."
851 (article-translate-strings gnus-article-dumbquotes-map))
853 (defun article-translate-characters (from to)
854 "Translate all characters in the body of the article according to FROM and TO.
855 FROM is a string of characters to translate from; to is a string of
856 characters to translate to."
858 (goto-char (point-min))
859 (when (search-forward "\n\n" nil t)
860 (let ((buffer-read-only nil)
861 (x (make-string 225 ?x))
863 (while (< (incf i) (length x))
866 (while (< i (length from))
867 (aset x (aref from i) (aref to i))
869 (translate-region (point) (point-max) x)))))
871 (defun article-translate-strings (map)
872 "Translate all string in the body of the article according to MAP.
873 MAP is an alist where the elements are on the form (\"from\" \"to\")."
875 (goto-char (point-min))
876 (when (search-forward "\n\n" nil t)
877 (let ((buffer-read-only nil)
879 (while (setq elem (pop map))
881 (while (search-forward (car elem) nil t)
882 (replace-match (cadr elem)))))))))
884 (defun article-treat-overstrike ()
885 "Translate overstrikes into bold text."
888 (goto-char (point-min))
889 (when (search-forward "\n\n" nil t)
890 (let ((buffer-read-only nil))
891 (while (search-forward "\b" nil t)
892 (let ((next (char-after))
893 (previous (char-after (- (point) 2))))
894 ;; We do the boldification/underlining by hiding the
895 ;; overstrikes and putting the proper text property
899 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
900 (put-text-property (point) (1+ (point)) 'face 'bold))
902 (gnus-article-hide-text-type
903 (1- (point)) (1+ (point)) 'overstrike)
905 (- (point) 2) (1- (point)) 'face 'underline))
907 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
909 (point) (1+ (point)) 'face 'underline)))))))))
911 (defun article-fill ()
912 "Format too long lines."
915 (let ((buffer-read-only nil))
917 (goto-char (point-min))
918 (search-forward "\n\n" nil t)
920 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
921 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
922 (adaptive-fill-mode t))
924 (and (>= (current-column) (min fill-column (window-width)))
925 (/= (preceding-char) ?:)
926 (fill-paragraph nil))
929 (defun article-remove-cr ()
930 "Translate CRLF pairs into LF, and then CR into LF.."
933 (let ((buffer-read-only nil))
934 (goto-char (point-min))
935 (while (search-forward "\r$" nil t)
936 (replace-match "" t t))
937 (goto-char (point-min))
938 (while (search-forward "\r" nil t)
939 (replace-match "\n" t t)))))
941 (defun article-remove-trailing-blank-lines ()
942 "Remove all trailing blank lines from the article."
945 (let ((buffer-read-only nil))
946 (goto-char (point-max))
950 (while (and (not (bobp))
951 (looking-at "^[ \t]*$")
952 (not (gnus-annotation-in-region-p
953 (point) (gnus-point-at-eol))))
958 (defun article-display-x-face (&optional force)
959 "Look for an X-Face header and display it if present."
960 (interactive (list 'force))
962 ;; Delete the old process, if any.
963 (when (process-status "article-x-face")
964 (delete-process "article-x-face"))
965 (let ((inhibit-point-motion-hooks t)
969 (nnheader-narrow-to-headers)
970 (setq from (message-fetch-field "from"))
971 (goto-char (point-min))
972 (while (and gnus-article-x-face-command
975 ;; Check whether this face is censored.
976 (not gnus-article-x-face-too-ugly)
977 (and gnus-article-x-face-too-ugly from
978 (not (string-match gnus-article-x-face-too-ugly
980 ;; Has to be present.
981 (re-search-forward "^X-Face: " nil t))
982 ;; This used to try to do multiple faces (`while' instead of
983 ;; `when' above), but (a) sending multiple EOFs to xv doesn't
984 ;; work (b) it can crash some versions of Emacs (c) are
985 ;; multiple faces really something to encourage?
986 (when (stringp gnus-article-x-face-command)
988 ;; We now have the area of the buffer where the X-Face is stored.
991 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
992 ;; We display the face.
993 (if (symbolp gnus-article-x-face-command)
994 ;; The command is a lisp function, so we call it.
995 (if (gnus-functionp gnus-article-x-face-command)
996 (funcall gnus-article-x-face-command beg end)
997 (error "%s is not a function" gnus-article-x-face-command))
998 ;; The command is a string, so we interpret the command
999 ;; as a, well, command, and fork it off.
1000 (let ((process-connection-type nil))
1001 (process-kill-without-query
1003 "article-x-face" nil shell-file-name shell-command-switch
1004 gnus-article-x-face-command))
1005 (process-send-region "article-x-face" beg end)
1006 (process-send-eof "article-x-face"))))))))))
1008 (defun article-decode-mime-words ()
1009 "Decode all MIME-encoded words in the article."
1012 (set-buffer gnus-article-buffer)
1013 (let ((inhibit-point-motion-hooks t)
1015 (mail-decode-encoded-word-region (point-min) (point-max)))))
1017 (defun article-decode-charset (&optional prompt)
1018 "Decode charset-encoded text in the article.
1019 If PROMPT (the prefix), prompt for a coding system to use."
1023 (message-narrow-to-head)
1024 (let* ((inhibit-point-motion-hooks t)
1025 (case-fold-search t)
1026 (ct (message-fetch-field "Content-Type" t))
1027 (cte (message-fetch-field "Content-Transfer-Encoding" t))
1028 (ctl (and ct (condition-case ()
1029 (mail-header-parse-content-type ct)
1033 (mm-read-coding-system "Charset to decode: "))
1035 (mail-content-type-get ctl 'charset))
1036 (gnus-newsgroup-name
1037 (gnus-group-find-parameter
1038 gnus-newsgroup-name 'charset))))
1041 (setq charset (downcase charset)))
1042 (goto-char (point-max))
1045 (narrow-to-region (point) (point-max))
1047 (equal (car ctl) "text/plain"))
1049 charset (and cte (intern (downcase
1050 (gnus-strip-whitespace cte))))
1053 (defun article-decode-encoded-words ()
1054 "Remove encoded-word encoding from headers."
1055 (let ((inhibit-point-motion-hooks t)
1056 (buffer-read-only nil))
1058 (message-narrow-to-head)
1059 (funcall gnus-decode-header-function (point-min) (point-max)))))
1061 (defun article-de-quoted-unreadable (&optional force)
1062 "Translate a quoted-printable-encoded article.
1063 If FORCE, decode the article whether it is marked as quoted-printable
1065 (interactive (list 'force))
1067 (let ((buffer-read-only nil)
1068 (type (gnus-fetch-field "content-transfer-encoding")))
1070 (and type (string-match "quoted-printable" (downcase type))))
1071 (goto-char (point-min))
1072 (search-forward "\n\n" nil 'move)
1074 (narrow-to-region (point) (point-max))
1075 (quoted-printable-decode-region (point-min) (point-max))
1076 (when mm-default-coding-system
1077 (mm-decode-body mm-default-coding-system)))))))
1079 (defun article-hide-pgp (&optional arg)
1080 "Toggle hiding of any PGP headers and signatures in the current article.
1081 If given a negative prefix, always show; if given a positive prefix,
1083 (interactive (gnus-article-hidden-arg))
1084 (unless (gnus-article-check-hidden-text 'pgp arg)
1086 (let ((inhibit-point-motion-hooks t)
1087 buffer-read-only beg end)
1089 (goto-char (point-min))
1090 ;; Hide the "header".
1091 (when (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
1092 (delete-region (1+ (match-beginning 0)) (match-end 0))
1093 ;; PGP 5 and GNU PG add a `Hash: <>' comment, hide that too
1094 (when (looking-at "Hash:.*$")
1095 (delete-region (point) (1+ (gnus-point-at-eol))))
1097 ;; Hide the actual signature.
1098 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
1099 (setq end (1+ (match-beginning 0)))
1102 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
1104 ;; Perhaps we shouldn't hide to the end of the buffer
1105 ;; if there is no end to the signature?
1107 ;; Hide "- " PGP quotation markers.
1109 (narrow-to-region beg end)
1110 (goto-char (point-min))
1111 (while (re-search-forward "^- " nil t)
1113 (match-beginning 0) (match-end 0)))
1115 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
1117 (defun article-hide-pem (&optional arg)
1118 "Toggle hiding of any PEM headers and signatures in the current article.
1119 If given a negative prefix, always show; if given a positive prefix,
1121 (interactive (gnus-article-hidden-arg))
1122 (unless (gnus-article-check-hidden-text 'pem arg)
1124 (let (buffer-read-only end)
1126 (goto-char (point-min))
1127 ;; hide the horrendously ugly "header".
1128 (and (search-forward "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
1131 (setq end (1+ (match-beginning 0)))
1132 (gnus-article-hide-text-type
1134 (if (search-forward "\n\n" nil t)
1138 ;; hide the trailer as well
1139 (and (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
1142 (gnus-article-hide-text-type
1143 (match-beginning 0) (match-end 0) 'pem))))))
1145 (defun article-hide-signature (&optional arg)
1146 "Hide the signature in the current article.
1147 If given a negative prefix, always show; if given a positive prefix,
1149 (interactive (gnus-article-hidden-arg))
1150 (unless (gnus-article-check-hidden-text 'signature arg)
1153 (let ((buffer-read-only nil))
1154 (when (gnus-article-narrow-to-signature)
1155 (gnus-article-hide-text-type
1156 (point-min) (point-max) 'signature)))))))
1158 (defun article-strip-leading-blank-lines ()
1159 "Remove all blank lines from the beginning of the article."
1162 (let ((inhibit-point-motion-hooks t)
1164 (goto-char (point-min))
1165 (when (search-forward "\n\n" nil t)
1166 (while (and (not (eobp))
1167 (looking-at "[ \t]*$"))
1168 (gnus-delete-line))))))
1170 (defun article-strip-multiple-blank-lines ()
1171 "Replace consecutive blank lines with one empty line."
1174 (let ((inhibit-point-motion-hooks t)
1176 ;; First make all blank lines empty.
1177 (goto-char (point-min))
1178 (search-forward "\n\n" nil t)
1179 (while (re-search-forward "^[ \t]+$" nil t)
1180 (unless (gnus-annotation-in-region-p
1181 (match-beginning 0) (match-end 0))
1182 (replace-match "" nil t)))
1183 ;; Then replace multiple empty lines with a single empty line.
1184 (goto-char (point-min))
1185 (search-forward "\n\n" nil t)
1186 (while (re-search-forward "\n\n\n+" nil t)
1187 (unless (gnus-annotation-in-region-p
1188 (match-beginning 0) (match-end 0))
1189 (replace-match "\n\n" t t))))))
1191 (defun article-strip-leading-space ()
1192 "Remove all white space from the beginning of the lines in the article."
1195 (let ((inhibit-point-motion-hooks t)
1197 (goto-char (point-min))
1198 (search-forward "\n\n" nil t)
1199 (while (re-search-forward "^[ \t]+" nil t)
1200 (replace-match "" t t)))))
1202 (defun article-strip-blank-lines ()
1203 "Strip leading, trailing and multiple blank lines."
1205 (article-strip-leading-blank-lines)
1206 (article-remove-trailing-blank-lines)
1207 (article-strip-multiple-blank-lines))
1209 (defun article-strip-all-blank-lines ()
1210 "Strip all blank lines."
1213 (let ((inhibit-point-motion-hooks t)
1215 (goto-char (point-min))
1216 (search-forward "\n\n" nil t)
1217 (while (re-search-forward "^[ \t]*\n" nil t)
1218 (replace-match "" t t)))))
1220 (defun gnus-article-narrow-to-signature ()
1221 "Narrow to the signature; return t if a signature is found, else nil."
1223 (let ((inhibit-point-motion-hooks t))
1224 (when (gnus-article-search-signature)
1226 ;; Check whether we have some limits to what we consider
1227 ;; to be a signature.
1228 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
1229 (list gnus-signature-limit)))
1231 (while (setq limit (pop limits))
1232 (if (or (and (integerp limit)
1233 (< (- (point-max) (point)) limit))
1235 (< (count-lines (point) (point-max)) limit))
1236 (and (gnus-functionp limit)
1238 (and (stringp limit)
1239 (not (re-search-forward limit nil t))))
1240 () ; This limit did not succeed.
1244 (narrow-to-region (point) (point-max))
1247 (defun gnus-article-search-signature ()
1248 "Search the current buffer for the signature separator.
1249 Put point at the beginning of the signature separator."
1250 (let ((cur (point)))
1251 (goto-char (point-max))
1252 (if (if (stringp gnus-signature-separator)
1253 (re-search-backward gnus-signature-separator nil t)
1254 (let ((seps gnus-signature-separator))
1256 (not (re-search-backward (car seps) nil t)))
1264 (autoload 'w3-display "w3-parse")
1265 (autoload 'w3-do-setup "w3" "" t)
1266 (autoload 'w3-region "w3-display" "" t))
1268 (defun gnus-article-treat-html ()
1271 (let ((cbuf (current-buffer)))
1272 (set-buffer gnus-article-buffer)
1273 (let (buf buffer-read-only b e)
1275 (goto-char (point-min))
1277 (if (search-forward "\n\n" nil t)
1280 (setq e (point-max)))
1282 (insert-buffer-substring gnus-article-buffer b e)
1284 (save-window-excursion
1285 (w3-region (point-min) (point-max))
1286 (setq buf (buffer-substring-no-properties (point-min) (point-max)))))
1288 (delete-region (point-min) (point-max))
1291 (goto-char (point-min))
1292 (set-window-start (get-buffer-window (current-buffer)) (point-min))
1293 (set-buffer cbuf))))
1295 (defun gnus-article-hidden-arg ()
1296 "Return the current prefix arg as a number, or 0 if no prefix."
1297 (list (if current-prefix-arg
1298 (prefix-numeric-value current-prefix-arg)
1301 (defun gnus-article-check-hidden-text (type arg)
1302 "Return nil if hiding is necessary.
1303 Arg can be nil or a number. Nil and positive means hide, negative
1304 means show, 0 means toggle."
1308 (let ((hide (gnus-article-hidden-text-p type)))
1314 (gnus-article-show-hidden-text type))
1316 (if (eq hide 'hidden)
1317 (gnus-article-show-hidden-text type)
1320 (defun gnus-article-hidden-text-p (type)
1321 "Say whether the current buffer contains hidden text of type TYPE."
1322 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
1324 (not (get-text-property pos 'invisible)))
1326 (text-property-any (1+ pos) (point-max) 'article-type type)))
1331 (defun gnus-article-show-hidden-text (type &optional hide)
1332 "Show all hidden text of type TYPE.
1333 If HIDE, hide the text instead."
1335 (let ((buffer-read-only nil)
1336 (inhibit-point-motion-hooks t)
1339 (while (setq beg (text-property-any end (point-max) 'article-type type))
1342 (text-property-not-all beg (point-max) 'article-type type)
1345 (gnus-article-hide-text beg end gnus-hidden-properties)
1346 (gnus-article-unhide-text beg end))
1350 (defconst article-time-units
1351 `((year . ,(* 365.25 24 60 60))
1352 (week . ,(* 7 24 60 60))
1353 (day . ,(* 24 60 60))
1357 "Mapping from time units to seconds.")
1359 (defun article-date-ut (&optional type highlight header)
1360 "Convert DATE date to universal time in the current article.
1361 If TYPE is `local', convert to local time; if it is `lapsed', output
1362 how much time has lapsed since DATE."
1363 (interactive (list 'ut t))
1364 (let* ((header (or header
1365 (mail-header-date gnus-current-headers)
1366 (message-fetch-field "date")
1368 (date (if (vectorp header) (mail-header-date header)
1370 (date-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
1371 (inhibit-point-motion-hooks t)
1372 bface eface newline)
1373 (when (and date (not (string= date "")))
1376 (nnheader-narrow-to-headers)
1377 (let ((buffer-read-only nil))
1378 ;; Delete any old Date headers.
1379 (if (re-search-forward date-regexp nil t)
1381 (setq bface (get-text-property (gnus-point-at-bol) 'face)
1382 eface (get-text-property (1- (gnus-point-at-eol))
1384 (delete-region (progn (beginning-of-line) (point))
1385 (progn (end-of-line) (point)))
1386 (beginning-of-line))
1387 (goto-char (point-max))
1389 (insert (article-make-date-line date type))
1392 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
1393 (put-text-property (match-beginning 1) (1+ (match-end 1))
1395 (put-text-property (match-beginning 2) (match-end 2)
1399 (insert "\n"))))))))
1401 (defun article-make-date-line (date type)
1402 "Return a DATE line of TYPE."
1403 (let ((time (condition-case ()
1407 ;; Convert to the local timezone. We have to slap a
1408 ;; `condition-case' round the calls to the timezone
1409 ;; functions since they aren't particularly resistant to
1412 (let ((tz (car (current-time-zone))))
1413 (format "Date: %s %s%04d" (current-time-string time)
1414 (if (> tz 0) "+" "-") (abs (/ tz 36)))))
1415 ;; Convert to Universal Time.
1418 (current-time-string
1419 (let* ((e (parse-time-string date))
1420 (tm (apply 'encode-time e))
1422 (ls (- (cadr tm) (car (current-time-zone)))))
1423 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
1424 ((> ls 65535) (list (1+ ms) (- ls 65536)))
1427 ;; Get the original date from the article.
1428 ((eq type 'original)
1429 (concat "Date: " (if (string-match "\n+$" date)
1430 (substring date 0 (match-beginning 0))
1432 ;; Let the user define the format.
1434 (if (gnus-functionp gnus-article-time-format)
1435 (funcall gnus-article-time-format time)
1438 (format-time-string gnus-article-time-format time))))
1443 (format-time-string "%Y%M%DT%h%m%s" time)))
1444 ;; Do an X-Sent lapsed format.
1446 ;; If the date is seriously mangled, the timezone functions are
1447 ;; liable to bug out, so we ignore all errors.
1448 (let* ((now (current-time))
1449 (real-time (subtract-time now time))
1450 (real-sec (and real-time
1451 (+ (* (float (car real-time)) 65536)
1453 (sec (and real-time (abs real-sec)))
1463 ;; This is a bit convoluted, but basically we go
1464 ;; through the time units for years, weeks, etc,
1465 ;; and divide things to see whether that results
1466 ;; in positive answers.
1469 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
1470 ;; The (remaining) seconds are too few to
1471 ;; be divided into this time unit.
1473 ;; It's big enough, so we output it.
1474 (setq sec (- sec (* num (cdr unit))))
1476 (concat (if prev ", " "") (int-to-string
1478 " " (symbol-name (car unit))
1479 (if (> num 1) "s" ""))
1481 article-time-units "")
1482 ;; If dates are odd, then it might appear like the
1483 ;; article was sent in the future.
1486 " in the future"))))))
1488 (error "Unknown conversion type: %s" type)))))
1490 (defun article-date-local (&optional highlight)
1491 "Convert the current article date to the local timezone."
1492 (interactive (list t))
1493 (article-date-ut 'local highlight))
1495 (defun article-date-original (&optional highlight)
1496 "Convert the current article date to what it was originally.
1497 This is only useful if you have used some other date conversion
1498 function and want to see what the date was before converting."
1499 (interactive (list t))
1500 (article-date-ut 'original highlight))
1502 (defun article-date-lapsed (&optional highlight)
1503 "Convert the current article date to time lapsed since it was sent."
1504 (interactive (list t))
1505 (article-date-ut 'lapsed highlight))
1507 (defun article-update-date-lapsed ()
1508 "Function to be run from a timer to update the lapsed time line."
1509 (let (deactivate-mark)
1514 (set-buffer (window-buffer w))
1515 (when (eq major-mode 'gnus-article-mode)
1516 (goto-char (point-min))
1517 (when (re-search-forward "^X-Sent:" nil t)
1518 (article-date-lapsed t)))))))))
1520 (defun gnus-start-date-timer (&optional n)
1521 "Start a timer to update the X-Sent header in the article buffers.
1522 The numerical prefix says how frequently (in seconds) the function
1527 (gnus-stop-date-timer)
1528 (setq article-lapsed-timer
1529 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
1531 (defun gnus-stop-date-timer ()
1532 "Stop the X-Sent timer."
1534 (when article-lapsed-timer
1535 (nnheader-cancel-timer article-lapsed-timer)
1536 (setq article-lapsed-timer nil)))
1538 (defun article-date-user (&optional highlight)
1539 "Convert the current article date to the user-defined format.
1540 This format is defined by the `gnus-article-time-format' variable."
1541 (interactive (list t))
1542 (article-date-ut 'user highlight))
1544 (defun article-date-iso8601 (&optional highlight)
1545 "Convert the current article date to ISO8601."
1546 (interactive (list t))
1547 (article-date-ut 'iso8601 highlight))
1549 (defun article-show-all ()
1550 "Show all hidden text in the article buffer."
1553 (let ((buffer-read-only nil))
1554 (gnus-article-unhide-text (point-min) (point-max)))))
1556 (defun article-emphasize (&optional arg)
1557 "Emphasize text according to `gnus-emphasis-alist'."
1558 (interactive (gnus-article-hidden-arg))
1559 (unless (gnus-article-check-hidden-text 'emphasis arg)
1561 (let ((alist gnus-emphasis-alist)
1562 (buffer-read-only nil)
1563 (props (append '(article-type emphasis)
1564 gnus-hidden-properties))
1565 regexp elem beg invisible visible face)
1566 (goto-char (point-min))
1567 (search-forward "\n\n" nil t)
1569 (while (setq elem (pop alist))
1571 (setq regexp (car elem)
1572 invisible (nth 1 elem)
1573 visible (nth 2 elem)
1575 (while (re-search-forward regexp nil t)
1576 (when (and (match-beginning visible) (match-beginning invisible))
1577 (gnus-article-hide-text
1578 (match-beginning invisible) (match-end invisible) props)
1579 (gnus-article-unhide-text-type
1580 (match-beginning visible) (match-end visible) 'emphasis)
1581 (gnus-put-text-property-excluding-newlines
1582 (match-beginning visible) (match-end visible) 'face face)
1583 (goto-char (match-end invisible)))))))))
1585 (defvar gnus-summary-article-menu)
1586 (defvar gnus-summary-post-menu)
1588 ;;; Saving functions.
1590 (defun gnus-article-save (save-buffer file &optional num)
1591 "Save the currently selected article."
1592 (unless gnus-save-all-headers
1593 ;; Remove headers according to `gnus-saved-headers'.
1594 (let ((gnus-visible-headers
1595 (or gnus-saved-headers gnus-visible-headers))
1596 (gnus-article-buffer save-buffer))
1598 (set-buffer save-buffer)
1599 (article-hide-headers 1 t))))
1600 (save-window-excursion
1601 (if (not gnus-default-article-saver)
1602 (error "No default saver is defined")
1603 ;; !!! Magic! The saving functions all save
1604 ;; `gnus-save-article-buffer' (or so they think), but we
1605 ;; bind that variable to our save-buffer.
1606 (set-buffer gnus-article-buffer)
1607 (let* ((gnus-save-article-buffer save-buffer)
1610 ((not gnus-prompt-before-saving) 'default)
1611 ((eq gnus-prompt-before-saving 'always) nil)
1613 (gnus-number-of-articles-to-be-saved
1614 (when (eq gnus-prompt-before-saving t)
1616 (set-buffer gnus-article-current-summary)
1617 (funcall gnus-default-article-saver filename)))))
1619 (defun gnus-read-save-file-name (prompt &optional filename
1620 function group headers variable)
1622 (funcall function group headers (symbol-value variable)))
1627 ((eq filename 'default)
1633 (let* ((split-name (gnus-get-split-value gnus-split-methods))
1636 (if (and gnus-number-of-articles-to-be-saved
1637 (> gnus-number-of-articles-to-be-saved 1))
1638 (format "these %d articles"
1639 gnus-number-of-articles-to-be-saved)
1642 ;; Let the split methods have their say.
1644 ;; No split name was found.
1647 (concat prompt " (default "
1648 (file-name-nondirectory default-name) ") ")
1649 (file-name-directory default-name)
1651 ;; A single group name is returned.
1652 ((stringp split-name)
1654 (funcall function split-name headers
1655 (symbol-value variable)))
1657 (concat prompt " (default "
1658 (file-name-nondirectory default-name) ") ")
1659 (file-name-directory default-name)
1661 ;; A single split name was found
1662 ((= 1 (length split-name))
1663 (let* ((name (expand-file-name
1664 (car split-name) gnus-article-save-directory))
1665 (dir (cond ((file-directory-p name)
1666 (file-name-as-directory name))
1667 ((file-exists-p name) name)
1668 (t gnus-article-save-directory))))
1670 (concat prompt " (default " name ") ")
1672 ;; A list of splits was found.
1674 (setq split-name (nreverse split-name))
1676 (let ((file-name-history
1677 (nconc split-name file-name-history)))
1681 (concat prompt " (`M-p' for defaults) ")
1682 gnus-article-save-directory
1684 gnus-article-save-directory)))
1685 (car (push result file-name-history)))))))
1686 ;; Create the directory.
1687 (gnus-make-directory (file-name-directory file))
1688 ;; If we have read a directory, we append the default file name.
1689 (when (file-directory-p file)
1690 (setq file (concat (file-name-as-directory file)
1691 (file-name-nondirectory default-name))))
1692 ;; Possibly translate some characters.
1693 (nnheader-translate-file-chars file)))))
1694 (gnus-make-directory (file-name-directory result))
1695 (set variable result)))
1697 (defun gnus-article-archive-name (group)
1698 "Return the first instance of an \"Archive-name\" in the current buffer."
1699 (let ((case-fold-search t))
1700 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
1701 (nnheader-concat gnus-article-save-directory
1702 (match-string 1)))))
1704 (defun gnus-article-nndoc-name (group)
1705 "If GROUP is an nndoc group, return the name of the parent group."
1706 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
1707 (gnus-group-get-parameter group 'save-article-group)))
1709 (defun gnus-summary-save-in-rmail (&optional filename)
1710 "Append this article to Rmail file.
1711 Optional argument FILENAME specifies file name.
1712 Directory to save to is default to `gnus-article-save-directory'."
1713 (setq filename (gnus-read-save-file-name
1714 "Save %s in rmail file:" filename
1715 gnus-rmail-save-name gnus-newsgroup-name
1716 gnus-current-headers 'gnus-newsgroup-last-rmail))
1717 (gnus-eval-in-buffer-window gnus-save-article-buffer
1721 (gnus-output-to-rmail filename))))
1724 (defun gnus-summary-save-in-mail (&optional filename)
1725 "Append this article to Unix mail file.
1726 Optional argument FILENAME specifies file name.
1727 Directory to save to is default to `gnus-article-save-directory'."
1728 (setq filename (gnus-read-save-file-name
1729 "Save %s in Unix mail file:" filename
1730 gnus-mail-save-name gnus-newsgroup-name
1731 gnus-current-headers 'gnus-newsgroup-last-mail))
1732 (gnus-eval-in-buffer-window gnus-save-article-buffer
1736 (if (and (file-readable-p filename)
1737 (mail-file-babyl-p filename))
1738 (rmail-output-to-rmail-file filename t)
1739 (gnus-output-to-mail filename)))))
1742 (defun gnus-summary-save-in-file (&optional filename overwrite)
1743 "Append this article to file.
1744 Optional argument FILENAME specifies file name.
1745 Directory to save to is default to `gnus-article-save-directory'."
1746 (setq filename (gnus-read-save-file-name
1747 "Save %s in file:" filename
1748 gnus-file-save-name gnus-newsgroup-name
1749 gnus-current-headers 'gnus-newsgroup-last-file))
1750 (gnus-eval-in-buffer-window gnus-save-article-buffer
1754 (when (and overwrite
1755 (file-exists-p filename))
1756 (delete-file filename))
1757 (gnus-output-to-file filename))))
1760 (defun gnus-summary-write-to-file (&optional filename)
1761 "Write this article to a file.
1762 Optional argument FILENAME specifies file name.
1763 The directory to save in defaults to `gnus-article-save-directory'."
1764 (gnus-summary-save-in-file nil t))
1766 (defun gnus-summary-save-body-in-file (&optional filename)
1767 "Append this article body to a file.
1768 Optional argument FILENAME specifies file name.
1769 The directory to save in defaults to `gnus-article-save-directory'."
1770 (setq filename (gnus-read-save-file-name
1771 "Save %s body in file:" filename
1772 gnus-file-save-name gnus-newsgroup-name
1773 gnus-current-headers 'gnus-newsgroup-last-file))
1774 (gnus-eval-in-buffer-window gnus-save-article-buffer
1778 (goto-char (point-min))
1779 (when (search-forward "\n\n" nil t)
1780 (narrow-to-region (point) (point-max)))
1781 (gnus-output-to-file filename))))
1784 (defun gnus-summary-save-in-pipe (&optional command)
1785 "Pipe this article to subprocess."
1787 (cond ((and (eq command 'default)
1788 gnus-last-shell-command)
1789 gnus-last-shell-command)
1793 "Shell command on %s: "
1794 (if (and gnus-number-of-articles-to-be-saved
1795 (> gnus-number-of-articles-to-be-saved 1))
1796 (format "these %d articles"
1797 gnus-number-of-articles-to-be-saved)
1799 gnus-last-shell-command))))
1800 (when (string-equal command "")
1801 (setq command gnus-last-shell-command))
1802 (gnus-eval-in-buffer-window gnus-article-buffer
1805 (shell-command-on-region (point-min) (point-max) command nil)))
1806 (setq gnus-last-shell-command command))
1808 ;;; Article file names when saving.
1810 (defun gnus-capitalize-newsgroup (newsgroup)
1811 "Capitalize NEWSGROUP name."
1812 (when (not (zerop (length newsgroup)))
1813 (concat (char-to-string (upcase (aref newsgroup 0)))
1814 (substring newsgroup 1))))
1816 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
1817 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1818 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
1819 Otherwise, it is like ~/News/news/group/num."
1822 (concat (if (gnus-use-long-file-name 'not-save)
1823 (gnus-capitalize-newsgroup newsgroup)
1824 (gnus-newsgroup-directory-form newsgroup))
1825 "/" (int-to-string (mail-header-number headers)))
1826 gnus-article-save-directory)))
1828 (string-equal (file-name-directory default)
1829 (file-name-directory last-file))
1830 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
1832 (or last-file default))))
1834 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
1835 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1836 If variable `gnus-use-long-file-name' is non-nil, it is
1837 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
1840 (concat (if (gnus-use-long-file-name 'not-save)
1842 (gnus-newsgroup-directory-form newsgroup))
1843 "/" (int-to-string (mail-header-number headers)))
1844 gnus-article-save-directory)))
1846 (string-equal (file-name-directory default)
1847 (file-name-directory last-file))
1848 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
1850 (or last-file default))))
1852 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
1853 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1854 If variable `gnus-use-long-file-name' is non-nil, it is
1855 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
1858 (if (gnus-use-long-file-name 'not-save)
1859 (gnus-capitalize-newsgroup newsgroup)
1860 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
1861 gnus-article-save-directory)))
1863 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
1864 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1865 If variable `gnus-use-long-file-name' is non-nil, it is
1866 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
1869 (if (gnus-use-long-file-name 'not-save)
1871 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
1872 gnus-article-save-directory)))
1879 (setq afunc (car func)
1882 gfunc (intern (format "gnus-%s" func))))
1884 (if (not (fboundp afunc))
1886 `(lambda (&optional interactive &rest args)
1887 ,(documentation afunc t)
1888 (interactive (list t))
1890 (set-buffer gnus-article-buffer)
1892 (call-interactively ',afunc)
1893 (apply ',afunc args))))))))
1894 '(article-hide-headers
1895 article-hide-boring-headers
1896 article-treat-overstrike
1897 (article-fill . gnus-article-word-wrap)
1899 article-display-x-face
1900 article-de-quoted-unreadable
1901 article-mime-decode-quoted-printable
1904 article-hide-signature
1905 article-remove-trailing-blank-lines
1906 article-strip-leading-blank-lines
1907 article-strip-multiple-blank-lines
1908 article-strip-leading-space
1909 article-strip-blank-lines
1910 article-strip-all-blank-lines
1912 article-date-iso8601
1913 article-date-original
1915 article-decode-mime-words
1916 article-decode-charset
1917 article-decode-encoded-words
1921 article-treat-dumbquotes
1922 (article-show-all . gnus-article-show-all-headers))))
1925 ;;; Gnus article mode
1928 (put 'gnus-article-mode 'mode-class 'special)
1930 (set-keymap-parent gnus-article-mode-map widget-keymap)
1932 (gnus-define-keys gnus-article-mode-map
1933 " " gnus-article-goto-next-page
1934 "\177" gnus-article-goto-prev-page
1935 [delete] gnus-article-goto-prev-page
1936 "\C-c^" gnus-article-refer-article
1937 "h" gnus-article-show-summary
1938 "s" gnus-article-show-summary
1939 "\C-c\C-m" gnus-article-mail
1940 "?" gnus-article-describe-briefly
1941 "e" gnus-article-edit
1942 "<" beginning-of-buffer
1944 "\C-c\C-i" gnus-info-find-node
1947 "\C-d" gnus-article-read-summary-keys
1948 "\M-*" gnus-article-read-summary-keys
1949 "\M-#" gnus-article-read-summary-keys
1950 "\M-^" gnus-article-read-summary-keys
1951 "\M-g" gnus-article-read-summary-keys)
1953 (substitute-key-definition
1954 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
1956 (defun gnus-article-make-menu-bar ()
1957 (gnus-turn-off-edit-menu 'article)
1958 (unless (boundp 'gnus-article-article-menu)
1960 gnus-article-article-menu gnus-article-mode-map ""
1962 ["Scroll forwards" gnus-article-goto-next-page t]
1963 ["Scroll backwards" gnus-article-goto-prev-page t]
1964 ["Show summary" gnus-article-show-summary t]
1965 ["Fetch Message-ID at point" gnus-article-refer-article t]
1966 ["Mail to address at point" gnus-article-mail t]
1967 ["Send a bug report" gnus-bug t]))
1970 gnus-article-treatment-menu gnus-article-mode-map ""
1972 ["Hide headers" gnus-article-hide-headers t]
1973 ["Hide signature" gnus-article-hide-signature t]
1974 ["Hide citation" gnus-article-hide-citation t]
1975 ["Treat overstrike" gnus-article-treat-overstrike t]
1976 ["Remove carriage return" gnus-article-remove-cr t]
1977 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]))
1979 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
1981 (when (boundp 'gnus-summary-post-menu)
1982 (define-key gnus-article-mode-map [menu-bar post]
1983 (cons "Post" gnus-summary-post-menu)))
1985 (gnus-run-hooks 'gnus-article-menu-hook)))
1987 (defun gnus-article-mode ()
1988 "Major mode for displaying an article.
1990 All normal editing commands are switched off.
1992 The following commands are available in addition to all summary mode
1994 \\<gnus-article-mode-map>
1995 \\[gnus-article-next-page]\t Scroll the article one page forwards
1996 \\[gnus-article-prev-page]\t Scroll the article one page backwards
1997 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
1998 \\[gnus-article-show-summary]\t Display the summary buffer
1999 \\[gnus-article-mail]\t Send a reply to the address near point
2000 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
2001 \\[gnus-info-find-node]\t Go to the Gnus info node"
2003 (when (gnus-visual-p 'article-menu 'menu)
2004 (gnus-article-make-menu-bar))
2005 (gnus-simplify-mode-line)
2006 (setq mode-name "Article")
2007 (setq major-mode 'gnus-article-mode)
2008 (make-local-variable 'minor-mode-alist)
2009 (use-local-map gnus-article-mode-map)
2010 (gnus-update-format-specifications nil 'article-mode)
2011 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
2012 (make-local-variable 'gnus-page-broken)
2013 (make-local-variable 'gnus-button-marker-list)
2014 (make-local-variable 'gnus-article-current-summary)
2015 (make-local-variable 'gnus-article-mime-handles)
2016 (make-local-variable 'gnus-article-decoded-p)
2017 (make-local-variable 'gnus-article-mime-handle-alist)
2018 (gnus-set-default-directory)
2019 (buffer-disable-undo)
2020 (setq buffer-read-only t)
2021 (set-syntax-table gnus-article-mode-syntax-table)
2022 (mm-enable-multibyte)
2023 (gnus-run-hooks 'gnus-article-mode-hook))
2025 (defun gnus-article-setup-buffer ()
2026 "Initialize the article buffer."
2027 (let* ((name (if gnus-single-article-buffer "*Article*"
2028 (concat "*Article " gnus-newsgroup-name "*")))
2030 (progn (string-match "\\*Article" name)
2031 (concat " *Original Article"
2032 (substring name (match-end 0))))))
2033 (setq gnus-article-buffer name)
2034 (setq gnus-original-article-buffer original)
2035 (setq gnus-article-mime-handle-alist nil)
2036 ;; This might be a variable local to the summary buffer.
2037 (unless gnus-single-article-buffer
2039 (set-buffer gnus-summary-buffer)
2040 (setq gnus-article-buffer name)
2041 (setq gnus-original-article-buffer original)
2042 (gnus-set-global-variables)))
2043 ;; Init original article buffer.
2045 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
2046 (mm-enable-multibyte)
2047 (setq major-mode 'gnus-original-article-mode)
2048 (make-local-variable 'gnus-original-article))
2049 (if (get-buffer name)
2052 (buffer-disable-undo)
2053 (setq buffer-read-only t)
2054 (unless (eq major-mode 'gnus-article-mode)
2055 (gnus-article-mode))
2058 (set-buffer (gnus-get-buffer-create name))
2060 (make-local-variable 'gnus-summary-buffer)
2061 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2062 (current-buffer)))))
2064 ;; Set article window start at LINE, where LINE is the number of lines
2065 ;; from the head of the article.
2066 (defun gnus-article-set-window-start (&optional line)
2068 (get-buffer-window gnus-article-buffer t)
2070 (set-buffer gnus-article-buffer)
2071 (goto-char (point-min))
2074 (gnus-message 6 "Moved to bookmark")
2075 (search-forward "\n\n" nil t)
2079 (defun gnus-article-prepare (article &optional all-headers header)
2080 "Prepare ARTICLE in article mode buffer.
2081 ARTICLE should either be an article number or a Message-ID.
2082 If ARTICLE is an id, HEADER should be the article headers.
2083 If ALL-HEADERS is non-nil, no headers are hidden."
2085 ;; Make sure we start in a summary buffer.
2086 (unless (eq major-mode 'gnus-summary-mode)
2087 (set-buffer gnus-summary-buffer))
2088 (setq gnus-summary-buffer (current-buffer))
2089 (let* ((gnus-article (if header (mail-header-number header) article))
2090 (summary-buffer (current-buffer))
2091 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
2092 (group gnus-newsgroup-name)
2095 (gnus-article-setup-buffer)
2096 (set-buffer gnus-article-buffer)
2097 ;; Deactivate active regions.
2098 (when (and (boundp 'transient-mark-mode)
2099 transient-mark-mode)
2100 (setq mark-active nil))
2101 (if (not (setq result (let ((buffer-read-only nil))
2102 (gnus-request-article-this-buffer
2104 ;; There is no such article.
2106 (when (and (numberp article)
2107 (not (memq article gnus-newsgroup-sparse)))
2108 (setq gnus-article-current
2109 (cons gnus-newsgroup-name article))
2110 (set-buffer gnus-summary-buffer)
2111 (setq gnus-current-article article)
2112 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
2114 (gnus-summary-set-agent-mark article)
2115 (message "Message marked for downloading"))
2116 (gnus-summary-mark-article article gnus-canceled-mark)
2117 (unless (memq article gnus-newsgroup-sparse)
2119 "No such article (may have expired or been canceled)")))))
2120 (if (or (eq result 'pseudo)
2121 (eq result 'nneething))
2124 (set-buffer summary-buffer)
2125 (push article gnus-newsgroup-history)
2126 (setq gnus-last-article gnus-current-article
2127 gnus-current-article 0
2128 gnus-current-headers nil
2129 gnus-article-current nil)
2130 (if (eq result 'nneething)
2131 (gnus-configure-windows 'summary)
2132 (gnus-configure-windows 'article))
2133 (gnus-set-global-variables))
2134 (gnus-set-mode-line 'article))
2135 ;; The result from the `request' was an actual article -
2136 ;; or at least some text that is now displayed in the
2138 (when (and (numberp article)
2139 (not (eq article gnus-current-article)))
2140 ;; Seems like a new article has been selected.
2141 ;; `gnus-current-article' must be an article number.
2143 (set-buffer summary-buffer)
2144 (push article gnus-newsgroup-history)
2145 (setq gnus-last-article gnus-current-article
2146 gnus-current-article article
2147 gnus-current-headers
2148 (gnus-summary-article-header gnus-current-article)
2149 gnus-article-current
2150 (cons gnus-newsgroup-name gnus-current-article))
2151 (unless (vectorp gnus-current-headers)
2152 (setq gnus-current-headers nil))
2153 (gnus-summary-goto-subject gnus-current-article)
2154 (when (gnus-summary-show-thread)
2155 ;; If the summary buffer really was folded, the
2156 ;; previous goto may not actually have gone to
2157 ;; the right article, but the thread root instead.
2159 (gnus-summary-goto-subject gnus-current-article))
2160 (gnus-run-hooks 'gnus-mark-article-hook)
2161 (gnus-set-mode-line 'summary)
2162 (when (gnus-visual-p 'article-highlight 'highlight)
2163 (gnus-run-hooks 'gnus-visual-mark-article-hook))
2164 ;; Set the global newsgroup variables here.
2165 ;; Suggested by Jim Sisolak
2166 ;; <sisolak@trans4.neep.wisc.edu>.
2167 (gnus-set-global-variables)
2168 (setq gnus-have-all-headers
2169 (or all-headers gnus-show-all-headers))))
2170 (when (or (numberp article)
2172 (gnus-article-prepare-display)
2174 (goto-char (point-min))
2175 (setq gnus-page-broken
2176 (when gnus-break-pages
2177 (gnus-narrow-to-page)
2179 (gnus-set-mode-line 'article)
2180 (gnus-configure-windows 'article)
2181 (goto-char (point-min))
2182 (search-forward "\n\n" nil t)
2183 (set-window-point (get-buffer-window (current-buffer)) (point))
2186 (defun gnus-article-prepare-display ()
2187 "Make the current buffer look like a nice article."
2188 ;; Hooks for getting information from the article.
2189 ;; This hook must be called before being narrowed.
2190 (let ((gnus-article-buffer (current-buffer))
2192 (unless (eq major-mode 'gnus-article-mode)
2193 (gnus-article-mode))
2194 (setq buffer-read-only nil)
2195 (gnus-run-hooks 'gnus-tmp-internal-hook)
2196 (gnus-run-hooks 'gnus-article-prepare-hook)
2197 (when gnus-display-mime-function
2198 (let ((url-standalone-mode (not gnus-plugged)))
2199 (funcall gnus-display-mime-function)))
2200 ;; Perform the article display hooks.
2201 (gnus-run-hooks 'gnus-article-display-hook)))
2204 ;;; Gnus MIME viewing functions
2207 (defvar gnus-mime-button-line-format "%{%([%p. %t%d%n]%)%}%e\n"
2208 "The following specs can be used:
2210 %n The `name' parameter
2211 %d The description, if any
2212 %l The length of the encoded part
2213 %p The part identifier
2214 %e Dots if the part isn't displayed")
2216 (defvar gnus-mime-button-line-format-alist
2217 '((?t gnus-tmp-type ?s)
2218 (?n gnus-tmp-name ?s)
2219 (?d gnus-tmp-description ?s)
2221 (?l gnus-tmp-length ?d)
2222 (?e gnus-tmp-dots ?s)))
2224 (defvar gnus-mime-button-commands
2225 '((gnus-article-press-button "\r" "Toggle Display")
2226 ;(gnus-mime-view-part "\M-\r" "View Interactively...")
2227 (gnus-mime-view-part "v" "View Interactively...")
2228 (gnus-mime-save-part "o" "Save...")
2229 (gnus-mime-copy-part "c" "View In Buffer")
2230 (gnus-mime-inline-part "i" "View Inline")
2231 (gnus-mime-pipe-part "|" "Pipe To Command...")))
2233 (defvar gnus-mime-button-map nil)
2234 (unless gnus-mime-button-map
2235 (setq gnus-mime-button-map (make-sparse-keymap))
2236 (set-keymap-parent gnus-mime-button-map gnus-article-mode-map)
2237 (define-key gnus-mime-button-map gnus-mouse-2 'gnus-article-push-button)
2238 (define-key gnus-mime-button-map gnus-mouse-3 'gnus-mime-button-menu)
2240 (define-key gnus-mime-button-map (cadr c) (car c)))
2241 gnus-mime-button-commands))
2243 (defun gnus-mime-button-menu (event)
2244 "Construct a context-sensitive menu of MIME commands."
2246 (let ((response (x-popup-menu
2248 ("" ,@(mapcar (lambda (c)
2249 (cons (caddr c) (car c)))
2250 gnus-mime-button-commands)))))
2251 (pos (event-start event)))
2253 (set-buffer (window-buffer (posn-window pos)))
2254 (goto-char (posn-point pos))
2255 (funcall response))))
2257 (defun gnus-mime-view-all-parts ()
2258 "View all the MIME parts."
2260 (let ((handles gnus-article-mime-handles))
2262 (mm-display-part (pop handles)))))
2264 (defun gnus-mime-save-part ()
2265 "Save the MIME part under point."
2267 (let ((data (get-text-property (point) 'gnus-data)))
2268 (mm-save-part data)))
2270 (defun gnus-mime-pipe-part ()
2271 "Pipe the MIME part under point to a process."
2273 (let ((data (get-text-property (point) 'gnus-data)))
2274 (mm-pipe-part data)))
2276 (defun gnus-mime-view-part ()
2277 "Interactively choose a view method for the MIME part under point."
2279 (let ((data (get-text-property (point) 'gnus-data))
2280 (url-standalone-mode (not gnus-plugged)))
2281 (mm-interactively-view-part data)))
2283 (defun gnus-mime-copy-part ()
2284 "Put the the MIME part under point into a new buffer."
2286 (let* ((handle (get-text-property (point) 'gnus-data))
2287 (contents (mm-get-part handle))
2288 (buffer (generate-new-buffer
2289 (file-name-nondirectory
2291 (mail-content-type-get (mm-handle-type handle) 'name)
2292 (mail-content-type-get (mm-handle-type handle)
2295 (switch-to-buffer buffer)
2298 (goto-char (point-min))))
2300 (defun gnus-mime-inline-part ()
2301 "Insert the MIME part under point into the current buffer."
2303 (let* ((data (get-text-property (point) 'gnus-data))
2304 (contents (mm-get-part data))
2305 (url-standalone-mode (not gnus-plugged))
2308 (if (mm-handle-undisplayer data)
2309 (mm-remove-part data)
2311 (mm-insert-inline data contents)
2314 (defun gnus-article-view-part (n)
2315 "View MIME part N, which is the numerical prefix."
2317 (save-current-buffer
2318 (set-buffer gnus-article-buffer)
2319 (when (> n (length gnus-article-mime-handle-alist))
2320 (error "No such part"))
2321 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
2322 (gnus-article-goto-part n)
2323 (if (equal (car handle) "multipart/alternative")
2324 (gnus-article-press-button)
2325 (when (eq (gnus-mm-display-part handle) 'internal)
2326 (gnus-set-window-start))))))
2328 (defun gnus-mm-display-part (handle)
2329 "Display HANDLE and fix MIME button."
2330 (let ((id (get-text-property (point) 'gnus-part))
2333 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
2334 (gnus-insert-mime-button
2335 handle id (list (not (mm-handle-displayed-p handle))))
2337 (mm-display-part handle)
2338 (goto-char point))))
2340 (defun gnus-article-goto-part (n)
2341 "Go to MIME part N."
2342 (goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
2344 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
2345 (let ((gnus-tmp-name (mail-content-type-get (mm-handle-type handle) 'name))
2346 (gnus-tmp-type (car (mm-handle-type handle)))
2347 (gnus-tmp-description (mm-handle-description handle))
2349 (if (if displayed (car displayed)
2350 (mm-handle-displayed-p handle))
2352 (gnus-tmp-length (save-excursion
2353 (set-buffer (mm-handle-buffer handle))
2358 (concat " (" gnus-tmp-name ")")
2360 (setq gnus-tmp-description
2361 (if gnus-tmp-description
2362 (concat " (" gnus-tmp-description ")")
2366 gnus-mime-button-line-format gnus-mime-button-line-format-alist
2367 `(local-map ,gnus-mime-button-map
2368 keymap ,gnus-mime-button-map
2369 gnus-callback gnus-mm-display-part
2370 gnus-part ,gnus-tmp-id
2371 article-type annotation
2374 (widget-convert-button 'link b e :action 'gnus-widget-press-button
2375 :button-keymap gnus-mime-button-map)))
2377 (defun gnus-widget-press-button (elems el)
2378 (goto-char (widget-get elems :from))
2379 (let ((url-standalone-mode (not gnus-plugged)))
2380 (gnus-article-press-button)))
2382 (defun gnus-display-mime (&optional ihandles)
2383 "Insert MIME buttons in the buffer."
2384 (let* ((handles (or ihandles (mm-dissect-buffer) (mm-uu-dissect)))
2385 handle name type b e display)
2388 ;; Top-level call; we clean up.
2389 (mm-destroy-parts gnus-article-mime-handles)
2390 (setq gnus-article-mime-handles handles
2391 gnus-article-mime-handle-alist nil)
2392 (goto-char (point-min))
2393 (search-forward "\n\n" nil t)
2394 (delete-region (point) (point-max)))
2395 (if (stringp (car handles))
2396 (if (equal (car handles) "multipart/alternative")
2397 (let ((id (1+ (length gnus-article-mime-handle-alist))))
2398 (push (cons id handles) gnus-article-mime-handle-alist)
2399 (gnus-mime-display-alternative (cdr handles) nil nil id))
2400 (gnus-mime-display-mixed (cdr handles)))
2401 (gnus-mime-display-single handles)))))
2403 (defun gnus-mime-display-mixed (handles)
2405 (while (setq handle (pop handles))
2406 (if (stringp (car handle))
2407 (if (equal (car handle) "multipart/alternative")
2408 (let ((id (1+ (length gnus-article-mime-handle-alist))))
2409 (push (cons id handle) gnus-article-mime-handle-alist)
2410 (gnus-mime-display-alternative (cdr handle) nil nil id))
2411 (gnus-mime-display-mixed (cdr handle)))
2412 (gnus-mime-display-single handle)))))
2414 (defun gnus-mime-display-single (handle)
2415 (let ((type (car (mm-handle-type handle)))
2416 (ignored gnus-ignored-mime-types)
2421 (when (string-match (pop ignored) type)
2422 (throw 'ignored nil)))
2423 (if (and (mm-automatic-display-p type)
2424 (mm-inlinable-part-p type)
2425 (or (not (mm-handle-disposition handle))
2426 (equal (car (mm-handle-disposition handle))
2429 (when (equal (car (split-string type "/"))
2432 (let ((id (1+ (length gnus-article-mime-handle-alist))))
2433 (push (cons id handle) gnus-article-mime-handle-alist)
2434 (gnus-insert-mime-button handle id (list (or display text))))
2439 (mm-display-part handle t)
2440 (goto-char (point-max)))
2444 (mm-insert-inline handle (mm-get-part handle))
2445 (goto-char (point-max))))))))
2447 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
2448 (let* ((preferred (mm-preferred-alternative handles preferred))
2451 handle buffer-read-only from props begend not-pref)
2454 (narrow-to-region (car ibegend) (cdr ibegend))
2455 (delete-region (point-min) (point-max))
2456 (mm-remove-parts handles))
2457 (setq begend (list (point-marker)))
2459 (unless (setq not-pref (cadr (member preferred ihandles)))
2460 (setq not-pref (car ihandles)))
2461 (gnus-add-text-properties
2464 (insert (format "%d. " id))
2468 (gnus-mime-display-alternative
2469 ',ihandles ,(if (stringp (car not-pref))
2471 (car (mm-handle-type not-pref)))
2473 local-map ,gnus-mime-button-map
2474 ,gnus-mouse-face-prop ,gnus-article-mouse-face
2475 face ,gnus-article-button-face
2476 keymap ,gnus-mime-button-map
2479 (widget-convert-button 'link from (point)
2480 :action 'gnus-widget-press-button
2481 :button-keymap gnus-widget-button-keymap)
2483 (while (setq handle (pop handles))
2484 (gnus-add-text-properties
2487 (insert (format "[%c] %-18s"
2488 (if (equal handle preferred) ?* ? )
2489 (if (stringp (car handle))
2491 (car (mm-handle-type handle)))))
2495 (gnus-mime-display-alternative
2496 ',ihandles ,(if (stringp (car handle))
2498 (car (mm-handle-type handle)))
2500 local-map ,gnus-mime-button-map
2501 ,gnus-mouse-face-prop ,gnus-article-mouse-face
2502 face ,gnus-article-button-face
2503 keymap ,gnus-mime-button-map
2506 (widget-convert-button 'link from (point)
2507 :action 'gnus-widget-press-button
2508 :button-keymap gnus-widget-button-keymap)
2512 (if (stringp (car preferred))
2513 (gnus-display-mime preferred)
2514 (mm-display-part preferred)
2515 (goto-char (point-max))
2516 (setcdr begend (point-marker)))))
2518 (goto-char point))))
2520 (defun gnus-article-wash-status ()
2521 "Return a string which display status of article washing."
2523 (set-buffer gnus-article-buffer)
2524 (let ((cite (gnus-article-hidden-text-p 'cite))
2525 (headers (gnus-article-hidden-text-p 'headers))
2526 (boring (gnus-article-hidden-text-p 'boring-headers))
2527 (pgp (gnus-article-hidden-text-p 'pgp))
2528 (pem (gnus-article-hidden-text-p 'pem))
2529 (signature (gnus-article-hidden-text-p 'signature))
2530 (overstrike (gnus-article-hidden-text-p 'overstrike))
2531 (emphasis (gnus-article-hidden-text-p 'emphasis)))
2532 (format "%c%c%c%c%c%c"
2534 (if (or headers boring) ?h ? )
2535 (if (or pgp pem) ?p ? )
2536 (if signature ?s ? )
2537 (if overstrike ?o ? )
2538 (if emphasis ?e ? )))))
2540 (fset 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
2542 (defun gnus-article-maybe-hide-headers ()
2543 "Hide unwanted headers if `gnus-have-all-headers' is nil.
2544 Provided for backwards compatibility."
2545 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
2547 (gnus-article-hide-headers)))
2551 (defun gnus-output-to-file (file-name)
2552 "Append the current article to a file named FILE-NAME."
2553 (let ((artbuf (current-buffer)))
2555 (insert-buffer-substring artbuf)
2556 ;; Append newline at end of the buffer as separator, and then
2558 (goto-char (point-max))
2560 (append-to-file (point-min) (point-max) file-name)
2563 (defun gnus-narrow-to-page (&optional arg)
2564 "Narrow the article buffer to a page.
2565 If given a numerical ARG, move forward ARG pages."
2567 (setq arg (if arg (prefix-numeric-value arg) 0))
2569 (set-buffer gnus-article-buffer)
2570 (goto-char (point-min))
2572 ;; Remove any old next/prev buttons.
2573 (when (gnus-visual-p 'page-marker)
2574 (let ((buffer-read-only nil))
2575 (gnus-remove-text-with-property 'gnus-prev)
2576 (gnus-remove-text-with-property 'gnus-next)))
2579 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
2581 (re-search-forward page-delimiter nil 'move arg)))
2582 (goto-char (match-end 0)))
2585 (if (re-search-forward page-delimiter nil 'move)
2588 (when (and (gnus-visual-p 'page-marker)
2589 (not (= (point-min) 1)))
2591 (goto-char (point-min))
2592 (gnus-insert-prev-page-button)))
2593 (when (and (gnus-visual-p 'page-marker)
2594 (< (+ (point-max) 2) (buffer-size)))
2596 (goto-char (point-max))
2597 (gnus-insert-next-page-button)))))
2599 ;; Article mode commands
2601 (defun gnus-article-goto-next-page ()
2602 "Show the next page of the article."
2604 (when (gnus-article-next-page)
2605 (goto-char (point-min))
2606 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
2608 (defun gnus-article-goto-prev-page ()
2609 "Show the next page of the article."
2611 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
2612 (gnus-article-prev-page nil)))
2614 (defun gnus-article-next-page (&optional lines)
2615 "Show the next page of the current article.
2616 If end of article, return non-nil. Otherwise return nil.
2617 Argument LINES specifies lines to be scrolled up."
2619 (move-to-window-line -1)
2622 (and (pos-visible-in-window-p) ;Not continuation line.
2624 ;; Nothing in this page.
2625 (if (or (not gnus-page-broken)
2628 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
2630 (gnus-narrow-to-page 1) ;Go to next page.
2632 ;; More in this page.
2633 (let ((scroll-in-place nil))
2637 ;; Long lines may cause an end-of-buffer error.
2638 (goto-char (point-max)))))
2639 (move-to-window-line 0)
2642 (defun gnus-article-prev-page (&optional lines)
2643 "Show previous page of current article.
2644 Argument LINES specifies lines to be scrolled down."
2646 (move-to-window-line 0)
2647 (if (and gnus-page-broken
2649 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
2651 (gnus-narrow-to-page -1) ;Go to previous page.
2652 (goto-char (point-max))
2654 (let ((scroll-in-place nil))
2658 (beginning-of-buffer
2659 (goto-char (point-min))))
2660 (move-to-window-line 0)))))
2662 (defun gnus-article-refer-article ()
2663 "Read article specified by message-id around point."
2665 (let ((point (point)))
2666 (search-forward ">" nil t) ;Move point to end of "<....>".
2667 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
2668 (let ((message-id (match-string 1)))
2670 (set-buffer gnus-summary-buffer)
2671 (gnus-summary-refer-article message-id))
2673 (error "No references around point"))))
2675 (defun gnus-article-show-summary ()
2676 "Reconfigure windows to show summary buffer."
2678 (if (not (gnus-buffer-live-p gnus-summary-buffer))
2679 (error "There is no summary buffer for this article buffer")
2680 (gnus-article-set-globals)
2681 (gnus-configure-windows 'article)
2682 (gnus-summary-goto-subject gnus-current-article)
2683 (gnus-summary-position-point)))
2685 (defun gnus-article-describe-briefly ()
2686 "Describe article mode commands briefly."
2689 (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")))
2691 (defun gnus-article-summary-command ()
2692 "Execute the last keystroke in the summary buffer."
2694 (let ((obuf (current-buffer))
2695 (owin (current-window-configuration))
2697 (switch-to-buffer gnus-article-current-summary 'norecord)
2698 (setq func (lookup-key (current-local-map) (this-command-keys)))
2699 (call-interactively func)
2701 (set-window-configuration owin)
2702 (set-window-point (get-buffer-window (current-buffer)) (point))))
2704 (defun gnus-article-summary-command-nosave ()
2705 "Execute the last keystroke in the summary buffer."
2708 (pop-to-buffer gnus-article-current-summary 'norecord)
2709 (setq func (lookup-key (current-local-map) (this-command-keys)))
2710 (call-interactively func)))
2712 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
2713 "Read a summary buffer key sequence and execute it from the article buffer."
2716 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
2717 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
2718 "=" "^" "\M-^" "|"))
2724 '("n" "Gn" "p" "Gp"))
2727 (set-buffer gnus-article-current-summary)
2728 (let (gnus-pick-mode)
2729 (push (or key last-command-event) unread-command-events)
2730 (setq keys (read-key-sequence nil))))
2733 (if (or (member keys nosaves)
2734 (member keys nosave-but-article)
2735 (member keys nosave-in-article))
2737 (save-window-excursion
2738 (pop-to-buffer gnus-article-current-summary 'norecord)
2739 ;; We disable the pick minor mode commands.
2740 (let (gnus-pick-mode)
2741 (setq func (lookup-key (current-local-map) keys))))
2744 (unless (member keys nosave-in-article)
2745 (set-buffer gnus-article-current-summary))
2746 (call-interactively func)
2747 (setq new-sum-point (point)))
2748 (when (member keys nosave-but-article)
2749 (pop-to-buffer gnus-article-buffer 'norecord)))
2750 ;; These commands should restore window configuration.
2751 (let ((obuf (current-buffer))
2752 (owin (current-window-configuration))
2754 (summary gnus-article-current-summary)
2755 func in-buffer selected)
2756 (if not-restore-window
2757 (pop-to-buffer summary 'norecord)
2758 (switch-to-buffer summary 'norecord))
2759 (setq in-buffer (current-buffer))
2760 ;; We disable the pick minor mode commands.
2761 (if (setq func (let (gnus-pick-mode)
2762 (lookup-key (current-local-map) keys)))
2764 (call-interactively func)
2765 (setq new-sum-point (point)))
2767 (when (eq in-buffer (current-buffer))
2768 (setq selected (gnus-summary-select-article))
2770 (unless not-restore-window
2771 (set-window-configuration owin))
2772 (unless (or (not (eq selected 'old)) (member keys up-to-top))
2773 (set-window-point (get-buffer-window (current-buffer))
2775 (let ((win (get-buffer-window gnus-article-current-summary)))
2777 (set-window-point win new-sum-point))))))))
2779 (defun gnus-article-hide (&optional arg force)
2780 "Hide all the gruft in the current article.
2781 This means that PGP stuff, signatures, cited text and (some)
2782 headers will be hidden.
2783 If given a prefix, show the hidden text instead."
2784 (interactive (append (gnus-article-hidden-arg) (list 'force)))
2785 (gnus-article-hide-headers arg)
2786 (gnus-article-hide-pgp arg)
2787 (gnus-article-hide-citation-maybe arg force)
2788 (gnus-article-hide-signature arg))
2790 (defun gnus-article-maybe-highlight ()
2791 "Do some article highlighting if article highlighting is requested."
2792 (when (gnus-visual-p 'article-highlight 'highlight)
2793 (gnus-article-highlight-some)))
2795 (defun gnus-check-group-server ()
2796 ;; Make sure the connection to the server is alive.
2797 (unless (gnus-server-opened
2798 (gnus-find-method-for-group gnus-newsgroup-name))
2799 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
2800 (gnus-request-group gnus-newsgroup-name t)))
2802 (defun gnus-request-article-this-buffer (article group)
2803 "Get an article and insert it into this buffer."
2804 (let (do-update-line sparse-header)
2808 (gnus-kill-all-overlays)
2809 (setq group (or group gnus-newsgroup-name))
2811 ;; Using `gnus-request-article' directly will insert the article into
2812 ;; `nntp-server-buffer' - so we'll save some time by not having to
2813 ;; copy it from the server buffer into the article buffer.
2815 ;; We only request an article by message-id when we do not have the
2816 ;; headers for it, so we'll have to get those.
2817 (when (stringp article)
2818 (let ((gnus-override-method gnus-refer-article-method))
2819 (gnus-read-header article)))
2821 ;; If the article number is negative, that means that this article
2822 ;; doesn't belong in this newsgroup (possibly), so we find its
2823 ;; message-id and request it by id instead of number.
2824 (when (and (numberp article)
2826 (get-buffer gnus-summary-buffer)
2827 (gnus-buffer-exists-p gnus-summary-buffer))
2829 (set-buffer gnus-summary-buffer)
2830 (let ((header (gnus-summary-article-header article)))
2833 ((memq article gnus-newsgroup-sparse)
2834 ;; This is a sparse gap article.
2835 (setq do-update-line article)
2836 (setq article (mail-header-id header))
2837 (let ((gnus-override-method gnus-refer-article-method))
2838 (setq sparse-header (gnus-read-header article)))
2839 (setq gnus-newsgroup-sparse
2840 (delq article gnus-newsgroup-sparse)))
2842 ;; It's a real article.
2843 (setq article (mail-header-id header)))
2845 ;; It is an extracted pseudo-article.
2846 (setq article 'pseudo)
2847 (gnus-request-pseudo-article header))))
2849 (let ((method (gnus-find-method-for-group
2850 gnus-newsgroup-name)))
2851 (when (and (eq (car method) 'nneething)
2854 (file-name-as-directory
2855 (or (cadr (assq 'nneething-address method))
2857 (mail-header-subject header))))
2858 (when (file-directory-p dir)
2859 (setq article 'nneething)
2860 (gnus-group-enter-directory dir))))))))
2863 ;; Refuse to select canceled articles.
2864 ((and (numberp article)
2866 (get-buffer gnus-summary-buffer)
2867 (gnus-buffer-exists-p gnus-summary-buffer)
2868 (eq (cdr (save-excursion
2869 (set-buffer gnus-summary-buffer)
2870 (assq article gnus-newsgroup-reads)))
2871 gnus-canceled-mark))
2873 ;; We first check `gnus-original-article-buffer'.
2874 ((and (get-buffer gnus-original-article-buffer)
2877 (set-buffer gnus-original-article-buffer)
2878 (and (equal (car gnus-original-article) group)
2879 (eq (cdr gnus-original-article) article))))
2880 (insert-buffer-substring gnus-original-article-buffer)
2882 ;; Check the backlog.
2883 ((and gnus-keep-backlog
2884 (gnus-backlog-request-article group article (current-buffer)))
2886 ;; Check asynchronous pre-fetch.
2887 ((gnus-async-request-fetched-article group article (current-buffer))
2888 (gnus-async-prefetch-next group article gnus-summary-buffer)
2889 (when (and (numberp article) gnus-keep-backlog)
2890 (gnus-backlog-enter-article group article (current-buffer)))
2893 ((and gnus-use-cache
2895 (gnus-cache-request-article article group))
2897 ;; Get the article and put into the article buffer.
2898 ((or (stringp article) (numberp article))
2899 (let ((gnus-override-method
2900 (and (stringp article) gnus-refer-article-method))
2901 (buffer-read-only nil))
2903 (gnus-kill-all-overlays)
2904 (gnus-check-group-server)
2905 (when (gnus-request-article article group (current-buffer))
2906 (when (numberp article)
2907 (gnus-async-prefetch-next group article gnus-summary-buffer)
2908 (when gnus-keep-backlog
2909 (gnus-backlog-enter-article
2910 group article (current-buffer))))
2915 ;; Associate this article with the current summary buffer.
2916 (setq gnus-article-current-summary gnus-summary-buffer)
2918 ;; Take the article from the original article buffer
2919 ;; and place it in the buffer it's supposed to be in.
2920 (when (and (get-buffer gnus-article-buffer)
2921 (equal (buffer-name (current-buffer))
2922 (buffer-name (get-buffer gnus-article-buffer))))
2924 (if (get-buffer gnus-original-article-buffer)
2925 (set-buffer gnus-original-article-buffer)
2926 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
2927 (buffer-disable-undo)
2928 (setq major-mode 'gnus-original-article-mode)
2929 (setq buffer-read-only t))
2930 (let (buffer-read-only)
2932 (insert-buffer-substring gnus-article-buffer))
2933 (setq gnus-original-article (cons group article)))
2936 (run-hooks 'gnus-article-decode-hook)
2937 ;; Mark article as decoded or not.
2938 (setq gnus-article-decoded-p gnus-article-decode-hook))
2940 ;; Update sparse articles.
2941 (when (and do-update-line
2942 (or (numberp article)
2944 (let ((buf (current-buffer)))
2945 (set-buffer gnus-summary-buffer)
2946 (gnus-summary-update-article do-update-line sparse-header)
2947 (gnus-summary-goto-subject do-update-line nil t)
2948 (set-window-point (get-buffer-window (current-buffer) t)
2950 (set-buffer buf))))))
2956 (defcustom gnus-article-edit-mode-hook nil
2957 "Hook run in article edit mode buffers."
2958 :group 'gnus-article-various
2961 (defvar gnus-article-edit-done-function nil)
2963 (defvar gnus-article-edit-mode-map nil)
2965 ;; Should we be using derived.el for this?
2966 (unless gnus-article-edit-mode-map
2967 (setq gnus-article-edit-mode-map (make-sparse-keymap))
2968 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
2970 (gnus-define-keys gnus-article-edit-mode-map
2971 "\C-c\C-c" gnus-article-edit-done
2972 "\C-c\C-k" gnus-article-edit-exit)
2974 (gnus-define-keys (gnus-article-edit-wash-map
2975 "\C-c\C-w" gnus-article-edit-mode-map)
2976 "f" gnus-article-edit-full-stops))
2978 (defun gnus-article-edit-mode ()
2979 "Major mode for editing articles.
2980 This is an extended text-mode.
2982 \\{gnus-article-edit-mode-map}"
2984 (setq major-mode 'gnus-article-edit-mode)
2985 (setq mode-name "Article Edit")
2986 (use-local-map gnus-article-edit-mode-map)
2987 (make-local-variable 'gnus-article-edit-done-function)
2988 (make-local-variable 'gnus-prev-winconf)
2989 (setq buffer-read-only nil)
2990 (buffer-enable-undo)
2992 (gnus-run-hooks 'text-mode-hook 'gnus-article-edit-mode-hook))
2994 (defun gnus-article-edit (&optional force)
2995 "Edit the current article.
2996 This will have permanent effect only in mail groups.
2997 If FORCE is non-nil, allow editing of articles even in read-only
3000 (when (and (not force)
3001 (gnus-group-read-only-p))
3002 (error "The current newsgroup does not support article editing"))
3003 (gnus-article-date-original)
3004 (gnus-article-edit-article
3005 `(lambda (no-highlight)
3006 (gnus-summary-edit-article-done
3007 ,(or (mail-header-references gnus-current-headers) "")
3008 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
3010 (defun gnus-article-edit-article (exit-func)
3011 "Start editing the contents of the current article buffer."
3012 (let ((winconf (current-window-configuration)))
3013 (set-buffer gnus-article-buffer)
3014 (gnus-article-edit-mode)
3015 (gnus-article-delete-text-of-type 'annotation)
3016 (gnus-set-text-properties (point-min) (point-max) nil)
3017 (gnus-configure-windows 'edit-article)
3018 (setq gnus-article-edit-done-function exit-func)
3019 (setq gnus-prev-winconf winconf)
3020 (gnus-message 6 "C-c C-c to end edits")))
3022 (defun gnus-article-edit-done (&optional arg)
3023 "Update the article edits and exit."
3028 (goto-char (point-min))
3029 (when (search-forward "\n\n" nil 1)
3030 (let ((lines (count-lines (point) (point-max)))
3031 (length (- (point-max) (point)))
3032 (case-fold-search t)
3033 (body (copy-marker (point))))
3034 (goto-char (point-min))
3035 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
3036 (delete-region (match-beginning 1) (match-end 1))
3037 (insert (number-to-string length)))
3038 (goto-char (point-min))
3039 (when (re-search-forward
3040 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
3041 (delete-region (match-beginning 1) (match-end 1))
3042 (insert (number-to-string length)))
3043 (goto-char (point-min))
3044 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
3045 (delete-region (match-beginning 1) (match-end 1))
3046 (insert (number-to-string lines)))))))
3047 (let ((func gnus-article-edit-done-function)
3048 (buf (current-buffer))
3049 (start (window-start)))
3050 (gnus-article-edit-exit)
3053 (let ((buffer-read-only nil))
3055 ;; The cache and backlog have to be flushed somewhat.
3056 (when gnus-keep-backlog
3057 (gnus-backlog-remove-article
3058 (car gnus-article-current) (cdr gnus-article-current)))
3059 ;; Flush original article as well.
3061 (when (get-buffer gnus-original-article-buffer)
3062 (set-buffer gnus-original-article-buffer)
3063 (setq gnus-original-article nil)))
3064 (when gnus-use-cache
3065 (gnus-cache-update-article
3066 (car gnus-article-current) (cdr gnus-article-current))))
3068 (set-window-start (get-buffer-window buf) start)
3069 (set-window-point (get-buffer-window buf) (point))))
3071 (defun gnus-article-edit-exit ()
3072 "Exit the article editing without updating."
3074 ;; We remove all text props from the article buffer.
3075 (let ((buf (format "%s" (buffer-string)))
3076 (curbuf (current-buffer))
3078 (window-start (window-start)))
3081 (let ((winconf gnus-prev-winconf))
3083 (set-window-configuration winconf)
3084 ;; Tippy-toe some to make sure that point remains where it was.
3085 (save-current-buffer
3087 (set-window-start (get-buffer-window (current-buffer)) window-start)
3090 (defun gnus-article-edit-full-stops ()
3091 "Interactively repair spacing at end of sentences."
3094 (goto-char (point-min))
3095 (search-forward-regexp "^$" nil t)
3096 (let ((case-fold-search nil))
3097 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
3100 ;;; Article highlights
3103 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
3105 ;;; Internal Variables:
3107 (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\\)"
3108 "Regular expression that matches URLs."
3109 :group 'gnus-article-buttons
3112 (defcustom gnus-button-alist
3113 `(("<\\(url:[>\n\t ]*?\\)?news:[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>" 0 t
3114 gnus-button-message-id 2)
3115 ("\\bnews:\\([^>\n\t ]*@[^>\n\t ]*\\)" 0 t gnus-button-message-id 1)
3116 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
3118 gnus-button-fetch-group 4)
3119 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
3120 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
3121 t gnus-button-message-id 3)
3122 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
3123 ("mailto:\\([-a-zA-Z.@_+0-9%]+\\)" 0 t gnus-url-mailto 1)
3124 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
3125 ;; This is how URLs _should_ be embedded in text...
3126 ("<URL: *\\([^>]*\\)>" 0 t gnus-button-embedded-url 1)
3128 (,gnus-button-url-regexp 0 t gnus-button-url 0))
3129 "*Alist of regexps matching buttons in article bodies.
3131 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
3132 REGEXP: is the string matching text around the button,
3133 BUTTON: is the number of the regexp grouping actually matching the button,
3134 FORM: is a lisp expression which must eval to true for the button to
3136 CALLBACK: is the function to call when the user push this button, and each
3137 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
3139 CALLBACK can also be a variable, in that case the value of that
3140 variable it the real callback function."
3141 :group 'gnus-article-buttons
3142 :type '(repeat (list regexp
3143 (integer :tag "Button")
3145 (function :tag "Callback")
3148 (integer :tag "Regexp group")))))
3150 (defcustom gnus-header-button-alist
3151 `(("^\\(References\\|Message-I[Dd]\\):" "<[^>]+>"
3152 0 t gnus-button-message-id 0)
3153 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
3154 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
3155 0 t gnus-button-mailto 0)
3156 ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t gnus-button-url 0)
3157 ("^Subject:" ,gnus-button-url-regexp 0 t gnus-button-url 0)
3158 ("^[^:]+:" ,gnus-button-url-regexp 0 t gnus-button-url 0)
3159 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
3160 gnus-button-message-id 3))
3161 "*Alist of headers and regexps to match buttons in article heads.
3163 This alist is very similar to `gnus-button-alist', except that each
3164 alist has an additional HEADER element first in each entry:
3166 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
3168 HEADER is a regexp to match a header. For a fuller explanation, see
3169 `gnus-button-alist'."
3170 :group 'gnus-article-buttons
3171 :group 'gnus-article-headers
3172 :type '(repeat (list (regexp :tag "Header")
3174 (integer :tag "Button")
3176 (function :tag "Callback")
3179 (integer :tag "Regexp group")))))
3181 (defvar gnus-button-regexp nil)
3182 (defvar gnus-button-marker-list nil)
3183 ;; Regexp matching any of the regexps from `gnus-button-alist'.
3185 (defvar gnus-button-last nil)
3186 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
3190 (defun gnus-article-push-button (event)
3191 "Check text under the mouse pointer for a callback function.
3192 If the text under the mouse pointer has a `gnus-callback' property,
3193 call it with the value of the `gnus-data' text property."
3195 (set-buffer (window-buffer (posn-window (event-start event))))
3196 (let* ((pos (posn-point (event-start event)))
3197 (data (get-text-property pos 'gnus-data))
3198 (fun (get-text-property pos 'gnus-callback)))
3201 (funcall fun data))))
3203 (defun gnus-article-press-button ()
3204 "Check text at point for a callback function.
3205 If the text at point has a `gnus-callback' property,
3206 call it with the value of the `gnus-data' text property."
3208 (let* ((data (get-text-property (point) 'gnus-data))
3209 (fun (get-text-property (point) 'gnus-callback)))
3211 (funcall fun data))))
3213 (defun gnus-article-highlight (&optional force)
3214 "Highlight current article.
3215 This function calls `gnus-article-highlight-headers',
3216 `gnus-article-highlight-citation',
3217 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
3218 do the highlighting. See the documentation for those functions."
3219 (interactive (list 'force))
3220 (gnus-article-highlight-headers)
3221 (gnus-article-highlight-citation force)
3222 (gnus-article-highlight-signature)
3223 (gnus-article-add-buttons force)
3224 (gnus-article-add-buttons-to-head))
3226 (defun gnus-article-highlight-some (&optional force)
3227 "Highlight current article.
3228 This function calls `gnus-article-highlight-headers',
3229 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
3230 do the highlighting. See the documentation for those functions."
3231 (interactive (list 'force))
3232 (gnus-article-highlight-headers)
3233 (gnus-article-highlight-signature)
3234 (gnus-article-add-buttons))
3236 (defun gnus-article-highlight-headers ()
3237 "Highlight article headers as specified by `gnus-header-face-alist'."
3240 (set-buffer gnus-article-buffer)
3242 (let ((alist gnus-header-face-alist)
3243 (buffer-read-only nil)
3244 (case-fold-search t)
3245 (inhibit-point-motion-hooks t)
3246 entry regexp header-face field-face from hpoints fpoints)
3247 (message-narrow-to-head)
3248 (while (setq entry (pop alist))
3249 (goto-char (point-min))
3250 (setq regexp (concat "^\\("
3251 (if (string-equal "" (nth 0 entry))
3255 header-face (nth 1 entry)
3256 field-face (nth 2 entry))
3257 (while (and (re-search-forward regexp nil t)
3261 (unless (search-forward ":" nil t)
3263 (when (and header-face
3264 (not (memq (point) hpoints)))
3265 (push (point) hpoints)
3266 (gnus-put-text-property from (point) 'face header-face))
3267 (when (and field-face
3268 (not (memq (setq from (point)) fpoints)))
3270 (if (re-search-forward "^[^ \t]" nil t)
3272 (goto-char (point-max)))
3273 (gnus-put-text-property from (point) 'face field-face))))))))
3275 (defun gnus-article-highlight-signature ()
3276 "Highlight the signature in an article.
3277 It does this by highlighting everything after
3278 `gnus-signature-separator' using `gnus-signature-face'."
3281 (set-buffer gnus-article-buffer)
3282 (let ((buffer-read-only nil)
3283 (inhibit-point-motion-hooks t))
3285 (when (and gnus-signature-face
3286 (gnus-article-narrow-to-signature))
3287 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
3288 'face gnus-signature-face)
3290 (gnus-article-search-signature)
3291 (let ((start (match-beginning 0))
3292 (end (set-marker (make-marker) (1+ (match-end 0)))))
3293 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
3296 (defun gnus-button-in-region-p (b e prop)
3297 "Say whether PROP exists in the region."
3298 (text-property-not-all b e prop nil))
3300 (defun gnus-article-add-buttons (&optional force)
3301 "Find external references in the article and make buttons of them.
3302 \"External references\" are things like Message-IDs and URLs, as
3303 specified by `gnus-button-alist'."
3304 (interactive (list 'force))
3306 (set-buffer gnus-article-buffer)
3307 (let ((buffer-read-only nil)
3308 (inhibit-point-motion-hooks t)
3309 (case-fold-search t)
3310 (alist gnus-button-alist)
3312 ;; Remove all old markers.
3314 (while (setq marker (pop gnus-button-marker-list))
3316 (when (setq entry (gnus-button-entry))
3317 (put-text-property (match-beginning (nth 1 entry))
3318 (match-end (nth 1 entry))
3319 'gnus-callback nil))
3320 (set-marker marker nil)))
3321 ;; We skip the headers.
3322 (goto-char (point-min))
3323 (unless (search-forward "\n\n" nil t)
3324 (goto-char (point-max)))
3326 (while (setq entry (pop alist))
3327 (setq regexp (car entry))
3329 (while (re-search-forward regexp nil t)
3330 (let* ((start (and entry (match-beginning (nth 1 entry))))
3331 (end (and entry (match-end (nth 1 entry))))
3332 (from (match-beginning 0)))
3333 (when (and (or (eq t (nth 2 entry))
3334 (eval (nth 2 entry)))
3335 (not (gnus-button-in-region-p
3336 start end 'gnus-callback)))
3337 ;; That optional form returned non-nil, so we add the
3339 (gnus-article-add-button
3340 start end 'gnus-button-push
3341 (car (push (set-marker (make-marker) from)
3342 gnus-button-marker-list))))))))))
3344 ;; Add buttons to the head of an article.
3345 (defun gnus-article-add-buttons-to-head ()
3346 "Add buttons to the head of the article."
3349 (set-buffer gnus-article-buffer)
3350 (let ((buffer-read-only nil)
3351 (inhibit-point-motion-hooks t)
3352 (case-fold-search t)
3353 (alist gnus-header-button-alist)
3355 (nnheader-narrow-to-headers)
3357 ;; Each alist entry.
3358 (setq entry (car alist)
3360 (goto-char (point-min))
3361 (while (re-search-forward (car entry) nil t)
3362 ;; Each header matching the entry.
3363 (setq beg (match-beginning 0))
3364 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
3365 (match-beginning 0))
3368 (while (re-search-forward (nth 1 entry) end t)
3369 ;; Each match within a header.
3370 (let* ((entry (cdr entry))
3371 (start (match-beginning (nth 1 entry)))
3372 (end (match-end (nth 1 entry)))
3373 (form (nth 2 entry)))
3374 (goto-char (match-end 0))
3376 (gnus-article-add-button
3377 start end (nth 3 entry)
3378 (buffer-substring (match-beginning (nth 4 entry))
3379 (match-end (nth 4 entry)))))))
3383 ;;; External functions:
3385 (defun gnus-article-add-button (from to fun &optional data)
3386 "Create a button between FROM and TO with callback FUN and data DATA."
3387 (when gnus-article-button-face
3388 (gnus-overlay-put (gnus-make-overlay from to)
3389 'face gnus-article-button-face))
3390 (gnus-add-text-properties
3392 (nconc (and gnus-article-mouse-face
3393 (list gnus-mouse-face-prop gnus-article-mouse-face))
3394 (list 'gnus-callback fun)
3395 (and data (list 'gnus-data data))))
3396 (widget-convert-button 'link from to :action 'gnus-widget-press-button
3397 :button-keymap gnus-widget-button-keymap))
3399 ;;; Internal functions:
3401 (defun gnus-article-set-globals ()
3403 (set-buffer gnus-summary-buffer)
3404 (gnus-set-global-variables)))
3406 (defun gnus-signature-toggle (end)
3408 (set-buffer gnus-article-buffer)
3409 (let ((buffer-read-only nil)
3410 (inhibit-point-motion-hooks t))
3411 (if (get-text-property end 'invisible)
3412 (gnus-article-unhide-text end (point-max))
3413 (gnus-article-hide-text end (point-max) gnus-hidden-properties)))))
3415 (defun gnus-button-entry ()
3416 ;; Return the first entry in `gnus-button-alist' matching this place.
3417 (let ((alist gnus-button-alist)
3420 (setq entry (pop alist))
3421 (if (looking-at (car entry))
3426 (defun gnus-button-push (marker)
3427 ;; Push button starting at MARKER.
3430 (let* ((entry (gnus-button-entry))
3431 (inhibit-point-motion-hooks t)
3433 (args (mapcar (lambda (group)
3434 (let ((string (match-string group)))
3435 (gnus-set-text-properties
3436 0 (length string) nil string)
3443 (fboundp (symbol-value fun)))
3444 (apply (symbol-value fun) args))
3446 (gnus-message 1 "You must define `%S' to use this button"
3447 (cons fun args)))))))
3449 (defun gnus-button-message-id (message-id)
3452 (set-buffer gnus-summary-buffer)
3453 (gnus-summary-refer-article message-id)))
3455 (defun gnus-button-fetch-group (address)
3456 "Fetch GROUP specified by ADDRESS."
3457 (if (not (string-match "[:/]" address))
3458 ;; This is just a simple group url.
3459 (gnus-group-read-ephemeral-group address gnus-select-method)
3460 (if (not (string-match "^\\([^:/]+\\)\\(:\\([^/]+\\)/\\)?\\(.*\\)$"
3462 (error "Can't parse %s" address)
3463 (gnus-group-read-ephemeral-group
3464 (match-string 4 address)
3465 `(nntp ,(match-string 1 address)
3466 (nntp-address ,(match-string 1 address))
3467 (nntp-port-number ,(if (match-end 3)
3468 (match-string 3 address)
3471 (defun gnus-url-parse-query-string (query &optional downcase)
3472 (let (retval pairs cur key val)
3473 (setq pairs (split-string query "&"))
3475 (setq cur (car pairs)
3477 (if (not (string-match "=" cur))
3479 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
3480 val (gnus-url-unhex-string (substring cur (match-end 0) nil)))
3482 (setq key (downcase key)))
3483 (setq cur (assoc key retval))
3485 (setcdr cur (cons val (cdr cur)))
3486 (setq retval (cons (list key val) retval)))))
3489 (defun gnus-url-unhex (x)
3496 (defun gnus-url-unhex-string (str &optional allow-newlines)
3497 "Remove %XXX embedded spaces, etc in a url.
3498 If optional second argument ALLOW-NEWLINES is non-nil, then allow the
3499 decoding of carriage returns and line feeds in the string, which is normally
3500 forbidden in URL encoding."
3501 (setq str (or str ""))
3503 (case-fold-search t))
3504 (while (string-match "%[0-9a-f][0-9a-f]" str)
3505 (let* ((start (match-beginning 0))
3506 (ch1 (gnus-url-unhex (elt str (+ start 1))))
3508 (gnus-url-unhex (elt str (+ start 2))))))
3510 tmp (substring str 0 start)
3513 (char-to-string code))
3514 ((or (= code ?\n) (= code ?\r))
3516 (t (char-to-string code))))
3517 str (substring str (match-end 0)))))
3518 (setq tmp (concat tmp str))
3521 (defun gnus-url-mailto (url)
3522 ;; Send mail to someone
3523 (when (string-match "mailto:/*\\(.*\\)" url)
3524 (setq url (substring url (match-beginning 1) nil)))
3525 (let (to args subject func)
3526 (if (string-match (regexp-quote "?") url)
3527 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
3528 args (gnus-url-parse-query-string
3529 (substring url (match-end 0) nil) t))
3530 (setq to (gnus-url-unhex-string url)))
3531 (setq args (cons (list "to" to) args)
3532 subject (cdr-safe (assoc "subject" args)))
3535 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
3538 (message-position-on-field (caar args)))
3539 (insert (mapconcat 'identity (cdar args) ", "))
3540 (setq args (cdr args)))
3543 (message-goto-subject))))
3545 (defun gnus-button-mailto (address)
3547 (set-buffer (gnus-copy-article-buffer))
3548 (message-reply address))
3550 (defun gnus-button-reply (address)
3551 ;; Reply to ADDRESS.
3552 (message-reply address))
3554 (defun gnus-button-url (address)
3556 ;; In Emacs 20, `browse-url-browser-function' may be an alist.
3557 (if (listp browse-url-browser-function)
3558 (browse-url address)
3559 (funcall browse-url-browser-function address)))
3561 (defun gnus-button-embedded-url (address)
3563 ;; In Emacs 20, `browse-url-browser-function' may be an alist.
3564 (if (listp browse-url-browser-function)
3565 (browse-url (gnus-strip-whitespace address))
3566 (funcall browse-url-browser-function (gnus-strip-whitespace address))))
3568 ;;; Next/prev buttons in the article buffer.
3570 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
3571 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
3573 (defvar gnus-prev-page-map nil)
3574 (unless gnus-prev-page-map
3575 (setq gnus-prev-page-map (make-sparse-keymap))
3576 (define-key gnus-prev-page-map gnus-mouse-2 'gnus-button-prev-page)
3577 (define-key gnus-prev-page-map "\r" 'gnus-button-prev-page))
3579 (defun gnus-insert-prev-page-button ()
3580 (let ((buffer-read-only nil))
3582 gnus-prev-page-line-format nil
3583 `(gnus-prev t local-map ,gnus-prev-page-map
3584 gnus-callback gnus-article-button-prev-page
3585 article-type annotation))))
3587 (defvar gnus-next-page-map nil)
3588 (unless gnus-next-page-map
3589 (setq gnus-next-page-map (make-keymap))
3590 (suppress-keymap gnus-prev-page-map)
3591 (define-key gnus-next-page-map gnus-mouse-2 'gnus-button-next-page)
3592 (define-key gnus-next-page-map "\r" 'gnus-button-next-page))
3594 (defun gnus-button-next-page ()
3595 "Go to the next page."
3597 (let ((win (selected-window)))
3598 (select-window (get-buffer-window gnus-article-buffer t))
3599 (gnus-article-next-page)
3600 (select-window win)))
3602 (defun gnus-button-prev-page ()
3603 "Go to the prev page."
3605 (let ((win (selected-window)))
3606 (select-window (get-buffer-window gnus-article-buffer t))
3607 (gnus-article-prev-page)
3608 (select-window win)))
3610 (defun gnus-insert-next-page-button ()
3611 (let ((buffer-read-only nil))
3612 (gnus-eval-format gnus-next-page-line-format nil
3614 t local-map ,gnus-next-page-map
3615 gnus-callback gnus-article-button-next-page
3616 article-type annotation))))
3618 (defun gnus-article-button-next-page (arg)
3619 "Go to the next page."
3621 (let ((win (selected-window)))
3622 (select-window (get-buffer-window gnus-article-buffer t))
3623 (gnus-article-next-page)
3624 (select-window win)))
3626 (defun gnus-article-button-prev-page (arg)
3627 "Go to the prev page."
3629 (let ((win (selected-window)))
3630 (select-window (get-buffer-window gnus-article-buffer t))
3631 (gnus-article-prev-page)
3632 (select-window win)))
3634 (defvar gnus-decode-header-methods
3635 '(mail-decode-encoded-word-region)
3636 "List of methods used to decode headers
3638 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item is
3639 FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
3640 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
3641 whose names match REGEXP.
3644 ((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
3645 mail-decode-encoded-word-region
3646 (\"chinese\" . rfc1843-decode-region))
3649 (defvar gnus-decode-header-methods-cache nil)
3651 (defun gnus-multi-decode-header (start end)
3652 "Apply the functions from `gnus-encoded-word-methods' that match."
3653 (unless (and gnus-decode-header-methods-cache
3654 (eq gnus-newsgroup-name
3655 (car gnus-decode-header-methods-cache)))
3656 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
3659 (nconc gnus-decode-header-methods-cache (list x))
3660 (if (and gnus-newsgroup-name
3661 (string-match (car x) gnus-newsgroup-name))
3662 (nconc gnus-decode-header-methods-cache
3664 gnus-decode-header-methods))
3665 (let ((xlist gnus-decode-header-methods-cache))
3668 (narrow-to-region start end)
3670 (funcall (pop xlist) (point-min) (point-max))))))
3676 (run-hooks 'gnus-art-load-hook)
3678 ;;; gnus-art.el ends here