1 ;;; gnus-art.el --- article mode commands for Semi-gnus
2 ;; Copyright (C) 1996,97,98 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
5 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Keywords: mail, news, MIME
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
40 (defgroup gnus-article nil
42 :link '(custom-manual "(gnus)The Article Buffer")
45 (defgroup gnus-article-hiding nil
46 "Hiding article parts."
47 :link '(custom-manual "(gnus)Article Hiding")
50 (defgroup gnus-article-highlight nil
51 "Article highlighting."
52 :link '(custom-manual "(gnus)Article Highlighting")
56 (defgroup gnus-article-signature nil
58 :link '(custom-manual "(gnus)Article Signature")
61 (defgroup gnus-article-headers nil
63 :link '(custom-manual "(gnus)Hiding Headers")
66 (defgroup gnus-article-washing nil
67 "Special commands on articles."
68 :link '(custom-manual "(gnus)Article Washing")
71 (defgroup gnus-article-emphasis nil
72 "Fontisizing articles."
73 :link '(custom-manual "(gnus)Article Fontisizing")
76 (defgroup gnus-article-saving nil
78 :link '(custom-manual "(gnus)Saving Articles")
81 (defgroup gnus-article-mime nil
82 "Worshiping the MIME wonder."
83 :link '(custom-manual "(gnus)Using MIME")
86 (defgroup gnus-article-buttons nil
87 "Pushable buttons in the article buffer."
88 :link '(custom-manual "(gnus)Article Buttons")
91 (defgroup gnus-article-various nil
92 "Other article options."
93 :link '(custom-manual "(gnus)Misc Article")
96 (defcustom gnus-ignored-headers
97 '("^Path:" "^Expires:" "^Date-Received:" "^References:" "^Xref:" "^Lines:"
98 "^Relay-Version:" "^Message-ID:" "^Approved:" "^Sender:" "^Received:"
99 "^X-UIDL:" "^MIME-Version:" "^Return-Path:" "^In-Reply-To:"
100 "^Content-Type:" "^Content-Transfer-Encoding:" "^X-WebTV-Signature:"
101 "^X-MimeOLE:" "^X-MSMail-Priority:" "^X-Priority:" "^X-Loop:"
102 "^X-Authentication-Warning:" "^X-MIME-Autoconverted:" "^X-Face:"
103 "^X-Attribution:" "^X-Originating-IP:" "^Delivered-To:"
104 "^NNTP-[-A-Za-z]+:" "^Distribution:" "^X-no-archive:" "^X-Trace:"
105 "^X-Complaints-To:" "^X-NNTP-Posting-Host:" "^X-Orig.*:"
106 "^Abuse-Reports-To:" "^Cache-Post-Path:" "^X-Article-Creation-Date:"
107 "^X-Poster:" "^X-Mail2News-Path:" "^X-Server-Date:" "^X-Cache:"
108 "^Originator:" "^X-Problems-To:" "^X-Auth-User:" "^X-Post-Time:"
109 "^X-Admin:" "^X-UID:" "^Resent-[-A-Za-z]+:" "^X-Mailing-List:"
110 "^Precedence:" "^Original-[-A-Za-z]+:" "^X-filename:" "^X-Orcpt:"
111 "^Old-Received:" "^X-Pgp-Fingerprint:" "^X-Pgp-Key-Id:"
112 "^X-Pgp-Public-Key-Url:" "^X-Auth:" "^X-From-Line:"
113 "^X-Gnus-Article-Number:" "^X-Majordomo:" "^X-Url:" "^X-Sender:"
114 "^X-Mailing-List:" "^MBOX-Line" "^Priority:" "^X-Pgp" "^X400-[-A-Za-z]+:"
116 "*All headers that start with this regexp will be hidden.
117 This variable can also be a list of regexps of headers to be ignored.
118 If `gnus-visible-headers' is non-nil, this variable will be ignored."
119 :type '(choice :custom-show nil
122 :group 'gnus-article-hiding)
124 (defcustom gnus-visible-headers
125 "From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^\\(Mail-\\)?Followup-To:\\|^\\(Mail-\\)?Reply-To:\\|^Mail-Copies-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^Cc:\\|^Posted-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:\\|X-Sent:"
126 "*All headers that do not match this regexp will be hidden.
127 This variable can also be a list of regexp of headers to remain visible.
128 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
129 :type '(repeat :value-to-internal (lambda (widget value)
130 (custom-split-regexp-maybe value))
131 :match (lambda (widget value)
133 (widget-editable-list-match widget value)))
135 :group 'gnus-article-hiding)
137 (defcustom gnus-sorted-header-list
138 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
139 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
140 "*This variable is a list of regular expressions.
141 If it is non-nil, headers that match the regular expressions will
142 be placed first in the article buffer in the sequence specified by
144 :type '(repeat regexp)
145 :group 'gnus-article-hiding)
147 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
148 "Headers that are only to be displayed if they have interesting data.
149 Possible values in this list are `empty', `newsgroups', `followup-to',
150 `reply-to', `date', `long-to', and `many-to'."
151 :type '(set (const :tag "Headers with no content." empty)
152 (const :tag "Newsgroups with only one group." newsgroups)
153 (const :tag "Followup-to identical to newsgroups." followup-to)
154 (const :tag "Reply-to identical to from." reply-to)
155 (const :tag "Date less than four days old." date)
156 (const :tag "Very long To header." long-to)
157 (const :tag "Multiple To headers." many-to))
158 :group 'gnus-article-hiding)
160 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
161 "Regexp matching signature separator.
162 This can also be a list of regexps. In that case, it will be checked
163 from head to tail looking for a separator. Searches will be done from
164 the end of the buffer."
165 :type '(repeat string)
166 :group 'gnus-article-signature)
168 (defcustom gnus-signature-limit nil
169 "Provide a limit to what is considered a signature.
170 If it is a number, no signature may not be longer (in characters) than
171 that number. If it is a floating point number, no signature may be
172 longer (in lines) than that number. If it is a function, the function
173 will be called without any parameters, and if it returns nil, there is
174 no signature in the buffer. If it is a string, it will be used as a
175 regexp. If it matches, the text in question is not a signature."
176 :type '(choice (integer :value 200)
178 (function :value fun)
179 (regexp :value ".*"))
180 :group 'gnus-article-signature)
182 (defcustom gnus-hidden-properties '(invisible t intangible t)
183 "Property list to use for hiding text."
185 :group 'gnus-article-hiding)
187 (defcustom gnus-article-x-face-command
188 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
189 "*String or function to be executed to display an X-Face header.
190 If it is a string, the command will be executed in a sub-shell
191 asynchronously. The compressed face will be piped to this command."
192 :type 'string ;Leave function case to Lisp.
193 :group 'gnus-article-washing)
195 (defcustom gnus-article-x-face-too-ugly nil
196 "Regexp matching posters whose face shouldn't be shown automatically."
197 :type '(choice regexp (const nil))
198 :group 'gnus-article-washing)
200 (defcustom gnus-emphasis-alist
202 "\\(\\s-\\|^\\|[-\"]\\|\\s(\\|\\s)\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\s-\\|[-?!.,;:\"]\\|\\s(\\|\\s)\\)")
204 '(("_" "_" underline)
207 ("_/" "/_" underline-italic)
208 ("_\\*" "\\*_" underline-bold)
209 ("\\*/" "/\\*" bold-italic)
210 ("_\\*/" "/\\*_" underline-bold-italic))))
211 `(("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
212 2 3 gnus-emphasis-underline)
216 (format format (car spec) (cadr spec))
217 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
219 "*Alist that says how to fontify certain phrases.
220 Each item looks like this:
222 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
224 The first element is a regular expression to be matched. The second
225 is a number that says what regular expression grouping used to find
226 the entire emphasized word. The third is a number that says what
227 regexp grouping should be displayed and highlighted. The fourth
228 is the face used for highlighting."
229 :type '(repeat (list :value ("" 0 0 default)
231 (integer :tag "Match group")
232 (integer :tag "Emphasize group")
234 :group 'gnus-article-emphasis)
236 (defface gnus-emphasis-bold '((t (:bold t)))
237 "Face used for displaying strong emphasized text (*word*)."
238 :group 'gnus-article-emphasis)
240 (defface gnus-emphasis-italic '((t (:italic t)))
241 "Face used for displaying italic emphasized text (/word/)."
242 :group 'gnus-article-emphasis)
244 (defface gnus-emphasis-underline '((t (:underline t)))
245 "Face used for displaying underlined emphasized text (_word_)."
246 :group 'gnus-article-emphasis)
248 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
249 "Face used for displaying underlined bold emphasized text (_*word*_)."
250 :group 'gnus-article-emphasis)
252 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
253 "Face used for displaying underlined italic emphasized text (_*word*_)."
254 :group 'gnus-article-emphasis)
256 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
257 "Face used for displaying bold italic emphasized text (/*word*/)."
258 :group 'gnus-article-emphasis)
260 (defface gnus-emphasis-underline-bold-italic
261 '((t (:bold t :italic t :underline t)))
262 "Face used for displaying underlined bold italic emphasized text.
263 Esample: (_/*word*/_)."
264 :group 'gnus-article-emphasis)
266 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
267 "Format for display of Date headers in article bodies.
268 See `format-time-string' for the possible values.
270 The variable can also be function, which should return a complete Date
271 header. The function is called with one argument, the time, which can
272 be fed to `format-time-string'."
273 :type '(choice string symbol)
274 :link '(custom-manual "(gnus)Article Date")
275 :group 'gnus-article-washing)
278 (autoload 'mail-extract-address-components "mail-extr"))
280 (defcustom gnus-save-all-headers t
281 "*If non-nil, don't remove any headers before saving."
282 :group 'gnus-article-saving
285 (defcustom gnus-prompt-before-saving 'always
286 "*This variable says how much prompting is to be done when saving articles.
287 If it is nil, no prompting will be done, and the articles will be
288 saved to the default files. If this variable is `always', each and
289 every article that is saved will be preceded by a prompt, even when
290 saving large batches of articles. If this variable is neither nil not
291 `always', there the user will be prompted once for a file name for
292 each invocation of the saving commands."
293 :group 'gnus-article-saving
294 :type '(choice (item always)
295 (item :tag "never" nil)
296 (sexp :tag "once" :format "%t\n" :value t)))
298 (defcustom gnus-saved-headers gnus-visible-headers
299 "Headers to keep if `gnus-save-all-headers' is nil.
300 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
301 If that variable is nil, however, all headers that match this regexp
302 will be kept while the rest will be deleted before saving."
303 :group 'gnus-article-saving
306 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
307 "A function to save articles in your favourite format.
308 The function must be interactively callable (in other words, it must
309 be an Emacs command).
311 Gnus provides the following functions:
313 * gnus-summary-save-in-rmail (Rmail format)
314 * gnus-summary-save-in-mail (Unix mail format)
315 * gnus-summary-save-in-folder (MH folder)
316 * gnus-summary-save-in-file (article format)
317 * gnus-summary-save-in-vm (use VM's folder format)
318 * gnus-summary-write-to-file (article format -- overwrite)."
319 :group 'gnus-article-saving
320 :type '(radio (function-item gnus-summary-save-in-rmail)
321 (function-item gnus-summary-save-in-mail)
322 (function-item gnus-summary-save-in-folder)
323 (function-item gnus-summary-save-in-file)
324 (function-item gnus-summary-save-in-vm)
325 (function-item gnus-summary-write-to-file)))
327 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
328 "A function generating a file name to save articles in Rmail format.
329 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
330 :group 'gnus-article-saving
333 (defcustom gnus-mail-save-name 'gnus-plain-save-name
334 "A function generating a file name to save articles in Unix mail format.
335 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
336 :group 'gnus-article-saving
339 (defcustom gnus-folder-save-name 'gnus-folder-save-name
340 "A function generating a file name to save articles in MH folder.
341 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
342 :group 'gnus-article-saving
345 (defcustom gnus-file-save-name 'gnus-numeric-save-name
346 "A function generating a file name to save articles in article format.
347 The function is called with NEWSGROUP, HEADERS, and optional
349 :group 'gnus-article-saving
352 (defcustom gnus-split-methods
353 '((gnus-article-archive-name)
354 (gnus-article-nndoc-name))
355 "*Variable used to suggest where articles are to be saved.
356 For instance, if you would like to save articles related to Gnus in
357 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
358 you could set this variable to something like:
360 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
361 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
363 This variable is an alist where the where the key is the match and the
364 value is a list of possible files to save in if the match is non-nil.
366 If the match is a string, it is used as a regexp match on the
367 article. If the match is a symbol, that symbol will be funcalled
368 from the buffer of the article to be saved with the newsgroup as the
369 parameter. If it is a list, it will be evaled in the same buffer.
371 If this form or function returns a string, this string will be used as
372 a possible file name; and if it returns a non-nil list, that list will
373 be used as possible file names."
374 :group 'gnus-article-saving
375 :type '(repeat (choice (list :value (fun) function)
376 (cons :value ("" "") regexp (repeat string))
379 (defcustom gnus-article-display-method-for-mime
380 'gnus-article-display-mime-message
381 "Function to display a MIME message.
382 The function is called from the article buffer."
383 :group 'gnus-article-mime
386 (defcustom gnus-article-display-method-for-encoded-word
387 'gnus-article-display-message-with-encoded-word
388 "*Function to display a message with MIME encoded-words.
389 The function is called from the article buffer."
390 :group 'gnus-article-mime
393 (defcustom gnus-article-display-method-for-traditional
394 'gnus-article-display-traditional-message
395 "*Function to display a traditional message.
396 The function is called from the article buffer."
397 :group 'gnus-article-mime
400 (defcustom gnus-page-delimiter "^\^L"
401 "*Regexp describing what to use as article page delimiters.
402 The default value is \"^\^L\", which is a form linefeed at the
403 beginning of a line."
405 :group 'gnus-article-various)
407 (defcustom gnus-article-mode-line-format "Gnus: %g %S"
408 "*The format specification for the article mode line.
409 See `gnus-summary-mode-line-format' for a closer description."
411 :group 'gnus-article-various)
413 (defcustom gnus-article-mode-hook nil
414 "*A hook for Gnus article mode."
416 :group 'gnus-article-various)
418 (defcustom gnus-article-menu-hook nil
419 "*Hook run after the creation of the article mode menu."
421 :group 'gnus-article-various)
423 (defcustom gnus-article-prepare-hook nil
424 "*A hook called after an article has been prepared in the article buffer.
425 If you want to run a special decoding program like nkf, use this hook."
427 :group 'gnus-article-various)
429 (defcustom gnus-article-hide-pgp-hook nil
430 "*A hook called after successfully hiding a PGP signature."
432 :group 'gnus-article-various)
434 (defcustom gnus-article-button-face 'bold
435 "Face used for highlighting buttons in the article buffer.
437 An article button is a piece of text that you can activate by pressing
438 `RET' or `mouse-2' above it."
440 :group 'gnus-article-buttons)
442 (defcustom gnus-article-mouse-face 'highlight
443 "Face used for mouse highlighting in the article buffer.
445 Article buttons will be displayed in this face when the cursor is
448 :group 'gnus-article-buttons)
450 (defcustom gnus-signature-face 'gnus-signature-face
451 "Face used for highlighting a signature in the article buffer.
452 Obsolete; use the face `gnus-signature-face' for customizations instead."
454 :group 'gnus-article-highlight
455 :group 'gnus-article-signature)
457 (defface gnus-signature-face
460 "Face used for highlighting a signature in the article buffer."
461 :group 'gnus-article-highlight
462 :group 'gnus-article-signature)
464 (defface gnus-header-from-face
467 (:foreground "spring green"))
470 (:foreground "red3"))
473 "Face used for displaying from headers."
474 :group 'gnus-article-headers
475 :group 'gnus-article-highlight)
477 (defface gnus-header-subject-face
480 (:foreground "SeaGreen3"))
483 (:foreground "red4"))
485 (:bold t :italic t)))
486 "Face used for displaying subject headers."
487 :group 'gnus-article-headers
488 :group 'gnus-article-highlight)
490 (defface gnus-header-newsgroups-face
493 (:foreground "yellow" :italic t))
496 (:foreground "MidnightBlue" :italic t))
499 "Face used for displaying newsgroups headers."
500 :group 'gnus-article-headers
501 :group 'gnus-article-highlight)
503 (defface gnus-header-name-face
506 (:foreground "SeaGreen"))
509 (:foreground "maroon"))
512 "Face used for displaying header names."
513 :group 'gnus-article-headers
514 :group 'gnus-article-highlight)
516 (defface gnus-header-content-face
519 (:foreground "forest green" :italic t))
522 (:foreground "indianred4" :italic t))
524 (:italic t))) "Face used for displaying header content."
525 :group 'gnus-article-headers
526 :group 'gnus-article-highlight)
528 (defcustom gnus-header-face-alist
529 '(("From" nil gnus-header-from-face)
530 ("Subject" nil gnus-header-subject-face)
531 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
532 ("" gnus-header-name-face gnus-header-content-face))
533 "*Controls highlighting of article header.
535 An alist of the form (HEADER NAME CONTENT).
537 HEADER is a regular expression which should match the name of an
538 header header and NAME and CONTENT are either face names or nil.
540 The name of each header field will be displayed using the face
541 specified by the first element in the list where HEADER match the
542 header name and NAME is non-nil. Similarly, the content will be
543 displayed by the first non-nil matching CONTENT face."
544 :group 'gnus-article-headers
545 :group 'gnus-article-highlight
546 :type '(repeat (list (regexp :tag "Header")
548 (item :tag "skip" nil)
549 (face :value default))
550 (choice :tag "Content"
551 (item :tag "skip" nil)
552 (face :value default)))))
554 (defcustom gnus-article-decode-hook nil
555 "*Hook run to decode charsets in articles."
556 :group 'gnus-article-headers
559 (defcustom gnus-display-mime-function 'gnus-display-mime
560 "Function to display MIME articles."
561 :group 'gnus-article-headers
564 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
565 "Function used to decode headers.")
567 (defvar gnus-article-dumbquotes-map
585 "Table for MS-to-Latin1 translation.")
587 ;;; Internal variables
589 (defvar gnus-article-mime-handle-alist nil)
590 (defvar article-lapsed-timer nil)
591 (defvar gnus-article-current-summary nil)
593 (defvar gnus-article-mode-syntax-table
594 (let ((table (copy-syntax-table text-mode-syntax-table)))
595 (modify-syntax-entry ?- "w" table)
596 (modify-syntax-entry ?> ")" table)
597 (modify-syntax-entry ?< "(" table)
599 "Syntax table used in article mode buffers.
600 Initialized from `text-mode-syntax-table.")
602 (defvar gnus-save-article-buffer nil)
604 (defvar gnus-article-mode-line-format-alist
605 (nconc '((?w (gnus-article-wash-status) ?s))
606 gnus-summary-mode-line-format-alist))
608 (defvar gnus-number-of-articles-to-be-saved nil)
610 (defvar gnus-inhibit-hiding nil)
612 (defsubst gnus-article-hide-text (b e props)
613 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
614 (add-text-properties b e props)
615 (when (memq 'intangible props)
617 (max (1- b) (point-min))
618 b 'intangible (cddr (memq 'intangible props)))))
620 (defsubst gnus-article-unhide-text (b e)
621 "Remove hidden text properties from region between B and E."
622 (remove-text-properties b e gnus-hidden-properties)
623 (when (memq 'intangible gnus-hidden-properties)
624 (put-text-property (max (1- b) (point-min))
627 (defun gnus-article-hide-text-type (b e type)
628 "Hide text of TYPE between B and E."
629 (gnus-article-hide-text
630 b e (cons 'article-type (cons type gnus-hidden-properties))))
632 (defun gnus-article-unhide-text-type (b e type)
633 "Unhide text of TYPE between B and E."
634 (remove-text-properties
635 b e (cons 'article-type (cons type gnus-hidden-properties)))
636 (when (memq 'intangible gnus-hidden-properties)
637 (put-text-property (max (1- b) (point-min))
640 (defun gnus-article-hide-text-of-type (type)
641 "Hide text of TYPE in the current buffer."
643 (let ((b (point-min))
645 (while (setq b (text-property-any b e 'article-type type))
646 (add-text-properties b (incf b) gnus-hidden-properties)))))
648 (defun gnus-article-delete-text-of-type (type)
649 "Delete text of TYPE in the current buffer."
651 (let ((b (point-min)))
652 (while (setq b (text-property-any b (point-max) 'article-type type))
654 b (or (text-property-not-all b (point-max) 'article-type type)
657 (defun gnus-article-delete-invisible-text ()
658 "Delete all invisible text in the current buffer."
660 (let ((b (point-min)))
661 (while (setq b (text-property-any b (point-max) 'invisible t))
663 b (or (text-property-not-all b (point-max) 'invisible t)
666 (defun gnus-article-text-type-exists-p (type)
667 "Say whether any text of type TYPE exists in the buffer."
668 (text-property-any (point-min) (point-max) 'article-type type))
670 (defsubst gnus-article-header-rank ()
671 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
672 (let ((list gnus-sorted-header-list)
675 (when (looking-at (car list))
677 (setq list (cdr list))
681 (defun article-hide-headers (&optional arg delete)
682 "Toggle whether to hide unwanted headers and possibly sort them as well.
683 If given a negative prefix, always show; if given a positive prefix,
685 (interactive (gnus-article-hidden-arg))
687 (if (gnus-article-check-hidden-text 'headers arg)
688 ;; Show boring headers as well.
689 (gnus-article-show-hidden-text 'boring-headers)
690 ;; This function might be inhibited.
691 (unless gnus-inhibit-hiding
694 (let ((buffer-read-only nil)
696 (props (nconc (list 'article-type 'headers)
697 gnus-hidden-properties))
698 (max (1+ (length gnus-sorted-header-list)))
699 (ignored (when (not gnus-visible-headers)
700 (cond ((stringp gnus-ignored-headers)
701 gnus-ignored-headers)
702 ((listp gnus-ignored-headers)
703 (mapconcat 'identity gnus-ignored-headers
706 (cond ((stringp gnus-visible-headers)
707 gnus-visible-headers)
708 ((and gnus-visible-headers
709 (listp gnus-visible-headers))
710 (mapconcat 'identity gnus-visible-headers "\\|"))))
711 (inhibit-point-motion-hooks t)
713 ;; First we narrow to just the headers.
715 (goto-char (point-min))
716 ;; Hide any "From " lines at the beginning of (mail) articles.
717 (while (looking-at "From ")
721 (delete-region (point-min) (point))
722 (gnus-article-hide-text (point-min) (point) props)))
723 ;; Then treat the rest of the header lines.
726 (if (search-forward "\n\n" nil t) ; if there's a body
727 (progn (forward-line -1) (point))
729 ;; Then we use the two regular expressions
730 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
731 ;; select which header lines is to remain visible in the
733 (goto-char (point-min))
734 (while (re-search-forward "^[^ \t]*:" nil t)
736 ;; Mark the rank of the header.
738 (point) (1+ (point)) 'message-rank
739 (if (or (and visible (looking-at visible))
741 (not (looking-at ignored))))
742 (gnus-article-header-rank)
745 (message-sort-headers-1)
746 (when (setq beg (text-property-any
747 (point-min) (point-max) 'message-rank (+ 2 max)))
748 ;; We make the unwanted headers invisible.
750 (delete-region beg (point-max))
751 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
752 (gnus-article-hide-text-type beg (point-max) 'headers))
753 ;; Work around XEmacs lossage.
754 (put-text-property (point-min) beg 'invisible nil))))))))
756 (defun article-hide-boring-headers (&optional arg)
757 "Toggle hiding of headers that aren't very interesting.
758 If given a negative prefix, always show; if given a positive prefix,
760 (interactive (gnus-article-hidden-arg))
761 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
762 (not gnus-show-all-headers))
765 (let ((buffer-read-only nil)
766 (list gnus-boring-article-headers)
767 (inhibit-point-motion-hooks t)
769 (nnheader-narrow-to-headers)
771 (setq elem (pop list))
772 (goto-char (point-min))
774 ;; Hide empty headers.
776 (while (re-search-forward "^[^:]+:[ \t]*\n[^ \t]" nil t)
778 (gnus-article-hide-text-type
779 (progn (beginning-of-line) (point))
782 (if (re-search-forward "^[^ \t]" nil t)
786 ;; Hide boring Newsgroups header.
787 ((eq elem 'newsgroups)
788 (when (equal (gnus-fetch-field "newsgroups")
789 (gnus-group-real-name
790 (if (boundp 'gnus-newsgroup-name)
793 (gnus-article-hide-header "newsgroups")))
794 ((eq elem 'followup-to)
795 (when (equal (message-fetch-field "followup-to")
796 (message-fetch-field "newsgroups"))
797 (gnus-article-hide-header "followup-to")))
799 (let ((from (message-fetch-field "from"))
800 (reply-to (message-fetch-field "reply-to")))
805 (nth 1 (funcall gnus-extract-address-components from))
806 (nth 1 (funcall gnus-extract-address-components reply-to)))))
807 (gnus-article-hide-header "reply-to"))))
809 (let ((date (message-fetch-field "date")))
811 (< (days-between (current-time-string) date)
813 (gnus-article-hide-header "date"))))
815 (let ((to (message-fetch-field "to")))
816 (when (> (length to) 1024)
817 (gnus-article-hide-header "to"))))
820 (goto-char (point-min))
821 (while (re-search-forward "^to:" nil t)
822 (setq to-count (1+ to-count)))
824 (while (> to-count 0)
825 (goto-char (point-min))
827 (re-search-forward "^to:" nil nil to-count)
829 (narrow-to-region (point) (point-max))
830 (gnus-article-hide-header "to"))
831 (setq to-count (1- to-count)))))))))))))
833 (defun gnus-article-hide-header (header)
835 (goto-char (point-min))
836 (when (re-search-forward (concat "^" header ":") nil t)
837 (gnus-article-hide-text-type
838 (progn (beginning-of-line) (point))
841 (if (re-search-forward "^[^ \t]" nil t)
846 (defun article-treat-dumbquotes ()
847 "Translate M******** sm*rtq**t*s into proper text."
849 (article-translate-strings gnus-article-dumbquotes-map))
851 (defun article-translate-characters (from to)
852 "Translate all characters in the body of the article according to FROM and TO.
853 FROM is a string of characters to translate from; to is a string of
854 characters to translate to."
856 (goto-char (point-min))
857 (when (search-forward "\n\n" nil t)
858 (let ((buffer-read-only nil)
859 (x (make-string 225 ?x))
861 (while (< (incf i) (length x))
864 (while (< i (length from))
865 (aset x (aref from i) (aref to i))
867 (translate-region (point) (point-max) x)))))
869 (defun article-translate-strings (map)
870 "Translate all string in the body of the article according to MAP.
871 MAP is an alist where the elements are on the form (\"from\" \"to\")."
873 (goto-char (point-min))
874 (when (search-forward "\n\n" nil t)
875 (let ((buffer-read-only nil)
877 (while (setq elem (pop map))
879 (while (search-forward (car elem) nil t)
880 (replace-match (cadr elem)))))))))
882 (defun article-treat-overstrike ()
883 "Translate overstrikes into bold text."
886 (goto-char (point-min))
887 (when (search-forward "\n\n" nil t)
888 (let ((buffer-read-only nil))
889 (while (search-forward "\b" nil t)
890 (let ((next (following-char))
891 (previous (char-after (- (point) 2))))
892 ;; We do the boldification/underlining by hiding the
893 ;; overstrikes and putting the proper text property
897 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
898 (put-text-property (point) (1+ (point)) 'face 'bold))
900 (gnus-article-hide-text-type
901 (1- (point)) (1+ (point)) 'overstrike)
903 (- (point) 2) (1- (point)) 'face 'underline))
905 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
907 (point) (1+ (point)) 'face 'underline)))))))))
909 (defun article-fill ()
910 "Format too long lines."
913 (let ((buffer-read-only nil))
915 (goto-char (point-min))
916 (search-forward "\n\n" nil t)
918 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
919 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
920 (adaptive-fill-mode t))
922 (and (>= (current-column) (min fill-column (window-width)))
923 (/= (preceding-char) ?:)
924 (fill-paragraph nil))
927 (defun article-remove-cr ()
928 "Remove carriage returns from an article."
931 (let ((buffer-read-only nil))
932 (goto-char (point-min))
933 (while (search-forward "\r" nil t)
934 (replace-match "" t t)))))
936 (defun article-remove-trailing-blank-lines ()
937 "Remove all trailing blank lines from the article."
940 (let ((buffer-read-only nil))
941 (goto-char (point-max))
945 (while (and (not (bobp))
946 (looking-at "^[ \t]*$")
947 (not (gnus-annotation-in-region-p
948 (point) (gnus-point-at-eol))))
953 (defun article-display-x-face (&optional force)
954 "Look for an X-Face header and display it if present."
955 (interactive (list 'force))
957 ;; Delete the old process, if any.
958 (when (process-status "article-x-face")
959 (delete-process "article-x-face"))
960 (let ((inhibit-point-motion-hooks t)
964 (nnheader-narrow-to-headers)
965 (setq from (message-fetch-field "from"))
966 (goto-char (point-min))
967 (while (and gnus-article-x-face-command
970 ;; Check whether this face is censored.
971 (not gnus-article-x-face-too-ugly)
972 (and gnus-article-x-face-too-ugly from
973 (not (string-match gnus-article-x-face-too-ugly
975 ;; Has to be present.
976 (re-search-forward "^X-Face: " nil t))
977 ;; This used to try to do multiple faces (`while' instead of
978 ;; `when' above), but (a) sending multiple EOFs to xv doesn't
979 ;; work (b) it can crash some versions of Emacs (c) are
980 ;; multiple faces really something to encourage?
981 (when (stringp gnus-article-x-face-command)
983 ;; We now have the area of the buffer where the X-Face is stored.
986 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
987 ;; We display the face.
988 (if (symbolp gnus-article-x-face-command)
989 ;; The command is a lisp function, so we call it.
990 (if (gnus-functionp gnus-article-x-face-command)
991 (funcall gnus-article-x-face-command beg end)
992 (error "%s is not a function" gnus-article-x-face-command))
993 ;; The command is a string, so we interpret the command
994 ;; as a, well, command, and fork it off.
995 (let ((process-connection-type nil))
996 (process-kill-without-query
998 "article-x-face" nil shell-file-name shell-command-switch
999 gnus-article-x-face-command))
1000 (process-send-region "article-x-face" beg end)
1001 (process-send-eof "article-x-face"))))))))))
1003 (defun article-decode-mime-words ()
1004 "Decode all MIME-encoded words in the article."
1007 (set-buffer gnus-article-buffer)
1008 (let ((inhibit-point-motion-hooks t)
1010 (mail-decode-encoded-word-region (point-min) (point-max)))))
1012 (defun article-decode-charset (&optional prompt)
1013 "Decode charset-encoded text in the article.
1014 If PROMPT (the prefix), prompt for a coding system to use."
1018 (message-narrow-to-head)
1019 (let* ((inhibit-point-motion-hooks t)
1020 (case-fold-search t)
1021 (ct (message-fetch-field "Content-Type" t))
1022 (cte (message-fetch-field "Content-Transfer-Encoding" t))
1023 (ctl (and ct (condition-case ()
1024 (mail-header-parse-content-type ct)
1028 (mm-read-coding-system "Charset to decode: "))
1030 (mail-content-type-get ctl 'charset))
1031 (gnus-newsgroup-name
1032 (gnus-group-find-parameter
1033 gnus-newsgroup-name 'charset))))
1035 (goto-char (point-max))
1038 (narrow-to-region (point) (point-max))
1040 (equal (car ctl) "text/plain"))
1042 charset (and cte (intern (downcase
1043 (gnus-strip-whitespace cte))))))))))
1045 (defun article-decode-encoded-words ()
1046 "Remove encoded-word encoding from headers."
1047 (let (buffer-read-only)
1048 (let ((charset (save-excursion
1049 (set-buffer gnus-summary-buffer)
1050 default-mime-charset)))
1051 (eword-decode-header charset)
1054 (defun article-de-quoted-unreadable (&optional force)
1055 "Translate a quoted-printable-encoded article.
1056 If FORCE, decode the article whether it is marked as quoted-printable
1058 (interactive (list 'force))
1060 (let ((buffer-read-only nil)
1061 (type (gnus-fetch-field "content-transfer-encoding")))
1063 (and type (string-match "quoted-printable" (downcase type))))
1064 (goto-char (point-min))
1065 (search-forward "\n\n" nil 'move)
1066 (quoted-printable-decode-region (point) (point-max))
1067 (when mm-default-coding-system
1068 (mm-decode-body mm-default-coding-system))))))
1070 (defun article-mime-decode-quoted-printable-buffer ()
1071 "Decode Quoted-Printable in the current buffer."
1072 (quoted-printable-decode-region (point-min) (point-max)))
1074 (defun article-hide-pgp (&optional arg)
1075 "Toggle hiding of any PGP headers and signatures in the current article.
1076 If given a negative prefix, always show; if given a positive prefix,
1078 (interactive (gnus-article-hidden-arg))
1079 (unless (gnus-article-check-hidden-text 'pgp arg)
1081 (let ((inhibit-point-motion-hooks t)
1082 buffer-read-only beg end)
1084 (goto-char (point-min))
1085 ;; Hide the "header".
1086 (when (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
1087 (delete-region (1+ (match-beginning 0)) (match-end 0))
1088 ;; PGP 5 and GNU PG add a `Hash: <>' comment, hide that too
1089 (when (looking-at "Hash:.*$")
1090 (delete-region (point) (1+ (gnus-point-at-eol))))
1092 ;; Hide the actual signature.
1093 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
1094 (setq end (1+ (match-beginning 0)))
1097 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
1099 ;; Perhaps we shouldn't hide to the end of the buffer
1100 ;; if there is no end to the signature?
1102 ;; Hide "- " PGP quotation markers.
1104 (narrow-to-region beg end)
1105 (goto-char (point-min))
1106 (while (re-search-forward "^- " nil t)
1108 (match-beginning 0) (match-end 0)))
1110 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
1112 (defun article-hide-pem (&optional arg)
1113 "Toggle hiding of any PEM headers and signatures in the current article.
1114 If given a negative prefix, always show; if given a positive prefix,
1116 (interactive (gnus-article-hidden-arg))
1117 (unless (gnus-article-check-hidden-text 'pem arg)
1119 (let (buffer-read-only end)
1121 (goto-char (point-min))
1122 ;; hide the horrendously ugly "header".
1123 (and (search-forward "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
1126 (setq end (1+ (match-beginning 0)))
1127 (gnus-article-hide-text-type
1129 (if (search-forward "\n\n" nil t)
1133 ;; hide the trailer as well
1134 (and (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
1137 (gnus-article-hide-text-type
1138 (match-beginning 0) (match-end 0) 'pem))))))
1140 (defun article-hide-signature (&optional arg)
1141 "Hide the signature in the current article.
1142 If given a negative prefix, always show; if given a positive prefix,
1144 (interactive (gnus-article-hidden-arg))
1145 (unless (gnus-article-check-hidden-text 'signature arg)
1148 (let ((buffer-read-only nil))
1149 (when (gnus-article-narrow-to-signature)
1150 (gnus-article-hide-text-type
1151 (point-min) (point-max) 'signature)))))))
1153 (defun article-strip-leading-blank-lines ()
1154 "Remove all blank lines from the beginning of the article."
1157 (let ((inhibit-point-motion-hooks t)
1159 (goto-char (point-min))
1160 (when (search-forward "\n\n" nil t)
1161 (while (and (not (eobp))
1162 (looking-at "[ \t]*$"))
1163 (gnus-delete-line))))))
1165 (defun article-strip-multiple-blank-lines ()
1166 "Replace consecutive blank lines with one empty line."
1169 (let ((inhibit-point-motion-hooks t)
1171 ;; First make all blank lines empty.
1172 (goto-char (point-min))
1173 (search-forward "\n\n" nil t)
1174 (while (re-search-forward "^[ \t]+$" nil t)
1175 (unless (gnus-annotation-in-region-p
1176 (match-beginning 0) (match-end 0))
1177 (replace-match "" nil t)))
1178 ;; Then replace multiple empty lines with a single empty line.
1179 (goto-char (point-min))
1180 (search-forward "\n\n" nil t)
1181 (while (re-search-forward "\n\n\n+" nil t)
1182 (unless (gnus-annotation-in-region-p
1183 (match-beginning 0) (match-end 0))
1184 (replace-match "\n\n" t t))))))
1186 (defun article-strip-leading-space ()
1187 "Remove all white space from the beginning of the lines in the article."
1190 (let ((inhibit-point-motion-hooks t)
1192 (goto-char (point-min))
1193 (search-forward "\n\n" nil t)
1194 (while (re-search-forward "^[ \t]+" nil t)
1195 (replace-match "" t t)))))
1197 (defun article-strip-blank-lines ()
1198 "Strip leading, trailing and multiple blank lines."
1200 (article-strip-leading-blank-lines)
1201 (article-remove-trailing-blank-lines)
1202 (article-strip-multiple-blank-lines))
1204 (defun article-strip-all-blank-lines ()
1205 "Strip all blank lines."
1208 (let ((inhibit-point-motion-hooks t)
1210 (goto-char (point-min))
1211 (search-forward "\n\n" nil t)
1212 (while (re-search-forward "^[ \t]*\n" nil t)
1213 (replace-match "" t t)))))
1215 (defun gnus-article-narrow-to-signature ()
1216 "Narrow to the signature; return t if a signature is found, else nil."
1218 (let ((inhibit-point-motion-hooks t))
1219 (when (gnus-article-search-signature)
1221 ;; Check whether we have some limits to what we consider
1222 ;; to be a signature.
1223 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
1224 (list gnus-signature-limit)))
1226 (while (setq limit (pop limits))
1227 (if (or (and (integerp limit)
1228 (< (- (point-max) (point)) limit))
1230 (< (count-lines (point) (point-max)) limit))
1231 (and (gnus-functionp limit)
1233 (and (stringp limit)
1234 (not (re-search-forward limit nil t))))
1235 () ; This limit did not succeed.
1239 (narrow-to-region (point) (point-max))
1242 (defun gnus-article-search-signature ()
1243 "Search the current buffer for the signature separator.
1244 Put point at the beginning of the signature separator."
1245 (let ((cur (point)))
1246 (goto-char (point-max))
1247 (if (if (stringp gnus-signature-separator)
1248 (re-search-backward gnus-signature-separator nil t)
1249 (let ((seps gnus-signature-separator))
1251 (not (re-search-backward (car seps) nil t)))
1259 (autoload 'w3-display "w3-parse")
1260 (autoload 'w3-do-setup "w3" "" t)
1261 (autoload 'w3-region "w3-display" "" t))
1263 (defun gnus-article-treat-html ()
1266 (let ((cbuf (current-buffer)))
1267 (set-buffer gnus-article-buffer)
1268 (let (buf buffer-read-only b e)
1270 (goto-char (point-min))
1272 (if (search-forward "\n\n" nil t)
1275 (setq e (point-max)))
1277 (insert-buffer-substring gnus-article-buffer b e)
1279 (save-window-excursion
1280 (w3-region (point-min) (point-max))
1281 (setq buf (buffer-substring-no-properties (point-min) (point-max)))))
1283 (delete-region (point-min) (point-max))
1286 (goto-char (point-min))
1287 (set-window-start (get-buffer-window (current-buffer)) (point-min))
1288 (set-buffer cbuf))))
1290 (defun gnus-article-hidden-arg ()
1291 "Return the current prefix arg as a number, or 0 if no prefix."
1292 (list (if current-prefix-arg
1293 (prefix-numeric-value current-prefix-arg)
1296 (defun gnus-article-check-hidden-text (type arg)
1297 "Return nil if hiding is necessary.
1298 Arg can be nil or a number. Nil and positive means hide, negative
1299 means show, 0 means toggle."
1303 (let ((hide (gnus-article-hidden-text-p type)))
1309 (gnus-article-show-hidden-text type))
1311 (if (eq hide 'hidden)
1312 (gnus-article-show-hidden-text type)
1315 (defun gnus-article-hidden-text-p (type)
1316 "Say whether the current buffer contains hidden text of type TYPE."
1317 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
1319 (not (get-text-property pos 'invisible)))
1321 (text-property-any (1+ pos) (point-max) 'article-type type)))
1326 (defun gnus-article-show-hidden-text (type &optional hide)
1327 "Show all hidden text of type TYPE.
1328 If HIDE, hide the text instead."
1330 (let ((buffer-read-only nil)
1331 (inhibit-point-motion-hooks t)
1334 (while (setq beg (text-property-any end (point-max) 'article-type type))
1337 (text-property-not-all beg (point-max) 'article-type type)
1340 (gnus-article-hide-text beg end gnus-hidden-properties)
1341 (gnus-article-unhide-text beg end))
1345 (defconst article-time-units
1346 `((year . ,(* 365.25 24 60 60))
1347 (week . ,(* 7 24 60 60))
1348 (day . ,(* 24 60 60))
1352 "Mapping from time units to seconds.")
1354 (defun article-date-ut (&optional type highlight header)
1355 "Convert DATE date to universal time in the current article.
1356 If TYPE is `local', convert to local time; if it is `lapsed', output
1357 how much time has lapsed since DATE."
1358 (interactive (list 'ut t))
1359 (let* ((header (or header
1360 (mail-header-date gnus-current-headers)
1361 (message-fetch-field "date")
1363 (date (if (vectorp header) (mail-header-date header)
1365 (date-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
1366 (inhibit-point-motion-hooks t)
1367 bface eface newline)
1368 (when (and date (not (string= date "")))
1371 (nnheader-narrow-to-headers)
1372 (let ((buffer-read-only nil))
1373 ;; Delete any old Date headers.
1374 (if (re-search-forward date-regexp nil t)
1376 (setq bface (get-text-property (gnus-point-at-bol) 'face)
1377 eface (get-text-property (1- (gnus-point-at-eol))
1379 (delete-region (progn (beginning-of-line) (point))
1380 (progn (end-of-line) (point)))
1381 (beginning-of-line))
1382 (goto-char (point-max))
1384 (insert (article-make-date-line date type))
1387 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
1388 (put-text-property (match-beginning 1) (1+ (match-end 1))
1390 (put-text-property (match-beginning 2) (match-end 2)
1394 (insert "\n"))))))))
1396 (defun article-make-date-line (date type)
1397 "Return a DATE line of TYPE."
1398 (let ((time (condition-case ()
1402 ;; Convert to the local timezone. We have to slap a
1403 ;; `condition-case' round the calls to the timezone
1404 ;; functions since they aren't particularly resistant to
1407 (let ((tz (car (current-time-zone))))
1408 (format "Date: %s %s%04d" (current-time-string time)
1409 (if (> tz 0) "+" "-") (abs (/ tz 36)))))
1410 ;; Convert to Universal Time.
1413 (current-time-string
1414 (let* ((e (parse-time-string date))
1415 (tm (apply 'encode-time e))
1417 (ls (- (cadr tm) (car (current-time-zone)))))
1418 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
1419 ((> ls 65535) (list (1+ ms) (- ls 65536)))
1422 ;; Get the original date from the article.
1423 ((eq type 'original)
1424 (concat "Date: " (if (string-match "\n+$" date)
1425 (substring date 0 (match-beginning 0))
1427 ;; Let the user define the format.
1429 (if (gnus-functionp gnus-article-time-format)
1430 (funcall gnus-article-time-format time)
1433 (format-time-string gnus-article-time-format time))))
1438 (format-time-string "%Y%M%DT%h%m%s" time)))
1439 ;; Do an X-Sent lapsed format.
1441 ;; If the date is seriously mangled, the timezone functions are
1442 ;; liable to bug out, so we ignore all errors.
1443 (let* ((now (current-time))
1444 (real-time (subtract-time now time))
1445 (real-sec (and real-time
1446 (+ (* (float (car real-time)) 65536)
1448 (sec (and real-time (abs real-sec)))
1458 ;; This is a bit convoluted, but basically we go
1459 ;; through the time units for years, weeks, etc,
1460 ;; and divide things to see whether that results
1461 ;; in positive answers.
1464 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
1465 ;; The (remaining) seconds are too few to
1466 ;; be divided into this time unit.
1468 ;; It's big enough, so we output it.
1469 (setq sec (- sec (* num (cdr unit))))
1471 (concat (if prev ", " "") (int-to-string
1473 " " (symbol-name (car unit))
1474 (if (> num 1) "s" ""))
1476 article-time-units "")
1477 ;; If dates are odd, then it might appear like the
1478 ;; article was sent in the future.
1481 " in the future"))))))
1483 (error "Unknown conversion type: %s" type)))))
1485 (defun article-date-local (&optional highlight)
1486 "Convert the current article date to the local timezone."
1487 (interactive (list t))
1488 (article-date-ut 'local highlight))
1490 (defun article-date-original (&optional highlight)
1491 "Convert the current article date to what it was originally.
1492 This is only useful if you have used some other date conversion
1493 function and want to see what the date was before converting."
1494 (interactive (list t))
1495 (article-date-ut 'original highlight))
1497 (defun article-date-lapsed (&optional highlight)
1498 "Convert the current article date to time lapsed since it was sent."
1499 (interactive (list t))
1500 (article-date-ut 'lapsed highlight))
1502 (defun article-update-date-lapsed ()
1503 "Function to be run from a timer to update the lapsed time line."
1504 (let (deactivate-mark)
1509 (set-buffer (window-buffer w))
1510 (when (eq major-mode 'gnus-article-mode)
1511 (goto-char (point-min))
1512 (when (re-search-forward "^X-Sent:" nil t)
1513 (article-date-lapsed t)))))))))
1515 (defun gnus-start-date-timer (&optional n)
1516 "Start a timer to update the X-Sent header in the article buffers.
1517 The numerical prefix says how frequently (in seconds) the function
1522 (gnus-stop-date-timer)
1523 (setq article-lapsed-timer
1524 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
1526 (defun gnus-stop-date-timer ()
1527 "Stop the X-Sent timer."
1529 (when article-lapsed-timer
1530 (nnheader-cancel-timer article-lapsed-timer)
1531 (setq article-lapsed-timer nil)))
1533 (defun article-date-user (&optional highlight)
1534 "Convert the current article date to the user-defined format.
1535 This format is defined by the `gnus-article-time-format' variable."
1536 (interactive (list t))
1537 (article-date-ut 'user highlight))
1539 (defun article-date-iso8601 (&optional highlight)
1540 "Convert the current article date to ISO8601."
1541 (interactive (list t))
1542 (article-date-ut 'iso8601 highlight))
1544 (defun article-show-all ()
1545 "Show all hidden text in the article buffer."
1548 (let ((buffer-read-only nil))
1549 (gnus-article-unhide-text (point-min) (point-max)))))
1551 (defun article-emphasize (&optional arg)
1552 "Emphasize text according to `gnus-emphasis-alist'."
1553 (interactive (gnus-article-hidden-arg))
1554 (unless (gnus-article-check-hidden-text 'emphasis arg)
1556 (let ((alist gnus-emphasis-alist)
1557 (buffer-read-only nil)
1558 (props (append '(article-type emphasis)
1559 gnus-hidden-properties))
1560 regexp elem beg invisible visible face)
1561 (goto-char (point-min))
1562 (search-forward "\n\n" nil t)
1564 (while (setq elem (pop alist))
1566 (setq regexp (car elem)
1567 invisible (nth 1 elem)
1568 visible (nth 2 elem)
1570 (while (re-search-forward regexp nil t)
1571 (when (and (match-beginning visible) (match-beginning invisible))
1572 (gnus-article-hide-text
1573 (match-beginning invisible) (match-end invisible) props)
1574 (gnus-article-unhide-text-type
1575 (match-beginning visible) (match-end visible) 'emphasis)
1576 (gnus-put-text-property-excluding-newlines
1577 (match-beginning visible) (match-end visible) 'face face)
1578 (goto-char (match-end invisible)))))))))
1580 (defvar gnus-summary-article-menu)
1581 (defvar gnus-summary-post-menu)
1583 ;;; Saving functions.
1585 (defun gnus-article-save (save-buffer file &optional num)
1586 "Save the currently selected article."
1587 (unless gnus-save-all-headers
1588 ;; Remove headers according to `gnus-saved-headers'.
1589 (let ((gnus-visible-headers
1590 (or gnus-saved-headers gnus-visible-headers))
1591 (gnus-article-buffer save-buffer))
1593 (set-buffer save-buffer)
1594 (article-hide-headers 1 t))))
1595 (save-window-excursion
1596 (if (not gnus-default-article-saver)
1597 (error "No default saver is defined")
1598 ;; !!! Magic! The saving functions all save
1599 ;; `gnus-save-article-buffer' (or so they think), but we
1600 ;; bind that variable to our save-buffer.
1601 (set-buffer gnus-article-buffer)
1602 (let* ((gnus-save-article-buffer save-buffer)
1605 ((not gnus-prompt-before-saving) 'default)
1606 ((eq gnus-prompt-before-saving 'always) nil)
1608 (gnus-number-of-articles-to-be-saved
1609 (when (eq gnus-prompt-before-saving t)
1611 (set-buffer gnus-article-current-summary)
1612 (funcall gnus-default-article-saver filename)))))
1614 (defun gnus-read-save-file-name (prompt &optional filename
1615 function group headers variable)
1617 (funcall function group headers (symbol-value variable)))
1622 ((eq filename 'default)
1628 (let* ((split-name (gnus-get-split-value gnus-split-methods))
1631 (if (and gnus-number-of-articles-to-be-saved
1632 (> gnus-number-of-articles-to-be-saved 1))
1633 (format "these %d articles"
1634 gnus-number-of-articles-to-be-saved)
1637 ;; Let the split methods have their say.
1639 ;; No split name was found.
1642 (concat prompt " (default "
1643 (file-name-nondirectory default-name) ") ")
1644 (file-name-directory default-name)
1646 ;; A single group name is returned.
1647 ((stringp split-name)
1649 (funcall function split-name headers
1650 (symbol-value variable)))
1652 (concat prompt " (default "
1653 (file-name-nondirectory default-name) ") ")
1654 (file-name-directory default-name)
1656 ;; A single split name was found
1657 ((= 1 (length split-name))
1658 (let* ((name (expand-file-name
1659 (car split-name) gnus-article-save-directory))
1660 (dir (cond ((file-directory-p name)
1661 (file-name-as-directory name))
1662 ((file-exists-p name) name)
1663 (t gnus-article-save-directory))))
1665 (concat prompt " (default " name ") ")
1667 ;; A list of splits was found.
1669 (setq split-name (nreverse split-name))
1671 (let ((file-name-history
1672 (nconc split-name file-name-history)))
1676 (concat prompt " (`M-p' for defaults) ")
1677 gnus-article-save-directory
1679 gnus-article-save-directory)))
1680 (car (push result file-name-history)))))))
1681 ;; Create the directory.
1682 (gnus-make-directory (file-name-directory file))
1683 ;; If we have read a directory, we append the default file name.
1684 (when (file-directory-p file)
1685 (setq file (concat (file-name-as-directory file)
1686 (file-name-nondirectory default-name))))
1687 ;; Possibly translate some characters.
1688 (nnheader-translate-file-chars file)))))
1689 (gnus-make-directory (file-name-directory result))
1690 (set variable result)))
1692 (defun gnus-article-archive-name (group)
1693 "Return the first instance of an \"Archive-name\" in the current buffer."
1694 (let ((case-fold-search t))
1695 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
1696 (nnheader-concat gnus-article-save-directory
1697 (match-string 1)))))
1699 (defun gnus-article-nndoc-name (group)
1700 "If GROUP is an nndoc group, return the name of the parent group."
1701 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
1702 (gnus-group-get-parameter group 'save-article-group)))
1704 (defun gnus-summary-save-in-rmail (&optional filename)
1705 "Append this article to Rmail file.
1706 Optional argument FILENAME specifies file name.
1707 Directory to save to is default to `gnus-article-save-directory'."
1708 (setq filename (gnus-read-save-file-name
1709 "Save %s in rmail file:" filename
1710 gnus-rmail-save-name gnus-newsgroup-name
1711 gnus-current-headers 'gnus-newsgroup-last-rmail))
1712 (gnus-eval-in-buffer-window gnus-save-article-buffer
1716 (rmail-output-to-rmail-file filename))))
1719 (defun gnus-summary-save-in-mail (&optional filename)
1720 "Append this article to Unix mail file.
1721 Optional argument FILENAME specifies file name.
1722 Directory to save to is default to `gnus-article-save-directory'."
1723 (setq filename (gnus-read-save-file-name
1724 "Save %s in Unix mail file:" filename
1725 gnus-mail-save-name gnus-newsgroup-name
1726 gnus-current-headers 'gnus-newsgroup-last-mail))
1727 (gnus-eval-in-buffer-window gnus-save-article-buffer
1731 (if (and (file-readable-p filename)
1732 (mail-file-babyl-p filename))
1733 (rmail-output-to-rmail-file filename t)
1734 (gnus-output-to-mail filename)))))
1737 (defun gnus-summary-save-in-file (&optional filename overwrite)
1738 "Append this article to file.
1739 Optional argument FILENAME specifies file name.
1740 Directory to save to is default to `gnus-article-save-directory'."
1741 (setq filename (gnus-read-save-file-name
1742 "Save %s in file:" filename
1743 gnus-file-save-name gnus-newsgroup-name
1744 gnus-current-headers 'gnus-newsgroup-last-file))
1745 (gnus-eval-in-buffer-window gnus-save-article-buffer
1749 (when (and overwrite
1750 (file-exists-p filename))
1751 (delete-file filename))
1752 (gnus-output-to-file filename))))
1755 (defun gnus-summary-write-to-file (&optional filename)
1756 "Write this article to a file.
1757 Optional argument FILENAME specifies file name.
1758 The directory to save in defaults to `gnus-article-save-directory'."
1759 (gnus-summary-save-in-file nil t))
1761 (defun gnus-summary-save-body-in-file (&optional filename)
1762 "Append this article body to a file.
1763 Optional argument FILENAME specifies file name.
1764 The directory to save in defaults to `gnus-article-save-directory'."
1765 (setq filename (gnus-read-save-file-name
1766 "Save %s body in file:" filename
1767 gnus-file-save-name gnus-newsgroup-name
1768 gnus-current-headers 'gnus-newsgroup-last-file))
1769 (gnus-eval-in-buffer-window gnus-save-article-buffer
1773 (goto-char (point-min))
1774 (when (search-forward "\n\n" nil t)
1775 (narrow-to-region (point) (point-max)))
1776 (gnus-output-to-file filename))))
1779 (defun gnus-summary-save-in-pipe (&optional command)
1780 "Pipe this article to subprocess."
1782 (cond ((and (eq command 'default)
1783 gnus-last-shell-command)
1784 gnus-last-shell-command)
1788 "Shell command on %s: "
1789 (if (and gnus-number-of-articles-to-be-saved
1790 (> gnus-number-of-articles-to-be-saved 1))
1791 (format "these %d articles"
1792 gnus-number-of-articles-to-be-saved)
1794 gnus-last-shell-command))))
1795 (when (string-equal command "")
1796 (setq command gnus-last-shell-command))
1797 (gnus-eval-in-buffer-window gnus-article-buffer
1800 (shell-command-on-region (point-min) (point-max) command nil)))
1801 (setq gnus-last-shell-command command))
1803 ;;; Article file names when saving.
1805 (defun gnus-capitalize-newsgroup (newsgroup)
1806 "Capitalize NEWSGROUP name."
1807 (when (not (zerop (length newsgroup)))
1808 (concat (char-to-string (upcase (aref newsgroup 0)))
1809 (substring newsgroup 1))))
1811 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
1812 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1813 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
1814 Otherwise, it is like ~/News/news/group/num."
1817 (concat (if (gnus-use-long-file-name 'not-save)
1818 (gnus-capitalize-newsgroup newsgroup)
1819 (gnus-newsgroup-directory-form newsgroup))
1820 "/" (int-to-string (mail-header-number headers)))
1821 gnus-article-save-directory)))
1823 (string-equal (file-name-directory default)
1824 (file-name-directory last-file))
1825 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
1827 (or last-file default))))
1829 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
1830 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1831 If variable `gnus-use-long-file-name' is non-nil, it is
1832 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
1835 (concat (if (gnus-use-long-file-name 'not-save)
1837 (gnus-newsgroup-directory-form newsgroup))
1838 "/" (int-to-string (mail-header-number headers)))
1839 gnus-article-save-directory)))
1841 (string-equal (file-name-directory default)
1842 (file-name-directory last-file))
1843 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
1845 (or last-file default))))
1847 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
1848 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1849 If variable `gnus-use-long-file-name' is non-nil, it is
1850 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
1853 (if (gnus-use-long-file-name 'not-save)
1854 (gnus-capitalize-newsgroup newsgroup)
1855 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
1856 gnus-article-save-directory)))
1858 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
1859 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
1860 If variable `gnus-use-long-file-name' is non-nil, it is
1861 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
1864 (if (gnus-use-long-file-name 'not-save)
1866 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
1867 gnus-article-save-directory)))
1874 (setq afunc (car func)
1877 gfunc (intern (format "gnus-%s" func))))
1879 (if (not (fboundp afunc))
1881 `(lambda (&optional interactive &rest args)
1882 ,(documentation afunc t)
1883 (interactive (list t))
1885 (set-buffer gnus-article-buffer)
1887 (call-interactively ',afunc)
1888 (apply ',afunc args))))))))
1889 '(article-hide-headers
1890 article-hide-boring-headers
1891 article-treat-overstrike
1892 (article-fill . gnus-article-word-wrap)
1894 article-display-x-face
1897 article-hide-signature
1898 article-remove-trailing-blank-lines
1899 article-strip-leading-blank-lines
1900 article-strip-multiple-blank-lines
1901 article-strip-leading-space
1902 article-strip-blank-lines
1903 article-strip-all-blank-lines
1905 article-date-iso8601
1906 article-date-original
1911 article-treat-dumbquotes
1912 (article-show-all . gnus-article-show-all-headers))))
1915 ;;; Gnus article mode
1918 (put 'gnus-article-mode 'mode-class 'special)
1920 (gnus-define-keys gnus-article-mode-map
1921 " " gnus-article-goto-next-page
1922 "\177" gnus-article-goto-prev-page
1923 [delete] gnus-article-goto-prev-page
1924 "\C-c^" gnus-article-refer-article
1925 "h" gnus-article-show-summary
1926 "s" gnus-article-show-summary
1927 "\C-c\C-m" gnus-article-mail
1928 "?" gnus-article-describe-briefly
1929 gnus-mouse-2 gnus-article-push-button
1930 "\r" gnus-article-press-button
1931 "\t" gnus-article-next-button
1932 "\M-\t" gnus-article-prev-button
1933 "e" gnus-article-edit
1934 "<" beginning-of-buffer
1936 "\C-c\C-i" gnus-info-find-node
1939 "\C-d" gnus-article-read-summary-keys
1940 "\M-*" gnus-article-read-summary-keys
1941 "\M-#" gnus-article-read-summary-keys
1942 "\M-^" gnus-article-read-summary-keys
1943 "\M-g" gnus-article-read-summary-keys)
1945 (substitute-key-definition
1946 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
1948 (defun gnus-article-make-menu-bar ()
1949 (gnus-turn-off-edit-menu 'article)
1950 (unless (boundp 'gnus-article-article-menu)
1952 gnus-article-article-menu gnus-article-mode-map ""
1954 ["Scroll forwards" gnus-article-goto-next-page t]
1955 ["Scroll backwards" gnus-article-goto-prev-page t]
1956 ["Show summary" gnus-article-show-summary t]
1957 ["Fetch Message-ID at point" gnus-article-refer-article t]
1958 ["Mail to address at point" gnus-article-mail t]
1959 ["Send a bug report" gnus-bug t]))
1962 gnus-article-treatment-menu gnus-article-mode-map ""
1964 ["Hide headers" gnus-article-hide-headers t]
1965 ["Hide signature" gnus-article-hide-signature t]
1966 ["Hide citation" gnus-article-hide-citation t]
1967 ["Treat overstrike" gnus-article-treat-overstrike t]
1968 ["Remove carriage return" gnus-article-remove-cr t]))
1970 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
1972 (when (boundp 'gnus-summary-post-menu)
1973 (define-key gnus-article-mode-map [menu-bar post]
1974 (cons "Post" gnus-summary-post-menu)))
1976 (gnus-run-hooks 'gnus-article-menu-hook)))
1978 (defun gnus-article-mode ()
1979 "Major mode for displaying an article.
1981 All normal editing commands are switched off.
1983 The following commands are available in addition to all summary mode
1985 \\<gnus-article-mode-map>
1986 \\[gnus-article-next-page]\t Scroll the article one page forwards
1987 \\[gnus-article-prev-page]\t Scroll the article one page backwards
1988 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
1989 \\[gnus-article-show-summary]\t Display the summary buffer
1990 \\[gnus-article-mail]\t Send a reply to the address near point
1991 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
1992 \\[gnus-info-find-node]\t Go to the Gnus info node"
1994 (when (gnus-visual-p 'article-menu 'menu)
1995 (gnus-article-make-menu-bar))
1996 (gnus-simplify-mode-line)
1997 (setq mode-name "Article")
1998 (setq major-mode 'gnus-article-mode)
1999 (make-local-variable 'minor-mode-alist)
2000 (unless (assq 'gnus-show-mime minor-mode-alist)
2001 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
2002 (use-local-map gnus-article-mode-map)
2003 (gnus-update-format-specifications nil 'article-mode)
2004 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
2005 (make-local-variable 'gnus-page-broken)
2006 (make-local-variable 'gnus-button-marker-list)
2007 (make-local-variable 'gnus-article-current-summary)
2008 (gnus-set-default-directory)
2009 (buffer-disable-undo)
2010 (setq buffer-read-only t)
2011 (set-syntax-table gnus-article-mode-syntax-table)
2012 (gnus-run-hooks 'gnus-article-mode-hook))
2014 (defun gnus-article-setup-buffer ()
2015 "Initialize the article buffer."
2016 (let* ((name (if gnus-single-article-buffer "*Article*"
2017 (concat "*Article " gnus-newsgroup-name "*")))
2019 (progn (string-match "\\*Article" name)
2020 (concat " *Original Article"
2021 (substring name (match-end 0))))))
2022 (setq gnus-article-buffer name)
2023 (setq gnus-original-article-buffer original)
2024 (setq gnus-article-mime-handle-alist nil)
2025 ;; This might be a variable local to the summary buffer.
2026 (unless gnus-single-article-buffer
2028 (set-buffer gnus-summary-buffer)
2029 (setq gnus-article-buffer name)
2030 (setq gnus-original-article-buffer original)
2031 (gnus-set-global-variables)))
2032 ;; Init original article buffer.
2034 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
2035 (setq major-mode 'gnus-original-article-mode)
2036 (make-local-variable 'gnus-original-article))
2037 (if (get-buffer name)
2040 (buffer-disable-undo)
2041 (setq buffer-read-only t)
2042 (unless (eq major-mode 'gnus-article-mode)
2043 (gnus-article-mode))
2046 (set-buffer (gnus-get-buffer-create name))
2048 (make-local-variable 'gnus-summary-buffer)
2049 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2050 (current-buffer)))))
2052 ;; Set article window start at LINE, where LINE is the number of lines
2053 ;; from the head of the article.
2054 (defun gnus-article-set-window-start (&optional line)
2056 (get-buffer-window gnus-article-buffer t)
2058 (set-buffer gnus-article-buffer)
2059 (goto-char (point-min))
2062 (gnus-message 6 "Moved to bookmark")
2063 (search-forward "\n\n" nil t)
2067 ;;; @@ article filters
2070 (defun gnus-article-display-mime-message ()
2071 "Article display method for MIME message."
2072 ;; called from `gnus-original-article-buffer'.
2073 (let ((default-mime-charset (save-excursion
2074 (set-buffer gnus-summary-buffer)
2075 default-mime-charset)))
2076 (mime-display-message mime-message-structure
2077 gnus-article-buffer nil gnus-article-mode-map))
2078 ;; `mime-display-message' changes current buffer to `gnus-article-buffer'.
2079 (make-local-variable 'mime-button-mother-dispatcher)
2080 (setq mime-button-mother-dispatcher
2081 (function gnus-article-push-button))
2082 (run-hooks 'gnus-mime-article-prepare-hook))
2084 (defun gnus-article-display-traditional-message ()
2085 "Article display method for traditional message."
2086 (set-buffer gnus-article-buffer)
2087 (let (buffer-read-only)
2089 (insert-buffer-substring gnus-original-article-buffer)))
2091 (defun gnus-article-display-message-with-encoded-word ()
2092 "Article display method for message with encoded-words."
2093 (let ((charset (save-excursion
2094 (set-buffer gnus-summary-buffer)
2095 default-mime-charset)))
2096 (gnus-article-display-traditional-message)
2097 (let (buffer-read-only)
2098 (eword-decode-header charset)
2099 (goto-char (point-min))
2100 (if (search-forward "\n\n" nil t)
2101 (decode-mime-charset-region (match-end 0) (point-max) charset)))
2102 (mime-maybe-hide-echo-buffer))
2103 (gnus-run-hooks 'gnus-mime-article-prepare-hook))
2105 (defun gnus-article-prepare (article &optional all-headers header)
2106 "Prepare ARTICLE in article mode buffer.
2107 ARTICLE should either be an article number or a Message-ID.
2108 If ARTICLE is an id, HEADER should be the article headers.
2109 If ALL-HEADERS is non-nil, no headers are hidden."
2111 ;; Make sure we start in a summary buffer.
2112 (unless (eq major-mode 'gnus-summary-mode)
2113 (set-buffer gnus-summary-buffer))
2114 (setq gnus-summary-buffer (current-buffer))
2115 (let* ((gnus-article (if header (mail-header-number header) article))
2116 (summary-buffer (current-buffer))
2117 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
2118 (group gnus-newsgroup-name)
2121 (gnus-article-setup-buffer)
2122 (set-buffer gnus-original-article-buffer)
2123 ;; Deactivate active regions.
2124 (when (and (boundp 'transient-mark-mode)
2125 transient-mark-mode)
2126 (setq mark-active nil))
2127 (if (not (setq result (let ((buffer-read-only nil))
2128 (gnus-request-article-this-buffer
2130 ;; There is no such article.
2132 (when (and (numberp article)
2133 (not (memq article gnus-newsgroup-sparse)))
2134 (setq gnus-article-current
2135 (cons gnus-newsgroup-name article))
2136 (set-buffer gnus-summary-buffer)
2137 (setq gnus-current-article article)
2138 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
2140 (gnus-summary-set-agent-mark article)
2141 (message "Message marked for downloading"))
2142 (gnus-summary-mark-article article gnus-canceled-mark)
2143 (unless (memq article gnus-newsgroup-sparse)
2145 "No such article (may have expired or been canceled)")))))
2146 (if (or (eq result 'pseudo)
2147 (eq result 'nneething))
2150 (set-buffer summary-buffer)
2151 (push article gnus-newsgroup-history)
2152 (setq gnus-last-article gnus-current-article
2153 gnus-current-article 0
2154 gnus-current-headers nil
2155 gnus-article-current nil)
2156 (if (eq result 'nneething)
2157 (gnus-configure-windows 'summary)
2158 (gnus-configure-windows 'article))
2159 (gnus-set-global-variables))
2160 (gnus-set-mode-line 'article))
2161 ;; The result from the `request' was an actual article -
2162 ;; or at least some text that is now displayed in the
2164 (when (and (numberp article)
2165 (not (eq article gnus-current-article)))
2166 ;; Seems like a new article has been selected.
2167 ;; `gnus-current-article' must be an article number.
2169 (set-buffer summary-buffer)
2170 (push article gnus-newsgroup-history)
2171 (setq gnus-last-article gnus-current-article
2172 gnus-current-article article
2173 gnus-current-headers
2174 (gnus-summary-article-header gnus-current-article)
2175 gnus-article-current
2176 (cons gnus-newsgroup-name gnus-current-article))
2177 (unless (vectorp gnus-current-headers)
2178 (setq gnus-current-headers nil))
2179 (gnus-summary-goto-subject gnus-current-article)
2180 (when (gnus-summary-show-thread)
2181 ;; If the summary buffer really was folded, the
2182 ;; previous goto may not actually have gone to
2183 ;; the right article, but the thread root instead.
2185 (gnus-summary-goto-subject gnus-current-article))
2186 (gnus-run-hooks 'gnus-mark-article-hook)
2187 (gnus-set-mode-line 'summary)
2188 (when (gnus-visual-p 'article-highlight 'highlight)
2189 (gnus-run-hooks 'gnus-visual-mark-article-hook))
2190 ;; Set the global newsgroup variables here.
2191 ;; Suggested by Jim Sisolak
2192 ;; <sisolak@trans4.neep.wisc.edu>.
2193 (gnus-set-global-variables)
2194 (setq gnus-have-all-headers
2195 (or all-headers gnus-show-all-headers))))
2196 (when (or (numberp article)
2198 (gnus-article-prepare-display)
2200 (goto-char (point-min))
2201 (setq gnus-page-broken
2202 (when gnus-break-pages
2203 (gnus-narrow-to-page)
2205 (gnus-set-mode-line 'article)
2206 (gnus-configure-windows 'article)
2207 (goto-char (point-min))
2208 (search-forward "\n\n" nil t)
2209 (set-window-point (get-buffer-window (current-buffer)) (point))
2212 (defun gnus-article-prepare-display ()
2213 "Make the current buffer look like a nice article."
2214 (let ((method (if gnus-show-mime
2217 gnus-article-display-method-for-mime)
2218 gnus-article-display-method-for-traditional)))
2219 ;; Hooks for getting information from the article.
2220 ;; This hook must be called before being narrowed.
2221 (gnus-run-hooks 'gnus-tmp-internal-hook)
2222 (gnus-run-hooks 'gnus-article-prepare-hook)
2225 ;; Associate this article with the current summary buffer.
2226 (setq gnus-article-current-summary (current-buffer))
2227 ;; Perform the article display hooks.
2228 (gnus-run-hooks 'gnus-article-display-hook)))
2231 ;;; Gnus MIME viewing functions
2234 (defvar gnus-mime-button-line-format "%{%([%p. %t%d%n]%)%}%e\n"
2235 "The following specs can be used:
2237 %n The `name' parameter
2238 %d The description, if any
2239 %l The length of the encoded part
2240 %p The part identifier
2241 %e Dots if the part isn't displayed")
2243 (defvar gnus-mime-button-line-format-alist
2244 '((?t gnus-tmp-type ?s)
2245 (?n gnus-tmp-name ?s)
2246 (?d gnus-tmp-description ?s)
2248 (?l gnus-tmp-length ?d)
2249 (?e gnus-tmp-dots ?s)))
2251 (defvar gnus-mime-button-commands
2252 '((gnus-article-press-button "\r" "Toggle Display")
2253 ;(gnus-mime-view-part "\M-\r" "View Interactively...")
2254 (gnus-mime-view-part "v" "View Interactively...")
2255 (gnus-mime-save-part "o" "Save...")
2256 (gnus-mime-copy-part "c" "View In Buffer")
2257 (gnus-mime-inline-part "i" "View Inline")
2258 (gnus-mime-pipe-part "|" "Pipe To Command...")))
2260 (defvar gnus-mime-button-map nil)
2261 (unless gnus-mime-button-map
2262 (setq gnus-mime-button-map (make-sparse-keymap))
2263 (set-keymap-parent gnus-mime-button-map gnus-article-mode-map)
2264 (define-key gnus-mime-button-map gnus-mouse-2 'gnus-article-push-button)
2265 (define-key gnus-mime-button-map gnus-mouse-3 'gnus-mime-button-menu)
2267 (define-key gnus-mime-button-map (cadr c) (car c)))
2268 gnus-mime-button-commands))
2270 (defun gnus-mime-button-menu (event)
2271 "Construct a context-sensitive menu of MIME commands."
2275 (defun gnus-mime-view-all-parts ()
2276 "View all the MIME parts."
2278 (let ((handles gnus-article-mime-handles))
2280 (mm-display-part (pop handles)))))
2282 (defun gnus-mime-save-part ()
2283 "Save the MIME part under point."
2285 (let ((data (get-text-property (point) 'gnus-data)))
2286 (mm-save-part data)))
2288 (defun gnus-mime-pipe-part ()
2289 "Pipe the MIME part under point to a process."
2291 (let ((data (get-text-property (point) 'gnus-data)))
2292 (mm-pipe-part data)))
2294 (defun gnus-mime-view-part ()
2295 "Interactively choose a view method for the MIME part under point."
2297 (let ((data (get-text-property (point) 'gnus-data))
2298 (url-standalone-mode (not gnus-plugged)))
2299 (mm-interactively-view-part data)))
2301 (defun gnus-mime-copy-part ()
2302 "Put the the MIME part under point into a new buffer."
2304 (let* ((handle (get-text-property (point) 'gnus-data))
2305 (contents (mm-get-part handle))
2306 (buffer (generate-new-buffer
2307 (file-name-nondirectory
2309 (mail-content-type-get (mm-handle-type handle) 'name)
2310 (mail-content-type-get (mm-handle-type handle)
2313 (set-buffer-major-mode buffer)
2314 (switch-to-buffer buffer)
2316 (goto-char (point-min))))
2318 (defun gnus-mime-inline-part ()
2319 "Insert the MIME part under point into the current buffer."
2321 (let* ((data (get-text-property (point) 'gnus-data))
2322 (contents (mm-get-part data))
2323 (url-standalone-mode (not gnus-plugged))
2326 (if (mm-handle-undisplayer data)
2327 (mm-remove-part data)
2329 (mm-insert-inline data contents)
2332 (defun gnus-article-view-part (n)
2333 "View MIME part N, which is the numerical prefix."
2335 (save-current-buffer
2336 (set-buffer gnus-article-buffer)
2337 (when (> n (length gnus-article-mime-handle-alist))
2338 (error "No such part"))
2339 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
2340 (gnus-article-goto-part n)
2341 (gnus-set-window-start)
2342 (gnus-mm-display-part handle))))
2344 (defun gnus-mm-display-part (handle)
2345 "Display HANDLE and fix MIME button."
2346 (let ((id (get-text-property (point) 'gnus-part))
2349 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
2350 (gnus-insert-mime-button
2351 handle id (list (not (mm-handle-displayed-p handle))))
2352 (mm-display-part handle)
2355 (defun gnus-article-goto-part (n)
2356 "Go to MIME part N."
2357 (goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
2359 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
2360 (let ((gnus-tmp-name (mail-content-type-get (mm-handle-type handle) 'name))
2361 (gnus-tmp-type (car (mm-handle-type handle)))
2362 (gnus-tmp-description (mm-handle-description handle))
2364 (if (if displayed (car displayed)
2365 (mm-handle-displayed-p handle))
2367 (gnus-tmp-length (save-excursion
2368 (set-buffer (mm-handle-buffer handle))
2373 (concat " (" gnus-tmp-name ")")
2375 (setq gnus-tmp-description
2376 (if gnus-tmp-description
2377 (concat " (" gnus-tmp-description ")")
2381 gnus-mime-button-line-format gnus-mime-button-line-format-alist
2382 `(local-map ,gnus-mime-button-map
2383 keymap ,gnus-mime-button-map
2384 gnus-callback gnus-mm-display-part
2385 gnus-part ,gnus-tmp-id
2386 gnus-type annotation
2389 (widget-convert-button 'link from to :action 'gnus-widget-press-button
2390 :button-keymap gnus-mime-button-map)))
2392 (defun gnus-widget-press-button (elems el)
2393 (goto-char (widget-get elems :from))
2394 (let ((url-standalone-mode (not gnus-plugged)))
2395 (gnus-article-press-button)))
2397 (defun gnus-display-mime (&optional ihandles)
2398 "Insert MIME buttons in the buffer."
2399 (let* ((handles (or ihandles (mm-dissect-buffer) (mm-uu-dissect)))
2400 handle name type b e display)
2403 ;; Top-level call; we clean up.
2404 (mm-destroy-parts gnus-article-mime-handles)
2405 (setq gnus-article-mime-handles handles
2406 gnus-article-mime-handle-alist nil)
2407 (goto-char (point-min))
2408 (search-forward "\n\n" nil t)
2409 (delete-region (point) (point-max)))
2410 (if (stringp (car handles))
2411 (if (equal (car handles) "multipart/alternative")
2412 (gnus-mime-display-alternative (cdr handles))
2413 (gnus-mime-display-mixed (cdr handles)))
2414 (gnus-mime-display-single handles)))))
2416 (defun gnus-mime-display-mixed (handles)
2418 (while (setq handle (pop handles))
2419 (gnus-mime-display-single handle))))
2421 (defun gnus-mime-display-single (handle)
2423 (when (and (mm-automatic-display-p
2424 (car (mm-handle-type handle)))
2425 (mm-inlinable-part-p (car (mm-handle-type handle)))
2426 (or (not (mm-handle-disposition handle))
2427 (equal (car (mm-handle-disposition handle))
2430 (let ((id (1+ (length gnus-article-mime-handle-alist))))
2431 (push (cons id handle) gnus-article-mime-handle-alist)
2432 (gnus-insert-mime-button handle id (list display)))
2436 (mm-display-part handle t)
2437 (goto-char (point-max)))))
2439 (defun gnus-mime-display-alternative (handles &optional preferred)
2440 (let* ((preferred (mm-preferred-alternative handles preferred))
2443 handle buffer-read-only from)
2444 (goto-char (point-min))
2445 (search-forward "\n\n" nil t)
2446 (delete-region (point) (point-max))
2448 ;; Top-level call; we clean up.
2449 (mm-remove-parts gnus-article-mime-handles)
2450 (setq gnus-article-mime-handles handles
2451 gnus-article-mime-handle-alist nil))
2452 (while (setq handle (pop handles))
2453 (gnus-add-text-properties
2456 (insert (format "[%c] %-18s"
2457 (if (equal handle preferred) ?* ? )
2458 (if (stringp (car handle))
2460 (car (mm-handle-type handle)))))
2462 `(local-map ,gnus-mime-button-map
2463 ,gnus-mouse-face-prop ,gnus-article-mouse-face
2464 face ,gnus-article-button-face
2465 keymap ,gnus-mime-button-map
2468 (gnus-mime-display-alternative
2469 ',ihandles ,(if (stringp (car handle))
2471 (car (mm-handle-type handle)))))
2473 (widget-convert-button 'link from (point)
2474 :action 'gnus-widget-press-button
2475 :button-keymap gnus-widget-button-keymap)
2479 (if (stringp (car preferred))
2480 (gnus-display-mime preferred)
2481 (mm-display-part preferred)))
2484 (defun gnus-article-wash-status ()
2485 "Return a string which display status of article washing."
2487 (set-buffer gnus-article-buffer)
2488 (let ((cite (gnus-article-hidden-text-p 'cite))
2489 (headers (gnus-article-hidden-text-p 'headers))
2490 (boring (gnus-article-hidden-text-p 'boring-headers))
2491 (pgp (gnus-article-hidden-text-p 'pgp))
2492 (pem (gnus-article-hidden-text-p 'pem))
2493 (signature (gnus-article-hidden-text-p 'signature))
2494 (overstrike (gnus-article-hidden-text-p 'overstrike))
2495 (emphasis (gnus-article-hidden-text-p 'emphasis))
2496 (mime gnus-show-mime))
2497 (format "%c%c%c%c%c%c%c"
2499 (if (or headers boring) ?h ? )
2500 (if (or pgp pem) ?p ? )
2501 (if signature ?s ? )
2502 (if overstrike ?o ? )
2504 (if emphasis ?e ? )))))
2506 (fset 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
2508 (defun gnus-article-maybe-hide-headers ()
2509 "Hide unwanted headers if `gnus-have-all-headers' is nil.
2510 Provided for backwards compatibility."
2511 (or (save-excursion (set-buffer gnus-summary-buffer) gnus-have-all-headers)
2513 (gnus-article-hide-headers)))
2517 (defun gnus-output-to-file (file-name)
2518 "Append the current article to a file named FILE-NAME."
2519 (let ((artbuf (current-buffer)))
2521 (insert-buffer-substring artbuf)
2522 ;; Append newline at end of the buffer as separator, and then
2524 (goto-char (point-max))
2526 (append-to-file (point-min) (point-max) file-name)
2529 (defun gnus-narrow-to-page (&optional arg)
2530 "Narrow the article buffer to a page.
2531 If given a numerical ARG, move forward ARG pages."
2533 (setq arg (if arg (prefix-numeric-value arg) 0))
2535 (set-buffer gnus-article-buffer)
2536 (goto-char (point-min))
2538 ;; Remove any old next/prev buttons.
2539 (when (gnus-visual-p 'page-marker)
2540 (let ((buffer-read-only nil))
2541 (gnus-remove-text-with-property 'gnus-prev)
2542 (gnus-remove-text-with-property 'gnus-next)))
2545 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
2547 (re-search-forward page-delimiter nil 'move arg)))
2548 (goto-char (match-end 0)))
2551 (if (re-search-forward page-delimiter nil 'move)
2554 (when (and (gnus-visual-p 'page-marker)
2555 (not (= (point-min) 1)))
2557 (goto-char (point-min))
2558 (gnus-insert-prev-page-button)))
2559 (when (and (gnus-visual-p 'page-marker)
2560 (< (+ (point-max) 2) (buffer-size)))
2562 (goto-char (point-max))
2563 (gnus-insert-next-page-button)))))
2565 ;; Article mode commands
2567 (defun gnus-article-goto-next-page ()
2568 "Show the next page of the article."
2570 (when (gnus-article-next-page)
2571 (goto-char (point-min))
2572 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
2574 (defun gnus-article-goto-prev-page ()
2575 "Show the next page of the article."
2577 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
2578 (gnus-article-prev-page nil)))
2580 (defun gnus-article-next-page (&optional lines)
2581 "Show the next page of the current article.
2582 If end of article, return non-nil. Otherwise return nil.
2583 Argument LINES specifies lines to be scrolled up."
2585 (move-to-window-line -1)
2588 (and (pos-visible-in-window-p) ;Not continuation line.
2590 ;; Nothing in this page.
2591 (if (or (not gnus-page-broken)
2594 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
2596 (gnus-narrow-to-page 1) ;Go to next page.
2598 ;; More in this page.
2599 (let ((scroll-in-place nil))
2603 ;; Long lines may cause an end-of-buffer error.
2604 (goto-char (point-max)))))
2605 (move-to-window-line 0)
2608 (defun gnus-article-prev-page (&optional lines)
2609 "Show previous page of current article.
2610 Argument LINES specifies lines to be scrolled down."
2612 (move-to-window-line 0)
2613 (if (and gnus-page-broken
2615 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
2617 (gnus-narrow-to-page -1) ;Go to previous page.
2618 (goto-char (point-max))
2620 (let ((scroll-in-place nil))
2624 (beginning-of-buffer
2625 (goto-char (point-min))))
2626 (move-to-window-line 0)))))
2628 (defun gnus-article-refer-article ()
2629 "Read article specified by message-id around point."
2631 (let ((point (point)))
2632 (search-forward ">" nil t) ;Move point to end of "<....>".
2633 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
2634 (let ((message-id (match-string 1)))
2636 (set-buffer gnus-summary-buffer)
2637 (gnus-summary-refer-article message-id))
2639 (error "No references around point"))))
2641 (defun gnus-article-show-summary ()
2642 "Reconfigure windows to show summary buffer."
2644 (if (not (gnus-buffer-live-p gnus-summary-buffer))
2645 (error "There is no summary buffer for this article buffer")
2646 (gnus-article-set-globals)
2647 (gnus-configure-windows 'article)
2648 (gnus-summary-goto-subject gnus-current-article)
2649 (gnus-summary-position-point)))
2651 (defun gnus-article-describe-briefly ()
2652 "Describe article mode commands briefly."
2655 (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")))
2657 (defun gnus-article-summary-command ()
2658 "Execute the last keystroke in the summary buffer."
2660 (let ((obuf (current-buffer))
2661 (owin (current-window-configuration))
2663 (switch-to-buffer gnus-article-current-summary 'norecord)
2664 (setq func (lookup-key (current-local-map) (this-command-keys)))
2665 (call-interactively func)
2667 (set-window-configuration owin)
2668 (set-window-point (get-buffer-window (current-buffer)) (point))))
2670 (defun gnus-article-summary-command-nosave ()
2671 "Execute the last keystroke in the summary buffer."
2674 (pop-to-buffer gnus-article-current-summary 'norecord)
2675 (setq func (lookup-key (current-local-map) (this-command-keys)))
2676 (call-interactively func)))
2678 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
2679 "Read a summary buffer key sequence and execute it from the article buffer."
2682 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
2683 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
2684 "=" "^" "\M-^" "|"))
2690 '("n" "Gn" "p" "Gp"))
2693 (set-buffer gnus-article-current-summary)
2694 (let (gnus-pick-mode)
2695 (push (or key last-command-event) unread-command-events)
2696 (setq keys (read-key-sequence nil))))
2699 (if (or (member keys nosaves)
2700 (member keys nosave-but-article)
2701 (member keys nosave-in-article))
2703 (save-window-excursion
2704 (pop-to-buffer gnus-article-current-summary 'norecord)
2705 ;; We disable the pick minor mode commands.
2706 (let (gnus-pick-mode)
2707 (setq func (lookup-key (current-local-map) keys))))
2710 (unless (member keys nosave-in-article)
2711 (set-buffer gnus-article-current-summary))
2712 (call-interactively func)
2713 (setq new-sum-point (point)))
2714 (when (member keys nosave-but-article)
2715 (pop-to-buffer gnus-article-buffer 'norecord)))
2716 ;; These commands should restore window configuration.
2717 (let ((obuf (current-buffer))
2718 (owin (current-window-configuration))
2720 (summary gnus-article-current-summary)
2721 func in-buffer selected)
2722 (if not-restore-window
2723 (pop-to-buffer summary 'norecord)
2724 (switch-to-buffer summary 'norecord))
2725 (setq in-buffer (current-buffer))
2726 ;; We disable the pick minor mode commands.
2727 (if (setq func (let (gnus-pick-mode)
2728 (lookup-key (current-local-map) keys)))
2730 (call-interactively func)
2731 (setq new-sum-point (point)))
2733 (when (eq in-buffer (current-buffer))
2734 (setq selected (gnus-summary-select-article))
2736 (unless not-restore-window
2737 (set-window-configuration owin))
2738 (unless (or (not (eq selected 'old)) (member keys up-to-top))
2739 (set-window-point (get-buffer-window (current-buffer))
2741 (let ((win (get-buffer-window gnus-article-current-summary)))
2743 (set-window-point win new-sum-point))))))))
2745 (defun gnus-article-hide (&optional arg force)
2746 "Hide all the gruft in the current article.
2747 This means that PGP stuff, signatures, cited text and (some)
2748 headers will be hidden.
2749 If given a prefix, show the hidden text instead."
2750 (interactive (append (gnus-article-hidden-arg) (list 'force)))
2751 (gnus-article-hide-headers arg)
2752 (gnus-article-hide-pgp arg)
2753 (gnus-article-hide-citation-maybe arg force)
2754 (gnus-article-hide-signature arg))
2756 (defun gnus-article-maybe-highlight ()
2757 "Do some article highlighting if article highlighting is requested."
2758 (when (gnus-visual-p 'article-highlight 'highlight)
2759 (gnus-article-highlight-some)))
2761 (defun gnus-check-group-server ()
2762 ;; Make sure the connection to the server is alive.
2763 (unless (gnus-server-opened
2764 (gnus-find-method-for-group gnus-newsgroup-name))
2765 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
2766 (gnus-request-group gnus-newsgroup-name t)))
2768 (defun gnus-request-article-this-buffer (article group)
2769 "Get an article and insert it into this buffer."
2770 (let (do-update-line sparse-header)
2774 (gnus-kill-all-overlays)
2775 (setq group (or group gnus-newsgroup-name))
2777 ;; Using `gnus-request-article' directly will insert the article into
2778 ;; `nntp-server-buffer' - so we'll save some time by not having to
2779 ;; copy it from the server buffer into the article buffer.
2781 ;; We only request an article by message-id when we do not have the
2782 ;; headers for it, so we'll have to get those.
2783 (when (stringp article)
2784 (let ((gnus-override-method gnus-refer-article-method))
2785 (gnus-read-header article)))
2787 ;; If the article number is negative, that means that this article
2788 ;; doesn't belong in this newsgroup (possibly), so we find its
2789 ;; message-id and request it by id instead of number.
2790 (when (and (numberp article)
2792 (get-buffer gnus-summary-buffer)
2793 (gnus-buffer-exists-p gnus-summary-buffer))
2795 (set-buffer gnus-summary-buffer)
2796 (let ((header (gnus-summary-article-header article)))
2799 ((memq article gnus-newsgroup-sparse)
2800 ;; This is a sparse gap article.
2801 (setq do-update-line article)
2802 (setq article (mail-header-id header))
2803 (let ((gnus-override-method gnus-refer-article-method))
2804 (setq sparse-header (gnus-read-header article)))
2805 (setq gnus-newsgroup-sparse
2806 (delq article gnus-newsgroup-sparse)))
2808 ;; It's a real article.
2809 (setq article (mail-header-id header)))
2811 ;; It is an extracted pseudo-article.
2812 (setq article 'pseudo)
2813 (gnus-request-pseudo-article header))))
2815 (let ((method (gnus-find-method-for-group
2816 gnus-newsgroup-name)))
2817 (when (and (eq (car method) 'nneething)
2820 (file-name-as-directory
2821 (or (cadr (assq 'nneething-address method))
2823 (mail-header-subject header))))
2824 (when (file-directory-p dir)
2825 (setq article 'nneething)
2826 (gnus-group-enter-directory dir))))))))
2829 ;; Refuse to select canceled articles.
2830 ((and (numberp article)
2832 (get-buffer gnus-summary-buffer)
2833 (gnus-buffer-exists-p gnus-summary-buffer)
2834 (eq (cdr (save-excursion
2835 (set-buffer gnus-summary-buffer)
2836 (assq article gnus-newsgroup-reads)))
2837 gnus-canceled-mark))
2839 ;; Check the backlog.
2840 ((and gnus-keep-backlog
2841 (gnus-backlog-request-article group article (current-buffer)))
2843 ;; Check asynchronous pre-fetch.
2844 ((gnus-async-request-fetched-article group article (current-buffer))
2845 (gnus-async-prefetch-next group article gnus-summary-buffer)
2846 (when (and (numberp article) gnus-keep-backlog)
2847 (gnus-backlog-enter-article group article (current-buffer)))
2850 ((and gnus-use-cache
2852 (gnus-cache-request-article article group))
2854 ;; Get the article and put into the article buffer.
2855 ((or (stringp article) (numberp article))
2856 (let ((gnus-override-method
2857 (and (stringp article) gnus-refer-article-method))
2858 (buffer-read-only nil))
2860 (gnus-kill-all-overlays)
2861 (gnus-check-group-server)
2862 (when (gnus-request-article article group (current-buffer))
2863 (when (numberp article)
2864 (gnus-async-prefetch-next group article gnus-summary-buffer)
2865 (when gnus-keep-backlog
2866 (gnus-backlog-enter-article
2867 group article (current-buffer))))
2872 ;; Associate this article with the current summary buffer.
2873 (setq gnus-article-current-summary gnus-summary-buffer)
2875 ;; Take the article from the original article buffer
2876 ;; and place it in the buffer it's supposed to be in.
2877 (when (and (get-buffer gnus-article-buffer)
2878 (equal (buffer-name (current-buffer))
2879 (buffer-name (get-buffer gnus-article-buffer))))
2881 (if (get-buffer gnus-original-article-buffer)
2882 (set-buffer gnus-original-article-buffer)
2883 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
2884 (buffer-disable-undo)
2885 (setq major-mode 'gnus-original-article-mode)
2886 (setq buffer-read-only t))
2887 (let (buffer-read-only)
2889 (insert-buffer-substring gnus-article-buffer))
2890 (setq gnus-original-article (cons group article)))
2893 (run-hooks 'gnus-article-decode-hook)
2894 ;; Mark article as decoded or not.
2895 (setq gnus-article-decoded-p gnus-article-decode-hook))
2897 ;; Update sparse articles.
2898 (when (and do-update-line
2899 (or (numberp article)
2901 (let ((buf (current-buffer)))
2902 (set-buffer gnus-summary-buffer)
2903 (gnus-summary-update-article do-update-line sparse-header)
2904 (gnus-summary-goto-subject do-update-line nil t)
2905 (set-window-point (get-buffer-window (current-buffer) t)
2907 (set-buffer buf))))))
2913 (defcustom gnus-article-edit-mode-hook nil
2914 "Hook run in article edit mode buffers."
2915 :group 'gnus-article-various
2918 (defvar gnus-article-edit-done-function nil)
2920 (defvar gnus-article-edit-mode-map nil)
2922 ;; Should we be using derived.el for this?
2923 (unless gnus-article-edit-mode-map
2924 (setq gnus-article-edit-mode-map (make-sparse-keymap))
2925 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
2927 (gnus-define-keys gnus-article-edit-mode-map
2928 "\C-c\C-c" gnus-article-edit-done
2929 "\C-c\C-k" gnus-article-edit-exit)
2931 (gnus-define-keys (gnus-article-edit-wash-map
2932 "\C-c\C-w" gnus-article-edit-mode-map)
2933 "f" gnus-article-edit-full-stops))
2935 (defun gnus-article-edit-mode ()
2936 "Major mode for editing articles.
2937 This is an extended text-mode.
2939 \\{gnus-article-edit-mode-map}"
2941 (setq major-mode 'gnus-article-edit-mode)
2942 (setq mode-name "Article Edit")
2943 (use-local-map gnus-article-edit-mode-map)
2944 (make-local-variable 'gnus-article-edit-done-function)
2945 (make-local-variable 'gnus-prev-winconf)
2946 (setq buffer-read-only nil)
2947 (buffer-enable-undo)
2949 (gnus-run-hooks 'text-mode-hook 'gnus-article-edit-mode-hook))
2951 (defun gnus-article-edit (&optional force)
2952 "Edit the current article.
2953 This will have permanent effect only in mail groups.
2954 If FORCE is non-nil, allow editing of articles even in read-only
2957 (when (and (not force)
2958 (gnus-group-read-only-p))
2959 (error "The current newsgroup does not support article editing"))
2960 (gnus-article-date-original)
2961 (gnus-article-edit-article
2962 `(lambda (no-highlight)
2963 (gnus-summary-edit-article-done
2964 ,(or (mail-header-references gnus-current-headers) "")
2965 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
2967 (defun gnus-article-edit-article (exit-func)
2968 "Start editing the contents of the current article buffer."
2969 (let ((winconf (current-window-configuration)))
2970 (set-buffer gnus-article-buffer)
2971 (gnus-article-edit-mode)
2972 (gnus-article-delete-text-of-type 'annotation)
2973 (gnus-set-text-properties (point-min) (point-max) nil)
2974 (gnus-configure-windows 'edit-article)
2975 (setq gnus-article-edit-done-function exit-func)
2976 (setq gnus-prev-winconf winconf)
2977 (gnus-message 6 "C-c C-c to end edits")))
2979 (defun gnus-article-edit-done (&optional arg)
2980 "Update the article edits and exit."
2985 (goto-char (point-min))
2986 (when (search-forward "\n\n" nil 1)
2987 (let ((lines (count-lines (point) (point-max)))
2988 (length (- (point-max) (point)))
2989 (case-fold-search t)
2990 (body (copy-marker (point))))
2991 (goto-char (point-min))
2992 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
2993 (delete-region (match-beginning 1) (match-end 1))
2994 (insert (number-to-string length)))
2995 (goto-char (point-min))
2996 (when (re-search-forward
2997 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
2998 (delete-region (match-beginning 1) (match-end 1))
2999 (insert (number-to-string length)))
3000 (goto-char (point-min))
3001 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
3002 (delete-region (match-beginning 1) (match-end 1))
3003 (insert (number-to-string lines)))))))
3004 (let ((func gnus-article-edit-done-function)
3005 (buf (current-buffer))
3006 (start (window-start)))
3007 (gnus-article-edit-exit)
3010 (let ((buffer-read-only nil))
3012 ;; The cache and backlog have to be flushed somewhat.
3013 (when gnus-keep-backlog
3014 (gnus-backlog-remove-article
3015 (car gnus-article-current) (cdr gnus-article-current)))
3016 ;; Flush original article as well.
3018 (when (get-buffer gnus-original-article-buffer)
3019 (set-buffer gnus-original-article-buffer)
3020 (setq gnus-original-article nil)))
3021 (when gnus-use-cache
3022 (gnus-cache-update-article
3023 (car gnus-article-current) (cdr gnus-article-current))))
3025 (set-window-start (get-buffer-window buf) start)
3026 (set-window-point (get-buffer-window buf) (point))))
3028 (defun gnus-article-edit-exit ()
3029 "Exit the article editing without updating."
3031 ;; We remove all text props from the article buffer.
3032 (let ((buf (format "%s" (buffer-string)))
3033 (curbuf (current-buffer))
3035 (window-start (window-start)))
3038 (let ((winconf gnus-prev-winconf))
3040 (set-window-configuration winconf)
3041 ;; Tippy-toe some to make sure that point remains where it was.
3042 (save-current-buffer
3044 (set-window-start (get-buffer-window (current-buffer)) window-start)
3047 (defun gnus-article-edit-full-stops ()
3048 "Interactively repair spacing at end of sentences."
3051 (goto-char (point-min))
3052 (search-forward-regexp "^$" nil t)
3053 (let ((case-fold-search nil))
3054 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
3057 ;;; Article highlights
3060 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
3062 ;;; Internal Variables:
3064 (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\\)"
3065 "Regular expression that matches URLs."
3066 :group 'gnus-article-buttons
3069 (defcustom gnus-button-alist
3070 `(("<\\(url:[>\n\t ]*?\\)?news:[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>" 0 t
3071 gnus-button-message-id 2)
3072 ("\\bnews:\\([^>\n\t ]*@[^>\n\t ]*\\)" 0 t gnus-button-message-id 1)
3073 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
3075 gnus-button-fetch-group 4)
3076 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
3077 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
3078 t gnus-button-message-id 3)
3079 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
3080 ("mailto:\\([-a-zA-Z.@_+0-9%]+\\)" 0 t gnus-url-mailto 1)
3081 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
3082 ;; This is how URLs _should_ be embedded in text...
3083 ("<URL: *\\([^>]*\\)>" 0 t gnus-button-embedded-url 1)
3085 (,gnus-button-url-regexp 0 t gnus-button-url 0))
3086 "*Alist of regexps matching buttons in article bodies.
3088 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
3089 REGEXP: is the string matching text around the button,
3090 BUTTON: is the number of the regexp grouping actually matching the button,
3091 FORM: is a lisp expression which must eval to true for the button to
3093 CALLBACK: is the function to call when the user push this button, and each
3094 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
3096 CALLBACK can also be a variable, in that case the value of that
3097 variable it the real callback function."
3098 :group 'gnus-article-buttons
3099 :type '(repeat (list regexp
3100 (integer :tag "Button")
3102 (function :tag "Callback")
3105 (integer :tag "Regexp group")))))
3107 (defcustom gnus-header-button-alist
3108 `(("^\\(References\\|Message-I[Dd]\\):" "<[^>]+>"
3109 0 t gnus-button-message-id 0)
3110 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
3111 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
3112 0 t gnus-button-mailto 0)
3113 ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t gnus-button-url 0)
3114 ("^Subject:" ,gnus-button-url-regexp 0 t gnus-button-url 0)
3115 ("^[^:]+:" ,gnus-button-url-regexp 0 t gnus-button-url 0)
3116 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
3117 gnus-button-message-id 3))
3118 "*Alist of headers and regexps to match buttons in article heads.
3120 This alist is very similar to `gnus-button-alist', except that each
3121 alist has an additional HEADER element first in each entry:
3123 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
3125 HEADER is a regexp to match a header. For a fuller explanation, see
3126 `gnus-button-alist'."
3127 :group 'gnus-article-buttons
3128 :group 'gnus-article-headers
3129 :type '(repeat (list (regexp :tag "Header")
3131 (integer :tag "Button")
3133 (function :tag "Callback")
3136 (integer :tag "Regexp group")))))
3138 (defvar gnus-button-regexp nil)
3139 (defvar gnus-button-marker-list nil)
3140 ;; Regexp matching any of the regexps from `gnus-button-alist'.
3142 (defvar gnus-button-last nil)
3143 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
3147 (defun gnus-article-push-button (event)
3148 "Check text under the mouse pointer for a callback function.
3149 If the text under the mouse pointer has a `gnus-callback' property,
3150 call it with the value of the `gnus-data' text property."
3152 (set-buffer (window-buffer (posn-window (event-start event))))
3153 (let* ((pos (posn-point (event-start event)))
3154 (data (get-text-property pos 'gnus-data))
3155 (fun (get-text-property pos 'gnus-callback)))
3158 (funcall fun data))))
3160 (defun gnus-article-press-button ()
3161 "Check text at point for a callback function.
3162 If the text at point has a `gnus-callback' property,
3163 call it with the value of the `gnus-data' text property."
3165 (let* ((data (get-text-property (point) 'gnus-data))
3166 (fun (get-text-property (point) 'gnus-callback)))
3168 (funcall fun data))))
3170 (defun gnus-article-prev-button (n)
3171 "Move point to N buttons backward.
3172 If N is negative, move forward instead."
3174 (gnus-article-next-button (- n)))
3176 (defun gnus-article-next-button (n)
3177 "Move point to N buttons forward.
3178 If N is negative, move backward instead."
3180 (let ((function (if (< n 0) 'previous-single-property-change
3181 'next-single-property-change))
3182 (inhibit-point-motion-hooks t)
3184 (limit (if (< n 0) (point-min) (point-max))))
3186 (while (and (not (= limit (point)))
3188 ;; Skip past the current button.
3189 (when (get-text-property (point) 'gnus-callback)
3190 (goto-char (funcall function (point) 'gnus-callback nil limit)))
3191 ;; Go to the next (or previous) button.
3192 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
3193 ;; Put point at the start of the button.
3194 (when (and backward (not (get-text-property (point) 'gnus-callback)))
3195 (goto-char (funcall function (point) 'gnus-callback nil limit)))
3196 ;; Skip past intangible buttons.
3197 (when (get-text-property (point) 'intangible)
3201 (gnus-message 5 "No more buttons"))
3204 (defun gnus-article-highlight (&optional force)
3205 "Highlight current article.
3206 This function calls `gnus-article-highlight-headers',
3207 `gnus-article-highlight-citation',
3208 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
3209 do the highlighting. See the documentation for those functions."
3210 (interactive (list 'force))
3211 (gnus-article-highlight-headers)
3212 (gnus-article-highlight-citation force)
3213 (gnus-article-highlight-signature)
3214 (gnus-article-add-buttons force)
3215 (gnus-article-add-buttons-to-head))
3217 (defun gnus-article-highlight-some (&optional force)
3218 "Highlight current article.
3219 This function calls `gnus-article-highlight-headers',
3220 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
3221 do the highlighting. See the documentation for those functions."
3222 (interactive (list 'force))
3223 (gnus-article-highlight-headers)
3224 (gnus-article-highlight-signature)
3225 (gnus-article-add-buttons))
3227 (defun gnus-article-highlight-headers ()
3228 "Highlight article headers as specified by `gnus-header-face-alist'."
3231 (set-buffer gnus-article-buffer)
3233 (let ((alist gnus-header-face-alist)
3234 (buffer-read-only nil)
3235 (case-fold-search t)
3236 (inhibit-point-motion-hooks t)
3237 entry regexp header-face field-face from hpoints fpoints)
3238 (message-narrow-to-head)
3239 (while (setq entry (pop alist))
3240 (goto-char (point-min))
3241 (setq regexp (concat "^\\("
3242 (if (string-equal "" (nth 0 entry))
3246 header-face (nth 1 entry)
3247 field-face (nth 2 entry))
3248 (while (and (re-search-forward regexp nil t)
3252 (unless (search-forward ":" nil t)
3254 (when (and header-face
3255 (not (memq (point) hpoints)))
3256 (push (point) hpoints)
3257 (gnus-put-text-property from (point) 'face header-face))
3258 (when (and field-face
3259 (not (memq (setq from (point)) fpoints)))
3261 (if (re-search-forward "^[^ \t]" nil t)
3263 (goto-char (point-max)))
3264 (gnus-put-text-property from (point) 'face field-face))))))))
3266 (defun gnus-article-highlight-signature ()
3267 "Highlight the signature in an article.
3268 It does this by highlighting everything after
3269 `gnus-signature-separator' using `gnus-signature-face'."
3272 (set-buffer gnus-article-buffer)
3273 (let ((buffer-read-only nil)
3274 (inhibit-point-motion-hooks t))
3276 (when (and gnus-signature-face
3277 (gnus-article-narrow-to-signature))
3278 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
3279 'face gnus-signature-face)
3281 (gnus-article-search-signature)
3282 (let ((start (match-beginning 0))
3283 (end (set-marker (make-marker) (1+ (match-end 0)))))
3284 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
3287 (defun gnus-button-in-region-p (b e prop)
3288 "Say whether PROP exists in the region."
3289 (text-property-not-all b e prop nil))
3291 (defun gnus-article-add-buttons (&optional force)
3292 "Find external references in the article and make buttons of them.
3293 \"External references\" are things like Message-IDs and URLs, as
3294 specified by `gnus-button-alist'."
3295 (interactive (list 'force))
3297 (set-buffer gnus-article-buffer)
3298 (let ((buffer-read-only nil)
3299 (inhibit-point-motion-hooks t)
3300 (case-fold-search t)
3301 (alist gnus-button-alist)
3303 ;; Remove all old markers.
3305 (while (setq marker (pop gnus-button-marker-list))
3307 (when (setq entry (gnus-button-entry))
3308 (put-text-property (match-beginning (nth 1 entry))
3309 (match-end (nth 1 entry))
3310 'gnus-callback nil))
3311 (set-marker marker nil)))
3312 ;; We skip the headers.
3313 (goto-char (point-min))
3314 (unless (search-forward "\n\n" nil t)
3315 (goto-char (point-max)))
3317 (while (setq entry (pop alist))
3318 (setq regexp (car entry))
3320 (while (re-search-forward regexp nil t)
3321 (let* ((start (and entry (match-beginning (nth 1 entry))))
3322 (end (and entry (match-end (nth 1 entry))))
3323 (from (match-beginning 0)))
3324 (when (and (or (eq t (nth 2 entry))
3325 (eval (nth 2 entry)))
3326 (not (gnus-button-in-region-p
3327 start end 'gnus-callback)))
3328 ;; That optional form returned non-nil, so we add the
3330 (gnus-article-add-button
3331 start end 'gnus-button-push
3332 (car (push (set-marker (make-marker) from)
3333 gnus-button-marker-list))))))))))
3335 ;; Add buttons to the head of an article.
3336 (defun gnus-article-add-buttons-to-head ()
3337 "Add buttons to the head of the article."
3340 (set-buffer gnus-article-buffer)
3341 (let ((buffer-read-only nil)
3342 (inhibit-point-motion-hooks t)
3343 (case-fold-search t)
3344 (alist gnus-header-button-alist)
3346 (nnheader-narrow-to-headers)
3348 ;; Each alist entry.
3349 (setq entry (car alist)
3351 (goto-char (point-min))
3352 (while (re-search-forward (car entry) nil t)
3353 ;; Each header matching the entry.
3354 (setq beg (match-beginning 0))
3355 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
3356 (match-beginning 0))
3359 (while (re-search-forward (nth 1 entry) end t)
3360 ;; Each match within a header.
3361 (let* ((entry (cdr entry))
3362 (start (match-beginning (nth 1 entry)))
3363 (end (match-end (nth 1 entry)))
3364 (form (nth 2 entry)))
3365 (goto-char (match-end 0))
3367 (gnus-article-add-button
3368 start end (nth 3 entry)
3369 (buffer-substring (match-beginning (nth 4 entry))
3370 (match-end (nth 4 entry)))))))
3374 ;;; External functions:
3376 (defun gnus-article-add-button (from to fun &optional data)
3377 "Create a button between FROM and TO with callback FUN and data DATA."
3378 (when gnus-article-button-face
3379 (gnus-overlay-put (gnus-make-overlay from to)
3380 'face gnus-article-button-face))
3381 (gnus-add-text-properties
3383 (nconc (and gnus-article-mouse-face
3384 (list gnus-mouse-face-prop gnus-article-mouse-face))
3385 (list 'gnus-callback fun)
3386 (and data (list 'gnus-data data)))))
3388 ;;; Internal functions:
3390 (defun gnus-article-set-globals ()
3392 (set-buffer gnus-summary-buffer)
3393 (gnus-set-global-variables)))
3395 (defun gnus-signature-toggle (end)
3397 (set-buffer gnus-article-buffer)
3398 (let ((buffer-read-only nil)
3399 (inhibit-point-motion-hooks t))
3400 (if (get-text-property end 'invisible)
3401 (gnus-article-unhide-text end (point-max))
3402 (gnus-article-hide-text end (point-max) gnus-hidden-properties)))))
3404 (defun gnus-button-entry ()
3405 ;; Return the first entry in `gnus-button-alist' matching this place.
3406 (let ((alist gnus-button-alist)
3409 (setq entry (pop alist))
3410 (if (looking-at (car entry))
3415 (defun gnus-button-push (marker)
3416 ;; Push button starting at MARKER.
3418 (set-buffer gnus-article-buffer)
3420 (let* ((entry (gnus-button-entry))
3421 (inhibit-point-motion-hooks t)
3423 (args (mapcar (lambda (group)
3424 (let ((string (match-string group)))
3425 (gnus-set-text-properties
3426 0 (length string) nil string)
3433 (fboundp (symbol-value fun)))
3434 (apply (symbol-value fun) args))
3436 (gnus-message 1 "You must define `%S' to use this button"
3437 (cons fun args)))))))
3439 (defun gnus-button-message-id (message-id)
3442 (set-buffer gnus-summary-buffer)
3443 (gnus-summary-refer-article message-id)))
3445 (defun gnus-button-fetch-group (address)
3446 "Fetch GROUP specified by ADDRESS."
3447 (if (not (string-match "[:/]" address))
3448 ;; This is just a simple group url.
3449 (gnus-group-read-ephemeral-group address gnus-select-method)
3450 (if (not (string-match "^\\([^:/]+\\)\\(:\\([^/]+\\)/\\)?\\(.*\\)$"
3452 (error "Can't parse %s" address)
3453 (gnus-group-read-ephemeral-group
3454 (match-string 4 address)
3455 `(nntp ,(match-string 1 address)
3456 (nntp-address ,(match-string 1 address))
3457 (nntp-port-number ,(if (match-end 3)
3458 (match-string 3 address)
3461 (defun gnus-url-parse-query-string (query &optional downcase)
3462 (let (retval pairs cur key val)
3463 (setq pairs (split-string query "&"))
3465 (setq cur (car pairs)
3467 (if (not (string-match "=" cur))
3469 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
3470 val (gnus-url-unhex-string (substring cur (match-end 0) nil)))
3472 (setq key (downcase key)))
3473 (setq cur (assoc key retval))
3475 (setcdr cur (cons val (cdr cur)))
3476 (setq retval (cons (list key val) retval)))))
3479 (defun gnus-url-unhex (x)
3486 (defun gnus-url-unhex-string (str &optional allow-newlines)
3487 "Remove %XXX embedded spaces, etc in a url.
3488 If optional second argument ALLOW-NEWLINES is non-nil, then allow the
3489 decoding of carriage returns and line feeds in the string, which is normally
3490 forbidden in URL encoding."
3491 (setq str (or str ""))
3493 (case-fold-search t))
3494 (while (string-match "%[0-9a-f][0-9a-f]" str)
3495 (let* ((start (match-beginning 0))
3496 (ch1 (gnus-url-unhex (elt str (+ start 1))))
3498 (gnus-url-unhex (elt str (+ start 2))))))
3500 tmp (substring str 0 start)
3503 (char-to-string code))
3504 ((or (= code ?\n) (= code ?\r))
3506 (t (char-to-string code))))
3507 str (substring str (match-end 0)))))
3508 (setq tmp (concat tmp str))
3511 (defun gnus-url-mailto (url)
3512 ;; Send mail to someone
3513 (when (string-match "mailto:/*\\(.*\\)" url)
3514 (setq url (substring url (match-beginning 1) nil)))
3515 (let (to args subject func)
3516 (if (string-match (regexp-quote "?") url)
3517 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
3518 args (gnus-url-parse-query-string
3519 (substring url (match-end 0) nil) t))
3520 (setq to (gnus-url-unhex-string url)))
3521 (setq args (cons (list "to" to) args)
3522 subject (cdr-safe (assoc "subject" args)))
3523 (gnus-setup-message 'reply
3526 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
3529 (message-position-on-field (caar args)))
3530 (insert (mapconcat 'identity (cdar args) ", "))
3531 (setq args (cdr args)))
3534 (message-goto-subject)))))
3536 (defun gnus-button-mailto (address)
3538 (set-buffer (gnus-copy-article-buffer))
3539 (gnus-setup-message 'reply
3540 (message-reply address)))
3542 (defun gnus-button-reply (address)
3543 ;; Reply to ADDRESS.
3544 (gnus-setup-message 'reply
3545 (message-reply address)))
3547 (defun gnus-button-url (address)
3549 ;; In Emacs 20, `browse-url-browser-function' may be an alist.
3550 (if (listp browse-url-browser-function)
3551 (browse-url address)
3552 (funcall browse-url-browser-function address)))
3554 (defun gnus-button-embedded-url (address)
3556 ;; In Emacs 20, `browse-url-browser-function' may be an alist.
3557 (if (listp browse-url-browser-function)
3558 (browse-url (gnus-strip-whitespace address))
3559 (funcall browse-url-browser-function (gnus-strip-whitespace address))))
3561 ;;; Next/prev buttons in the article buffer.
3563 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
3564 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
3566 (defvar gnus-prev-page-map nil)
3567 (unless gnus-prev-page-map
3568 (setq gnus-prev-page-map (make-sparse-keymap))
3569 (define-key gnus-prev-page-map gnus-mouse-2 'gnus-button-prev-page)
3570 (define-key gnus-prev-page-map "\r" 'gnus-button-prev-page))
3572 (defun gnus-insert-prev-page-button ()
3573 (let ((buffer-read-only nil))
3575 gnus-prev-page-line-format nil
3576 `(gnus-prev t local-map ,gnus-prev-page-map
3577 gnus-callback gnus-article-button-prev-page
3578 gnus-type annotation))))
3580 (defvar gnus-next-page-map nil)
3581 (unless gnus-next-page-map
3582 (setq gnus-next-page-map (make-keymap))
3583 (suppress-keymap gnus-prev-page-map)
3584 (define-key gnus-next-page-map gnus-mouse-2 'gnus-button-next-page)
3585 (define-key gnus-next-page-map "\r" 'gnus-button-next-page))
3587 (defun gnus-button-next-page ()
3588 "Go to the next page."
3590 (let ((win (selected-window)))
3591 (select-window (get-buffer-window gnus-article-buffer t))
3592 (gnus-article-next-page)
3593 (select-window win)))
3595 (defun gnus-button-prev-page ()
3596 "Go to the prev page."
3598 (let ((win (selected-window)))
3599 (select-window (get-buffer-window gnus-article-buffer t))
3600 (gnus-article-prev-page)
3601 (select-window win)))
3603 (defun gnus-insert-next-page-button ()
3604 (let ((buffer-read-only nil))
3605 (gnus-eval-format gnus-next-page-line-format nil
3607 t local-map ,gnus-next-page-map
3608 gnus-callback gnus-article-button-next-page
3609 gnus-type annotation))))
3611 (defun gnus-article-button-next-page (arg)
3612 "Go to the next page."
3614 (let ((win (selected-window)))
3615 (select-window (get-buffer-window gnus-article-buffer t))
3616 (gnus-article-next-page)
3617 (select-window win)))
3619 (defun gnus-article-button-prev-page (arg)
3620 "Go to the prev page."
3622 (let ((win (selected-window)))
3623 (select-window (get-buffer-window gnus-article-buffer t))
3624 (gnus-article-prev-page)
3625 (select-window win)))
3631 (defun gnus-article-header-presentation-method (entity situation)
3632 (mime-insert-decoded-header entity)
3635 (set-alist 'mime-header-presentation-method-alist
3636 'gnus-original-article-mode
3637 #'gnus-article-header-presentation-method)
3639 (defun gnus-mime-preview-quitting-method ()
3641 (gnus-article-show-summary)
3642 (mime-preview-kill-buffer)
3643 (delete-other-windows)
3644 (gnus-article-show-summary)
3645 (gnus-summary-select-article nil t)
3648 (set-alist 'mime-preview-quitting-method-alist
3649 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
3651 (defun gnus-following-method (buf)
3654 (message-yank-original)
3656 (goto-char (point-min))
3659 (set-alist 'mime-preview-following-method-alist
3660 'gnus-original-article-mode #'gnus-following-method)
3670 (run-hooks 'gnus-art-load-hook)
3672 ;;; gnus-art.el ends here