1 ;;; gnus-art.el --- article mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
43 (autoload 'gnus-msg-mail "gnus-msg" nil t)
44 (autoload 'gnus-button-mailto "gnus-msg")
45 (autoload 'gnus-button-reply "gnus-msg" nil t)
47 (defgroup gnus-article nil
49 :link '(custom-manual "(gnus)The Article Buffer")
52 (defgroup gnus-article-treat nil
53 "Treating article parts."
54 :link '(custom-manual "(gnus)Article Hiding")
57 (defgroup gnus-article-hiding nil
58 "Hiding article parts."
59 :link '(custom-manual "(gnus)Article Hiding")
62 (defgroup gnus-article-highlight nil
63 "Article highlighting."
64 :link '(custom-manual "(gnus)Article Highlighting")
68 (defgroup gnus-article-signature nil
70 :link '(custom-manual "(gnus)Article Signature")
73 (defgroup gnus-article-headers nil
75 :link '(custom-manual "(gnus)Hiding Headers")
78 (defgroup gnus-article-washing nil
79 "Special commands on articles."
80 :link '(custom-manual "(gnus)Article Washing")
83 (defgroup gnus-article-emphasis nil
84 "Fontisizing articles."
85 :link '(custom-manual "(gnus)Article Fontisizing")
88 (defgroup gnus-article-saving nil
90 :link '(custom-manual "(gnus)Saving Articles")
93 (defgroup gnus-article-mime nil
94 "Worshiping the MIME wonder."
95 :link '(custom-manual "(gnus)Using MIME")
98 (defgroup gnus-article-buttons nil
99 "Pushable buttons in the article buffer."
100 :link '(custom-manual "(gnus)Article Buttons")
101 :group 'gnus-article)
103 (defgroup gnus-article-various nil
104 "Other article options."
105 :link '(custom-manual "(gnus)Misc Article")
106 :group 'gnus-article)
108 (defcustom gnus-ignored-headers
109 '("^Path:" "^Expires:" "^Date-Received:" "^References:" "^Xref:" "^Lines:"
110 "^Relay-Version:" "^Message-ID:" "^Approved:" "^Sender:" "^Received:"
111 "^X-UIDL:" "^MIME-Version:" "^Return-Path:" "^In-Reply-To:"
112 "^Content-Type:" "^Content-Transfer-Encoding:" "^X-WebTV-Signature:"
113 "^X-MimeOLE:" "^X-MSMail-Priority:" "^X-Priority:" "^X-Loop:"
114 "^X-Authentication-Warning:" "^X-MIME-Autoconverted:" "^X-Face"
115 "^X-Attribution:" "^X-Originating-IP:" "^Delivered-To:"
116 "^NNTP-[-A-Za-z]+:" "^Distribution:" "^X-no-archive:" "^X-Trace:"
117 "^X-Complaints-To:" "^X-NNTP-Posting-Host:" "^X-Orig.*:"
118 "^Abuse-Reports-To:" "^Cache-Post-Path:" "^X-Article-Creation-Date:"
119 "^X-Poster:" "^X-Mail2News-Path:" "^X-Server-Date:" "^X-Cache:"
120 "^Originator:" "^X-Problems-To:" "^X-Auth-User:" "^X-Post-Time:"
121 "^X-Admin:" "^X-UID:" "^Resent-[-A-Za-z]+:" "^X-Mailing-List:"
122 "^Precedence:" "^Original-[-A-Za-z]+:" "^X-filename:" "^X-Orcpt:"
123 "^Old-Received:" "^X-Pgp" "^X-Auth:" "^X-From-Line:"
124 "^X-Gnus-Article-Number:" "^X-Majordomo:" "^X-Url:" "^X-Sender:"
125 "^MBOX-Line" "^Priority:" "^X400-[-A-Za-z]+:"
126 "^Status:" "^X-Gnus-Mail-Source:" "^Cancel-Lock:"
127 "^X-FTN" "^X-EXP32-SerialNo:" "^Encoding:" "^Importance:"
128 "^Autoforwarded:" "^Original-Encoded-Information-Types:" "^X-Ya-Pop3:"
129 "^X-Face-Version:" "^X-Vms-To:" "^X-ML-NAME:" "^X-ML-COUNT:"
130 "^Mailing-List:" "^X-finfo:" "^X-md5sum:" "^X-md5sum-Origin:"
131 "^X-Sun-Charset:" "^X-Accept-Language:" "^X-Envelope-Sender:"
132 "^List-[A-Za-z]+:" "^X-Listprocessor-Version:"
133 "^X-Received:" "^X-Distribute:" "^X-Sequence:" "^X-Juno-Line-Breaks:"
134 "^X-Notes-Item:" "^X-MS-TNEF-Correlator:" "^x-uunet-gateway:"
135 "^X-Received:" "^Content-length:" "X-precedence:"
136 "^X-Authenticated-User:" "^X-Comment" "^X-Report:" "^X-Abuse-Info:"
137 "^X-HTTP-Proxy:" "^X-Mydeja-Info:" "^X-Copyright" "^X-No-Markup:"
138 "^X-Abuse-Info:" "^X-From_:" "^X-Accept-Language:" "^Errors-To:"
139 "^X-BeenThere:" "^X-Mailman-Version:" "^List-Help:" "^List-Post:"
140 "^List-Subscribe:" "^List-Id:" "^List-Unsubscribe:" "^List-Archive:"
141 "^X-Content-length:" "^X-Posting-Agent:" "^Original-Received:"
142 "^X-Request-PGP:" "^X-Fingerprint:" "^X-WRIEnvto:" "^X-WRIEnvfrom:"
143 "^X-Virus-Scanned:" "^X-Delivery-Agent:" "^Posted-Date:" "^X-Gateway:"
144 "^X-Local-Origin:" "^X-Local-Destination:" "^X-UserInfo1:"
146 "*All headers that start with this regexp will be hidden.
147 This variable can also be a list of regexps of headers to be ignored.
148 If `gnus-visible-headers' is non-nil, this variable will be ignored."
149 :type '(choice :custom-show nil
152 :group 'gnus-article-hiding)
154 (defcustom gnus-visible-headers
155 "^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:"
156 "*All headers that do not match this regexp will be hidden.
157 This variable can also be a list of regexp of headers to remain visible.
158 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
159 :type '(repeat :value-to-internal (lambda (widget value)
160 (custom-split-regexp-maybe value))
161 :match (lambda (widget value)
163 (widget-editable-list-match widget value)))
165 :group 'gnus-article-hiding)
167 (defcustom gnus-sorted-header-list
168 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
169 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
170 "*This variable is a list of regular expressions.
171 If it is non-nil, headers that match the regular expressions will
172 be placed first in the article buffer in the sequence specified by
174 :type '(repeat regexp)
175 :group 'gnus-article-hiding)
177 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
178 "Headers that are only to be displayed if they have interesting data.
179 Possible values in this list are:
181 'empty Headers with no content.
182 'newsgroups Newsgroup identical to Gnus group.
183 'to-address To identical to To-address.
184 'followup-to Followup-to identical to Newsgroups.
185 'reply-to Reply-to identical to From.
186 'date Date less than four days old.
187 'long-to To and/or Cc longer than 1024 characters.
188 'many-to Multiple To and/or Cc."
189 :type '(set (const :tag "Headers with no content." empty)
190 (const :tag "Newsgroups identical to Gnus group." newsgroups)
191 (const :tag "To identical to To-address." to-address)
192 (const :tag "Followup-to identical to Newsgroups." followup-to)
193 (const :tag "Reply-to identical to From." reply-to)
194 (const :tag "Date less than four days old." date)
195 (const :tag "To and/or Cc longer than 1024 characters." long-to)
196 (const :tag "Multiple To and/or Cc headers." many-to))
197 :group 'gnus-article-hiding)
199 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
200 "Regexp matching signature separator.
201 This can also be a list of regexps. In that case, it will be checked
202 from head to tail looking for a separator. Searches will be done from
203 the end of the buffer."
204 :type '(repeat string)
205 :group 'gnus-article-signature)
207 (defcustom gnus-signature-limit nil
208 "Provide a limit to what is considered a signature.
209 If it is a number, no signature may not be longer (in characters) than
210 that number. If it is a floating point number, no signature may be
211 longer (in lines) than that number. If it is a function, the function
212 will be called without any parameters, and if it returns nil, there is
213 no signature in the buffer. If it is a string, it will be used as a
214 regexp. If it matches, the text in question is not a signature."
215 :type '(choice (integer :value 200)
217 (function :value fun)
218 (regexp :value ".*"))
219 :group 'gnus-article-signature)
221 (defcustom gnus-hidden-properties '(invisible t intangible t)
222 "Property list to use for hiding text."
224 :group 'gnus-article-hiding)
226 ;; Fixme: This isn't the right thing for mixed graphical and and
227 ;; non-graphical frames in a session.
228 (defcustom gnus-article-x-face-command
229 (if (featurep 'xemacs)
230 (if (or (gnus-image-type-available-p 'xface)
231 (gnus-image-type-available-p 'pbm))
232 'gnus-display-x-face-in-from
233 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
234 (if (gnus-image-type-available-p 'pbm)
235 'gnus-display-x-face-in-from
236 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
238 "*String or function to be executed to display an X-Face header.
239 If it is a string, the command will be executed in a sub-shell
240 asynchronously. The compressed face will be piped to this command."
241 :type `(choice string
242 (function-item gnus-display-x-face-in-from)
245 :group 'gnus-article-washing)
247 (defcustom gnus-article-x-face-too-ugly nil
248 "Regexp matching posters whose face shouldn't be shown automatically."
249 :type '(choice regexp (const nil))
250 :group 'gnus-article-washing)
252 (defcustom gnus-article-banner-alist nil
253 "Banner alist for stripping.
255 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
257 :type '(repeat (cons symbol regexp))
258 :group 'gnus-article-washing)
260 (gnus-define-group-parameter
263 "Alist of regexps (to match group names) and banner."
264 :variable-group gnus-article-washing
266 '(choice :tag "Banner"
268 (const :tag "Remove signature" signature)
269 (symbol :tag "Item in `gnus-article-banner-alist'" none)
271 (const :tag "None" nil))
273 "If non-nil, specify how to remove `banners' from articles.
275 Symbol `signature' means to remove signatures delimited by
276 `gnus-signature-separator'. Any other symbol is used to look up a
277 regular expression to match the banner in `gnus-article-banner-alist'.
278 A string is used as a regular expression to match the banner
281 (defcustom gnus-emphasis-alist
283 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
288 ("_/" "/_" underline-italic)
289 ("_\\*" "\\*_" underline-bold)
290 ("\\*/" "/\\*" bold-italic)
291 ("_\\*/" "/\\*_" underline-bold-italic))))
295 (format format (car spec) (cadr spec))
296 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
298 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
299 2 3 gnus-emphasis-underline)))
300 "*Alist that says how to fontify certain phrases.
301 Each item looks like this:
303 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
305 The first element is a regular expression to be matched. The second
306 is a number that says what regular expression grouping used to find
307 the entire emphasized word. The third is a number that says what
308 regexp grouping should be displayed and highlighted. The fourth
309 is the face used for highlighting."
310 :type '(repeat (list :value ("" 0 0 default)
312 (integer :tag "Match group")
313 (integer :tag "Emphasize group")
315 :group 'gnus-article-emphasis)
317 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
318 "A regexp to describe whitespace which should not be emphasized.
319 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
320 The former avoids underlining of leading and trailing whitespace,
321 and the latter avoids underlining any whitespace at all."
323 :group 'gnus-article-emphasis
326 (defface gnus-emphasis-bold '((t (:bold t)))
327 "Face used for displaying strong emphasized text (*word*)."
328 :group 'gnus-article-emphasis)
330 (defface gnus-emphasis-italic '((t (:italic t)))
331 "Face used for displaying italic emphasized text (/word/)."
332 :group 'gnus-article-emphasis)
334 (defface gnus-emphasis-underline '((t (:underline t)))
335 "Face used for displaying underlined emphasized text (_word_)."
336 :group 'gnus-article-emphasis)
338 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
339 "Face used for displaying underlined bold emphasized text (_*word*_)."
340 :group 'gnus-article-emphasis)
342 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
343 "Face used for displaying underlined italic emphasized text (_/word/_)."
344 :group 'gnus-article-emphasis)
346 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
347 "Face used for displaying bold italic emphasized text (/*word*/)."
348 :group 'gnus-article-emphasis)
350 (defface gnus-emphasis-underline-bold-italic
351 '((t (:bold t :italic t :underline t)))
352 "Face used for displaying underlined bold italic emphasized text.
353 Esample: (_/*word*/_)."
354 :group 'gnus-article-emphasis)
356 (defface gnus-emphasis-highlight-words
357 '((t (:background "black" :foreground "yellow")))
358 "Face used for displaying highlighted words."
359 :group 'gnus-article-emphasis)
361 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
362 "Format for display of Date headers in article bodies.
363 See `format-time-string' for the possible values.
365 The variable can also be function, which should return a complete Date
366 header. The function is called with one argument, the time, which can
367 be fed to `format-time-string'."
368 :type '(choice string symbol)
369 :link '(custom-manual "(gnus)Article Date")
370 :group 'gnus-article-washing)
373 (autoload 'mail-extract-address-components "mail-extr"))
375 (defcustom gnus-save-all-headers t
376 "*If non-nil, don't remove any headers before saving."
377 :group 'gnus-article-saving
380 (defcustom gnus-prompt-before-saving 'always
381 "*This variable says how much prompting is to be done when saving articles.
382 If it is nil, no prompting will be done, and the articles will be
383 saved to the default files. If this variable is `always', each and
384 every article that is saved will be preceded by a prompt, even when
385 saving large batches of articles. If this variable is neither nil not
386 `always', there the user will be prompted once for a file name for
387 each invocation of the saving commands."
388 :group 'gnus-article-saving
389 :type '(choice (item always)
390 (item :tag "never" nil)
391 (sexp :tag "once" :format "%t\n" :value t)))
393 (defcustom gnus-saved-headers gnus-visible-headers
394 "Headers to keep if `gnus-save-all-headers' is nil.
395 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
396 If that variable is nil, however, all headers that match this regexp
397 will be kept while the rest will be deleted before saving."
398 :group 'gnus-article-saving
401 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
402 "A function to save articles in your favourite format.
403 The function must be interactively callable (in other words, it must
404 be an Emacs command).
406 Gnus provides the following functions:
408 * gnus-summary-save-in-rmail (Rmail format)
409 * gnus-summary-save-in-mail (Unix mail format)
410 * gnus-summary-save-in-folder (MH folder)
411 * gnus-summary-save-in-file (article format)
412 * gnus-summary-save-body-in-file (article body)
413 * gnus-summary-save-in-vm (use VM's folder format)
414 * gnus-summary-write-to-file (article format -- overwrite)."
415 :group 'gnus-article-saving
416 :type '(radio (function-item gnus-summary-save-in-rmail)
417 (function-item gnus-summary-save-in-mail)
418 (function-item gnus-summary-save-in-folder)
419 (function-item gnus-summary-save-in-file)
420 (function-item gnus-summary-save-body-in-file)
421 (function-item gnus-summary-save-in-vm)
422 (function-item gnus-summary-write-to-file)))
424 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
425 "A function generating a file name to save articles in Rmail format.
426 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
427 :group 'gnus-article-saving
430 (defcustom gnus-mail-save-name 'gnus-plain-save-name
431 "A function generating a file name to save articles in Unix mail format.
432 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
433 :group 'gnus-article-saving
436 (defcustom gnus-folder-save-name 'gnus-folder-save-name
437 "A function generating a file name to save articles in MH folder.
438 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
439 :group 'gnus-article-saving
442 (defcustom gnus-file-save-name 'gnus-numeric-save-name
443 "A function generating a file name to save articles in article format.
444 The function is called with NEWSGROUP, HEADERS, and optional
446 :group 'gnus-article-saving
449 (defcustom gnus-split-methods
450 '((gnus-article-archive-name)
451 (gnus-article-nndoc-name))
452 "*Variable used to suggest where articles are to be saved.
453 For instance, if you would like to save articles related to Gnus in
454 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
455 you could set this variable to something like:
457 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
458 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
460 This variable is an alist where the where the key is the match and the
461 value is a list of possible files to save in if the match is non-nil.
463 If the match is a string, it is used as a regexp match on the
464 article. If the match is a symbol, that symbol will be funcalled
465 from the buffer of the article to be saved with the newsgroup as the
466 parameter. If it is a list, it will be evaled in the same buffer.
468 If this form or function returns a string, this string will be used as
469 a possible file name; and if it returns a non-nil list, that list will
470 be used as possible file names."
471 :group 'gnus-article-saving
472 :type '(repeat (choice (list :value (fun) function)
473 (cons :value ("" "") regexp (repeat string))
476 (defcustom gnus-page-delimiter "^\^L"
477 "*Regexp describing what to use as article page delimiters.
478 The default value is \"^\^L\", which is a form linefeed at the
479 beginning of a line."
481 :group 'gnus-article-various)
483 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
484 "*The format specification for the article mode line.
485 See `gnus-summary-mode-line-format' for a closer description.
487 The following additional specs are available:
489 %w The article washing status.
490 %m The number of MIME parts in the article."
492 :group 'gnus-article-various)
494 (defcustom gnus-article-mode-hook nil
495 "*A hook for Gnus article mode."
497 :group 'gnus-article-various)
499 (when (featurep 'xemacs)
500 ;; Extracted from gnus-xmas-define in order to preserve user settings
501 (when (fboundp 'turn-off-scroll-in-place)
502 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
503 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
504 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
506 (defcustom gnus-article-menu-hook nil
507 "*Hook run after the creation of the article mode menu."
509 :group 'gnus-article-various)
511 (defcustom gnus-article-prepare-hook nil
512 "*A hook called after an article has been prepared in the article buffer."
514 :group 'gnus-article-various)
516 (defcustom gnus-article-hide-pgp-hook nil
517 "*A hook called after successfully hiding a PGP signature."
519 :group 'gnus-article-various)
521 (defcustom gnus-article-button-face 'bold
522 "Face used for highlighting buttons in the article buffer.
524 An article button is a piece of text that you can activate by pressing
525 `RET' or `mouse-2' above it."
527 :group 'gnus-article-buttons)
529 (defcustom gnus-article-mouse-face 'highlight
530 "Face used for mouse highlighting in the article buffer.
532 Article buttons will be displayed in this face when the cursor is
535 :group 'gnus-article-buttons)
537 (defcustom gnus-signature-face 'gnus-signature-face
538 "Face used for highlighting a signature in the article buffer.
539 Obsolete; use the face `gnus-signature-face' for customizations instead."
541 :group 'gnus-article-highlight
542 :group 'gnus-article-signature)
544 (defface gnus-signature-face
547 "Face used for highlighting a signature in the article buffer."
548 :group 'gnus-article-highlight
549 :group 'gnus-article-signature)
551 (defface gnus-header-from-face
554 (:foreground "spring green"))
557 (:foreground "red3"))
560 "Face used for displaying from headers."
561 :group 'gnus-article-headers
562 :group 'gnus-article-highlight)
564 (defface gnus-header-subject-face
567 (:foreground "SeaGreen3"))
570 (:foreground "red4"))
572 (:bold t :italic t)))
573 "Face used for displaying subject headers."
574 :group 'gnus-article-headers
575 :group 'gnus-article-highlight)
577 (defface gnus-header-newsgroups-face
580 (:foreground "yellow" :italic t))
583 (:foreground "MidnightBlue" :italic t))
586 "Face used for displaying newsgroups headers."
587 :group 'gnus-article-headers
588 :group 'gnus-article-highlight)
590 (defface gnus-header-name-face
593 (:foreground "SeaGreen"))
596 (:foreground "maroon"))
599 "Face used for displaying header names."
600 :group 'gnus-article-headers
601 :group 'gnus-article-highlight)
603 (defface gnus-header-content-face
606 (:foreground "forest green" :italic t))
609 (:foreground "indianred4" :italic t))
611 (:italic t))) "Face used for displaying header content."
612 :group 'gnus-article-headers
613 :group 'gnus-article-highlight)
615 (defcustom gnus-header-face-alist
616 '(("From" nil gnus-header-from-face)
617 ("Subject" nil gnus-header-subject-face)
618 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
619 ("" gnus-header-name-face gnus-header-content-face))
620 "*Controls highlighting of article header.
622 An alist of the form (HEADER NAME CONTENT).
624 HEADER is a regular expression which should match the name of an
625 header header and NAME and CONTENT are either face names or nil.
627 The name of each header field will be displayed using the face
628 specified by the first element in the list where HEADER match the
629 header name and NAME is non-nil. Similarly, the content will be
630 displayed by the first non-nil matching CONTENT face."
631 :group 'gnus-article-headers
632 :group 'gnus-article-highlight
633 :type '(repeat (list (regexp :tag "Header")
635 (item :tag "skip" nil)
636 (face :value default))
637 (choice :tag "Content"
638 (item :tag "skip" nil)
639 (face :value default)))))
641 (defcustom gnus-article-decode-hook
642 '(article-decode-charset article-decode-encoded-words
643 article-decode-group-name)
644 "*Hook run to decode charsets in articles."
645 :group 'gnus-article-headers
648 (defcustom gnus-display-mime-function 'gnus-display-mime
649 "Function to display MIME articles."
650 :group 'gnus-article-mime
653 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
654 "Function used to decode headers.")
656 (defvar gnus-article-dumbquotes-map
675 "Table for MS-to-Latin1 translation.")
677 (defcustom gnus-ignored-mime-types nil
678 "List of MIME types that should be ignored by Gnus."
680 :group 'gnus-article-mime
681 :type '(repeat regexp))
683 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
684 "List of MIME types that should not be given buttons when rendered inline.
685 See also `gnus-buttonized-mime-types' which may override this variable."
687 :group 'gnus-article-mime
688 :type '(repeat regexp))
690 (defcustom gnus-buttonized-mime-types nil
691 "List of MIME types that should be given buttons when rendered inline.
692 If set, this variable overrides `gnus-unbuttonized-mime-types'.
693 To see e.g. security buttons you could set this to
694 `(\"multipart/signed\")'."
696 :group 'gnus-article-mime
697 :type '(repeat regexp))
699 (defcustom gnus-body-boundary-delimiter "_"
700 "String used to delimit header and body.
701 This variable is used by `gnus-article-treat-body-boundary' which can
702 be controlled by `gnus-treat-body-boundary'."
703 :group 'gnus-article-various
704 :type '(choice (item :tag "None" :value nil)
707 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
708 "*Defines the location of the faces database.
709 For information on obtaining this database of pretty pictures, please
710 see http://www.cs.indiana.edu/picons/ftp/index.html"
714 (defun gnus-picons-installed-p ()
715 "Say whether picons are installed on your machine."
716 (let ((installed nil))
717 (dolist (database gnus-picon-databases)
718 (when (file-exists-p database)
722 (defcustom gnus-article-mime-part-function nil
723 "Function called with a MIME handle as the argument.
724 This is meant for people who want to do something automatic based
725 on parts -- for instance, adding Vcard info to a database."
726 :group 'gnus-article-mime
729 (defcustom gnus-mime-multipart-functions nil
730 "An alist of MIME types to functions to display them."
732 :group 'gnus-article-mime
735 (defcustom gnus-article-date-lapsed-new-header nil
736 "Whether the X-Sent and Date headers can coexist.
737 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
738 either replace the old \"Date:\" header (if this variable is nil), or
739 be added below it (otherwise)."
741 :group 'gnus-article-headers
744 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
745 "Function called with a MIME handle as the argument.
746 This is meant for people who want to view first matched part.
747 For `undisplayed-alternative' (default), the first undisplayed
748 part or alternative part is used. For `undisplayed', the first
749 undisplayed part is used. For a function, the first part which
750 the function return `t' is used. For `nil', the first part is
753 :group 'gnus-article-mime
755 (item :tag "first" :value nil)
756 (item :tag "undisplayed" :value undisplayed)
757 (item :tag "undisplayed or alternative"
758 :value undisplayed-alternative)
761 (defcustom gnus-mime-action-alist
762 '(("save to file" . gnus-mime-save-part)
763 ("save and strip" . gnus-mime-save-part-and-strip)
764 ("display as text" . gnus-mime-inline-part)
765 ("view the part" . gnus-mime-view-part)
766 ("pipe to command" . gnus-mime-pipe-part)
767 ("toggle display" . gnus-article-press-button)
768 ("toggle display" . gnus-article-view-part-as-charset)
769 ("view as type" . gnus-mime-view-part-as-type)
770 ("internalize type" . gnus-mime-internalize-part)
771 ("externalize type" . gnus-mime-externalize-part))
772 "An alist of actions that run on the MIME attachment."
773 :group 'gnus-article-mime
774 :type '(repeat (cons (string :tag "name")
777 (defcustom gnus-mime-action-alist
778 '(("save to file" . gnus-mime-save-part)
779 ("display as text" . gnus-mime-inline-part)
780 ("view the part" . gnus-mime-view-part)
781 ("pipe to command" . gnus-mime-pipe-part)
782 ("toggle display" . gnus-article-press-button)
783 ("view as type" . gnus-mime-view-part-as-type)
784 ("internalize type" . gnus-mime-internalize-part)
785 ("externalize type" . gnus-mime-externalize-part))
786 "An alist of actions that run on the MIME attachment."
788 :group 'gnus-article-mime
789 :type '(repeat (cons (string :tag "name")
793 ;;; The treatment variables
796 (defvar gnus-part-display-hook nil
797 "Hook called on parts that are to receive treatment.")
799 (defvar gnus-article-treat-custom
800 '(choice (const :tag "Off" nil)
802 (const :tag "Header" head)
803 (const :tag "Last" last)
804 (integer :tag "Less")
805 (repeat :tag "Groups" regexp)
806 (sexp :tag "Predicate")))
808 (defvar gnus-article-treat-head-custom
809 '(choice (const :tag "Off" nil)
810 (const :tag "Header" head)))
812 (defvar gnus-article-treat-types '("text/plain")
815 (defvar gnus-inhibit-treatment nil
816 "Whether to inhibit treatment.")
818 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
819 "Highlight the signature.
820 Valid values are nil, t, `head', `last', an integer or a predicate.
821 See Info node `(gnus)Customizing Articles'."
822 :group 'gnus-article-treat
823 :type gnus-article-treat-custom)
824 (put 'gnus-treat-highlight-signature 'highlight t)
826 (defcustom gnus-treat-buttonize 100000
828 Valid values are nil, t, `head', `last', an integer or a predicate.
829 See Info node `(gnus)Customizing Articles'."
830 :group 'gnus-article-treat
831 :type gnus-article-treat-custom)
832 (put 'gnus-treat-buttonize 'highlight t)
834 (defcustom gnus-treat-buttonize-head 'head
835 "Add buttons to the head.
836 Valid values are nil, t, `head', `last', an integer or a predicate.
837 See Info node `(gnus)Customizing Articles' for details."
838 :group 'gnus-article-treat
839 :type gnus-article-treat-head-custom)
840 (put 'gnus-treat-buttonize-head 'highlight t)
842 (defcustom gnus-treat-emphasize
843 (and (or window-system
845 (>= (string-to-number emacs-version) 21))
848 Valid values are nil, t, `head', `last', an integer or a predicate.
849 See Info node `(gnus)Customizing Articles' for details."
850 :group 'gnus-article-treat
851 :type gnus-article-treat-custom)
852 (put 'gnus-treat-emphasize 'highlight t)
854 (defcustom gnus-treat-strip-cr nil
855 "Remove carriage returns.
856 Valid values are nil, t, `head', `last', an integer or a predicate.
857 See Info node `(gnus)Customizing Articles' for details."
858 :group 'gnus-article-treat
859 :type gnus-article-treat-custom)
861 (defcustom gnus-treat-leading-whitespace nil
862 "Remove leading whitespace in headers.
863 Valid values are nil, t, `head', `last', an integer or a predicate.
864 See Info node `(gnus)Customizing Articles' for details."
865 :group 'gnus-article-treat
866 :type gnus-article-treat-custom)
868 (defcustom gnus-treat-hide-headers 'head
870 Valid values are nil, t, `head', `last', an integer or a predicate.
871 See Info node `(gnus)Customizing Articles' for details."
872 :group 'gnus-article-treat
873 :type gnus-article-treat-head-custom)
875 (defcustom gnus-treat-hide-boring-headers nil
876 "Hide boring headers.
877 Valid values are nil, t, `head', `last', an integer or a predicate.
878 See Info node `(gnus)Customizing Articles' for details."
879 :group 'gnus-article-treat
880 :type gnus-article-treat-head-custom)
882 (defcustom gnus-treat-hide-signature nil
884 Valid values are nil, t, `head', `last', an integer or a predicate.
885 See Info node `(gnus)Customizing Articles' for details."
886 :group 'gnus-article-treat
887 :type gnus-article-treat-custom)
889 (defcustom gnus-treat-fill-article nil
891 Valid values are nil, t, `head', `last', an integer or a predicate.
892 See Info node `(gnus)Customizing Articles' for details."
893 :group 'gnus-article-treat
894 :type gnus-article-treat-custom)
896 (defcustom gnus-treat-hide-citation nil
898 Valid values are nil, t, `head', `last', an integer or a predicate.
899 See Info node `(gnus)Customizing Articles' for details."
900 :group 'gnus-article-treat
901 :type gnus-article-treat-custom)
903 (defcustom gnus-treat-hide-citation-maybe nil
905 Valid values are nil, t, `head', `last', an integer or a predicate.
906 See Info node `(gnus)Customizing Articles' for details."
907 :group 'gnus-article-treat
908 :type gnus-article-treat-custom)
910 (defcustom gnus-treat-strip-list-identifiers 'head
911 "Strip list identifiers from `gnus-list-identifiers`.
912 Valid values are nil, t, `head', `last', an integer or a predicate.
913 See Info node `(gnus)Customizing Articles' for details."
915 :group 'gnus-article-treat
916 :type gnus-article-treat-custom)
918 (defcustom gnus-treat-strip-pgp t
919 "Strip PGP signatures.
920 Valid values are nil, t, `head', `last', an integer or a predicate.
921 See Info node `(gnus)Customizing Articles' for details."
922 :group 'gnus-article-treat
923 :type gnus-article-treat-custom)
925 (defcustom gnus-treat-strip-pem nil
926 "Strip PEM signatures.
927 Valid values are nil, t, `head', `last', an integer or a predicate.
928 See Info node `(gnus)Customizing Articles' for details."
929 :group 'gnus-article-treat
930 :type gnus-article-treat-custom)
932 (defcustom gnus-treat-strip-banner t
933 "Strip banners from articles.
934 The banner to be stripped is specified in the `banner' group parameter.
935 Valid values are nil, t, `head', `last', an integer or a predicate.
936 See Info node `(gnus)Customizing Articles' for details."
937 :group 'gnus-article-treat
938 :type gnus-article-treat-custom)
940 (defcustom gnus-treat-highlight-headers 'head
941 "Highlight the headers.
942 Valid values are nil, t, `head', `last', an integer or a predicate.
943 See Info node `(gnus)Customizing Articles' for details."
944 :group 'gnus-article-treat
945 :type gnus-article-treat-head-custom)
946 (put 'gnus-treat-highlight-headers 'highlight t)
948 (defcustom gnus-treat-highlight-citation t
949 "Highlight cited text.
950 Valid values are nil, t, `head', `last', an integer or a predicate.
951 See Info node `(gnus)Customizing Articles' for details."
952 :group 'gnus-article-treat
953 :type gnus-article-treat-custom)
954 (put 'gnus-treat-highlight-citation 'highlight t)
956 (defcustom gnus-treat-date-ut nil
957 "Display the Date in UT (GMT).
958 Valid values are nil, t, `head', `last', an integer or a predicate.
959 See Info node `(gnus)Customizing Articles' for details."
960 :group 'gnus-article-treat
961 :type gnus-article-treat-head-custom)
963 (defcustom gnus-treat-date-local nil
964 "Display the Date in the local timezone.
965 Valid values are nil, t, `head', `last', an integer or a predicate.
966 See Info node `(gnus)Customizing Articles' for details."
967 :group 'gnus-article-treat
968 :type gnus-article-treat-head-custom)
970 (defcustom gnus-treat-date-english nil
971 "Display the Date in a format that can be read aloud in English.
972 Valid values are nil, t, `head', `last', an integer or a predicate.
973 See Info node `(gnus)Customizing Articles' for details."
974 :group 'gnus-article-treat
975 :type gnus-article-treat-head-custom)
977 (defcustom gnus-treat-date-lapsed nil
978 "Display the Date header in a way that says how much time has elapsed.
979 Valid values are nil, t, `head', `last', an integer or a predicate.
980 See Info node `(gnus)Customizing Articles' for details."
981 :group 'gnus-article-treat
982 :type gnus-article-treat-head-custom)
984 (defcustom gnus-treat-date-original nil
985 "Display the date in the original timezone.
986 Valid values are nil, t, `head', `last', an integer or a predicate.
987 See Info node `(gnus)Customizing Articles' for details."
988 :group 'gnus-article-treat
989 :type gnus-article-treat-head-custom)
991 (defcustom gnus-treat-date-iso8601 nil
992 "Display the date in the ISO8601 format.
993 Valid values are nil, t, `head', `last', an integer or a predicate.
994 See Info node `(gnus)Customizing Articles' for details."
996 :group 'gnus-article-treat
997 :type gnus-article-treat-head-custom)
999 (defcustom gnus-treat-date-user-defined nil
1000 "Display the date in a user-defined format.
1001 The format is defined by the `gnus-article-time-format' variable.
1002 Valid values are nil, t, `head', `last', an integer or a predicate.
1003 See Info node `(gnus)Customizing Articles' for details."
1004 :group 'gnus-article-treat
1005 :type gnus-article-treat-head-custom)
1007 (defcustom gnus-treat-strip-headers-in-body t
1008 "Strip the X-No-Archive header line from the beginning of the body.
1009 Valid values are nil, t, `head', `last', an integer or a predicate.
1010 See Info node `(gnus)Customizing Articles' for details."
1012 :group 'gnus-article-treat
1013 :type gnus-article-treat-custom)
1015 (defcustom gnus-treat-strip-trailing-blank-lines nil
1016 "Strip trailing blank lines.
1017 Valid values are nil, t, `head', `last', an integer or a predicate.
1018 See Info node `(gnus)Customizing Articles' for details."
1019 :group 'gnus-article-treat
1020 :type gnus-article-treat-custom)
1022 (defcustom gnus-treat-strip-leading-blank-lines nil
1023 "Strip leading blank lines.
1024 Valid values are nil, t, `head', `last', an integer or a predicate.
1025 See Info node `(gnus)Customizing Articles' for details."
1026 :group 'gnus-article-treat
1027 :type gnus-article-treat-custom)
1029 (defcustom gnus-treat-strip-multiple-blank-lines nil
1030 "Strip multiple blank lines.
1031 Valid values are nil, t, `head', `last', an integer or a predicate.
1032 See Info node `(gnus)Customizing Articles' for details."
1033 :group 'gnus-article-treat
1034 :type gnus-article-treat-custom)
1036 (defcustom gnus-treat-unfold-headers 'head
1037 "Unfold folded header lines.
1038 Valid values are nil, t, `head', `last', an integer or a predicate.
1039 See Info node `(gnus)Customizing Articles' for details."
1040 :group 'gnus-article-treat
1041 :type gnus-article-treat-custom)
1043 (defcustom gnus-treat-fold-headers nil
1045 Valid values are nil, t, `head', `last', an integer or a predicate.
1046 See Info node `(gnus)Customizing Articles' for details."
1047 :group 'gnus-article-treat
1048 :type gnus-article-treat-custom)
1050 (defcustom gnus-treat-fold-newsgroups 'head
1051 "Fold the Newsgroups and Followup-To headers.
1052 Valid values are nil, t, `head', `last', an integer or a predicate.
1053 See Info node `(gnus)Customizing Articles' for details."
1054 :group 'gnus-article-treat
1055 :type gnus-article-treat-custom)
1057 (defcustom gnus-treat-overstrike t
1058 "Treat overstrike highlighting.
1059 Valid values are nil, t, `head', `last', an integer or a predicate.
1060 See Info node `(gnus)Customizing Articles' for details."
1061 :group 'gnus-article-treat
1062 :type gnus-article-treat-custom)
1063 (put 'gnus-treat-overstrike 'highlight t)
1065 (defcustom gnus-treat-display-xface
1066 (and (or (and (fboundp 'image-type-available-p)
1067 (image-type-available-p 'xbm)
1068 (string-match "^0x" (shell-command-to-string "uncompface")))
1069 (and (featurep 'xemacs)
1072 "Display X-Face headers.
1073 Valid values are nil, t, `head', `last', an integer or a predicate.
1074 See Info node `(gnus)Customizing Articles' and Info node
1075 `(gnus)X-Face' for details."
1076 :group 'gnus-article-treat
1078 :type gnus-article-treat-head-custom)
1079 (put 'gnus-treat-display-xface 'highlight t)
1081 (defcustom gnus-treat-display-smileys
1082 (if (or (and (featurep 'xemacs)
1084 (and (fboundp 'image-type-available-p)
1085 (image-type-available-p 'pbm)))
1088 Valid values are nil, t, `head', `last', an integer or a predicate.
1089 See Info node `(gnus)Customizing Articles' and Info node
1090 `(gnus)Smileys' for details."
1091 :group 'gnus-article-treat
1093 :type gnus-article-treat-custom)
1094 (put 'gnus-treat-display-smileys 'highlight t)
1096 (defcustom gnus-treat-from-picon
1097 (if (and (gnus-image-type-available-p 'xpm)
1098 (gnus-picons-installed-p))
1100 "Display picons in the From header.
1101 Valid values are nil, t, `head', `last', an integer or a predicate.
1102 See Info node `(gnus)Customizing Articles' and Info node
1103 `(gnus)Picons' for details."
1104 :group 'gnus-article-treat
1105 :type gnus-article-treat-head-custom)
1106 (put 'gnus-treat-from-picon 'highlight t)
1108 (defcustom gnus-treat-mail-picon
1109 (if (and (gnus-image-type-available-p 'xpm)
1110 (gnus-picons-installed-p))
1112 "Display picons in To and Cc headers.
1113 Valid values are nil, t, `head', `last', an integer or a predicate.
1114 See Info node `(gnus)Customizing Articles' and Info node
1115 `(gnus)Picons' for details."
1116 :group 'gnus-article-treat
1117 :type gnus-article-treat-head-custom)
1118 (put 'gnus-treat-mail-picon 'highlight t)
1120 (defcustom gnus-treat-newsgroups-picon
1121 (if (and (gnus-image-type-available-p 'xpm)
1122 (gnus-picons-installed-p))
1124 "Display picons in the Newsgroups and Followup-To headers.
1125 Valid values are nil, t, `head', `last', an integer or a predicate.
1126 See Info node `(gnus)Customizing Articles' and Info node
1127 `(gnus)Picons' for details."
1128 :group 'gnus-article-treat
1129 :type gnus-article-treat-head-custom)
1130 (put 'gnus-treat-newsgroups-picon 'highlight t)
1132 (defcustom gnus-treat-body-boundary
1133 (if (or gnus-treat-newsgroups-picon
1134 gnus-treat-mail-picon
1135 gnus-treat-from-picon)
1137 "Draw a boundary at the end of the headers.
1138 Valid values are nil, t, `head', `last', an integer or a predicate.
1139 See Info node `(gnus)Customizing Articles' for details."
1141 :group 'gnus-article-treat
1142 :type gnus-article-treat-custom)
1144 (defcustom gnus-treat-capitalize-sentences nil
1145 "Capitalize sentence-starting words.
1146 Valid values are nil, t, `head', `last', an integer or a predicate.
1147 See Info node `(gnus)Customizing Articles' for details."
1149 :group 'gnus-article-treat
1150 :type gnus-article-treat-custom)
1152 (defcustom gnus-treat-fill-long-lines nil
1154 Valid values are nil, t, `head', `last', an integer or a predicate.
1155 See Info node `(gnus)Customizing Articles' for details."
1156 :group 'gnus-article-treat
1157 :type gnus-article-treat-custom)
1159 (defcustom gnus-treat-play-sounds nil
1161 Valid values are nil, t, `head', `last', an integer or a predicate.
1162 See Info node `(gnus)Customizing Articles' for details."
1164 :group 'gnus-article-treat
1165 :type gnus-article-treat-custom)
1167 (defcustom gnus-treat-translate nil
1168 "Translate articles from one language to another.
1169 Valid values are nil, t, `head', `last', an integer or a predicate.
1170 See Info node `(gnus)Customizing Articles' for details."
1172 :group 'gnus-article-treat
1173 :type gnus-article-treat-custom)
1175 (defcustom gnus-treat-x-pgp-sig nil
1177 To automatically treat X-PGP-Sig, set it to head.
1178 Valid values are nil, t, `head', `last', an integer or a predicate.
1179 See Info node `(gnus)Customizing Articles' for details."
1180 :group 'gnus-article-treat
1181 :group 'mime-security
1182 :type gnus-article-treat-custom)
1184 (defvar gnus-article-encrypt-protocol-alist
1185 '(("PGP" . mml2015-self-encrypt)))
1187 ;; Set to nil if more than one protocol added to
1188 ;; gnus-article-encrypt-protocol-alist.
1189 (defcustom gnus-article-encrypt-protocol "PGP"
1190 "The protocol used for encrypt articles.
1191 It is a string, such as \"PGP\". If nil, ask user."
1193 :group 'mime-security)
1195 ;;; Internal variables
1197 (defvar gnus-english-month-names
1198 '("January" "February" "March" "April" "May" "June" "July" "August"
1199 "September" "October" "November" "December"))
1201 (defvar article-goto-body-goes-to-point-min-p nil)
1202 (defvar gnus-article-wash-types nil)
1203 (defvar gnus-article-emphasis-alist nil)
1204 (defvar gnus-article-image-alist nil)
1206 (defvar gnus-article-mime-handle-alist-1 nil)
1207 (defvar gnus-treatment-function-alist
1208 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1209 (gnus-treat-strip-banner gnus-article-strip-banner)
1210 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1211 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1212 (gnus-treat-buttonize gnus-article-add-buttons)
1213 (gnus-treat-fill-article gnus-article-fill-cited-article)
1214 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1215 (gnus-treat-strip-cr gnus-article-remove-cr)
1216 (gnus-treat-date-ut gnus-article-date-ut)
1217 (gnus-treat-date-local gnus-article-date-local)
1218 (gnus-treat-date-english gnus-article-date-english)
1219 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1220 (gnus-treat-date-original gnus-article-date-original)
1221 (gnus-treat-date-user-defined gnus-article-date-user)
1222 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1223 (gnus-treat-display-xface gnus-article-display-x-face)
1224 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1225 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1226 (gnus-treat-hide-signature gnus-article-hide-signature)
1227 (gnus-treat-hide-citation gnus-article-hide-citation)
1228 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1229 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1230 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1231 (gnus-treat-strip-pgp gnus-article-hide-pgp)
1232 (gnus-treat-strip-pem gnus-article-hide-pem)
1233 (gnus-treat-from-picon gnus-treat-from-picon)
1234 (gnus-treat-mail-picon gnus-treat-mail-picon)
1235 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1236 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1237 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1238 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1239 (gnus-treat-strip-trailing-blank-lines
1240 gnus-article-remove-trailing-blank-lines)
1241 (gnus-treat-strip-leading-blank-lines
1242 gnus-article-strip-leading-blank-lines)
1243 (gnus-treat-strip-multiple-blank-lines
1244 gnus-article-strip-multiple-blank-lines)
1245 (gnus-treat-overstrike gnus-article-treat-overstrike)
1246 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1247 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1248 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1249 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1250 (gnus-treat-display-smileys gnus-treat-smiley)
1251 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1252 (gnus-treat-emphasize gnus-article-emphasize)
1253 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1254 (gnus-treat-play-sounds gnus-earcon-display)))
1256 (defvar gnus-article-mime-handle-alist nil)
1257 (defvar article-lapsed-timer nil)
1258 (defvar gnus-article-current-summary nil)
1260 (defvar gnus-article-mode-syntax-table
1261 (let ((table (copy-syntax-table text-mode-syntax-table)))
1262 ;; This causes the citation match run O(2^n).
1263 ;; (modify-syntax-entry ?- "w" table)
1264 (modify-syntax-entry ?> ")" table)
1265 (modify-syntax-entry ?< "(" table)
1267 "Syntax table used in article mode buffers.
1268 Initialized from `text-mode-syntax-table.")
1270 (defvar gnus-save-article-buffer nil)
1272 (defvar gnus-article-mode-line-format-alist
1273 (nconc '((?w (gnus-article-wash-status) ?s)
1274 (?m (gnus-article-mime-part-status) ?s))
1275 gnus-summary-mode-line-format-alist))
1277 (defvar gnus-number-of-articles-to-be-saved nil)
1279 (defvar gnus-inhibit-hiding nil)
1281 ;;; Macros for dealing with the article buffer.
1283 (defmacro gnus-with-article-headers (&rest forms)
1285 (set-buffer gnus-article-buffer)
1287 (let ((buffer-read-only nil)
1288 (inhibit-point-motion-hooks t)
1289 (case-fold-search t))
1290 (article-narrow-to-head)
1293 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1294 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1296 (defmacro gnus-with-article-buffer (&rest forms)
1298 (set-buffer gnus-article-buffer)
1299 (let ((buffer-read-only nil))
1302 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1303 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1305 (defun gnus-article-goto-header (header)
1306 "Go to HEADER, which is a regular expression."
1307 (re-search-forward (concat "^\\(" header "\\):") nil t))
1309 (defsubst gnus-article-hide-text (b e props)
1310 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1311 (gnus-add-text-properties-when 'article-type nil b e props)
1312 (when (memq 'intangible props)
1314 (max (1- b) (point-min))
1315 b 'intangible (cddr (memq 'intangible props)))))
1317 (defsubst gnus-article-unhide-text (b e)
1318 "Remove hidden text properties from region between B and E."
1319 (remove-text-properties b e gnus-hidden-properties)
1320 (when (memq 'intangible gnus-hidden-properties)
1321 (put-text-property (max (1- b) (point-min))
1322 b 'intangible nil)))
1324 (defun gnus-article-hide-text-type (b e type)
1325 "Hide text of TYPE between B and E."
1326 (gnus-add-wash-type type)
1327 (gnus-article-hide-text
1328 b e (cons 'article-type (cons type gnus-hidden-properties))))
1330 (defun gnus-article-unhide-text-type (b e type)
1331 "Unhide text of TYPE between B and E."
1332 (gnus-delete-wash-type type)
1333 (remove-text-properties
1334 b e (cons 'article-type (cons type gnus-hidden-properties)))
1335 (when (memq 'intangible gnus-hidden-properties)
1336 (put-text-property (max (1- b) (point-min))
1337 b 'intangible nil)))
1339 (defun gnus-article-hide-text-of-type (type)
1340 "Hide text of TYPE in the current buffer."
1342 (let ((b (point-min))
1344 (while (setq b (text-property-any b e 'article-type type))
1345 (add-text-properties b (incf b) gnus-hidden-properties)))))
1347 (defun gnus-article-delete-text-of-type (type)
1348 "Delete text of TYPE in the current buffer."
1350 (let ((b (point-min)))
1351 (while (setq b (text-property-any b (point-max) 'article-type type))
1353 b (or (text-property-not-all b (point-max) 'article-type type)
1356 (defun gnus-article-delete-invisible-text ()
1357 "Delete all invisible text in the current buffer."
1359 (let ((b (point-min)))
1360 (while (setq b (text-property-any b (point-max) 'invisible t))
1362 b (or (text-property-not-all b (point-max) 'invisible t)
1365 (defun gnus-article-text-type-exists-p (type)
1366 "Say whether any text of type TYPE exists in the buffer."
1367 (text-property-any (point-min) (point-max) 'article-type type))
1369 (defsubst gnus-article-header-rank ()
1370 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1371 (let ((list gnus-sorted-header-list)
1374 (when (looking-at (car list))
1376 (setq list (cdr list))
1380 (defun article-hide-headers (&optional arg delete)
1381 "Hide unwanted headers and possibly sort them as well."
1383 ;; This function might be inhibited.
1384 (unless gnus-inhibit-hiding
1387 (let ((buffer-read-only nil)
1388 (case-fold-search t)
1389 (max (1+ (length gnus-sorted-header-list)))
1390 (ignored (when (not gnus-visible-headers)
1391 (cond ((stringp gnus-ignored-headers)
1392 gnus-ignored-headers)
1393 ((listp gnus-ignored-headers)
1394 (mapconcat 'identity gnus-ignored-headers
1397 (cond ((stringp gnus-visible-headers)
1398 gnus-visible-headers)
1399 ((and gnus-visible-headers
1400 (listp gnus-visible-headers))
1401 (mapconcat 'identity gnus-visible-headers "\\|"))))
1402 (inhibit-point-motion-hooks t)
1404 ;; First we narrow to just the headers.
1405 (article-narrow-to-head)
1406 ;; Hide any "From " lines at the beginning of (mail) articles.
1407 (while (looking-at "From ")
1410 (delete-region (point-min) (point)))
1411 ;; Then treat the rest of the header lines.
1412 ;; Then we use the two regular expressions
1413 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1414 ;; select which header lines is to remain visible in the
1416 (while (re-search-forward "^[^ \t:]*:" nil t)
1418 ;; Mark the rank of the header.
1420 (point) (1+ (point)) 'message-rank
1421 (if (or (and visible (looking-at visible))
1423 (not (looking-at ignored))))
1424 (gnus-article-header-rank)
1427 (message-sort-headers-1)
1428 (when (setq beg (text-property-any
1429 (point-min) (point-max) 'message-rank (+ 2 max)))
1430 ;; We delete the unwanted headers.
1431 (gnus-add-wash-type 'headers)
1432 (add-text-properties (point-min) (+ 5 (point-min))
1433 '(article-type headers dummy-invisible t))
1434 (delete-region beg (point-max))))))))
1436 (defun article-hide-boring-headers (&optional arg)
1437 "Toggle hiding of headers that aren't very interesting.
1438 If given a negative prefix, always show; if given a positive prefix,
1440 (interactive (gnus-article-hidden-arg))
1441 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1442 (not gnus-show-all-headers))
1445 (let ((buffer-read-only nil)
1446 (list gnus-boring-article-headers)
1447 (inhibit-point-motion-hooks t)
1449 (article-narrow-to-head)
1451 (setq elem (pop list))
1452 (goto-char (point-min))
1454 ;; Hide empty headers.
1456 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1458 (gnus-article-hide-text-type
1459 (progn (beginning-of-line) (point))
1462 (if (re-search-forward "^[^ \t]" nil t)
1466 ;; Hide boring Newsgroups header.
1467 ((eq elem 'newsgroups)
1468 (when (gnus-string-equal
1469 (gnus-fetch-field "newsgroups")
1470 (gnus-group-real-name
1471 (if (boundp 'gnus-newsgroup-name)
1474 (gnus-article-hide-header "newsgroups")))
1475 ((eq elem 'to-address)
1476 (let ((to (message-fetch-field "to"))
1478 (gnus-parameter-to-address
1479 (if (boundp 'gnus-newsgroup-name)
1480 gnus-newsgroup-name ""))))
1481 (when (and to to-address
1484 ;; only one address in To
1485 (nth 1 (mail-extract-address-components to))
1487 (gnus-article-hide-header "to"))))
1488 ((eq elem 'followup-to)
1489 (when (gnus-string-equal
1490 (message-fetch-field "followup-to")
1491 (message-fetch-field "newsgroups"))
1492 (gnus-article-hide-header "followup-to")))
1493 ((eq elem 'reply-to)
1494 (let ((from (message-fetch-field "from"))
1495 (reply-to (message-fetch-field "reply-to")))
1500 (nth 1 (mail-extract-address-components from))
1501 (nth 1 (mail-extract-address-components reply-to)))))
1502 (gnus-article-hide-header "reply-to"))))
1504 (let ((date (message-fetch-field "date")))
1506 (< (days-between (current-time-string) date)
1508 (gnus-article-hide-header "date"))))
1510 (let ((to (message-fetch-field "to"))
1511 (cc (message-fetch-field "cc")))
1512 (when (> (length to) 1024)
1513 (gnus-article-hide-header "to"))
1514 (when (> (length cc) 1024)
1515 (gnus-article-hide-header "cc"))))
1519 (goto-char (point-min))
1520 (while (re-search-forward "^to:" nil t)
1521 (setq to-count (1+ to-count)))
1522 (when (> to-count 1)
1523 (while (> to-count 0)
1524 (goto-char (point-min))
1526 (re-search-forward "^to:" nil nil to-count)
1528 (narrow-to-region (point) (point-max))
1529 (gnus-article-hide-header "to"))
1530 (setq to-count (1- to-count))))
1531 (goto-char (point-min))
1532 (while (re-search-forward "^cc:" nil t)
1533 (setq cc-count (1+ cc-count)))
1534 (when (> cc-count 1)
1535 (while (> cc-count 0)
1536 (goto-char (point-min))
1538 (re-search-forward "^cc:" nil nil cc-count)
1540 (narrow-to-region (point) (point-max))
1541 (gnus-article-hide-header "cc"))
1542 (setq cc-count (1- cc-count)))))))))))))
1544 (defun gnus-article-hide-header (header)
1546 (goto-char (point-min))
1547 (when (re-search-forward (concat "^" header ":") nil t)
1548 (gnus-article-hide-text-type
1549 (progn (beginning-of-line) (point))
1552 (if (re-search-forward "^[^ \t]" nil t)
1557 (defvar gnus-article-normalized-header-length 40
1558 "Length of normalized headers.")
1560 (defun article-normalize-headers ()
1561 "Make all header lines 40 characters long."
1563 (let ((buffer-read-only nil)
1567 (article-narrow-to-head)
1570 ((< (setq column (- (gnus-point-at-eol) (point)))
1571 gnus-article-normalized-header-length)
1573 (insert (make-string
1574 (- gnus-article-normalized-header-length column)
1576 ((> column gnus-article-normalized-header-length)
1577 (gnus-put-text-property
1579 (forward-char gnus-article-normalized-header-length)
1586 (forward-line 1))))))
1588 (defun article-treat-dumbquotes ()
1589 "Translate M****s*** sm*rtq**t*s into proper text.
1590 Note that this function guesses whether a character is a sm*rtq**t* or
1591 not, so it should only be used interactively.
1593 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1594 in an attempt to provide more quoting characters. If you see
1595 something like \\222 or \\264 where you're expecting some kind of
1596 apostrophe or quotation mark, then try this wash."
1598 (article-translate-strings gnus-article-dumbquotes-map))
1600 (defun article-translate-characters (from to)
1601 "Translate all characters in the body of the article according to FROM and TO.
1602 FROM is a string of characters to translate from; to is a string of
1603 characters to translate to."
1605 (when (article-goto-body)
1606 (let ((buffer-read-only nil)
1607 (x (make-string 225 ?x))
1609 (while (< (incf i) (length x))
1612 (while (< i (length from))
1613 (aset x (aref from i) (aref to i))
1615 (translate-region (point) (point-max) x)))))
1617 (defun article-translate-strings (map)
1618 "Translate all string in the body of the article according to MAP.
1619 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1621 (when (article-goto-body)
1622 (let ((buffer-read-only nil)
1624 (while (setq elem (pop map))
1626 (while (search-forward (car elem) nil t)
1627 (replace-match (cadr elem)))))))))
1629 (defun article-treat-overstrike ()
1630 "Translate overstrikes into bold text."
1633 (when (article-goto-body)
1634 (let ((buffer-read-only nil))
1635 (while (search-forward "\b" nil t)
1636 (let ((next (char-after))
1637 (previous (char-after (- (point) 2))))
1638 ;; We do the boldification/underlining by hiding the
1639 ;; overstrikes and putting the proper text property
1643 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1644 (put-text-property (point) (1+ (point)) 'face 'bold))
1646 (gnus-article-hide-text-type
1647 (1- (point)) (1+ (point)) 'overstrike)
1649 (- (point) 2) (1- (point)) 'face 'underline))
1651 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1653 (point) (1+ (point)) 'face 'underline)))))))))
1655 (defun gnus-article-treat-unfold-headers ()
1656 "Unfold folded message headers.
1657 Only the headers that fit into the current window width will be
1660 (gnus-with-article-headers
1664 (mail-header-narrow-to-field)
1665 (let ((header (buffer-substring (point-min) (point-max))))
1668 (goto-char (point-min))
1669 (while (re-search-forward "[\t ]*\n[\t ]+" nil t)
1670 (replace-match " " t t)))
1671 (setq length (- (point-max) (point-min) 1)))
1672 (when (< length (window-width))
1673 (while (re-search-forward "[\t ]*\n[\t ]+" nil t)
1674 (replace-match " " t t)))
1675 (goto-char (point-max)))))))
1677 (defun gnus-article-treat-fold-headers ()
1678 "Fold message headers."
1680 (gnus-with-article-headers
1683 (mail-header-narrow-to-field)
1684 (mail-header-fold-field)
1685 (goto-char (point-max))))))
1687 (defun gnus-treat-smiley ()
1688 "Display textual emoticons (\"smileys\") as small graphical icons."
1690 (gnus-with-article-buffer
1691 (if (memq 'smiley gnus-article-wash-types)
1692 (gnus-delete-images 'smiley)
1694 (let ((images (smiley-region (point) (point-max))))
1696 (gnus-add-wash-type 'smiley)
1697 (dolist (image images)
1698 (gnus-add-image 'smiley image)))))))
1700 (defun gnus-article-remove-images ()
1701 "Remove all images from the article buffer."
1703 (gnus-with-article-buffer
1704 (dolist (elem gnus-article-image-alist)
1705 (gnus-delete-images (car elem)))))
1707 (defun gnus-article-treat-fold-newsgroups ()
1708 "Unfold folded message headers.
1709 Only the headers that fit into the current window width will be
1712 (gnus-with-article-headers
1713 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1715 (mail-header-narrow-to-field)
1716 (while (re-search-forward ", *" nil t)
1717 (replace-match ", " t t))
1718 (mail-header-fold-field)
1719 (goto-char (point-max))))))
1721 (defun gnus-article-treat-body-boundary ()
1722 "Place a boundary line at the end of the headers."
1724 (when (and gnus-body-boundary-delimiter
1725 (> (length gnus-body-boundary-delimiter) 0))
1726 (gnus-with-article-headers
1727 (goto-char (point-max))
1728 (let ((start (point)))
1729 (insert "X-Boundary: ")
1730 (gnus-add-text-properties start (point) '(invisible t intangible t))
1732 (while (>= (1- (window-width)) (length str))
1733 (setq str (concat str gnus-body-boundary-delimiter)))
1734 (substring str 0 (1- (window-width))))
1737 (defun article-fill-long-lines ()
1738 "Fill lines that are wider than the window width."
1741 (let ((buffer-read-only nil)
1742 (width (window-width (get-buffer-window (current-buffer)))))
1745 (let ((adaptive-fill-mode nil)) ;Why? -sm
1748 (when (>= (current-column) (min fill-column width))
1749 (narrow-to-region (point) (gnus-point-at-bol))
1750 (fill-paragraph nil)
1751 (goto-char (point-max))
1753 (forward-line 1)))))))
1755 (defun article-capitalize-sentences ()
1756 "Capitalize the first word in each sentence."
1759 (let ((buffer-read-only nil)
1760 (paragraph-start "^[\n\^L]"))
1764 (forward-sentence)))))
1766 (defun article-remove-cr ()
1767 "Remove trailing CRs and then translate remaining CRs into LFs."
1770 (let ((buffer-read-only nil))
1771 (goto-char (point-min))
1772 (while (re-search-forward "\r+$" nil t)
1773 (replace-match "" t t))
1774 (goto-char (point-min))
1775 (while (search-forward "\r" nil t)
1776 (replace-match "\n" t t)))))
1778 (defun article-remove-trailing-blank-lines ()
1779 "Remove all trailing blank lines from the article."
1782 (let ((buffer-read-only nil))
1783 (goto-char (point-max))
1787 (while (and (not (bobp))
1788 (looking-at "^[ \t]*$")
1789 (not (gnus-annotation-in-region-p
1790 (point) (gnus-point-at-eol))))
1795 (defun article-display-x-face (&optional force)
1796 "Look for an X-Face header and display it if present."
1797 (interactive (list 'force))
1798 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
1799 (gnus-with-article-headers
1800 ;; Delete the old process, if any.
1801 (when (process-status "article-x-face")
1802 (delete-process "article-x-face"))
1803 (if (memq 'xface gnus-article-wash-types)
1804 ;; We have already displayed X-Faces, so we remove them
1806 (gnus-delete-images 'xface)
1808 (let (x-faces from face grey)
1810 (when (and wash-face-p
1812 (goto-char (point-min))
1813 (not (re-search-forward
1814 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
1815 (gnus-buffer-live-p gnus-original-article-buffer))
1816 ;; If type `W f', use gnus-original-article-buffer,
1817 ;; otherwise use the current buffer because displaying
1818 ;; RFC822 parts calls this function too.
1819 (set-buffer gnus-original-article-buffer))
1821 (mail-narrow-to-head)
1822 (while (gnus-article-goto-header "x-face\\(-[0-9]+\\)?")
1823 (when (match-beginning 2)
1825 (push (mail-header-field-value) x-faces))
1826 (setq from (message-fetch-field "from"))))
1828 (let ((xpm (gnus-convert-gray-x-face-to-xpm x-faces))
1831 (setq image (gnus-create-image xpm 'xpm t))
1832 (gnus-article-goto-header "from")
1834 (insert "From: [no `from' set]\n")
1836 (gnus-add-wash-type 'xface)
1837 (gnus-add-image 'xface image)
1838 (gnus-put-image image)))
1839 ;; Sending multiple EOFs to xv doesn't work, so we only do a
1840 ;; single external face.
1841 (when (stringp gnus-article-x-face-command)
1842 (setq x-faces (list (car x-faces))))
1843 (while (and (setq face (pop x-faces))
1844 gnus-article-x-face-command
1846 ;; Check whether this face is censored.
1847 (not gnus-article-x-face-too-ugly)
1848 (and gnus-article-x-face-too-ugly from
1849 (not (string-match gnus-article-x-face-too-ugly
1851 ;; We display the face.
1852 (if (symbolp gnus-article-x-face-command)
1853 ;; The command is a lisp function, so we call it.
1854 (if (gnus-functionp gnus-article-x-face-command)
1855 (funcall gnus-article-x-face-command face)
1856 (error "%s is not a function" gnus-article-x-face-command))
1857 ;; The command is a string, so we interpret the command
1858 ;; as a, well, command, and fork it off.
1859 (let ((process-connection-type nil))
1860 (process-kill-without-query
1862 "article-x-face" nil shell-file-name shell-command-switch
1863 gnus-article-x-face-command))
1866 (process-send-region "article-x-face"
1867 (point-min) (point-max)))
1868 (process-send-eof "article-x-face"))))))))))
1870 (defun article-decode-mime-words ()
1871 "Decode all MIME-encoded words in the article."
1874 (set-buffer gnus-article-buffer)
1875 (let ((inhibit-point-motion-hooks t)
1877 (mail-parse-charset gnus-newsgroup-charset)
1878 (mail-parse-ignored-charsets
1879 (save-excursion (set-buffer gnus-summary-buffer)
1880 gnus-newsgroup-ignored-charsets)))
1881 (mail-decode-encoded-word-region (point-min) (point-max)))))
1883 (defun article-decode-charset (&optional prompt)
1884 "Decode charset-encoded text in the article.
1885 If PROMPT (the prefix), prompt for a coding system to use."
1887 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
1889 (mail-parse-charset gnus-newsgroup-charset)
1890 (mail-parse-ignored-charsets
1891 (save-excursion (condition-case nil
1892 (set-buffer gnus-summary-buffer)
1894 gnus-newsgroup-ignored-charsets))
1895 ct cte ctl charset format)
1898 (article-narrow-to-head)
1899 (setq ct (message-fetch-field "Content-Type" t)
1900 cte (message-fetch-field "Content-Transfer-Encoding" t)
1901 ctl (and ct (ignore-errors
1902 (mail-header-parse-content-type ct)))
1905 (mm-read-coding-system "Charset to decode: "))
1907 (mail-content-type-get ctl 'charset)))
1908 format (and ctl (mail-content-type-get ctl 'format)))
1910 (setq cte (mail-header-strip cte)))
1911 (if (and ctl (not (string-match "/" (car ctl))))
1913 (goto-char (point-max)))
1916 (narrow-to-region (point) (point-max))
1917 (when (and (eq mail-parse-charset 'gnus-decoded)
1918 (eq (mm-body-7-or-8) '8bit))
1919 ;; The text code could have been decoded.
1920 (setq charset mail-parse-charset))
1921 (when (and (or (not ctl)
1922 (equal (car ctl) "text/plain"))
1923 (not format)) ;; article with format will decode later.
1925 charset (and cte (intern (downcase
1926 (gnus-strip-whitespace cte))))
1929 (defun article-decode-encoded-words ()
1930 "Remove encoded-word encoding from headers."
1931 (let ((inhibit-point-motion-hooks t)
1932 (mail-parse-charset gnus-newsgroup-charset)
1933 (mail-parse-ignored-charsets
1934 (save-excursion (condition-case nil
1935 (set-buffer gnus-summary-buffer)
1937 gnus-newsgroup-ignored-charsets))
1940 (article-narrow-to-head)
1941 (funcall gnus-decode-header-function (point-min) (point-max)))))
1943 (defun article-decode-group-name ()
1944 "Decode group names in `Newsgroups:'."
1945 (let ((inhibit-point-motion-hooks t)
1947 (method (gnus-find-method-for-group gnus-newsgroup-name)))
1948 (when (and (or gnus-group-name-charset-method-alist
1949 gnus-group-name-charset-group-alist)
1950 (gnus-buffer-live-p gnus-original-article-buffer))
1951 (when (nnmail-fetch-field "Newsgroups")
1952 (nnheader-replace-header "Newsgroups"
1953 (gnus-decode-newsgroups
1954 (with-current-buffer
1955 gnus-original-article-buffer
1956 (nnmail-fetch-field "Newsgroups"))
1957 gnus-newsgroup-name method)))
1958 (when (nnmail-fetch-field "Followup-To")
1959 (nnheader-replace-header "Followup-To"
1960 (gnus-decode-newsgroups
1961 (with-current-buffer
1962 gnus-original-article-buffer
1963 (nnmail-fetch-field "Followup-To"))
1964 gnus-newsgroup-name method))))))
1966 (defun article-de-quoted-unreadable (&optional force read-charset)
1967 "Translate a quoted-printable-encoded article.
1968 If FORCE, decode the article whether it is marked as quoted-printable
1970 If READ-CHARSET, ask for a coding system."
1971 (interactive (list 'force current-prefix-arg))
1973 (let ((buffer-read-only nil) type charset)
1974 (if (gnus-buffer-live-p gnus-original-article-buffer)
1975 (with-current-buffer gnus-original-article-buffer
1977 (gnus-fetch-field "content-transfer-encoding"))
1978 (let* ((ct (gnus-fetch-field "content-type"))
1981 (mail-header-parse-content-type ct)))))
1982 (setq charset (and ctl
1983 (mail-content-type-get ctl 'charset)))
1984 (if (stringp charset)
1985 (setq charset (intern (downcase charset)))))))
1987 (setq charset (mm-read-coding-system "Charset: " charset)))
1989 (setq charset gnus-newsgroup-charset))
1991 (and type (let ((case-fold-search t))
1992 (string-match "quoted-printable" type))))
1994 (quoted-printable-decode-region
1995 (point) (point-max) (mm-charset-to-coding-system charset))))))
1997 (defun article-de-base64-unreadable (&optional force read-charset)
1998 "Translate a base64 article.
1999 If FORCE, decode the article whether it is marked as base64 not.
2000 If READ-CHARSET, ask for a coding system."
2001 (interactive (list 'force current-prefix-arg))
2003 (let ((buffer-read-only nil) type charset)
2004 (if (gnus-buffer-live-p gnus-original-article-buffer)
2005 (with-current-buffer gnus-original-article-buffer
2007 (gnus-fetch-field "content-transfer-encoding"))
2008 (let* ((ct (gnus-fetch-field "content-type"))
2011 (mail-header-parse-content-type ct)))))
2012 (setq charset (and ctl
2013 (mail-content-type-get ctl 'charset)))
2014 (if (stringp charset)
2015 (setq charset (intern (downcase charset)))))))
2017 (setq charset (mm-read-coding-system "Charset: " charset)))
2019 (setq charset gnus-newsgroup-charset))
2021 (and type (let ((case-fold-search t))
2022 (string-match "base64" type))))
2025 (narrow-to-region (point) (point-max))
2026 (base64-decode-region (point-min) (point-max))
2027 (mm-decode-coding-region
2028 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2033 (defun article-decode-HZ ()
2034 "Translate a HZ-encoded article."
2038 (let ((buffer-read-only nil))
2039 (rfc1843-decode-region (point-min) (point-max)))))
2041 (defun article-wash-html (&optional read-charset)
2042 "Format an html article.
2043 If READ-CHARSET, ask for a coding system."
2046 (let ((buffer-read-only nil)
2048 (if (gnus-buffer-live-p gnus-original-article-buffer)
2049 (with-current-buffer gnus-original-article-buffer
2050 (let* ((ct (gnus-fetch-field "content-type"))
2053 (mail-header-parse-content-type ct)))))
2054 (setq charset (and ctl
2055 (mail-content-type-get ctl 'charset)))
2056 (if (stringp charset)
2057 (setq charset (intern (downcase charset)))))))
2059 (setq charset (mm-read-coding-system "Charset: " charset)))
2061 (setq charset gnus-newsgroup-charset))
2063 (save-window-excursion
2065 (narrow-to-region (point) (point-max))
2067 (let ((w3-strict-width (window-width))
2068 (url-standalone-mode t)
2069 (w3-honor-stylesheets nil)
2070 (w3-delay-image-loads t))
2072 (w3-region (point-min) (point-max))
2075 (defun article-hide-list-identifiers ()
2076 "Remove list identifies from the Subject header.
2077 The `gnus-list-identifiers' variable specifies what to do."
2079 (let ((inhibit-point-motion-hooks t)
2080 (regexp (if (consp gnus-list-identifiers)
2081 (mapconcat 'identity gnus-list-identifiers " *\\|")
2082 gnus-list-identifiers))
2087 (article-narrow-to-head)
2088 (goto-char (point-min))
2089 (while (re-search-forward
2090 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2092 (delete-region (match-beginning 2) (match-end 0))
2093 (beginning-of-line))
2094 (when (re-search-forward
2095 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2096 (delete-region (match-beginning 1) (match-end 1))))))))
2098 (defun article-hide-pgp ()
2099 "Remove any PGP headers and signatures in the current article."
2103 (let ((inhibit-point-motion-hooks t)
2104 buffer-read-only beg end)
2106 ;; Hide the "header".
2107 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
2108 (gnus-add-wash-type 'pgp)
2109 (delete-region (match-beginning 0) (match-end 0))
2110 ;; Remove armor headers (rfc2440 6.2)
2111 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
2114 ;; Hide the actual signature.
2115 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
2116 (setq end (1+ (match-beginning 0)))
2119 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
2121 ;; Perhaps we shouldn't hide to the end of the buffer
2122 ;; if there is no end to the signature?
2124 ;; Hide "- " PGP quotation markers.
2126 (narrow-to-region beg end)
2127 (goto-char (point-min))
2128 (while (re-search-forward "^- " nil t)
2130 (match-beginning 0) (match-end 0)))
2132 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
2134 (defun article-hide-pem (&optional arg)
2135 "Toggle hiding of any PEM headers and signatures in the current article.
2136 If given a negative prefix, always show; if given a positive prefix,
2138 (interactive (gnus-article-hidden-arg))
2139 (unless (gnus-article-check-hidden-text 'pem arg)
2141 (let (buffer-read-only end)
2142 (goto-char (point-min))
2143 ;; Hide the horrendously ugly "header".
2144 (when (and (search-forward
2145 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2147 (setq end (1+ (match-beginning 0))))
2148 (gnus-add-wash-type 'pem)
2149 (gnus-article-hide-text-type
2151 (if (search-forward "\n\n" nil t)
2155 ;; Hide the trailer as well
2156 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2158 (gnus-article-hide-text-type
2159 (match-beginning 0) (match-end 0) 'pem)))))))
2161 (defun article-strip-banner ()
2162 "Strip the banner specified by the `banner' group parameter."
2166 (let ((inhibit-point-motion-hooks t)
2167 (banner (gnus-parameter-banner gnus-newsgroup-name))
2168 (gnus-signature-limit nil)
2169 buffer-read-only beg end)
2173 ((eq banner 'signature)
2174 (when (gnus-article-narrow-to-signature)
2177 (delete-region (point) (point-max))))
2179 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2180 (while (re-search-forward banner nil t)
2181 (delete-region (match-beginning 0) (match-end 0)))))
2183 (while (re-search-forward banner nil t)
2184 (delete-region (match-beginning 0) (match-end 0))))))))))
2186 (defun article-babel ()
2187 "Translate article using an online translation service."
2191 (set-buffer gnus-article-buffer)
2192 (when (article-goto-body)
2193 (let* ((buffer-read-only nil)
2196 (orig (buffer-substring start end))
2197 (trans (babel-as-string orig)))
2199 (narrow-to-region start end)
2200 (delete-region start end)
2203 (defun article-hide-signature (&optional arg)
2204 "Hide the signature in the current article.
2205 If given a negative prefix, always show; if given a positive prefix,
2207 (interactive (gnus-article-hidden-arg))
2208 (unless (gnus-article-check-hidden-text 'signature arg)
2211 (let ((buffer-read-only nil))
2212 (when (gnus-article-narrow-to-signature)
2213 (gnus-article-hide-text-type
2214 (point-min) (point-max) 'signature))))))
2215 (gnus-set-mode-line 'article))
2217 (defun article-strip-headers-in-body ()
2218 "Strip offensive headers from bodies."
2222 (let ((case-fold-search t))
2223 (when (looking-at "x-no-archive:")
2224 (gnus-delete-line)))))
2226 (defun article-strip-leading-blank-lines ()
2227 "Remove all blank lines from the beginning of the article."
2230 (let ((inhibit-point-motion-hooks t)
2232 (when (article-goto-body)
2233 (while (and (not (eobp))
2234 (looking-at "[ \t]*$"))
2235 (gnus-delete-line))))))
2237 (defun article-narrow-to-head ()
2238 "Narrow the buffer to the head of the message.
2239 Point is left at the beginning of the narrowed-to region."
2241 (goto-char (point-min))
2242 (if (search-forward "\n\n" nil 1)
2245 (goto-char (point-min)))
2247 (defun article-goto-body ()
2248 "Place point at the start of the body."
2249 (goto-char (point-min))
2251 ;; This variable is only bound when dealing with separate
2253 (article-goto-body-goes-to-point-min-p
2255 ((search-forward "\n\n" nil t)
2258 (goto-char (point-max))
2261 (defun article-strip-multiple-blank-lines ()
2262 "Replace consecutive blank lines with one empty line."
2265 (let ((inhibit-point-motion-hooks t)
2267 ;; First make all blank lines empty.
2269 (while (re-search-forward "^[ \t]+$" nil t)
2270 (unless (gnus-annotation-in-region-p
2271 (match-beginning 0) (match-end 0))
2272 (replace-match "" nil t)))
2273 ;; Then replace multiple empty lines with a single empty line.
2275 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2276 (unless (gnus-annotation-in-region-p
2277 (match-beginning 0) (match-end 0))
2278 (delete-region (match-beginning 1) (match-end 1)))))))
2280 (defun article-strip-leading-space ()
2281 "Remove all white space from the beginning of the lines in the article."
2284 (let ((inhibit-point-motion-hooks t)
2287 (while (re-search-forward "^[ \t]+" nil t)
2288 (replace-match "" t t)))))
2290 (defun article-strip-trailing-space ()
2291 "Remove all white space from the end of the lines in the article."
2294 (let ((inhibit-point-motion-hooks t)
2297 (while (re-search-forward "[ \t]+$" nil t)
2298 (replace-match "" t t)))))
2300 (defun article-strip-blank-lines ()
2301 "Strip leading, trailing and multiple blank lines."
2303 (article-strip-leading-blank-lines)
2304 (article-remove-trailing-blank-lines)
2305 (article-strip-multiple-blank-lines))
2307 (defun article-strip-all-blank-lines ()
2308 "Strip all blank lines."
2311 (let ((inhibit-point-motion-hooks t)
2314 (while (re-search-forward "^[ \t]*\n" nil t)
2315 (replace-match "" t t)))))
2317 (defun gnus-article-narrow-to-signature ()
2318 "Narrow to the signature; return t if a signature is found, else nil."
2319 (let ((inhibit-point-motion-hooks t))
2320 (when (gnus-article-search-signature)
2322 ;; Check whether we have some limits to what we consider
2323 ;; to be a signature.
2324 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2325 (list gnus-signature-limit)))
2327 (while (setq limit (pop limits))
2328 (if (or (and (integerp limit)
2329 (< (- (point-max) (point)) limit))
2331 (< (count-lines (point) (point-max)) limit))
2332 (and (gnus-functionp limit)
2334 (and (stringp limit)
2335 (not (re-search-forward limit nil t))))
2336 () ; This limit did not succeed.
2340 (narrow-to-region (point) (point-max))
2343 (defun gnus-article-search-signature ()
2344 "Search the current buffer for the signature separator.
2345 Put point at the beginning of the signature separator."
2346 (let ((cur (point)))
2347 (goto-char (point-max))
2348 (if (if (stringp gnus-signature-separator)
2349 (re-search-backward gnus-signature-separator nil t)
2350 (let ((seps gnus-signature-separator))
2352 (not (re-search-backward (car seps) nil t)))
2359 (defun gnus-article-hidden-arg ()
2360 "Return the current prefix arg as a number, or 0 if no prefix."
2361 (list (if current-prefix-arg
2362 (prefix-numeric-value current-prefix-arg)
2365 (defun gnus-article-check-hidden-text (type arg)
2366 "Return nil if hiding is necessary.
2367 Arg can be nil or a number. nil and positive means hide, negative
2368 means show, 0 means toggle."
2371 (let ((hide (gnus-article-hidden-text-p type)))
2377 (gnus-article-show-hidden-text type)
2380 (if (eq hide 'hidden)
2382 (gnus-article-show-hidden-text type)
2386 (defun gnus-article-hidden-text-p (type)
2387 "Say whether the current buffer contains hidden text of type TYPE."
2388 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2390 (not (get-text-property pos 'invisible))
2391 (not (get-text-property pos 'dummy-invisible)))
2393 (text-property-any (1+ pos) (point-max) 'article-type type)))
2398 (defun gnus-article-show-hidden-text (type &optional dummy)
2399 "Show all hidden text of type TYPE.
2400 Originally it is hide instead of DUMMY."
2401 (let ((buffer-read-only nil)
2402 (inhibit-point-motion-hooks t))
2403 (gnus-remove-text-properties-when
2405 (point-min) (point-max)
2406 (cons 'article-type (cons type
2407 gnus-hidden-properties)))
2408 (gnus-delete-wash-type type)))
2410 (defconst article-time-units
2411 `((year . ,(* 365.25 24 60 60))
2412 (week . ,(* 7 24 60 60))
2413 (day . ,(* 24 60 60))
2417 "Mapping from time units to seconds.")
2419 (defun article-date-ut (&optional type highlight header)
2420 "Convert DATE date to universal time in the current article.
2421 If TYPE is `local', convert to local time; if it is `lapsed', output
2422 how much time has lapsed since DATE. For `lapsed', the value of
2423 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2424 should replace the \"Date:\" one, or should be added below it."
2425 (interactive (list 'ut t))
2426 (let* ((header (or header
2427 (message-fetch-field "date")
2429 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2432 ((not gnus-article-date-lapsed-new-header)
2438 (date (if (vectorp header) (mail-header-date header)
2440 (inhibit-point-motion-hooks t)
2445 (article-narrow-to-head)
2446 (when (re-search-forward tdate-regexp nil t)
2447 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2448 date (or (get-text-property (gnus-point-at-bol)
2451 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2453 (when (and date (not (string= date "")))
2454 (goto-char (point-min))
2455 (let ((buffer-read-only nil))
2456 ;; Delete any old Date headers.
2457 (while (re-search-forward date-regexp nil t)
2459 (delete-region (progn (beginning-of-line) (point))
2460 (progn (forward-line 1) (point)))
2461 (delete-region (progn (beginning-of-line) (point))
2462 (progn (end-of-line) (point)))
2463 (setq pos (point))))
2464 (when (and (not pos) (re-search-forward tdate-regexp nil t))
2466 (if pos (goto-char pos))
2467 (insert (article-make-date-line date (or type 'ut)))
2473 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2474 (put-text-property (match-beginning 1) (1+ (match-end 1))
2475 'original-date date)
2476 (put-text-property (match-beginning 1) (1+ (match-end 1))
2478 (put-text-property (match-beginning 2) (match-end 2)
2481 (defun article-make-date-line (date type)
2482 "Return a DATE line of TYPE."
2483 (unless (memq type '(local ut original user iso8601 lapsed english))
2484 (error "Unknown conversion type: %s" type))
2486 (let ((time (date-to-time date)))
2488 ;; Convert to the local timezone.
2490 (let ((tz (car (current-time-zone time))))
2491 (format "Date: %s %s%02d%02d" (current-time-string time)
2492 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2493 (/ (% (abs tz) 3600) 60))))
2494 ;; Convert to Universal Time.
2497 (current-time-string
2498 (let* ((e (parse-time-string date))
2499 (tm (apply 'encode-time e))
2501 (ls (- (cadr tm) (car (current-time-zone time)))))
2502 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2503 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2506 ;; Get the original date from the article.
2507 ((eq type 'original)
2508 (concat "Date: " (if (string-match "\n+$" date)
2509 (substring date 0 (match-beginning 0))
2511 ;; Let the user define the format.
2513 (if (gnus-functionp gnus-article-time-format)
2514 (funcall gnus-article-time-format time)
2517 (format-time-string gnus-article-time-format time))))
2520 (let ((tz (car (current-time-zone time))))
2523 (format-time-string "%Y%m%dT%H%M%S" time)
2524 (format "%s%02d%02d"
2525 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2526 (/ (% (abs tz) 3600) 60)))))
2527 ;; Do an X-Sent lapsed format.
2529 ;; If the date is seriously mangled, the timezone functions are
2530 ;; liable to bug out, so we ignore all errors.
2531 (let* ((now (current-time))
2532 (real-time (subtract-time now time))
2533 (real-sec (and real-time
2534 (+ (* (float (car real-time)) 65536)
2536 (sec (and real-time (abs real-sec)))
2546 ;; This is a bit convoluted, but basically we go
2547 ;; through the time units for years, weeks, etc,
2548 ;; and divide things to see whether that results
2549 ;; in positive answers.
2552 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2553 ;; The (remaining) seconds are too few to
2554 ;; be divided into this time unit.
2556 ;; It's big enough, so we output it.
2557 (setq sec (- sec (* num (cdr unit))))
2559 (concat (if prev ", " "") (int-to-string
2561 " " (symbol-name (car unit))
2562 (if (> num 1) "s" ""))
2564 article-time-units "")
2565 ;; If dates are odd, then it might appear like the
2566 ;; article was sent in the future.
2569 " in the future"))))))
2570 ;; Display the date in proper English
2572 (let ((dtime (decode-time time)))
2575 (number-to-string (nth 3 dtime))
2576 (let ((digit (% (nth 3 dtime) 10)))
2578 ((memq (nth 3 dtime) '(11 12 13)) "th")
2584 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2586 (number-to-string (nth 5 dtime))
2588 (format "%02d" (nth 2 dtime))
2590 (format "%02d" (nth 1 dtime)))))))
2592 (format "Date: %s (from Oort)" date))))
2594 (defun article-date-local (&optional highlight)
2595 "Convert the current article date to the local timezone."
2596 (interactive (list t))
2597 (article-date-ut 'local highlight))
2599 (defun article-date-english (&optional highlight)
2600 "Convert the current article date to something that is proper English."
2601 (interactive (list t))
2602 (article-date-ut 'english highlight))
2604 (defun article-date-original (&optional highlight)
2605 "Convert the current article date to what it was originally.
2606 This is only useful if you have used some other date conversion
2607 function and want to see what the date was before converting."
2608 (interactive (list t))
2609 (article-date-ut 'original highlight))
2611 (defun article-date-lapsed (&optional highlight)
2612 "Convert the current article date to time lapsed since it was sent."
2613 (interactive (list t))
2614 (article-date-ut 'lapsed highlight))
2616 (defun article-update-date-lapsed ()
2617 "Function to be run from a timer to update the lapsed time line."
2618 (let (deactivate-mark)
2623 (set-buffer (window-buffer w))
2624 (when (eq major-mode 'gnus-article-mode)
2625 (goto-char (point-min))
2626 (when (re-search-forward "^X-Sent:" nil t)
2627 (article-date-lapsed t))))
2630 (defun gnus-start-date-timer (&optional n)
2631 "Start a timer to update the X-Sent header in the article buffers.
2632 The numerical prefix says how frequently (in seconds) the function
2637 (gnus-stop-date-timer)
2638 (setq article-lapsed-timer
2639 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2641 (defun gnus-stop-date-timer ()
2642 "Stop the X-Sent timer."
2644 (when article-lapsed-timer
2645 (nnheader-cancel-timer article-lapsed-timer)
2646 (setq article-lapsed-timer nil)))
2648 (defun article-date-user (&optional highlight)
2649 "Convert the current article date to the user-defined format.
2650 This format is defined by the `gnus-article-time-format' variable."
2651 (interactive (list t))
2652 (article-date-ut 'user highlight))
2654 (defun article-date-iso8601 (&optional highlight)
2655 "Convert the current article date to ISO8601."
2656 (interactive (list t))
2657 (article-date-ut 'iso8601 highlight))
2659 ;; (defun article-show-all ()
2660 ;; "Show all hidden text in the article buffer."
2663 ;; (let ((buffer-read-only nil))
2664 ;; (gnus-article-unhide-text (point-min) (point-max)))))
2666 (defun article-remove-leading-whitespace ()
2667 "Remove excessive whitespace from all headers."
2671 (let ((buffer-read-only nil))
2672 (article-narrow-to-head)
2673 (goto-char (point-min))
2674 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2675 (delete-region (match-beginning 1) (match-end 1)))))))
2677 (defun article-emphasize (&optional arg)
2678 "Emphasize text according to `gnus-emphasis-alist'."
2679 (interactive (gnus-article-hidden-arg))
2680 (unless (gnus-article-check-hidden-text 'emphasis arg)
2684 (with-current-buffer gnus-summary-buffer
2685 gnus-article-emphasis-alist)
2687 gnus-emphasis-alist))
2688 (buffer-read-only nil)
2689 (props (append '(article-type emphasis)
2690 gnus-hidden-properties))
2691 regexp elem beg invisible visible face)
2694 (while (setq elem (pop alist))
2696 (setq regexp (car elem)
2697 invisible (nth 1 elem)
2698 visible (nth 2 elem)
2700 (while (re-search-forward regexp nil t)
2701 (when (and (match-beginning visible) (match-beginning invisible))
2702 (gnus-article-hide-text
2703 (match-beginning invisible) (match-end invisible) props)
2704 (gnus-article-unhide-text-type
2705 (match-beginning visible) (match-end visible) 'emphasis)
2706 (gnus-put-overlay-excluding-newlines
2707 (match-beginning visible) (match-end visible) 'face face)
2708 (gnus-add-wash-type 'emphasis)
2709 (goto-char (match-end invisible)))))))))
2711 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2712 "Setup newsgroup emphasis alist."
2713 (unless gnus-article-emphasis-alist
2714 (let ((name (and gnus-newsgroup-name
2715 (gnus-group-real-name gnus-newsgroup-name))))
2716 (make-local-variable 'gnus-article-emphasis-alist)
2717 (setq gnus-article-emphasis-alist
2719 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2720 (while (setq elem (pop alist))
2721 (when (and name (string-match (car elem) name))
2723 highlight (copy-sequence (cdr elem)))))
2725 (copy-sequence highlight-words)
2726 (if gnus-newsgroup-name
2727 (copy-sequence (gnus-group-find-parameter
2728 gnus-newsgroup-name 'highlight-words t)))
2729 gnus-emphasis-alist)))))
2732 (defvar gnus-summary-article-menu)
2733 (defvar gnus-summary-post-menu))
2735 ;;; Saving functions.
2737 (defun gnus-article-save (save-buffer file &optional num)
2738 "Save the currently selected article."
2739 (unless gnus-save-all-headers
2740 ;; Remove headers according to `gnus-saved-headers'.
2741 (let ((gnus-visible-headers
2742 (or gnus-saved-headers gnus-visible-headers))
2743 (gnus-article-buffer save-buffer))
2745 (set-buffer save-buffer)
2746 (article-hide-headers 1 t))))
2747 (save-window-excursion
2748 (if (not gnus-default-article-saver)
2749 (error "No default saver is defined")
2750 ;; !!! Magic! The saving functions all save
2751 ;; `gnus-save-article-buffer' (or so they think), but we
2752 ;; bind that variable to our save-buffer.
2753 (set-buffer gnus-article-buffer)
2754 (let* ((gnus-save-article-buffer save-buffer)
2757 ((not gnus-prompt-before-saving) 'default)
2758 ((eq gnus-prompt-before-saving 'always) nil)
2760 (gnus-number-of-articles-to-be-saved
2761 (when (eq gnus-prompt-before-saving t)
2763 (set-buffer gnus-article-current-summary)
2764 (funcall gnus-default-article-saver filename)))))
2766 (defun gnus-read-save-file-name (prompt &optional filename
2767 function group headers variable)
2769 (funcall function group headers (symbol-value variable)))
2774 ((eq filename 'default)
2780 (let* ((split-name (gnus-get-split-value gnus-split-methods))
2783 (if (and gnus-number-of-articles-to-be-saved
2784 (> gnus-number-of-articles-to-be-saved 1))
2785 (format "these %d articles"
2786 gnus-number-of-articles-to-be-saved)
2789 ;; Let the split methods have their say.
2791 ;; No split name was found.
2794 (concat prompt " (default "
2795 (file-name-nondirectory default-name) ") ")
2796 (file-name-directory default-name)
2798 ;; A single group name is returned.
2799 ((stringp split-name)
2801 (funcall function split-name headers
2802 (symbol-value variable)))
2804 (concat prompt " (default "
2805 (file-name-nondirectory default-name) ") ")
2806 (file-name-directory default-name)
2808 ;; A single split name was found
2809 ((= 1 (length split-name))
2810 (let* ((name (expand-file-name
2812 gnus-article-save-directory))
2813 (dir (cond ((file-directory-p name)
2814 (file-name-as-directory name))
2815 ((file-exists-p name) name)
2816 (t gnus-article-save-directory))))
2818 (concat prompt " (default " name ") ")
2820 ;; A list of splits was found.
2822 (setq split-name (nreverse split-name))
2824 (let ((file-name-history
2825 (nconc split-name file-name-history)))
2829 (concat prompt " (`M-p' for defaults) ")
2830 gnus-article-save-directory
2832 gnus-article-save-directory)))
2833 (car (push result file-name-history)))))))
2834 ;; Create the directory.
2835 (gnus-make-directory (file-name-directory file))
2836 ;; If we have read a directory, we append the default file name.
2837 (when (file-directory-p file)
2838 (setq file (expand-file-name (file-name-nondirectory
2840 (file-name-as-directory file))))
2841 ;; Possibly translate some characters.
2842 (nnheader-translate-file-chars file))))))
2843 (gnus-make-directory (file-name-directory result))
2844 (set variable result)))
2846 (defun gnus-article-archive-name (group)
2847 "Return the first instance of an \"Archive-name\" in the current buffer."
2848 (let ((case-fold-search t))
2849 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
2850 (nnheader-concat gnus-article-save-directory
2851 (match-string 1)))))
2853 (defun gnus-article-nndoc-name (group)
2854 "If GROUP is an nndoc group, return the name of the parent group."
2855 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
2856 (gnus-group-get-parameter group 'save-article-group)))
2858 (defun gnus-summary-save-in-rmail (&optional filename)
2859 "Append this article to Rmail file.
2860 Optional argument FILENAME specifies file name.
2861 Directory to save to is default to `gnus-article-save-directory'."
2862 (setq filename (gnus-read-save-file-name
2863 "Save %s in rmail file:" filename
2864 gnus-rmail-save-name gnus-newsgroup-name
2865 gnus-current-headers 'gnus-newsgroup-last-rmail))
2866 (gnus-eval-in-buffer-window gnus-save-article-buffer
2870 (gnus-output-to-rmail filename))))
2873 (defun gnus-summary-save-in-mail (&optional filename)
2874 "Append this article to Unix mail file.
2875 Optional argument FILENAME specifies file name.
2876 Directory to save to is default to `gnus-article-save-directory'."
2877 (setq filename (gnus-read-save-file-name
2878 "Save %s in Unix mail file:" filename
2879 gnus-mail-save-name gnus-newsgroup-name
2880 gnus-current-headers 'gnus-newsgroup-last-mail))
2881 (gnus-eval-in-buffer-window gnus-save-article-buffer
2885 (if (and (file-readable-p filename)
2886 (mail-file-babyl-p filename))
2887 (rmail-output-to-rmail-file filename t)
2888 (gnus-output-to-mail filename)))))
2891 (defun gnus-summary-save-in-file (&optional filename overwrite)
2892 "Append this article to file.
2893 Optional argument FILENAME specifies file name.
2894 Directory to save to is default to `gnus-article-save-directory'."
2895 (setq filename (gnus-read-save-file-name
2896 "Save %s in file:" filename
2897 gnus-file-save-name gnus-newsgroup-name
2898 gnus-current-headers 'gnus-newsgroup-last-file))
2899 (gnus-eval-in-buffer-window gnus-save-article-buffer
2903 (when (and overwrite
2904 (file-exists-p filename))
2905 (delete-file filename))
2906 (gnus-output-to-file filename))))
2909 (defun gnus-summary-write-to-file (&optional filename)
2910 "Write this article to a file, overwriting it if the file exists.
2911 Optional argument FILENAME specifies file name.
2912 The directory to save in defaults to `gnus-article-save-directory'."
2913 (gnus-summary-save-in-file nil t))
2915 (defun gnus-summary-save-body-in-file (&optional filename)
2916 "Append this article body to a file.
2917 Optional argument FILENAME specifies file name.
2918 The directory to save in defaults to `gnus-article-save-directory'."
2919 (setq filename (gnus-read-save-file-name
2920 "Save %s body in file:" filename
2921 gnus-file-save-name gnus-newsgroup-name
2922 gnus-current-headers 'gnus-newsgroup-last-file))
2923 (gnus-eval-in-buffer-window gnus-save-article-buffer
2927 (when (article-goto-body)
2928 (narrow-to-region (point) (point-max)))
2929 (gnus-output-to-file filename))))
2932 (defun gnus-summary-save-in-pipe (&optional command)
2933 "Pipe this article to subprocess."
2935 (cond ((and (eq command 'default)
2936 gnus-last-shell-command)
2937 gnus-last-shell-command)
2942 "Shell command on %s: "
2943 (if (and gnus-number-of-articles-to-be-saved
2944 (> gnus-number-of-articles-to-be-saved 1))
2945 (format "these %d articles"
2946 gnus-number-of-articles-to-be-saved)
2948 gnus-last-shell-command))))
2949 (when (string-equal command "")
2950 (if gnus-last-shell-command
2951 (setq command gnus-last-shell-command)
2952 (error "A command is required")))
2953 (gnus-eval-in-buffer-window gnus-article-buffer
2956 (shell-command-on-region (point-min) (point-max) command nil)))
2957 (setq gnus-last-shell-command command))
2959 (defun gnus-summary-pipe-to-muttprint (&optional command)
2960 "Pipe this article to muttprint."
2961 (setq command (read-string
2962 "Print using command: " gnus-summary-muttprint-program
2963 nil gnus-summary-muttprint-program))
2964 (gnus-summary-save-in-pipe command))
2966 ;;; Article file names when saving.
2968 (defun gnus-capitalize-newsgroup (newsgroup)
2969 "Capitalize NEWSGROUP name."
2970 (when (not (zerop (length newsgroup)))
2971 (concat (char-to-string (upcase (aref newsgroup 0)))
2972 (substring newsgroup 1))))
2974 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2975 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2976 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
2977 Otherwise, it is like ~/News/news/group/num."
2980 (concat (if (gnus-use-long-file-name 'not-save)
2981 (gnus-capitalize-newsgroup newsgroup)
2982 (gnus-newsgroup-directory-form newsgroup))
2983 "/" (int-to-string (mail-header-number headers)))
2984 gnus-article-save-directory)))
2986 (string-equal (file-name-directory default)
2987 (file-name-directory last-file))
2988 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2990 (or last-file default))))
2992 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2993 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2994 If variable `gnus-use-long-file-name' is non-nil, it is
2995 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2998 (concat (if (gnus-use-long-file-name 'not-save)
3000 (gnus-newsgroup-directory-form newsgroup))
3001 "/" (int-to-string (mail-header-number headers)))
3002 gnus-article-save-directory)))
3004 (string-equal (file-name-directory default)
3005 (file-name-directory last-file))
3006 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3008 (or last-file default))))
3010 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3011 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3012 If variable `gnus-use-long-file-name' is non-nil, it is
3013 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3016 (if (gnus-use-long-file-name 'not-save)
3019 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3021 gnus-article-save-directory)))
3023 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3024 "Generate file name from sender."
3025 (let ((from (mail-header-from headers)))
3027 (if (and from (string-match "\\([^ <]+\\)@" from))
3028 (match-string 1 from)
3030 gnus-article-save-directory)))
3032 (defun article-verify-x-pgp-sig ()
3035 (if (gnus-buffer-live-p gnus-original-article-buffer)
3036 (let ((sig (with-current-buffer gnus-original-article-buffer
3037 (gnus-fetch-field "X-PGP-Sig")))
3041 (mml2015-clear-verify-function))
3043 (insert-buffer gnus-original-article-buffer)
3044 (setq items (split-string sig))
3045 (message-narrow-to-head)
3046 (let ((inhibit-point-motion-hooks t)
3047 (case-fold-search t))
3048 ;; Don't verify multiple headers.
3049 (setq headers (mapconcat (lambda (header)
3051 (mail-fetch-field header) "\n"))
3052 (split-string (nth 1 items) ",") "")))
3053 (delete-region (point-min) (point-max))
3054 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3055 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3060 (if (looking-at "^-")
3063 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3064 (insert "Version: " (car items) "\n\n")
3065 (insert (mapconcat 'identity (cddr items) "\n"))
3066 (insert "\n-----END PGP SIGNATURE-----\n")
3067 (let ((mm-security-handle (list (format "multipart/signed"))))
3068 (mml2015-clean-buffer)
3069 (let ((coding-system-for-write (or gnus-newsgroup-charset
3071 (funcall (mml2015-clear-verify-function)))
3073 (or (mm-handle-multipart-ctl-parameter
3074 mm-security-handle 'gnus-details)
3075 (mm-handle-multipart-ctl-parameter
3076 mm-security-handle 'gnus-info)))))
3078 (let (buffer-read-only bface eface)
3080 (message-narrow-to-head)
3081 (goto-char (point-max))
3083 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3084 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3085 (message-remove-header "X-Gnus-PGP-Verify")
3086 (if (re-search-forward "^X-PGP-Sig:" nil t)
3088 (goto-char (point-max)))
3089 (narrow-to-region (point) (point))
3090 (insert "X-Gnus-PGP-Verify: " info "\n")
3091 (goto-char (point-min))
3094 (if (not (looking-at "^[ \t]"))
3098 (goto-char (point-min))
3099 (when (looking-at "\\([^:]+\\): *")
3100 (put-text-property (match-beginning 1) (1+ (match-end 1))
3102 (put-text-property (match-end 0) (point-max)
3103 'face eface)))))))))
3105 (defun article-verify-cancel-lock ()
3106 "Verify Cancel-Lock header."
3108 (if (gnus-buffer-live-p gnus-original-article-buffer)
3109 (canlock-verify gnus-original-article-buffer)))
3116 (setq afunc (car func)
3119 gfunc (intern (format "gnus-%s" func))))
3121 (when (fboundp afunc)
3122 `(lambda (&optional interactive &rest args)
3123 ,(documentation afunc t)
3124 (interactive (list t))
3126 (set-buffer gnus-article-buffer)
3128 (call-interactively ',afunc)
3129 (apply ',afunc args))))))))
3130 '(article-hide-headers
3131 article-verify-x-pgp-sig
3132 article-verify-cancel-lock
3133 article-hide-boring-headers
3134 article-treat-overstrike
3135 article-fill-long-lines
3136 article-capitalize-sentences
3138 article-remove-leading-whitespace
3139 article-display-x-face
3140 article-de-quoted-unreadable
3141 article-de-base64-unreadable
3144 article-hide-list-identifiers
3146 article-strip-banner
3149 article-hide-signature
3150 article-strip-headers-in-body
3151 article-remove-trailing-blank-lines
3152 article-strip-leading-blank-lines
3153 article-strip-multiple-blank-lines
3154 article-strip-leading-space
3155 article-strip-trailing-space
3156 article-strip-blank-lines
3157 article-strip-all-blank-lines
3158 article-replace-with-quoted-text
3160 article-date-english
3161 article-date-iso8601
3162 article-date-original
3164 article-decode-mime-words
3165 article-decode-charset
3166 article-decode-encoded-words
3170 article-treat-dumbquotes
3171 article-normalize-headers
3172 ;; (article-show-all . gnus-article-show-all-headers)
3176 ;;; Gnus article mode
3179 (put 'gnus-article-mode 'mode-class 'special)
3181 (set-keymap-parent gnus-article-mode-map widget-keymap)
3183 (gnus-define-keys gnus-article-mode-map
3184 " " gnus-article-goto-next-page
3185 "\177" gnus-article-goto-prev-page
3186 [delete] gnus-article-goto-prev-page
3187 [backspace] gnus-article-goto-prev-page
3188 "\C-c^" gnus-article-refer-article
3189 "h" gnus-article-show-summary
3190 "s" gnus-article-show-summary
3191 "\C-c\C-m" gnus-article-mail
3192 "?" gnus-article-describe-briefly
3193 "e" gnus-summary-edit-article
3194 "<" beginning-of-buffer
3196 "\C-c\C-i" gnus-info-find-node
3198 "R" gnus-article-reply-with-original
3199 "F" gnus-article-followup-with-original
3200 "\C-hk" gnus-article-describe-key
3201 "\C-hc" gnus-article-describe-key-briefly
3203 "\C-d" gnus-article-read-summary-keys
3204 "\M-*" gnus-article-read-summary-keys
3205 "\M-#" gnus-article-read-summary-keys
3206 "\M-^" gnus-article-read-summary-keys
3207 "\M-g" gnus-article-read-summary-keys)
3209 (substitute-key-definition
3210 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3212 (defun gnus-article-make-menu-bar ()
3213 (unless (boundp 'gnus-article-commands-menu)
3214 (gnus-summary-make-menu-bar))
3215 (gnus-turn-off-edit-menu 'article)
3216 (unless (boundp 'gnus-article-article-menu)
3218 gnus-article-article-menu gnus-article-mode-map ""
3220 ["Scroll forwards" gnus-article-goto-next-page t]
3221 ["Scroll backwards" gnus-article-goto-prev-page t]
3222 ["Show summary" gnus-article-show-summary t]
3223 ["Fetch Message-ID at point" gnus-article-refer-article t]
3224 ["Mail to address at point" gnus-article-mail t]
3225 ["Send a bug report" gnus-bug t]))
3228 gnus-article-treatment-menu gnus-article-mode-map ""
3229 ;; Fixme: this should use :active (and maybe :visible).
3231 ["Hide headers" gnus-article-hide-headers t]
3232 ["Hide signature" gnus-article-hide-signature t]
3233 ["Hide citation" gnus-article-hide-citation t]
3234 ["Treat overstrike" gnus-article-treat-overstrike t]
3235 ["Remove carriage return" gnus-article-remove-cr t]
3236 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3237 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3238 ["Remove base64" gnus-article-de-base64-unreadable t]
3239 ["Treat html" gnus-article-wash-html t]
3240 ["Decode HZ" gnus-article-decode-HZ t]))
3242 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3244 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3246 (gnus-run-hooks 'gnus-article-menu-hook)))
3248 ;; Fixme: do something for the Emacs tool bar in Article mode a la
3251 (defun gnus-article-mode ()
3252 "Major mode for displaying an article.
3254 All normal editing commands are switched off.
3256 The following commands are available in addition to all summary mode
3258 \\<gnus-article-mode-map>
3259 \\[gnus-article-next-page]\t Scroll the article one page forwards
3260 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3261 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3262 \\[gnus-article-show-summary]\t Display the summary buffer
3263 \\[gnus-article-mail]\t Send a reply to the address near point
3264 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3265 \\[gnus-info-find-node]\t Go to the Gnus info node"
3267 (gnus-simplify-mode-line)
3268 (setq mode-name "Article")
3269 (setq major-mode 'gnus-article-mode)
3270 (make-local-variable 'minor-mode-alist)
3271 (use-local-map gnus-article-mode-map)
3272 (when (gnus-visual-p 'article-menu 'menu)
3273 (gnus-article-make-menu-bar))
3274 (gnus-update-format-specifications nil 'article-mode)
3275 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3276 (make-local-variable 'gnus-page-broken)
3277 (make-local-variable 'gnus-button-marker-list)
3278 (make-local-variable 'gnus-article-current-summary)
3279 (make-local-variable 'gnus-article-mime-handles)
3280 (make-local-variable 'gnus-article-decoded-p)
3281 (make-local-variable 'gnus-article-mime-handle-alist)
3282 (make-local-variable 'gnus-article-wash-types)
3283 (make-local-variable 'gnus-article-image-alist)
3284 (make-local-variable 'gnus-article-charset)
3285 (make-local-variable 'gnus-article-ignored-charsets)
3286 (gnus-set-default-directory)
3287 (buffer-disable-undo)
3288 (setq buffer-read-only t)
3289 (set-syntax-table gnus-article-mode-syntax-table)
3290 (mm-enable-multibyte)
3291 (gnus-run-hooks 'gnus-article-mode-hook))
3293 (defun gnus-article-setup-buffer ()
3294 "Initialize the article buffer."
3295 (let* ((name (if gnus-single-article-buffer "*Article*"
3296 (concat "*Article " gnus-newsgroup-name "*")))
3298 (progn (string-match "\\*Article" name)
3299 (concat " *Original Article"
3300 (substring name (match-end 0))))))
3301 (setq gnus-article-buffer name)
3302 (setq gnus-original-article-buffer original)
3303 (setq gnus-article-mime-handle-alist nil)
3304 ;; This might be a variable local to the summary buffer.
3305 (unless gnus-single-article-buffer
3307 (set-buffer gnus-summary-buffer)
3308 (setq gnus-article-buffer name)
3309 (setq gnus-original-article-buffer original)
3310 (gnus-set-global-variables)))
3311 (gnus-article-setup-highlight-words)
3312 ;; Init original article buffer.
3314 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3315 (mm-enable-multibyte)
3316 (setq major-mode 'gnus-original-article-mode)
3317 (make-local-variable 'gnus-original-article))
3318 (if (get-buffer name)
3321 (when gnus-article-mime-handles
3322 (mm-destroy-parts gnus-article-mime-handles)
3323 (setq gnus-article-mime-handles nil))
3324 ;; Set it to nil in article-buffer!
3325 (setq gnus-article-mime-handle-alist nil)
3326 (buffer-disable-undo)
3327 (setq buffer-read-only t)
3328 (unless (eq major-mode 'gnus-article-mode)
3329 (gnus-article-mode))
3332 (set-buffer (gnus-get-buffer-create name))
3334 (make-local-variable 'gnus-summary-buffer)
3335 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3336 (current-buffer)))))
3338 ;; Set article window start at LINE, where LINE is the number of lines
3339 ;; from the head of the article.
3340 (defun gnus-article-set-window-start (&optional line)
3342 (gnus-get-buffer-window gnus-article-buffer t)
3344 (set-buffer gnus-article-buffer)
3345 (goto-char (point-min))
3348 (gnus-message 6 "Moved to bookmark")
3349 (search-forward "\n\n" nil t)
3353 (defun gnus-article-prepare (article &optional all-headers header)
3354 "Prepare ARTICLE in article mode buffer.
3355 ARTICLE should either be an article number or a Message-ID.
3356 If ARTICLE is an id, HEADER should be the article headers.
3357 If ALL-HEADERS is non-nil, no headers are hidden."
3359 ;; Make sure we start in a summary buffer.
3360 (unless (eq major-mode 'gnus-summary-mode)
3361 (set-buffer gnus-summary-buffer))
3362 (setq gnus-summary-buffer (current-buffer))
3363 (let* ((gnus-article (if header (mail-header-number header) article))
3364 (summary-buffer (current-buffer))
3365 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3366 (group gnus-newsgroup-name)
3369 (gnus-article-setup-buffer)
3370 (set-buffer gnus-article-buffer)
3371 ;; Deactivate active regions.
3372 (when (and (boundp 'transient-mark-mode)
3373 transient-mark-mode)
3374 (setq mark-active nil))
3375 (if (not (setq result (let ((buffer-read-only nil))
3376 (gnus-request-article-this-buffer
3378 ;; There is no such article.
3380 (when (and (numberp article)
3381 (not (memq article gnus-newsgroup-sparse)))
3382 (setq gnus-article-current
3383 (cons gnus-newsgroup-name article))
3384 (set-buffer gnus-summary-buffer)
3385 (setq gnus-current-article article)
3386 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
3388 (gnus-summary-set-agent-mark article)
3389 (message "Message marked for downloading"))
3390 (gnus-summary-mark-article article gnus-canceled-mark)
3391 (unless (memq article gnus-newsgroup-sparse)
3392 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3393 (if (or (eq result 'pseudo)
3394 (eq result 'nneething))
3397 (set-buffer summary-buffer)
3398 (push article gnus-newsgroup-history)
3399 (setq gnus-last-article gnus-current-article
3400 gnus-current-article 0
3401 gnus-current-headers nil
3402 gnus-article-current nil)
3403 (if (eq result 'nneething)
3404 (gnus-configure-windows 'summary)
3405 (gnus-configure-windows 'article))
3406 (gnus-set-global-variables))
3407 (let ((gnus-article-mime-handle-alist-1
3408 gnus-article-mime-handle-alist))
3409 (gnus-set-mode-line 'article)))
3410 ;; The result from the `request' was an actual article -
3411 ;; or at least some text that is now displayed in the
3413 (when (and (numberp article)
3414 (not (eq article gnus-current-article)))
3415 ;; Seems like a new article has been selected.
3416 ;; `gnus-current-article' must be an article number.
3418 (set-buffer summary-buffer)
3419 (push article gnus-newsgroup-history)
3420 (setq gnus-last-article gnus-current-article
3421 gnus-current-article article
3422 gnus-current-headers
3423 (gnus-summary-article-header gnus-current-article)
3424 gnus-article-current
3425 (cons gnus-newsgroup-name gnus-current-article))
3426 (unless (vectorp gnus-current-headers)
3427 (setq gnus-current-headers nil))
3428 (gnus-summary-goto-subject gnus-current-article)
3429 (when (gnus-summary-show-thread)
3430 ;; If the summary buffer really was folded, the
3431 ;; previous goto may not actually have gone to
3432 ;; the right article, but the thread root instead.
3434 (gnus-summary-goto-subject gnus-current-article))
3435 (gnus-run-hooks 'gnus-mark-article-hook)
3436 (gnus-set-mode-line 'summary)
3437 (when (gnus-visual-p 'article-highlight 'highlight)
3438 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3439 ;; Set the global newsgroup variables here.
3440 (gnus-set-global-variables)
3441 (setq gnus-have-all-headers
3442 (or all-headers gnus-show-all-headers))))
3444 (gnus-configure-windows 'article))
3445 (when (or (numberp article)
3447 (gnus-article-prepare-display)
3449 (goto-char (point-min))
3450 (setq gnus-page-broken
3451 (when gnus-break-pages
3452 (gnus-narrow-to-page)
3454 (let ((gnus-article-mime-handle-alist-1
3455 gnus-article-mime-handle-alist))
3456 (gnus-set-mode-line 'article))
3458 (set-window-point (get-buffer-window (current-buffer)) (point))
3459 (gnus-configure-windows 'article)
3463 (defun gnus-article-prepare-display ()
3464 "Make the current buffer look like a nice article."
3465 ;; Hooks for getting information from the article.
3466 ;; This hook must be called before being narrowed.
3467 (let ((gnus-article-buffer (current-buffer))
3469 (unless (eq major-mode 'gnus-article-mode)
3470 (gnus-article-mode))
3471 (setq buffer-read-only nil
3472 gnus-article-wash-types nil
3473 gnus-article-image-alist nil)
3474 (gnus-run-hooks 'gnus-tmp-internal-hook)
3475 (when gnus-display-mime-function
3476 (funcall gnus-display-mime-function))
3477 (gnus-run-hooks 'gnus-article-prepare-hook)))
3480 ;;; Gnus MIME viewing functions
3483 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3484 "Format of the MIME buttons.
3486 Valid specifiers include:
3488 %T MIME type, along with additional info
3489 %n The `name' parameter
3490 %d The description, if any
3491 %l The length of the encoded part
3492 %p The part identifier number
3493 %e Dots if the part isn't displayed
3495 General format specifiers can also be used. See
3496 (gnus)Formatting Variables.")
3498 (defvar gnus-mime-button-line-format-alist
3499 '((?t gnus-tmp-type ?s)
3500 (?T gnus-tmp-type-long ?s)
3501 (?n gnus-tmp-name ?s)
3502 (?d gnus-tmp-description ?s)
3504 (?l gnus-tmp-length ?d)
3505 (?e gnus-tmp-dots ?s)))
3507 (defvar gnus-mime-button-commands
3508 '((gnus-article-press-button "\r" "Toggle Display")
3509 (gnus-mime-view-part "v" "View Interactively...")
3510 (gnus-mime-view-part-as-type "t" "View As Type...")
3511 (gnus-mime-view-part-as-charset "C" "View As charset...")
3512 (gnus-mime-save-part "o" "Save...")
3513 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3514 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3515 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3516 (gnus-mime-internalize-part "E" "View Internally")
3517 (gnus-mime-externalize-part "e" "View Externally")
3518 (gnus-mime-print-part "p" "Print")
3519 (gnus-mime-pipe-part "|" "Pipe To Command...")
3520 (gnus-mime-action-on-part "." "Take action on the part")))
3522 (defun gnus-article-mime-part-status ()
3523 (if gnus-article-mime-handle-alist-1
3524 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3526 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3529 (defvar gnus-mime-button-map
3530 (let ((map (make-sparse-keymap)))
3531 (unless (>= (string-to-number emacs-version) 21)
3532 ;; XEmacs doesn't care.
3533 (set-keymap-parent map gnus-article-mode-map))
3534 (define-key map gnus-mouse-2 'gnus-article-push-button)
3535 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3536 (dolist (c gnus-mime-button-commands)
3537 (define-key map (cadr c) (car c)))
3540 (defun gnus-mime-button-menu (event)
3541 "Construct a context-sensitive menu of MIME commands."
3543 (save-window-excursion
3544 (let ((pos (event-start event)))
3545 (select-window (posn-window pos))
3546 (goto-char (posn-point pos))
3547 (gnus-article-check-buffer)
3548 (let ((response (x-popup-menu
3550 ("" ,@(mapcar (lambda (c)
3551 (cons (caddr c) (car c)))
3552 gnus-mime-button-commands))))))
3554 (call-interactively response))))))
3556 (defun gnus-mime-view-all-parts (&optional handles)
3557 "View all the MIME parts."
3559 (save-current-buffer
3560 (set-buffer gnus-article-buffer)
3561 (let ((handles (or handles gnus-article-mime-handles))
3562 (mail-parse-charset gnus-newsgroup-charset)
3563 (mail-parse-ignored-charsets
3564 (with-current-buffer gnus-summary-buffer
3565 gnus-newsgroup-ignored-charsets)))
3567 (mm-remove-parts handles)
3568 (goto-char (point-min))
3569 (or (search-forward "\n\n") (goto-char (point-max)))
3570 (let (buffer-read-only)
3571 (delete-region (point) (point-max))
3572 (mm-display-parts handles))))))
3574 (defun gnus-mime-save-part-and-strip ()
3575 "Save the MIME part under point then replace it with an external body."
3577 (gnus-article-check-buffer)
3578 (let* ((data (get-text-property (point) 'gnus-data))
3580 (handles gnus-article-mime-handles))
3581 (if (mm-multiple-handles gnus-article-mime-handles)
3582 (error "This function is not implemented"))
3583 (setq file (and data (mm-save-part data)))
3585 (with-current-buffer (mm-handle-buffer data)
3587 (insert "Content-Type: " (mm-handle-media-type data))
3588 (mml-insert-parameter-string (cdr (mm-handle-type data))
3591 (insert "Content-ID: " (message-make-message-id) "\n")
3592 (insert "Content-Transfer-Encoding: binary\n")
3595 (cdr (mm-make-handle nil
3596 `("message/external-body"
3597 (access-type . "LOCAL-FILE")
3599 (set-buffer gnus-summary-buffer)
3600 (gnus-article-edit-article
3603 (let ((mail-parse-charset (or gnus-article-charset
3604 ',gnus-newsgroup-charset))
3605 (mail-parse-ignored-charsets
3606 (or gnus-article-ignored-charsets
3607 ',gnus-newsgroup-ignored-charsets))
3608 (mbl mml-buffer-list))
3609 (setq mml-buffer-list nil)
3610 (insert-buffer gnus-original-article-buffer)
3611 (mime-to-mml ',handles)
3612 (setq gnus-article-mime-handles nil)
3613 (let ((mbl1 mml-buffer-list))
3614 (setq mml-buffer-list mbl)
3615 (set (make-local-variable 'mml-buffer-list) mbl1))
3616 ;; LOCAL argument of add-hook differs between GNU Emacs
3617 ;; and XEmacs. make-local-hook makes sure they are local.
3618 (make-local-hook 'kill-buffer-hook)
3619 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3620 `(lambda (no-highlight)
3621 (let ((mail-parse-charset (or gnus-article-charset
3622 ',gnus-newsgroup-charset))
3623 (message-options message-options)
3624 (message-options-set-recipient)
3625 (mail-parse-ignored-charsets
3626 (or gnus-article-ignored-charsets
3627 ',gnus-newsgroup-ignored-charsets)))
3629 (mml-destroy-buffers)
3630 (remove-hook 'kill-buffer-hook
3631 'mml-destroy-buffers t)
3632 (kill-local-variable 'mml-buffer-list))
3633 (gnus-summary-edit-article-done
3634 ,(or (mail-header-references gnus-current-headers) "")
3635 ,(gnus-group-read-only-p)
3636 ,gnus-summary-buffer no-highlight))))))
3638 (defun gnus-mime-save-part ()
3639 "Save the MIME part under point."
3641 (gnus-article-check-buffer)
3642 (let ((data (get-text-property (point) 'gnus-data)))
3644 (mm-save-part data))))
3646 (defun gnus-mime-pipe-part ()
3647 "Pipe the MIME part under point to a process."
3649 (gnus-article-check-buffer)
3650 (let ((data (get-text-property (point) 'gnus-data)))
3652 (mm-pipe-part data))))
3654 (defun gnus-mime-view-part ()
3655 "Interactively choose a viewing method for the MIME part under point."
3657 (gnus-article-check-buffer)
3658 (let ((data (get-text-property (point) 'gnus-data)))
3660 (setq gnus-article-mime-handles
3662 gnus-article-mime-handles (setq data (copy-sequence data))))
3663 (mm-interactively-view-part data))))
3665 (defun gnus-mime-view-part-as-type-internal ()
3666 (gnus-article-check-buffer)
3667 (let* ((name (mail-content-type-get
3668 (mm-handle-type (get-text-property (point) 'gnus-data))
3670 (def-type (and name (mm-default-file-encoding name))))
3671 (and def-type (cons def-type 0))))
3673 (defun gnus-mime-view-part-as-type (&optional mime-type)
3674 "Choose a MIME media type, and view the part as such."
3677 (setq mime-type (completing-read
3678 "View as MIME type: "
3679 (mapcar #'list (mailcap-mime-types))
3681 (gnus-mime-view-part-as-type-internal))))
3682 (gnus-article-check-buffer)
3683 (let ((handle (get-text-property (point) 'gnus-data)))
3686 (mm-make-handle (mm-handle-buffer handle)
3687 (cons mime-type (cdr (mm-handle-type handle)))
3688 (mm-handle-encoding handle)
3689 (mm-handle-undisplayer handle)
3690 (mm-handle-disposition handle)
3691 (mm-handle-description handle)
3693 (mm-handle-id handle)))
3694 (setq gnus-article-mime-handles
3695 (mm-merge-handles gnus-article-mime-handles handle))
3696 (gnus-mm-display-part handle))))
3698 (defun gnus-mime-copy-part (&optional handle)
3699 "Put the MIME part under point into a new buffer."
3701 (gnus-article-check-buffer)
3702 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3703 (contents (and handle (mm-get-part handle)))
3705 (file-name-nondirectory
3707 (mail-content-type-get (mm-handle-type handle) 'name)
3708 (mail-content-type-get (mm-handle-type handle)
3711 (buffer (and base (generate-new-buffer base))))
3713 (switch-to-buffer buffer)
3715 ;; We do it this way to make `normal-mode' set the appropriate mode.
3718 (setq buffer-file-name (expand-file-name base))
3720 (setq buffer-file-name nil))
3721 (goto-char (point-min)))))
3723 (defun gnus-mime-print-part (&optional handle)
3724 "Print the MIME part under point."
3726 (gnus-article-check-buffer)
3727 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3728 (contents (and handle (mm-get-part handle)))
3729 (file (make-temp-name (expand-file-name "mm." mm-tmp-directory)))
3730 (printer (mailcap-mime-info (mm-handle-type handle) "print")))
3735 (with-temp-file file
3737 (call-process shell-file-name nil
3738 (generate-new-buffer " *mm*")
3740 shell-command-switch
3742 printer file (mm-handle-type handle))))
3746 (gnus-print-buffer))))))
3748 (defun gnus-mime-inline-part (&optional handle arg)
3749 "Insert the MIME part under point into the current buffer."
3750 (interactive (list nil current-prefix-arg))
3751 (gnus-article-check-buffer)
3752 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3757 (if (and (not arg) (mm-handle-undisplayer handle))
3758 (mm-remove-part handle)
3759 (setq contents (mm-get-part handle))
3762 (setq charset (or (mail-content-type-get
3763 (mm-handle-type handle) 'charset)
3764 gnus-newsgroup-charset)))
3766 (if (mm-handle-undisplayer handle)
3767 (mm-remove-part handle))
3770 gnus-summary-show-article-charset-alist))
3771 (mm-read-coding-system "Charset: ")))))
3773 (mm-insert-inline handle
3775 (setq charset (mm-charset-to-coding-system
3777 (not (eq charset 'ascii)))
3778 (mm-decode-coding-string contents charset)
3782 (defun gnus-mime-view-part-as-charset (&optional handle arg)
3783 "Insert the MIME part under point into the current buffer using the
3785 (interactive (list nil current-prefix-arg))
3786 (gnus-article-check-buffer)
3787 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3792 (if (mm-handle-undisplayer handle)
3793 (mm-remove-part handle))
3794 (let ((gnus-newsgroup-charset
3796 gnus-summary-show-article-charset-alist))
3797 (mm-read-coding-system "Charset: ")))
3798 (gnus-newsgroup-ignored-charsets 'gnus-all))
3799 (gnus-article-press-button)))))
3801 (defun gnus-mime-externalize-part (&optional handle)
3802 "View the MIME part under point with an external viewer."
3804 (gnus-article-check-buffer)
3805 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3806 (mm-user-display-methods nil)
3807 (mm-inlined-types nil)
3808 (mail-parse-charset gnus-newsgroup-charset)
3809 (mail-parse-ignored-charsets
3810 (save-excursion (set-buffer gnus-summary-buffer)
3811 gnus-newsgroup-ignored-charsets)))
3813 (if (mm-handle-undisplayer handle)
3814 (mm-remove-part handle)
3815 (mm-display-part handle)))))
3817 (defun gnus-mime-internalize-part (&optional handle)
3818 "View the MIME part under point with an internal viewer.
3819 If no internal viewer is available, use an external viewer."
3821 (gnus-article-check-buffer)
3822 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3823 (mm-inlined-types '(".*"))
3824 (mm-inline-large-images t)
3825 (mail-parse-charset gnus-newsgroup-charset)
3826 (mail-parse-ignored-charsets
3827 (save-excursion (set-buffer gnus-summary-buffer)
3828 gnus-newsgroup-ignored-charsets)))
3830 (if (mm-handle-undisplayer handle)
3831 (mm-remove-part handle)
3832 (mm-display-part handle)))))
3834 (defun gnus-mime-action-on-part (&optional action)
3835 "Do something with the MIME attachment at \(point\)."
3837 (list (completing-read "Action: " gnus-mime-action-alist)))
3838 (gnus-article-check-buffer)
3839 (let ((action-pair (assoc action gnus-mime-action-alist)))
3841 (funcall (cdr action-pair)))))
3843 (defun gnus-article-part-wrapper (n function)
3844 (save-current-buffer
3845 (set-buffer gnus-article-buffer)
3846 (when (> n (length gnus-article-mime-handle-alist))
3847 (error "No such part"))
3848 (gnus-article-goto-part n)
3849 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3850 (funcall function handle))))
3852 (defun gnus-article-pipe-part (n)
3853 "Pipe MIME part N, which is the numerical prefix."
3855 (gnus-article-part-wrapper n 'mm-pipe-part))
3857 (defun gnus-article-save-part (n)
3858 "Save MIME part N, which is the numerical prefix."
3860 (gnus-article-part-wrapper n 'mm-save-part))
3862 (defun gnus-article-interactively-view-part (n)
3863 "View MIME part N interactively, which is the numerical prefix."
3865 (gnus-article-part-wrapper n 'mm-interactively-view-part))
3867 (defun gnus-article-copy-part (n)
3868 "Copy MIME part N, which is the numerical prefix."
3870 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
3872 (defun gnus-article-view-part-as-charset (n)
3873 "Copy MIME part N, which is the numerical prefix."
3875 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
3877 (defun gnus-article-externalize-part (n)
3878 "View MIME part N externally, which is the numerical prefix."
3880 (gnus-article-part-wrapper n 'gnus-mime-externalize-part))
3882 (defun gnus-article-inline-part (n)
3883 "Inline MIME part N, which is the numerical prefix."
3885 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
3887 (defun gnus-article-mime-match-handle-first (condition)
3889 (let ((alist gnus-article-mime-handle-alist) ihandle n)
3890 (while (setq ihandle (pop alist))
3892 ((functionp condition)
3893 (funcall condition (cdr ihandle)))
3894 ((eq condition 'undisplayed)
3895 (not (or (mm-handle-undisplayer (cdr ihandle))
3896 (equal (mm-handle-media-type (cdr ihandle))
3897 "multipart/alternative"))))
3898 ((eq condition 'undisplayed-alternative)
3899 (not (mm-handle-undisplayer (cdr ihandle))))
3901 (gnus-article-goto-part (car ihandle))
3902 (or (not n) (< (car ihandle) n)))
3903 (setq n (car ihandle))))
3907 (defun gnus-article-view-part (&optional n)
3908 "View MIME part N, which is the numerical prefix."
3910 (save-current-buffer
3911 (set-buffer gnus-article-buffer)
3912 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
3913 gnus-article-mime-match-handle-function)))
3914 (when (> n (length gnus-article-mime-handle-alist))
3915 (error "No such part"))
3916 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3917 (when (gnus-article-goto-part n)
3918 (if (equal (car handle) "multipart/alternative")
3919 (gnus-article-press-button)
3920 (when (eq (gnus-mm-display-part handle) 'internal)
3921 (gnus-set-window-start)))))))
3923 (defsubst gnus-article-mime-total-parts ()
3924 (if (bufferp (car gnus-article-mime-handles))
3926 (1- (length gnus-article-mime-handles))))
3928 (defun gnus-mm-display-part (handle)
3929 "Display HANDLE and fix MIME button."
3930 (let ((id (get-text-property (point) 'gnus-part))
3935 (let ((window (selected-window))
3936 (mail-parse-charset gnus-newsgroup-charset)
3937 (mail-parse-ignored-charsets
3938 (save-excursion (set-buffer gnus-summary-buffer)
3939 gnus-newsgroup-ignored-charsets)))
3942 (let ((win (gnus-get-buffer-window (current-buffer) t))
3945 (select-window win))
3948 (if (mm-handle-displayed-p handle)
3949 ;; This will remove the part.
3950 (mm-display-part handle)
3952 (narrow-to-region (point)
3953 (if (eobp) (point) (1+ (point))))
3954 (mm-display-part handle)
3955 ;; We narrow to the part itself and
3956 ;; then call the treatment functions.
3957 (goto-char (point-min))
3959 (narrow-to-region (point) (point-max))
3962 (gnus-article-mime-total-parts)
3963 (mm-handle-media-type handle)))))
3964 (if (window-live-p window)
3965 (select-window window)))))
3967 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
3968 (gnus-insert-mime-button
3969 handle id (list (mm-handle-displayed-p handle)))
3970 (goto-char point))))
3972 (defun gnus-article-goto-part (n)
3973 "Go to MIME part N."
3974 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
3976 (goto-char point))))
3978 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
3979 (let ((gnus-tmp-name
3980 (or (mail-content-type-get (mm-handle-type handle) 'name)
3981 (mail-content-type-get (mm-handle-disposition handle) 'filename)
3982 (mail-content-type-get (mm-handle-type handle) 'url)
3984 (gnus-tmp-type (mm-handle-media-type handle))
3985 (gnus-tmp-description
3986 (mail-decode-encoded-word-string (or (mm-handle-description handle)
3989 (if (if displayed (car displayed)
3990 (mm-handle-displayed-p handle))
3992 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
3994 gnus-tmp-type-long b e)
3995 (when (string-match ".*/" gnus-tmp-name)
3996 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
3997 (setq gnus-tmp-type-long (concat gnus-tmp-type
3998 (and (not (equal gnus-tmp-name ""))
3999 (concat "; " gnus-tmp-name))))
4000 (unless (equal gnus-tmp-description "")
4001 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4006 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4007 `(,@(gnus-local-map-property gnus-mime-button-map)
4008 gnus-callback gnus-mm-display-part
4009 gnus-part ,gnus-tmp-id
4010 article-type annotation
4013 (widget-convert-button
4016 :action 'gnus-widget-press-button
4017 :button-keymap gnus-mime-button-map
4019 (lambda (widget/window &optional overlay pos)
4020 ;; Needed to properly clear the message due to a bug in
4021 ;; wid-edit (XEmacs only).
4022 (if (boundp 'help-echo-owns-message)
4023 (setq help-echo-owns-message t))
4025 "%S: %s the MIME part; %S: more options"
4026 (aref gnus-mouse-2 0)
4027 ;; XEmacs will get a single widget arg; Emacs 21 will get
4028 ;; window, overlay, position.
4029 (if (mm-handle-displayed-p
4031 (with-current-buffer (gnus-overlay-buffer overlay)
4032 (widget-get (widget-at (gnus-overlay-start overlay))
4034 (widget-get widget/window :mime-handle)))
4036 (aref gnus-down-mouse-3 0))))))
4038 (defun gnus-widget-press-button (elems el)
4039 (goto-char (widget-get elems :from))
4040 (gnus-article-press-button))
4042 (defvar gnus-displaying-mime nil)
4044 (defun gnus-display-mime (&optional ihandles)
4045 "Display the MIME parts."
4047 (save-selected-window
4048 (let ((window (get-buffer-window gnus-article-buffer))
4051 (select-window window)
4052 ;; We have to do this since selecting the window
4053 ;; may change the point. So we set the window point.
4054 (set-window-point window point)))
4055 (let* ((handles (or ihandles (mm-dissect-buffer) (mm-uu-dissect)))
4056 buffer-read-only handle name type b e display)
4057 (when (and (not ihandles)
4058 (not gnus-displaying-mime))
4059 ;; Top-level call; we clean up.
4060 (when gnus-article-mime-handles
4061 (mm-destroy-parts gnus-article-mime-handles)
4062 (setq gnus-article-mime-handle-alist nil));; A trick.
4063 (setq gnus-article-mime-handles handles)
4064 ;; We allow users to glean info from the handles.
4065 (when gnus-article-mime-part-function
4066 (gnus-mime-part-function handles)))
4068 (or (not (stringp (car handles)))
4071 (when (and (not ihandles)
4072 (not gnus-displaying-mime))
4073 ;; Clean up for mime parts.
4075 (delete-region (point) (point-max)))
4076 (let ((gnus-displaying-mime t))
4077 (gnus-mime-display-part handles)))
4080 (narrow-to-region (point) (point-max))
4081 (gnus-treat-article nil 1 1)
4084 ;; Highlight the headers.
4088 (narrow-to-region (point-min) (point))
4089 (gnus-treat-article 'head))))))))
4091 (defvar gnus-mime-display-multipart-as-mixed nil)
4092 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
4093 (defvar gnus-mime-display-multipart-related-as-mixed nil)
4095 (defun gnus-mime-display-part (handle)
4098 ((not (stringp (car handle)))
4099 (gnus-mime-display-single handle))
4100 ;; User-defined multipart
4101 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4102 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4104 ;; multipart/alternative
4105 ((and (equal (car handle) "multipart/alternative")
4106 (not (or gnus-mime-display-multipart-as-mixed
4107 gnus-mime-display-multipart-alternative-as-mixed)))
4108 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4109 (push (cons id handle) gnus-article-mime-handle-alist)
4110 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4111 ;; multipart/related
4112 ((and (equal (car handle) "multipart/related")
4113 (not (or gnus-mime-display-multipart-as-mixed
4114 gnus-mime-display-multipart-related-as-mixed)))
4115 ;;;!!!We should find the start part, but we just default
4116 ;;;!!!to the first part.
4117 ;;(gnus-mime-display-part (cadr handle))
4118 ;;;!!! Most multipart/related is an HTML message plus images.
4119 ;;;!!! Unfortunately we are unable to let W3 display those
4120 ;;;!!! included images, so we just display it as a mixed multipart.
4121 ;;(gnus-mime-display-mixed (cdr handle))
4122 ;;;!!! No, w3 can display everything just fine.
4123 (gnus-mime-display-part (cadr handle)))
4124 ((equal (car handle) "multipart/signed")
4125 (gnus-add-wash-type 'signed)
4126 (gnus-mime-display-security handle))
4127 ((equal (car handle) "multipart/encrypted")
4128 (gnus-add-wash-type 'encrypted)
4129 (gnus-mime-display-security handle))
4130 ;; Other multiparts are handled like multipart/mixed.
4132 (gnus-mime-display-mixed (cdr handle)))))
4134 (defun gnus-mime-part-function (handles)
4135 (if (stringp (car handles))
4136 (mapcar 'gnus-mime-part-function (cdr handles))
4137 (funcall gnus-article-mime-part-function handles)))
4139 (defun gnus-mime-display-mixed (handles)
4140 (mapcar 'gnus-mime-display-part handles))
4142 (defun gnus-mime-display-single (handle)
4143 (let ((type (mm-handle-media-type handle))
4144 (ignored gnus-ignored-mime-types)
4151 (when (string-match (pop ignored) type)
4152 (throw 'ignored nil)))
4153 (if (and (setq not-attachment
4154 (and (not (mm-inline-override-p handle))
4155 (or (not (mm-handle-disposition handle))
4156 (equal (car (mm-handle-disposition handle))
4158 (mm-attachment-override-p handle))))
4159 (mm-automatic-display-p handle)
4161 (mm-inlinable-p handle)
4162 (mm-inlined-p handle))
4163 (mm-automatic-external-display-p type)))
4165 (when (equal (mm-handle-media-supertype handle) "text")
4167 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4169 (push (cons id handle) gnus-article-mime-handle-alist)
4170 (when (or (not display)
4171 (not (gnus-unbuttonized-mime-type-p type)))
4172 ;(gnus-article-insert-newline)
4173 (gnus-insert-mime-button
4174 handle id (list (or display (and not-attachment text))))
4175 (gnus-article-insert-newline)
4176 ;(gnus-article-insert-newline)
4177 ;; Remember modify the number of forward lines.
4185 (let ((mail-parse-charset gnus-newsgroup-charset)
4186 (mail-parse-ignored-charsets
4187 (save-excursion (condition-case ()
4188 (set-buffer gnus-summary-buffer)
4190 gnus-newsgroup-ignored-charsets)))
4191 (mm-display-part handle t))
4192 (goto-char (point-max)))
4193 ((and text not-attachment)
4197 (gnus-article-insert-newline)
4198 (mm-insert-inline handle (mm-get-part handle))
4199 (goto-char (point-max))))
4203 (narrow-to-region beg (point))
4206 (gnus-article-mime-total-parts)
4207 (mm-handle-media-type handle)))))))))
4209 (defun gnus-unbuttonized-mime-type-p (type)
4210 "Say whether TYPE is to be unbuttonized."
4211 (unless gnus-inhibit-mime-unbuttonizing
4213 (let ((types gnus-unbuttonized-mime-types))
4215 (when (string-match (pop types) type)
4216 (throw 'found t)))))
4218 (let ((types gnus-buttonized-mime-types))
4220 (when (string-match (pop types) type)
4221 (throw 'found t)))))))))
4223 (defun gnus-article-insert-newline ()
4224 "Insert a newline, but mark it as undeletable."
4225 (gnus-put-text-property
4226 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4228 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4229 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4232 handle buffer-read-only from props begend not-pref)
4233 (save-window-excursion
4236 (narrow-to-region (car ibegend)
4239 (goto-char (car ibegend))
4242 (delete-region (point-min) (point-max))
4243 (mm-remove-parts handles))
4244 (setq begend (list (point-marker)))
4246 (unless (setq not-pref (cadr (member preferred ihandles)))
4247 (setq not-pref (car ihandles)))
4250 (not (gnus-unbuttonized-mime-type-p
4251 "multipart/alternative")))
4252 (gnus-add-text-properties
4255 (insert (format "%d. " id))
4259 (unless ,(not ibegend)
4260 (setq gnus-article-mime-handle-alist
4261 ',gnus-article-mime-handle-alist))
4262 (gnus-mime-display-alternative
4263 ',ihandles ',not-pref ',begend ,id))
4264 ,@(gnus-local-map-property gnus-mime-button-map)
4265 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4266 face ,gnus-article-button-face
4269 (widget-convert-button 'link from (point)
4270 :action 'gnus-widget-press-button
4271 :button-keymap gnus-widget-button-keymap)
4273 (while (setq handle (pop handles))
4274 (gnus-add-text-properties
4277 (insert (format "(%c) %-18s"
4278 (if (equal handle preferred) ?* ? )
4279 (mm-handle-media-type handle)))
4283 (unless ,(not ibegend)
4284 (setq gnus-article-mime-handle-alist
4285 ',gnus-article-mime-handle-alist))
4286 (gnus-mime-display-alternative
4287 ',ihandles ',handle ',begend ,id))
4288 ,@(gnus-local-map-property gnus-mime-button-map)
4289 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4290 face ,gnus-article-button-face
4293 (widget-convert-button 'link from (point)
4294 :action 'gnus-widget-press-button
4295 :button-keymap gnus-widget-button-keymap)
4299 (if (stringp (car preferred))
4300 (gnus-display-mime preferred)
4301 (let ((mail-parse-charset gnus-newsgroup-charset)
4302 (mail-parse-ignored-charsets
4303 (save-excursion (set-buffer gnus-summary-buffer)
4304 gnus-newsgroup-ignored-charsets)))
4305 (mm-display-part preferred)
4309 (narrow-to-region (car begend) (point-max))
4311 nil (length gnus-article-mime-handle-alist)
4312 (gnus-article-mime-total-parts)
4313 (mm-handle-media-type handle))))))
4314 (goto-char (point-max))
4315 (setcdr begend (point-marker)))))
4317 (goto-char point))))
4319 (defconst gnus-article-wash-status-strings
4320 (let ((alist '((cite "c" "Possible hidden citation text"
4321 " " "All citation text visible")
4322 (headers "h" "Hidden headers"
4323 " " "All headers visible.")
4324 (pgp "p" "Encrypted or signed message status hidden"
4325 " " "No hidden encryption nor digital signature status")
4326 (signature "s" "Signature has been hidden"
4327 " " "Signature is visible")
4328 (overstrike "o" "Overstrike (^H) characters applied"
4329 " " "No overstrike characters applied")
4330 (emphasis "e" "/*_Emphasis_*/ characters applied"
4331 " " "No /*_emphasis_*/ characters applied")))
4333 (dolist (entry alist result)
4334 (let ((key (nth 0 entry))
4335 (on (copy-sequence (nth 1 entry)))
4336 (on-help (nth 2 entry))
4337 (off (copy-sequence (nth 3 entry)))
4338 (off-help (nth 4 entry)))
4339 (put-text-property 0 1 'help-echo on-help on)
4340 (put-text-property 0 1 'help-echo off-help off)
4341 (push (list key on off) result))))
4342 "Alist of strings describing wash status in the mode line.
4343 Each entry has the form (KEY ON OF), where the KEY is a symbol
4344 representing the particular washing function, ON is the string to use
4345 in the article mode line when the washing function is active, and OFF
4346 is the string to use when it is inactive.")
4348 (defun gnus-article-wash-status-entry (key value)
4349 (let ((entry (assoc key gnus-article-wash-status-strings)))
4350 (if value (nth 1 entry) (nth 2 entry))))
4352 (defun gnus-article-wash-status ()
4353 "Return a string which display status of article washing."
4355 (set-buffer gnus-article-buffer)
4356 (let ((cite (memq 'cite gnus-article-wash-types))
4357 (headers (memq 'headers gnus-article-wash-types))
4358 (boring (memq 'boring-headers gnus-article-wash-types))
4359 (pgp (memq 'pgp gnus-article-wash-types))
4360 (pem (memq 'pem gnus-article-wash-types))
4361 (signed (memq 'signed gnus-article-wash-types))
4362 (encrypted (memq 'encrypted gnus-article-wash-types))
4363 (signature (memq 'signature gnus-article-wash-types))
4364 (overstrike (memq 'overstrike gnus-article-wash-types))
4365 (emphasis (memq 'emphasis gnus-article-wash-types)))
4367 (gnus-article-wash-status-entry 'cite cite)
4368 (gnus-article-wash-status-entry 'headers (or headers boring))
4369 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4370 (gnus-article-wash-status-entry 'signature signature)
4371 (gnus-article-wash-status-entry 'overstrike overstrike)
4372 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4374 (defun gnus-add-wash-type (type)
4375 "Add a washing of TYPE to the current status."
4376 (push type gnus-article-wash-types))
4378 (defun gnus-delete-wash-type (type)
4379 "Add a washing of TYPE to the current status."
4380 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4382 (defun gnus-add-image (category image)
4383 "Add IMAGE of CATEGORY to the list of displayed images."
4384 (let ((entry (assq category gnus-article-image-alist)))
4386 (setq entry (list category))
4387 (push entry gnus-article-image-alist))
4388 (nconc entry (list image))))
4390 (defun gnus-delete-images (category)
4391 "Delete all images in CATEGORY."
4392 (let ((entry (assq category gnus-article-image-alist)))
4393 (dolist (image (cdr entry))
4394 (gnus-remove-image image))
4395 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4396 (gnus-delete-wash-type category)))
4398 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4400 (defun gnus-article-maybe-hide-headers ()
4401 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4402 Provided for backwards compatibility."
4403 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4404 (not (save-excursion (set-buffer gnus-summary-buffer)
4405 gnus-have-all-headers)))
4406 (not gnus-inhibit-hiding))
4407 (gnus-article-hide-headers)))
4411 (defun gnus-output-to-file (file-name)
4412 "Append the current article to a file named FILE-NAME."
4413 (let ((artbuf (current-buffer)))
4415 (insert-buffer-substring artbuf)
4416 ;; Append newline at end of the buffer as separator, and then
4418 (goto-char (point-max))
4420 (let ((file-name-coding-system nnmail-pathname-coding-system))
4421 (mm-append-to-file (point-min) (point-max) file-name))
4424 (defun gnus-narrow-to-page (&optional arg)
4425 "Narrow the article buffer to a page.
4426 If given a numerical ARG, move forward ARG pages."
4428 (setq arg (if arg (prefix-numeric-value arg) 0))
4430 (set-buffer gnus-article-buffer)
4431 (goto-char (point-min))
4433 ;; Remove any old next/prev buttons.
4434 (when (gnus-visual-p 'page-marker)
4435 (let ((buffer-read-only nil))
4436 (gnus-remove-text-with-property 'gnus-prev)
4437 (gnus-remove-text-with-property 'gnus-next)))
4440 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4442 (re-search-forward page-delimiter nil 'move arg)))
4443 (goto-char (match-end 0)))
4446 (if (re-search-forward page-delimiter nil 'move)
4449 (when (and (gnus-visual-p 'page-marker)
4450 (not (= (point-min) 1)))
4452 (goto-char (point-min))
4453 (gnus-insert-prev-page-button)))
4454 (when (and (gnus-visual-p 'page-marker)
4455 (< (+ (point-max) 2) (buffer-size)))
4457 (goto-char (point-max))
4458 (gnus-insert-next-page-button)))))
4460 ;; Article mode commands
4462 (defun gnus-article-goto-next-page ()
4463 "Show the next page of the article."
4465 (when (gnus-article-next-page)
4466 (goto-char (point-min))
4467 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4469 (defun gnus-article-goto-prev-page ()
4470 "Show the next page of the article."
4472 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4473 (gnus-article-prev-page nil)))
4475 (defun gnus-article-next-page (&optional lines)
4476 "Show the next page of the current article.
4477 If end of article, return non-nil. Otherwise return nil.
4478 Argument LINES specifies lines to be scrolled up."
4480 (move-to-window-line -1)
4483 (and (pos-visible-in-window-p) ;Not continuation line.
4485 ;; Nothing in this page.
4486 (if (or (not gnus-page-broken)
4489 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
4491 (gnus-narrow-to-page 1) ;Go to next page.
4493 ;; More in this page.
4494 (let ((scroll-in-place nil))
4498 ;; Long lines may cause an end-of-buffer error.
4499 (goto-char (point-max)))))
4500 (move-to-window-line 0)
4503 (defun gnus-article-prev-page (&optional lines)
4504 "Show previous page of current article.
4505 Argument LINES specifies lines to be scrolled down."
4507 (move-to-window-line 0)
4508 (if (and gnus-page-broken
4510 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
4512 (gnus-narrow-to-page -1) ;Go to previous page.
4513 (goto-char (point-max))
4515 (let ((scroll-in-place nil))
4519 (beginning-of-buffer
4520 (goto-char (point-min))))
4521 (move-to-window-line 0)))))
4523 (defun gnus-article-refer-article ()
4524 "Read article specified by message-id around point."
4526 (let ((point (point)))
4527 (search-forward ">" nil t) ;Move point to end of "<....>".
4528 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
4529 (let ((message-id (match-string 1)))
4531 (set-buffer gnus-summary-buffer)
4532 (gnus-summary-refer-article message-id))
4534 (error "No references around point"))))
4536 (defun gnus-article-show-summary ()
4537 "Reconfigure windows to show summary buffer."
4539 (if (not (gnus-buffer-live-p gnus-summary-buffer))
4540 (error "There is no summary buffer for this article buffer")
4541 (gnus-article-set-globals)
4542 (gnus-configure-windows 'article)
4543 (gnus-summary-goto-subject gnus-current-article)
4544 (gnus-summary-position-point)))
4546 (defun gnus-article-describe-briefly ()
4547 "Describe article mode commands briefly."
4549 (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")))
4551 (defun gnus-article-summary-command ()
4552 "Execute the last keystroke in the summary buffer."
4554 (let ((obuf (current-buffer))
4555 (owin (current-window-configuration))
4557 (switch-to-buffer gnus-article-current-summary 'norecord)
4558 (setq func (lookup-key (current-local-map) (this-command-keys)))
4559 (call-interactively func)
4561 (set-window-configuration owin)
4562 (set-window-point (get-buffer-window (current-buffer)) (point))))
4564 (defun gnus-article-summary-command-nosave ()
4565 "Execute the last keystroke in the summary buffer."
4568 (pop-to-buffer gnus-article-current-summary 'norecord)
4569 (setq func (lookup-key (current-local-map) (this-command-keys)))
4570 (call-interactively func)))
4572 (defun gnus-article-check-buffer ()
4573 "Beep if not in an article buffer."
4574 (unless (equal major-mode 'gnus-article-mode)
4575 (error "Command invoked outside of a Gnus article buffer")))
4577 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
4578 "Read a summary buffer key sequence and execute it from the article buffer."
4580 (gnus-article-check-buffer)
4582 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
4583 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
4584 "=" "^" "\M-^" "|"))
4590 '("n" "Gn" "p" "Gp"))
4593 (set-buffer gnus-article-current-summary)
4594 (let (gnus-pick-mode)
4595 (push (or key last-command-event) unread-command-events)
4596 (setq keys (if (featurep 'xemacs)
4597 (events-to-keys (read-key-sequence nil))
4598 (read-key-sequence nil)))))
4602 (if (or (member keys nosaves)
4603 (member keys nosave-but-article)
4604 (member keys nosave-in-article))
4606 (save-window-excursion
4607 (pop-to-buffer gnus-article-current-summary 'norecord)
4608 ;; We disable the pick minor mode commands.
4609 (let (gnus-pick-mode)
4610 (setq func (lookup-key (current-local-map) keys))))
4614 (unless (member keys nosave-in-article)
4615 (set-buffer gnus-article-current-summary))
4616 (call-interactively func)
4617 (setq new-sum-point (point)))
4618 (when (member keys nosave-but-article)
4619 (pop-to-buffer gnus-article-buffer 'norecord)))
4620 ;; These commands should restore window configuration.
4621 (let ((obuf (current-buffer))
4622 (owin (current-window-configuration))
4624 (summary gnus-article-current-summary)
4625 func in-buffer selected)
4626 (if not-restore-window
4627 (pop-to-buffer summary 'norecord)
4628 (switch-to-buffer summary 'norecord))
4629 (setq in-buffer (current-buffer))
4630 ;; We disable the pick minor mode commands.
4631 (if (and (setq func (let (gnus-pick-mode)
4632 (lookup-key (current-local-map) keys)))
4635 (call-interactively func)
4636 (setq new-sum-point (point))
4637 (when (eq in-buffer (current-buffer))
4638 (setq selected (gnus-summary-select-article))
4640 (unless not-restore-window
4641 (set-window-configuration owin))
4642 (when (eq selected 'old)
4644 (set-window-start (get-buffer-window (current-buffer))
4646 (set-window-point (get-buffer-window (current-buffer))
4648 (let ((win (get-buffer-window gnus-article-current-summary)))
4650 (set-window-point win new-sum-point)))) )
4651 (switch-to-buffer gnus-article-buffer)
4654 (defun gnus-article-describe-key (key)
4655 "Display documentation of the function invoked by KEY. KEY is a string."
4656 (interactive "kDescribe key: ")
4657 (gnus-article-check-buffer)
4658 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4660 (set-buffer gnus-article-current-summary)
4661 (let (gnus-pick-mode)
4662 (if (featurep 'xemacs)
4664 (push (elt key 0) unread-command-events)
4665 (setq key (events-to-keys
4666 (read-key-sequence "Describe key: "))))
4667 (setq unread-command-events
4669 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4670 (string-to-list key)))
4671 (setq key (read-key-sequence "Describe key: "))))
4673 (describe-key key)))
4675 (defun gnus-article-describe-key-briefly (key &optional insert)
4676 "Display documentation of the function invoked by KEY. KEY is a string."
4677 (interactive "kDescribe key: \nP")
4678 (gnus-article-check-buffer)
4679 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4681 (set-buffer gnus-article-current-summary)
4682 (let (gnus-pick-mode)
4683 (if (featurep 'xemacs)
4685 (push (elt key 0) unread-command-events)
4686 (setq key (events-to-keys
4687 (read-key-sequence "Describe key: "))))
4688 (setq unread-command-events
4690 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4691 (string-to-list key)))
4692 (setq key (read-key-sequence "Describe key: "))))
4693 (describe-key-briefly key insert))
4694 (describe-key-briefly key insert)))
4696 (defun gnus-article-reply-with-original (&optional wide)
4697 "Start composing a reply mail to the current message.
4698 The text in the region will be yanked. If the region isn't active,
4699 the entire article will be yanked."
4701 (let ((article (cdr gnus-article-current)) cont)
4703 (gnus-summary-reply (list (list article)) wide)
4704 (setq cont (buffer-substring (point) (mark)))
4705 ;; Deactivate active regions.
4706 (when (and (boundp 'transient-mark-mode)
4707 transient-mark-mode)
4708 (setq mark-active nil))
4710 (list (list article cont)) wide))))
4712 (defun gnus-article-followup-with-original ()
4713 "Compose a followup to the current article.
4714 The text in the region will be yanked. If the region isn't active,
4715 the entire article will be yanked."
4717 (let ((article (cdr gnus-article-current))
4719 (if (not (gnus-region-active-p))
4720 (gnus-summary-followup (list (list article)))
4721 (setq cont (buffer-substring (point) (mark)))
4722 ;; Deactivate active regions.
4723 (when (and (boundp 'transient-mark-mode)
4724 transient-mark-mode)
4725 (setq mark-active nil))
4726 (gnus-summary-followup
4727 (list (list article cont))))))
4729 (defun gnus-article-hide (&optional arg force)
4730 "Hide all the gruft in the current article.
4731 This means that PGP stuff, signatures, cited text and (some)
4732 headers will be hidden.
4733 If given a prefix, show the hidden text instead."
4734 (interactive (append (gnus-article-hidden-arg) (list 'force)))
4735 (gnus-article-hide-headers arg)
4736 (gnus-article-hide-list-identifiers arg)
4737 (gnus-article-hide-pgp arg)
4738 (gnus-article-hide-citation-maybe arg force)
4739 (gnus-article-hide-signature arg))
4741 (defun gnus-article-maybe-highlight ()
4742 "Do some article highlighting if article highlighting is requested."
4743 (when (gnus-visual-p 'article-highlight 'highlight)
4744 (gnus-article-highlight-some)))
4746 (defun gnus-check-group-server ()
4747 ;; Make sure the connection to the server is alive.
4748 (unless (gnus-server-opened
4749 (gnus-find-method-for-group gnus-newsgroup-name))
4750 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
4751 (gnus-request-group gnus-newsgroup-name t)))
4753 (defun gnus-request-article-this-buffer (article group)
4754 "Get an article and insert it into this buffer."
4755 (let (do-update-line sparse-header)
4759 (gnus-kill-all-overlays)
4760 (setq group (or group gnus-newsgroup-name))
4762 ;; Using `gnus-request-article' directly will insert the article into
4763 ;; `nntp-server-buffer' - so we'll save some time by not having to
4764 ;; copy it from the server buffer into the article buffer.
4766 ;; We only request an article by message-id when we do not have the
4767 ;; headers for it, so we'll have to get those.
4768 (when (stringp article)
4769 (gnus-read-header article))
4771 ;; If the article number is negative, that means that this article
4772 ;; doesn't belong in this newsgroup (possibly), so we find its
4773 ;; message-id and request it by id instead of number.
4774 (when (and (numberp article)
4776 (get-buffer gnus-summary-buffer)
4777 (gnus-buffer-exists-p gnus-summary-buffer))
4779 (set-buffer gnus-summary-buffer)
4780 (let ((header (gnus-summary-article-header article)))
4783 ((memq article gnus-newsgroup-sparse)
4784 ;; This is a sparse gap article.
4785 (setq do-update-line article)
4786 (setq article (mail-header-id header))
4787 (setq sparse-header (gnus-read-header article))
4788 (setq gnus-newsgroup-sparse
4789 (delq article gnus-newsgroup-sparse)))
4791 ;; It's a real article.
4792 (setq article (mail-header-id header)))
4794 ;; It is an extracted pseudo-article.
4795 (setq article 'pseudo)
4796 (gnus-request-pseudo-article header))))
4798 (let ((method (gnus-find-method-for-group
4799 gnus-newsgroup-name)))
4800 (when (and (eq (car method) 'nneething)
4802 (let ((dir (expand-file-name
4803 (mail-header-subject header)
4804 (file-name-as-directory
4805 (or (cadr (assq 'nneething-address method))
4807 (when (file-directory-p dir)
4808 (setq article 'nneething)
4809 (gnus-group-enter-directory dir))))))))
4812 ;; Refuse to select canceled articles.
4813 ((and (numberp article)
4815 (get-buffer gnus-summary-buffer)
4816 (gnus-buffer-exists-p gnus-summary-buffer)
4817 (eq (cdr (save-excursion
4818 (set-buffer gnus-summary-buffer)
4819 (assq article gnus-newsgroup-reads)))
4820 gnus-canceled-mark))
4822 ;; We first check `gnus-original-article-buffer'.
4823 ((and (get-buffer gnus-original-article-buffer)
4826 (set-buffer gnus-original-article-buffer)
4827 (and (equal (car gnus-original-article) group)
4828 (eq (cdr gnus-original-article) article))))
4829 (insert-buffer-substring gnus-original-article-buffer)
4831 ;; Check the backlog.
4832 ((and gnus-keep-backlog
4833 (gnus-backlog-request-article group article (current-buffer)))
4835 ;; Check asynchronous pre-fetch.
4836 ((gnus-async-request-fetched-article group article (current-buffer))
4837 (gnus-async-prefetch-next group article gnus-summary-buffer)
4838 (when (and (numberp article) gnus-keep-backlog)
4839 (gnus-backlog-enter-article group article (current-buffer)))
4842 ((and gnus-use-cache
4844 (gnus-cache-request-article article group))
4846 ;; Check the agent cache.
4847 ((and gnus-agent gnus-agent-cache gnus-plugged
4849 (gnus-agent-request-article article group))
4851 ;; Get the article and put into the article buffer.
4852 ((or (stringp article)
4854 (let ((gnus-override-method gnus-override-method)
4855 (methods (and (stringp article)
4856 gnus-refer-article-method))
4858 (buffer-read-only nil))
4859 (if (or (not (listp methods))
4860 (and (symbolp (car methods))
4861 (assq (car methods) nnoo-definition-alist)))
4862 (setq methods (list methods)))
4863 (when (and (null gnus-override-method)
4865 (setq gnus-override-method (pop methods)))
4867 (when (eq gnus-override-method 'current)
4868 (setq gnus-override-method
4869 (with-current-buffer gnus-summary-buffer
4870 gnus-current-select-method)))
4872 (gnus-kill-all-overlays)
4873 (let ((gnus-newsgroup-name group))
4874 (gnus-check-group-server))
4875 (when (gnus-request-article article group (current-buffer))
4876 (when (numberp article)
4877 (gnus-async-prefetch-next group article
4878 gnus-summary-buffer)
4879 (when gnus-keep-backlog
4880 (gnus-backlog-enter-article
4881 group article (current-buffer))))
4882 (setq result 'article))
4885 (setq gnus-override-method (pop methods))
4886 (setq result 'done))))
4887 (and (eq result 'article) 'article)))
4891 ;; Associate this article with the current summary buffer.
4892 (setq gnus-article-current-summary gnus-summary-buffer)
4894 ;; Take the article from the original article buffer
4895 ;; and place it in the buffer it's supposed to be in.
4896 (when (and (get-buffer gnus-article-buffer)
4897 (equal (buffer-name (current-buffer))
4898 (buffer-name (get-buffer gnus-article-buffer))))
4900 (if (get-buffer gnus-original-article-buffer)
4901 (set-buffer gnus-original-article-buffer)
4902 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
4903 (buffer-disable-undo)
4904 (setq major-mode 'gnus-original-article-mode)
4905 (setq buffer-read-only t))
4906 (let (buffer-read-only)
4908 (insert-buffer-substring gnus-article-buffer))
4909 (setq gnus-original-article (cons group article)))
4912 (run-hooks 'gnus-article-decode-hook)
4913 ;; Mark article as decoded or not.
4914 (setq gnus-article-decoded-p gnus-article-decode-hook))
4916 ;; Update sparse articles.
4917 (when (and do-update-line
4918 (or (numberp article)
4920 (let ((buf (current-buffer)))
4921 (set-buffer gnus-summary-buffer)
4922 (gnus-summary-update-article do-update-line sparse-header)
4923 (gnus-summary-goto-subject do-update-line nil t)
4924 (set-window-point (gnus-get-buffer-window (current-buffer) t)
4926 (set-buffer buf))))))
4932 (defcustom gnus-article-edit-mode-hook nil
4933 "Hook run in article edit mode buffers."
4934 :group 'gnus-article-various
4937 (defvar gnus-article-edit-done-function nil)
4939 (defvar gnus-article-edit-mode-map nil)
4941 ;; Should we be using derived.el for this?
4942 (unless gnus-article-edit-mode-map
4943 (setq gnus-article-edit-mode-map (make-sparse-keymap))
4944 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
4946 (gnus-define-keys gnus-article-edit-mode-map
4947 "\C-c\C-c" gnus-article-edit-done
4948 "\C-c\C-k" gnus-article-edit-exit)
4950 (gnus-define-keys (gnus-article-edit-wash-map
4951 "\C-c\C-w" gnus-article-edit-mode-map)
4952 "f" gnus-article-edit-full-stops))
4954 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
4955 "Major mode for editing articles.
4956 This is an extended text-mode.
4958 \\{gnus-article-edit-mode-map}"
4959 (make-local-variable 'gnus-article-edit-done-function)
4960 (make-local-variable 'gnus-prev-winconf)
4961 (set (make-local-variable 'font-lock-defaults)
4962 '(message-font-lock-keywords t))
4963 (setq buffer-read-only nil)
4964 (buffer-enable-undo)
4967 (defun gnus-article-edit (&optional force)
4968 "Edit the current article.
4969 This will have permanent effect only in mail groups.
4970 If FORCE is non-nil, allow editing of articles even in read-only
4973 (when (and (not force)
4974 (gnus-group-read-only-p))
4975 (error "The current newsgroup does not support article editing"))
4976 (gnus-article-date-original)
4977 (gnus-article-edit-article
4979 `(lambda (no-highlight)
4981 (gnus-summary-edit-article-done
4982 ,(or (mail-header-references gnus-current-headers) "")
4983 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
4985 (defun gnus-article-edit-article (start-func exit-func)
4986 "Start editing the contents of the current article buffer."
4987 (let ((winconf (current-window-configuration)))
4988 (set-buffer gnus-article-buffer)
4989 (gnus-article-edit-mode)
4990 (funcall start-func)
4991 (set-buffer-modified-p nil)
4992 (gnus-configure-windows 'edit-article)
4993 (setq gnus-article-edit-done-function exit-func)
4994 (setq gnus-prev-winconf winconf)
4995 (gnus-message 6 "C-c C-c to end edits")))
4997 (defun gnus-article-edit-done (&optional arg)
4998 "Update the article edits and exit."
5000 (let ((func gnus-article-edit-done-function)
5001 (buf (current-buffer))
5002 (start (window-start)))
5003 ;; We remove all text props from the article buffer.
5005 (buffer-substring-no-properties (point-min) (point-max)))
5009 (let ((winconf gnus-prev-winconf))
5011 (set-window-configuration winconf)
5012 ;; Tippy-toe some to make sure that point remains where it was.
5013 (save-current-buffer
5015 (set-window-start (get-buffer-window (current-buffer)) start)
5019 (let ((buffer-read-only nil))
5021 ;; The cache and backlog have to be flushed somewhat.
5022 (when gnus-keep-backlog
5023 (gnus-backlog-remove-article
5024 (car gnus-article-current) (cdr gnus-article-current)))
5025 ;; Flush original article as well.
5027 (when (get-buffer gnus-original-article-buffer)
5028 (set-buffer gnus-original-article-buffer)
5029 (setq gnus-original-article nil)))
5030 (when gnus-use-cache
5031 (gnus-cache-update-article
5032 (car gnus-article-current) (cdr gnus-article-current))))
5034 (set-window-start (get-buffer-window buf) start)
5035 (set-window-point (get-buffer-window buf) (point))))
5037 (defun gnus-article-edit-exit ()
5038 "Exit the article editing without updating."
5040 (when (or (not (buffer-modified-p))
5041 (yes-or-no-p "Article modified; kill anyway? "))
5042 (let ((curbuf (current-buffer))
5044 (window-start (window-start)))
5046 (if (gnus-buffer-live-p gnus-original-article-buffer)
5047 (insert-buffer gnus-original-article-buffer))
5048 (let ((winconf gnus-prev-winconf))
5050 (set-window-configuration winconf)
5051 ;; Tippy-toe some to make sure that point remains where it was.
5052 (save-current-buffer
5054 (set-window-start (get-buffer-window (current-buffer)) window-start)
5057 (defun gnus-article-edit-full-stops ()
5058 "Interactively repair spacing at end of sentences."
5061 (goto-char (point-min))
5062 (search-forward-regexp "^$" nil t)
5063 (let ((case-fold-search nil))
5064 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5067 ;;; Article highlights
5070 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5072 ;;; Internal Variables:
5074 (defcustom gnus-button-url-regexp "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-zA-Z0-9_.]+:[0-9]*\\)?\\([-a-zA-Z0-9_=!?#$@~`%&*+|\\/:;.,]\\|\\w\\)+\\([-a-zA-Z0-9_=#$@~`%&*+|\\/]\\|\\w\\)\\)"
5075 "Regular expression that matches URLs."
5076 :group 'gnus-article-buttons
5079 (defcustom gnus-button-alist
5080 `(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
5081 0 t gnus-button-handle-news 3)
5082 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
5083 gnus-button-handle-news 2)
5084 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
5086 gnus-button-fetch-group 4)
5087 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
5088 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
5089 t gnus-button-message-id 3)
5090 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
5091 ("mailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5092 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
5094 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t
5095 gnus-button-handle-info 2)
5096 ;; This is how URLs _should_ be embedded in text...
5097 ("<URL: *\\([^<>]*\\)>" 1 t gnus-button-embedded-url 1)
5099 (,gnus-button-url-regexp 0 t browse-url 0))
5100 "*Alist of regexps matching buttons in article bodies.
5102 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
5103 REGEXP: is the string matching text around the button,
5104 BUTTON: is the number of the regexp grouping actually matching the button,
5105 FORM: is a lisp expression which must eval to true for the button to
5107 CALLBACK: is the function to call when the user push this button, and each
5108 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
5110 CALLBACK can also be a variable, in that case the value of that
5111 variable it the real callback function."
5112 :group 'gnus-article-buttons
5113 :type '(repeat (list regexp
5114 (integer :tag "Button")
5116 (function :tag "Callback")
5119 (integer :tag "Regexp group")))))
5121 (defcustom gnus-header-button-alist
5122 `(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
5123 0 t gnus-button-message-id 0)
5124 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
5125 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
5126 0 t gnus-button-mailto 0)
5127 ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t browse-url 0)
5128 ("^Subject:" ,gnus-button-url-regexp 0 t browse-url 0)
5129 ("^[^:]+:" ,gnus-button-url-regexp 0 t browse-url 0)
5130 ("^[^:]+:" "\\bmailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5131 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
5132 gnus-button-message-id 3))
5133 "*Alist of headers and regexps to match buttons in article heads.
5135 This alist is very similar to `gnus-button-alist', except that each
5136 alist has an additional HEADER element first in each entry:
5138 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
5140 HEADER is a regexp to match a header. For a fuller explanation, see
5141 `gnus-button-alist'."
5142 :group 'gnus-article-buttons
5143 :group 'gnus-article-headers
5144 :type '(repeat (list (regexp :tag "Header")
5146 (integer :tag "Button")
5148 (function :tag "Callback")
5151 (integer :tag "Regexp group")))))
5153 (defvar gnus-button-regexp nil)
5154 (defvar gnus-button-marker-list nil)
5155 ;; Regexp matching any of the regexps from `gnus-button-alist'.
5157 (defvar gnus-button-last nil)
5158 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
5162 (defun gnus-article-push-button (event)
5163 "Check text under the mouse pointer for a callback function.
5164 If the text under the mouse pointer has a `gnus-callback' property,
5165 call it with the value of the `gnus-data' text property."
5167 (set-buffer (window-buffer (posn-window (event-start event))))
5168 (let* ((pos (posn-point (event-start event)))
5169 (data (get-text-property pos 'gnus-data))
5170 (fun (get-text-property pos 'gnus-callback)))
5173 (funcall fun data))))
5175 (defun gnus-article-press-button ()
5176 "Check text at point for a callback function.
5177 If the text at point has a `gnus-callback' property,
5178 call it with the value of the `gnus-data' text property."
5180 (let* ((data (get-text-property (point) 'gnus-data))
5181 (fun (get-text-property (point) 'gnus-callback)))
5183 (funcall fun data))))
5185 (defun gnus-article-highlight (&optional force)
5186 "Highlight current article.
5187 This function calls `gnus-article-highlight-headers',
5188 `gnus-article-highlight-citation',
5189 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5190 do the highlighting. See the documentation for those functions."
5191 (interactive (list 'force))
5192 (gnus-article-highlight-headers)
5193 (gnus-article-highlight-citation force)
5194 (gnus-article-highlight-signature)
5195 (gnus-article-add-buttons force)
5196 (gnus-article-add-buttons-to-head))
5198 (defun gnus-article-highlight-some (&optional force)
5199 "Highlight current article.
5200 This function calls `gnus-article-highlight-headers',
5201 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5202 do the highlighting. See the documentation for those functions."
5203 (interactive (list 'force))
5204 (gnus-article-highlight-headers)
5205 (gnus-article-highlight-signature)
5206 (gnus-article-add-buttons))
5208 (defun gnus-article-highlight-headers ()
5209 "Highlight article headers as specified by `gnus-header-face-alist'."
5212 (set-buffer gnus-article-buffer)
5214 (let ((alist gnus-header-face-alist)
5215 (buffer-read-only nil)
5216 (case-fold-search t)
5217 (inhibit-point-motion-hooks t)
5218 entry regexp header-face field-face from hpoints fpoints)
5219 (article-narrow-to-head)
5220 (while (setq entry (pop alist))
5221 (goto-char (point-min))
5222 (setq regexp (concat "^\\("
5223 (if (string-equal "" (nth 0 entry))
5227 header-face (nth 1 entry)
5228 field-face (nth 2 entry))
5229 (while (and (re-search-forward regexp nil t)
5233 (unless (search-forward ":" nil t)
5235 (when (and header-face
5236 (not (memq (point) hpoints)))
5237 (push (point) hpoints)
5238 (gnus-put-text-property from (point) 'face header-face))
5239 (when (and field-face
5240 (not (memq (setq from (point)) fpoints)))
5242 (if (re-search-forward "^[^ \t]" nil t)
5244 (goto-char (point-max)))
5245 (gnus-put-text-property from (point) 'face field-face))))))))
5247 (defun gnus-article-highlight-signature ()
5248 "Highlight the signature in an article.
5249 It does this by highlighting everything after
5250 `gnus-signature-separator' using `gnus-signature-face'."
5253 (set-buffer gnus-article-buffer)
5254 (let ((buffer-read-only nil)
5255 (inhibit-point-motion-hooks t))
5257 (when (and gnus-signature-face
5258 (gnus-article-narrow-to-signature))
5259 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
5260 'face gnus-signature-face)
5262 (gnus-article-search-signature)
5263 (let ((start (match-beginning 0))
5264 (end (set-marker (make-marker) (1+ (match-end 0)))))
5265 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
5268 (defun gnus-button-in-region-p (b e prop)
5269 "Say whether PROP exists in the region."
5270 (text-property-not-all b e prop nil))
5272 (defun gnus-article-add-buttons (&optional force)
5273 "Find external references in the article and make buttons of them.
5274 \"External references\" are things like Message-IDs and URLs, as
5275 specified by `gnus-button-alist'."
5276 (interactive (list 'force))
5278 (set-buffer gnus-article-buffer)
5279 (let ((buffer-read-only nil)
5280 (inhibit-point-motion-hooks t)
5281 (case-fold-search t)
5282 (alist gnus-button-alist)
5284 ;; Remove all old markers.
5285 (let (marker entry new-list)
5286 (while (setq marker (pop gnus-button-marker-list))
5287 (if (or (< marker (point-min)) (>= marker (point-max)))
5288 (push marker new-list)
5290 (when (setq entry (gnus-button-entry))
5291 (put-text-property (match-beginning (nth 1 entry))
5292 (match-end (nth 1 entry))
5293 'gnus-callback nil))
5294 (set-marker marker nil)))
5295 (setq gnus-button-marker-list new-list))
5296 ;; We skip the headers.
5299 (while (setq entry (pop alist))
5300 (setq regexp (car entry))
5302 (while (re-search-forward regexp nil t)
5303 (let* ((start (and entry (match-beginning (nth 1 entry))))
5304 (end (and entry (match-end (nth 1 entry))))
5305 (from (match-beginning 0)))
5306 (when (and (or (eq t (nth 2 entry))
5307 (eval (nth 2 entry)))
5308 (not (gnus-button-in-region-p
5309 start end 'gnus-callback)))
5310 ;; That optional form returned non-nil, so we add the
5312 (gnus-article-add-button
5313 start end 'gnus-button-push
5314 (car (push (set-marker (make-marker) from)
5315 gnus-button-marker-list))))))))))
5317 ;; Add buttons to the head of an article.
5318 (defun gnus-article-add-buttons-to-head ()
5319 "Add buttons to the head of the article."
5322 (set-buffer gnus-article-buffer)
5324 (let ((buffer-read-only nil)
5325 (inhibit-point-motion-hooks t)
5326 (case-fold-search t)
5327 (alist gnus-header-button-alist)
5329 (article-narrow-to-head)
5331 ;; Each alist entry.
5332 (setq entry (car alist)
5334 (goto-char (point-min))
5335 (while (re-search-forward (car entry) nil t)
5336 ;; Each header matching the entry.
5337 (setq beg (match-beginning 0))
5338 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
5339 (match-beginning 0))
5342 (while (re-search-forward (nth 1 entry) end t)
5343 ;; Each match within a header.
5344 (let* ((entry (cdr entry))
5345 (start (match-beginning (nth 1 entry)))
5346 (end (match-end (nth 1 entry)))
5347 (form (nth 2 entry)))
5348 (goto-char (match-end 0))
5350 (gnus-article-add-button
5351 start end (nth 3 entry)
5352 (buffer-substring (match-beginning (nth 4 entry))
5353 (match-end (nth 4 entry)))))))
5354 (goto-char end)))))))
5356 ;;; External functions:
5358 (defun gnus-article-add-button (from to fun &optional data)
5359 "Create a button between FROM and TO with callback FUN and data DATA."
5360 (when gnus-article-button-face
5361 (gnus-overlay-put (gnus-make-overlay from to)
5362 'face gnus-article-button-face))
5363 (gnus-add-text-properties
5365 (nconc (and gnus-article-mouse-face
5366 (list gnus-mouse-face-prop gnus-article-mouse-face))
5367 (list 'gnus-callback fun)
5368 (and data (list 'gnus-data data))))
5369 (widget-convert-button 'link from to :action 'gnus-widget-press-button
5370 :button-keymap gnus-widget-button-keymap))
5372 ;;; Internal functions:
5374 (defun gnus-article-set-globals ()
5376 (set-buffer gnus-summary-buffer)
5377 (gnus-set-global-variables)))
5379 (defun gnus-signature-toggle (end)
5381 (set-buffer gnus-article-buffer)
5382 (let ((buffer-read-only nil)
5383 (inhibit-point-motion-hooks t))
5384 (if (text-property-any end (point-max) 'article-type 'signature)
5386 (gnus-delete-wash-type 'signature)
5387 (gnus-remove-text-properties-when
5388 'article-type 'signature end (point-max)
5389 (cons 'article-type (cons 'signature
5390 gnus-hidden-properties))))
5391 (gnus-add-wash-type 'signature)
5392 (gnus-add-text-properties-when
5393 'article-type nil end (point-max)
5394 (cons 'article-type (cons 'signature
5395 gnus-hidden-properties)))))
5396 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
5397 (gnus-set-mode-line 'article))))
5399 (defun gnus-button-entry ()
5400 ;; Return the first entry in `gnus-button-alist' matching this place.
5401 (let ((alist gnus-button-alist)
5404 (setq entry (pop alist))
5405 (if (looking-at (car entry))
5410 (defun gnus-button-push (marker)
5411 ;; Push button starting at MARKER.
5414 (let* ((entry (gnus-button-entry))
5415 (inhibit-point-motion-hooks t)
5417 (args (mapcar (lambda (group)
5418 (let ((string (match-string group)))
5419 (gnus-set-text-properties
5420 0 (length string) nil string)
5427 (fboundp (symbol-value fun)))
5428 (apply (symbol-value fun) args))
5430 (gnus-message 1 "You must define `%S' to use this button"
5431 (cons fun args)))))))
5433 (defun gnus-parse-news-url (url)
5434 (let (scheme server group message-id articles)
5437 (goto-char (point-min))
5438 (when (looking-at "\\([A-Za-z]+\\):")
5439 (setq scheme (match-string 1))
5440 (goto-char (match-end 0)))
5441 (when (looking-at "//\\([^/]+\\)/")
5442 (setq server (match-string 1))
5443 (goto-char (match-end 0)))
5446 ((looking-at "\\(.*@.*\\)")
5447 (setq message-id (match-string 1)))
5448 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
5449 (setq group (match-string 1)
5450 articles (split-string (match-string 2) "-")))
5451 ((looking-at "\\([^/]+\\)/?")
5452 (setq group (match-string 1)))
5454 (error "Unknown news URL syntax"))))
5455 (list scheme server group message-id articles)))
5457 (defun gnus-button-handle-news (url)
5459 (destructuring-bind (scheme server group message-id articles)
5460 (gnus-parse-news-url url)
5464 (set-buffer gnus-summary-buffer)
5466 (let ((gnus-refer-article-method (list (list 'nntp server))))
5467 (gnus-summary-refer-article message-id))
5468 (gnus-summary-refer-article message-id))))
5470 (gnus-button-fetch-group url)))))
5472 (defun gnus-button-handle-info (url)
5473 "Fetch an info URL."
5475 "^\\([^:/]+\\)?/\\(.*\\)"
5477 (gnus-info-find-node
5478 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
5481 (gnus-url-unhex-string (match-string 2 url))))
5482 (error "Can't parse %s" url)))
5484 (defun gnus-button-message-id (message-id)
5487 (set-buffer gnus-summary-buffer)
5488 (gnus-summary-refer-article message-id)))
5490 (defun gnus-button-fetch-group (address)
5491 "Fetch GROUP specified by ADDRESS."
5492 (if (not (string-match "[:/]" address))
5493 ;; This is just a simple group url.
5494 (gnus-group-read-ephemeral-group address gnus-select-method)
5497 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
5499 (error "Can't parse %s" address)
5500 (gnus-group-read-ephemeral-group
5501 (match-string 4 address)
5502 `(nntp ,(match-string 1 address)
5503 (nntp-address ,(match-string 1 address))
5504 (nntp-port-number ,(if (match-end 3)
5505 (match-string 3 address)
5508 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
5510 (defun gnus-url-parse-query-string (query &optional downcase)
5511 (let (retval pairs cur key val)
5512 (setq pairs (split-string query "&"))
5514 (setq cur (car pairs)
5516 (if (not (string-match "=" cur))
5518 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
5519 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
5521 (setq key (downcase key)))
5522 (setq cur (assoc key retval))
5524 (setcdr cur (cons val (cdr cur)))
5525 (setq retval (cons (list key val) retval)))))
5528 (defun gnus-url-mailto (url)
5529 ;; Send mail to someone
5530 (when (string-match "mailto:/*\\(.*\\)" url)
5531 (setq url (substring url (match-beginning 1) nil)))
5532 (let (to args subject func)
5533 (if (string-match (regexp-quote "?") url)
5534 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
5535 args (gnus-url-parse-query-string
5536 (substring url (match-end 0) nil) t))
5537 (setq to (gnus-url-unhex-string url)))
5538 (setq args (cons (list "to" to) args)
5539 subject (cdr-safe (assoc "subject" args)))
5542 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
5545 (message-position-on-field (caar args)))
5546 (insert (mapconcat 'identity (cdar args) ", "))
5547 (setq args (cdr args)))
5550 (message-goto-subject))))
5552 (defun gnus-button-embedded-url (address)
5553 "Activate ADDRESS with `browse-url'."
5554 (browse-url (gnus-strip-whitespace address)))
5556 ;;; Next/prev buttons in the article buffer.
5558 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
5559 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
5561 (defvar gnus-prev-page-map
5562 (let ((map (make-sparse-keymap)))
5563 (unless (>= emacs-major-version 21)
5564 ;; XEmacs doesn't care.
5565 (set-keymap-parent map gnus-article-mode-map))
5566 (define-key map gnus-mouse-2 'gnus-button-prev-page)
5567 (define-key map "\r" 'gnus-button-prev-page)
5570 (defun gnus-insert-prev-page-button ()
5572 (buffer-read-only nil))
5574 gnus-prev-page-line-format nil
5575 `(,@(gnus-local-map-property gnus-prev-page-map)
5577 gnus-callback gnus-article-button-prev-page
5578 article-type annotation))
5579 (widget-convert-button
5581 :action 'gnus-button-prev-page
5582 :button-keymap gnus-prev-page-map)))
5584 (defvar gnus-prev-page-map
5585 (let ((map (make-sparse-keymap)))
5586 (unless (>= emacs-major-version 21)
5587 ;; XEmacs doesn't care.
5588 (set-keymap-parent map gnus-article-mode-map))
5589 (define-key map gnus-mouse-2 'gnus-button-prev-page)
5590 (define-key map "\r" 'gnus-button-prev-page)
5593 (defvar gnus-next-page-map
5594 (let ((map (make-sparse-keymap)))
5595 (unless (>= emacs-major-version 21)
5596 ;; XEmacs doesn't care.
5597 (set-keymap-parent map gnus-article-mode-map))
5598 (define-key map gnus-mouse-2 'gnus-button-next-page)
5599 (define-key map "\r" 'gnus-button-next-page)
5602 (defun gnus-button-next-page (&optional args more-args)
5603 "Go to the next page."
5605 (let ((win (selected-window)))
5606 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5607 (gnus-article-next-page)
5608 (select-window win)))
5610 (defun gnus-button-prev-page (&optional args more-args)
5611 "Go to the prev page."
5613 (let ((win (selected-window)))
5614 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5615 (gnus-article-prev-page)
5616 (select-window win)))
5618 (defun gnus-insert-next-page-button ()
5620 (buffer-read-only nil))
5621 (gnus-eval-format gnus-next-page-line-format nil
5622 `(,@(gnus-local-map-property gnus-next-page-map)
5624 gnus-callback gnus-article-button-next-page
5625 article-type annotation))
5626 (widget-convert-button
5628 :action 'gnus-button-next-page
5629 :button-keymap gnus-next-page-map)))
5631 (defun gnus-article-button-next-page (arg)
5632 "Go to the next page."
5634 (let ((win (selected-window)))
5635 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5636 (gnus-article-next-page)
5637 (select-window win)))
5639 (defun gnus-article-button-prev-page (arg)
5640 "Go to the prev page."
5642 (let ((win (selected-window)))
5643 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5644 (gnus-article-prev-page)
5645 (select-window win)))
5647 (defvar gnus-decode-header-methods
5648 '(mail-decode-encoded-word-region)
5649 "List of methods used to decode headers.
5651 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
5652 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
5653 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
5654 whose names match REGEXP.
5657 ((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
5658 mail-decode-encoded-word-region
5659 (\"chinese\" . rfc1843-decode-region))
5662 (defvar gnus-decode-header-methods-cache nil)
5664 (defun gnus-multi-decode-header (start end)
5665 "Apply the functions from `gnus-encoded-word-methods' that match."
5666 (unless (and gnus-decode-header-methods-cache
5667 (eq gnus-newsgroup-name
5668 (car gnus-decode-header-methods-cache)))
5669 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
5672 (nconc gnus-decode-header-methods-cache (list x))
5673 (if (and gnus-newsgroup-name
5674 (string-match (car x) gnus-newsgroup-name))
5675 (nconc gnus-decode-header-methods-cache
5677 gnus-decode-header-methods))
5678 (let ((xlist gnus-decode-header-methods-cache))
5681 (narrow-to-region start end)
5683 (funcall (pop xlist) (point-min) (point-max))))))
5686 ;;; Treatment top-level handling.
5689 (defun gnus-treat-article (condition &optional part-number total-parts type)
5690 (let ((length (- (point-max) (point-min)))
5691 (alist gnus-treatment-function-alist)
5692 (article-goto-body-goes-to-point-min-p t)
5696 (let ((list gnus-article-treat-types))
5698 (when (string-match (pop list) type)
5699 (throw 'found t)))))))
5700 (highlightp (gnus-visual-p 'article-highlight 'highlight))
5702 (gnus-run-hooks 'gnus-part-display-hook)
5703 (while (setq elem (pop alist))
5706 (if (gnus-buffer-live-p gnus-summary-buffer)
5707 (set-buffer gnus-summary-buffer))
5708 (symbol-value (car elem))))
5709 (when (and (or (consp val)
5711 (gnus-treat-predicate val)
5712 (or (not (get (car elem) 'highlight))
5715 (funcall (cadr elem)))))))
5717 ;; Dynamic variables.
5719 (defvar part-number)
5720 (defvar total-parts)
5725 (defun gnus-treat-predicate (val)
5730 (stringp (car val)))
5731 (apply 'gnus-or (mapcar `(lambda (s)
5732 (string-match s ,(or gnus-newsgroup-name "")))
5735 (let ((pred (pop val)))
5738 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
5740 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
5742 (not (gnus-treat-predicate (car val))))
5744 (equal (car val) type))
5746 (error "%S is not a valid predicate" pred)))))
5754 (eq part-number total-parts))
5758 (error "%S is not a valid value" val))))
5760 (defun gnus-article-encrypt-body (protocol &optional n)
5761 "Encrypt the article body."
5764 (or gnus-article-encrypt-protocol
5765 (completing-read "Encrypt protocol: "
5766 gnus-article-encrypt-protocol-alist
5768 current-prefix-arg))
5769 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
5771 (error (format "Can't find the encrypt protocol %s" protocol)))
5772 (if (equal gnus-newsgroup-name "nndraft:drafts")
5773 (error "Can't encrypt the article in group nndraft:drafts"))
5774 (if (equal gnus-newsgroup-name "nndraft:queue")
5775 (error "Don't encrypt the article in group nndraft:queue"))
5776 (gnus-summary-iterate n
5778 (set-buffer gnus-summary-buffer)
5779 (let ((mail-parse-charset gnus-newsgroup-charset)
5780 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5781 (summary-buffer gnus-summary-buffer)
5783 (gnus-set-global-variables)
5784 (when (gnus-group-read-only-p)
5785 (error "The current newsgroup does not support article encrypt"))
5786 (gnus-summary-show-article t)
5788 (or (mail-header-references gnus-current-headers) ""))
5789 (set-buffer gnus-article-buffer)
5790 (let* ((buffer-read-only nil)
5792 (mapcar (lambda (field)
5793 (and (save-restriction
5794 (message-narrow-to-head)
5795 (goto-char (point-min))
5796 (search-forward field nil t))
5798 (message-narrow-to-field)
5799 (buffer-substring (point-min) (point-max))
5800 (delete-region (point-min) (point-max))
5802 '("Content-Type:" "Content-Transfer-Encoding:"
5803 "Content-Disposition:"))))
5804 (message-narrow-to-head)
5805 (message-remove-header "MIME-Version")
5806 (goto-char (point-max))
5807 (setq point (point))
5808 (insert (apply 'concat headers))
5810 (narrow-to-region point (point-max))
5811 (let ((message-options message-options))
5812 (message-options-set 'message-sender user-mail-address)
5813 (message-options-set 'message-recipients user-mail-address)
5814 (message-options-set 'message-sign-encrypt 'not)
5816 (goto-char (point-min))
5817 (insert "MIME-Version: 1.0\n")
5819 (gnus-summary-edit-article-done
5820 references nil summary-buffer t))
5821 (when gnus-keep-backlog
5822 (gnus-backlog-remove-article
5823 (car gnus-article-current) (cdr gnus-article-current)))
5825 (when (get-buffer gnus-original-article-buffer)
5826 (set-buffer gnus-original-article-buffer)
5827 (setq gnus-original-article nil)))
5828 (when gnus-use-cache
5829 (gnus-cache-update-article
5830 (car gnus-article-current) (cdr gnus-article-current))))))))
5832 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
5833 "The following specs can be used:
5834 %t The security MIME type
5837 %D Details if button is pressed")
5839 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
5840 "The following specs can be used:
5841 %t The security MIME type
5844 %D Details if button is pressed")
5846 (defvar gnus-mime-security-button-line-format-alist
5847 '((?t gnus-tmp-type ?s)
5848 (?i gnus-tmp-info ?s)
5849 (?d gnus-tmp-details ?s)
5850 (?D gnus-tmp-pressed-details ?s)))
5852 (defvar gnus-mime-security-button-map
5853 (let ((map (make-sparse-keymap)))
5854 (unless (>= (string-to-number emacs-version) 21)
5855 (set-keymap-parent map gnus-article-mode-map))
5856 (define-key map gnus-mouse-2 'gnus-article-push-button)
5857 (define-key map "\r" 'gnus-article-press-button)
5860 (defvar gnus-mime-security-details-buffer nil)
5862 (defvar gnus-mime-security-button-pressed nil)
5864 (defvar gnus-mime-security-show-details-inline t
5865 "If non-nil, show details in the article buffer.")
5867 (defun gnus-mime-security-verify-or-decrypt (handle)
5868 (mm-remove-parts (cdr handle))
5869 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
5870 point buffer-read-only)
5872 (goto-char (car region)))
5874 (narrow-to-region (point) (point))
5875 (with-current-buffer (mm-handle-multipart-original-buffer handle)
5876 (let* ((mm-verify-option 'known)
5877 (mm-decrypt-option 'known)
5878 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
5879 (unless (eq nparts (cdr handle))
5880 (mm-destroy-parts (cdr handle))
5881 (setcdr handle nparts))))
5882 (setq point (point))
5883 (gnus-mime-display-security handle)
5884 (goto-char (point-max)))
5886 (delete-region (point) (cdr region))
5887 (set-marker (car region) nil)
5888 (set-marker (cdr region) nil))
5891 (defun gnus-mime-security-show-details (handle)
5892 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
5894 (if gnus-mime-security-show-details-inline
5895 (let ((gnus-mime-security-button-pressed t)
5896 (gnus-mime-security-button-line-format
5897 (get-text-property (point) 'gnus-line-format))
5900 (while (eq (get-text-property (point) 'gnus-line-format)
5901 gnus-mime-security-button-line-format)
5905 (narrow-to-region (point) (point))
5906 (gnus-insert-mime-security-button handle))
5907 (delete-region (point)
5908 (or (text-property-not-all
5911 gnus-mime-security-button-line-format)
5913 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
5914 (with-current-buffer gnus-mime-security-details-buffer
5917 (setq gnus-mime-security-details-buffer
5918 (gnus-get-buffer-create "*MIME Security Details*")))
5919 (with-current-buffer gnus-mime-security-details-buffer
5921 (goto-char (point-min)))
5922 (pop-to-buffer gnus-mime-security-details-buffer))
5923 (gnus-message 5 "No details."))))
5925 (defun gnus-mime-security-press-button (handle)
5926 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
5927 (gnus-mime-security-show-details handle)
5928 (gnus-mime-security-verify-or-decrypt handle)))
5930 (defun gnus-insert-mime-security-button (handle &optional displayed)
5931 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
5934 (or (nth 2 (assoc protocol mm-verify-function-alist))
5935 (nth 2 (assoc protocol mm-decrypt-function-alist))
5937 (if (equal (car handle) "multipart/signed")
5938 " Signed" " Encrypted")
5941 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
5944 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
5945 gnus-tmp-pressed-details
5947 (setq gnus-tmp-details
5948 (if gnus-tmp-details
5949 (concat "\n" gnus-tmp-details) ""))
5950 (setq gnus-tmp-pressed-details
5951 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
5956 gnus-mime-security-button-line-format
5957 gnus-mime-security-button-line-format-alist
5958 `(,@(gnus-local-map-property gnus-mime-security-button-map)
5959 gnus-callback gnus-mime-security-press-button
5960 gnus-line-format ,gnus-mime-security-button-line-format
5961 article-type annotation
5964 (widget-convert-button
5967 :action 'gnus-widget-press-button
5968 :button-keymap gnus-mime-security-button-map
5970 (lambda (widget/window &optional overlay pos)
5971 ;; Needed to properly clear the message due to a bug in
5972 ;; wid-edit (XEmacs only).
5973 (if (boundp 'help-echo-owns-message)
5974 (setq help-echo-owns-message t))
5977 (aref gnus-mouse-2 0))))))
5979 (defun gnus-mime-display-security (handle)
5981 (narrow-to-region (point) (point))
5982 (unless (gnus-unbuttonized-mime-type-p (car handle))
5983 (gnus-insert-mime-security-button handle))
5984 (gnus-mime-display-mixed (cdr handle))
5987 (unless (gnus-unbuttonized-mime-type-p (car handle))
5988 (let ((gnus-mime-security-button-line-format
5989 gnus-mime-security-button-end-line-format))
5990 (gnus-insert-mime-security-button handle)))
5991 (mm-set-handle-multipart-parameter
5993 (cons (set-marker (make-marker) (point-min))
5994 (set-marker (make-marker) (point-max))))))
6000 (run-hooks 'gnus-art-load-hook)
6002 ;;; gnus-art.el ends here