1 ;;; gnus-art.el --- article mode commands for Semi-gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;; Katsumi Yamaoka <yamaoka@jpl.org>
8 ;; Keywords: mail, news, MIME
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
31 (eval-when-compile (require 'cl))
32 (eval-when-compile (require 'static))
43 ;; Avoid byte-compile warnings.
52 (autoload 'gnus-msg-mail "gnus-msg" nil t)
53 (autoload 'gnus-button-mailto "gnus-msg")
54 (autoload 'gnus-button-reply "gnus-msg" nil t)
56 (defgroup gnus-article nil
58 :link '(custom-manual "(gnus)The Article Buffer")
61 (defgroup gnus-article-treat nil
62 "Treating article parts."
63 :link '(custom-manual "(gnus)Article Hiding")
66 (defgroup gnus-article-hiding nil
67 "Hiding article parts."
68 :link '(custom-manual "(gnus)Article Hiding")
71 (defgroup gnus-article-highlight nil
72 "Article highlighting."
73 :link '(custom-manual "(gnus)Article Highlighting")
77 (defgroup gnus-article-signature nil
79 :link '(custom-manual "(gnus)Article Signature")
82 (defgroup gnus-article-headers nil
84 :link '(custom-manual "(gnus)Hiding Headers")
87 (defgroup gnus-article-washing nil
88 "Special commands on articles."
89 :link '(custom-manual "(gnus)Article Washing")
92 (defgroup gnus-article-emphasis nil
93 "Fontisizing articles."
94 :link '(custom-manual "(gnus)Article Fontisizing")
97 (defgroup gnus-article-saving nil
99 :link '(custom-manual "(gnus)Saving Articles")
100 :group 'gnus-article)
102 (defgroup gnus-article-mime nil
103 "Worshiping the MIME wonder."
104 :link '(custom-manual "(gnus)Using MIME")
105 :group 'gnus-article)
107 (defgroup gnus-article-buttons nil
108 "Pushable buttons in the article buffer."
109 :link '(custom-manual "(gnus)Article Buttons")
110 :group 'gnus-article)
112 (defgroup gnus-article-various nil
113 "Other article options."
114 :link '(custom-manual "(gnus)Misc Article")
115 :group 'gnus-article)
117 (defcustom gnus-ignored-headers
118 '("^Path:" "^Expires:" "^Date-Received:" "^References:" "^Xref:" "^Lines:"
119 "^Relay-Version:" "^Message-ID:" "^Approved:" "^Sender:" "^Received:"
120 "^X-UIDL:" "^MIME-Version:" "^Return-Path:" "^In-Reply-To:"
121 "^Content-Type:" "^Content-Transfer-Encoding:" "^X-WebTV-Signature:"
122 "^X-MimeOLE:" "^X-MSMail-Priority:" "^X-Priority:" "^X-Loop:"
123 "^X-Authentication-Warning:" "^X-MIME-Autoconverted:" "^X-Face:"
124 "^X-Attribution:" "^X-Originating-IP:" "^Delivered-To:"
125 "^NNTP-[-A-Za-z]+:" "^Distribution:" "^X-no-archive:" "^X-Trace:"
126 "^X-Complaints-To:" "^X-NNTP-Posting-Host:" "^X-Orig.*:"
127 "^Abuse-Reports-To:" "^Cache-Post-Path:" "^X-Article-Creation-Date:"
128 "^X-Poster:" "^X-Mail2News-Path:" "^X-Server-Date:" "^X-Cache:"
129 "^Originator:" "^X-Problems-To:" "^X-Auth-User:" "^X-Post-Time:"
130 "^X-Admin:" "^X-UID:" "^Resent-[-A-Za-z]+:" "^X-Mailing-List:"
131 "^Precedence:" "^Original-[-A-Za-z]+:" "^X-filename:" "^X-Orcpt:"
132 "^Old-Received:" "^X-Pgp" "^X-Auth:" "^X-From-Line:"
133 "^X-Gnus-Article-Number:" "^X-Majordomo:" "^X-Url:" "^X-Sender:"
134 "^MBOX-Line" "^Priority:" "^X400-[-A-Za-z]+:"
135 "^Status:" "^X-Gnus-Mail-Source:" "^Cancel-Lock:"
136 "^X-FTN" "^X-EXP32-SerialNo:" "^Encoding:" "^Importance:"
137 "^Autoforwarded:" "^Original-Encoded-Information-Types:" "^X-Ya-Pop3:"
138 "^X-Face-Version:" "^X-Vms-To:" "^X-ML-NAME:" "^X-ML-COUNT:"
139 "^Mailing-List:" "^X-finfo:" "^X-md5sum:" "^X-md5sum-Origin:"
140 "^X-Sun-Charset:" "^X-Accept-Language:" "^X-Envelope-Sender:"
141 "^List-[A-Za-z]+:" "^X-Listprocessor-Version:"
142 "^X-Received:" "^X-Distribute:" "^X-Sequence:" "^X-Juno-Line-Breaks:"
143 "^X-Notes-Item:" "^X-MS-TNEF-Correlator:" "^x-uunet-gateway:"
144 "^X-Received:" "^Content-length:" "X-precedence:"
145 "^X-Authenticated-User:" "^X-Comment" "^X-Report:" "^X-Abuse-Info:"
146 "^X-HTTP-Proxy:" "^X-Mydeja-Info:" "^X-Copyright" "^X-No-Markup:"
147 "^X-Abuse-Info:" "^X-From_:" "^X-Accept-Language:" "^Errors-To:"
148 "^X-BeenThere:" "^X-Mailman-Version:" "^List-Help:" "^List-Post:"
149 "^List-Subscribe:" "^List-Id:" "^List-Unsubscribe:" "^List-Archive:"
150 "^X-Content-length:" "^X-Posting-Agent:" "^Original-Received:")
151 "*All headers that start with this regexp will be hidden.
152 This variable can also be a list of regexps of headers to be ignored.
153 If `gnus-visible-headers' is non-nil, this variable will be ignored."
154 :type '(choice :custom-show nil
157 :group 'gnus-article-hiding)
159 (defcustom gnus-visible-headers
160 "^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:"
161 "*All headers that do not match this regexp will be hidden.
162 This variable can also be a list of regexp of headers to remain visible.
163 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
164 :type '(repeat :value-to-internal (lambda (widget value)
165 (custom-split-regexp-maybe value))
166 :match (lambda (widget value)
168 (widget-editable-list-match widget value)))
170 :group 'gnus-article-hiding)
172 (defcustom gnus-sorted-header-list
173 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
174 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
175 "*This variable is a list of regular expressions.
176 If it is non-nil, headers that match the regular expressions will
177 be placed first in the article buffer in the sequence specified by
179 :type '(repeat regexp)
180 :group 'gnus-article-hiding)
182 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
183 "Headers that are only to be displayed if they have interesting data.
184 Possible values in this list are:
186 'empty Headers with no content.
187 'newsgroups Newsgroup identical to Gnus group.
188 'to-address To identical to To-address.
189 'followup-to Followup-to identical to Newsgroups.
190 'reply-to Reply-to identical to From.
191 'date Date less than four days old.
192 'long-to To and/or Cc longer than 1024 characters.
193 'many-to Multiple To and/or Cc."
194 :type '(set (const :tag "Headers with no content." empty)
195 (const :tag "Newsgroups identical to Gnus group." newsgroups)
196 (const :tag "To identical to To-address." to-address)
197 (const :tag "Followup-to identical to Newsgroups." followup-to)
198 (const :tag "Reply-to identical to From." reply-to)
199 (const :tag "Date less than four days old." date)
200 (const :tag "To and/or Cc longer than 1024 characters." long-to)
201 (const :tag "Multiple To and/or Cc headers." many-to))
202 :group 'gnus-article-hiding)
204 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
205 "Regexp matching signature separator.
206 This can also be a list of regexps. In that case, it will be checked
207 from head to tail looking for a separator. Searches will be done from
208 the end of the buffer."
209 :type '(repeat string)
210 :group 'gnus-article-signature)
212 (defcustom gnus-signature-limit nil
213 "Provide a limit to what is considered a signature.
214 If it is a number, no signature may not be longer (in characters) than
215 that number. If it is a floating point number, no signature may be
216 longer (in lines) than that number. If it is a function, the function
217 will be called without any parameters, and if it returns nil, there is
218 no signature in the buffer. If it is a string, it will be used as a
219 regexp. If it matches, the text in question is not a signature."
220 :type '(choice (integer :value 200)
222 (function :value fun)
223 (regexp :value ".*"))
224 :group 'gnus-article-signature)
226 (defcustom gnus-hidden-properties '(invisible t intangible t)
227 "Property list to use for hiding text."
229 :group 'gnus-article-hiding)
231 ;; Fixme: This isn't the right thing for mixed graphical and and
232 ;; non-graphical frames in a session.
233 (defcustom gnus-article-x-face-command
236 (if (or (featurep 'xface)
238 'gnus-xmas-article-display-xface
239 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -"))
240 ((and (fboundp 'image-type-available-p)
241 (module-installed-p 'x-face-e21))
242 'x-face-decode-message-header)
243 ((and (fboundp 'image-type-available-p)
244 (image-type-available-p 'xbm))
245 'gnus-article-display-xface)
247 (module-installed-p 'x-face-mule))
248 'x-face-mule-gnus-article-display-x-face)
249 (gnus-article-compface-xbm
250 "{ echo '/* Width=48, Height=48 */'; uncompface; } | display -")
252 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
254 "*String or function to be executed to display an X-Face header.
255 If it is a string, the command will be executed in a sub-shell
256 asynchronously. The compressed face will be piped to this command."
258 ,@(let (x-face-e21 x-face-mule)
259 (if (featurep 'xemacs)
261 (setq x-face-e21 (module-installed-p 'x-face-e21)
262 x-face-mule (module-installed-p 'x-face-mule)))
266 (if (and (featurep 'xemacs)
267 (or (featurep 'xface)
269 '(function-item gnus-xmas-article-display-xface))
271 (fboundp 'image-type-available-p))
273 :tag "x-face-decode-message-header (x-face-e21)"
274 x-face-decode-message-header))
277 x-face-mule-gnus-article-display-x-face))
280 :group 'gnus-article-washing)
282 (defcustom gnus-article-x-face-too-ugly nil
283 "Regexp matching posters whose face shouldn't be shown automatically."
284 :type '(choice regexp (const nil))
285 :group 'gnus-article-washing)
287 (defcustom gnus-article-banner-alist nil
288 "Banner alist for stripping.
290 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
292 :type '(repeat (cons symbol regexp))
293 :group 'gnus-article-washing)
295 (gnus-define-group-parameter
298 "Alist of regexps (to match group names) and banner."
299 :variable-group gnus-article-washing
301 '(choice :tag "Banner"
303 (const :tag "Remove signature" signature)
304 (symbol :tag "Item in `gnus-article-banner-alist'" none)
306 (const :tag "None" nil))
308 "If non-nil, specify how to remove `banners' from articles.
310 Symbol `signature' means to remove signatures delimited by
311 `gnus-signature-separator'. Any other symbol is used to look up a
312 regular expression to match the banner in `gnus-article-banner-alist'.
313 A string is used as a regular expression to match the banner
316 (defcustom gnus-emphasis-alist
318 "\\(\\s-\\|^\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\s-\\|[-,;:\"]\\s-\\|[?!.]+\\s-\\|\\s)\\)")
320 '(("_" "_" underline)
323 ("_/" "/_" underline-italic)
324 ("_\\*" "\\*_" underline-bold)
325 ("\\*/" "/\\*" bold-italic)
326 ("_\\*/" "/\\*_" underline-bold-italic))))
327 `(("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
328 2 3 gnus-emphasis-underline)
332 (format format (car spec) (car (cdr spec)))
333 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
335 "*Alist that says how to fontify certain phrases.
336 Each item looks like this:
338 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
340 The first element is a regular expression to be matched. The second
341 is a number that says what regular expression grouping used to find
342 the entire emphasized word. The third is a number that says what
343 regexp grouping should be displayed and highlighted. The fourth
344 is the face used for highlighting."
345 :type '(repeat (list :value ("" 0 0 default)
347 (integer :tag "Match group")
348 (integer :tag "Emphasize group")
350 :group 'gnus-article-emphasis)
352 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
353 "A regexp to describe whitespace which should not be emphasized.
354 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
355 The former avoids underlining of leading and trailing whitespace,
356 and the latter avoids underlining any whitespace at all."
358 :group 'gnus-article-emphasis
361 (defface gnus-emphasis-bold '((t (:bold t)))
362 "Face used for displaying strong emphasized text (*word*)."
363 :group 'gnus-article-emphasis)
365 (defface gnus-emphasis-italic '((t (:italic t)))
366 "Face used for displaying italic emphasized text (/word/)."
367 :group 'gnus-article-emphasis)
369 (defface gnus-emphasis-underline '((t (:underline t)))
370 "Face used for displaying underlined emphasized text (_word_)."
371 :group 'gnus-article-emphasis)
373 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
374 "Face used for displaying underlined bold emphasized text (_*word*_)."
375 :group 'gnus-article-emphasis)
377 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
378 "Face used for displaying underlined italic emphasized text (_/word/_)."
379 :group 'gnus-article-emphasis)
381 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
382 "Face used for displaying bold italic emphasized text (/*word*/)."
383 :group 'gnus-article-emphasis)
385 (defface gnus-emphasis-underline-bold-italic
386 '((t (:bold t :italic t :underline t)))
387 "Face used for displaying underlined bold italic emphasized text.
388 Esample: (_/*word*/_)."
389 :group 'gnus-article-emphasis)
391 (defface gnus-emphasis-highlight-words
392 '((t (:background "black" :foreground "yellow")))
393 "Face used for displaying highlighted words."
394 :group 'gnus-article-emphasis)
396 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
397 "Format for display of Date headers in article bodies.
398 See `format-time-string' for the possible values.
400 The variable can also be function, which should return a complete Date
401 header. The function is called with one argument, the time, which can
402 be fed to `format-time-string'."
403 :type '(choice string symbol)
404 :link '(custom-manual "(gnus)Article Date")
405 :group 'gnus-article-washing)
408 (autoload 'mail-extract-address-components "mail-extr"))
410 (defcustom gnus-save-all-headers t
411 "*If non-nil, don't remove any headers before saving."
412 :group 'gnus-article-saving
415 (defcustom gnus-prompt-before-saving 'always
416 "*This variable says how much prompting is to be done when saving articles.
417 If it is nil, no prompting will be done, and the articles will be
418 saved to the default files. If this variable is `always', each and
419 every article that is saved will be preceded by a prompt, even when
420 saving large batches of articles. If this variable is neither nil not
421 `always', there the user will be prompted once for a file name for
422 each invocation of the saving commands."
423 :group 'gnus-article-saving
424 :type '(choice (item always)
425 (item :tag "never" nil)
426 (sexp :tag "once" :format "%t\n" :value t)))
428 (defcustom gnus-saved-headers gnus-visible-headers
429 "Headers to keep if `gnus-save-all-headers' is nil.
430 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
431 If that variable is nil, however, all headers that match this regexp
432 will be kept while the rest will be deleted before saving."
433 :group 'gnus-article-saving
436 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
437 "A function to save articles in your favourite format.
438 The function must be interactively callable (in other words, it must
439 be an Emacs command).
441 Gnus provides the following functions:
443 * gnus-summary-save-in-rmail (Rmail format)
444 * gnus-summary-save-in-mail (Unix mail format)
445 * gnus-summary-save-in-folder (MH folder)
446 * gnus-summary-save-in-file (article format)
447 * gnus-summary-save-body-in-file (article body)
448 * gnus-summary-save-in-vm (use VM's folder format)
449 * gnus-summary-write-to-file (article format -- overwrite)."
450 :group 'gnus-article-saving
451 :type '(radio (function-item gnus-summary-save-in-rmail)
452 (function-item gnus-summary-save-in-mail)
453 (function-item gnus-summary-save-in-folder)
454 (function-item gnus-summary-save-in-file)
455 (function-item gnus-summary-save-body-in-file)
456 (function-item gnus-summary-save-in-vm)
457 (function-item gnus-summary-write-to-file)))
459 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
460 "A function generating a file name to save articles in Rmail format.
461 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
462 :group 'gnus-article-saving
465 (defcustom gnus-mail-save-name 'gnus-plain-save-name
466 "A function generating a file name to save articles in Unix mail format.
467 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
468 :group 'gnus-article-saving
471 (defcustom gnus-folder-save-name 'gnus-folder-save-name
472 "A function generating a file name to save articles in MH folder.
473 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
474 :group 'gnus-article-saving
477 (defcustom gnus-file-save-name 'gnus-numeric-save-name
478 "A function generating a file name to save articles in article format.
479 The function is called with NEWSGROUP, HEADERS, and optional
481 :group 'gnus-article-saving
484 (defcustom gnus-split-methods
485 '((gnus-article-archive-name)
486 (gnus-article-nndoc-name))
487 "*Variable used to suggest where articles are to be saved.
488 For instance, if you would like to save articles related to Gnus in
489 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
490 you could set this variable to something like:
492 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
493 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
495 This variable is an alist where the where the key is the match and the
496 value is a list of possible files to save in if the match is non-nil.
498 If the match is a string, it is used as a regexp match on the
499 article. If the match is a symbol, that symbol will be funcalled
500 from the buffer of the article to be saved with the newsgroup as the
501 parameter. If it is a list, it will be evaled in the same buffer.
503 If this form or function returns a string, this string will be used as
504 a possible file name; and if it returns a non-nil list, that list will
505 be used as possible file names."
506 :group 'gnus-article-saving
507 :type '(repeat (choice (list :value (fun) function)
508 (cons :value ("" "") regexp (repeat string))
511 (defcustom gnus-article-display-method-for-mime
512 'gnus-article-display-mime-message
513 "Function to display a MIME message.
514 The function is called from the article buffer."
515 :group 'gnus-article-mime
518 (defcustom gnus-article-display-method-for-traditional
519 'gnus-article-display-traditional-message
520 "*Function to display a traditional message.
521 The function is called from the article buffer."
522 :group 'gnus-article-mime
525 (defcustom gnus-page-delimiter "^\^L"
526 "*Regexp describing what to use as article page delimiters.
527 The default value is \"^\^L\", which is a form linefeed at the
528 beginning of a line."
530 :group 'gnus-article-various)
532 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
533 "*The format specification for the article mode line.
534 See `gnus-summary-mode-line-format' for a closer description.
536 The following additional specs are available:
538 %w The article washing status.
539 %m The number of MIME parts in the article."
541 :group 'gnus-article-various)
543 (defcustom gnus-article-mode-hook nil
544 "*A hook for Gnus article mode."
546 :group 'gnus-article-various)
548 (when (featurep 'xemacs)
549 ;; Extracted from gnus-xmas-define in order to preserve user settings
550 (when (fboundp 'turn-off-scroll-in-place)
551 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
552 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
553 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
555 (defcustom gnus-article-menu-hook nil
556 "*Hook run after the creation of the article mode menu."
558 :group 'gnus-article-various)
560 (defcustom gnus-article-prepare-hook nil
561 "*A hook called after an article has been prepared in the article buffer."
563 :group 'gnus-article-various)
565 (defcustom gnus-article-hide-pgp-hook nil
566 "*A hook called after successfully hiding a PGP signature."
568 :group 'gnus-article-various)
570 (defcustom gnus-article-button-face 'bold
571 "Face used for highlighting buttons in the article buffer.
573 An article button is a piece of text that you can activate by pressing
574 `RET' or `mouse-2' above it."
576 :group 'gnus-article-buttons)
578 (defcustom gnus-article-mouse-face 'highlight
579 "Face used for mouse highlighting in the article buffer.
581 Article buttons will be displayed in this face when the cursor is
584 :group 'gnus-article-buttons)
586 (defcustom gnus-signature-face 'gnus-signature-face
587 "Face used for highlighting a signature in the article buffer.
588 Obsolete; use the face `gnus-signature-face' for customizations instead."
590 :group 'gnus-article-highlight
591 :group 'gnus-article-signature)
593 (defface gnus-signature-face
596 "Face used for highlighting a signature in the article buffer."
597 :group 'gnus-article-highlight
598 :group 'gnus-article-signature)
600 (defface gnus-header-from-face
603 (:foreground "spring green"))
606 (:foreground "red3"))
609 "Face used for displaying from headers."
610 :group 'gnus-article-headers
611 :group 'gnus-article-highlight)
613 (defface gnus-header-subject-face
616 (:foreground "SeaGreen3"))
619 (:foreground "red4"))
621 (:bold t :italic t)))
622 "Face used for displaying subject headers."
623 :group 'gnus-article-headers
624 :group 'gnus-article-highlight)
626 (defface gnus-header-newsgroups-face
629 (:foreground "yellow" :italic t))
632 (:foreground "MidnightBlue" :italic t))
635 "Face used for displaying newsgroups headers."
636 :group 'gnus-article-headers
637 :group 'gnus-article-highlight)
639 (defface gnus-header-name-face
642 (:foreground "SeaGreen"))
645 (:foreground "maroon"))
648 "Face used for displaying header names."
649 :group 'gnus-article-headers
650 :group 'gnus-article-highlight)
652 (defface gnus-header-content-face
655 (:foreground "forest green" :italic t))
658 (:foreground "indianred4" :italic t))
661 "Face used for displaying header content."
662 :group 'gnus-article-headers
663 :group 'gnus-article-highlight)
665 (defcustom gnus-header-face-alist
666 '(("From" nil gnus-header-from-face)
667 ("Subject" nil gnus-header-subject-face)
668 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
669 ("" gnus-header-name-face gnus-header-content-face))
670 "*Controls highlighting of article header.
672 An alist of the form (HEADER NAME CONTENT).
674 HEADER is a regular expression which should match the name of an
675 header header and NAME and CONTENT are either face names or nil.
677 The name of each header field will be displayed using the face
678 specified by the first element in the list where HEADER match the
679 header name and NAME is non-nil. Similarly, the content will be
680 displayed by the first non-nil matching CONTENT face."
681 :group 'gnus-article-headers
682 :group 'gnus-article-highlight
683 :type '(repeat (list (regexp :tag "Header")
685 (item :tag "skip" nil)
686 (face :value default))
687 (choice :tag "Content"
688 (item :tag "skip" nil)
689 (face :value default)))))
691 (defcustom gnus-article-decode-hook nil
692 "*Hook run to decode charsets in articles."
693 :group 'gnus-article-headers
696 (defcustom gnus-display-mime-function 'gnus-display-mime
697 "Function to display MIME articles."
698 :group 'gnus-article-mime
701 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
702 "Function used to decode headers.")
704 (defvar gnus-article-dumbquotes-map
723 "Table for MS-to-Latin1 translation.")
725 (defcustom gnus-ignored-mime-types nil
726 "List of MIME types that should be ignored by Gnus."
728 :group 'gnus-article-mime
729 :type '(repeat regexp))
731 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
732 "List of MIME types that should not be given buttons when rendered inline.
733 See also `gnus-buttonized-mime-types' which may override this variable."
735 :group 'gnus-article-mime
736 :type '(repeat regexp))
738 (defcustom gnus-buttonized-mime-types nil
739 "List of MIME types that should be given buttons when rendered inline.
740 If set, this variable overrides `gnus-unbuttonized-mime-types'.
741 To see e.g. security buttons you could set this to
742 `(\"multipart/signed\")'."
744 :group 'gnus-article-mime
745 :type '(repeat regexp))
747 (defcustom gnus-article-mime-part-function nil
748 "Function called with a MIME handle as the argument.
749 This is meant for people who want to do something automatic based
750 on parts -- for instance, adding Vcard info to a database."
751 :group 'gnus-article-mime
754 (defcustom gnus-mime-multipart-functions nil
755 "An alist of MIME types to functions to display them."
757 :group 'gnus-article-mime
760 (defcustom gnus-article-date-lapsed-new-header nil
761 "Whether the X-Sent and Date headers can coexist.
762 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
763 either replace the old \"Date:\" header (if this variable is nil), or
764 be added below it (otherwise)."
766 :group 'gnus-article-headers
769 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
770 "Function called with a MIME handle as the argument.
771 This is meant for people who want to view first matched part.
772 For `undisplayed-alternative' (default), the first undisplayed
773 part or alternative part is used. For `undisplayed', the first
774 undisplayed part is used. For a function, the first part which
775 the function return `t' is used. For `nil', the first part is
778 :group 'gnus-article-mime
780 (item :tag "first" :value nil)
781 (item :tag "undisplayed" :value undisplayed)
782 (item :tag "undisplayed or alternative"
783 :value undisplayed-alternative)
786 (defcustom gnus-mime-action-alist
787 '(("save to file" . gnus-mime-save-part)
788 ("save and strip" . gnus-mime-save-part-and-strip)
789 ("display as text" . gnus-mime-inline-part)
790 ("view the part" . gnus-mime-view-part)
791 ("pipe to command" . gnus-mime-pipe-part)
792 ("toggle display" . gnus-article-press-button)
793 ("toggle display" . gnus-article-view-part-as-charset)
794 ("view as type" . gnus-mime-view-part-as-type)
795 ("internalize type" . gnus-mime-internalize-part)
796 ("externalize type" . gnus-mime-externalize-part))
797 "An alist of actions that run on the MIME attachment."
798 :group 'gnus-article-mime
799 :type '(repeat (cons (string :tag "name")
802 (defcustom gnus-mime-action-alist
803 '(("save to file" . gnus-mime-save-part)
804 ("display as text" . gnus-mime-inline-part)
805 ("view the part" . gnus-mime-view-part)
806 ("pipe to command" . gnus-mime-pipe-part)
807 ("toggle display" . gnus-article-press-button)
808 ("view as type" . gnus-mime-view-part-as-type)
809 ("internalize type" . gnus-mime-internalize-part)
810 ("externalize type" . gnus-mime-externalize-part))
811 "An alist of actions that run on the MIME attachment."
813 :group 'gnus-article-mime
814 :type '(repeat (cons (string :tag "name")
818 ;;; The treatment variables
821 (defvar gnus-part-display-hook nil
822 "Hook called on parts that are to receive treatment.")
824 (defvar gnus-article-treat-custom
825 '(choice (const :tag "Off" nil)
827 (const :tag "Header" head)
828 (const :tag "Last" last)
829 (const :tag "Mime" mime)
830 (integer :tag "Less")
831 (repeat :tag "Groups" regexp)
832 (sexp :tag "Predicate")))
834 (defvar gnus-article-treat-head-custom
835 '(choice (const :tag "Off" nil)
836 (const :tag "Header" head)))
838 (defvar gnus-article-treat-types '("text/plain")
841 (defvar gnus-inhibit-treatment nil
842 "Whether to inhibit treatment.")
844 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
845 "Highlight the signature.
846 Valid values are nil, t, `head', `last', an integer or a predicate.
847 See Info node `(gnus)Customizing Articles'."
848 :group 'gnus-article-treat
849 :type gnus-article-treat-custom)
850 (put 'gnus-treat-highlight-signature 'highlight t)
852 (defcustom gnus-treat-buttonize 100000
854 Valid values are nil, t, `head', `last', an integer or a predicate.
855 See the manual for details."
856 :group 'gnus-article-treat
857 :type gnus-article-treat-custom)
858 (put 'gnus-treat-buttonize 'highlight t)
860 (defcustom gnus-treat-buttonize-head 'head
861 "Add buttons to the head.
862 Valid values are nil, t, `head', `last', an integer or a predicate.
863 See the manual for details."
864 :group 'gnus-article-treat
865 :type gnus-article-treat-head-custom)
866 (put 'gnus-treat-buttonize-head 'highlight t)
868 (defcustom gnus-treat-emphasize
869 (and (or window-system
871 (>= (string-to-number emacs-version) 21))
874 Valid values are nil, t, `head', `last', an integer or a predicate.
875 See the manual for details."
876 :group 'gnus-article-treat
877 :type gnus-article-treat-custom)
878 (put 'gnus-treat-emphasize 'highlight t)
880 (defcustom gnus-treat-strip-cr nil
881 "Remove carriage returns.
882 Valid values are nil, t, `head', `last', an integer or a predicate.
883 See the manual for details."
884 :group 'gnus-article-treat
885 :type gnus-article-treat-custom)
887 (defcustom gnus-treat-leading-whitespace nil
888 "Remove leading whitespace in headers.
889 Valid values are nil, t, `head', `last', an integer or a predicate.
890 See the manual for details."
891 :group 'gnus-article-treat
892 :type gnus-article-treat-custom)
894 (defcustom gnus-treat-hide-headers 'head
896 Valid values are nil, t, `head', `last', an integer or a predicate.
897 See the manual for details."
898 :group 'gnus-article-treat
899 :type gnus-article-treat-head-custom)
901 (defcustom gnus-treat-hide-boring-headers nil
902 "Hide boring headers.
903 Valid values are nil, t, `head', `last', an integer or a predicate.
904 See the manual for details."
905 :group 'gnus-article-treat
906 :type gnus-article-treat-head-custom)
908 (defcustom gnus-treat-hide-signature nil
910 Valid values are nil, t, `head', `last', an integer or a predicate.
911 See the manual for details."
912 :group 'gnus-article-treat
913 :type gnus-article-treat-custom)
915 (defcustom gnus-treat-fill-article nil
917 Valid values are nil, t, `head', `last', an integer or a predicate.
918 See the manual for details."
919 :group 'gnus-article-treat
920 :type gnus-article-treat-custom)
922 (defcustom gnus-treat-hide-citation nil
924 Valid values are nil, t, `head', `last', an integer or a predicate.
925 See the manual for details."
926 :group 'gnus-article-treat
927 :type gnus-article-treat-custom)
929 (defcustom gnus-treat-hide-citation-maybe nil
931 Valid values are nil, t, `head', `last', an integer or a predicate.
932 See the manual for details."
933 :group 'gnus-article-treat
934 :type gnus-article-treat-custom)
936 (defcustom gnus-treat-strip-list-identifiers 'head
937 "Strip list identifiers from `gnus-list-identifiers`.
938 Valid values are nil, t, `head', `last', an integer or a predicate.
939 See the manual for details."
941 :group 'gnus-article-treat
942 :type gnus-article-treat-custom)
944 (defcustom gnus-treat-strip-pgp t
945 "Strip PGP signatures.
946 Valid values are nil, t, `head', `last', an integer or a predicate.
947 See the manual for details."
948 :group 'gnus-article-treat
949 :type gnus-article-treat-custom)
951 (defcustom gnus-treat-strip-pem nil
952 "Strip PEM signatures.
953 Valid values are nil, t, `head', `last', an integer or a predicate.
954 See the manual for details."
955 :group 'gnus-article-treat
956 :type gnus-article-treat-custom)
958 (defcustom gnus-treat-strip-banner t
959 "Strip banners from articles.
960 The banner to be stripped is specified in the `banner' group parameter.
961 Valid values are nil, t, `head', `last', an integer or a predicate.
962 See the manual for details."
963 :group 'gnus-article-treat
964 :type gnus-article-treat-custom)
966 (defcustom gnus-treat-highlight-headers 'head
967 "Highlight the headers.
968 Valid values are nil, t, `head', `last', an integer or a predicate.
969 See the manual for details."
970 :group 'gnus-article-treat
971 :type gnus-article-treat-head-custom)
972 (put 'gnus-treat-highlight-headers 'highlight t)
974 (defcustom gnus-treat-highlight-citation t
975 "Highlight cited text.
976 Valid values are nil, t, `head', `last', an integer or a predicate.
977 See the manual for details."
978 :group 'gnus-article-treat
979 :type gnus-article-treat-custom)
980 (put 'gnus-treat-highlight-citation 'highlight t)
982 (defcustom gnus-treat-date-ut nil
983 "Display the Date in UT (GMT).
984 Valid values are nil, t, `head', `last', an integer or a predicate.
985 See the manual for details."
986 :group 'gnus-article-treat
987 :type gnus-article-treat-head-custom)
989 (defcustom gnus-treat-date-local nil
990 "Display the Date in the local timezone.
991 Valid values are nil, t, `head', `last', an integer or a predicate.
992 See the manual for details."
993 :group 'gnus-article-treat
994 :type gnus-article-treat-head-custom)
996 (defcustom gnus-treat-date-english nil
997 "Display the Date in a format that can be read aloud in English.
998 Valid values are nil, t, `head', `last', an integer or a predicate.
999 See the manual for details."
1000 :group 'gnus-article-treat
1001 :type gnus-article-treat-head-custom)
1003 (defcustom gnus-treat-date-lapsed nil
1004 "Display the Date header in a way that says how much time has elapsed.
1005 Valid values are nil, t, `head', `last', an integer or a predicate.
1006 See the manual for details."
1007 :group 'gnus-article-treat
1008 :type gnus-article-treat-head-custom)
1010 (defcustom gnus-treat-date-original nil
1011 "Display the date in the original timezone.
1012 Valid values are nil, t, `head', `last', an integer or a predicate.
1013 See the manual for details."
1014 :group 'gnus-article-treat
1015 :type gnus-article-treat-head-custom)
1017 (defcustom gnus-treat-date-iso8601 nil
1018 "Display the date in the ISO8601 format.
1019 Valid values are nil, t, `head', `last', an integer or a predicate.
1020 See the manual for details."
1022 :group 'gnus-article-treat
1023 :type gnus-article-treat-head-custom)
1025 (defcustom gnus-treat-date-user-defined nil
1026 "Display the date in a user-defined format.
1027 The format is defined by the `gnus-article-time-format' variable.
1028 Valid values are nil, t, `head', `last', an integer or a predicate.
1029 See the manual for details."
1030 :group 'gnus-article-treat
1031 :type gnus-article-treat-head-custom)
1033 (defcustom gnus-treat-strip-headers-in-body t
1034 "Strip the X-No-Archive header line from the beginning of the body.
1035 Valid values are nil, t, `head', `last', an integer or a predicate.
1036 See the manual for details."
1038 :group 'gnus-article-treat
1039 :type gnus-article-treat-custom)
1041 (defcustom gnus-treat-strip-trailing-blank-lines nil
1042 "Strip trailing blank lines.
1043 Valid values are nil, t, `head', `last', an integer or a predicate.
1044 See the manual for details."
1045 :group 'gnus-article-treat
1046 :type gnus-article-treat-custom)
1048 (defcustom gnus-treat-strip-leading-blank-lines nil
1049 "Strip leading blank lines.
1050 Valid values are nil, t, `head', `last', an integer or a predicate.
1051 See the manual for details."
1052 :group 'gnus-article-treat
1053 :type gnus-article-treat-custom)
1055 (defcustom gnus-treat-strip-multiple-blank-lines nil
1056 "Strip multiple blank lines.
1057 Valid values are nil, t, `head', `last', an integer or a predicate.
1058 See the manual for details."
1059 :group 'gnus-article-treat
1060 :type gnus-article-treat-custom)
1062 (defcustom gnus-treat-overstrike t
1063 "Treat overstrike highlighting.
1064 Valid values are nil, t, `head', `last', an integer or a predicate.
1065 See the manual for details."
1066 :group 'gnus-article-treat
1067 :type gnus-article-treat-custom)
1068 (put 'gnus-treat-overstrike 'highlight t)
1070 (defcustom gnus-treat-display-xface
1071 (and (or (and (fboundp 'image-type-available-p)
1072 (image-type-available-p 'xbm)
1073 (string-match "^0x" (shell-command-to-string "uncompface")))
1074 (and (featurep 'xemacs) (featurep 'xface))
1075 (eq 'x-face-mule-gnus-article-display-x-face
1076 gnus-article-x-face-command))
1078 "Display X-Face headers.
1079 Valid values are nil, t, `head', `last', an integer or a predicate.
1080 See the manual for details."
1081 :group 'gnus-article-treat
1083 :type gnus-article-treat-head-custom)
1084 (put 'gnus-treat-display-xface 'highlight t)
1086 (defcustom gnus-treat-display-smileys
1087 (if (or (and (featurep 'xemacs)
1089 (and (fboundp 'image-type-available-p)
1090 (image-type-available-p 'pbm))
1091 (and (not (featurep 'xemacs))
1093 (module-installed-p 'smiley-mule)))
1097 Valid values are nil, t, `head', `last', an integer or a predicate.
1098 See the manual for details."
1099 :group 'gnus-article-treat
1101 :type gnus-article-treat-custom)
1102 (put 'gnus-treat-display-smileys 'highlight t)
1104 (defcustom gnus-treat-display-picons (if (featurep 'xemacs) 'head nil)
1106 Valid values are nil, t, `head', `last', an integer or a predicate.
1107 See the manual for details."
1108 :group 'gnus-article-treat
1109 :type gnus-article-treat-head-custom)
1110 (put 'gnus-treat-display-picons 'highlight t)
1112 (defcustom gnus-treat-capitalize-sentences nil
1113 "Capitalize sentence-starting words.
1114 Valid values are nil, t, `head', `last', an integer or a predicate.
1115 See the manual for details."
1117 :group 'gnus-article-treat
1118 :type gnus-article-treat-custom)
1120 (defcustom gnus-treat-fill-long-lines nil
1122 Valid values are nil, t, `head', `last', an integer or a predicate.
1123 See the manual for details."
1124 :group 'gnus-article-treat
1125 :type gnus-article-treat-custom)
1127 (defcustom gnus-treat-play-sounds nil
1129 Valid values are nil, t, `head', `last', an integer or a predicate.
1130 See the manual for details."
1132 :group 'gnus-article-treat
1133 :type gnus-article-treat-custom)
1135 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
1136 "Decode an article as `default-mime-charset'. For instance, if you want to
1137 attempt to decode an article even if the value of `gnus-show-mime' is nil,
1138 you could set this variable to something like: nil for don't decode, t for
1139 decode the body, '(or header t) for the whole article, etc."
1140 :group 'gnus-article-treat
1141 :type '(radio (const :tag "Off" nil)
1142 (const :tag "Decode body" t)
1143 (const :tag "Decode all" (or head t))))
1145 (defcustom gnus-treat-translate nil
1146 "Translate articles from one language to another.
1147 Valid values are nil, t, `head', `last', an integer or a predicate.
1148 See the manual for details."
1150 :group 'gnus-article-treat
1151 :type gnus-article-treat-custom)
1153 (defcustom gnus-treat-x-pgp-sig nil
1155 To automatically treat X-PGP-Sig, set it to head.
1156 Valid values are nil, t, `head', `last', an integer or a predicate.
1157 See the manual for details."
1158 :group 'gnus-article-treat
1159 :group 'mime-security
1160 :type gnus-article-treat-custom)
1162 (defvar gnus-article-encrypt-protocol-alist
1163 '(("PGP" . mml2015-self-encrypt)))
1165 ;; Set to nil if more than one protocol added to
1166 ;; gnus-article-encrypt-protocol-alist.
1167 (defcustom gnus-article-encrypt-protocol "PGP"
1168 "The protocol used for encrypt articles.
1169 It is a string, such as \"PGP\". If nil, ask user."
1171 :group 'mime-security)
1173 ;;; Internal variables
1175 (defvar gnus-english-month-names
1176 '("January" "February" "March" "April" "May" "June" "July" "August"
1177 "September" "October" "November" "December"))
1179 (defvar article-goto-body-goes-to-point-min-p nil)
1180 (defvar gnus-article-wash-types nil)
1181 (defvar gnus-article-emphasis-alist nil)
1183 (defvar gnus-article-mime-handle-alist-1 nil)
1184 (defvar gnus-treatment-function-alist
1185 `((gnus-treat-decode-article-as-default-mime-charset
1186 gnus-article-decode-article-as-default-mime-charset)
1187 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1188 (gnus-treat-strip-banner gnus-article-strip-banner)
1189 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1190 (gnus-treat-buttonize gnus-article-add-buttons)
1191 (gnus-treat-fill-article gnus-article-fill-cited-article)
1192 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1193 (gnus-treat-strip-cr gnus-article-remove-cr)
1194 (gnus-treat-display-xface gnus-article-display-x-face)
1195 (gnus-treat-date-ut gnus-article-date-ut)
1196 (gnus-treat-date-local gnus-article-date-local)
1197 (gnus-treat-date-english gnus-article-date-english)
1198 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1199 (gnus-treat-date-original gnus-article-date-original)
1200 (gnus-treat-date-user-defined gnus-article-date-user)
1201 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1202 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1203 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1204 (gnus-treat-hide-signature gnus-article-hide-signature)
1205 (gnus-treat-hide-citation gnus-article-hide-citation)
1206 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1207 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1208 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1209 (gnus-treat-strip-pgp gnus-article-hide-pgp)
1210 (gnus-treat-strip-pem gnus-article-hide-pem)
1211 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1212 (gnus-treat-emphasize gnus-article-emphasize)
1213 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1214 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1215 (gnus-treat-strip-trailing-blank-lines
1216 gnus-article-remove-trailing-blank-lines)
1217 (gnus-treat-strip-leading-blank-lines
1218 gnus-article-strip-leading-blank-lines)
1219 (gnus-treat-strip-multiple-blank-lines
1220 gnus-article-strip-multiple-blank-lines)
1221 (gnus-treat-overstrike gnus-article-treat-overstrike)
1222 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1223 (gnus-treat-display-smileys ,(if (or (featurep 'xemacs)
1224 (>= emacs-major-version 21))
1225 'gnus-smiley-display
1226 'gnus-article-smiley-display))
1227 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1228 (gnus-treat-display-picons gnus-article-display-picons)
1229 (gnus-treat-play-sounds gnus-earcon-display)))
1231 (defvar gnus-article-mime-handle-alist nil)
1232 (defvar article-lapsed-timer nil)
1233 (defvar gnus-article-current-summary nil)
1235 (defvar gnus-article-mode-syntax-table
1236 (let ((table (copy-syntax-table text-mode-syntax-table)))
1237 ;; This causes the citation match run O(2^n).
1238 ;; (modify-syntax-entry ?- "w" table)
1239 (modify-syntax-entry ?> ")" table)
1240 (modify-syntax-entry ?< "(" table)
1242 "Syntax table used in article mode buffers.
1243 Initialized from `text-mode-syntax-table.")
1245 (defvar gnus-save-article-buffer nil)
1247 (defvar gnus-article-mode-line-format-alist
1248 (nconc '((?w (gnus-article-wash-status) ?s)
1249 (?m (gnus-article-mime-part-status) ?s))
1250 gnus-summary-mode-line-format-alist))
1252 (defvar gnus-number-of-articles-to-be-saved nil)
1254 (defvar gnus-inhibit-hiding nil)
1256 (defsubst gnus-article-hide-text (b e props)
1257 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1258 (gnus-add-text-properties-when 'article-type nil b e props)
1259 (when (memq 'intangible props)
1261 (max (1- b) (point-min))
1262 b 'intangible (cddr (memq 'intangible props)))))
1264 (defsubst gnus-article-unhide-text (b e)
1265 "Remove hidden text properties from region between B and E."
1266 (remove-text-properties b e gnus-hidden-properties)
1267 (when (memq 'intangible gnus-hidden-properties)
1268 (put-text-property (max (1- b) (point-min))
1269 b 'intangible nil)))
1271 (defun gnus-article-hide-text-type (b e type)
1272 "Hide text of TYPE between B and E."
1273 (push type gnus-article-wash-types)
1274 (gnus-article-hide-text
1275 b e (cons 'article-type (cons type gnus-hidden-properties))))
1277 (defun gnus-article-unhide-text-type (b e type)
1278 "Unhide text of TYPE between B and E."
1279 (setq gnus-article-wash-types
1280 (delq type gnus-article-wash-types))
1281 (remove-text-properties
1282 b e (cons 'article-type (cons type gnus-hidden-properties)))
1283 (when (memq 'intangible gnus-hidden-properties)
1284 (put-text-property (max (1- b) (point-min))
1285 b 'intangible nil)))
1287 (defun gnus-article-hide-text-of-type (type)
1288 "Hide text of TYPE in the current buffer."
1290 (let ((b (point-min))
1292 (while (setq b (text-property-any b e 'article-type type))
1293 (add-text-properties b (incf b) gnus-hidden-properties)))))
1295 (defun gnus-article-delete-text-of-type (type)
1296 "Delete text of TYPE in the current buffer."
1298 (let ((b (point-min)))
1299 (while (setq b (text-property-any b (point-max) 'article-type type))
1301 b (or (text-property-not-all b (point-max) 'article-type type)
1304 (defun gnus-article-delete-invisible-text ()
1305 "Delete all invisible text in the current buffer."
1307 (let ((b (point-min)))
1308 (while (setq b (text-property-any b (point-max) 'invisible t))
1310 b (or (text-property-not-all b (point-max) 'invisible t)
1313 (defun gnus-article-text-type-exists-p (type)
1314 "Say whether any text of type TYPE exists in the buffer."
1315 (text-property-any (point-min) (point-max) 'article-type type))
1317 (defsubst gnus-article-header-rank ()
1318 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1319 (let ((list gnus-sorted-header-list)
1322 (when (looking-at (car list))
1324 (setq list (cdr list))
1328 (defun article-hide-headers (&optional arg delete)
1329 "Hide unwanted headers and possibly sort them as well."
1330 (interactive (gnus-article-hidden-arg))
1331 ;; Lars said that this function might be inhibited.
1332 (if (gnus-article-check-hidden-text 'headers arg)
1334 ;; Show boring headers as well.
1335 (gnus-article-show-hidden-text 'boring-headers)
1336 (when (eq 1 (point-min))
1337 (set-window-start (get-buffer-window (current-buffer)) 1)))
1338 (unless gnus-inhibit-hiding
1341 (let ((inhibit-read-only t)
1342 (case-fold-search t)
1343 (max (1+ (length gnus-sorted-header-list)))
1344 (ignored (when (not gnus-visible-headers)
1345 (cond ((stringp gnus-ignored-headers)
1346 gnus-ignored-headers)
1347 ((listp gnus-ignored-headers)
1348 (mapconcat 'identity gnus-ignored-headers
1351 (cond ((stringp gnus-visible-headers)
1352 gnus-visible-headers)
1353 ((and gnus-visible-headers
1354 (listp gnus-visible-headers))
1355 (mapconcat 'identity gnus-visible-headers "\\|"))))
1356 (inhibit-point-motion-hooks t)
1358 ;; First we narrow to just the headers.
1359 (article-narrow-to-head)
1360 ;; Hide any "From " lines at the beginning of (mail) articles.
1361 (while (looking-at "From ")
1365 (delete-region (point-min) (point))
1366 (gnus-article-hide-text (point-min) (point)
1367 (nconc (list 'article-type 'headers)
1368 gnus-hidden-properties))))
1369 ;; Then treat the rest of the header lines.
1370 ;; Then we use the two regular expressions
1371 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1372 ;; select which header lines is to remain visible in the
1374 (while (re-search-forward "^[^ \t:]*:" nil t)
1376 ;; Mark the rank of the header.
1378 (point) (1+ (point)) 'message-rank
1379 (if (or (and visible (looking-at visible))
1381 (not (looking-at ignored))))
1382 (gnus-article-header-rank)
1385 (message-sort-headers-1)
1386 (when (setq beg (text-property-any
1387 (point-min) (point-max) 'message-rank (+ 2 max)))
1388 ;; We delete or make invisible the unwanted headers.
1389 (push 'headers gnus-article-wash-types)
1392 (add-text-properties
1393 (point-min) (+ 5 (point-min))
1394 '(article-type headers dummy-invisible t))
1395 (delete-region beg (point-max)))
1396 (gnus-article-hide-text-type beg (point-max) 'headers))))))))
1399 (defun article-hide-boring-headers (&optional arg)
1400 "Toggle hiding of headers that aren't very interesting.
1401 If given a negative prefix, always show; if given a positive prefix,
1403 (interactive (gnus-article-hidden-arg))
1404 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1405 (not gnus-show-all-headers))
1408 (let ((buffer-read-only nil)
1409 (list gnus-boring-article-headers)
1410 (inhibit-point-motion-hooks t)
1412 (article-narrow-to-head)
1414 (setq elem (pop list))
1415 (goto-char (point-min))
1417 ;; Hide empty headers.
1419 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1421 (gnus-article-hide-text-type
1422 (progn (beginning-of-line) (point))
1425 (if (re-search-forward "^[^ \t]" nil t)
1429 ;; Hide boring Newsgroups header.
1430 ((eq elem 'newsgroups)
1431 (when (gnus-string-equal
1432 (gnus-fetch-field "newsgroups")
1433 (gnus-group-real-name
1434 (if (boundp 'gnus-newsgroup-name)
1437 (gnus-article-hide-header "newsgroups")))
1438 ((eq elem 'to-address)
1439 (let ((to (message-fetch-field "to"))
1441 (gnus-parameter-to-address
1442 (if (boundp 'gnus-newsgroup-name)
1443 gnus-newsgroup-name ""))))
1444 (when (and to to-address
1447 ;; only one address in To
1448 (nth 1 (mail-extract-address-components to))
1450 (gnus-article-hide-header "to"))))
1451 ((eq elem 'followup-to)
1452 (when (gnus-string-equal
1453 (message-fetch-field "followup-to")
1454 (message-fetch-field "newsgroups"))
1455 (gnus-article-hide-header "followup-to")))
1456 ((eq elem 'reply-to)
1457 (let ((from (message-fetch-field "from"))
1458 (reply-to (message-fetch-field "reply-to")))
1463 (nth 1 (mail-extract-address-components from))
1464 (nth 1 (mail-extract-address-components reply-to)))))
1465 (gnus-article-hide-header "reply-to"))))
1467 (let ((date (message-fetch-field "date")))
1469 (< (days-between (current-time-string) date)
1471 (gnus-article-hide-header "date"))))
1473 (let ((to (message-fetch-field "to"))
1474 (cc (message-fetch-field "cc")))
1475 (when (> (length to) 1024)
1476 (gnus-article-hide-header "to"))
1477 (when (> (length cc) 1024)
1478 (gnus-article-hide-header "cc"))))
1482 (goto-char (point-min))
1483 (while (re-search-forward "^to:" nil t)
1484 (setq to-count (1+ to-count)))
1485 (when (> to-count 1)
1486 (while (> to-count 0)
1487 (goto-char (point-min))
1489 (re-search-forward "^to:" nil nil to-count)
1491 (narrow-to-region (point) (point-max))
1492 (gnus-article-hide-header "to"))
1493 (setq to-count (1- to-count))))
1494 (goto-char (point-min))
1495 (while (re-search-forward "^cc:" nil t)
1496 (setq cc-count (1+ cc-count)))
1497 (when (> cc-count 1)
1498 (while (> cc-count 0)
1499 (goto-char (point-min))
1501 (re-search-forward "^cc:" nil nil cc-count)
1503 (narrow-to-region (point) (point-max))
1504 (gnus-article-hide-header "cc"))
1505 (setq cc-count (1- cc-count)))))))))))))
1507 (defun gnus-article-hide-header (header)
1509 (goto-char (point-min))
1510 (when (re-search-forward (concat "^" header ":") nil t)
1511 (gnus-article-hide-text-type
1512 (progn (beginning-of-line) (point))
1515 (if (re-search-forward "^[^ \t]" nil t)
1520 (defun article-toggle-headers (&optional arg)
1521 "Toggle hiding of headers. If given a negative prefix, always show;
1522 if given a positive prefix, always hide."
1523 (interactive (gnus-article-hidden-arg))
1524 (let ((force (when (numberp arg)
1525 (cond ((> arg 0) 'always-hide)
1526 ((< arg 0) 'always-show))))
1527 (window (get-buffer-window gnus-article-buffer))
1528 (header-end (point-min))
1529 header-start field-end field-start
1530 (inhibit-point-motion-hooks t)
1531 (inhibit-read-only t))
1534 (while (and (setq header-start
1535 (text-property-any header-end (point-max)
1536 'article-treated-header t))
1538 (text-property-not-all header-start (point-max)
1539 'article-treated-header t)))
1540 (setq field-end header-start)
1542 (;; Hide exposed invisible fields.
1543 (and (not (eq 'always-show force))
1545 (text-property-any field-end header-end
1546 'exposed-invisible-field t)))
1547 (while (and field-start
1548 (setq field-end (text-property-not-all
1549 field-start header-end
1550 'exposed-invisible-field t)))
1551 (add-text-properties field-start field-end gnus-hidden-properties)
1552 (setq field-start (text-property-any field-end header-end
1553 'exposed-invisible-field t)))
1554 (put-text-property header-start header-end
1555 'exposed-invisible-field nil))
1556 (;; Expose invisible fields.
1557 (and (not (eq 'always-hide force))
1559 (text-property-any field-end header-end 'invisible t)))
1560 (while (and field-start
1561 (setq field-end (text-property-not-all
1562 field-start header-end
1564 ;; If the invisible text is not terminated with newline, we
1565 ;; won't expose it. Because it may be created by x-face-mule.
1566 ;; BTW, XEmacs sometimes fail in putting a invisible text
1567 ;; property with `gnus-article-hide-text' (really?). In that
1568 ;; case, the invisible text might be started from the middle of
1569 ;; a line so we will expose the sort of thing.
1570 (when (or (not (or (eq header-start field-start)
1571 (eq ?\n (char-before field-start))))
1572 (eq ?\n (char-before field-end)))
1573 (remove-text-properties field-start field-end
1574 gnus-hidden-properties)
1575 (put-text-property field-start field-end
1576 'exposed-invisible-field t))
1577 (setq field-start (text-property-any field-end header-end
1580 (not (eq 'always-show force))
1581 (narrow-to-region header-start header-end)
1582 (article-hide-headers)
1583 ;; Re-display X-Face image under XEmacs.
1584 (when (and (featurep 'xemacs)
1585 (gnus-functionp gnus-article-x-face-command))
1586 (let ((func (cadr (assq 'gnus-treat-display-xface
1587 gnus-treatment-function-alist)))
1589 (when (and (not gnus-inhibit-treatment)
1591 (gnus-treat-predicate gnus-treat-display-xface))
1593 (put-text-property header-start header-end 'read-only nil))))
1596 (goto-char (point-min))
1598 (set-window-start window (point-min))))))
1600 (defvar gnus-article-normalized-header-length 40
1601 "Length of normalized headers.")
1603 (defun article-normalize-headers ()
1604 "Make all header lines 40 characters long."
1606 (let ((buffer-read-only nil)
1610 (article-narrow-to-head)
1613 ((< (setq column (- (gnus-point-at-eol) (point)))
1614 gnus-article-normalized-header-length)
1616 (insert (make-string
1617 (- gnus-article-normalized-header-length column)
1619 ((> column gnus-article-normalized-header-length)
1620 (gnus-put-text-property
1622 (forward-char gnus-article-normalized-header-length)
1629 (forward-line 1))))))
1631 (defun article-treat-dumbquotes ()
1632 "Translate M****s*** sm*rtq**t*s into proper text.
1633 Note that this function guesses whether a character is a sm*rtq**t* or
1634 not, so it should only be used interactively.
1636 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1637 in an attempt to provide more quoting characters. If you see
1638 something like \\222 or \\264 where you're expecting some kind of
1639 apostrophe or quotation mark, then try this wash."
1641 (article-translate-strings gnus-article-dumbquotes-map))
1643 (defun article-translate-characters (from to)
1644 "Translate all characters in the body of the article according to FROM and TO.
1645 FROM is a string of characters to translate from; to is a string of
1646 characters to translate to."
1648 (when (article-goto-body)
1649 (let ((buffer-read-only nil)
1650 (x (make-string 225 ?x))
1652 (while (< (incf i) (length x))
1655 (while (< i (length from))
1656 (aset x (aref from i) (aref to i))
1658 (translate-region (point) (point-max) x)))))
1660 (defun article-translate-strings (map)
1661 "Translate all string in the body of the article according to MAP.
1662 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1664 (when (article-goto-body)
1665 (let ((buffer-read-only nil)
1667 (while (setq elem (pop map))
1669 (while (search-forward (car elem) nil t)
1670 (replace-match (cadr elem)))))))))
1672 (defun article-treat-overstrike ()
1673 "Translate overstrikes into bold text."
1676 (when (article-goto-body)
1677 (let ((buffer-read-only nil))
1678 (while (search-forward "\b" nil t)
1679 (let ((next (char-after))
1683 previous (char-after))
1687 ;; We do the boldification/underlining by hiding the
1688 ;; overstrikes and putting the proper text property
1692 (gnus-article-hide-text-type start (point) 'overstrike)
1693 (put-text-property (point) end 'face 'bold))
1695 (gnus-article-hide-text-type
1696 (1- (point)) (1+ (point)) 'overstrike)
1698 start (1- (point)) 'face 'underline))
1700 (gnus-article-hide-text-type start (point) 'overstrike)
1702 (point) end 'face 'underline)))))))))
1704 (defun article-fill-long-lines ()
1705 "Fill lines that are wider than the window width."
1708 (let ((buffer-read-only nil)
1709 (width (window-width (get-buffer-window (current-buffer)))))
1712 (let ((adaptive-fill-mode nil)) ;Why? -sm
1715 (when (>= (current-column) (min fill-column width))
1716 (narrow-to-region (point) (gnus-point-at-bol))
1717 (fill-paragraph nil)
1718 (goto-char (point-max))
1720 (forward-line 1)))))))
1722 (defun article-capitalize-sentences ()
1723 "Capitalize the first word in each sentence."
1726 (let ((buffer-read-only nil)
1727 (paragraph-start "^[\n\^L]"))
1731 (forward-sentence)))))
1733 (defun article-remove-cr ()
1734 "Remove trailing CRs and then translate remaining CRs into LFs."
1737 (let ((buffer-read-only nil))
1738 (goto-char (point-min))
1739 (while (re-search-forward "\r+$" nil t)
1740 (replace-match "" t t))
1741 (goto-char (point-min))
1742 (while (search-forward "\r" nil t)
1743 (replace-match "\n" t t)))))
1745 (defun article-remove-trailing-blank-lines ()
1746 "Remove all trailing blank lines from the article."
1749 (let ((buffer-read-only nil))
1750 (goto-char (point-max))
1754 (while (and (not (bobp))
1755 (looking-at "^[ \t]*$")
1756 (not (gnus-annotation-in-region-p
1757 (point) (gnus-point-at-eol))))
1762 (defun article-display-x-face (&optional force)
1763 "Look for an X-Face header and display it if present."
1764 (interactive (list 'force))
1766 ;; Delete the old process, if any.
1767 (when (process-status "article-x-face")
1768 (delete-process "article-x-face"))
1769 (let ((inhibit-point-motion-hooks t)
1771 (case-fold-search t)
1774 (article-narrow-to-head)
1775 ;; (when (and buffer-read-only ;; When type `W f'
1777 ;; (goto-char (point-min))
1778 ;; (not (re-search-forward "^X-Face:[\t ]*" nil t)))
1779 ;; (gnus-buffer-live-p gnus-original-article-buffer))
1780 ;; (with-current-buffer gnus-original-article-buffer
1781 ;; (save-restriction
1782 ;; (article-narrow-to-head)
1783 ;; (while (re-search-forward "^X-Face:" nil t)
1787 ;; (buffer-substring
1788 ;; (match-beginning 0)
1789 ;; (1- (re-search-forward
1790 ;; "^\\($\\|[^ \t]\\)" nil t))))))))
1792 ;; (let (point start bface eface buffer-read-only)
1793 ;; (goto-char (point-max))
1794 ;; (forward-line -1)
1795 ;; (setq bface (get-text-property (gnus-point-at-bol) 'face)
1796 ;; eface (get-text-property (1- (gnus-point-at-eol)) 'face))
1797 ;; (goto-char (point-max))
1798 ;; (setq point (point))
1800 ;; (goto-char point)
1801 ;; (while (looking-at "\\([^:]+\\): *")
1802 ;; (put-text-property (match-beginning 1) (1+ (match-end 1))
1804 ;; (setq start (match-end 0))
1806 ;; (while (looking-at "[\t ]")
1807 ;; (forward-line 1))
1808 ;; (put-text-property start (point)
1810 (goto-char (point-min))
1811 (setq from (message-fetch-field "from"))
1812 (goto-char (point-min))
1813 (while (and gnus-article-x-face-command
1816 ;; Check whether this face is censored.
1817 (not gnus-article-x-face-too-ugly)
1818 (and gnus-article-x-face-too-ugly from
1819 (not (string-match gnus-article-x-face-too-ugly
1821 ;; Has to be present.
1822 (re-search-forward "^X-Face:[\t ]*" nil t))
1823 ;; This used to try to do multiple faces (`while' instead of
1824 ;; `when' above), but (a) sending multiple EOFs to xv doesn't
1825 ;; work (b) it can crash some versions of Emacs (c) are
1826 ;; multiple faces really something to encourage?
1827 (when (stringp gnus-article-x-face-command)
1829 ;; We now have the area of the buffer where the X-Face is stored.
1832 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t)))
1834 ;; We display the face.
1835 (if (symbolp gnus-article-x-face-command)
1836 ;; The command is a lisp function, so we call it.
1837 (if (gnus-functionp gnus-article-x-face-command)
1838 (funcall gnus-article-x-face-command beg end)
1839 (error "%s is not a function" gnus-article-x-face-command))
1840 ;; The command is a string, so we interpret the command
1841 ;; as a, well, command, and fork it off.
1842 (let ((process-connection-type nil))
1843 (process-kill-without-query
1845 "article-x-face" nil shell-file-name shell-command-switch
1846 gnus-article-x-face-command))
1847 (process-send-region "article-x-face" beg end)
1848 (process-send-eof "article-x-face"))))))))))
1850 (defun article-decode-mime-words ()
1851 "Decode all MIME-encoded words in the article."
1854 (set-buffer gnus-article-buffer)
1855 (let ((inhibit-point-motion-hooks t)
1857 (mail-parse-charset gnus-newsgroup-charset)
1858 (mail-parse-ignored-charsets
1859 (save-excursion (set-buffer gnus-summary-buffer)
1860 gnus-newsgroup-ignored-charsets)))
1861 (mail-decode-encoded-word-region (point-min) (point-max)))))
1863 (defun article-decode-charset (&optional prompt)
1864 "Decode charset-encoded text in the article.
1865 If PROMPT (the prefix), prompt for a coding system to use."
1867 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
1869 (mail-parse-charset gnus-newsgroup-charset)
1870 (mail-parse-ignored-charsets
1871 (save-excursion (condition-case nil
1872 (set-buffer gnus-summary-buffer)
1874 gnus-newsgroup-ignored-charsets))
1875 ct cte ctl charset format)
1878 (article-narrow-to-head)
1879 (setq ct (message-fetch-field "Content-Type" t)
1880 cte (message-fetch-field "Content-Transfer-Encoding" t)
1881 ctl (and ct (ignore-errors
1882 (mail-header-parse-content-type ct)))
1885 (mm-read-coding-system "Charset to decode: "))
1887 (mail-content-type-get ctl 'charset)))
1888 format (and ctl (mail-content-type-get ctl 'format)))
1890 (setq cte (mail-header-strip cte)))
1891 (if (and ctl (not (string-match "/" (car ctl))))
1893 (goto-char (point-max)))
1896 (narrow-to-region (point) (point-max))
1897 (when (and (eq mail-parse-charset 'gnus-decoded)
1898 (eq (mm-body-7-or-8) '8bit))
1899 ;; The text code could have been decoded.
1900 (setq charset mail-parse-charset))
1901 (when (and (or (not ctl)
1902 (equal (car ctl) "text/plain"))
1903 (not format)) ;; article with format will decode later.
1905 charset (and cte (intern (downcase
1906 (gnus-strip-whitespace cte))))
1909 (defun article-decode-encoded-words ()
1910 "Remove encoded-word encoding from headers."
1911 (let (buffer-read-only)
1912 (let ((charset (save-excursion
1913 (set-buffer gnus-summary-buffer)
1914 default-mime-charset)))
1915 (mime-decode-header-in-buffer charset))))
1917 (defun article-decode-group-name ()
1918 "Decode group names in `Newsgroups:'."
1919 (let ((inhibit-point-motion-hooks t)
1921 (method (gnus-find-method-for-group gnus-newsgroup-name)))
1922 (when (and (or gnus-group-name-charset-method-alist
1923 gnus-group-name-charset-group-alist)
1924 (gnus-buffer-live-p gnus-original-article-buffer))
1925 (when (nnmail-fetch-field "Newsgroups")
1926 (nnheader-replace-header "Newsgroups"
1927 (gnus-decode-newsgroups
1928 (with-current-buffer
1929 gnus-original-article-buffer
1930 (nnmail-fetch-field "Newsgroups"))
1931 gnus-newsgroup-name method)))
1932 (when (nnmail-fetch-field "Followup-To")
1933 (nnheader-replace-header "Followup-To"
1934 (gnus-decode-newsgroups
1935 (with-current-buffer
1936 gnus-original-article-buffer
1937 (nnmail-fetch-field "Followup-To"))
1938 gnus-newsgroup-name method))))))
1940 (defun article-de-quoted-unreadable (&optional force read-charset)
1941 "Translate a quoted-printable-encoded article.
1942 If FORCE, decode the article whether it is marked as quoted-printable
1944 If READ-CHARSET, ask for a coding system."
1945 (interactive (list 'force current-prefix-arg))
1947 (let ((buffer-read-only nil) type charset)
1948 (if (gnus-buffer-live-p gnus-original-article-buffer)
1949 (with-current-buffer gnus-original-article-buffer
1951 (gnus-fetch-field "content-transfer-encoding"))
1952 (let* ((ct (gnus-fetch-field "content-type"))
1955 (mail-header-parse-content-type ct)))))
1956 (setq charset (and ctl
1957 (mail-content-type-get ctl 'charset)))
1958 (if (stringp charset)
1959 (setq charset (intern (downcase charset)))))))
1961 (setq charset (mm-read-coding-system "Charset: " charset)))
1963 (setq charset gnus-newsgroup-charset))
1965 (and type (let ((case-fold-search t))
1966 (string-match "quoted-printable" type))))
1968 (quoted-printable-decode-region
1969 (point) (point-max) (mm-charset-to-coding-system charset))))))
1971 (defun article-de-base64-unreadable (&optional force read-charset)
1972 "Translate a base64 article.
1973 If FORCE, decode the article whether it is marked as base64 not.
1974 If READ-CHARSET, ask for a coding system."
1975 (interactive (list 'force current-prefix-arg))
1977 (let ((buffer-read-only nil) type charset)
1978 (if (gnus-buffer-live-p gnus-original-article-buffer)
1979 (with-current-buffer gnus-original-article-buffer
1981 (gnus-fetch-field "content-transfer-encoding"))
1982 (let* ((ct (gnus-fetch-field "content-type"))
1985 (mail-header-parse-content-type ct)))))
1986 (setq charset (and ctl
1987 (mail-content-type-get ctl 'charset)))
1988 (if (stringp charset)
1989 (setq charset (intern (downcase charset)))))))
1991 (setq charset (mm-read-coding-system "Charset: " charset)))
1993 (setq charset gnus-newsgroup-charset))
1995 (and type (let ((case-fold-search t))
1996 (string-match "base64" type))))
1999 (narrow-to-region (point) (point-max))
2000 (base64-decode-region (point-min) (point-max))
2001 (mm-decode-coding-region
2002 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2007 (defun article-decode-HZ ()
2008 "Translate a HZ-encoded article."
2012 (let ((buffer-read-only nil))
2013 (rfc1843-decode-region (point-min) (point-max)))))
2015 (defun article-wash-html (&optional read-charset)
2016 "Format an html article.
2017 If READ-CHARSET, ask for a coding system."
2020 (let ((buffer-read-only nil)
2022 (if (gnus-buffer-live-p gnus-original-article-buffer)
2023 (with-current-buffer gnus-original-article-buffer
2024 (let* ((ct (gnus-fetch-field "content-type"))
2027 (mail-header-parse-content-type ct)))))
2028 (setq charset (and ctl
2029 (mail-content-type-get ctl 'charset)))
2030 (if (stringp charset)
2031 (setq charset (intern (downcase charset)))))))
2033 (setq charset (mm-read-coding-system "Charset: " charset)))
2035 (setq charset gnus-newsgroup-charset))
2037 (save-window-excursion
2039 (narrow-to-region (point) (point-max))
2041 (let ((w3-strict-width (window-width))
2042 (url-standalone-mode t))
2044 (w3-region (point-min) (point-max))
2047 (defun article-hide-list-identifiers ()
2048 "Remove list identifies from the Subject header.
2049 The `gnus-list-identifiers' variable specifies what to do."
2051 (let ((inhibit-point-motion-hooks t)
2052 (regexp (if (consp gnus-list-identifiers)
2053 (mapconcat 'identity gnus-list-identifiers " *\\|")
2054 gnus-list-identifiers))
2059 (article-narrow-to-head)
2060 (goto-char (point-min))
2061 (while (re-search-forward
2062 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2064 (delete-region (match-beginning 2) (match-end 0))
2065 (beginning-of-line))
2066 (when (re-search-forward
2067 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2068 (delete-region (match-beginning 1) (match-end 1))))))))
2070 (defun article-hide-pgp ()
2071 "Remove any PGP headers and signatures in the current article."
2075 (let ((inhibit-point-motion-hooks t)
2076 buffer-read-only beg end)
2078 ;; Hide the "header".
2079 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
2080 (push 'pgp gnus-article-wash-types)
2081 (delete-region (match-beginning 0) (match-end 0))
2082 ;; Remove armor headers (rfc2440 6.2)
2083 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
2086 ;; Hide the actual signature.
2087 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
2088 (setq end (1+ (match-beginning 0)))
2091 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
2093 ;; Perhaps we shouldn't hide to the end of the buffer
2094 ;; if there is no end to the signature?
2096 ;; Hide "- " PGP quotation markers.
2098 (narrow-to-region beg end)
2099 (goto-char (point-min))
2100 (while (re-search-forward "^- " nil t)
2102 (match-beginning 0) (match-end 0)))
2104 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
2106 (defun article-hide-pem (&optional arg)
2107 "Toggle hiding of any PEM headers and signatures in the current article.
2108 If given a negative prefix, always show; if given a positive prefix,
2110 (interactive (gnus-article-hidden-arg))
2111 (unless (gnus-article-check-hidden-text 'pem arg)
2113 (let (buffer-read-only end)
2114 (goto-char (point-min))
2115 ;; Hide the horrendously ugly "header".
2116 (when (and (search-forward
2117 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2119 (setq end (1+ (match-beginning 0))))
2120 (push 'pem gnus-article-wash-types)
2121 (gnus-article-hide-text-type
2123 (if (search-forward "\n\n" nil t)
2127 ;; Hide the trailer as well
2128 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2130 (gnus-article-hide-text-type
2131 (match-beginning 0) (match-end 0) 'pem)))))))
2133 (defun article-strip-banner ()
2134 "Strip the banner specified by the `banner' group parameter."
2138 (let ((inhibit-point-motion-hooks t)
2139 (banner (gnus-parameter-banner gnus-newsgroup-name))
2140 (gnus-signature-limit nil)
2141 buffer-read-only beg end)
2145 ((eq banner 'signature)
2146 (when (gnus-article-narrow-to-signature)
2149 (delete-region (point) (point-max))))
2151 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2152 (while (re-search-forward banner nil t)
2153 (delete-region (match-beginning 0) (match-end 0)))))
2155 (while (re-search-forward banner nil t)
2156 (delete-region (match-beginning 0) (match-end 0))))))))))
2158 (defun article-babel ()
2159 "Translate article using an online translation service."
2163 (set-buffer gnus-article-buffer)
2164 (when (article-goto-body)
2165 (let* ((buffer-read-only nil)
2168 (orig (buffer-substring start end))
2169 (trans (babel-as-string orig)))
2171 (narrow-to-region start end)
2172 (delete-region start end)
2175 (defun article-hide-signature (&optional arg)
2176 "Hide the signature in the current article.
2177 If given a negative prefix, always show; if given a positive prefix,
2179 (interactive (gnus-article-hidden-arg))
2185 (article-goto-body))
2186 (goto-char (point-min)))
2187 (unless (gnus-article-check-hidden-text 'signature arg)
2188 (let ((buffer-read-only nil)
2190 (while (setq button (text-property-any button (point-max)
2192 'gnus-signature-toggle))
2193 (setq button (text-property-not-all button (point-max)
2195 'gnus-signature-toggle))
2196 (when (and button (not (eobp)))
2197 (gnus-article-hide-text-type
2199 (next-single-property-change (1+ button) 'mime-view-entity
2203 (defun article-strip-headers-in-body ()
2204 "Strip offensive headers from bodies."
2208 (let ((case-fold-search t))
2209 (when (looking-at "x-no-archive:")
2210 (gnus-delete-line)))))
2212 (defun article-strip-leading-blank-lines ()
2213 "Remove all blank lines from the beginning of the article."
2216 (let ((inhibit-point-motion-hooks t)
2218 (when (article-goto-body)
2219 (while (and (not (eobp))
2220 (looking-at "[ \t]*$"))
2221 (gnus-delete-line))))))
2223 (defun article-narrow-to-head ()
2224 "Narrow the buffer to the head of the message.
2225 Point is left at the beginning of the narrowed-to region."
2227 (goto-char (point-min))
2228 (if (search-forward "\n\n" nil 1)
2231 (goto-char (point-min)))
2233 (defun article-goto-body ()
2234 "Place point at the start of the body."
2235 (goto-char (point-min))
2237 ;; This variable is only bound when dealing with separate
2239 (article-goto-body-goes-to-point-min-p
2241 ((search-forward "\n\n" nil t)
2244 (goto-char (point-max))
2247 (defun article-strip-multiple-blank-lines ()
2248 "Replace consecutive blank lines with one empty line."
2251 (let ((inhibit-point-motion-hooks t)
2253 ;; First make all blank lines empty.
2255 (while (re-search-forward "^[ \t]+$" nil t)
2256 (unless (gnus-annotation-in-region-p
2257 (match-beginning 0) (match-end 0))
2258 (replace-match "" nil t)))
2259 ;; Then replace multiple empty lines with a single empty line.
2261 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2262 (unless (gnus-annotation-in-region-p
2263 (match-beginning 0) (match-end 0))
2264 (delete-region (match-beginning 1) (match-end 1)))))))
2266 (defun article-strip-leading-space ()
2267 "Remove all white space from the beginning of the lines in the article."
2270 (let ((inhibit-point-motion-hooks t)
2273 (while (re-search-forward "^[ \t]+" nil t)
2274 (replace-match "" t t)))))
2276 (defun article-strip-trailing-space ()
2277 "Remove all white space from the end of the lines in the article."
2280 (let ((inhibit-point-motion-hooks t)
2283 (while (re-search-forward "[ \t]+$" nil t)
2284 (replace-match "" t t)))))
2286 (defun article-strip-blank-lines ()
2287 "Strip leading, trailing and multiple blank lines."
2289 (article-strip-leading-blank-lines)
2290 (article-remove-trailing-blank-lines)
2291 (article-strip-multiple-blank-lines))
2293 (defun article-strip-all-blank-lines ()
2294 "Strip all blank lines."
2297 (let ((inhibit-point-motion-hooks t)
2300 (while (re-search-forward "^[ \t]*\n" nil t)
2301 (replace-match "" t t)))))
2303 (defun gnus-article-narrow-to-signature ()
2304 "Narrow to the signature; return t if a signature is found, else nil."
2305 (let ((inhibit-point-motion-hooks t))
2306 (when (gnus-article-search-signature)
2308 ;; Check whether we have some limits to what we consider
2309 ;; to be a signature.
2310 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2311 (list gnus-signature-limit)))
2313 (while (setq limit (pop limits))
2314 (if (or (and (integerp limit)
2315 (< (- (point-max) (point)) limit))
2317 (< (count-lines (point) (point-max)) limit))
2318 (and (gnus-functionp limit)
2320 (and (stringp limit)
2321 (not (re-search-forward limit nil t))))
2322 () ; This limit did not succeed.
2326 (narrow-to-region (point) (point-max))
2329 (defun gnus-article-search-signature ()
2330 "Search the current buffer for the signature separator.
2331 Put point at the beginning of the signature separator."
2332 (let ((cur (point)))
2333 (goto-char (point-max))
2334 (if (if (stringp gnus-signature-separator)
2335 (re-search-backward gnus-signature-separator nil t)
2336 (let ((seps gnus-signature-separator))
2338 (not (re-search-backward (car seps) nil t)))
2345 (defun gnus-article-hidden-arg ()
2346 "Return the current prefix arg as a number, or 0 if no prefix."
2347 (list (if current-prefix-arg
2348 (prefix-numeric-value current-prefix-arg)
2351 (defun gnus-article-check-hidden-text (type arg)
2352 "Return nil if hiding is necessary.
2353 Arg can be nil or a number. Nil and positive means hide, negative
2354 means show, 0 means toggle."
2357 (let ((hide (gnus-article-hidden-text-p type)))
2363 (gnus-article-show-hidden-text type)
2366 (if (eq hide 'hidden)
2368 (gnus-article-show-hidden-text type)
2372 (defun gnus-article-hidden-text-p (type)
2373 "Say whether the current buffer contains hidden text of type TYPE."
2374 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2376 (not (get-text-property pos 'invisible))
2377 (not (get-text-property pos 'dummy-invisible)))
2379 (text-property-any (1+ pos) (point-max) 'article-type type)))
2384 (defun gnus-article-show-hidden-text (type &optional dummy)
2385 "Show all hidden text of type TYPE.
2386 Originally it is hide instead of DUMMY."
2387 (let ((buffer-read-only nil)
2388 (inhibit-point-motion-hooks t))
2389 (gnus-remove-text-properties-when
2391 (point-min) (point-max)
2392 (cons 'article-type (cons type
2393 gnus-hidden-properties)))))
2395 (defconst article-time-units
2396 `((year . ,(* 365.25 24 60 60))
2397 (week . ,(* 7 24 60 60))
2398 (day . ,(* 24 60 60))
2402 "Mapping from time units to seconds.")
2404 (defun article-date-ut (&optional type highlight header)
2405 "Convert DATE date to universal time in the current article.
2406 If TYPE is `local', convert to local time; if it is `lapsed', output
2407 how much time has lapsed since DATE. For `lapsed', the value of
2408 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2409 should replace the \"Date:\" one, or should be added below it."
2410 (interactive (list 'ut t))
2411 (let* ((header (or header
2412 (and (eq 1 (point-min))
2413 (mail-header-date (save-excursion
2414 (set-buffer gnus-summary-buffer)
2415 gnus-current-headers)))
2416 (message-fetch-field "date")
2418 (date (if (vectorp header) (mail-header-date header)
2420 (inhibit-point-motion-hooks t)
2421 bface eface date-pos)
2422 (when (and date (not (string= date "")))
2425 (article-narrow-to-head)
2426 (when (or (and (eq type 'lapsed)
2427 gnus-article-date-lapsed-new-header
2428 ;; Attempt to get the face of X-Sent first.
2429 (re-search-forward "^X-Sent:[ \t]" nil t))
2430 (re-search-forward "^Date:[ \t]" nil t)
2431 ;; If Date is missing, try again for X-Sent.
2432 (re-search-forward "^X-Sent:[ \t]" nil t))
2433 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2434 date (or (get-text-property (gnus-point-at-bol)
2437 eface (get-text-property (1- (gnus-point-at-eol))
2439 (let ((buffer-read-only nil))
2440 ;; Delete any old X-Sent headers.
2441 (when (setq date-pos
2442 (text-property-any (point-min) (point-max)
2443 'article-date-lapsed t))
2444 (goto-char (setq date-pos (set-marker (make-marker) date-pos)))
2445 (delete-region (match-beginning 0)
2446 (progn (forward-line 1) (point))))
2447 (goto-char (point-min))
2448 ;; Delete any old Date headers.
2449 (while (re-search-forward "^Date:[ \t]" nil t)
2451 (setq date-pos (match-beginning 0)))
2452 (unless (and (eq type 'lapsed)
2453 gnus-article-date-lapsed-new-header)
2454 (delete-region (match-beginning 0)
2455 (progn (message-next-header) (point)))))
2458 (goto-char date-pos)
2460 ;; Possibly, Date has been deleted.
2462 (when (and (eq type 'lapsed)
2463 gnus-article-date-lapsed-new-header
2464 (looking-at "Date:"))
2466 (goto-char (point-min)))
2467 (insert (article-make-date-line date type))
2468 (when (eq type 'lapsed)
2469 (put-text-property (gnus-point-at-bol) (point)
2470 'article-date-lapsed t))
2474 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2475 (put-text-property (match-beginning 1) (1+ (match-end 1))
2476 'original-date date)
2477 (put-text-property (match-beginning 1) (1+ (match-end 1))
2479 (put-text-property (match-beginning 2) (match-end 2)
2482 (defun article-make-date-line (date type)
2483 "Return a DATE line of TYPE."
2484 (unless (memq type '(local ut original user iso8601 lapsed english))
2485 (error "Unknown conversion type: %s" type))
2487 (let ((time (date-to-time date)))
2489 ;; Convert to the local timezone.
2491 (let ((tz (car (current-time-zone time))))
2492 (format "Date: %s %s%02d%02d" (current-time-string time)
2493 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2494 (/ (% (abs tz) 3600) 60))))
2495 ;; Convert to Universal Time.
2498 (current-time-string
2499 (let* ((e (parse-time-string date))
2500 (tm (apply 'encode-time e))
2502 (ls (- (cadr tm) (car (current-time-zone time)))))
2503 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2504 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2507 ;; Get the original date from the article.
2508 ((eq type 'original)
2509 (concat "Date: " (if (string-match "\n+$" date)
2510 (substring date 0 (match-beginning 0))
2512 ;; Let the user define the format.
2514 (if (gnus-functionp gnus-article-time-format)
2515 (funcall gnus-article-time-format time)
2518 (format-time-string gnus-article-time-format time))))
2521 (let ((tz (car (current-time-zone time))))
2524 (format-time-string "%Y%m%dT%H%M%S" time)
2525 (format "%s%02d%02d"
2526 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2527 (/ (% (abs tz) 3600) 60)))))
2528 ;; Do an X-Sent lapsed format.
2530 ;; If the date is seriously mangled, the timezone functions are
2531 ;; liable to bug out, so we ignore all errors.
2532 (let* ((now (current-time))
2533 (real-time (subtract-time now time))
2534 (real-sec (and real-time
2535 (+ (* (float (car real-time)) 65536)
2537 (sec (and real-time (abs real-sec)))
2547 ;; This is a bit convoluted, but basically we go
2548 ;; through the time units for years, weeks, etc,
2549 ;; and divide things to see whether that results
2550 ;; in positive answers.
2553 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2554 ;; The (remaining) seconds are too few to
2555 ;; be divided into this time unit.
2557 ;; It's big enough, so we output it.
2558 (setq sec (- sec (* num (cdr unit))))
2560 (concat (if prev ", " "") (int-to-string
2562 " " (symbol-name (car unit))
2563 (if (> num 1) "s" ""))
2565 article-time-units "")
2566 ;; If dates are odd, then it might appear like the
2567 ;; article was sent in the future.
2570 " in the future"))))))
2571 ;; Display the date in proper English
2573 (let ((dtime (decode-time time)))
2576 (number-to-string (nth 3 dtime))
2577 (let ((digit (% (nth 3 dtime) 10)))
2579 ((memq (nth 3 dtime) '(11 12 13)) "th")
2585 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2587 (number-to-string (nth 5 dtime))
2589 (format "%02d" (nth 2 dtime))
2591 (format "%02d" (nth 1 dtime)))))))
2593 (format "Date: %s (from Oort)" date))))
2595 (defun article-date-local (&optional highlight)
2596 "Convert the current article date to the local timezone."
2597 (interactive (list t))
2598 (article-date-ut 'local highlight))
2600 (defun article-date-english (&optional highlight)
2601 "Convert the current article date to something that is proper English."
2602 (interactive (list t))
2603 (article-date-ut 'english highlight))
2605 (defun article-date-original (&optional highlight)
2606 "Convert the current article date to what it was originally.
2607 This is only useful if you have used some other date conversion
2608 function and want to see what the date was before converting."
2609 (interactive (list t))
2610 (article-date-ut 'original highlight))
2612 (defun article-date-lapsed (&optional highlight)
2613 "Convert the current article date to time lapsed since it was sent."
2614 (interactive (list t))
2615 (article-date-ut 'lapsed highlight))
2617 (defun article-update-date-lapsed ()
2618 "Function to be run from a timer to update the lapsed time line."
2619 (let (deactivate-mark)
2624 (set-buffer (window-buffer w))
2625 (when (eq major-mode 'gnus-article-mode)
2626 (goto-char (point-min))
2627 (when (re-search-forward "^X-Sent:" nil t)
2628 (article-date-lapsed t))))
2631 (defun gnus-start-date-timer (&optional n)
2632 "Start a timer to update the X-Sent header in the article buffers.
2633 The numerical prefix says how frequently (in seconds) the function
2638 (gnus-stop-date-timer)
2639 (setq article-lapsed-timer
2640 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2642 (defun gnus-stop-date-timer ()
2643 "Stop the X-Sent timer."
2645 (when article-lapsed-timer
2646 (nnheader-cancel-timer article-lapsed-timer)
2647 (setq article-lapsed-timer nil)))
2649 (defun article-date-user (&optional highlight)
2650 "Convert the current article date to the user-defined format.
2651 This format is defined by the `gnus-article-time-format' variable."
2652 (interactive (list t))
2653 (article-date-ut 'user highlight))
2655 (defun article-date-iso8601 (&optional highlight)
2656 "Convert the current article date to ISO8601."
2657 (interactive (list t))
2658 (article-date-ut 'iso8601 highlight))
2660 (defun article-show-all ()
2661 "Show all hidden text in the article buffer."
2665 (let ((buffer-read-only nil))
2666 (gnus-article-unhide-text (point-min) (point-max))
2667 (gnus-remove-text-with-property 'gnus-prev)
2668 (gnus-remove-text-with-property 'gnus-next))))
2670 (defun article-show-all-headers ()
2671 "Show all hidden headers in the article buffer."
2676 (article-narrow-to-head)
2677 (let ((buffer-read-only nil))
2678 (gnus-article-unhide-text (point-min) (point-max))))))
2680 (defun article-remove-leading-whitespace ()
2681 "Remove excessive whitespace from all headers."
2685 (let ((buffer-read-only nil))
2686 (article-narrow-to-head)
2687 (goto-char (point-min))
2688 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2689 (delete-region (match-beginning 1) (match-end 1)))))))
2691 (defun article-emphasize (&optional arg)
2692 "Emphasize text according to `gnus-emphasis-alist'."
2693 (interactive (gnus-article-hidden-arg))
2694 (unless (gnus-article-check-hidden-text 'emphasis arg)
2698 (with-current-buffer gnus-summary-buffer
2699 gnus-article-emphasis-alist)
2701 gnus-emphasis-alist))
2702 (buffer-read-only nil)
2703 (props (append '(article-type emphasis)
2704 gnus-hidden-properties))
2705 regexp elem beg invisible visible face)
2708 (while (setq elem (pop alist))
2710 (setq regexp (car elem)
2711 invisible (nth 1 elem)
2712 visible (nth 2 elem)
2714 (while (re-search-forward regexp nil t)
2715 (when (and (match-beginning visible) (match-beginning invisible))
2716 (gnus-article-hide-text
2717 (match-beginning invisible) (match-end invisible) props)
2718 (gnus-article-unhide-text-type
2719 (match-beginning visible) (match-end visible) 'emphasis)
2720 (gnus-put-text-property-excluding-newlines
2721 (match-beginning visible) (match-end visible) 'face face)
2722 (push 'emphasis gnus-article-wash-types)
2723 (goto-char (match-end invisible)))))))))
2725 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2726 "Setup newsgroup emphasis alist."
2727 (unless gnus-article-emphasis-alist
2728 (let ((name (and gnus-newsgroup-name
2729 (gnus-group-real-name gnus-newsgroup-name))))
2730 (make-local-variable 'gnus-article-emphasis-alist)
2731 (setq gnus-article-emphasis-alist
2733 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2734 (while (setq elem (pop alist))
2735 (when (and name (string-match (car elem) name))
2737 highlight (copy-sequence (cdr elem)))))
2739 (copy-sequence highlight-words)
2740 (if gnus-newsgroup-name
2741 (copy-sequence (gnus-group-find-parameter
2742 gnus-newsgroup-name 'highlight-words t)))
2743 gnus-emphasis-alist)))))
2746 (defvar gnus-summary-article-menu)
2747 (defvar gnus-summary-post-menu))
2749 ;;; Saving functions.
2751 (defun gnus-article-save (save-buffer file &optional num)
2752 "Save the currently selected article."
2753 (unless gnus-save-all-headers
2754 ;; Remove headers according to `gnus-saved-headers'.
2755 (let ((gnus-visible-headers
2756 (or gnus-saved-headers gnus-visible-headers))
2757 (gnus-article-buffer save-buffer))
2759 (set-buffer save-buffer)
2760 (article-hide-headers 1 t))))
2761 (save-window-excursion
2762 (if (not gnus-default-article-saver)
2763 (error "No default saver is defined")
2764 ;; !!! Magic! The saving functions all save
2765 ;; `gnus-save-article-buffer' (or so they think), but we
2766 ;; bind that variable to our save-buffer.
2767 (set-buffer gnus-article-buffer)
2768 (let* ((gnus-save-article-buffer save-buffer)
2771 ((not gnus-prompt-before-saving) 'default)
2772 ((eq gnus-prompt-before-saving 'always) nil)
2774 (gnus-number-of-articles-to-be-saved
2775 (when (eq gnus-prompt-before-saving t)
2777 (set-buffer gnus-article-current-summary)
2778 (funcall gnus-default-article-saver filename)))))
2780 (defun gnus-read-save-file-name (prompt &optional filename
2781 function group headers variable)
2783 (funcall function group headers (symbol-value variable)))
2788 ((eq filename 'default)
2794 (let* ((split-name (gnus-get-split-value gnus-split-methods))
2797 (if (and gnus-number-of-articles-to-be-saved
2798 (> gnus-number-of-articles-to-be-saved 1))
2799 (format "these %d articles"
2800 gnus-number-of-articles-to-be-saved)
2803 ;; Let the split methods have their say.
2805 ;; No split name was found.
2808 (concat prompt " (default "
2809 (file-name-nondirectory default-name) ") ")
2810 (file-name-directory default-name)
2812 ;; A single group name is returned.
2813 ((stringp split-name)
2815 (funcall function split-name headers
2816 (symbol-value variable)))
2818 (concat prompt " (default "
2819 (file-name-nondirectory default-name) ") ")
2820 (file-name-directory default-name)
2822 ;; A single split name was found
2823 ((= 1 (length split-name))
2824 (let* ((name (expand-file-name
2826 gnus-article-save-directory))
2827 (dir (cond ((file-directory-p name)
2828 (file-name-as-directory name))
2829 ((file-exists-p name) name)
2830 (t gnus-article-save-directory))))
2832 (concat prompt " (default " name ") ")
2834 ;; A list of splits was found.
2836 (setq split-name (nreverse split-name))
2838 (let ((file-name-history
2839 (nconc split-name file-name-history)))
2843 (concat prompt " (`M-p' for defaults) ")
2844 gnus-article-save-directory
2846 gnus-article-save-directory)))
2847 (car (push result file-name-history)))))))
2848 ;; Create the directory.
2849 (gnus-make-directory (file-name-directory file))
2850 ;; If we have read a directory, we append the default file name.
2851 (when (file-directory-p file)
2852 (setq file (expand-file-name (file-name-nondirectory
2854 (file-name-as-directory file))))
2855 ;; Possibly translate some characters.
2856 (nnheader-translate-file-chars file))))))
2857 (gnus-make-directory (file-name-directory result))
2858 (set variable result)))
2860 (defun gnus-article-archive-name (group)
2861 "Return the first instance of an \"Archive-name\" in the current buffer."
2862 (let ((case-fold-search t))
2863 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
2864 (nnheader-concat gnus-article-save-directory
2865 (match-string 1)))))
2867 (defun gnus-article-nndoc-name (group)
2868 "If GROUP is an nndoc group, return the name of the parent group."
2869 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
2870 (gnus-group-get-parameter group 'save-article-group)))
2872 (defun gnus-summary-save-in-rmail (&optional filename)
2873 "Append this article to Rmail file.
2874 Optional argument FILENAME specifies file name.
2875 Directory to save to is default to `gnus-article-save-directory'."
2876 (setq filename (gnus-read-save-file-name
2877 "Save %s in rmail file:" filename
2878 gnus-rmail-save-name gnus-newsgroup-name
2879 gnus-current-headers 'gnus-newsgroup-last-rmail))
2880 (gnus-eval-in-buffer-window gnus-save-article-buffer
2884 (gnus-output-to-rmail filename))))
2887 (defun gnus-summary-save-in-mail (&optional filename)
2888 "Append this article to Unix mail file.
2889 Optional argument FILENAME specifies file name.
2890 Directory to save to is default to `gnus-article-save-directory'."
2891 (setq filename (gnus-read-save-file-name
2892 "Save %s in Unix mail file:" filename
2893 gnus-mail-save-name gnus-newsgroup-name
2894 gnus-current-headers 'gnus-newsgroup-last-mail))
2895 (gnus-eval-in-buffer-window gnus-save-article-buffer
2899 (if (and (file-readable-p filename)
2900 (mail-file-babyl-p filename))
2901 (rmail-output-to-rmail-file filename t)
2902 (gnus-output-to-mail filename)))))
2905 (defun gnus-summary-save-in-file (&optional filename overwrite)
2906 "Append this article to file.
2907 Optional argument FILENAME specifies file name.
2908 Directory to save to is default to `gnus-article-save-directory'."
2909 (setq filename (gnus-read-save-file-name
2910 "Save %s in file:" filename
2911 gnus-file-save-name gnus-newsgroup-name
2912 gnus-current-headers 'gnus-newsgroup-last-file))
2913 (gnus-eval-in-buffer-window gnus-save-article-buffer
2917 (when (and overwrite
2918 (file-exists-p filename))
2919 (delete-file filename))
2920 (gnus-output-to-file filename))))
2923 (defun gnus-summary-write-to-file (&optional filename)
2924 "Write this article to a file, overwriting it if the file exists.
2925 Optional argument FILENAME specifies file name.
2926 The directory to save in defaults to `gnus-article-save-directory'."
2927 (gnus-summary-save-in-file nil t))
2929 (defun gnus-summary-save-body-in-file (&optional filename)
2930 "Append this article body to a file.
2931 Optional argument FILENAME specifies file name.
2932 The directory to save in defaults to `gnus-article-save-directory'."
2933 (setq filename (gnus-read-save-file-name
2934 "Save %s body in file:" filename
2935 gnus-file-save-name gnus-newsgroup-name
2936 gnus-current-headers 'gnus-newsgroup-last-file))
2937 (gnus-eval-in-buffer-window gnus-save-article-buffer
2941 (when (article-goto-body)
2942 (narrow-to-region (point) (point-max)))
2943 (gnus-output-to-file filename))))
2946 (defun gnus-summary-save-in-pipe (&optional command)
2947 "Pipe this article to subprocess."
2949 (cond ((and (eq command 'default)
2950 gnus-last-shell-command)
2951 gnus-last-shell-command)
2956 "Shell command on %s: "
2957 (if (and gnus-number-of-articles-to-be-saved
2958 (> gnus-number-of-articles-to-be-saved 1))
2959 (format "these %d articles"
2960 gnus-number-of-articles-to-be-saved)
2962 gnus-last-shell-command))))
2963 (when (string-equal command "")
2964 (if gnus-last-shell-command
2965 (setq command gnus-last-shell-command)
2966 (error "A command is required")))
2967 (gnus-eval-in-buffer-window gnus-article-buffer
2970 (shell-command-on-region (point-min) (point-max) command nil)))
2971 (setq gnus-last-shell-command command))
2973 ;;; Article file names when saving.
2975 (defun gnus-capitalize-newsgroup (newsgroup)
2976 "Capitalize NEWSGROUP name."
2977 (when (not (zerop (length newsgroup)))
2978 (concat (char-to-string (upcase (aref newsgroup 0)))
2979 (substring newsgroup 1))))
2981 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2982 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2983 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
2984 Otherwise, it is like ~/News/news/group/num."
2987 (concat (if (gnus-use-long-file-name 'not-save)
2988 (gnus-capitalize-newsgroup newsgroup)
2989 (gnus-newsgroup-directory-form newsgroup))
2990 "/" (int-to-string (mail-header-number headers)))
2991 gnus-article-save-directory)))
2993 (string-equal (file-name-directory default)
2994 (file-name-directory last-file))
2995 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2997 (or last-file default))))
2999 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3000 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3001 If variable `gnus-use-long-file-name' is non-nil, it is
3002 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3005 (concat (if (gnus-use-long-file-name 'not-save)
3007 (gnus-newsgroup-directory-form newsgroup))
3008 "/" (int-to-string (mail-header-number headers)))
3009 gnus-article-save-directory)))
3011 (string-equal (file-name-directory default)
3012 (file-name-directory last-file))
3013 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3015 (or last-file default))))
3017 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3018 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3019 If variable `gnus-use-long-file-name' is non-nil, it is
3020 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3023 (if (gnus-use-long-file-name 'not-save)
3026 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3028 gnus-article-save-directory)))
3030 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3031 "Generate file name from sender."
3032 (let ((from (mail-header-from headers)))
3034 (if (and from (string-match "\\([^ <]+\\)@" from))
3035 (match-string 1 from)
3037 gnus-article-save-directory)))
3039 (defun article-verify-x-pgp-sig ()
3042 (if (gnus-buffer-live-p gnus-original-article-buffer)
3043 (let ((sig (with-current-buffer gnus-original-article-buffer
3044 (gnus-fetch-field "X-PGP-Sig")))
3048 (mml2015-clear-verify-function))
3050 (insert-buffer gnus-original-article-buffer)
3051 (setq items (split-string sig))
3052 (message-narrow-to-head)
3053 (let ((inhibit-point-motion-hooks t)
3054 (case-fold-search t))
3055 ;; Don't verify multiple headers.
3056 (setq headers (mapconcat (lambda (header)
3058 (mail-fetch-field header) "\n"))
3059 (split-string (nth 1 items) ",") "")))
3060 (delete-region (point-min) (point-max))
3061 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3062 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3067 (if (looking-at "^-")
3070 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3071 (insert "Version: " (car items) "\n\n")
3072 (insert (mapconcat 'identity (cddr items) "\n"))
3073 (insert "\n-----END PGP SIGNATURE-----\n")
3074 (let ((mm-security-handle (list (format "multipart/signed"))))
3075 (mml2015-clean-buffer)
3076 (let ((coding-system-for-write (or gnus-newsgroup-charset
3078 (funcall (mml2015-clear-verify-function)))
3080 (or (mm-handle-multipart-ctl-parameter
3081 mm-security-handle 'gnus-details)
3082 (mm-handle-multipart-ctl-parameter
3083 mm-security-handle 'gnus-info)))))
3085 (let (buffer-read-only bface eface)
3087 (message-narrow-to-head)
3088 (goto-char (point-max))
3090 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3091 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3092 (message-remove-header "X-Gnus-PGP-Verify")
3093 (if (re-search-forward "^X-PGP-Sig:" nil t)
3095 (goto-char (point-max)))
3096 (narrow-to-region (point) (point))
3097 (insert "X-Gnus-PGP-Verify: " info "\n")
3098 (goto-char (point-min))
3101 (if (not (looking-at "^[ \t]"))
3105 (goto-char (point-min))
3106 (when (looking-at "\\([^:]+\\): *")
3107 (put-text-property (match-beginning 1) (1+ (match-end 1))
3109 (put-text-property (match-end 0) (point-max)
3110 'face eface)))))))))
3112 (defun article-verify-cancel-lock ()
3113 "Verify Cancel-Lock header."
3115 (if (gnus-buffer-live-p gnus-original-article-buffer)
3116 (canlock-verify gnus-original-article-buffer)))
3123 (setq afunc (car func)
3126 gfunc (intern (format "gnus-%s" func))))
3129 `(lambda (&optional interactive &rest args)
3130 ,(documentation afunc t)
3131 (interactive (list t))
3133 (set-buffer gnus-article-buffer)
3135 (call-interactively ',afunc)
3136 (apply ',afunc args))))))))
3137 '(article-hide-headers
3138 article-verify-x-pgp-sig
3139 article-verify-cancel-lock
3140 article-hide-boring-headers
3141 article-toggle-headers
3142 article-treat-overstrike
3143 article-fill-long-lines
3144 article-capitalize-sentences
3146 article-remove-leading-whitespace
3147 article-display-x-face
3148 article-de-quoted-unreadable
3149 article-de-base64-unreadable
3152 article-hide-list-identifiers
3154 article-strip-banner
3157 article-hide-signature
3158 article-strip-headers-in-body
3159 article-remove-trailing-blank-lines
3160 article-strip-leading-blank-lines
3161 article-strip-multiple-blank-lines
3162 article-strip-leading-space
3163 article-strip-trailing-space
3164 article-strip-blank-lines
3165 article-strip-all-blank-lines
3167 article-date-english
3168 article-date-iso8601
3169 article-date-original
3171 article-decode-mime-words
3172 article-decode-charset
3173 article-decode-encoded-words
3177 article-treat-dumbquotes
3178 article-normalize-headers
3179 (article-show-all-headers . gnus-article-show-all-headers)
3180 (article-show-all . gnus-article-show-all))))
3183 ;;; Gnus article mode
3186 (put 'gnus-article-mode 'mode-class 'special)
3188 (gnus-define-keys gnus-article-mode-map
3189 " " gnus-article-goto-next-page
3190 "\177" gnus-article-goto-prev-page
3191 [delete] gnus-article-goto-prev-page
3192 [backspace] gnus-article-goto-prev-page
3193 "\C-c^" gnus-article-refer-article
3194 "h" gnus-article-show-summary
3195 "s" gnus-article-show-summary
3196 "\C-c\C-m" gnus-article-mail
3197 "?" gnus-article-describe-briefly
3198 "e" gnus-summary-edit-article
3199 "<" beginning-of-buffer
3201 "\C-c\C-i" gnus-info-find-node
3203 "\C-hk" gnus-article-describe-key
3204 "\C-hc" gnus-article-describe-key-briefly
3206 "\C-d" gnus-article-read-summary-keys
3207 "\M-*" gnus-article-read-summary-keys
3208 "\M-#" gnus-article-read-summary-keys
3209 "\M-^" gnus-article-read-summary-keys
3210 "\M-g" gnus-article-read-summary-keys)
3212 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3216 (push (char-to-string key) keys)
3218 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3219 (setq key (car elem))
3220 (when (and (> (length key) 0)
3221 (not (eq 'menu-bar (aref key 0)))
3222 (symbolp (lookup-key gnus-summary-mode-map key)))
3225 (unless (lookup-key gnus-article-mode-map key)
3226 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3228 (defun gnus-article-make-menu-bar ()
3229 (unless (boundp 'gnus-article-commands-menu)
3230 (gnus-summary-make-menu-bar))
3231 (gnus-turn-off-edit-menu 'article)
3232 (unless (boundp 'gnus-article-article-menu)
3234 gnus-article-article-menu gnus-article-mode-map ""
3236 ["Scroll forwards" gnus-article-goto-next-page t]
3237 ["Scroll backwards" gnus-article-goto-prev-page t]
3238 ["Show summary" gnus-article-show-summary t]
3239 ["Fetch Message-ID at point" gnus-article-refer-article t]
3240 ["Mail to address at point" gnus-article-mail t]
3241 ["Send a bug report" gnus-bug t]))
3244 gnus-article-treatment-menu gnus-article-mode-map ""
3245 ;; Fixme: this should use :active (and maybe :visible).
3247 ["Hide headers" gnus-article-toggle-headers t]
3248 ["Hide signature" gnus-article-hide-signature t]
3249 ["Hide citation" gnus-article-hide-citation t]
3250 ["Treat overstrike" gnus-article-treat-overstrike t]
3251 ["Remove carriage return" gnus-article-remove-cr t]
3252 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3253 ["Decode HZ" gnus-article-decode-HZ t]))
3255 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3257 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3259 (gnus-run-hooks 'gnus-article-menu-hook)))
3261 ;; Fixme: do something for the Emacs tool bar in Article mode a la
3264 (defun gnus-article-mode ()
3265 "Major mode for displaying an article.
3267 All normal editing commands are switched off.
3269 The following commands are available in addition to all summary mode
3271 \\<gnus-article-mode-map>
3272 \\[gnus-article-next-page]\t Scroll the article one page forwards
3273 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3274 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3275 \\[gnus-article-show-summary]\t Display the summary buffer
3276 \\[gnus-article-mail]\t Send a reply to the address near point
3277 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3278 \\[gnus-info-find-node]\t Go to the Gnus info node"
3280 (gnus-simplify-mode-line)
3281 (setq mode-name "Article")
3282 (setq major-mode 'gnus-article-mode)
3283 (make-local-variable 'minor-mode-alist)
3284 (unless (assq 'gnus-show-mime minor-mode-alist)
3285 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3286 (use-local-map gnus-article-mode-map)
3287 (when (gnus-visual-p 'article-menu 'menu)
3288 (gnus-article-make-menu-bar))
3289 (gnus-update-format-specifications nil 'article-mode)
3290 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3291 (make-local-variable 'gnus-page-broken)
3292 (make-local-variable 'gnus-button-marker-list)
3293 (make-local-variable 'gnus-article-current-summary)
3294 (make-local-variable 'gnus-article-mime-handles)
3295 (make-local-variable 'gnus-article-decoded-p)
3296 (make-local-variable 'gnus-article-mime-handle-alist)
3297 (make-local-variable 'gnus-article-wash-types)
3298 (make-local-variable 'gnus-article-charset)
3299 (make-local-variable 'gnus-article-ignored-charsets)
3300 (gnus-set-default-directory)
3301 (buffer-disable-undo)
3302 (setq buffer-read-only t)
3303 (set-syntax-table gnus-article-mode-syntax-table)
3304 (gnus-run-hooks 'gnus-article-mode-hook))
3306 (defun gnus-article-setup-buffer ()
3307 "Initialize the article buffer."
3308 (let* ((name (if gnus-single-article-buffer "*Article*"
3309 (concat "*Article " gnus-newsgroup-name "*")))
3311 (progn (string-match "\\*Article" name)
3312 (concat " *Original Article"
3313 (substring name (match-end 0))))))
3314 (setq gnus-article-buffer name)
3315 (setq gnus-original-article-buffer original)
3316 (setq gnus-article-mime-handle-alist nil)
3317 ;; This might be a variable local to the summary buffer.
3318 (unless gnus-single-article-buffer
3320 (set-buffer gnus-summary-buffer)
3321 (setq gnus-article-buffer name)
3322 (setq gnus-original-article-buffer original)
3323 (gnus-set-global-variables)))
3324 (gnus-article-setup-highlight-words)
3325 ;; Init original article buffer.
3327 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3328 (set-buffer-multibyte nil)
3329 (setq major-mode 'gnus-original-article-mode)
3330 (make-local-variable 'gnus-original-article))
3331 (if (get-buffer name)
3334 (buffer-disable-undo)
3335 (setq buffer-read-only t)
3336 (unless (eq major-mode 'gnus-article-mode)
3337 (gnus-article-mode))
3340 (set-buffer (gnus-get-buffer-create name))
3342 (make-local-variable 'gnus-summary-buffer)
3343 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3344 (current-buffer)))))
3346 ;; Set article window start at LINE, where LINE is the number of lines
3347 ;; from the head of the article.
3348 (defun gnus-article-set-window-start (&optional line)
3350 (get-buffer-window gnus-article-buffer t)
3352 (set-buffer gnus-article-buffer)
3353 (goto-char (point-min))
3356 (gnus-message 6 "Moved to bookmark")
3357 (search-forward "\n\n" nil t)
3361 ;;; @@ article filters
3364 (defun gnus-article-display-mime-message ()
3365 "Article display method for MIME message."
3366 ;; called from `gnus-original-article-buffer'.
3367 (let (charset all-headers)
3368 (with-current-buffer gnus-summary-buffer
3369 (setq charset default-mime-charset
3370 all-headers gnus-have-all-headers))
3371 (make-local-variable 'default-mime-charset)
3372 (setq default-mime-charset charset)
3373 (with-current-buffer (get-buffer-create gnus-article-buffer)
3374 (make-local-variable 'default-mime-charset)
3375 (setq default-mime-charset charset))
3376 (mime-display-message mime-message-structure
3377 gnus-article-buffer nil gnus-article-mode-map)
3379 (gnus-article-hide-headers nil -1)))
3380 (run-hooks 'gnus-mime-article-prepare-hook))
3382 (defun gnus-article-display-traditional-message ()
3383 "Article display method for traditional message."
3384 (set-buffer gnus-article-buffer)
3385 (let (buffer-read-only)
3387 (insert-buffer-substring gnus-original-article-buffer)))
3389 (defun gnus-article-make-full-mail-header (&optional number charset)
3390 "Create a new mail header structure in a raw article buffer."
3391 (unless (and number charset)
3392 (save-current-buffer
3393 (set-buffer gnus-summary-buffer)
3395 (setq number (or (cdr gnus-article-current) 0)))
3397 (setq charset (or default-mime-charset 'x-ctext)))))
3398 (goto-char (point-min))
3399 (let ((header-end (if (search-forward "\n\n" nil t)
3401 (goto-char (point-max))))
3402 (chars (- (point-max) (point)))
3403 (lines (count-lines (point) (point-max)))
3404 (default-mime-charset charset)
3406 (narrow-to-region (point-min) header-end)
3407 (setq xref (std11-fetch-field "xref"))
3409 (make-full-mail-header
3411 (std11-fetch-field "subject")
3412 (std11-fetch-field "from")
3413 (std11-fetch-field "date")
3414 (std11-fetch-field "message-id")
3415 (std11-fetch-field "references")
3418 (when xref (concat "Xref: " xref)))
3421 (defun gnus-article-prepare (article &optional all-headers header)
3422 "Prepare ARTICLE in article mode buffer.
3423 ARTICLE should either be an article number or a Message-ID.
3424 If ARTICLE is an id, HEADER should be the article headers.
3425 If ALL-HEADERS is non-nil, no headers are hidden."
3427 ;; Make sure we start in a summary buffer.
3428 (unless (eq major-mode 'gnus-summary-mode)
3429 (set-buffer gnus-summary-buffer))
3430 (setq gnus-summary-buffer (current-buffer))
3431 (let* ((gnus-article (if header (mail-header-number header) article))
3432 (summary-buffer (current-buffer))
3433 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3434 (group gnus-newsgroup-name)
3437 (gnus-article-setup-buffer)
3438 (set-buffer gnus-article-buffer)
3439 ;; Deactivate active regions.
3440 (when (and (boundp 'transient-mark-mode)
3441 transient-mark-mode)
3442 (setq mark-active nil))
3443 (if (not (setq result (let ((buffer-read-only nil))
3444 (gnus-request-article-this-buffer
3446 ;; There is no such article.
3448 (when (and (numberp article)
3449 (not (memq article gnus-newsgroup-sparse)))
3450 (setq gnus-article-current
3451 (cons gnus-newsgroup-name article))
3452 (set-buffer gnus-summary-buffer)
3453 (setq gnus-current-article article)
3454 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
3456 (gnus-summary-set-agent-mark article)
3457 (message "Message marked for downloading"))
3458 (gnus-summary-mark-article article gnus-canceled-mark)
3459 (unless (memq article gnus-newsgroup-sparse)
3460 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3461 (if (or (eq result 'pseudo)
3462 (eq result 'nneething))
3465 (set-buffer summary-buffer)
3466 (push article gnus-newsgroup-history)
3467 (setq gnus-last-article gnus-current-article
3468 gnus-current-article 0
3469 gnus-current-headers nil
3470 gnus-article-current nil)
3471 (if (eq result 'nneething)
3472 (gnus-configure-windows 'summary)
3473 (gnus-configure-windows 'article))
3474 (gnus-set-global-variables))
3475 (let ((gnus-article-mime-handle-alist-1
3476 gnus-article-mime-handle-alist))
3477 (gnus-set-mode-line 'article)))
3478 ;; The result from the `request' was an actual article -
3479 ;; or at least some text that is now displayed in the
3481 (when (and (numberp article)
3482 (not (eq article gnus-current-article)))
3483 ;; Seems like a new article has been selected.
3484 ;; `gnus-current-article' must be an article number.
3486 (set-buffer summary-buffer)
3487 (push article gnus-newsgroup-history)
3488 (setq gnus-last-article gnus-current-article
3489 gnus-current-article article
3490 gnus-current-headers
3491 (gnus-summary-article-header gnus-current-article)
3492 gnus-article-current
3493 (cons gnus-newsgroup-name gnus-current-article))
3494 (unless (vectorp gnus-current-headers)
3495 (setq gnus-current-headers nil))
3496 (gnus-summary-goto-subject gnus-current-article)
3497 (when (gnus-summary-show-thread)
3498 ;; If the summary buffer really was folded, the
3499 ;; previous goto may not actually have gone to
3500 ;; the right article, but the thread root instead.
3502 (gnus-summary-goto-subject gnus-current-article))
3503 (gnus-run-hooks 'gnus-mark-article-hook)
3504 (gnus-set-mode-line 'summary)
3505 (when (gnus-visual-p 'article-highlight 'highlight)
3506 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3507 ;; Set the global newsgroup variables here.
3508 (gnus-set-global-variables)
3509 (setq gnus-have-all-headers
3510 (or all-headers gnus-show-all-headers))))
3512 (gnus-configure-windows 'article))
3513 (when (or (numberp article)
3515 (gnus-article-prepare-display)
3517 (goto-char (point-min))
3518 (setq gnus-page-broken
3519 (when gnus-break-pages
3520 (gnus-narrow-to-page)
3522 (let ((gnus-article-mime-handle-alist-1
3523 gnus-article-mime-handle-alist))
3524 (gnus-set-mode-line 'article))
3526 (set-window-point (get-buffer-window (current-buffer)) (point))
3527 (gnus-configure-windows 'article)
3530 (defun gnus-article-prepare-mime-display (&optional number)
3531 (goto-char (point-min))
3532 (when (re-search-forward "^[^\t ]+:" nil t)
3533 (goto-char (match-beginning 0)))
3534 (let ((entity (if (eq 1 (point-min))
3535 (get-text-property 1 'mime-view-entity)
3536 (get-text-property (point) 'mime-view-entity)))
3537 last-entity child-entity next type)
3538 (setq child-entity (mime-entity-children entity))
3540 (setq last-entity (nth (1- (length child-entity))
3542 (setq last-entity entity))
3544 (narrow-to-region (point)
3545 (if (search-forward "\n\n" nil t)
3548 (gnus-treat-article 'head)
3549 (put-text-property (point-min) (point-max) 'article-treated-header t)
3550 (goto-char (point-max)))
3551 (while (and (not (eobp)) entity)
3552 (setq next (set-marker
3554 (next-single-property-change (point) 'mime-view-entity
3556 (let ((types (mime-entity-content-type entity)))
3557 (while (eq 'multipart (mime-content-type-primary-type types))
3558 (setq entity (car (mime-entity-children entity))
3559 types (mime-entity-content-type entity)))
3561 (setq type (format "%s/%s"
3562 (mime-content-type-primary-type types)
3563 (mime-content-type-subtype types)))))
3564 (if (string-equal type "message/rfc822")
3567 (let ((children (mime-entity-children entity))
3570 (setq last-children (nth (1- (length children)) children))
3573 (not (eq last-children
3574 (get-text-property next 'mime-view-entity)))
3576 (next-single-property-change next
3578 nil (point-max)))))))
3579 (setq next (next-single-property-change next 'mime-view-entity
3582 (narrow-to-region (point) next)
3583 (gnus-article-prepare-mime-display)
3584 (goto-char (point-max)))
3585 (setq entity (get-text-property (point) 'mime-view-entity)))
3587 (narrow-to-region (point) next)
3588 ;; Kludge. We have to count true number, but for now,
3589 ;; part number is here only to achieve `last'.
3590 (gnus-treat-article nil 1
3591 (if (eq entity last-entity)
3594 (goto-char (point-max)))
3595 (setq entity (get-text-property next 'mime-view-entity))))))
3598 (defun gnus-article-prepare-display ()
3599 "Make the current buffer look like a nice article."
3600 (let ((gnus-article-buffer (current-buffer))
3602 (unless (eq major-mode 'gnus-article-mode)
3603 (gnus-article-mode))
3604 (setq buffer-read-only nil
3605 gnus-button-marker-list nil
3606 gnus-article-wash-types nil)
3609 (static-if (featurep 'xemacs)
3610 (map-extents (lambda (extent maparg) (delete-extent extent)))
3611 (let ((lists (overlay-lists)))
3612 (dolist (overlay (nconc (car lists) (cdr lists)))
3613 (delete-overlay overlay)))))
3614 (gnus-run-hooks 'gnus-tmp-internal-hook))
3615 (set-buffer gnus-original-article-buffer)
3617 (setq mime-message-structure gnus-current-headers)
3618 (mime-buffer-entity-set-buffer-internal mime-message-structure
3619 gnus-original-article-buffer)
3620 (mime-entity-set-representation-type-internal mime-message-structure
3621 'mime-buffer-entity)
3622 (luna-send mime-message-structure 'initialize-instance
3623 mime-message-structure)
3625 (let (mime-display-header-hook mime-display-text/plain-hook)
3626 (funcall gnus-article-display-method-for-mime))
3627 (funcall gnus-article-display-method-for-traditional))
3628 ;; Call the treatment functions.
3629 (let ((inhibit-read-only t))
3633 (gnus-article-prepare-mime-display)
3634 (narrow-to-region (goto-char (point-min))
3635 (if (search-forward "\n\n" nil t)
3638 (gnus-treat-article 'head)
3639 (put-text-property (point-min) (point-max) 'article-treated-header t)
3640 (goto-char (point-max))
3642 (narrow-to-region (point) (point-max))
3643 (gnus-treat-article nil))
3644 (put-text-property (point-min) (point-max) 'read-only nil)))
3645 (gnus-run-hooks 'gnus-article-prepare-hook))
3647 (defun gnus-article-decode-article-as-default-mime-charset ()
3648 "Decode an article as `default-mime-charset'. It won't work if the
3649 value of the variable `gnus-show-mime' is non-nil."
3650 (unless gnus-show-mime
3651 (set (make-local-variable 'default-mime-charset)
3652 (with-current-buffer gnus-summary-buffer
3653 default-mime-charset))
3654 (decode-mime-charset-region (point-min) (point-max)
3655 default-mime-charset)))
3658 ;;; Gnus MIME viewing functions
3661 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3662 "The following specs can be used:
3664 %T MIME type, along with additional info
3665 %n The `name' parameter
3666 %d The description, if any
3667 %l The length of the encoded part
3668 %p The part identifier number
3669 %e Dots if the part isn't displayed")
3671 (defvar gnus-mime-button-line-format-alist
3672 '((?t gnus-tmp-type ?s)
3673 (?T gnus-tmp-type-long ?s)
3674 (?n gnus-tmp-name ?s)
3675 (?d gnus-tmp-description ?s)
3677 (?l gnus-tmp-length ?d)
3678 (?e gnus-tmp-dots ?s)))
3680 (defvar gnus-mime-button-commands
3681 '((gnus-article-press-button "\r" "Toggle Display")
3682 (gnus-mime-view-part "v" "View Interactively...")
3683 (gnus-mime-view-part-as-type "t" "View As Type...")
3684 (gnus-mime-view-part-as-charset "C" "View As charset...")
3685 (gnus-mime-save-part "o" "Save...")
3686 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3687 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3688 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3689 (gnus-mime-internalize-part "E" "View Internally")
3690 (gnus-mime-externalize-part "e" "View Externally")
3691 (gnus-mime-pipe-part "|" "Pipe To Command...")
3692 (gnus-mime-action-on-part "." "Take action on the part")))
3694 (defun gnus-article-mime-part-status ()
3695 (with-current-buffer gnus-article-buffer
3696 (let ((entity (get-text-property (point-min) 'mime-view-entity))
3699 (setq children (mime-entity-children entity))
3700 (setq children (length children)))
3703 (format " (%d parts)" children))
3706 (defvar gnus-mime-button-map
3707 (let ((map (make-sparse-keymap)))
3708 (unless (>= (string-to-number emacs-version) 21)
3709 ;; XEmacs doesn't care.
3710 (set-keymap-parent map gnus-article-mode-map))
3711 (define-key map gnus-mouse-2 'gnus-article-push-button)
3712 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3713 (dolist (c gnus-mime-button-commands)
3714 (define-key map (cadr c) (car c)))
3717 (defun gnus-mime-button-menu (event)
3718 "Construct a context-sensitive menu of MIME commands."
3720 (save-window-excursion
3721 (let ((pos (event-start event)))
3722 (select-window (posn-window pos))
3723 (goto-char (posn-point pos))
3724 (gnus-article-check-buffer)
3725 (let ((response (x-popup-menu
3727 ("" ,@(mapcar (lambda (c)
3728 (cons (caddr c) (car c)))
3729 gnus-mime-button-commands))))))
3731 (call-interactively response))))))
3733 (defun gnus-mime-view-all-parts (&optional handles)
3734 "View all the MIME parts."
3736 (save-current-buffer
3737 (set-buffer gnus-article-buffer)
3738 (let ((handles (or handles gnus-article-mime-handles))
3739 (mail-parse-charset gnus-newsgroup-charset)
3740 (mail-parse-ignored-charsets
3741 (with-current-buffer gnus-summary-buffer
3742 gnus-newsgroup-ignored-charsets)))
3744 (mm-remove-parts handles)
3745 (goto-char (point-min))
3746 (or (search-forward "\n\n") (goto-char (point-max)))
3747 (let (buffer-read-only)
3748 (delete-region (point) (point-max))
3749 (mm-display-parts handles))))))
3751 (defun gnus-mime-save-part-and-strip ()
3752 "Save the MIME part under point then replace it with an external body."
3754 (gnus-article-check-buffer)
3755 (let* ((data (get-text-property (point) 'gnus-data))
3757 (handles gnus-article-mime-handles))
3758 (if (mm-multiple-handles gnus-article-mime-handles)
3759 (error "This function is not implemented"))
3760 (setq file (and data (mm-save-part data)))
3762 (with-current-buffer (mm-handle-buffer data)
3764 (insert "Content-Type: " (mm-handle-media-type data))
3765 (mml-insert-parameter-string (cdr (mm-handle-type data))
3768 (insert "Content-ID: " (message-make-message-id) "\n")
3769 (insert "Content-Transfer-Encoding: binary\n")
3772 (cdr (mm-make-handle nil
3773 `("message/external-body"
3774 (access-type . "LOCAL-FILE")
3776 (set-buffer gnus-summary-buffer)
3777 (gnus-article-edit-article
3780 (let ((mail-parse-charset (or gnus-article-charset
3781 ',gnus-newsgroup-charset))
3782 (mail-parse-ignored-charsets
3783 (or gnus-article-ignored-charsets
3784 ',gnus-newsgroup-ignored-charsets))
3785 (mbl mml-buffer-list))
3786 (setq mml-buffer-list nil)
3787 (insert-buffer gnus-original-article-buffer)
3788 (mime-to-mml ',handles)
3789 (setq gnus-article-mime-handles nil)
3790 (let ((mbl1 mml-buffer-list))
3791 (setq mml-buffer-list mbl)
3792 (set (make-local-variable 'mml-buffer-list) mbl1))
3793 ;; LOCAL argument of add-hook differs between GNU Emacs
3794 ;; and XEmacs. make-local-hook makes sure they are local.
3795 (make-local-hook 'kill-buffer-hook)
3796 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3797 `(lambda (no-highlight)
3798 (let ((mail-parse-charset (or gnus-article-charset
3799 ',gnus-newsgroup-charset))
3800 (message-options message-options)
3801 (message-options-set-recipient)
3802 (mail-parse-ignored-charsets
3803 (or gnus-article-ignored-charsets
3804 ',gnus-newsgroup-ignored-charsets)))
3806 (mml-destroy-buffers)
3807 (remove-hook 'kill-buffer-hook
3808 'mml-destroy-buffers t)
3809 (kill-local-variable 'mml-buffer-list))
3810 (gnus-summary-edit-article-done
3811 ,(or (mail-header-references gnus-current-headers) "")
3812 ,(gnus-group-read-only-p)
3813 ,gnus-summary-buffer no-highlight))))))
3815 (defun gnus-mime-save-part ()
3816 "Save the MIME part under point."
3818 (gnus-article-check-buffer)
3819 (let ((data (get-text-property (point) 'gnus-data)))
3821 (mm-save-part data))))
3823 (defun gnus-mime-pipe-part ()
3824 "Pipe the MIME part under point to a process."
3826 (gnus-article-check-buffer)
3827 (let ((data (get-text-property (point) 'gnus-data)))
3829 (mm-pipe-part data))))
3831 (defun gnus-mime-view-part ()
3832 "Interactively choose a viewing method for the MIME part under point."
3834 (gnus-article-check-buffer)
3835 (let ((data (get-text-property (point) 'gnus-data)))
3837 (setq gnus-article-mime-handles
3839 gnus-article-mime-handles (setq data (copy-sequence data))))
3840 (mm-interactively-view-part data))))
3842 (defun gnus-mime-view-part-as-type-internal ()
3843 (gnus-article-check-buffer)
3844 (let* ((name (mail-content-type-get
3845 (mm-handle-type (get-text-property (point) 'gnus-data))
3847 (def-type (and name (mm-default-file-encoding name))))
3848 (and def-type (cons def-type 0))))
3850 (defun gnus-mime-view-part-as-type (&optional mime-type)
3851 "Choose a MIME media type, and view the part as such."
3854 (setq mime-type (completing-read
3855 "View as MIME type: "
3856 (mapcar #'list (mailcap-mime-types))
3858 (gnus-mime-view-part-as-type-internal))))
3859 (gnus-article-check-buffer)
3860 (let ((handle (get-text-property (point) 'gnus-data)))
3863 (mm-make-handle (mm-handle-buffer handle)
3864 (cons mime-type (cdr (mm-handle-type handle)))
3865 (mm-handle-encoding handle)
3866 (mm-handle-undisplayer handle)
3867 (mm-handle-disposition handle)
3868 (mm-handle-description handle)
3870 (mm-handle-id handle)))
3871 (setq gnus-article-mime-handles
3872 (mm-merge-handles gnus-article-mime-handles handle))
3873 (gnus-mm-display-part handle))))
3875 (defun gnus-mime-copy-part (&optional handle)
3876 "Put the the MIME part under point into a new buffer."
3878 (gnus-article-check-buffer)
3879 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3880 (contents (and handle (mm-get-part handle)))
3882 (file-name-nondirectory
3884 (mail-content-type-get (mm-handle-type handle) 'name)
3885 (mail-content-type-get (mm-handle-type handle)
3888 (buffer (and base (generate-new-buffer base))))
3890 (switch-to-buffer buffer)
3892 ;; We do it this way to make `normal-mode' set the appropriate mode.
3895 (setq buffer-file-name (expand-file-name base))
3897 (setq buffer-file-name nil))
3898 (goto-char (point-min)))))
3900 (defun gnus-mime-inline-part (&optional handle arg)
3901 "Insert the MIME part under point into the current buffer."
3902 (interactive (list nil current-prefix-arg))
3903 (gnus-article-check-buffer)
3904 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3909 (if (and (not arg) (mm-handle-undisplayer handle))
3910 (mm-remove-part handle)
3911 (setq contents (mm-get-part handle))
3914 (setq charset (or (mail-content-type-get
3915 (mm-handle-type handle) 'charset)
3916 gnus-newsgroup-charset)))
3918 (if (mm-handle-undisplayer handle)
3919 (mm-remove-part handle))
3922 gnus-summary-show-article-charset-alist))
3923 (mm-read-coding-system "Charset: ")))))
3925 (mm-insert-inline handle
3927 (setq charset (mm-charset-to-coding-system
3929 (not (eq charset 'ascii)))
3930 (mm-decode-coding-string contents charset)
3934 (defun gnus-mime-view-part-as-charset (&optional handle arg)
3935 "Insert the MIME part under point into the current buffer using the
3937 (interactive (list nil current-prefix-arg))
3938 (gnus-article-check-buffer)
3939 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3944 (if (mm-handle-undisplayer handle)
3945 (mm-remove-part handle))
3946 (let ((gnus-newsgroup-charset
3948 gnus-summary-show-article-charset-alist))
3949 (mm-read-coding-system "Charset: ")))
3950 (gnus-newsgroup-ignored-charsets 'gnus-all))
3951 (gnus-article-press-button)))))
3953 (defun gnus-mime-externalize-part (&optional handle)
3954 "View the MIME part under point with an external viewer."
3956 (gnus-article-check-buffer)
3957 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3958 (mm-user-display-methods nil)
3959 (mm-inlined-types nil)
3960 (mail-parse-charset gnus-newsgroup-charset)
3961 (mail-parse-ignored-charsets
3962 (save-excursion (set-buffer gnus-summary-buffer)
3963 gnus-newsgroup-ignored-charsets)))
3965 (if (mm-handle-undisplayer handle)
3966 (mm-remove-part handle)
3967 (mm-display-part handle)))))
3969 (defun gnus-mime-internalize-part (&optional handle)
3970 "View the MIME part under point with an internal viewer.
3971 If no internal viewer is available, use an external viewer."
3973 (gnus-article-check-buffer)
3974 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3975 (mm-inlined-types '(".*"))
3976 (mm-inline-large-images t)
3977 (mail-parse-charset gnus-newsgroup-charset)
3978 (mail-parse-ignored-charsets
3979 (save-excursion (set-buffer gnus-summary-buffer)
3980 gnus-newsgroup-ignored-charsets)))
3982 (if (mm-handle-undisplayer handle)
3983 (mm-remove-part handle)
3984 (mm-display-part handle)))))
3986 (defun gnus-mime-action-on-part (&optional action)
3987 "Do something with the MIME attachment at \(point\)."
3989 (list (completing-read "Action: " gnus-mime-action-alist)))
3990 (gnus-article-check-buffer)
3991 (let ((action-pair (assoc action gnus-mime-action-alist)))
3993 (funcall (cdr action-pair)))))
3995 (defun gnus-article-part-wrapper (n function)
3996 (save-current-buffer
3997 (set-buffer gnus-article-buffer)
3998 (when (> n (length gnus-article-mime-handle-alist))
3999 (error "No such part"))
4000 (gnus-article-goto-part n)
4001 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4002 (funcall function handle))))
4004 (defun gnus-article-pipe-part (n)
4005 "Pipe MIME part N, which is the numerical prefix."
4007 (gnus-article-part-wrapper n 'mm-pipe-part))
4009 (defun gnus-article-save-part (n)
4010 "Save MIME part N, which is the numerical prefix."
4012 (gnus-article-part-wrapper n 'mm-save-part))
4014 (defun gnus-article-interactively-view-part (n)
4015 "View MIME part N interactively, which is the numerical prefix."
4017 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4019 (defun gnus-article-copy-part (n)
4020 "Copy MIME part N, which is the numerical prefix."
4022 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4024 (defun gnus-article-view-part-as-charset (n)
4025 "Copy MIME part N, which is the numerical prefix."
4027 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4029 (defun gnus-article-externalize-part (n)
4030 "View MIME part N externally, which is the numerical prefix."
4032 (gnus-article-part-wrapper n 'gnus-mime-externalize-part))
4034 (defun gnus-article-inline-part (n)
4035 "Inline MIME part N, which is the numerical prefix."
4037 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4039 (defun gnus-article-mime-match-handle-first (condition)
4041 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4042 (while (setq ihandle (pop alist))
4044 ((functionp condition)
4045 (funcall condition (cdr ihandle)))
4046 ((eq condition 'undisplayed)
4047 (not (or (mm-handle-undisplayer (cdr ihandle))
4048 (equal (mm-handle-media-type (cdr ihandle))
4049 "multipart/alternative"))))
4050 ((eq condition 'undisplayed-alternative)
4051 (not (mm-handle-undisplayer (cdr ihandle))))
4053 (gnus-article-goto-part (car ihandle))
4054 (or (not n) (< (car ihandle) n)))
4055 (setq n (car ihandle))))
4059 (defun gnus-article-view-part (&optional n)
4060 "View MIME part N, which is the numerical prefix."
4062 (save-current-buffer
4063 (set-buffer gnus-article-buffer)
4064 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4065 gnus-article-mime-match-handle-function)))
4066 (when (> n (length gnus-article-mime-handle-alist))
4067 (error "No such part"))
4068 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4069 (when (gnus-article-goto-part n)
4070 (if (equal (car handle) "multipart/alternative")
4071 (gnus-article-press-button)
4072 (when (eq (gnus-mm-display-part handle) 'internal)
4073 (gnus-set-window-start)))))))
4075 (defsubst gnus-article-mime-total-parts ()
4076 (if (bufferp (car gnus-article-mime-handles))
4078 (1- (length gnus-article-mime-handles))))
4080 (defun gnus-mm-display-part (handle)
4081 "Display HANDLE and fix MIME button."
4082 (let ((id (get-text-property (point) 'gnus-part))
4087 (let ((window (selected-window))
4088 (mail-parse-charset gnus-newsgroup-charset)
4089 (mail-parse-ignored-charsets
4090 (save-excursion (set-buffer gnus-summary-buffer)
4091 gnus-newsgroup-ignored-charsets)))
4094 (let ((win (get-buffer-window (current-buffer) t))
4097 (select-window win))
4100 (if (mm-handle-displayed-p handle)
4101 ;; This will remove the part.
4102 (mm-display-part handle)
4104 (narrow-to-region (point)
4105 (if (eobp) (point) (1+ (point))))
4106 (mm-display-part handle)
4107 ;; We narrow to the part itself and
4108 ;; then call the treatment functions.
4109 (goto-char (point-min))
4111 (narrow-to-region (point) (point-max))
4114 (gnus-article-mime-total-parts)
4115 (mm-handle-media-type handle)))))
4116 (if (window-live-p window)
4117 (select-window window)))))
4119 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
4120 (gnus-insert-mime-button
4121 handle id (list (mm-handle-displayed-p handle)))
4122 (goto-char point))))
4124 (defun gnus-article-goto-part (n)
4125 "Go to MIME part N."
4126 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
4128 (goto-char point))))
4130 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4131 (let ((gnus-tmp-name
4132 (or (mail-content-type-get (mm-handle-type handle) 'name)
4133 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4134 (mail-content-type-get (mm-handle-type handle) 'url)
4136 (gnus-tmp-type (mm-handle-media-type handle))
4137 (gnus-tmp-description
4138 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4141 (if (if displayed (car displayed)
4142 (mm-handle-displayed-p handle))
4144 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4146 gnus-tmp-type-long b e)
4147 (when (string-match ".*/" gnus-tmp-name)
4148 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4149 (setq gnus-tmp-type-long (concat gnus-tmp-type
4150 (and (not (equal gnus-tmp-name ""))
4151 (concat "; " gnus-tmp-name))))
4152 (unless (equal gnus-tmp-description "")
4153 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4158 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4159 `(keymap ,gnus-mime-button-map
4160 ,@(if (>= (string-to-number emacs-version) 21)
4162 (list 'local-map gnus-mime-button-map))
4163 gnus-callback gnus-mm-display-part
4164 gnus-part ,gnus-tmp-id
4165 article-type annotation
4168 (widget-convert-button
4171 :action 'gnus-widget-press-button
4172 :button-keymap gnus-mime-button-map
4174 (lambda (widget/window &optional overlay pos)
4175 ;; Needed to properly clear the message due to a bug in
4176 ;; wid-edit (XEmacs only).
4177 (if (boundp 'help-echo-owns-message)
4178 (setq help-echo-owns-message t))
4180 "%S: %s the MIME part; %S: more options"
4181 (aref gnus-mouse-2 0)
4182 ;; XEmacs will get a single widget arg; Emacs 21 will get
4183 ;; window, overlay, position.
4184 (if (mm-handle-displayed-p
4186 (with-current-buffer (gnus-overlay-buffer overlay)
4187 (widget-get (widget-at (gnus-overlay-start overlay))
4189 (widget-get widget/window :mime-handle)))
4191 (aref gnus-down-mouse-3 0))))))
4193 (defun gnus-widget-press-button (elems el)
4194 (goto-char (widget-get elems :from))
4195 (gnus-article-press-button))
4197 (defvar gnus-displaying-mime nil)
4199 (defun gnus-display-mime (&optional ihandles)
4200 "Display the MIME parts."
4202 (save-selected-window
4203 (let ((window (get-buffer-window gnus-article-buffer))
4206 (select-window window)
4207 ;; We have to do this since selecting the window
4208 ;; may change the point. So we set the window point.
4209 (set-window-point window point)))
4210 (let* ((handles (or ihandles (mm-dissect-buffer) (mm-uu-dissect)))
4211 buffer-read-only handle name type b e display)
4212 (when (and (not ihandles)
4213 (not gnus-displaying-mime))
4214 ;; Top-level call; we clean up.
4215 (when gnus-article-mime-handles
4216 (mm-destroy-parts gnus-article-mime-handles)
4217 (setq gnus-article-mime-handle-alist nil));; A trick.
4218 (setq gnus-article-mime-handles handles)
4219 ;; We allow users to glean info from the handles.
4220 (when gnus-article-mime-part-function
4221 (gnus-mime-part-function handles)))
4223 (or (not (stringp (car handles)))
4226 (when (and (not ihandles)
4227 (not gnus-displaying-mime))
4228 ;; Clean up for mime parts.
4230 (delete-region (point) (point-max)))
4231 (let ((gnus-displaying-mime t))
4232 (gnus-mime-display-part handles)))
4235 (narrow-to-region (point) (point-max))
4236 (gnus-treat-article nil 1 1)
4239 ;; Highlight the headers.
4243 (narrow-to-region (point-min) (point))
4244 (gnus-treat-article 'head))))))))
4246 (defvar gnus-mime-display-multipart-as-mixed nil)
4247 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
4248 (defvar gnus-mime-display-multipart-related-as-mixed nil)
4250 (defun gnus-mime-display-part (handle)
4253 ((not (stringp (car handle)))
4254 (gnus-mime-display-single handle))
4255 ;; User-defined multipart
4256 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4257 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4259 ;; multipart/alternative
4260 ((and (equal (car handle) "multipart/alternative")
4261 (not (or gnus-mime-display-multipart-as-mixed
4262 gnus-mime-display-multipart-alternative-as-mixed)))
4263 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4264 (push (cons id handle) gnus-article-mime-handle-alist)
4265 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4266 ;; multipart/related
4267 ((and (equal (car handle) "multipart/related")
4268 (not (or gnus-mime-display-multipart-as-mixed
4269 gnus-mime-display-multipart-related-as-mixed)))
4270 ;;;!!!We should find the start part, but we just default
4271 ;;;!!!to the first part.
4272 ;;(gnus-mime-display-part (cadr handle))
4273 ;;;!!! Most multipart/related is an HTML message plus images.
4274 ;;;!!! Unfortunately we are unable to let W3 display those
4275 ;;;!!! included images, so we just display it as a mixed multipart.
4276 ;;(gnus-mime-display-mixed (cdr handle))
4277 ;;;!!! No, w3 can display everything just fine.
4278 (gnus-mime-display-part (cadr handle)))
4279 ((equal (car handle) "multipart/signed")
4280 (or (memq 'signed gnus-article-wash-types)
4281 (push 'signed gnus-article-wash-types))
4282 (gnus-mime-display-security handle))
4283 ((equal (car handle) "multipart/encrypted")
4284 (or (memq 'encrypted gnus-article-wash-types)
4285 (push 'encrypted gnus-article-wash-types))
4286 (gnus-mime-display-security handle))
4287 ;; Other multiparts are handled like multipart/mixed.
4289 (gnus-mime-display-mixed (cdr handle)))))
4291 (defun gnus-mime-part-function (handles)
4292 (if (stringp (car handles))
4293 (mapcar 'gnus-mime-part-function (cdr handles))
4294 (funcall gnus-article-mime-part-function handles)))
4296 (defun gnus-mime-display-mixed (handles)
4297 (mapcar 'gnus-mime-display-part handles))
4299 (defun gnus-mime-display-single (handle)
4300 (let ((type (mm-handle-media-type handle))
4301 (ignored gnus-ignored-mime-types)
4308 (when (string-match (pop ignored) type)
4309 (throw 'ignored nil)))
4310 (if (and (setq not-attachment
4311 (and (not (mm-inline-override-p handle))
4312 (or (not (mm-handle-disposition handle))
4313 (equal (car (mm-handle-disposition handle))
4315 (mm-attachment-override-p handle))))
4316 (mm-automatic-display-p handle)
4318 (mm-inlinable-p handle)
4319 (mm-inlined-p handle))
4320 (mm-automatic-external-display-p type)))
4322 (when (equal (mm-handle-media-supertype handle) "text")
4324 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4326 (push (cons id handle) gnus-article-mime-handle-alist)
4327 (when (or (not display)
4328 (not (gnus-unbuttonized-mime-type-p type)))
4329 ;(gnus-article-insert-newline)
4330 (gnus-insert-mime-button
4331 handle id (list (or display (and not-attachment text))))
4332 (gnus-article-insert-newline)
4333 ;(gnus-article-insert-newline)
4334 ;; Remember modify the number of forward lines.
4342 (let ((mail-parse-charset gnus-newsgroup-charset)
4343 (mail-parse-ignored-charsets
4344 (save-excursion (condition-case ()
4345 (set-buffer gnus-summary-buffer)
4347 gnus-newsgroup-ignored-charsets)))
4348 (mm-display-part handle t))
4349 (goto-char (point-max)))
4350 ((and text not-attachment)
4354 (gnus-article-insert-newline)
4355 (mm-insert-inline handle (mm-get-part handle))
4356 (goto-char (point-max))))
4360 (narrow-to-region beg (point))
4363 (gnus-article-mime-total-parts)
4364 (mm-handle-media-type handle)))))))))
4366 (defun gnus-unbuttonized-mime-type-p (type)
4367 "Say whether TYPE is to be unbuttonized."
4368 (unless gnus-inhibit-mime-unbuttonizing
4370 (let ((types gnus-unbuttonized-mime-types))
4372 (when (string-match (pop types) type)
4373 (throw 'found t)))))
4375 (let ((types gnus-buttonized-mime-types))
4377 (when (string-match (pop types) type)
4378 (throw 'found t)))))))))
4380 (defun gnus-article-insert-newline ()
4381 "Insert a newline, but mark it as undeletable."
4382 (gnus-put-text-property
4383 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4385 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4386 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4389 handle buffer-read-only from props begend not-pref)
4390 (save-window-excursion
4393 (narrow-to-region (car ibegend)
4396 (goto-char (car ibegend))
4399 (delete-region (point-min) (point-max))
4400 (mm-remove-parts handles))
4401 (setq begend (list (point-marker)))
4403 (unless (setq not-pref (cadr (member preferred ihandles)))
4404 (setq not-pref (car ihandles)))
4407 (not (gnus-unbuttonized-mime-type-p
4408 "multipart/alternative")))
4409 (gnus-add-text-properties
4412 (insert (format "%d. " id))
4416 (unless ,(not ibegend)
4417 (setq gnus-article-mime-handle-alist
4418 ',gnus-article-mime-handle-alist))
4419 (gnus-mime-display-alternative
4420 ',ihandles ',not-pref ',begend ,id))
4421 ,@(if (>= (string-to-number emacs-version) 21)
4422 nil ;; XEmacs doesn't care
4423 (list 'local-map gnus-mime-button-map))
4424 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4425 face ,gnus-article-button-face
4426 keymap ,gnus-mime-button-map
4429 (widget-convert-button 'link from (point)
4430 :action 'gnus-widget-press-button
4431 :button-keymap gnus-widget-button-keymap)
4433 (while (setq handle (pop handles))
4434 (gnus-add-text-properties
4437 (insert (format "(%c) %-18s"
4438 (if (equal handle preferred) ?* ? )
4439 (mm-handle-media-type handle)))
4443 (unless ,(not ibegend)
4444 (setq gnus-article-mime-handle-alist
4445 ',gnus-article-mime-handle-alist))
4446 (gnus-mime-display-alternative
4447 ',ihandles ',handle ',begend ,id))
4448 ,@(if (>= (string-to-number emacs-version) 21)
4449 nil ;; XEmacs doesn't care
4450 (list 'local-map gnus-mime-button-map))
4451 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4452 face ,gnus-article-button-face
4453 keymap ,gnus-mime-button-map
4456 (widget-convert-button 'link from (point)
4457 :action 'gnus-widget-press-button
4458 :button-keymap gnus-widget-button-keymap)
4462 (if (stringp (car preferred))
4463 (gnus-display-mime preferred)
4464 (let ((mail-parse-charset gnus-newsgroup-charset)
4465 (mail-parse-ignored-charsets
4466 (save-excursion (set-buffer gnus-summary-buffer)
4467 gnus-newsgroup-ignored-charsets)))
4468 (mm-display-part preferred)
4472 (narrow-to-region (car begend) (point-max))
4474 nil (length gnus-article-mime-handle-alist)
4475 (gnus-article-mime-total-parts)
4476 (mm-handle-media-type handle))))))
4477 (goto-char (point-max))
4478 (setcdr begend (point-marker)))))
4480 (goto-char point))))
4482 (defconst gnus-article-wash-status-strings
4483 (let ((alist '((cite "c" "Possible hidden citation text"
4484 " " "All citation text visible")
4485 (headers "h" "Hidden headers"
4486 " " "All headers visible.")
4487 (pgp "p" "Encrypted or signed message status hidden"
4488 " " "No hidden encryption nor digital signature status")
4489 (signature "s" "Signature has been hidden"
4490 " " "Signature is visible")
4491 (overstrike "o" "Overstrike (^H) characters applied"
4492 " " "No overstrike characters applied")
4493 (gnus-show-mime "m" "Mime processing is activated"
4494 " " "Mime processing is not activated")
4495 (emphasis "e" "/*_Emphasis_*/ characters applied"
4496 " " "No /*_emphasis_*/ characters applied")))
4498 (dolist (entry alist result)
4499 (let ((key (nth 0 entry))
4500 (on (copy-seq (nth 1 entry)))
4501 (on-help (nth 2 entry))
4502 (off (copy-seq (nth 3 entry)))
4503 (off-help (nth 4 entry)))
4504 (put-text-property 0 1 'help-echo on-help on)
4505 (put-text-property 0 1 'help-echo off-help off)
4506 (push (list key on off) result))))
4507 "Alist of strings describing wash status in the mode line.
4508 Each entry has the form (KEY ON OF), where the KEY is a symbol
4509 representing the particular washing function, ON is the string to use
4510 in the article mode line when the washing function is active, and OFF
4511 is the string to use when it is inactive.")
4513 (defun gnus-gnus-article-wash-status-entry (key value)
4514 (let ((entry (assoc key gnus-article-wash-status-strings)))
4515 (if value (nth 1 entry) (nth 2 entry))))
4517 (defun gnus-article-wash-status ()
4518 "Return a string which display status of article washing."
4520 (set-buffer gnus-article-buffer)
4521 (let ((cite (memq 'cite gnus-article-wash-types))
4522 (headers (memq 'headers gnus-article-wash-types))
4523 (boring (memq 'boring-headers gnus-article-wash-types))
4524 (pgp (memq 'pgp gnus-article-wash-types))
4525 (pem (memq 'pem gnus-article-wash-types))
4526 (signed (memq 'signed gnus-article-wash-types))
4527 (encrypted (memq 'encrypted gnus-article-wash-types))
4528 (signature (memq 'signature gnus-article-wash-types))
4529 (overstrike (memq 'overstrike gnus-article-wash-types))
4530 (emphasis (memq 'emphasis gnus-article-wash-types)))
4531 (concat (gnus-gnus-article-wash-status-entry 'cite cite)
4532 (gnus-gnus-article-wash-status-entry 'headers
4533 (or headers boring))
4534 (gnus-gnus-article-wash-status-entry
4535 'pgp (or pgp pem signed encrypted))
4536 (gnus-gnus-article-wash-status-entry 'signature signature)
4537 (gnus-gnus-article-wash-status-entry 'overstrike overstrike)
4538 (gnus-gnus-article-wash-status-entry 'gnus-show-mime
4540 (gnus-gnus-article-wash-status-entry 'emphasis emphasis)))))
4542 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4544 (defun gnus-article-maybe-hide-headers ()
4545 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4546 Provided for backwards compatibility."
4547 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4548 (not (save-excursion (set-buffer gnus-summary-buffer)
4549 gnus-have-all-headers)))
4550 (not gnus-inhibit-hiding))
4551 (gnus-article-hide-headers)))
4555 (defun gnus-output-to-file (file-name)
4556 "Append the current article to a file named FILE-NAME."
4557 (let ((artbuf (current-buffer)))
4559 (insert-buffer-substring artbuf)
4560 ;; Append newline at end of the buffer as separator, and then
4562 (goto-char (point-max))
4564 (let ((file-name-coding-system nnmail-pathname-coding-system)
4565 (pathname-coding-system nnmail-pathname-coding-system))
4566 (write-region-as-binary (point-min) (point-max) file-name 'append))
4569 (defun gnus-narrow-to-page (&optional arg)
4570 "Narrow the article buffer to a page.
4571 If given a numerical ARG, move forward ARG pages."
4573 (setq arg (if arg (prefix-numeric-value arg) 0))
4575 (set-buffer gnus-article-buffer)
4576 (goto-char (point-min))
4578 ;; Remove any old next/prev buttons.
4579 (when (gnus-visual-p 'page-marker)
4580 (let ((buffer-read-only nil))
4581 (gnus-remove-text-with-property 'gnus-prev)
4582 (gnus-remove-text-with-property 'gnus-next)))
4585 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4587 (re-search-forward page-delimiter nil 'move arg)))
4588 (goto-char (match-end 0)))
4591 (if (re-search-forward page-delimiter nil 'move)
4594 (when (and (gnus-visual-p 'page-marker)
4595 (not (= (point-min) 1)))
4597 (goto-char (point-min))
4598 (gnus-insert-prev-page-button)))
4599 (when (and (gnus-visual-p 'page-marker)
4600 (< (+ (point-max) 2) (buffer-size)))
4602 (goto-char (point-max))
4603 (gnus-insert-next-page-button)))))
4605 ;; Article mode commands
4607 (defun gnus-article-goto-next-page ()
4608 "Show the next page of the article."
4610 (when (gnus-article-next-page)
4611 (goto-char (point-min))
4612 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4614 (defun gnus-article-goto-prev-page ()
4615 "Show the next page of the article."
4617 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4618 (gnus-article-prev-page nil)))
4620 (defun gnus-article-next-page (&optional lines)
4621 "Show the next page of the current article.
4622 If end of article, return non-nil. Otherwise return nil.
4623 Argument LINES specifies lines to be scrolled up."
4625 (let ((start (window-start))
4626 end-of-buffer end-of-page)
4628 (move-to-window-line -1)
4629 (if (<= (point) start)
4632 (setq start (point)))
4635 (unless (or (cond ((eq (1+ (buffer-size)) (point))
4636 (and (pos-visible-in-window-p)
4637 (setq end-of-buffer t)))
4639 (setq end-of-page t)))
4641 (move-to-window-line lines)
4642 (unless (search-backward "\n\n" nil t)
4643 (setq start (point)))))
4644 (cond (end-of-buffer t)
4646 (gnus-narrow-to-page 1)
4650 (set-window-start (selected-window) start)
4651 (let (window-pixel-scroll-increment)
4655 (defun gnus-article-prev-page (&optional lines)
4656 "Show previous page of current article.
4657 Argument LINES specifies lines to be scrolled down."
4659 (let (beginning-of-buffer beginning-of-page)
4661 (move-to-window-line 0)
4662 (cond ((eq 1 (point))
4663 (setq beginning-of-buffer t))
4665 (setq beginning-of-page t))))
4666 (cond (beginning-of-buffer)
4668 (gnus-narrow-to-page -1))
4671 (let (window-pixel-scroll-increment)
4672 (scroll-down lines))
4673 (beginning-of-buffer
4674 (goto-char (point-min))))))))
4676 (defun gnus-article-refer-article ()
4677 "Read article specified by message-id around point."
4679 (let ((point (point)))
4680 (search-forward ">" nil t) ;Move point to end of "<....>".
4681 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
4682 (let ((message-id (match-string 1)))
4684 (set-buffer gnus-summary-buffer)
4685 (gnus-summary-refer-article message-id))
4687 (error "No references around point"))))
4689 (defun gnus-article-show-summary ()
4690 "Reconfigure windows to show summary buffer."
4692 (if (not (gnus-buffer-live-p gnus-summary-buffer))
4693 (error "There is no summary buffer for this article buffer")
4694 (gnus-article-set-globals)
4695 (gnus-configure-windows 'article)
4696 (gnus-summary-goto-subject gnus-current-article)
4697 (gnus-summary-position-point)))
4699 (defun gnus-article-describe-briefly ()
4700 "Describe article mode commands briefly."
4702 (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")))
4704 (defun gnus-article-summary-command ()
4705 "Execute the last keystroke in the summary buffer."
4707 (let ((obuf (current-buffer))
4708 (owin (current-window-configuration))
4710 (switch-to-buffer gnus-article-current-summary 'norecord)
4711 (setq func (lookup-key (current-local-map) (this-command-keys)))
4712 (call-interactively func)
4714 (set-window-configuration owin)
4715 (set-window-point (get-buffer-window (current-buffer)) (point))))
4717 (defun gnus-article-summary-command-nosave ()
4718 "Execute the last keystroke in the summary buffer."
4721 (pop-to-buffer gnus-article-current-summary 'norecord)
4722 (setq func (lookup-key (current-local-map) (this-command-keys)))
4723 (call-interactively func)))
4725 (defun gnus-article-check-buffer ()
4726 "Beep if not in an article buffer."
4727 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
4728 (error "Command invoked outside of a Gnus article buffer")))
4730 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
4731 "Read a summary buffer key sequence and execute it from the article buffer."
4733 (gnus-article-check-buffer)
4735 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
4736 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
4737 "=" "^" "\M-^" "|"))
4743 '("n" "Gn" "p" "Gp"))
4746 (set-buffer gnus-article-current-summary)
4747 (let (gnus-pick-mode)
4748 (push (or key last-command-event) unread-command-events)
4749 (setq keys (static-if (featurep 'xemacs)
4750 (events-to-keys (read-key-sequence nil))
4751 (read-key-sequence nil)))))
4754 (if (or (member keys nosaves)
4755 (member keys nosave-but-article)
4756 (member keys nosave-in-article))
4758 (save-window-excursion
4759 (pop-to-buffer gnus-article-current-summary 'norecord)
4760 ;; We disable the pick minor mode commands.
4761 (let (gnus-pick-mode)
4762 (setq func (lookup-key (current-local-map) keys))))
4766 (unless (member keys nosave-in-article)
4767 (set-buffer gnus-article-current-summary))
4768 (call-interactively func)
4769 (setq new-sum-point (point)))
4770 (when (member keys nosave-but-article)
4771 (pop-to-buffer gnus-article-buffer 'norecord)))
4772 ;; These commands should restore window configuration.
4773 (let ((obuf (current-buffer))
4774 (owin (current-window-configuration))
4776 (summary gnus-article-current-summary)
4777 func in-buffer selected)
4778 (if not-restore-window
4779 (pop-to-buffer summary 'norecord)
4780 (switch-to-buffer summary 'norecord))
4781 (setq in-buffer (current-buffer))
4782 ;; We disable the pick minor mode commands.
4783 (if (and (setq func (let (gnus-pick-mode)
4784 (lookup-key (current-local-map) keys)))
4787 (call-interactively func)
4788 (setq new-sum-point (point))
4789 (when (eq in-buffer (current-buffer))
4790 (setq selected (gnus-summary-select-article))
4792 (unless not-restore-window
4793 (set-window-configuration owin))
4794 (when (eq selected 'old)
4796 (set-window-start (get-buffer-window (current-buffer))
4798 (set-window-point (get-buffer-window (current-buffer))
4800 (let ((win (get-buffer-window gnus-article-current-summary)))
4802 (set-window-point win new-sum-point)))) )
4803 (switch-to-buffer gnus-article-buffer)
4806 (defun gnus-article-describe-key (key)
4807 "Display documentation of the function invoked by KEY. KEY is a string."
4808 (interactive "kDescribe key: ")
4809 (gnus-article-check-buffer)
4810 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4812 (set-buffer gnus-article-current-summary)
4813 (let (gnus-pick-mode)
4814 (if (featurep 'xemacs)
4816 (push (elt key 0) unread-command-events)
4817 (setq key (events-to-keys
4818 (read-key-sequence "Describe key: "))))
4819 (setq unread-command-events
4821 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4823 (setq key (read-key-sequence "Describe key: "))))
4825 (describe-key key)))
4827 (defun gnus-article-describe-key-briefly (key &optional insert)
4828 "Display documentation of the function invoked by KEY. KEY is a string."
4829 (interactive "kDescribe key: \nP")
4830 (gnus-article-check-buffer)
4831 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4833 (set-buffer gnus-article-current-summary)
4834 (let (gnus-pick-mode)
4835 (if (featurep 'xemacs)
4837 (push (elt key 0) unread-command-events)
4838 (setq key (events-to-keys
4839 (read-key-sequence "Describe key: "))))
4840 (setq unread-command-events
4842 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4844 (setq key (read-key-sequence "Describe key: "))))
4845 (describe-key-briefly key insert))
4846 (describe-key-briefly key insert)))
4848 (defun gnus-article-hide (&optional arg force)
4849 "Hide all the gruft in the current article.
4850 This means that PGP stuff, signatures, cited text and (some)
4851 headers will be hidden.
4852 If given a prefix, show the hidden text instead."
4853 (interactive (append (gnus-article-hidden-arg) (list 'force)))
4854 (gnus-article-hide-headers arg)
4855 (gnus-article-hide-list-identifiers arg)
4856 (gnus-article-hide-pgp arg)
4857 (gnus-article-hide-citation-maybe arg force)
4858 (gnus-article-hide-signature arg))
4860 (defun gnus-article-maybe-highlight ()
4861 "Do some article highlighting if article highlighting is requested."
4862 (when (gnus-visual-p 'article-highlight 'highlight)
4863 (gnus-article-highlight-some)))
4865 (defun gnus-check-group-server ()
4866 ;; Make sure the connection to the server is alive.
4867 (unless (gnus-server-opened
4868 (gnus-find-method-for-group gnus-newsgroup-name))
4869 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
4870 (gnus-request-group gnus-newsgroup-name t)))
4872 (defun gnus-request-article-this-buffer (article group)
4873 "Get an article and insert it into this buffer.
4874 T-gnus change: Insert an article into `gnus-original-article-buffer'."
4875 (let (do-update-line sparse-header)
4876 ;; The current buffer is `gnus-article-buffer'.
4880 (gnus-kill-all-overlays)
4881 (setq group (or group gnus-newsgroup-name))
4883 ;; Using `gnus-request-article' directly will insert the article into
4884 ;; `nntp-server-buffer' - so we'll save some time by not having to
4885 ;; copy it from the server buffer into the article buffer.
4887 ;; We only request an article by message-id when we do not have the
4888 ;; headers for it, so we'll have to get those.
4889 (when (stringp article)
4890 (gnus-read-header article))
4892 ;; If the article number is negative, that means that this article
4893 ;; doesn't belong in this newsgroup (possibly), so we find its
4894 ;; message-id and request it by id instead of number.
4895 (when (and (numberp article)
4897 (get-buffer gnus-summary-buffer)
4898 (gnus-buffer-exists-p gnus-summary-buffer))
4900 (set-buffer gnus-summary-buffer)
4901 (let ((header (gnus-summary-article-header article)))
4904 ((memq article gnus-newsgroup-sparse)
4905 ;; This is a sparse gap article.
4906 (setq do-update-line article)
4907 (setq article (mail-header-id header))
4908 (setq sparse-header (gnus-read-header article))
4909 (setq gnus-newsgroup-sparse
4910 (delq article gnus-newsgroup-sparse)))
4912 ;; It's a real article.
4913 (setq article (mail-header-id header)))
4915 ;; It is an extracted pseudo-article.
4916 (setq article 'pseudo)
4917 (gnus-request-pseudo-article header))))
4919 (let ((method (gnus-find-method-for-group
4920 gnus-newsgroup-name)))
4921 (when (and (eq (car method) 'nneething)
4923 (let ((dir (expand-file-name
4924 (mail-header-subject header)
4925 (file-name-as-directory
4926 (or (cadr (assq 'nneething-address method))
4928 (when (file-directory-p dir)
4929 (setq article 'nneething)
4930 (gnus-group-enter-directory dir))))))))
4931 (setq gnus-original-article (cons group article))
4933 ;; The current buffer is `gnus-original-article-buffer'.
4934 (if (get-buffer gnus-original-article-buffer)
4935 (set-buffer gnus-original-article-buffer)
4936 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
4937 (set-buffer-multibyte nil)
4938 (buffer-disable-undo)
4939 (setq major-mode 'gnus-original-article-mode)
4940 (setq buffer-read-only nil))
4943 ;; Refuse to select canceled articles.
4944 ((and (numberp article)
4946 (get-buffer gnus-summary-buffer)
4947 (gnus-buffer-exists-p gnus-summary-buffer)
4948 (eq (cdr (save-excursion
4949 (set-buffer gnus-summary-buffer)
4950 (assq article gnus-newsgroup-reads)))
4951 gnus-canceled-mark))
4953 ;; Check the backlog.
4954 ((and gnus-keep-backlog
4955 (gnus-backlog-request-article group article (current-buffer)))
4957 ;; Check asynchronous pre-fetch.
4958 ((gnus-async-request-fetched-article group article (current-buffer))
4959 (gnus-async-prefetch-next group article gnus-summary-buffer)
4960 (when (and (numberp article) gnus-keep-backlog)
4961 (gnus-backlog-enter-article group article (current-buffer)))
4964 ((and gnus-use-cache
4966 (gnus-cache-request-article article group))
4968 ;; Get the article and put into the article buffer.
4969 ((or (stringp article)
4971 (let ((gnus-override-method gnus-override-method)
4972 (methods (and (stringp article)
4973 gnus-refer-article-method))
4975 (buffer-read-only nil))
4976 (if (or (not (listp methods))
4977 (and (symbolp (car methods))
4978 (assq (car methods) nnoo-definition-alist)))
4979 (setq methods (list methods)))
4980 (when (and (null gnus-override-method)
4982 (setq gnus-override-method (pop methods)))
4984 (when (eq gnus-override-method 'current)
4985 (setq gnus-override-method
4986 (with-current-buffer gnus-summary-buffer
4987 gnus-current-select-method)))
4989 (gnus-kill-all-overlays)
4990 (let ((gnus-newsgroup-name group))
4991 (gnus-check-group-server))
4992 (when (gnus-request-article article group (current-buffer))
4993 (when (numberp article)
4994 (gnus-async-prefetch-next group article
4995 gnus-summary-buffer)
4996 (when gnus-keep-backlog
4997 (gnus-backlog-enter-article
4998 group article (current-buffer))))
4999 (setq result 'article))
5002 (setq gnus-override-method (pop methods))
5003 (setq result 'done))))
5004 (and (eq result 'article) 'article)))
5008 ;; Associate this article with the current summary buffer.
5009 (setq gnus-article-current-summary gnus-summary-buffer)
5011 ;; Copy the requested article from `gnus-original-article-buffer'.
5012 (unless (equal (buffer-name (current-buffer))
5013 (buffer-name (get-buffer gnus-original-article-buffer)))
5014 (insert-buffer gnus-original-article-buffer))
5017 (run-hooks 'gnus-article-decode-hook)
5018 ;; Mark article as decoded or not.
5019 (setq gnus-article-decoded-p gnus-article-decode-hook)
5021 ;; Update sparse articles.
5022 (when (and do-update-line
5023 (or (numberp article)
5025 (let ((buf (current-buffer)))
5026 (set-buffer gnus-summary-buffer)
5027 (gnus-summary-update-article do-update-line sparse-header)
5028 (gnus-summary-goto-subject do-update-line nil t)
5029 (set-window-point (get-buffer-window (current-buffer) t)
5031 (set-buffer buf))))))
5037 (defcustom gnus-article-edit-mode-hook nil
5038 "Hook run in article edit mode buffers."
5039 :group 'gnus-article-various
5042 (defcustom gnus-article-edit-article-setup-function
5043 'gnus-article-mime-edit-article-setup
5044 "Function called to setup an editing article buffer."
5045 :group 'gnus-article-various
5048 (defvar gnus-article-edit-done-function nil)
5050 (defvar gnus-article-edit-mode-map nil)
5052 ;; Should we be using derived.el for this?
5053 (unless gnus-article-edit-mode-map
5054 (setq gnus-article-edit-mode-map (make-sparse-keymap))
5055 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5057 (gnus-define-keys gnus-article-edit-mode-map
5058 "\C-c\C-c" gnus-article-edit-done
5059 "\C-c\C-k" gnus-article-edit-exit)
5061 (gnus-define-keys (gnus-article-edit-wash-map
5062 "\C-c\C-w" gnus-article-edit-mode-map)
5063 "f" gnus-article-edit-full-stops))
5065 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5066 "Major mode for editing articles.
5067 This is an extended text-mode.
5069 \\{gnus-article-edit-mode-map}"
5070 (make-local-variable 'gnus-article-edit-done-function)
5071 (make-local-variable 'gnus-prev-winconf)
5072 (set (make-local-variable 'font-lock-defaults)
5073 '(message-font-lock-keywords t))
5074 (setq buffer-read-only nil)
5075 (buffer-enable-undo)
5078 (defun gnus-article-edit (&optional force)
5079 "Edit the current article.
5080 This will have permanent effect only in mail groups.
5081 If FORCE is non-nil, allow editing of articles even in read-only
5084 (when (and (not force)
5085 (gnus-group-read-only-p))
5086 (error "The current newsgroup does not support article editing"))
5087 (gnus-article-date-original)
5088 (gnus-article-edit-article
5090 `(lambda (no-highlight)
5092 (gnus-summary-edit-article-done
5093 ,(or (mail-header-references gnus-current-headers) "")
5094 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5096 (defun gnus-article-edit-article (start-func exit-func)
5097 "Start editing the contents of the current article buffer."
5098 (let ((winconf (current-window-configuration)))
5099 (set-buffer gnus-article-buffer)
5100 (gnus-article-edit-mode)
5101 (funcall start-func)
5102 (set-buffer-modified-p nil)
5103 (gnus-configure-windows 'edit-article)
5104 (setq gnus-article-edit-done-function exit-func)
5105 (setq gnus-prev-winconf winconf)
5106 (when gnus-article-edit-article-setup-function
5107 (funcall gnus-article-edit-article-setup-function))
5108 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit")))
5110 (defun gnus-article-edit-done (&optional arg)
5111 "Update the article edits and exit."
5113 (let ((func gnus-article-edit-done-function)
5114 (buf (current-buffer))
5115 (start (window-start)))
5116 (remove-hook 'gnus-article-mode-hook
5117 'gnus-article-mime-edit-article-unwind)
5118 ;; We remove all text props from the article buffer.
5120 (buffer-substring-no-properties (point-min) (point-max)))
5124 (let ((winconf gnus-prev-winconf))
5126 (set-window-configuration winconf)
5127 ;; Tippy-toe some to make sure that point remains where it was.
5128 (save-current-buffer
5130 (set-window-start (get-buffer-window (current-buffer)) start)
5134 (let ((buffer-read-only nil))
5136 ;; The cache and backlog have to be flushed somewhat.
5137 (when gnus-keep-backlog
5138 (gnus-backlog-remove-article
5139 (car gnus-article-current) (cdr gnus-article-current)))
5140 ;; Flush original article as well.
5142 (when (get-buffer gnus-original-article-buffer)
5143 (set-buffer gnus-original-article-buffer)
5144 (setq gnus-original-article nil)))
5145 (when gnus-use-cache
5146 (gnus-cache-update-article
5147 (car gnus-article-current) (cdr gnus-article-current))))
5149 (set-window-start (get-buffer-window buf) start)
5150 (set-window-point (get-buffer-window buf) (point))))
5152 (defun gnus-article-edit-exit ()
5153 "Exit the article editing without updating."
5155 (when (or (not (buffer-modified-p))
5156 (yes-or-no-p "Article modified; kill anyway? "))
5157 (let ((curbuf (current-buffer))
5159 (window-start (window-start)))
5161 (if (gnus-buffer-live-p gnus-original-article-buffer)
5162 (insert-buffer gnus-original-article-buffer))
5163 (let ((winconf gnus-prev-winconf))
5165 (set-window-configuration winconf)
5166 ;; Tippy-toe some to make sure that point remains where it was.
5167 (save-current-buffer
5169 (set-window-start (get-buffer-window (current-buffer)) window-start)
5172 (defun gnus-article-edit-full-stops ()
5173 "Interactively repair spacing at end of sentences."
5176 (goto-char (point-min))
5177 (search-forward-regexp "^$" nil t)
5178 (let ((case-fold-search nil))
5179 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5182 ;;; Article editing with MIME-Edit
5185 (defcustom gnus-article-mime-edit-article-setup-hook nil
5186 "Hook run after setting up a MIME editing article buffer."
5187 :group 'gnus-article-various
5190 (defun gnus-article-mime-edit-article-unwind ()
5191 "Unwind `gnus-article-buffer' if article editing was given up."
5192 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
5193 (when (featurep 'font-lock)
5194 (setq font-lock-defaults nil)
5195 (font-lock-mode -1))
5196 (when mime-edit-mode-flag
5197 (mime-edit-exit 'nomime 'no-error)
5200 (defun gnus-article-mime-edit-article-setup ()
5201 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
5202 after replacing with the original article."
5203 (setq gnus-show-mime t)
5204 (setq gnus-article-edit-done-function
5205 `(lambda (&rest args)
5206 (when mime-edit-mode-flag
5207 (let (mime-edit-insert-user-agent-field)
5210 (goto-char (point-min))
5211 (let (case-fold-search)
5212 (when (re-search-forward
5213 (format "^%s$" (regexp-quote mail-header-separator))
5215 (replace-match "")))
5216 (apply ,gnus-article-edit-done-function args)
5219 (buffer-substring-no-properties (point-min) (point-max))
5220 (set-buffer (get-buffer-create gnus-original-article-buffer))
5222 (setq gnus-current-headers (gnus-article-make-full-mail-header))
5223 (set-buffer gnus-article-buffer)
5224 (gnus-article-prepare-display)))
5225 (substitute-key-definition 'gnus-article-edit-done
5226 'gnus-article-mime-edit-done
5227 gnus-article-edit-mode-map)
5228 (substitute-key-definition 'gnus-article-edit-exit
5229 'gnus-article-mime-edit-exit
5230 gnus-article-edit-mode-map)
5232 (insert-buffer gnus-original-article-buffer)
5233 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
5234 (fset 'mime-edit-decode-single-part-in-buffer
5235 (lambda (&rest args)
5236 (if (let ((content-type (car args)))
5237 (and (eq 'message (mime-content-type-primary-type
5239 (eq 'rfc822 (mime-content-type-subtype content-type))))
5240 (setcar (cdr args) 'not-decode-text))
5244 (fset 'mime-edit-decode-single-part-in-buffer ofn)))
5245 (when (featurep 'font-lock)
5246 (set (make-local-variable 'font-lock-defaults)
5247 '(message-font-lock-keywords t))
5248 (font-lock-set-defaults)
5249 (turn-on-font-lock))
5250 (set-buffer-modified-p nil)
5251 (delete-other-windows)
5252 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
5253 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
5255 (defun gnus-article-mime-edit-done (&optional arg)
5256 "Update the article MIME edits and exit."
5258 (when (featurep 'font-lock)
5259 (setq font-lock-defaults nil)
5260 (font-lock-mode -1))
5261 (gnus-article-edit-done arg))
5263 (defun gnus-article-mime-edit-exit ()
5264 "Exit the article MIME editing without updating."
5266 (when (or (not (buffer-modified-p))
5267 (yes-or-no-p "Article modified; kill anyway? "))
5268 (when (featurep 'font-lock)
5269 (setq font-lock-defaults nil)
5270 (font-lock-mode -1))
5271 (when mime-edit-mode-flag
5272 (let (mime-edit-insert-user-agent-field)
5275 (goto-char (point-min))
5276 (let (case-fold-search)
5277 (when (re-search-forward
5278 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
5279 (replace-match "")))
5280 (let ((winconf gnus-prev-winconf))
5282 (buffer-substring-no-properties (point-min) (point-max))
5283 (set-buffer (get-buffer-create gnus-original-article-buffer))
5285 (setq gnus-current-headers (gnus-article-make-full-mail-header))
5286 (set-buffer gnus-article-buffer)
5287 (gnus-article-prepare-display)
5288 (set-window-configuration winconf))))
5291 ;;; Article highlights
5294 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5296 ;;; Internal Variables:
5298 (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\\)\\)"
5299 "Regular expression that matches URLs."
5300 :group 'gnus-article-buttons
5303 (defcustom gnus-button-alist
5304 `(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
5305 0 t gnus-button-handle-news 3)
5306 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
5307 gnus-button-handle-news 2)
5308 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
5310 gnus-button-fetch-group 4)
5311 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
5312 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
5313 t gnus-button-message-id 3)
5314 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
5315 ("mailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5316 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
5318 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t
5319 gnus-button-handle-info 2)
5320 ;; This is how URLs _should_ be embedded in text...
5321 ("<URL: *\\([^<>]*\\)>" 0 t gnus-button-embedded-url 1)
5323 (,gnus-button-url-regexp 0 t browse-url 0))
5324 "*Alist of regexps matching buttons in article bodies.
5326 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
5327 REGEXP: is the string matching text around the button,
5328 BUTTON: is the number of the regexp grouping actually matching the button,
5329 FORM: is a lisp expression which must eval to true for the button to
5331 CALLBACK: is the function to call when the user push this button, and each
5332 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
5334 CALLBACK can also be a variable, in that case the value of that
5335 variable it the real callback function."
5336 :group 'gnus-article-buttons
5337 :type '(repeat (list regexp
5338 (integer :tag "Button")
5340 (function :tag "Callback")
5343 (integer :tag "Regexp group")))))
5345 (defcustom gnus-header-button-alist
5346 `(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
5347 0 t gnus-button-message-id 0)
5348 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
5349 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
5350 0 t gnus-button-mailto 0)
5351 ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t browse-url 0)
5352 ("^Subject:" ,gnus-button-url-regexp 0 t browse-url 0)
5353 ("^[^:]+:" ,gnus-button-url-regexp 0 t browse-url 0)
5354 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
5355 gnus-button-message-id 3))
5356 "*Alist of headers and regexps to match buttons in article heads.
5358 This alist is very similar to `gnus-button-alist', except that each
5359 alist has an additional HEADER element first in each entry:
5361 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
5363 HEADER is a regexp to match a header. For a fuller explanation, see
5364 `gnus-button-alist'."
5365 :group 'gnus-article-buttons
5366 :group 'gnus-article-headers
5367 :type '(repeat (list (regexp :tag "Header")
5369 (integer :tag "Button")
5371 (function :tag "Callback")
5374 (integer :tag "Regexp group")))))
5376 (defvar gnus-button-regexp nil)
5377 (defvar gnus-button-marker-list nil)
5378 ;; Regexp matching any of the regexps from `gnus-button-alist'.
5380 (defvar gnus-button-last nil)
5381 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
5385 (defun gnus-article-push-button (event)
5386 "Check text under the mouse pointer for a callback function.
5387 If the text under the mouse pointer has a `gnus-callback' property,
5388 call it with the value of the `gnus-data' text property."
5390 (set-buffer (window-buffer (posn-window (event-start event))))
5391 (let* ((pos (posn-point (event-start event)))
5392 (data (get-text-property pos 'gnus-data))
5393 (fun (get-text-property pos 'gnus-callback)))
5396 (funcall fun data))))
5398 (defun gnus-article-press-button ()
5399 "Check text at point for a callback function.
5400 If the text at point has a `gnus-callback' property,
5401 call it with the value of the `gnus-data' text property."
5403 (let* ((data (get-text-property (point) 'gnus-data))
5404 (fun (get-text-property (point) 'gnus-callback)))
5406 (funcall fun data))))
5408 (defun gnus-article-prev-button (n)
5409 "Move point to N buttons backward.
5410 If N is negative, move forward instead."
5412 (gnus-article-next-button (- n)))
5414 (defun gnus-article-next-button (n)
5415 "Move point to N buttons forward.
5416 If N is negative, move backward instead."
5418 (let ((function (if (< n 0) 'previous-single-property-change
5419 'next-single-property-change))
5420 (inhibit-point-motion-hooks t)
5422 (limit (if (< n 0) (point-min) (point-max))))
5424 (while (and (not (= limit (point)))
5426 ;; Skip past the current button.
5427 (when (get-text-property (point) 'gnus-callback)
5428 (goto-char (funcall function (point) 'gnus-callback nil limit)))
5429 ;; Go to the next (or previous) button.
5430 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
5431 ;; Put point at the start of the button.
5432 (when (and backward (not (get-text-property (point) 'gnus-callback)))
5433 (goto-char (funcall function (point) 'gnus-callback nil limit)))
5434 ;; Skip past intangible buttons.
5435 (when (get-text-property (point) 'intangible)
5439 (gnus-message 5 "No more buttons"))
5442 (defun gnus-article-highlight (&optional force)
5443 "Highlight current article.
5444 This function calls `gnus-article-highlight-headers',
5445 `gnus-article-highlight-citation',
5446 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5447 do the highlighting. See the documentation for those functions."
5448 (interactive (list 'force))
5449 (gnus-article-highlight-headers)
5450 (gnus-article-highlight-citation force)
5451 (gnus-article-highlight-signature)
5452 (gnus-article-add-buttons force)
5453 (gnus-article-add-buttons-to-head))
5455 (defun gnus-article-highlight-some (&optional force)
5456 "Highlight current article.
5457 This function calls `gnus-article-highlight-headers',
5458 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5459 do the highlighting. See the documentation for those functions."
5460 (interactive (list 'force))
5461 (gnus-article-highlight-headers)
5462 (gnus-article-highlight-signature)
5463 (gnus-article-add-buttons))
5465 (defun gnus-article-highlight-headers ()
5466 "Highlight article headers as specified by `gnus-header-face-alist'."
5469 (set-buffer gnus-article-buffer)
5471 (let ((alist gnus-header-face-alist)
5472 (buffer-read-only nil)
5473 (case-fold-search t)
5474 (inhibit-point-motion-hooks t)
5475 entry regexp header-face field-face from hpoints fpoints)
5476 (article-narrow-to-head)
5477 (while (setq entry (pop alist))
5478 (goto-char (point-min))
5479 (setq regexp (concat "^\\("
5480 (if (string-equal "" (nth 0 entry))
5484 header-face (nth 1 entry)
5485 field-face (nth 2 entry))
5486 (while (and (re-search-forward regexp nil t)
5490 (unless (search-forward ":" nil t)
5492 (when (and header-face
5493 (not (memq (point) hpoints)))
5494 (push (point) hpoints)
5495 (gnus-put-text-property from (point) 'face header-face))
5496 (when (and field-face
5497 (not (memq (setq from (point)) fpoints)))
5499 (if (re-search-forward "^[^ \t]" nil t)
5501 (goto-char (point-max)))
5502 (gnus-put-text-property from (point) 'face field-face))))))))
5504 (defun gnus-article-highlight-signature ()
5505 "Highlight the signature in an article.
5506 It does this by highlighting everything after
5507 `gnus-signature-separator' using `gnus-signature-face'."
5509 (when gnus-signature-face
5511 (set-buffer gnus-article-buffer)
5512 (let ((buffer-read-only nil)
5513 (inhibit-point-motion-hooks t))
5515 (when (gnus-article-narrow-to-signature)
5516 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
5517 'face gnus-signature-face)))))))
5519 (defun gnus-article-buttonize-signature ()
5520 "Add button to the signature."
5523 (set-buffer gnus-article-buffer)
5524 (let ((buffer-read-only nil)
5525 (inhibit-point-motion-hooks t))
5526 (when (gnus-article-search-signature)
5527 (gnus-article-add-button (match-beginning 0) (match-end 0)
5528 'gnus-signature-toggle
5529 (set-marker (make-marker)
5530 (1+ (match-end 0))))))))
5532 (defun gnus-button-in-region-p (b e prop)
5533 "Say whether PROP exists in the region."
5534 (text-property-not-all b e prop nil))
5536 (defun gnus-article-add-buttons (&optional force)
5537 "Find external references in the article and make buttons of them.
5538 \"External references\" are things like Message-IDs and URLs, as
5539 specified by `gnus-button-alist'."
5540 (interactive (list 'force))
5542 (set-buffer gnus-article-buffer)
5543 (let ((buffer-read-only nil)
5544 (inhibit-point-motion-hooks t)
5545 (case-fold-search t)
5546 (alist gnus-button-alist)
5548 ;; Remove all old markers.
5549 (let (marker entry new-list)
5550 (while (setq marker (pop gnus-button-marker-list))
5551 (if (or (< marker (point-min)) (>= marker (point-max)))
5552 (push marker new-list)
5554 (when (setq entry (gnus-button-entry))
5555 (put-text-property (match-beginning (nth 1 entry))
5556 (match-end (nth 1 entry))
5557 'gnus-callback nil))
5558 (set-marker marker nil)))
5559 (setq gnus-button-marker-list new-list))
5560 ;; We skip the headers.
5563 (while (setq entry (pop alist))
5564 (setq regexp (car entry))
5566 (while (re-search-forward regexp nil t)
5567 (let* ((start (and entry (match-beginning (nth 1 entry))))
5568 (end (and entry (match-end (nth 1 entry))))
5569 (from (match-beginning 0)))
5570 (when (and (or (eq t (nth 2 entry))
5571 (eval (nth 2 entry)))
5572 (not (gnus-button-in-region-p
5573 start end 'gnus-callback)))
5574 ;; That optional form returned non-nil, so we add the
5576 (gnus-article-add-button
5577 start end 'gnus-button-push
5578 (car (push (set-marker (make-marker) from)
5579 gnus-button-marker-list))))))))))
5581 ;; Add buttons to the head of an article.
5582 (defun gnus-article-add-buttons-to-head ()
5583 "Add buttons to the head of the article."
5586 (set-buffer gnus-article-buffer)
5588 (let ((buffer-read-only nil)
5589 (inhibit-point-motion-hooks t)
5590 (case-fold-search t)
5591 (alist gnus-header-button-alist)
5593 (article-narrow-to-head)
5595 ;; Each alist entry.
5596 (setq entry (car alist)
5598 (goto-char (point-min))
5599 (while (re-search-forward (car entry) nil t)
5600 ;; Each header matching the entry.
5601 (setq beg (match-beginning 0))
5602 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
5603 (match-beginning 0))
5606 (while (re-search-forward (nth 1 entry) end t)
5607 ;; Each match within a header.
5608 (let* ((entry (cdr entry))
5609 (start (match-beginning (nth 1 entry)))
5610 (end (match-end (nth 1 entry)))
5611 (form (nth 2 entry)))
5612 (goto-char (match-end 0))
5614 (gnus-article-add-button
5615 start end (nth 3 entry)
5616 (buffer-substring (match-beginning (nth 4 entry))
5617 (match-end (nth 4 entry)))))))
5618 (goto-char end)))))))
5620 ;;; External functions:
5622 (defun gnus-article-add-button (from to fun &optional data)
5623 "Create a button between FROM and TO with callback FUN and data DATA."
5624 (when gnus-article-button-face
5625 (gnus-overlay-put (gnus-make-overlay from to)
5626 'face gnus-article-button-face))
5627 (gnus-add-text-properties
5629 (nconc (and gnus-article-mouse-face
5630 (list gnus-mouse-face-prop gnus-article-mouse-face))
5631 (list 'gnus-callback fun)
5632 (and data (list 'gnus-data data))))
5633 (widget-convert-button 'link from to :action 'gnus-widget-press-button
5634 ;; Quote `:button-keymap' for Mule 2.3
5635 ;; but it won't work.
5636 ':button-keymap gnus-widget-button-keymap))
5638 ;;; Internal functions:
5640 (defun gnus-article-set-globals ()
5642 (set-buffer gnus-summary-buffer)
5643 (gnus-set-global-variables)))
5645 (defun gnus-signature-toggle (end)
5647 (set-buffer gnus-article-buffer)
5648 (let ((buffer-read-only nil)
5649 (inhibit-point-motion-hooks t)
5650 (limit (next-single-property-change end 'mime-view-entity
5652 (if (text-property-any end limit 'article-type 'signature)
5654 (setq gnus-article-wash-types
5655 (delq 'signature gnus-article-wash-types))
5656 (gnus-remove-text-properties-when
5657 'article-type 'signature end limit
5658 (cons 'article-type (cons 'signature
5659 gnus-hidden-properties))))
5660 (or (memq 'signature gnus-article-wash-types)
5661 (push 'signature gnus-article-wash-types))
5662 (gnus-add-text-properties-when
5663 'article-type nil end limit
5664 (cons 'article-type (cons 'signature
5665 gnus-hidden-properties)))))
5666 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
5667 (gnus-set-mode-line 'article))))
5669 (defun gnus-button-entry ()
5670 ;; Return the first entry in `gnus-button-alist' matching this place.
5671 (let ((alist gnus-button-alist)
5674 (setq entry (pop alist))
5675 (if (looking-at (car entry))
5680 (defun gnus-button-push (marker)
5681 ;; Push button starting at MARKER.
5684 (let* ((entry (gnus-button-entry))
5685 (inhibit-point-motion-hooks t)
5687 (args (mapcar (lambda (group)
5688 (let ((string (match-string group)))
5689 (gnus-set-text-properties
5690 0 (length string) nil string)
5697 (fboundp (symbol-value fun)))
5698 (apply (symbol-value fun) args))
5700 (gnus-message 1 "You must define `%S' to use this button"
5701 (cons fun args)))))))
5703 (defun gnus-parse-news-url (url)
5704 (let (scheme server group message-id articles)
5707 (goto-char (point-min))
5708 (when (looking-at "\\([A-Za-z]+\\):")
5709 (setq scheme (match-string 1))
5710 (goto-char (match-end 0)))
5711 (when (looking-at "//\\([^/]+\\)/")
5712 (setq server (match-string 1))
5713 (goto-char (match-end 0)))
5716 ((looking-at "\\(.*@.*\\)")
5717 (setq message-id (match-string 1)))
5718 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
5719 (setq group (match-string 1)
5720 articles (split-string (match-string 2) "-")))
5721 ((looking-at "\\([^/]+\\)/?")
5722 (setq group (match-string 1)))
5724 (error "Unknown news URL syntax"))))
5725 (list scheme server group message-id articles)))
5727 (defun gnus-button-handle-news (url)
5729 (destructuring-bind (scheme server group message-id articles)
5730 (gnus-parse-news-url url)
5734 (set-buffer gnus-summary-buffer)
5736 (let ((gnus-refer-article-method (list (list 'nntp server))))
5737 (gnus-summary-refer-article message-id))
5738 (gnus-summary-refer-article message-id))))
5740 (gnus-button-fetch-group url)))))
5742 (defun gnus-button-handle-info (url)
5743 "Fetch an info URL."
5745 "^\\([^:/]+\\)?/\\(.*\\)"
5747 (gnus-info-find-node
5748 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
5751 (gnus-url-unhex-string (match-string 2 url))))
5752 (error "Can't parse %s" url)))
5754 (defun gnus-button-message-id (message-id)
5757 (set-buffer gnus-summary-buffer)
5758 (gnus-summary-refer-article message-id)))
5760 (defun gnus-button-fetch-group (address)
5761 "Fetch GROUP specified by ADDRESS."
5762 (if (not (string-match "[:/]" address))
5763 ;; This is just a simple group url.
5764 (gnus-group-read-ephemeral-group address gnus-select-method)
5767 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
5769 (error "Can't parse %s" address)
5770 (gnus-group-read-ephemeral-group
5771 (match-string 4 address)
5772 `(nntp ,(match-string 1 address)
5773 (nntp-address ,(match-string 1 address))
5774 (nntp-port-number ,(if (match-end 3)
5775 (match-string 3 address)
5778 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
5780 (defun gnus-url-parse-query-string (query &optional downcase)
5781 (let (retval pairs cur key val)
5782 (setq pairs (split-string query "&"))
5784 (setq cur (car pairs)
5786 (if (not (string-match "=" cur))
5788 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
5789 val (gnus-url-unhex-string (substring cur (match-end 0) nil)))
5791 (setq key (downcase key)))
5792 (setq cur (assoc key retval))
5794 (setcdr cur (cons val (cdr cur)))
5795 (setq retval (cons (list key val) retval)))))
5798 (defun gnus-url-unhex (x)
5805 (defun gnus-url-unhex-string (str &optional allow-newlines)
5806 "Remove %XXX embedded spaces, etc in a url.
5807 If optional second argument ALLOW-NEWLINES is non-nil, then allow the
5808 decoding of carriage returns and line feeds in the string, which is normally
5809 forbidden in URL encoding."
5810 (setq str (or (nnheader-replace-chars-in-string str ?+ ? ) ""))
5812 (case-fold-search t))
5813 (while (string-match "%[0-9a-f][0-9a-f]" str)
5814 (let* ((start (match-beginning 0))
5815 (ch1 (gnus-url-unhex (elt str (+ start 1))))
5817 (gnus-url-unhex (elt str (+ start 2))))))
5819 tmp (substring str 0 start)
5822 (char-to-string code))
5823 ((or (= code ?\n) (= code ?\r))
5825 (t (char-to-string code))))
5826 str (substring str (match-end 0)))))
5827 (setq tmp (concat tmp str))
5830 (defun gnus-url-mailto (url)
5831 ;; Send mail to someone
5832 (when (string-match "mailto:/*\\(.*\\)" url)
5833 (setq url (substring url (match-beginning 1) nil)))
5834 (let (to args subject func)
5835 (if (string-match (regexp-quote "?") url)
5836 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
5837 args (gnus-url-parse-query-string
5838 (substring url (match-end 0) nil) t))
5839 (setq to (gnus-url-unhex-string url)))
5840 (setq args (cons (list "to" to) args)
5841 subject (cdr-safe (assoc "subject" args)))
5844 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
5847 (message-position-on-field (caar args)))
5848 (insert (mapconcat 'identity (cdar args) ", "))
5849 (setq args (cdr args)))
5852 (message-goto-subject))))
5854 (defun gnus-button-embedded-url (address)
5855 "Activate ADDRESS with `browse-url'."
5856 (browse-url (gnus-strip-whitespace address)))
5859 ;; Silence the byte-compiler.
5860 (autoload 'smiley-toggle-buffer "gnus-bitmap"))
5861 (defun gnus-article-smiley-display ()
5862 "Display \"smileys\" as small graphical icons."
5863 (smiley-toggle-buffer 1 (current-buffer) (point-min) (point-max)))
5865 ;;; Next/prev buttons in the article buffer.
5867 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
5868 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
5870 (defvar gnus-prev-page-map nil)
5871 (unless gnus-prev-page-map
5872 (setq gnus-prev-page-map (make-sparse-keymap))
5873 (define-key gnus-prev-page-map gnus-mouse-2 'gnus-button-prev-page)
5874 (define-key gnus-prev-page-map "\r" 'gnus-button-prev-page))
5876 (static-if (featurep 'xemacs)
5877 (defun gnus-insert-prev-page-button ()
5878 (let ((buffer-read-only nil))
5880 gnus-prev-page-line-format nil
5881 `(gnus-prev t local-map ,gnus-prev-page-map
5882 gnus-callback gnus-article-button-prev-page
5883 article-type annotation))))
5884 (defun gnus-insert-prev-page-button ()
5885 (let ((buffer-read-only nil)
5886 (situation (get-text-property (point-min) 'mime-view-situation)))
5887 (set-keymap-parent gnus-prev-page-map (current-local-map))
5889 gnus-prev-page-line-format nil
5890 `(gnus-prev t local-map ,gnus-prev-page-map
5891 gnus-callback gnus-article-button-prev-page
5892 article-type annotation
5893 mime-view-situation ,situation))))
5896 (defvar gnus-next-page-map nil)
5897 (unless gnus-next-page-map
5898 (setq gnus-next-page-map (make-sparse-keymap))
5899 (define-key gnus-next-page-map gnus-mouse-2 'gnus-button-next-page)
5900 (define-key gnus-next-page-map "\r" 'gnus-button-next-page))
5902 (defun gnus-button-next-page ()
5903 "Go to the next page."
5905 (let ((win (selected-window)))
5906 (select-window (get-buffer-window gnus-article-buffer t))
5907 (gnus-article-next-page)
5908 (select-window win)))
5910 (defun gnus-button-prev-page ()
5911 "Go to the prev page."
5913 (let ((win (selected-window)))
5914 (select-window (get-buffer-window gnus-article-buffer t))
5915 (gnus-article-prev-page)
5916 (select-window win)))
5918 (static-if (featurep 'xemacs)
5919 (defun gnus-insert-next-page-button ()
5920 (let ((buffer-read-only nil))
5921 (gnus-eval-format gnus-next-page-line-format nil
5923 t local-map ,gnus-next-page-map
5924 gnus-callback gnus-article-button-next-page
5925 article-type annotation))))
5926 (defun gnus-insert-next-page-button ()
5927 (let ((buffer-read-only nil)
5928 (situation (get-text-property (point-min) 'mime-view-situation)))
5929 (set-keymap-parent gnus-next-page-map (current-local-map))
5930 (gnus-eval-format gnus-next-page-line-format nil
5932 t local-map ,gnus-next-page-map
5933 gnus-callback gnus-article-button-next-page
5934 article-type annotation
5935 mime-view-situation ,situation))))
5938 (defun gnus-article-button-next-page (arg)
5939 "Go to the next page."
5941 (let ((win (selected-window)))
5942 (select-window (get-buffer-window gnus-article-buffer t))
5943 (gnus-article-next-page)
5944 (select-window win)))
5946 (defun gnus-article-button-prev-page (arg)
5947 "Go to the prev page."
5949 (let ((win (selected-window)))
5950 (select-window (get-buffer-window gnus-article-buffer t))
5951 (gnus-article-prev-page)
5952 (select-window win)))
5954 (defvar gnus-decode-header-methods
5955 '(mail-decode-encoded-word-region)
5956 "List of methods used to decode headers.
5958 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
5959 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
5960 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
5961 whose names match REGEXP.
5964 ((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
5965 mail-decode-encoded-word-region
5966 (\"chinese\" . rfc1843-decode-region))
5969 (defvar gnus-decode-header-methods-cache nil)
5971 (defun gnus-multi-decode-header (start end)
5972 "Apply the functions from `gnus-encoded-word-methods' that match."
5973 (unless (and gnus-decode-header-methods-cache
5974 (eq gnus-newsgroup-name
5975 (car gnus-decode-header-methods-cache)))
5976 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
5979 (nconc gnus-decode-header-methods-cache (list x))
5980 (if (and gnus-newsgroup-name
5981 (string-match (car x) gnus-newsgroup-name))
5982 (nconc gnus-decode-header-methods-cache
5984 gnus-decode-header-methods))
5985 (let ((xlist gnus-decode-header-methods-cache))
5988 (narrow-to-region start end)
5990 (funcall (pop xlist) (point-min) (point-max))))))
5993 ;;; Treatment top-level handling.
5996 (defun gnus-treat-article (condition &optional part-number total-parts type)
5997 (let ((length (- (point-max) (point-min)))
5998 (alist gnus-treatment-function-alist)
5999 (article-goto-body-goes-to-point-min-p t)
6003 (let ((list gnus-article-treat-types))
6005 (when (string-match (pop list) type)
6006 (throw 'found t)))))))
6007 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6008 (entity (static-unless (featurep 'xemacs)
6009 (when (eq 'head condition)
6010 (get-text-property (point-min) 'mime-view-entity))))
6011 val elem buttonized)
6012 (gnus-run-hooks 'gnus-part-display-hook)
6013 (unless gnus-inhibit-treatment
6014 (while (setq elem (pop alist))
6017 (if (gnus-buffer-live-p gnus-summary-buffer)
6018 (set-buffer gnus-summary-buffer))
6019 (symbol-value (car elem))))
6020 (when (and (or (consp val)
6022 (gnus-treat-predicate val)
6023 (or (not (get (car elem) 'highlight))
6025 (when (and (not buttonized)
6027 '(gnus-treat-hide-signature
6028 gnus-treat-highlight-signature)))
6029 (gnus-article-buttonize-signature)
6030 (setq buttonized t))
6032 (funcall (cadr elem)))))
6033 ;; FSF Emacsen does not inherit the existing text properties
6034 ;; in the new text, so we should do it for `mime-view-entity'.
6035 (static-unless (featurep 'xemacs)
6037 (put-text-property (point-min) (point-max)
6038 'mime-view-entity entity))))))
6040 ;; Dynamic variables.
6042 (defvar part-number)
6043 (defvar total-parts)
6048 (defun gnus-treat-predicate (val)
6053 (stringp (car val)))
6054 (apply 'gnus-or (mapcar `(lambda (s)
6055 (string-match s ,(or gnus-newsgroup-name "")))
6058 (let ((pred (pop val)))
6061 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
6063 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
6065 (not (gnus-treat-predicate (car val))))
6067 (equal (car val) type))
6069 (error "%S is not a valid predicate" pred)))))
6079 (eq part-number total-parts))
6083 (error "%S is not a valid value" val))))
6085 (defun gnus-article-encrypt-body (protocol &optional n)
6086 "Encrypt the article body."
6089 (or gnus-article-encrypt-protocol
6090 (completing-read "Encrypt protocol: "
6091 gnus-article-encrypt-protocol-alist
6093 current-prefix-arg))
6094 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
6096 (error (format "Can't find the encrypt protocol %s" protocol)))
6097 (if (equal gnus-newsgroup-name "nndraft:drafts")
6098 (error "Can't encrypt the article in group nndraft:drafts"))
6099 (if (equal gnus-newsgroup-name "nndraft:queue")
6100 (error "Don't encrypt the article in group nndraft:queue"))
6101 (gnus-summary-iterate n
6103 (set-buffer gnus-summary-buffer)
6104 (let ((mail-parse-charset gnus-newsgroup-charset)
6105 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6106 (summary-buffer gnus-summary-buffer)
6108 (gnus-set-global-variables)
6109 (when (gnus-group-read-only-p)
6110 (error "The current newsgroup does not support article encrypt"))
6111 (gnus-summary-show-article t)
6113 (or (mail-header-references gnus-current-headers) ""))
6114 (set-buffer gnus-article-buffer)
6115 (let* ((buffer-read-only nil)
6117 (mapcar (lambda (field)
6118 (and (save-restriction
6119 (message-narrow-to-head)
6120 (goto-char (point-min))
6121 (search-forward field nil t))
6123 (message-narrow-to-field)
6124 (buffer-substring (point-min) (point-max))
6125 (delete-region (point-min) (point-max))
6127 '("Content-Type:" "Content-Transfer-Encoding:"
6128 "Content-Disposition:"))))
6129 (message-narrow-to-head)
6130 (message-remove-header "MIME-Version")
6131 (goto-char (point-max))
6132 (setq point (point))
6133 (insert (apply 'concat headers))
6135 (narrow-to-region point (point-max))
6136 (let ((message-options message-options))
6137 (message-options-set 'message-sender user-mail-address)
6138 (message-options-set 'message-recipients user-mail-address)
6139 (message-options-set 'message-sign-encrypt 'not)
6141 (goto-char (point-min))
6142 (insert "MIME-Version: 1.0\n")
6144 (gnus-summary-edit-article-done
6145 references nil summary-buffer t))
6146 (when gnus-keep-backlog
6147 (gnus-backlog-remove-article
6148 (car gnus-article-current) (cdr gnus-article-current)))
6150 (when (get-buffer gnus-original-article-buffer)
6151 (set-buffer gnus-original-article-buffer)
6152 (setq gnus-original-article nil)))
6153 (when gnus-use-cache
6154 (gnus-cache-update-article
6155 (car gnus-article-current) (cdr gnus-article-current))))))))
6157 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
6158 "The following specs can be used:
6159 %t The security MIME type
6162 %D Details if button is pressed")
6164 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
6165 "The following specs can be used:
6166 %t The security MIME type
6169 %D Details if button is pressed")
6171 (defvar gnus-mime-security-button-line-format-alist
6172 '((?t gnus-tmp-type ?s)
6173 (?i gnus-tmp-info ?s)
6174 (?d gnus-tmp-details ?s)
6175 (?D gnus-tmp-pressed-details ?s)))
6177 (defvar gnus-mime-security-button-map
6178 (let ((map (make-sparse-keymap)))
6179 (unless (>= (string-to-number emacs-version) 21)
6180 (set-keymap-parent map gnus-article-mode-map))
6181 (define-key map gnus-mouse-2 'gnus-article-push-button)
6182 (define-key map "\r" 'gnus-article-press-button)
6185 (defvar gnus-mime-security-details-buffer nil)
6187 (defvar gnus-mime-security-button-pressed nil)
6189 (defvar gnus-mime-security-show-details-inline t
6190 "If non-nil, show details in the article buffer.")
6192 (defun gnus-mime-security-verify-or-decrypt (handle)
6193 (mm-remove-parts (cdr handle))
6194 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
6195 point buffer-read-only)
6197 (goto-char (car region)))
6199 (narrow-to-region (point) (point))
6200 (with-current-buffer (mm-handle-multipart-original-buffer handle)
6201 (let* ((mm-verify-option 'known)
6202 (mm-decrypt-option 'known)
6203 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
6204 (unless (eq nparts (cdr handle))
6205 (mm-destroy-parts (cdr handle))
6206 (setcdr handle nparts))))
6207 (setq point (point))
6208 (gnus-mime-display-security handle)
6209 (goto-char (point-max)))
6211 (delete-region (point) (cdr region))
6212 (set-marker (car region) nil)
6213 (set-marker (cdr region) nil))
6216 (defun gnus-mime-security-show-details (handle)
6217 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
6219 (if gnus-mime-security-show-details-inline
6220 (let ((gnus-mime-security-button-pressed t)
6221 (gnus-mime-security-button-line-format
6222 (get-text-property (point) 'gnus-line-format))
6225 (while (eq (get-text-property (point) 'gnus-line-format)
6226 gnus-mime-security-button-line-format)
6230 (narrow-to-region (point) (point))
6231 (gnus-insert-mime-security-button handle))
6232 (delete-region (point)
6233 (or (text-property-not-all
6236 gnus-mime-security-button-line-format)
6238 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
6239 (with-current-buffer gnus-mime-security-details-buffer
6242 (setq gnus-mime-security-details-buffer
6243 (gnus-get-buffer-create "*MIME Security Details*")))
6244 (with-current-buffer gnus-mime-security-details-buffer
6246 (goto-char (point-min)))
6247 (pop-to-buffer gnus-mime-security-details-buffer))
6248 (gnus-message 5 "No details."))))
6250 (defun gnus-mime-security-press-button (handle)
6251 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6252 (gnus-mime-security-show-details handle)
6253 (gnus-mime-security-verify-or-decrypt handle)))
6255 (defun gnus-insert-mime-security-button (handle &optional displayed)
6256 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
6259 (or (nth 2 (assoc protocol mm-verify-function-alist))
6260 (nth 2 (assoc protocol mm-decrypt-function-alist))
6262 (if (equal (car handle) "multipart/signed")
6263 " Signed" " Encrypted")
6266 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6269 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
6270 gnus-tmp-pressed-details
6272 (setq gnus-tmp-details
6273 (if gnus-tmp-details
6274 (concat "\n" gnus-tmp-details) ""))
6275 (setq gnus-tmp-pressed-details
6276 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
6281 gnus-mime-security-button-line-format
6282 gnus-mime-security-button-line-format-alist
6283 `(keymap ,gnus-mime-security-button-map
6284 ,@(if (>= (string-to-number emacs-version) 21)
6285 nil ;; XEmacs doesn't care
6286 (list 'local-map gnus-mime-security-button-map))
6287 gnus-callback gnus-mime-security-press-button
6288 gnus-line-format ,gnus-mime-security-button-line-format
6289 article-type annotation
6292 (widget-convert-button
6295 :action 'gnus-widget-press-button
6296 :button-keymap gnus-mime-security-button-map
6298 (lambda (widget/window &optional overlay pos)
6299 ;; Needed to properly clear the message due to a bug in
6300 ;; wid-edit (XEmacs only).
6301 (if (boundp 'help-echo-owns-message)
6302 (setq help-echo-owns-message t))
6305 (aref gnus-mouse-2 0))))))
6307 (defun gnus-mime-display-security (handle)
6309 (narrow-to-region (point) (point))
6310 (unless (gnus-unbuttonized-mime-type-p (car handle))
6311 (gnus-insert-mime-security-button handle))
6312 (gnus-mime-display-mixed (cdr handle))
6315 (unless (gnus-unbuttonized-mime-type-p (car handle))
6316 (let ((gnus-mime-security-button-line-format
6317 gnus-mime-security-button-end-line-format))
6318 (gnus-insert-mime-security-button handle)))
6319 (mm-set-handle-multipart-parameter
6321 (cons (set-marker (make-marker) (point-min))
6322 (set-marker (make-marker) (point-max))))))
6328 (defun gnus-article-header-presentation-method (entity situation)
6329 (mime-insert-header entity)
6330 (article-decode-group-name))
6332 (set-alist 'mime-header-presentation-method-alist
6333 'gnus-original-article-mode
6334 #'gnus-article-header-presentation-method)
6336 (defun gnus-mime-preview-quitting-method ()
6337 (mime-preview-kill-buffer)
6338 (delete-other-windows)
6339 (gnus-article-show-summary)
6340 (gnus-summary-select-article gnus-show-all-headers t))
6342 (set-alist 'mime-preview-quitting-method-alist
6343 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
6345 (set-alist 'mime-preview-following-method-alist
6346 'gnus-original-article-mode #'gnus-following-method)
6348 (set-alist 'mime-preview-over-to-previous-method-alist
6349 'gnus-original-article-mode
6351 (if (> (point-min) 1)
6352 (gnus-article-prev-page)
6353 (gnus-article-read-summary-keys
6354 nil (gnus-character-to-event ?P)))))
6356 (set-alist 'mime-preview-over-to-next-method-alist
6357 'gnus-original-article-mode'
6359 (if (< (point-max) (buffer-size))
6360 (gnus-article-next-page)
6361 (gnus-article-read-summary-keys
6362 nil (gnus-character-to-event ?N)))))
6372 (run-hooks 'gnus-art-load-hook)
6374 ;;; gnus-art.el ends here