1 ;;; gnus-art.el --- article mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
4 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 ;; Boston, MA 02111-1307, USA.
28 (eval-when-compile (require 'cl))
41 (defgroup gnus-article nil
43 :link '(custom-manual "(gnus)The Article Buffer")
46 (defgroup gnus-article-treat nil
47 "Treating article parts."
48 :link '(custom-manual "(gnus)Article Hiding")
51 (defgroup gnus-article-hiding nil
52 "Hiding article parts."
53 :link '(custom-manual "(gnus)Article Hiding")
56 (defgroup gnus-article-highlight nil
57 "Article highlighting."
58 :link '(custom-manual "(gnus)Article Highlighting")
62 (defgroup gnus-article-signature nil
64 :link '(custom-manual "(gnus)Article Signature")
67 (defgroup gnus-article-headers nil
69 :link '(custom-manual "(gnus)Hiding Headers")
72 (defgroup gnus-article-washing nil
73 "Special commands on articles."
74 :link '(custom-manual "(gnus)Article Washing")
77 (defgroup gnus-article-emphasis nil
78 "Fontisizing articles."
79 :link '(custom-manual "(gnus)Article Fontisizing")
82 (defgroup gnus-article-saving nil
84 :link '(custom-manual "(gnus)Saving Articles")
87 (defgroup gnus-article-mime nil
88 "Worshiping the MIME wonder."
89 :link '(custom-manual "(gnus)Using MIME")
92 (defgroup gnus-article-buttons nil
93 "Pushable buttons in the article buffer."
94 :link '(custom-manual "(gnus)Article Buttons")
97 (defgroup gnus-article-various nil
98 "Other article options."
99 :link '(custom-manual "(gnus)Misc Article")
100 :group 'gnus-article)
102 (defcustom gnus-ignored-headers
103 '("^Path:" "^Expires:" "^Date-Received:" "^References:" "^Xref:" "^Lines:"
104 "^Relay-Version:" "^Message-ID:" "^Approved:" "^Sender:" "^Received:"
105 "^X-UIDL:" "^MIME-Version:" "^Return-Path:" "^In-Reply-To:"
106 "^Content-Type:" "^Content-Transfer-Encoding:" "^X-WebTV-Signature:"
107 "^X-MimeOLE:" "^X-MSMail-Priority:" "^X-Priority:" "^X-Loop:"
108 "^X-Authentication-Warning:" "^X-MIME-Autoconverted:" "^X-Face:"
109 "^X-Attribution:" "^X-Originating-IP:" "^Delivered-To:"
110 "^NNTP-[-A-Za-z]+:" "^Distribution:" "^X-no-archive:" "^X-Trace:"
111 "^X-Complaints-To:" "^X-NNTP-Posting-Host:" "^X-Orig.*:"
112 "^Abuse-Reports-To:" "^Cache-Post-Path:" "^X-Article-Creation-Date:"
113 "^X-Poster:" "^X-Mail2News-Path:" "^X-Server-Date:" "^X-Cache:"
114 "^Originator:" "^X-Problems-To:" "^X-Auth-User:" "^X-Post-Time:"
115 "^X-Admin:" "^X-UID:" "^Resent-[-A-Za-z]+:" "^X-Mailing-List:"
116 "^Precedence:" "^Original-[-A-Za-z]+:" "^X-filename:" "^X-Orcpt:"
117 "^Old-Received:" "^X-Pgp" "^X-Auth:" "^X-From-Line:"
118 "^X-Gnus-Article-Number:" "^X-Majordomo:" "^X-Url:" "^X-Sender:"
119 "^MBOX-Line" "^Priority:" "^X-Pgp" "^X400-[-A-Za-z]+:"
120 "^Status:" "^X-Gnus-Mail-Source:" "^Cancel-Lock:"
121 "^X-FTN" "^X-EXP32-SerialNo:" "^Encoding:" "^Importance:"
122 "^Autoforwarded:" "^Original-Encoded-Information-Types:" "^X-Ya-Pop3:"
123 "^X-Face-Version:" "^X-Vms-To:" "^X-ML-NAME:" "^X-ML-COUNT:"
124 "^Mailing-List:" "^X-finfo:" "^X-md5sum:" "^X-md5sum-Origin:"
125 "^X-Sun-Charset:" "^X-Accept-Language:" "^X-Envelope-Sender:"
126 "^List-[A-Za-z]+:" "^X-Listprocessor-Version:"
127 "^X-Received:" "^X-Distribute:" "^X-Sequence:" "^X-Juno-Line-Breaks:"
128 "^X-Notes-Item:" "^X-MS-TNEF-Correlator:" "^x-uunet-gateway:"
129 "^X-Received:" "^Content-length:" "X-precedence:")
130 "*All headers that start with this regexp will be hidden.
131 This variable can also be a list of regexps of headers to be ignored.
132 If `gnus-visible-headers' is non-nil, this variable will be ignored."
133 :type '(choice :custom-show nil
136 :group 'gnus-article-hiding)
138 (defcustom gnus-visible-headers
139 "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^[BGF]?Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Mail-Followup-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:\\|^X-Sent:"
140 "*All headers that do not match this regexp will be hidden.
141 This variable can also be a list of regexp of headers to remain visible.
142 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
143 :type '(repeat :value-to-internal (lambda (widget value)
144 (custom-split-regexp-maybe value))
145 :match (lambda (widget value)
147 (widget-editable-list-match widget value)))
149 :group 'gnus-article-hiding)
151 (defcustom gnus-sorted-header-list
152 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
153 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
154 "*This variable is a list of regular expressions.
155 If it is non-nil, headers that match the regular expressions will
156 be placed first in the article buffer in the sequence specified by
158 :type '(repeat regexp)
159 :group 'gnus-article-hiding)
161 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
162 "Headers that are only to be displayed if they have interesting data.
163 Possible values in this list are `empty', `newsgroups', `followup-to',
164 `reply-to', `date', `long-to', and `many-to'."
165 :type '(set (const :tag "Headers with no content." empty)
166 (const :tag "Newsgroups with only one group." newsgroups)
167 (const :tag "Followup-to identical to newsgroups." followup-to)
168 (const :tag "Reply-to identical to from." reply-to)
169 (const :tag "Date less than four days old." date)
170 (const :tag "Very long To and/or Cc header." long-to)
171 (const :tag "Multiple To and/or Cc headers." many-to))
172 :group 'gnus-article-hiding)
174 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
175 "Regexp matching signature separator.
176 This can also be a list of regexps. In that case, it will be checked
177 from head to tail looking for a separator. Searches will be done from
178 the end of the buffer."
179 :type '(repeat string)
180 :group 'gnus-article-signature)
182 (defcustom gnus-signature-limit nil
183 "Provide a limit to what is considered a signature.
184 If it is a number, no signature may not be longer (in characters) than
185 that number. If it is a floating point number, no signature may be
186 longer (in lines) than that number. If it is a function, the function
187 will be called without any parameters, and if it returns nil, there is
188 no signature in the buffer. If it is a string, it will be used as a
189 regexp. If it matches, the text in question is not a signature."
190 :type '(choice (integer :value 200)
192 (function :value fun)
193 (regexp :value ".*"))
194 :group 'gnus-article-signature)
196 (defcustom gnus-hidden-properties '(invisible t intangible t)
197 "Property list to use for hiding text."
199 :group 'gnus-article-hiding)
201 ;; Fixme: This isn't the right thing for mixed graphical and and
202 ;; non-graphical frames in a session.
203 ;; gnus-xmas.el overrides this for XEmacs.
204 (defcustom gnus-article-x-face-command
205 (if (and (fboundp 'image-type-available-p)
206 (image-type-available-p 'xbm))
207 'gnus-article-display-xface
208 (if gnus-article-compface-xbm
209 "{ echo '/* Width=48, Height=48 */'; uncompface; } | display -"
210 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
212 "*String or function to be executed to display an X-Face header.
213 If it is a string, the command will be executed in a sub-shell
214 asynchronously. The compressed face will be piped to this command."
215 :type '(choice string
216 (function-item gnus-article-display-xface)
218 :group 'gnus-article-washing)
220 (defcustom gnus-article-x-face-too-ugly nil
221 "Regexp matching posters whose face shouldn't be shown automatically."
222 :type '(choice regexp (const nil))
223 :group 'gnus-article-washing)
225 (defcustom gnus-article-banner-alist nil
226 "Banner alist for stripping.
228 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( eGroups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
229 :type '(repeat (cons symbol regexp))
230 :group 'gnus-article-washing)
232 (defcustom gnus-emphasis-alist
234 "\\(\\s-\\|^\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\s-\\|[-,;:\"]\\s-\\|[?!.]+\\s-\\|\\s)\\)")
236 '(("_" "_" underline)
239 ("_/" "/_" underline-italic)
240 ("_\\*" "\\*_" underline-bold)
241 ("\\*/" "/\\*" bold-italic)
242 ("_\\*/" "/\\*_" underline-bold-italic))))
243 `(("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
244 2 3 gnus-emphasis-underline)
248 (format format (car spec) (cadr spec))
249 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
251 "*Alist that says how to fontify certain phrases.
252 Each item looks like this:
254 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
256 The first element is a regular expression to be matched. The second
257 is a number that says what regular expression grouping used to find
258 the entire emphasized word. The third is a number that says what
259 regexp grouping should be displayed and highlighted. The fourth
260 is the face used for highlighting."
261 :type '(repeat (list :value ("" 0 0 default)
263 (integer :tag "Match group")
264 (integer :tag "Emphasize group")
266 :group 'gnus-article-emphasis)
268 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
269 "A regexp to describe whitespace which should not be emphasized.
270 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
271 The former avoids underlining of leading and trailing whitespace,
272 and the latter avoids underlining any whitespace at all."
273 :group 'gnus-article-emphasis
276 (defface gnus-emphasis-bold '((t (:bold t)))
277 "Face used for displaying strong emphasized text (*word*)."
278 :group 'gnus-article-emphasis)
280 (defface gnus-emphasis-italic '((t (:italic t)))
281 "Face used for displaying italic emphasized text (/word/)."
282 :group 'gnus-article-emphasis)
284 (defface gnus-emphasis-underline '((t (:underline t)))
285 "Face used for displaying underlined emphasized text (_word_)."
286 :group 'gnus-article-emphasis)
288 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
289 "Face used for displaying underlined bold emphasized text (_*word*_)."
290 :group 'gnus-article-emphasis)
292 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
293 "Face used for displaying underlined italic emphasized text (_/word/_)."
294 :group 'gnus-article-emphasis)
296 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
297 "Face used for displaying bold italic emphasized text (/*word*/)."
298 :group 'gnus-article-emphasis)
300 (defface gnus-emphasis-underline-bold-italic
301 '((t (:bold t :italic t :underline t)))
302 "Face used for displaying underlined bold italic emphasized text.
303 Esample: (_/*word*/_)."
304 :group 'gnus-article-emphasis)
306 (defface gnus-emphasis-highlight-words
307 '((t (:background "black" :foreground "yellow")))
308 "Face used for displaying highlighted words."
309 :group 'gnus-article-emphasis)
311 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
312 "Format for display of Date headers in article bodies.
313 See `format-time-string' for the possible values.
315 The variable can also be function, which should return a complete Date
316 header. The function is called with one argument, the time, which can
317 be fed to `format-time-string'."
318 :type '(choice string symbol)
319 :link '(custom-manual "(gnus)Article Date")
320 :group 'gnus-article-washing)
323 (autoload 'mail-extract-address-components "mail-extr"))
325 (defcustom gnus-save-all-headers t
326 "*If non-nil, don't remove any headers before saving."
327 :group 'gnus-article-saving
330 (defcustom gnus-prompt-before-saving 'always
331 "*This variable says how much prompting is to be done when saving articles.
332 If it is nil, no prompting will be done, and the articles will be
333 saved to the default files. If this variable is `always', each and
334 every article that is saved will be preceded by a prompt, even when
335 saving large batches of articles. If this variable is neither nil not
336 `always', there the user will be prompted once for a file name for
337 each invocation of the saving commands."
338 :group 'gnus-article-saving
339 :type '(choice (item always)
340 (item :tag "never" nil)
341 (sexp :tag "once" :format "%t\n" :value t)))
343 (defcustom gnus-saved-headers gnus-visible-headers
344 "Headers to keep if `gnus-save-all-headers' is nil.
345 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
346 If that variable is nil, however, all headers that match this regexp
347 will be kept while the rest will be deleted before saving."
348 :group 'gnus-article-saving
351 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
352 "A function to save articles in your favourite format.
353 The function must be interactively callable (in other words, it must
354 be an Emacs command).
356 Gnus provides the following functions:
358 * gnus-summary-save-in-rmail (Rmail format)
359 * gnus-summary-save-in-mail (Unix mail format)
360 * gnus-summary-save-in-folder (MH folder)
361 * gnus-summary-save-in-file (article format)
362 * gnus-summary-save-in-vm (use VM's folder format)
363 * gnus-summary-write-to-file (article format -- overwrite)."
364 :group 'gnus-article-saving
365 :type '(radio (function-item gnus-summary-save-in-rmail)
366 (function-item gnus-summary-save-in-mail)
367 (function-item gnus-summary-save-in-folder)
368 (function-item gnus-summary-save-in-file)
369 (function-item gnus-summary-save-in-vm)
370 (function-item gnus-summary-write-to-file)))
372 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
373 "A function generating a file name to save articles in Rmail format.
374 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
375 :group 'gnus-article-saving
378 (defcustom gnus-mail-save-name 'gnus-plain-save-name
379 "A function generating a file name to save articles in Unix mail format.
380 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
381 :group 'gnus-article-saving
384 (defcustom gnus-folder-save-name 'gnus-folder-save-name
385 "A function generating a file name to save articles in MH folder.
386 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
387 :group 'gnus-article-saving
390 (defcustom gnus-file-save-name 'gnus-numeric-save-name
391 "A function generating a file name to save articles in article format.
392 The function is called with NEWSGROUP, HEADERS, and optional
394 :group 'gnus-article-saving
397 (defcustom gnus-split-methods
398 '((gnus-article-archive-name)
399 (gnus-article-nndoc-name))
400 "*Variable used to suggest where articles are to be saved.
401 For instance, if you would like to save articles related to Gnus in
402 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
403 you could set this variable to something like:
405 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
406 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
408 This variable is an alist where the where the key is the match and the
409 value is a list of possible files to save in if the match is non-nil.
411 If the match is a string, it is used as a regexp match on the
412 article. If the match is a symbol, that symbol will be funcalled
413 from the buffer of the article to be saved with the newsgroup as the
414 parameter. If it is a list, it will be evaled in the same buffer.
416 If this form or function returns a string, this string will be used as
417 a possible file name; and if it returns a non-nil list, that list will
418 be used as possible file names."
419 :group 'gnus-article-saving
420 :type '(repeat (choice (list :value (fun) function)
421 (cons :value ("" "") regexp (repeat string))
424 (defcustom gnus-page-delimiter "^\^L"
425 "*Regexp describing what to use as article page delimiters.
426 The default value is \"^\^L\", which is a form linefeed at the
427 beginning of a line."
429 :group 'gnus-article-various)
431 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
432 "*The format specification for the article mode line.
433 See `gnus-summary-mode-line-format' for a closer description.
435 The following additional specs are available:
437 %w The article washing status.
438 %m The number of MIME parts in the article."
440 :group 'gnus-article-various)
442 (defcustom gnus-article-mode-hook nil
443 "*A hook for Gnus article mode."
445 :group 'gnus-article-various)
447 (defcustom gnus-article-menu-hook nil
448 "*Hook run after the creation of the article mode menu."
450 :group 'gnus-article-various)
452 (defcustom gnus-article-prepare-hook nil
453 "*A hook called after an article has been prepared in the article buffer."
455 :group 'gnus-article-various)
457 (defcustom gnus-article-hide-pgp-hook nil
458 "*A hook called after successfully hiding a PGP signature."
460 :group 'gnus-article-various)
462 (defcustom gnus-article-button-face 'bold
463 "Face used for highlighting buttons in the article buffer.
465 An article button is a piece of text that you can activate by pressing
466 `RET' or `mouse-2' above it."
468 :group 'gnus-article-buttons)
470 (defcustom gnus-article-mouse-face 'highlight
471 "Face used for mouse highlighting in the article buffer.
473 Article buttons will be displayed in this face when the cursor is
476 :group 'gnus-article-buttons)
478 (defcustom gnus-signature-face 'gnus-signature-face
479 "Face used for highlighting a signature in the article buffer.
480 Obsolete; use the face `gnus-signature-face' for customizations instead."
482 :group 'gnus-article-highlight
483 :group 'gnus-article-signature)
485 (defface gnus-signature-face
488 "Face used for highlighting a signature in the article buffer."
489 :group 'gnus-article-highlight
490 :group 'gnus-article-signature)
492 (defface gnus-header-from-face
495 (:foreground "spring green"))
498 (:foreground "red3"))
501 "Face used for displaying from headers."
502 :group 'gnus-article-headers
503 :group 'gnus-article-highlight)
505 (defface gnus-header-subject-face
508 (:foreground "SeaGreen3"))
511 (:foreground "red4"))
513 (:bold t :italic t)))
514 "Face used for displaying subject headers."
515 :group 'gnus-article-headers
516 :group 'gnus-article-highlight)
518 (defface gnus-header-newsgroups-face
521 (:foreground "yellow" :italic t))
524 (:foreground "MidnightBlue" :italic t))
527 "Face used for displaying newsgroups headers."
528 :group 'gnus-article-headers
529 :group 'gnus-article-highlight)
531 (defface gnus-header-name-face
534 (:foreground "SeaGreen"))
537 (:foreground "maroon"))
540 "Face used for displaying header names."
541 :group 'gnus-article-headers
542 :group 'gnus-article-highlight)
544 (defface gnus-header-content-face
547 (:foreground "forest green" :italic t))
550 (:foreground "indianred4" :italic t))
552 (:italic t))) "Face used for displaying header content."
553 :group 'gnus-article-headers
554 :group 'gnus-article-highlight)
556 (defcustom gnus-header-face-alist
557 '(("From" nil gnus-header-from-face)
558 ("Subject" nil gnus-header-subject-face)
559 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
560 ("" gnus-header-name-face gnus-header-content-face))
561 "*Controls highlighting of article header.
563 An alist of the form (HEADER NAME CONTENT).
565 HEADER is a regular expression which should match the name of an
566 header header and NAME and CONTENT are either face names or nil.
568 The name of each header field will be displayed using the face
569 specified by the first element in the list where HEADER match the
570 header name and NAME is non-nil. Similarly, the content will be
571 displayed by the first non-nil matching CONTENT face."
572 :group 'gnus-article-headers
573 :group 'gnus-article-highlight
574 :type '(repeat (list (regexp :tag "Header")
576 (item :tag "skip" nil)
577 (face :value default))
578 (choice :tag "Content"
579 (item :tag "skip" nil)
580 (face :value default)))))
582 (defcustom gnus-article-decode-hook
583 '(article-decode-charset article-decode-encoded-words)
584 "*Hook run to decode charsets in articles."
585 :group 'gnus-article-headers
588 (defcustom gnus-display-mime-function 'gnus-display-mime
589 "Function to display MIME articles."
590 :group 'gnus-article-mime
593 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
594 "Function used to decode headers.")
596 (defvar gnus-article-dumbquotes-map
614 "Table for MS-to-Latin1 translation.")
616 (defcustom gnus-ignored-mime-types nil
617 "List of MIME types that should be ignored by Gnus."
618 :group 'gnus-article-mime
619 :type '(repeat regexp))
621 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
622 "List of MIME types that should not be given buttons when rendered inline."
623 :group 'gnus-article-mime
624 :type '(repeat regexp))
626 (defcustom gnus-article-mime-part-function nil
627 "Function called with a MIME handle as the argument.
628 This is meant for people who want to do something automatic based
629 on parts -- for instance, adding Vcard info to a database."
630 :group 'gnus-article-mime
633 (defcustom gnus-mime-multipart-functions nil
634 "An alist of MIME types to functions to display them.")
636 (defcustom gnus-article-date-lapsed-new-header nil
637 "Whether the X-Sent and Date headers can coexist.
638 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
639 either replace the old \"Date:\" header (if this variable is nil), or
640 be added below it (otherwise)."
641 :group 'gnus-article-headers
644 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
645 "Function called with a MIME handle as the argument.
646 This is meant for people who want to view first matched part.
647 For `undisplayed-alternative' (default), the first undisplayed
648 part or alternative part is used. For `undisplayed', the first
649 undisplayed part is used. For a function, the first part which
650 the function return `t' is used. For `nil', the first part is
652 :group 'gnus-article-mime
654 (item :tag "first" :value nil)
655 (item :tag "undisplayed" :value undisplayed)
656 (item :tag "undisplayed or alternative"
657 :value undisplayed-alternative)
660 (defcustom gnus-mime-action-alist
661 '(("save to file" . gnus-mime-save-part)
662 ("save and strip" . gnus-mime-save-part-and-strip)
663 ("display as text" . gnus-mime-inline-part)
664 ("view the part" . gnus-mime-view-part)
665 ("pipe to command" . gnus-mime-pipe-part)
666 ("toggle display" . gnus-article-press-button)
667 ("toggle display" . gnus-article-view-part-as-charset)
668 ("view as type" . gnus-mime-view-part-as-type)
669 ("internalize type" . gnus-mime-internalize-part)
670 ("externalize type" . gnus-mime-externalize-part))
671 "An alist of actions that run on the MIME attachment."
672 :group 'gnus-article-mime
673 :type '(repeat (cons (string :tag "name")
677 ;;; The treatment variables
680 (defvar gnus-part-display-hook nil
681 "Hook called on parts that are to receive treatment.")
683 (defvar gnus-article-treat-custom
684 '(choice (const :tag "Off" nil)
686 (const :tag "Header" head)
687 (const :tag "Last" last)
688 (integer :tag "Less")
689 (repeat :tag "Groups" regexp)
690 (sexp :tag "Predicate")))
692 (defvar gnus-article-treat-head-custom
693 '(choice (const :tag "Off" nil)
694 (const :tag "Header" head)))
696 (defvar gnus-article-treat-types '("text/plain")
699 (defvar gnus-inhibit-treatment nil
700 "Whether to inhibit treatment.")
702 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
703 "Highlight the signature.
704 Valid values are nil, t, `head', `last', an integer or a predicate.
705 See the manual for details."
706 :group 'gnus-article-treat
707 :type gnus-article-treat-custom)
708 (put 'gnus-treat-highlight-signature 'highlight t)
710 (defcustom gnus-treat-buttonize 100000
712 Valid values are nil, t, `head', `last', an integer or a predicate.
713 See the manual for details."
714 :group 'gnus-article-treat
715 :type gnus-article-treat-custom)
716 (put 'gnus-treat-buttonize 'highlight t)
718 (defcustom gnus-treat-buttonize-head 'head
719 "Add buttons to the head.
720 Valid values are nil, t, `head', `last', an integer or a predicate.
721 See the manual for details."
722 :group 'gnus-article-treat
723 :type gnus-article-treat-head-custom)
724 (put 'gnus-treat-buttonize-head 'highlight t)
726 (defcustom gnus-treat-emphasize 50000
728 Valid values are nil, t, `head', `last', an integer or a predicate.
729 See the manual for details."
730 :group 'gnus-article-treat
731 :type gnus-article-treat-custom)
732 (put 'gnus-treat-emphasize 'highlight t)
734 (defcustom gnus-treat-strip-cr nil
735 "Remove carriage returns.
736 Valid values are nil, t, `head', `last', an integer or a predicate.
737 See the manual for details."
738 :group 'gnus-article-treat
739 :type gnus-article-treat-custom)
741 (defcustom gnus-treat-hide-headers 'head
743 Valid values are nil, t, `head', `last', an integer or a predicate.
744 See the manual for details."
745 :group 'gnus-article-treat
746 :type gnus-article-treat-head-custom)
748 (defcustom gnus-treat-hide-boring-headers nil
749 "Hide boring headers.
750 Valid values are nil, t, `head', `last', an integer or a predicate.
751 See the manual for details."
752 :group 'gnus-article-treat
753 :type gnus-article-treat-head-custom)
755 (defcustom gnus-treat-hide-signature nil
757 Valid values are nil, t, `head', `last', an integer or a predicate.
758 See the manual for details."
759 :group 'gnus-article-treat
760 :type gnus-article-treat-custom)
762 (defcustom gnus-treat-fill-article nil
764 Valid values are nil, t, `head', `last', an integer or a predicate.
765 See the manual for details."
766 :group 'gnus-article-treat
767 :type gnus-article-treat-custom)
769 (defcustom gnus-treat-hide-citation nil
771 Valid values are nil, t, `head', `last', an integer or a predicate.
772 See the manual for details."
773 :group 'gnus-article-treat
774 :type gnus-article-treat-custom)
776 (defcustom gnus-treat-hide-citation-maybe nil
778 Valid values are nil, t, `head', `last', an integer or a predicate.
779 See the manual for details."
780 :group 'gnus-article-treat
781 :type gnus-article-treat-custom)
783 (defcustom gnus-treat-strip-list-identifiers 'head
784 "Strip list identifiers from `gnus-list-identifiers`.
785 Valid values are nil, t, `head', `last', an integer or a predicate.
786 See the manual for details."
787 :group 'gnus-article-treat
788 :type gnus-article-treat-custom)
790 (defcustom gnus-treat-strip-pgp t
791 "Strip PGP signatures.
792 Valid values are nil, t, `head', `last', an integer or a predicate.
793 See the manual for details."
794 :group 'gnus-article-treat
795 :type gnus-article-treat-custom)
797 (defcustom gnus-treat-strip-pem nil
798 "Strip PEM signatures.
799 Valid values are nil, t, `head', `last', an integer or a predicate.
800 See the manual for details."
801 :group 'gnus-article-treat
802 :type gnus-article-treat-custom)
804 (defcustom gnus-treat-strip-banner t
805 "Strip banners from articles.
806 The banner to be stripped is specified in the `banner' group parameter.
807 Valid values are nil, t, `head', `last', an integer or a predicate.
808 See the manual for details."
809 :group 'gnus-article-treat
810 :type gnus-article-treat-custom)
812 (defcustom gnus-treat-highlight-headers 'head
813 "Highlight the headers.
814 Valid values are nil, t, `head', `last', an integer or a predicate.
815 See the manual for details."
816 :group 'gnus-article-treat
817 :type gnus-article-treat-head-custom)
818 (put 'gnus-treat-highlight-headers 'highlight t)
820 (defcustom gnus-treat-highlight-citation t
821 "Highlight cited text.
822 Valid values are nil, t, `head', `last', an integer or a predicate.
823 See the manual for details."
824 :group 'gnus-article-treat
825 :type gnus-article-treat-custom)
826 (put 'gnus-treat-highlight-citation 'highlight t)
828 (defcustom gnus-treat-date-ut nil
829 "Display the Date in UT (GMT).
830 Valid values are nil, t, `head', `last', an integer or a predicate.
831 See the manual for details."
832 :group 'gnus-article-treat
833 :type gnus-article-treat-head-custom)
835 (defcustom gnus-treat-date-local nil
836 "Display the Date in the local timezone.
837 Valid values are nil, t, `head', `last', an integer or a predicate.
838 See the manual for details."
839 :group 'gnus-article-treat
840 :type gnus-article-treat-head-custom)
842 (defcustom gnus-treat-date-lapsed nil
843 "Display the Date header in a way that says how much time has elapsed.
844 Valid values are nil, t, `head', `last', an integer or a predicate.
845 See the manual for details."
846 :group 'gnus-article-treat
847 :type gnus-article-treat-head-custom)
849 (defcustom gnus-treat-date-original nil
850 "Display the date in the original timezone.
851 Valid values are nil, t, `head', `last', an integer or a predicate.
852 See the manual for details."
853 :group 'gnus-article-treat
854 :type gnus-article-treat-head-custom)
856 (defcustom gnus-treat-date-iso8601 nil
857 "Display the date in the ISO8601 format.
858 Valid values are nil, t, `head', `last', an integer or a predicate.
859 See the manual for details."
860 :group 'gnus-article-treat
861 :type gnus-article-treat-head-custom)
863 (defcustom gnus-treat-date-user-defined nil
864 "Display the date in a user-defined format.
865 The format is defined by the `gnus-article-time-format' variable.
866 Valid values are nil, t, `head', `last', an integer or a predicate.
867 See the manual for details."
868 :group 'gnus-article-treat
869 :type gnus-article-treat-head-custom)
871 (defcustom gnus-treat-strip-headers-in-body t
872 "Strip the X-No-Archive header line from the beginning of the body.
873 Valid values are nil, t, `head', `last', an integer or a predicate.
874 See the manual for details."
875 :group 'gnus-article-treat
876 :type gnus-article-treat-custom)
878 (defcustom gnus-treat-strip-trailing-blank-lines nil
879 "Strip trailing blank lines.
880 Valid values are nil, t, `head', `last', an integer or a predicate.
881 See the manual for details."
882 :group 'gnus-article-treat
883 :type gnus-article-treat-custom)
885 (defcustom gnus-treat-strip-leading-blank-lines nil
886 "Strip leading blank lines.
887 Valid values are nil, t, `head', `last', an integer or a predicate.
888 See the manual for details."
889 :group 'gnus-article-treat
890 :type gnus-article-treat-custom)
892 (defcustom gnus-treat-strip-multiple-blank-lines nil
893 "Strip multiple blank lines.
894 Valid values are nil, t, `head', `last', an integer or a predicate.
895 See the manual for details."
896 :group 'gnus-article-treat
897 :type gnus-article-treat-custom)
899 (defcustom gnus-treat-overstrike t
900 "Treat overstrike highlighting.
901 Valid values are nil, t, `head', `last', an integer or a predicate.
902 See the manual for details."
903 :group 'gnus-article-treat
904 :type gnus-article-treat-custom)
905 (put 'gnus-treat-overstrike 'highlight t)
907 (defcustom gnus-treat-display-xface
908 (and (or (and (fboundp 'image-type-available-p)
909 (image-type-available-p 'xbm)
910 (string-match "^0x" (shell-command-to-string "uncompface")))
911 (and (featurep 'xemacs) (featurep 'xface)))
913 "Display X-Face headers.
914 Valid values are nil, t, `head', `last', an integer or a predicate.
915 See the manual for details."
916 :group 'gnus-article-treat
917 :type gnus-article-treat-head-custom)
918 (put 'gnus-treat-display-xface 'highlight t)
920 (defcustom gnus-treat-display-smileys
921 (if (or (and (featurep 'xemacs)
923 (and (fboundp 'image-type-available-p)
924 (image-type-available-p 'pbm)))
927 Valid values are nil, t, `head', `last', an integer or a predicate.
928 See the manual for details."
929 :group 'gnus-article-treat
930 :type gnus-article-treat-custom)
931 (put 'gnus-treat-display-smileys 'highlight t)
933 (defcustom gnus-treat-display-picons (if (featurep 'xemacs) 'head nil)
935 Valid values are nil, t, `head', `last', an integer or a predicate.
936 See the manual for details."
937 :group 'gnus-article-treat
938 :type gnus-article-treat-head-custom)
939 (put 'gnus-treat-display-picons 'highlight t)
941 (defcustom gnus-treat-capitalize-sentences nil
942 "Capitalize sentence-starting words.
943 Valid values are nil, t, `head', `last', an integer or a predicate.
944 See the manual for details."
945 :group 'gnus-article-treat
946 :type gnus-article-treat-custom)
948 (defcustom gnus-treat-fill-long-lines nil
950 Valid values are nil, t, `head', `last', an integer or a predicate.
951 See the manual for details."
952 :group 'gnus-article-treat
953 :type gnus-article-treat-custom)
955 (defcustom gnus-treat-play-sounds nil
957 Valid values are nil, t, `head', `last', an integer or a predicate.
958 See the manual for details."
959 :group 'gnus-article-treat
960 :type gnus-article-treat-custom)
962 (defcustom gnus-treat-translate nil
963 "Translate articles from one language to another.
964 Valid values are nil, t, `head', `last', an integer or a predicate.
965 See the manual for details."
966 :group 'gnus-article-treat
967 :type gnus-article-treat-custom)
969 (defvar gnus-article-encrypt-protocol-alist
970 '(("PGP" . mml2015-self-encrypt)))
972 ;; Set to nil if more than one protocol added to
973 ;; gnus-article-encrypt-protocol-alist.
974 (defcustom gnus-article-encrypt-protocol "PGP"
975 "The protocol used for encrypt articles.
976 It is a string, such as \"PGP\". If nil, ask user."
978 :group 'mime-security)
980 ;;; Internal variables
982 (defvar article-goto-body-goes-to-point-min-p nil)
983 (defvar gnus-article-wash-types nil)
984 (defvar gnus-article-emphasis-alist nil)
986 (defvar gnus-article-mime-handle-alist-1 nil)
987 (defvar gnus-treatment-function-alist
988 '((gnus-treat-strip-banner gnus-article-strip-banner)
989 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
990 (gnus-treat-highlight-signature gnus-article-highlight-signature)
991 (gnus-treat-buttonize gnus-article-add-buttons)
992 (gnus-treat-fill-article gnus-article-fill-cited-article)
993 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
994 (gnus-treat-strip-cr gnus-article-remove-cr)
995 (gnus-treat-emphasize gnus-article-emphasize)
996 (gnus-treat-display-xface gnus-article-display-x-face)
997 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
998 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
999 (gnus-treat-hide-signature gnus-article-hide-signature)
1000 (gnus-treat-hide-citation gnus-article-hide-citation)
1001 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1002 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1003 (gnus-treat-strip-pgp gnus-article-hide-pgp)
1004 (gnus-treat-strip-pem gnus-article-hide-pem)
1005 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1006 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1007 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1008 (gnus-treat-date-ut gnus-article-date-ut)
1009 (gnus-treat-date-local gnus-article-date-local)
1010 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1011 (gnus-treat-date-original gnus-article-date-original)
1012 (gnus-treat-date-user-defined gnus-article-date-user)
1013 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1014 (gnus-treat-strip-trailing-blank-lines
1015 gnus-article-remove-trailing-blank-lines)
1016 (gnus-treat-strip-leading-blank-lines
1017 gnus-article-strip-leading-blank-lines)
1018 (gnus-treat-strip-multiple-blank-lines
1019 gnus-article-strip-multiple-blank-lines)
1020 (gnus-treat-overstrike gnus-article-treat-overstrike)
1021 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1022 (gnus-treat-display-smileys gnus-smiley-display)
1023 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1024 (gnus-treat-display-picons gnus-article-display-picons)
1025 (gnus-treat-play-sounds gnus-earcon-display)))
1027 (defvar gnus-article-mime-handle-alist nil)
1028 (defvar article-lapsed-timer nil)
1029 (defvar gnus-article-current-summary nil)
1031 (defvar gnus-article-mode-syntax-table
1032 (let ((table (copy-syntax-table text-mode-syntax-table)))
1033 (modify-syntax-entry ?- "w" table)
1034 (modify-syntax-entry ?> ")" table)
1035 (modify-syntax-entry ?< "(" table)
1037 "Syntax table used in article mode buffers.
1038 Initialized from `text-mode-syntax-table.")
1040 (defvar gnus-save-article-buffer nil)
1042 (defvar gnus-article-mode-line-format-alist
1043 (nconc '((?w (gnus-article-wash-status) ?s)
1044 (?m (gnus-article-mime-part-status) ?s))
1045 gnus-summary-mode-line-format-alist))
1047 (defvar gnus-number-of-articles-to-be-saved nil)
1049 (defvar gnus-inhibit-hiding nil)
1051 (defsubst gnus-article-hide-text (b e props)
1052 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1053 (add-text-properties b e props)
1054 (when (memq 'intangible props)
1056 (max (1- b) (point-min))
1057 b 'intangible (cddr (memq 'intangible props)))))
1058 (defsubst gnus-article-unhide-text (b e)
1059 "Remove hidden text properties from region between B and E."
1060 (remove-text-properties b e gnus-hidden-properties)
1061 (when (memq 'intangible gnus-hidden-properties)
1062 (put-text-property (max (1- b) (point-min))
1063 b 'intangible nil)))
1065 (defun gnus-article-hide-text-type (b e type)
1066 "Hide text of TYPE between B and E."
1067 (push type gnus-article-wash-types)
1068 (gnus-article-hide-text
1069 b e (cons 'article-type (cons type gnus-hidden-properties))))
1071 (defun gnus-article-unhide-text-type (b e type)
1072 "Unhide text of TYPE between B and E."
1073 (setq gnus-article-wash-types
1074 (delq type gnus-article-wash-types))
1075 (remove-text-properties
1076 b e (cons 'article-type (cons type gnus-hidden-properties)))
1077 (when (memq 'intangible gnus-hidden-properties)
1078 (put-text-property (max (1- b) (point-min))
1079 b 'intangible nil)))
1081 (defun gnus-article-hide-text-of-type (type)
1082 "Hide text of TYPE in the current buffer."
1084 (let ((b (point-min))
1086 (while (setq b (text-property-any b e 'article-type type))
1087 (add-text-properties b (incf b) gnus-hidden-properties)))))
1089 (defun gnus-article-delete-text-of-type (type)
1090 "Delete text of TYPE in the current buffer."
1092 (let ((b (point-min)))
1093 (while (setq b (text-property-any b (point-max) 'article-type type))
1095 b (or (text-property-not-all b (point-max) 'article-type type)
1098 (defun gnus-article-delete-invisible-text ()
1099 "Delete all invisible text in the current buffer."
1101 (let ((b (point-min)))
1102 (while (setq b (text-property-any b (point-max) 'invisible t))
1104 b (or (text-property-not-all b (point-max) 'invisible t)
1107 (defun gnus-article-text-type-exists-p (type)
1108 "Say whether any text of type TYPE exists in the buffer."
1109 (text-property-any (point-min) (point-max) 'article-type type))
1111 (defsubst gnus-article-header-rank ()
1112 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1113 (let ((list gnus-sorted-header-list)
1116 (when (looking-at (car list))
1118 (setq list (cdr list))
1122 (defun article-hide-headers (&optional arg delete)
1123 "Hide unwanted headers and possibly sort them as well."
1125 ;; This function might be inhibited.
1126 (unless gnus-inhibit-hiding
1129 (let ((buffer-read-only nil)
1130 (case-fold-search t)
1131 (max (1+ (length gnus-sorted-header-list)))
1132 (ignored (when (not gnus-visible-headers)
1133 (cond ((stringp gnus-ignored-headers)
1134 gnus-ignored-headers)
1135 ((listp gnus-ignored-headers)
1136 (mapconcat 'identity gnus-ignored-headers
1139 (cond ((stringp gnus-visible-headers)
1140 gnus-visible-headers)
1141 ((and gnus-visible-headers
1142 (listp gnus-visible-headers))
1143 (mapconcat 'identity gnus-visible-headers "\\|"))))
1144 (inhibit-point-motion-hooks t)
1146 ;; First we narrow to just the headers.
1147 (article-narrow-to-head)
1148 ;; Hide any "From " lines at the beginning of (mail) articles.
1149 (while (looking-at "From ")
1152 (delete-region (point-min) (point)))
1153 ;; Then treat the rest of the header lines.
1154 ;; Then we use the two regular expressions
1155 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1156 ;; select which header lines is to remain visible in the
1158 (while (re-search-forward "^[^ \t]*:" nil t)
1160 ;; Mark the rank of the header.
1162 (point) (1+ (point)) 'message-rank
1163 (if (or (and visible (looking-at visible))
1165 (not (looking-at ignored))))
1166 (gnus-article-header-rank)
1169 (message-sort-headers-1)
1170 (when (setq beg (text-property-any
1171 (point-min) (point-max) 'message-rank (+ 2 max)))
1172 ;; We delete the unwanted headers.
1173 (push 'headers gnus-article-wash-types)
1174 (add-text-properties (point-min) (+ 5 (point-min))
1175 '(article-type headers dummy-invisible t))
1176 (delete-region beg (point-max))))))))
1178 (defun article-hide-boring-headers (&optional arg)
1179 "Toggle hiding of headers that aren't very interesting.
1180 If given a negative prefix, always show; if given a positive prefix,
1182 (interactive (gnus-article-hidden-arg))
1183 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1184 (not gnus-show-all-headers))
1187 (let ((buffer-read-only nil)
1188 (list gnus-boring-article-headers)
1189 (inhibit-point-motion-hooks t)
1191 (article-narrow-to-head)
1193 (setq elem (pop list))
1194 (goto-char (point-min))
1196 ;; Hide empty headers.
1198 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1200 (gnus-article-hide-text-type
1201 (progn (beginning-of-line) (point))
1204 (if (re-search-forward "^[^ \t]" nil t)
1208 ;; Hide boring Newsgroups header.
1209 ((eq elem 'newsgroups)
1210 (when (equal (gnus-fetch-field "newsgroups")
1211 (gnus-group-real-name
1212 (if (boundp 'gnus-newsgroup-name)
1215 (gnus-article-hide-header "newsgroups")))
1216 ((eq elem 'followup-to)
1217 (when (equal (message-fetch-field "followup-to")
1218 (message-fetch-field "newsgroups"))
1219 (gnus-article-hide-header "followup-to")))
1220 ((eq elem 'reply-to)
1221 (let ((from (message-fetch-field "from"))
1222 (reply-to (message-fetch-field "reply-to")))
1227 (nth 1 (mail-extract-address-components from))
1228 (nth 1 (mail-extract-address-components reply-to)))))
1229 (gnus-article-hide-header "reply-to"))))
1231 (let ((date (message-fetch-field "date")))
1233 (< (days-between (current-time-string) date)
1235 (gnus-article-hide-header "date"))))
1237 (let ((to (message-fetch-field "to"))
1238 (cc (message-fetch-field "cc")))
1239 (when (> (length to) 1024)
1240 (gnus-article-hide-header "to"))
1241 (when (> (length cc) 1024)
1242 (gnus-article-hide-header "cc"))))
1246 (goto-char (point-min))
1247 (while (re-search-forward "^to:" nil t)
1248 (setq to-count (1+ to-count)))
1249 (when (> to-count 1)
1250 (while (> to-count 0)
1251 (goto-char (point-min))
1253 (re-search-forward "^to:" nil nil to-count)
1255 (narrow-to-region (point) (point-max))
1256 (gnus-article-hide-header "to"))
1257 (setq to-count (1- to-count))))
1258 (goto-char (point-min))
1259 (while (re-search-forward "^cc:" nil t)
1260 (setq cc-count (1+ cc-count)))
1261 (when (> cc-count 1)
1262 (while (> cc-count 0)
1263 (goto-char (point-min))
1265 (re-search-forward "^cc:" nil nil cc-count)
1267 (narrow-to-region (point) (point-max))
1268 (gnus-article-hide-header "cc"))
1269 (setq cc-count (1- cc-count)))))))))))))
1271 (defun gnus-article-hide-header (header)
1273 (goto-char (point-min))
1274 (when (re-search-forward (concat "^" header ":") nil t)
1275 (gnus-article-hide-text-type
1276 (progn (beginning-of-line) (point))
1279 (if (re-search-forward "^[^ \t]" nil t)
1284 (defvar gnus-article-normalized-header-length 40
1285 "Length of normalized headers.")
1287 (defun article-normalize-headers ()
1288 "Make all header lines 40 characters long."
1290 (let ((buffer-read-only nil)
1294 (article-narrow-to-head)
1297 ((< (setq column (- (gnus-point-at-eol) (point)))
1298 gnus-article-normalized-header-length)
1300 (insert (make-string
1301 (- gnus-article-normalized-header-length column)
1303 ((> column gnus-article-normalized-header-length)
1304 (gnus-put-text-property
1306 (forward-char gnus-article-normalized-header-length)
1313 (forward-line 1))))))
1315 (defun article-treat-dumbquotes ()
1316 "Translate M******** sm*rtq**t*s into proper text.
1317 Note that this function guesses whether a character is a sm*rtq**t* or
1318 not, so it should only be used interactively."
1320 (article-translate-strings gnus-article-dumbquotes-map))
1322 (defun article-translate-characters (from to)
1323 "Translate all characters in the body of the article according to FROM and TO.
1324 FROM is a string of characters to translate from; to is a string of
1325 characters to translate to."
1327 (when (article-goto-body)
1328 (let ((buffer-read-only nil)
1329 (x (make-string 225 ?x))
1331 (while (< (incf i) (length x))
1334 (while (< i (length from))
1335 (aset x (aref from i) (aref to i))
1337 (translate-region (point) (point-max) x)))))
1339 (defun article-translate-strings (map)
1340 "Translate all string in the body of the article according to MAP.
1341 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1343 (when (article-goto-body)
1344 (let ((buffer-read-only nil)
1346 (while (setq elem (pop map))
1348 (while (search-forward (car elem) nil t)
1349 (replace-match (cadr elem)))))))))
1351 (defun article-treat-overstrike ()
1352 "Translate overstrikes into bold text."
1355 (when (article-goto-body)
1356 (let ((buffer-read-only nil))
1357 (while (search-forward "\b" nil t)
1358 (let ((next (char-after))
1359 (previous (char-after (- (point) 2))))
1360 ;; We do the boldification/underlining by hiding the
1361 ;; overstrikes and putting the proper text property
1365 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1366 (put-text-property (point) (1+ (point)) 'face 'bold))
1368 (gnus-article-hide-text-type
1369 (1- (point)) (1+ (point)) 'overstrike)
1371 (- (point) 2) (1- (point)) 'face 'underline))
1373 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1375 (point) (1+ (point)) 'face 'underline)))))))))
1377 (defun article-fill-long-lines ()
1378 "Fill lines that are wider than the window width."
1381 (let ((buffer-read-only nil)
1382 (width (window-width (get-buffer-window (current-buffer)))))
1385 (let ((adaptive-fill-mode nil))
1388 (when (>= (current-column) (min fill-column width))
1389 (narrow-to-region (point) (gnus-point-at-bol))
1390 (fill-paragraph nil)
1391 (goto-char (point-max))
1393 (forward-line 1)))))))
1395 (defun article-capitalize-sentences ()
1396 "Capitalize the first word in each sentence."
1399 (let ((buffer-read-only nil)
1400 (paragraph-start "^[\n\^L]"))
1404 (forward-sentence)))))
1406 (defun article-remove-cr ()
1407 "Remove trailing CRs and then translate remaining CRs into LFs."
1410 (let ((buffer-read-only nil))
1411 (goto-char (point-min))
1412 (while (re-search-forward "\r+$" nil t)
1413 (replace-match "" t t))
1414 (goto-char (point-min))
1415 (while (search-forward "\r" nil t)
1416 (replace-match "\n" t t)))))
1418 (defun article-remove-trailing-blank-lines ()
1419 "Remove all trailing blank lines from the article."
1422 (let ((buffer-read-only nil))
1423 (goto-char (point-max))
1427 (while (and (not (bobp))
1428 (looking-at "^[ \t]*$")
1429 (not (gnus-annotation-in-region-p
1430 (point) (gnus-point-at-eol))))
1435 (defun article-display-x-face (&optional force)
1436 "Look for an X-Face header and display it if present."
1437 (interactive (list 'force))
1439 ;; Delete the old process, if any.
1440 (when (process-status "article-x-face")
1441 (delete-process "article-x-face"))
1442 (let ((inhibit-point-motion-hooks t)
1443 (case-fold-search t)
1446 (article-narrow-to-head)
1447 (goto-char (point-min))
1448 (setq from (message-fetch-field "from"))
1449 (goto-char (point-min))
1450 (while (and gnus-article-x-face-command
1453 ;; Check whether this face is censored.
1454 (not gnus-article-x-face-too-ugly)
1455 (and gnus-article-x-face-too-ugly from
1456 (not (string-match gnus-article-x-face-too-ugly
1458 ;; Has to be present.
1459 (re-search-forward "^X-Face: " nil t))
1460 ;; This used to try to do multiple faces (`while' instead of
1461 ;; `when' above), but (a) sending multiple EOFs to xv doesn't
1462 ;; work (b) it can crash some versions of Emacs (c) are
1463 ;; multiple faces really something to encourage?
1464 (when (stringp gnus-article-x-face-command)
1466 ;; We now have the area of the buffer where the X-Face is stored.
1469 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
1470 ;; We display the face.
1471 (if (symbolp gnus-article-x-face-command)
1472 ;; The command is a lisp function, so we call it.
1473 (if (gnus-functionp gnus-article-x-face-command)
1474 (funcall gnus-article-x-face-command beg end)
1475 (error "%s is not a function" gnus-article-x-face-command))
1476 ;; The command is a string, so we interpret the command
1477 ;; as a, well, command, and fork it off.
1478 (let ((process-connection-type nil))
1479 (process-kill-without-query
1481 "article-x-face" nil shell-file-name shell-command-switch
1482 gnus-article-x-face-command))
1483 (process-send-region "article-x-face" beg end)
1484 (process-send-eof "article-x-face"))))))))))
1486 (defun article-decode-mime-words ()
1487 "Decode all MIME-encoded words in the article."
1490 (set-buffer gnus-article-buffer)
1491 (let ((inhibit-point-motion-hooks t)
1493 (mail-parse-charset gnus-newsgroup-charset)
1494 (mail-parse-ignored-charsets
1495 (save-excursion (set-buffer gnus-summary-buffer)
1496 gnus-newsgroup-ignored-charsets)))
1497 (mail-decode-encoded-word-region (point-min) (point-max)))))
1499 (defun article-decode-charset (&optional prompt)
1500 "Decode charset-encoded text in the article.
1501 If PROMPT (the prefix), prompt for a coding system to use."
1503 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
1505 (mail-parse-charset gnus-newsgroup-charset)
1506 (mail-parse-ignored-charsets
1507 (save-excursion (condition-case nil
1508 (set-buffer gnus-summary-buffer)
1510 gnus-newsgroup-ignored-charsets))
1511 ct cte ctl charset format)
1514 (article-narrow-to-head)
1515 (setq ct (message-fetch-field "Content-Type" t)
1516 cte (message-fetch-field "Content-Transfer-Encoding" t)
1517 ctl (and ct (ignore-errors
1518 (mail-header-parse-content-type ct)))
1521 (mm-read-coding-system "Charset to decode: "))
1523 (mail-content-type-get ctl 'charset)))
1524 format (and ctl (mail-content-type-get ctl 'format)))
1526 (setq cte (mail-header-strip cte)))
1527 (if (and ctl (not (string-match "/" (car ctl))))
1529 (goto-char (point-max)))
1532 (narrow-to-region (point) (point-max))
1533 (when (and (eq mail-parse-charset 'gnus-decoded)
1534 (eq (mm-body-7-or-8) '8bit))
1535 ;; The text code could have been decoded.
1536 (setq charset mail-parse-charset))
1537 (when (and (or (not ctl)
1538 (equal (car ctl) "text/plain"))
1539 (not format)) ;; article with format will decode later.
1541 charset (and cte (intern (downcase
1542 (gnus-strip-whitespace cte))))
1545 (defun article-decode-encoded-words ()
1546 "Remove encoded-word encoding from headers."
1547 (let ((inhibit-point-motion-hooks t)
1548 (mail-parse-charset gnus-newsgroup-charset)
1549 (mail-parse-ignored-charsets
1550 (save-excursion (condition-case nil
1551 (set-buffer gnus-summary-buffer)
1553 gnus-newsgroup-ignored-charsets))
1556 (article-narrow-to-head)
1557 (funcall gnus-decode-header-function (point-min) (point-max)))))
1559 (defun article-de-quoted-unreadable (&optional force)
1560 "Translate a quoted-printable-encoded article.
1561 If FORCE, decode the article whether it is marked as quoted-printable
1563 (interactive (list 'force))
1565 (let ((buffer-read-only nil) type charset)
1566 (if (gnus-buffer-live-p gnus-original-article-buffer)
1567 (with-current-buffer gnus-original-article-buffer
1569 (gnus-fetch-field "content-transfer-encoding"))
1570 (let* ((ct (gnus-fetch-field "content-type"))
1573 (mail-header-parse-content-type ct)))))
1574 (setq charset (and ctl
1575 (mail-content-type-get ctl 'charset)))
1576 (if (stringp charset)
1577 (setq charset (intern (downcase charset)))))))
1579 (setq charset gnus-newsgroup-charset))
1581 (and type (let ((case-fold-search t))
1582 (string-match "quoted-printable" type))))
1584 (quoted-printable-decode-region
1585 (point) (point-max) (mm-charset-to-coding-system charset))))))
1587 (defun article-de-base64-unreadable (&optional force)
1588 "Translate a base64 article.
1589 If FORCE, decode the article whether it is marked as base64 not."
1590 (interactive (list 'force))
1592 (let ((buffer-read-only nil) type charset)
1593 (if (gnus-buffer-live-p gnus-original-article-buffer)
1594 (with-current-buffer gnus-original-article-buffer
1596 (gnus-fetch-field "content-transfer-encoding"))
1597 (let* ((ct (gnus-fetch-field "content-type"))
1600 (mail-header-parse-content-type ct)))))
1601 (setq charset (and ctl
1602 (mail-content-type-get ctl 'charset)))
1603 (if (stringp charset)
1604 (setq charset (intern (downcase charset)))))))
1606 (setq charset gnus-newsgroup-charset))
1608 (and type (let ((case-fold-search t))
1609 (string-match "base64" type))))
1612 (narrow-to-region (point) (point-max))
1613 (base64-decode-region (point-min) (point-max))
1614 (mm-decode-coding-region
1615 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
1620 (defun article-decode-HZ ()
1621 "Translate a HZ-encoded article."
1625 (let ((buffer-read-only nil))
1626 (rfc1843-decode-region (point-min) (point-max)))))
1628 (defun article-wash-html ()
1629 "Format an html article."
1632 (let ((buffer-read-only nil)
1634 (if (gnus-buffer-live-p gnus-original-article-buffer)
1635 (with-current-buffer gnus-original-article-buffer
1636 (let* ((ct (gnus-fetch-field "content-type"))
1639 (mail-header-parse-content-type ct)))))
1640 (setq charset (and ctl
1641 (mail-content-type-get ctl 'charset)))
1642 (if (stringp charset)
1643 (setq charset (intern (downcase charset)))))))
1645 (setq charset gnus-newsgroup-charset))
1647 (save-window-excursion
1649 (narrow-to-region (point) (point-max))
1651 (let ((w3-strict-width (window-width))
1652 (url-standalone-mode t))
1654 (w3-region (point-min) (point-max))
1657 (defun article-hide-list-identifiers ()
1658 "Remove list identifies from the Subject header.
1659 The `gnus-list-identifiers' variable specifies what to do."
1663 (let ((inhibit-point-motion-hooks t)
1665 (article-narrow-to-head)
1666 (let ((regexp (if (stringp gnus-list-identifiers) gnus-list-identifiers
1667 (mapconcat 'identity gnus-list-identifiers " *\\|"))))
1669 (goto-char (point-min))
1670 (when (re-search-forward
1671 (concat "^Subject: +\\(\\(\\(Re: +\\)?\\(" regexp
1672 " *\\)\\)+\\(Re: +\\)?\\)")
1674 (let ((s (or (match-string 3) (match-string 5))))
1675 (delete-region (match-beginning 1) (match-end 1))
1677 (goto-char (match-beginning 1))
1680 (defun article-hide-pgp ()
1681 "Remove any PGP headers and signatures in the current article."
1685 (let ((inhibit-point-motion-hooks t)
1686 buffer-read-only beg end)
1688 ;; Hide the "header".
1689 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
1690 (push 'pgp gnus-article-wash-types)
1691 (delete-region (match-beginning 0) (match-end 0))
1692 ;; Remove armor headers (rfc2440 6.2)
1693 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
1696 ;; Hide the actual signature.
1697 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
1698 (setq end (1+ (match-beginning 0)))
1701 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
1703 ;; Perhaps we shouldn't hide to the end of the buffer
1704 ;; if there is no end to the signature?
1706 ;; Hide "- " PGP quotation markers.
1708 (narrow-to-region beg end)
1709 (goto-char (point-min))
1710 (while (re-search-forward "^- " nil t)
1712 (match-beginning 0) (match-end 0)))
1714 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
1716 (defun article-hide-pem (&optional arg)
1717 "Toggle hiding of any PEM headers and signatures in the current article.
1718 If given a negative prefix, always show; if given a positive prefix,
1720 (interactive (gnus-article-hidden-arg))
1721 (unless (gnus-article-check-hidden-text 'pem arg)
1723 (let (buffer-read-only end)
1724 (goto-char (point-min))
1725 ;; Hide the horrendously ugly "header".
1726 (when (and (search-forward
1727 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
1729 (setq end (1+ (match-beginning 0))))
1730 (push 'pem gnus-article-wash-types)
1731 (gnus-article-hide-text-type
1733 (if (search-forward "\n\n" nil t)
1737 ;; Hide the trailer as well
1738 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
1740 (gnus-article-hide-text-type
1741 (match-beginning 0) (match-end 0) 'pem)))))))
1743 (defun article-strip-banner ()
1744 "Strip the banner specified by the `banner' group parameter."
1748 (let ((inhibit-point-motion-hooks t)
1749 (banner (gnus-group-find-parameter gnus-newsgroup-name 'banner))
1750 (gnus-signature-limit nil)
1751 buffer-read-only beg end)
1755 ((eq banner 'signature)
1756 (when (gnus-article-narrow-to-signature)
1759 (delete-region (point) (point-max))))
1761 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
1762 (while (re-search-forward banner nil t)
1763 (delete-region (match-beginning 0) (match-end 0)))))
1765 (while (re-search-forward banner nil t)
1766 (delete-region (match-beginning 0) (match-end 0))))))))))
1768 (defun article-babel ()
1769 "Translate article using an online translation service."
1773 (set-buffer gnus-article-buffer)
1774 (when (article-goto-body)
1775 (let* ((buffer-read-only nil)
1778 (orig (buffer-substring start end))
1779 (trans (babel-as-string orig)))
1781 (narrow-to-region start end)
1782 (delete-region start end)
1785 (defun article-hide-signature (&optional arg)
1786 "Hide the signature in the current article.
1787 If given a negative prefix, always show; if given a positive prefix,
1789 (interactive (gnus-article-hidden-arg))
1790 (unless (gnus-article-check-hidden-text 'signature arg)
1793 (let ((buffer-read-only nil))
1794 (when (gnus-article-narrow-to-signature)
1795 (gnus-article-hide-text-type
1796 (point-min) (point-max) 'signature)))))))
1798 (defun article-strip-headers-in-body ()
1799 "Strip offensive headers from bodies."
1803 (let ((case-fold-search t))
1804 (when (looking-at "x-no-archive:")
1805 (gnus-delete-line)))))
1807 (defun article-strip-leading-blank-lines ()
1808 "Remove all blank lines from the beginning of the article."
1811 (let ((inhibit-point-motion-hooks t)
1813 (when (article-goto-body)
1814 (while (and (not (eobp))
1815 (looking-at "[ \t]*$"))
1816 (gnus-delete-line))))))
1818 (defun article-narrow-to-head ()
1819 "Narrow the buffer to the head of the message.
1820 Point is left at the beginning of the narrowed-to region."
1822 (goto-char (point-min))
1823 (if (search-forward "\n\n" nil 1)
1826 (goto-char (point-min)))
1828 (defun article-goto-body ()
1829 "Place point at the start of the body."
1830 (goto-char (point-min))
1832 ;; This variable is only bound when dealing with separate
1834 (article-goto-body-goes-to-point-min-p
1836 ((search-forward "\n\n" nil t)
1839 (goto-char (point-max))
1842 (defun article-strip-multiple-blank-lines ()
1843 "Replace consecutive blank lines with one empty line."
1846 (let ((inhibit-point-motion-hooks t)
1848 ;; First make all blank lines empty.
1850 (while (re-search-forward "^[ \t]+$" nil t)
1851 (unless (gnus-annotation-in-region-p
1852 (match-beginning 0) (match-end 0))
1853 (replace-match "" nil t)))
1854 ;; Then replace multiple empty lines with a single empty line.
1856 (while (re-search-forward "\n\n\n+" nil t)
1857 (unless (gnus-annotation-in-region-p
1858 (match-beginning 0) (match-end 0))
1859 (replace-match "\n\n" t t))))))
1861 (defun article-strip-leading-space ()
1862 "Remove all white space from the beginning of the lines in the article."
1865 (let ((inhibit-point-motion-hooks t)
1868 (while (re-search-forward "^[ \t]+" nil t)
1869 (replace-match "" t t)))))
1871 (defun article-strip-trailing-space ()
1872 "Remove all white space from the end of the lines in the article."
1875 (let ((inhibit-point-motion-hooks t)
1878 (while (re-search-forward "[ \t]+$" nil t)
1879 (replace-match "" t t)))))
1881 (defun article-strip-blank-lines ()
1882 "Strip leading, trailing and multiple blank lines."
1884 (article-strip-leading-blank-lines)
1885 (article-remove-trailing-blank-lines)
1886 (article-strip-multiple-blank-lines))
1888 (defun article-strip-all-blank-lines ()
1889 "Strip all blank lines."
1892 (let ((inhibit-point-motion-hooks t)
1895 (while (re-search-forward "^[ \t]*\n" nil t)
1896 (replace-match "" t t)))))
1898 (defun gnus-article-narrow-to-signature ()
1899 "Narrow to the signature; return t if a signature is found, else nil."
1900 (let ((inhibit-point-motion-hooks t))
1901 (when (gnus-article-search-signature)
1903 ;; Check whether we have some limits to what we consider
1904 ;; to be a signature.
1905 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
1906 (list gnus-signature-limit)))
1908 (while (setq limit (pop limits))
1909 (if (or (and (integerp limit)
1910 (< (- (point-max) (point)) limit))
1912 (< (count-lines (point) (point-max)) limit))
1913 (and (gnus-functionp limit)
1915 (and (stringp limit)
1916 (not (re-search-forward limit nil t))))
1917 () ; This limit did not succeed.
1921 (narrow-to-region (point) (point-max))
1924 (defun gnus-article-search-signature ()
1925 "Search the current buffer for the signature separator.
1926 Put point at the beginning of the signature separator."
1927 (let ((cur (point)))
1928 (goto-char (point-max))
1929 (if (if (stringp gnus-signature-separator)
1930 (re-search-backward gnus-signature-separator nil t)
1931 (let ((seps gnus-signature-separator))
1933 (not (re-search-backward (car seps) nil t)))
1940 (defun gnus-article-hidden-arg ()
1941 "Return the current prefix arg as a number, or 0 if no prefix."
1942 (list (if current-prefix-arg
1943 (prefix-numeric-value current-prefix-arg)
1946 (defun gnus-article-check-hidden-text (type arg)
1947 "Return nil if hiding is necessary.
1948 Arg can be nil or a number. Nil and positive means hide, negative
1949 means show, 0 means toggle."
1952 (let ((hide (gnus-article-hidden-text-p type)))
1958 (gnus-article-show-hidden-text type))
1960 (if (eq hide 'hidden)
1961 (gnus-article-show-hidden-text type)
1964 (defun gnus-article-hidden-text-p (type)
1965 "Say whether the current buffer contains hidden text of type TYPE."
1966 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
1968 (not (get-text-property pos 'invisible))
1969 (not (get-text-property pos 'dummy-invisible)))
1971 (text-property-any (1+ pos) (point-max) 'article-type type)))
1976 (defun gnus-article-show-hidden-text (type &optional hide)
1977 "Show all hidden text of type TYPE.
1978 If HIDE, hide the text instead."
1980 (let ((buffer-read-only nil)
1981 (inhibit-point-motion-hooks t)
1984 (while (setq beg (text-property-any end (point-max) 'article-type type))
1987 (text-property-not-all beg (point-max) 'article-type type)
1990 (gnus-article-hide-text beg end gnus-hidden-properties)
1991 (gnus-article-unhide-text beg end))
1995 (defconst article-time-units
1996 `((year . ,(* 365.25 24 60 60))
1997 (week . ,(* 7 24 60 60))
1998 (day . ,(* 24 60 60))
2002 "Mapping from time units to seconds.")
2004 (defun article-date-ut (&optional type highlight header)
2005 "Convert DATE date to universal time in the current article.
2006 If TYPE is `local', convert to local time; if it is `lapsed', output
2007 how much time has lapsed since DATE. For `lapsed', the value of
2008 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2009 should replace the \"Date:\" one, or should be added below it."
2010 (interactive (list 'ut t))
2011 (let* ((header (or header
2012 (message-fetch-field "date")
2014 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2017 ((not gnus-article-date-lapsed-new-header)
2023 (date (if (vectorp header) (mail-header-date header)
2025 (inhibit-point-motion-hooks t)
2030 (article-narrow-to-head)
2031 (when (re-search-forward tdate-regexp nil t)
2032 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2033 date (or (get-text-property (gnus-point-at-bol)
2036 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2038 (when (and date (not (string= date "")))
2039 (goto-char (point-min))
2040 (let ((buffer-read-only nil))
2041 ;; Delete any old Date headers.
2042 (while (re-search-forward date-regexp nil t)
2044 (delete-region (progn (beginning-of-line) (point))
2045 (progn (forward-line 1) (point)))
2046 (delete-region (progn (beginning-of-line) (point))
2047 (progn (end-of-line) (point)))
2048 (setq pos (point))))
2049 (when (and (not pos) (re-search-forward tdate-regexp nil t))
2051 (if pos (goto-char pos))
2052 (insert (article-make-date-line date (or type 'ut)))
2058 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2059 (put-text-property (match-beginning 1) (1+ (match-end 1))
2060 'original-date date)
2061 (put-text-property (match-beginning 1) (1+ (match-end 1))
2063 (put-text-property (match-beginning 2) (match-end 2)
2066 (defun article-make-date-line (date type)
2067 "Return a DATE line of TYPE."
2068 (let ((time (condition-case ()
2072 ;; Convert to the local timezone. We have to slap a
2073 ;; `condition-case' round the calls to the timezone
2074 ;; functions since they aren't particularly resistant to
2077 (let ((tz (car (current-time-zone time))))
2078 (format "Date: %s %s%02d%02d" (current-time-string time)
2079 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2080 (/ (% (abs tz) 3600) 60))))
2081 ;; Convert to Universal Time.
2084 (current-time-string
2085 (let* ((e (parse-time-string date))
2086 (tm (apply 'encode-time e))
2088 (ls (- (cadr tm) (car (current-time-zone time)))))
2089 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2090 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2093 ;; Get the original date from the article.
2094 ((eq type 'original)
2095 (concat "Date: " (if (string-match "\n+$" date)
2096 (substring date 0 (match-beginning 0))
2098 ;; Let the user define the format.
2100 (if (gnus-functionp gnus-article-time-format)
2101 (funcall gnus-article-time-format time)
2104 (format-time-string gnus-article-time-format time))))
2107 (let ((tz (car (current-time-zone time))))
2110 (format-time-string "%Y%m%dT%H%M%S" time)
2111 (format "%s%02d%02d"
2112 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2113 (/ (% (abs tz) 3600) 60)))))
2114 ;; Do an X-Sent lapsed format.
2116 ;; If the date is seriously mangled, the timezone functions are
2117 ;; liable to bug out, so we ignore all errors.
2118 (let* ((now (current-time))
2119 (real-time (subtract-time now time))
2120 (real-sec (and real-time
2121 (+ (* (float (car real-time)) 65536)
2123 (sec (and real-time (abs real-sec)))
2133 ;; This is a bit convoluted, but basically we go
2134 ;; through the time units for years, weeks, etc,
2135 ;; and divide things to see whether that results
2136 ;; in positive answers.
2139 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2140 ;; The (remaining) seconds are too few to
2141 ;; be divided into this time unit.
2143 ;; It's big enough, so we output it.
2144 (setq sec (- sec (* num (cdr unit))))
2146 (concat (if prev ", " "") (int-to-string
2148 " " (symbol-name (car unit))
2149 (if (> num 1) "s" ""))
2151 article-time-units "")
2152 ;; If dates are odd, then it might appear like the
2153 ;; article was sent in the future.
2156 " in the future"))))))
2158 (error "Unknown conversion type: %s" type)))))
2160 (defun article-date-local (&optional highlight)
2161 "Convert the current article date to the local timezone."
2162 (interactive (list t))
2163 (article-date-ut 'local highlight))
2165 (defun article-date-original (&optional highlight)
2166 "Convert the current article date to what it was originally.
2167 This is only useful if you have used some other date conversion
2168 function and want to see what the date was before converting."
2169 (interactive (list t))
2170 (article-date-ut 'original highlight))
2172 (defun article-date-lapsed (&optional highlight)
2173 "Convert the current article date to time lapsed since it was sent."
2174 (interactive (list t))
2175 (article-date-ut 'lapsed highlight))
2177 (defun article-update-date-lapsed ()
2178 "Function to be run from a timer to update the lapsed time line."
2179 (let (deactivate-mark)
2184 (set-buffer (window-buffer w))
2185 (when (eq major-mode 'gnus-article-mode)
2186 (goto-char (point-min))
2187 (when (re-search-forward "^X-Sent:" nil t)
2188 (article-date-lapsed t))))
2191 (defun gnus-start-date-timer (&optional n)
2192 "Start a timer to update the X-Sent header in the article buffers.
2193 The numerical prefix says how frequently (in seconds) the function
2198 (gnus-stop-date-timer)
2199 (setq article-lapsed-timer
2200 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2202 (defun gnus-stop-date-timer ()
2203 "Stop the X-Sent timer."
2205 (when article-lapsed-timer
2206 (nnheader-cancel-timer article-lapsed-timer)
2207 (setq article-lapsed-timer nil)))
2209 (defun article-date-user (&optional highlight)
2210 "Convert the current article date to the user-defined format.
2211 This format is defined by the `gnus-article-time-format' variable."
2212 (interactive (list t))
2213 (article-date-ut 'user highlight))
2215 (defun article-date-iso8601 (&optional highlight)
2216 "Convert the current article date to ISO8601."
2217 (interactive (list t))
2218 (article-date-ut 'iso8601 highlight))
2220 (defun article-show-all ()
2221 "Show all hidden text in the article buffer."
2224 (let ((buffer-read-only nil))
2225 (gnus-article-unhide-text (point-min) (point-max)))))
2227 (defun article-emphasize (&optional arg)
2228 "Emphasize text according to `gnus-emphasis-alist'."
2229 (interactive (gnus-article-hidden-arg))
2230 (unless (gnus-article-check-hidden-text 'emphasis arg)
2234 (with-current-buffer gnus-summary-buffer
2235 gnus-article-emphasis-alist)
2237 gnus-emphasis-alist))
2238 (buffer-read-only nil)
2239 (props (append '(article-type emphasis)
2240 gnus-hidden-properties))
2241 regexp elem beg invisible visible face)
2244 (while (setq elem (pop alist))
2246 (setq regexp (car elem)
2247 invisible (nth 1 elem)
2248 visible (nth 2 elem)
2250 (while (re-search-forward regexp nil t)
2251 (when (and (match-beginning visible) (match-beginning invisible))
2252 (push 'emphasis gnus-article-wash-types)
2253 (gnus-article-hide-text
2254 (match-beginning invisible) (match-end invisible) props)
2255 (gnus-article-unhide-text-type
2256 (match-beginning visible) (match-end visible) 'emphasis)
2257 (gnus-put-text-property-excluding-newlines
2258 (match-beginning visible) (match-end visible) 'face face)
2259 (goto-char (match-end invisible)))))))))
2261 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2262 "Setup newsgroup emphasis alist."
2263 (unless gnus-article-emphasis-alist
2264 (let ((name (and gnus-newsgroup-name
2265 (gnus-group-real-name gnus-newsgroup-name))))
2266 (make-local-variable 'gnus-article-emphasis-alist)
2267 (setq gnus-article-emphasis-alist
2269 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2270 (while (setq elem (pop alist))
2271 (when (and name (string-match (car elem) name))
2273 highlight (copy-sequence (cdr elem)))))
2275 (copy-sequence highlight-words)
2276 (if gnus-newsgroup-name
2277 (copy-sequence (gnus-group-find-parameter
2278 gnus-newsgroup-name 'highlight-words t)))
2279 gnus-emphasis-alist)))))
2281 (defvar gnus-summary-article-menu)
2282 (defvar gnus-summary-post-menu)
2284 ;;; Saving functions.
2286 (defun gnus-article-save (save-buffer file &optional num)
2287 "Save the currently selected article."
2288 (unless gnus-save-all-headers
2289 ;; Remove headers according to `gnus-saved-headers'.
2290 (let ((gnus-visible-headers
2291 (or gnus-saved-headers gnus-visible-headers))
2292 (gnus-article-buffer save-buffer))
2294 (set-buffer save-buffer)
2295 (article-hide-headers 1 t))))
2296 (save-window-excursion
2297 (if (not gnus-default-article-saver)
2298 (error "No default saver is defined")
2299 ;; !!! Magic! The saving functions all save
2300 ;; `gnus-save-article-buffer' (or so they think), but we
2301 ;; bind that variable to our save-buffer.
2302 (set-buffer gnus-article-buffer)
2303 (let* ((gnus-save-article-buffer save-buffer)
2306 ((not gnus-prompt-before-saving) 'default)
2307 ((eq gnus-prompt-before-saving 'always) nil)
2309 (gnus-number-of-articles-to-be-saved
2310 (when (eq gnus-prompt-before-saving t)
2312 (set-buffer gnus-article-current-summary)
2313 (funcall gnus-default-article-saver filename)))))
2315 (defun gnus-read-save-file-name (prompt &optional filename
2316 function group headers variable)
2318 (funcall function group headers (symbol-value variable)))
2323 ((eq filename 'default)
2329 (let* ((split-name (gnus-get-split-value gnus-split-methods))
2332 (if (and gnus-number-of-articles-to-be-saved
2333 (> gnus-number-of-articles-to-be-saved 1))
2334 (format "these %d articles"
2335 gnus-number-of-articles-to-be-saved)
2338 ;; Let the split methods have their say.
2340 ;; No split name was found.
2343 (concat prompt " (default "
2344 (file-name-nondirectory default-name) ") ")
2345 (file-name-directory default-name)
2347 ;; A single group name is returned.
2348 ((stringp split-name)
2350 (funcall function split-name headers
2351 (symbol-value variable)))
2353 (concat prompt " (default "
2354 (file-name-nondirectory default-name) ") ")
2355 (file-name-directory default-name)
2357 ;; A single split name was found
2358 ((= 1 (length split-name))
2359 (let* ((name (expand-file-name
2361 gnus-article-save-directory))
2362 (dir (cond ((file-directory-p name)
2363 (file-name-as-directory name))
2364 ((file-exists-p name) name)
2365 (t gnus-article-save-directory))))
2367 (concat prompt " (default " name ") ")
2369 ;; A list of splits was found.
2371 (setq split-name (nreverse split-name))
2373 (let ((file-name-history
2374 (nconc split-name file-name-history)))
2378 (concat prompt " (`M-p' for defaults) ")
2379 gnus-article-save-directory
2381 gnus-article-save-directory)))
2382 (car (push result file-name-history)))))))
2383 ;; Create the directory.
2384 (gnus-make-directory (file-name-directory file))
2385 ;; If we have read a directory, we append the default file name.
2386 (when (file-directory-p file)
2387 (setq file (expand-file-name (file-name-nondirectory
2389 (file-name-as-directory file))))
2390 ;; Possibly translate some characters.
2391 (nnheader-translate-file-chars file))))))
2392 (gnus-make-directory (file-name-directory result))
2393 (set variable result)))
2395 (defun gnus-article-archive-name (group)
2396 "Return the first instance of an \"Archive-name\" in the current buffer."
2397 (let ((case-fold-search t))
2398 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
2399 (nnheader-concat gnus-article-save-directory
2400 (match-string 1)))))
2402 (defun gnus-article-nndoc-name (group)
2403 "If GROUP is an nndoc group, return the name of the parent group."
2404 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
2405 (gnus-group-get-parameter group 'save-article-group)))
2407 (defun gnus-summary-save-in-rmail (&optional filename)
2408 "Append this article to Rmail file.
2409 Optional argument FILENAME specifies file name.
2410 Directory to save to is default to `gnus-article-save-directory'."
2411 (setq filename (gnus-read-save-file-name
2412 "Save %s in rmail file:" filename
2413 gnus-rmail-save-name gnus-newsgroup-name
2414 gnus-current-headers 'gnus-newsgroup-last-rmail))
2415 (gnus-eval-in-buffer-window gnus-save-article-buffer
2419 (gnus-output-to-rmail filename))))
2422 (defun gnus-summary-save-in-mail (&optional filename)
2423 "Append this article to Unix mail file.
2424 Optional argument FILENAME specifies file name.
2425 Directory to save to is default to `gnus-article-save-directory'."
2426 (setq filename (gnus-read-save-file-name
2427 "Save %s in Unix mail file:" filename
2428 gnus-mail-save-name gnus-newsgroup-name
2429 gnus-current-headers 'gnus-newsgroup-last-mail))
2430 (gnus-eval-in-buffer-window gnus-save-article-buffer
2434 (if (and (file-readable-p filename)
2435 (mail-file-babyl-p filename))
2436 (rmail-output-to-rmail-file filename t)
2437 (gnus-output-to-mail filename)))))
2440 (defun gnus-summary-save-in-file (&optional filename overwrite)
2441 "Append this article to file.
2442 Optional argument FILENAME specifies file name.
2443 Directory to save to is default to `gnus-article-save-directory'."
2444 (setq filename (gnus-read-save-file-name
2445 "Save %s in file:" filename
2446 gnus-file-save-name gnus-newsgroup-name
2447 gnus-current-headers 'gnus-newsgroup-last-file))
2448 (gnus-eval-in-buffer-window gnus-save-article-buffer
2452 (when (and overwrite
2453 (file-exists-p filename))
2454 (delete-file filename))
2455 (gnus-output-to-file filename))))
2458 (defun gnus-summary-write-to-file (&optional filename)
2459 "Write this article to a file.
2460 Optional argument FILENAME specifies file name.
2461 The directory to save in defaults to `gnus-article-save-directory'."
2462 (gnus-summary-save-in-file nil t))
2464 (defun gnus-summary-save-body-in-file (&optional filename)
2465 "Append this article body to a file.
2466 Optional argument FILENAME specifies file name.
2467 The directory to save in defaults to `gnus-article-save-directory'."
2468 (setq filename (gnus-read-save-file-name
2469 "Save %s body in file:" filename
2470 gnus-file-save-name gnus-newsgroup-name
2471 gnus-current-headers 'gnus-newsgroup-last-file))
2472 (gnus-eval-in-buffer-window gnus-save-article-buffer
2476 (when (article-goto-body)
2477 (narrow-to-region (point) (point-max)))
2478 (gnus-output-to-file filename))))
2481 (defun gnus-summary-save-in-pipe (&optional command)
2482 "Pipe this article to subprocess."
2484 (cond ((and (eq command 'default)
2485 gnus-last-shell-command)
2486 gnus-last-shell-command)
2490 "Shell command on %s: "
2491 (if (and gnus-number-of-articles-to-be-saved
2492 (> gnus-number-of-articles-to-be-saved 1))
2493 (format "these %d articles"
2494 gnus-number-of-articles-to-be-saved)
2496 gnus-last-shell-command))))
2497 (when (string-equal command "")
2498 (setq command gnus-last-shell-command))
2499 (gnus-eval-in-buffer-window gnus-article-buffer
2502 (shell-command-on-region (point-min) (point-max) command nil)))
2503 (setq gnus-last-shell-command command))
2505 ;;; Article file names when saving.
2507 (defun gnus-capitalize-newsgroup (newsgroup)
2508 "Capitalize NEWSGROUP name."
2509 (when (not (zerop (length newsgroup)))
2510 (concat (char-to-string (upcase (aref newsgroup 0)))
2511 (substring newsgroup 1))))
2513 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2514 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2515 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
2516 Otherwise, it is like ~/News/news/group/num."
2519 (concat (if (gnus-use-long-file-name 'not-save)
2520 (gnus-capitalize-newsgroup newsgroup)
2521 (gnus-newsgroup-directory-form newsgroup))
2522 "/" (int-to-string (mail-header-number headers)))
2523 gnus-article-save-directory)))
2525 (string-equal (file-name-directory default)
2526 (file-name-directory last-file))
2527 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2529 (or last-file default))))
2531 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2532 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2533 If variable `gnus-use-long-file-name' is non-nil, it is
2534 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2537 (concat (if (gnus-use-long-file-name 'not-save)
2539 (gnus-newsgroup-directory-form newsgroup))
2540 "/" (int-to-string (mail-header-number headers)))
2541 gnus-article-save-directory)))
2543 (string-equal (file-name-directory default)
2544 (file-name-directory last-file))
2545 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2547 (or last-file default))))
2549 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2550 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2551 If variable `gnus-use-long-file-name' is non-nil, it is
2552 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2555 (if (gnus-use-long-file-name 'not-save)
2557 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup)))
2558 gnus-article-save-directory)))
2565 (setq afunc (car func)
2568 gfunc (intern (format "gnus-%s" func))))
2571 `(lambda (&optional interactive &rest args)
2572 ,(documentation afunc t)
2573 (interactive (list t))
2575 (set-buffer gnus-article-buffer)
2577 (call-interactively ',afunc)
2578 (apply ',afunc args))))))))
2579 '(article-hide-headers
2580 article-hide-boring-headers
2581 article-treat-overstrike
2582 article-fill-long-lines
2583 article-capitalize-sentences
2585 article-display-x-face
2586 article-de-quoted-unreadable
2587 article-de-base64-unreadable
2590 article-hide-list-identifiers
2592 article-strip-banner
2595 article-hide-signature
2596 article-strip-headers-in-body
2597 article-remove-trailing-blank-lines
2598 article-strip-leading-blank-lines
2599 article-strip-multiple-blank-lines
2600 article-strip-leading-space
2601 article-strip-trailing-space
2602 article-strip-blank-lines
2603 article-strip-all-blank-lines
2605 article-date-iso8601
2606 article-date-original
2608 article-decode-mime-words
2609 article-decode-charset
2610 article-decode-encoded-words
2614 article-treat-dumbquotes
2615 article-normalize-headers
2616 (article-show-all . gnus-article-show-all-headers))))
2619 ;;; Gnus article mode
2622 (put 'gnus-article-mode 'mode-class 'special)
2624 (set-keymap-parent gnus-article-mode-map widget-keymap)
2626 (gnus-define-keys gnus-article-mode-map
2627 " " gnus-article-goto-next-page
2628 "\177" gnus-article-goto-prev-page
2629 [delete] gnus-article-goto-prev-page
2630 [backspace] gnus-article-goto-prev-page
2631 "\C-c^" gnus-article-refer-article
2632 "h" gnus-article-show-summary
2633 "s" gnus-article-show-summary
2634 "\C-c\C-m" gnus-article-mail
2635 "?" gnus-article-describe-briefly
2636 "e" gnus-summary-edit-article
2637 "<" beginning-of-buffer
2639 "\C-c\C-i" gnus-info-find-node
2642 "\C-d" gnus-article-read-summary-keys
2643 "\M-*" gnus-article-read-summary-keys
2644 "\M-#" gnus-article-read-summary-keys
2645 "\M-^" gnus-article-read-summary-keys
2646 "\M-g" gnus-article-read-summary-keys)
2648 (substitute-key-definition
2649 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
2651 (defun gnus-article-make-menu-bar ()
2652 (gnus-turn-off-edit-menu 'article)
2653 (unless (boundp 'gnus-article-article-menu)
2655 gnus-article-article-menu gnus-article-mode-map ""
2657 ["Scroll forwards" gnus-article-goto-next-page t]
2658 ["Scroll backwards" gnus-article-goto-prev-page t]
2659 ["Show summary" gnus-article-show-summary t]
2660 ["Fetch Message-ID at point" gnus-article-refer-article t]
2661 ["Mail to address at point" gnus-article-mail t]
2662 ["Send a bug report" gnus-bug t]))
2665 gnus-article-treatment-menu gnus-article-mode-map ""
2667 ["Hide headers" gnus-article-hide-headers t]
2668 ["Hide signature" gnus-article-hide-signature t]
2669 ["Hide citation" gnus-article-hide-citation t]
2670 ["Treat overstrike" gnus-article-treat-overstrike t]
2671 ["Remove carriage return" gnus-article-remove-cr t]
2672 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
2673 ["Remove base64" gnus-article-de-base64-unreadable t]
2674 ["Treat html" gnus-article-wash-html t]
2675 ["Decode HZ" gnus-article-decode-HZ t]))
2677 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
2679 (when (boundp 'gnus-summary-post-menu)
2680 (define-key gnus-article-mode-map [menu-bar post]
2681 (cons "Post" gnus-summary-post-menu)))
2683 (gnus-run-hooks 'gnus-article-menu-hook)))
2685 (defun gnus-article-mode ()
2686 "Major mode for displaying an article.
2688 All normal editing commands are switched off.
2690 The following commands are available in addition to all summary mode
2692 \\<gnus-article-mode-map>
2693 \\[gnus-article-next-page]\t Scroll the article one page forwards
2694 \\[gnus-article-prev-page]\t Scroll the article one page backwards
2695 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
2696 \\[gnus-article-show-summary]\t Display the summary buffer
2697 \\[gnus-article-mail]\t Send a reply to the address near point
2698 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
2699 \\[gnus-info-find-node]\t Go to the Gnus info node"
2701 (when (gnus-visual-p 'article-menu 'menu)
2702 (gnus-article-make-menu-bar))
2703 (gnus-simplify-mode-line)
2704 (setq mode-name "Article")
2705 (setq major-mode 'gnus-article-mode)
2706 (make-local-variable 'minor-mode-alist)
2707 (use-local-map gnus-article-mode-map)
2708 (gnus-update-format-specifications nil 'article-mode)
2709 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
2710 (make-local-variable 'gnus-page-broken)
2711 (make-local-variable 'gnus-button-marker-list)
2712 (make-local-variable 'gnus-article-current-summary)
2713 (make-local-variable 'gnus-article-mime-handles)
2714 (make-local-variable 'gnus-article-decoded-p)
2715 (make-local-variable 'gnus-article-mime-handle-alist)
2716 (make-local-variable 'gnus-article-wash-types)
2717 (make-local-variable 'gnus-article-charset)
2718 (make-local-variable 'gnus-article-ignored-charsets)
2719 (gnus-set-default-directory)
2720 (buffer-disable-undo)
2721 (setq buffer-read-only t)
2722 (set-syntax-table gnus-article-mode-syntax-table)
2723 (mm-enable-multibyte)
2724 (gnus-run-hooks 'gnus-article-mode-hook))
2726 (defun gnus-article-setup-buffer ()
2727 "Initialize the article buffer."
2728 (let* ((name (if gnus-single-article-buffer "*Article*"
2729 (concat "*Article " gnus-newsgroup-name "*")))
2731 (progn (string-match "\\*Article" name)
2732 (concat " *Original Article"
2733 (substring name (match-end 0))))))
2734 (setq gnus-article-buffer name)
2735 (setq gnus-original-article-buffer original)
2736 (setq gnus-article-mime-handle-alist nil)
2737 ;; This might be a variable local to the summary buffer.
2738 (unless gnus-single-article-buffer
2740 (set-buffer gnus-summary-buffer)
2741 (setq gnus-article-buffer name)
2742 (setq gnus-original-article-buffer original)
2743 (gnus-set-global-variables)))
2744 (gnus-article-setup-highlight-words)
2745 ;; Init original article buffer.
2747 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
2748 (mm-enable-multibyte)
2749 (setq major-mode 'gnus-original-article-mode)
2750 (make-local-variable 'gnus-original-article))
2751 (if (get-buffer name)
2754 (when gnus-article-mime-handles
2755 (mm-destroy-parts gnus-article-mime-handles)
2756 (setq gnus-article-mime-handles nil))
2757 ;; Set it to nil in article-buffer!
2758 (setq gnus-article-mime-handle-alist nil)
2759 (buffer-disable-undo)
2760 (setq buffer-read-only t)
2761 (unless (eq major-mode 'gnus-article-mode)
2762 (gnus-article-mode))
2765 (set-buffer (gnus-get-buffer-create name))
2767 (make-local-variable 'gnus-summary-buffer)
2768 (gnus-summary-set-local-parameters gnus-newsgroup-name)
2769 (current-buffer)))))
2771 ;; Set article window start at LINE, where LINE is the number of lines
2772 ;; from the head of the article.
2773 (defun gnus-article-set-window-start (&optional line)
2775 (get-buffer-window gnus-article-buffer t)
2777 (set-buffer gnus-article-buffer)
2778 (goto-char (point-min))
2781 (gnus-message 6 "Moved to bookmark")
2782 (search-forward "\n\n" nil t)
2786 (defun gnus-article-prepare (article &optional all-headers header)
2787 "Prepare ARTICLE in article mode buffer.
2788 ARTICLE should either be an article number or a Message-ID.
2789 If ARTICLE is an id, HEADER should be the article headers.
2790 If ALL-HEADERS is non-nil, no headers are hidden."
2792 ;; Make sure we start in a summary buffer.
2793 (unless (eq major-mode 'gnus-summary-mode)
2794 (set-buffer gnus-summary-buffer))
2795 (setq gnus-summary-buffer (current-buffer))
2796 (let* ((gnus-article (if header (mail-header-number header) article))
2797 (summary-buffer (current-buffer))
2798 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
2799 (group gnus-newsgroup-name)
2802 (gnus-article-setup-buffer)
2803 (set-buffer gnus-article-buffer)
2804 ;; Deactivate active regions.
2805 (when (and (boundp 'transient-mark-mode)
2806 transient-mark-mode)
2807 (setq mark-active nil))
2808 (if (not (setq result (let ((buffer-read-only nil))
2809 (gnus-request-article-this-buffer
2811 ;; There is no such article.
2813 (when (and (numberp article)
2814 (not (memq article gnus-newsgroup-sparse)))
2815 (setq gnus-article-current
2816 (cons gnus-newsgroup-name article))
2817 (set-buffer gnus-summary-buffer)
2818 (setq gnus-current-article article)
2819 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
2821 (gnus-summary-set-agent-mark article)
2822 (message "Message marked for downloading"))
2823 (gnus-summary-mark-article article gnus-canceled-mark)
2824 (unless (memq article gnus-newsgroup-sparse)
2825 (gnus-error 1 "No such article (may have expired or been canceled)")))))
2826 (if (or (eq result 'pseudo)
2827 (eq result 'nneething))
2830 (set-buffer summary-buffer)
2831 (push article gnus-newsgroup-history)
2832 (setq gnus-last-article gnus-current-article
2833 gnus-current-article 0
2834 gnus-current-headers nil
2835 gnus-article-current nil)
2836 (if (eq result 'nneething)
2837 (gnus-configure-windows 'summary)
2838 (gnus-configure-windows 'article))
2839 (gnus-set-global-variables))
2840 (let ((gnus-article-mime-handle-alist-1
2841 gnus-article-mime-handle-alist))
2842 (gnus-set-mode-line 'article)))
2843 ;; The result from the `request' was an actual article -
2844 ;; or at least some text that is now displayed in the
2846 (when (and (numberp article)
2847 (not (eq article gnus-current-article)))
2848 ;; Seems like a new article has been selected.
2849 ;; `gnus-current-article' must be an article number.
2851 (set-buffer summary-buffer)
2852 (push article gnus-newsgroup-history)
2853 (setq gnus-last-article gnus-current-article
2854 gnus-current-article article
2855 gnus-current-headers
2856 (gnus-summary-article-header gnus-current-article)
2857 gnus-article-current
2858 (cons gnus-newsgroup-name gnus-current-article))
2859 (unless (vectorp gnus-current-headers)
2860 (setq gnus-current-headers nil))
2861 (gnus-summary-goto-subject gnus-current-article)
2862 (when (gnus-summary-show-thread)
2863 ;; If the summary buffer really was folded, the
2864 ;; previous goto may not actually have gone to
2865 ;; the right article, but the thread root instead.
2867 (gnus-summary-goto-subject gnus-current-article))
2868 (gnus-run-hooks 'gnus-mark-article-hook)
2869 (gnus-set-mode-line 'summary)
2870 (when (gnus-visual-p 'article-highlight 'highlight)
2871 (gnus-run-hooks 'gnus-visual-mark-article-hook))
2872 ;; Set the global newsgroup variables here.
2873 (gnus-set-global-variables)
2874 (setq gnus-have-all-headers
2875 (or all-headers gnus-show-all-headers))))
2877 (gnus-configure-windows 'article))
2878 (when (or (numberp article)
2880 (gnus-article-prepare-display)
2882 (goto-char (point-min))
2883 (setq gnus-page-broken
2884 (when gnus-break-pages
2885 (gnus-narrow-to-page)
2887 (let ((gnus-article-mime-handle-alist-1
2888 gnus-article-mime-handle-alist))
2889 (gnus-set-mode-line 'article))
2891 (set-window-point (get-buffer-window (current-buffer)) (point))
2892 (gnus-configure-windows 'article)
2896 (defun gnus-article-prepare-display ()
2897 "Make the current buffer look like a nice article."
2898 ;; Hooks for getting information from the article.
2899 ;; This hook must be called before being narrowed.
2900 (let ((gnus-article-buffer (current-buffer))
2902 (unless (eq major-mode 'gnus-article-mode)
2903 (gnus-article-mode))
2904 (setq buffer-read-only nil
2905 gnus-article-wash-types nil)
2906 (gnus-run-hooks 'gnus-tmp-internal-hook)
2907 (when gnus-display-mime-function
2908 (funcall gnus-display-mime-function))
2909 (gnus-run-hooks 'gnus-article-prepare-hook)))
2912 ;;; Gnus MIME viewing functions
2915 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
2916 "The following specs can be used:
2918 %T MIME type, along with additional info
2919 %n The `name' parameter
2920 %d The description, if any
2921 %l The length of the encoded part
2922 %p The part identifier number
2923 %e Dots if the part isn't displayed")
2925 (defvar gnus-mime-button-line-format-alist
2926 '((?t gnus-tmp-type ?s)
2927 (?T gnus-tmp-type-long ?s)
2928 (?n gnus-tmp-name ?s)
2929 (?d gnus-tmp-description ?s)
2931 (?l gnus-tmp-length ?d)
2932 (?e gnus-tmp-dots ?s)))
2934 (defvar gnus-mime-button-commands
2935 '((gnus-article-press-button "\r" "Toggle Display")
2936 (gnus-mime-view-part "v" "View Interactively...")
2937 (gnus-mime-view-part-as-type "t" "View As Type...")
2938 (gnus-mime-view-part-as-charset "C" "View As charset...")
2939 (gnus-mime-save-part "o" "Save...")
2940 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
2941 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
2942 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
2943 (gnus-mime-internalize-part "E" "View Internally")
2944 (gnus-mime-externalize-part "e" "View Externally")
2945 (gnus-mime-pipe-part "|" "Pipe To Command...")
2946 (gnus-mime-action-on-part "." "Take action on the part")))
2948 (defun gnus-article-mime-part-status ()
2949 (if gnus-article-mime-handle-alist-1
2950 (format " (%d parts)" (length gnus-article-mime-handle-alist-1))
2953 (defvar gnus-mime-button-map
2954 (let ((map (make-sparse-keymap)))
2955 (set-keymap-parent map gnus-article-mode-map)
2956 (define-key map gnus-mouse-2 'gnus-article-push-button)
2957 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
2958 (dolist (c gnus-mime-button-commands)
2959 (define-key map (cadr c) (car c)))
2962 (defun gnus-mime-button-menu (event)
2963 "Construct a context-sensitive menu of MIME commands."
2966 (let ((pos (event-start event)))
2967 (set-buffer (window-buffer (posn-window pos)))
2968 (goto-char (posn-point pos))
2969 (gnus-article-check-buffer)
2970 (let ((response (x-popup-menu
2972 ("" ,@(mapcar (lambda (c)
2973 (cons (caddr c) (car c)))
2974 gnus-mime-button-commands))))))
2976 (call-interactively response))))))
2978 (defun gnus-mime-view-all-parts (&optional handles)
2979 "View all the MIME parts."
2981 (save-current-buffer
2982 (set-buffer gnus-article-buffer)
2983 (let ((handles (or handles gnus-article-mime-handles))
2984 (mail-parse-charset gnus-newsgroup-charset)
2985 (mail-parse-ignored-charsets
2986 (with-current-buffer gnus-summary-buffer
2987 gnus-newsgroup-ignored-charsets)))
2988 (mm-remove-parts handles)
2989 (goto-char (point-min))
2990 (or (search-forward "\n\n") (goto-char (point-max)))
2991 (let (buffer-read-only)
2992 (delete-region (point) (point-max)))
2993 (mm-display-parts handles))))
2995 (defun gnus-mime-save-part-and-strip ()
2996 "Save the MIME part under point then replace it with an external body."
2998 (gnus-article-check-buffer)
2999 (let* ((data (get-text-property (point) 'gnus-data))
3000 (file (mm-save-part data))
3003 (with-current-buffer (mm-handle-buffer data)
3005 (insert "Content-Type: " (mm-handle-media-type data))
3006 (mml-insert-parameter-string (cdr (mm-handle-type data))
3009 (insert "Content-ID: " (message-make-message-id) "\n")
3010 (insert "Content-Transfer-Encoding: binary\n")
3013 (cdr (mm-make-handle nil
3014 `("message/external-body"
3015 (access-type . "LOCAL-FILE")
3017 (set-buffer gnus-summary-buffer)
3018 (gnus-article-edit-article
3021 (let ((mail-parse-charset (or gnus-article-charset
3022 ',gnus-newsgroup-charset))
3023 (mail-parse-ignored-charsets
3024 (or gnus-article-ignored-charsets
3025 ',gnus-newsgroup-ignored-charsets))
3026 (mbl mml-buffer-list))
3027 (setq mml-buffer-list nil)
3028 (insert-buffer gnus-original-article-buffer)
3029 (mime-to-mml gnus-article-mime-handles)
3030 (setq gnus-article-mime-handles nil)
3031 (make-local-hook 'kill-buffer-hook)
3032 (let ((mbl1 mml-buffer-list))
3033 (setq mml-buffer-list mbl)
3034 (set (make-local-variable 'mml-buffer-list) mbl1))
3035 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3036 `(lambda (no-highlight)
3037 (let ((mail-parse-charset (or gnus-article-charset
3038 ',gnus-newsgroup-charset))
3039 (message-options message-options)
3040 (message-options-set-recipient)
3041 (mail-parse-ignored-charsets
3042 (or gnus-article-ignored-charsets
3043 ',gnus-newsgroup-ignored-charsets)))
3045 (mml-destroy-buffers)
3046 (remove-hook 'kill-buffer-hook
3047 'mml-destroy-buffers t)
3048 (kill-local-variable 'mml-buffer-list))
3049 (gnus-summary-edit-article-done
3050 ,(or (mail-header-references gnus-current-headers) "")
3051 ,(gnus-group-read-only-p)
3052 ,gnus-summary-buffer no-highlight))))))
3054 (defun gnus-mime-save-part ()
3055 "Save the MIME part under point."
3057 (gnus-article-check-buffer)
3058 (let ((data (get-text-property (point) 'gnus-data)))
3059 (mm-save-part data)))
3061 (defun gnus-mime-pipe-part ()
3062 "Pipe the MIME part under point to a process."
3064 (gnus-article-check-buffer)
3065 (let ((data (get-text-property (point) 'gnus-data)))
3066 (mm-pipe-part data)))
3068 (defun gnus-mime-view-part ()
3069 "Interactively choose a viewing method for the MIME part under point."
3071 (gnus-article-check-buffer)
3072 (let ((data (get-text-property (point) 'gnus-data)))
3073 (mm-interactively-view-part data)))
3075 (defun gnus-mime-view-part-as-type-internal ()
3076 (gnus-article-check-buffer)
3077 (let* ((name (mail-content-type-get
3078 (mm-handle-type (get-text-property (point) 'gnus-data))
3080 (def-type (and name (mm-default-file-encoding name))))
3081 (and def-type (cons def-type 0))))
3083 (defun gnus-mime-view-part-as-type (mime-type)
3084 "Choose a MIME media type, and view the part as such."
3086 (list (completing-read
3087 "View as MIME type: "
3088 (mapcar #'list (mailcap-mime-types))
3090 (gnus-mime-view-part-as-type-internal))))
3091 (gnus-article-check-buffer)
3092 (let ((handle (get-text-property (point) 'gnus-data)))
3093 (gnus-mm-display-part
3094 (mm-make-handle (mm-handle-buffer handle)
3095 (cons mime-type (cdr (mm-handle-type handle)))
3096 (mm-handle-encoding handle)
3097 (mm-handle-undisplayer handle)
3098 (mm-handle-disposition handle)
3099 (mm-handle-description handle)
3100 (mm-handle-cache handle)
3101 (mm-handle-id handle)))))
3103 (defun gnus-mime-copy-part (&optional handle)
3104 "Put the the MIME part under point into a new buffer."
3106 (gnus-article-check-buffer)
3107 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3108 (contents (mm-get-part handle))|
3109 (base (file-name-nondirectory
3111 (mail-content-type-get (mm-handle-type handle) 'name)
3112 (mail-content-type-get (mm-handle-type handle)
3115 (buffer (generate-new-buffer base)))
3116 (switch-to-buffer buffer)
3118 ;; We do it this way to make `normal-mode' set the appropriate mode.
3121 (setq buffer-file-name (expand-file-name base))
3123 (setq buffer-file-name nil))
3124 (goto-char (point-min))))
3126 (defun gnus-mime-inline-part (&optional handle arg)
3127 "Insert the MIME part under point into the current buffer."
3128 (interactive (list nil current-prefix-arg))
3129 (gnus-article-check-buffer)
3130 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3134 (if (and (not arg) (mm-handle-undisplayer handle))
3135 (mm-remove-part handle)
3136 (setq contents (mm-get-part handle))
3139 (setq charset (or (mail-content-type-get
3140 (mm-handle-type handle) 'charset)
3141 gnus-newsgroup-charset)))
3143 (if (mm-handle-undisplayer handle)
3144 (mm-remove-part handle))
3147 gnus-summary-show-article-charset-alist))
3148 (read-coding-system "Charset: ")))))
3150 (mm-insert-inline handle
3152 (setq charset (mm-charset-to-coding-system
3154 (not (eq charset 'ascii)))
3155 (mm-decode-coding-string contents charset)
3159 (defun gnus-mime-view-part-as-charset (&optional handle arg)
3160 "Insert the MIME part under point into the current buffer."
3161 (interactive (list nil current-prefix-arg))
3162 (gnus-article-check-buffer)
3163 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3167 (if (mm-handle-undisplayer handle)
3168 (mm-remove-part handle))
3169 (let ((gnus-newsgroup-charset
3171 gnus-summary-show-article-charset-alist))
3172 (read-coding-system "Charset: ")))
3173 (gnus-newsgroup-ignored-charsets 'gnus-all))
3174 (gnus-article-press-button))))
3176 (defun gnus-mime-externalize-part (&optional handle)
3177 "View the MIME part under point with an external viewer."
3179 (gnus-article-check-buffer)
3180 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3181 (mm-user-display-methods nil)
3182 (mm-inlined-types nil)
3183 (mail-parse-charset gnus-newsgroup-charset)
3184 (mail-parse-ignored-charsets
3185 (save-excursion (set-buffer gnus-summary-buffer)
3186 gnus-newsgroup-ignored-charsets)))
3187 (if (mm-handle-undisplayer handle)
3188 (mm-remove-part handle)
3189 (mm-display-part handle))))
3191 (defun gnus-mime-internalize-part (&optional handle)
3192 "View the MIME part under point with an internal viewer.
3193 In no internal viewer is available, use an external viewer."
3195 (gnus-article-check-buffer)
3196 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3197 (mm-inlined-types '(".*"))
3198 (mm-inline-large-images t)
3199 (mail-parse-charset gnus-newsgroup-charset)
3200 (mail-parse-ignored-charsets
3201 (save-excursion (set-buffer gnus-summary-buffer)
3202 gnus-newsgroup-ignored-charsets)))
3203 (if (mm-handle-undisplayer handle)
3204 (mm-remove-part handle)
3205 (mm-display-part handle))))
3207 (defun gnus-mime-action-on-part (&optional action)
3208 "Do something with the MIME attachment at \(point\)."
3210 (list (completing-read "Action: " gnus-mime-action-alist)))
3211 (gnus-article-check-buffer)
3212 (let ((action-pair (assoc action gnus-mime-action-alist)))
3214 (funcall (cdr action-pair)))))
3217 (defun gnus-article-part-wrapper (n function)
3218 (save-current-buffer
3219 (set-buffer gnus-article-buffer)
3220 (when (> n (length gnus-article-mime-handle-alist))
3221 (error "No such part"))
3222 (gnus-article-goto-part n)
3223 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3224 (funcall function handle))))
3226 (defun gnus-article-pipe-part (n)
3227 "Pipe MIME part N, which is the numerical prefix."
3229 (gnus-article-part-wrapper n 'mm-pipe-part))
3231 (defun gnus-article-save-part (n)
3232 "Save MIME part N, which is the numerical prefix."
3234 (gnus-article-part-wrapper n 'mm-save-part))
3236 (defun gnus-article-interactively-view-part (n)
3237 "View MIME part N interactively, which is the numerical prefix."
3239 (gnus-article-part-wrapper n 'mm-interactively-view-part))
3241 (defun gnus-article-copy-part (n)
3242 "Copy MIME part N, which is the numerical prefix."
3244 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
3246 (defun gnus-article-view-part-as-charset (n)
3247 "Copy MIME part N, which is the numerical prefix."
3249 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
3251 (defun gnus-article-externalize-part (n)
3252 "View MIME part N externally, which is the numerical prefix."
3254 (gnus-article-part-wrapper n 'gnus-mime-externalize-part))
3256 (defun gnus-article-inline-part (n)
3257 "Inline MIME part N, which is the numerical prefix."
3259 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
3261 (defun gnus-article-mime-match-handle-first (condition)
3263 (let ((alist gnus-article-mime-handle-alist) ihandle n)
3264 (while (setq ihandle (pop alist))
3266 ((functionp condition)
3267 (funcall condition (cdr ihandle)))
3268 ((eq condition 'undisplayed)
3269 (not (or (mm-handle-undisplayer (cdr ihandle))
3270 (equal (mm-handle-media-type (cdr ihandle))
3271 "multipart/alternative"))))
3272 ((eq condition 'undisplayed-alternative)
3273 (not (mm-handle-undisplayer (cdr ihandle))))
3275 (gnus-article-goto-part (car ihandle))
3276 (or (not n) (< (car ihandle) n)))
3277 (setq n (car ihandle))))
3281 (defun gnus-article-view-part (&optional n)
3282 "View MIME part N, which is the numerical prefix."
3284 (save-current-buffer
3285 (set-buffer gnus-article-buffer)
3286 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
3287 gnus-article-mime-match-handle-function)))
3288 (when (> n (length gnus-article-mime-handle-alist))
3289 (error "No such part"))
3290 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3291 (when (gnus-article-goto-part n)
3292 (if (equal (car handle) "multipart/alternative")
3293 (gnus-article-press-button)
3294 (when (eq (gnus-mm-display-part handle) 'internal)
3295 (gnus-set-window-start)))))))
3297 (defsubst gnus-article-mime-total-parts ()
3298 (if (bufferp (car gnus-article-mime-handles))
3300 (1- (length gnus-article-mime-handles))))
3302 (defun gnus-mm-display-part (handle)
3303 "Display HANDLE and fix MIME button."
3304 (let ((id (get-text-property (point) 'gnus-part))
3309 (let ((window (selected-window))
3310 (mail-parse-charset gnus-newsgroup-charset)
3311 (mail-parse-ignored-charsets
3312 (save-excursion (set-buffer gnus-summary-buffer)
3313 gnus-newsgroup-ignored-charsets)))
3316 (let ((win (get-buffer-window (current-buffer) t))
3319 (select-window win))
3322 (if (mm-handle-displayed-p handle)
3323 ;; This will remove the part.
3324 (mm-display-part handle)
3326 (narrow-to-region (point) (1+ (point)))
3327 (mm-display-part handle)
3328 ;; We narrow to the part itself and
3329 ;; then call the treatment functions.
3330 (goto-char (point-min))
3332 (narrow-to-region (point) (point-max))
3335 (gnus-article-mime-total-parts)
3336 (mm-handle-media-type handle)))))
3337 (select-window window))))
3339 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
3340 (gnus-insert-mime-button
3341 handle id (list (mm-handle-displayed-p handle)))
3342 (goto-char point))))
3344 (defun gnus-article-goto-part (n)
3345 "Go to MIME part N."
3346 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
3348 (goto-char point))))
3350 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
3351 (let ((gnus-tmp-name
3352 (or (mail-content-type-get (mm-handle-type handle)
3354 (mail-content-type-get (mm-handle-disposition handle)
3356 (mail-content-type-get (mm-handle-type handle)
3359 (gnus-tmp-type (mm-handle-media-type handle))
3360 (gnus-tmp-description
3361 (mail-decode-encoded-word-string (or (mm-handle-description handle)
3364 (if (if displayed (car displayed)
3365 (mm-handle-displayed-p handle))
3367 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
3369 gnus-tmp-type-long b e)
3370 (when (string-match ".*/" gnus-tmp-name)
3371 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
3372 (setq gnus-tmp-type-long (concat gnus-tmp-type
3373 (and (not (equal gnus-tmp-name ""))
3374 (concat "; " gnus-tmp-name))))
3375 (or (equal gnus-tmp-description "")
3376 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
3381 gnus-mime-button-line-format gnus-mime-button-line-format-alist
3382 `(local-map ,gnus-mime-button-map
3383 keymap ,gnus-mime-button-map
3384 gnus-callback gnus-mm-display-part
3385 gnus-part ,gnus-tmp-id
3386 article-type annotation
3389 (widget-convert-button
3392 :action 'gnus-widget-press-button
3393 :button-keymap gnus-mime-button-map
3395 (lambda (widget/window &optional overlay pos)
3396 ;; Needed to properly clear the message due to a bug in
3397 ;; wid-edit (XEmacs only).
3398 (if (boundp 'help-echo-owns-message)
3399 (setq help-echo-owns-message t))
3401 "%S: %s the MIME part; %S: more options"
3402 (aref gnus-mouse-2 0)
3403 ;; XEmacs will get a single widget arg; Emacs 21 will get
3404 ;; window, overlay, position.
3405 (if (mm-handle-displayed-p
3407 (with-current-buffer (gnus-overlay-buffer overlay)
3408 (widget-get (widget-at (gnus-overlay-start overlay))
3410 (widget-get widget/window :mime-handle)))
3412 (aref gnus-down-mouse-3 0))))))
3414 (defun gnus-widget-press-button (elems el)
3415 (goto-char (widget-get elems :from))
3416 (gnus-article-press-button))
3418 (defvar gnus-displaying-mime nil)
3420 (defun gnus-display-mime (&optional ihandles)
3421 "Display the MIME parts."
3423 (save-selected-window
3424 (let ((window (get-buffer-window gnus-article-buffer))
3427 (select-window window)
3428 ;; We have to do this since selecting the window
3429 ;; may change the point. So we set the window point.
3430 (set-window-point window point)))
3431 (let* ((handles (or ihandles (mm-dissect-buffer) (mm-uu-dissect)))
3432 buffer-read-only handle name type b e display)
3433 (when (and (not ihandles)
3434 (not gnus-displaying-mime))
3435 ;; Top-level call; we clean up.
3436 (when gnus-article-mime-handles
3437 (mm-destroy-parts gnus-article-mime-handles)
3438 (setq gnus-article-mime-handle-alist nil));; A trick.
3439 (setq gnus-article-mime-handles handles)
3440 ;; We allow users to glean info from the handles.
3441 (when gnus-article-mime-part-function
3442 (gnus-mime-part-function handles)))
3444 (or (not (stringp (car handles)))
3447 (when (and (not ihandles)
3448 (not gnus-displaying-mime))
3449 ;; Clean up for mime parts.
3451 (delete-region (point) (point-max)))
3452 (let ((gnus-displaying-mime t))
3453 (gnus-mime-display-part handles)))
3456 (narrow-to-region (point) (point-max))
3457 (gnus-treat-article nil 1 1)
3460 ;; Highlight the headers.
3464 (narrow-to-region (point-min) (point))
3465 (gnus-treat-article 'head))))))))
3467 (defvar gnus-mime-display-multipart-as-mixed nil)
3469 (defun gnus-mime-display-part (handle)
3472 ((not (stringp (car handle)))
3473 (gnus-mime-display-single handle))
3474 ;; User-defined multipart
3475 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
3476 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
3478 ;; multipart/alternative
3479 ((and (equal (car handle) "multipart/alternative")
3480 (not gnus-mime-display-multipart-as-mixed))
3481 (let ((id (1+ (length gnus-article-mime-handle-alist))))
3482 (push (cons id handle) gnus-article-mime-handle-alist)
3483 (gnus-mime-display-alternative (cdr handle) nil nil id)))
3484 ;; multipart/related
3485 ((and (equal (car handle) "multipart/related")
3486 (not gnus-mime-display-multipart-as-mixed))
3487 ;;;!!!We should find the start part, but we just default
3488 ;;;!!!to the first part.
3489 (gnus-mime-display-part (cadr handle)))
3490 ;; Other multiparts are handled like multipart/mixed.
3491 ((equal (car handle) "multipart/signed")
3492 (or (memq 'signed gnus-article-wash-types)
3493 (push 'signed gnus-article-wash-types))
3494 (gnus-insert-mime-security-button handle)
3495 (gnus-mime-display-mixed (cdr handle)))
3496 ((equal (car handle) "multipart/encrypted")
3497 (or (memq 'encrypted gnus-article-wash-types)
3498 (push 'encrypted gnus-article-wash-types))
3499 (gnus-insert-mime-security-button handle)
3500 (gnus-mime-display-mixed (cdr handle)))
3502 (gnus-mime-display-mixed (cdr handle)))))
3504 (defun gnus-mime-part-function (handles)
3505 (if (stringp (car handles))
3506 (mapcar 'gnus-mime-part-function (cdr handles))
3507 (funcall gnus-article-mime-part-function handles)))
3509 (defun gnus-mime-display-mixed (handles)
3510 (mapcar 'gnus-mime-display-part handles))
3512 (defun gnus-mime-display-single (handle)
3513 (let ((type (mm-handle-media-type handle))
3514 (ignored gnus-ignored-mime-types)
3521 (when (string-match (pop ignored) type)
3522 (throw 'ignored nil)))
3523 (if (and (setq not-attachment
3524 (and (not (mm-inline-override-p handle))
3525 (or (not (mm-handle-disposition handle))
3526 (equal (car (mm-handle-disposition handle))
3528 (mm-attachment-override-p handle))))
3529 (mm-automatic-display-p handle)
3530 (or (mm-inlined-p handle)
3531 (mm-automatic-external-display-p type)))
3533 (when (equal (mm-handle-media-supertype handle) "text")
3535 (let ((id (1+ (length gnus-article-mime-handle-alist)))
3537 (push (cons id handle) gnus-article-mime-handle-alist)
3538 (when (or (not display)
3539 (not (gnus-unbuttonized-mime-type-p type)))
3540 ;(gnus-article-insert-newline)
3541 (gnus-insert-mime-button
3542 handle id (list (or display (and not-attachment text))))
3543 (gnus-article-insert-newline)
3544 ;(gnus-article-insert-newline)
3545 ;; Remember modify the number of forward lines.
3553 (let ((mail-parse-charset gnus-newsgroup-charset)
3554 (mail-parse-ignored-charsets
3555 (save-excursion (condition-case ()
3556 (set-buffer gnus-summary-buffer)
3558 gnus-newsgroup-ignored-charsets)))
3559 (mm-display-part handle t))
3560 (goto-char (point-max)))
3561 ((and text not-attachment)
3565 (gnus-article-insert-newline)
3566 (mm-insert-inline handle (mm-get-part handle))
3567 (goto-char (point-max))))
3571 (narrow-to-region beg (point))
3574 (gnus-article-mime-total-parts)
3575 (mm-handle-media-type handle)))))))))
3577 (defun gnus-unbuttonized-mime-type-p (type)
3578 "Say whether TYPE is to be unbuttonized."
3579 (unless gnus-inhibit-mime-unbuttonizing
3581 (let ((types gnus-unbuttonized-mime-types))
3583 (when (string-match (pop types) type)
3584 (throw 'found t)))))))
3586 (defun gnus-article-insert-newline ()
3587 "Insert a newline, but mark it as undeletable."
3588 (gnus-put-text-property
3589 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
3591 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
3592 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
3595 handle buffer-read-only from props begend not-pref)
3596 (save-window-excursion
3599 (narrow-to-region (car ibegend)
3602 (goto-char (car ibegend))
3605 (delete-region (point-min) (point-max))
3606 (mm-remove-parts handles))
3607 (setq begend (list (point-marker)))
3609 (unless (setq not-pref (cadr (member preferred ihandles)))
3610 (setq not-pref (car ihandles)))
3612 (not (gnus-unbuttonized-mime-type-p
3613 "multipart/alternative")))
3614 (gnus-add-text-properties
3617 (insert (format "%d. " id))
3621 (unless ,(not ibegend)
3622 (setq gnus-article-mime-handle-alist
3623 ',gnus-article-mime-handle-alist))
3624 (gnus-mime-display-alternative
3625 ',ihandles ',not-pref ',begend ,id))
3626 local-map ,gnus-mime-button-map
3627 ,gnus-mouse-face-prop ,gnus-article-mouse-face
3628 face ,gnus-article-button-face
3629 keymap ,gnus-mime-button-map
3632 (widget-convert-button 'link from (point)
3633 :action 'gnus-widget-press-button
3634 :button-keymap gnus-widget-button-keymap)
3636 (while (setq handle (pop handles))
3637 (gnus-add-text-properties
3640 (insert (format "(%c) %-18s"
3641 (if (equal handle preferred) ?* ? )
3642 (mm-handle-media-type handle)))
3646 (unless ,(not ibegend)
3647 (setq gnus-article-mime-handle-alist
3648 ',gnus-article-mime-handle-alist))
3649 (gnus-mime-display-alternative
3650 ',ihandles ',handle ',begend ,id))
3651 local-map ,gnus-mime-button-map
3652 ,gnus-mouse-face-prop ,gnus-article-mouse-face
3653 face ,gnus-article-button-face
3654 keymap ,gnus-mime-button-map
3657 (widget-convert-button 'link from (point)
3658 :action 'gnus-widget-press-button
3659 :button-keymap gnus-widget-button-keymap)
3663 (if (stringp (car preferred))
3664 (gnus-display-mime preferred)
3665 (let ((mail-parse-charset gnus-newsgroup-charset)
3666 (mail-parse-ignored-charsets
3667 (save-excursion (set-buffer gnus-summary-buffer)
3668 gnus-newsgroup-ignored-charsets)))
3669 (mm-display-part preferred)
3673 (narrow-to-region (car begend) (point-max))
3675 nil (length gnus-article-mime-handle-alist)
3676 (gnus-article-mime-total-parts)
3677 (mm-handle-media-type handle))))))
3678 (goto-char (point-max))
3679 (setcdr begend (point-marker)))))
3681 (goto-char point))))
3683 (defun gnus-article-wash-status ()
3684 "Return a string which display status of article washing."
3686 (set-buffer gnus-article-buffer)
3687 (let ((cite (memq 'cite gnus-article-wash-types))
3688 (headers (memq 'headers gnus-article-wash-types))
3689 (boring (memq 'boring-headers gnus-article-wash-types))
3690 (pgp (memq 'pgp gnus-article-wash-types))
3691 (pem (memq 'pem gnus-article-wash-types))
3692 (signed (memq 'signed gnus-article-wash-types))
3693 (encrypted (memq 'encrypted gnus-article-wash-types))
3694 (signature (memq 'signature gnus-article-wash-types))
3695 (overstrike (memq 'overstrike gnus-article-wash-types))
3696 (emphasis (memq 'emphasis gnus-article-wash-types)))
3697 (format "%c%c%c%c%c%c"
3699 (if (or headers boring) ?h ? )
3700 (if (or pgp pem signed encrypted) ?p ? )
3701 (if signature ?s ? )
3702 (if overstrike ?o ? )
3703 (if emphasis ?e ? )))))
3705 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
3707 (defun gnus-article-maybe-hide-headers ()
3708 "Hide unwanted headers if `gnus-have-all-headers' is nil.
3709 Provided for backwards compatibility."
3710 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
3711 (not (save-excursion (set-buffer gnus-summary-buffer)
3712 gnus-have-all-headers)))
3713 (not gnus-inhibit-hiding))
3714 (gnus-article-hide-headers)))
3718 (defun gnus-output-to-file (file-name)
3719 "Append the current article to a file named FILE-NAME."
3720 (let ((artbuf (current-buffer)))
3722 (insert-buffer-substring artbuf)
3723 ;; Append newline at end of the buffer as separator, and then
3725 (goto-char (point-max))
3727 (mm-append-to-file (point-min) (point-max) file-name)
3730 (defun gnus-narrow-to-page (&optional arg)
3731 "Narrow the article buffer to a page.
3732 If given a numerical ARG, move forward ARG pages."
3734 (setq arg (if arg (prefix-numeric-value arg) 0))
3736 (set-buffer gnus-article-buffer)
3737 (goto-char (point-min))
3739 ;; Remove any old next/prev buttons.
3740 (when (gnus-visual-p 'page-marker)
3741 (let ((buffer-read-only nil))
3742 (gnus-remove-text-with-property 'gnus-prev)
3743 (gnus-remove-text-with-property 'gnus-next)))
3746 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
3748 (re-search-forward page-delimiter nil 'move arg)))
3749 (goto-char (match-end 0)))
3752 (if (re-search-forward page-delimiter nil 'move)
3755 (when (and (gnus-visual-p 'page-marker)
3756 (not (= (point-min) 1)))
3758 (goto-char (point-min))
3759 (gnus-insert-prev-page-button)))
3760 (when (and (gnus-visual-p 'page-marker)
3761 (< (+ (point-max) 2) (buffer-size)))
3763 (goto-char (point-max))
3764 (gnus-insert-next-page-button)))))
3766 ;; Article mode commands
3768 (defun gnus-article-goto-next-page ()
3769 "Show the next page of the article."
3771 (when (gnus-article-next-page)
3772 (goto-char (point-min))
3773 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
3775 (defun gnus-article-goto-prev-page ()
3776 "Show the next page of the article."
3778 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
3779 (gnus-article-prev-page nil)))
3781 (defun gnus-article-next-page (&optional lines)
3782 "Show the next page of the current article.
3783 If end of article, return non-nil. Otherwise return nil.
3784 Argument LINES specifies lines to be scrolled up."
3786 (move-to-window-line -1)
3789 (and (pos-visible-in-window-p) ;Not continuation line.
3791 ;; Nothing in this page.
3792 (if (or (not gnus-page-broken)
3795 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
3797 (gnus-narrow-to-page 1) ;Go to next page.
3799 ;; More in this page.
3800 (let ((scroll-in-place nil))
3804 ;; Long lines may cause an end-of-buffer error.
3805 (goto-char (point-max)))))
3806 (move-to-window-line 0)
3809 (defun gnus-article-prev-page (&optional lines)
3810 "Show previous page of current article.
3811 Argument LINES specifies lines to be scrolled down."
3813 (move-to-window-line 0)
3814 (if (and gnus-page-broken
3816 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
3818 (gnus-narrow-to-page -1) ;Go to previous page.
3819 (goto-char (point-max))
3821 (let ((scroll-in-place nil))
3825 (beginning-of-buffer
3826 (goto-char (point-min))))
3827 (move-to-window-line 0)))))
3829 (defun gnus-article-refer-article ()
3830 "Read article specified by message-id around point."
3832 (let ((point (point)))
3833 (search-forward ">" nil t) ;Move point to end of "<....>".
3834 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
3835 (let ((message-id (match-string 1)))
3837 (set-buffer gnus-summary-buffer)
3838 (gnus-summary-refer-article message-id))
3840 (error "No references around point"))))
3842 (defun gnus-article-show-summary ()
3843 "Reconfigure windows to show summary buffer."
3845 (if (not (gnus-buffer-live-p gnus-summary-buffer))
3846 (error "There is no summary buffer for this article buffer")
3847 (gnus-article-set-globals)
3848 (gnus-configure-windows 'article)
3849 (gnus-summary-goto-subject gnus-current-article)
3850 (gnus-summary-position-point)))
3852 (defun gnus-article-describe-briefly ()
3853 "Describe article mode commands briefly."
3855 (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")))
3857 (defun gnus-article-summary-command ()
3858 "Execute the last keystroke in the summary buffer."
3860 (let ((obuf (current-buffer))
3861 (owin (current-window-configuration))
3863 (switch-to-buffer gnus-article-current-summary 'norecord)
3864 (setq func (lookup-key (current-local-map) (this-command-keys)))
3865 (call-interactively func)
3867 (set-window-configuration owin)
3868 (set-window-point (get-buffer-window (current-buffer)) (point))))
3870 (defun gnus-article-summary-command-nosave ()
3871 "Execute the last keystroke in the summary buffer."
3874 (pop-to-buffer gnus-article-current-summary 'norecord)
3875 (setq func (lookup-key (current-local-map) (this-command-keys)))
3876 (call-interactively func)))
3878 (defun gnus-article-check-buffer ()
3879 "Beep if not in an article buffer."
3880 (unless (equal major-mode 'gnus-article-mode)
3881 (error "Command invoked outside of a Gnus article buffer")))
3883 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
3884 "Read a summary buffer key sequence and execute it from the article buffer."
3886 (gnus-article-check-buffer)
3888 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
3889 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
3890 "=" "^" "\M-^" "|"))
3896 '("n" "Gn" "p" "Gp"))
3899 (set-buffer gnus-article-current-summary)
3900 (let (gnus-pick-mode)
3901 (push (or key last-command-event) unread-command-events)
3902 (setq keys (if (featurep 'xemacs)
3903 (events-to-keys (read-key-sequence nil))
3904 (read-key-sequence nil)))))
3908 (if (or (member keys nosaves)
3909 (member keys nosave-but-article)
3910 (member keys nosave-in-article))
3912 (save-window-excursion
3913 (pop-to-buffer gnus-article-current-summary 'norecord)
3914 ;; We disable the pick minor mode commands.
3915 (let (gnus-pick-mode)
3916 (setq func (lookup-key (current-local-map) keys))))
3920 (unless (member keys nosave-in-article)
3921 (set-buffer gnus-article-current-summary))
3922 (call-interactively func)
3923 (setq new-sum-point (point)))
3924 (when (member keys nosave-but-article)
3925 (pop-to-buffer gnus-article-buffer 'norecord)))
3926 ;; These commands should restore window configuration.
3927 (let ((obuf (current-buffer))
3928 (owin (current-window-configuration))
3930 (summary gnus-article-current-summary)
3931 func in-buffer selected)
3932 (if not-restore-window
3933 (pop-to-buffer summary 'norecord)
3934 (switch-to-buffer summary 'norecord))
3935 (setq in-buffer (current-buffer))
3936 ;; We disable the pick minor mode commands.
3937 (if (setq func (let (gnus-pick-mode)
3938 (lookup-key (current-local-map) keys)))
3940 (call-interactively func)
3941 (setq new-sum-point (point)))
3943 (when (eq in-buffer (current-buffer))
3944 (setq selected (gnus-summary-select-article))
3946 (unless not-restore-window
3947 (set-window-configuration owin))
3948 (when (eq selected 'old)
3950 (set-window-start (get-buffer-window (current-buffer))
3952 (set-window-point (get-buffer-window (current-buffer))
3954 (let ((win (get-buffer-window gnus-article-current-summary)))
3956 (set-window-point win new-sum-point))))))))
3958 (defun gnus-article-hide (&optional arg force)
3959 "Hide all the gruft in the current article.
3960 This means that PGP stuff, signatures, cited text and (some)
3961 headers will be hidden.
3962 If given a prefix, show the hidden text instead."
3963 (interactive (append (gnus-article-hidden-arg) (list 'force)))
3964 (gnus-article-hide-headers arg)
3965 (gnus-article-hide-list-identifiers arg)
3966 (gnus-article-hide-pgp arg)
3967 (gnus-article-hide-citation-maybe arg force)
3968 (gnus-article-hide-signature arg))
3970 (defun gnus-article-maybe-highlight ()
3971 "Do some article highlighting if article highlighting is requested."
3972 (when (gnus-visual-p 'article-highlight 'highlight)
3973 (gnus-article-highlight-some)))
3975 (defun gnus-check-group-server ()
3976 ;; Make sure the connection to the server is alive.
3977 (unless (gnus-server-opened
3978 (gnus-find-method-for-group gnus-newsgroup-name))
3979 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
3980 (gnus-request-group gnus-newsgroup-name t)))
3982 (defun gnus-request-article-this-buffer (article group)
3983 "Get an article and insert it into this buffer."
3984 (let (do-update-line sparse-header)
3988 (gnus-kill-all-overlays)
3989 (setq group (or group gnus-newsgroup-name))
3991 ;; Using `gnus-request-article' directly will insert the article into
3992 ;; `nntp-server-buffer' - so we'll save some time by not having to
3993 ;; copy it from the server buffer into the article buffer.
3995 ;; We only request an article by message-id when we do not have the
3996 ;; headers for it, so we'll have to get those.
3997 (when (stringp article)
3998 (gnus-read-header article))
4000 ;; If the article number is negative, that means that this article
4001 ;; doesn't belong in this newsgroup (possibly), so we find its
4002 ;; message-id and request it by id instead of number.
4003 (when (and (numberp article)
4005 (get-buffer gnus-summary-buffer)
4006 (gnus-buffer-exists-p gnus-summary-buffer))
4008 (set-buffer gnus-summary-buffer)
4009 (let ((header (gnus-summary-article-header article)))
4012 ((memq article gnus-newsgroup-sparse)
4013 ;; This is a sparse gap article.
4014 (setq do-update-line article)
4015 (setq article (mail-header-id header))
4016 (setq sparse-header (gnus-read-header article))
4017 (setq gnus-newsgroup-sparse
4018 (delq article gnus-newsgroup-sparse)))
4020 ;; It's a real article.
4021 (setq article (mail-header-id header)))
4023 ;; It is an extracted pseudo-article.
4024 (setq article 'pseudo)
4025 (gnus-request-pseudo-article header))))
4027 (let ((method (gnus-find-method-for-group
4028 gnus-newsgroup-name)))
4029 (when (and (eq (car method) 'nneething)
4031 (let ((dir (expand-file-name
4032 (mail-header-subject header)
4033 (file-name-as-directory
4034 (or (cadr (assq 'nneething-address method))
4036 (when (file-directory-p dir)
4037 (setq article 'nneething)
4038 (gnus-group-enter-directory dir))))))))
4041 ;; Refuse to select canceled articles.
4042 ((and (numberp article)
4044 (get-buffer gnus-summary-buffer)
4045 (gnus-buffer-exists-p gnus-summary-buffer)
4046 (eq (cdr (save-excursion
4047 (set-buffer gnus-summary-buffer)
4048 (assq article gnus-newsgroup-reads)))
4049 gnus-canceled-mark))
4051 ;; We first check `gnus-original-article-buffer'.
4052 ((and (get-buffer gnus-original-article-buffer)
4055 (set-buffer gnus-original-article-buffer)
4056 (and (equal (car gnus-original-article) group)
4057 (eq (cdr gnus-original-article) article))))
4058 (insert-buffer-substring gnus-original-article-buffer)
4060 ;; Check the backlog.
4061 ((and gnus-keep-backlog
4062 (gnus-backlog-request-article group article (current-buffer)))
4064 ;; Check asynchronous pre-fetch.
4065 ((gnus-async-request-fetched-article group article (current-buffer))
4066 (gnus-async-prefetch-next group article gnus-summary-buffer)
4067 (when (and (numberp article) gnus-keep-backlog)
4068 (gnus-backlog-enter-article group article (current-buffer)))
4071 ((and gnus-use-cache
4073 (gnus-cache-request-article article group))
4075 ;; Get the article and put into the article buffer.
4076 ((or (stringp article)
4078 (let ((gnus-override-method gnus-override-method)
4079 (methods (and (stringp article)
4080 gnus-refer-article-method))
4082 (buffer-read-only nil))
4083 (if (or (not (listp methods))
4084 (and (symbolp (car methods))
4085 (assq (car methods) nnoo-definition-alist)))
4086 (setq methods (list methods)))
4087 (when (and (null gnus-override-method)
4089 (setq gnus-override-method (pop methods)))
4091 (when (eq gnus-override-method 'current)
4092 (setq gnus-override-method gnus-current-select-method))
4094 (gnus-kill-all-overlays)
4095 (let ((gnus-newsgroup-name group))
4096 (gnus-check-group-server))
4097 (when (gnus-request-article article group (current-buffer))
4098 (when (numberp article)
4099 (gnus-async-prefetch-next group article
4100 gnus-summary-buffer)
4101 (when gnus-keep-backlog
4102 (gnus-backlog-enter-article
4103 group article (current-buffer))))
4104 (setq result 'article))
4107 (setq gnus-override-method (pop methods))
4108 (setq result 'done))))
4109 (and (eq result 'article) 'article)))
4113 ;; Associate this article with the current summary buffer.
4114 (setq gnus-article-current-summary gnus-summary-buffer)
4116 ;; Take the article from the original article buffer
4117 ;; and place it in the buffer it's supposed to be in.
4118 (when (and (get-buffer gnus-article-buffer)
4119 (equal (buffer-name (current-buffer))
4120 (buffer-name (get-buffer gnus-article-buffer))))
4122 (if (get-buffer gnus-original-article-buffer)
4123 (set-buffer gnus-original-article-buffer)
4124 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
4125 (buffer-disable-undo)
4126 (setq major-mode 'gnus-original-article-mode)
4127 (setq buffer-read-only t))
4128 (let (buffer-read-only)
4130 (insert-buffer-substring gnus-article-buffer))
4131 (setq gnus-original-article (cons group article)))
4134 (run-hooks 'gnus-article-decode-hook)
4135 ;; Mark article as decoded or not.
4136 (setq gnus-article-decoded-p gnus-article-decode-hook))
4138 ;; Update sparse articles.
4139 (when (and do-update-line
4140 (or (numberp article)
4142 (let ((buf (current-buffer)))
4143 (set-buffer gnus-summary-buffer)
4144 (gnus-summary-update-article do-update-line sparse-header)
4145 (gnus-summary-goto-subject do-update-line nil t)
4146 (set-window-point (get-buffer-window (current-buffer) t)
4148 (set-buffer buf))))))
4154 (defcustom gnus-article-edit-mode-hook nil
4155 "Hook run in article edit mode buffers."
4156 :group 'gnus-article-various
4159 (defvar gnus-article-edit-done-function nil)
4161 (defvar gnus-article-edit-mode-map nil)
4163 ;; Should we be using derived.el for this?
4164 (unless gnus-article-edit-mode-map
4165 (setq gnus-article-edit-mode-map (make-sparse-keymap))
4166 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
4168 (gnus-define-keys gnus-article-edit-mode-map
4169 "\C-c\C-c" gnus-article-edit-done
4170 "\C-c\C-k" gnus-article-edit-exit)
4172 (gnus-define-keys (gnus-article-edit-wash-map
4173 "\C-c\C-w" gnus-article-edit-mode-map)
4174 "f" gnus-article-edit-full-stops))
4176 (defun gnus-article-edit-mode ()
4177 "Major mode for editing articles.
4178 This is an extended text-mode.
4180 \\{gnus-article-edit-mode-map}"
4182 (setq major-mode 'gnus-article-edit-mode)
4183 (setq mode-name "Article Edit")
4184 (use-local-map gnus-article-edit-mode-map)
4185 (make-local-variable 'gnus-article-edit-done-function)
4186 (make-local-variable 'gnus-prev-winconf)
4187 (setq buffer-read-only nil)
4188 (buffer-enable-undo)
4190 (gnus-run-hooks 'text-mode-hook 'gnus-article-edit-mode-hook))
4192 (defun gnus-article-edit (&optional force)
4193 "Edit the current article.
4194 This will have permanent effect only in mail groups.
4195 If FORCE is non-nil, allow editing of articles even in read-only
4198 (when (and (not force)
4199 (gnus-group-read-only-p))
4200 (error "The current newsgroup does not support article editing"))
4201 (gnus-article-date-original)
4202 (gnus-article-edit-article
4204 `(lambda (no-highlight)
4206 (gnus-summary-edit-article-done
4207 ,(or (mail-header-references gnus-current-headers) "")
4208 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
4210 (defun gnus-article-edit-article (start-func exit-func)
4211 "Start editing the contents of the current article buffer."
4212 (let ((winconf (current-window-configuration)))
4213 (set-buffer gnus-article-buffer)
4214 (gnus-article-edit-mode)
4215 (funcall start-func)
4216 (gnus-configure-windows 'edit-article)
4217 (setq gnus-article-edit-done-function exit-func)
4218 (setq gnus-prev-winconf winconf)
4219 (gnus-message 6 "C-c C-c to end edits")))
4221 (defun gnus-article-edit-done (&optional arg)
4222 "Update the article edits and exit."
4224 (let ((func gnus-article-edit-done-function)
4225 (buf (current-buffer))
4226 (start (window-start)))
4227 (gnus-article-edit-exit)
4230 (let ((buffer-read-only nil))
4232 ;; The cache and backlog have to be flushed somewhat.
4233 (when gnus-keep-backlog
4234 (gnus-backlog-remove-article
4235 (car gnus-article-current) (cdr gnus-article-current)))
4236 ;; Flush original article as well.
4238 (when (get-buffer gnus-original-article-buffer)
4239 (set-buffer gnus-original-article-buffer)
4240 (setq gnus-original-article nil)))
4241 (when gnus-use-cache
4242 (gnus-cache-update-article
4243 (car gnus-article-current) (cdr gnus-article-current))))
4245 (set-window-start (get-buffer-window buf) start)
4246 (set-window-point (get-buffer-window buf) (point))))
4248 (defun gnus-article-edit-exit ()
4249 "Exit the article editing without updating."
4251 ;; We remove all text props from the article buffer.
4252 (let ((buf (buffer-substring-no-properties (point-min) (point-max)))
4253 (curbuf (current-buffer))
4255 (window-start (window-start)))
4258 (let ((winconf gnus-prev-winconf))
4260 (set-window-configuration winconf)
4261 ;; Tippy-toe some to make sure that point remains where it was.
4262 (save-current-buffer
4264 (set-window-start (get-buffer-window (current-buffer)) window-start)
4267 (defun gnus-article-edit-full-stops ()
4268 "Interactively repair spacing at end of sentences."
4271 (goto-char (point-min))
4272 (search-forward-regexp "^$" nil t)
4273 (let ((case-fold-search nil))
4274 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
4277 ;;; Article highlights
4280 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
4282 ;;; Internal Variables:
4284 (defcustom gnus-button-url-regexp "\\b\\(\\(www\\.\\|\\(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\\)\\)"
4285 "Regular expression that matches URLs."
4286 :group 'gnus-article-buttons
4289 (defcustom gnus-button-alist
4290 `(("<\\(url:[>\n\t ]*?\\)?news:[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
4291 0 t gnus-button-message-id 2)
4292 ("\\bnews:\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t gnus-button-message-id 1)
4293 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
4295 gnus-button-fetch-group 4)
4296 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
4297 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
4298 t gnus-button-message-id 3)
4299 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
4300 ("mailto:\\([-a-zA-Z.@_+0-9%]+\\)" 0 t gnus-url-mailto 1)
4301 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
4302 ;; This is how URLs _should_ be embedded in text...
4303 ("<URL: *\\([^<>]*\\)>" 0 t gnus-button-embedded-url 1)
4305 (,gnus-button-url-regexp 0 t browse-url 0))
4306 "*Alist of regexps matching buttons in article bodies.
4308 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
4309 REGEXP: is the string matching text around the button,
4310 BUTTON: is the number of the regexp grouping actually matching the button,
4311 FORM: is a lisp expression which must eval to true for the button to
4313 CALLBACK: is the function to call when the user push this button, and each
4314 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
4316 CALLBACK can also be a variable, in that case the value of that
4317 variable it the real callback function."
4318 :group 'gnus-article-buttons
4319 :type '(repeat (list regexp
4320 (integer :tag "Button")
4322 (function :tag "Callback")
4325 (integer :tag "Regexp group")))))
4327 (defcustom gnus-header-button-alist
4328 `(("^\\(References\\|Message-I[Dd]\\):" "<[^>]+>"
4329 0 t gnus-button-message-id 0)
4330 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
4331 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
4332 0 t gnus-button-mailto 0)
4333 ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t browse-url 0)
4334 ("^Subject:" ,gnus-button-url-regexp 0 t browse-url 0)
4335 ("^[^:]+:" ,gnus-button-url-regexp 0 t browse-url 0)
4336 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
4337 gnus-button-message-id 3))
4338 "*Alist of headers and regexps to match buttons in article heads.
4340 This alist is very similar to `gnus-button-alist', except that each
4341 alist has an additional HEADER element first in each entry:
4343 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
4345 HEADER is a regexp to match a header. For a fuller explanation, see
4346 `gnus-button-alist'."
4347 :group 'gnus-article-buttons
4348 :group 'gnus-article-headers
4349 :type '(repeat (list (regexp :tag "Header")
4351 (integer :tag "Button")
4353 (function :tag "Callback")
4356 (integer :tag "Regexp group")))))
4358 (defvar gnus-button-regexp nil)
4359 (defvar gnus-button-marker-list nil)
4360 ;; Regexp matching any of the regexps from `gnus-button-alist'.
4362 (defvar gnus-button-last nil)
4363 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
4367 (defun gnus-article-push-button (event)
4368 "Check text under the mouse pointer for a callback function.
4369 If the text under the mouse pointer has a `gnus-callback' property,
4370 call it with the value of the `gnus-data' text property."
4372 (set-buffer (window-buffer (posn-window (event-start event))))
4373 (let* ((pos (posn-point (event-start event)))
4374 (data (get-text-property pos 'gnus-data))
4375 (fun (get-text-property pos 'gnus-callback)))
4378 (funcall fun data))))
4380 (defun gnus-article-press-button ()
4381 "Check text at point for a callback function.
4382 If the text at point has a `gnus-callback' property,
4383 call it with the value of the `gnus-data' text property."
4385 (let* ((data (get-text-property (point) 'gnus-data))
4386 (fun (get-text-property (point) 'gnus-callback)))
4388 (funcall fun data))))
4390 (defun gnus-article-highlight (&optional force)
4391 "Highlight current article.
4392 This function calls `gnus-article-highlight-headers',
4393 `gnus-article-highlight-citation',
4394 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
4395 do the highlighting. See the documentation for those functions."
4396 (interactive (list 'force))
4397 (gnus-article-highlight-headers)
4398 (gnus-article-highlight-citation force)
4399 (gnus-article-highlight-signature)
4400 (gnus-article-add-buttons force)
4401 (gnus-article-add-buttons-to-head))
4403 (defun gnus-article-highlight-some (&optional force)
4404 "Highlight current article.
4405 This function calls `gnus-article-highlight-headers',
4406 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
4407 do the highlighting. See the documentation for those functions."
4408 (interactive (list 'force))
4409 (gnus-article-highlight-headers)
4410 (gnus-article-highlight-signature)
4411 (gnus-article-add-buttons))
4413 (defun gnus-article-highlight-headers ()
4414 "Highlight article headers as specified by `gnus-header-face-alist'."
4417 (set-buffer gnus-article-buffer)
4419 (let ((alist gnus-header-face-alist)
4420 (buffer-read-only nil)
4421 (case-fold-search t)
4422 (inhibit-point-motion-hooks t)
4423 entry regexp header-face field-face from hpoints fpoints)
4424 (article-narrow-to-head)
4425 (while (setq entry (pop alist))
4426 (goto-char (point-min))
4427 (setq regexp (concat "^\\("
4428 (if (string-equal "" (nth 0 entry))
4432 header-face (nth 1 entry)
4433 field-face (nth 2 entry))
4434 (while (and (re-search-forward regexp nil t)
4438 (unless (search-forward ":" nil t)
4440 (when (and header-face
4441 (not (memq (point) hpoints)))
4442 (push (point) hpoints)
4443 (gnus-put-text-property from (point) 'face header-face))
4444 (when (and field-face
4445 (not (memq (setq from (point)) fpoints)))
4447 (if (re-search-forward "^[^ \t]" nil t)
4449 (goto-char (point-max)))
4450 (gnus-put-text-property from (point) 'face field-face))))))))
4452 (defun gnus-article-highlight-signature ()
4453 "Highlight the signature in an article.
4454 It does this by highlighting everything after
4455 `gnus-signature-separator' using `gnus-signature-face'."
4458 (set-buffer gnus-article-buffer)
4459 (let ((buffer-read-only nil)
4460 (inhibit-point-motion-hooks t))
4462 (when (and gnus-signature-face
4463 (gnus-article-narrow-to-signature))
4464 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
4465 'face gnus-signature-face)
4467 (gnus-article-search-signature)
4468 (let ((start (match-beginning 0))
4469 (end (set-marker (make-marker) (1+ (match-end 0)))))
4470 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
4473 (defun gnus-button-in-region-p (b e prop)
4474 "Say whether PROP exists in the region."
4475 (text-property-not-all b e prop nil))
4477 (defun gnus-article-add-buttons (&optional force)
4478 "Find external references in the article and make buttons of them.
4479 \"External references\" are things like Message-IDs and URLs, as
4480 specified by `gnus-button-alist'."
4481 (interactive (list 'force))
4483 (set-buffer gnus-article-buffer)
4484 (let ((buffer-read-only nil)
4485 (inhibit-point-motion-hooks t)
4486 (case-fold-search t)
4487 (alist gnus-button-alist)
4489 ;; Remove all old markers.
4490 (let (marker entry new-list)
4491 (while (setq marker (pop gnus-button-marker-list))
4492 (if (or (< marker (point-min)) (>= marker (point-max)))
4493 (push marker new-list)
4495 (when (setq entry (gnus-button-entry))
4496 (put-text-property (match-beginning (nth 1 entry))
4497 (match-end (nth 1 entry))
4498 'gnus-callback nil))
4499 (set-marker marker nil)))
4500 (setq gnus-button-marker-list new-list))
4501 ;; We skip the headers.
4504 (while (setq entry (pop alist))
4505 (setq regexp (car entry))
4507 (while (re-search-forward regexp nil t)
4508 (let* ((start (and entry (match-beginning (nth 1 entry))))
4509 (end (and entry (match-end (nth 1 entry))))
4510 (from (match-beginning 0)))
4511 (when (and (or (eq t (nth 2 entry))
4512 (eval (nth 2 entry)))
4513 (not (gnus-button-in-region-p
4514 start end 'gnus-callback)))
4515 ;; That optional form returned non-nil, so we add the
4517 (gnus-article-add-button
4518 start end 'gnus-button-push
4519 (car (push (set-marker (make-marker) from)
4520 gnus-button-marker-list))))))))))
4522 ;; Add buttons to the head of an article.
4523 (defun gnus-article-add-buttons-to-head ()
4524 "Add buttons to the head of the article."
4527 (set-buffer gnus-article-buffer)
4529 (let ((buffer-read-only nil)
4530 (inhibit-point-motion-hooks t)
4531 (case-fold-search t)
4532 (alist gnus-header-button-alist)
4534 (article-narrow-to-head)
4536 ;; Each alist entry.
4537 (setq entry (car alist)
4539 (goto-char (point-min))
4540 (while (re-search-forward (car entry) nil t)
4541 ;; Each header matching the entry.
4542 (setq beg (match-beginning 0))
4543 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
4544 (match-beginning 0))
4547 (while (re-search-forward (nth 1 entry) end t)
4548 ;; Each match within a header.
4549 (let* ((entry (cdr entry))
4550 (start (match-beginning (nth 1 entry)))
4551 (end (match-end (nth 1 entry)))
4552 (form (nth 2 entry)))
4553 (goto-char (match-end 0))
4555 (gnus-article-add-button
4556 start end (nth 3 entry)
4557 (buffer-substring (match-beginning (nth 4 entry))
4558 (match-end (nth 4 entry)))))))
4559 (goto-char end)))))))
4561 ;;; External functions:
4563 (defun gnus-article-add-button (from to fun &optional data)
4564 "Create a button between FROM and TO with callback FUN and data DATA."
4565 (when gnus-article-button-face
4566 (gnus-overlay-put (gnus-make-overlay from to)
4567 'face gnus-article-button-face))
4568 (gnus-add-text-properties
4570 (nconc (and gnus-article-mouse-face
4571 (list gnus-mouse-face-prop gnus-article-mouse-face))
4572 (list 'gnus-callback fun)
4573 (and data (list 'gnus-data data))))
4574 (widget-convert-button 'link from to :action 'gnus-widget-press-button
4575 :button-keymap gnus-widget-button-keymap))
4577 ;;; Internal functions:
4579 (defun gnus-article-set-globals ()
4581 (set-buffer gnus-summary-buffer)
4582 (gnus-set-global-variables)))
4584 (defun gnus-signature-toggle (end)
4586 (set-buffer gnus-article-buffer)
4587 (let ((buffer-read-only nil)
4588 (inhibit-point-motion-hooks t))
4589 (if (get-text-property end 'invisible)
4590 (gnus-article-unhide-text end (point-max))
4591 (gnus-article-hide-text end (point-max) gnus-hidden-properties)))))
4593 (defun gnus-button-entry ()
4594 ;; Return the first entry in `gnus-button-alist' matching this place.
4595 (let ((alist gnus-button-alist)
4598 (setq entry (pop alist))
4599 (if (looking-at (car entry))
4604 (defun gnus-button-push (marker)
4605 ;; Push button starting at MARKER.
4608 (let* ((entry (gnus-button-entry))
4609 (inhibit-point-motion-hooks t)
4611 (args (mapcar (lambda (group)
4612 (let ((string (match-string group)))
4613 (gnus-set-text-properties
4614 0 (length string) nil string)
4621 (fboundp (symbol-value fun)))
4622 (apply (symbol-value fun) args))
4624 (gnus-message 1 "You must define `%S' to use this button"
4625 (cons fun args)))))))
4627 (defun gnus-button-message-id (message-id)
4630 (set-buffer gnus-summary-buffer)
4631 (gnus-summary-refer-article message-id)))
4633 (defun gnus-button-fetch-group (address)
4634 "Fetch GROUP specified by ADDRESS."
4635 (if (not (string-match "[:/]" address))
4636 ;; This is just a simple group url.
4637 (gnus-group-read-ephemeral-group address gnus-select-method)
4638 (if (not (string-match "^\\([^:/]+\\)\\(:\\([^/]+\\)/\\)?\\(.*\\)$"
4640 (error "Can't parse %s" address)
4641 (gnus-group-read-ephemeral-group
4642 (match-string 4 address)
4643 `(nntp ,(match-string 1 address)
4644 (nntp-address ,(match-string 1 address))
4645 (nntp-port-number ,(if (match-end 3)
4646 (match-string 3 address)
4649 (defun gnus-url-parse-query-string (query &optional downcase)
4650 (let (retval pairs cur key val)
4651 (setq pairs (split-string query "&"))
4653 (setq cur (car pairs)
4655 (if (not (string-match "=" cur))
4657 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
4658 val (gnus-url-unhex-string (substring cur (match-end 0) nil)))
4660 (setq key (downcase key)))
4661 (setq cur (assoc key retval))
4663 (setcdr cur (cons val (cdr cur)))
4664 (setq retval (cons (list key val) retval)))))
4667 (defun gnus-url-unhex (x)
4674 (defun gnus-url-unhex-string (str &optional allow-newlines)
4675 "Remove %XXX embedded spaces, etc in a url.
4676 If optional second argument ALLOW-NEWLINES is non-nil, then allow the
4677 decoding of carriage returns and line feeds in the string, which is normally
4678 forbidden in URL encoding."
4679 (setq str (or str ""))
4681 (case-fold-search t))
4682 (while (string-match "%[0-9a-f][0-9a-f]" str)
4683 (let* ((start (match-beginning 0))
4684 (ch1 (gnus-url-unhex (elt str (+ start 1))))
4686 (gnus-url-unhex (elt str (+ start 2))))))
4688 tmp (substring str 0 start)
4691 (char-to-string code))
4692 ((or (= code ?\n) (= code ?\r))
4694 (t (char-to-string code))))
4695 str (substring str (match-end 0)))))
4696 (setq tmp (concat tmp str))
4699 (defun gnus-url-mailto (url)
4700 ;; Send mail to someone
4701 (when (string-match "mailto:/*\\(.*\\)" url)
4702 (setq url (substring url (match-beginning 1) nil)))
4703 (let (to args subject func)
4704 (if (string-match (regexp-quote "?") url)
4705 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
4706 args (gnus-url-parse-query-string
4707 (substring url (match-end 0) nil) t))
4708 (setq to (gnus-url-unhex-string url)))
4709 (setq args (cons (list "to" to) args)
4710 subject (cdr-safe (assoc "subject" args)))
4713 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
4716 (message-position-on-field (caar args)))
4717 (insert (mapconcat 'identity (cdar args) ", "))
4718 (setq args (cdr args)))
4721 (message-goto-subject))))
4723 (defun gnus-button-mailto (address)
4725 (set-buffer (gnus-copy-article-buffer))
4726 (message-reply address))
4728 (defalias 'gnus-button-reply 'message-reply)
4730 (defun gnus-button-embedded-url (address)
4731 "Activate ADDRESS with `browse-url'."
4732 (browse-url (gnus-strip-whitespace address)))
4734 ;;; Next/prev buttons in the article buffer.
4736 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
4737 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
4739 (defvar gnus-prev-page-map nil)
4740 (unless gnus-prev-page-map
4741 (setq gnus-prev-page-map (make-sparse-keymap))
4742 (define-key gnus-prev-page-map gnus-mouse-2 'gnus-button-prev-page)
4743 (define-key gnus-prev-page-map "\r" 'gnus-button-prev-page))
4745 (defun gnus-insert-prev-page-button ()
4746 (let ((buffer-read-only nil))
4748 gnus-prev-page-line-format nil
4749 `(gnus-prev t local-map ,gnus-prev-page-map
4750 gnus-callback gnus-article-button-prev-page
4751 article-type annotation))))
4753 (defvar gnus-next-page-map nil)
4754 (unless gnus-next-page-map
4755 (setq gnus-next-page-map (make-keymap))
4756 (suppress-keymap gnus-prev-page-map)
4757 (define-key gnus-next-page-map gnus-mouse-2 'gnus-button-next-page)
4758 (define-key gnus-next-page-map "\r" 'gnus-button-next-page))
4760 (defun gnus-button-next-page ()
4761 "Go to the next page."
4763 (let ((win (selected-window)))
4764 (select-window (get-buffer-window gnus-article-buffer t))
4765 (gnus-article-next-page)
4766 (select-window win)))
4768 (defun gnus-button-prev-page ()
4769 "Go to the prev page."
4771 (let ((win (selected-window)))
4772 (select-window (get-buffer-window gnus-article-buffer t))
4773 (gnus-article-prev-page)
4774 (select-window win)))
4776 (defun gnus-insert-next-page-button ()
4777 (let ((buffer-read-only nil))
4778 (gnus-eval-format gnus-next-page-line-format nil
4780 t local-map ,gnus-next-page-map
4781 gnus-callback gnus-article-button-next-page
4782 article-type annotation))))
4784 (defun gnus-article-button-next-page (arg)
4785 "Go to the next page."
4787 (let ((win (selected-window)))
4788 (select-window (get-buffer-window gnus-article-buffer t))
4789 (gnus-article-next-page)
4790 (select-window win)))
4792 (defun gnus-article-button-prev-page (arg)
4793 "Go to the prev page."
4795 (let ((win (selected-window)))
4796 (select-window (get-buffer-window gnus-article-buffer t))
4797 (gnus-article-prev-page)
4798 (select-window win)))
4800 (defvar gnus-decode-header-methods
4801 '(mail-decode-encoded-word-region)
4802 "List of methods used to decode headers.
4804 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
4805 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
4806 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
4807 whose names match REGEXP.
4810 ((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
4811 mail-decode-encoded-word-region
4812 (\"chinese\" . rfc1843-decode-region))
4815 (defvar gnus-decode-header-methods-cache nil)
4817 (defun gnus-multi-decode-header (start end)
4818 "Apply the functions from `gnus-encoded-word-methods' that match."
4819 (unless (and gnus-decode-header-methods-cache
4820 (eq gnus-newsgroup-name
4821 (car gnus-decode-header-methods-cache)))
4822 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
4825 (nconc gnus-decode-header-methods-cache (list x))
4826 (if (and gnus-newsgroup-name
4827 (string-match (car x) gnus-newsgroup-name))
4828 (nconc gnus-decode-header-methods-cache
4830 gnus-decode-header-methods))
4831 (let ((xlist gnus-decode-header-methods-cache))
4834 (narrow-to-region start end)
4836 (funcall (pop xlist) (point-min) (point-max))))))
4839 ;;; Treatment top-level handling.
4842 (defun gnus-treat-article (condition &optional part-number total-parts type)
4843 (let ((length (- (point-max) (point-min)))
4844 (alist gnus-treatment-function-alist)
4845 (article-goto-body-goes-to-point-min-p t)
4849 (let ((list gnus-article-treat-types))
4851 (when (string-match (pop list) type)
4852 (throw 'found t)))))))
4853 (highlightp (gnus-visual-p 'article-highlight 'highlight))
4855 (gnus-run-hooks 'gnus-part-display-hook)
4856 (while (setq elem (pop alist))
4859 (if (gnus-buffer-live-p gnus-summary-buffer)
4860 (set-buffer gnus-summary-buffer))
4861 (symbol-value (car elem))))
4862 (when (and (or (consp val)
4864 (gnus-treat-predicate val)
4865 (or (not (get (car elem) 'highlight))
4868 (funcall (cadr elem)))))))
4870 ;; Dynamic variables.
4872 (defvar part-number)
4873 (defvar total-parts)
4878 (defun gnus-treat-predicate (val)
4883 (stringp (car val)))
4884 (apply 'gnus-or (mapcar `(lambda (s)
4885 (string-match s ,(or gnus-newsgroup-name "")))
4888 (let ((pred (pop val)))
4891 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
4893 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
4895 (not (gnus-treat-predicate (car val))))
4897 (equal (car val) type))
4899 (error "%S is not a valid predicate" pred)))))
4907 (eq part-number total-parts))
4911 (error "%S is not a valid value" val))))
4913 (defun gnus-article-encrypt-body (protocol &optional n)
4914 "Encrypt the article body."
4917 (or gnus-article-encrypt-protocol
4918 (completing-read "Encrypt protocol: "
4919 gnus-article-encrypt-protocol-alist
4921 current-prefix-arg))
4922 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
4924 (error (format "Can't find the encrypt protocol %s" protocol)))
4925 (if (equal gnus-newsgroup-name "nndraft:drafts")
4926 (error "Can't encrypt the article in group nndraft:drafts."))
4927 (if (equal gnus-newsgroup-name "nndraft:queue")
4928 (error "Don't encrypt the article in group nndraft:queue."))
4929 (gnus-summary-iterate n
4931 (set-buffer gnus-summary-buffer)
4932 (let ((mail-parse-charset gnus-newsgroup-charset)
4933 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
4934 (summary-buffer gnus-summary-buffer)
4936 (gnus-set-global-variables)
4937 (when (gnus-group-read-only-p)
4938 (error "The current newsgroup does not support article encrypt"))
4939 (gnus-summary-show-article t)
4941 (or (mail-header-references gnus-current-headers) ""))
4942 (set-buffer gnus-article-buffer)
4943 (let* ((buffer-read-only nil)
4945 (mapcar (lambda (field)
4946 (and (save-restriction
4947 (message-narrow-to-head)
4948 (goto-char (point-min))
4949 (search-forward field nil t))
4951 (message-narrow-to-field)
4952 (buffer-substring (point-min) (point-max))
4953 (delete-region (point-min) (point-max))
4955 '("Content-Type:" "Content-Transfer-Encoding:"
4956 "Content-Disposition:"))))
4957 (message-narrow-to-head)
4958 (message-remove-header "MIME-Version")
4959 (goto-char (point-max))
4960 (setq point (point))
4961 (insert (apply 'concat headers))
4963 (narrow-to-region point (point-max))
4964 (let ((message-options message-options))
4965 (message-options-set 'message-sender user-mail-address)
4966 (message-options-set 'message-recipients user-mail-address)
4967 (message-options-set 'message-sign-encrypt 'not)
4969 (goto-char (point-min))
4970 (insert "MIME-Version: 1.0\n")
4972 (gnus-summary-edit-article-done
4973 references nil summary-buffer t))
4974 (when gnus-keep-backlog
4975 (gnus-backlog-remove-article
4976 (car gnus-article-current) (cdr gnus-article-current)))
4978 (when (get-buffer gnus-original-article-buffer)
4979 (set-buffer gnus-original-article-buffer)
4980 (setq gnus-original-article nil)))
4981 (when gnus-use-cache
4982 (gnus-cache-update-article
4983 (car gnus-article-current) (cdr gnus-article-current))))))))
4985 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]]%)%}\n"
4986 "The following specs can be used:
4987 %t The security MIME type
4988 %i Additional info")
4990 (defvar gnus-mime-security-button-line-format-alist
4991 '((?t gnus-tmp-type ?s)
4992 (?i gnus-tmp-info ?s)))
4994 (defvar gnus-mime-security-button-map
4995 (let ((map (make-sparse-keymap)))
4996 (set-keymap-parent map gnus-article-mode-map)
4997 (define-key map gnus-mouse-2 'gnus-article-push-button)
4998 (define-key map "\r" 'gnus-article-press-button)
5001 (defvar gnus-mime-security-details-buffer nil)
5003 (defun gnus-mime-security-show-details (handle)
5004 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
5007 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
5008 (with-current-buffer gnus-mime-security-details-buffer
5011 (setq gnus-mime-security-details-buffer
5012 (gnus-get-buffer-create "*MIME Security Details*")))
5013 (with-current-buffer gnus-mime-security-details-buffer
5015 (pop-to-buffer gnus-mime-security-details-buffer))
5016 (gnus-message 5 "No details."))))
5018 (defun gnus-insert-mime-security-button (handle &optional displayed)
5019 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
5022 (or (nth 2 (assoc protocol mm-verify-function-alist))
5023 (nth 2 (assoc protocol mm-decrypt-function-alist))
5025 (if (equal (car handle) "multipart/signed")
5026 " Signed" " Encrypted")))
5028 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
5035 gnus-mime-security-button-line-format
5036 gnus-mime-security-button-line-format-alist
5037 `(local-map ,gnus-mime-security-button-map
5038 keymap ,gnus-mime-security-button-map
5039 gnus-callback gnus-mime-security-show-details
5040 article-type annotation
5043 (widget-convert-button
5046 :action 'gnus-widget-press-button
5047 :button-keymap gnus-mime-security-button-map
5049 (lambda (widget/window &optional overlay pos)
5050 ;; Needed to properly clear the message due to a bug in
5051 ;; wid-edit (XEmacs only).
5052 (if (boundp 'help-echo-owns-message)
5053 (setq help-echo-owns-message t))
5056 (aref gnus-mouse-2 0))))))
5062 (run-hooks 'gnus-art-load-hook)
5064 ;;; gnus-art.el ends here