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)\\)")
285 '(("_" "_" underline)
288 ("_/" "/_" underline-italic)
289 ("_\\*" "\\*_" underline-bold)
290 ("\\*/" "/\\*" bold-italic)
291 ("_\\*/" "/\\*_" underline-bold-italic))))
292 `(("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
293 2 3 gnus-emphasis-underline)
297 (format format (car spec) (cadr spec))
298 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
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-article-mime-part-function nil
708 "Function called with a MIME handle as the argument.
709 This is meant for people who want to do something automatic based
710 on parts -- for instance, adding Vcard info to a database."
711 :group 'gnus-article-mime
714 (defcustom gnus-mime-multipart-functions nil
715 "An alist of MIME types to functions to display them."
717 :group 'gnus-article-mime
720 (defcustom gnus-article-date-lapsed-new-header nil
721 "Whether the X-Sent and Date headers can coexist.
722 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
723 either replace the old \"Date:\" header (if this variable is nil), or
724 be added below it (otherwise)."
726 :group 'gnus-article-headers
729 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
730 "Function called with a MIME handle as the argument.
731 This is meant for people who want to view first matched part.
732 For `undisplayed-alternative' (default), the first undisplayed
733 part or alternative part is used. For `undisplayed', the first
734 undisplayed part is used. For a function, the first part which
735 the function return `t' is used. For `nil', the first part is
738 :group 'gnus-article-mime
740 (item :tag "first" :value nil)
741 (item :tag "undisplayed" :value undisplayed)
742 (item :tag "undisplayed or alternative"
743 :value undisplayed-alternative)
746 (defcustom gnus-mime-action-alist
747 '(("save to file" . gnus-mime-save-part)
748 ("save and strip" . gnus-mime-save-part-and-strip)
749 ("display as text" . gnus-mime-inline-part)
750 ("view the part" . gnus-mime-view-part)
751 ("pipe to command" . gnus-mime-pipe-part)
752 ("toggle display" . gnus-article-press-button)
753 ("toggle display" . gnus-article-view-part-as-charset)
754 ("view as type" . gnus-mime-view-part-as-type)
755 ("internalize type" . gnus-mime-internalize-part)
756 ("externalize type" . gnus-mime-externalize-part))
757 "An alist of actions that run on the MIME attachment."
758 :group 'gnus-article-mime
759 :type '(repeat (cons (string :tag "name")
762 (defcustom gnus-mime-action-alist
763 '(("save to file" . gnus-mime-save-part)
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 ("view as type" . gnus-mime-view-part-as-type)
769 ("internalize type" . gnus-mime-internalize-part)
770 ("externalize type" . gnus-mime-externalize-part))
771 "An alist of actions that run on the MIME attachment."
773 :group 'gnus-article-mime
774 :type '(repeat (cons (string :tag "name")
778 ;;; The treatment variables
781 (defvar gnus-part-display-hook nil
782 "Hook called on parts that are to receive treatment.")
784 (defvar gnus-article-treat-custom
785 '(choice (const :tag "Off" nil)
787 (const :tag "Header" head)
788 (const :tag "Last" last)
789 (integer :tag "Less")
790 (repeat :tag "Groups" regexp)
791 (sexp :tag "Predicate")))
793 (defvar gnus-article-treat-head-custom
794 '(choice (const :tag "Off" nil)
795 (const :tag "Header" head)))
797 (defvar gnus-article-treat-types '("text/plain")
800 (defvar gnus-inhibit-treatment nil
801 "Whether to inhibit treatment.")
803 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
804 "Highlight the signature.
805 Valid values are nil, t, `head', `last', an integer or a predicate.
806 See Info node `(gnus)Customizing Articles'."
807 :group 'gnus-article-treat
808 :type gnus-article-treat-custom)
809 (put 'gnus-treat-highlight-signature 'highlight t)
811 (defcustom gnus-treat-buttonize 100000
813 Valid values are nil, t, `head', `last', an integer or a predicate.
814 See Info node `(gnus)Customizing Articles'."
815 :group 'gnus-article-treat
816 :type gnus-article-treat-custom)
817 (put 'gnus-treat-buttonize 'highlight t)
819 (defcustom gnus-treat-buttonize-head 'head
820 "Add buttons to the head.
821 Valid values are nil, t, `head', `last', an integer or a predicate.
822 See Info node `(gnus)Customizing Articles' for details."
823 :group 'gnus-article-treat
824 :type gnus-article-treat-head-custom)
825 (put 'gnus-treat-buttonize-head 'highlight t)
827 (defcustom gnus-treat-emphasize
828 (and (or window-system
830 (>= (string-to-number emacs-version) 21))
833 Valid values are nil, t, `head', `last', an integer or a predicate.
834 See Info node `(gnus)Customizing Articles' for details."
835 :group 'gnus-article-treat
836 :type gnus-article-treat-custom)
837 (put 'gnus-treat-emphasize 'highlight t)
839 (defcustom gnus-treat-strip-cr nil
840 "Remove carriage returns.
841 Valid values are nil, t, `head', `last', an integer or a predicate.
842 See Info node `(gnus)Customizing Articles' for details."
843 :group 'gnus-article-treat
844 :type gnus-article-treat-custom)
846 (defcustom gnus-treat-leading-whitespace nil
847 "Remove leading whitespace in headers.
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)
853 (defcustom gnus-treat-hide-headers 'head
855 Valid values are nil, t, `head', `last', an integer or a predicate.
856 See Info node `(gnus)Customizing Articles' for details."
857 :group 'gnus-article-treat
858 :type gnus-article-treat-head-custom)
860 (defcustom gnus-treat-hide-boring-headers nil
861 "Hide boring headers.
862 Valid values are nil, t, `head', `last', an integer or a predicate.
863 See Info node `(gnus)Customizing Articles' for details."
864 :group 'gnus-article-treat
865 :type gnus-article-treat-head-custom)
867 (defcustom gnus-treat-hide-signature nil
869 Valid values are nil, t, `head', `last', an integer or a predicate.
870 See Info node `(gnus)Customizing Articles' for details."
871 :group 'gnus-article-treat
872 :type gnus-article-treat-custom)
874 (defcustom gnus-treat-fill-article nil
876 Valid values are nil, t, `head', `last', an integer or a predicate.
877 See Info node `(gnus)Customizing Articles' for details."
878 :group 'gnus-article-treat
879 :type gnus-article-treat-custom)
881 (defcustom gnus-treat-hide-citation nil
883 Valid values are nil, t, `head', `last', an integer or a predicate.
884 See Info node `(gnus)Customizing Articles' for details."
885 :group 'gnus-article-treat
886 :type gnus-article-treat-custom)
888 (defcustom gnus-treat-hide-citation-maybe nil
890 Valid values are nil, t, `head', `last', an integer or a predicate.
891 See Info node `(gnus)Customizing Articles' for details."
892 :group 'gnus-article-treat
893 :type gnus-article-treat-custom)
895 (defcustom gnus-treat-strip-list-identifiers 'head
896 "Strip list identifiers from `gnus-list-identifiers`.
897 Valid values are nil, t, `head', `last', an integer or a predicate.
898 See Info node `(gnus)Customizing Articles' for details."
900 :group 'gnus-article-treat
901 :type gnus-article-treat-custom)
903 (defcustom gnus-treat-strip-pgp t
904 "Strip PGP signatures.
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-pem nil
911 "Strip PEM signatures.
912 Valid values are nil, t, `head', `last', an integer or a predicate.
913 See Info node `(gnus)Customizing Articles' for details."
914 :group 'gnus-article-treat
915 :type gnus-article-treat-custom)
917 (defcustom gnus-treat-strip-banner t
918 "Strip banners from articles.
919 The banner to be stripped is specified in the `banner' group parameter.
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-highlight-headers 'head
926 "Highlight the headers.
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-head-custom)
931 (put 'gnus-treat-highlight-headers 'highlight t)
933 (defcustom gnus-treat-highlight-citation t
934 "Highlight cited text.
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)
939 (put 'gnus-treat-highlight-citation 'highlight t)
941 (defcustom gnus-treat-date-ut nil
942 "Display the Date in UT (GMT).
943 Valid values are nil, t, `head', `last', an integer or a predicate.
944 See Info node `(gnus)Customizing Articles' for details."
945 :group 'gnus-article-treat
946 :type gnus-article-treat-head-custom)
948 (defcustom gnus-treat-date-local nil
949 "Display the Date in the local timezone.
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-head-custom)
955 (defcustom gnus-treat-date-english nil
956 "Display the Date in a format that can be read aloud in English.
957 Valid values are nil, t, `head', `last', an integer or a predicate.
958 See Info node `(gnus)Customizing Articles' for details."
959 :group 'gnus-article-treat
960 :type gnus-article-treat-head-custom)
962 (defcustom gnus-treat-date-lapsed nil
963 "Display the Date header in a way that says how much time has elapsed.
964 Valid values are nil, t, `head', `last', an integer or a predicate.
965 See Info node `(gnus)Customizing Articles' for details."
966 :group 'gnus-article-treat
967 :type gnus-article-treat-head-custom)
969 (defcustom gnus-treat-date-original nil
970 "Display the date in the original timezone.
971 Valid values are nil, t, `head', `last', an integer or a predicate.
972 See Info node `(gnus)Customizing Articles' for details."
973 :group 'gnus-article-treat
974 :type gnus-article-treat-head-custom)
976 (defcustom gnus-treat-date-iso8601 nil
977 "Display the date in the ISO8601 format.
978 Valid values are nil, t, `head', `last', an integer or a predicate.
979 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-user-defined nil
985 "Display the date in a user-defined format.
986 The format is defined by the `gnus-article-time-format' variable.
987 Valid values are nil, t, `head', `last', an integer or a predicate.
988 See Info node `(gnus)Customizing Articles' for details."
989 :group 'gnus-article-treat
990 :type gnus-article-treat-head-custom)
992 (defcustom gnus-treat-strip-headers-in-body t
993 "Strip the X-No-Archive header line from the beginning of the body.
994 Valid values are nil, t, `head', `last', an integer or a predicate.
995 See Info node `(gnus)Customizing Articles' for details."
997 :group 'gnus-article-treat
998 :type gnus-article-treat-custom)
1000 (defcustom gnus-treat-strip-trailing-blank-lines nil
1001 "Strip trailing blank lines.
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-custom)
1007 (defcustom gnus-treat-strip-leading-blank-lines nil
1008 "Strip leading blank lines.
1009 Valid values are nil, t, `head', `last', an integer or a predicate.
1010 See Info node `(gnus)Customizing Articles' for details."
1011 :group 'gnus-article-treat
1012 :type gnus-article-treat-custom)
1014 (defcustom gnus-treat-strip-multiple-blank-lines nil
1015 "Strip multiple blank lines.
1016 Valid values are nil, t, `head', `last', an integer or a predicate.
1017 See Info node `(gnus)Customizing Articles' for details."
1018 :group 'gnus-article-treat
1019 :type gnus-article-treat-custom)
1021 (defcustom gnus-treat-unfold-headers 'head
1022 "Unfold folded header lines.
1023 Valid values are nil, t, `head', `last', an integer or a predicate.
1024 See Info node `(gnus)Customizing Articles' for details."
1025 :group 'gnus-article-treat
1026 :type gnus-article-treat-custom)
1028 (defcustom gnus-treat-fold-headers nil
1030 Valid values are nil, t, `head', `last', an integer or a predicate.
1031 See Info node `(gnus)Customizing Articles' for details."
1032 :group 'gnus-article-treat
1033 :type gnus-article-treat-custom)
1035 (defcustom gnus-treat-fold-newsgroups 'head
1036 "Fold the Newsgroups and Followup-To headers.
1037 Valid values are nil, t, `head', `last', an integer or a predicate.
1038 See Info node `(gnus)Customizing Articles' for details."
1039 :group 'gnus-article-treat
1040 :type gnus-article-treat-custom)
1042 (defcustom gnus-treat-overstrike t
1043 "Treat overstrike highlighting.
1044 Valid values are nil, t, `head', `last', an integer or a predicate.
1045 See Info node `(gnus)Customizing Articles' for details."
1046 :group 'gnus-article-treat
1047 :type gnus-article-treat-custom)
1048 (put 'gnus-treat-overstrike 'highlight t)
1050 (defcustom gnus-treat-display-xface
1051 (and (or (and (fboundp 'image-type-available-p)
1052 (image-type-available-p 'xbm)
1053 (string-match "^0x" (shell-command-to-string "uncompface")))
1054 (and (featurep 'xemacs)
1057 "Display X-Face headers.
1058 Valid values are nil, t, `head', `last', an integer or a predicate.
1059 See Info node `(gnus)Customizing Articles' and Info node
1060 `(gnus)X-Face' for details."
1061 :group 'gnus-article-treat
1063 :type gnus-article-treat-head-custom)
1064 (put 'gnus-treat-display-xface 'highlight t)
1066 (defcustom gnus-treat-display-smileys
1067 (if (or (and (featurep 'xemacs)
1069 (and (fboundp 'image-type-available-p)
1070 (image-type-available-p 'pbm)))
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)Smileys' for details."
1076 :group 'gnus-article-treat
1078 :type gnus-article-treat-custom)
1079 (put 'gnus-treat-display-smileys 'highlight t)
1081 (defcustom gnus-treat-from-picon
1082 (if (gnus-image-type-available-p 'xpm)
1084 "Display picons in the From header.
1085 Valid values are nil, t, `head', `last', an integer or a predicate.
1086 See Info node `(gnus)Customizing Articles' and Info node
1087 `(gnus)Picons' for details."
1088 :group 'gnus-article-treat
1089 :type gnus-article-treat-head-custom)
1090 (put 'gnus-treat-from-picon 'highlight t)
1092 (defcustom gnus-treat-mail-picon
1093 (if (gnus-image-type-available-p 'xpm)
1095 "Display picons in To and Cc headers.
1096 Valid values are nil, t, `head', `last', an integer or a predicate.
1097 See Info node `(gnus)Customizing Articles' and Info node
1098 `(gnus)Picons' for details."
1099 :group 'gnus-article-treat
1100 :type gnus-article-treat-head-custom)
1101 (put 'gnus-treat-mail-picon 'highlight t)
1103 (defcustom gnus-treat-newsgroups-picon
1104 (if (gnus-image-type-available-p 'xpm)
1106 "Display picons in the Newsgroups and Followup-To headers.
1107 Valid values are nil, t, `head', `last', an integer or a predicate.
1108 See Info node `(gnus)Customizing Articles' and Info node
1109 `(gnus)Picons' for details."
1110 :group 'gnus-article-treat
1111 :type gnus-article-treat-head-custom)
1112 (put 'gnus-treat-newsgroups-picon 'highlight t)
1114 (defcustom gnus-treat-body-boundary
1115 (if (or gnus-treat-newsgroups-picon
1116 gnus-treat-mail-picon
1117 gnus-treat-from-picon)
1119 "Draw a boundary at the end of the headers.
1120 Valid values are nil, t, `head', `last', an integer or a predicate.
1121 See Info node `(gnus)Customizing Articles' for details."
1123 :group 'gnus-article-treat
1124 :type gnus-article-treat-custom)
1126 (defcustom gnus-treat-capitalize-sentences nil
1127 "Capitalize sentence-starting words.
1128 Valid values are nil, t, `head', `last', an integer or a predicate.
1129 See Info node `(gnus)Customizing Articles' for details."
1131 :group 'gnus-article-treat
1132 :type gnus-article-treat-custom)
1134 (defcustom gnus-treat-fill-long-lines nil
1136 Valid values are nil, t, `head', `last', an integer or a predicate.
1137 See Info node `(gnus)Customizing Articles' for details."
1138 :group 'gnus-article-treat
1139 :type gnus-article-treat-custom)
1141 (defcustom gnus-treat-play-sounds nil
1143 Valid values are nil, t, `head', `last', an integer or a predicate.
1144 See Info node `(gnus)Customizing Articles' for details."
1146 :group 'gnus-article-treat
1147 :type gnus-article-treat-custom)
1149 (defcustom gnus-treat-translate nil
1150 "Translate articles from one language to another.
1151 Valid values are nil, t, `head', `last', an integer or a predicate.
1152 See Info node `(gnus)Customizing Articles' for details."
1154 :group 'gnus-article-treat
1155 :type gnus-article-treat-custom)
1157 (defcustom gnus-treat-x-pgp-sig nil
1159 To automatically treat X-PGP-Sig, set it to head.
1160 Valid values are nil, t, `head', `last', an integer or a predicate.
1161 See Info node `(gnus)Customizing Articles' for details."
1162 :group 'gnus-article-treat
1163 :group 'mime-security
1164 :type gnus-article-treat-custom)
1166 (defvar gnus-article-encrypt-protocol-alist
1167 '(("PGP" . mml2015-self-encrypt)))
1169 ;; Set to nil if more than one protocol added to
1170 ;; gnus-article-encrypt-protocol-alist.
1171 (defcustom gnus-article-encrypt-protocol "PGP"
1172 "The protocol used for encrypt articles.
1173 It is a string, such as \"PGP\". If nil, ask user."
1175 :group 'mime-security)
1177 ;;; Internal variables
1179 (defvar gnus-english-month-names
1180 '("January" "February" "March" "April" "May" "June" "July" "August"
1181 "September" "October" "November" "December"))
1183 (defvar article-goto-body-goes-to-point-min-p nil)
1184 (defvar gnus-article-wash-types nil)
1185 (defvar gnus-article-emphasis-alist nil)
1186 (defvar gnus-article-image-alist nil)
1188 (defvar gnus-article-mime-handle-alist-1 nil)
1189 (defvar gnus-treatment-function-alist
1190 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1191 (gnus-treat-strip-banner gnus-article-strip-banner)
1192 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1193 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1194 (gnus-treat-buttonize gnus-article-add-buttons)
1195 (gnus-treat-fill-article gnus-article-fill-cited-article)
1196 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1197 (gnus-treat-strip-cr gnus-article-remove-cr)
1198 (gnus-treat-date-ut gnus-article-date-ut)
1199 (gnus-treat-date-local gnus-article-date-local)
1200 (gnus-treat-date-english gnus-article-date-english)
1201 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1202 (gnus-treat-date-original gnus-article-date-original)
1203 (gnus-treat-date-user-defined gnus-article-date-user)
1204 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1205 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1206 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1207 (gnus-treat-hide-signature gnus-article-hide-signature)
1208 (gnus-treat-hide-citation gnus-article-hide-citation)
1209 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1210 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1211 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1212 (gnus-treat-strip-pgp gnus-article-hide-pgp)
1213 (gnus-treat-strip-pem gnus-article-hide-pem)
1214 (gnus-treat-from-picon gnus-treat-from-picon)
1215 (gnus-treat-mail-picon gnus-treat-mail-picon)
1216 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1217 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1218 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1219 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1220 (gnus-treat-strip-trailing-blank-lines
1221 gnus-article-remove-trailing-blank-lines)
1222 (gnus-treat-strip-leading-blank-lines
1223 gnus-article-strip-leading-blank-lines)
1224 (gnus-treat-strip-multiple-blank-lines
1225 gnus-article-strip-multiple-blank-lines)
1226 (gnus-treat-overstrike gnus-article-treat-overstrike)
1227 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1228 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1229 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1230 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1231 (gnus-treat-display-smileys gnus-treat-smiley)
1232 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1233 (gnus-treat-emphasize gnus-article-emphasize)
1234 (gnus-treat-display-xface gnus-article-display-x-face)
1235 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1236 (gnus-treat-play-sounds gnus-earcon-display)))
1238 (defvar gnus-article-mime-handle-alist nil)
1239 (defvar article-lapsed-timer nil)
1240 (defvar gnus-article-current-summary nil)
1242 (defvar gnus-article-mode-syntax-table
1243 (let ((table (copy-syntax-table text-mode-syntax-table)))
1244 ;; This causes the citation match run O(2^n).
1245 ;; (modify-syntax-entry ?- "w" table)
1246 (modify-syntax-entry ?> ")" table)
1247 (modify-syntax-entry ?< "(" table)
1249 "Syntax table used in article mode buffers.
1250 Initialized from `text-mode-syntax-table.")
1252 (defvar gnus-save-article-buffer nil)
1254 (defvar gnus-article-mode-line-format-alist
1255 (nconc '((?w (gnus-article-wash-status) ?s)
1256 (?m (gnus-article-mime-part-status) ?s))
1257 gnus-summary-mode-line-format-alist))
1259 (defvar gnus-number-of-articles-to-be-saved nil)
1261 (defvar gnus-inhibit-hiding nil)
1263 ;;; Macros for dealing with the article buffer.
1265 (defmacro gnus-with-article-headers (&rest forms)
1267 (set-buffer gnus-article-buffer)
1269 (let ((buffer-read-only nil)
1270 (inhibit-point-motion-hooks t)
1271 (case-fold-search t))
1272 (article-narrow-to-head)
1275 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1276 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1278 (defmacro gnus-with-article-buffer (&rest forms)
1280 (set-buffer gnus-article-buffer)
1281 (let ((buffer-read-only nil))
1284 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1285 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1287 (defun gnus-article-goto-header (header)
1288 "Go to HEADER, which is a regular expression."
1289 (re-search-forward (concat "^\\(" header "\\):") nil t))
1291 (defsubst gnus-article-hide-text (b e props)
1292 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1293 (gnus-add-text-properties-when 'article-type nil b e props)
1294 (when (memq 'intangible props)
1296 (max (1- b) (point-min))
1297 b 'intangible (cddr (memq 'intangible props)))))
1299 (defsubst gnus-article-unhide-text (b e)
1300 "Remove hidden text properties from region between B and E."
1301 (remove-text-properties b e gnus-hidden-properties)
1302 (when (memq 'intangible gnus-hidden-properties)
1303 (put-text-property (max (1- b) (point-min))
1304 b 'intangible nil)))
1306 (defun gnus-article-hide-text-type (b e type)
1307 "Hide text of TYPE between B and E."
1308 (gnus-add-wash-type type)
1309 (gnus-article-hide-text
1310 b e (cons 'article-type (cons type gnus-hidden-properties))))
1312 (defun gnus-article-unhide-text-type (b e type)
1313 "Unhide text of TYPE between B and E."
1314 (gnus-delete-wash-type type)
1315 (remove-text-properties
1316 b e (cons 'article-type (cons type gnus-hidden-properties)))
1317 (when (memq 'intangible gnus-hidden-properties)
1318 (put-text-property (max (1- b) (point-min))
1319 b 'intangible nil)))
1321 (defun gnus-article-hide-text-of-type (type)
1322 "Hide text of TYPE in the current buffer."
1324 (let ((b (point-min))
1326 (while (setq b (text-property-any b e 'article-type type))
1327 (add-text-properties b (incf b) gnus-hidden-properties)))))
1329 (defun gnus-article-delete-text-of-type (type)
1330 "Delete text of TYPE in the current buffer."
1332 (let ((b (point-min)))
1333 (while (setq b (text-property-any b (point-max) 'article-type type))
1335 b (or (text-property-not-all b (point-max) 'article-type type)
1338 (defun gnus-article-delete-invisible-text ()
1339 "Delete all invisible text in the current buffer."
1341 (let ((b (point-min)))
1342 (while (setq b (text-property-any b (point-max) 'invisible t))
1344 b (or (text-property-not-all b (point-max) 'invisible t)
1347 (defun gnus-article-text-type-exists-p (type)
1348 "Say whether any text of type TYPE exists in the buffer."
1349 (text-property-any (point-min) (point-max) 'article-type type))
1351 (defsubst gnus-article-header-rank ()
1352 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1353 (let ((list gnus-sorted-header-list)
1356 (when (looking-at (car list))
1358 (setq list (cdr list))
1362 (defun article-hide-headers (&optional arg delete)
1363 "Hide unwanted headers and possibly sort them as well."
1365 ;; This function might be inhibited.
1366 (unless gnus-inhibit-hiding
1369 (let ((buffer-read-only nil)
1370 (case-fold-search t)
1371 (max (1+ (length gnus-sorted-header-list)))
1372 (ignored (when (not gnus-visible-headers)
1373 (cond ((stringp gnus-ignored-headers)
1374 gnus-ignored-headers)
1375 ((listp gnus-ignored-headers)
1376 (mapconcat 'identity gnus-ignored-headers
1379 (cond ((stringp gnus-visible-headers)
1380 gnus-visible-headers)
1381 ((and gnus-visible-headers
1382 (listp gnus-visible-headers))
1383 (mapconcat 'identity gnus-visible-headers "\\|"))))
1384 (inhibit-point-motion-hooks t)
1386 ;; First we narrow to just the headers.
1387 (article-narrow-to-head)
1388 ;; Hide any "From " lines at the beginning of (mail) articles.
1389 (while (looking-at "From ")
1392 (delete-region (point-min) (point)))
1393 ;; Then treat the rest of the header lines.
1394 ;; Then we use the two regular expressions
1395 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1396 ;; select which header lines is to remain visible in the
1398 (while (re-search-forward "^[^ \t:]*:" nil t)
1400 ;; Mark the rank of the header.
1402 (point) (1+ (point)) 'message-rank
1403 (if (or (and visible (looking-at visible))
1405 (not (looking-at ignored))))
1406 (gnus-article-header-rank)
1409 (message-sort-headers-1)
1410 (when (setq beg (text-property-any
1411 (point-min) (point-max) 'message-rank (+ 2 max)))
1412 ;; We delete the unwanted headers.
1413 (gnus-add-wash-type 'headers)
1414 (add-text-properties (point-min) (+ 5 (point-min))
1415 '(article-type headers dummy-invisible t))
1416 (delete-region beg (point-max))))))))
1418 (defun article-hide-boring-headers (&optional arg)
1419 "Toggle hiding of headers that aren't very interesting.
1420 If given a negative prefix, always show; if given a positive prefix,
1422 (interactive (gnus-article-hidden-arg))
1423 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1424 (not gnus-show-all-headers))
1427 (let ((buffer-read-only nil)
1428 (list gnus-boring-article-headers)
1429 (inhibit-point-motion-hooks t)
1431 (article-narrow-to-head)
1433 (setq elem (pop list))
1434 (goto-char (point-min))
1436 ;; Hide empty headers.
1438 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1440 (gnus-article-hide-text-type
1441 (progn (beginning-of-line) (point))
1444 (if (re-search-forward "^[^ \t]" nil t)
1448 ;; Hide boring Newsgroups header.
1449 ((eq elem 'newsgroups)
1450 (when (gnus-string-equal
1451 (gnus-fetch-field "newsgroups")
1452 (gnus-group-real-name
1453 (if (boundp 'gnus-newsgroup-name)
1456 (gnus-article-hide-header "newsgroups")))
1457 ((eq elem 'to-address)
1458 (let ((to (message-fetch-field "to"))
1460 (gnus-parameter-to-address
1461 (if (boundp 'gnus-newsgroup-name)
1462 gnus-newsgroup-name ""))))
1463 (when (and to to-address
1466 ;; only one address in To
1467 (nth 1 (mail-extract-address-components to))
1469 (gnus-article-hide-header "to"))))
1470 ((eq elem 'followup-to)
1471 (when (gnus-string-equal
1472 (message-fetch-field "followup-to")
1473 (message-fetch-field "newsgroups"))
1474 (gnus-article-hide-header "followup-to")))
1475 ((eq elem 'reply-to)
1476 (let ((from (message-fetch-field "from"))
1477 (reply-to (message-fetch-field "reply-to")))
1482 (nth 1 (mail-extract-address-components from))
1483 (nth 1 (mail-extract-address-components reply-to)))))
1484 (gnus-article-hide-header "reply-to"))))
1486 (let ((date (message-fetch-field "date")))
1488 (< (days-between (current-time-string) date)
1490 (gnus-article-hide-header "date"))))
1492 (let ((to (message-fetch-field "to"))
1493 (cc (message-fetch-field "cc")))
1494 (when (> (length to) 1024)
1495 (gnus-article-hide-header "to"))
1496 (when (> (length cc) 1024)
1497 (gnus-article-hide-header "cc"))))
1501 (goto-char (point-min))
1502 (while (re-search-forward "^to:" nil t)
1503 (setq to-count (1+ to-count)))
1504 (when (> to-count 1)
1505 (while (> to-count 0)
1506 (goto-char (point-min))
1508 (re-search-forward "^to:" nil nil to-count)
1510 (narrow-to-region (point) (point-max))
1511 (gnus-article-hide-header "to"))
1512 (setq to-count (1- to-count))))
1513 (goto-char (point-min))
1514 (while (re-search-forward "^cc:" nil t)
1515 (setq cc-count (1+ cc-count)))
1516 (when (> cc-count 1)
1517 (while (> cc-count 0)
1518 (goto-char (point-min))
1520 (re-search-forward "^cc:" nil nil cc-count)
1522 (narrow-to-region (point) (point-max))
1523 (gnus-article-hide-header "cc"))
1524 (setq cc-count (1- cc-count)))))))))))))
1526 (defun gnus-article-hide-header (header)
1528 (goto-char (point-min))
1529 (when (re-search-forward (concat "^" header ":") nil t)
1530 (gnus-article-hide-text-type
1531 (progn (beginning-of-line) (point))
1534 (if (re-search-forward "^[^ \t]" nil t)
1539 (defvar gnus-article-normalized-header-length 40
1540 "Length of normalized headers.")
1542 (defun article-normalize-headers ()
1543 "Make all header lines 40 characters long."
1545 (let ((buffer-read-only nil)
1549 (article-narrow-to-head)
1552 ((< (setq column (- (gnus-point-at-eol) (point)))
1553 gnus-article-normalized-header-length)
1555 (insert (make-string
1556 (- gnus-article-normalized-header-length column)
1558 ((> column gnus-article-normalized-header-length)
1559 (gnus-put-text-property
1561 (forward-char gnus-article-normalized-header-length)
1568 (forward-line 1))))))
1570 (defun article-treat-dumbquotes ()
1571 "Translate M****s*** sm*rtq**t*s into proper text.
1572 Note that this function guesses whether a character is a sm*rtq**t* or
1573 not, so it should only be used interactively.
1575 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1576 in an attempt to provide more quoting characters. If you see
1577 something like \\222 or \\264 where you're expecting some kind of
1578 apostrophe or quotation mark, then try this wash."
1580 (article-translate-strings gnus-article-dumbquotes-map))
1582 (defun article-translate-characters (from to)
1583 "Translate all characters in the body of the article according to FROM and TO.
1584 FROM is a string of characters to translate from; to is a string of
1585 characters to translate to."
1587 (when (article-goto-body)
1588 (let ((buffer-read-only nil)
1589 (x (make-string 225 ?x))
1591 (while (< (incf i) (length x))
1594 (while (< i (length from))
1595 (aset x (aref from i) (aref to i))
1597 (translate-region (point) (point-max) x)))))
1599 (defun article-translate-strings (map)
1600 "Translate all string in the body of the article according to MAP.
1601 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1603 (when (article-goto-body)
1604 (let ((buffer-read-only nil)
1606 (while (setq elem (pop map))
1608 (while (search-forward (car elem) nil t)
1609 (replace-match (cadr elem)))))))))
1611 (defun article-treat-overstrike ()
1612 "Translate overstrikes into bold text."
1615 (when (article-goto-body)
1616 (let ((buffer-read-only nil))
1617 (while (search-forward "\b" nil t)
1618 (let ((next (char-after))
1619 (previous (char-after (- (point) 2))))
1620 ;; We do the boldification/underlining by hiding the
1621 ;; overstrikes and putting the proper text property
1625 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1626 (put-text-property (point) (1+ (point)) 'face 'bold))
1628 (gnus-article-hide-text-type
1629 (1- (point)) (1+ (point)) 'overstrike)
1631 (- (point) 2) (1- (point)) 'face 'underline))
1633 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1635 (point) (1+ (point)) 'face 'underline)))))))))
1637 (defun gnus-article-treat-unfold-headers ()
1638 "Unfold folded message headers.
1639 Only the headers that fit into the current window width will be
1642 (gnus-with-article-headers
1646 (mail-header-narrow-to-field)
1647 (let ((header (buffer-substring (point-min) (point-max))))
1650 (goto-char (point-min))
1651 (while (re-search-forward "[\t ]*\n[\t ]+" nil t)
1652 (replace-match " " t t)))
1653 (setq length (- (point-max) (point-min) 1)))
1654 (when (< length (window-width))
1655 (while (re-search-forward "[\t ]*\n[\t ]+" nil t)
1656 (replace-match " " t t)))
1657 (goto-char (point-max)))))))
1659 (defun gnus-article-treat-fold-headers ()
1660 "Fold message headers."
1662 (gnus-with-article-headers
1665 (mail-header-narrow-to-field)
1666 (mail-header-fold-field)
1667 (goto-char (point-max))))))
1669 (defun gnus-treat-smiley ()
1670 "Display textual emoticons (\"smileys\") as small graphical icons."
1672 (gnus-with-article-buffer
1673 (if (memq 'smiley gnus-article-wash-types)
1674 (gnus-delete-images 'smiley)
1676 (let ((images (smiley-region (point) (point-max))))
1678 (gnus-add-wash-type 'smiley)
1679 (dolist (image images)
1680 (gnus-add-image 'smiley image)))))))
1682 (defun gnus-article-remove-images ()
1683 "Remove all images from the article buffer."
1685 (gnus-with-article-buffer
1686 (dolist (elem gnus-article-image-alist)
1687 (gnus-delete-images (car elem)))))
1689 (defun gnus-article-treat-fold-newsgroups ()
1690 "Unfold folded message headers.
1691 Only the headers that fit into the current window width will be
1694 (gnus-with-article-headers
1695 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1697 (mail-header-narrow-to-field)
1698 (while (re-search-forward ", *" nil t)
1699 (replace-match ", " t t))
1700 (mail-header-fold-field)
1701 (goto-char (point-max))))))
1703 (defun gnus-article-treat-body-boundary ()
1704 "Place a boundary line at the end of the headers."
1706 (when (and gnus-body-boundary-delimiter
1707 (> (length gnus-body-boundary-delimiter) 0))
1708 (gnus-with-article-headers
1709 (goto-char (point-max))
1710 (let ((start (point)))
1711 (insert "X-Boundary: ")
1712 (gnus-add-text-properties start (point) '(invisible t intangible t))
1714 (while (>= (1- (window-width)) (length str))
1715 (setq str (concat str gnus-body-boundary-delimiter)))
1716 (substring str 0 (1- (window-width))))
1719 (defun article-fill-long-lines ()
1720 "Fill lines that are wider than the window width."
1723 (let ((buffer-read-only nil)
1724 (width (window-width (get-buffer-window (current-buffer)))))
1727 (let ((adaptive-fill-mode nil)) ;Why? -sm
1730 (when (>= (current-column) (min fill-column width))
1731 (narrow-to-region (point) (gnus-point-at-bol))
1732 (fill-paragraph nil)
1733 (goto-char (point-max))
1735 (forward-line 1)))))))
1737 (defun article-capitalize-sentences ()
1738 "Capitalize the first word in each sentence."
1741 (let ((buffer-read-only nil)
1742 (paragraph-start "^[\n\^L]"))
1746 (forward-sentence)))))
1748 (defun article-remove-cr ()
1749 "Remove trailing CRs and then translate remaining CRs into LFs."
1752 (let ((buffer-read-only nil))
1753 (goto-char (point-min))
1754 (while (re-search-forward "\r+$" nil t)
1755 (replace-match "" t t))
1756 (goto-char (point-min))
1757 (while (search-forward "\r" nil t)
1758 (replace-match "\n" t t)))))
1760 (defun article-remove-trailing-blank-lines ()
1761 "Remove all trailing blank lines from the article."
1764 (let ((buffer-read-only nil))
1765 (goto-char (point-max))
1769 (while (and (not (bobp))
1770 (looking-at "^[ \t]*$")
1771 (not (gnus-annotation-in-region-p
1772 (point) (gnus-point-at-eol))))
1777 (defun article-display-x-face (&optional force)
1778 "Look for an X-Face header and display it if present."
1779 (interactive (list 'force))
1780 (gnus-with-article-headers
1781 ;; Delete the old process, if any.
1782 (when (process-status "article-x-face")
1783 (delete-process "article-x-face"))
1784 (if (memq 'xface gnus-article-wash-types)
1785 ;; We have already displayed X-Faces, so we remove them
1787 (gnus-delete-images 'xface)
1789 (let (x-faces from face grey)
1791 (set-buffer gnus-original-article-buffer)
1793 (mail-narrow-to-head)
1794 (while (gnus-article-goto-header "x-face\\(-[0-9]+\\)?")
1795 (when (match-beginning 2)
1797 (push (mail-header-field-value) x-faces))
1798 (setq from (message-fetch-field "from"))))
1800 (let ((xpm (gnus-convert-gray-x-face-to-xpm x-faces))
1803 (setq image (gnus-create-image xpm 'xpm t))
1804 (gnus-article-goto-header "from")
1805 (gnus-add-wash-type 'xface)
1806 (gnus-add-image 'xface image)
1807 (gnus-put-image image)))
1808 ;; Sending multiple EOFs to xv doesn't work, so we only do a
1809 ;; single external face.
1810 (when (stringp gnus-article-x-face-command)
1811 (setq x-faces (list (car x-faces))))
1812 (while (and (setq face (pop x-faces))
1813 gnus-article-x-face-command
1815 ;; Check whether this face is censored.
1816 (not gnus-article-x-face-too-ugly)
1817 (and gnus-article-x-face-too-ugly from
1818 (not (string-match gnus-article-x-face-too-ugly
1820 ;; We display the face.
1821 (if (symbolp gnus-article-x-face-command)
1822 ;; The command is a lisp function, so we call it.
1823 (if (gnus-functionp gnus-article-x-face-command)
1824 (funcall gnus-article-x-face-command face)
1825 (error "%s is not a function" gnus-article-x-face-command))
1826 ;; The command is a string, so we interpret the command
1827 ;; as a, well, command, and fork it off.
1828 (let ((process-connection-type nil))
1829 (process-kill-without-query
1831 "article-x-face" nil shell-file-name shell-command-switch
1832 gnus-article-x-face-command))
1835 (process-send-region "article-x-face"
1836 (point-min) (point-max)))
1837 (process-send-eof "article-x-face")))))))))
1839 (defun article-decode-mime-words ()
1840 "Decode all MIME-encoded words in the article."
1843 (set-buffer gnus-article-buffer)
1844 (let ((inhibit-point-motion-hooks t)
1846 (mail-parse-charset gnus-newsgroup-charset)
1847 (mail-parse-ignored-charsets
1848 (save-excursion (set-buffer gnus-summary-buffer)
1849 gnus-newsgroup-ignored-charsets)))
1850 (mail-decode-encoded-word-region (point-min) (point-max)))))
1852 (defun article-decode-charset (&optional prompt)
1853 "Decode charset-encoded text in the article.
1854 If PROMPT (the prefix), prompt for a coding system to use."
1856 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
1858 (mail-parse-charset gnus-newsgroup-charset)
1859 (mail-parse-ignored-charsets
1860 (save-excursion (condition-case nil
1861 (set-buffer gnus-summary-buffer)
1863 gnus-newsgroup-ignored-charsets))
1864 ct cte ctl charset format)
1867 (article-narrow-to-head)
1868 (setq ct (message-fetch-field "Content-Type" t)
1869 cte (message-fetch-field "Content-Transfer-Encoding" t)
1870 ctl (and ct (ignore-errors
1871 (mail-header-parse-content-type ct)))
1874 (mm-read-coding-system "Charset to decode: "))
1876 (mail-content-type-get ctl 'charset)))
1877 format (and ctl (mail-content-type-get ctl 'format)))
1879 (setq cte (mail-header-strip cte)))
1880 (if (and ctl (not (string-match "/" (car ctl))))
1882 (goto-char (point-max)))
1885 (narrow-to-region (point) (point-max))
1886 (when (and (eq mail-parse-charset 'gnus-decoded)
1887 (eq (mm-body-7-or-8) '8bit))
1888 ;; The text code could have been decoded.
1889 (setq charset mail-parse-charset))
1890 (when (and (or (not ctl)
1891 (equal (car ctl) "text/plain"))
1892 (not format)) ;; article with format will decode later.
1894 charset (and cte (intern (downcase
1895 (gnus-strip-whitespace cte))))
1898 (defun article-decode-encoded-words ()
1899 "Remove encoded-word encoding from headers."
1900 (let ((inhibit-point-motion-hooks t)
1901 (mail-parse-charset gnus-newsgroup-charset)
1902 (mail-parse-ignored-charsets
1903 (save-excursion (condition-case nil
1904 (set-buffer gnus-summary-buffer)
1906 gnus-newsgroup-ignored-charsets))
1909 (article-narrow-to-head)
1910 (funcall gnus-decode-header-function (point-min) (point-max)))))
1912 (defun article-decode-group-name ()
1913 "Decode group names in `Newsgroups:'."
1914 (let ((inhibit-point-motion-hooks t)
1916 (method (gnus-find-method-for-group gnus-newsgroup-name)))
1917 (when (and (or gnus-group-name-charset-method-alist
1918 gnus-group-name-charset-group-alist)
1919 (gnus-buffer-live-p gnus-original-article-buffer))
1920 (when (nnmail-fetch-field "Newsgroups")
1921 (nnheader-replace-header "Newsgroups"
1922 (gnus-decode-newsgroups
1923 (with-current-buffer
1924 gnus-original-article-buffer
1925 (nnmail-fetch-field "Newsgroups"))
1926 gnus-newsgroup-name method)))
1927 (when (nnmail-fetch-field "Followup-To")
1928 (nnheader-replace-header "Followup-To"
1929 (gnus-decode-newsgroups
1930 (with-current-buffer
1931 gnus-original-article-buffer
1932 (nnmail-fetch-field "Followup-To"))
1933 gnus-newsgroup-name method))))))
1935 (defun article-de-quoted-unreadable (&optional force read-charset)
1936 "Translate a quoted-printable-encoded article.
1937 If FORCE, decode the article whether it is marked as quoted-printable
1939 If READ-CHARSET, ask for a coding system."
1940 (interactive (list 'force current-prefix-arg))
1942 (let ((buffer-read-only nil) type charset)
1943 (if (gnus-buffer-live-p gnus-original-article-buffer)
1944 (with-current-buffer gnus-original-article-buffer
1946 (gnus-fetch-field "content-transfer-encoding"))
1947 (let* ((ct (gnus-fetch-field "content-type"))
1950 (mail-header-parse-content-type ct)))))
1951 (setq charset (and ctl
1952 (mail-content-type-get ctl 'charset)))
1953 (if (stringp charset)
1954 (setq charset (intern (downcase charset)))))))
1956 (setq charset (mm-read-coding-system "Charset: " charset)))
1958 (setq charset gnus-newsgroup-charset))
1960 (and type (let ((case-fold-search t))
1961 (string-match "quoted-printable" type))))
1963 (quoted-printable-decode-region
1964 (point) (point-max) (mm-charset-to-coding-system charset))))))
1966 (defun article-de-base64-unreadable (&optional force read-charset)
1967 "Translate a base64 article.
1968 If FORCE, decode the article whether it is marked as base64 not.
1969 If READ-CHARSET, ask for a coding system."
1970 (interactive (list 'force current-prefix-arg))
1972 (let ((buffer-read-only nil) type charset)
1973 (if (gnus-buffer-live-p gnus-original-article-buffer)
1974 (with-current-buffer gnus-original-article-buffer
1976 (gnus-fetch-field "content-transfer-encoding"))
1977 (let* ((ct (gnus-fetch-field "content-type"))
1980 (mail-header-parse-content-type ct)))))
1981 (setq charset (and ctl
1982 (mail-content-type-get ctl 'charset)))
1983 (if (stringp charset)
1984 (setq charset (intern (downcase charset)))))))
1986 (setq charset (mm-read-coding-system "Charset: " charset)))
1988 (setq charset gnus-newsgroup-charset))
1990 (and type (let ((case-fold-search t))
1991 (string-match "base64" type))))
1994 (narrow-to-region (point) (point-max))
1995 (base64-decode-region (point-min) (point-max))
1996 (mm-decode-coding-region
1997 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2002 (defun article-decode-HZ ()
2003 "Translate a HZ-encoded article."
2007 (let ((buffer-read-only nil))
2008 (rfc1843-decode-region (point-min) (point-max)))))
2010 (defun article-wash-html (&optional read-charset)
2011 "Format an html article.
2012 If READ-CHARSET, ask for a coding system."
2015 (let ((buffer-read-only nil)
2017 (if (gnus-buffer-live-p gnus-original-article-buffer)
2018 (with-current-buffer gnus-original-article-buffer
2019 (let* ((ct (gnus-fetch-field "content-type"))
2022 (mail-header-parse-content-type ct)))))
2023 (setq charset (and ctl
2024 (mail-content-type-get ctl 'charset)))
2025 (if (stringp charset)
2026 (setq charset (intern (downcase charset)))))))
2028 (setq charset (mm-read-coding-system "Charset: " charset)))
2030 (setq charset gnus-newsgroup-charset))
2032 (save-window-excursion
2034 (narrow-to-region (point) (point-max))
2036 (let ((w3-strict-width (window-width))
2037 (url-standalone-mode t)
2038 (w3-honor-stylesheets nil)
2039 (w3-delay-image-loads t))
2041 (w3-region (point-min) (point-max))
2044 (defun article-hide-list-identifiers ()
2045 "Remove list identifies from the Subject header.
2046 The `gnus-list-identifiers' variable specifies what to do."
2048 (let ((inhibit-point-motion-hooks t)
2049 (regexp (if (consp gnus-list-identifiers)
2050 (mapconcat 'identity gnus-list-identifiers " *\\|")
2051 gnus-list-identifiers))
2056 (article-narrow-to-head)
2057 (goto-char (point-min))
2058 (while (re-search-forward
2059 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2061 (delete-region (match-beginning 2) (match-end 0))
2062 (beginning-of-line))
2063 (when (re-search-forward
2064 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2065 (delete-region (match-beginning 1) (match-end 1))))))))
2067 (defun article-hide-pgp ()
2068 "Remove any PGP headers and signatures in the current article."
2072 (let ((inhibit-point-motion-hooks t)
2073 buffer-read-only beg end)
2075 ;; Hide the "header".
2076 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
2077 (gnus-add-wash-type 'pgp)
2078 (delete-region (match-beginning 0) (match-end 0))
2079 ;; Remove armor headers (rfc2440 6.2)
2080 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
2083 ;; Hide the actual signature.
2084 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
2085 (setq end (1+ (match-beginning 0)))
2088 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
2090 ;; Perhaps we shouldn't hide to the end of the buffer
2091 ;; if there is no end to the signature?
2093 ;; Hide "- " PGP quotation markers.
2095 (narrow-to-region beg end)
2096 (goto-char (point-min))
2097 (while (re-search-forward "^- " nil t)
2099 (match-beginning 0) (match-end 0)))
2101 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
2103 (defun article-hide-pem (&optional arg)
2104 "Toggle hiding of any PEM headers and signatures in the current article.
2105 If given a negative prefix, always show; if given a positive prefix,
2107 (interactive (gnus-article-hidden-arg))
2108 (unless (gnus-article-check-hidden-text 'pem arg)
2110 (let (buffer-read-only end)
2111 (goto-char (point-min))
2112 ;; Hide the horrendously ugly "header".
2113 (when (and (search-forward
2114 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2116 (setq end (1+ (match-beginning 0))))
2117 (gnus-add-wash-type 'pem)
2118 (gnus-article-hide-text-type
2120 (if (search-forward "\n\n" nil t)
2124 ;; Hide the trailer as well
2125 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2127 (gnus-article-hide-text-type
2128 (match-beginning 0) (match-end 0) 'pem)))))))
2130 (defun article-strip-banner ()
2131 "Strip the banner specified by the `banner' group parameter."
2135 (let ((inhibit-point-motion-hooks t)
2136 (banner (gnus-parameter-banner gnus-newsgroup-name))
2137 (gnus-signature-limit nil)
2138 buffer-read-only beg end)
2142 ((eq banner 'signature)
2143 (when (gnus-article-narrow-to-signature)
2146 (delete-region (point) (point-max))))
2148 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2149 (while (re-search-forward banner nil t)
2150 (delete-region (match-beginning 0) (match-end 0)))))
2152 (while (re-search-forward banner nil t)
2153 (delete-region (match-beginning 0) (match-end 0))))))))))
2155 (defun article-babel ()
2156 "Translate article using an online translation service."
2160 (set-buffer gnus-article-buffer)
2161 (when (article-goto-body)
2162 (let* ((buffer-read-only nil)
2165 (orig (buffer-substring start end))
2166 (trans (babel-as-string orig)))
2168 (narrow-to-region start end)
2169 (delete-region start end)
2172 (defun article-hide-signature (&optional arg)
2173 "Hide the signature in the current article.
2174 If given a negative prefix, always show; if given a positive prefix,
2176 (interactive (gnus-article-hidden-arg))
2177 (unless (gnus-article-check-hidden-text 'signature arg)
2180 (let ((buffer-read-only nil))
2181 (when (gnus-article-narrow-to-signature)
2182 (gnus-article-hide-text-type
2183 (point-min) (point-max) 'signature))))))
2184 (gnus-set-mode-line 'article))
2186 (defun article-strip-headers-in-body ()
2187 "Strip offensive headers from bodies."
2191 (let ((case-fold-search t))
2192 (when (looking-at "x-no-archive:")
2193 (gnus-delete-line)))))
2195 (defun article-strip-leading-blank-lines ()
2196 "Remove all blank lines from the beginning of the article."
2199 (let ((inhibit-point-motion-hooks t)
2201 (when (article-goto-body)
2202 (while (and (not (eobp))
2203 (looking-at "[ \t]*$"))
2204 (gnus-delete-line))))))
2206 (defun article-narrow-to-head ()
2207 "Narrow the buffer to the head of the message.
2208 Point is left at the beginning of the narrowed-to region."
2210 (goto-char (point-min))
2211 (if (search-forward "\n\n" nil 1)
2214 (goto-char (point-min)))
2216 (defun article-goto-body ()
2217 "Place point at the start of the body."
2218 (goto-char (point-min))
2220 ;; This variable is only bound when dealing with separate
2222 (article-goto-body-goes-to-point-min-p
2224 ((search-forward "\n\n" nil t)
2227 (goto-char (point-max))
2230 (defun article-strip-multiple-blank-lines ()
2231 "Replace consecutive blank lines with one empty line."
2234 (let ((inhibit-point-motion-hooks t)
2236 ;; First make all blank lines empty.
2238 (while (re-search-forward "^[ \t]+$" nil t)
2239 (unless (gnus-annotation-in-region-p
2240 (match-beginning 0) (match-end 0))
2241 (replace-match "" nil t)))
2242 ;; Then replace multiple empty lines with a single empty line.
2244 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2245 (unless (gnus-annotation-in-region-p
2246 (match-beginning 0) (match-end 0))
2247 (delete-region (match-beginning 1) (match-end 1)))))))
2249 (defun article-strip-leading-space ()
2250 "Remove all white space from the beginning of the lines in the article."
2253 (let ((inhibit-point-motion-hooks t)
2256 (while (re-search-forward "^[ \t]+" nil t)
2257 (replace-match "" t t)))))
2259 (defun article-strip-trailing-space ()
2260 "Remove all white space from the end of the lines in the article."
2263 (let ((inhibit-point-motion-hooks t)
2266 (while (re-search-forward "[ \t]+$" nil t)
2267 (replace-match "" t t)))))
2269 (defun article-strip-blank-lines ()
2270 "Strip leading, trailing and multiple blank lines."
2272 (article-strip-leading-blank-lines)
2273 (article-remove-trailing-blank-lines)
2274 (article-strip-multiple-blank-lines))
2276 (defun article-strip-all-blank-lines ()
2277 "Strip all blank lines."
2280 (let ((inhibit-point-motion-hooks t)
2283 (while (re-search-forward "^[ \t]*\n" nil t)
2284 (replace-match "" t t)))))
2286 (defun gnus-article-narrow-to-signature ()
2287 "Narrow to the signature; return t if a signature is found, else nil."
2288 (let ((inhibit-point-motion-hooks t))
2289 (when (gnus-article-search-signature)
2291 ;; Check whether we have some limits to what we consider
2292 ;; to be a signature.
2293 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2294 (list gnus-signature-limit)))
2296 (while (setq limit (pop limits))
2297 (if (or (and (integerp limit)
2298 (< (- (point-max) (point)) limit))
2300 (< (count-lines (point) (point-max)) limit))
2301 (and (gnus-functionp limit)
2303 (and (stringp limit)
2304 (not (re-search-forward limit nil t))))
2305 () ; This limit did not succeed.
2309 (narrow-to-region (point) (point-max))
2312 (defun gnus-article-search-signature ()
2313 "Search the current buffer for the signature separator.
2314 Put point at the beginning of the signature separator."
2315 (let ((cur (point)))
2316 (goto-char (point-max))
2317 (if (if (stringp gnus-signature-separator)
2318 (re-search-backward gnus-signature-separator nil t)
2319 (let ((seps gnus-signature-separator))
2321 (not (re-search-backward (car seps) nil t)))
2328 (defun gnus-article-hidden-arg ()
2329 "Return the current prefix arg as a number, or 0 if no prefix."
2330 (list (if current-prefix-arg
2331 (prefix-numeric-value current-prefix-arg)
2334 (defun gnus-article-check-hidden-text (type arg)
2335 "Return nil if hiding is necessary.
2336 Arg can be nil or a number. nil and positive means hide, negative
2337 means show, 0 means toggle."
2340 (let ((hide (gnus-article-hidden-text-p type)))
2346 (gnus-article-show-hidden-text type)
2349 (if (eq hide 'hidden)
2351 (gnus-article-show-hidden-text type)
2355 (defun gnus-article-hidden-text-p (type)
2356 "Say whether the current buffer contains hidden text of type TYPE."
2357 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2359 (not (get-text-property pos 'invisible))
2360 (not (get-text-property pos 'dummy-invisible)))
2362 (text-property-any (1+ pos) (point-max) 'article-type type)))
2367 (defun gnus-article-show-hidden-text (type &optional dummy)
2368 "Show all hidden text of type TYPE.
2369 Originally it is hide instead of DUMMY."
2370 (let ((buffer-read-only nil)
2371 (inhibit-point-motion-hooks t))
2372 (gnus-remove-text-properties-when
2374 (point-min) (point-max)
2375 (cons 'article-type (cons type
2376 gnus-hidden-properties)))
2377 (gnus-delete-wash-type type)))
2379 (defconst article-time-units
2380 `((year . ,(* 365.25 24 60 60))
2381 (week . ,(* 7 24 60 60))
2382 (day . ,(* 24 60 60))
2386 "Mapping from time units to seconds.")
2388 (defun article-date-ut (&optional type highlight header)
2389 "Convert DATE date to universal time in the current article.
2390 If TYPE is `local', convert to local time; if it is `lapsed', output
2391 how much time has lapsed since DATE. For `lapsed', the value of
2392 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2393 should replace the \"Date:\" one, or should be added below it."
2394 (interactive (list 'ut t))
2395 (let* ((header (or header
2396 (message-fetch-field "date")
2398 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2401 ((not gnus-article-date-lapsed-new-header)
2407 (date (if (vectorp header) (mail-header-date header)
2409 (inhibit-point-motion-hooks t)
2414 (article-narrow-to-head)
2415 (when (re-search-forward tdate-regexp nil t)
2416 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2417 date (or (get-text-property (gnus-point-at-bol)
2420 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2422 (when (and date (not (string= date "")))
2423 (goto-char (point-min))
2424 (let ((buffer-read-only nil))
2425 ;; Delete any old Date headers.
2426 (while (re-search-forward date-regexp nil t)
2428 (delete-region (progn (beginning-of-line) (point))
2429 (progn (forward-line 1) (point)))
2430 (delete-region (progn (beginning-of-line) (point))
2431 (progn (end-of-line) (point)))
2432 (setq pos (point))))
2433 (when (and (not pos) (re-search-forward tdate-regexp nil t))
2435 (if pos (goto-char pos))
2436 (insert (article-make-date-line date (or type 'ut)))
2442 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2443 (put-text-property (match-beginning 1) (1+ (match-end 1))
2444 'original-date date)
2445 (put-text-property (match-beginning 1) (1+ (match-end 1))
2447 (put-text-property (match-beginning 2) (match-end 2)
2450 (defun article-make-date-line (date type)
2451 "Return a DATE line of TYPE."
2452 (unless (memq type '(local ut original user iso8601 lapsed english))
2453 (error "Unknown conversion type: %s" type))
2455 (let ((time (date-to-time date)))
2457 ;; Convert to the local timezone.
2459 (let ((tz (car (current-time-zone time))))
2460 (format "Date: %s %s%02d%02d" (current-time-string time)
2461 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2462 (/ (% (abs tz) 3600) 60))))
2463 ;; Convert to Universal Time.
2466 (current-time-string
2467 (let* ((e (parse-time-string date))
2468 (tm (apply 'encode-time e))
2470 (ls (- (cadr tm) (car (current-time-zone time)))))
2471 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2472 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2475 ;; Get the original date from the article.
2476 ((eq type 'original)
2477 (concat "Date: " (if (string-match "\n+$" date)
2478 (substring date 0 (match-beginning 0))
2480 ;; Let the user define the format.
2482 (if (gnus-functionp gnus-article-time-format)
2483 (funcall gnus-article-time-format time)
2486 (format-time-string gnus-article-time-format time))))
2489 (let ((tz (car (current-time-zone time))))
2492 (format-time-string "%Y%m%dT%H%M%S" time)
2493 (format "%s%02d%02d"
2494 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2495 (/ (% (abs tz) 3600) 60)))))
2496 ;; Do an X-Sent lapsed format.
2498 ;; If the date is seriously mangled, the timezone functions are
2499 ;; liable to bug out, so we ignore all errors.
2500 (let* ((now (current-time))
2501 (real-time (subtract-time now time))
2502 (real-sec (and real-time
2503 (+ (* (float (car real-time)) 65536)
2505 (sec (and real-time (abs real-sec)))
2515 ;; This is a bit convoluted, but basically we go
2516 ;; through the time units for years, weeks, etc,
2517 ;; and divide things to see whether that results
2518 ;; in positive answers.
2521 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2522 ;; The (remaining) seconds are too few to
2523 ;; be divided into this time unit.
2525 ;; It's big enough, so we output it.
2526 (setq sec (- sec (* num (cdr unit))))
2528 (concat (if prev ", " "") (int-to-string
2530 " " (symbol-name (car unit))
2531 (if (> num 1) "s" ""))
2533 article-time-units "")
2534 ;; If dates are odd, then it might appear like the
2535 ;; article was sent in the future.
2538 " in the future"))))))
2539 ;; Display the date in proper English
2541 (let ((dtime (decode-time time)))
2544 (number-to-string (nth 3 dtime))
2545 (let ((digit (% (nth 3 dtime) 10)))
2547 ((memq (nth 3 dtime) '(11 12 13)) "th")
2553 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2555 (number-to-string (nth 5 dtime))
2557 (format "%02d" (nth 2 dtime))
2559 (format "%02d" (nth 1 dtime)))))))
2561 (format "Date: %s (from Oort)" date))))
2563 (defun article-date-local (&optional highlight)
2564 "Convert the current article date to the local timezone."
2565 (interactive (list t))
2566 (article-date-ut 'local highlight))
2568 (defun article-date-english (&optional highlight)
2569 "Convert the current article date to something that is proper English."
2570 (interactive (list t))
2571 (article-date-ut 'english highlight))
2573 (defun article-date-original (&optional highlight)
2574 "Convert the current article date to what it was originally.
2575 This is only useful if you have used some other date conversion
2576 function and want to see what the date was before converting."
2577 (interactive (list t))
2578 (article-date-ut 'original highlight))
2580 (defun article-date-lapsed (&optional highlight)
2581 "Convert the current article date to time lapsed since it was sent."
2582 (interactive (list t))
2583 (article-date-ut 'lapsed highlight))
2585 (defun article-update-date-lapsed ()
2586 "Function to be run from a timer to update the lapsed time line."
2587 (let (deactivate-mark)
2592 (set-buffer (window-buffer w))
2593 (when (eq major-mode 'gnus-article-mode)
2594 (goto-char (point-min))
2595 (when (re-search-forward "^X-Sent:" nil t)
2596 (article-date-lapsed t))))
2599 (defun gnus-start-date-timer (&optional n)
2600 "Start a timer to update the X-Sent header in the article buffers.
2601 The numerical prefix says how frequently (in seconds) the function
2606 (gnus-stop-date-timer)
2607 (setq article-lapsed-timer
2608 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2610 (defun gnus-stop-date-timer ()
2611 "Stop the X-Sent timer."
2613 (when article-lapsed-timer
2614 (nnheader-cancel-timer article-lapsed-timer)
2615 (setq article-lapsed-timer nil)))
2617 (defun article-date-user (&optional highlight)
2618 "Convert the current article date to the user-defined format.
2619 This format is defined by the `gnus-article-time-format' variable."
2620 (interactive (list t))
2621 (article-date-ut 'user highlight))
2623 (defun article-date-iso8601 (&optional highlight)
2624 "Convert the current article date to ISO8601."
2625 (interactive (list t))
2626 (article-date-ut 'iso8601 highlight))
2628 (defun article-show-all ()
2629 "Show all hidden text in the article buffer."
2632 (let ((buffer-read-only nil))
2633 (gnus-article-unhide-text (point-min) (point-max)))))
2635 (defun article-remove-leading-whitespace ()
2636 "Remove excessive whitespace from all headers."
2640 (let ((buffer-read-only nil))
2641 (article-narrow-to-head)
2642 (goto-char (point-min))
2643 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2644 (delete-region (match-beginning 1) (match-end 1)))))))
2646 (defun article-emphasize (&optional arg)
2647 "Emphasize text according to `gnus-emphasis-alist'."
2648 (interactive (gnus-article-hidden-arg))
2649 (unless (gnus-article-check-hidden-text 'emphasis arg)
2653 (with-current-buffer gnus-summary-buffer
2654 gnus-article-emphasis-alist)
2656 gnus-emphasis-alist))
2657 (buffer-read-only nil)
2658 (props (append '(article-type emphasis)
2659 gnus-hidden-properties))
2660 regexp elem beg invisible visible face)
2663 (while (setq elem (pop alist))
2665 (setq regexp (car elem)
2666 invisible (nth 1 elem)
2667 visible (nth 2 elem)
2669 (while (re-search-forward regexp nil t)
2670 (when (and (match-beginning visible) (match-beginning invisible))
2671 (gnus-article-hide-text
2672 (match-beginning invisible) (match-end invisible) props)
2673 (gnus-article-unhide-text-type
2674 (match-beginning visible) (match-end visible) 'emphasis)
2675 (gnus-put-overlay-excluding-newlines
2676 (match-beginning visible) (match-end visible) 'face face)
2677 (gnus-add-wash-type 'emphasis)
2678 (goto-char (match-end invisible)))))))))
2680 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2681 "Setup newsgroup emphasis alist."
2682 (unless gnus-article-emphasis-alist
2683 (let ((name (and gnus-newsgroup-name
2684 (gnus-group-real-name gnus-newsgroup-name))))
2685 (make-local-variable 'gnus-article-emphasis-alist)
2686 (setq gnus-article-emphasis-alist
2688 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2689 (while (setq elem (pop alist))
2690 (when (and name (string-match (car elem) name))
2692 highlight (copy-sequence (cdr elem)))))
2694 (copy-sequence highlight-words)
2695 (if gnus-newsgroup-name
2696 (copy-sequence (gnus-group-find-parameter
2697 gnus-newsgroup-name 'highlight-words t)))
2698 gnus-emphasis-alist)))))
2701 (defvar gnus-summary-article-menu)
2702 (defvar gnus-summary-post-menu))
2704 ;;; Saving functions.
2706 (defun gnus-article-save (save-buffer file &optional num)
2707 "Save the currently selected article."
2708 (unless gnus-save-all-headers
2709 ;; Remove headers according to `gnus-saved-headers'.
2710 (let ((gnus-visible-headers
2711 (or gnus-saved-headers gnus-visible-headers))
2712 (gnus-article-buffer save-buffer))
2714 (set-buffer save-buffer)
2715 (article-hide-headers 1 t))))
2716 (save-window-excursion
2717 (if (not gnus-default-article-saver)
2718 (error "No default saver is defined")
2719 ;; !!! Magic! The saving functions all save
2720 ;; `gnus-save-article-buffer' (or so they think), but we
2721 ;; bind that variable to our save-buffer.
2722 (set-buffer gnus-article-buffer)
2723 (let* ((gnus-save-article-buffer save-buffer)
2726 ((not gnus-prompt-before-saving) 'default)
2727 ((eq gnus-prompt-before-saving 'always) nil)
2729 (gnus-number-of-articles-to-be-saved
2730 (when (eq gnus-prompt-before-saving t)
2732 (set-buffer gnus-article-current-summary)
2733 (funcall gnus-default-article-saver filename)))))
2735 (defun gnus-read-save-file-name (prompt &optional filename
2736 function group headers variable)
2738 (funcall function group headers (symbol-value variable)))
2743 ((eq filename 'default)
2749 (let* ((split-name (gnus-get-split-value gnus-split-methods))
2752 (if (and gnus-number-of-articles-to-be-saved
2753 (> gnus-number-of-articles-to-be-saved 1))
2754 (format "these %d articles"
2755 gnus-number-of-articles-to-be-saved)
2758 ;; Let the split methods have their say.
2760 ;; No split name was found.
2763 (concat prompt " (default "
2764 (file-name-nondirectory default-name) ") ")
2765 (file-name-directory default-name)
2767 ;; A single group name is returned.
2768 ((stringp split-name)
2770 (funcall function split-name headers
2771 (symbol-value variable)))
2773 (concat prompt " (default "
2774 (file-name-nondirectory default-name) ") ")
2775 (file-name-directory default-name)
2777 ;; A single split name was found
2778 ((= 1 (length split-name))
2779 (let* ((name (expand-file-name
2781 gnus-article-save-directory))
2782 (dir (cond ((file-directory-p name)
2783 (file-name-as-directory name))
2784 ((file-exists-p name) name)
2785 (t gnus-article-save-directory))))
2787 (concat prompt " (default " name ") ")
2789 ;; A list of splits was found.
2791 (setq split-name (nreverse split-name))
2793 (let ((file-name-history
2794 (nconc split-name file-name-history)))
2798 (concat prompt " (`M-p' for defaults) ")
2799 gnus-article-save-directory
2801 gnus-article-save-directory)))
2802 (car (push result file-name-history)))))))
2803 ;; Create the directory.
2804 (gnus-make-directory (file-name-directory file))
2805 ;; If we have read a directory, we append the default file name.
2806 (when (file-directory-p file)
2807 (setq file (expand-file-name (file-name-nondirectory
2809 (file-name-as-directory file))))
2810 ;; Possibly translate some characters.
2811 (nnheader-translate-file-chars file))))))
2812 (gnus-make-directory (file-name-directory result))
2813 (set variable result)))
2815 (defun gnus-article-archive-name (group)
2816 "Return the first instance of an \"Archive-name\" in the current buffer."
2817 (let ((case-fold-search t))
2818 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
2819 (nnheader-concat gnus-article-save-directory
2820 (match-string 1)))))
2822 (defun gnus-article-nndoc-name (group)
2823 "If GROUP is an nndoc group, return the name of the parent group."
2824 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
2825 (gnus-group-get-parameter group 'save-article-group)))
2827 (defun gnus-summary-save-in-rmail (&optional filename)
2828 "Append this article to Rmail file.
2829 Optional argument FILENAME specifies file name.
2830 Directory to save to is default to `gnus-article-save-directory'."
2831 (setq filename (gnus-read-save-file-name
2832 "Save %s in rmail file:" filename
2833 gnus-rmail-save-name gnus-newsgroup-name
2834 gnus-current-headers 'gnus-newsgroup-last-rmail))
2835 (gnus-eval-in-buffer-window gnus-save-article-buffer
2839 (gnus-output-to-rmail filename))))
2842 (defun gnus-summary-save-in-mail (&optional filename)
2843 "Append this article to Unix mail file.
2844 Optional argument FILENAME specifies file name.
2845 Directory to save to is default to `gnus-article-save-directory'."
2846 (setq filename (gnus-read-save-file-name
2847 "Save %s in Unix mail file:" filename
2848 gnus-mail-save-name gnus-newsgroup-name
2849 gnus-current-headers 'gnus-newsgroup-last-mail))
2850 (gnus-eval-in-buffer-window gnus-save-article-buffer
2854 (if (and (file-readable-p filename)
2855 (mail-file-babyl-p filename))
2856 (rmail-output-to-rmail-file filename t)
2857 (gnus-output-to-mail filename)))))
2860 (defun gnus-summary-save-in-file (&optional filename overwrite)
2861 "Append this article to file.
2862 Optional argument FILENAME specifies file name.
2863 Directory to save to is default to `gnus-article-save-directory'."
2864 (setq filename (gnus-read-save-file-name
2865 "Save %s in file:" filename
2866 gnus-file-save-name gnus-newsgroup-name
2867 gnus-current-headers 'gnus-newsgroup-last-file))
2868 (gnus-eval-in-buffer-window gnus-save-article-buffer
2872 (when (and overwrite
2873 (file-exists-p filename))
2874 (delete-file filename))
2875 (gnus-output-to-file filename))))
2878 (defun gnus-summary-write-to-file (&optional filename)
2879 "Write this article to a file, overwriting it if the file exists.
2880 Optional argument FILENAME specifies file name.
2881 The directory to save in defaults to `gnus-article-save-directory'."
2882 (gnus-summary-save-in-file nil t))
2884 (defun gnus-summary-save-body-in-file (&optional filename)
2885 "Append this article body to a file.
2886 Optional argument FILENAME specifies file name.
2887 The directory to save in defaults to `gnus-article-save-directory'."
2888 (setq filename (gnus-read-save-file-name
2889 "Save %s body in file:" filename
2890 gnus-file-save-name gnus-newsgroup-name
2891 gnus-current-headers 'gnus-newsgroup-last-file))
2892 (gnus-eval-in-buffer-window gnus-save-article-buffer
2896 (when (article-goto-body)
2897 (narrow-to-region (point) (point-max)))
2898 (gnus-output-to-file filename))))
2901 (defun gnus-summary-save-in-pipe (&optional command)
2902 "Pipe this article to subprocess."
2904 (cond ((and (eq command 'default)
2905 gnus-last-shell-command)
2906 gnus-last-shell-command)
2911 "Shell command on %s: "
2912 (if (and gnus-number-of-articles-to-be-saved
2913 (> gnus-number-of-articles-to-be-saved 1))
2914 (format "these %d articles"
2915 gnus-number-of-articles-to-be-saved)
2917 gnus-last-shell-command))))
2918 (when (string-equal command "")
2919 (if gnus-last-shell-command
2920 (setq command gnus-last-shell-command)
2921 (error "A command is required")))
2922 (gnus-eval-in-buffer-window gnus-article-buffer
2925 (shell-command-on-region (point-min) (point-max) command nil)))
2926 (setq gnus-last-shell-command command))
2928 (defun gnus-summary-pipe-to-muttprint (&optional command)
2929 "Pipe this article to muttprint."
2930 (setq command (read-string
2931 "Print using command: " gnus-summary-muttprint-program
2932 nil gnus-summary-muttprint-program))
2933 (gnus-summary-save-in-pipe command))
2935 ;;; Article file names when saving.
2937 (defun gnus-capitalize-newsgroup (newsgroup)
2938 "Capitalize NEWSGROUP name."
2939 (when (not (zerop (length newsgroup)))
2940 (concat (char-to-string (upcase (aref newsgroup 0)))
2941 (substring newsgroup 1))))
2943 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2944 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2945 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
2946 Otherwise, it is like ~/News/news/group/num."
2949 (concat (if (gnus-use-long-file-name 'not-save)
2950 (gnus-capitalize-newsgroup newsgroup)
2951 (gnus-newsgroup-directory-form newsgroup))
2952 "/" (int-to-string (mail-header-number headers)))
2953 gnus-article-save-directory)))
2955 (string-equal (file-name-directory default)
2956 (file-name-directory last-file))
2957 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2959 (or last-file default))))
2961 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2962 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2963 If variable `gnus-use-long-file-name' is non-nil, it is
2964 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2967 (concat (if (gnus-use-long-file-name 'not-save)
2969 (gnus-newsgroup-directory-form newsgroup))
2970 "/" (int-to-string (mail-header-number headers)))
2971 gnus-article-save-directory)))
2973 (string-equal (file-name-directory default)
2974 (file-name-directory last-file))
2975 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2977 (or last-file default))))
2979 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
2980 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2981 If variable `gnus-use-long-file-name' is non-nil, it is
2982 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
2985 (if (gnus-use-long-file-name 'not-save)
2988 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
2990 gnus-article-save-directory)))
2992 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
2993 "Generate file name from sender."
2994 (let ((from (mail-header-from headers)))
2996 (if (and from (string-match "\\([^ <]+\\)@" from))
2997 (match-string 1 from)
2999 gnus-article-save-directory)))
3001 (defun article-verify-x-pgp-sig ()
3004 (if (gnus-buffer-live-p gnus-original-article-buffer)
3005 (let ((sig (with-current-buffer gnus-original-article-buffer
3006 (gnus-fetch-field "X-PGP-Sig")))
3010 (mml2015-clear-verify-function))
3012 (insert-buffer gnus-original-article-buffer)
3013 (setq items (split-string sig))
3014 (message-narrow-to-head)
3015 (let ((inhibit-point-motion-hooks t)
3016 (case-fold-search t))
3017 ;; Don't verify multiple headers.
3018 (setq headers (mapconcat (lambda (header)
3020 (mail-fetch-field header) "\n"))
3021 (split-string (nth 1 items) ",") "")))
3022 (delete-region (point-min) (point-max))
3023 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3024 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3029 (if (looking-at "^-")
3032 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3033 (insert "Version: " (car items) "\n\n")
3034 (insert (mapconcat 'identity (cddr items) "\n"))
3035 (insert "\n-----END PGP SIGNATURE-----\n")
3036 (let ((mm-security-handle (list (format "multipart/signed"))))
3037 (mml2015-clean-buffer)
3038 (let ((coding-system-for-write (or gnus-newsgroup-charset
3040 (funcall (mml2015-clear-verify-function)))
3042 (or (mm-handle-multipart-ctl-parameter
3043 mm-security-handle 'gnus-details)
3044 (mm-handle-multipart-ctl-parameter
3045 mm-security-handle 'gnus-info)))))
3047 (let (buffer-read-only bface eface)
3049 (message-narrow-to-head)
3050 (goto-char (point-max))
3052 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3053 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3054 (message-remove-header "X-Gnus-PGP-Verify")
3055 (if (re-search-forward "^X-PGP-Sig:" nil t)
3057 (goto-char (point-max)))
3058 (narrow-to-region (point) (point))
3059 (insert "X-Gnus-PGP-Verify: " info "\n")
3060 (goto-char (point-min))
3063 (if (not (looking-at "^[ \t]"))
3067 (goto-char (point-min))
3068 (when (looking-at "\\([^:]+\\): *")
3069 (put-text-property (match-beginning 1) (1+ (match-end 1))
3071 (put-text-property (match-end 0) (point-max)
3072 'face eface)))))))))
3074 (defun article-verify-cancel-lock ()
3075 "Verify Cancel-Lock header."
3077 (if (gnus-buffer-live-p gnus-original-article-buffer)
3078 (canlock-verify gnus-original-article-buffer)))
3085 (setq afunc (car func)
3088 gfunc (intern (format "gnus-%s" func))))
3090 (when (fboundp afunc)
3091 `(lambda (&optional interactive &rest args)
3092 ,(documentation afunc t)
3093 (interactive (list t))
3095 (set-buffer gnus-article-buffer)
3097 (call-interactively ',afunc)
3098 (apply ',afunc args))))))))
3099 '(article-hide-headers
3100 article-verify-x-pgp-sig
3101 article-verify-cancel-lock
3102 article-hide-boring-headers
3103 article-treat-overstrike
3104 article-fill-long-lines
3105 article-capitalize-sentences
3107 article-remove-leading-whitespace
3108 article-display-x-face
3109 article-de-quoted-unreadable
3110 article-de-base64-unreadable
3113 article-hide-list-identifiers
3115 article-strip-banner
3118 article-hide-signature
3119 article-strip-headers-in-body
3120 article-remove-trailing-blank-lines
3121 article-strip-leading-blank-lines
3122 article-strip-multiple-blank-lines
3123 article-strip-leading-space
3124 article-strip-trailing-space
3125 article-strip-blank-lines
3126 article-strip-all-blank-lines
3127 article-replace-with-quoted-text
3129 article-date-english
3130 article-date-iso8601
3131 article-date-original
3133 article-decode-mime-words
3134 article-decode-charset
3135 article-decode-encoded-words
3139 article-treat-dumbquotes
3140 article-normalize-headers
3141 (article-show-all . gnus-article-show-all-headers))))
3144 ;;; Gnus article mode
3147 (put 'gnus-article-mode 'mode-class 'special)
3149 (set-keymap-parent gnus-article-mode-map widget-keymap)
3151 (gnus-define-keys gnus-article-mode-map
3152 " " gnus-article-goto-next-page
3153 "\177" gnus-article-goto-prev-page
3154 [delete] gnus-article-goto-prev-page
3155 [backspace] gnus-article-goto-prev-page
3156 "\C-c^" gnus-article-refer-article
3157 "h" gnus-article-show-summary
3158 "s" gnus-article-show-summary
3159 "\C-c\C-m" gnus-article-mail
3160 "?" gnus-article-describe-briefly
3161 "e" gnus-summary-edit-article
3162 "<" beginning-of-buffer
3164 "\C-c\C-i" gnus-info-find-node
3166 "R" gnus-article-reply-with-original
3167 "F" gnus-article-followup-with-original
3168 "\C-hk" gnus-article-describe-key
3169 "\C-hc" gnus-article-describe-key-briefly
3171 "\C-d" gnus-article-read-summary-keys
3172 "\M-*" gnus-article-read-summary-keys
3173 "\M-#" gnus-article-read-summary-keys
3174 "\M-^" gnus-article-read-summary-keys
3175 "\M-g" gnus-article-read-summary-keys)
3177 (substitute-key-definition
3178 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3180 (defun gnus-article-make-menu-bar ()
3181 (unless (boundp 'gnus-article-commands-menu)
3182 (gnus-summary-make-menu-bar))
3183 (gnus-turn-off-edit-menu 'article)
3184 (unless (boundp 'gnus-article-article-menu)
3186 gnus-article-article-menu gnus-article-mode-map ""
3188 ["Scroll forwards" gnus-article-goto-next-page t]
3189 ["Scroll backwards" gnus-article-goto-prev-page t]
3190 ["Show summary" gnus-article-show-summary t]
3191 ["Fetch Message-ID at point" gnus-article-refer-article t]
3192 ["Mail to address at point" gnus-article-mail t]
3193 ["Send a bug report" gnus-bug t]))
3196 gnus-article-treatment-menu gnus-article-mode-map ""
3197 ;; Fixme: this should use :active (and maybe :visible).
3199 ["Hide headers" gnus-article-hide-headers t]
3200 ["Hide signature" gnus-article-hide-signature t]
3201 ["Hide citation" gnus-article-hide-citation t]
3202 ["Treat overstrike" gnus-article-treat-overstrike t]
3203 ["Remove carriage return" gnus-article-remove-cr t]
3204 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3205 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3206 ["Remove base64" gnus-article-de-base64-unreadable t]
3207 ["Treat html" gnus-article-wash-html t]
3208 ["Decode HZ" gnus-article-decode-HZ t]))
3210 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3212 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3214 (gnus-run-hooks 'gnus-article-menu-hook)))
3216 ;; Fixme: do something for the Emacs tool bar in Article mode a la
3219 (defun gnus-article-mode ()
3220 "Major mode for displaying an article.
3222 All normal editing commands are switched off.
3224 The following commands are available in addition to all summary mode
3226 \\<gnus-article-mode-map>
3227 \\[gnus-article-next-page]\t Scroll the article one page forwards
3228 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3229 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3230 \\[gnus-article-show-summary]\t Display the summary buffer
3231 \\[gnus-article-mail]\t Send a reply to the address near point
3232 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3233 \\[gnus-info-find-node]\t Go to the Gnus info node"
3235 (gnus-simplify-mode-line)
3236 (setq mode-name "Article")
3237 (setq major-mode 'gnus-article-mode)
3238 (make-local-variable 'minor-mode-alist)
3239 (use-local-map gnus-article-mode-map)
3240 (when (gnus-visual-p 'article-menu 'menu)
3241 (gnus-article-make-menu-bar))
3242 (gnus-update-format-specifications nil 'article-mode)
3243 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3244 (make-local-variable 'gnus-page-broken)
3245 (make-local-variable 'gnus-button-marker-list)
3246 (make-local-variable 'gnus-article-current-summary)
3247 (make-local-variable 'gnus-article-mime-handles)
3248 (make-local-variable 'gnus-article-decoded-p)
3249 (make-local-variable 'gnus-article-mime-handle-alist)
3250 (make-local-variable 'gnus-article-wash-types)
3251 (make-local-variable 'gnus-article-image-alist)
3252 (make-local-variable 'gnus-article-charset)
3253 (make-local-variable 'gnus-article-ignored-charsets)
3254 (gnus-set-default-directory)
3255 (buffer-disable-undo)
3256 (setq buffer-read-only t)
3257 (set-syntax-table gnus-article-mode-syntax-table)
3258 (mm-enable-multibyte)
3259 (gnus-run-hooks 'gnus-article-mode-hook))
3261 (defun gnus-article-setup-buffer ()
3262 "Initialize the article buffer."
3263 (let* ((name (if gnus-single-article-buffer "*Article*"
3264 (concat "*Article " gnus-newsgroup-name "*")))
3266 (progn (string-match "\\*Article" name)
3267 (concat " *Original Article"
3268 (substring name (match-end 0))))))
3269 (setq gnus-article-buffer name)
3270 (setq gnus-original-article-buffer original)
3271 (setq gnus-article-mime-handle-alist nil)
3272 ;; This might be a variable local to the summary buffer.
3273 (unless gnus-single-article-buffer
3275 (set-buffer gnus-summary-buffer)
3276 (setq gnus-article-buffer name)
3277 (setq gnus-original-article-buffer original)
3278 (gnus-set-global-variables)))
3279 (gnus-article-setup-highlight-words)
3280 ;; Init original article buffer.
3282 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3283 (mm-enable-multibyte)
3284 (setq major-mode 'gnus-original-article-mode)
3285 (make-local-variable 'gnus-original-article))
3286 (if (get-buffer name)
3289 (when gnus-article-mime-handles
3290 (mm-destroy-parts gnus-article-mime-handles)
3291 (setq gnus-article-mime-handles nil))
3292 ;; Set it to nil in article-buffer!
3293 (setq gnus-article-mime-handle-alist nil)
3294 (buffer-disable-undo)
3295 (setq buffer-read-only t)
3296 (unless (eq major-mode 'gnus-article-mode)
3297 (gnus-article-mode))
3300 (set-buffer (gnus-get-buffer-create name))
3302 (make-local-variable 'gnus-summary-buffer)
3303 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3304 (current-buffer)))))
3306 ;; Set article window start at LINE, where LINE is the number of lines
3307 ;; from the head of the article.
3308 (defun gnus-article-set-window-start (&optional line)
3310 (gnus-get-buffer-window gnus-article-buffer t)
3312 (set-buffer gnus-article-buffer)
3313 (goto-char (point-min))
3316 (gnus-message 6 "Moved to bookmark")
3317 (search-forward "\n\n" nil t)
3321 (defun gnus-article-prepare (article &optional all-headers header)
3322 "Prepare ARTICLE in article mode buffer.
3323 ARTICLE should either be an article number or a Message-ID.
3324 If ARTICLE is an id, HEADER should be the article headers.
3325 If ALL-HEADERS is non-nil, no headers are hidden."
3327 ;; Make sure we start in a summary buffer.
3328 (unless (eq major-mode 'gnus-summary-mode)
3329 (set-buffer gnus-summary-buffer))
3330 (setq gnus-summary-buffer (current-buffer))
3331 (let* ((gnus-article (if header (mail-header-number header) article))
3332 (summary-buffer (current-buffer))
3333 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3334 (group gnus-newsgroup-name)
3337 (gnus-article-setup-buffer)
3338 (set-buffer gnus-article-buffer)
3339 ;; Deactivate active regions.
3340 (when (and (boundp 'transient-mark-mode)
3341 transient-mark-mode)
3342 (setq mark-active nil))
3343 (if (not (setq result (let ((buffer-read-only nil))
3344 (gnus-request-article-this-buffer
3346 ;; There is no such article.
3348 (when (and (numberp article)
3349 (not (memq article gnus-newsgroup-sparse)))
3350 (setq gnus-article-current
3351 (cons gnus-newsgroup-name article))
3352 (set-buffer gnus-summary-buffer)
3353 (setq gnus-current-article article)
3354 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
3356 (gnus-summary-set-agent-mark article)
3357 (message "Message marked for downloading"))
3358 (gnus-summary-mark-article article gnus-canceled-mark)
3359 (unless (memq article gnus-newsgroup-sparse)
3360 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3361 (if (or (eq result 'pseudo)
3362 (eq result 'nneething))
3365 (set-buffer summary-buffer)
3366 (push article gnus-newsgroup-history)
3367 (setq gnus-last-article gnus-current-article
3368 gnus-current-article 0
3369 gnus-current-headers nil
3370 gnus-article-current nil)
3371 (if (eq result 'nneething)
3372 (gnus-configure-windows 'summary)
3373 (gnus-configure-windows 'article))
3374 (gnus-set-global-variables))
3375 (let ((gnus-article-mime-handle-alist-1
3376 gnus-article-mime-handle-alist))
3377 (gnus-set-mode-line 'article)))
3378 ;; The result from the `request' was an actual article -
3379 ;; or at least some text that is now displayed in the
3381 (when (and (numberp article)
3382 (not (eq article gnus-current-article)))
3383 ;; Seems like a new article has been selected.
3384 ;; `gnus-current-article' must be an article number.
3386 (set-buffer summary-buffer)
3387 (push article gnus-newsgroup-history)
3388 (setq gnus-last-article gnus-current-article
3389 gnus-current-article article
3390 gnus-current-headers
3391 (gnus-summary-article-header gnus-current-article)
3392 gnus-article-current
3393 (cons gnus-newsgroup-name gnus-current-article))
3394 (unless (vectorp gnus-current-headers)
3395 (setq gnus-current-headers nil))
3396 (gnus-summary-goto-subject gnus-current-article)
3397 (when (gnus-summary-show-thread)
3398 ;; If the summary buffer really was folded, the
3399 ;; previous goto may not actually have gone to
3400 ;; the right article, but the thread root instead.
3402 (gnus-summary-goto-subject gnus-current-article))
3403 (gnus-run-hooks 'gnus-mark-article-hook)
3404 (gnus-set-mode-line 'summary)
3405 (when (gnus-visual-p 'article-highlight 'highlight)
3406 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3407 ;; Set the global newsgroup variables here.
3408 (gnus-set-global-variables)
3409 (setq gnus-have-all-headers
3410 (or all-headers gnus-show-all-headers))))
3412 (gnus-configure-windows 'article))
3413 (when (or (numberp article)
3415 (gnus-article-prepare-display)
3417 (goto-char (point-min))
3418 (setq gnus-page-broken
3419 (when gnus-break-pages
3420 (gnus-narrow-to-page)
3422 (let ((gnus-article-mime-handle-alist-1
3423 gnus-article-mime-handle-alist))
3424 (gnus-set-mode-line 'article))
3426 (set-window-point (get-buffer-window (current-buffer)) (point))
3427 (gnus-configure-windows 'article)
3431 (defun gnus-article-prepare-display ()
3432 "Make the current buffer look like a nice article."
3433 ;; Hooks for getting information from the article.
3434 ;; This hook must be called before being narrowed.
3435 (let ((gnus-article-buffer (current-buffer))
3437 (unless (eq major-mode 'gnus-article-mode)
3438 (gnus-article-mode))
3439 (setq buffer-read-only nil
3440 gnus-article-wash-types nil
3441 gnus-article-image-alist nil)
3442 (gnus-run-hooks 'gnus-tmp-internal-hook)
3443 (when gnus-display-mime-function
3444 (funcall gnus-display-mime-function))
3445 (gnus-run-hooks 'gnus-article-prepare-hook)))
3448 ;;; Gnus MIME viewing functions
3451 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3452 "Format of the MIME buttons.
3454 Valid specifiers include:
3456 %T MIME type, along with additional info
3457 %n The `name' parameter
3458 %d The description, if any
3459 %l The length of the encoded part
3460 %p The part identifier number
3461 %e Dots if the part isn't displayed
3463 General format specifiers can also be used. See
3464 (gnus)Formatting Variables.")
3466 (defvar gnus-mime-button-line-format-alist
3467 '((?t gnus-tmp-type ?s)
3468 (?T gnus-tmp-type-long ?s)
3469 (?n gnus-tmp-name ?s)
3470 (?d gnus-tmp-description ?s)
3472 (?l gnus-tmp-length ?d)
3473 (?e gnus-tmp-dots ?s)))
3475 (defvar gnus-mime-button-commands
3476 '((gnus-article-press-button "\r" "Toggle Display")
3477 (gnus-mime-view-part "v" "View Interactively...")
3478 (gnus-mime-view-part-as-type "t" "View As Type...")
3479 (gnus-mime-view-part-as-charset "C" "View As charset...")
3480 (gnus-mime-save-part "o" "Save...")
3481 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3482 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3483 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3484 (gnus-mime-internalize-part "E" "View Internally")
3485 (gnus-mime-externalize-part "e" "View Externally")
3486 (gnus-mime-print-part "p" "Print")
3487 (gnus-mime-pipe-part "|" "Pipe To Command...")
3488 (gnus-mime-action-on-part "." "Take action on the part")))
3490 (defun gnus-article-mime-part-status ()
3491 (if gnus-article-mime-handle-alist-1
3492 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3494 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3497 (defvar gnus-mime-button-map
3498 (let ((map (make-sparse-keymap)))
3499 (unless (>= (string-to-number emacs-version) 21)
3500 ;; XEmacs doesn't care.
3501 (set-keymap-parent map gnus-article-mode-map))
3502 (define-key map gnus-mouse-2 'gnus-article-push-button)
3503 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3504 (dolist (c gnus-mime-button-commands)
3505 (define-key map (cadr c) (car c)))
3508 (defun gnus-mime-button-menu (event)
3509 "Construct a context-sensitive menu of MIME commands."
3511 (save-window-excursion
3512 (let ((pos (event-start event)))
3513 (select-window (posn-window pos))
3514 (goto-char (posn-point pos))
3515 (gnus-article-check-buffer)
3516 (let ((response (x-popup-menu
3518 ("" ,@(mapcar (lambda (c)
3519 (cons (caddr c) (car c)))
3520 gnus-mime-button-commands))))))
3522 (call-interactively response))))))
3524 (defun gnus-mime-view-all-parts (&optional handles)
3525 "View all the MIME parts."
3527 (save-current-buffer
3528 (set-buffer gnus-article-buffer)
3529 (let ((handles (or handles gnus-article-mime-handles))
3530 (mail-parse-charset gnus-newsgroup-charset)
3531 (mail-parse-ignored-charsets
3532 (with-current-buffer gnus-summary-buffer
3533 gnus-newsgroup-ignored-charsets)))
3535 (mm-remove-parts handles)
3536 (goto-char (point-min))
3537 (or (search-forward "\n\n") (goto-char (point-max)))
3538 (let (buffer-read-only)
3539 (delete-region (point) (point-max))
3540 (mm-display-parts handles))))))
3542 (defun gnus-mime-save-part-and-strip ()
3543 "Save the MIME part under point then replace it with an external body."
3545 (gnus-article-check-buffer)
3546 (let* ((data (get-text-property (point) 'gnus-data))
3548 (handles gnus-article-mime-handles))
3549 (if (mm-multiple-handles gnus-article-mime-handles)
3550 (error "This function is not implemented"))
3551 (setq file (and data (mm-save-part data)))
3553 (with-current-buffer (mm-handle-buffer data)
3555 (insert "Content-Type: " (mm-handle-media-type data))
3556 (mml-insert-parameter-string (cdr (mm-handle-type data))
3559 (insert "Content-ID: " (message-make-message-id) "\n")
3560 (insert "Content-Transfer-Encoding: binary\n")
3563 (cdr (mm-make-handle nil
3564 `("message/external-body"
3565 (access-type . "LOCAL-FILE")
3567 (set-buffer gnus-summary-buffer)
3568 (gnus-article-edit-article
3571 (let ((mail-parse-charset (or gnus-article-charset
3572 ',gnus-newsgroup-charset))
3573 (mail-parse-ignored-charsets
3574 (or gnus-article-ignored-charsets
3575 ',gnus-newsgroup-ignored-charsets))
3576 (mbl mml-buffer-list))
3577 (setq mml-buffer-list nil)
3578 (insert-buffer gnus-original-article-buffer)
3579 (mime-to-mml ',handles)
3580 (setq gnus-article-mime-handles nil)
3581 (let ((mbl1 mml-buffer-list))
3582 (setq mml-buffer-list mbl)
3583 (set (make-local-variable 'mml-buffer-list) mbl1))
3584 ;; LOCAL argument of add-hook differs between GNU Emacs
3585 ;; and XEmacs. make-local-hook makes sure they are local.
3586 (make-local-hook 'kill-buffer-hook)
3587 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3588 `(lambda (no-highlight)
3589 (let ((mail-parse-charset (or gnus-article-charset
3590 ',gnus-newsgroup-charset))
3591 (message-options message-options)
3592 (message-options-set-recipient)
3593 (mail-parse-ignored-charsets
3594 (or gnus-article-ignored-charsets
3595 ',gnus-newsgroup-ignored-charsets)))
3597 (mml-destroy-buffers)
3598 (remove-hook 'kill-buffer-hook
3599 'mml-destroy-buffers t)
3600 (kill-local-variable 'mml-buffer-list))
3601 (gnus-summary-edit-article-done
3602 ,(or (mail-header-references gnus-current-headers) "")
3603 ,(gnus-group-read-only-p)
3604 ,gnus-summary-buffer no-highlight))))))
3606 (defun gnus-mime-save-part ()
3607 "Save the MIME part under point."
3609 (gnus-article-check-buffer)
3610 (let ((data (get-text-property (point) 'gnus-data)))
3612 (mm-save-part data))))
3614 (defun gnus-mime-pipe-part ()
3615 "Pipe the MIME part under point to a process."
3617 (gnus-article-check-buffer)
3618 (let ((data (get-text-property (point) 'gnus-data)))
3620 (mm-pipe-part data))))
3622 (defun gnus-mime-view-part ()
3623 "Interactively choose a viewing method for the MIME part under point."
3625 (gnus-article-check-buffer)
3626 (let ((data (get-text-property (point) 'gnus-data)))
3628 (setq gnus-article-mime-handles
3630 gnus-article-mime-handles (setq data (copy-sequence data))))
3631 (mm-interactively-view-part data))))
3633 (defun gnus-mime-view-part-as-type-internal ()
3634 (gnus-article-check-buffer)
3635 (let* ((name (mail-content-type-get
3636 (mm-handle-type (get-text-property (point) 'gnus-data))
3638 (def-type (and name (mm-default-file-encoding name))))
3639 (and def-type (cons def-type 0))))
3641 (defun gnus-mime-view-part-as-type (&optional mime-type)
3642 "Choose a MIME media type, and view the part as such."
3645 (setq mime-type (completing-read
3646 "View as MIME type: "
3647 (mapcar #'list (mailcap-mime-types))
3649 (gnus-mime-view-part-as-type-internal))))
3650 (gnus-article-check-buffer)
3651 (let ((handle (get-text-property (point) 'gnus-data)))
3654 (mm-make-handle (mm-handle-buffer handle)
3655 (cons mime-type (cdr (mm-handle-type handle)))
3656 (mm-handle-encoding handle)
3657 (mm-handle-undisplayer handle)
3658 (mm-handle-disposition handle)
3659 (mm-handle-description handle)
3661 (mm-handle-id handle)))
3662 (setq gnus-article-mime-handles
3663 (mm-merge-handles gnus-article-mime-handles handle))
3664 (gnus-mm-display-part handle))))
3666 (defun gnus-mime-copy-part (&optional handle)
3667 "Put the MIME part under point into a new buffer."
3669 (gnus-article-check-buffer)
3670 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3671 (contents (and handle (mm-get-part handle)))
3673 (file-name-nondirectory
3675 (mail-content-type-get (mm-handle-type handle) 'name)
3676 (mail-content-type-get (mm-handle-type handle)
3679 (buffer (and base (generate-new-buffer base))))
3681 (switch-to-buffer buffer)
3683 ;; We do it this way to make `normal-mode' set the appropriate mode.
3686 (setq buffer-file-name (expand-file-name base))
3688 (setq buffer-file-name nil))
3689 (goto-char (point-min)))))
3691 (defun gnus-mime-print-part (&optional handle)
3692 "Print the MIME part under point."
3694 (gnus-article-check-buffer)
3695 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3696 (contents (and handle (mm-get-part handle)))
3697 (file (make-temp-name (expand-file-name "mm." mm-tmp-directory)))
3698 (printer (mailcap-mime-info (mm-handle-type handle) "print")))
3703 (with-temp-file file
3705 (call-process shell-file-name nil
3706 (generate-new-buffer " *mm*")
3708 shell-command-switch
3710 printer file (mm-handle-type handle))))
3714 (gnus-print-buffer))))))
3716 (defun gnus-mime-inline-part (&optional handle arg)
3717 "Insert the MIME part under point into the current buffer."
3718 (interactive (list nil current-prefix-arg))
3719 (gnus-article-check-buffer)
3720 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3725 (if (and (not arg) (mm-handle-undisplayer handle))
3726 (mm-remove-part handle)
3727 (setq contents (mm-get-part handle))
3730 (setq charset (or (mail-content-type-get
3731 (mm-handle-type handle) 'charset)
3732 gnus-newsgroup-charset)))
3734 (if (mm-handle-undisplayer handle)
3735 (mm-remove-part handle))
3738 gnus-summary-show-article-charset-alist))
3739 (mm-read-coding-system "Charset: ")))))
3741 (mm-insert-inline handle
3743 (setq charset (mm-charset-to-coding-system
3745 (not (eq charset 'ascii)))
3746 (mm-decode-coding-string contents charset)
3750 (defun gnus-mime-view-part-as-charset (&optional handle arg)
3751 "Insert the MIME part under point into the current buffer using the
3753 (interactive (list nil current-prefix-arg))
3754 (gnus-article-check-buffer)
3755 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3760 (if (mm-handle-undisplayer handle)
3761 (mm-remove-part handle))
3762 (let ((gnus-newsgroup-charset
3764 gnus-summary-show-article-charset-alist))
3765 (mm-read-coding-system "Charset: ")))
3766 (gnus-newsgroup-ignored-charsets 'gnus-all))
3767 (gnus-article-press-button)))))
3769 (defun gnus-mime-externalize-part (&optional handle)
3770 "View the MIME part under point with an external viewer."
3772 (gnus-article-check-buffer)
3773 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3774 (mm-user-display-methods nil)
3775 (mm-inlined-types nil)
3776 (mail-parse-charset gnus-newsgroup-charset)
3777 (mail-parse-ignored-charsets
3778 (save-excursion (set-buffer gnus-summary-buffer)
3779 gnus-newsgroup-ignored-charsets)))
3781 (if (mm-handle-undisplayer handle)
3782 (mm-remove-part handle)
3783 (mm-display-part handle)))))
3785 (defun gnus-mime-internalize-part (&optional handle)
3786 "View the MIME part under point with an internal viewer.
3787 If no internal viewer is available, use an external viewer."
3789 (gnus-article-check-buffer)
3790 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3791 (mm-inlined-types '(".*"))
3792 (mm-inline-large-images t)
3793 (mail-parse-charset gnus-newsgroup-charset)
3794 (mail-parse-ignored-charsets
3795 (save-excursion (set-buffer gnus-summary-buffer)
3796 gnus-newsgroup-ignored-charsets)))
3798 (if (mm-handle-undisplayer handle)
3799 (mm-remove-part handle)
3800 (mm-display-part handle)))))
3802 (defun gnus-mime-action-on-part (&optional action)
3803 "Do something with the MIME attachment at \(point\)."
3805 (list (completing-read "Action: " gnus-mime-action-alist)))
3806 (gnus-article-check-buffer)
3807 (let ((action-pair (assoc action gnus-mime-action-alist)))
3809 (funcall (cdr action-pair)))))
3811 (defun gnus-article-part-wrapper (n function)
3812 (save-current-buffer
3813 (set-buffer gnus-article-buffer)
3814 (when (> n (length gnus-article-mime-handle-alist))
3815 (error "No such part"))
3816 (gnus-article-goto-part n)
3817 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3818 (funcall function handle))))
3820 (defun gnus-article-pipe-part (n)
3821 "Pipe MIME part N, which is the numerical prefix."
3823 (gnus-article-part-wrapper n 'mm-pipe-part))
3825 (defun gnus-article-save-part (n)
3826 "Save MIME part N, which is the numerical prefix."
3828 (gnus-article-part-wrapper n 'mm-save-part))
3830 (defun gnus-article-interactively-view-part (n)
3831 "View MIME part N interactively, which is the numerical prefix."
3833 (gnus-article-part-wrapper n 'mm-interactively-view-part))
3835 (defun gnus-article-copy-part (n)
3836 "Copy MIME part N, which is the numerical prefix."
3838 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
3840 (defun gnus-article-view-part-as-charset (n)
3841 "Copy MIME part N, which is the numerical prefix."
3843 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
3845 (defun gnus-article-externalize-part (n)
3846 "View MIME part N externally, which is the numerical prefix."
3848 (gnus-article-part-wrapper n 'gnus-mime-externalize-part))
3850 (defun gnus-article-inline-part (n)
3851 "Inline MIME part N, which is the numerical prefix."
3853 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
3855 (defun gnus-article-mime-match-handle-first (condition)
3857 (let ((alist gnus-article-mime-handle-alist) ihandle n)
3858 (while (setq ihandle (pop alist))
3860 ((functionp condition)
3861 (funcall condition (cdr ihandle)))
3862 ((eq condition 'undisplayed)
3863 (not (or (mm-handle-undisplayer (cdr ihandle))
3864 (equal (mm-handle-media-type (cdr ihandle))
3865 "multipart/alternative"))))
3866 ((eq condition 'undisplayed-alternative)
3867 (not (mm-handle-undisplayer (cdr ihandle))))
3869 (gnus-article-goto-part (car ihandle))
3870 (or (not n) (< (car ihandle) n)))
3871 (setq n (car ihandle))))
3875 (defun gnus-article-view-part (&optional n)
3876 "View MIME part N, which is the numerical prefix."
3878 (save-current-buffer
3879 (set-buffer gnus-article-buffer)
3880 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
3881 gnus-article-mime-match-handle-function)))
3882 (when (> n (length gnus-article-mime-handle-alist))
3883 (error "No such part"))
3884 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3885 (when (gnus-article-goto-part n)
3886 (if (equal (car handle) "multipart/alternative")
3887 (gnus-article-press-button)
3888 (when (eq (gnus-mm-display-part handle) 'internal)
3889 (gnus-set-window-start)))))))
3891 (defsubst gnus-article-mime-total-parts ()
3892 (if (bufferp (car gnus-article-mime-handles))
3894 (1- (length gnus-article-mime-handles))))
3896 (defun gnus-mm-display-part (handle)
3897 "Display HANDLE and fix MIME button."
3898 (let ((id (get-text-property (point) 'gnus-part))
3903 (let ((window (selected-window))
3904 (mail-parse-charset gnus-newsgroup-charset)
3905 (mail-parse-ignored-charsets
3906 (save-excursion (set-buffer gnus-summary-buffer)
3907 gnus-newsgroup-ignored-charsets)))
3910 (let ((win (gnus-get-buffer-window (current-buffer) t))
3913 (select-window win))
3916 (if (mm-handle-displayed-p handle)
3917 ;; This will remove the part.
3918 (mm-display-part handle)
3920 (narrow-to-region (point)
3921 (if (eobp) (point) (1+ (point))))
3922 (mm-display-part handle)
3923 ;; We narrow to the part itself and
3924 ;; then call the treatment functions.
3925 (goto-char (point-min))
3927 (narrow-to-region (point) (point-max))
3930 (gnus-article-mime-total-parts)
3931 (mm-handle-media-type handle)))))
3932 (if (window-live-p window)
3933 (select-window window)))))
3935 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
3936 (gnus-insert-mime-button
3937 handle id (list (mm-handle-displayed-p handle)))
3938 (goto-char point))))
3940 (defun gnus-article-goto-part (n)
3941 "Go to MIME part N."
3942 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
3944 (goto-char point))))
3946 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
3947 (let ((gnus-tmp-name
3948 (or (mail-content-type-get (mm-handle-type handle) 'name)
3949 (mail-content-type-get (mm-handle-disposition handle) 'filename)
3950 (mail-content-type-get (mm-handle-type handle) 'url)
3952 (gnus-tmp-type (mm-handle-media-type handle))
3953 (gnus-tmp-description
3954 (mail-decode-encoded-word-string (or (mm-handle-description handle)
3957 (if (if displayed (car displayed)
3958 (mm-handle-displayed-p handle))
3960 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
3962 gnus-tmp-type-long b e)
3963 (when (string-match ".*/" gnus-tmp-name)
3964 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
3965 (setq gnus-tmp-type-long (concat gnus-tmp-type
3966 (and (not (equal gnus-tmp-name ""))
3967 (concat "; " gnus-tmp-name))))
3968 (unless (equal gnus-tmp-description "")
3969 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
3974 gnus-mime-button-line-format gnus-mime-button-line-format-alist
3975 `(,@(gnus-local-map-property gnus-mime-button-map)
3976 gnus-callback gnus-mm-display-part
3977 gnus-part ,gnus-tmp-id
3978 article-type annotation
3981 (widget-convert-button
3984 :action 'gnus-widget-press-button
3985 :button-keymap gnus-mime-button-map
3987 (lambda (widget/window &optional overlay pos)
3988 ;; Needed to properly clear the message due to a bug in
3989 ;; wid-edit (XEmacs only).
3990 (if (boundp 'help-echo-owns-message)
3991 (setq help-echo-owns-message t))
3993 "%S: %s the MIME part; %S: more options"
3994 (aref gnus-mouse-2 0)
3995 ;; XEmacs will get a single widget arg; Emacs 21 will get
3996 ;; window, overlay, position.
3997 (if (mm-handle-displayed-p
3999 (with-current-buffer (gnus-overlay-buffer overlay)
4000 (widget-get (widget-at (gnus-overlay-start overlay))
4002 (widget-get widget/window :mime-handle)))
4004 (aref gnus-down-mouse-3 0))))))
4006 (defun gnus-widget-press-button (elems el)
4007 (goto-char (widget-get elems :from))
4008 (gnus-article-press-button))
4010 (defvar gnus-displaying-mime nil)
4012 (defun gnus-display-mime (&optional ihandles)
4013 "Display the MIME parts."
4015 (save-selected-window
4016 (let ((window (get-buffer-window gnus-article-buffer))
4019 (select-window window)
4020 ;; We have to do this since selecting the window
4021 ;; may change the point. So we set the window point.
4022 (set-window-point window point)))
4023 (let* ((handles (or ihandles (mm-dissect-buffer) (mm-uu-dissect)))
4024 buffer-read-only handle name type b e display)
4025 (when (and (not ihandles)
4026 (not gnus-displaying-mime))
4027 ;; Top-level call; we clean up.
4028 (when gnus-article-mime-handles
4029 (mm-destroy-parts gnus-article-mime-handles)
4030 (setq gnus-article-mime-handle-alist nil));; A trick.
4031 (setq gnus-article-mime-handles handles)
4032 ;; We allow users to glean info from the handles.
4033 (when gnus-article-mime-part-function
4034 (gnus-mime-part-function handles)))
4036 (or (not (stringp (car handles)))
4039 (when (and (not ihandles)
4040 (not gnus-displaying-mime))
4041 ;; Clean up for mime parts.
4043 (delete-region (point) (point-max)))
4044 (let ((gnus-displaying-mime t))
4045 (gnus-mime-display-part handles)))
4048 (narrow-to-region (point) (point-max))
4049 (gnus-treat-article nil 1 1)
4052 ;; Highlight the headers.
4056 (narrow-to-region (point-min) (point))
4057 (gnus-treat-article 'head))))))))
4059 (defvar gnus-mime-display-multipart-as-mixed nil)
4060 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
4061 (defvar gnus-mime-display-multipart-related-as-mixed nil)
4063 (defun gnus-mime-display-part (handle)
4066 ((not (stringp (car handle)))
4067 (gnus-mime-display-single handle))
4068 ;; User-defined multipart
4069 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4070 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4072 ;; multipart/alternative
4073 ((and (equal (car handle) "multipart/alternative")
4074 (not (or gnus-mime-display-multipart-as-mixed
4075 gnus-mime-display-multipart-alternative-as-mixed)))
4076 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4077 (push (cons id handle) gnus-article-mime-handle-alist)
4078 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4079 ;; multipart/related
4080 ((and (equal (car handle) "multipart/related")
4081 (not (or gnus-mime-display-multipart-as-mixed
4082 gnus-mime-display-multipart-related-as-mixed)))
4083 ;;;!!!We should find the start part, but we just default
4084 ;;;!!!to the first part.
4085 ;;(gnus-mime-display-part (cadr handle))
4086 ;;;!!! Most multipart/related is an HTML message plus images.
4087 ;;;!!! Unfortunately we are unable to let W3 display those
4088 ;;;!!! included images, so we just display it as a mixed multipart.
4089 ;;(gnus-mime-display-mixed (cdr handle))
4090 ;;;!!! No, w3 can display everything just fine.
4091 (gnus-mime-display-part (cadr handle)))
4092 ((equal (car handle) "multipart/signed")
4093 (gnus-add-wash-type 'signed)
4094 (gnus-mime-display-security handle))
4095 ((equal (car handle) "multipart/encrypted")
4096 (gnus-add-wash-type 'encrypted)
4097 (gnus-mime-display-security handle))
4098 ;; Other multiparts are handled like multipart/mixed.
4100 (gnus-mime-display-mixed (cdr handle)))))
4102 (defun gnus-mime-part-function (handles)
4103 (if (stringp (car handles))
4104 (mapcar 'gnus-mime-part-function (cdr handles))
4105 (funcall gnus-article-mime-part-function handles)))
4107 (defun gnus-mime-display-mixed (handles)
4108 (mapcar 'gnus-mime-display-part handles))
4110 (defun gnus-mime-display-single (handle)
4111 (let ((type (mm-handle-media-type handle))
4112 (ignored gnus-ignored-mime-types)
4119 (when (string-match (pop ignored) type)
4120 (throw 'ignored nil)))
4121 (if (and (setq not-attachment
4122 (and (not (mm-inline-override-p handle))
4123 (or (not (mm-handle-disposition handle))
4124 (equal (car (mm-handle-disposition handle))
4126 (mm-attachment-override-p handle))))
4127 (mm-automatic-display-p handle)
4129 (mm-inlinable-p handle)
4130 (mm-inlined-p handle))
4131 (mm-automatic-external-display-p type)))
4133 (when (equal (mm-handle-media-supertype handle) "text")
4135 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4137 (push (cons id handle) gnus-article-mime-handle-alist)
4138 (when (or (not display)
4139 (not (gnus-unbuttonized-mime-type-p type)))
4140 ;(gnus-article-insert-newline)
4141 (gnus-insert-mime-button
4142 handle id (list (or display (and not-attachment text))))
4143 (gnus-article-insert-newline)
4144 ;(gnus-article-insert-newline)
4145 ;; Remember modify the number of forward lines.
4153 (let ((mail-parse-charset gnus-newsgroup-charset)
4154 (mail-parse-ignored-charsets
4155 (save-excursion (condition-case ()
4156 (set-buffer gnus-summary-buffer)
4158 gnus-newsgroup-ignored-charsets)))
4159 (mm-display-part handle t))
4160 (goto-char (point-max)))
4161 ((and text not-attachment)
4165 (gnus-article-insert-newline)
4166 (mm-insert-inline handle (mm-get-part handle))
4167 (goto-char (point-max))))
4171 (narrow-to-region beg (point))
4174 (gnus-article-mime-total-parts)
4175 (mm-handle-media-type handle)))))))))
4177 (defun gnus-unbuttonized-mime-type-p (type)
4178 "Say whether TYPE is to be unbuttonized."
4179 (unless gnus-inhibit-mime-unbuttonizing
4181 (let ((types gnus-unbuttonized-mime-types))
4183 (when (string-match (pop types) type)
4184 (throw 'found t)))))
4186 (let ((types gnus-buttonized-mime-types))
4188 (when (string-match (pop types) type)
4189 (throw 'found t)))))))))
4191 (defun gnus-article-insert-newline ()
4192 "Insert a newline, but mark it as undeletable."
4193 (gnus-put-text-property
4194 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4196 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4197 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4200 handle buffer-read-only from props begend not-pref)
4201 (save-window-excursion
4204 (narrow-to-region (car ibegend)
4207 (goto-char (car ibegend))
4210 (delete-region (point-min) (point-max))
4211 (mm-remove-parts handles))
4212 (setq begend (list (point-marker)))
4214 (unless (setq not-pref (cadr (member preferred ihandles)))
4215 (setq not-pref (car ihandles)))
4218 (not (gnus-unbuttonized-mime-type-p
4219 "multipart/alternative")))
4220 (gnus-add-text-properties
4223 (insert (format "%d. " id))
4227 (unless ,(not ibegend)
4228 (setq gnus-article-mime-handle-alist
4229 ',gnus-article-mime-handle-alist))
4230 (gnus-mime-display-alternative
4231 ',ihandles ',not-pref ',begend ,id))
4232 ,@(gnus-local-map-property gnus-mime-button-map)
4233 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4234 face ,gnus-article-button-face
4237 (widget-convert-button 'link from (point)
4238 :action 'gnus-widget-press-button
4239 :button-keymap gnus-widget-button-keymap)
4241 (while (setq handle (pop handles))
4242 (gnus-add-text-properties
4245 (insert (format "(%c) %-18s"
4246 (if (equal handle preferred) ?* ? )
4247 (mm-handle-media-type handle)))
4251 (unless ,(not ibegend)
4252 (setq gnus-article-mime-handle-alist
4253 ',gnus-article-mime-handle-alist))
4254 (gnus-mime-display-alternative
4255 ',ihandles ',handle ',begend ,id))
4256 ,@(gnus-local-map-property gnus-mime-button-map)
4257 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4258 face ,gnus-article-button-face
4261 (widget-convert-button 'link from (point)
4262 :action 'gnus-widget-press-button
4263 :button-keymap gnus-widget-button-keymap)
4267 (if (stringp (car preferred))
4268 (gnus-display-mime preferred)
4269 (let ((mail-parse-charset gnus-newsgroup-charset)
4270 (mail-parse-ignored-charsets
4271 (save-excursion (set-buffer gnus-summary-buffer)
4272 gnus-newsgroup-ignored-charsets)))
4273 (mm-display-part preferred)
4277 (narrow-to-region (car begend) (point-max))
4279 nil (length gnus-article-mime-handle-alist)
4280 (gnus-article-mime-total-parts)
4281 (mm-handle-media-type handle))))))
4282 (goto-char (point-max))
4283 (setcdr begend (point-marker)))))
4285 (goto-char point))))
4287 (defconst gnus-article-wash-status-strings
4288 (let ((alist '((cite "c" "Possible hidden citation text"
4289 " " "All citation text visible")
4290 (headers "h" "Hidden headers"
4291 " " "All headers visible.")
4292 (pgp "p" "Encrypted or signed message status hidden"
4293 " " "No hidden encryption nor digital signature status")
4294 (signature "s" "Signature has been hidden"
4295 " " "Signature is visible")
4296 (overstrike "o" "Overstrike (^H) characters applied"
4297 " " "No overstrike characters applied")
4298 (emphasis "e" "/*_Emphasis_*/ characters applied"
4299 " " "No /*_emphasis_*/ characters applied")))
4301 (dolist (entry alist result)
4302 (let ((key (nth 0 entry))
4303 (on (copy-sequence (nth 1 entry)))
4304 (on-help (nth 2 entry))
4305 (off (copy-sequence (nth 3 entry)))
4306 (off-help (nth 4 entry)))
4307 (put-text-property 0 1 'help-echo on-help on)
4308 (put-text-property 0 1 'help-echo off-help off)
4309 (push (list key on off) result))))
4310 "Alist of strings describing wash status in the mode line.
4311 Each entry has the form (KEY ON OF), where the KEY is a symbol
4312 representing the particular washing function, ON is the string to use
4313 in the article mode line when the washing function is active, and OFF
4314 is the string to use when it is inactive.")
4316 (defun gnus-article-wash-status-entry (key value)
4317 (let ((entry (assoc key gnus-article-wash-status-strings)))
4318 (if value (nth 1 entry) (nth 2 entry))))
4320 (defun gnus-article-wash-status ()
4321 "Return a string which display status of article washing."
4323 (set-buffer gnus-article-buffer)
4324 (let ((cite (memq 'cite gnus-article-wash-types))
4325 (headers (memq 'headers gnus-article-wash-types))
4326 (boring (memq 'boring-headers gnus-article-wash-types))
4327 (pgp (memq 'pgp gnus-article-wash-types))
4328 (pem (memq 'pem gnus-article-wash-types))
4329 (signed (memq 'signed gnus-article-wash-types))
4330 (encrypted (memq 'encrypted gnus-article-wash-types))
4331 (signature (memq 'signature gnus-article-wash-types))
4332 (overstrike (memq 'overstrike gnus-article-wash-types))
4333 (emphasis (memq 'emphasis gnus-article-wash-types)))
4335 (gnus-article-wash-status-entry 'cite cite)
4336 (gnus-article-wash-status-entry 'headers (or headers boring))
4337 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4338 (gnus-article-wash-status-entry 'signature signature)
4339 (gnus-article-wash-status-entry 'overstrike overstrike)
4340 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4342 (defun gnus-add-wash-type (type)
4343 "Add a washing of TYPE to the current status."
4344 (push type gnus-article-wash-types))
4346 (defun gnus-delete-wash-type (type)
4347 "Add a washing of TYPE to the current status."
4348 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4350 (defun gnus-add-image (category image)
4351 "Add IMAGE of CATEGORY to the list of displayed images."
4352 (let ((entry (assq category gnus-article-image-alist)))
4354 (setq entry (list category))
4355 (push entry gnus-article-image-alist))
4356 (nconc entry (list image))))
4358 (defun gnus-delete-images (category)
4359 "Delete all images in CATEGORY."
4360 (let ((entry (assq category gnus-article-image-alist)))
4361 (dolist (image (cdr entry))
4362 (gnus-remove-image image))
4363 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4364 (gnus-delete-wash-type category)))
4366 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4368 (defun gnus-article-maybe-hide-headers ()
4369 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4370 Provided for backwards compatibility."
4371 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4372 (not (save-excursion (set-buffer gnus-summary-buffer)
4373 gnus-have-all-headers)))
4374 (not gnus-inhibit-hiding))
4375 (gnus-article-hide-headers)))
4379 (defun gnus-output-to-file (file-name)
4380 "Append the current article to a file named FILE-NAME."
4381 (let ((artbuf (current-buffer)))
4383 (insert-buffer-substring artbuf)
4384 ;; Append newline at end of the buffer as separator, and then
4386 (goto-char (point-max))
4388 (let ((file-name-coding-system nnmail-pathname-coding-system))
4389 (mm-append-to-file (point-min) (point-max) file-name))
4392 (defun gnus-narrow-to-page (&optional arg)
4393 "Narrow the article buffer to a page.
4394 If given a numerical ARG, move forward ARG pages."
4396 (setq arg (if arg (prefix-numeric-value arg) 0))
4398 (set-buffer gnus-article-buffer)
4399 (goto-char (point-min))
4401 ;; Remove any old next/prev buttons.
4402 (when (gnus-visual-p 'page-marker)
4403 (let ((buffer-read-only nil))
4404 (gnus-remove-text-with-property 'gnus-prev)
4405 (gnus-remove-text-with-property 'gnus-next)))
4408 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4410 (re-search-forward page-delimiter nil 'move arg)))
4411 (goto-char (match-end 0)))
4414 (if (re-search-forward page-delimiter nil 'move)
4417 (when (and (gnus-visual-p 'page-marker)
4418 (not (= (point-min) 1)))
4420 (goto-char (point-min))
4421 (gnus-insert-prev-page-button)))
4422 (when (and (gnus-visual-p 'page-marker)
4423 (< (+ (point-max) 2) (buffer-size)))
4425 (goto-char (point-max))
4426 (gnus-insert-next-page-button)))))
4428 ;; Article mode commands
4430 (defun gnus-article-goto-next-page ()
4431 "Show the next page of the article."
4433 (when (gnus-article-next-page)
4434 (goto-char (point-min))
4435 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4437 (defun gnus-article-goto-prev-page ()
4438 "Show the next page of the article."
4440 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4441 (gnus-article-prev-page nil)))
4443 (defun gnus-article-next-page (&optional lines)
4444 "Show the next page of the current article.
4445 If end of article, return non-nil. Otherwise return nil.
4446 Argument LINES specifies lines to be scrolled up."
4448 (move-to-window-line -1)
4451 (and (pos-visible-in-window-p) ;Not continuation line.
4453 ;; Nothing in this page.
4454 (if (or (not gnus-page-broken)
4457 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
4459 (gnus-narrow-to-page 1) ;Go to next page.
4461 ;; More in this page.
4462 (let ((scroll-in-place nil))
4466 ;; Long lines may cause an end-of-buffer error.
4467 (goto-char (point-max)))))
4468 (move-to-window-line 0)
4471 (defun gnus-article-prev-page (&optional lines)
4472 "Show previous page of current article.
4473 Argument LINES specifies lines to be scrolled down."
4475 (move-to-window-line 0)
4476 (if (and gnus-page-broken
4478 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
4480 (gnus-narrow-to-page -1) ;Go to previous page.
4481 (goto-char (point-max))
4483 (let ((scroll-in-place nil))
4487 (beginning-of-buffer
4488 (goto-char (point-min))))
4489 (move-to-window-line 0)))))
4491 (defun gnus-article-refer-article ()
4492 "Read article specified by message-id around point."
4494 (let ((point (point)))
4495 (search-forward ">" nil t) ;Move point to end of "<....>".
4496 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
4497 (let ((message-id (match-string 1)))
4499 (set-buffer gnus-summary-buffer)
4500 (gnus-summary-refer-article message-id))
4502 (error "No references around point"))))
4504 (defun gnus-article-show-summary ()
4505 "Reconfigure windows to show summary buffer."
4507 (if (not (gnus-buffer-live-p gnus-summary-buffer))
4508 (error "There is no summary buffer for this article buffer")
4509 (gnus-article-set-globals)
4510 (gnus-configure-windows 'article)
4511 (gnus-summary-goto-subject gnus-current-article)
4512 (gnus-summary-position-point)))
4514 (defun gnus-article-describe-briefly ()
4515 "Describe article mode commands briefly."
4517 (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")))
4519 (defun gnus-article-summary-command ()
4520 "Execute the last keystroke in the summary buffer."
4522 (let ((obuf (current-buffer))
4523 (owin (current-window-configuration))
4525 (switch-to-buffer gnus-article-current-summary 'norecord)
4526 (setq func (lookup-key (current-local-map) (this-command-keys)))
4527 (call-interactively func)
4529 (set-window-configuration owin)
4530 (set-window-point (get-buffer-window (current-buffer)) (point))))
4532 (defun gnus-article-summary-command-nosave ()
4533 "Execute the last keystroke in the summary buffer."
4536 (pop-to-buffer gnus-article-current-summary 'norecord)
4537 (setq func (lookup-key (current-local-map) (this-command-keys)))
4538 (call-interactively func)))
4540 (defun gnus-article-check-buffer ()
4541 "Beep if not in an article buffer."
4542 (unless (equal major-mode 'gnus-article-mode)
4543 (error "Command invoked outside of a Gnus article buffer")))
4545 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
4546 "Read a summary buffer key sequence and execute it from the article buffer."
4548 (gnus-article-check-buffer)
4550 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
4551 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
4552 "=" "^" "\M-^" "|"))
4558 '("n" "Gn" "p" "Gp"))
4561 (set-buffer gnus-article-current-summary)
4562 (let (gnus-pick-mode)
4563 (push (or key last-command-event) unread-command-events)
4564 (setq keys (if (featurep 'xemacs)
4565 (events-to-keys (read-key-sequence nil))
4566 (read-key-sequence nil)))))
4570 (if (or (member keys nosaves)
4571 (member keys nosave-but-article)
4572 (member keys nosave-in-article))
4574 (save-window-excursion
4575 (pop-to-buffer gnus-article-current-summary 'norecord)
4576 ;; We disable the pick minor mode commands.
4577 (let (gnus-pick-mode)
4578 (setq func (lookup-key (current-local-map) keys))))
4582 (unless (member keys nosave-in-article)
4583 (set-buffer gnus-article-current-summary))
4584 (call-interactively func)
4585 (setq new-sum-point (point)))
4586 (when (member keys nosave-but-article)
4587 (pop-to-buffer gnus-article-buffer 'norecord)))
4588 ;; These commands should restore window configuration.
4589 (let ((obuf (current-buffer))
4590 (owin (current-window-configuration))
4592 (summary gnus-article-current-summary)
4593 func in-buffer selected)
4594 (if not-restore-window
4595 (pop-to-buffer summary 'norecord)
4596 (switch-to-buffer summary 'norecord))
4597 (setq in-buffer (current-buffer))
4598 ;; We disable the pick minor mode commands.
4599 (if (and (setq func (let (gnus-pick-mode)
4600 (lookup-key (current-local-map) keys)))
4603 (call-interactively func)
4604 (setq new-sum-point (point))
4605 (when (eq in-buffer (current-buffer))
4606 (setq selected (gnus-summary-select-article))
4608 (unless not-restore-window
4609 (set-window-configuration owin))
4610 (when (eq selected 'old)
4612 (set-window-start (get-buffer-window (current-buffer))
4614 (set-window-point (get-buffer-window (current-buffer))
4616 (let ((win (get-buffer-window gnus-article-current-summary)))
4618 (set-window-point win new-sum-point)))) )
4619 (switch-to-buffer gnus-article-buffer)
4622 (defun gnus-article-describe-key (key)
4623 "Display documentation of the function invoked by KEY. KEY is a string."
4624 (interactive "kDescribe key: ")
4625 (gnus-article-check-buffer)
4626 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4628 (set-buffer gnus-article-current-summary)
4629 (let (gnus-pick-mode)
4630 (if (featurep 'xemacs)
4632 (push (elt key 0) unread-command-events)
4633 (setq key (events-to-keys
4634 (read-key-sequence "Describe key: "))))
4635 (setq unread-command-events
4637 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4638 (string-to-list key)))
4639 (setq key (read-key-sequence "Describe key: "))))
4641 (describe-key key)))
4643 (defun gnus-article-describe-key-briefly (key &optional insert)
4644 "Display documentation of the function invoked by KEY. KEY is a string."
4645 (interactive "kDescribe key: \nP")
4646 (gnus-article-check-buffer)
4647 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4649 (set-buffer gnus-article-current-summary)
4650 (let (gnus-pick-mode)
4651 (if (featurep 'xemacs)
4653 (push (elt key 0) unread-command-events)
4654 (setq key (events-to-keys
4655 (read-key-sequence "Describe key: "))))
4656 (setq unread-command-events
4658 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4659 (string-to-list key)))
4660 (setq key (read-key-sequence "Describe key: "))))
4661 (describe-key-briefly key insert))
4662 (describe-key-briefly key insert)))
4664 (defun gnus-article-reply-with-original (&optional wide)
4665 "Start composing a reply mail to the current message.
4666 The text in the region will be yanked. If the region isn't active,
4667 the entire article will be yanked."
4669 (let ((article (cdr gnus-article-current)))
4670 (if (not mark-active)
4671 (gnus-summary-reply (list (list article)) wide)
4672 ;; Deactivate active regions.
4673 (when (and (boundp 'transient-mark-mode)
4674 transient-mark-mode)
4675 (setq mark-active nil))
4677 (list (list article (buffer-substring (point) (mark)))) wide))))
4679 (defun gnus-article-followup-with-original ()
4680 "Compose a followup to the current article.
4681 The text in the region will be yanked. If the region isn't active,
4682 the entire article will be yanked."
4684 (let ((article (cdr gnus-article-current)))
4685 (if (not mark-active)
4686 (gnus-summary-followup (list (list article)))
4687 ;; Deactivate active regions.
4688 (when (and (boundp 'transient-mark-mode)
4689 transient-mark-mode)
4690 (setq mark-active nil))
4691 (gnus-summary-followup
4692 (list (list article (buffer-substring (point) (mark))))))))
4694 (defun gnus-article-hide (&optional arg force)
4695 "Hide all the gruft in the current article.
4696 This means that PGP stuff, signatures, cited text and (some)
4697 headers will be hidden.
4698 If given a prefix, show the hidden text instead."
4699 (interactive (append (gnus-article-hidden-arg) (list 'force)))
4700 (gnus-article-hide-headers arg)
4701 (gnus-article-hide-list-identifiers arg)
4702 (gnus-article-hide-pgp arg)
4703 (gnus-article-hide-citation-maybe arg force)
4704 (gnus-article-hide-signature arg))
4706 (defun gnus-article-maybe-highlight ()
4707 "Do some article highlighting if article highlighting is requested."
4708 (when (gnus-visual-p 'article-highlight 'highlight)
4709 (gnus-article-highlight-some)))
4711 (defun gnus-check-group-server ()
4712 ;; Make sure the connection to the server is alive.
4713 (unless (gnus-server-opened
4714 (gnus-find-method-for-group gnus-newsgroup-name))
4715 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
4716 (gnus-request-group gnus-newsgroup-name t)))
4718 (defun gnus-request-article-this-buffer (article group)
4719 "Get an article and insert it into this buffer."
4720 (let (do-update-line sparse-header)
4724 (gnus-kill-all-overlays)
4725 (setq group (or group gnus-newsgroup-name))
4727 ;; Using `gnus-request-article' directly will insert the article into
4728 ;; `nntp-server-buffer' - so we'll save some time by not having to
4729 ;; copy it from the server buffer into the article buffer.
4731 ;; We only request an article by message-id when we do not have the
4732 ;; headers for it, so we'll have to get those.
4733 (when (stringp article)
4734 (gnus-read-header article))
4736 ;; If the article number is negative, that means that this article
4737 ;; doesn't belong in this newsgroup (possibly), so we find its
4738 ;; message-id and request it by id instead of number.
4739 (when (and (numberp article)
4741 (get-buffer gnus-summary-buffer)
4742 (gnus-buffer-exists-p gnus-summary-buffer))
4744 (set-buffer gnus-summary-buffer)
4745 (let ((header (gnus-summary-article-header article)))
4748 ((memq article gnus-newsgroup-sparse)
4749 ;; This is a sparse gap article.
4750 (setq do-update-line article)
4751 (setq article (mail-header-id header))
4752 (setq sparse-header (gnus-read-header article))
4753 (setq gnus-newsgroup-sparse
4754 (delq article gnus-newsgroup-sparse)))
4756 ;; It's a real article.
4757 (setq article (mail-header-id header)))
4759 ;; It is an extracted pseudo-article.
4760 (setq article 'pseudo)
4761 (gnus-request-pseudo-article header))))
4763 (let ((method (gnus-find-method-for-group
4764 gnus-newsgroup-name)))
4765 (when (and (eq (car method) 'nneething)
4767 (let ((dir (expand-file-name
4768 (mail-header-subject header)
4769 (file-name-as-directory
4770 (or (cadr (assq 'nneething-address method))
4772 (when (file-directory-p dir)
4773 (setq article 'nneething)
4774 (gnus-group-enter-directory dir))))))))
4777 ;; Refuse to select canceled articles.
4778 ((and (numberp article)
4780 (get-buffer gnus-summary-buffer)
4781 (gnus-buffer-exists-p gnus-summary-buffer)
4782 (eq (cdr (save-excursion
4783 (set-buffer gnus-summary-buffer)
4784 (assq article gnus-newsgroup-reads)))
4785 gnus-canceled-mark))
4787 ;; We first check `gnus-original-article-buffer'.
4788 ((and (get-buffer gnus-original-article-buffer)
4791 (set-buffer gnus-original-article-buffer)
4792 (and (equal (car gnus-original-article) group)
4793 (eq (cdr gnus-original-article) article))))
4794 (insert-buffer-substring gnus-original-article-buffer)
4796 ;; Check the backlog.
4797 ((and gnus-keep-backlog
4798 (gnus-backlog-request-article group article (current-buffer)))
4800 ;; Check asynchronous pre-fetch.
4801 ((gnus-async-request-fetched-article group article (current-buffer))
4802 (gnus-async-prefetch-next group article gnus-summary-buffer)
4803 (when (and (numberp article) gnus-keep-backlog)
4804 (gnus-backlog-enter-article group article (current-buffer)))
4807 ((and gnus-use-cache
4809 (gnus-cache-request-article article group))
4811 ;; Get the article and put into the article buffer.
4812 ((or (stringp article)
4814 (let ((gnus-override-method gnus-override-method)
4815 (methods (and (stringp article)
4816 gnus-refer-article-method))
4818 (buffer-read-only nil))
4819 (if (or (not (listp methods))
4820 (and (symbolp (car methods))
4821 (assq (car methods) nnoo-definition-alist)))
4822 (setq methods (list methods)))
4823 (when (and (null gnus-override-method)
4825 (setq gnus-override-method (pop methods)))
4827 (when (eq gnus-override-method 'current)
4828 (setq gnus-override-method
4829 (with-current-buffer gnus-summary-buffer
4830 gnus-current-select-method)))
4832 (gnus-kill-all-overlays)
4833 (let ((gnus-newsgroup-name group))
4834 (gnus-check-group-server))
4835 (when (gnus-request-article article group (current-buffer))
4836 (when (numberp article)
4837 (gnus-async-prefetch-next group article
4838 gnus-summary-buffer)
4839 (when gnus-keep-backlog
4840 (gnus-backlog-enter-article
4841 group article (current-buffer))))
4842 (setq result 'article))
4845 (setq gnus-override-method (pop methods))
4846 (setq result 'done))))
4847 (and (eq result 'article) 'article)))
4851 ;; Associate this article with the current summary buffer.
4852 (setq gnus-article-current-summary gnus-summary-buffer)
4854 ;; Take the article from the original article buffer
4855 ;; and place it in the buffer it's supposed to be in.
4856 (when (and (get-buffer gnus-article-buffer)
4857 (equal (buffer-name (current-buffer))
4858 (buffer-name (get-buffer gnus-article-buffer))))
4860 (if (get-buffer gnus-original-article-buffer)
4861 (set-buffer gnus-original-article-buffer)
4862 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
4863 (buffer-disable-undo)
4864 (setq major-mode 'gnus-original-article-mode)
4865 (setq buffer-read-only t))
4866 (let (buffer-read-only)
4868 (insert-buffer-substring gnus-article-buffer))
4869 (setq gnus-original-article (cons group article)))
4872 (run-hooks 'gnus-article-decode-hook)
4873 ;; Mark article as decoded or not.
4874 (setq gnus-article-decoded-p gnus-article-decode-hook))
4876 ;; Update sparse articles.
4877 (when (and do-update-line
4878 (or (numberp article)
4880 (let ((buf (current-buffer)))
4881 (set-buffer gnus-summary-buffer)
4882 (gnus-summary-update-article do-update-line sparse-header)
4883 (gnus-summary-goto-subject do-update-line nil t)
4884 (set-window-point (gnus-get-buffer-window (current-buffer) t)
4886 (set-buffer buf))))))
4892 (defcustom gnus-article-edit-mode-hook nil
4893 "Hook run in article edit mode buffers."
4894 :group 'gnus-article-various
4897 (defvar gnus-article-edit-done-function nil)
4899 (defvar gnus-article-edit-mode-map nil)
4901 ;; Should we be using derived.el for this?
4902 (unless gnus-article-edit-mode-map
4903 (setq gnus-article-edit-mode-map (make-sparse-keymap))
4904 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
4906 (gnus-define-keys gnus-article-edit-mode-map
4907 "\C-c\C-c" gnus-article-edit-done
4908 "\C-c\C-k" gnus-article-edit-exit)
4910 (gnus-define-keys (gnus-article-edit-wash-map
4911 "\C-c\C-w" gnus-article-edit-mode-map)
4912 "f" gnus-article-edit-full-stops))
4914 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
4915 "Major mode for editing articles.
4916 This is an extended text-mode.
4918 \\{gnus-article-edit-mode-map}"
4919 (make-local-variable 'gnus-article-edit-done-function)
4920 (make-local-variable 'gnus-prev-winconf)
4921 (set (make-local-variable 'font-lock-defaults)
4922 '(message-font-lock-keywords t))
4923 (setq buffer-read-only nil)
4924 (buffer-enable-undo)
4927 (defun gnus-article-edit (&optional force)
4928 "Edit the current article.
4929 This will have permanent effect only in mail groups.
4930 If FORCE is non-nil, allow editing of articles even in read-only
4933 (when (and (not force)
4934 (gnus-group-read-only-p))
4935 (error "The current newsgroup does not support article editing"))
4936 (gnus-article-date-original)
4937 (gnus-article-edit-article
4939 `(lambda (no-highlight)
4941 (gnus-summary-edit-article-done
4942 ,(or (mail-header-references gnus-current-headers) "")
4943 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
4945 (defun gnus-article-edit-article (start-func exit-func)
4946 "Start editing the contents of the current article buffer."
4947 (let ((winconf (current-window-configuration)))
4948 (set-buffer gnus-article-buffer)
4949 (gnus-article-edit-mode)
4950 (funcall start-func)
4951 (set-buffer-modified-p nil)
4952 (gnus-configure-windows 'edit-article)
4953 (setq gnus-article-edit-done-function exit-func)
4954 (setq gnus-prev-winconf winconf)
4955 (gnus-message 6 "C-c C-c to end edits")))
4957 (defun gnus-article-edit-done (&optional arg)
4958 "Update the article edits and exit."
4960 (let ((func gnus-article-edit-done-function)
4961 (buf (current-buffer))
4962 (start (window-start)))
4963 ;; We remove all text props from the article buffer.
4965 (buffer-substring-no-properties (point-min) (point-max)))
4969 (let ((winconf gnus-prev-winconf))
4971 (set-window-configuration winconf)
4972 ;; Tippy-toe some to make sure that point remains where it was.
4973 (save-current-buffer
4975 (set-window-start (get-buffer-window (current-buffer)) start)
4979 (let ((buffer-read-only nil))
4981 ;; The cache and backlog have to be flushed somewhat.
4982 (when gnus-keep-backlog
4983 (gnus-backlog-remove-article
4984 (car gnus-article-current) (cdr gnus-article-current)))
4985 ;; Flush original article as well.
4987 (when (get-buffer gnus-original-article-buffer)
4988 (set-buffer gnus-original-article-buffer)
4989 (setq gnus-original-article nil)))
4990 (when gnus-use-cache
4991 (gnus-cache-update-article
4992 (car gnus-article-current) (cdr gnus-article-current))))
4994 (set-window-start (get-buffer-window buf) start)
4995 (set-window-point (get-buffer-window buf) (point))))
4997 (defun gnus-article-edit-exit ()
4998 "Exit the article editing without updating."
5000 (when (or (not (buffer-modified-p))
5001 (yes-or-no-p "Article modified; kill anyway? "))
5002 (let ((curbuf (current-buffer))
5004 (window-start (window-start)))
5006 (if (gnus-buffer-live-p gnus-original-article-buffer)
5007 (insert-buffer gnus-original-article-buffer))
5008 (let ((winconf gnus-prev-winconf))
5010 (set-window-configuration winconf)
5011 ;; Tippy-toe some to make sure that point remains where it was.
5012 (save-current-buffer
5014 (set-window-start (get-buffer-window (current-buffer)) window-start)
5017 (defun gnus-article-edit-full-stops ()
5018 "Interactively repair spacing at end of sentences."
5021 (goto-char (point-min))
5022 (search-forward-regexp "^$" nil t)
5023 (let ((case-fold-search nil))
5024 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5027 ;;; Article highlights
5030 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5032 ;;; Internal Variables:
5034 (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\\)\\)"
5035 "Regular expression that matches URLs."
5036 :group 'gnus-article-buttons
5039 (defcustom gnus-button-alist
5040 `(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
5041 0 t gnus-button-handle-news 3)
5042 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
5043 gnus-button-handle-news 2)
5044 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
5046 gnus-button-fetch-group 4)
5047 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
5048 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
5049 t gnus-button-message-id 3)
5050 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
5051 ("mailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5052 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
5054 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t
5055 gnus-button-handle-info 2)
5056 ;; This is how URLs _should_ be embedded in text...
5057 ("<URL: *\\([^<>]*\\)>" 0 t gnus-button-embedded-url 1)
5059 (,gnus-button-url-regexp 0 t browse-url 0))
5060 "*Alist of regexps matching buttons in article bodies.
5062 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
5063 REGEXP: is the string matching text around the button,
5064 BUTTON: is the number of the regexp grouping actually matching the button,
5065 FORM: is a lisp expression which must eval to true for the button to
5067 CALLBACK: is the function to call when the user push this button, and each
5068 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
5070 CALLBACK can also be a variable, in that case the value of that
5071 variable it the real callback function."
5072 :group 'gnus-article-buttons
5073 :type '(repeat (list regexp
5074 (integer :tag "Button")
5076 (function :tag "Callback")
5079 (integer :tag "Regexp group")))))
5081 (defcustom gnus-header-button-alist
5082 `(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
5083 0 t gnus-button-message-id 0)
5084 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
5085 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
5086 0 t gnus-button-mailto 0)
5087 ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t browse-url 0)
5088 ("^Subject:" ,gnus-button-url-regexp 0 t browse-url 0)
5089 ("^[^:]+:" ,gnus-button-url-regexp 0 t browse-url 0)
5090 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
5091 gnus-button-message-id 3))
5092 "*Alist of headers and regexps to match buttons in article heads.
5094 This alist is very similar to `gnus-button-alist', except that each
5095 alist has an additional HEADER element first in each entry:
5097 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
5099 HEADER is a regexp to match a header. For a fuller explanation, see
5100 `gnus-button-alist'."
5101 :group 'gnus-article-buttons
5102 :group 'gnus-article-headers
5103 :type '(repeat (list (regexp :tag "Header")
5105 (integer :tag "Button")
5107 (function :tag "Callback")
5110 (integer :tag "Regexp group")))))
5112 (defvar gnus-button-regexp nil)
5113 (defvar gnus-button-marker-list nil)
5114 ;; Regexp matching any of the regexps from `gnus-button-alist'.
5116 (defvar gnus-button-last nil)
5117 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
5121 (defun gnus-article-push-button (event)
5122 "Check text under the mouse pointer for a callback function.
5123 If the text under the mouse pointer has a `gnus-callback' property,
5124 call it with the value of the `gnus-data' text property."
5126 (set-buffer (window-buffer (posn-window (event-start event))))
5127 (let* ((pos (posn-point (event-start event)))
5128 (data (get-text-property pos 'gnus-data))
5129 (fun (get-text-property pos 'gnus-callback)))
5132 (funcall fun data))))
5134 (defun gnus-article-press-button ()
5135 "Check text at point for a callback function.
5136 If the text at point has a `gnus-callback' property,
5137 call it with the value of the `gnus-data' text property."
5139 (let* ((data (get-text-property (point) 'gnus-data))
5140 (fun (get-text-property (point) 'gnus-callback)))
5142 (funcall fun data))))
5144 (defun gnus-article-highlight (&optional force)
5145 "Highlight current article.
5146 This function calls `gnus-article-highlight-headers',
5147 `gnus-article-highlight-citation',
5148 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5149 do the highlighting. See the documentation for those functions."
5150 (interactive (list 'force))
5151 (gnus-article-highlight-headers)
5152 (gnus-article-highlight-citation force)
5153 (gnus-article-highlight-signature)
5154 (gnus-article-add-buttons force)
5155 (gnus-article-add-buttons-to-head))
5157 (defun gnus-article-highlight-some (&optional force)
5158 "Highlight current article.
5159 This function calls `gnus-article-highlight-headers',
5160 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5161 do the highlighting. See the documentation for those functions."
5162 (interactive (list 'force))
5163 (gnus-article-highlight-headers)
5164 (gnus-article-highlight-signature)
5165 (gnus-article-add-buttons))
5167 (defun gnus-article-highlight-headers ()
5168 "Highlight article headers as specified by `gnus-header-face-alist'."
5171 (set-buffer gnus-article-buffer)
5173 (let ((alist gnus-header-face-alist)
5174 (buffer-read-only nil)
5175 (case-fold-search t)
5176 (inhibit-point-motion-hooks t)
5177 entry regexp header-face field-face from hpoints fpoints)
5178 (article-narrow-to-head)
5179 (while (setq entry (pop alist))
5180 (goto-char (point-min))
5181 (setq regexp (concat "^\\("
5182 (if (string-equal "" (nth 0 entry))
5186 header-face (nth 1 entry)
5187 field-face (nth 2 entry))
5188 (while (and (re-search-forward regexp nil t)
5192 (unless (search-forward ":" nil t)
5194 (when (and header-face
5195 (not (memq (point) hpoints)))
5196 (push (point) hpoints)
5197 (gnus-put-text-property from (point) 'face header-face))
5198 (when (and field-face
5199 (not (memq (setq from (point)) fpoints)))
5201 (if (re-search-forward "^[^ \t]" nil t)
5203 (goto-char (point-max)))
5204 (gnus-put-text-property from (point) 'face field-face))))))))
5206 (defun gnus-article-highlight-signature ()
5207 "Highlight the signature in an article.
5208 It does this by highlighting everything after
5209 `gnus-signature-separator' using `gnus-signature-face'."
5212 (set-buffer gnus-article-buffer)
5213 (let ((buffer-read-only nil)
5214 (inhibit-point-motion-hooks t))
5216 (when (and gnus-signature-face
5217 (gnus-article-narrow-to-signature))
5218 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
5219 'face gnus-signature-face)
5221 (gnus-article-search-signature)
5222 (let ((start (match-beginning 0))
5223 (end (set-marker (make-marker) (1+ (match-end 0)))))
5224 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
5227 (defun gnus-button-in-region-p (b e prop)
5228 "Say whether PROP exists in the region."
5229 (text-property-not-all b e prop nil))
5231 (defun gnus-article-add-buttons (&optional force)
5232 "Find external references in the article and make buttons of them.
5233 \"External references\" are things like Message-IDs and URLs, as
5234 specified by `gnus-button-alist'."
5235 (interactive (list 'force))
5237 (set-buffer gnus-article-buffer)
5238 (let ((buffer-read-only nil)
5239 (inhibit-point-motion-hooks t)
5240 (case-fold-search t)
5241 (alist gnus-button-alist)
5243 ;; Remove all old markers.
5244 (let (marker entry new-list)
5245 (while (setq marker (pop gnus-button-marker-list))
5246 (if (or (< marker (point-min)) (>= marker (point-max)))
5247 (push marker new-list)
5249 (when (setq entry (gnus-button-entry))
5250 (put-text-property (match-beginning (nth 1 entry))
5251 (match-end (nth 1 entry))
5252 'gnus-callback nil))
5253 (set-marker marker nil)))
5254 (setq gnus-button-marker-list new-list))
5255 ;; We skip the headers.
5258 (while (setq entry (pop alist))
5259 (setq regexp (car entry))
5261 (while (re-search-forward regexp nil t)
5262 (let* ((start (and entry (match-beginning (nth 1 entry))))
5263 (end (and entry (match-end (nth 1 entry))))
5264 (from (match-beginning 0)))
5265 (when (and (or (eq t (nth 2 entry))
5266 (eval (nth 2 entry)))
5267 (not (gnus-button-in-region-p
5268 start end 'gnus-callback)))
5269 ;; That optional form returned non-nil, so we add the
5271 (gnus-article-add-button
5272 start end 'gnus-button-push
5273 (car (push (set-marker (make-marker) from)
5274 gnus-button-marker-list))))))))))
5276 ;; Add buttons to the head of an article.
5277 (defun gnus-article-add-buttons-to-head ()
5278 "Add buttons to the head of the article."
5281 (set-buffer gnus-article-buffer)
5283 (let ((buffer-read-only nil)
5284 (inhibit-point-motion-hooks t)
5285 (case-fold-search t)
5286 (alist gnus-header-button-alist)
5288 (article-narrow-to-head)
5290 ;; Each alist entry.
5291 (setq entry (car alist)
5293 (goto-char (point-min))
5294 (while (re-search-forward (car entry) nil t)
5295 ;; Each header matching the entry.
5296 (setq beg (match-beginning 0))
5297 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
5298 (match-beginning 0))
5301 (while (re-search-forward (nth 1 entry) end t)
5302 ;; Each match within a header.
5303 (let* ((entry (cdr entry))
5304 (start (match-beginning (nth 1 entry)))
5305 (end (match-end (nth 1 entry)))
5306 (form (nth 2 entry)))
5307 (goto-char (match-end 0))
5309 (gnus-article-add-button
5310 start end (nth 3 entry)
5311 (buffer-substring (match-beginning (nth 4 entry))
5312 (match-end (nth 4 entry)))))))
5313 (goto-char end)))))))
5315 ;;; External functions:
5317 (defun gnus-article-add-button (from to fun &optional data)
5318 "Create a button between FROM and TO with callback FUN and data DATA."
5319 (when gnus-article-button-face
5320 (gnus-overlay-put (gnus-make-overlay from to)
5321 'face gnus-article-button-face))
5322 (gnus-add-text-properties
5324 (nconc (and gnus-article-mouse-face
5325 (list gnus-mouse-face-prop gnus-article-mouse-face))
5326 (list 'gnus-callback fun)
5327 (and data (list 'gnus-data data))))
5328 (widget-convert-button 'link from to :action 'gnus-widget-press-button
5329 :button-keymap gnus-widget-button-keymap))
5331 ;;; Internal functions:
5333 (defun gnus-article-set-globals ()
5335 (set-buffer gnus-summary-buffer)
5336 (gnus-set-global-variables)))
5338 (defun gnus-signature-toggle (end)
5340 (set-buffer gnus-article-buffer)
5341 (let ((buffer-read-only nil)
5342 (inhibit-point-motion-hooks t))
5343 (if (text-property-any end (point-max) 'article-type 'signature)
5345 (gnus-delete-wash-type 'signature)
5346 (gnus-remove-text-properties-when
5347 'article-type 'signature end (point-max)
5348 (cons 'article-type (cons 'signature
5349 gnus-hidden-properties))))
5350 (gnus-add-wash-type 'signature)
5351 (gnus-add-text-properties-when
5352 'article-type nil end (point-max)
5353 (cons 'article-type (cons 'signature
5354 gnus-hidden-properties)))))
5355 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
5356 (gnus-set-mode-line 'article))))
5358 (defun gnus-button-entry ()
5359 ;; Return the first entry in `gnus-button-alist' matching this place.
5360 (let ((alist gnus-button-alist)
5363 (setq entry (pop alist))
5364 (if (looking-at (car entry))
5369 (defun gnus-button-push (marker)
5370 ;; Push button starting at MARKER.
5373 (let* ((entry (gnus-button-entry))
5374 (inhibit-point-motion-hooks t)
5376 (args (mapcar (lambda (group)
5377 (let ((string (match-string group)))
5378 (gnus-set-text-properties
5379 0 (length string) nil string)
5386 (fboundp (symbol-value fun)))
5387 (apply (symbol-value fun) args))
5389 (gnus-message 1 "You must define `%S' to use this button"
5390 (cons fun args)))))))
5392 (defun gnus-parse-news-url (url)
5393 (let (scheme server group message-id articles)
5396 (goto-char (point-min))
5397 (when (looking-at "\\([A-Za-z]+\\):")
5398 (setq scheme (match-string 1))
5399 (goto-char (match-end 0)))
5400 (when (looking-at "//\\([^/]+\\)/")
5401 (setq server (match-string 1))
5402 (goto-char (match-end 0)))
5405 ((looking-at "\\(.*@.*\\)")
5406 (setq message-id (match-string 1)))
5407 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
5408 (setq group (match-string 1)
5409 articles (split-string (match-string 2) "-")))
5410 ((looking-at "\\([^/]+\\)/?")
5411 (setq group (match-string 1)))
5413 (error "Unknown news URL syntax"))))
5414 (list scheme server group message-id articles)))
5416 (defun gnus-button-handle-news (url)
5418 (destructuring-bind (scheme server group message-id articles)
5419 (gnus-parse-news-url url)
5423 (set-buffer gnus-summary-buffer)
5425 (let ((gnus-refer-article-method (list (list 'nntp server))))
5426 (gnus-summary-refer-article message-id))
5427 (gnus-summary-refer-article message-id))))
5429 (gnus-button-fetch-group url)))))
5431 (defun gnus-button-handle-info (url)
5432 "Fetch an info URL."
5434 "^\\([^:/]+\\)?/\\(.*\\)"
5436 (gnus-info-find-node
5437 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
5440 (gnus-url-unhex-string (match-string 2 url))))
5441 (error "Can't parse %s" url)))
5443 (defun gnus-button-message-id (message-id)
5446 (set-buffer gnus-summary-buffer)
5447 (gnus-summary-refer-article message-id)))
5449 (defun gnus-button-fetch-group (address)
5450 "Fetch GROUP specified by ADDRESS."
5451 (if (not (string-match "[:/]" address))
5452 ;; This is just a simple group url.
5453 (gnus-group-read-ephemeral-group address gnus-select-method)
5456 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
5458 (error "Can't parse %s" address)
5459 (gnus-group-read-ephemeral-group
5460 (match-string 4 address)
5461 `(nntp ,(match-string 1 address)
5462 (nntp-address ,(match-string 1 address))
5463 (nntp-port-number ,(if (match-end 3)
5464 (match-string 3 address)
5467 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
5469 (defun gnus-url-parse-query-string (query &optional downcase)
5470 (let (retval pairs cur key val)
5471 (setq pairs (split-string query "&"))
5473 (setq cur (car pairs)
5475 (if (not (string-match "=" cur))
5477 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
5478 val (gnus-url-unhex-string (substring cur (match-end 0) nil)))
5480 (setq key (downcase key)))
5481 (setq cur (assoc key retval))
5483 (setcdr cur (cons val (cdr cur)))
5484 (setq retval (cons (list key val) retval)))))
5487 (defun gnus-url-mailto (url)
5488 ;; Send mail to someone
5489 (when (string-match "mailto:/*\\(.*\\)" url)
5490 (setq url (substring url (match-beginning 1) nil)))
5491 (let (to args subject func)
5492 (if (string-match (regexp-quote "?") url)
5493 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
5494 args (gnus-url-parse-query-string
5495 (substring url (match-end 0) nil) t))
5496 (setq to (gnus-url-unhex-string url)))
5497 (setq args (cons (list "to" to) args)
5498 subject (cdr-safe (assoc "subject" args)))
5501 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
5504 (message-position-on-field (caar args)))
5505 (insert (mapconcat 'identity (cdar args) ", "))
5506 (setq args (cdr args)))
5509 (message-goto-subject))))
5511 (defun gnus-button-embedded-url (address)
5512 "Activate ADDRESS with `browse-url'."
5513 (browse-url (gnus-strip-whitespace address)))
5515 ;;; Next/prev buttons in the article buffer.
5517 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
5518 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
5520 (defvar gnus-prev-page-map
5521 (let ((map (make-sparse-keymap)))
5522 (unless (>= emacs-major-version 21)
5523 ;; XEmacs doesn't care.
5524 (set-keymap-parent map gnus-article-mode-map))
5525 (define-key map gnus-mouse-2 'gnus-button-prev-page)
5526 (define-key map "\r" 'gnus-button-prev-page)
5529 (defun gnus-insert-prev-page-button ()
5531 (buffer-read-only nil))
5533 gnus-prev-page-line-format nil
5534 `(,@(gnus-local-map-property gnus-prev-page-map)
5536 gnus-callback gnus-article-button-prev-page
5537 article-type annotation))
5538 (widget-convert-button
5540 :action 'gnus-button-prev-page
5541 :button-keymap gnus-prev-page-map)))
5543 (defvar gnus-prev-page-map
5544 (let ((map (make-sparse-keymap)))
5545 (unless (>= emacs-major-version 21)
5546 ;; XEmacs doesn't care.
5547 (set-keymap-parent map gnus-article-mode-map))
5548 (define-key map gnus-mouse-2 'gnus-button-prev-page)
5549 (define-key map "\r" 'gnus-button-prev-page)
5552 (defvar gnus-next-page-map
5553 (let ((map (make-sparse-keymap)))
5554 (unless (>= emacs-major-version 21)
5555 ;; XEmacs doesn't care.
5556 (set-keymap-parent map gnus-article-mode-map))
5557 (define-key map gnus-mouse-2 'gnus-button-next-page)
5558 (define-key map "\r" 'gnus-button-next-page)
5561 (defun gnus-button-next-page (&optional args more-args)
5562 "Go to the next page."
5564 (let ((win (selected-window)))
5565 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5566 (gnus-article-next-page)
5567 (select-window win)))
5569 (defun gnus-button-prev-page (&optional args more-args)
5570 "Go to the prev page."
5572 (let ((win (selected-window)))
5573 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5574 (gnus-article-prev-page)
5575 (select-window win)))
5577 (defun gnus-insert-next-page-button ()
5579 (buffer-read-only nil))
5580 (gnus-eval-format gnus-next-page-line-format nil
5581 `(,@(gnus-local-map-property gnus-next-page-map)
5583 gnus-callback gnus-article-button-next-page
5584 article-type annotation))
5585 (widget-convert-button
5587 :action 'gnus-button-next-page
5588 :button-keymap gnus-next-page-map)))
5590 (defun gnus-article-button-next-page (arg)
5591 "Go to the next page."
5593 (let ((win (selected-window)))
5594 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5595 (gnus-article-next-page)
5596 (select-window win)))
5598 (defun gnus-article-button-prev-page (arg)
5599 "Go to the prev page."
5601 (let ((win (selected-window)))
5602 (select-window (gnus-get-buffer-window gnus-article-buffer t))
5603 (gnus-article-prev-page)
5604 (select-window win)))
5606 (defvar gnus-decode-header-methods
5607 '(mail-decode-encoded-word-region)
5608 "List of methods used to decode headers.
5610 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
5611 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
5612 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
5613 whose names match REGEXP.
5616 ((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
5617 mail-decode-encoded-word-region
5618 (\"chinese\" . rfc1843-decode-region))
5621 (defvar gnus-decode-header-methods-cache nil)
5623 (defun gnus-multi-decode-header (start end)
5624 "Apply the functions from `gnus-encoded-word-methods' that match."
5625 (unless (and gnus-decode-header-methods-cache
5626 (eq gnus-newsgroup-name
5627 (car gnus-decode-header-methods-cache)))
5628 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
5631 (nconc gnus-decode-header-methods-cache (list x))
5632 (if (and gnus-newsgroup-name
5633 (string-match (car x) gnus-newsgroup-name))
5634 (nconc gnus-decode-header-methods-cache
5636 gnus-decode-header-methods))
5637 (let ((xlist gnus-decode-header-methods-cache))
5640 (narrow-to-region start end)
5642 (funcall (pop xlist) (point-min) (point-max))))))
5645 ;;; Treatment top-level handling.
5648 (defun gnus-treat-article (condition &optional part-number total-parts type)
5649 (let ((length (- (point-max) (point-min)))
5650 (alist gnus-treatment-function-alist)
5651 (article-goto-body-goes-to-point-min-p t)
5655 (let ((list gnus-article-treat-types))
5657 (when (string-match (pop list) type)
5658 (throw 'found t)))))))
5659 (highlightp (gnus-visual-p 'article-highlight 'highlight))
5661 (gnus-run-hooks 'gnus-part-display-hook)
5662 (while (setq elem (pop alist))
5665 (if (gnus-buffer-live-p gnus-summary-buffer)
5666 (set-buffer gnus-summary-buffer))
5667 (symbol-value (car elem))))
5668 (when (and (or (consp val)
5670 (gnus-treat-predicate val)
5671 (or (not (get (car elem) 'highlight))
5674 (funcall (cadr elem)))))))
5676 ;; Dynamic variables.
5678 (defvar part-number)
5679 (defvar total-parts)
5684 (defun gnus-treat-predicate (val)
5689 (stringp (car val)))
5690 (apply 'gnus-or (mapcar `(lambda (s)
5691 (string-match s ,(or gnus-newsgroup-name "")))
5694 (let ((pred (pop val)))
5697 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
5699 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
5701 (not (gnus-treat-predicate (car val))))
5703 (equal (car val) type))
5705 (error "%S is not a valid predicate" pred)))))
5713 (eq part-number total-parts))
5717 (error "%S is not a valid value" val))))
5719 (defun gnus-article-encrypt-body (protocol &optional n)
5720 "Encrypt the article body."
5723 (or gnus-article-encrypt-protocol
5724 (completing-read "Encrypt protocol: "
5725 gnus-article-encrypt-protocol-alist
5727 current-prefix-arg))
5728 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
5730 (error (format "Can't find the encrypt protocol %s" protocol)))
5731 (if (equal gnus-newsgroup-name "nndraft:drafts")
5732 (error "Can't encrypt the article in group nndraft:drafts"))
5733 (if (equal gnus-newsgroup-name "nndraft:queue")
5734 (error "Don't encrypt the article in group nndraft:queue"))
5735 (gnus-summary-iterate n
5737 (set-buffer gnus-summary-buffer)
5738 (let ((mail-parse-charset gnus-newsgroup-charset)
5739 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
5740 (summary-buffer gnus-summary-buffer)
5742 (gnus-set-global-variables)
5743 (when (gnus-group-read-only-p)
5744 (error "The current newsgroup does not support article encrypt"))
5745 (gnus-summary-show-article t)
5747 (or (mail-header-references gnus-current-headers) ""))
5748 (set-buffer gnus-article-buffer)
5749 (let* ((buffer-read-only nil)
5751 (mapcar (lambda (field)
5752 (and (save-restriction
5753 (message-narrow-to-head)
5754 (goto-char (point-min))
5755 (search-forward field nil t))
5757 (message-narrow-to-field)
5758 (buffer-substring (point-min) (point-max))
5759 (delete-region (point-min) (point-max))
5761 '("Content-Type:" "Content-Transfer-Encoding:"
5762 "Content-Disposition:"))))
5763 (message-narrow-to-head)
5764 (message-remove-header "MIME-Version")
5765 (goto-char (point-max))
5766 (setq point (point))
5767 (insert (apply 'concat headers))
5769 (narrow-to-region point (point-max))
5770 (let ((message-options message-options))
5771 (message-options-set 'message-sender user-mail-address)
5772 (message-options-set 'message-recipients user-mail-address)
5773 (message-options-set 'message-sign-encrypt 'not)
5775 (goto-char (point-min))
5776 (insert "MIME-Version: 1.0\n")
5778 (gnus-summary-edit-article-done
5779 references nil summary-buffer t))
5780 (when gnus-keep-backlog
5781 (gnus-backlog-remove-article
5782 (car gnus-article-current) (cdr gnus-article-current)))
5784 (when (get-buffer gnus-original-article-buffer)
5785 (set-buffer gnus-original-article-buffer)
5786 (setq gnus-original-article nil)))
5787 (when gnus-use-cache
5788 (gnus-cache-update-article
5789 (car gnus-article-current) (cdr gnus-article-current))))))))
5791 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
5792 "The following specs can be used:
5793 %t The security MIME type
5796 %D Details if button is pressed")
5798 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
5799 "The following specs can be used:
5800 %t The security MIME type
5803 %D Details if button is pressed")
5805 (defvar gnus-mime-security-button-line-format-alist
5806 '((?t gnus-tmp-type ?s)
5807 (?i gnus-tmp-info ?s)
5808 (?d gnus-tmp-details ?s)
5809 (?D gnus-tmp-pressed-details ?s)))
5811 (defvar gnus-mime-security-button-map
5812 (let ((map (make-sparse-keymap)))
5813 (unless (>= (string-to-number emacs-version) 21)
5814 (set-keymap-parent map gnus-article-mode-map))
5815 (define-key map gnus-mouse-2 'gnus-article-push-button)
5816 (define-key map "\r" 'gnus-article-press-button)
5819 (defvar gnus-mime-security-details-buffer nil)
5821 (defvar gnus-mime-security-button-pressed nil)
5823 (defvar gnus-mime-security-show-details-inline t
5824 "If non-nil, show details in the article buffer.")
5826 (defun gnus-mime-security-verify-or-decrypt (handle)
5827 (mm-remove-parts (cdr handle))
5828 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
5829 point buffer-read-only)
5831 (goto-char (car region)))
5833 (narrow-to-region (point) (point))
5834 (with-current-buffer (mm-handle-multipart-original-buffer handle)
5835 (let* ((mm-verify-option 'known)
5836 (mm-decrypt-option 'known)
5837 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
5838 (unless (eq nparts (cdr handle))
5839 (mm-destroy-parts (cdr handle))
5840 (setcdr handle nparts))))
5841 (setq point (point))
5842 (gnus-mime-display-security handle)
5843 (goto-char (point-max)))
5845 (delete-region (point) (cdr region))
5846 (set-marker (car region) nil)
5847 (set-marker (cdr region) nil))
5850 (defun gnus-mime-security-show-details (handle)
5851 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
5853 (if gnus-mime-security-show-details-inline
5854 (let ((gnus-mime-security-button-pressed t)
5855 (gnus-mime-security-button-line-format
5856 (get-text-property (point) 'gnus-line-format))
5859 (while (eq (get-text-property (point) 'gnus-line-format)
5860 gnus-mime-security-button-line-format)
5864 (narrow-to-region (point) (point))
5865 (gnus-insert-mime-security-button handle))
5866 (delete-region (point)
5867 (or (text-property-not-all
5870 gnus-mime-security-button-line-format)
5872 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
5873 (with-current-buffer gnus-mime-security-details-buffer
5876 (setq gnus-mime-security-details-buffer
5877 (gnus-get-buffer-create "*MIME Security Details*")))
5878 (with-current-buffer gnus-mime-security-details-buffer
5880 (goto-char (point-min)))
5881 (pop-to-buffer gnus-mime-security-details-buffer))
5882 (gnus-message 5 "No details."))))
5884 (defun gnus-mime-security-press-button (handle)
5885 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
5886 (gnus-mime-security-show-details handle)
5887 (gnus-mime-security-verify-or-decrypt handle)))
5889 (defun gnus-insert-mime-security-button (handle &optional displayed)
5890 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
5893 (or (nth 2 (assoc protocol mm-verify-function-alist))
5894 (nth 2 (assoc protocol mm-decrypt-function-alist))
5896 (if (equal (car handle) "multipart/signed")
5897 " Signed" " Encrypted")
5900 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
5903 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
5904 gnus-tmp-pressed-details
5906 (setq gnus-tmp-details
5907 (if gnus-tmp-details
5908 (concat "\n" gnus-tmp-details) ""))
5909 (setq gnus-tmp-pressed-details
5910 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
5915 gnus-mime-security-button-line-format
5916 gnus-mime-security-button-line-format-alist
5917 `(,@(gnus-local-map-property gnus-mime-security-button-map)
5918 gnus-callback gnus-mime-security-press-button
5919 gnus-line-format ,gnus-mime-security-button-line-format
5920 article-type annotation
5923 (widget-convert-button
5926 :action 'gnus-widget-press-button
5927 :button-keymap gnus-mime-security-button-map
5929 (lambda (widget/window &optional overlay pos)
5930 ;; Needed to properly clear the message due to a bug in
5931 ;; wid-edit (XEmacs only).
5932 (if (boundp 'help-echo-owns-message)
5933 (setq help-echo-owns-message t))
5936 (aref gnus-mouse-2 0))))))
5938 (defun gnus-mime-display-security (handle)
5940 (narrow-to-region (point) (point))
5941 (unless (gnus-unbuttonized-mime-type-p (car handle))
5942 (gnus-insert-mime-security-button handle))
5943 (gnus-mime-display-mixed (cdr handle))
5946 (unless (gnus-unbuttonized-mime-type-p (car handle))
5947 (let ((gnus-mime-security-button-line-format
5948 gnus-mime-security-button-end-line-format))
5949 (gnus-insert-mime-security-button handle)))
5950 (mm-set-handle-multipart-parameter
5952 (cons (set-marker (make-marker) (point-min))
5953 (set-marker (make-marker) (point-max))))))
5959 (run-hooks 'gnus-art-load-hook)
5961 ;;; gnus-art.el ends here