1 ;;; gnus-art.el --- article mode commands for Semi-gnus
2 ;; Copyright (C) 1996,97,98,99 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
5 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Katsumi Yamaoka <yamaoka@jpl.org>
7 ;; Keywords: mail, news, MIME
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
30 (eval-when-compile (require 'cl))
41 ;; Avoid byte-compile warnings.
43 (defvar gnus-article-decoded-p)
44 (defvar gnus-article-mime-handles)
53 (defgroup gnus-article nil
55 :link '(custom-manual "(gnus)The Article Buffer")
58 (defgroup gnus-article-treat nil
59 "Treating article parts."
60 :link '(custom-manual "(gnus)Article Hiding")
63 (defgroup gnus-article-hiding nil
64 "Hiding article parts."
65 :link '(custom-manual "(gnus)Article Hiding")
68 (defgroup gnus-article-highlight nil
69 "Article highlighting."
70 :link '(custom-manual "(gnus)Article Highlighting")
74 (defgroup gnus-article-signature nil
76 :link '(custom-manual "(gnus)Article Signature")
79 (defgroup gnus-article-headers nil
81 :link '(custom-manual "(gnus)Hiding Headers")
84 (defgroup gnus-article-washing nil
85 "Special commands on articles."
86 :link '(custom-manual "(gnus)Article Washing")
89 (defgroup gnus-article-emphasis nil
90 "Fontisizing articles."
91 :link '(custom-manual "(gnus)Article Fontisizing")
94 (defgroup gnus-article-saving nil
96 :link '(custom-manual "(gnus)Saving Articles")
99 (defgroup gnus-article-mime nil
100 "Worshiping the MIME wonder."
101 :link '(custom-manual "(gnus)Using MIME")
102 :group 'gnus-article)
104 (defgroup gnus-article-buttons nil
105 "Pushable buttons in the article buffer."
106 :link '(custom-manual "(gnus)Article Buttons")
107 :group 'gnus-article)
109 (defgroup gnus-article-various nil
110 "Other article options."
111 :link '(custom-manual "(gnus)Misc Article")
112 :group 'gnus-article)
114 (defcustom gnus-ignored-headers
115 '("^Path:" "^Expires:" "^Date-Received:" "^References:" "^Xref:" "^Lines:"
116 "^Relay-Version:" "^Message-ID:" "^Approved:" "^Sender:" "^Received:"
117 "^X-UIDL:" "^MIME-Version:" "^Return-Path:" "^In-Reply-To:"
118 "^Content-Type:" "^Content-Transfer-Encoding:" "^X-WebTV-Signature:"
119 "^X-MimeOLE:" "^X-MSMail-Priority:" "^X-Priority:" "^X-Loop:"
120 "^X-Authentication-Warning:" "^X-MIME-Autoconverted:" "^X-Face:"
121 "^X-Attribution:" "^X-Originating-IP:" "^Delivered-To:"
122 "^NNTP-[-A-Za-z]+:" "^Distribution:" "^X-no-archive:" "^X-Trace:"
123 "^X-Complaints-To:" "^X-NNTP-Posting-Host:" "^X-Orig.*:"
124 "^Abuse-Reports-To:" "^Cache-Post-Path:" "^X-Article-Creation-Date:"
125 "^X-Poster:" "^X-Mail2News-Path:" "^X-Server-Date:" "^X-Cache:"
126 "^Originator:" "^X-Problems-To:" "^X-Auth-User:" "^X-Post-Time:"
127 "^X-Admin:" "^X-UID:" "^Resent-[-A-Za-z]+:" "^X-Mailing-List:"
128 "^Precedence:" "^Original-[-A-Za-z]+:" "^X-filename:" "^X-Orcpt:"
129 "^Old-Received:" "^X-Pgp-Fingerprint:" "^X-Pgp-Key-Id:"
130 "^X-Pgp-Public-Key-Url:" "^X-Auth:" "^X-From-Line:"
131 "^X-Gnus-Article-Number:" "^X-Majordomo:" "^X-Url:" "^X-Sender:"
132 "^X-Mailing-List:" "^MBOX-Line" "^Priority:" "^X-Pgp" "^X400-[-A-Za-z]+:"
134 "*All headers that start with this regexp will be hidden.
135 This variable can also be a list of regexps of headers to be ignored.
136 If `gnus-visible-headers' is non-nil, this variable will be ignored."
137 :type '(choice :custom-show nil
140 :group 'gnus-article-hiding)
142 (defcustom gnus-visible-headers
143 "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^[BGF]?Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:\\|^X-Sent:"
144 "*All headers that do not match this regexp will be hidden.
145 This variable can also be a list of regexp of headers to remain visible.
146 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
147 :type '(repeat :value-to-internal (lambda (widget value)
148 (custom-split-regexp-maybe value))
149 :match (lambda (widget value)
151 (widget-editable-list-match widget value)))
153 :group 'gnus-article-hiding)
155 (defcustom gnus-sorted-header-list
156 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
157 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
158 "*This variable is a list of regular expressions.
159 If it is non-nil, headers that match the regular expressions will
160 be placed first in the article buffer in the sequence specified by
162 :type '(repeat regexp)
163 :group 'gnus-article-hiding)
165 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
166 "Headers that are only to be displayed if they have interesting data.
167 Possible values in this list are `empty', `newsgroups', `followup-to',
168 `reply-to', `date', `long-to', and `many-to'."
169 :type '(set (const :tag "Headers with no content." empty)
170 (const :tag "Newsgroups with only one group." newsgroups)
171 (const :tag "Followup-to identical to newsgroups." followup-to)
172 (const :tag "Reply-to identical to from." reply-to)
173 (const :tag "Date less than four days old." date)
174 (const :tag "Very long To header." long-to)
175 (const :tag "Multiple To headers." many-to))
176 :group 'gnus-article-hiding)
178 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
179 "Regexp matching signature separator.
180 This can also be a list of regexps. In that case, it will be checked
181 from head to tail looking for a separator. Searches will be done from
182 the end of the buffer."
183 :type '(repeat string)
184 :group 'gnus-article-signature)
186 (defcustom gnus-signature-limit nil
187 "Provide a limit to what is considered a signature.
188 If it is a number, no signature may not be longer (in characters) than
189 that number. If it is a floating point number, no signature may be
190 longer (in lines) than that number. If it is a function, the function
191 will be called without any parameters, and if it returns nil, there is
192 no signature in the buffer. If it is a string, it will be used as a
193 regexp. If it matches, the text in question is not a signature."
194 :type '(choice (integer :value 200)
196 (function :value fun)
197 (regexp :value ".*"))
198 :group 'gnus-article-signature)
200 (defcustom gnus-hidden-properties '(invisible t intangible t)
201 "Property list to use for hiding text."
203 :group 'gnus-article-hiding)
205 (defcustom gnus-article-x-face-command
206 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | xv -quit -"
207 "*String or function to be executed to display an X-Face header.
208 If it is a string, the command will be executed in a sub-shell
209 asynchronously. The compressed face will be piped to this command."
210 :type 'string ;Leave function case to Lisp.
211 :group 'gnus-article-washing)
213 (defcustom gnus-article-x-face-too-ugly nil
214 "Regexp matching posters whose face shouldn't be shown automatically."
215 :type '(choice regexp (const nil))
216 :group 'gnus-article-washing)
218 (defcustom gnus-emphasis-alist
220 "\\(\\s-\\|^\\|[-\"]\\|\\s(\\|\\s)\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\s-\\|[-?!.,;:\"]\\|\\s(\\|\\s)\\)")
222 '(("_" "_" underline)
225 ("_/" "/_" underline-italic)
226 ("_\\*" "\\*_" underline-bold)
227 ("\\*/" "/\\*" bold-italic)
228 ("_\\*/" "/\\*_" underline-bold-italic))))
229 `(("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
230 2 3 gnus-emphasis-underline)
234 (format format (car spec) (cadr spec))
235 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
237 "*Alist that says how to fontify certain phrases.
238 Each item looks like this:
240 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
242 The first element is a regular expression to be matched. The second
243 is a number that says what regular expression grouping used to find
244 the entire emphasized word. The third is a number that says what
245 regexp grouping should be displayed and highlighted. The fourth
246 is the face used for highlighting."
247 :type '(repeat (list :value ("" 0 0 default)
249 (integer :tag "Match group")
250 (integer :tag "Emphasize group")
252 :group 'gnus-article-emphasis)
254 (defface gnus-emphasis-bold '((t (:bold t)))
255 "Face used for displaying strong emphasized text (*word*)."
256 :group 'gnus-article-emphasis)
258 (defface gnus-emphasis-italic '((t (:italic t)))
259 "Face used for displaying italic emphasized text (/word/)."
260 :group 'gnus-article-emphasis)
262 (defface gnus-emphasis-underline '((t (:underline t)))
263 "Face used for displaying underlined emphasized text (_word_)."
264 :group 'gnus-article-emphasis)
266 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
267 "Face used for displaying underlined bold emphasized text (_*word*_)."
268 :group 'gnus-article-emphasis)
270 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
271 "Face used for displaying underlined italic emphasized text (_*word*_)."
272 :group 'gnus-article-emphasis)
274 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
275 "Face used for displaying bold italic emphasized text (/*word*/)."
276 :group 'gnus-article-emphasis)
278 (defface gnus-emphasis-underline-bold-italic
279 '((t (:bold t :italic t :underline t)))
280 "Face used for displaying underlined bold italic emphasized text.
281 Esample: (_/*word*/_)."
282 :group 'gnus-article-emphasis)
284 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
285 "Format for display of Date headers in article bodies.
286 See `format-time-string' for the possible values.
288 The variable can also be function, which should return a complete Date
289 header. The function is called with one argument, the time, which can
290 be fed to `format-time-string'."
291 :type '(choice string symbol)
292 :link '(custom-manual "(gnus)Article Date")
293 :group 'gnus-article-washing)
296 (autoload 'mail-extract-address-components "mail-extr"))
298 (defcustom gnus-save-all-headers t
299 "*If non-nil, don't remove any headers before saving."
300 :group 'gnus-article-saving
303 (defcustom gnus-prompt-before-saving 'always
304 "*This variable says how much prompting is to be done when saving articles.
305 If it is nil, no prompting will be done, and the articles will be
306 saved to the default files. If this variable is `always', each and
307 every article that is saved will be preceded by a prompt, even when
308 saving large batches of articles. If this variable is neither nil not
309 `always', there the user will be prompted once for a file name for
310 each invocation of the saving commands."
311 :group 'gnus-article-saving
312 :type '(choice (item always)
313 (item :tag "never" nil)
314 (sexp :tag "once" :format "%t\n" :value t)))
316 (defcustom gnus-saved-headers gnus-visible-headers
317 "Headers to keep if `gnus-save-all-headers' is nil.
318 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
319 If that variable is nil, however, all headers that match this regexp
320 will be kept while the rest will be deleted before saving."
321 :group 'gnus-article-saving
324 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
325 "A function to save articles in your favourite format.
326 The function must be interactively callable (in other words, it must
327 be an Emacs command).
329 Gnus provides the following functions:
331 * gnus-summary-save-in-rmail (Rmail format)
332 * gnus-summary-save-in-mail (Unix mail format)
333 * gnus-summary-save-in-folder (MH folder)
334 * gnus-summary-save-in-file (article format)
335 * gnus-summary-save-in-vm (use VM's folder format)
336 * gnus-summary-write-to-file (article format -- overwrite)."
337 :group 'gnus-article-saving
338 :type '(radio (function-item gnus-summary-save-in-rmail)
339 (function-item gnus-summary-save-in-mail)
340 (function-item gnus-summary-save-in-folder)
341 (function-item gnus-summary-save-in-file)
342 (function-item gnus-summary-save-in-vm)
343 (function-item gnus-summary-write-to-file)))
345 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
346 "A function generating a file name to save articles in Rmail format.
347 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
348 :group 'gnus-article-saving
351 (defcustom gnus-mail-save-name 'gnus-plain-save-name
352 "A function generating a file name to save articles in Unix mail format.
353 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
354 :group 'gnus-article-saving
357 (defcustom gnus-folder-save-name 'gnus-folder-save-name
358 "A function generating a file name to save articles in MH folder.
359 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
360 :group 'gnus-article-saving
363 (defcustom gnus-file-save-name 'gnus-numeric-save-name
364 "A function generating a file name to save articles in article format.
365 The function is called with NEWSGROUP, HEADERS, and optional
367 :group 'gnus-article-saving
370 (defcustom gnus-split-methods
371 '((gnus-article-archive-name)
372 (gnus-article-nndoc-name))
373 "*Variable used to suggest where articles are to be saved.
374 For instance, if you would like to save articles related to Gnus in
375 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
376 you could set this variable to something like:
378 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
379 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
381 This variable is an alist where the where the key is the match and the
382 value is a list of possible files to save in if the match is non-nil.
384 If the match is a string, it is used as a regexp match on the
385 article. If the match is a symbol, that symbol will be funcalled
386 from the buffer of the article to be saved with the newsgroup as the
387 parameter. If it is a list, it will be evaled in the same buffer.
389 If this form or function returns a string, this string will be used as
390 a possible file name; and if it returns a non-nil list, that list will
391 be used as possible file names."
392 :group 'gnus-article-saving
393 :type '(repeat (choice (list :value (fun) function)
394 (cons :value ("" "") regexp (repeat string))
397 (defcustom gnus-article-display-method-for-mime
398 'gnus-article-display-mime-message
399 "Function to display a MIME message.
400 The function is called from the article buffer."
401 :group 'gnus-article-mime
404 (defcustom gnus-article-display-method-for-traditional
405 'gnus-article-display-traditional-message
406 "*Function to display a traditional message.
407 The function is called from the article buffer."
408 :group 'gnus-article-mime
411 (defcustom gnus-page-delimiter "^\^L"
412 "*Regexp describing what to use as article page delimiters.
413 The default value is \"^\^L\", which is a form linefeed at the
414 beginning of a line."
416 :group 'gnus-article-various)
418 (defcustom gnus-article-mode-line-format "Gnus: %g %S%m"
419 "*The format specification for the article mode line.
420 See `gnus-summary-mode-line-format' for a closer description.
422 The following additional specs are available:
424 %w The article washing status.
425 %m The number of MIME parts in the article."
427 :group 'gnus-article-various)
429 (defcustom gnus-article-mode-hook nil
430 "*A hook for Gnus article mode."
432 :group 'gnus-article-various)
434 (defcustom gnus-article-menu-hook nil
435 "*Hook run after the creation of the article mode menu."
437 :group 'gnus-article-various)
439 (defcustom gnus-article-prepare-hook nil
440 "*A hook called after an article has been prepared in the article buffer.
441 If you want to run a special decoding program like nkf, use this hook."
443 :group 'gnus-article-various)
445 (defcustom gnus-article-hide-pgp-hook nil
446 "*A hook called after successfully hiding a PGP signature."
448 :group 'gnus-article-various)
450 (defcustom gnus-article-button-face 'bold
451 "Face used for highlighting buttons in the article buffer.
453 An article button is a piece of text that you can activate by pressing
454 `RET' or `mouse-2' above it."
456 :group 'gnus-article-buttons)
458 (defcustom gnus-article-mouse-face 'highlight
459 "Face used for mouse highlighting in the article buffer.
461 Article buttons will be displayed in this face when the cursor is
464 :group 'gnus-article-buttons)
466 (defcustom gnus-signature-face 'gnus-signature-face
467 "Face used for highlighting a signature in the article buffer.
468 Obsolete; use the face `gnus-signature-face' for customizations instead."
470 :group 'gnus-article-highlight
471 :group 'gnus-article-signature)
473 (defface gnus-signature-face
476 "Face used for highlighting a signature in the article buffer."
477 :group 'gnus-article-highlight
478 :group 'gnus-article-signature)
480 (defface gnus-header-from-face
483 (:foreground "spring green"))
486 (:foreground "red3"))
489 "Face used for displaying from headers."
490 :group 'gnus-article-headers
491 :group 'gnus-article-highlight)
493 (defface gnus-header-subject-face
496 (:foreground "SeaGreen3"))
499 (:foreground "red4"))
501 (:bold t :italic t)))
502 "Face used for displaying subject headers."
503 :group 'gnus-article-headers
504 :group 'gnus-article-highlight)
506 (defface gnus-header-newsgroups-face
509 (:foreground "yellow" :italic t))
512 (:foreground "MidnightBlue" :italic t))
515 "Face used for displaying newsgroups headers."
516 :group 'gnus-article-headers
517 :group 'gnus-article-highlight)
519 (defface gnus-header-name-face
522 (:foreground "SeaGreen"))
525 (:foreground "maroon"))
528 "Face used for displaying header names."
529 :group 'gnus-article-headers
530 :group 'gnus-article-highlight)
532 (defface gnus-header-content-face
535 (:foreground "forest green" :italic t))
538 (:foreground "indianred4" :italic t))
540 (:italic t))) "Face used for displaying header content."
541 :group 'gnus-article-headers
542 :group 'gnus-article-highlight)
544 (defcustom gnus-header-face-alist
545 '(("From" nil gnus-header-from-face)
546 ("Subject" nil gnus-header-subject-face)
547 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
548 ("" gnus-header-name-face gnus-header-content-face))
549 "*Controls highlighting of article header.
551 An alist of the form (HEADER NAME CONTENT).
553 HEADER is a regular expression which should match the name of an
554 header header and NAME and CONTENT are either face names or nil.
556 The name of each header field will be displayed using the face
557 specified by the first element in the list where HEADER match the
558 header name and NAME is non-nil. Similarly, the content will be
559 displayed by the first non-nil matching CONTENT face."
560 :group 'gnus-article-headers
561 :group 'gnus-article-highlight
562 :type '(repeat (list (regexp :tag "Header")
564 (item :tag "skip" nil)
565 (face :value default))
566 (choice :tag "Content"
567 (item :tag "skip" nil)
568 (face :value default)))))
570 (defcustom gnus-article-decode-hook nil
571 "*Hook run to decode charsets in articles."
572 :group 'gnus-article-headers
575 (defcustom gnus-display-mime-function 'gnus-display-mime
576 "Function to display MIME articles."
577 :group 'gnus-article-mime
580 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
581 "Function used to decode headers.")
583 (defvar gnus-article-dumbquotes-map
601 "Table for MS-to-Latin1 translation.")
603 (defcustom gnus-ignored-mime-types nil
604 "List of MIME types that should be ignored by Gnus."
605 :group 'gnus-article-mime
606 :type '(repeat regexp))
608 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
609 "List of MIME types that should not be given buttons when rendered."
610 :group 'gnus-article-mime
611 :type '(repeat regexp))
613 (defcustom gnus-article-mime-part-function nil
614 "Function called with a MIME handle as the argument.
615 This is meant for people who want to do something automatic based
616 on parts -- for instance, adding Vcard info to a database."
617 :group 'gnus-article-mime
621 ;;; The treatment variables
624 (defvar gnus-article-treat-custom
625 '(choice (const :tag "Off" nil)
627 (const :tag "Header" head)
628 (const :tag "Last" last)
629 (integer :tag "Less")
630 (sexp :tag "Predicate")))
632 (defvar gnus-article-treat-types '("text/plain")
635 (defvar gnus-inhibit-treatment nil
636 "Whether to inhibit treatment.")
638 (defcustom gnus-treat-highlight-signature 'last
639 "Highlight the signature."
640 :group 'gnus-article-treat
641 :type gnus-article-treat-custom)
643 (defcustom gnus-treat-buttonize t
645 :group 'gnus-article-treat
646 :type gnus-article-treat-custom)
648 (defcustom gnus-treat-buttonize-head 'head
649 "Add buttons to the head."
650 :group 'gnus-article-treat
651 :type gnus-article-treat-custom)
653 (defcustom gnus-treat-emphasize t
655 :group 'gnus-article-treat
656 :type gnus-article-treat-custom)
658 (defcustom gnus-treat-strip-cr nil
659 "Remove carriage returns."
660 :group 'gnus-article-treat
661 :type gnus-article-treat-custom)
663 (defcustom gnus-treat-hide-headers 'head
665 :group 'gnus-article-treat
666 :type gnus-article-treat-custom)
668 (defcustom gnus-treat-hide-boring-headers nil
669 "Hide boring headers."
670 :group 'gnus-article-treat
671 :type gnus-article-treat-custom)
673 (defcustom gnus-treat-hide-signature nil
674 "Hide the signature."
675 :group 'gnus-article-treat
676 :type gnus-article-treat-custom)
678 (defcustom gnus-treat-fill-article nil
680 :group 'gnus-article-treat
681 :type gnus-article-treat-custom)
683 (defcustom gnus-treat-hide-citation nil
685 :group 'gnus-article-treat
686 :type gnus-article-treat-custom)
688 (defcustom gnus-treat-strip-pgp t
689 "Strip PGP signatures."
690 :group 'gnus-article-treat
691 :type gnus-article-treat-custom)
693 (defcustom gnus-treat-strip-pem nil
694 "Strip PEM signatures."
695 :group 'gnus-article-treat
696 :type gnus-article-treat-custom)
698 (defcustom gnus-treat-highlight-headers 'head
699 "Highlight the headers."
700 :group 'gnus-article-treat
701 :type gnus-article-treat-custom)
703 (defcustom gnus-treat-highlight-citation t
704 "Highlight cited text."
705 :group 'gnus-article-treat
706 :type gnus-article-treat-custom)
708 (defcustom gnus-treat-date-ut nil
709 "Display the Date in UT (GMT)."
710 :group 'gnus-article-treat
711 :type gnus-article-treat-custom)
713 (defcustom gnus-treat-date-local nil
714 "Display the Date in the local timezone."
715 :group 'gnus-article-treat
716 :type gnus-article-treat-custom)
718 (defcustom gnus-treat-date-lapsed nil
719 "Display the Date header in a way that says how much time has elapsed."
720 :group 'gnus-article-treat
721 :type gnus-article-treat-custom)
723 (defcustom gnus-treat-date-original nil
724 "Display the date in the original timezone."
725 :group 'gnus-article-treat
726 :type gnus-article-treat-custom)
728 (defcustom gnus-treat-strip-trailing-blank-lines nil
729 "Strip trailing blank lines."
730 :group 'gnus-article-treat
731 :type gnus-article-treat-custom)
733 (defcustom gnus-treat-strip-leading-blank-lines nil
734 "Strip leading blank lines."
735 :group 'gnus-article-treat
736 :type gnus-article-treat-custom)
738 (defcustom gnus-treat-strip-multiple-blank-lines nil
739 "Strip multiple blank lines."
740 :group 'gnus-article-treat
741 :type gnus-article-treat-custom)
743 (defcustom gnus-treat-strip-blank-lines nil
744 "Strip all blank lines."
745 :group 'gnus-article-treat
746 :type gnus-article-treat-custom)
748 (defcustom gnus-treat-overstrike t
749 "Treat overstrike highlighting."
750 :group 'gnus-article-treat
751 :type gnus-article-treat-custom)
753 (defcustom gnus-treat-display-xface (if gnus-xemacs 'head nil)
754 "Display X-Face headers."
755 :group 'gnus-article-treat
756 :type gnus-article-treat-custom)
758 (defcustom gnus-treat-display-smileys (if gnus-xemacs t nil)
760 :group 'gnus-article-treat
761 :type gnus-article-treat-custom)
763 (defcustom gnus-treat-display-picons (if gnus-xemacs 'head nil)
766 :type gnus-article-treat-custom)
768 ;;; Internal variables
770 (defvar gnus-article-mime-handle-alist-1 nil)
771 (defvar gnus-treatment-function-alist
772 '((gnus-treat-highlight-signature gnus-article-highlight-signature)
773 (gnus-treat-buttonize gnus-article-add-buttons)
774 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
775 (gnus-treat-emphasize gnus-article-emphasize)
776 (gnus-treat-fill-article gnus-article-fill-cited-article)
777 (gnus-treat-strip-cr gnus-article-remove-cr)
778 (gnus-treat-hide-headers gnus-article-hide-headers)
779 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
780 (gnus-treat-hide-signature gnus-article-hide-signature)
781 (gnus-treat-hide-citation gnus-article-hide-citation)
782 (gnus-treat-strip-pgp gnus-article-hide-pgp)
783 (gnus-treat-strip-pem gnus-article-hide-pem)
784 (gnus-treat-highlight-headers gnus-article-highlight-headers)
785 (gnus-treat-highlight-citation gnus-article-highlight-citation)
786 (gnus-treat-highlight-signature gnus-article-highlight-signature)
787 (gnus-treat-date-ut gnus-article-date-ut)
788 (gnus-treat-date-local gnus-article-date-local)
789 (gnus-treat-date-lapsed gnus-article-date-lapsed)
790 (gnus-treat-date-original gnus-article-date-original)
791 (gnus-treat-strip-trailing-blank-lines
792 gnus-article-remove-trailing-blank-lines)
793 (gnus-treat-strip-leading-blank-lines
794 gnus-article-strip-leading-blank-lines)
795 (gnus-treat-strip-multiple-blank-lines
796 gnus-article-strip-multiple-blank-lines)
797 (gnus-treat-strip-blank-lines gnus-article-strip-blank-lines)
798 (gnus-treat-overstrike gnus-article-treat-overstrike)
799 (gnus-treat-display-xface gnus-article-display-x-face)
800 (gnus-treat-display-smileys gnus-smiley-display)))
802 (defvar gnus-article-mime-handle-alist nil)
803 (defvar article-lapsed-timer nil)
804 (defvar gnus-article-current-summary nil)
806 (defvar gnus-article-mode-syntax-table
807 (let ((table (copy-syntax-table text-mode-syntax-table)))
808 (modify-syntax-entry ?- "w" table)
809 (modify-syntax-entry ?> ")" table)
810 (modify-syntax-entry ?< "(" table)
812 "Syntax table used in article mode buffers.
813 Initialized from `text-mode-syntax-table.")
815 (defvar gnus-save-article-buffer nil)
817 (defvar gnus-article-mode-line-format-alist
818 (nconc '((?w (gnus-article-wash-status) ?s)
819 (?m (gnus-article-mime-part-status) ?s))
820 gnus-summary-mode-line-format-alist))
822 (defvar gnus-number-of-articles-to-be-saved nil)
824 (defvar gnus-inhibit-hiding nil)
826 (defsubst gnus-article-hide-text (b e props)
827 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
828 (add-text-properties b e props)
829 (when (memq 'intangible props)
831 (max (1- b) (point-min))
832 b 'intangible (cddr (memq 'intangible props)))))
834 (defmacro gnus-with-article (article &rest forms)
835 "Select ARTICLE and perform FORMS in the original article buffer.
836 Then replace the article with the result."
838 ;; We don't want the article to be marked as read.
839 (let (gnus-mark-article-hook)
840 (gnus-summary-select-article t t nil ,article))
841 (set-buffer gnus-original-article-buffer)
843 (if (not (gnus-check-backend-function
844 'request-replace-article (car gnus-article-current)))
845 (gnus-message 5 "Read-only group; not replacing")
846 (unless (gnus-request-replace-article
847 ,article (car gnus-article-current)
849 (error "Couldn't replace article")))
850 ;; The cache and backlog have to be flushed somewhat.
851 (when gnus-keep-backlog
852 (gnus-backlog-remove-article
853 (car gnus-article-current) (cdr gnus-article-current)))
855 (gnus-cache-update-article
856 (car gnus-article-current) (cdr gnus-article-current)))))
858 (put 'gnus-with-article 'lisp-indent-function 1)
859 (put 'gnus-with-article 'edebug-form-spec '(form body))
861 (defsubst gnus-article-unhide-text (b e)
862 "Remove hidden text properties from region between B and E."
863 (remove-text-properties b e gnus-hidden-properties)
864 (when (memq 'intangible gnus-hidden-properties)
865 (put-text-property (max (1- b) (point-min))
868 (defun gnus-article-hide-text-type (b e type)
869 "Hide text of TYPE between B and E."
870 (gnus-article-hide-text
871 b e (cons 'article-type (cons type gnus-hidden-properties))))
873 (defun gnus-article-unhide-text-type (b e type)
874 "Unhide text of TYPE between B and E."
875 (remove-text-properties
876 b e (cons 'article-type (cons type gnus-hidden-properties)))
877 (when (memq 'intangible gnus-hidden-properties)
878 (put-text-property (max (1- b) (point-min))
881 (defun gnus-article-hide-text-of-type (type)
882 "Hide text of TYPE in the current buffer."
884 (let ((b (point-min))
886 (while (setq b (text-property-any b e 'article-type type))
887 (add-text-properties b (incf b) gnus-hidden-properties)))))
889 (defun gnus-article-delete-text-of-type (type)
890 "Delete text of TYPE in the current buffer."
892 (let ((b (point-min)))
893 (while (setq b (text-property-any b (point-max) 'article-type type))
895 b (or (text-property-not-all b (point-max) 'article-type type)
898 (defun gnus-article-delete-invisible-text ()
899 "Delete all invisible text in the current buffer."
901 (let ((b (point-min)))
902 (while (setq b (text-property-any b (point-max) 'invisible t))
904 b (or (text-property-not-all b (point-max) 'invisible t)
907 (defun gnus-article-text-type-exists-p (type)
908 "Say whether any text of type TYPE exists in the buffer."
909 (text-property-any (point-min) (point-max) 'article-type type))
911 (defsubst gnus-article-header-rank ()
912 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
913 (let ((list gnus-sorted-header-list)
916 (when (looking-at (car list))
918 (setq list (cdr list))
922 (defun article-hide-headers (&optional arg delete)
923 "Toggle whether to hide unwanted headers and possibly sort them as well.
924 If given a negative prefix, always show; if given a positive prefix,
926 (interactive (gnus-article-hidden-arg))
928 (if (gnus-article-check-hidden-text 'headers arg)
929 ;; Show boring headers as well.
930 (gnus-article-show-hidden-text 'boring-headers)
931 ;; This function might be inhibited.
932 (unless gnus-inhibit-hiding
935 (let ((buffer-read-only nil)
937 (props (nconc (list 'article-type 'headers)
938 gnus-hidden-properties))
939 (max (1+ (length gnus-sorted-header-list)))
940 (ignored (when (not gnus-visible-headers)
941 (cond ((stringp gnus-ignored-headers)
942 gnus-ignored-headers)
943 ((listp gnus-ignored-headers)
944 (mapconcat 'identity gnus-ignored-headers
947 (cond ((stringp gnus-visible-headers)
948 gnus-visible-headers)
949 ((and gnus-visible-headers
950 (listp gnus-visible-headers))
951 (mapconcat 'identity gnus-visible-headers "\\|"))))
952 (inhibit-point-motion-hooks t)
954 ;; First we narrow to just the headers.
956 (goto-char (point-min))
957 ;; Hide any "From " lines at the beginning of (mail) articles.
958 (while (looking-at "From ")
962 (delete-region (point-min) (point))
963 (gnus-article-hide-text (point-min) (point) props)))
964 ;; Then treat the rest of the header lines.
967 (if (search-forward "\n\n" nil t) ; if there's a body
968 (progn (forward-line -1) (point))
970 ;; Then we use the two regular expressions
971 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
972 ;; select which header lines is to remain visible in the
974 (goto-char (point-min))
975 (while (re-search-forward "^[^ \t]*:" nil t)
977 ;; Mark the rank of the header.
979 (point) (1+ (point)) 'message-rank
980 (if (or (and visible (looking-at visible))
982 (not (looking-at ignored))))
983 (gnus-article-header-rank)
986 (message-sort-headers-1)
987 (when (setq beg (text-property-any
988 (point-min) (point-max) 'message-rank (+ 2 max)))
989 ;; We make the unwanted headers invisible.
991 (delete-region beg (point-max))
992 ;; Suggested by Sudish Joseph <joseph@cis.ohio-state.edu>.
993 (gnus-article-hide-text-type beg (point-max) 'headers))
994 ;; Work around XEmacs lossage.
995 (put-text-property (point-min) beg 'invisible nil))))))))
997 (defun article-hide-boring-headers (&optional arg)
998 "Toggle hiding of headers that aren't very interesting.
999 If given a negative prefix, always show; if given a positive prefix,
1001 (interactive (gnus-article-hidden-arg))
1002 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1003 (not gnus-show-all-headers))
1006 (let ((buffer-read-only nil)
1007 (list gnus-boring-article-headers)
1008 (inhibit-point-motion-hooks t)
1010 (nnheader-narrow-to-headers)
1012 (setq elem (pop list))
1013 (goto-char (point-min))
1015 ;; Hide empty headers.
1017 (while (re-search-forward "^[^:]+:[ \t]*\n[^ \t]" nil t)
1019 (gnus-article-hide-text-type
1020 (progn (beginning-of-line) (point))
1023 (if (re-search-forward "^[^ \t]" nil t)
1027 ;; Hide boring Newsgroups header.
1028 ((eq elem 'newsgroups)
1029 (when (equal (gnus-fetch-field "newsgroups")
1030 (gnus-group-real-name
1031 (if (boundp 'gnus-newsgroup-name)
1034 (gnus-article-hide-header "newsgroups")))
1035 ((eq elem 'followup-to)
1036 (when (equal (message-fetch-field "followup-to")
1037 (message-fetch-field "newsgroups"))
1038 (gnus-article-hide-header "followup-to")))
1039 ((eq elem 'reply-to)
1040 (let ((from (message-fetch-field "from"))
1041 (reply-to (message-fetch-field "reply-to")))
1046 (nth 1 (funcall gnus-extract-address-components from))
1047 (nth 1 (funcall gnus-extract-address-components reply-to)))))
1048 (gnus-article-hide-header "reply-to"))))
1050 (let ((date (message-fetch-field "date")))
1052 (< (days-between (current-time-string) date)
1054 (gnus-article-hide-header "date"))))
1056 (let ((to (message-fetch-field "to")))
1057 (when (> (length to) 1024)
1058 (gnus-article-hide-header "to"))))
1061 (goto-char (point-min))
1062 (while (re-search-forward "^to:" nil t)
1063 (setq to-count (1+ to-count)))
1064 (when (> to-count 1)
1065 (while (> to-count 0)
1066 (goto-char (point-min))
1068 (re-search-forward "^to:" nil nil to-count)
1070 (narrow-to-region (point) (point-max))
1071 (gnus-article-hide-header "to"))
1072 (setq to-count (1- to-count)))))))))))))
1074 (defun gnus-article-hide-header (header)
1076 (goto-char (point-min))
1077 (when (re-search-forward (concat "^" header ":") nil t)
1078 (gnus-article-hide-text-type
1079 (progn (beginning-of-line) (point))
1082 (if (re-search-forward "^[^ \t]" nil t)
1087 (defvar gnus-article-normalized-header-length 40
1088 "Length of normalized headers.")
1090 (defun article-normalize-headers ()
1091 "Make all header lines 40 characters long."
1093 (let ((buffer-read-only nil)
1097 (message-narrow-to-head)
1100 ((< (setq column (- (gnus-point-at-eol) (point)))
1101 gnus-article-normalized-header-length)
1103 (insert (make-string
1104 (- gnus-article-normalized-header-length column)
1106 ((> column gnus-article-normalized-header-length)
1107 (gnus-put-text-property
1109 (forward-char gnus-article-normalized-header-length)
1116 (forward-line 1))))))
1118 (defun article-treat-dumbquotes ()
1119 "Translate M******** sm*rtq**t*s into proper text.
1120 Note that this function guesses whether a character is a sm*rtq**t* or
1121 not, so it should only be used interactively."
1123 (article-translate-strings gnus-article-dumbquotes-map))
1125 (defun article-translate-characters (from to)
1126 "Translate all characters in the body of the article according to FROM and TO.
1127 FROM is a string of characters to translate from; to is a string of
1128 characters to translate to."
1130 (when (article-goto-body)
1131 (let ((buffer-read-only nil)
1132 (x (make-string 225 ?x))
1134 (while (< (incf i) (length x))
1137 (while (< i (length from))
1138 (aset x (aref from i) (aref to i))
1140 (translate-region (point) (point-max) x)))))
1142 (defun article-translate-strings (map)
1143 "Translate all string in the body of the article according to MAP.
1144 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1146 (when (article-goto-body)
1147 (let ((buffer-read-only nil)
1149 (while (setq elem (pop map))
1151 (while (search-forward (car elem) nil t)
1152 (replace-match (cadr elem)))))))))
1154 (defun article-treat-overstrike ()
1155 "Translate overstrikes into bold text."
1158 (when (article-goto-body)
1159 (let ((buffer-read-only nil))
1160 (while (search-forward "\b" nil t)
1161 (let ((next (char-after))
1162 (previous (char-after (- (point) 2))))
1163 ;; We do the boldification/underlining by hiding the
1164 ;; overstrikes and putting the proper text property
1168 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1169 (put-text-property (point) (1+ (point)) 'face 'bold))
1171 (gnus-article-hide-text-type
1172 (1- (point)) (1+ (point)) 'overstrike)
1174 (- (point) 2) (1- (point)) 'face 'underline))
1176 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1178 (point) (1+ (point)) 'face 'underline)))))))))
1180 (defun article-fill ()
1181 "Format too long lines."
1184 (let ((buffer-read-only nil))
1188 (let ((paragraph-start "^[>|#:<;* ]*[ \t]*$")
1189 (adaptive-fill-regexp "[ \t]*\\([|#:<;>*]+ *\\)?")
1190 (adaptive-fill-mode t))
1192 (and (>= (current-column) (min fill-column (window-width)))
1193 (/= (preceding-char) ?:)
1194 (fill-paragraph nil))
1195 (end-of-line 2))))))
1197 (defun article-remove-cr ()
1198 "Translate CRLF pairs into LF, and then CR into LF.."
1201 (let ((buffer-read-only nil))
1202 (goto-char (point-min))
1203 (while (search-forward "\r$" nil t)
1204 (replace-match "" t t))
1205 (goto-char (point-min))
1206 (while (search-forward "\r" nil t)
1207 (replace-match "\n" t t)))))
1209 (defun article-remove-trailing-blank-lines ()
1210 "Remove all trailing blank lines from the article."
1213 (let ((buffer-read-only nil))
1214 (goto-char (point-max))
1218 (while (and (not (bobp))
1219 (looking-at "^[ \t]*$")
1220 (not (gnus-annotation-in-region-p
1221 (point) (gnus-point-at-eol))))
1226 (defun article-display-x-face (&optional force)
1227 "Look for an X-Face header and display it if present."
1228 (interactive (list 'force))
1230 ;; Delete the old process, if any.
1231 (when (process-status "article-x-face")
1232 (delete-process "article-x-face"))
1233 (let ((inhibit-point-motion-hooks t)
1234 (case-fold-search t)
1237 (nnheader-narrow-to-headers)
1238 (setq from (message-fetch-field "from"))
1239 (goto-char (point-min))
1240 (while (and gnus-article-x-face-command
1243 ;; Check whether this face is censored.
1244 (not gnus-article-x-face-too-ugly)
1245 (and gnus-article-x-face-too-ugly from
1246 (not (string-match gnus-article-x-face-too-ugly
1248 ;; Has to be present.
1249 (re-search-forward "^X-Face: " nil t))
1250 ;; This used to try to do multiple faces (`while' instead of
1251 ;; `when' above), but (a) sending multiple EOFs to xv doesn't
1252 ;; work (b) it can crash some versions of Emacs (c) are
1253 ;; multiple faces really something to encourage?
1254 (when (stringp gnus-article-x-face-command)
1256 ;; We now have the area of the buffer where the X-Face is stored.
1259 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
1260 ;; We display the face.
1261 (if (symbolp gnus-article-x-face-command)
1262 ;; The command is a lisp function, so we call it.
1263 (if (gnus-functionp gnus-article-x-face-command)
1264 (funcall gnus-article-x-face-command beg end)
1265 (error "%s is not a function" gnus-article-x-face-command))
1266 ;; The command is a string, so we interpret the command
1267 ;; as a, well, command, and fork it off.
1268 (let ((process-connection-type nil))
1269 (process-kill-without-query
1271 "article-x-face" nil shell-file-name shell-command-switch
1272 gnus-article-x-face-command))
1273 (process-send-region "article-x-face" beg end)
1274 (process-send-eof "article-x-face"))))))))))
1276 (defun article-decode-mime-words ()
1277 "Decode all MIME-encoded words in the article."
1280 (set-buffer gnus-article-buffer)
1281 (let ((inhibit-point-motion-hooks t)
1283 (mail-parse-charset gnus-newsgroup-charset))
1284 (mail-decode-encoded-word-region (point-min) (point-max)))))
1286 (defun article-decode-charset (&optional prompt)
1287 "Decode charset-encoded text in the article.
1288 If PROMPT (the prefix), prompt for a coding system to use."
1292 (message-narrow-to-head)
1293 (let* ((inhibit-point-motion-hooks t)
1294 (case-fold-search t)
1295 (ct (message-fetch-field "Content-Type" t))
1296 (cte (message-fetch-field "Content-Transfer-Encoding" t))
1297 (ctl (and ct (condition-case ()
1298 (mail-header-parse-content-type ct)
1302 (mm-read-coding-system "Charset to decode: "))
1304 (mail-content-type-get ctl 'charset))))
1305 (mail-parse-charset gnus-newsgroup-charset)
1307 (goto-char (point-max))
1310 (narrow-to-region (point) (point-max))
1311 (when (and (or (not ctl)
1312 (equal (car ctl) "text/plain"))
1315 charset (and cte (intern (downcase
1316 (gnus-strip-whitespace cte))))
1319 (defun article-decode-encoded-words ()
1320 "Remove encoded-word encoding from headers."
1321 (let (buffer-read-only)
1322 (let ((charset (save-excursion
1323 (set-buffer gnus-summary-buffer)
1324 default-mime-charset)))
1325 (mime-decode-header-in-buffer charset)
1328 (defun article-de-quoted-unreadable (&optional force)
1329 "Translate a quoted-printable-encoded article.
1330 If FORCE, decode the article whether it is marked as quoted-printable
1332 (interactive (list 'force))
1334 (let ((buffer-read-only nil)
1335 (type (gnus-fetch-field "content-transfer-encoding"))
1336 (charset gnus-newsgroup-charset))
1338 (and type (string-match "quoted-printable" (downcase type))))
1341 (narrow-to-region (point) (point-max))
1342 (quoted-printable-decode-region (point-min) (point-max))
1344 (mm-decode-body charset)))))))
1346 (defun article-hide-pgp (&optional arg)
1347 "Toggle hiding of any PGP headers and signatures in the current article.
1348 If given a negative prefix, always show; if given a positive prefix,
1350 (interactive (gnus-article-hidden-arg))
1351 (unless (gnus-article-check-hidden-text 'pgp arg)
1353 (let ((inhibit-point-motion-hooks t)
1354 buffer-read-only beg end)
1356 (goto-char (point-min))
1357 ;; Hide the "header".
1358 (when (search-forward "\n-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
1359 (delete-region (1+ (match-beginning 0)) (match-end 0))
1360 ;; PGP 5 and GNU PG add a `Hash: <>' comment, hide that too
1361 (when (looking-at "Hash:.*$")
1362 (delete-region (point) (1+ (gnus-point-at-eol))))
1364 ;; Hide the actual signature.
1365 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
1366 (setq end (1+ (match-beginning 0)))
1369 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
1371 ;; Perhaps we shouldn't hide to the end of the buffer
1372 ;; if there is no end to the signature?
1374 ;; Hide "- " PGP quotation markers.
1376 (narrow-to-region beg end)
1377 (goto-char (point-min))
1378 (while (re-search-forward "^- " nil t)
1380 (match-beginning 0) (match-end 0)))
1382 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
1384 (defun article-hide-pem (&optional arg)
1385 "Toggle hiding of any PEM headers and signatures in the current article.
1386 If given a negative prefix, always show; if given a positive prefix,
1388 (interactive (gnus-article-hidden-arg))
1389 (unless (gnus-article-check-hidden-text 'pem arg)
1391 (let (buffer-read-only end)
1393 (goto-char (point-min))
1394 ;; hide the horrendously ugly "header".
1395 (and (search-forward "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
1398 (setq end (1+ (match-beginning 0)))
1399 (gnus-article-hide-text-type
1401 (if (search-forward "\n\n" nil t)
1405 ;; hide the trailer as well
1406 (and (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
1409 (gnus-article-hide-text-type
1410 (match-beginning 0) (match-end 0) 'pem))))))
1412 (defun article-hide-signature (&optional arg)
1413 "Hide the signature in the current article.
1414 If given a negative prefix, always show; if given a positive prefix,
1416 (interactive (gnus-article-hidden-arg))
1417 (unless (gnus-article-check-hidden-text 'signature arg)
1420 (let ((buffer-read-only nil))
1421 (when (gnus-article-narrow-to-signature)
1422 (gnus-article-hide-text-type
1423 (point-min) (point-max) 'signature)))))))
1425 (defun article-strip-leading-blank-lines ()
1426 "Remove all blank lines from the beginning of the article."
1429 (let ((inhibit-point-motion-hooks t)
1431 (when (article-goto-body)
1432 (while (and (not (eobp))
1433 (looking-at "[ \t]*$"))
1434 (gnus-delete-line))))))
1436 (defun article-goto-body ()
1437 "Place point at the start of the body."
1438 (goto-char (point-min))
1439 (if (search-forward "\n\n" nil t)
1441 (goto-char (point-max))
1444 (defun article-strip-multiple-blank-lines ()
1445 "Replace consecutive blank lines with one empty line."
1448 (let ((inhibit-point-motion-hooks t)
1450 ;; First make all blank lines empty.
1452 (while (re-search-forward "^[ \t]+$" nil t)
1453 (unless (gnus-annotation-in-region-p
1454 (match-beginning 0) (match-end 0))
1455 (replace-match "" nil t)))
1456 ;; Then replace multiple empty lines with a single empty line.
1458 (while (re-search-forward "\n\n\n+" nil t)
1459 (unless (gnus-annotation-in-region-p
1460 (match-beginning 0) (match-end 0))
1461 (replace-match "\n\n" t t))))))
1463 (defun article-strip-leading-space ()
1464 "Remove all white space from the beginning of the lines in the article."
1467 (let ((inhibit-point-motion-hooks t)
1470 (while (re-search-forward "^[ \t]+" nil t)
1471 (replace-match "" t t)))))
1473 (defun article-strip-trailing-space ()
1474 "Remove all white space from the end of the lines in the article."
1477 (let ((inhibit-point-motion-hooks t)
1480 (while (re-search-forward "[ \t]+$" nil t)
1481 (replace-match "" t t)))))
1483 (defun article-strip-blank-lines ()
1484 "Strip leading, trailing and multiple blank lines."
1486 (article-strip-leading-blank-lines)
1487 (article-remove-trailing-blank-lines)
1488 (article-strip-multiple-blank-lines))
1490 (defun article-strip-all-blank-lines ()
1491 "Strip all blank lines."
1494 (let ((inhibit-point-motion-hooks t)
1497 (while (re-search-forward "^[ \t]*\n" nil t)
1498 (replace-match "" t t)))))
1500 (defun gnus-article-narrow-to-signature ()
1501 "Narrow to the signature; return t if a signature is found, else nil."
1503 (let ((inhibit-point-motion-hooks t))
1504 (when (gnus-article-search-signature)
1506 ;; Check whether we have some limits to what we consider
1507 ;; to be a signature.
1508 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
1509 (list gnus-signature-limit)))
1511 (while (setq limit (pop limits))
1512 (if (or (and (integerp limit)
1513 (< (- (point-max) (point)) limit))
1515 (< (count-lines (point) (point-max)) limit))
1516 (and (gnus-functionp limit)
1518 (and (stringp limit)
1519 (not (re-search-forward limit nil t))))
1520 () ; This limit did not succeed.
1524 (narrow-to-region (point) (point-max))
1527 (defun gnus-article-search-signature ()
1528 "Search the current buffer for the signature separator.
1529 Put point at the beginning of the signature separator."
1530 (let ((cur (point)))
1531 (goto-char (point-max))
1532 (if (if (stringp gnus-signature-separator)
1533 (re-search-backward gnus-signature-separator nil t)
1534 (let ((seps gnus-signature-separator))
1536 (not (re-search-backward (car seps) nil t)))
1544 (autoload 'w3-display "w3-parse")
1545 (autoload 'w3-do-setup "w3" "" t)
1546 (autoload 'w3-region "w3-display" "" t))
1548 (defun gnus-article-treat-html ()
1551 (let ((cbuf (current-buffer)))
1552 (set-buffer gnus-article-buffer)
1553 (let (buf buffer-read-only b e)
1555 (goto-char (point-min))
1557 (if (search-forward "\n\n" nil t)
1560 (setq e (point-max)))
1562 (insert-buffer-substring gnus-article-buffer b e)
1564 (save-window-excursion
1565 (w3-region (point-min) (point-max))
1566 (setq buf (buffer-substring-no-properties (point-min) (point-max)))))
1568 (delete-region (point-min) (point-max))
1571 (goto-char (point-min))
1572 (set-window-start (get-buffer-window (current-buffer)) (point-min))
1573 (set-buffer cbuf))))
1575 (defun gnus-article-hidden-arg ()
1576 "Return the current prefix arg as a number, or 0 if no prefix."
1577 (list (if current-prefix-arg
1578 (prefix-numeric-value current-prefix-arg)
1581 (defun gnus-article-check-hidden-text (type arg)
1582 "Return nil if hiding is necessary.
1583 Arg can be nil or a number. Nil and positive means hide, negative
1584 means show, 0 means toggle."
1588 (let ((hide (gnus-article-hidden-text-p type)))
1594 (gnus-article-show-hidden-text type))
1596 (if (eq hide 'hidden)
1597 (gnus-article-show-hidden-text type)
1600 (defun gnus-article-hidden-text-p (type)
1601 "Say whether the current buffer contains hidden text of type TYPE."
1602 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
1604 (not (get-text-property pos 'invisible)))
1606 (text-property-any (1+ pos) (point-max) 'article-type type)))
1611 (defun gnus-article-show-hidden-text (type &optional hide)
1612 "Show all hidden text of type TYPE.
1613 If HIDE, hide the text instead."
1615 (let ((buffer-read-only nil)
1616 (inhibit-point-motion-hooks t)
1619 (while (setq beg (text-property-any end (point-max) 'article-type type))
1622 (text-property-not-all beg (point-max) 'article-type type)
1625 (gnus-article-hide-text beg end gnus-hidden-properties)
1626 (gnus-article-unhide-text beg end))
1630 (defconst article-time-units
1631 `((year . ,(* 365.25 24 60 60))
1632 (week . ,(* 7 24 60 60))
1633 (day . ,(* 24 60 60))
1637 "Mapping from time units to seconds.")
1639 (defun article-date-ut (&optional type highlight header)
1640 "Convert DATE date to universal time in the current article.
1641 If TYPE is `local', convert to local time; if it is `lapsed', output
1642 how much time has lapsed since DATE."
1643 (interactive (list 'ut t))
1644 (let* ((header (or header
1645 (mail-header-date (save-excursion
1646 (set-buffer gnus-summary-buffer)
1647 gnus-current-headers))
1648 (message-fetch-field "date")
1650 (date (if (vectorp header) (mail-header-date header)
1652 (date-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
1653 (inhibit-point-motion-hooks t)
1654 bface eface newline)
1655 (when (and date (not (string= date "")))
1658 (nnheader-narrow-to-headers)
1659 (let ((buffer-read-only nil))
1660 ;; Delete any old Date headers.
1661 (if (re-search-forward date-regexp nil t)
1663 (setq bface (get-text-property (gnus-point-at-bol) 'face)
1664 eface (get-text-property (1- (gnus-point-at-eol))
1666 (delete-region (progn (beginning-of-line) (point))
1667 (progn (end-of-line) (point)))
1668 (beginning-of-line))
1669 (goto-char (point-max))
1671 (insert (article-make-date-line date type))
1674 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
1675 (put-text-property (match-beginning 1) (1+ (match-end 1))
1677 (put-text-property (match-beginning 2) (match-end 2)
1681 (insert "\n"))))))))
1683 (defun article-make-date-line (date type)
1684 "Return a DATE line of TYPE."
1685 (let ((time (condition-case ()
1689 ;; Convert to the local timezone. We have to slap a
1690 ;; `condition-case' round the calls to the timezone
1691 ;; functions since they aren't particularly resistant to
1694 (let ((tz (car (current-time-zone))))
1695 (format "Date: %s %s%04d" (current-time-string time)
1696 (if (> tz 0) "+" "-") (abs (/ tz 36)))))
1697 ;; Convert to Universal Time.
1700 (current-time-string
1701 (let* ((e (parse-time-string date))
1702 (tm (apply 'encode-time e))
1704 (ls (- (cadr tm) (car (current-time-zone)))))
1705 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
1706 ((> ls 65535) (list (1+ ms) (- ls 65536)))
1709 ;; Get the original date from the article.
1710 ((eq type 'original)
1711 (concat "Date: " (if (string-match "\n+$" date)
1712 (substring date 0 (match-beginning 0))
1714 ;; Let the user define the format.
1716 (if (gnus-functionp gnus-article-time-format)
1717 (funcall gnus-article-time-format time)
1720 (format-time-string gnus-article-time-format time))))
1725 (format-time-string "%Y%M%DT%h%m%s" time)))
1726 ;; Do an X-Sent lapsed format.
1728 ;; If the date is seriously mangled, the timezone functions are
1729 ;; liable to bug out, so we ignore all errors.
1730 (let* ((now (current-time))
1731 (real-time (subtract-time now time))
1732 (real-sec (and real-time
1733 (+ (* (float (car real-time)) 65536)
1735 (sec (and real-time (abs real-sec)))
1745 ;; This is a bit convoluted, but basically we go
1746 ;; through the time units for years, weeks, etc,
1747 ;; and divide things to see whether that results
1748 ;; in positive answers.
1751 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
1752 ;; The (remaining) seconds are too few to
1753 ;; be divided into this time unit.
1755 ;; It's big enough, so we output it.
1756 (setq sec (- sec (* num (cdr unit))))
1758 (concat (if prev ", " "") (int-to-string
1760 " " (symbol-name (car unit))
1761 (if (> num 1) "s" ""))
1763 article-time-units "")
1764 ;; If dates are odd, then it might appear like the
1765 ;; article was sent in the future.
1768 " in the future"))))))
1770 (error "Unknown conversion type: %s" type)))))
1772 (defun article-date-local (&optional highlight)
1773 "Convert the current article date to the local timezone."
1774 (interactive (list t))
1775 (article-date-ut 'local highlight))
1777 (defun article-date-original (&optional highlight)
1778 "Convert the current article date to what it was originally.
1779 This is only useful if you have used some other date conversion
1780 function and want to see what the date was before converting."
1781 (interactive (list t))
1782 (article-date-ut 'original highlight))
1784 (defun article-date-lapsed (&optional highlight)
1785 "Convert the current article date to time lapsed since it was sent."
1786 (interactive (list t))
1787 (article-date-ut 'lapsed highlight))
1789 (defun article-update-date-lapsed ()
1790 "Function to be run from a timer to update the lapsed time line."
1791 (let (deactivate-mark)
1796 (set-buffer (window-buffer w))
1797 (when (eq major-mode 'gnus-article-mode)
1798 (goto-char (point-min))
1799 (when (re-search-forward "^X-Sent:" nil t)
1800 (article-date-lapsed t))))
1803 (defun gnus-start-date-timer (&optional n)
1804 "Start a timer to update the X-Sent header in the article buffers.
1805 The numerical prefix says how frequently (in seconds) the function
1810 (gnus-stop-date-timer)
1811 (setq article-lapsed-timer
1812 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
1814 (defun gnus-stop-date-timer ()
1815 "Stop the X-Sent timer."
1817 (when article-lapsed-timer
1818 (nnheader-cancel-timer article-lapsed-timer)
1819 (setq article-lapsed-timer nil)))
1821 (defun article-date-user (&optional highlight)
1822 "Convert the current article date to the user-defined format.
1823 This format is defined by the `gnus-article-time-format' variable."
1824 (interactive (list t))
1825 (article-date-ut 'user highlight))
1827 (defun article-date-iso8601 (&optional highlight)
1828 "Convert the current article date to ISO8601."
1829 (interactive (list t))
1830 (article-date-ut 'iso8601 highlight))
1832 (defun article-show-all ()
1833 "Show all hidden text in the article buffer."
1836 (let ((buffer-read-only nil))
1837 (gnus-article-unhide-text (point-min) (point-max)))))
1839 (defun article-emphasize (&optional arg)
1840 "Emphasize text according to `gnus-emphasis-alist'."
1841 (interactive (gnus-article-hidden-arg))
1842 (unless (gnus-article-check-hidden-text 'emphasis arg)
1844 (let ((alist gnus-emphasis-alist)
1845 (buffer-read-only nil)
1846 (props (append '(article-type emphasis)
1847 gnus-hidden-properties))
1848 regexp elem beg invisible visible face)
1851 (while (setq elem (pop alist))
1853 (setq regexp (car elem)
1854 invisible (nth 1 elem)
1855 visible (nth 2 elem)
1857 (while (re-search-forward regexp nil t)
1858 (when (and (match-beginning visible) (match-beginning invisible))
1859 (gnus-article-hide-text
1860 (match-beginning invisible) (match-end invisible) props)
1861 (gnus-article-unhide-text-type
1862 (match-beginning visible) (match-end visible) 'emphasis)
1863 (gnus-put-text-property-excluding-newlines
1864 (match-beginning visible) (match-end visible) 'face face)
1865 (goto-char (match-end invisible)))))))))
1867 (defvar gnus-summary-article-menu)
1868 (defvar gnus-summary-post-menu)
1870 ;;; Saving functions.
1872 (defun gnus-article-save (save-buffer file &optional num)
1873 "Save the currently selected article."
1874 (unless gnus-save-all-headers
1875 ;; Remove headers according to `gnus-saved-headers'.
1876 (let ((gnus-visible-headers
1877 (or gnus-saved-headers gnus-visible-headers))
1878 (gnus-article-buffer save-buffer))
1880 (set-buffer save-buffer)
1881 (article-hide-headers 1 t))))
1882 (save-window-excursion
1883 (if (not gnus-default-article-saver)
1884 (error "No default saver is defined")
1885 ;; !!! Magic! The saving functions all save
1886 ;; `gnus-save-article-buffer' (or so they think), but we
1887 ;; bind that variable to our save-buffer.
1888 (set-buffer gnus-article-buffer)
1889 (let* ((gnus-save-article-buffer save-buffer)
1892 ((not gnus-prompt-before-saving) 'default)
1893 ((eq gnus-prompt-before-saving 'always) nil)
1895 (gnus-number-of-articles-to-be-saved
1896 (when (eq gnus-prompt-before-saving t)
1898 (set-buffer gnus-article-current-summary)
1899 (funcall gnus-default-article-saver filename)))))
1901 (defun gnus-read-save-file-name (prompt &optional filename
1902 function group headers variable)
1904 (funcall function group headers (symbol-value variable)))
1909 ((eq filename 'default)
1915 (let* ((split-name (gnus-get-split-value gnus-split-methods))
1918 (if (and gnus-number-of-articles-to-be-saved
1919 (> gnus-number-of-articles-to-be-saved 1))
1920 (format "these %d articles"
1921 gnus-number-of-articles-to-be-saved)
1924 ;; Let the split methods have their say.
1926 ;; No split name was found.
1929 (concat prompt " (default "
1930 (file-name-nondirectory default-name) ") ")
1931 (file-name-directory default-name)
1933 ;; A single group name is returned.
1934 ((stringp split-name)
1936 (funcall function split-name headers
1937 (symbol-value variable)))
1939 (concat prompt " (default "
1940 (file-name-nondirectory default-name) ") ")
1941 (file-name-directory default-name)
1943 ;; A single split name was found
1944 ((= 1 (length split-name))
1945 (let* ((name (expand-file-name
1946 (car split-name) gnus-article-save-directory))
1947 (dir (cond ((file-directory-p name)
1948 (file-name-as-directory name))
1949 ((file-exists-p name) name)
1950 (t gnus-article-save-directory))))
1952 (concat prompt " (default " name ") ")
1954 ;; A list of splits was found.
1956 (setq split-name (nreverse split-name))
1958 (let ((file-name-history
1959 (nconc split-name file-name-history)))
1963 (concat prompt " (`M-p' for defaults) ")
1964 gnus-article-save-directory
1966 gnus-article-save-directory)))
1967 (car (push result file-name-history)))))))
1968 ;; Create the directory.
1969 (gnus-make-directory (file-name-directory file))
1970 ;; If we have read a directory, we append the default file name.
1971 (when (file-directory-p file)
1972 (setq file (concat (file-name-as-directory file)
1973 (file-name-nondirectory default-name))))
1974 ;; Possibly translate some characters.
1975 (nnheader-translate-file-chars file)))))
1976 (gnus-make-directory (file-name-directory result))
1977 (set variable result)))
1979 (defun gnus-article-archive-name (group)
1980 "Return the first instance of an \"Archive-name\" in the current buffer."
1981 (let ((case-fold-search t))
1982 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
1983 (nnheader-concat gnus-article-save-directory
1984 (match-string 1)))))
1986 (defun gnus-article-nndoc-name (group)
1987 "If GROUP is an nndoc group, return the name of the parent group."
1988 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
1989 (gnus-group-get-parameter group 'save-article-group)))
1991 (defun gnus-summary-save-in-rmail (&optional filename)
1992 "Append this article to Rmail file.
1993 Optional argument FILENAME specifies file name.
1994 Directory to save to is default to `gnus-article-save-directory'."
1995 (setq filename (gnus-read-save-file-name
1996 "Save %s in rmail file:" filename
1997 gnus-rmail-save-name gnus-newsgroup-name
1998 gnus-current-headers 'gnus-newsgroup-last-rmail))
1999 (gnus-eval-in-buffer-window gnus-save-article-buffer
2003 (gnus-output-to-rmail filename))))
2006 (defun gnus-summary-save-in-mail (&optional filename)
2007 "Append this article to Unix mail file.
2008 Optional argument FILENAME specifies file name.
2009 Directory to save to is default to `gnus-article-save-directory'."
2010 (setq filename (gnus-read-save-file-name
2011 "Save %s in Unix mail file:" filename
2012 gnus-mail-save-name gnus-newsgroup-name
2013 gnus-current-headers 'gnus-newsgroup-last-mail))
2014 (gnus-eval-in-buffer-window gnus-save-article-buffer
2018 (if (and (file-readable-p filename)
2019 (mail-file-babyl-p filename))
2020 (rmail-output-to-rmail-file filename t)
2021 (gnus-output-to-mail filename)))))
2024 (defun gnus-summary-save-in-file (&optional filename overwrite)
2025 "Append this article to file.
2026 Optional argument FILENAME specifies file name.
2027 Directory to save to is default to `gnus-article-save-directory'."
2028 (setq filename (gnus-read-save-file-name
2029 "Save %s in file:" filename
2030 gnus-file-save-name gnus-newsgroup-name
2031 gnus-current-headers 'gnus-newsgroup-last-file))
2032 (gnus-eval-in-buffer-window gnus-save-article-buffer
2036 (when (and overwrite
2037 (file-exists-p filename))
2038 (delete-file filename))
2039 (gnus-output-to-file filename))))
2042 (defun gnus-summary-write-to-file (&optional filename)
2043 "Write this article to a file.
2044 Optional argument FILENAME specifies file name.
2045 The directory to save in defaults to `gnus-article-save-directory'."
2046 (gnus-summary-save-in-file nil t))
2048 (defun gnus-summary-save-body-in-file (&optional filename)
2049 "Append this article body to a file.
2050 Optional argument FILENAME specifies file name.
2051 The directory to save in defaults to `gnus-article-save-directory'."
2052 (setq filename (gnus-read-save-file-name
2053 "Save %s body in file:" filename
2054 gnus-file-save-name gnus-newsgroup-name
2055 gnus-current-headers 'gnus-newsgroup-last-file))
2056 (gnus-eval-in-buffer-window gnus-save-article-buffer
2060 (when (article-goto-body)
2061 (narrow-to-region (point) (point-max)))
2062 (gnus-output-to-file filename))))
2065 (defun gnus-summary-save-in-pipe (&optional command)
2066 "Pipe this article to subprocess."
2068 (cond ((and (eq command 'default)
2069 gnus-last-shell-command)
2070 gnus-last-shell-command)
2074 "Shell command on %s: "
2075 (if (and gnus-number-of-articles-to-be-saved
2076 (> gnus-number-of-articles-to-be-saved 1))
2077 (format "these %d articles"
2078 gnus-number-of-articles-to-be-saved)
2080 gnus-last-shell-command))))
2081 (when (string-equal command "")
2082 (setq command gnus-last-shell-command))
2083 (gnus-eval-in-buffer-window gnus-article-buffer
2086 (shell-command-on-region (point-min) (point-max) command nil)))
2087 (setq gnus-last-shell-command command))
2089 ;;; Article file names when saving.
2091 (defun gnus-capitalize-newsgroup (newsgroup)
2092 "Capitalize NEWSGROUP name."
2093 (when (not (zerop (length newsgroup)))
2094 (concat (char-to-string (upcase (aref newsgroup 0)))
2095 (substring newsgroup 1))))
2097 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2098 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2099 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
2100 Otherwise, it is like ~/News/news/group/num."
2103 (concat (if (gnus-use-long-file-name 'not-save)
2104 (gnus-capitalize-newsgroup newsgroup)
2105 (gnus-newsgroup-directory-form newsgroup))
2106 "/" (int-to-string (mail-header-number headers)))
2107 gnus-article-save-directory)))
2109 (string-equal (file-name-directory default)
2110 (file-name-directory last-file))
2111 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2113 (or last-file default))))
2115 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2116 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2117 If variable `gnus-use-long-file-name' is non-nil, it is
2118 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2121 (concat (if (gnus-use-long-file-name 'not-save)
2123 (gnus-newsgroup-directory-form newsgroup))
2124 "/" (int-to-string (mail-header-number headers)))
2125 gnus-article-save-directory)))
2127 (string-equal (file-name-directory default)
2128 (file-name-directory last-file))
2129 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2131 (or last-file default))))
2133 (defun gnus-Plain-save-name (newsgroup headers &optional last-file)
2134 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2135 If variable `gnus-use-long-file-name' is non-nil, it is
2136 ~/News/News.group. Otherwise, it is like ~/News/news/group/news."
2139 (if (gnus-use-long-file-name 'not-save)
2140 (gnus-capitalize-newsgroup newsgroup)
2141 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2142 gnus-article-save-directory)))
2144 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2145 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2146 If variable `gnus-use-long-file-name' is non-nil, it is
2147 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2150 (if (gnus-use-long-file-name 'not-save)
2152 (concat (gnus-newsgroup-directory-form newsgroup) "/news"))
2153 gnus-article-save-directory)))
2160 (setq afunc (car func)
2163 gfunc (intern (format "gnus-%s" func))))
2165 (if (not (fboundp afunc))
2167 `(lambda (&optional interactive &rest args)
2168 ,(documentation afunc t)
2169 (interactive (list t))
2171 (set-buffer gnus-article-buffer)
2173 (call-interactively ',afunc)
2174 (apply ',afunc args))))))))
2175 '(article-hide-headers
2176 article-hide-boring-headers
2177 article-treat-overstrike
2178 (article-fill . gnus-article-word-wrap)
2180 article-display-x-face
2181 article-de-quoted-unreadable
2182 article-mime-decode-quoted-printable
2185 article-hide-signature
2186 article-remove-trailing-blank-lines
2187 article-strip-leading-blank-lines
2188 article-strip-multiple-blank-lines
2189 article-strip-leading-space
2190 article-strip-trailing-space
2191 article-strip-blank-lines
2192 article-strip-all-blank-lines
2194 article-date-iso8601
2195 article-date-original
2197 article-decode-mime-words
2198 article-decode-charset
2199 article-decode-encoded-words
2203 article-treat-dumbquotes
2204 article-normalize-headers
2205 (article-show-all . gnus-article-show-all-headers))))
2208 ;;; Gnus article mode
2211 (put 'gnus-article-mode 'mode-class 'special)
2213 (gnus-define-keys gnus-article-mode-map
2214 " " gnus-article-goto-next-page
2215 "\177" gnus-article-goto-prev-page
2216 [delete] gnus-article-goto-prev-page
2217 "\C-c^" gnus-article-refer-article
2218 "h" gnus-article-show-summary
2219 "s" gnus-article-show-summary
2220 "\C-c\C-m" gnus-article-mail
2221 "?" gnus-article-describe-briefly
2222 gnus-mouse-2 gnus-article-push-button
2223 "\r" gnus-article-press-button
2224 "\t" gnus-article-next-button
2225 "\M-\t" gnus-article-prev-button
2226 "e" gnus-article-edit
2227 "<" beginning-of-buffer
2229 "\C-c\C-i" gnus-info-find-node
2232 "\C-d" gnus-article-read-summary-keys
2233 "\M-*" gnus-article-read-summary-keys
2234 "\M-#" gnus-article-read-summary-keys
2235 "\M-^" gnus-article-read-summary-keys
2236 "\M-g" gnus-article-read-summary-keys)
2238 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
2241 (unless (lookup-key gnus-article-mode-map key)
2242 (define-key gnus-article-mode-map key
2243 'gnus-article-read-summary-keys)))
2248 (let ((key (car elt)))
2249 (and (> (length key) 0)
2250 (not (eq 'menu-bar (aref key 0)))
2251 (symbolp (lookup-key gnus-summary-mode-map key))
2253 (accessible-keymaps gnus-summary-mode-map))
2257 (push (char-to-string c) keys)
2261 (defun gnus-article-make-menu-bar ()
2262 (gnus-turn-off-edit-menu 'article)
2263 (unless (boundp 'gnus-article-article-menu)
2265 gnus-article-article-menu gnus-article-mode-map ""
2267 ["Scroll forwards" gnus-article-goto-next-page t]
2268 ["Scroll backwards" gnus-article-goto-prev-page t]
2269 ["Show summary" gnus-article-show-summary t]
2270 ["Fetch Message-ID at point" gnus-article-refer-article t]
2271 ["Mail to address at point" gnus-article-mail t]
2272 ["Send a bug report" gnus-bug t]))
2275 gnus-article-treatment-menu gnus-article-mode-map ""
2277 ["Hide headers" gnus-article-hide-headers t]
2278 ["Hide signature" gnus-article-hide-signature t]
2279 ["Hide citation" gnus-article-hide-citation t]
2280 ["Treat overstrike" gnus-article-treat-overstrike t]
2281 ["Remove carriage return" gnus-article-remove-cr t]))
2283 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
2285 (when (boundp 'gnus-summary-post-menu)
2286 (define-key gnus-article-mode-map [menu-bar post]
2287 (cons "Post" gnus-summary-post-menu)))
2289 (gnus-run-hooks 'gnus-article-menu-hook)))
2291 (defun gnus-article-mode ()
2292 "Major mode for displaying an article.
2294 All normal editing commands are switched off.
2296 The following commands are available in addition to all summary mode
2298 \\<gnus-article-mode-map>
2299 \\[gnus-article-next-page]\t Scroll the article one page forwards
2300 \\[gnus-article-prev-page]\t Scroll the article one page backwards
2301 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
2302 \\[gnus-article-show-summary]\t Display the summary buffer
2303 \\[gnus-article-mail]\t Send a reply to the address near point
2304 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
2305 \\[gnus-info-find-node]\t Go to the Gnus info node"
2307 (when (gnus-visual-p 'article-menu 'menu)
2308 (gnus-article-make-menu-bar))
2309 (gnus-simplify-mode-line)
2310 (setq mode-name "Article")
2311 (setq major-mode 'gnus-article-mode)
2312 (make-local-variable 'minor-mode-alist)
2313 (unless (assq 'gnus-show-mime minor-mode-alist)
2314 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
2315 (use-local-map gnus-article-mode-map)
2316 (gnus-update-format-specifications nil 'article-mode)
2317 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
2318 (make-local-variable 'gnus-page-broken)
2319 (make-local-variable 'gnus-button-marker-list)
2320 (make-local-variable 'gnus-article-current-summary)
2321 (make-local-variable 'gnus-article-mime-handles)
2322 (make-local-variable 'gnus-article-decoded-p)
2323 (make-local-variable 'gnus-article-mime-handle-alist)
2324 (gnus-set-default-directory)
2325 (buffer-disable-undo)
2326 (setq buffer-read-only t)
2327 (set-syntax-table gnus-article-mode-syntax-table)
2328 (gnus-run-hooks 'gnus-article-mode-hook))
2330 (defun gnus-article-setup-buffer ()
2331 "Initialize the article buffer."
2332 (let* ((name (if gnus-single-article-buffer "*Article*"
2333 (concat "*Article " gnus-newsgroup-name "*")))
2335 (progn (string-match "\\*Article" name)
2336 (concat " *Original Article"
2337 (substring name (match-end 0))))))
2338 (setq gnus-article-buffer name)
2339 (setq gnus-original-article-buffer original)
2340 (setq gnus-article-mime-handle-alist nil)
2341 ;; This might be a variable local to the summary buffer.
2342 (unless gnus-single-article-buffer
2344 (set-buffer gnus-summary-buffer)
2345 (setq gnus-article-buffer name)
2346 (setq gnus-original-article-buffer original)
2347 (gnus-set-global-variables)))
2348 ;; Init original article buffer.
2350 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
2351 (setq major-mode 'gnus-original-article-mode)
2352 (make-local-variable 'gnus-original-article))
2353 (if (get-buffer name)
2356 (buffer-disable-undo)
2357 (setq buffer-read-only t)
2358 (unless (eq major-mode 'gnus-article-mode)
2359 (gnus-article-mode))
2362 (set-buffer (gnus-get-buffer-create name))
2364 (make-local-variable 'gnus-summary-buffer)
2365 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2366 (current-buffer)))))
2368 ;; Set article window start at LINE, where LINE is the number of lines
2369 ;; from the head of the article.
2370 (defun gnus-article-set-window-start (&optional line)
2372 (get-buffer-window gnus-article-buffer t)
2374 (set-buffer gnus-article-buffer)
2375 (goto-char (point-min))
2378 (gnus-message 6 "Moved to bookmark")
2379 (search-forward "\n\n" nil t)
2383 ;;; @@ article filters
2386 (defun gnus-article-display-mime-message ()
2387 "Article display method for MIME message."
2388 ;; called from `gnus-original-article-buffer'.
2389 (let (charset all-headers)
2390 (with-current-buffer gnus-summary-buffer
2391 (setq charset default-mime-charset
2392 all-headers gnus-have-all-headers))
2393 (make-local-variable 'default-mime-charset)
2394 (setq default-mime-charset charset)
2395 (mime-display-message mime-message-structure
2396 gnus-article-buffer nil gnus-article-mode-map)
2398 (gnus-article-hide-headers nil -1))
2399 (make-local-variable 'default-mime-charset)
2400 (setq default-mime-charset charset)
2402 ;; `mime-display-message' changes current buffer to `gnus-article-buffer'.
2403 (make-local-variable 'mime-button-mother-dispatcher)
2404 (setq mime-button-mother-dispatcher
2405 (function gnus-article-push-button))
2406 (run-hooks 'gnus-mime-article-prepare-hook))
2408 (defun gnus-article-display-traditional-message ()
2409 "Article display method for traditional message."
2410 (set-buffer gnus-article-buffer)
2411 (let (buffer-read-only)
2413 (insert-buffer-substring gnus-original-article-buffer)))
2415 (defun gnus-article-make-full-mail-header (&optional number charset)
2416 "Create a new mail header structure in a raw article buffer."
2417 (unless (and number charset)
2418 (save-current-buffer
2419 (set-buffer gnus-summary-buffer)
2421 (setq number (or (cdr gnus-article-current) 0)))
2423 (setq charset (or default-mime-charset 'x-ctext)))))
2424 (goto-char (point-min))
2425 (let ((header-end (if (search-forward "\n\n" nil t)
2427 (goto-char (point-max))))
2428 (chars (- (point-max) (point)))
2429 (lines (count-lines (point) (point-max)))
2430 (default-mime-charset charset)
2432 (narrow-to-region (point-min) header-end)
2433 (setq xref (std11-fetch-field "xref"))
2435 (make-full-mail-header
2437 (std11-fetch-field "subject")
2438 (std11-fetch-field "from")
2439 (std11-fetch-field "date")
2440 (std11-fetch-field "message-id")
2441 (std11-fetch-field "references")
2444 (when xref (concat "Xref: " xref)))
2447 (defun gnus-article-prepare (article &optional all-headers header)
2448 "Prepare ARTICLE in article mode buffer.
2449 ARTICLE should either be an article number or a Message-ID.
2450 If ARTICLE is an id, HEADER should be the article headers.
2451 If ALL-HEADERS is non-nil, no headers are hidden."
2453 ;; Make sure we start in a summary buffer.
2454 (unless (eq major-mode 'gnus-summary-mode)
2455 (set-buffer gnus-summary-buffer))
2456 (setq gnus-summary-buffer (current-buffer))
2457 (let* ((gnus-article (if header (mail-header-number header) article))
2458 (summary-buffer (current-buffer))
2459 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
2460 (group gnus-newsgroup-name)
2463 (gnus-article-setup-buffer)
2464 (set-buffer gnus-original-article-buffer)
2465 ;; Deactivate active regions.
2466 (when (and (boundp 'transient-mark-mode)
2467 transient-mark-mode)
2468 (setq mark-active nil))
2469 (if (not (setq result (let ((buffer-read-only nil))
2470 (gnus-request-article-this-buffer
2472 ;; There is no such article.
2474 (when (and (numberp article)
2475 (not (memq article gnus-newsgroup-sparse)))
2476 (setq gnus-article-current
2477 (cons gnus-newsgroup-name article))
2478 (set-buffer gnus-summary-buffer)
2479 (setq gnus-current-article article)
2480 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
2482 (gnus-summary-set-agent-mark article)
2483 (message "Message marked for downloading"))
2484 (gnus-summary-mark-article article gnus-canceled-mark)
2485 (unless (memq article gnus-newsgroup-sparse)
2487 "No such article (may have expired or been canceled)")))))
2488 (if (or (eq result 'pseudo)
2489 (eq result 'nneething))
2492 (set-buffer summary-buffer)
2493 (push article gnus-newsgroup-history)
2494 (setq gnus-last-article gnus-current-article
2495 gnus-current-article 0
2496 gnus-current-headers nil
2497 gnus-article-current nil)
2498 (if (eq result 'nneething)
2499 (gnus-configure-windows 'summary)
2500 (gnus-configure-windows 'article))
2501 (gnus-set-global-variables))
2502 (let ((gnus-article-mime-handle-alist-1
2503 gnus-article-mime-handle-alist))
2504 (gnus-set-mode-line 'article)))
2505 ;; The result from the `request' was an actual article -
2506 ;; or at least some text that is now displayed in the
2508 (when (and (numberp article)
2509 (not (eq article gnus-current-article)))
2510 ;; Seems like a new article has been selected.
2511 ;; `gnus-current-article' must be an article number.
2513 (set-buffer summary-buffer)
2514 (push article gnus-newsgroup-history)
2515 (setq gnus-last-article gnus-current-article
2516 gnus-current-article article
2517 gnus-current-headers
2518 (gnus-summary-article-header gnus-current-article)
2519 gnus-article-current
2520 (cons gnus-newsgroup-name gnus-current-article))
2521 (unless (vectorp gnus-current-headers)
2522 (setq gnus-current-headers nil))
2523 (gnus-summary-goto-subject gnus-current-article)
2524 (when (gnus-summary-show-thread)
2525 ;; If the summary buffer really was folded, the
2526 ;; previous goto may not actually have gone to
2527 ;; the right article, but the thread root instead.
2529 (gnus-summary-goto-subject gnus-current-article))
2530 (gnus-run-hooks 'gnus-mark-article-hook)
2531 (gnus-set-mode-line 'summary)
2532 (when (gnus-visual-p 'article-highlight 'highlight)
2533 (gnus-run-hooks 'gnus-visual-mark-article-hook))
2534 ;; Set the global newsgroup variables here.
2535 ;; Suggested by Jim Sisolak
2536 ;; <sisolak@trans4.neep.wisc.edu>.
2537 (gnus-set-global-variables)
2538 (setq gnus-have-all-headers
2539 (or all-headers gnus-show-all-headers))))
2540 (when (or (numberp article)
2542 (gnus-article-prepare-display)
2544 (goto-char (point-min))
2545 (setq gnus-page-broken
2546 (when gnus-break-pages
2547 (gnus-narrow-to-page)
2549 (let ((gnus-article-mime-handle-alist-1
2550 gnus-article-mime-handle-alist))
2551 (gnus-set-mode-line 'article))
2552 (gnus-configure-windows 'article)
2554 (set-window-point (get-buffer-window (current-buffer)) (point))
2558 (defun gnus-article-prepare-display ()
2559 "Make the current buffer look like a nice article."
2563 (setq mime-message-structure gnus-current-headers)
2564 gnus-article-display-method-for-mime)
2565 gnus-article-display-method-for-traditional)))
2566 (gnus-run-hooks 'gnus-tmp-internal-hook)
2567 (gnus-run-hooks 'gnus-article-prepare-hook)
2570 ;; Associate this article with the current summary buffer.
2571 (setq gnus-article-current-summary gnus-summary-buffer)
2572 ;; Perform the article display hooks.
2573 (gnus-run-hooks 'gnus-article-display-hook)))
2576 ;;; Gnus MIME viewing functions
2579 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
2580 "The following specs can be used:
2582 %T MIME type, along with additional info
2583 %n The `name' parameter
2584 %d The description, if any
2585 %l The length of the encoded part
2586 %p The part identifier number
2587 %e Dots if the part isn't displayed")
2589 (defvar gnus-mime-button-line-format-alist
2590 '((?t gnus-tmp-type ?s)
2591 (?T gnus-tmp-type-long ?s)
2592 (?n gnus-tmp-name ?s)
2593 (?d gnus-tmp-description ?s)
2595 (?l gnus-tmp-length ?d)
2596 (?e gnus-tmp-dots ?s)))
2598 (defvar gnus-mime-button-commands
2599 '((gnus-article-press-button "\r" "Toggle Display")
2600 (gnus-mime-view-part "v" "View Interactively...")
2601 (gnus-mime-save-part "o" "Save...")
2602 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
2603 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
2604 (gnus-mime-internalize-part "E" "View Internally")
2605 (gnus-mime-externalize-part "e" "View Externally")
2606 (gnus-mime-pipe-part "|" "Pipe To Command...")))
2608 (defun gnus-article-mime-part-status ()
2609 (if gnus-article-mime-handle-alist-1
2610 (format " (%d parts)" (length gnus-article-mime-handle-alist-1))
2613 (defvar gnus-mime-button-map nil)
2614 (unless gnus-mime-button-map
2615 (setq gnus-mime-button-map (make-sparse-keymap))
2616 (set-keymap-parent gnus-mime-button-map gnus-article-mode-map)
2617 (define-key gnus-mime-button-map gnus-mouse-2 'gnus-article-push-button)
2618 (define-key gnus-mime-button-map gnus-down-mouse-3 'gnus-mime-button-menu)
2620 (define-key gnus-mime-button-map (cadr c) (car c)))
2621 gnus-mime-button-commands))
2623 (defun gnus-mime-button-menu (event)
2624 "Construct a context-sensitive menu of MIME commands."
2627 (let ((pos (event-start event)))
2628 (set-buffer (window-buffer (posn-window pos)))
2629 (goto-char (posn-point pos))
2630 (gnus-article-check-buffer)
2631 (let ((response (x-popup-menu
2633 ("" ,@(mapcar (lambda (c)
2634 (cons (caddr c) (car c)))
2635 gnus-mime-button-commands))))))
2637 (funcall response))))))
2639 (defun gnus-mime-view-all-parts (&optional handles)
2640 "View all the MIME parts."
2642 (save-current-buffer
2643 (set-buffer gnus-article-buffer)
2644 (let ((handles (or handles gnus-article-mime-handles))
2645 (mail-parse-charset gnus-newsgroup-charset))
2646 (if (stringp (car handles))
2647 (gnus-mime-view-all-parts (cdr handles))
2648 (mapcar 'mm-display-part handles)))))
2650 (defun gnus-mime-save-part ()
2651 "Save the MIME part under point."
2653 (gnus-article-check-buffer)
2654 (let ((data (get-text-property (point) 'gnus-data)))
2655 (mm-save-part data)))
2657 (defun gnus-mime-pipe-part ()
2658 "Pipe the MIME part under point to a process."
2660 (gnus-article-check-buffer)
2661 (let ((data (get-text-property (point) 'gnus-data)))
2662 (mm-pipe-part data)))
2664 (defun gnus-mime-view-part ()
2665 "Interactively choose a view method for the MIME part under point."
2667 (gnus-article-check-buffer)
2668 (let ((data (get-text-property (point) 'gnus-data)))
2669 (mm-interactively-view-part data)))
2671 (defun gnus-mime-copy-part (&optional handle)
2672 "Put the the MIME part under point into a new buffer."
2674 (gnus-article-check-buffer)
2675 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
2676 (contents (mm-get-part handle))|
2677 (base (file-name-nondirectory
2679 (mail-content-type-get (mm-handle-type handle) 'name)
2680 (mail-content-type-get (mm-handle-type handle)
2683 (buffer (generate-new-buffer base)))
2684 (switch-to-buffer buffer)
2686 ;; We do it this way to make `normal-mode' set the appropriate mode.
2689 (setq buffer-file-name (expand-file-name base))
2691 (setq buffer-file-name nil))
2692 (goto-char (point-min))))
2694 (defun gnus-mime-inline-part (&optional charset)
2695 "Insert the MIME part under point into the current buffer."
2696 (interactive "P") ; For compatibility reasons we are not using "z".
2697 (gnus-article-check-buffer)
2698 (let* ((data (get-text-property (point) 'gnus-data))
2702 (if (mm-handle-undisplayer data)
2703 (mm-remove-part data)
2704 (setq contents (mm-get-part data))
2707 (unless (symbolp charset)
2708 (setq charset (mm-read-coding-system "Charset: ")))
2709 (setq contents (mm-decode-coding-string contents charset)))
2710 (mm-insert-inline data contents)
2713 (defun gnus-mime-externalize-part (&optional handle)
2714 "View the MIME part under point with an external viewer."
2716 (gnus-article-check-buffer)
2717 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
2718 (mm-user-display-methods nil)
2719 (mm-all-images-fit t)
2720 (mail-parse-charset gnus-newsgroup-charset))
2721 (if (mm-handle-undisplayer handle)
2722 (mm-remove-part handle)
2723 (mm-display-part handle))))
2725 (defun gnus-mime-internalize-part (&optional handle)
2726 "View the MIME part under point with an internal viewer."
2728 (gnus-article-check-buffer)
2729 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
2730 (mm-user-display-methods '((".*" . inline)))
2731 (mm-all-images-fit t)
2732 (mail-parse-charset gnus-newsgroup-charset))
2733 (if (mm-handle-undisplayer handle)
2734 (mm-remove-part handle)
2735 (mm-display-part handle))))
2737 (defun gnus-article-part-wrapper (n function)
2738 (save-current-buffer
2739 (set-buffer gnus-article-buffer)
2740 (when (> n (length gnus-article-mime-handle-alist))
2741 (error "No such part"))
2742 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
2743 (funcall function handle))))
2745 (defun gnus-article-pipe-part (n)
2746 "Pipe MIME part N, which is the numerical prefix."
2748 (gnus-article-part-wrapper n 'mm-pipe-part))
2750 (defun gnus-article-save-part (n)
2751 "Save MIME part N, which is the numerical prefix."
2753 (gnus-article-part-wrapper n 'mm-save-part))
2755 (defun gnus-article-interactively-view-part (n)
2756 "Pipe MIME part N, which is the numerical prefix."
2758 (gnus-article-part-wrapper n 'mm-interactively-view-part))
2760 (defun gnus-article-copy-part (n)
2761 "Pipe MIME part N, which is the numerical prefix."
2763 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
2765 (defun gnus-article-externalize-part (n)
2766 "Pipe MIME part N, which is the numerical prefix."
2768 (gnus-article-part-wrapper n 'gnus-mime-externalize-part))
2770 (defun gnus-article-view-part (n)
2771 "View MIME part N, which is the numerical prefix."
2773 (save-current-buffer
2774 (set-buffer gnus-article-buffer)
2775 (when (> n (length gnus-article-mime-handle-alist))
2776 (error "No such part"))
2777 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
2778 (when (gnus-article-goto-part n)
2779 (if (equal (car handle) "multipart/alternative")
2780 (gnus-article-press-button)
2781 (when (eq (gnus-mm-display-part handle) 'internal)
2782 (gnus-set-window-start)))))))
2784 (defun gnus-mm-display-part (handle)
2785 "Display HANDLE and fix MIME button."
2786 (let ((id (get-text-property (point) 'gnus-part))
2789 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
2790 (gnus-insert-mime-button
2791 handle id (list (not (mm-handle-displayed-p handle))))
2793 (let ((window (selected-window))
2794 (mail-parse-charset gnus-newsgroup-charset))
2797 (let ((win (get-buffer-window (current-buffer) t))
2800 (select-window win))
2803 (if (mm-handle-displayed-p handle)
2804 (mm-display-part handle)
2806 (narrow-to-region (point) (1+ (point)))
2807 (mm-display-part handle)
2810 (1- (length gnus-article-mime-handles))
2811 (car (mm-handle-type handle))))))
2812 (select-window window))))
2813 (goto-char point))))
2815 (defun gnus-article-goto-part (n)
2816 "Go to MIME part N."
2817 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
2819 (goto-char point))))
2821 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
2822 (let ((gnus-tmp-name
2823 (or (mail-content-type-get (mm-handle-type handle)
2825 (mail-content-type-get (mm-handle-disposition handle)
2828 (gnus-tmp-type (car (mm-handle-type handle)))
2829 (gnus-tmp-description
2830 (mail-decode-encoded-word-string (or (mm-handle-description handle)
2833 (if (if displayed (car displayed)
2834 (mm-handle-displayed-p handle))
2836 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
2838 gnus-tmp-type-long b e)
2839 (when (string-match ".*/" gnus-tmp-name)
2840 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
2841 (setq gnus-tmp-type-long (concat gnus-tmp-type
2842 (and (not (equal gnus-tmp-name ""))
2843 (concat "; " gnus-tmp-name))))
2844 (or (equal gnus-tmp-description "")
2845 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
2850 gnus-mime-button-line-format gnus-mime-button-line-format-alist
2851 `(local-map ,gnus-mime-button-map
2852 keymap ,gnus-mime-button-map
2853 gnus-callback gnus-mm-display-part
2854 gnus-part ,gnus-tmp-id
2855 article-type annotation
2858 (widget-convert-button 'link b e
2860 :action 'gnus-widget-press-button
2861 :button-keymap gnus-mime-button-map
2864 ;; Needed to properly clear the message
2865 ;; due to a bug in wid-edit
2866 (setq help-echo-owns-message t)
2868 "Click to %s the MIME part; %s for more options"
2869 (if (mm-handle-displayed-p
2870 (widget-get widget :mime-handle))
2872 (if gnus-xemacs "button3" "mouse-3"))))))
2874 (defun gnus-widget-press-button (elems el)
2875 (goto-char (widget-get elems :from))
2876 (gnus-article-press-button))
2878 (defun gnus-display-mime (&optional ihandles)
2879 "Display the MIME parts."
2881 (save-selected-window
2882 (let ((window (get-buffer-window gnus-article-buffer))
2885 (select-window window)
2886 ;; We have to do this since selecting the window
2887 ;; may change the point. So we set the window point.
2888 (set-window-point window point)))
2889 (let* ((handles (or ihandles (mm-dissect-buffer) (mm-uu-dissect)))
2890 handle name type b e display)
2892 ;; Top-level call; we clean up.
2893 (mm-destroy-parts gnus-article-mime-handles)
2894 (setq gnus-article-mime-handles handles
2895 gnus-article-mime-handle-alist nil)
2896 ;; We allow users to glean info from the handles.
2897 (when gnus-article-mime-part-function
2898 (gnus-mime-part-function handles)))
2900 (or (not (stringp (car handles)))
2904 ;; Clean up for mime parts.
2906 (delete-region (point) (point-max)))
2907 (gnus-mime-display-part handles))
2910 (narrow-to-region (point) (point-max))
2911 (gnus-treat-article nil 1 1)))
2912 ;; Highlight the headers.
2916 (narrow-to-region (point-min) (point))
2917 (gnus-treat-article 'head)))))))
2919 (defvar gnus-mime-display-multipart-as-mixed nil)
2921 (defun gnus-mime-display-part (handle)
2924 ((not (stringp (car handle)))
2925 (gnus-mime-display-single handle))
2926 ;; multipart/alternative
2927 ((and (equal (car handle) "multipart/alternative")
2928 (not gnus-mime-display-multipart-as-mixed))
2929 (let ((id (1+ (length gnus-article-mime-handle-alist))))
2930 (push (cons id handle) gnus-article-mime-handle-alist)
2931 (gnus-mime-display-alternative (cdr handle) nil nil id)))
2932 ;; multipart/related
2933 ((and (equal (car handle) "multipart/related")
2934 (not gnus-mime-display-multipart-as-mixed))
2935 ;;;!!!We should find the start part, but we just default
2936 ;;;!!!to the first part.
2937 (gnus-mime-display-part (cadr handle)))
2938 ;; Other multiparts are handled like multipart/mixed.
2940 (gnus-mime-display-mixed (cdr handle)))))
2942 (defun gnus-mime-part-function (handles)
2943 (if (stringp (car handles))
2944 (mapcar 'gnus-mime-part-function (cdr handles))
2945 (funcall gnus-article-mime-part-function handles)))
2947 (defun gnus-mime-display-mixed (handles)
2948 (mapcar 'gnus-mime-display-part handles))
2950 (defun gnus-mime-display-single (handle)
2951 (let ((type (car (mm-handle-type handle)))
2952 (ignored gnus-ignored-mime-types)
2959 (when (string-match (pop ignored) type)
2960 (throw 'ignored nil)))
2961 (if (and (setq not-attachment
2962 (or (not (mm-handle-disposition handle))
2963 (equal (car (mm-handle-disposition handle))
2965 (mm-automatic-display-p type)
2966 (or (mm-inlinable-part-p type)
2967 (mm-automatic-external-display-p type)))
2969 (when (equal (car (split-string type "/"))
2972 (let ((id (1+ (length gnus-article-mime-handle-alist))))
2973 (push (cons id handle) gnus-article-mime-handle-alist)
2974 (when (or (not display)
2975 (not (gnus-unbuttonized-mime-type-p type)))
2976 (gnus-article-insert-newline)
2977 (gnus-insert-mime-button
2978 handle id (list (or display (and not-attachment text))))
2979 (gnus-article-insert-newline)
2980 (gnus-article-insert-newline)
2982 (let ((beg (point)))
2987 (let ((mail-parse-charset gnus-newsgroup-charset))
2988 (mm-display-part handle t))
2989 (goto-char (point-max)))
2990 ((and text not-attachment)
2993 (gnus-article-insert-newline)
2994 (mm-insert-inline handle (mm-get-part handle))
2995 (goto-char (point-max))))
2999 (narrow-to-region beg (point))
3001 nil (length gnus-article-mime-handle-alist)
3002 (1- (length gnus-article-mime-handles))
3003 (car (mm-handle-type handle))))))))))
3005 (defun gnus-unbuttonized-mime-type-p (type)
3006 "Say whether TYPE is to be unbuttonized."
3007 (unless gnus-inhibit-mime-unbuttonizing
3009 (let ((types gnus-unbuttonized-mime-types))
3011 (when (string-match (pop types) type)
3012 (throw 'found t)))))))
3014 (defun gnus-article-insert-newline ()
3015 "Insert a newline, but mark it as undeletable."
3016 (gnus-put-text-property
3017 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
3019 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
3020 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
3023 handle buffer-read-only from props begend not-pref)
3024 (save-window-excursion
3027 (narrow-to-region (car ibegend)
3030 (goto-char (car ibegend))
3033 (delete-region (point-min) (point-max))
3034 (mm-remove-parts handles))
3035 (setq begend (list (point-marker)))
3037 (unless (setq not-pref (cadr (member preferred ihandles)))
3038 (setq not-pref (car ihandles)))
3040 (not (gnus-unbuttonized-mime-type-p
3041 "multipart/alternative")))
3042 (gnus-add-text-properties
3045 (insert (format "%d. " id))
3049 (unless ,(not ibegend)
3050 (setq gnus-article-mime-handle-alist
3051 ',gnus-article-mime-handle-alist))
3052 (gnus-mime-display-alternative
3053 ',ihandles ',not-pref ',begend ,id))
3054 local-map ,gnus-mime-button-map
3055 ,gnus-mouse-face-prop ,gnus-article-mouse-face
3056 face ,gnus-article-button-face
3057 keymap ,gnus-mime-button-map
3060 (widget-convert-button 'link from (point)
3061 :action 'gnus-widget-press-button
3062 :button-keymap gnus-widget-button-keymap)
3064 (while (setq handle (pop handles))
3065 (gnus-add-text-properties
3068 (insert (format "(%c) %-18s"
3069 (if (equal handle preferred) ?* ? )
3070 (if (stringp (car handle))
3072 (car (mm-handle-type handle)))))
3076 (unless ,(not ibegend)
3077 (setq gnus-article-mime-handle-alist
3078 ',gnus-article-mime-handle-alist))
3079 (gnus-mime-display-alternative
3080 ',ihandles ',handle ',begend ,id))
3081 local-map ,gnus-mime-button-map
3082 ,gnus-mouse-face-prop ,gnus-article-mouse-face
3083 face ,gnus-article-button-face
3084 keymap ,gnus-mime-button-map
3087 (widget-convert-button 'link from (point)
3088 :action 'gnus-widget-press-button
3089 :button-keymap gnus-widget-button-keymap)
3093 (if (stringp (car preferred))
3094 (gnus-display-mime preferred)
3095 (let ((mail-parse-charset gnus-newsgroup-charset))
3096 (mm-display-part preferred)))
3097 (goto-char (point-max))
3098 (setcdr begend (point-marker)))))
3100 (goto-char point))))
3102 (defun gnus-article-wash-status ()
3103 "Return a string which display status of article washing."
3105 (set-buffer gnus-article-buffer)
3106 (let ((cite (gnus-article-hidden-text-p 'cite))
3107 (headers (gnus-article-hidden-text-p 'headers))
3108 (boring (gnus-article-hidden-text-p 'boring-headers))
3109 (pgp (gnus-article-hidden-text-p 'pgp))
3110 (pem (gnus-article-hidden-text-p 'pem))
3111 (signature (gnus-article-hidden-text-p 'signature))
3112 (overstrike (gnus-article-hidden-text-p 'overstrike))
3113 (emphasis (gnus-article-hidden-text-p 'emphasis))
3114 (mime gnus-show-mime))
3115 (format "%c%c%c%c%c%c%c"
3117 (if (or headers boring) ?h ? )
3118 (if (or pgp pem) ?p ? )
3119 (if signature ?s ? )
3120 (if overstrike ?o ? )
3122 (if emphasis ?e ? )))))
3124 (fset 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
3126 (defun gnus-article-maybe-hide-headers ()
3127 "Hide unwanted headers if `gnus-have-all-headers' is nil.
3128 Provided for backwards compatibility."
3129 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
3130 (not (save-excursion (set-buffer gnus-summary-buffer)
3131 gnus-have-all-headers)))
3132 (not gnus-inhibit-hiding))
3133 (gnus-article-hide-headers)))
3137 (defun gnus-output-to-file (file-name)
3138 "Append the current article to a file named FILE-NAME."
3139 (let ((artbuf (current-buffer)))
3141 (insert-buffer-substring artbuf)
3142 ;; Append newline at end of the buffer as separator, and then
3144 (goto-char (point-max))
3146 (append-to-file (point-min) (point-max) file-name)
3149 (defun gnus-narrow-to-page (&optional arg)
3150 "Narrow the article buffer to a page.
3151 If given a numerical ARG, move forward ARG pages."
3153 (setq arg (if arg (prefix-numeric-value arg) 0))
3155 (set-buffer gnus-article-buffer)
3156 (goto-char (point-min))
3158 ;; Remove any old next/prev buttons.
3159 (when (gnus-visual-p 'page-marker)
3160 (let ((buffer-read-only nil))
3161 (gnus-remove-text-with-property 'gnus-prev)
3162 (gnus-remove-text-with-property 'gnus-next)))
3165 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
3167 (re-search-forward page-delimiter nil 'move arg)))
3168 (goto-char (match-end 0)))
3171 (if (re-search-forward page-delimiter nil 'move)
3174 (when (and (gnus-visual-p 'page-marker)
3175 (not (= (point-min) 1)))
3177 (goto-char (point-min))
3178 (gnus-insert-prev-page-button)))
3179 (when (and (gnus-visual-p 'page-marker)
3180 (< (+ (point-max) 2) (buffer-size)))
3182 (goto-char (point-max))
3183 (gnus-insert-next-page-button)))))
3185 ;; Article mode commands
3187 (defun gnus-article-goto-next-page ()
3188 "Show the next page of the article."
3190 (when (gnus-article-next-page)
3191 (goto-char (point-min))
3192 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
3194 (defun gnus-article-goto-prev-page ()
3195 "Show the next page of the article."
3197 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
3198 (gnus-article-prev-page nil)))
3200 (defun gnus-article-next-page (&optional lines)
3201 "Show the next page of the current article.
3202 If end of article, return non-nil. Otherwise return nil.
3203 Argument LINES specifies lines to be scrolled up."
3205 (move-to-window-line -1)
3208 (and (pos-visible-in-window-p) ;Not continuation line.
3210 ;; Nothing in this page.
3211 (if (or (not gnus-page-broken)
3214 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
3216 (gnus-narrow-to-page 1) ;Go to next page.
3218 ;; More in this page.
3219 (let ((scroll-in-place nil))
3223 ;; Long lines may cause an end-of-buffer error.
3224 (goto-char (point-max)))))
3225 (move-to-window-line 0)
3228 (defun gnus-article-prev-page (&optional lines)
3229 "Show previous page of current article.
3230 Argument LINES specifies lines to be scrolled down."
3232 (move-to-window-line 0)
3233 (if (and gnus-page-broken
3235 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
3237 (gnus-narrow-to-page -1) ;Go to previous page.
3238 (goto-char (point-max))
3240 (let ((scroll-in-place nil))
3244 (beginning-of-buffer
3245 (goto-char (point-min))))
3246 (move-to-window-line 0)))))
3248 (defun gnus-article-refer-article ()
3249 "Read article specified by message-id around point."
3251 (let ((point (point)))
3252 (search-forward ">" nil t) ;Move point to end of "<....>".
3253 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
3254 (let ((message-id (match-string 1)))
3256 (set-buffer gnus-summary-buffer)
3257 (gnus-summary-refer-article message-id))
3259 (error "No references around point"))))
3261 (defun gnus-article-show-summary ()
3262 "Reconfigure windows to show summary buffer."
3264 (if (not (gnus-buffer-live-p gnus-summary-buffer))
3265 (error "There is no summary buffer for this article buffer")
3266 (gnus-article-set-globals)
3267 (gnus-configure-windows 'article)
3268 (gnus-summary-goto-subject gnus-current-article)
3269 (gnus-summary-position-point)))
3271 (defun gnus-article-describe-briefly ()
3272 "Describe article mode commands briefly."
3274 (gnus-message 6 (substitute-command-keys "\\<gnus-article-mode-map>\\[gnus-article-goto-next-page]:Next page \\[gnus-article-goto-prev-page]:Prev page \\[gnus-article-show-summary]:Show summary \\[gnus-info-find-node]:Run Info \\[gnus-article-describe-briefly]:This help")))
3276 (defun gnus-article-summary-command ()
3277 "Execute the last keystroke in the summary buffer."
3279 (let ((obuf (current-buffer))
3280 (owin (current-window-configuration))
3282 (switch-to-buffer gnus-article-current-summary 'norecord)
3283 (setq func (lookup-key (current-local-map) (this-command-keys)))
3284 (call-interactively func)
3286 (set-window-configuration owin)
3287 (set-window-point (get-buffer-window (current-buffer)) (point))))
3289 (defun gnus-article-summary-command-nosave ()
3290 "Execute the last keystroke in the summary buffer."
3293 (pop-to-buffer gnus-article-current-summary 'norecord)
3294 (setq func (lookup-key (current-local-map) (this-command-keys)))
3295 (call-interactively func)))
3297 (defun gnus-article-check-buffer ()
3298 "Beep if not in an article buffer."
3299 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
3300 (error "Command invoked outside of a Gnus article buffer")))
3302 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
3303 "Read a summary buffer key sequence and execute it from the article buffer."
3305 (gnus-article-check-buffer)
3307 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
3308 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
3309 "=" "^" "\M-^" "|"))
3315 '("n" "Gn" "p" "Gp"))
3318 (set-buffer gnus-article-current-summary)
3319 (let (gnus-pick-mode)
3320 (push (or key last-command-event) unread-command-events)
3321 (setq keys (read-key-sequence nil))))
3324 (if (or (member keys nosaves)
3325 (member keys nosave-but-article)
3326 (member keys nosave-in-article))
3328 (save-window-excursion
3329 (pop-to-buffer gnus-article-current-summary 'norecord)
3330 ;; We disable the pick minor mode commands.
3331 (let (gnus-pick-mode)
3332 (setq func (lookup-key (current-local-map) keys))))
3335 (unless (member keys nosave-in-article)
3336 (set-buffer gnus-article-current-summary))
3337 (call-interactively func)
3338 (setq new-sum-point (point)))
3339 (when (member keys nosave-but-article)
3340 (pop-to-buffer gnus-article-buffer 'norecord)))
3341 ;; These commands should restore window configuration.
3342 (let ((obuf (current-buffer))
3343 (owin (current-window-configuration))
3345 (summary gnus-article-current-summary)
3346 func in-buffer selected)
3347 (if not-restore-window
3348 (pop-to-buffer summary 'norecord)
3349 (switch-to-buffer summary 'norecord))
3350 (setq in-buffer (current-buffer))
3351 ;; We disable the pick minor mode commands.
3352 (if (setq func (let (gnus-pick-mode)
3353 (lookup-key (current-local-map) keys)))
3355 (call-interactively func)
3356 (setq new-sum-point (point)))
3358 (when (eq in-buffer (current-buffer))
3359 (setq selected (gnus-summary-select-article))
3361 (unless not-restore-window
3362 (set-window-configuration owin))
3363 (unless (or (not (eq selected 'old)) (member keys up-to-top))
3364 (set-window-point (get-buffer-window (current-buffer))
3366 (let ((win (get-buffer-window gnus-article-current-summary)))
3368 (set-window-point win new-sum-point))))))))
3370 (defun gnus-article-hide (&optional arg force)
3371 "Hide all the gruft in the current article.
3372 This means that PGP stuff, signatures, cited text and (some)
3373 headers will be hidden.
3374 If given a prefix, show the hidden text instead."
3375 (interactive (append (gnus-article-hidden-arg) (list 'force)))
3376 (gnus-article-hide-headers arg)
3377 (gnus-article-hide-pgp arg)
3378 (gnus-article-hide-citation-maybe arg force)
3379 (gnus-article-hide-signature arg))
3381 (defun gnus-article-maybe-highlight ()
3382 "Do some article highlighting if article highlighting is requested."
3383 (when (gnus-visual-p 'article-highlight 'highlight)
3384 (gnus-article-highlight-some)))
3386 (defun gnus-check-group-server ()
3387 ;; Make sure the connection to the server is alive.
3388 (unless (gnus-server-opened
3389 (gnus-find-method-for-group gnus-newsgroup-name))
3390 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
3391 (gnus-request-group gnus-newsgroup-name t)))
3393 (defun gnus-request-article-this-buffer (article group)
3394 "Get an article and insert it into this buffer."
3395 (let (do-update-line sparse-header)
3399 (gnus-kill-all-overlays)
3400 (setq group (or group gnus-newsgroup-name))
3402 ;; Using `gnus-request-article' directly will insert the article into
3403 ;; `nntp-server-buffer' - so we'll save some time by not having to
3404 ;; copy it from the server buffer into the article buffer.
3406 ;; We only request an article by message-id when we do not have the
3407 ;; headers for it, so we'll have to get those.
3408 (when (stringp article)
3409 (let ((gnus-override-method gnus-refer-article-method))
3410 (gnus-read-header article)))
3412 ;; If the article number is negative, that means that this article
3413 ;; doesn't belong in this newsgroup (possibly), so we find its
3414 ;; message-id and request it by id instead of number.
3415 (when (and (numberp article)
3417 (get-buffer gnus-summary-buffer)
3418 (gnus-buffer-exists-p gnus-summary-buffer))
3420 (set-buffer gnus-summary-buffer)
3421 (let ((header (gnus-summary-article-header article)))
3424 ((memq article gnus-newsgroup-sparse)
3425 ;; This is a sparse gap article.
3426 (setq do-update-line article)
3427 (setq article (mail-header-id header))
3428 (let ((gnus-override-method gnus-refer-article-method))
3429 (setq sparse-header (gnus-read-header article)))
3430 (setq gnus-newsgroup-sparse
3431 (delq article gnus-newsgroup-sparse)))
3433 ;; It's a real article.
3434 (setq article (mail-header-id header)))
3436 ;; It is an extracted pseudo-article.
3437 (setq article 'pseudo)
3438 (gnus-request-pseudo-article header))))
3440 (let ((method (gnus-find-method-for-group
3441 gnus-newsgroup-name)))
3442 (when (and (eq (car method) 'nneething)
3445 (file-name-as-directory
3446 (or (cadr (assq 'nneething-address method))
3448 (mail-header-subject header))))
3449 (when (file-directory-p dir)
3450 (setq article 'nneething)
3451 (gnus-group-enter-directory dir))))))))
3454 ;; Refuse to select canceled articles.
3455 ((and (numberp article)
3457 (get-buffer gnus-summary-buffer)
3458 (gnus-buffer-exists-p gnus-summary-buffer)
3459 (eq (cdr (save-excursion
3460 (set-buffer gnus-summary-buffer)
3461 (assq article gnus-newsgroup-reads)))
3462 gnus-canceled-mark))
3464 ;; Check the backlog.
3465 ((and gnus-keep-backlog
3466 (gnus-backlog-request-article group article (current-buffer)))
3468 ;; Check asynchronous pre-fetch.
3469 ((gnus-async-request-fetched-article group article (current-buffer))
3470 (gnus-async-prefetch-next group article gnus-summary-buffer)
3471 (when (and (numberp article) gnus-keep-backlog)
3472 (gnus-backlog-enter-article group article (current-buffer)))
3475 ((and gnus-use-cache
3477 (gnus-cache-request-article article group))
3479 ;; Get the article and put into the article buffer.
3480 ((or (stringp article) (numberp article))
3481 (let ((gnus-override-method
3482 (and (stringp article) gnus-refer-article-method))
3483 (buffer-read-only nil))
3485 (gnus-kill-all-overlays)
3486 (gnus-check-group-server)
3487 (when (gnus-request-article article group (current-buffer))
3488 (when (numberp article)
3489 (gnus-async-prefetch-next group article gnus-summary-buffer)
3490 (when gnus-keep-backlog
3491 (gnus-backlog-enter-article
3492 group article (current-buffer))))
3497 ;; Associate this article with the current summary buffer.
3498 (setq gnus-article-current-summary gnus-summary-buffer)
3500 ;; Take the article from the original article buffer
3501 ;; and place it in the buffer it's supposed to be in.
3502 (when (and (get-buffer gnus-article-buffer)
3503 (equal (buffer-name (current-buffer))
3504 (buffer-name (get-buffer gnus-article-buffer))))
3506 (if (get-buffer gnus-original-article-buffer)
3507 (set-buffer gnus-original-article-buffer)
3508 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3509 (buffer-disable-undo)
3510 (setq major-mode 'gnus-original-article-mode)
3511 (setq buffer-read-only t))
3512 (let (buffer-read-only)
3514 (insert-buffer-substring gnus-article-buffer))
3515 (setq gnus-original-article (cons group article)))
3518 (run-hooks 'gnus-article-decode-hook)
3519 ;; Mark article as decoded or not.
3520 (setq gnus-article-decoded-p gnus-article-decode-hook))
3522 ;; Update sparse articles.
3523 (when (and do-update-line
3524 (or (numberp article)
3526 (let ((buf (current-buffer)))
3527 (set-buffer gnus-summary-buffer)
3528 (gnus-summary-update-article do-update-line sparse-header)
3529 (gnus-summary-goto-subject do-update-line nil t)
3530 (set-window-point (get-buffer-window (current-buffer) t)
3532 (set-buffer buf))))))
3538 (defcustom gnus-article-edit-mode-hook nil
3539 "Hook run in article edit mode buffers."
3540 :group 'gnus-article-various
3543 (defcustom gnus-article-edit-article-setup-function
3544 'gnus-article-mime-edit-article-setup
3545 "Function called to setup an editing article buffer."
3546 :group 'gnus-article-various
3549 (defvar gnus-article-edit-done-function nil)
3551 (defvar gnus-article-edit-mode-map nil)
3553 ;; Should we be using derived.el for this?
3554 (unless gnus-article-edit-mode-map
3555 (setq gnus-article-edit-mode-map (make-sparse-keymap))
3556 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
3558 (gnus-define-keys gnus-article-edit-mode-map
3559 "\C-c\C-c" gnus-article-edit-done
3560 "\C-c\C-k" gnus-article-edit-exit)
3562 (gnus-define-keys (gnus-article-edit-wash-map
3563 "\C-c\C-w" gnus-article-edit-mode-map)
3564 "f" gnus-article-edit-full-stops))
3566 (defun gnus-article-edit-mode ()
3567 "Major mode for editing articles.
3568 This is an extended text-mode.
3570 \\{gnus-article-edit-mode-map}"
3572 (setq major-mode 'gnus-article-edit-mode)
3573 (setq mode-name "Article Edit")
3574 (use-local-map gnus-article-edit-mode-map)
3575 (make-local-variable 'gnus-article-edit-done-function)
3576 (make-local-variable 'gnus-prev-winconf)
3577 (setq buffer-read-only nil)
3578 (buffer-enable-undo)
3580 (gnus-run-hooks 'text-mode-hook 'gnus-article-edit-mode-hook))
3582 (defun gnus-article-edit (&optional force)
3583 "Edit the current article.
3584 This will have permanent effect only in mail groups.
3585 If FORCE is non-nil, allow editing of articles even in read-only
3588 (when (and (not force)
3589 (gnus-group-read-only-p))
3590 (error "The current newsgroup does not support article editing"))
3591 (gnus-article-date-original)
3592 (gnus-article-edit-article
3593 `(lambda (no-highlight)
3594 (gnus-summary-edit-article-done
3595 ,(or (mail-header-references gnus-current-headers) "")
3596 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
3598 (defun gnus-article-edit-article (exit-func)
3599 "Start editing the contents of the current article buffer."
3600 (let ((winconf (current-window-configuration)))
3601 (set-buffer gnus-article-buffer)
3602 (gnus-article-edit-mode)
3603 (gnus-article-delete-text-of-type 'annotation)
3604 (gnus-set-text-properties (point-min) (point-max) nil)
3605 (gnus-configure-windows 'edit-article)
3606 (setq gnus-article-edit-done-function exit-func)
3607 (setq gnus-prev-winconf winconf)
3608 (when gnus-article-edit-article-setup-function
3609 (funcall gnus-article-edit-article-setup-function))
3610 (gnus-message 6 "C-c C-c to end edits")))
3612 (defun gnus-article-edit-done (&optional arg)
3613 "Update the article edits and exit."
3618 (when (article-goto-body)
3619 (let ((lines (count-lines (point) (point-max)))
3620 (length (- (point-max) (point)))
3621 (case-fold-search t)
3622 (body (copy-marker (point))))
3623 (goto-char (point-min))
3624 (when (re-search-forward "^content-length:[ \t]\\([0-9]+\\)" body t)
3625 (delete-region (match-beginning 1) (match-end 1))
3626 (insert (number-to-string length)))
3627 (goto-char (point-min))
3628 (when (re-search-forward
3629 "^x-content-length:[ \t]\\([0-9]+\\)" body t)
3630 (delete-region (match-beginning 1) (match-end 1))
3631 (insert (number-to-string length)))
3632 (goto-char (point-min))
3633 (when (re-search-forward "^lines:[ \t]\\([0-9]+\\)" body t)
3634 (delete-region (match-beginning 1) (match-end 1))
3635 (insert (number-to-string lines)))))))
3636 (let ((func gnus-article-edit-done-function)
3637 (buf (current-buffer))
3638 (start (window-start)))
3639 (remove-hook 'gnus-article-mode-hook
3640 'gnus-article-mime-edit-article-unwind)
3641 (gnus-article-edit-exit)
3644 (let ((buffer-read-only nil))
3646 ;; The cache and backlog have to be flushed somewhat.
3647 (when gnus-keep-backlog
3648 (gnus-backlog-remove-article
3649 (car gnus-article-current) (cdr gnus-article-current)))
3650 ;; Flush original article as well.
3652 (when (get-buffer gnus-original-article-buffer)
3653 (set-buffer gnus-original-article-buffer)
3654 (setq gnus-original-article nil)))
3655 (when gnus-use-cache
3656 (gnus-cache-update-article
3657 (car gnus-article-current) (cdr gnus-article-current))))
3659 (set-window-start (get-buffer-window buf) start)
3660 (set-window-point (get-buffer-window buf) (point))))
3662 (defun gnus-article-edit-exit ()
3663 "Exit the article editing without updating."
3665 ;; We remove all text props from the article buffer.
3666 (let ((buf (format "%s" (buffer-string)))
3667 (curbuf (current-buffer))
3669 (window-start (window-start)))
3672 (let ((winconf gnus-prev-winconf))
3674 (set-window-configuration winconf)
3675 ;; Tippy-toe some to make sure that point remains where it was.
3676 (save-current-buffer
3678 (set-window-start (get-buffer-window (current-buffer)) window-start)
3681 (defun gnus-article-edit-full-stops ()
3682 "Interactively repair spacing at end of sentences."
3685 (goto-char (point-min))
3686 (search-forward-regexp "^$" nil t)
3687 (let ((case-fold-search nil))
3688 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
3691 ;;; Article editing with MIME-Edit
3694 (defcustom gnus-article-mime-edit-article-setup-hook nil
3695 "Hook run after setting up a MIME editing article buffer."
3696 :group 'gnus-article-various
3699 (defun gnus-article-mime-edit-article-unwind ()
3700 "Unwind `gnus-article-buffer' if article editing was given up."
3701 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
3702 (when mime-edit-mode-flag
3703 (mime-edit-exit 'nomime 'no-error)
3705 (when (featurep 'font-lock)
3706 (setq font-lock-defaults nil)
3707 (font-lock-mode 0)))
3709 (defun gnus-article-mime-edit-article-setup ()
3710 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
3711 after replacing with the original article."
3712 (setq gnus-show-mime t)
3713 (setq gnus-article-edit-done-function
3714 `(lambda (&rest args)
3715 (when mime-edit-mode-flag
3718 (goto-char (point-min))
3719 (let (case-fold-search)
3720 (when (re-search-forward
3721 (format "^%s$" (regexp-quote mail-header-separator))
3723 (replace-match "")))
3724 (when (featurep 'font-lock)
3725 (setq font-lock-defaults nil)
3727 (apply ,gnus-article-edit-done-function args)
3728 (set-buffer gnus-original-article-buffer)
3730 (insert-buffer gnus-article-buffer)
3731 (setq gnus-current-headers (gnus-article-make-full-mail-header))
3732 (gnus-article-prepare-display)))
3733 (substitute-key-definition
3734 'gnus-article-edit-exit 'gnus-article-mime-edit-exit
3735 gnus-article-edit-mode-map)
3737 (insert-buffer gnus-original-article-buffer)
3739 (when (featurep 'font-lock)
3740 (set (make-local-variable 'font-lock-defaults)
3741 '(message-font-lock-keywords t))
3742 (font-lock-set-defaults)
3743 (turn-on-font-lock))
3744 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
3745 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
3747 (defun gnus-article-mime-edit-exit ()
3748 "Exit the article MIME editing without updating."
3750 (let ((winconf gnus-prev-winconf)
3752 (when mime-edit-mode-flag
3755 (goto-char (point-min))
3756 (let (case-fold-search)
3757 (when (re-search-forward
3758 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
3759 (replace-match "")))
3760 (when (featurep 'font-lock)
3761 (setq font-lock-defaults nil)
3763 ;; We remove all text props from the article buffer.
3764 (setq buf (format "%s" (buffer-string)))
3765 (set-buffer (get-buffer-create gnus-original-article-buffer))
3768 (setq gnus-current-headers (gnus-article-make-full-mail-header))
3769 (gnus-article-prepare-display)
3770 (set-window-configuration winconf)))
3773 ;;; Article highlights
3776 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
3778 ;;; Internal Variables:
3780 (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\\)"
3781 "Regular expression that matches URLs."
3782 :group 'gnus-article-buttons
3785 (defcustom gnus-button-alist
3786 `(("<\\(url:[>\n\t ]*?\\)?news:[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
3787 0 t gnus-button-message-id 2)
3788 ("\\bnews:\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t gnus-button-message-id 1)
3789 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
3791 gnus-button-fetch-group 4)
3792 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
3793 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
3794 t gnus-button-message-id 3)
3795 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
3796 ("mailto:\\([-a-zA-Z.@_+0-9%]+\\)" 0 t gnus-url-mailto 1)
3797 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
3798 ;; This is how URLs _should_ be embedded in text...
3799 ("<URL: *\\([^>]*\\)>" 0 t gnus-button-embedded-url 1)
3801 (,gnus-button-url-regexp 0 t gnus-button-url 0))
3802 "*Alist of regexps matching buttons in article bodies.
3804 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
3805 REGEXP: is the string matching text around the button,
3806 BUTTON: is the number of the regexp grouping actually matching the button,
3807 FORM: is a lisp expression which must eval to true for the button to
3809 CALLBACK: is the function to call when the user push this button, and each
3810 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
3812 CALLBACK can also be a variable, in that case the value of that
3813 variable it the real callback function."
3814 :group 'gnus-article-buttons
3815 :type '(repeat (list regexp
3816 (integer :tag "Button")
3818 (function :tag "Callback")
3821 (integer :tag "Regexp group")))))
3823 (defcustom gnus-header-button-alist
3824 `(("^\\(References\\|Message-I[Dd]\\):" "<[^>]+>"
3825 0 t gnus-button-message-id 0)
3826 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
3827 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
3828 0 t gnus-button-mailto 0)
3829 ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t gnus-button-url 0)
3830 ("^Subject:" ,gnus-button-url-regexp 0 t gnus-button-url 0)
3831 ("^[^:]+:" ,gnus-button-url-regexp 0 t gnus-button-url 0)
3832 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
3833 gnus-button-message-id 3))
3834 "*Alist of headers and regexps to match buttons in article heads.
3836 This alist is very similar to `gnus-button-alist', except that each
3837 alist has an additional HEADER element first in each entry:
3839 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
3841 HEADER is a regexp to match a header. For a fuller explanation, see
3842 `gnus-button-alist'."
3843 :group 'gnus-article-buttons
3844 :group 'gnus-article-headers
3845 :type '(repeat (list (regexp :tag "Header")
3847 (integer :tag "Button")
3849 (function :tag "Callback")
3852 (integer :tag "Regexp group")))))
3854 (defvar gnus-button-regexp nil)
3855 (defvar gnus-button-marker-list nil)
3856 ;; Regexp matching any of the regexps from `gnus-button-alist'.
3858 (defvar gnus-button-last nil)
3859 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
3863 (defun gnus-article-push-button (event)
3864 "Check text under the mouse pointer for a callback function.
3865 If the text under the mouse pointer has a `gnus-callback' property,
3866 call it with the value of the `gnus-data' text property."
3868 (set-buffer (window-buffer (posn-window (event-start event))))
3869 (let* ((pos (posn-point (event-start event)))
3870 (data (get-text-property pos 'gnus-data))
3871 (fun (get-text-property pos 'gnus-callback)))
3874 (funcall fun data))))
3876 (defun gnus-article-press-button ()
3877 "Check text at point for a callback function.
3878 If the text at point has a `gnus-callback' property,
3879 call it with the value of the `gnus-data' text property."
3881 (let* ((data (get-text-property (point) 'gnus-data))
3882 (fun (get-text-property (point) 'gnus-callback)))
3884 (funcall fun data))))
3886 (defun gnus-article-prev-button (n)
3887 "Move point to N buttons backward.
3888 If N is negative, move forward instead."
3890 (gnus-article-next-button (- n)))
3892 (defun gnus-article-next-button (n)
3893 "Move point to N buttons forward.
3894 If N is negative, move backward instead."
3896 (let ((function (if (< n 0) 'previous-single-property-change
3897 'next-single-property-change))
3898 (inhibit-point-motion-hooks t)
3900 (limit (if (< n 0) (point-min) (point-max))))
3902 (while (and (not (= limit (point)))
3904 ;; Skip past the current button.
3905 (when (get-text-property (point) 'gnus-callback)
3906 (goto-char (funcall function (point) 'gnus-callback nil limit)))
3907 ;; Go to the next (or previous) button.
3908 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
3909 ;; Put point at the start of the button.
3910 (when (and backward (not (get-text-property (point) 'gnus-callback)))
3911 (goto-char (funcall function (point) 'gnus-callback nil limit)))
3912 ;; Skip past intangible buttons.
3913 (when (get-text-property (point) 'intangible)
3917 (gnus-message 5 "No more buttons"))
3920 (defun gnus-article-highlight (&optional force)
3921 "Highlight current article.
3922 This function calls `gnus-article-highlight-headers',
3923 `gnus-article-highlight-citation',
3924 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
3925 do the highlighting. See the documentation for those functions."
3926 (interactive (list 'force))
3927 (gnus-article-highlight-headers)
3928 (gnus-article-highlight-citation force)
3929 (gnus-article-highlight-signature)
3930 (gnus-article-add-buttons force)
3931 (gnus-article-add-buttons-to-head))
3933 (defun gnus-article-highlight-some (&optional force)
3934 "Highlight current article.
3935 This function calls `gnus-article-highlight-headers',
3936 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
3937 do the highlighting. See the documentation for those functions."
3938 (interactive (list 'force))
3939 (gnus-article-highlight-headers)
3940 (gnus-article-highlight-signature)
3941 (gnus-article-add-buttons))
3943 (defun gnus-article-highlight-headers ()
3944 "Highlight article headers as specified by `gnus-header-face-alist'."
3947 (set-buffer gnus-article-buffer)
3949 (let ((alist gnus-header-face-alist)
3950 (buffer-read-only nil)
3951 (case-fold-search t)
3952 (inhibit-point-motion-hooks t)
3953 entry regexp header-face field-face from hpoints fpoints)
3954 (message-narrow-to-head)
3955 (while (setq entry (pop alist))
3956 (goto-char (point-min))
3957 (setq regexp (concat "^\\("
3958 (if (string-equal "" (nth 0 entry))
3962 header-face (nth 1 entry)
3963 field-face (nth 2 entry))
3964 (while (and (re-search-forward regexp nil t)
3968 (unless (search-forward ":" nil t)
3970 (when (and header-face
3971 (not (memq (point) hpoints)))
3972 (push (point) hpoints)
3973 (gnus-put-text-property from (point) 'face header-face))
3974 (when (and field-face
3975 (not (memq (setq from (point)) fpoints)))
3977 (if (re-search-forward "^[^ \t]" nil t)
3979 (goto-char (point-max)))
3980 (gnus-put-text-property from (point) 'face field-face))))))))
3982 (defun gnus-article-highlight-signature ()
3983 "Highlight the signature in an article.
3984 It does this by highlighting everything after
3985 `gnus-signature-separator' using `gnus-signature-face'."
3988 (set-buffer gnus-article-buffer)
3989 (let ((buffer-read-only nil)
3990 (inhibit-point-motion-hooks t))
3992 (when (and gnus-signature-face
3993 (gnus-article-narrow-to-signature))
3994 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
3995 'face gnus-signature-face)
3997 (gnus-article-search-signature)
3998 (let ((start (match-beginning 0))
3999 (end (set-marker (make-marker) (1+ (match-end 0)))))
4000 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
4003 (defun gnus-button-in-region-p (b e prop)
4004 "Say whether PROP exists in the region."
4005 (text-property-not-all b e prop nil))
4007 (defun gnus-article-add-buttons (&optional force)
4008 "Find external references in the article and make buttons of them.
4009 \"External references\" are things like Message-IDs and URLs, as
4010 specified by `gnus-button-alist'."
4011 (interactive (list 'force))
4013 (set-buffer gnus-article-buffer)
4014 (let ((buffer-read-only nil)
4015 (inhibit-point-motion-hooks t)
4016 (case-fold-search t)
4017 (alist gnus-button-alist)
4019 ;; Remove all old markers.
4021 (while (setq marker (pop gnus-button-marker-list))
4023 (when (setq entry (gnus-button-entry))
4024 (put-text-property (match-beginning (nth 1 entry))
4025 (match-end (nth 1 entry))
4026 'gnus-callback nil))
4027 (set-marker marker nil)))
4028 ;; We skip the headers.
4031 (while (setq entry (pop alist))
4032 (setq regexp (car entry))
4034 (while (re-search-forward regexp nil t)
4035 (let* ((start (and entry (match-beginning (nth 1 entry))))
4036 (end (and entry (match-end (nth 1 entry))))
4037 (from (match-beginning 0)))
4038 (when (and (or (eq t (nth 2 entry))
4039 (eval (nth 2 entry)))
4040 (not (gnus-button-in-region-p
4041 start end 'gnus-callback)))
4042 ;; That optional form returned non-nil, so we add the
4044 (gnus-article-add-button
4045 start end 'gnus-button-push
4046 (car (push (set-marker (make-marker) from)
4047 gnus-button-marker-list))))))))))
4049 ;; Add buttons to the head of an article.
4050 (defun gnus-article-add-buttons-to-head ()
4051 "Add buttons to the head of the article."
4054 (set-buffer gnus-article-buffer)
4055 (let ((buffer-read-only nil)
4056 (inhibit-point-motion-hooks t)
4057 (case-fold-search t)
4058 (alist gnus-header-button-alist)
4060 (nnheader-narrow-to-headers)
4062 ;; Each alist entry.
4063 (setq entry (car alist)
4065 (goto-char (point-min))
4066 (while (re-search-forward (car entry) nil t)
4067 ;; Each header matching the entry.
4068 (setq beg (match-beginning 0))
4069 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
4070 (match-beginning 0))
4073 (while (re-search-forward (nth 1 entry) end t)
4074 ;; Each match within a header.
4075 (let* ((entry (cdr entry))
4076 (start (match-beginning (nth 1 entry)))
4077 (end (match-end (nth 1 entry)))
4078 (form (nth 2 entry)))
4079 (goto-char (match-end 0))
4081 (gnus-article-add-button
4082 start end (nth 3 entry)
4083 (buffer-substring (match-beginning (nth 4 entry))
4084 (match-end (nth 4 entry)))))))
4088 ;;; External functions:
4090 (defun gnus-article-add-button (from to fun &optional data)
4091 "Create a button between FROM and TO with callback FUN and data DATA."
4092 (when gnus-article-button-face
4093 (gnus-overlay-put (gnus-make-overlay from to)
4094 'face gnus-article-button-face))
4095 (gnus-add-text-properties
4097 (nconc (and gnus-article-mouse-face
4098 (list gnus-mouse-face-prop gnus-article-mouse-face))
4099 (list 'gnus-callback fun)
4100 (and data (list 'gnus-data data)))))
4102 ;;; Internal functions:
4104 (defun gnus-article-set-globals ()
4106 (set-buffer gnus-summary-buffer)
4107 (gnus-set-global-variables)))
4109 (defun gnus-signature-toggle (end)
4111 (set-buffer gnus-article-buffer)
4112 (let ((buffer-read-only nil)
4113 (inhibit-point-motion-hooks t))
4114 (if (get-text-property end 'invisible)
4115 (gnus-article-unhide-text end (point-max))
4116 (gnus-article-hide-text end (point-max) gnus-hidden-properties)))))
4118 (defun gnus-button-entry ()
4119 ;; Return the first entry in `gnus-button-alist' matching this place.
4120 (let ((alist gnus-button-alist)
4123 (setq entry (pop alist))
4124 (if (looking-at (car entry))
4129 (defun gnus-button-push (marker)
4130 ;; Push button starting at MARKER.
4133 (let* ((entry (gnus-button-entry))
4134 (inhibit-point-motion-hooks t)
4136 (args (mapcar (lambda (group)
4137 (let ((string (match-string group)))
4138 (gnus-set-text-properties
4139 0 (length string) nil string)
4146 (fboundp (symbol-value fun)))
4147 (apply (symbol-value fun) args))
4149 (gnus-message 1 "You must define `%S' to use this button"
4150 (cons fun args)))))))
4152 (defun gnus-button-message-id (message-id)
4155 (set-buffer gnus-summary-buffer)
4156 (gnus-summary-refer-article message-id)))
4158 (defun gnus-button-fetch-group (address)
4159 "Fetch GROUP specified by ADDRESS."
4160 (if (not (string-match "[:/]" address))
4161 ;; This is just a simple group url.
4162 (gnus-group-read-ephemeral-group address gnus-select-method)
4163 (if (not (string-match "^\\([^:/]+\\)\\(:\\([^/]+\\)/\\)?\\(.*\\)$"
4165 (error "Can't parse %s" address)
4166 (gnus-group-read-ephemeral-group
4167 (match-string 4 address)
4168 `(nntp ,(match-string 1 address)
4169 (nntp-address ,(match-string 1 address))
4170 (nntp-port-number ,(if (match-end 3)
4171 (match-string 3 address)
4174 (defun gnus-url-parse-query-string (query &optional downcase)
4175 (let (retval pairs cur key val)
4176 (setq pairs (split-string query "&"))
4178 (setq cur (car pairs)
4180 (if (not (string-match "=" cur))
4182 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
4183 val (gnus-url-unhex-string (substring cur (match-end 0) nil)))
4185 (setq key (downcase key)))
4186 (setq cur (assoc key retval))
4188 (setcdr cur (cons val (cdr cur)))
4189 (setq retval (cons (list key val) retval)))))
4192 (defun gnus-url-unhex (x)
4199 (defun gnus-url-unhex-string (str &optional allow-newlines)
4200 "Remove %XXX embedded spaces, etc in a url.
4201 If optional second argument ALLOW-NEWLINES is non-nil, then allow the
4202 decoding of carriage returns and line feeds in the string, which is normally
4203 forbidden in URL encoding."
4204 (setq str (or str ""))
4206 (case-fold-search t))
4207 (while (string-match "%[0-9a-f][0-9a-f]" str)
4208 (let* ((start (match-beginning 0))
4209 (ch1 (gnus-url-unhex (elt str (+ start 1))))
4211 (gnus-url-unhex (elt str (+ start 2))))))
4213 tmp (substring str 0 start)
4216 (char-to-string code))
4217 ((or (= code ?\n) (= code ?\r))
4219 (t (char-to-string code))))
4220 str (substring str (match-end 0)))))
4221 (setq tmp (concat tmp str))
4224 (defun gnus-url-mailto (url)
4225 ;; Send mail to someone
4226 (when (string-match "mailto:/*\\(.*\\)" url)
4227 (setq url (substring url (match-beginning 1) nil)))
4228 (let (to args subject func)
4229 (if (string-match (regexp-quote "?") url)
4230 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
4231 args (gnus-url-parse-query-string
4232 (substring url (match-end 0) nil) t))
4233 (setq to (gnus-url-unhex-string url)))
4234 (setq args (cons (list "to" to) args)
4235 subject (cdr-safe (assoc "subject" args)))
4236 (gnus-setup-message 'reply
4239 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
4242 (message-position-on-field (caar args)))
4243 (insert (mapconcat 'identity (cdar args) ", "))
4244 (setq args (cdr args)))
4247 (message-goto-subject)))))
4249 (defun gnus-button-mailto (address)
4251 (set-buffer (gnus-copy-article-buffer))
4252 (gnus-setup-message 'reply
4253 (message-reply address)))
4255 (defun gnus-button-reply (address)
4256 ;; Reply to ADDRESS.
4257 (gnus-setup-message 'reply
4258 (message-reply address)))
4260 (defun gnus-button-url (address)
4262 ;; In Emacs 20, `browse-url-browser-function' may be an alist.
4263 (if (listp browse-url-browser-function)
4264 (browse-url address)
4265 (funcall browse-url-browser-function address)))
4267 (defun gnus-button-embedded-url (address)
4269 ;; In Emacs 20, `browse-url-browser-function' may be an alist.
4270 (if (listp browse-url-browser-function)
4271 (browse-url (gnus-strip-whitespace address))
4272 (funcall browse-url-browser-function (gnus-strip-whitespace address))))
4274 ;;; Next/prev buttons in the article buffer.
4276 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
4277 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
4279 (defvar gnus-prev-page-map nil)
4280 (unless gnus-prev-page-map
4281 (setq gnus-prev-page-map (make-sparse-keymap))
4282 (define-key gnus-prev-page-map gnus-mouse-2 'gnus-button-prev-page)
4283 (define-key gnus-prev-page-map "\r" 'gnus-button-prev-page))
4285 (defun gnus-insert-prev-page-button ()
4286 (let ((buffer-read-only nil))
4288 gnus-prev-page-line-format nil
4289 `(gnus-prev t local-map ,gnus-prev-page-map
4290 gnus-callback gnus-article-button-prev-page
4291 article-type annotation))))
4293 (defvar gnus-next-page-map nil)
4294 (unless gnus-next-page-map
4295 (setq gnus-next-page-map (make-keymap))
4296 (suppress-keymap gnus-prev-page-map)
4297 (define-key gnus-next-page-map gnus-mouse-2 'gnus-button-next-page)
4298 (define-key gnus-next-page-map "\r" 'gnus-button-next-page))
4300 (defun gnus-button-next-page ()
4301 "Go to the next page."
4303 (let ((win (selected-window)))
4304 (select-window (get-buffer-window gnus-article-buffer t))
4305 (gnus-article-next-page)
4306 (select-window win)))
4308 (defun gnus-button-prev-page ()
4309 "Go to the prev page."
4311 (let ((win (selected-window)))
4312 (select-window (get-buffer-window gnus-article-buffer t))
4313 (gnus-article-prev-page)
4314 (select-window win)))
4316 (defun gnus-insert-next-page-button ()
4317 (let ((buffer-read-only nil))
4318 (gnus-eval-format gnus-next-page-line-format nil
4320 t local-map ,gnus-next-page-map
4321 gnus-callback gnus-article-button-next-page
4322 article-type annotation))))
4324 (defun gnus-article-button-next-page (arg)
4325 "Go to the next page."
4327 (let ((win (selected-window)))
4328 (select-window (get-buffer-window gnus-article-buffer t))
4329 (gnus-article-next-page)
4330 (select-window win)))
4332 (defun gnus-article-button-prev-page (arg)
4333 "Go to the prev page."
4335 (let ((win (selected-window)))
4336 (select-window (get-buffer-window gnus-article-buffer t))
4337 (gnus-article-prev-page)
4338 (select-window win)))
4340 (defvar gnus-decode-header-methods
4341 '(mail-decode-encoded-word-region)
4342 "List of methods used to decode headers.
4344 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item is
4345 FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
4346 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
4347 whose names match REGEXP.
4350 ((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
4351 mail-decode-encoded-word-region
4352 (\"chinese\" . rfc1843-decode-region))
4355 (defvar gnus-decode-header-methods-cache nil)
4357 (defun gnus-multi-decode-header (start end)
4358 "Apply the functions from `gnus-encoded-word-methods' that match."
4359 (unless (and gnus-decode-header-methods-cache
4360 (eq gnus-newsgroup-name
4361 (car gnus-decode-header-methods-cache)))
4362 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
4365 (nconc gnus-decode-header-methods-cache (list x))
4366 (if (and gnus-newsgroup-name
4367 (string-match (car x) gnus-newsgroup-name))
4368 (nconc gnus-decode-header-methods-cache
4370 gnus-decode-header-methods))
4371 (let ((xlist gnus-decode-header-methods-cache))
4374 (narrow-to-region start end)
4376 (funcall (pop xlist) (point-min) (point-max))))))
4379 ;;; Treatment top-level handling.
4382 (defun gnus-treat-article (condition &optional part-number total-parts type)
4383 (let ((length (- (point-max) (point-min)))
4384 (alist gnus-treatment-function-alist)
4386 (when (or (not type)
4388 (let ((list gnus-article-treat-types))
4390 (when (string-match (pop list) type)
4391 (throw 'found t))))))
4392 (while (setq elem (pop alist))
4393 (setq val (symbol-value (car elem)))
4404 (eq part-number total-parts))
4409 (funcall (cadr elem)))))))
4415 (defun gnus-article-header-presentation-method (entity situation)
4416 (mime-insert-header entity)
4419 (set-alist 'mime-header-presentation-method-alist
4420 'gnus-original-article-mode
4421 #'gnus-article-header-presentation-method)
4423 (defun gnus-mime-preview-quitting-method ()
4424 (mime-preview-kill-buffer)
4425 (delete-other-windows)
4426 (gnus-article-show-summary)
4427 (gnus-summary-select-article gnus-show-all-headers t))
4429 (set-alist 'mime-preview-quitting-method-alist
4430 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
4432 (defun gnus-following-method (buf)
4435 (message-yank-original)
4437 (goto-char (point-min))
4440 (set-alist 'mime-preview-following-method-alist
4441 'gnus-original-article-mode #'gnus-following-method)
4443 (set-alist 'mime-preview-over-to-previous-method-alist
4444 'gnus-original-article-mode
4446 (gnus-article-read-summary-keys
4447 nil (gnus-character-to-event ?P))))
4449 (set-alist 'mime-preview-over-to-next-method-alist
4450 'gnus-original-article-mode'
4452 (gnus-article-read-summary-keys
4453 nil (gnus-character-to-event ?N))))
4463 (run-hooks 'gnus-art-load-hook)
4465 ;;; gnus-art.el ends here