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-in-vm (use VM's folder format)
448 * gnus-summary-write-to-file (article format -- overwrite)."
449 :group 'gnus-article-saving
450 :type '(radio (function-item gnus-summary-save-in-rmail)
451 (function-item gnus-summary-save-in-mail)
452 (function-item gnus-summary-save-in-folder)
453 (function-item gnus-summary-save-in-file)
454 (function-item gnus-summary-save-in-vm)
455 (function-item gnus-summary-write-to-file)))
457 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
458 "A function generating a file name to save articles in Rmail format.
459 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
460 :group 'gnus-article-saving
463 (defcustom gnus-mail-save-name 'gnus-plain-save-name
464 "A function generating a file name to save articles in Unix mail format.
465 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
466 :group 'gnus-article-saving
469 (defcustom gnus-folder-save-name 'gnus-folder-save-name
470 "A function generating a file name to save articles in MH folder.
471 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
472 :group 'gnus-article-saving
475 (defcustom gnus-file-save-name 'gnus-numeric-save-name
476 "A function generating a file name to save articles in article format.
477 The function is called with NEWSGROUP, HEADERS, and optional
479 :group 'gnus-article-saving
482 (defcustom gnus-split-methods
483 '((gnus-article-archive-name)
484 (gnus-article-nndoc-name))
485 "*Variable used to suggest where articles are to be saved.
486 For instance, if you would like to save articles related to Gnus in
487 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
488 you could set this variable to something like:
490 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
491 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
493 This variable is an alist where the where the key is the match and the
494 value is a list of possible files to save in if the match is non-nil.
496 If the match is a string, it is used as a regexp match on the
497 article. If the match is a symbol, that symbol will be funcalled
498 from the buffer of the article to be saved with the newsgroup as the
499 parameter. If it is a list, it will be evaled in the same buffer.
501 If this form or function returns a string, this string will be used as
502 a possible file name; and if it returns a non-nil list, that list will
503 be used as possible file names."
504 :group 'gnus-article-saving
505 :type '(repeat (choice (list :value (fun) function)
506 (cons :value ("" "") regexp (repeat string))
509 (defcustom gnus-article-display-method-for-mime
510 'gnus-article-display-mime-message
511 "Function to display a MIME message.
512 The function is called from the article buffer."
513 :group 'gnus-article-mime
516 (defcustom gnus-article-display-method-for-traditional
517 'gnus-article-display-traditional-message
518 "*Function to display a traditional message.
519 The function is called from the article buffer."
520 :group 'gnus-article-mime
523 (defcustom gnus-page-delimiter "^\^L"
524 "*Regexp describing what to use as article page delimiters.
525 The default value is \"^\^L\", which is a form linefeed at the
526 beginning of a line."
528 :group 'gnus-article-various)
530 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
531 "*The format specification for the article mode line.
532 See `gnus-summary-mode-line-format' for a closer description.
534 The following additional specs are available:
536 %w The article washing status.
537 %m The number of MIME parts in the article."
539 :group 'gnus-article-various)
541 (defcustom gnus-article-mode-hook nil
542 "*A hook for Gnus article mode."
544 :group 'gnus-article-various)
546 (when (featurep 'xemacs)
547 ;; Extracted from gnus-xmas-define in order to preserve user settings
548 (when (fboundp 'turn-off-scroll-in-place)
549 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
550 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
551 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
553 (defcustom gnus-article-menu-hook nil
554 "*Hook run after the creation of the article mode menu."
556 :group 'gnus-article-various)
558 (defcustom gnus-article-prepare-hook nil
559 "*A hook called after an article has been prepared in the article buffer."
561 :group 'gnus-article-various)
563 (defcustom gnus-article-hide-pgp-hook nil
564 "*A hook called after successfully hiding a PGP signature."
566 :group 'gnus-article-various)
568 (defcustom gnus-article-button-face 'bold
569 "Face used for highlighting buttons in the article buffer.
571 An article button is a piece of text that you can activate by pressing
572 `RET' or `mouse-2' above it."
574 :group 'gnus-article-buttons)
576 (defcustom gnus-article-mouse-face 'highlight
577 "Face used for mouse highlighting in the article buffer.
579 Article buttons will be displayed in this face when the cursor is
582 :group 'gnus-article-buttons)
584 (defcustom gnus-signature-face 'gnus-signature-face
585 "Face used for highlighting a signature in the article buffer.
586 Obsolete; use the face `gnus-signature-face' for customizations instead."
588 :group 'gnus-article-highlight
589 :group 'gnus-article-signature)
591 (defface gnus-signature-face
594 "Face used for highlighting a signature in the article buffer."
595 :group 'gnus-article-highlight
596 :group 'gnus-article-signature)
598 (defface gnus-header-from-face
601 (:foreground "spring green"))
604 (:foreground "red3"))
607 "Face used for displaying from headers."
608 :group 'gnus-article-headers
609 :group 'gnus-article-highlight)
611 (defface gnus-header-subject-face
614 (:foreground "SeaGreen3"))
617 (:foreground "red4"))
619 (:bold t :italic t)))
620 "Face used for displaying subject headers."
621 :group 'gnus-article-headers
622 :group 'gnus-article-highlight)
624 (defface gnus-header-newsgroups-face
627 (:foreground "yellow" :italic t))
630 (:foreground "MidnightBlue" :italic t))
633 "Face used for displaying newsgroups headers."
634 :group 'gnus-article-headers
635 :group 'gnus-article-highlight)
637 (defface gnus-header-name-face
640 (:foreground "SeaGreen"))
643 (:foreground "maroon"))
646 "Face used for displaying header names."
647 :group 'gnus-article-headers
648 :group 'gnus-article-highlight)
650 (defface gnus-header-content-face
653 (:foreground "forest green" :italic t))
656 (:foreground "indianred4" :italic t))
659 "Face used for displaying header content."
660 :group 'gnus-article-headers
661 :group 'gnus-article-highlight)
663 (defcustom gnus-header-face-alist
664 '(("From" nil gnus-header-from-face)
665 ("Subject" nil gnus-header-subject-face)
666 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
667 ("" gnus-header-name-face gnus-header-content-face))
668 "*Controls highlighting of article header.
670 An alist of the form (HEADER NAME CONTENT).
672 HEADER is a regular expression which should match the name of an
673 header header and NAME and CONTENT are either face names or nil.
675 The name of each header field will be displayed using the face
676 specified by the first element in the list where HEADER match the
677 header name and NAME is non-nil. Similarly, the content will be
678 displayed by the first non-nil matching CONTENT face."
679 :group 'gnus-article-headers
680 :group 'gnus-article-highlight
681 :type '(repeat (list (regexp :tag "Header")
683 (item :tag "skip" nil)
684 (face :value default))
685 (choice :tag "Content"
686 (item :tag "skip" nil)
687 (face :value default)))))
689 (defcustom gnus-article-decode-hook nil
690 "*Hook run to decode charsets in articles."
691 :group 'gnus-article-headers
694 (defcustom gnus-display-mime-function 'gnus-display-mime
695 "Function to display MIME articles."
696 :group 'gnus-article-mime
699 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
700 "Function used to decode headers.")
702 (defvar gnus-article-dumbquotes-map
721 "Table for MS-to-Latin1 translation.")
723 (defcustom gnus-ignored-mime-types nil
724 "List of MIME types that should be ignored by Gnus."
726 :group 'gnus-article-mime
727 :type '(repeat regexp))
729 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
730 "List of MIME types that should not be given buttons when rendered inline.
731 See also `gnus-buttonized-mime-types' which may override this variable."
733 :group 'gnus-article-mime
734 :type '(repeat regexp))
736 (defcustom gnus-buttonized-mime-types nil
737 "List of MIME types that should be given buttons when rendered inline.
738 If set, this variable overrides `gnus-unbuttonized-mime-types'.
739 To see e.g. security buttons you could set this to
740 `(\"multipart/signed\")'."
742 :group 'gnus-article-mime
743 :type '(repeat regexp))
745 (defcustom gnus-article-mime-part-function nil
746 "Function called with a MIME handle as the argument.
747 This is meant for people who want to do something automatic based
748 on parts -- for instance, adding Vcard info to a database."
749 :group 'gnus-article-mime
752 (defcustom gnus-mime-multipart-functions nil
753 "An alist of MIME types to functions to display them."
755 :group 'gnus-article-mime
758 (defcustom gnus-article-date-lapsed-new-header nil
759 "Whether the X-Sent and Date headers can coexist.
760 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
761 either replace the old \"Date:\" header (if this variable is nil), or
762 be added below it (otherwise)."
764 :group 'gnus-article-headers
767 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
768 "Function called with a MIME handle as the argument.
769 This is meant for people who want to view first matched part.
770 For `undisplayed-alternative' (default), the first undisplayed
771 part or alternative part is used. For `undisplayed', the first
772 undisplayed part is used. For a function, the first part which
773 the function return `t' is used. For `nil', the first part is
776 :group 'gnus-article-mime
778 (item :tag "first" :value nil)
779 (item :tag "undisplayed" :value undisplayed)
780 (item :tag "undisplayed or alternative"
781 :value undisplayed-alternative)
784 (defcustom gnus-mime-action-alist
785 '(("save to file" . gnus-mime-save-part)
786 ("save and strip" . gnus-mime-save-part-and-strip)
787 ("display as text" . gnus-mime-inline-part)
788 ("view the part" . gnus-mime-view-part)
789 ("pipe to command" . gnus-mime-pipe-part)
790 ("toggle display" . gnus-article-press-button)
791 ("toggle display" . gnus-article-view-part-as-charset)
792 ("view as type" . gnus-mime-view-part-as-type)
793 ("internalize type" . gnus-mime-internalize-part)
794 ("externalize type" . gnus-mime-externalize-part))
795 "An alist of actions that run on the MIME attachment."
796 :group 'gnus-article-mime
797 :type '(repeat (cons (string :tag "name")
800 (defcustom gnus-mime-action-alist
801 '(("save to file" . gnus-mime-save-part)
802 ("display as text" . gnus-mime-inline-part)
803 ("view the part" . gnus-mime-view-part)
804 ("pipe to command" . gnus-mime-pipe-part)
805 ("toggle display" . gnus-article-press-button)
806 ("view as type" . gnus-mime-view-part-as-type)
807 ("internalize type" . gnus-mime-internalize-part)
808 ("externalize type" . gnus-mime-externalize-part))
809 "An alist of actions that run on the MIME attachment."
811 :group 'gnus-article-mime
812 :type '(repeat (cons (string :tag "name")
816 ;;; The treatment variables
819 (defvar gnus-part-display-hook nil
820 "Hook called on parts that are to receive treatment.")
822 (defvar gnus-article-treat-custom
823 '(choice (const :tag "Off" nil)
825 (const :tag "Header" head)
826 (const :tag "Last" last)
827 (const :tag "Mime" mime)
828 (integer :tag "Less")
829 (repeat :tag "Groups" regexp)
830 (sexp :tag "Predicate")))
832 (defvar gnus-article-treat-head-custom
833 '(choice (const :tag "Off" nil)
834 (const :tag "Header" head)))
836 (defvar gnus-article-treat-types '("text/plain")
839 (defvar gnus-inhibit-treatment nil
840 "Whether to inhibit treatment.")
842 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
843 "Highlight the signature.
844 Valid values are nil, t, `head', `last', an integer or a predicate.
845 See the manual for details."
846 :group 'gnus-article-treat
847 :type gnus-article-treat-custom)
848 (put 'gnus-treat-highlight-signature 'highlight t)
850 (defcustom gnus-treat-buttonize 100000
852 Valid values are nil, t, `head', `last', an integer or a predicate.
853 See the manual for details."
854 :group 'gnus-article-treat
855 :type gnus-article-treat-custom)
856 (put 'gnus-treat-buttonize 'highlight t)
858 (defcustom gnus-treat-buttonize-head 'head
859 "Add buttons to the head.
860 Valid values are nil, t, `head', `last', an integer or a predicate.
861 See the manual for details."
862 :group 'gnus-article-treat
863 :type gnus-article-treat-head-custom)
864 (put 'gnus-treat-buttonize-head 'highlight t)
866 (defcustom gnus-treat-emphasize
867 (and (or window-system
869 (>= (string-to-number emacs-version) 21))
872 Valid values are nil, t, `head', `last', an integer or a predicate.
873 See the manual for details."
874 :group 'gnus-article-treat
875 :type gnus-article-treat-custom)
876 (put 'gnus-treat-emphasize 'highlight t)
878 (defcustom gnus-treat-strip-cr nil
879 "Remove carriage returns.
880 Valid values are nil, t, `head', `last', an integer or a predicate.
881 See the manual for details."
882 :group 'gnus-article-treat
883 :type gnus-article-treat-custom)
885 (defcustom gnus-treat-leading-whitespace nil
886 "Remove leading whitespace in headers.
887 Valid values are nil, t, `head', `last', an integer or a predicate.
888 See the manual for details."
889 :group 'gnus-article-treat
890 :type gnus-article-treat-custom)
892 (defcustom gnus-treat-hide-headers 'head
894 Valid values are nil, t, `head', `last', an integer or a predicate.
895 See the manual for details."
896 :group 'gnus-article-treat
897 :type gnus-article-treat-head-custom)
899 (defcustom gnus-treat-hide-boring-headers nil
900 "Hide boring headers.
901 Valid values are nil, t, `head', `last', an integer or a predicate.
902 See the manual for details."
903 :group 'gnus-article-treat
904 :type gnus-article-treat-head-custom)
906 (defcustom gnus-treat-hide-signature nil
908 Valid values are nil, t, `head', `last', an integer or a predicate.
909 See the manual for details."
910 :group 'gnus-article-treat
911 :type gnus-article-treat-custom)
913 (defcustom gnus-treat-fill-article nil
915 Valid values are nil, t, `head', `last', an integer or a predicate.
916 See the manual for details."
917 :group 'gnus-article-treat
918 :type gnus-article-treat-custom)
920 (defcustom gnus-treat-hide-citation nil
922 Valid values are nil, t, `head', `last', an integer or a predicate.
923 See the manual for details."
924 :group 'gnus-article-treat
925 :type gnus-article-treat-custom)
927 (defcustom gnus-treat-hide-citation-maybe nil
929 Valid values are nil, t, `head', `last', an integer or a predicate.
930 See the manual for details."
931 :group 'gnus-article-treat
932 :type gnus-article-treat-custom)
934 (defcustom gnus-treat-hide-citation-maybe nil
936 Valid values are nil, t, `head', `last', an integer or a predicate.
937 See the manual for details."
938 :group 'gnus-article-treat
939 :type gnus-article-treat-custom)
941 (defcustom gnus-treat-strip-list-identifiers 'head
942 "Strip list identifiers from `gnus-list-identifiers`.
943 Valid values are nil, t, `head', `last', an integer or a predicate.
944 See the manual for details."
946 :group 'gnus-article-treat
947 :type gnus-article-treat-custom)
949 (defcustom gnus-treat-strip-pgp t
950 "Strip PGP signatures.
951 Valid values are nil, t, `head', `last', an integer or a predicate.
952 See the manual for details."
953 :group 'gnus-article-treat
954 :type gnus-article-treat-custom)
956 (defcustom gnus-treat-strip-pem nil
957 "Strip PEM signatures.
958 Valid values are nil, t, `head', `last', an integer or a predicate.
959 See the manual for details."
960 :group 'gnus-article-treat
961 :type gnus-article-treat-custom)
963 (defcustom gnus-treat-strip-banner t
964 "Strip banners from articles.
965 The banner to be stripped is specified in the `banner' group parameter.
966 Valid values are nil, t, `head', `last', an integer or a predicate.
967 See the manual for details."
968 :group 'gnus-article-treat
969 :type gnus-article-treat-custom)
971 (defcustom gnus-treat-highlight-headers 'head
972 "Highlight the headers.
973 Valid values are nil, t, `head', `last', an integer or a predicate.
974 See the manual for details."
975 :group 'gnus-article-treat
976 :type gnus-article-treat-head-custom)
977 (put 'gnus-treat-highlight-headers 'highlight t)
979 (defcustom gnus-treat-highlight-citation t
980 "Highlight cited text.
981 Valid values are nil, t, `head', `last', an integer or a predicate.
982 See the manual for details."
983 :group 'gnus-article-treat
984 :type gnus-article-treat-custom)
985 (put 'gnus-treat-highlight-citation 'highlight t)
987 (defcustom gnus-treat-date-ut nil
988 "Display the Date in UT (GMT).
989 Valid values are nil, t, `head', `last', an integer or a predicate.
990 See the manual for details."
991 :group 'gnus-article-treat
992 :type gnus-article-treat-head-custom)
994 (defcustom gnus-treat-date-local nil
995 "Display the Date in the local timezone.
996 Valid values are nil, t, `head', `last', an integer or a predicate.
997 See the manual for details."
998 :group 'gnus-article-treat
999 :type gnus-article-treat-head-custom)
1001 (defcustom gnus-treat-date-english nil
1002 "Display the Date in a format that can be read aloud in English.
1003 Valid values are nil, t, `head', `last', an integer or a predicate.
1004 See the manual for details."
1005 :group 'gnus-article-treat
1006 :type gnus-article-treat-head-custom)
1008 (defcustom gnus-treat-date-lapsed nil
1009 "Display the Date header in a way that says how much time has elapsed.
1010 Valid values are nil, t, `head', `last', an integer or a predicate.
1011 See the manual for details."
1012 :group 'gnus-article-treat
1013 :type gnus-article-treat-head-custom)
1015 (defcustom gnus-treat-date-original nil
1016 "Display the date in the original timezone.
1017 Valid values are nil, t, `head', `last', an integer or a predicate.
1018 See the manual for details."
1019 :group 'gnus-article-treat
1020 :type gnus-article-treat-head-custom)
1022 (defcustom gnus-treat-date-iso8601 nil
1023 "Display the date in the ISO8601 format.
1024 Valid values are nil, t, `head', `last', an integer or a predicate.
1025 See the manual for details."
1027 :group 'gnus-article-treat
1028 :type gnus-article-treat-head-custom)
1030 (defcustom gnus-treat-date-user-defined nil
1031 "Display the date in a user-defined format.
1032 The format is defined by the `gnus-article-time-format' variable.
1033 Valid values are nil, t, `head', `last', an integer or a predicate.
1034 See the manual for details."
1035 :group 'gnus-article-treat
1036 :type gnus-article-treat-head-custom)
1038 (defcustom gnus-treat-strip-headers-in-body t
1039 "Strip the X-No-Archive header line from the beginning of the body.
1040 Valid values are nil, t, `head', `last', an integer or a predicate.
1041 See the manual for details."
1043 :group 'gnus-article-treat
1044 :type gnus-article-treat-custom)
1046 (defcustom gnus-treat-strip-trailing-blank-lines nil
1047 "Strip trailing blank lines.
1048 Valid values are nil, t, `head', `last', an integer or a predicate.
1049 See the manual for details."
1050 :group 'gnus-article-treat
1051 :type gnus-article-treat-custom)
1053 (defcustom gnus-treat-strip-leading-blank-lines nil
1054 "Strip leading blank lines.
1055 Valid values are nil, t, `head', `last', an integer or a predicate.
1056 See the manual for details."
1057 :group 'gnus-article-treat
1058 :type gnus-article-treat-custom)
1060 (defcustom gnus-treat-strip-multiple-blank-lines nil
1061 "Strip multiple blank lines.
1062 Valid values are nil, t, `head', `last', an integer or a predicate.
1063 See the manual for details."
1064 :group 'gnus-article-treat
1065 :type gnus-article-treat-custom)
1067 (defcustom gnus-treat-overstrike t
1068 "Treat overstrike highlighting.
1069 Valid values are nil, t, `head', `last', an integer or a predicate.
1070 See the manual for details."
1071 :group 'gnus-article-treat
1072 :type gnus-article-treat-custom)
1073 (put 'gnus-treat-overstrike 'highlight t)
1075 (defcustom gnus-treat-display-xface
1076 (and (or (and (fboundp 'image-type-available-p)
1077 (image-type-available-p 'xbm)
1078 (string-match "^0x" (shell-command-to-string "uncompface")))
1079 (and (featurep 'xemacs) (featurep 'xface))
1080 (eq 'x-face-mule-gnus-article-display-x-face
1081 gnus-article-x-face-command))
1083 "Display X-Face headers.
1084 Valid values are nil, t, `head', `last', an integer or a predicate.
1085 See the manual for details."
1086 :group 'gnus-article-treat
1088 :type gnus-article-treat-head-custom)
1089 (put 'gnus-treat-display-xface 'highlight t)
1091 (defcustom gnus-treat-display-smileys
1092 (if (or (and (featurep 'xemacs)
1094 (and (fboundp 'image-type-available-p)
1095 (image-type-available-p 'pbm))
1096 (and (not (featurep 'xemacs))
1098 (module-installed-p 'smiley-mule)))
1102 Valid values are nil, t, `head', `last', an integer or a predicate.
1103 See the manual for details."
1104 :group 'gnus-article-treat
1106 :type gnus-article-treat-custom)
1107 (put 'gnus-treat-display-smileys 'highlight t)
1109 (defcustom gnus-treat-display-picons (if (featurep 'xemacs) 'head nil)
1111 Valid values are nil, t, `head', `last', an integer or a predicate.
1112 See the manual for details."
1113 :group 'gnus-article-treat
1114 :type gnus-article-treat-head-custom)
1115 (put 'gnus-treat-display-picons 'highlight t)
1117 (defcustom gnus-treat-capitalize-sentences nil
1118 "Capitalize sentence-starting words.
1119 Valid values are nil, t, `head', `last', an integer or a predicate.
1120 See the manual for details."
1122 :group 'gnus-article-treat
1123 :type gnus-article-treat-custom)
1125 (defcustom gnus-treat-fill-long-lines nil
1127 Valid values are nil, t, `head', `last', an integer or a predicate.
1128 See the manual for details."
1129 :group 'gnus-article-treat
1130 :type gnus-article-treat-custom)
1132 (defcustom gnus-treat-play-sounds nil
1134 Valid values are nil, t, `head', `last', an integer or a predicate.
1135 See the manual for details."
1137 :group 'gnus-article-treat
1138 :type gnus-article-treat-custom)
1140 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
1141 "Decode an article as `default-mime-charset'. For instance, if you want to
1142 attempt to decode an article even if the value of `gnus-show-mime' is nil,
1143 you could set this variable to something like: nil for don't decode, t for
1144 decode the body, '(or header t) for the whole article, etc."
1145 :group 'gnus-article-treat
1146 :type '(radio (const :tag "Off" nil)
1147 (const :tag "Decode body" t)
1148 (const :tag "Decode all" (or head t))))
1150 (defcustom gnus-treat-translate nil
1151 "Translate articles from one language to another.
1152 Valid values are nil, t, `head', `last', an integer or a predicate.
1153 See the manual for details."
1155 :group 'gnus-article-treat
1156 :type gnus-article-treat-custom)
1158 (defcustom gnus-treat-x-pgp-sig nil
1160 To automatically treat X-PGP-Sig, set it to head.
1161 Valid values are nil, t, `head', `last', an integer or a predicate.
1162 See the manual for details."
1163 :group 'gnus-article-treat
1164 :group 'mime-security
1165 :type gnus-article-treat-custom)
1167 (defvar gnus-article-encrypt-protocol-alist
1168 '(("PGP" . mml2015-self-encrypt)))
1170 ;; Set to nil if more than one protocol added to
1171 ;; gnus-article-encrypt-protocol-alist.
1172 (defcustom gnus-article-encrypt-protocol "PGP"
1173 "The protocol used for encrypt articles.
1174 It is a string, such as \"PGP\". If nil, ask user."
1176 :group 'mime-security)
1178 ;;; Internal variables
1180 (defvar gnus-english-month-names
1181 '("January" "February" "March" "April" "May" "June" "July" "August"
1182 "September" "October" "November" "December"))
1184 (defvar article-goto-body-goes-to-point-min-p nil)
1185 (defvar gnus-article-wash-types nil)
1186 (defvar gnus-article-emphasis-alist nil)
1188 (defvar gnus-article-mime-handle-alist-1 nil)
1189 (defvar gnus-treatment-function-alist
1190 `((gnus-treat-decode-article-as-default-mime-charset
1191 gnus-article-decode-article-as-default-mime-charset)
1192 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1193 (gnus-treat-strip-banner gnus-article-strip-banner)
1194 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1195 (gnus-treat-buttonize gnus-article-add-buttons)
1196 (gnus-treat-fill-article gnus-article-fill-cited-article)
1197 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1198 (gnus-treat-strip-cr gnus-article-remove-cr)
1199 (gnus-treat-display-xface gnus-article-display-x-face)
1200 (gnus-treat-date-ut gnus-article-date-ut)
1201 (gnus-treat-date-local gnus-article-date-local)
1202 (gnus-treat-date-english gnus-article-date-english)
1203 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1204 (gnus-treat-date-original gnus-article-date-original)
1205 (gnus-treat-date-user-defined gnus-article-date-user)
1206 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1207 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1208 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1209 (gnus-treat-hide-signature gnus-article-hide-signature)
1210 (gnus-treat-hide-citation gnus-article-hide-citation)
1211 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1212 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1213 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1214 (gnus-treat-strip-pgp gnus-article-hide-pgp)
1215 (gnus-treat-strip-pem gnus-article-hide-pem)
1216 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1217 (gnus-treat-emphasize gnus-article-emphasize)
1218 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1219 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1220 (gnus-treat-strip-trailing-blank-lines
1221 gnus-article-remove-trailing-blank-lines)
1222 (gnus-treat-strip-leading-blank-lines
1223 gnus-article-strip-leading-blank-lines)
1224 (gnus-treat-strip-multiple-blank-lines
1225 gnus-article-strip-multiple-blank-lines)
1226 (gnus-treat-overstrike gnus-article-treat-overstrike)
1227 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1228 (gnus-treat-display-smileys ,(if (or (featurep 'xemacs)
1229 (>= emacs-major-version 21))
1230 'gnus-smiley-display
1231 'gnus-article-smiley-display))
1232 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1233 (gnus-treat-display-picons gnus-article-display-picons)
1234 (gnus-treat-play-sounds gnus-earcon-display)))
1236 (defvar gnus-article-mime-handle-alist nil)
1237 (defvar article-lapsed-timer nil)
1238 (defvar gnus-article-current-summary nil)
1240 (defvar gnus-article-mode-syntax-table
1241 (let ((table (copy-syntax-table text-mode-syntax-table)))
1242 ;; This causes the citation match run O(2^n).
1243 ;; (modify-syntax-entry ?- "w" table)
1244 (modify-syntax-entry ?> ")" table)
1245 (modify-syntax-entry ?< "(" table)
1247 "Syntax table used in article mode buffers.
1248 Initialized from `text-mode-syntax-table.")
1250 (defvar gnus-save-article-buffer nil)
1252 (defvar gnus-article-mode-line-format-alist
1253 (nconc '((?w (gnus-article-wash-status) ?s)
1254 (?m (gnus-article-mime-part-status) ?s))
1255 gnus-summary-mode-line-format-alist))
1257 (defvar gnus-number-of-articles-to-be-saved nil)
1259 (defvar gnus-inhibit-hiding nil)
1261 (defsubst gnus-article-hide-text (b e props)
1262 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1263 (gnus-add-text-properties-when 'article-type nil b e props)
1264 (when (memq 'intangible props)
1266 (max (1- b) (point-min))
1267 b 'intangible (cddr (memq 'intangible props)))))
1269 (defsubst gnus-article-unhide-text (b e)
1270 "Remove hidden text properties from region between B and E."
1271 (remove-text-properties b e gnus-hidden-properties)
1272 (when (memq 'intangible gnus-hidden-properties)
1273 (put-text-property (max (1- b) (point-min))
1274 b 'intangible nil)))
1276 (defun gnus-article-hide-text-type (b e type)
1277 "Hide text of TYPE between B and E."
1278 (push type gnus-article-wash-types)
1279 (gnus-article-hide-text
1280 b e (cons 'article-type (cons type gnus-hidden-properties))))
1282 (defun gnus-article-unhide-text-type (b e type)
1283 "Unhide text of TYPE between B and E."
1284 (setq gnus-article-wash-types
1285 (delq type gnus-article-wash-types))
1286 (remove-text-properties
1287 b e (cons 'article-type (cons type gnus-hidden-properties)))
1288 (when (memq 'intangible gnus-hidden-properties)
1289 (put-text-property (max (1- b) (point-min))
1290 b 'intangible nil)))
1292 (defun gnus-article-hide-text-of-type (type)
1293 "Hide text of TYPE in the current buffer."
1295 (let ((b (point-min))
1297 (while (setq b (text-property-any b e 'article-type type))
1298 (add-text-properties b (incf b) gnus-hidden-properties)))))
1300 (defun gnus-article-delete-text-of-type (type)
1301 "Delete text of TYPE in the current buffer."
1303 (let ((b (point-min)))
1304 (while (setq b (text-property-any b (point-max) 'article-type type))
1306 b (or (text-property-not-all b (point-max) 'article-type type)
1309 (defun gnus-article-delete-invisible-text ()
1310 "Delete all invisible text in the current buffer."
1312 (let ((b (point-min)))
1313 (while (setq b (text-property-any b (point-max) 'invisible t))
1315 b (or (text-property-not-all b (point-max) 'invisible t)
1318 (defun gnus-article-text-type-exists-p (type)
1319 "Say whether any text of type TYPE exists in the buffer."
1320 (text-property-any (point-min) (point-max) 'article-type type))
1322 (defsubst gnus-article-header-rank ()
1323 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1324 (let ((list gnus-sorted-header-list)
1327 (when (looking-at (car list))
1329 (setq list (cdr list))
1333 (defun article-hide-headers (&optional arg delete)
1334 "Hide unwanted headers and possibly sort them as well."
1335 (interactive (gnus-article-hidden-arg))
1336 ;; Lars said that this function might be inhibited.
1337 (if (gnus-article-check-hidden-text 'headers arg)
1339 ;; Show boring headers as well.
1340 (gnus-article-show-hidden-text 'boring-headers)
1341 (when (eq 1 (point-min))
1342 (set-window-start (get-buffer-window (current-buffer)) 1)))
1343 (unless gnus-inhibit-hiding
1346 (let ((inhibit-read-only t)
1347 (case-fold-search t)
1348 (max (1+ (length gnus-sorted-header-list)))
1349 (ignored (when (not gnus-visible-headers)
1350 (cond ((stringp gnus-ignored-headers)
1351 gnus-ignored-headers)
1352 ((listp gnus-ignored-headers)
1353 (mapconcat 'identity gnus-ignored-headers
1356 (cond ((stringp gnus-visible-headers)
1357 gnus-visible-headers)
1358 ((and gnus-visible-headers
1359 (listp gnus-visible-headers))
1360 (mapconcat 'identity gnus-visible-headers "\\|"))))
1361 (inhibit-point-motion-hooks t)
1363 ;; First we narrow to just the headers.
1364 (article-narrow-to-head)
1365 ;; Hide any "From " lines at the beginning of (mail) articles.
1366 (while (looking-at "From ")
1370 (delete-region (point-min) (point))
1371 (gnus-article-hide-text (point-min) (point)
1372 (nconc (list 'article-type 'headers)
1373 gnus-hidden-properties))))
1374 ;; Then treat the rest of the header lines.
1375 ;; Then we use the two regular expressions
1376 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1377 ;; select which header lines is to remain visible in the
1379 (while (re-search-forward "^[^ \t:]*:" nil t)
1381 ;; Mark the rank of the header.
1383 (point) (1+ (point)) 'message-rank
1384 (if (or (and visible (looking-at visible))
1386 (not (looking-at ignored))))
1387 (gnus-article-header-rank)
1390 (message-sort-headers-1)
1391 (when (setq beg (text-property-any
1392 (point-min) (point-max) 'message-rank (+ 2 max)))
1393 ;; We delete or make invisible the unwanted headers.
1394 (push 'headers gnus-article-wash-types)
1397 (add-text-properties
1398 (point-min) (+ 5 (point-min))
1399 '(article-type headers dummy-invisible t))
1400 (delete-region beg (point-max)))
1401 (gnus-article-hide-text-type beg (point-max) 'headers))))))))
1404 (defun article-hide-boring-headers (&optional arg)
1405 "Toggle hiding of headers that aren't very interesting.
1406 If given a negative prefix, always show; if given a positive prefix,
1408 (interactive (gnus-article-hidden-arg))
1409 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1410 (not gnus-show-all-headers))
1413 (let ((buffer-read-only nil)
1414 (list gnus-boring-article-headers)
1415 (inhibit-point-motion-hooks t)
1417 (article-narrow-to-head)
1419 (setq elem (pop list))
1420 (goto-char (point-min))
1422 ;; Hide empty headers.
1424 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1426 (gnus-article-hide-text-type
1427 (progn (beginning-of-line) (point))
1430 (if (re-search-forward "^[^ \t]" nil t)
1434 ;; Hide boring Newsgroups header.
1435 ((eq elem 'newsgroups)
1436 (when (gnus-string-equal
1437 (gnus-fetch-field "newsgroups")
1438 (gnus-group-real-name
1439 (if (boundp 'gnus-newsgroup-name)
1442 (gnus-article-hide-header "newsgroups")))
1443 ((eq elem 'to-address)
1444 (let ((to (message-fetch-field "to"))
1446 (gnus-parameter-to-address
1447 (if (boundp 'gnus-newsgroup-name)
1448 gnus-newsgroup-name ""))))
1449 (when (and to to-address
1452 ;; only one address in To
1453 (nth 1 (mail-extract-address-components to))
1455 (gnus-article-hide-header "to"))))
1456 ((eq elem 'followup-to)
1457 (when (gnus-string-equal
1458 (message-fetch-field "followup-to")
1459 (message-fetch-field "newsgroups"))
1460 (gnus-article-hide-header "followup-to")))
1461 ((eq elem 'reply-to)
1462 (let ((from (message-fetch-field "from"))
1463 (reply-to (message-fetch-field "reply-to")))
1468 (nth 1 (mail-extract-address-components from))
1469 (nth 1 (mail-extract-address-components reply-to)))))
1470 (gnus-article-hide-header "reply-to"))))
1472 (let ((date (message-fetch-field "date")))
1474 (< (days-between (current-time-string) date)
1476 (gnus-article-hide-header "date"))))
1478 (let ((to (message-fetch-field "to"))
1479 (cc (message-fetch-field "cc")))
1480 (when (> (length to) 1024)
1481 (gnus-article-hide-header "to"))
1482 (when (> (length cc) 1024)
1483 (gnus-article-hide-header "cc"))))
1487 (goto-char (point-min))
1488 (while (re-search-forward "^to:" nil t)
1489 (setq to-count (1+ to-count)))
1490 (when (> to-count 1)
1491 (while (> to-count 0)
1492 (goto-char (point-min))
1494 (re-search-forward "^to:" nil nil to-count)
1496 (narrow-to-region (point) (point-max))
1497 (gnus-article-hide-header "to"))
1498 (setq to-count (1- to-count))))
1499 (goto-char (point-min))
1500 (while (re-search-forward "^cc:" nil t)
1501 (setq cc-count (1+ cc-count)))
1502 (when (> cc-count 1)
1503 (while (> cc-count 0)
1504 (goto-char (point-min))
1506 (re-search-forward "^cc:" nil nil cc-count)
1508 (narrow-to-region (point) (point-max))
1509 (gnus-article-hide-header "cc"))
1510 (setq cc-count (1- cc-count)))))))))))))
1512 (defun gnus-article-hide-header (header)
1514 (goto-char (point-min))
1515 (when (re-search-forward (concat "^" header ":") nil t)
1516 (gnus-article-hide-text-type
1517 (progn (beginning-of-line) (point))
1520 (if (re-search-forward "^[^ \t]" nil t)
1525 (defun article-toggle-headers (&optional arg)
1526 "Toggle hiding of headers. If given a negative prefix, always show;
1527 if given a positive prefix, always hide."
1528 (interactive (gnus-article-hidden-arg))
1529 (let ((force (when (numberp arg)
1530 (cond ((> arg 0) 'always-hide)
1531 ((< arg 0) 'always-show))))
1532 (window (get-buffer-window gnus-article-buffer))
1533 (header-end (point-min))
1534 header-start field-end field-start
1535 (inhibit-point-motion-hooks t)
1536 (inhibit-read-only t))
1539 (while (and (setq header-start
1540 (text-property-any header-end (point-max)
1541 'article-treated-header t))
1543 (text-property-not-all header-start (point-max)
1544 'article-treated-header t)))
1545 (setq field-end header-start)
1547 (;; Hide exposed invisible fields.
1548 (and (not (eq 'always-show force))
1550 (text-property-any field-end header-end
1551 'exposed-invisible-field t)))
1552 (while (and field-start
1553 (setq field-end (text-property-not-all
1554 field-start header-end
1555 'exposed-invisible-field t)))
1556 (add-text-properties field-start field-end gnus-hidden-properties)
1557 (setq field-start (text-property-any field-end header-end
1558 'exposed-invisible-field t)))
1559 (put-text-property header-start header-end
1560 'exposed-invisible-field nil))
1561 (;; Expose invisible fields.
1562 (and (not (eq 'always-hide force))
1564 (text-property-any field-end header-end 'invisible t)))
1565 (while (and field-start
1566 (setq field-end (text-property-not-all
1567 field-start header-end
1569 ;; If the invisible text is not terminated with newline, we
1570 ;; won't expose it. Because it may be created by x-face-mule.
1571 ;; BTW, XEmacs sometimes fail in putting a invisible text
1572 ;; property with `gnus-article-hide-text' (really?). In that
1573 ;; case, the invisible text might be started from the middle of
1574 ;; a line so we will expose the sort of thing.
1575 (when (or (not (or (eq header-start field-start)
1576 (eq ?\n (char-before field-start))))
1577 (eq ?\n (char-before field-end)))
1578 (remove-text-properties field-start field-end
1579 gnus-hidden-properties)
1580 (put-text-property field-start field-end
1581 'exposed-invisible-field t))
1582 (setq field-start (text-property-any field-end header-end
1585 (not (eq 'always-show force))
1586 (narrow-to-region header-start header-end)
1587 (article-hide-headers)
1588 ;; Re-display X-Face image under XEmacs.
1589 (when (and (featurep 'xemacs)
1590 (gnus-functionp gnus-article-x-face-command))
1591 (let ((func (cadr (assq 'gnus-treat-display-xface
1592 gnus-treatment-function-alist)))
1594 (when (and (not gnus-inhibit-treatment)
1596 (gnus-treat-predicate gnus-treat-display-xface))
1598 (put-text-property header-start header-end 'read-only nil))))
1601 (goto-char (point-min))
1603 (set-window-start window (point-min))))))
1605 (defvar gnus-article-normalized-header-length 40
1606 "Length of normalized headers.")
1608 (defun article-normalize-headers ()
1609 "Make all header lines 40 characters long."
1611 (let ((buffer-read-only nil)
1615 (article-narrow-to-head)
1618 ((< (setq column (- (gnus-point-at-eol) (point)))
1619 gnus-article-normalized-header-length)
1621 (insert (make-string
1622 (- gnus-article-normalized-header-length column)
1624 ((> column gnus-article-normalized-header-length)
1625 (gnus-put-text-property
1627 (forward-char gnus-article-normalized-header-length)
1634 (forward-line 1))))))
1636 (defun article-treat-dumbquotes ()
1637 "Translate M****s*** sm*rtq**t*s into proper text.
1638 Note that this function guesses whether a character is a sm*rtq**t* or
1639 not, so it should only be used interactively.
1641 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1642 in an attempt to provide more quoting characters. If you see
1643 something like \\222 or \\264 where you're expecting some kind of
1644 apostrophe or quotation mark, then try this wash."
1646 (article-translate-strings gnus-article-dumbquotes-map))
1648 (defun article-translate-characters (from to)
1649 "Translate all characters in the body of the article according to FROM and TO.
1650 FROM is a string of characters to translate from; to is a string of
1651 characters to translate to."
1653 (when (article-goto-body)
1654 (let ((buffer-read-only nil)
1655 (x (make-string 225 ?x))
1657 (while (< (incf i) (length x))
1660 (while (< i (length from))
1661 (aset x (aref from i) (aref to i))
1663 (translate-region (point) (point-max) x)))))
1665 (defun article-translate-strings (map)
1666 "Translate all string in the body of the article according to MAP.
1667 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1669 (when (article-goto-body)
1670 (let ((buffer-read-only nil)
1672 (while (setq elem (pop map))
1674 (while (search-forward (car elem) nil t)
1675 (replace-match (cadr elem)))))))))
1677 (defun article-treat-overstrike ()
1678 "Translate overstrikes into bold text."
1681 (when (article-goto-body)
1682 (let ((buffer-read-only nil))
1683 (while (search-forward "\b" nil t)
1684 (let ((next (char-after))
1688 previous (char-after))
1692 ;; We do the boldification/underlining by hiding the
1693 ;; overstrikes and putting the proper text property
1697 (gnus-article-hide-text-type start (point) 'overstrike)
1698 (put-text-property (point) end 'face 'bold))
1700 (gnus-article-hide-text-type
1701 (1- (point)) (1+ (point)) 'overstrike)
1703 start (1- (point)) 'face 'underline))
1705 (gnus-article-hide-text-type start (point) 'overstrike)
1707 (point) end 'face 'underline)))))))))
1709 (defun article-fill-long-lines ()
1710 "Fill lines that are wider than the window width."
1713 (let ((buffer-read-only nil)
1714 (width (window-width (get-buffer-window (current-buffer)))))
1717 (let ((adaptive-fill-mode nil)) ;Why? -sm
1720 (when (>= (current-column) (min fill-column width))
1721 (narrow-to-region (point) (gnus-point-at-bol))
1722 (fill-paragraph nil)
1723 (goto-char (point-max))
1725 (forward-line 1)))))))
1727 (defun article-capitalize-sentences ()
1728 "Capitalize the first word in each sentence."
1731 (let ((buffer-read-only nil)
1732 (paragraph-start "^[\n\^L]"))
1736 (forward-sentence)))))
1738 (defun article-remove-cr ()
1739 "Remove trailing CRs and then translate remaining CRs into LFs."
1742 (let ((buffer-read-only nil))
1743 (goto-char (point-min))
1744 (while (re-search-forward "\r+$" nil t)
1745 (replace-match "" t t))
1746 (goto-char (point-min))
1747 (while (search-forward "\r" nil t)
1748 (replace-match "\n" t t)))))
1750 (defun article-remove-trailing-blank-lines ()
1751 "Remove all trailing blank lines from the article."
1754 (let ((buffer-read-only nil))
1755 (goto-char (point-max))
1759 (while (and (not (bobp))
1760 (looking-at "^[ \t]*$")
1761 (not (gnus-annotation-in-region-p
1762 (point) (gnus-point-at-eol))))
1767 (defun article-display-x-face (&optional force)
1768 "Look for an X-Face header and display it if present."
1769 (interactive (list 'force))
1771 ;; Delete the old process, if any.
1772 (when (process-status "article-x-face")
1773 (delete-process "article-x-face"))
1774 (let ((inhibit-point-motion-hooks t)
1776 (case-fold-search t)
1779 (article-narrow-to-head)
1780 ;; (when (and buffer-read-only ;; When type `W f'
1782 ;; (goto-char (point-min))
1783 ;; (not (re-search-forward "^X-Face:[\t ]*" nil t)))
1784 ;; (gnus-buffer-live-p gnus-original-article-buffer))
1785 ;; (with-current-buffer gnus-original-article-buffer
1786 ;; (save-restriction
1787 ;; (article-narrow-to-head)
1788 ;; (while (re-search-forward "^X-Face:" nil t)
1792 ;; (buffer-substring
1793 ;; (match-beginning 0)
1794 ;; (1- (re-search-forward
1795 ;; "^\\($\\|[^ \t]\\)" nil t))))))))
1797 ;; (let (point start bface eface buffer-read-only)
1798 ;; (goto-char (point-max))
1799 ;; (forward-line -1)
1800 ;; (setq bface (get-text-property (gnus-point-at-bol) 'face)
1801 ;; eface (get-text-property (1- (gnus-point-at-eol)) 'face))
1802 ;; (goto-char (point-max))
1803 ;; (setq point (point))
1805 ;; (goto-char point)
1806 ;; (while (looking-at "\\([^:]+\\): *")
1807 ;; (put-text-property (match-beginning 1) (1+ (match-end 1))
1809 ;; (setq start (match-end 0))
1811 ;; (while (looking-at "[\t ]")
1812 ;; (forward-line 1))
1813 ;; (put-text-property start (point)
1815 (goto-char (point-min))
1816 (setq from (message-fetch-field "from"))
1817 (goto-char (point-min))
1818 (while (and gnus-article-x-face-command
1821 ;; Check whether this face is censored.
1822 (not gnus-article-x-face-too-ugly)
1823 (and gnus-article-x-face-too-ugly from
1824 (not (string-match gnus-article-x-face-too-ugly
1826 ;; Has to be present.
1827 (re-search-forward "^X-Face:[\t ]*" nil t))
1828 ;; This used to try to do multiple faces (`while' instead of
1829 ;; `when' above), but (a) sending multiple EOFs to xv doesn't
1830 ;; work (b) it can crash some versions of Emacs (c) are
1831 ;; multiple faces really something to encourage?
1832 (when (stringp gnus-article-x-face-command)
1834 ;; We now have the area of the buffer where the X-Face is stored.
1837 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
1838 ;; We display the face.
1839 (if (symbolp gnus-article-x-face-command)
1840 ;; The command is a lisp function, so we call it.
1841 (if (gnus-functionp gnus-article-x-face-command)
1842 (funcall gnus-article-x-face-command beg end)
1843 (error "%s is not a function" gnus-article-x-face-command))
1844 ;; The command is a string, so we interpret the command
1845 ;; as a, well, command, and fork it off.
1846 (let ((process-connection-type nil))
1847 (process-kill-without-query
1849 "article-x-face" nil shell-file-name shell-command-switch
1850 gnus-article-x-face-command))
1851 (process-send-region "article-x-face" beg end)
1852 (process-send-eof "article-x-face"))))))))))
1854 (defun article-decode-mime-words ()
1855 "Decode all MIME-encoded words in the article."
1858 (set-buffer gnus-article-buffer)
1859 (let ((inhibit-point-motion-hooks t)
1861 (mail-parse-charset gnus-newsgroup-charset)
1862 (mail-parse-ignored-charsets
1863 (save-excursion (set-buffer gnus-summary-buffer)
1864 gnus-newsgroup-ignored-charsets)))
1865 (mail-decode-encoded-word-region (point-min) (point-max)))))
1867 (defun article-decode-charset (&optional prompt)
1868 "Decode charset-encoded text in the article.
1869 If PROMPT (the prefix), prompt for a coding system to use."
1871 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
1873 (mail-parse-charset gnus-newsgroup-charset)
1874 (mail-parse-ignored-charsets
1875 (save-excursion (condition-case nil
1876 (set-buffer gnus-summary-buffer)
1878 gnus-newsgroup-ignored-charsets))
1879 ct cte ctl charset format)
1882 (article-narrow-to-head)
1883 (setq ct (message-fetch-field "Content-Type" t)
1884 cte (message-fetch-field "Content-Transfer-Encoding" t)
1885 ctl (and ct (ignore-errors
1886 (mail-header-parse-content-type ct)))
1889 (mm-read-coding-system "Charset to decode: "))
1891 (mail-content-type-get ctl 'charset)))
1892 format (and ctl (mail-content-type-get ctl 'format)))
1894 (setq cte (mail-header-strip cte)))
1895 (if (and ctl (not (string-match "/" (car ctl))))
1897 (goto-char (point-max)))
1900 (narrow-to-region (point) (point-max))
1901 (when (and (eq mail-parse-charset 'gnus-decoded)
1902 (eq (mm-body-7-or-8) '8bit))
1903 ;; The text code could have been decoded.
1904 (setq charset mail-parse-charset))
1905 (when (and (or (not ctl)
1906 (equal (car ctl) "text/plain"))
1907 (not format)) ;; article with format will decode later.
1909 charset (and cte (intern (downcase
1910 (gnus-strip-whitespace cte))))
1913 (defun article-decode-encoded-words ()
1914 "Remove encoded-word encoding from headers."
1915 (let (buffer-read-only)
1916 (let ((charset (save-excursion
1917 (set-buffer gnus-summary-buffer)
1918 default-mime-charset)))
1919 (mime-decode-header-in-buffer charset))))
1921 (defun article-decode-group-name ()
1922 "Decode group names in `Newsgroups:'."
1923 (let ((inhibit-point-motion-hooks t)
1925 (method (gnus-find-method-for-group gnus-newsgroup-name)))
1926 (when (and (or gnus-group-name-charset-method-alist
1927 gnus-group-name-charset-group-alist)
1928 (gnus-buffer-live-p gnus-original-article-buffer))
1929 (when (mail-fetch-field "Newsgroups")
1930 (nnheader-replace-header "Newsgroups"
1931 (gnus-decode-newsgroups
1932 (with-current-buffer
1933 gnus-original-article-buffer
1934 (mail-fetch-field "Newsgroups"))
1935 gnus-newsgroup-name method)))
1936 (when (mail-fetch-field "Followup-To")
1937 (nnheader-replace-header "Followup-To"
1938 (gnus-decode-newsgroups
1939 (with-current-buffer
1940 gnus-original-article-buffer
1941 (mail-fetch-field "Followup-To"))
1942 gnus-newsgroup-name method))))))
1944 (defun article-de-quoted-unreadable (&optional force read-charset)
1945 "Translate a quoted-printable-encoded article.
1946 If FORCE, decode the article whether it is marked as quoted-printable
1948 If READ-CHARSET, ask for a coding system."
1949 (interactive (list 'force current-prefix-arg))
1951 (let ((buffer-read-only nil) type charset)
1952 (if (gnus-buffer-live-p gnus-original-article-buffer)
1953 (with-current-buffer gnus-original-article-buffer
1955 (gnus-fetch-field "content-transfer-encoding"))
1956 (let* ((ct (gnus-fetch-field "content-type"))
1959 (mail-header-parse-content-type ct)))))
1960 (setq charset (and ctl
1961 (mail-content-type-get ctl 'charset)))
1962 (if (stringp charset)
1963 (setq charset (intern (downcase charset)))))))
1965 (setq charset (mm-read-coding-system "Charset: " charset)))
1967 (setq charset gnus-newsgroup-charset))
1969 (and type (let ((case-fold-search t))
1970 (string-match "quoted-printable" type))))
1972 (quoted-printable-decode-region
1973 (point) (point-max) (mm-charset-to-coding-system charset))))))
1975 (defun article-de-base64-unreadable (&optional force read-charset)
1976 "Translate a base64 article.
1977 If FORCE, decode the article whether it is marked as base64 not.
1978 If READ-CHARSET, ask for a coding system."
1979 (interactive (list 'force current-prefix-arg))
1981 (let ((buffer-read-only nil) type charset)
1982 (if (gnus-buffer-live-p gnus-original-article-buffer)
1983 (with-current-buffer gnus-original-article-buffer
1985 (gnus-fetch-field "content-transfer-encoding"))
1986 (let* ((ct (gnus-fetch-field "content-type"))
1989 (mail-header-parse-content-type ct)))))
1990 (setq charset (and ctl
1991 (mail-content-type-get ctl 'charset)))
1992 (if (stringp charset)
1993 (setq charset (intern (downcase charset)))))))
1995 (setq charset (mm-read-coding-system "Charset: " charset)))
1997 (setq charset gnus-newsgroup-charset))
1999 (and type (let ((case-fold-search t))
2000 (string-match "base64" type))))
2003 (narrow-to-region (point) (point-max))
2004 (base64-decode-region (point-min) (point-max))
2005 (mm-decode-coding-region
2006 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2011 (defun article-decode-HZ ()
2012 "Translate a HZ-encoded article."
2016 (let ((buffer-read-only nil))
2017 (rfc1843-decode-region (point-min) (point-max)))))
2019 (defun article-wash-html (&optional read-charset)
2020 "Format an html article.
2021 If READ-CHARSET, ask for a coding system."
2024 (let ((buffer-read-only nil)
2026 (if (gnus-buffer-live-p gnus-original-article-buffer)
2027 (with-current-buffer gnus-original-article-buffer
2028 (let* ((ct (gnus-fetch-field "content-type"))
2031 (mail-header-parse-content-type ct)))))
2032 (setq charset (and ctl
2033 (mail-content-type-get ctl 'charset)))
2034 (if (stringp charset)
2035 (setq charset (intern (downcase charset)))))))
2037 (setq charset (mm-read-coding-system "Charset: " charset)))
2039 (setq charset gnus-newsgroup-charset))
2041 (save-window-excursion
2043 (narrow-to-region (point) (point-max))
2045 (let ((w3-strict-width (window-width))
2046 (url-standalone-mode t))
2048 (w3-region (point-min) (point-max))
2051 (defun article-hide-list-identifiers ()
2052 "Remove list identifies from the Subject header.
2053 The `gnus-list-identifiers' variable specifies what to do."
2055 (let ((inhibit-point-motion-hooks t)
2056 (regexp (if (consp gnus-list-identifiers)
2057 (mapconcat 'identity gnus-list-identifiers " *\\|")
2058 gnus-list-identifiers))
2063 (article-narrow-to-head)
2064 (goto-char (point-min))
2065 (while (re-search-forward
2066 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2068 (delete-region (match-beginning 2) (match-end 0))
2069 (beginning-of-line))
2070 (when (re-search-forward
2071 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2072 (delete-region (match-beginning 1) (match-end 1))))))))
2074 (defun article-hide-pgp ()
2075 "Remove any PGP headers and signatures in the current article."
2079 (let ((inhibit-point-motion-hooks t)
2080 buffer-read-only beg end)
2082 ;; Hide the "header".
2083 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
2084 (push 'pgp gnus-article-wash-types)
2085 (delete-region (match-beginning 0) (match-end 0))
2086 ;; Remove armor headers (rfc2440 6.2)
2087 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
2090 ;; Hide the actual signature.
2091 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
2092 (setq end (1+ (match-beginning 0)))
2095 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
2097 ;; Perhaps we shouldn't hide to the end of the buffer
2098 ;; if there is no end to the signature?
2100 ;; Hide "- " PGP quotation markers.
2102 (narrow-to-region beg end)
2103 (goto-char (point-min))
2104 (while (re-search-forward "^- " nil t)
2106 (match-beginning 0) (match-end 0)))
2108 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
2110 (defun article-hide-pem (&optional arg)
2111 "Toggle hiding of any PEM headers and signatures in the current article.
2112 If given a negative prefix, always show; if given a positive prefix,
2114 (interactive (gnus-article-hidden-arg))
2115 (unless (gnus-article-check-hidden-text 'pem arg)
2117 (let (buffer-read-only end)
2118 (goto-char (point-min))
2119 ;; Hide the horrendously ugly "header".
2120 (when (and (search-forward
2121 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2123 (setq end (1+ (match-beginning 0))))
2124 (push 'pem gnus-article-wash-types)
2125 (gnus-article-hide-text-type
2127 (if (search-forward "\n\n" nil t)
2131 ;; Hide the trailer as well
2132 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2134 (gnus-article-hide-text-type
2135 (match-beginning 0) (match-end 0) 'pem)))))))
2137 (defun article-strip-banner ()
2138 "Strip the banner specified by the `banner' group parameter."
2142 (let ((inhibit-point-motion-hooks t)
2143 (banner (gnus-parameter-banner gnus-newsgroup-name))
2144 (gnus-signature-limit nil)
2145 buffer-read-only beg end)
2149 ((eq banner 'signature)
2150 (when (gnus-article-narrow-to-signature)
2153 (delete-region (point) (point-max))))
2155 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2156 (while (re-search-forward banner nil t)
2157 (delete-region (match-beginning 0) (match-end 0)))))
2159 (while (re-search-forward banner nil t)
2160 (delete-region (match-beginning 0) (match-end 0))))))))))
2162 (defun article-babel ()
2163 "Translate article using an online translation service."
2167 (set-buffer gnus-article-buffer)
2168 (when (article-goto-body)
2169 (let* ((buffer-read-only nil)
2172 (orig (buffer-substring start end))
2173 (trans (babel-as-string orig)))
2175 (narrow-to-region start end)
2176 (delete-region start end)
2179 (defun article-hide-signature (&optional arg)
2180 "Hide the signature in the current article.
2181 If given a negative prefix, always show; if given a positive prefix,
2183 (interactive (gnus-article-hidden-arg))
2189 (article-goto-body))
2190 (goto-char (point-min)))
2191 (unless (gnus-article-check-hidden-text 'signature arg)
2192 (let ((buffer-read-only nil)
2194 (while (setq button (text-property-any button (point-max)
2196 'gnus-signature-toggle))
2197 (setq button (text-property-not-all button (point-max)
2199 'gnus-signature-toggle))
2200 (when (and button (not (eobp)))
2201 (gnus-article-hide-text-type
2203 (next-single-property-change (1+ button) 'mime-view-entity
2207 (defun article-strip-headers-in-body ()
2208 "Strip offensive headers from bodies."
2212 (let ((case-fold-search t))
2213 (when (looking-at "x-no-archive:")
2214 (gnus-delete-line)))))
2216 (defun article-strip-leading-blank-lines ()
2217 "Remove all blank lines from the beginning of the article."
2220 (let ((inhibit-point-motion-hooks t)
2222 (when (article-goto-body)
2223 (while (and (not (eobp))
2224 (looking-at "[ \t]*$"))
2225 (gnus-delete-line))))))
2227 (defun article-narrow-to-head ()
2228 "Narrow the buffer to the head of the message.
2229 Point is left at the beginning of the narrowed-to region."
2231 (goto-char (point-min))
2232 (if (search-forward "\n\n" nil 1)
2235 (goto-char (point-min)))
2237 (defun article-goto-body ()
2238 "Place point at the start of the body."
2239 (goto-char (point-min))
2241 ;; This variable is only bound when dealing with separate
2243 (article-goto-body-goes-to-point-min-p
2245 ((search-forward "\n\n" nil t)
2248 (goto-char (point-max))
2251 (defun article-strip-multiple-blank-lines ()
2252 "Replace consecutive blank lines with one empty line."
2255 (let ((inhibit-point-motion-hooks t)
2257 ;; First make all blank lines empty.
2259 (while (re-search-forward "^[ \t]+$" nil t)
2260 (unless (gnus-annotation-in-region-p
2261 (match-beginning 0) (match-end 0))
2262 (replace-match "" nil t)))
2263 ;; Then replace multiple empty lines with a single empty line.
2265 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2266 (unless (gnus-annotation-in-region-p
2267 (match-beginning 0) (match-end 0))
2268 (delete-region (match-beginning 1) (match-end 1)))))))
2270 (defun article-strip-leading-space ()
2271 "Remove all white space from the beginning of the lines in the article."
2274 (let ((inhibit-point-motion-hooks t)
2277 (while (re-search-forward "^[ \t]+" nil t)
2278 (replace-match "" t t)))))
2280 (defun article-strip-trailing-space ()
2281 "Remove all white space from the end of the lines in the article."
2284 (let ((inhibit-point-motion-hooks t)
2287 (while (re-search-forward "[ \t]+$" nil t)
2288 (replace-match "" t t)))))
2290 (defun article-strip-blank-lines ()
2291 "Strip leading, trailing and multiple blank lines."
2293 (article-strip-leading-blank-lines)
2294 (article-remove-trailing-blank-lines)
2295 (article-strip-multiple-blank-lines))
2297 (defun article-strip-all-blank-lines ()
2298 "Strip all blank lines."
2301 (let ((inhibit-point-motion-hooks t)
2304 (while (re-search-forward "^[ \t]*\n" nil t)
2305 (replace-match "" t t)))))
2307 (defun gnus-article-narrow-to-signature ()
2308 "Narrow to the signature; return t if a signature is found, else nil."
2309 (let ((inhibit-point-motion-hooks t))
2310 (when (gnus-article-search-signature)
2312 ;; Check whether we have some limits to what we consider
2313 ;; to be a signature.
2314 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2315 (list gnus-signature-limit)))
2317 (while (setq limit (pop limits))
2318 (if (or (and (integerp limit)
2319 (< (- (point-max) (point)) limit))
2321 (< (count-lines (point) (point-max)) limit))
2322 (and (gnus-functionp limit)
2324 (and (stringp limit)
2325 (not (re-search-forward limit nil t))))
2326 () ; This limit did not succeed.
2330 (narrow-to-region (point) (point-max))
2333 (defun gnus-article-search-signature ()
2334 "Search the current buffer for the signature separator.
2335 Put point at the beginning of the signature separator."
2336 (let ((cur (point)))
2337 (goto-char (point-max))
2338 (if (if (stringp gnus-signature-separator)
2339 (re-search-backward gnus-signature-separator nil t)
2340 (let ((seps gnus-signature-separator))
2342 (not (re-search-backward (car seps) nil t)))
2349 (defun gnus-article-hidden-arg ()
2350 "Return the current prefix arg as a number, or 0 if no prefix."
2351 (list (if current-prefix-arg
2352 (prefix-numeric-value current-prefix-arg)
2355 (defun gnus-article-check-hidden-text (type arg)
2356 "Return nil if hiding is necessary.
2357 Arg can be nil or a number. Nil and positive means hide, negative
2358 means show, 0 means toggle."
2361 (let ((hide (gnus-article-hidden-text-p type)))
2367 (gnus-article-show-hidden-text type)
2370 (if (eq hide 'hidden)
2372 (gnus-article-show-hidden-text type)
2376 (defun gnus-article-hidden-text-p (type)
2377 "Say whether the current buffer contains hidden text of type TYPE."
2378 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2380 (not (get-text-property pos 'invisible))
2381 (not (get-text-property pos 'dummy-invisible)))
2383 (text-property-any (1+ pos) (point-max) 'article-type type)))
2388 (defun gnus-article-show-hidden-text (type &optional dummy)
2389 "Show all hidden text of type TYPE.
2390 Originally it is hide instead of DUMMY."
2391 (let ((buffer-read-only nil)
2392 (inhibit-point-motion-hooks t))
2393 (gnus-remove-text-properties-when
2395 (point-min) (point-max)
2396 (cons 'article-type (cons type
2397 gnus-hidden-properties)))))
2399 (defconst article-time-units
2400 `((year . ,(* 365.25 24 60 60))
2401 (week . ,(* 7 24 60 60))
2402 (day . ,(* 24 60 60))
2406 "Mapping from time units to seconds.")
2408 (defun article-date-ut (&optional type highlight header)
2409 "Convert DATE date to universal time in the current article.
2410 If TYPE is `local', convert to local time; if it is `lapsed', output
2411 how much time has lapsed since DATE. For `lapsed', the value of
2412 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2413 should replace the \"Date:\" one, or should be added below it."
2414 (interactive (list 'ut t))
2415 (let* ((header (or header
2416 (and (eq 1 (point-min))
2417 (mail-header-date (save-excursion
2418 (set-buffer gnus-summary-buffer)
2419 gnus-current-headers)))
2420 (message-fetch-field "date")
2422 (date (if (vectorp header) (mail-header-date header)
2424 (inhibit-point-motion-hooks t)
2425 bface eface date-pos)
2426 (when (and date (not (string= date "")))
2429 (article-narrow-to-head)
2430 (when (or (and (eq type 'lapsed)
2431 gnus-article-date-lapsed-new-header
2432 ;; Attempt to get the face of X-Sent first.
2433 (re-search-forward "^X-Sent:[ \t]" nil t))
2434 (re-search-forward "^Date:[ \t]" nil t)
2435 ;; If Date is missing, try again for X-Sent.
2436 (re-search-forward "^X-Sent:[ \t]" nil t))
2437 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2438 date (or (get-text-property (gnus-point-at-bol)
2441 eface (get-text-property (1- (gnus-point-at-eol))
2443 (let ((buffer-read-only nil))
2444 ;; Delete any old X-Sent headers.
2445 (when (setq date-pos
2446 (text-property-any (point-min) (point-max)
2447 'article-date-lapsed t))
2448 (goto-char (setq date-pos (set-marker (make-marker) date-pos)))
2449 (delete-region (match-beginning 0)
2450 (progn (forward-line 1) (point))))
2451 (goto-char (point-min))
2452 ;; Delete any old Date headers.
2453 (while (re-search-forward "^Date:[ \t]" nil t)
2455 (setq date-pos (match-beginning 0)))
2456 (unless (and (eq type 'lapsed)
2457 gnus-article-date-lapsed-new-header)
2458 (delete-region (match-beginning 0)
2459 (progn (message-next-header) (point)))))
2462 (goto-char date-pos)
2464 ;; Possibly, Date has been deleted.
2466 (when (and (eq type 'lapsed)
2467 gnus-article-date-lapsed-new-header
2468 (looking-at "Date:"))
2470 (goto-char (point-min)))
2471 (insert (article-make-date-line date type))
2472 (when (eq type 'lapsed)
2473 (put-text-property (gnus-point-at-bol) (point)
2474 'article-date-lapsed t))
2478 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2479 (put-text-property (match-beginning 1) (1+ (match-end 1))
2480 'original-date date)
2481 (put-text-property (match-beginning 1) (1+ (match-end 1))
2483 (put-text-property (match-beginning 2) (match-end 2)
2486 (defun article-make-date-line (date type)
2487 "Return a DATE line of TYPE."
2488 (unless (memq type '(local ut original user iso8601 lapsed english))
2489 (error "Unknown conversion type: %s" type))
2491 (let ((time (date-to-time date)))
2493 ;; Convert to the local timezone.
2495 (let ((tz (car (current-time-zone time))))
2496 (format "Date: %s %s%02d%02d" (current-time-string time)
2497 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2498 (/ (% (abs tz) 3600) 60))))
2499 ;; Convert to Universal Time.
2502 (current-time-string
2503 (let* ((e (parse-time-string date))
2504 (tm (apply 'encode-time e))
2506 (ls (- (cadr tm) (car (current-time-zone time)))))
2507 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2508 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2511 ;; Get the original date from the article.
2512 ((eq type 'original)
2513 (concat "Date: " (if (string-match "\n+$" date)
2514 (substring date 0 (match-beginning 0))
2516 ;; Let the user define the format.
2518 (if (gnus-functionp gnus-article-time-format)
2519 (funcall gnus-article-time-format time)
2522 (format-time-string gnus-article-time-format time))))
2525 (let ((tz (car (current-time-zone time))))
2528 (format-time-string "%Y%m%dT%H%M%S" time)
2529 (format "%s%02d%02d"
2530 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2531 (/ (% (abs tz) 3600) 60)))))
2532 ;; Do an X-Sent lapsed format.
2534 ;; If the date is seriously mangled, the timezone functions are
2535 ;; liable to bug out, so we ignore all errors.
2536 (let* ((now (current-time))
2537 (real-time (subtract-time now time))
2538 (real-sec (and real-time
2539 (+ (* (float (car real-time)) 65536)
2541 (sec (and real-time (abs real-sec)))
2551 ;; This is a bit convoluted, but basically we go
2552 ;; through the time units for years, weeks, etc,
2553 ;; and divide things to see whether that results
2554 ;; in positive answers.
2557 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2558 ;; The (remaining) seconds are too few to
2559 ;; be divided into this time unit.
2561 ;; It's big enough, so we output it.
2562 (setq sec (- sec (* num (cdr unit))))
2564 (concat (if prev ", " "") (int-to-string
2566 " " (symbol-name (car unit))
2567 (if (> num 1) "s" ""))
2569 article-time-units "")
2570 ;; If dates are odd, then it might appear like the
2571 ;; article was sent in the future.
2574 " in the future"))))))
2575 ;; Display the date in proper English
2577 (let ((dtime (decode-time time)))
2580 (number-to-string (nth 3 dtime))
2581 (let ((digit (% (nth 3 dtime) 10)))
2583 ((memq (nth 3 dtime) '(11 12 13)) "th")
2589 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2591 (number-to-string (nth 5 dtime))
2593 (format "%02d" (nth 2 dtime))
2595 (format "%02d" (nth 1 dtime)))))))
2597 (format "Date: %s (from Oort)" date))))
2599 (defun article-date-local (&optional highlight)
2600 "Convert the current article date to the local timezone."
2601 (interactive (list t))
2602 (article-date-ut 'local highlight))
2604 (defun article-date-english (&optional highlight)
2605 "Convert the current article date to something that is proper English."
2606 (interactive (list t))
2607 (article-date-ut 'english highlight))
2609 (defun article-date-original (&optional highlight)
2610 "Convert the current article date to what it was originally.
2611 This is only useful if you have used some other date conversion
2612 function and want to see what the date was before converting."
2613 (interactive (list t))
2614 (article-date-ut 'original highlight))
2616 (defun article-date-lapsed (&optional highlight)
2617 "Convert the current article date to time lapsed since it was sent."
2618 (interactive (list t))
2619 (article-date-ut 'lapsed highlight))
2621 (defun article-update-date-lapsed ()
2622 "Function to be run from a timer to update the lapsed time line."
2623 (let (deactivate-mark)
2628 (set-buffer (window-buffer w))
2629 (when (eq major-mode 'gnus-article-mode)
2630 (goto-char (point-min))
2631 (when (re-search-forward "^X-Sent:" nil t)
2632 (article-date-lapsed t))))
2635 (defun gnus-start-date-timer (&optional n)
2636 "Start a timer to update the X-Sent header in the article buffers.
2637 The numerical prefix says how frequently (in seconds) the function
2642 (gnus-stop-date-timer)
2643 (setq article-lapsed-timer
2644 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2646 (defun gnus-stop-date-timer ()
2647 "Stop the X-Sent timer."
2649 (when article-lapsed-timer
2650 (nnheader-cancel-timer article-lapsed-timer)
2651 (setq article-lapsed-timer nil)))
2653 (defun article-date-user (&optional highlight)
2654 "Convert the current article date to the user-defined format.
2655 This format is defined by the `gnus-article-time-format' variable."
2656 (interactive (list t))
2657 (article-date-ut 'user highlight))
2659 (defun article-date-iso8601 (&optional highlight)
2660 "Convert the current article date to ISO8601."
2661 (interactive (list t))
2662 (article-date-ut 'iso8601 highlight))
2664 (defun article-show-all ()
2665 "Show all hidden text in the article buffer."
2669 (let ((buffer-read-only nil))
2670 (gnus-article-unhide-text (point-min) (point-max))
2671 (gnus-remove-text-with-property 'gnus-prev)
2672 (gnus-remove-text-with-property 'gnus-next))))
2674 (defun article-show-all-headers ()
2675 "Show all hidden headers in the article buffer."
2680 (article-narrow-to-head)
2681 (let ((buffer-read-only nil))
2682 (gnus-article-unhide-text (point-min) (point-max))))))
2684 (defun article-remove-leading-whitespace ()
2685 "Remove excessive whitespace from all headers."
2689 (let ((buffer-read-only nil))
2690 (article-narrow-to-head)
2691 (goto-char (point-min))
2692 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2693 (delete-region (match-beginning 1) (match-end 1)))))))
2695 (defun article-emphasize (&optional arg)
2696 "Emphasize text according to `gnus-emphasis-alist'."
2697 (interactive (gnus-article-hidden-arg))
2698 (unless (gnus-article-check-hidden-text 'emphasis arg)
2702 (with-current-buffer gnus-summary-buffer
2703 gnus-article-emphasis-alist)
2705 gnus-emphasis-alist))
2706 (buffer-read-only nil)
2707 (props (append '(article-type emphasis)
2708 gnus-hidden-properties))
2709 regexp elem beg invisible visible face)
2712 (while (setq elem (pop alist))
2714 (setq regexp (car elem)
2715 invisible (nth 1 elem)
2716 visible (nth 2 elem)
2718 (while (re-search-forward regexp nil t)
2719 (when (and (match-beginning visible) (match-beginning invisible))
2720 (push 'emphasis gnus-article-wash-types)
2721 (gnus-article-hide-text
2722 (match-beginning invisible) (match-end invisible) props)
2723 (gnus-article-unhide-text-type
2724 (match-beginning visible) (match-end visible) 'emphasis)
2725 (gnus-put-text-property-excluding-newlines
2726 (match-beginning visible) (match-end visible) 'face face)
2727 (goto-char (match-end invisible)))))))))
2729 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2730 "Setup newsgroup emphasis alist."
2731 (unless gnus-article-emphasis-alist
2732 (let ((name (and gnus-newsgroup-name
2733 (gnus-group-real-name gnus-newsgroup-name))))
2734 (make-local-variable 'gnus-article-emphasis-alist)
2735 (setq gnus-article-emphasis-alist
2737 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2738 (while (setq elem (pop alist))
2739 (when (and name (string-match (car elem) name))
2741 highlight (copy-sequence (cdr elem)))))
2743 (copy-sequence highlight-words)
2744 (if gnus-newsgroup-name
2745 (copy-sequence (gnus-group-find-parameter
2746 gnus-newsgroup-name 'highlight-words t)))
2747 gnus-emphasis-alist)))))
2750 (defvar gnus-summary-article-menu)
2751 (defvar gnus-summary-post-menu))
2753 ;;; Saving functions.
2755 (defun gnus-article-save (save-buffer file &optional num)
2756 "Save the currently selected article."
2757 (unless gnus-save-all-headers
2758 ;; Remove headers according to `gnus-saved-headers'.
2759 (let ((gnus-visible-headers
2760 (or gnus-saved-headers gnus-visible-headers))
2761 (gnus-article-buffer save-buffer))
2763 (set-buffer save-buffer)
2764 (article-hide-headers 1 t))))
2765 (save-window-excursion
2766 (if (not gnus-default-article-saver)
2767 (error "No default saver is defined")
2768 ;; !!! Magic! The saving functions all save
2769 ;; `gnus-save-article-buffer' (or so they think), but we
2770 ;; bind that variable to our save-buffer.
2771 (set-buffer gnus-article-buffer)
2772 (let* ((gnus-save-article-buffer save-buffer)
2775 ((not gnus-prompt-before-saving) 'default)
2776 ((eq gnus-prompt-before-saving 'always) nil)
2778 (gnus-number-of-articles-to-be-saved
2779 (when (eq gnus-prompt-before-saving t)
2781 (set-buffer gnus-article-current-summary)
2782 (funcall gnus-default-article-saver filename)))))
2784 (defun gnus-read-save-file-name (prompt &optional filename
2785 function group headers variable)
2787 (funcall function group headers (symbol-value variable)))
2792 ((eq filename 'default)
2798 (let* ((split-name (gnus-get-split-value gnus-split-methods))
2801 (if (and gnus-number-of-articles-to-be-saved
2802 (> gnus-number-of-articles-to-be-saved 1))
2803 (format "these %d articles"
2804 gnus-number-of-articles-to-be-saved)
2807 ;; Let the split methods have their say.
2809 ;; No split name was found.
2812 (concat prompt " (default "
2813 (file-name-nondirectory default-name) ") ")
2814 (file-name-directory default-name)
2816 ;; A single group name is returned.
2817 ((stringp split-name)
2819 (funcall function split-name headers
2820 (symbol-value variable)))
2822 (concat prompt " (default "
2823 (file-name-nondirectory default-name) ") ")
2824 (file-name-directory default-name)
2826 ;; A single split name was found
2827 ((= 1 (length split-name))
2828 (let* ((name (expand-file-name
2830 gnus-article-save-directory))
2831 (dir (cond ((file-directory-p name)
2832 (file-name-as-directory name))
2833 ((file-exists-p name) name)
2834 (t gnus-article-save-directory))))
2836 (concat prompt " (default " name ") ")
2838 ;; A list of splits was found.
2840 (setq split-name (nreverse split-name))
2842 (let ((file-name-history
2843 (nconc split-name file-name-history)))
2847 (concat prompt " (`M-p' for defaults) ")
2848 gnus-article-save-directory
2850 gnus-article-save-directory)))
2851 (car (push result file-name-history)))))))
2852 ;; Create the directory.
2853 (gnus-make-directory (file-name-directory file))
2854 ;; If we have read a directory, we append the default file name.
2855 (when (file-directory-p file)
2856 (setq file (expand-file-name (file-name-nondirectory
2858 (file-name-as-directory file))))
2859 ;; Possibly translate some characters.
2860 (nnheader-translate-file-chars file))))))
2861 (gnus-make-directory (file-name-directory result))
2862 (set variable result)))
2864 (defun gnus-article-archive-name (group)
2865 "Return the first instance of an \"Archive-name\" in the current buffer."
2866 (let ((case-fold-search t))
2867 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
2868 (nnheader-concat gnus-article-save-directory
2869 (match-string 1)))))
2871 (defun gnus-article-nndoc-name (group)
2872 "If GROUP is an nndoc group, return the name of the parent group."
2873 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
2874 (gnus-group-get-parameter group 'save-article-group)))
2876 (defun gnus-summary-save-in-rmail (&optional filename)
2877 "Append this article to Rmail file.
2878 Optional argument FILENAME specifies file name.
2879 Directory to save to is default to `gnus-article-save-directory'."
2880 (setq filename (gnus-read-save-file-name
2881 "Save %s in rmail file:" filename
2882 gnus-rmail-save-name gnus-newsgroup-name
2883 gnus-current-headers 'gnus-newsgroup-last-rmail))
2884 (gnus-eval-in-buffer-window gnus-save-article-buffer
2888 (gnus-output-to-rmail filename))))
2891 (defun gnus-summary-save-in-mail (&optional filename)
2892 "Append this article to Unix mail file.
2893 Optional argument FILENAME specifies file name.
2894 Directory to save to is default to `gnus-article-save-directory'."
2895 (setq filename (gnus-read-save-file-name
2896 "Save %s in Unix mail file:" filename
2897 gnus-mail-save-name gnus-newsgroup-name
2898 gnus-current-headers 'gnus-newsgroup-last-mail))
2899 (gnus-eval-in-buffer-window gnus-save-article-buffer
2903 (if (and (file-readable-p filename)
2904 (mail-file-babyl-p filename))
2905 (rmail-output-to-rmail-file filename t)
2906 (gnus-output-to-mail filename)))))
2909 (defun gnus-summary-save-in-file (&optional filename overwrite)
2910 "Append this article to file.
2911 Optional argument FILENAME specifies file name.
2912 Directory to save to is default to `gnus-article-save-directory'."
2913 (setq filename (gnus-read-save-file-name
2914 "Save %s in file:" filename
2915 gnus-file-save-name gnus-newsgroup-name
2916 gnus-current-headers 'gnus-newsgroup-last-file))
2917 (gnus-eval-in-buffer-window gnus-save-article-buffer
2921 (when (and overwrite
2922 (file-exists-p filename))
2923 (delete-file filename))
2924 (gnus-output-to-file filename))))
2927 (defun gnus-summary-write-to-file (&optional filename)
2928 "Write this article to a file.
2929 Optional argument FILENAME specifies file name.
2930 The directory to save in defaults to `gnus-article-save-directory'."
2931 (gnus-summary-save-in-file nil t))
2933 (defun gnus-summary-save-body-in-file (&optional filename)
2934 "Append this article body to a file.
2935 Optional argument FILENAME specifies file name.
2936 The directory to save in defaults to `gnus-article-save-directory'."
2937 (setq filename (gnus-read-save-file-name
2938 "Save %s body in file:" filename
2939 gnus-file-save-name gnus-newsgroup-name
2940 gnus-current-headers 'gnus-newsgroup-last-file))
2941 (gnus-eval-in-buffer-window gnus-save-article-buffer
2945 (when (article-goto-body)
2946 (narrow-to-region (point) (point-max)))
2947 (gnus-output-to-file filename))))
2950 (defun gnus-summary-save-in-pipe (&optional command)
2951 "Pipe this article to subprocess."
2953 (cond ((and (eq command 'default)
2954 gnus-last-shell-command)
2955 gnus-last-shell-command)
2960 "Shell command on %s: "
2961 (if (and gnus-number-of-articles-to-be-saved
2962 (> gnus-number-of-articles-to-be-saved 1))
2963 (format "these %d articles"
2964 gnus-number-of-articles-to-be-saved)
2966 gnus-last-shell-command))))
2967 (when (string-equal command "")
2968 (if gnus-last-shell-command
2969 (setq command gnus-last-shell-command)
2970 (error "A command is required")))
2971 (gnus-eval-in-buffer-window gnus-article-buffer
2974 (shell-command-on-region (point-min) (point-max) command nil)))
2975 (setq gnus-last-shell-command command))
2977 ;;; Article file names when saving.
2979 (defun gnus-capitalize-newsgroup (newsgroup)
2980 "Capitalize NEWSGROUP name."
2981 (when (not (zerop (length newsgroup)))
2982 (concat (char-to-string (upcase (aref newsgroup 0)))
2983 (substring newsgroup 1))))
2985 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2986 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2987 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
2988 Otherwise, it is like ~/News/news/group/num."
2991 (concat (if (gnus-use-long-file-name 'not-save)
2992 (gnus-capitalize-newsgroup newsgroup)
2993 (gnus-newsgroup-directory-form newsgroup))
2994 "/" (int-to-string (mail-header-number headers)))
2995 gnus-article-save-directory)))
2997 (string-equal (file-name-directory default)
2998 (file-name-directory last-file))
2999 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3001 (or last-file default))))
3003 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3004 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3005 If variable `gnus-use-long-file-name' is non-nil, it is
3006 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3009 (concat (if (gnus-use-long-file-name 'not-save)
3011 (gnus-newsgroup-directory-form newsgroup))
3012 "/" (int-to-string (mail-header-number headers)))
3013 gnus-article-save-directory)))
3015 (string-equal (file-name-directory default)
3016 (file-name-directory last-file))
3017 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3019 (or last-file default))))
3021 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3022 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3023 If variable `gnus-use-long-file-name' is non-nil, it is
3024 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3027 (if (gnus-use-long-file-name 'not-save)
3030 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3032 gnus-article-save-directory)))
3034 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3035 "Generate file name from sender."
3036 (let ((from (mail-header-from headers)))
3038 (if (and from (string-match "\\([^ <]+\\)@" from))
3039 (match-string 1 from)
3041 gnus-article-save-directory)))
3043 (defun article-verify-x-pgp-sig ()
3046 (if (gnus-buffer-live-p gnus-original-article-buffer)
3047 (let ((sig (with-current-buffer gnus-original-article-buffer
3048 (gnus-fetch-field "X-PGP-Sig")))
3052 (mml2015-clear-verify-function))
3054 (insert-buffer gnus-original-article-buffer)
3055 (setq items (split-string sig))
3056 (message-narrow-to-head)
3057 (let ((inhibit-point-motion-hooks t)
3058 (case-fold-search t))
3059 ;; Don't verify multiple headers.
3060 (setq headers (mapconcat (lambda (header)
3062 (mail-fetch-field header) "\n"))
3063 (split-string (nth 1 items) ",") "")))
3064 (delete-region (point-min) (point-max))
3065 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3066 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3071 (if (looking-at "^-")
3074 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3075 (insert "Version: " (car items) "\n\n")
3076 (insert (mapconcat 'identity (cddr items) "\n"))
3077 (insert "\n-----END PGP SIGNATURE-----\n")
3078 (let ((mm-security-handle (list (format "multipart/signed"))))
3079 (mml2015-clean-buffer)
3080 (let ((coding-system-for-write (or gnus-newsgroup-charset
3082 (funcall (mml2015-clear-verify-function)))
3084 (or (mm-handle-multipart-ctl-parameter
3085 mm-security-handle 'gnus-details)
3086 (mm-handle-multipart-ctl-parameter
3087 mm-security-handle 'gnus-info)))))
3089 (let (buffer-read-only bface eface)
3091 (message-narrow-to-head)
3092 (goto-char (point-max))
3094 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3095 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3096 (message-remove-header "X-Gnus-PGP-Verify")
3097 (if (re-search-forward "^X-PGP-Sig:" nil t)
3099 (goto-char (point-max)))
3100 (narrow-to-region (point) (point))
3101 (insert "X-Gnus-PGP-Verify: " info "\n")
3102 (goto-char (point-min))
3105 (if (not (looking-at "^[ \t]"))
3109 (goto-char (point-min))
3110 (when (looking-at "\\([^:]+\\): *")
3111 (put-text-property (match-beginning 1) (1+ (match-end 1))
3113 (put-text-property (match-end 0) (point-max)
3114 'face eface)))))))))
3121 (setq afunc (car func)
3124 gfunc (intern (format "gnus-%s" func))))
3127 `(lambda (&optional interactive &rest args)
3128 ,(documentation afunc t)
3129 (interactive (list t))
3131 (set-buffer gnus-article-buffer)
3133 (call-interactively ',afunc)
3134 (apply ',afunc args))))))))
3135 '(article-hide-headers
3136 article-verify-x-pgp-sig
3137 article-hide-boring-headers
3138 article-toggle-headers
3139 article-treat-overstrike
3140 article-fill-long-lines
3141 article-capitalize-sentences
3143 article-remove-leading-whitespace
3144 article-display-x-face
3145 article-de-quoted-unreadable
3146 article-de-base64-unreadable
3149 article-hide-list-identifiers
3151 article-strip-banner
3154 article-hide-signature
3155 article-strip-headers-in-body
3156 article-remove-trailing-blank-lines
3157 article-strip-leading-blank-lines
3158 article-strip-multiple-blank-lines
3159 article-strip-leading-space
3160 article-strip-trailing-space
3161 article-strip-blank-lines
3162 article-strip-all-blank-lines
3164 article-date-english
3165 article-date-iso8601
3166 article-date-original
3168 article-decode-mime-words
3169 article-decode-charset
3170 article-decode-encoded-words
3174 article-treat-dumbquotes
3175 article-normalize-headers
3176 (article-show-all-headers . gnus-article-show-all-headers)
3177 (article-show-all . gnus-article-show-all))))
3180 ;;; Gnus article mode
3183 (put 'gnus-article-mode 'mode-class 'special)
3185 (gnus-define-keys gnus-article-mode-map
3186 " " gnus-article-goto-next-page
3187 "\177" gnus-article-goto-prev-page
3188 [delete] gnus-article-goto-prev-page
3189 [backspace] gnus-article-goto-prev-page
3190 "\C-c^" gnus-article-refer-article
3191 "h" gnus-article-show-summary
3192 "s" gnus-article-show-summary
3193 "\C-c\C-m" gnus-article-mail
3194 "?" gnus-article-describe-briefly
3195 "e" gnus-summary-edit-article
3196 "<" beginning-of-buffer
3198 "\C-c\C-i" gnus-info-find-node
3200 "\C-hk" gnus-article-describe-key
3201 "\C-hc" gnus-article-describe-key-briefly
3203 "\C-d" gnus-article-read-summary-keys
3204 "\M-*" gnus-article-read-summary-keys
3205 "\M-#" gnus-article-read-summary-keys
3206 "\M-^" gnus-article-read-summary-keys
3207 "\M-g" gnus-article-read-summary-keys)
3209 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3213 (push (char-to-string key) keys)
3215 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3216 (setq key (car elem))
3217 (when (and (> (length key) 0)
3218 (not (eq 'menu-bar (aref key 0)))
3219 (symbolp (lookup-key gnus-summary-mode-map key)))
3222 (unless (lookup-key gnus-article-mode-map key)
3223 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3225 (defun gnus-article-make-menu-bar ()
3226 (unless (boundp 'gnus-article-commands-menu)
3227 (gnus-summary-make-menu-bar))
3228 (gnus-turn-off-edit-menu 'article)
3229 (unless (boundp 'gnus-article-article-menu)
3231 gnus-article-article-menu gnus-article-mode-map ""
3233 ["Scroll forwards" gnus-article-goto-next-page t]
3234 ["Scroll backwards" gnus-article-goto-prev-page t]
3235 ["Show summary" gnus-article-show-summary t]
3236 ["Fetch Message-ID at point" gnus-article-refer-article t]
3237 ["Mail to address at point" gnus-article-mail t]
3238 ["Send a bug report" gnus-bug t]))
3241 gnus-article-treatment-menu gnus-article-mode-map ""
3242 ;; Fixme: this should use :active (and maybe :visible).
3244 ["Hide headers" gnus-article-toggle-headers t]
3245 ["Hide signature" gnus-article-hide-signature t]
3246 ["Hide citation" gnus-article-hide-citation t]
3247 ["Treat overstrike" gnus-article-treat-overstrike t]
3248 ["Remove carriage return" gnus-article-remove-cr t]
3249 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3250 ["Decode HZ" gnus-article-decode-HZ t]))
3252 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3254 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3256 (gnus-run-hooks 'gnus-article-menu-hook)))
3258 ;; Fixme: do something for the Emacs tool bar in Article mode a la
3261 (defun gnus-article-mode ()
3262 "Major mode for displaying an article.
3264 All normal editing commands are switched off.
3266 The following commands are available in addition to all summary mode
3268 \\<gnus-article-mode-map>
3269 \\[gnus-article-next-page]\t Scroll the article one page forwards
3270 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3271 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3272 \\[gnus-article-show-summary]\t Display the summary buffer
3273 \\[gnus-article-mail]\t Send a reply to the address near point
3274 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3275 \\[gnus-info-find-node]\t Go to the Gnus info node"
3277 (gnus-simplify-mode-line)
3278 (setq mode-name "Article")
3279 (setq major-mode 'gnus-article-mode)
3280 (make-local-variable 'minor-mode-alist)
3281 (unless (assq 'gnus-show-mime minor-mode-alist)
3282 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3283 (use-local-map gnus-article-mode-map)
3284 (when (gnus-visual-p 'article-menu 'menu)
3285 (gnus-article-make-menu-bar))
3286 (gnus-update-format-specifications nil 'article-mode)
3287 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3288 (make-local-variable 'gnus-page-broken)
3289 (make-local-variable 'gnus-button-marker-list)
3290 (make-local-variable 'gnus-article-current-summary)
3291 (make-local-variable 'gnus-article-mime-handles)
3292 (make-local-variable 'gnus-article-decoded-p)
3293 (make-local-variable 'gnus-article-mime-handle-alist)
3294 (make-local-variable 'gnus-article-wash-types)
3295 (make-local-variable 'gnus-article-charset)
3296 (make-local-variable 'gnus-article-ignored-charsets)
3297 (gnus-set-default-directory)
3298 (buffer-disable-undo)
3299 (setq buffer-read-only t)
3300 (set-syntax-table gnus-article-mode-syntax-table)
3301 (gnus-run-hooks 'gnus-article-mode-hook))
3303 (defun gnus-article-setup-buffer ()
3304 "Initialize the article buffer."
3305 (let* ((name (if gnus-single-article-buffer "*Article*"
3306 (concat "*Article " gnus-newsgroup-name "*")))
3308 (progn (string-match "\\*Article" name)
3309 (concat " *Original Article"
3310 (substring name (match-end 0))))))
3311 (setq gnus-article-buffer name)
3312 (setq gnus-original-article-buffer original)
3313 (setq gnus-article-mime-handle-alist nil)
3314 ;; This might be a variable local to the summary buffer.
3315 (unless gnus-single-article-buffer
3317 (set-buffer gnus-summary-buffer)
3318 (setq gnus-article-buffer name)
3319 (setq gnus-original-article-buffer original)
3320 (gnus-set-global-variables)))
3321 (gnus-article-setup-highlight-words)
3322 ;; Init original article buffer.
3324 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3325 (set-buffer-multibyte nil)
3326 (setq major-mode 'gnus-original-article-mode)
3327 (make-local-variable 'gnus-original-article))
3328 (if (get-buffer name)
3331 (buffer-disable-undo)
3332 (setq buffer-read-only t)
3333 (unless (eq major-mode 'gnus-article-mode)
3334 (gnus-article-mode))
3337 (set-buffer (gnus-get-buffer-create name))
3339 (make-local-variable 'gnus-summary-buffer)
3340 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3341 (current-buffer)))))
3343 ;; Set article window start at LINE, where LINE is the number of lines
3344 ;; from the head of the article.
3345 (defun gnus-article-set-window-start (&optional line)
3347 (get-buffer-window gnus-article-buffer t)
3349 (set-buffer gnus-article-buffer)
3350 (goto-char (point-min))
3353 (gnus-message 6 "Moved to bookmark")
3354 (search-forward "\n\n" nil t)
3358 ;;; @@ article filters
3361 (defun gnus-article-display-mime-message ()
3362 "Article display method for MIME message."
3363 ;; called from `gnus-original-article-buffer'.
3364 (let (charset all-headers)
3365 (with-current-buffer gnus-summary-buffer
3366 (setq charset default-mime-charset
3367 all-headers gnus-have-all-headers))
3368 (make-local-variable 'default-mime-charset)
3369 (setq default-mime-charset charset)
3370 (with-current-buffer (get-buffer-create gnus-article-buffer)
3371 (make-local-variable 'default-mime-charset)
3372 (setq default-mime-charset charset))
3373 (mime-display-message mime-message-structure
3374 gnus-article-buffer nil gnus-article-mode-map)
3376 (gnus-article-hide-headers nil -1)))
3377 (run-hooks 'gnus-mime-article-prepare-hook))
3379 (defun gnus-article-display-traditional-message ()
3380 "Article display method for traditional message."
3381 (set-buffer gnus-article-buffer)
3382 (let (buffer-read-only)
3384 (insert-buffer-substring gnus-original-article-buffer)))
3386 (defun gnus-article-make-full-mail-header (&optional number charset)
3387 "Create a new mail header structure in a raw article buffer."
3388 (unless (and number charset)
3389 (save-current-buffer
3390 (set-buffer gnus-summary-buffer)
3392 (setq number (or (cdr gnus-article-current) 0)))
3394 (setq charset (or default-mime-charset 'x-ctext)))))
3395 (goto-char (point-min))
3396 (let ((header-end (if (search-forward "\n\n" nil t)
3398 (goto-char (point-max))))
3399 (chars (- (point-max) (point)))
3400 (lines (count-lines (point) (point-max)))
3401 (default-mime-charset charset)
3403 (narrow-to-region (point-min) header-end)
3404 (setq xref (std11-fetch-field "xref"))
3406 (make-full-mail-header
3408 (std11-fetch-field "subject")
3409 (std11-fetch-field "from")
3410 (std11-fetch-field "date")
3411 (std11-fetch-field "message-id")
3412 (std11-fetch-field "references")
3415 (when xref (concat "Xref: " xref)))
3418 (defun gnus-article-prepare (article &optional all-headers header)
3419 "Prepare ARTICLE in article mode buffer.
3420 ARTICLE should either be an article number or a Message-ID.
3421 If ARTICLE is an id, HEADER should be the article headers.
3422 If ALL-HEADERS is non-nil, no headers are hidden."
3424 ;; Make sure we start in a summary buffer.
3425 (unless (eq major-mode 'gnus-summary-mode)
3426 (set-buffer gnus-summary-buffer))
3427 (setq gnus-summary-buffer (current-buffer))
3428 (let* ((gnus-article (if header (mail-header-number header) article))
3429 (summary-buffer (current-buffer))
3430 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3431 (group gnus-newsgroup-name)
3434 (gnus-article-setup-buffer)
3435 (set-buffer gnus-article-buffer)
3436 ;; Deactivate active regions.
3437 (when (and (boundp 'transient-mark-mode)
3438 transient-mark-mode)
3439 (setq mark-active nil))
3440 (if (not (setq result (let ((buffer-read-only nil))
3441 (gnus-request-article-this-buffer
3443 ;; There is no such article.
3445 (when (and (numberp article)
3446 (not (memq article gnus-newsgroup-sparse)))
3447 (setq gnus-article-current
3448 (cons gnus-newsgroup-name article))
3449 (set-buffer gnus-summary-buffer)
3450 (setq gnus-current-article article)
3451 (if (eq (gnus-article-mark article) gnus-undownloaded-mark)
3453 (gnus-summary-set-agent-mark article)
3454 (message "Message marked for downloading"))
3455 (gnus-summary-mark-article article gnus-canceled-mark)
3456 (unless (memq article gnus-newsgroup-sparse)
3457 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3458 (if (or (eq result 'pseudo)
3459 (eq result 'nneething))
3462 (set-buffer summary-buffer)
3463 (push article gnus-newsgroup-history)
3464 (setq gnus-last-article gnus-current-article
3465 gnus-current-article 0
3466 gnus-current-headers nil
3467 gnus-article-current nil)
3468 (if (eq result 'nneething)
3469 (gnus-configure-windows 'summary)
3470 (gnus-configure-windows 'article))
3471 (gnus-set-global-variables))
3472 (let ((gnus-article-mime-handle-alist-1
3473 gnus-article-mime-handle-alist))
3474 (gnus-set-mode-line 'article)))
3475 ;; The result from the `request' was an actual article -
3476 ;; or at least some text that is now displayed in the
3478 (when (and (numberp article)
3479 (not (eq article gnus-current-article)))
3480 ;; Seems like a new article has been selected.
3481 ;; `gnus-current-article' must be an article number.
3483 (set-buffer summary-buffer)
3484 (push article gnus-newsgroup-history)
3485 (setq gnus-last-article gnus-current-article
3486 gnus-current-article article
3487 gnus-current-headers
3488 (gnus-summary-article-header gnus-current-article)
3489 gnus-article-current
3490 (cons gnus-newsgroup-name gnus-current-article))
3491 (unless (vectorp gnus-current-headers)
3492 (setq gnus-current-headers nil))
3493 (gnus-summary-goto-subject gnus-current-article)
3494 (when (gnus-summary-show-thread)
3495 ;; If the summary buffer really was folded, the
3496 ;; previous goto may not actually have gone to
3497 ;; the right article, but the thread root instead.
3499 (gnus-summary-goto-subject gnus-current-article))
3500 (gnus-run-hooks 'gnus-mark-article-hook)
3501 (gnus-set-mode-line 'summary)
3502 (when (gnus-visual-p 'article-highlight 'highlight)
3503 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3504 ;; Set the global newsgroup variables here.
3505 (gnus-set-global-variables)
3506 (setq gnus-have-all-headers
3507 (or all-headers gnus-show-all-headers))))
3509 (gnus-configure-windows 'article))
3510 (when (or (numberp article)
3512 (gnus-article-prepare-display)
3514 (goto-char (point-min))
3515 (setq gnus-page-broken
3516 (when gnus-break-pages
3517 (gnus-narrow-to-page)
3519 (let ((gnus-article-mime-handle-alist-1
3520 gnus-article-mime-handle-alist))
3521 (gnus-set-mode-line 'article))
3523 (set-window-point (get-buffer-window (current-buffer)) (point))
3524 (gnus-configure-windows 'article)
3527 (defun gnus-article-prepare-mime-display (&optional number)
3528 (goto-char (point-min))
3529 (when (re-search-forward "^[^\t ]+:" nil t)
3530 (goto-char (match-beginning 0)))
3531 (let ((entity (if (eq 1 (point-min))
3532 (get-text-property 1 'mime-view-entity)
3533 (get-text-property (point) 'mime-view-entity)))
3534 last-entity child-entity next type)
3535 (setq child-entity (mime-entity-children entity))
3537 (setq last-entity (nth (1- (length child-entity))
3539 (setq last-entity entity))
3541 (narrow-to-region (point)
3542 (if (search-forward "\n\n" nil t)
3545 (gnus-treat-article 'head)
3546 (put-text-property (point-min) (point-max) 'article-treated-header t)
3547 (goto-char (point-max)))
3548 (while (and (not (eobp)) entity)
3549 (setq next (set-marker
3551 (next-single-property-change (point) 'mime-view-entity
3553 (let ((types (mime-entity-content-type entity)))
3554 (while (eq 'multipart (mime-content-type-primary-type types))
3555 (setq entity (car (mime-entity-children entity))
3556 types (mime-entity-content-type entity)))
3558 (setq type (format "%s/%s"
3559 (mime-content-type-primary-type types)
3560 (mime-content-type-subtype types)))))
3561 (if (string-equal type "message/rfc822")
3564 (let ((children (mime-entity-children entity))
3567 (setq last-children (nth (1- (length children)) children))
3570 (not (eq last-children
3571 (get-text-property next 'mime-view-entity)))
3573 (next-single-property-change next
3575 nil (point-max)))))))
3576 (setq next (next-single-property-change next 'mime-view-entity
3579 (narrow-to-region (point) next)
3580 (gnus-article-prepare-mime-display)
3581 (goto-char (point-max)))
3582 (setq entity (get-text-property (point) 'mime-view-entity)))
3584 (narrow-to-region (point) next)
3585 ;; Kludge. We have to count true number, but for now,
3586 ;; part number is here only to achieve `last'.
3587 (gnus-treat-article nil 1
3588 (if (eq entity last-entity)
3591 (goto-char (point-max)))
3592 (setq entity (get-text-property next 'mime-view-entity))))))
3595 (defun gnus-article-prepare-display ()
3596 "Make the current buffer look like a nice article."
3597 (let ((gnus-article-buffer (current-buffer))
3599 (unless (eq major-mode 'gnus-article-mode)
3600 (gnus-article-mode))
3601 (setq buffer-read-only nil
3602 gnus-button-marker-list nil
3603 gnus-article-wash-types nil)
3606 (static-if (featurep 'xemacs)
3607 (map-extents (lambda (extent maparg) (delete-extent extent)))
3608 (let ((lists (overlay-lists)))
3609 (dolist (overlay (nconc (car lists) (cdr lists)))
3610 (delete-overlay overlay)))))
3611 (gnus-run-hooks 'gnus-tmp-internal-hook))
3612 (set-buffer gnus-original-article-buffer)
3614 (setq mime-message-structure gnus-current-headers)
3615 (mime-buffer-entity-set-buffer-internal mime-message-structure
3616 gnus-original-article-buffer)
3617 (mime-entity-set-representation-type-internal mime-message-structure
3618 'mime-buffer-entity)
3619 (luna-send mime-message-structure 'initialize-instance
3620 mime-message-structure)
3622 (let (mime-display-header-hook mime-display-text/plain-hook)
3623 (funcall gnus-article-display-method-for-mime))
3624 (funcall gnus-article-display-method-for-traditional))
3625 ;; Call the treatment functions.
3626 (let ((inhibit-read-only t))
3630 (gnus-article-prepare-mime-display)
3631 (narrow-to-region (goto-char (point-min))
3632 (if (search-forward "\n\n" nil t)
3635 (gnus-treat-article 'head)
3636 (put-text-property (point-min) (point-max) 'article-treated-header t)
3637 (goto-char (point-max))
3639 (narrow-to-region (point) (point-max))
3640 (gnus-treat-article nil))
3641 (put-text-property (point-min) (point-max) 'read-only nil)))
3642 (gnus-run-hooks 'gnus-article-prepare-hook))
3644 (defun gnus-article-decode-article-as-default-mime-charset ()
3645 "Decode an article as `default-mime-charset'. It won't work if the
3646 value of the variable `gnus-show-mime' is non-nil."
3647 (unless gnus-show-mime
3648 (set (make-local-variable 'default-mime-charset)
3649 (with-current-buffer gnus-summary-buffer
3650 default-mime-charset))
3651 (decode-mime-charset-region (point-min) (point-max)
3652 default-mime-charset)))
3655 ;;; Gnus MIME viewing functions
3658 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3659 "The following specs can be used:
3661 %T MIME type, along with additional info
3662 %n The `name' parameter
3663 %d The description, if any
3664 %l The length of the encoded part
3665 %p The part identifier number
3666 %e Dots if the part isn't displayed")
3668 (defvar gnus-mime-button-line-format-alist
3669 '((?t gnus-tmp-type ?s)
3670 (?T gnus-tmp-type-long ?s)
3671 (?n gnus-tmp-name ?s)
3672 (?d gnus-tmp-description ?s)
3674 (?l gnus-tmp-length ?d)
3675 (?e gnus-tmp-dots ?s)))
3677 (defvar gnus-mime-button-commands
3678 '((gnus-article-press-button "\r" "Toggle Display")
3679 (gnus-mime-view-part "v" "View Interactively...")
3680 (gnus-mime-view-part-as-type "t" "View As Type...")
3681 (gnus-mime-view-part-as-charset "C" "View As charset...")
3682 (gnus-mime-save-part "o" "Save...")
3683 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3684 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3685 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3686 (gnus-mime-internalize-part "E" "View Internally")
3687 (gnus-mime-externalize-part "e" "View Externally")
3688 (gnus-mime-pipe-part "|" "Pipe To Command...")
3689 (gnus-mime-action-on-part "." "Take action on the part")))
3691 (defun gnus-article-mime-part-status ()
3692 (with-current-buffer gnus-article-buffer
3693 (let ((entity (get-text-property (point-min) 'mime-view-entity))
3696 (setq children (mime-entity-children entity))
3697 (setq children (length children)))
3700 (format " (%d parts)" children))
3703 (defvar gnus-mime-button-map
3704 (let ((map (make-sparse-keymap)))
3705 (unless (>= (string-to-number emacs-version) 21)
3706 ;; XEmacs doesn't care.
3707 (set-keymap-parent map gnus-article-mode-map))
3708 (define-key map gnus-mouse-2 'gnus-article-push-button)
3709 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3710 (dolist (c gnus-mime-button-commands)
3711 (define-key map (cadr c) (car c)))
3714 (defun gnus-mime-button-menu (event)
3715 "Construct a context-sensitive menu of MIME commands."
3717 (save-window-excursion
3718 (let ((pos (event-start event)))
3719 (select-window (posn-window pos))
3720 (goto-char (posn-point pos))
3721 (gnus-article-check-buffer)
3722 (let ((response (x-popup-menu
3724 ("" ,@(mapcar (lambda (c)
3725 (cons (caddr c) (car c)))
3726 gnus-mime-button-commands))))))
3728 (call-interactively response))))))
3730 (defun gnus-mime-view-all-parts (&optional handles)
3731 "View all the MIME parts."
3733 (save-current-buffer
3734 (set-buffer gnus-article-buffer)
3735 (let ((handles (or handles gnus-article-mime-handles))
3736 (mail-parse-charset gnus-newsgroup-charset)
3737 (mail-parse-ignored-charsets
3738 (with-current-buffer gnus-summary-buffer
3739 gnus-newsgroup-ignored-charsets)))
3741 (mm-remove-parts handles)
3742 (goto-char (point-min))
3743 (or (search-forward "\n\n") (goto-char (point-max)))
3744 (let (buffer-read-only)
3745 (delete-region (point) (point-max))
3746 (mm-display-parts handles))))))
3748 (defun gnus-mime-save-part-and-strip ()
3749 "Save the MIME part under point then replace it with an external body."
3751 (gnus-article-check-buffer)
3752 (let* ((data (get-text-property (point) 'gnus-data))
3754 (handles gnus-article-mime-handles))
3755 (if (mm-multiple-handles gnus-article-mime-handles)
3756 (error "This function is not implemented"))
3757 (setq file (and data (mm-save-part data)))
3759 (with-current-buffer (mm-handle-buffer data)
3761 (insert "Content-Type: " (mm-handle-media-type data))
3762 (mml-insert-parameter-string (cdr (mm-handle-type data))
3765 (insert "Content-ID: " (message-make-message-id) "\n")
3766 (insert "Content-Transfer-Encoding: binary\n")
3769 (cdr (mm-make-handle nil
3770 `("message/external-body"
3771 (access-type . "LOCAL-FILE")
3773 (set-buffer gnus-summary-buffer)
3774 (gnus-article-edit-article
3777 (let ((mail-parse-charset (or gnus-article-charset
3778 ',gnus-newsgroup-charset))
3779 (mail-parse-ignored-charsets
3780 (or gnus-article-ignored-charsets
3781 ',gnus-newsgroup-ignored-charsets))
3782 (mbl mml-buffer-list))
3783 (setq mml-buffer-list nil)
3784 (insert-buffer gnus-original-article-buffer)
3785 (mime-to-mml ',handles)
3786 (setq gnus-article-mime-handles nil)
3787 (let ((mbl1 mml-buffer-list))
3788 (setq mml-buffer-list mbl)
3789 (set (make-local-variable 'mml-buffer-list) mbl1))
3790 ;; LOCAL argument of add-hook differs between GNU Emacs
3791 ;; and XEmacs. make-local-hook makes sure they are local.
3792 (make-local-hook 'kill-buffer-hook)
3793 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3794 `(lambda (no-highlight)
3795 (let ((mail-parse-charset (or gnus-article-charset
3796 ',gnus-newsgroup-charset))
3797 (message-options message-options)
3798 (message-options-set-recipient)
3799 (mail-parse-ignored-charsets
3800 (or gnus-article-ignored-charsets
3801 ',gnus-newsgroup-ignored-charsets)))
3803 (mml-destroy-buffers)
3804 (remove-hook 'kill-buffer-hook
3805 'mml-destroy-buffers t)
3806 (kill-local-variable 'mml-buffer-list))
3807 (gnus-summary-edit-article-done
3808 ,(or (mail-header-references gnus-current-headers) "")
3809 ,(gnus-group-read-only-p)
3810 ,gnus-summary-buffer no-highlight))))))
3812 (defun gnus-mime-save-part ()
3813 "Save the MIME part under point."
3815 (gnus-article-check-buffer)
3816 (let ((data (get-text-property (point) 'gnus-data)))
3818 (mm-save-part data))))
3820 (defun gnus-mime-pipe-part ()
3821 "Pipe the MIME part under point to a process."
3823 (gnus-article-check-buffer)
3824 (let ((data (get-text-property (point) 'gnus-data)))
3826 (mm-pipe-part data))))
3828 (defun gnus-mime-view-part ()
3829 "Interactively choose a viewing method for the MIME part under point."
3831 (gnus-article-check-buffer)
3832 (let ((data (get-text-property (point) 'gnus-data)))
3834 (setq gnus-article-mime-handles
3836 gnus-article-mime-handles (setq data (copy-sequence data))))
3837 (mm-interactively-view-part data))))
3839 (defun gnus-mime-view-part-as-type-internal ()
3840 (gnus-article-check-buffer)
3841 (let* ((name (mail-content-type-get
3842 (mm-handle-type (get-text-property (point) 'gnus-data))
3844 (def-type (and name (mm-default-file-encoding name))))
3845 (and def-type (cons def-type 0))))
3847 (defun gnus-mime-view-part-as-type (&optional mime-type)
3848 "Choose a MIME media type, and view the part as such."
3851 (setq mime-type (completing-read
3852 "View as MIME type: "
3853 (mapcar #'list (mailcap-mime-types))
3855 (gnus-mime-view-part-as-type-internal))))
3856 (gnus-article-check-buffer)
3857 (let ((handle (get-text-property (point) 'gnus-data)))
3860 (mm-make-handle (mm-handle-buffer handle)
3861 (cons mime-type (cdr (mm-handle-type handle)))
3862 (mm-handle-encoding handle)
3863 (mm-handle-undisplayer handle)
3864 (mm-handle-disposition handle)
3865 (mm-handle-description handle)
3867 (mm-handle-id handle)))
3868 (setq gnus-article-mime-handles
3869 (mm-merge-handles gnus-article-mime-handles handle))
3870 (gnus-mm-display-part handle))))
3872 (defun gnus-mime-copy-part (&optional handle)
3873 "Put the the MIME part under point into a new buffer."
3875 (gnus-article-check-buffer)
3876 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3877 (contents (and handle (mm-get-part handle)))
3879 (file-name-nondirectory
3881 (mail-content-type-get (mm-handle-type handle) 'name)
3882 (mail-content-type-get (mm-handle-type handle)
3885 (buffer (and base (generate-new-buffer base))))
3887 (switch-to-buffer buffer)
3889 ;; We do it this way to make `normal-mode' set the appropriate mode.
3892 (setq buffer-file-name (expand-file-name base))
3894 (setq buffer-file-name nil))
3895 (goto-char (point-min)))))
3897 (defun gnus-mime-inline-part (&optional handle arg)
3898 "Insert the MIME part under point into the current buffer."
3899 (interactive (list nil current-prefix-arg))
3900 (gnus-article-check-buffer)
3901 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3906 (if (and (not arg) (mm-handle-undisplayer handle))
3907 (mm-remove-part handle)
3908 (setq contents (mm-get-part handle))
3911 (setq charset (or (mail-content-type-get
3912 (mm-handle-type handle) 'charset)
3913 gnus-newsgroup-charset)))
3915 (if (mm-handle-undisplayer handle)
3916 (mm-remove-part handle))
3919 gnus-summary-show-article-charset-alist))
3920 (mm-read-coding-system "Charset: ")))))
3922 (mm-insert-inline handle
3924 (setq charset (mm-charset-to-coding-system
3926 (not (eq charset 'ascii)))
3927 (mm-decode-coding-string contents charset)
3931 (defun gnus-mime-view-part-as-charset (&optional handle arg)
3932 "Insert the MIME part under point into the current buffer using the
3934 (interactive (list nil current-prefix-arg))
3935 (gnus-article-check-buffer)
3936 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3941 (if (mm-handle-undisplayer handle)
3942 (mm-remove-part handle))
3943 (let ((gnus-newsgroup-charset
3945 gnus-summary-show-article-charset-alist))
3946 (mm-read-coding-system "Charset: ")))
3947 (gnus-newsgroup-ignored-charsets 'gnus-all))
3948 (gnus-article-press-button)))))
3950 (defun gnus-mime-externalize-part (&optional handle)
3951 "View the MIME part under point with an external viewer."
3953 (gnus-article-check-buffer)
3954 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3955 (mm-user-display-methods nil)
3956 (mm-inlined-types nil)
3957 (mail-parse-charset gnus-newsgroup-charset)
3958 (mail-parse-ignored-charsets
3959 (save-excursion (set-buffer gnus-summary-buffer)
3960 gnus-newsgroup-ignored-charsets)))
3962 (if (mm-handle-undisplayer handle)
3963 (mm-remove-part handle)
3964 (mm-display-part handle)))))
3966 (defun gnus-mime-internalize-part (&optional handle)
3967 "View the MIME part under point with an internal viewer.
3968 If no internal viewer is available, use an external viewer."
3970 (gnus-article-check-buffer)
3971 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3972 (mm-inlined-types '(".*"))
3973 (mm-inline-large-images t)
3974 (mail-parse-charset gnus-newsgroup-charset)
3975 (mail-parse-ignored-charsets
3976 (save-excursion (set-buffer gnus-summary-buffer)
3977 gnus-newsgroup-ignored-charsets)))
3979 (if (mm-handle-undisplayer handle)
3980 (mm-remove-part handle)
3981 (mm-display-part handle)))))
3983 (defun gnus-mime-action-on-part (&optional action)
3984 "Do something with the MIME attachment at \(point\)."
3986 (list (completing-read "Action: " gnus-mime-action-alist)))
3987 (gnus-article-check-buffer)
3988 (let ((action-pair (assoc action gnus-mime-action-alist)))
3990 (funcall (cdr action-pair)))))
3992 (defun gnus-article-part-wrapper (n function)
3993 (save-current-buffer
3994 (set-buffer gnus-article-buffer)
3995 (when (> n (length gnus-article-mime-handle-alist))
3996 (error "No such part"))
3997 (gnus-article-goto-part n)
3998 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
3999 (funcall function handle))))
4001 (defun gnus-article-pipe-part (n)
4002 "Pipe MIME part N, which is the numerical prefix."
4004 (gnus-article-part-wrapper n 'mm-pipe-part))
4006 (defun gnus-article-save-part (n)
4007 "Save MIME part N, which is the numerical prefix."
4009 (gnus-article-part-wrapper n 'mm-save-part))
4011 (defun gnus-article-interactively-view-part (n)
4012 "View MIME part N interactively, which is the numerical prefix."
4014 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4016 (defun gnus-article-copy-part (n)
4017 "Copy MIME part N, which is the numerical prefix."
4019 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4021 (defun gnus-article-view-part-as-charset (n)
4022 "Copy MIME part N, which is the numerical prefix."
4024 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4026 (defun gnus-article-externalize-part (n)
4027 "View MIME part N externally, which is the numerical prefix."
4029 (gnus-article-part-wrapper n 'gnus-mime-externalize-part))
4031 (defun gnus-article-inline-part (n)
4032 "Inline MIME part N, which is the numerical prefix."
4034 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4036 (defun gnus-article-mime-match-handle-first (condition)
4038 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4039 (while (setq ihandle (pop alist))
4041 ((functionp condition)
4042 (funcall condition (cdr ihandle)))
4043 ((eq condition 'undisplayed)
4044 (not (or (mm-handle-undisplayer (cdr ihandle))
4045 (equal (mm-handle-media-type (cdr ihandle))
4046 "multipart/alternative"))))
4047 ((eq condition 'undisplayed-alternative)
4048 (not (mm-handle-undisplayer (cdr ihandle))))
4050 (gnus-article-goto-part (car ihandle))
4051 (or (not n) (< (car ihandle) n)))
4052 (setq n (car ihandle))))
4056 (defun gnus-article-view-part (&optional n)
4057 "View MIME part N, which is the numerical prefix."
4059 (save-current-buffer
4060 (set-buffer gnus-article-buffer)
4061 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4062 gnus-article-mime-match-handle-function)))
4063 (when (> n (length gnus-article-mime-handle-alist))
4064 (error "No such part"))
4065 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4066 (when (gnus-article-goto-part n)
4067 (if (equal (car handle) "multipart/alternative")
4068 (gnus-article-press-button)
4069 (when (eq (gnus-mm-display-part handle) 'internal)
4070 (gnus-set-window-start)))))))
4072 (defsubst gnus-article-mime-total-parts ()
4073 (if (bufferp (car gnus-article-mime-handles))
4075 (1- (length gnus-article-mime-handles))))
4077 (defun gnus-mm-display-part (handle)
4078 "Display HANDLE and fix MIME button."
4079 (let ((id (get-text-property (point) 'gnus-part))
4084 (let ((window (selected-window))
4085 (mail-parse-charset gnus-newsgroup-charset)
4086 (mail-parse-ignored-charsets
4087 (save-excursion (set-buffer gnus-summary-buffer)
4088 gnus-newsgroup-ignored-charsets)))
4091 (let ((win (get-buffer-window (current-buffer) t))
4094 (select-window win))
4097 (if (mm-handle-displayed-p handle)
4098 ;; This will remove the part.
4099 (mm-display-part handle)
4101 (narrow-to-region (point)
4102 (if (eobp) (point) (1+ (point))))
4103 (mm-display-part handle)
4104 ;; We narrow to the part itself and
4105 ;; then call the treatment functions.
4106 (goto-char (point-min))
4108 (narrow-to-region (point) (point-max))
4111 (gnus-article-mime-total-parts)
4112 (mm-handle-media-type handle)))))
4113 (if (window-live-p window)
4114 (select-window window)))))
4116 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
4117 (gnus-insert-mime-button
4118 handle id (list (mm-handle-displayed-p handle)))
4119 (goto-char point))))
4121 (defun gnus-article-goto-part (n)
4122 "Go to MIME part N."
4123 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
4125 (goto-char point))))
4127 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4128 (let ((gnus-tmp-name
4129 (or (mail-content-type-get (mm-handle-type handle) 'name)
4130 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4131 (mail-content-type-get (mm-handle-type handle) 'url)
4133 (gnus-tmp-type (mm-handle-media-type handle))
4134 (gnus-tmp-description
4135 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4138 (if (if displayed (car displayed)
4139 (mm-handle-displayed-p handle))
4141 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4143 gnus-tmp-type-long b e)
4144 (when (string-match ".*/" gnus-tmp-name)
4145 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4146 (setq gnus-tmp-type-long (concat gnus-tmp-type
4147 (and (not (equal gnus-tmp-name ""))
4148 (concat "; " gnus-tmp-name))))
4149 (unless (equal gnus-tmp-description "")
4150 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4155 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4156 `(keymap ,gnus-mime-button-map
4157 ,@(if (>= (string-to-number emacs-version) 21)
4159 (list 'local-map gnus-mime-button-map))
4160 gnus-callback gnus-mm-display-part
4161 gnus-part ,gnus-tmp-id
4162 article-type annotation
4165 (widget-convert-button
4168 :action 'gnus-widget-press-button
4169 :button-keymap gnus-mime-button-map
4171 (lambda (widget/window &optional overlay pos)
4172 ;; Needed to properly clear the message due to a bug in
4173 ;; wid-edit (XEmacs only).
4174 (if (boundp 'help-echo-owns-message)
4175 (setq help-echo-owns-message t))
4177 "%S: %s the MIME part; %S: more options"
4178 (aref gnus-mouse-2 0)
4179 ;; XEmacs will get a single widget arg; Emacs 21 will get
4180 ;; window, overlay, position.
4181 (if (mm-handle-displayed-p
4183 (with-current-buffer (gnus-overlay-buffer overlay)
4184 (widget-get (widget-at (gnus-overlay-start overlay))
4186 (widget-get widget/window :mime-handle)))
4188 (aref gnus-down-mouse-3 0))))))
4190 (defun gnus-widget-press-button (elems el)
4191 (goto-char (widget-get elems :from))
4192 (gnus-article-press-button))
4194 (defvar gnus-displaying-mime nil)
4196 (defun gnus-display-mime (&optional ihandles)
4197 "Display the MIME parts."
4199 (save-selected-window
4200 (let ((window (get-buffer-window gnus-article-buffer))
4203 (select-window window)
4204 ;; We have to do this since selecting the window
4205 ;; may change the point. So we set the window point.
4206 (set-window-point window point)))
4207 (let* ((handles (or ihandles (mm-dissect-buffer) (mm-uu-dissect)))
4208 buffer-read-only handle name type b e display)
4209 (when (and (not ihandles)
4210 (not gnus-displaying-mime))
4211 ;; Top-level call; we clean up.
4212 (when gnus-article-mime-handles
4213 (mm-destroy-parts gnus-article-mime-handles)
4214 (setq gnus-article-mime-handle-alist nil));; A trick.
4215 (setq gnus-article-mime-handles handles)
4216 ;; We allow users to glean info from the handles.
4217 (when gnus-article-mime-part-function
4218 (gnus-mime-part-function handles)))
4220 (or (not (stringp (car handles)))
4223 (when (and (not ihandles)
4224 (not gnus-displaying-mime))
4225 ;; Clean up for mime parts.
4227 (delete-region (point) (point-max)))
4228 (let ((gnus-displaying-mime t))
4229 (gnus-mime-display-part handles)))
4232 (narrow-to-region (point) (point-max))
4233 (gnus-treat-article nil 1 1)
4236 ;; Highlight the headers.
4240 (narrow-to-region (point-min) (point))
4241 (gnus-treat-article 'head))))))))
4243 (defvar gnus-mime-display-multipart-as-mixed nil)
4244 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
4245 (defvar gnus-mime-display-multipart-related-as-mixed nil)
4247 (defun gnus-mime-display-part (handle)
4250 ((not (stringp (car handle)))
4251 (gnus-mime-display-single handle))
4252 ;; User-defined multipart
4253 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4254 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4256 ;; multipart/alternative
4257 ((and (equal (car handle) "multipart/alternative")
4258 (not (or gnus-mime-display-multipart-as-mixed
4259 gnus-mime-display-multipart-alternative-as-mixed)))
4260 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4261 (push (cons id handle) gnus-article-mime-handle-alist)
4262 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4263 ;; multipart/related
4264 ((and (equal (car handle) "multipart/related")
4265 (not (or gnus-mime-display-multipart-as-mixed
4266 gnus-mime-display-multipart-related-as-mixed)))
4267 ;;;!!!We should find the start part, but we just default
4268 ;;;!!!to the first part.
4269 ;;(gnus-mime-display-part (cadr handle))
4270 ;;;!!! Most multipart/related is an HTML message plus images.
4271 ;;;!!! Unfortunately we are unable to let W3 display those
4272 ;;;!!! included images, so we just display it as a mixed multipart.
4273 ;;(gnus-mime-display-mixed (cdr handle))
4274 ;;;!!! No, w3 can display everything just fine.
4275 (gnus-mime-display-part (cadr handle)))
4276 ((equal (car handle) "multipart/signed")
4277 (or (memq 'signed gnus-article-wash-types)
4278 (push 'signed gnus-article-wash-types))
4279 (gnus-mime-display-security handle))
4280 ((equal (car handle) "multipart/encrypted")
4281 (or (memq 'encrypted gnus-article-wash-types)
4282 (push 'encrypted gnus-article-wash-types))
4283 (gnus-mime-display-security handle))
4284 ;; Other multiparts are handled like multipart/mixed.
4286 (gnus-mime-display-mixed (cdr handle)))))
4288 (defun gnus-mime-part-function (handles)
4289 (if (stringp (car handles))
4290 (mapcar 'gnus-mime-part-function (cdr handles))
4291 (funcall gnus-article-mime-part-function handles)))
4293 (defun gnus-mime-display-mixed (handles)
4294 (mapcar 'gnus-mime-display-part handles))
4296 (defun gnus-mime-display-single (handle)
4297 (let ((type (mm-handle-media-type handle))
4298 (ignored gnus-ignored-mime-types)
4305 (when (string-match (pop ignored) type)
4306 (throw 'ignored nil)))
4307 (if (and (setq not-attachment
4308 (and (not (mm-inline-override-p handle))
4309 (or (not (mm-handle-disposition handle))
4310 (equal (car (mm-handle-disposition handle))
4312 (mm-attachment-override-p handle))))
4313 (mm-automatic-display-p handle)
4315 (mm-inlinable-p handle)
4316 (mm-inlined-p handle))
4317 (mm-automatic-external-display-p type)))
4319 (when (equal (mm-handle-media-supertype handle) "text")
4321 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4323 (push (cons id handle) gnus-article-mime-handle-alist)
4324 (when (or (not display)
4325 (not (gnus-unbuttonized-mime-type-p type)))
4326 ;(gnus-article-insert-newline)
4327 (gnus-insert-mime-button
4328 handle id (list (or display (and not-attachment text))))
4329 (gnus-article-insert-newline)
4330 ;(gnus-article-insert-newline)
4331 ;; Remember modify the number of forward lines.
4339 (let ((mail-parse-charset gnus-newsgroup-charset)
4340 (mail-parse-ignored-charsets
4341 (save-excursion (condition-case ()
4342 (set-buffer gnus-summary-buffer)
4344 gnus-newsgroup-ignored-charsets)))
4345 (mm-display-part handle t))
4346 (goto-char (point-max)))
4347 ((and text not-attachment)
4351 (gnus-article-insert-newline)
4352 (mm-insert-inline handle (mm-get-part handle))
4353 (goto-char (point-max))))
4357 (narrow-to-region beg (point))
4360 (gnus-article-mime-total-parts)
4361 (mm-handle-media-type handle)))))))))
4363 (defun gnus-unbuttonized-mime-type-p (type)
4364 "Say whether TYPE is to be unbuttonized."
4365 (unless gnus-inhibit-mime-unbuttonizing
4367 (let ((types gnus-unbuttonized-mime-types))
4369 (when (string-match (pop types) type)
4370 (throw 'found t)))))
4372 (let ((types gnus-buttonized-mime-types))
4374 (when (string-match (pop types) type)
4375 (throw 'found t)))))))))
4377 (defun gnus-article-insert-newline ()
4378 "Insert a newline, but mark it as undeletable."
4379 (gnus-put-text-property
4380 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4382 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4383 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4386 handle buffer-read-only from props begend not-pref)
4387 (save-window-excursion
4390 (narrow-to-region (car ibegend)
4393 (goto-char (car ibegend))
4396 (delete-region (point-min) (point-max))
4397 (mm-remove-parts handles))
4398 (setq begend (list (point-marker)))
4400 (unless (setq not-pref (cadr (member preferred ihandles)))
4401 (setq not-pref (car ihandles)))
4404 (not (gnus-unbuttonized-mime-type-p
4405 "multipart/alternative")))
4406 (gnus-add-text-properties
4409 (insert (format "%d. " id))
4413 (unless ,(not ibegend)
4414 (setq gnus-article-mime-handle-alist
4415 ',gnus-article-mime-handle-alist))
4416 (gnus-mime-display-alternative
4417 ',ihandles ',not-pref ',begend ,id))
4418 ,@(if (>= (string-to-number emacs-version) 21)
4419 nil ;; XEmacs doesn't care
4420 (list 'local-map gnus-mime-button-map))
4421 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4422 face ,gnus-article-button-face
4423 keymap ,gnus-mime-button-map
4426 (widget-convert-button 'link from (point)
4427 :action 'gnus-widget-press-button
4428 :button-keymap gnus-widget-button-keymap)
4430 (while (setq handle (pop handles))
4431 (gnus-add-text-properties
4434 (insert (format "(%c) %-18s"
4435 (if (equal handle preferred) ?* ? )
4436 (mm-handle-media-type handle)))
4440 (unless ,(not ibegend)
4441 (setq gnus-article-mime-handle-alist
4442 ',gnus-article-mime-handle-alist))
4443 (gnus-mime-display-alternative
4444 ',ihandles ',handle ',begend ,id))
4445 ,@(if (>= (string-to-number emacs-version) 21)
4446 nil ;; XEmacs doesn't care
4447 (list 'local-map gnus-mime-button-map))
4448 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4449 face ,gnus-article-button-face
4450 keymap ,gnus-mime-button-map
4453 (widget-convert-button 'link from (point)
4454 :action 'gnus-widget-press-button
4455 :button-keymap gnus-widget-button-keymap)
4459 (if (stringp (car preferred))
4460 (gnus-display-mime preferred)
4461 (let ((mail-parse-charset gnus-newsgroup-charset)
4462 (mail-parse-ignored-charsets
4463 (save-excursion (set-buffer gnus-summary-buffer)
4464 gnus-newsgroup-ignored-charsets)))
4465 (mm-display-part preferred)
4469 (narrow-to-region (car begend) (point-max))
4471 nil (length gnus-article-mime-handle-alist)
4472 (gnus-article-mime-total-parts)
4473 (mm-handle-media-type handle))))))
4474 (goto-char (point-max))
4475 (setcdr begend (point-marker)))))
4477 (goto-char point))))
4479 (defun gnus-article-wash-status ()
4480 "Return a string which display status of article washing."
4482 (set-buffer gnus-article-buffer)
4483 (let ((cite (memq 'cite gnus-article-wash-types))
4484 (headers (memq 'headers gnus-article-wash-types))
4485 (boring (memq 'boring-headers gnus-article-wash-types))
4486 (pgp (memq 'pgp gnus-article-wash-types))
4487 (pem (memq 'pem gnus-article-wash-types))
4488 (signed (memq 'signed gnus-article-wash-types))
4489 (encrypted (memq 'encrypted gnus-article-wash-types))
4490 (signature (memq 'signature gnus-article-wash-types))
4491 (overstrike (memq 'overstrike gnus-article-wash-types))
4492 (emphasis (memq 'emphasis gnus-article-wash-types)))
4493 (format "%c%c%c%c%c%c%c"
4495 (if (or headers boring) ?h ? )
4496 (if (or pgp pem signed encrypted) ?p ? )
4497 (if signature ?s ? )
4498 (if overstrike ?o ? )
4499 (if gnus-show-mime ?m ? )
4500 (if emphasis ?e ? )))))
4502 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4504 (defun gnus-article-maybe-hide-headers ()
4505 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4506 Provided for backwards compatibility."
4507 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4508 (not (save-excursion (set-buffer gnus-summary-buffer)
4509 gnus-have-all-headers)))
4510 (not gnus-inhibit-hiding))
4511 (gnus-article-hide-headers)))
4515 (defun gnus-output-to-file (file-name)
4516 "Append the current article to a file named FILE-NAME."
4517 (let ((artbuf (current-buffer)))
4519 (insert-buffer-substring artbuf)
4520 ;; Append newline at end of the buffer as separator, and then
4522 (goto-char (point-max))
4524 (let ((file-name-coding-system nnmail-pathname-coding-system)
4525 (pathname-coding-system nnmail-pathname-coding-system))
4526 (write-region-as-binary (point-min) (point-max) file-name 'append))
4529 (defun gnus-narrow-to-page (&optional arg)
4530 "Narrow the article buffer to a page.
4531 If given a numerical ARG, move forward ARG pages."
4533 (setq arg (if arg (prefix-numeric-value arg) 0))
4535 (set-buffer gnus-article-buffer)
4536 (goto-char (point-min))
4538 ;; Remove any old next/prev buttons.
4539 (when (gnus-visual-p 'page-marker)
4540 (let ((buffer-read-only nil))
4541 (gnus-remove-text-with-property 'gnus-prev)
4542 (gnus-remove-text-with-property 'gnus-next)))
4545 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4547 (re-search-forward page-delimiter nil 'move arg)))
4548 (goto-char (match-end 0)))
4551 (if (re-search-forward page-delimiter nil 'move)
4554 (when (and (gnus-visual-p 'page-marker)
4555 (not (= (point-min) 1)))
4557 (goto-char (point-min))
4558 (gnus-insert-prev-page-button)))
4559 (when (and (gnus-visual-p 'page-marker)
4560 (< (+ (point-max) 2) (buffer-size)))
4562 (goto-char (point-max))
4563 (gnus-insert-next-page-button)))))
4565 ;; Article mode commands
4567 (defun gnus-article-goto-next-page ()
4568 "Show the next page of the article."
4570 (when (gnus-article-next-page)
4571 (goto-char (point-min))
4572 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
4574 (defun gnus-article-goto-prev-page ()
4575 "Show the next page of the article."
4577 (if (bobp) (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
4578 (gnus-article-prev-page nil)))
4580 (defun gnus-article-next-page (&optional lines)
4581 "Show the next page of the current article.
4582 If end of article, return non-nil. Otherwise return nil.
4583 Argument LINES specifies lines to be scrolled up."
4585 (let ((start (window-start))
4586 end-of-buffer end-of-page)
4588 (move-to-window-line -1)
4589 (if (<= (point) start)
4592 (setq start (point)))
4595 (unless (or (cond ((eq (1+ (buffer-size)) (point))
4596 (and (pos-visible-in-window-p)
4597 (setq end-of-buffer t)))
4599 (setq end-of-page t)))
4601 (move-to-window-line lines)
4602 (unless (search-backward "\n\n" nil t)
4603 (setq start (point)))))
4604 (cond (end-of-buffer t)
4606 (gnus-narrow-to-page 1)
4610 (set-window-start (selected-window) start)
4611 (let (window-pixel-scroll-increment)
4615 (defun gnus-article-prev-page (&optional lines)
4616 "Show previous page of current article.
4617 Argument LINES specifies lines to be scrolled down."
4619 (let (beginning-of-buffer beginning-of-page)
4621 (move-to-window-line 0)
4622 (cond ((eq 1 (point))
4623 (setq beginning-of-buffer t))
4625 (setq beginning-of-page t))))
4626 (cond (beginning-of-buffer)
4628 (gnus-narrow-to-page -1))
4631 (let (window-pixel-scroll-increment)
4632 (scroll-down lines))
4633 (beginning-of-buffer
4634 (goto-char (point-min))))))))
4636 (defun gnus-article-refer-article ()
4637 "Read article specified by message-id around point."
4639 (let ((point (point)))
4640 (search-forward ">" nil t) ;Move point to end of "<....>".
4641 (if (re-search-backward "\\(<[^<> \t\n]+>\\)" nil t)
4642 (let ((message-id (match-string 1)))
4644 (set-buffer gnus-summary-buffer)
4645 (gnus-summary-refer-article message-id))
4647 (error "No references around point"))))
4649 (defun gnus-article-show-summary ()
4650 "Reconfigure windows to show summary buffer."
4652 (if (not (gnus-buffer-live-p gnus-summary-buffer))
4653 (error "There is no summary buffer for this article buffer")
4654 (gnus-article-set-globals)
4655 (gnus-configure-windows 'article)
4656 (gnus-summary-goto-subject gnus-current-article)
4657 (gnus-summary-position-point)))
4659 (defun gnus-article-describe-briefly ()
4660 "Describe article mode commands briefly."
4662 (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")))
4664 (defun gnus-article-summary-command ()
4665 "Execute the last keystroke in the summary buffer."
4667 (let ((obuf (current-buffer))
4668 (owin (current-window-configuration))
4670 (switch-to-buffer gnus-article-current-summary 'norecord)
4671 (setq func (lookup-key (current-local-map) (this-command-keys)))
4672 (call-interactively func)
4674 (set-window-configuration owin)
4675 (set-window-point (get-buffer-window (current-buffer)) (point))))
4677 (defun gnus-article-summary-command-nosave ()
4678 "Execute the last keystroke in the summary buffer."
4681 (pop-to-buffer gnus-article-current-summary 'norecord)
4682 (setq func (lookup-key (current-local-map) (this-command-keys)))
4683 (call-interactively func)))
4685 (defun gnus-article-check-buffer ()
4686 "Beep if not in an article buffer."
4687 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
4688 (error "Command invoked outside of a Gnus article buffer")))
4690 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
4691 "Read a summary buffer key sequence and execute it from the article buffer."
4693 (gnus-article-check-buffer)
4695 '("q" "Q" "c" "r" "R" "\C-c\C-f" "m" "a" "f" "F"
4696 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
4697 "=" "^" "\M-^" "|"))
4703 '("n" "Gn" "p" "Gp"))
4706 (set-buffer gnus-article-current-summary)
4707 (let (gnus-pick-mode)
4708 (push (or key last-command-event) unread-command-events)
4709 (setq keys (static-if (featurep 'xemacs)
4710 (events-to-keys (read-key-sequence nil))
4711 (read-key-sequence nil)))))
4714 (if (or (member keys nosaves)
4715 (member keys nosave-but-article)
4716 (member keys nosave-in-article))
4718 (save-window-excursion
4719 (pop-to-buffer gnus-article-current-summary 'norecord)
4720 ;; We disable the pick minor mode commands.
4721 (let (gnus-pick-mode)
4722 (setq func (lookup-key (current-local-map) keys))))
4726 (unless (member keys nosave-in-article)
4727 (set-buffer gnus-article-current-summary))
4728 (call-interactively func)
4729 (setq new-sum-point (point)))
4730 (when (member keys nosave-but-article)
4731 (pop-to-buffer gnus-article-buffer 'norecord)))
4732 ;; These commands should restore window configuration.
4733 (let ((obuf (current-buffer))
4734 (owin (current-window-configuration))
4736 (summary gnus-article-current-summary)
4737 func in-buffer selected)
4738 (if not-restore-window
4739 (pop-to-buffer summary 'norecord)
4740 (switch-to-buffer summary 'norecord))
4741 (setq in-buffer (current-buffer))
4742 ;; We disable the pick minor mode commands.
4743 (if (and (setq func (let (gnus-pick-mode)
4744 (lookup-key (current-local-map) keys)))
4747 (call-interactively func)
4748 (setq new-sum-point (point))
4749 (when (eq in-buffer (current-buffer))
4750 (setq selected (gnus-summary-select-article))
4752 (unless not-restore-window
4753 (set-window-configuration owin))
4754 (when (eq selected 'old)
4756 (set-window-start (get-buffer-window (current-buffer))
4758 (set-window-point (get-buffer-window (current-buffer))
4760 (let ((win (get-buffer-window gnus-article-current-summary)))
4762 (set-window-point win new-sum-point)))) )
4763 (switch-to-buffer gnus-article-buffer)
4766 (defun gnus-article-describe-key (key)
4767 "Display documentation of the function invoked by KEY. KEY is a string."
4768 (interactive "kDescribe key: ")
4769 (gnus-article-check-buffer)
4770 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4772 (set-buffer gnus-article-current-summary)
4773 (let (gnus-pick-mode)
4774 (if (featurep 'xemacs)
4776 (push (elt key 0) unread-command-events)
4777 (setq key (events-to-keys
4778 (read-key-sequence "Describe key: "))))
4779 (setq unread-command-events
4781 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4783 (setq key (read-key-sequence "Describe key: "))))
4785 (describe-key key)))
4787 (defun gnus-article-describe-key-briefly (key &optional insert)
4788 "Display documentation of the function invoked by KEY. KEY is a string."
4789 (interactive "kDescribe key: \nP")
4790 (gnus-article-check-buffer)
4791 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4793 (set-buffer gnus-article-current-summary)
4794 (let (gnus-pick-mode)
4795 (if (featurep 'xemacs)
4797 (push (elt key 0) unread-command-events)
4798 (setq key (events-to-keys
4799 (read-key-sequence "Describe key: "))))
4800 (setq unread-command-events
4802 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4804 (setq key (read-key-sequence "Describe key: "))))
4805 (describe-key-briefly key insert))
4806 (describe-key-briefly key insert)))
4808 (defun gnus-article-hide (&optional arg force)
4809 "Hide all the gruft in the current article.
4810 This means that PGP stuff, signatures, cited text and (some)
4811 headers will be hidden.
4812 If given a prefix, show the hidden text instead."
4813 (interactive (append (gnus-article-hidden-arg) (list 'force)))
4814 (gnus-article-hide-headers arg)
4815 (gnus-article-hide-list-identifiers arg)
4816 (gnus-article-hide-pgp arg)
4817 (gnus-article-hide-citation-maybe arg force)
4818 (gnus-article-hide-signature arg))
4820 (defun gnus-article-maybe-highlight ()
4821 "Do some article highlighting if article highlighting is requested."
4822 (when (gnus-visual-p 'article-highlight 'highlight)
4823 (gnus-article-highlight-some)))
4825 (defun gnus-check-group-server ()
4826 ;; Make sure the connection to the server is alive.
4827 (unless (gnus-server-opened
4828 (gnus-find-method-for-group gnus-newsgroup-name))
4829 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
4830 (gnus-request-group gnus-newsgroup-name t)))
4832 (defun gnus-request-article-this-buffer (article group)
4833 "Get an article and insert it into this buffer.
4834 T-gnus change: Insert an article into `gnus-original-article-buffer'."
4835 (let (do-update-line sparse-header)
4836 ;; The current buffer is `gnus-article-buffer'.
4840 (gnus-kill-all-overlays)
4841 (setq group (or group gnus-newsgroup-name))
4843 ;; Using `gnus-request-article' directly will insert the article into
4844 ;; `nntp-server-buffer' - so we'll save some time by not having to
4845 ;; copy it from the server buffer into the article buffer.
4847 ;; We only request an article by message-id when we do not have the
4848 ;; headers for it, so we'll have to get those.
4849 (when (stringp article)
4850 (gnus-read-header article))
4852 ;; If the article number is negative, that means that this article
4853 ;; doesn't belong in this newsgroup (possibly), so we find its
4854 ;; message-id and request it by id instead of number.
4855 (when (and (numberp article)
4857 (get-buffer gnus-summary-buffer)
4858 (gnus-buffer-exists-p gnus-summary-buffer))
4860 (set-buffer gnus-summary-buffer)
4861 (let ((header (gnus-summary-article-header article)))
4864 ((memq article gnus-newsgroup-sparse)
4865 ;; This is a sparse gap article.
4866 (setq do-update-line article)
4867 (setq article (mail-header-id header))
4868 (setq sparse-header (gnus-read-header article))
4869 (setq gnus-newsgroup-sparse
4870 (delq article gnus-newsgroup-sparse)))
4872 ;; It's a real article.
4873 (setq article (mail-header-id header)))
4875 ;; It is an extracted pseudo-article.
4876 (setq article 'pseudo)
4877 (gnus-request-pseudo-article header))))
4879 (let ((method (gnus-find-method-for-group
4880 gnus-newsgroup-name)))
4881 (when (and (eq (car method) 'nneething)
4883 (let ((dir (expand-file-name
4884 (mail-header-subject header)
4885 (file-name-as-directory
4886 (or (cadr (assq 'nneething-address method))
4888 (when (file-directory-p dir)
4889 (setq article 'nneething)
4890 (gnus-group-enter-directory dir))))))))
4891 (setq gnus-original-article (cons group article))
4893 ;; The current buffer is `gnus-original-article-buffer'.
4894 (if (get-buffer gnus-original-article-buffer)
4895 (set-buffer gnus-original-article-buffer)
4896 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
4897 (set-buffer-multibyte nil)
4898 (buffer-disable-undo)
4899 (setq major-mode 'gnus-original-article-mode)
4900 (setq buffer-read-only nil))
4903 ;; Refuse to select canceled articles.
4904 ((and (numberp article)
4906 (get-buffer gnus-summary-buffer)
4907 (gnus-buffer-exists-p gnus-summary-buffer)
4908 (eq (cdr (save-excursion
4909 (set-buffer gnus-summary-buffer)
4910 (assq article gnus-newsgroup-reads)))
4911 gnus-canceled-mark))
4913 ;; Check the backlog.
4914 ((and gnus-keep-backlog
4915 (gnus-backlog-request-article group article (current-buffer)))
4917 ;; Check asynchronous pre-fetch.
4918 ((gnus-async-request-fetched-article group article (current-buffer))
4919 (gnus-async-prefetch-next group article gnus-summary-buffer)
4920 (when (and (numberp article) gnus-keep-backlog)
4921 (gnus-backlog-enter-article group article (current-buffer)))
4924 ((and gnus-use-cache
4926 (gnus-cache-request-article article group))
4928 ;; Get the article and put into the article buffer.
4929 ((or (stringp article)
4931 (let ((gnus-override-method gnus-override-method)
4932 (methods (and (stringp article)
4933 gnus-refer-article-method))
4935 (buffer-read-only nil))
4936 (if (or (not (listp methods))
4937 (and (symbolp (car methods))
4938 (assq (car methods) nnoo-definition-alist)))
4939 (setq methods (list methods)))
4940 (when (and (null gnus-override-method)
4942 (setq gnus-override-method (pop methods)))
4944 (when (eq gnus-override-method 'current)
4945 (setq gnus-override-method
4946 (with-current-buffer gnus-summary-buffer
4947 gnus-current-select-method)))
4949 (gnus-kill-all-overlays)
4950 (let ((gnus-newsgroup-name group))
4951 (gnus-check-group-server))
4952 (when (gnus-request-article article group (current-buffer))
4953 (when (numberp article)
4954 (gnus-async-prefetch-next group article
4955 gnus-summary-buffer)
4956 (when gnus-keep-backlog
4957 (gnus-backlog-enter-article
4958 group article (current-buffer))))
4959 (setq result 'article))
4962 (setq gnus-override-method (pop methods))
4963 (setq result 'done))))
4964 (and (eq result 'article) 'article)))
4968 ;; Associate this article with the current summary buffer.
4969 (setq gnus-article-current-summary gnus-summary-buffer)
4971 ;; Copy the requested article from `gnus-original-article-buffer'.
4972 (unless (equal (buffer-name (current-buffer))
4973 (buffer-name (get-buffer gnus-original-article-buffer)))
4974 (insert-buffer gnus-original-article-buffer))
4977 (run-hooks 'gnus-article-decode-hook)
4978 ;; Mark article as decoded or not.
4979 (setq gnus-article-decoded-p gnus-article-decode-hook)
4981 ;; Update sparse articles.
4982 (when (and do-update-line
4983 (or (numberp article)
4985 (let ((buf (current-buffer)))
4986 (set-buffer gnus-summary-buffer)
4987 (gnus-summary-update-article do-update-line sparse-header)
4988 (gnus-summary-goto-subject do-update-line nil t)
4989 (set-window-point (get-buffer-window (current-buffer) t)
4991 (set-buffer buf))))))
4997 (defcustom gnus-article-edit-mode-hook nil
4998 "Hook run in article edit mode buffers."
4999 :group 'gnus-article-various
5002 (defcustom gnus-article-edit-article-setup-function
5003 'gnus-article-mime-edit-article-setup
5004 "Function called to setup an editing article buffer."
5005 :group 'gnus-article-various
5008 (defvar gnus-article-edit-done-function nil)
5010 (defvar gnus-article-edit-mode-map nil)
5012 ;; Should we be using derived.el for this?
5013 (unless gnus-article-edit-mode-map
5014 (setq gnus-article-edit-mode-map (make-sparse-keymap))
5015 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5017 (gnus-define-keys gnus-article-edit-mode-map
5018 "\C-c\C-c" gnus-article-edit-done
5019 "\C-c\C-k" gnus-article-edit-exit)
5021 (gnus-define-keys (gnus-article-edit-wash-map
5022 "\C-c\C-w" gnus-article-edit-mode-map)
5023 "f" gnus-article-edit-full-stops))
5025 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5026 "Major mode for editing articles.
5027 This is an extended text-mode.
5029 \\{gnus-article-edit-mode-map}"
5030 (make-local-variable 'gnus-article-edit-done-function)
5031 (make-local-variable 'gnus-prev-winconf)
5032 (set (make-local-variable 'font-lock-defaults)
5033 '(message-font-lock-keywords t))
5034 (setq buffer-read-only nil)
5035 (buffer-enable-undo)
5038 (defun gnus-article-edit (&optional force)
5039 "Edit the current article.
5040 This will have permanent effect only in mail groups.
5041 If FORCE is non-nil, allow editing of articles even in read-only
5044 (when (and (not force)
5045 (gnus-group-read-only-p))
5046 (error "The current newsgroup does not support article editing"))
5047 (gnus-article-date-original)
5048 (gnus-article-edit-article
5050 `(lambda (no-highlight)
5052 (gnus-summary-edit-article-done
5053 ,(or (mail-header-references gnus-current-headers) "")
5054 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5056 (defun gnus-article-edit-article (start-func exit-func)
5057 "Start editing the contents of the current article buffer."
5058 (let ((winconf (current-window-configuration)))
5059 (set-buffer gnus-article-buffer)
5060 (gnus-article-edit-mode)
5061 (funcall start-func)
5062 (set-buffer-modified-p nil)
5063 (gnus-configure-windows 'edit-article)
5064 (setq gnus-article-edit-done-function exit-func)
5065 (setq gnus-prev-winconf winconf)
5066 (when gnus-article-edit-article-setup-function
5067 (funcall gnus-article-edit-article-setup-function))
5068 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit")))
5070 (defun gnus-article-edit-done (&optional arg)
5071 "Update the article edits and exit."
5073 (let ((func gnus-article-edit-done-function)
5074 (buf (current-buffer))
5075 (start (window-start)))
5076 (remove-hook 'gnus-article-mode-hook
5077 'gnus-article-mime-edit-article-unwind)
5078 ;; We remove all text props from the article buffer.
5080 (buffer-substring-no-properties (point-min) (point-max)))
5084 (let ((winconf gnus-prev-winconf))
5086 (set-window-configuration winconf)
5087 ;; Tippy-toe some to make sure that point remains where it was.
5088 (save-current-buffer
5090 (set-window-start (get-buffer-window (current-buffer)) start)
5094 (let ((buffer-read-only nil))
5096 ;; The cache and backlog have to be flushed somewhat.
5097 (when gnus-keep-backlog
5098 (gnus-backlog-remove-article
5099 (car gnus-article-current) (cdr gnus-article-current)))
5100 ;; Flush original article as well.
5102 (when (get-buffer gnus-original-article-buffer)
5103 (set-buffer gnus-original-article-buffer)
5104 (setq gnus-original-article nil)))
5105 (when gnus-use-cache
5106 (gnus-cache-update-article
5107 (car gnus-article-current) (cdr gnus-article-current))))
5109 (set-window-start (get-buffer-window buf) start)
5110 (set-window-point (get-buffer-window buf) (point))))
5112 (defun gnus-article-edit-exit ()
5113 "Exit the article editing without updating."
5115 (when (or (not (buffer-modified-p))
5116 (yes-or-no-p "Article modified; kill anyway? "))
5117 (let ((curbuf (current-buffer))
5119 (window-start (window-start)))
5121 (if (gnus-buffer-live-p gnus-original-article-buffer)
5122 (insert-buffer gnus-original-article-buffer))
5123 (let ((winconf gnus-prev-winconf))
5125 (set-window-configuration winconf)
5126 ;; Tippy-toe some to make sure that point remains where it was.
5127 (save-current-buffer
5129 (set-window-start (get-buffer-window (current-buffer)) window-start)
5132 (defun gnus-article-edit-full-stops ()
5133 "Interactively repair spacing at end of sentences."
5136 (goto-char (point-min))
5137 (search-forward-regexp "^$" nil t)
5138 (let ((case-fold-search nil))
5139 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5142 ;;; Article editing with MIME-Edit
5145 (defcustom gnus-article-mime-edit-article-setup-hook nil
5146 "Hook run after setting up a MIME editing article buffer."
5147 :group 'gnus-article-various
5150 (defun gnus-article-mime-edit-article-unwind ()
5151 "Unwind `gnus-article-buffer' if article editing was given up."
5152 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
5153 (when (featurep 'font-lock)
5154 (setq font-lock-defaults nil)
5155 (font-lock-mode -1))
5156 (when mime-edit-mode-flag
5157 (mime-edit-exit 'nomime 'no-error)
5160 (defun gnus-article-mime-edit-article-setup ()
5161 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
5162 after replacing with the original article."
5163 (setq gnus-show-mime t)
5164 (setq gnus-article-edit-done-function
5165 `(lambda (&rest args)
5166 (when mime-edit-mode-flag
5167 (let (mime-edit-insert-user-agent-field)
5170 (goto-char (point-min))
5171 (let (case-fold-search)
5172 (when (re-search-forward
5173 (format "^%s$" (regexp-quote mail-header-separator))
5175 (replace-match "")))
5176 (apply ,gnus-article-edit-done-function args)
5179 (buffer-substring-no-properties (point-min) (point-max))
5180 (set-buffer (get-buffer-create gnus-original-article-buffer))
5182 (setq gnus-current-headers (gnus-article-make-full-mail-header))
5183 (set-buffer gnus-article-buffer)
5184 (gnus-article-prepare-display)))
5185 (substitute-key-definition 'gnus-article-edit-done
5186 'gnus-article-mime-edit-done
5187 gnus-article-edit-mode-map)
5188 (substitute-key-definition 'gnus-article-edit-exit
5189 'gnus-article-mime-edit-exit
5190 gnus-article-edit-mode-map)
5192 (insert-buffer gnus-original-article-buffer)
5193 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
5194 (fset 'mime-edit-decode-single-part-in-buffer
5195 (lambda (&rest args)
5196 (if (let ((content-type (car args)))
5197 (and (eq 'message (mime-content-type-primary-type
5199 (eq 'rfc822 (mime-content-type-subtype content-type))))
5200 (setcar (cdr args) 'not-decode-text))
5204 (fset 'mime-edit-decode-single-part-in-buffer ofn)))
5205 (when (featurep 'font-lock)
5206 (set (make-local-variable 'font-lock-defaults)
5207 '(message-font-lock-keywords t))
5208 (font-lock-set-defaults)
5209 (turn-on-font-lock))
5210 (set-buffer-modified-p nil)
5211 (delete-other-windows)
5212 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
5213 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
5215 (defun gnus-article-mime-edit-done (&optional arg)
5216 "Update the article MIME edits and exit."
5218 (when (featurep 'font-lock)
5219 (setq font-lock-defaults nil)
5220 (font-lock-mode -1))
5221 (gnus-article-edit-done arg))
5223 (defun gnus-article-mime-edit-exit ()
5224 "Exit the article MIME editing without updating."
5226 (when (or (not (buffer-modified-p))
5227 (yes-or-no-p "Article modified; kill anyway? "))
5228 (when (featurep 'font-lock)
5229 (setq font-lock-defaults nil)
5230 (font-lock-mode -1))
5231 (when mime-edit-mode-flag
5232 (let (mime-edit-insert-user-agent-field)
5235 (goto-char (point-min))
5236 (let (case-fold-search)
5237 (when (re-search-forward
5238 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
5239 (replace-match "")))
5240 (let ((winconf gnus-prev-winconf))
5242 (buffer-substring-no-properties (point-min) (point-max))
5243 (set-buffer (get-buffer-create gnus-original-article-buffer))
5245 (setq gnus-current-headers (gnus-article-make-full-mail-header))
5246 (set-buffer gnus-article-buffer)
5247 (gnus-article-prepare-display)
5248 (set-window-configuration winconf))))
5251 ;;; Article highlights
5254 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5256 ;;; Internal Variables:
5258 (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\\)\\)"
5259 "Regular expression that matches URLs."
5260 :group 'gnus-article-buttons
5263 (defcustom gnus-button-alist
5264 `(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
5265 0 t gnus-button-handle-news 3)
5266 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
5267 gnus-button-handle-news 2)
5268 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
5270 gnus-button-fetch-group 4)
5271 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
5272 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
5273 t gnus-button-message-id 3)
5274 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
5275 ("mailto:\\([-a-zA-Z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5276 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
5278 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t
5279 gnus-button-handle-info 2)
5280 ;; This is how URLs _should_ be embedded in text...
5281 ("<URL: *\\([^<>]*\\)>" 0 t gnus-button-embedded-url 1)
5283 (,gnus-button-url-regexp 0 t browse-url 0))
5284 "*Alist of regexps matching buttons in article bodies.
5286 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
5287 REGEXP: is the string matching text around the button,
5288 BUTTON: is the number of the regexp grouping actually matching the button,
5289 FORM: is a lisp expression which must eval to true for the button to
5291 CALLBACK: is the function to call when the user push this button, and each
5292 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
5294 CALLBACK can also be a variable, in that case the value of that
5295 variable it the real callback function."
5296 :group 'gnus-article-buttons
5297 :type '(repeat (list regexp
5298 (integer :tag "Button")
5300 (function :tag "Callback")
5303 (integer :tag "Regexp group")))))
5305 (defcustom gnus-header-button-alist
5306 `(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
5307 0 t gnus-button-message-id 0)
5308 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
5309 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
5310 0 t gnus-button-mailto 0)
5311 ("^X-[Uu][Rr][Ll]:" ,gnus-button-url-regexp 0 t browse-url 0)
5312 ("^Subject:" ,gnus-button-url-regexp 0 t browse-url 0)
5313 ("^[^:]+:" ,gnus-button-url-regexp 0 t browse-url 0)
5314 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
5315 gnus-button-message-id 3))
5316 "*Alist of headers and regexps to match buttons in article heads.
5318 This alist is very similar to `gnus-button-alist', except that each
5319 alist has an additional HEADER element first in each entry:
5321 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
5323 HEADER is a regexp to match a header. For a fuller explanation, see
5324 `gnus-button-alist'."
5325 :group 'gnus-article-buttons
5326 :group 'gnus-article-headers
5327 :type '(repeat (list (regexp :tag "Header")
5329 (integer :tag "Button")
5331 (function :tag "Callback")
5334 (integer :tag "Regexp group")))))
5336 (defvar gnus-button-regexp nil)
5337 (defvar gnus-button-marker-list nil)
5338 ;; Regexp matching any of the regexps from `gnus-button-alist'.
5340 (defvar gnus-button-last nil)
5341 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
5345 (defun gnus-article-push-button (event)
5346 "Check text under the mouse pointer for a callback function.
5347 If the text under the mouse pointer has a `gnus-callback' property,
5348 call it with the value of the `gnus-data' text property."
5350 (set-buffer (window-buffer (posn-window (event-start event))))
5351 (let* ((pos (posn-point (event-start event)))
5352 (data (get-text-property pos 'gnus-data))
5353 (fun (get-text-property pos 'gnus-callback)))
5356 (funcall fun data))))
5358 (defun gnus-article-press-button ()
5359 "Check text at point for a callback function.
5360 If the text at point has a `gnus-callback' property,
5361 call it with the value of the `gnus-data' text property."
5363 (let* ((data (get-text-property (point) 'gnus-data))
5364 (fun (get-text-property (point) 'gnus-callback)))
5366 (funcall fun data))))
5368 (defun gnus-article-prev-button (n)
5369 "Move point to N buttons backward.
5370 If N is negative, move forward instead."
5372 (gnus-article-next-button (- n)))
5374 (defun gnus-article-next-button (n)
5375 "Move point to N buttons forward.
5376 If N is negative, move backward instead."
5378 (let ((function (if (< n 0) 'previous-single-property-change
5379 'next-single-property-change))
5380 (inhibit-point-motion-hooks t)
5382 (limit (if (< n 0) (point-min) (point-max))))
5384 (while (and (not (= limit (point)))
5386 ;; Skip past the current button.
5387 (when (get-text-property (point) 'gnus-callback)
5388 (goto-char (funcall function (point) 'gnus-callback nil limit)))
5389 ;; Go to the next (or previous) button.
5390 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
5391 ;; Put point at the start of the button.
5392 (when (and backward (not (get-text-property (point) 'gnus-callback)))
5393 (goto-char (funcall function (point) 'gnus-callback nil limit)))
5394 ;; Skip past intangible buttons.
5395 (when (get-text-property (point) 'intangible)
5399 (gnus-message 5 "No more buttons"))
5402 (defun gnus-article-highlight (&optional force)
5403 "Highlight current article.
5404 This function calls `gnus-article-highlight-headers',
5405 `gnus-article-highlight-citation',
5406 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5407 do the highlighting. See the documentation for those functions."
5408 (interactive (list 'force))
5409 (gnus-article-highlight-headers)
5410 (gnus-article-highlight-citation force)
5411 (gnus-article-highlight-signature)
5412 (gnus-article-add-buttons force)
5413 (gnus-article-add-buttons-to-head))
5415 (defun gnus-article-highlight-some (&optional force)
5416 "Highlight current article.
5417 This function calls `gnus-article-highlight-headers',
5418 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5419 do the highlighting. See the documentation for those functions."
5420 (interactive (list 'force))
5421 (gnus-article-highlight-headers)
5422 (gnus-article-highlight-signature)
5423 (gnus-article-add-buttons))
5425 (defun gnus-article-highlight-headers ()
5426 "Highlight article headers as specified by `gnus-header-face-alist'."
5429 (set-buffer gnus-article-buffer)
5431 (let ((alist gnus-header-face-alist)
5432 (buffer-read-only nil)
5433 (case-fold-search t)
5434 (inhibit-point-motion-hooks t)
5435 entry regexp header-face field-face from hpoints fpoints)
5436 (article-narrow-to-head)
5437 (while (setq entry (pop alist))
5438 (goto-char (point-min))
5439 (setq regexp (concat "^\\("
5440 (if (string-equal "" (nth 0 entry))
5444 header-face (nth 1 entry)
5445 field-face (nth 2 entry))
5446 (while (and (re-search-forward regexp nil t)
5450 (unless (search-forward ":" nil t)
5452 (when (and header-face
5453 (not (memq (point) hpoints)))
5454 (push (point) hpoints)
5455 (gnus-put-text-property from (point) 'face header-face))
5456 (when (and field-face
5457 (not (memq (setq from (point)) fpoints)))
5459 (if (re-search-forward "^[^ \t]" nil t)
5461 (goto-char (point-max)))
5462 (gnus-put-text-property from (point) 'face field-face))))))))
5464 (defun gnus-article-highlight-signature ()
5465 "Highlight the signature in an article.
5466 It does this by highlighting everything after
5467 `gnus-signature-separator' using `gnus-signature-face'."
5469 (when gnus-signature-face
5471 (set-buffer gnus-article-buffer)
5472 (let ((buffer-read-only nil)
5473 (inhibit-point-motion-hooks t))
5475 (when (gnus-article-narrow-to-signature)
5476 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
5477 'face gnus-signature-face)))))))
5479 (defun gnus-article-buttonize-signature ()
5480 "Add button to the signature."
5483 (set-buffer gnus-article-buffer)
5484 (let ((buffer-read-only nil)
5485 (inhibit-point-motion-hooks t))
5486 (when (gnus-article-search-signature)
5487 (gnus-article-add-button (match-beginning 0) (match-end 0)
5488 'gnus-signature-toggle
5489 (set-marker (make-marker)
5490 (1+ (match-end 0))))))))
5492 (defun gnus-button-in-region-p (b e prop)
5493 "Say whether PROP exists in the region."
5494 (text-property-not-all b e prop nil))
5496 (defun gnus-article-add-buttons (&optional force)
5497 "Find external references in the article and make buttons of them.
5498 \"External references\" are things like Message-IDs and URLs, as
5499 specified by `gnus-button-alist'."
5500 (interactive (list 'force))
5502 (set-buffer gnus-article-buffer)
5503 (let ((buffer-read-only nil)
5504 (inhibit-point-motion-hooks t)
5505 (case-fold-search t)
5506 (alist gnus-button-alist)
5508 ;; Remove all old markers.
5509 (let (marker entry new-list)
5510 (while (setq marker (pop gnus-button-marker-list))
5511 (if (or (< marker (point-min)) (>= marker (point-max)))
5512 (push marker new-list)
5514 (when (setq entry (gnus-button-entry))
5515 (put-text-property (match-beginning (nth 1 entry))
5516 (match-end (nth 1 entry))
5517 'gnus-callback nil))
5518 (set-marker marker nil)))
5519 (setq gnus-button-marker-list new-list))
5520 ;; We skip the headers.
5523 (while (setq entry (pop alist))
5524 (setq regexp (car entry))
5526 (while (re-search-forward regexp nil t)
5527 (let* ((start (and entry (match-beginning (nth 1 entry))))
5528 (end (and entry (match-end (nth 1 entry))))
5529 (from (match-beginning 0)))
5530 (when (and (or (eq t (nth 2 entry))
5531 (eval (nth 2 entry)))
5532 (not (gnus-button-in-region-p
5533 start end 'gnus-callback)))
5534 ;; That optional form returned non-nil, so we add the
5536 (gnus-article-add-button
5537 start end 'gnus-button-push
5538 (car (push (set-marker (make-marker) from)
5539 gnus-button-marker-list))))))))))
5541 ;; Add buttons to the head of an article.
5542 (defun gnus-article-add-buttons-to-head ()
5543 "Add buttons to the head of the article."
5546 (set-buffer gnus-article-buffer)
5548 (let ((buffer-read-only nil)
5549 (inhibit-point-motion-hooks t)
5550 (case-fold-search t)
5551 (alist gnus-header-button-alist)
5553 (article-narrow-to-head)
5555 ;; Each alist entry.
5556 (setq entry (car alist)
5558 (goto-char (point-min))
5559 (while (re-search-forward (car entry) nil t)
5560 ;; Each header matching the entry.
5561 (setq beg (match-beginning 0))
5562 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
5563 (match-beginning 0))
5566 (while (re-search-forward (nth 1 entry) end t)
5567 ;; Each match within a header.
5568 (let* ((entry (cdr entry))
5569 (start (match-beginning (nth 1 entry)))
5570 (end (match-end (nth 1 entry)))
5571 (form (nth 2 entry)))
5572 (goto-char (match-end 0))
5574 (gnus-article-add-button
5575 start end (nth 3 entry)
5576 (buffer-substring (match-beginning (nth 4 entry))
5577 (match-end (nth 4 entry)))))))
5578 (goto-char end)))))))
5580 ;;; External functions:
5582 (defun gnus-article-add-button (from to fun &optional data)
5583 "Create a button between FROM and TO with callback FUN and data DATA."
5584 (when gnus-article-button-face
5585 (gnus-overlay-put (gnus-make-overlay from to)
5586 'face gnus-article-button-face))
5587 (gnus-add-text-properties
5589 (nconc (and gnus-article-mouse-face
5590 (list gnus-mouse-face-prop gnus-article-mouse-face))
5591 (list 'gnus-callback fun)
5592 (and data (list 'gnus-data data))))
5593 (widget-convert-button 'link from to :action 'gnus-widget-press-button
5594 ;; Quote `:button-keymap' for Mule 2.3
5595 ;; but it won't work.
5596 ':button-keymap gnus-widget-button-keymap))
5598 ;;; Internal functions:
5600 (defun gnus-article-set-globals ()
5602 (set-buffer gnus-summary-buffer)
5603 (gnus-set-global-variables)))
5605 (defun gnus-signature-toggle (end)
5607 (set-buffer gnus-article-buffer)
5608 (let ((buffer-read-only nil)
5609 (inhibit-point-motion-hooks t)
5610 (limit (next-single-property-change end 'mime-view-entity
5612 (if (text-property-any end limit 'article-type 'signature)
5613 (gnus-remove-text-properties-when
5614 'article-type 'signature end limit
5615 (cons 'article-type (cons 'signature
5616 gnus-hidden-properties)))
5617 (gnus-add-text-properties-when
5618 'article-type nil end limit
5619 (cons 'article-type (cons 'signature
5620 gnus-hidden-properties)))))))
5622 (defun gnus-button-entry ()
5623 ;; Return the first entry in `gnus-button-alist' matching this place.
5624 (let ((alist gnus-button-alist)
5627 (setq entry (pop alist))
5628 (if (looking-at (car entry))
5633 (defun gnus-button-push (marker)
5634 ;; Push button starting at MARKER.
5637 (let* ((entry (gnus-button-entry))
5638 (inhibit-point-motion-hooks t)
5640 (args (mapcar (lambda (group)
5641 (let ((string (match-string group)))
5642 (gnus-set-text-properties
5643 0 (length string) nil string)
5650 (fboundp (symbol-value fun)))
5651 (apply (symbol-value fun) args))
5653 (gnus-message 1 "You must define `%S' to use this button"
5654 (cons fun args)))))))
5656 (defun gnus-parse-news-url (url)
5657 (let (scheme server group message-id articles)
5660 (goto-char (point-min))
5661 (when (looking-at "\\([A-Za-z]+\\):")
5662 (setq scheme (match-string 1))
5663 (goto-char (match-end 0)))
5664 (when (looking-at "//\\([^/]+\\)/")
5665 (setq server (match-string 1))
5666 (goto-char (match-end 0)))
5669 ((looking-at "\\(.*@.*\\)")
5670 (setq message-id (match-string 1)))
5671 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
5672 (setq group (match-string 1)
5673 articles (split-string (match-string 2) "-")))
5674 ((looking-at "\\([^/]+\\)/?")
5675 (setq group (match-string 1)))
5677 (error "Unknown news URL syntax"))))
5678 (list scheme server group message-id articles)))
5680 (defun gnus-button-handle-news (url)
5682 (destructuring-bind (scheme server group message-id articles)
5683 (gnus-parse-news-url url)
5687 (set-buffer gnus-summary-buffer)
5689 (let ((gnus-refer-article-method (list (list 'nntp server))))
5690 (gnus-summary-refer-article message-id))
5691 (gnus-summary-refer-article message-id))))
5693 (gnus-button-fetch-group url)))))
5695 (defun gnus-button-handle-info (url)
5696 "Fetch an info URL."
5698 "^\\([^:/]+\\)?/\\(.*\\)"
5700 (gnus-info-find-node
5701 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
5704 (gnus-url-unhex-string (match-string 2 url))))
5705 (error "Can't parse %s" url)))
5707 (defun gnus-button-message-id (message-id)
5710 (set-buffer gnus-summary-buffer)
5711 (gnus-summary-refer-article message-id)))
5713 (defun gnus-button-fetch-group (address)
5714 "Fetch GROUP specified by ADDRESS."
5715 (if (not (string-match "[:/]" address))
5716 ;; This is just a simple group url.
5717 (gnus-group-read-ephemeral-group address gnus-select-method)
5720 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
5722 (error "Can't parse %s" address)
5723 (gnus-group-read-ephemeral-group
5724 (match-string 4 address)
5725 `(nntp ,(match-string 1 address)
5726 (nntp-address ,(match-string 1 address))
5727 (nntp-port-number ,(if (match-end 3)
5728 (match-string 3 address)
5731 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
5733 (defun gnus-url-parse-query-string (query &optional downcase)
5734 (let (retval pairs cur key val)
5735 (setq pairs (split-string query "&"))
5737 (setq cur (car pairs)
5739 (if (not (string-match "=" cur))
5741 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
5742 val (gnus-url-unhex-string (substring cur (match-end 0) nil)))
5744 (setq key (downcase key)))
5745 (setq cur (assoc key retval))
5747 (setcdr cur (cons val (cdr cur)))
5748 (setq retval (cons (list key val) retval)))))
5751 (defun gnus-url-unhex (x)
5758 (defun gnus-url-unhex-string (str &optional allow-newlines)
5759 "Remove %XXX embedded spaces, etc in a url.
5760 If optional second argument ALLOW-NEWLINES is non-nil, then allow the
5761 decoding of carriage returns and line feeds in the string, which is normally
5762 forbidden in URL encoding."
5763 (setq str (or (nnheader-replace-chars-in-string str ?+ ? ) ""))
5765 (case-fold-search t))
5766 (while (string-match "%[0-9a-f][0-9a-f]" str)
5767 (let* ((start (match-beginning 0))
5768 (ch1 (gnus-url-unhex (elt str (+ start 1))))
5770 (gnus-url-unhex (elt str (+ start 2))))))
5772 tmp (substring str 0 start)
5775 (char-to-string code))
5776 ((or (= code ?\n) (= code ?\r))
5778 (t (char-to-string code))))
5779 str (substring str (match-end 0)))))
5780 (setq tmp (concat tmp str))
5783 (defun gnus-url-mailto (url)
5784 ;; Send mail to someone
5785 (when (string-match "mailto:/*\\(.*\\)" url)
5786 (setq url (substring url (match-beginning 1) nil)))
5787 (let (to args subject func)
5788 (if (string-match (regexp-quote "?") url)
5789 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
5790 args (gnus-url-parse-query-string
5791 (substring url (match-end 0) nil) t))
5792 (setq to (gnus-url-unhex-string url)))
5793 (setq args (cons (list "to" to) args)
5794 subject (cdr-safe (assoc "subject" args)))
5797 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
5800 (message-position-on-field (caar args)))
5801 (insert (mapconcat 'identity (cdar args) ", "))
5802 (setq args (cdr args)))
5805 (message-goto-subject))))
5807 (defun gnus-button-embedded-url (address)
5808 "Activate ADDRESS with `browse-url'."
5809 (browse-url (gnus-strip-whitespace address)))
5812 ;; Silence the byte-compiler.
5813 (autoload 'smiley-toggle-buffer "gnus-bitmap"))
5814 (defun gnus-article-smiley-display ()
5815 "Display \"smileys\" as small graphical icons."
5816 (smiley-toggle-buffer 1 (current-buffer) (point-min) (point-max)))
5818 ;;; Next/prev buttons in the article buffer.
5820 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
5821 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
5823 (defvar gnus-prev-page-map nil)
5824 (unless gnus-prev-page-map
5825 (setq gnus-prev-page-map (make-sparse-keymap))
5826 (define-key gnus-prev-page-map gnus-mouse-2 'gnus-button-prev-page)
5827 (define-key gnus-prev-page-map "\r" 'gnus-button-prev-page))
5829 (static-if (featurep 'xemacs)
5830 (defun gnus-insert-prev-page-button ()
5831 (let ((buffer-read-only nil))
5833 gnus-prev-page-line-format nil
5834 `(gnus-prev t local-map ,gnus-prev-page-map
5835 gnus-callback gnus-article-button-prev-page
5836 article-type annotation))))
5837 (defun gnus-insert-prev-page-button ()
5838 (let ((buffer-read-only nil)
5839 (situation (get-text-property (point-min) 'mime-view-situation)))
5840 (set-keymap-parent gnus-prev-page-map (current-local-map))
5842 gnus-prev-page-line-format nil
5843 `(gnus-prev t local-map ,gnus-prev-page-map
5844 gnus-callback gnus-article-button-prev-page
5845 article-type annotation
5846 mime-view-situation ,situation))))
5849 (defvar gnus-next-page-map nil)
5850 (unless gnus-next-page-map
5851 (setq gnus-next-page-map (make-sparse-keymap))
5852 (define-key gnus-next-page-map gnus-mouse-2 'gnus-button-next-page)
5853 (define-key gnus-next-page-map "\r" 'gnus-button-next-page))
5855 (defun gnus-button-next-page ()
5856 "Go to the next page."
5858 (let ((win (selected-window)))
5859 (select-window (get-buffer-window gnus-article-buffer t))
5860 (gnus-article-next-page)
5861 (select-window win)))
5863 (defun gnus-button-prev-page ()
5864 "Go to the prev page."
5866 (let ((win (selected-window)))
5867 (select-window (get-buffer-window gnus-article-buffer t))
5868 (gnus-article-prev-page)
5869 (select-window win)))
5871 (static-if (featurep 'xemacs)
5872 (defun gnus-insert-next-page-button ()
5873 (let ((buffer-read-only nil))
5874 (gnus-eval-format gnus-next-page-line-format nil
5876 t local-map ,gnus-next-page-map
5877 gnus-callback gnus-article-button-next-page
5878 article-type annotation))))
5879 (defun gnus-insert-next-page-button ()
5880 (let ((buffer-read-only nil)
5881 (situation (get-text-property (point-min) 'mime-view-situation)))
5882 (set-keymap-parent gnus-next-page-map (current-local-map))
5883 (gnus-eval-format gnus-next-page-line-format nil
5885 t local-map ,gnus-next-page-map
5886 gnus-callback gnus-article-button-next-page
5887 article-type annotation
5888 mime-view-situation ,situation))))
5891 (defun gnus-article-button-next-page (arg)
5892 "Go to the next page."
5894 (let ((win (selected-window)))
5895 (select-window (get-buffer-window gnus-article-buffer t))
5896 (gnus-article-next-page)
5897 (select-window win)))
5899 (defun gnus-article-button-prev-page (arg)
5900 "Go to the prev page."
5902 (let ((win (selected-window)))
5903 (select-window (get-buffer-window gnus-article-buffer t))
5904 (gnus-article-prev-page)
5905 (select-window win)))
5907 (defvar gnus-decode-header-methods
5908 '(mail-decode-encoded-word-region)
5909 "List of methods used to decode headers.
5911 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
5912 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
5913 (REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
5914 whose names match REGEXP.
5917 ((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
5918 mail-decode-encoded-word-region
5919 (\"chinese\" . rfc1843-decode-region))
5922 (defvar gnus-decode-header-methods-cache nil)
5924 (defun gnus-multi-decode-header (start end)
5925 "Apply the functions from `gnus-encoded-word-methods' that match."
5926 (unless (and gnus-decode-header-methods-cache
5927 (eq gnus-newsgroup-name
5928 (car gnus-decode-header-methods-cache)))
5929 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
5932 (nconc gnus-decode-header-methods-cache (list x))
5933 (if (and gnus-newsgroup-name
5934 (string-match (car x) gnus-newsgroup-name))
5935 (nconc gnus-decode-header-methods-cache
5937 gnus-decode-header-methods))
5938 (let ((xlist gnus-decode-header-methods-cache))
5941 (narrow-to-region start end)
5943 (funcall (pop xlist) (point-min) (point-max))))))
5946 ;;; Treatment top-level handling.
5949 (defun gnus-treat-article (condition &optional part-number total-parts type)
5950 (let ((length (- (point-max) (point-min)))
5951 (alist gnus-treatment-function-alist)
5952 (article-goto-body-goes-to-point-min-p t)
5956 (let ((list gnus-article-treat-types))
5958 (when (string-match (pop list) type)
5959 (throw 'found t)))))))
5960 (highlightp (gnus-visual-p 'article-highlight 'highlight))
5961 (entity (static-unless (featurep 'xemacs)
5962 (when (eq 'head condition)
5963 (get-text-property (point-min) 'mime-view-entity))))
5964 val elem buttonized)
5965 (gnus-run-hooks 'gnus-part-display-hook)
5966 (unless gnus-inhibit-treatment
5967 (while (setq elem (pop alist))
5970 (if (gnus-buffer-live-p gnus-summary-buffer)
5971 (set-buffer gnus-summary-buffer))
5972 (symbol-value (car elem))))
5973 (when (and (or (consp val)
5975 (gnus-treat-predicate val)
5976 (or (not (get (car elem) 'highlight))
5978 (when (and (not buttonized)
5980 '(gnus-treat-hide-signature
5981 gnus-treat-highlight-signature)))
5982 (gnus-article-buttonize-signature)
5983 (setq buttonized t))
5985 (funcall (cadr elem)))))
5986 ;; FSF Emacsen does not inherit the existing text properties
5987 ;; in the new text, so we should do it for `mime-view-entity'.
5988 (static-unless (featurep 'xemacs)
5990 (put-text-property (point-min) (point-max)
5991 'mime-view-entity entity))))))
5993 ;; Dynamic variables.
5995 (defvar part-number)
5996 (defvar total-parts)
6001 (defun gnus-treat-predicate (val)
6006 (stringp (car val)))
6007 (apply 'gnus-or (mapcar `(lambda (s)
6008 (string-match s ,(or gnus-newsgroup-name "")))
6011 (let ((pred (pop val)))
6014 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
6016 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
6018 (not (gnus-treat-predicate (car val))))
6020 (equal (car val) type))
6022 (error "%S is not a valid predicate" pred)))))
6032 (eq part-number total-parts))
6036 (error "%S is not a valid value" val))))
6038 (defun gnus-article-encrypt-body (protocol &optional n)
6039 "Encrypt the article body."
6042 (or gnus-article-encrypt-protocol
6043 (completing-read "Encrypt protocol: "
6044 gnus-article-encrypt-protocol-alist
6046 current-prefix-arg))
6047 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
6049 (error (format "Can't find the encrypt protocol %s" protocol)))
6050 (if (equal gnus-newsgroup-name "nndraft:drafts")
6051 (error "Can't encrypt the article in group nndraft:drafts"))
6052 (if (equal gnus-newsgroup-name "nndraft:queue")
6053 (error "Don't encrypt the article in group nndraft:queue"))
6054 (gnus-summary-iterate n
6056 (set-buffer gnus-summary-buffer)
6057 (let ((mail-parse-charset gnus-newsgroup-charset)
6058 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6059 (summary-buffer gnus-summary-buffer)
6061 (gnus-set-global-variables)
6062 (when (gnus-group-read-only-p)
6063 (error "The current newsgroup does not support article encrypt"))
6064 (gnus-summary-show-article t)
6066 (or (mail-header-references gnus-current-headers) ""))
6067 (set-buffer gnus-article-buffer)
6068 (let* ((buffer-read-only nil)
6070 (mapcar (lambda (field)
6071 (and (save-restriction
6072 (message-narrow-to-head)
6073 (goto-char (point-min))
6074 (search-forward field nil t))
6076 (message-narrow-to-field)
6077 (buffer-substring (point-min) (point-max))
6078 (delete-region (point-min) (point-max))
6080 '("Content-Type:" "Content-Transfer-Encoding:"
6081 "Content-Disposition:"))))
6082 (message-narrow-to-head)
6083 (message-remove-header "MIME-Version")
6084 (goto-char (point-max))
6085 (setq point (point))
6086 (insert (apply 'concat headers))
6088 (narrow-to-region point (point-max))
6089 (let ((message-options message-options))
6090 (message-options-set 'message-sender user-mail-address)
6091 (message-options-set 'message-recipients user-mail-address)
6092 (message-options-set 'message-sign-encrypt 'not)
6094 (goto-char (point-min))
6095 (insert "MIME-Version: 1.0\n")
6097 (gnus-summary-edit-article-done
6098 references nil summary-buffer t))
6099 (when gnus-keep-backlog
6100 (gnus-backlog-remove-article
6101 (car gnus-article-current) (cdr gnus-article-current)))
6103 (when (get-buffer gnus-original-article-buffer)
6104 (set-buffer gnus-original-article-buffer)
6105 (setq gnus-original-article nil)))
6106 (when gnus-use-cache
6107 (gnus-cache-update-article
6108 (car gnus-article-current) (cdr gnus-article-current))))))))
6110 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
6111 "The following specs can be used:
6112 %t The security MIME type
6115 %D Details if button is pressed")
6117 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
6118 "The following specs can be used:
6119 %t The security MIME type
6122 %D Details if button is pressed")
6124 (defvar gnus-mime-security-button-line-format-alist
6125 '((?t gnus-tmp-type ?s)
6126 (?i gnus-tmp-info ?s)
6127 (?d gnus-tmp-details ?s)
6128 (?D gnus-tmp-pressed-details ?s)))
6130 (defvar gnus-mime-security-button-map
6131 (let ((map (make-sparse-keymap)))
6132 (unless (>= (string-to-number emacs-version) 21)
6133 (set-keymap-parent map gnus-article-mode-map))
6134 (define-key map gnus-mouse-2 'gnus-article-push-button)
6135 (define-key map "\r" 'gnus-article-press-button)
6138 (defvar gnus-mime-security-details-buffer nil)
6140 (defvar gnus-mime-security-button-pressed nil)
6142 (defvar gnus-mime-security-show-details-inline t
6143 "If non-nil, show details in the article buffer.")
6145 (defun gnus-mime-security-verify-or-decrypt (handle)
6146 (mm-remove-parts (cdr handle))
6147 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
6148 point buffer-read-only)
6150 (goto-char (car region)))
6152 (narrow-to-region (point) (point))
6153 (with-current-buffer (mm-handle-multipart-original-buffer handle)
6154 (let* ((mm-verify-option 'known)
6155 (mm-decrypt-option 'known)
6156 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
6157 (unless (eq nparts (cdr handle))
6158 (mm-destroy-parts (cdr handle))
6159 (setcdr handle nparts))))
6160 (setq point (point))
6161 (gnus-mime-display-security handle)
6162 (goto-char (point-max)))
6164 (delete-region (point) (cdr region))
6165 (set-marker (car region) nil)
6166 (set-marker (cdr region) nil))
6169 (defun gnus-mime-security-show-details (handle)
6170 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
6172 (if gnus-mime-security-show-details-inline
6173 (let ((gnus-mime-security-button-pressed t)
6174 (gnus-mime-security-button-line-format
6175 (get-text-property (point) 'gnus-line-format))
6178 (while (eq (get-text-property (point) 'gnus-line-format)
6179 gnus-mime-security-button-line-format)
6183 (narrow-to-region (point) (point))
6184 (gnus-insert-mime-security-button handle))
6185 (delete-region (point)
6186 (or (text-property-not-all
6189 gnus-mime-security-button-line-format)
6191 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
6192 (with-current-buffer gnus-mime-security-details-buffer
6195 (setq gnus-mime-security-details-buffer
6196 (gnus-get-buffer-create "*MIME Security Details*")))
6197 (with-current-buffer gnus-mime-security-details-buffer
6199 (goto-char (point-min)))
6200 (pop-to-buffer gnus-mime-security-details-buffer))
6201 (gnus-message 5 "No details."))))
6203 (defun gnus-mime-security-press-button (handle)
6204 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6205 (gnus-mime-security-show-details handle)
6206 (gnus-mime-security-verify-or-decrypt handle)))
6208 (defun gnus-insert-mime-security-button (handle &optional displayed)
6209 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
6212 (or (nth 2 (assoc protocol mm-verify-function-alist))
6213 (nth 2 (assoc protocol mm-decrypt-function-alist))
6215 (if (equal (car handle) "multipart/signed")
6216 " Signed" " Encrypted")
6219 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6222 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
6223 gnus-tmp-pressed-details
6225 (setq gnus-tmp-details
6226 (if gnus-tmp-details
6227 (concat "\n" gnus-tmp-details) ""))
6228 (setq gnus-tmp-pressed-details
6229 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
6234 gnus-mime-security-button-line-format
6235 gnus-mime-security-button-line-format-alist
6236 `(keymap ,gnus-mime-security-button-map
6237 ,@(if (>= (string-to-number emacs-version) 21)
6238 nil ;; XEmacs doesn't care
6239 (list 'local-map gnus-mime-security-button-map))
6240 gnus-callback gnus-mime-security-press-button
6241 gnus-line-format ,gnus-mime-security-button-line-format
6242 article-type annotation
6245 (widget-convert-button
6248 :action 'gnus-widget-press-button
6249 :button-keymap gnus-mime-security-button-map
6251 (lambda (widget/window &optional overlay pos)
6252 ;; Needed to properly clear the message due to a bug in
6253 ;; wid-edit (XEmacs only).
6254 (if (boundp 'help-echo-owns-message)
6255 (setq help-echo-owns-message t))
6258 (aref gnus-mouse-2 0))))))
6260 (defun gnus-mime-display-security (handle)
6262 (narrow-to-region (point) (point))
6263 (unless (gnus-unbuttonized-mime-type-p (car handle))
6264 (gnus-insert-mime-security-button handle))
6265 (gnus-mime-display-mixed (cdr handle))
6268 (unless (gnus-unbuttonized-mime-type-p (car handle))
6269 (let ((gnus-mime-security-button-line-format
6270 gnus-mime-security-button-end-line-format))
6271 (gnus-insert-mime-security-button handle)))
6272 (mm-set-handle-multipart-parameter
6274 (cons (set-marker (make-marker) (point-min))
6275 (set-marker (make-marker) (point-max))))))
6281 (defun gnus-article-header-presentation-method (entity situation)
6282 (mime-insert-header entity)
6283 (article-decode-group-name))
6285 (set-alist 'mime-header-presentation-method-alist
6286 'gnus-original-article-mode
6287 #'gnus-article-header-presentation-method)
6289 (defun gnus-mime-preview-quitting-method ()
6290 (mime-preview-kill-buffer)
6291 (delete-other-windows)
6292 (gnus-article-show-summary)
6293 (gnus-summary-select-article gnus-show-all-headers t))
6295 (set-alist 'mime-preview-quitting-method-alist
6296 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
6298 (set-alist 'mime-preview-following-method-alist
6299 'gnus-original-article-mode #'gnus-following-method)
6301 (set-alist 'mime-preview-over-to-previous-method-alist
6302 'gnus-original-article-mode
6304 (if (> (point-min) 1)
6305 (gnus-article-prev-page)
6306 (gnus-article-read-summary-keys
6307 nil (gnus-character-to-event ?P)))))
6309 (set-alist 'mime-preview-over-to-next-method-alist
6310 'gnus-original-article-mode'
6312 (if (< (point-max) (buffer-size))
6313 (gnus-article-next-page)
6314 (gnus-article-read-summary-keys
6315 nil (gnus-character-to-event ?N)))))
6325 (run-hooks 'gnus-art-load-hook)
6327 ;;; gnus-art.el ends here