1 ;;; gnus-art.el --- article mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
43 (autoload 'gnus-msg-mail "gnus-msg" nil t)
44 (autoload 'gnus-button-mailto "gnus-msg")
45 (autoload 'gnus-button-reply "gnus-msg" nil t)
47 (defgroup gnus-article nil
49 :link '(custom-manual "(gnus)The Article Buffer")
52 (defgroup gnus-article-treat nil
53 "Treating article parts."
54 :link '(custom-manual "(gnus)Article Hiding")
57 (defgroup gnus-article-hiding nil
58 "Hiding article parts."
59 :link '(custom-manual "(gnus)Article Hiding")
62 (defgroup gnus-article-highlight nil
63 "Article highlighting."
64 :link '(custom-manual "(gnus)Article Highlighting")
68 (defgroup gnus-article-signature nil
70 :link '(custom-manual "(gnus)Article Signature")
73 (defgroup gnus-article-headers nil
75 :link '(custom-manual "(gnus)Hiding Headers")
78 (defgroup gnus-article-washing nil
79 "Special commands on articles."
80 :link '(custom-manual "(gnus)Article Washing")
83 (defgroup gnus-article-emphasis nil
84 "Fontisizing articles."
85 :link '(custom-manual "(gnus)Article Fontisizing")
88 (defgroup gnus-article-saving nil
90 :link '(custom-manual "(gnus)Saving Articles")
93 (defgroup gnus-article-mime nil
94 "Worshiping the MIME wonder."
95 :link '(custom-manual "(gnus)Using MIME")
98 (defgroup gnus-article-buttons nil
99 "Pushable buttons in the article buffer."
100 :link '(custom-manual "(gnus)Article Buttons")
101 :group 'gnus-article)
103 (defgroup gnus-article-various nil
104 "Other article options."
105 :link '(custom-manual "(gnus)Misc Article")
106 :group 'gnus-article)
108 (defcustom gnus-ignored-headers
111 (concat "^" header ":"))
112 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
113 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
114 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
115 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
116 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
117 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
118 "X-Attribution" "X-Originating-IP" "Delivered-To"
119 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
120 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
121 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
122 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
123 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
124 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
125 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
126 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
127 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
128 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
129 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
130 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
131 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
132 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
133 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
134 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
135 "List-[A-Za-z]+" "X-Listprocessor-Version"
136 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
137 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
138 "X-Received" "Content-length" "X-precedence"
139 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
140 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
141 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
142 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
143 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
144 "X-Content-length" "X-Posting-Agent" "Original-Received"
145 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
146 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
147 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
148 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
149 "X-Abuse-and-DMCA-Info" "X-Postfilter"))
150 "*All headers that start with this regexp will be hidden.
151 This variable can also be a list of regexps of headers to be ignored.
152 If `gnus-visible-headers' is non-nil, this variable will be ignored."
153 :type '(choice :custom-show nil
156 :group 'gnus-article-hiding)
158 (defcustom gnus-visible-headers
159 "^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:"
160 "*All headers that do not match this regexp will be hidden.
161 This variable can also be a list of regexp of headers to remain visible.
162 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
163 :type '(repeat :value-to-internal (lambda (widget value)
164 (custom-split-regexp-maybe value))
165 :match (lambda (widget value)
167 (widget-editable-list-match widget value)))
169 :group 'gnus-article-hiding)
171 (defcustom gnus-sorted-header-list
172 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
173 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
174 "*This variable is a list of regular expressions.
175 If it is non-nil, headers that match the regular expressions will
176 be placed first in the article buffer in the sequence specified by
178 :type '(repeat regexp)
179 :group 'gnus-article-hiding)
181 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
182 "Headers that are only to be displayed if they have interesting data.
183 Possible values in this list are:
185 'empty Headers with no content.
186 'newsgroups Newsgroup identical to Gnus group.
187 'to-address To identical to To-address.
188 'to-list To identical to To-list.
189 'cc-list CC identical to To-list.
190 'followup-to Followup-to identical to Newsgroups.
191 'reply-to Reply-to identical to From.
192 'date Date less than four days old.
193 'long-to To and/or Cc longer than 1024 characters.
194 'many-to Multiple To and/or Cc."
195 :type '(set (const :tag "Headers with no content." empty)
196 (const :tag "Newsgroups identical to Gnus group." newsgroups)
197 (const :tag "To identical to To-address." to-address)
198 (const :tag "To identical to To-list." to-list)
199 (const :tag "CC identical to To-list." cc-list)
200 (const :tag "Followup-to identical to Newsgroups." followup-to)
201 (const :tag "Reply-to identical to From." reply-to)
202 (const :tag "Date less than four days old." date)
203 (const :tag "To and/or Cc longer than 1024 characters." long-to)
204 (const :tag "Multiple To and/or Cc headers." many-to))
205 :group 'gnus-article-hiding)
207 (defcustom gnus-article-skip-boring nil
208 "Skip over text that is not worth reading.
209 By default, if you set this t, then Gnus will display citations and
210 signatures, but will never scroll down to show you a page consisting
211 only of boring text. Boring text is controlled by
212 `gnus-article-boring-faces'."
214 :group 'gnus-article-hiding)
216 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
217 "Regexp matching signature separator.
218 This can also be a list of regexps. In that case, it will be checked
219 from head to tail looking for a separator. Searches will be done from
220 the end of the buffer."
221 :type '(repeat string)
222 :group 'gnus-article-signature)
224 (defcustom gnus-signature-limit nil
225 "Provide a limit to what is considered a signature.
226 If it is a number, no signature may not be longer (in characters) than
227 that number. If it is a floating point number, no signature may be
228 longer (in lines) than that number. If it is a function, the function
229 will be called without any parameters, and if it returns nil, there is
230 no signature in the buffer. If it is a string, it will be used as a
231 regexp. If it matches, the text in question is not a signature."
232 :type '(choice (integer :value 200)
234 (function :value fun)
235 (regexp :value ".*"))
236 :group 'gnus-article-signature)
238 (defcustom gnus-hidden-properties '(invisible t intangible t)
239 "Property list to use for hiding text."
241 :group 'gnus-article-hiding)
243 ;; Fixme: This isn't the right thing for mixed graphical and and
244 ;; non-graphical frames in a session.
245 (defcustom gnus-article-x-face-command
246 (if (featurep 'xemacs)
247 (if (or (gnus-image-type-available-p 'xface)
248 (gnus-image-type-available-p 'pbm))
249 'gnus-display-x-face-in-from
250 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
251 (if (gnus-image-type-available-p 'pbm)
252 'gnus-display-x-face-in-from
253 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
255 "*String or function to be executed to display an X-Face header.
256 If it is a string, the command will be executed in a sub-shell
257 asynchronously. The compressed face will be piped to this command."
258 :type `(choice string
259 (function-item gnus-display-x-face-in-from)
263 :group 'gnus-article-washing)
265 (defcustom gnus-article-x-face-too-ugly nil
266 "Regexp matching posters whose face shouldn't be shown automatically."
267 :type '(choice regexp (const nil))
268 :group 'gnus-article-washing)
270 (defcustom gnus-article-banner-alist nil
271 "Banner alist for stripping.
273 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
275 :type '(repeat (cons symbol regexp))
276 :group 'gnus-article-washing)
278 (gnus-define-group-parameter
281 "Alist of regexps (to match group names) and banner."
282 :variable-group gnus-article-washing
284 '(choice :tag "Banner"
286 (const :tag "Remove signature" signature)
287 (symbol :tag "Item in `gnus-article-banner-alist'" none)
289 (const :tag "None" nil))
291 "If non-nil, specify how to remove `banners' from articles.
293 Symbol `signature' means to remove signatures delimited by
294 `gnus-signature-separator'. Any other symbol is used to look up a
295 regular expression to match the banner in `gnus-article-banner-alist'.
296 A string is used as a regular expression to match the banner
299 (defcustom gnus-article-address-banner-alist nil
300 "Alist of mail addresses and banners.
301 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
302 to match a mail address in the From: header, BANNER is one of a symbol
303 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
304 If ADDRESS matches author's mail address, it will remove things like
305 advertisements. For example:
307 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
311 (regexp :tag "Address")
312 (choice :tag "Banner" :value nil
313 (const :tag "Remove signature" signature)
314 (symbol :tag "Item in `gnus-article-banner-alist'" none)
316 (const :tag "None" nil))))
317 :group 'gnus-article-washing)
319 (defcustom gnus-emphasis-alist
321 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
326 ("_/" "/_" underline-italic)
327 ("_\\*" "\\*_" underline-bold)
328 ("\\*/" "/\\*" bold-italic)
329 ("_\\*/" "/\\*_" underline-bold-italic))))
333 (format format (car spec) (cadr spec))
334 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
336 ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
337 2 3 gnus-emphasis-strikethru)
338 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
339 2 3 gnus-emphasis-underline)))
340 "*Alist that says how to fontify certain phrases.
341 Each item looks like this:
343 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
345 The first element is a regular expression to be matched. The second
346 is a number that says what regular expression grouping used to find
347 the entire emphasized word. The third is a number that says what
348 regexp grouping should be displayed and highlighted. The fourth
349 is the face used for highlighting."
350 :type '(repeat (list :value ("" 0 0 default)
352 (integer :tag "Match group")
353 (integer :tag "Emphasize group")
355 :group 'gnus-article-emphasis)
357 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
358 "A regexp to describe whitespace which should not be emphasized.
359 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
360 The former avoids underlining of leading and trailing whitespace,
361 and the latter avoids underlining any whitespace at all."
363 :group 'gnus-article-emphasis
366 (defface gnus-emphasis-bold '((t (:bold t)))
367 "Face used for displaying strong emphasized text (*word*)."
368 :group 'gnus-article-emphasis)
370 (defface gnus-emphasis-italic '((t (:italic t)))
371 "Face used for displaying italic emphasized text (/word/)."
372 :group 'gnus-article-emphasis)
374 (defface gnus-emphasis-underline '((t (:underline t)))
375 "Face used for displaying underlined emphasized text (_word_)."
376 :group 'gnus-article-emphasis)
378 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
379 "Face used for displaying underlined bold emphasized text (_*word*_)."
380 :group 'gnus-article-emphasis)
382 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
383 "Face used for displaying underlined italic emphasized text (_/word/_)."
384 :group 'gnus-article-emphasis)
386 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
387 "Face used for displaying bold italic emphasized text (/*word*/)."
388 :group 'gnus-article-emphasis)
390 (defface gnus-emphasis-underline-bold-italic
391 '((t (:bold t :italic t :underline t)))
392 "Face used for displaying underlined bold italic emphasized text.
393 Example: (_/*word*/_)."
394 :group 'gnus-article-emphasis)
396 (defface gnus-emphasis-strikethru '((t (:strikethru t)))
397 "Face used for displaying strike-through text (-word-)."
398 :group 'gnus-article-emphasis)
400 (defface gnus-emphasis-highlight-words
401 '((t (:background "black" :foreground "yellow")))
402 "Face used for displaying highlighted words."
403 :group 'gnus-article-emphasis)
405 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
406 "Format for display of Date headers in article bodies.
407 See `format-time-string' for the possible values.
409 The variable can also be function, which should return a complete Date
410 header. The function is called with one argument, the time, which can
411 be fed to `format-time-string'."
412 :type '(choice string symbol)
413 :link '(custom-manual "(gnus)Article Date")
414 :group 'gnus-article-washing)
417 (autoload 'mail-extract-address-components "mail-extr"))
419 (defcustom gnus-save-all-headers t
420 "*If non-nil, don't remove any headers before saving."
421 :group 'gnus-article-saving
424 (defcustom gnus-prompt-before-saving 'always
425 "*This variable says how much prompting is to be done when saving articles.
426 If it is nil, no prompting will be done, and the articles will be
427 saved to the default files. If this variable is `always', each and
428 every article that is saved will be preceded by a prompt, even when
429 saving large batches of articles. If this variable is neither nil not
430 `always', there the user will be prompted once for a file name for
431 each invocation of the saving commands."
432 :group 'gnus-article-saving
433 :type '(choice (item always)
434 (item :tag "never" nil)
435 (sexp :tag "once" :format "%t\n" :value t)))
437 (defcustom gnus-saved-headers gnus-visible-headers
438 "Headers to keep if `gnus-save-all-headers' is nil.
439 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
440 If that variable is nil, however, all headers that match this regexp
441 will be kept while the rest will be deleted before saving."
442 :group 'gnus-article-saving
445 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
446 "A function to save articles in your favourite format.
447 The function must be interactively callable (in other words, it must
448 be an Emacs command).
450 Gnus provides the following functions:
452 * gnus-summary-save-in-rmail (Rmail format)
453 * gnus-summary-save-in-mail (Unix mail format)
454 * gnus-summary-save-in-folder (MH folder)
455 * gnus-summary-save-in-file (article format)
456 * gnus-summary-save-body-in-file (article body)
457 * gnus-summary-save-in-vm (use VM's folder format)
458 * gnus-summary-write-to-file (article format -- overwrite)."
459 :group 'gnus-article-saving
460 :type '(radio (function-item gnus-summary-save-in-rmail)
461 (function-item gnus-summary-save-in-mail)
462 (function-item gnus-summary-save-in-folder)
463 (function-item gnus-summary-save-in-file)
464 (function-item gnus-summary-save-body-in-file)
465 (function-item gnus-summary-save-in-vm)
466 (function-item gnus-summary-write-to-file)))
468 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
469 "A function generating a file name to save articles in Rmail format.
470 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
471 :group 'gnus-article-saving
474 (defcustom gnus-mail-save-name 'gnus-plain-save-name
475 "A function generating a file name to save articles in Unix mail format.
476 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
477 :group 'gnus-article-saving
480 (defcustom gnus-folder-save-name 'gnus-folder-save-name
481 "A function generating a file name to save articles in MH folder.
482 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
483 :group 'gnus-article-saving
486 (defcustom gnus-file-save-name 'gnus-numeric-save-name
487 "A function generating a file name to save articles in article format.
488 The function is called with NEWSGROUP, HEADERS, and optional
490 :group 'gnus-article-saving
493 (defcustom gnus-split-methods
494 '((gnus-article-archive-name)
495 (gnus-article-nndoc-name))
496 "*Variable used to suggest where articles are to be saved.
497 For instance, if you would like to save articles related to Gnus in
498 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
499 you could set this variable to something like:
501 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
502 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
504 This variable is an alist where the where the key is the match and the
505 value is a list of possible files to save in if the match is non-nil.
507 If the match is a string, it is used as a regexp match on the
508 article. If the match is a symbol, that symbol will be funcalled
509 from the buffer of the article to be saved with the newsgroup as the
510 parameter. If it is a list, it will be evaled in the same buffer.
512 If this form or function returns a string, this string will be used as
513 a possible file name; and if it returns a non-nil list, that list will
514 be used as possible file names."
515 :group 'gnus-article-saving
516 :type '(repeat (choice (list :value (fun) function)
517 (cons :value ("" "") regexp (repeat string))
520 (defcustom gnus-page-delimiter "^\^L"
521 "*Regexp describing what to use as article page delimiters.
522 The default value is \"^\^L\", which is a form linefeed at the
523 beginning of a line."
525 :group 'gnus-article-various)
527 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
528 "*The format specification for the article mode line.
529 See `gnus-summary-mode-line-format' for a closer description.
531 The following additional specs are available:
533 %w The article washing status.
534 %m The number of MIME parts in the article."
536 :group 'gnus-article-various)
538 (defcustom gnus-article-mode-hook nil
539 "*A hook for Gnus article mode."
541 :group 'gnus-article-various)
543 (when (featurep 'xemacs)
544 ;; Extracted from gnus-xmas-define in order to preserve user settings
545 (when (fboundp 'turn-off-scroll-in-place)
546 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
547 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
548 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
550 (defcustom gnus-article-menu-hook nil
551 "*Hook run after the creation of the article mode menu."
553 :group 'gnus-article-various)
555 (defcustom gnus-article-prepare-hook nil
556 "*A hook called after an article has been prepared in the article buffer."
558 :group 'gnus-article-various)
560 (defvar gnus-article-hide-pgp-hook nil)
561 (make-obsolete-variable 'gnus-article-hide-pgp-hook
562 "This variable is obsolete in Gnus 5.10.")
564 (defcustom gnus-article-button-face 'bold
565 "Face used for highlighting buttons in the article buffer.
567 An article button is a piece of text that you can activate by pressing
568 `RET' or `mouse-2' above it."
570 :group 'gnus-article-buttons)
572 (defcustom gnus-article-mouse-face 'highlight
573 "Face used for mouse highlighting in the article buffer.
575 Article buttons will be displayed in this face when the cursor is
578 :group 'gnus-article-buttons)
580 (defcustom gnus-signature-face 'gnus-signature-face
581 "Face used for highlighting a signature in the article buffer.
582 Obsolete; use the face `gnus-signature-face' for customizations instead."
584 :group 'gnus-article-highlight
585 :group 'gnus-article-signature)
587 (defface gnus-signature-face
590 "Face used for highlighting a signature in the article buffer."
591 :group 'gnus-article-highlight
592 :group 'gnus-article-signature)
594 (defface gnus-header-from-face
597 (:foreground "spring green"))
600 (:foreground "red3"))
603 "Face used for displaying from headers."
604 :group 'gnus-article-headers
605 :group 'gnus-article-highlight)
607 (defface gnus-header-subject-face
610 (:foreground "SeaGreen3"))
613 (:foreground "red4"))
615 (:bold t :italic t)))
616 "Face used for displaying subject headers."
617 :group 'gnus-article-headers
618 :group 'gnus-article-highlight)
620 (defface gnus-header-newsgroups-face
623 (:foreground "yellow" :italic t))
626 (:foreground "MidnightBlue" :italic t))
629 "Face used for displaying newsgroups headers."
630 :group 'gnus-article-headers
631 :group 'gnus-article-highlight)
633 (defface gnus-header-name-face
636 (:foreground "SeaGreen"))
639 (:foreground "maroon"))
642 "Face used for displaying header names."
643 :group 'gnus-article-headers
644 :group 'gnus-article-highlight)
646 (defface gnus-header-content-face
649 (:foreground "forest green" :italic t))
652 (:foreground "indianred4" :italic t))
654 (:italic t))) "Face used for displaying header content."
655 :group 'gnus-article-headers
656 :group 'gnus-article-highlight)
658 (defcustom gnus-header-face-alist
659 '(("From" nil gnus-header-from-face)
660 ("Subject" nil gnus-header-subject-face)
661 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
662 ("" gnus-header-name-face gnus-header-content-face))
663 "*Controls highlighting of article header.
665 An alist of the form (HEADER NAME CONTENT).
667 HEADER is a regular expression which should match the name of an
668 header header and NAME and CONTENT are either face names or nil.
670 The name of each header field will be displayed using the face
671 specified by the first element in the list where HEADER match the
672 header name and NAME is non-nil. Similarly, the content will be
673 displayed by the first non-nil matching CONTENT face."
674 :group 'gnus-article-headers
675 :group 'gnus-article-highlight
676 :type '(repeat (list (regexp :tag "Header")
678 (item :tag "skip" nil)
679 (face :value default))
680 (choice :tag "Content"
681 (item :tag "skip" nil)
682 (face :value default)))))
684 (defcustom gnus-article-decode-hook
685 '(article-decode-charset article-decode-encoded-words
686 article-decode-group-name)
687 "*Hook run to decode charsets in articles."
688 :group 'gnus-article-headers
691 (defcustom gnus-display-mime-function 'gnus-display-mime
692 "Function to display MIME articles."
693 :group 'gnus-article-mime
696 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
697 "Function used to decode headers.")
699 (defvar gnus-article-dumbquotes-map
719 "Table for MS-to-Latin1 translation.")
721 (defcustom gnus-ignored-mime-types nil
722 "List of MIME types that should be ignored by Gnus."
724 :group 'gnus-article-mime
725 :type '(repeat regexp))
727 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
728 "List of MIME types that should not be given buttons when rendered inline.
729 See also `gnus-buttonized-mime-types' which may override this variable.
730 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
732 :group 'gnus-article-mime
733 :type '(repeat regexp))
735 (defcustom gnus-buttonized-mime-types nil
736 "List of MIME types that should be given buttons when rendered inline.
737 If set, this variable overrides `gnus-unbuttonized-mime-types'.
738 To see e.g. security buttons you could set this to
739 `(\"multipart/signed\")'.
740 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
742 :group 'gnus-article-mime
743 :type '(repeat regexp))
745 (defcustom gnus-inhibit-mime-unbuttonizing nil
746 "If non-nil, all MIME parts get buttons.
747 When nil (the default value), then some MIME parts do not get buttons,
748 as described by the variables `gnus-buttonized-mime-types' and
749 `gnus-unbuttonized-mime-types'."
753 (defcustom gnus-body-boundary-delimiter "_"
754 "String used to delimit header and body.
755 This variable is used by `gnus-article-treat-body-boundary' which can
756 be controlled by `gnus-treat-body-boundary'."
757 :group 'gnus-article-various
758 :type '(choice (item :tag "None" :value nil)
761 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
762 "Defines the location of the faces database.
763 For information on obtaining this database of pretty pictures, please
764 see http://www.cs.indiana.edu/picons/ftp/index.html"
765 :type '(repeat directory)
766 :link '(url-link :tag "download"
767 "http://www.cs.indiana.edu/picons/ftp/index.html")
768 :link '(custom-manual "(gnus)Picons")
771 (defun gnus-picons-installed-p ()
772 "Say whether picons are installed on your machine."
773 (let ((installed nil))
774 (dolist (database gnus-picon-databases)
775 (when (file-exists-p database)
779 (defcustom gnus-article-mime-part-function nil
780 "Function called with a MIME handle as the argument.
781 This is meant for people who want to do something automatic based
782 on parts -- for instance, adding Vcard info to a database."
783 :group 'gnus-article-mime
786 (defcustom gnus-mime-multipart-functions nil
787 "An alist of MIME types to functions to display them."
789 :group 'gnus-article-mime
792 (defcustom gnus-article-date-lapsed-new-header nil
793 "Whether the X-Sent and Date headers can coexist.
794 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
795 either replace the old \"Date:\" header (if this variable is nil), or
796 be added below it (otherwise)."
798 :group 'gnus-article-headers
801 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
802 "Function called with a MIME handle as the argument.
803 This is meant for people who want to view first matched part.
804 For `undisplayed-alternative' (default), the first undisplayed
805 part or alternative part is used. For `undisplayed', the first
806 undisplayed part is used. For a function, the first part which
807 the function return t is used. For nil, the first part is
810 :group 'gnus-article-mime
812 (item :tag "first" :value nil)
813 (item :tag "undisplayed" :value undisplayed)
814 (item :tag "undisplayed or alternative"
815 :value undisplayed-alternative)
818 (defcustom gnus-mime-action-alist
819 '(("save to file" . gnus-mime-save-part)
820 ("save and strip" . gnus-mime-save-part-and-strip)
821 ("display as text" . gnus-mime-inline-part)
822 ("view the part" . gnus-mime-view-part)
823 ("pipe to command" . gnus-mime-pipe-part)
824 ("toggle display" . gnus-article-press-button)
825 ("toggle display" . gnus-article-view-part-as-charset)
826 ("view as type" . gnus-mime-view-part-as-type)
827 ("view internally" . gnus-mime-view-part-internally)
828 ("view externally" . gnus-mime-view-part-externally))
829 "An alist of actions that run on the MIME attachment."
830 :group 'gnus-article-mime
831 :type '(repeat (cons (string :tag "name")
835 ;;; The treatment variables
838 (defvar gnus-part-display-hook nil
839 "Hook called on parts that are to receive treatment.")
841 (defvar gnus-article-treat-custom
842 '(choice (const :tag "Off" nil)
844 (const :tag "Header" head)
845 (const :tag "Last" last)
846 (integer :tag "Less")
847 (repeat :tag "Groups" regexp)
848 (sexp :tag "Predicate")))
850 (defvar gnus-article-treat-head-custom
851 '(choice (const :tag "Off" nil)
852 (const :tag "Header" head)))
854 (defvar gnus-article-treat-types '("text/plain")
857 (defvar gnus-inhibit-treatment nil
858 "Whether to inhibit treatment.")
860 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
861 "Highlight the signature.
862 Valid values are nil, t, `head', `last', an integer or a predicate.
863 See Info node `(gnus)Customizing Articles'."
864 :group 'gnus-article-treat
865 :link '(custom-manual "(gnus)Customizing Articles")
866 :type gnus-article-treat-custom)
867 (put 'gnus-treat-highlight-signature 'highlight t)
869 (defcustom gnus-treat-buttonize 100000
871 Valid values are nil, t, `head', `last', an integer or a predicate.
872 See Info node `(gnus)Customizing Articles'."
873 :group 'gnus-article-treat
874 :link '(custom-manual "(gnus)Customizing Articles")
875 :type gnus-article-treat-custom)
876 (put 'gnus-treat-buttonize 'highlight t)
878 (defcustom gnus-treat-buttonize-head 'head
879 "Add buttons to the head.
880 Valid values are nil, t, `head', `last', an integer or a predicate.
881 See Info node `(gnus)Customizing Articles' for details."
882 :group 'gnus-article-treat
883 :link '(custom-manual "(gnus)Customizing Articles")
884 :type gnus-article-treat-head-custom)
885 (put 'gnus-treat-buttonize-head 'highlight t)
887 (defcustom gnus-treat-emphasize
888 (and (or window-system
890 (>= (string-to-number emacs-version) 21))
893 Valid values are nil, t, `head', `last', an integer or a predicate.
894 See Info node `(gnus)Customizing Articles' for details."
895 :group 'gnus-article-treat
896 :link '(custom-manual "(gnus)Customizing Articles")
897 :type gnus-article-treat-custom)
898 (put 'gnus-treat-emphasize 'highlight t)
900 (defcustom gnus-treat-strip-cr nil
901 "Remove carriage returns.
902 Valid values are nil, t, `head', `last', an integer or a predicate.
903 See Info node `(gnus)Customizing Articles' for details."
904 :group 'gnus-article-treat
905 :link '(custom-manual "(gnus)Customizing Articles")
906 :type gnus-article-treat-custom)
908 (defcustom gnus-treat-unsplit-urls nil
909 "Remove newlines from within URLs.
910 Valid values are nil, t, `head', `last', an integer or a predicate.
911 See Info node `(gnus)Customizing Articles' for details."
912 :group 'gnus-article-treat
913 :link '(custom-manual "(gnus)Customizing Articles")
914 :type gnus-article-treat-custom)
916 (defcustom gnus-treat-leading-whitespace nil
917 "Remove leading whitespace in headers.
918 Valid values are nil, t, `head', `last', an integer or a predicate.
919 See Info node `(gnus)Customizing Articles' for details."
920 :group 'gnus-article-treat
921 :link '(custom-manual "(gnus)Customizing Articles")
922 :type gnus-article-treat-custom)
924 (defcustom gnus-treat-hide-headers 'head
926 Valid values are nil, t, `head', `last', an integer or a predicate.
927 See Info node `(gnus)Customizing Articles' for details."
928 :group 'gnus-article-treat
929 :link '(custom-manual "(gnus)Customizing Articles")
930 :type gnus-article-treat-head-custom)
932 (defcustom gnus-treat-hide-boring-headers nil
933 "Hide boring headers.
934 Valid values are nil, t, `head', `last', an integer or a predicate.
935 See Info node `(gnus)Customizing Articles' for details."
936 :group 'gnus-article-treat
937 :link '(custom-manual "(gnus)Customizing Articles")
938 :type gnus-article-treat-head-custom)
940 (defcustom gnus-treat-hide-signature nil
942 Valid values are nil, t, `head', `last', an integer or a predicate.
943 See Info node `(gnus)Customizing Articles' for details."
944 :group 'gnus-article-treat
945 :link '(custom-manual "(gnus)Customizing Articles")
946 :type gnus-article-treat-custom)
948 (defcustom gnus-treat-fill-article nil
950 Valid values are nil, t, `head', `last', an integer or a predicate.
951 See Info node `(gnus)Customizing Articles' for details."
952 :group 'gnus-article-treat
953 :link '(custom-manual "(gnus)Customizing Articles")
954 :type gnus-article-treat-custom)
956 (defcustom gnus-treat-hide-citation nil
958 Valid values are nil, t, `head', `last', an integer or a predicate.
959 See Info node `(gnus)Customizing Articles' for details."
960 :group 'gnus-article-treat
961 :link '(custom-manual "(gnus)Customizing Articles")
962 :type gnus-article-treat-custom)
964 (defcustom gnus-treat-hide-citation-maybe nil
966 Valid values are nil, t, `head', `last', an integer or a predicate.
967 See Info node `(gnus)Customizing Articles' for details."
968 :group 'gnus-article-treat
969 :link '(custom-manual "(gnus)Customizing Articles")
970 :type gnus-article-treat-custom)
972 (defcustom gnus-treat-strip-list-identifiers 'head
973 "Strip list identifiers from `gnus-list-identifiers`.
974 Valid values are nil, t, `head', `last', an integer or a predicate.
975 See Info node `(gnus)Customizing Articles' for details."
977 :group 'gnus-article-treat
978 :link '(custom-manual "(gnus)Customizing Articles")
979 :type gnus-article-treat-custom)
981 (make-obsolete-variable 'gnus-treat-strip-pgp
982 "This option is obsolete in Gnus 5.10.")
984 (defcustom gnus-treat-strip-pem nil
985 "Strip PEM signatures.
986 Valid values are nil, t, `head', `last', an integer or a predicate.
987 See Info node `(gnus)Customizing Articles' for details."
988 :group 'gnus-article-treat
989 :link '(custom-manual "(gnus)Customizing Articles")
990 :type gnus-article-treat-custom)
992 (defcustom gnus-treat-strip-banner t
993 "Strip banners from articles.
994 The banner to be stripped is specified in the `banner' group parameter.
995 Valid values are nil, t, `head', `last', an integer or a predicate.
996 See Info node `(gnus)Customizing Articles' for details."
997 :group 'gnus-article-treat
998 :link '(custom-manual "(gnus)Customizing Articles")
999 :type gnus-article-treat-custom)
1001 (defcustom gnus-treat-highlight-headers 'head
1002 "Highlight the headers.
1003 Valid values are nil, t, `head', `last', an integer or a predicate.
1004 See Info node `(gnus)Customizing Articles' for details."
1005 :group 'gnus-article-treat
1006 :link '(custom-manual "(gnus)Customizing Articles")
1007 :type gnus-article-treat-head-custom)
1008 (put 'gnus-treat-highlight-headers 'highlight t)
1010 (defcustom gnus-treat-highlight-citation t
1011 "Highlight cited text.
1012 Valid values are nil, t, `head', `last', an integer or a predicate.
1013 See Info node `(gnus)Customizing Articles' for details."
1014 :group 'gnus-article-treat
1015 :link '(custom-manual "(gnus)Customizing Articles")
1016 :type gnus-article-treat-custom)
1017 (put 'gnus-treat-highlight-citation 'highlight t)
1019 (defcustom gnus-treat-date-ut nil
1020 "Display the Date in UT (GMT).
1021 Valid values are nil, t, `head', `last', an integer or a predicate.
1022 See Info node `(gnus)Customizing Articles' for details."
1023 :group 'gnus-article-treat
1024 :link '(custom-manual "(gnus)Customizing Articles")
1025 :type gnus-article-treat-head-custom)
1027 (defcustom gnus-treat-date-local nil
1028 "Display the Date in the local timezone.
1029 Valid values are nil, t, `head', `last', an integer or a predicate.
1030 See Info node `(gnus)Customizing Articles' for details."
1031 :group 'gnus-article-treat
1032 :link '(custom-manual "(gnus)Customizing Articles")
1033 :type gnus-article-treat-head-custom)
1035 (defcustom gnus-treat-date-english nil
1036 "Display the Date in a format that can be read aloud in English.
1037 Valid values are nil, t, `head', `last', an integer or a predicate.
1038 See Info node `(gnus)Customizing Articles' for details."
1039 :group 'gnus-article-treat
1040 :link '(custom-manual "(gnus)Customizing Articles")
1041 :type gnus-article-treat-head-custom)
1043 (defcustom gnus-treat-date-lapsed nil
1044 "Display the Date header in a way that says how much time has elapsed.
1045 Valid values are nil, t, `head', `last', an integer or a predicate.
1046 See Info node `(gnus)Customizing Articles' for details."
1047 :group 'gnus-article-treat
1048 :link '(custom-manual "(gnus)Customizing Articles")
1049 :type gnus-article-treat-head-custom)
1051 (defcustom gnus-treat-date-original nil
1052 "Display the date in the original timezone.
1053 Valid values are nil, t, `head', `last', an integer or a predicate.
1054 See Info node `(gnus)Customizing Articles' for details."
1055 :group 'gnus-article-treat
1056 :link '(custom-manual "(gnus)Customizing Articles")
1057 :type gnus-article-treat-head-custom)
1059 (defcustom gnus-treat-date-iso8601 nil
1060 "Display the date in the ISO8601 format.
1061 Valid values are nil, t, `head', `last', an integer or a predicate.
1062 See Info node `(gnus)Customizing Articles' for details."
1064 :group 'gnus-article-treat
1065 :link '(custom-manual "(gnus)Customizing Articles")
1066 :type gnus-article-treat-head-custom)
1068 (defcustom gnus-treat-date-user-defined nil
1069 "Display the date in a user-defined format.
1070 The format is defined by the `gnus-article-time-format' variable.
1071 Valid values are nil, t, `head', `last', an integer or a predicate.
1072 See Info node `(gnus)Customizing Articles' for details."
1073 :group 'gnus-article-treat
1074 :link '(custom-manual "(gnus)Customizing Articles")
1075 :type gnus-article-treat-head-custom)
1077 (defcustom gnus-treat-strip-headers-in-body t
1078 "Strip the X-No-Archive header line from the beginning of the body.
1079 Valid values are nil, t, `head', `last', an integer or a predicate.
1080 See Info node `(gnus)Customizing Articles' for details."
1082 :group 'gnus-article-treat
1083 :link '(custom-manual "(gnus)Customizing Articles")
1084 :type gnus-article-treat-custom)
1086 (defcustom gnus-treat-strip-trailing-blank-lines nil
1087 "Strip trailing blank lines.
1088 Valid values are nil, t, `head', `last', an integer or a predicate.
1089 See Info node `(gnus)Customizing Articles' for details."
1090 :group 'gnus-article-treat
1091 :link '(custom-manual "(gnus)Customizing Articles")
1092 :type gnus-article-treat-custom)
1094 (defcustom gnus-treat-strip-leading-blank-lines nil
1095 "Strip leading blank lines.
1096 Valid values are nil, t, `head', `last', an integer or a predicate.
1097 See Info node `(gnus)Customizing Articles' for details."
1098 :group 'gnus-article-treat
1099 :link '(custom-manual "(gnus)Customizing Articles")
1100 :type gnus-article-treat-custom)
1102 (defcustom gnus-treat-strip-multiple-blank-lines nil
1103 "Strip multiple blank lines.
1104 Valid values are nil, t, `head', `last', an integer or a predicate.
1105 See Info node `(gnus)Customizing Articles' for details."
1106 :group 'gnus-article-treat
1107 :link '(custom-manual "(gnus)Customizing Articles")
1108 :type gnus-article-treat-custom)
1110 (defcustom gnus-treat-unfold-headers 'head
1111 "Unfold folded header lines.
1112 Valid values are nil, t, `head', `last', an integer or a predicate.
1113 See Info node `(gnus)Customizing Articles' for details."
1114 :group 'gnus-article-treat
1115 :link '(custom-manual "(gnus)Customizing Articles")
1116 :type gnus-article-treat-custom)
1118 (defcustom gnus-treat-fold-headers nil
1120 Valid values are nil, t, `head', `last', an integer or a predicate.
1121 See Info node `(gnus)Customizing Articles' for details."
1122 :group 'gnus-article-treat
1123 :link '(custom-manual "(gnus)Customizing Articles")
1124 :type gnus-article-treat-custom)
1126 (defcustom gnus-treat-fold-newsgroups 'head
1127 "Fold the Newsgroups and Followup-To headers.
1128 Valid values are nil, t, `head', `last', an integer or a predicate.
1129 See Info node `(gnus)Customizing Articles' for details."
1130 :group 'gnus-article-treat
1131 :link '(custom-manual "(gnus)Customizing Articles")
1132 :type gnus-article-treat-custom)
1134 (defcustom gnus-treat-overstrike t
1135 "Treat overstrike highlighting.
1136 Valid values are nil, t, `head', `last', an integer or a predicate.
1137 See Info node `(gnus)Customizing Articles' for details."
1138 :group 'gnus-article-treat
1139 :link '(custom-manual "(gnus)Customizing Articles")
1140 :type gnus-article-treat-custom)
1141 (put 'gnus-treat-overstrike 'highlight t)
1143 (defcustom gnus-treat-display-xface
1144 (and (not noninteractive)
1145 (or (and (fboundp 'image-type-available-p)
1146 (image-type-available-p 'xbm)
1147 (string-match "^0x" (shell-command-to-string "uncompface")))
1148 (and (featurep 'xemacs)
1151 "Display X-Face headers.
1152 Valid values are nil, t, `head', `last', an integer or a predicate.
1153 See Info node `(gnus)Customizing Articles' and Info node
1154 `(gnus)X-Face' for details."
1155 :group 'gnus-article-treat
1157 :link '(custom-manual "(gnus)Customizing Articles")
1158 :link '(custom-manual "(gnus)X-Face")
1159 :type gnus-article-treat-head-custom)
1160 (put 'gnus-treat-display-xface 'highlight t)
1162 (defcustom gnus-treat-display-face
1163 (and (not noninteractive)
1164 (or (and (fboundp 'image-type-available-p)
1165 (image-type-available-p 'png))
1166 (and (featurep 'xemacs)
1169 "Display Face headers.
1170 Valid values are nil, t, `head', `last', an integer or a predicate.
1171 See Info node `(gnus)Customizing Articles' and Info node
1172 `(gnus)X-Face' for details."
1173 :group 'gnus-article-treat
1175 :link '(custom-manual "(gnus)Customizing Articles")
1176 :link '(custom-manual "(gnus)X-Face")
1177 :type gnus-article-treat-head-custom)
1178 (put 'gnus-treat-display-xface 'highlight t)
1180 (defcustom gnus-treat-display-smileys
1181 (if (or (and (featurep 'xemacs)
1183 (and (fboundp 'image-type-available-p)
1184 (image-type-available-p 'pbm)))
1187 Valid values are nil, t, `head', `last', an integer or a predicate.
1188 See Info node `(gnus)Customizing Articles' and Info node
1189 `(gnus)Smileys' for details."
1190 :group 'gnus-article-treat
1192 :link '(custom-manual "(gnus)Customizing Articles")
1193 :link '(custom-manual "(gnus)Smileys")
1194 :type gnus-article-treat-custom)
1195 (put 'gnus-treat-display-smileys 'highlight t)
1197 (defcustom gnus-treat-from-picon
1198 (if (and (gnus-image-type-available-p 'xpm)
1199 (gnus-picons-installed-p))
1201 "Display picons in the From header.
1202 Valid values are nil, t, `head', `last', an integer or a predicate.
1203 See Info node `(gnus)Customizing Articles' and Info node
1204 `(gnus)Picons' for details."
1205 :group 'gnus-article-treat
1207 :link '(custom-manual "(gnus)Customizing Articles")
1208 :link '(custom-manual "(gnus)Picons")
1209 :type gnus-article-treat-head-custom)
1210 (put 'gnus-treat-from-picon 'highlight t)
1212 (defcustom gnus-treat-mail-picon
1213 (if (and (gnus-image-type-available-p 'xpm)
1214 (gnus-picons-installed-p))
1216 "Display picons in To and Cc headers.
1217 Valid values are nil, t, `head', `last', an integer or a predicate.
1218 See Info node `(gnus)Customizing Articles' and Info node
1219 `(gnus)Picons' for details."
1220 :group 'gnus-article-treat
1222 :link '(custom-manual "(gnus)Customizing Articles")
1223 :link '(custom-manual "(gnus)Picons")
1224 :type gnus-article-treat-head-custom)
1225 (put 'gnus-treat-mail-picon 'highlight t)
1227 (defcustom gnus-treat-newsgroups-picon
1228 (if (and (gnus-image-type-available-p 'xpm)
1229 (gnus-picons-installed-p))
1231 "Display picons in the Newsgroups and Followup-To headers.
1232 Valid values are nil, t, `head', `last', an integer or a predicate.
1233 See Info node `(gnus)Customizing Articles' and Info node
1234 `(gnus)Picons' for details."
1235 :group 'gnus-article-treat
1237 :link '(custom-manual "(gnus)Customizing Articles")
1238 :link '(custom-manual "(gnus)Picons")
1239 :type gnus-article-treat-head-custom)
1240 (put 'gnus-treat-newsgroups-picon 'highlight t)
1242 (defcustom gnus-treat-body-boundary
1243 (if (or gnus-treat-newsgroups-picon
1244 gnus-treat-mail-picon
1245 gnus-treat-from-picon)
1247 "Draw a boundary at the end of the headers.
1248 Valid values are nil, t, `head', `last', an integer or a predicate.
1249 See Info node `(gnus)Customizing Articles' for details."
1251 :group 'gnus-article-treat
1252 :link '(custom-manual "(gnus)Customizing Articles")
1253 :type gnus-article-treat-custom)
1255 (defcustom gnus-treat-capitalize-sentences nil
1256 "Capitalize sentence-starting words.
1257 Valid values are nil, t, `head', `last', an integer or a predicate.
1258 See Info node `(gnus)Customizing Articles' for details."
1260 :group 'gnus-article-treat
1261 :link '(custom-manual "(gnus)Customizing Articles")
1262 :type gnus-article-treat-custom)
1264 (defcustom gnus-treat-wash-html nil
1266 Valid values are nil, t, `head', `last', an integer or a predicate.
1267 See Info node `(gnus)Customizing Articles' for details."
1268 :group 'gnus-article-treat
1269 :link '(custom-manual "(gnus)Customizing Articles")
1270 :type gnus-article-treat-custom)
1272 (defcustom gnus-treat-fill-long-lines nil
1274 Valid values are nil, t, `head', `last', an integer or a predicate.
1275 See Info node `(gnus)Customizing Articles' for details."
1276 :group 'gnus-article-treat
1277 :link '(custom-manual "(gnus)Customizing Articles")
1278 :type gnus-article-treat-custom)
1280 (defcustom gnus-treat-play-sounds nil
1282 Valid values are nil, t, `head', `last', an integer or a predicate.
1283 See Info node `(gnus)Customizing Articles' for details."
1285 :group 'gnus-article-treat
1286 :link '(custom-manual "(gnus)Customizing Articles")
1287 :type gnus-article-treat-custom)
1289 (defcustom gnus-treat-translate nil
1290 "Translate articles from one language to another.
1291 Valid values are nil, t, `head', `last', an integer or a predicate.
1292 See Info node `(gnus)Customizing Articles' for details."
1294 :group 'gnus-article-treat
1295 :link '(custom-manual "(gnus)Customizing Articles")
1296 :type gnus-article-treat-custom)
1298 (defcustom gnus-treat-x-pgp-sig nil
1300 To automatically treat X-PGP-Sig, set it to head.
1301 Valid values are nil, t, `head', `last', an integer or a predicate.
1302 See Info node `(gnus)Customizing Articles' for details."
1303 :group 'gnus-article-treat
1304 :group 'mime-security
1305 :link '(custom-manual "(gnus)Customizing Articles")
1306 :type gnus-article-treat-custom)
1308 (defvar gnus-article-encrypt-protocol-alist
1309 '(("PGP" . mml2015-self-encrypt)))
1311 ;; Set to nil if more than one protocol added to
1312 ;; gnus-article-encrypt-protocol-alist.
1313 (defcustom gnus-article-encrypt-protocol "PGP"
1314 "The protocol used for encrypt articles.
1315 It is a string, such as \"PGP\". If nil, ask user."
1317 :group 'mime-security)
1319 (defvar gnus-article-wash-function nil
1320 "Function used for converting HTML into text.")
1322 ;;; Internal variables
1324 (defvar gnus-english-month-names
1325 '("January" "February" "March" "April" "May" "June" "July" "August"
1326 "September" "October" "November" "December"))
1328 (defvar article-goto-body-goes-to-point-min-p nil)
1329 (defvar gnus-article-wash-types nil)
1330 (defvar gnus-article-emphasis-alist nil)
1331 (defvar gnus-article-image-alist nil)
1333 (defvar gnus-article-mime-handle-alist-1 nil)
1334 (defvar gnus-treatment-function-alist
1335 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1336 (gnus-treat-strip-banner gnus-article-strip-banner)
1337 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1338 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1339 (gnus-treat-buttonize gnus-article-add-buttons)
1340 (gnus-treat-fill-article gnus-article-fill-cited-article)
1341 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1342 (gnus-treat-strip-cr gnus-article-remove-cr)
1343 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1344 (gnus-treat-date-ut gnus-article-date-ut)
1345 (gnus-treat-date-local gnus-article-date-local)
1346 (gnus-treat-date-english gnus-article-date-english)
1347 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1348 (gnus-treat-date-original gnus-article-date-original)
1349 (gnus-treat-date-user-defined gnus-article-date-user)
1350 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1351 (gnus-treat-display-xface gnus-article-display-x-face)
1352 (gnus-treat-display-face gnus-article-display-face)
1353 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1354 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1355 (gnus-treat-hide-signature gnus-article-hide-signature)
1356 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1357 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1358 (gnus-treat-strip-pem gnus-article-hide-pem)
1359 (gnus-treat-from-picon gnus-treat-from-picon)
1360 (gnus-treat-mail-picon gnus-treat-mail-picon)
1361 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1362 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1363 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1364 (gnus-treat-strip-trailing-blank-lines
1365 gnus-article-remove-trailing-blank-lines)
1366 (gnus-treat-strip-leading-blank-lines
1367 gnus-article-strip-leading-blank-lines)
1368 (gnus-treat-strip-multiple-blank-lines
1369 gnus-article-strip-multiple-blank-lines)
1370 (gnus-treat-overstrike gnus-article-treat-overstrike)
1371 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1372 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1373 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1374 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1375 (gnus-treat-display-smileys gnus-treat-smiley)
1376 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1377 (gnus-treat-wash-html gnus-article-wash-html)
1378 (gnus-treat-emphasize gnus-article-emphasize)
1379 (gnus-treat-hide-citation gnus-article-hide-citation)
1380 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1381 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1382 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1383 (gnus-treat-play-sounds gnus-earcon-display)))
1385 (defvar gnus-article-mime-handle-alist nil)
1386 (defvar article-lapsed-timer nil)
1387 (defvar gnus-article-current-summary nil)
1389 (defvar gnus-article-mode-syntax-table
1390 (let ((table (copy-syntax-table text-mode-syntax-table)))
1391 ;; This causes the citation match run O(2^n).
1392 ;; (modify-syntax-entry ?- "w" table)
1393 (modify-syntax-entry ?> ")<" table)
1394 (modify-syntax-entry ?< "(>" table)
1395 ;; make M-. in article buffers work for `foo' strings
1396 (modify-syntax-entry ?' " " table)
1397 (modify-syntax-entry ?` " " table)
1399 "Syntax table used in article mode buffers.
1400 Initialized from `text-mode-syntax-table.")
1402 (defvar gnus-save-article-buffer nil)
1404 (defvar gnus-article-mode-line-format-alist
1405 (nconc '((?w (gnus-article-wash-status) ?s)
1406 (?m (gnus-article-mime-part-status) ?s))
1407 gnus-summary-mode-line-format-alist))
1409 (defvar gnus-number-of-articles-to-be-saved nil)
1411 (defvar gnus-inhibit-hiding nil)
1413 ;;; Macros for dealing with the article buffer.
1415 (defmacro gnus-with-article-headers (&rest forms)
1417 (set-buffer gnus-article-buffer)
1419 (let ((buffer-read-only nil)
1420 (inhibit-point-motion-hooks t)
1421 (case-fold-search t))
1422 (article-narrow-to-head)
1425 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1426 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1428 (defmacro gnus-with-article-buffer (&rest forms)
1430 (set-buffer gnus-article-buffer)
1431 (let ((buffer-read-only nil))
1434 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1435 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1437 (defun gnus-article-goto-header (header)
1438 "Go to HEADER, which is a regular expression."
1439 (re-search-forward (concat "^\\(" header "\\):") nil t))
1441 (defsubst gnus-article-hide-text (b e props)
1442 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1443 (gnus-add-text-properties-when 'article-type nil b e props)
1444 (when (memq 'intangible props)
1446 (max (1- b) (point-min))
1447 b 'intangible (cddr (memq 'intangible props)))))
1449 (defsubst gnus-article-unhide-text (b e)
1450 "Remove hidden text properties from region between B and E."
1451 (remove-text-properties b e gnus-hidden-properties)
1452 (when (memq 'intangible gnus-hidden-properties)
1453 (put-text-property (max (1- b) (point-min))
1454 b 'intangible nil)))
1456 (defun gnus-article-hide-text-type (b e type)
1457 "Hide text of TYPE between B and E."
1458 (gnus-add-wash-type type)
1459 (gnus-article-hide-text
1460 b e (cons 'article-type (cons type gnus-hidden-properties))))
1462 (defun gnus-article-unhide-text-type (b e type)
1463 "Unhide text of TYPE between B and E."
1464 (gnus-delete-wash-type type)
1465 (remove-text-properties
1466 b e (cons 'article-type (cons type gnus-hidden-properties)))
1467 (when (memq 'intangible gnus-hidden-properties)
1468 (put-text-property (max (1- b) (point-min))
1469 b 'intangible nil)))
1471 (defun gnus-article-hide-text-of-type (type)
1472 "Hide text of TYPE in the current buffer."
1474 (let ((b (point-min))
1476 (while (setq b (text-property-any b e 'article-type type))
1477 (add-text-properties b (incf b) gnus-hidden-properties)))))
1479 (defun gnus-article-delete-text-of-type (type)
1480 "Delete text of TYPE in the current buffer."
1482 (let ((b (point-min)))
1483 (while (setq b (text-property-any b (point-max) 'article-type type))
1485 b (or (text-property-not-all b (point-max) 'article-type type)
1488 (defun gnus-article-delete-invisible-text ()
1489 "Delete all invisible text in the current buffer."
1491 (let ((b (point-min)))
1492 (while (setq b (text-property-any b (point-max) 'invisible t))
1494 b (or (text-property-not-all b (point-max) 'invisible t)
1497 (defun gnus-article-text-type-exists-p (type)
1498 "Say whether any text of type TYPE exists in the buffer."
1499 (text-property-any (point-min) (point-max) 'article-type type))
1501 (defsubst gnus-article-header-rank ()
1502 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1503 (let ((list gnus-sorted-header-list)
1506 (if (looking-at (car list))
1508 (setq list (cdr list))
1512 (defun article-hide-headers (&optional arg delete)
1513 "Hide unwanted headers and possibly sort them as well."
1515 ;; This function might be inhibited.
1516 (unless gnus-inhibit-hiding
1519 (let ((buffer-read-only nil)
1520 (case-fold-search t)
1521 (max (1+ (length gnus-sorted-header-list)))
1522 (ignored (when (not gnus-visible-headers)
1523 (cond ((stringp gnus-ignored-headers)
1524 gnus-ignored-headers)
1525 ((listp gnus-ignored-headers)
1526 (mapconcat 'identity gnus-ignored-headers
1529 (cond ((stringp gnus-visible-headers)
1530 gnus-visible-headers)
1531 ((and gnus-visible-headers
1532 (listp gnus-visible-headers))
1533 (mapconcat 'identity gnus-visible-headers "\\|"))))
1534 (inhibit-point-motion-hooks t)
1536 ;; First we narrow to just the headers.
1537 (article-narrow-to-head)
1538 ;; Hide any "From " lines at the beginning of (mail) articles.
1539 (while (looking-at "From ")
1542 (delete-region (point-min) (point)))
1543 ;; Then treat the rest of the header lines.
1544 ;; Then we use the two regular expressions
1545 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1546 ;; select which header lines is to remain visible in the
1548 (while (re-search-forward "^[^ \t:]*:" nil t)
1550 ;; Mark the rank of the header.
1552 (point) (1+ (point)) 'message-rank
1553 (if (or (and visible (looking-at visible))
1555 (not (looking-at ignored))))
1556 (gnus-article-header-rank)
1559 (message-sort-headers-1)
1560 (when (setq beg (text-property-any
1561 (point-min) (point-max) 'message-rank (+ 2 max)))
1562 ;; We delete the unwanted headers.
1563 (gnus-add-wash-type 'headers)
1564 (add-text-properties (point-min) (+ 5 (point-min))
1565 '(article-type headers dummy-invisible t))
1566 (delete-region beg (point-max))))))))
1568 (defun article-hide-boring-headers (&optional arg)
1569 "Toggle hiding of headers that aren't very interesting.
1570 If given a negative prefix, always show; if given a positive prefix,
1572 (interactive (gnus-article-hidden-arg))
1573 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1574 (not gnus-show-all-headers))
1577 (let ((buffer-read-only nil)
1578 (list gnus-boring-article-headers)
1579 (inhibit-point-motion-hooks t)
1581 (article-narrow-to-head)
1583 (setq elem (pop list))
1584 (goto-char (point-min))
1586 ;; Hide empty headers.
1588 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1590 (gnus-article-hide-text-type
1591 (progn (beginning-of-line) (point))
1594 (if (re-search-forward "^[^ \t]" nil t)
1598 ;; Hide boring Newsgroups header.
1599 ((eq elem 'newsgroups)
1600 (when (gnus-string-equal
1601 (gnus-fetch-field "newsgroups")
1602 (gnus-group-real-name
1603 (if (boundp 'gnus-newsgroup-name)
1606 (gnus-article-hide-header "newsgroups")))
1607 ((eq elem 'to-address)
1608 (let ((to (message-fetch-field "to"))
1610 (gnus-parameter-to-address
1611 (if (boundp 'gnus-newsgroup-name)
1612 gnus-newsgroup-name ""))))
1613 (when (and to to-address
1616 ;; only one address in To
1617 (nth 1 (mail-extract-address-components to))
1619 (gnus-article-hide-header "to"))))
1621 (let ((to (message-fetch-field "to"))
1623 (gnus-parameter-to-list
1624 (if (boundp 'gnus-newsgroup-name)
1625 gnus-newsgroup-name ""))))
1626 (when (and to to-list
1629 ;; only one address in To
1630 (nth 1 (mail-extract-address-components to))
1632 (gnus-article-hide-header "to"))))
1634 (let ((cc (message-fetch-field "cc"))
1636 (gnus-parameter-to-list
1637 (if (boundp 'gnus-newsgroup-name)
1638 gnus-newsgroup-name ""))))
1639 (when (and cc to-list
1642 ;; only one address in CC
1643 (nth 1 (mail-extract-address-components cc))
1645 (gnus-article-hide-header "cc"))))
1646 ((eq elem 'followup-to)
1647 (when (gnus-string-equal
1648 (message-fetch-field "followup-to")
1649 (message-fetch-field "newsgroups"))
1650 (gnus-article-hide-header "followup-to")))
1651 ((eq elem 'reply-to)
1652 (let ((from (message-fetch-field "from"))
1653 (reply-to (message-fetch-field "reply-to")))
1658 (nth 1 (mail-extract-address-components from))
1659 (nth 1 (mail-extract-address-components reply-to)))))
1660 (gnus-article-hide-header "reply-to"))))
1662 (let ((date (message-fetch-field "date")))
1664 (< (days-between (current-time-string) date)
1666 (gnus-article-hide-header "date"))))
1668 (let ((to (message-fetch-field "to"))
1669 (cc (message-fetch-field "cc")))
1670 (when (> (length to) 1024)
1671 (gnus-article-hide-header "to"))
1672 (when (> (length cc) 1024)
1673 (gnus-article-hide-header "cc"))))
1677 (goto-char (point-min))
1678 (while (re-search-forward "^to:" nil t)
1679 (setq to-count (1+ to-count)))
1680 (when (> to-count 1)
1681 (while (> to-count 0)
1682 (goto-char (point-min))
1684 (re-search-forward "^to:" nil nil to-count)
1686 (narrow-to-region (point) (point-max))
1687 (gnus-article-hide-header "to"))
1688 (setq to-count (1- to-count))))
1689 (goto-char (point-min))
1690 (while (re-search-forward "^cc:" nil t)
1691 (setq cc-count (1+ cc-count)))
1692 (when (> cc-count 1)
1693 (while (> cc-count 0)
1694 (goto-char (point-min))
1696 (re-search-forward "^cc:" nil nil cc-count)
1698 (narrow-to-region (point) (point-max))
1699 (gnus-article-hide-header "cc"))
1700 (setq cc-count (1- cc-count)))))))))))))
1702 (defun gnus-article-hide-header (header)
1704 (goto-char (point-min))
1705 (when (re-search-forward (concat "^" header ":") nil t)
1706 (gnus-article-hide-text-type
1707 (progn (beginning-of-line) (point))
1710 (if (re-search-forward "^[^ \t]" nil t)
1715 (defvar gnus-article-normalized-header-length 40
1716 "Length of normalized headers.")
1718 (defun article-normalize-headers ()
1719 "Make all header lines 40 characters long."
1721 (let ((buffer-read-only nil)
1725 (article-narrow-to-head)
1728 ((< (setq column (- (gnus-point-at-eol) (point)))
1729 gnus-article-normalized-header-length)
1731 (insert (make-string
1732 (- gnus-article-normalized-header-length column)
1734 ((> column gnus-article-normalized-header-length)
1735 (gnus-put-text-property
1737 (forward-char gnus-article-normalized-header-length)
1744 (forward-line 1))))))
1746 (defun article-treat-dumbquotes ()
1747 "Translate M****s*** sm*rtq**t*s into proper text.
1748 Note that this function guesses whether a character is a sm*rtq**t* or
1749 not, so it should only be used interactively.
1751 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1752 in an attempt to provide more quoting characters. If you see
1753 something like \\222 or \\264 where you're expecting some kind of
1754 apostrophe or quotation mark, then try this wash."
1756 (article-translate-strings gnus-article-dumbquotes-map))
1758 (defun article-translate-characters (from to)
1759 "Translate all characters in the body of the article according to FROM and TO.
1760 FROM is a string of characters to translate from; to is a string of
1761 characters to translate to."
1763 (when (article-goto-body)
1764 (let ((buffer-read-only nil)
1765 (x (make-string 225 ?x))
1767 (while (< (incf i) (length x))
1770 (while (< i (length from))
1771 (aset x (aref from i) (aref to i))
1773 (translate-region (point) (point-max) x)))))
1775 (defun article-translate-strings (map)
1776 "Translate all string in the body of the article according to MAP.
1777 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1779 (when (article-goto-body)
1780 (let ((buffer-read-only nil)
1782 (while (setq elem (pop map))
1784 (while (search-forward (car elem) nil t)
1785 (replace-match (cadr elem)))))))))
1787 (defun article-treat-overstrike ()
1788 "Translate overstrikes into bold text."
1791 (when (article-goto-body)
1792 (let ((buffer-read-only nil))
1793 (while (search-forward "\b" nil t)
1794 (let ((next (char-after))
1795 (previous (char-after (- (point) 2))))
1796 ;; We do the boldification/underlining by hiding the
1797 ;; overstrikes and putting the proper text property
1801 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1802 (put-text-property (point) (1+ (point)) 'face 'bold))
1804 (gnus-article-hide-text-type
1805 (1- (point)) (1+ (point)) 'overstrike)
1807 (- (point) 2) (1- (point)) 'face 'underline))
1809 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1811 (point) (1+ (point)) 'face 'underline)))))))))
1813 (defun gnus-article-treat-unfold-headers ()
1814 "Unfold folded message headers.
1815 Only the headers that fit into the current window width will be
1818 (gnus-with-article-headers
1822 (mail-header-narrow-to-field)
1823 (let ((header (buffer-substring (point-min) (point-max))))
1826 (goto-char (point-min))
1827 (while (re-search-forward "\n[\t ]" nil t)
1828 (replace-match " " t t)))
1829 (setq length (- (point-max) (point-min) 1)))
1830 (when (< length (window-width))
1831 (while (re-search-forward "\n[\t ]" nil t)
1832 (replace-match " " t t)))
1833 (goto-char (point-max)))))))
1835 (defun gnus-article-treat-fold-headers ()
1836 "Fold message headers."
1838 (gnus-with-article-headers
1841 (mail-header-narrow-to-field)
1842 (mail-header-fold-field)
1843 (goto-char (point-max))))))
1845 (defun gnus-treat-smiley ()
1846 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1848 (gnus-with-article-buffer
1849 (if (memq 'smiley gnus-article-wash-types)
1850 (gnus-delete-images 'smiley)
1852 (let ((images (smiley-region (point) (point-max))))
1854 (gnus-add-wash-type 'smiley)
1855 (dolist (image images)
1856 (gnus-add-image 'smiley image)))))))
1858 (defun gnus-article-remove-images ()
1859 "Remove all images from the article buffer."
1861 (gnus-with-article-buffer
1862 (dolist (elem gnus-article-image-alist)
1863 (gnus-delete-images (car elem)))))
1865 (defun gnus-article-treat-fold-newsgroups ()
1866 "Unfold folded message headers.
1867 Only the headers that fit into the current window width will be
1870 (gnus-with-article-headers
1871 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1873 (mail-header-narrow-to-field)
1874 (while (re-search-forward ", *" nil t)
1875 (replace-match ", " t t))
1876 (mail-header-fold-field)
1877 (goto-char (point-max))))))
1879 (defun gnus-article-treat-body-boundary ()
1880 "Place a boundary line at the end of the headers."
1882 (when (and gnus-body-boundary-delimiter
1883 (> (length gnus-body-boundary-delimiter) 0))
1884 (gnus-with-article-headers
1885 (goto-char (point-max))
1886 (let ((start (point)))
1887 (insert "X-Boundary: ")
1888 (gnus-add-text-properties start (point) '(invisible t intangible t))
1890 (while (>= (1- (window-width)) (length str))
1891 (setq str (concat str gnus-body-boundary-delimiter)))
1892 (substring str 0 (1- (window-width))))
1894 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
1896 (defun article-fill-long-lines ()
1897 "Fill lines that are wider than the window width."
1900 (let ((buffer-read-only nil)
1901 (width (window-width (get-buffer-window (current-buffer)))))
1904 (let ((adaptive-fill-mode nil)) ;Why? -sm
1907 (when (>= (current-column) (min fill-column width))
1908 (narrow-to-region (min (1+ (point)) (point-max)) (gnus-point-at-bol))
1909 (let ((goback (point-marker)))
1910 (fill-paragraph nil)
1911 (goto-char (marker-position goback)))
1913 (forward-line 1)))))))
1915 (defun article-capitalize-sentences ()
1916 "Capitalize the first word in each sentence."
1919 (let ((buffer-read-only nil)
1920 (paragraph-start "^[\n\^L]"))
1924 (forward-sentence)))))
1926 (defun article-remove-cr ()
1927 "Remove trailing CRs and then translate remaining CRs into LFs."
1930 (let ((buffer-read-only nil))
1931 (goto-char (point-min))
1932 (while (re-search-forward "\r+$" nil t)
1933 (replace-match "" t t))
1934 (goto-char (point-min))
1935 (while (search-forward "\r" nil t)
1936 (replace-match "\n" t t)))))
1938 (defun article-remove-trailing-blank-lines ()
1939 "Remove all trailing blank lines from the article."
1942 (let ((buffer-read-only nil))
1943 (goto-char (point-max))
1947 (while (and (not (bobp))
1948 (looking-at "^[ \t]*$")
1949 (not (gnus-annotation-in-region-p
1950 (point) (gnus-point-at-eol))))
1955 (defun article-display-face ()
1956 "Display any Face headers in the header."
1958 (gnus-with-article-headers
1959 (let ((face (message-fetch-field "face")))
1961 (let ((png (gnus-convert-face-to-png face))
1964 (setq image (gnus-create-image png 'png t))
1965 (gnus-article-goto-header "from")
1967 (insert "From: [no `from' set]\n")
1969 (gnus-add-wash-type 'face)
1970 (gnus-add-image 'face image)
1971 (gnus-put-image image)))))))
1973 (defun article-display-x-face (&optional force)
1974 "Look for an X-Face header and display it if present."
1975 (interactive (list 'force))
1976 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
1977 (gnus-with-article-headers
1978 ;; Delete the old process, if any.
1979 (when (process-status "article-x-face")
1980 (delete-process "article-x-face"))
1981 (if (memq 'xface gnus-article-wash-types)
1982 ;; We have already displayed X-Faces, so we remove them
1984 (gnus-delete-images 'xface)
1986 (let (x-faces from face)
1988 (when (and wash-face-p
1990 (goto-char (point-min))
1991 (not (re-search-forward
1992 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
1993 (gnus-buffer-live-p gnus-original-article-buffer))
1994 ;; If type `W f', use gnus-original-article-buffer,
1995 ;; otherwise use the current buffer because displaying
1996 ;; RFC822 parts calls this function too.
1997 (set-buffer gnus-original-article-buffer))
1999 (mail-narrow-to-head)
2000 (while (gnus-article-goto-header "X-Face")
2001 (push (mail-header-field-value) x-faces))
2002 (setq from (message-fetch-field "from"))))
2003 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2004 ;; single external face.
2005 (when (stringp gnus-article-x-face-command)
2006 (setq x-faces (list (car x-faces))))
2007 (while (and (setq face (pop x-faces))
2008 gnus-article-x-face-command
2010 ;; Check whether this face is censored.
2011 (not gnus-article-x-face-too-ugly)
2012 (and gnus-article-x-face-too-ugly from
2013 (not (string-match gnus-article-x-face-too-ugly
2015 ;; We display the face.
2016 (if (symbolp gnus-article-x-face-command)
2017 ;; The command is a lisp function, so we call it.
2018 (if (gnus-functionp gnus-article-x-face-command)
2019 (funcall gnus-article-x-face-command face)
2020 (error "%s is not a function" gnus-article-x-face-command))
2021 ;; The command is a string, so we interpret the command
2022 ;; as a, well, command, and fork it off.
2023 (let ((process-connection-type nil))
2024 (process-kill-without-query
2026 "article-x-face" nil shell-file-name shell-command-switch
2027 gnus-article-x-face-command))
2030 (process-send-region "article-x-face"
2031 (point-min) (point-max)))
2032 (process-send-eof "article-x-face")))))))))
2034 (defun article-decode-mime-words ()
2035 "Decode all MIME-encoded words in the article."
2038 (set-buffer gnus-article-buffer)
2039 (let ((inhibit-point-motion-hooks t)
2041 (mail-parse-charset gnus-newsgroup-charset)
2042 (mail-parse-ignored-charsets
2043 (save-excursion (set-buffer gnus-summary-buffer)
2044 gnus-newsgroup-ignored-charsets)))
2045 (mail-decode-encoded-word-region (point-min) (point-max)))))
2047 (defun article-decode-charset (&optional prompt)
2048 "Decode charset-encoded text in the article.
2049 If PROMPT (the prefix), prompt for a coding system to use."
2051 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2053 (mail-parse-charset gnus-newsgroup-charset)
2054 (mail-parse-ignored-charsets
2055 (save-excursion (condition-case nil
2056 (set-buffer gnus-summary-buffer)
2058 gnus-newsgroup-ignored-charsets))
2059 ct cte ctl charset format)
2062 (article-narrow-to-head)
2063 (setq ct (message-fetch-field "Content-Type" t)
2064 cte (message-fetch-field "Content-Transfer-Encoding" t)
2065 ctl (and ct (ignore-errors
2066 (mail-header-parse-content-type ct)))
2069 (mm-read-coding-system "Charset to decode: "))
2071 (mail-content-type-get ctl 'charset)))
2072 format (and ctl (mail-content-type-get ctl 'format)))
2074 (setq cte (mail-header-strip cte)))
2075 (if (and ctl (not (string-match "/" (car ctl))))
2077 (goto-char (point-max)))
2080 (narrow-to-region (point) (point-max))
2081 (when (and (eq mail-parse-charset 'gnus-decoded)
2082 (eq (mm-body-7-or-8) '8bit))
2083 ;; The text code could have been decoded.
2084 (setq charset mail-parse-charset))
2085 (when (and (or (not ctl)
2086 (equal (car ctl) "text/plain"))
2087 (not format)) ;; article with format will decode later.
2089 charset (and cte (intern (downcase
2090 (gnus-strip-whitespace cte))))
2093 (defun article-decode-encoded-words ()
2094 "Remove encoded-word encoding from headers."
2095 (let ((inhibit-point-motion-hooks t)
2096 (mail-parse-charset gnus-newsgroup-charset)
2097 (mail-parse-ignored-charsets
2098 (save-excursion (condition-case nil
2099 (set-buffer gnus-summary-buffer)
2101 gnus-newsgroup-ignored-charsets))
2104 (article-narrow-to-head)
2105 (funcall gnus-decode-header-function (point-min) (point-max)))))
2107 (defun article-decode-group-name ()
2108 "Decode group names in `Newsgroups:'."
2109 (let ((inhibit-point-motion-hooks t)
2111 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2112 (when (and (or gnus-group-name-charset-method-alist
2113 gnus-group-name-charset-group-alist)
2114 (gnus-buffer-live-p gnus-original-article-buffer))
2115 (when (nnmail-fetch-field "Newsgroups")
2116 (nnheader-replace-header "Newsgroups"
2117 (gnus-decode-newsgroups
2118 (with-current-buffer
2119 gnus-original-article-buffer
2120 (nnmail-fetch-field "Newsgroups"))
2121 gnus-newsgroup-name method)))
2122 (when (nnmail-fetch-field "Followup-To")
2123 (nnheader-replace-header "Followup-To"
2124 (gnus-decode-newsgroups
2125 (with-current-buffer
2126 gnus-original-article-buffer
2127 (nnmail-fetch-field "Followup-To"))
2128 gnus-newsgroup-name method))))))
2130 (defun article-de-quoted-unreadable (&optional force read-charset)
2131 "Translate a quoted-printable-encoded article.
2132 If FORCE, decode the article whether it is marked as quoted-printable
2134 If READ-CHARSET, ask for a coding system."
2135 (interactive (list 'force current-prefix-arg))
2137 (let ((buffer-read-only nil) type charset)
2138 (if (gnus-buffer-live-p gnus-original-article-buffer)
2139 (with-current-buffer gnus-original-article-buffer
2141 (gnus-fetch-field "content-transfer-encoding"))
2142 (let* ((ct (gnus-fetch-field "content-type"))
2145 (mail-header-parse-content-type ct)))))
2146 (setq charset (and ctl
2147 (mail-content-type-get ctl 'charset)))
2148 (if (stringp charset)
2149 (setq charset (intern (downcase charset)))))))
2151 (setq charset (mm-read-coding-system "Charset: " charset)))
2153 (setq charset gnus-newsgroup-charset))
2155 (and type (let ((case-fold-search t))
2156 (string-match "quoted-printable" type))))
2158 (quoted-printable-decode-region
2159 (point) (point-max) (mm-charset-to-coding-system charset))))))
2161 (defun article-de-base64-unreadable (&optional force read-charset)
2162 "Translate a base64 article.
2163 If FORCE, decode the article whether it is marked as base64 not.
2164 If READ-CHARSET, ask for a coding system."
2165 (interactive (list 'force current-prefix-arg))
2167 (let ((buffer-read-only nil) type charset)
2168 (if (gnus-buffer-live-p gnus-original-article-buffer)
2169 (with-current-buffer gnus-original-article-buffer
2171 (gnus-fetch-field "content-transfer-encoding"))
2172 (let* ((ct (gnus-fetch-field "content-type"))
2175 (mail-header-parse-content-type ct)))))
2176 (setq charset (and ctl
2177 (mail-content-type-get ctl 'charset)))
2178 (if (stringp charset)
2179 (setq charset (intern (downcase charset)))))))
2181 (setq charset (mm-read-coding-system "Charset: " charset)))
2183 (setq charset gnus-newsgroup-charset))
2185 (and type (let ((case-fold-search t))
2186 (string-match "base64" type))))
2189 (narrow-to-region (point) (point-max))
2190 (base64-decode-region (point-min) (point-max))
2191 (mm-decode-coding-region
2192 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2197 (defun article-decode-HZ ()
2198 "Translate a HZ-encoded article."
2202 (let ((buffer-read-only nil))
2203 (rfc1843-decode-region (point-min) (point-max)))))
2205 (defun article-unsplit-urls ()
2206 "Remove the newlines that some other mailers insert into URLs."
2209 (let ((buffer-read-only nil))
2210 (goto-char (point-min))
2211 (while (re-search-forward
2212 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2213 (replace-match "\\1\\3" t)))
2214 (when (and gnus-display-mime-function (interactive-p))
2215 (funcall gnus-display-mime-function))))
2218 (defun article-wash-html (&optional read-charset)
2219 "Format an HTML article.
2220 If READ-CHARSET, ask for a coding system."
2223 (let ((buffer-read-only nil)
2225 (when (gnus-buffer-live-p gnus-original-article-buffer)
2226 (with-current-buffer gnus-original-article-buffer
2227 (let* ((ct (gnus-fetch-field "content-type"))
2230 (mail-header-parse-content-type ct)))))
2231 (setq charset (and ctl
2232 (mail-content-type-get ctl 'charset)))
2233 (when (stringp charset)
2234 (setq charset (intern (downcase charset)))))))
2236 (setq charset (mm-read-coding-system "Charset: " charset)))
2238 (setq charset gnus-newsgroup-charset))
2240 (save-window-excursion
2242 (narrow-to-region (point) (point-max))
2243 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2244 (entry (assq func mm-text-html-washer-alist)))
2246 (setq func (cdr entry)))
2248 ((gnus-functionp func)
2251 (apply (car func) (cdr func))))))))))
2253 (defun gnus-article-wash-html-with-w3 ()
2254 "Wash the current buffer with w3."
2256 (let ((w3-strict-width (window-width))
2257 (url-standalone-mode t)
2258 (url-gateway-unplugged t)
2259 (w3-honor-stylesheets nil))
2261 (w3-region (point-min) (point-max))
2264 (defun gnus-article-wash-html-with-w3m ()
2265 "Wash the current buffer with emacs-w3m."
2268 (narrow-to-region (point) (point-max))
2269 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2272 (w3m-display-inline-images mm-inline-text-html-with-images)
2273 w3m-force-redisplay)
2274 (w3m-region (point-min) (point-max)))
2275 (when mm-inline-text-html-with-w3m-keymap
2276 (add-text-properties
2277 (point-min) (point-max)
2278 (nconc (mm-w3m-local-map-property)
2279 '(mm-inline-text-html-with-w3m t))))))
2281 (defun article-hide-list-identifiers ()
2282 "Remove list identifies from the Subject header.
2283 The `gnus-list-identifiers' variable specifies what to do."
2285 (let ((inhibit-point-motion-hooks t)
2286 (regexp (if (consp gnus-list-identifiers)
2287 (mapconcat 'identity gnus-list-identifiers " *\\|")
2288 gnus-list-identifiers))
2293 (article-narrow-to-head)
2294 (goto-char (point-min))
2295 (while (re-search-forward
2296 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2298 (delete-region (match-beginning 2) (match-end 0))
2299 (beginning-of-line))
2300 (when (re-search-forward
2301 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2302 (delete-region (match-beginning 1) (match-end 1))))))))
2304 (defun article-hide-pem (&optional arg)
2305 "Toggle hiding of any PEM headers and signatures in the current article.
2306 If given a negative prefix, always show; if given a positive prefix,
2308 (interactive (gnus-article-hidden-arg))
2309 (unless (gnus-article-check-hidden-text 'pem arg)
2311 (let (buffer-read-only end)
2312 (goto-char (point-min))
2313 ;; Hide the horrendously ugly "header".
2314 (when (and (search-forward
2315 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2317 (setq end (1+ (match-beginning 0))))
2318 (gnus-add-wash-type 'pem)
2319 (gnus-article-hide-text-type
2321 (if (search-forward "\n\n" nil t)
2325 ;; Hide the trailer as well
2326 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2328 (gnus-article-hide-text-type
2329 (match-beginning 0) (match-end 0) 'pem)))))))
2331 (defun article-strip-banner ()
2332 "Strip the banners specified by the `banner' group parameter and by
2333 `gnus-article-address-banner-alist'."
2337 (let ((inhibit-point-motion-hooks t))
2338 (when (gnus-parameter-banner gnus-newsgroup-name)
2339 (article-really-strip-banner
2340 (gnus-parameter-banner gnus-newsgroup-name)))
2341 (when gnus-article-address-banner-alist
2342 (article-really-strip-banner
2343 (let ((from (save-restriction
2345 (article-narrow-to-head)
2346 (mail-fetch-field "from"))))
2349 (caar (mail-header-parse-addresses from))))
2351 (dolist (pair gnus-article-address-banner-alist)
2352 (when (string-match (car pair) from)
2353 (throw 'found (cdr pair)))))))))))))
2355 (defun article-really-strip-banner (banner)
2356 "Strip the banner specified by the argument."
2359 (let ((inhibit-point-motion-hooks t)
2360 (gnus-signature-limit nil)
2364 ((eq banner 'signature)
2365 (when (gnus-article-narrow-to-signature)
2368 (delete-region (point) (point-max))))
2370 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2371 (while (re-search-forward banner nil t)
2372 (delete-region (match-beginning 0) (match-end 0)))))
2374 (while (re-search-forward banner nil t)
2375 (delete-region (match-beginning 0) (match-end 0)))))))))
2377 (defun article-babel ()
2378 "Translate article using an online translation service."
2382 (set-buffer gnus-article-buffer)
2383 (when (article-goto-body)
2384 (let* ((buffer-read-only nil)
2387 (orig (buffer-substring start end))
2388 (trans (babel-as-string orig)))
2390 (narrow-to-region start end)
2391 (delete-region start end)
2394 (defun article-hide-signature (&optional arg)
2395 "Hide the signature in the current article.
2396 If given a negative prefix, always show; if given a positive prefix,
2398 (interactive (gnus-article-hidden-arg))
2399 (unless (gnus-article-check-hidden-text 'signature arg)
2402 (let ((buffer-read-only nil))
2403 (when (gnus-article-narrow-to-signature)
2404 (gnus-article-hide-text-type
2405 (point-min) (point-max) 'signature))))))
2406 (gnus-set-mode-line 'article))
2408 (defun article-strip-headers-in-body ()
2409 "Strip offensive headers from bodies."
2413 (let ((case-fold-search t))
2414 (when (looking-at "x-no-archive:")
2415 (gnus-delete-line)))))
2417 (defun article-strip-leading-blank-lines ()
2418 "Remove all blank lines from the beginning of the article."
2421 (let ((inhibit-point-motion-hooks t)
2423 (when (article-goto-body)
2424 (while (and (not (eobp))
2425 (looking-at "[ \t]*$"))
2426 (gnus-delete-line))))))
2428 (defun article-narrow-to-head ()
2429 "Narrow the buffer to the head of the message.
2430 Point is left at the beginning of the narrowed-to region."
2432 (goto-char (point-min))
2433 (if (search-forward "\n\n" nil 1)
2436 (goto-char (point-min)))
2438 (defun article-goto-body ()
2439 "Place point at the start of the body."
2440 (goto-char (point-min))
2442 ;; This variable is only bound when dealing with separate
2444 (article-goto-body-goes-to-point-min-p
2446 ((search-forward "\n\n" nil t)
2449 (goto-char (point-max))
2452 (defun article-strip-multiple-blank-lines ()
2453 "Replace consecutive blank lines with one empty line."
2456 (let ((inhibit-point-motion-hooks t)
2458 ;; First make all blank lines empty.
2460 (while (re-search-forward "^[ \t]+$" nil t)
2461 (unless (gnus-annotation-in-region-p
2462 (match-beginning 0) (match-end 0))
2463 (replace-match "" nil t)))
2464 ;; Then replace multiple empty lines with a single empty line.
2466 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2467 (unless (gnus-annotation-in-region-p
2468 (match-beginning 0) (match-end 0))
2469 (delete-region (match-beginning 1) (match-end 1)))))))
2471 (defun article-strip-leading-space ()
2472 "Remove all white space from the beginning of the lines in the article."
2475 (let ((inhibit-point-motion-hooks t)
2478 (while (re-search-forward "^[ \t]+" nil t)
2479 (replace-match "" t t)))))
2481 (defun article-strip-trailing-space ()
2482 "Remove all white space from the end of the lines in the article."
2485 (let ((inhibit-point-motion-hooks t)
2488 (while (re-search-forward "[ \t]+$" nil t)
2489 (replace-match "" t t)))))
2491 (defun article-strip-blank-lines ()
2492 "Strip leading, trailing and multiple blank lines."
2494 (article-strip-leading-blank-lines)
2495 (article-remove-trailing-blank-lines)
2496 (article-strip-multiple-blank-lines))
2498 (defun article-strip-all-blank-lines ()
2499 "Strip all blank lines."
2502 (let ((inhibit-point-motion-hooks t)
2505 (while (re-search-forward "^[ \t]*\n" nil t)
2506 (replace-match "" t t)))))
2508 (defun gnus-article-narrow-to-signature ()
2509 "Narrow to the signature; return t if a signature is found, else nil."
2510 (let ((inhibit-point-motion-hooks t))
2511 (when (gnus-article-search-signature)
2513 ;; Check whether we have some limits to what we consider
2514 ;; to be a signature.
2515 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2516 (list gnus-signature-limit)))
2518 (while (setq limit (pop limits))
2519 (if (or (and (integerp limit)
2520 (< (- (point-max) (point)) limit))
2522 (< (count-lines (point) (point-max)) limit))
2523 (and (gnus-functionp limit)
2525 (and (stringp limit)
2526 (not (re-search-forward limit nil t))))
2527 () ; This limit did not succeed.
2531 (narrow-to-region (point) (point-max))
2534 (defun gnus-article-search-signature ()
2535 "Search the current buffer for the signature separator.
2536 Put point at the beginning of the signature separator."
2537 (let ((cur (point)))
2538 (goto-char (point-max))
2539 (if (if (stringp gnus-signature-separator)
2540 (re-search-backward gnus-signature-separator nil t)
2541 (let ((seps gnus-signature-separator))
2543 (not (re-search-backward (car seps) nil t)))
2550 (defun gnus-article-hidden-arg ()
2551 "Return the current prefix arg as a number, or 0 if no prefix."
2552 (list (if current-prefix-arg
2553 (prefix-numeric-value current-prefix-arg)
2556 (defun gnus-article-check-hidden-text (type arg)
2557 "Return nil if hiding is necessary.
2558 Arg can be nil or a number. nil and positive means hide, negative
2559 means show, 0 means toggle."
2562 (let ((hide (gnus-article-hidden-text-p type)))
2568 (gnus-article-show-hidden-text type)
2571 (if (eq hide 'hidden)
2573 (gnus-article-show-hidden-text type)
2577 (defun gnus-article-hidden-text-p (type)
2578 "Say whether the current buffer contains hidden text of type TYPE."
2579 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2581 (not (get-text-property pos 'invisible))
2582 (not (get-text-property pos 'dummy-invisible)))
2584 (text-property-any (1+ pos) (point-max) 'article-type type)))
2589 (defun gnus-article-show-hidden-text (type &optional dummy)
2590 "Show all hidden text of type TYPE.
2591 Originally it is hide instead of DUMMY."
2592 (let ((buffer-read-only nil)
2593 (inhibit-point-motion-hooks t))
2594 (gnus-remove-text-properties-when
2596 (point-min) (point-max)
2597 (cons 'article-type (cons type
2598 gnus-hidden-properties)))
2599 (gnus-delete-wash-type type)))
2601 (defconst article-time-units
2602 `((year . ,(* 365.25 24 60 60))
2603 (week . ,(* 7 24 60 60))
2604 (day . ,(* 24 60 60))
2608 "Mapping from time units to seconds.")
2610 (defun gnus-article-forward-header ()
2611 "Move point to the start of the next header.
2612 If the current header is a continuation header, this can be several
2617 (if (looking-at "[ \t]+[^ \t]")
2621 (defun article-date-ut (&optional type highlight header)
2622 "Convert DATE date to universal time in the current article.
2623 If TYPE is `local', convert to local time; if it is `lapsed', output
2624 how much time has lapsed since DATE. For `lapsed', the value of
2625 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2626 should replace the \"Date:\" one, or should be added below it."
2627 (interactive (list 'ut t))
2628 (let* ((header (or header
2629 (message-fetch-field "date")
2631 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2634 ((not gnus-article-date-lapsed-new-header)
2640 (date (if (vectorp header) (mail-header-date header)
2642 (inhibit-point-motion-hooks t)
2647 (article-narrow-to-head)
2648 (when (re-search-forward tdate-regexp nil t)
2649 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2650 date (or (get-text-property (gnus-point-at-bol)
2653 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2655 (when (and date (not (string= date "")))
2656 (goto-char (point-min))
2657 (let ((buffer-read-only nil))
2658 ;; Delete any old Date headers.
2659 (while (re-search-forward date-regexp nil t)
2661 (delete-region (progn (beginning-of-line) (point))
2662 (progn (gnus-article-forward-header)
2664 (delete-region (progn (beginning-of-line) (point))
2665 (progn (gnus-article-forward-header)
2668 (setq pos (point))))
2669 (when (and (not pos)
2670 (re-search-forward tdate-regexp nil t))
2674 (insert (article-make-date-line date (or type 'ut)))
2680 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2681 (put-text-property (match-beginning 1) (1+ (match-end 1))
2682 'original-date date)
2683 (put-text-property (match-beginning 1) (1+ (match-end 1))
2685 (put-text-property (match-beginning 2) (match-end 2)
2688 (defun article-make-date-line (date type)
2689 "Return a DATE line of TYPE."
2690 (unless (memq type '(local ut original user iso8601 lapsed english))
2691 (error "Unknown conversion type: %s" type))
2693 (let ((time (date-to-time date)))
2695 ;; Convert to the local timezone.
2697 (let ((tz (car (current-time-zone time))))
2698 (format "Date: %s %s%02d%02d" (current-time-string time)
2699 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2700 (/ (% (abs tz) 3600) 60))))
2701 ;; Convert to Universal Time.
2704 (current-time-string
2705 (let* ((e (parse-time-string date))
2706 (tm (apply 'encode-time e))
2708 (ls (- (cadr tm) (car (current-time-zone time)))))
2709 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2710 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2713 ;; Get the original date from the article.
2714 ((eq type 'original)
2715 (concat "Date: " (if (string-match "\n+$" date)
2716 (substring date 0 (match-beginning 0))
2718 ;; Let the user define the format.
2720 (let ((format (or (condition-case nil
2721 (with-current-buffer gnus-summary-buffer
2722 gnus-article-time-format)
2724 gnus-article-time-format)))
2725 (if (gnus-functionp format)
2726 (funcall format time)
2727 (concat "Date: " (format-time-string format time)))))
2730 (let ((tz (car (current-time-zone time))))
2733 (format-time-string "%Y%m%dT%H%M%S" time)
2734 (format "%s%02d%02d"
2735 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2736 (/ (% (abs tz) 3600) 60)))))
2737 ;; Do an X-Sent lapsed format.
2739 ;; If the date is seriously mangled, the timezone functions are
2740 ;; liable to bug out, so we ignore all errors.
2741 (let* ((now (current-time))
2742 (real-time (subtract-time now time))
2743 (real-sec (and real-time
2744 (+ (* (float (car real-time)) 65536)
2746 (sec (and real-time (abs real-sec)))
2756 ;; This is a bit convoluted, but basically we go
2757 ;; through the time units for years, weeks, etc,
2758 ;; and divide things to see whether that results
2759 ;; in positive answers.
2762 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2763 ;; The (remaining) seconds are too few to
2764 ;; be divided into this time unit.
2766 ;; It's big enough, so we output it.
2767 (setq sec (- sec (* num (cdr unit))))
2769 (concat (if prev ", " "") (int-to-string
2771 " " (symbol-name (car unit))
2772 (if (> num 1) "s" ""))
2774 article-time-units "")
2775 ;; If dates are odd, then it might appear like the
2776 ;; article was sent in the future.
2779 " in the future"))))))
2780 ;; Display the date in proper English
2782 (let ((dtime (decode-time time)))
2785 (number-to-string (nth 3 dtime))
2786 (let ((digit (% (nth 3 dtime) 10)))
2788 ((memq (nth 3 dtime) '(11 12 13)) "th")
2794 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2796 (number-to-string (nth 5 dtime))
2798 (format "%02d" (nth 2 dtime))
2800 (format "%02d" (nth 1 dtime)))))))
2802 (format "Date: %s (from Gnus)" date))))
2804 (defun article-date-local (&optional highlight)
2805 "Convert the current article date to the local timezone."
2806 (interactive (list t))
2807 (article-date-ut 'local highlight))
2809 (defun article-date-english (&optional highlight)
2810 "Convert the current article date to something that is proper English."
2811 (interactive (list t))
2812 (article-date-ut 'english highlight))
2814 (defun article-date-original (&optional highlight)
2815 "Convert the current article date to what it was originally.
2816 This is only useful if you have used some other date conversion
2817 function and want to see what the date was before converting."
2818 (interactive (list t))
2819 (article-date-ut 'original highlight))
2821 (defun article-date-lapsed (&optional highlight)
2822 "Convert the current article date to time lapsed since it was sent."
2823 (interactive (list t))
2824 (article-date-ut 'lapsed highlight))
2826 (defun article-update-date-lapsed ()
2827 "Function to be run from a timer to update the lapsed time line."
2828 (let (deactivate-mark)
2833 (set-buffer (window-buffer w))
2834 (when (eq major-mode 'gnus-article-mode)
2835 (goto-char (point-min))
2836 (when (re-search-forward "^X-Sent:" nil t)
2837 (article-date-lapsed t))))
2840 (defun gnus-start-date-timer (&optional n)
2841 "Start a timer to update the X-Sent header in the article buffers.
2842 The numerical prefix says how frequently (in seconds) the function
2847 (gnus-stop-date-timer)
2848 (setq article-lapsed-timer
2849 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2851 (defun gnus-stop-date-timer ()
2852 "Stop the X-Sent timer."
2854 (when article-lapsed-timer
2855 (nnheader-cancel-timer article-lapsed-timer)
2856 (setq article-lapsed-timer nil)))
2858 (defun article-date-user (&optional highlight)
2859 "Convert the current article date to the user-defined format.
2860 This format is defined by the `gnus-article-time-format' variable."
2861 (interactive (list t))
2862 (article-date-ut 'user highlight))
2864 (defun article-date-iso8601 (&optional highlight)
2865 "Convert the current article date to ISO8601."
2866 (interactive (list t))
2867 (article-date-ut 'iso8601 highlight))
2869 ;; (defun article-show-all ()
2870 ;; "Show all hidden text in the article buffer."
2873 ;; (let ((buffer-read-only nil))
2874 ;; (gnus-article-unhide-text (point-min) (point-max)))))
2876 (defun article-remove-leading-whitespace ()
2877 "Remove excessive whitespace from all headers."
2881 (let ((buffer-read-only nil))
2882 (article-narrow-to-head)
2883 (goto-char (point-min))
2884 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2885 (delete-region (match-beginning 1) (match-end 1)))))))
2887 (defun article-emphasize (&optional arg)
2888 "Emphasize text according to `gnus-emphasis-alist'."
2889 (interactive (gnus-article-hidden-arg))
2890 (unless (gnus-article-check-hidden-text 'emphasis arg)
2894 (with-current-buffer gnus-summary-buffer
2895 gnus-article-emphasis-alist)
2897 gnus-emphasis-alist))
2898 (buffer-read-only nil)
2899 (props (append '(article-type emphasis)
2900 gnus-hidden-properties))
2901 regexp elem beg invisible visible face)
2904 (while (setq elem (pop alist))
2906 (setq regexp (car elem)
2907 invisible (nth 1 elem)
2908 visible (nth 2 elem)
2910 (while (re-search-forward regexp nil t)
2911 (when (and (match-beginning visible) (match-beginning invisible))
2912 (gnus-article-hide-text
2913 (match-beginning invisible) (match-end invisible) props)
2914 (gnus-article-unhide-text-type
2915 (match-beginning visible) (match-end visible) 'emphasis)
2916 (gnus-put-overlay-excluding-newlines
2917 (match-beginning visible) (match-end visible) 'face face)
2918 (gnus-add-wash-type 'emphasis)
2919 (goto-char (match-end invisible)))))))))
2921 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2922 "Setup newsgroup emphasis alist."
2923 (unless gnus-article-emphasis-alist
2924 (let ((name (and gnus-newsgroup-name
2925 (gnus-group-real-name gnus-newsgroup-name))))
2926 (make-local-variable 'gnus-article-emphasis-alist)
2927 (setq gnus-article-emphasis-alist
2929 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2930 (while (setq elem (pop alist))
2931 (when (and name (string-match (car elem) name))
2933 highlight (copy-sequence (cdr elem)))))
2935 (copy-sequence highlight-words)
2936 (if gnus-newsgroup-name
2937 (copy-sequence (gnus-group-find-parameter
2938 gnus-newsgroup-name 'highlight-words t)))
2939 gnus-emphasis-alist)))))
2942 (defvar gnus-summary-article-menu)
2943 (defvar gnus-summary-post-menu))
2945 ;;; Saving functions.
2947 (defun gnus-article-save (save-buffer file &optional num)
2948 "Save the currently selected article."
2949 (unless gnus-save-all-headers
2950 ;; Remove headers according to `gnus-saved-headers'.
2951 (let ((gnus-visible-headers
2952 (or gnus-saved-headers gnus-visible-headers))
2953 (gnus-article-buffer save-buffer))
2955 (set-buffer save-buffer)
2956 (article-hide-headers 1 t))))
2957 (save-window-excursion
2958 (if (not gnus-default-article-saver)
2959 (error "No default saver is defined")
2960 ;; !!! Magic! The saving functions all save
2961 ;; `gnus-save-article-buffer' (or so they think), but we
2962 ;; bind that variable to our save-buffer.
2963 (set-buffer gnus-article-buffer)
2964 (let* ((gnus-save-article-buffer save-buffer)
2967 ((not gnus-prompt-before-saving) 'default)
2968 ((eq gnus-prompt-before-saving 'always) nil)
2970 (gnus-number-of-articles-to-be-saved
2971 (when (eq gnus-prompt-before-saving t)
2973 (set-buffer gnus-article-current-summary)
2974 (funcall gnus-default-article-saver filename)))))
2976 (defun gnus-read-save-file-name (prompt &optional filename
2977 function group headers variable)
2979 (funcall function group headers (symbol-value variable)))
2984 ((eq filename 'default)
2990 (let* ((split-name (gnus-get-split-value gnus-split-methods))
2993 (if (and gnus-number-of-articles-to-be-saved
2994 (> gnus-number-of-articles-to-be-saved 1))
2995 (format "these %d articles"
2996 gnus-number-of-articles-to-be-saved)
2999 ;; Let the split methods have their say.
3001 ;; No split name was found.
3004 (concat prompt " (default "
3005 (file-name-nondirectory default-name) ") ")
3006 (file-name-directory default-name)
3008 ;; A single group name is returned.
3009 ((stringp split-name)
3011 (funcall function split-name headers
3012 (symbol-value variable)))
3014 (concat prompt " (default "
3015 (file-name-nondirectory default-name) ") ")
3016 (file-name-directory default-name)
3018 ;; A single split name was found
3019 ((= 1 (length split-name))
3020 (let* ((name (expand-file-name
3022 gnus-article-save-directory))
3023 (dir (cond ((file-directory-p name)
3024 (file-name-as-directory name))
3025 ((file-exists-p name) name)
3026 (t gnus-article-save-directory))))
3028 (concat prompt " (default " name ") ")
3030 ;; A list of splits was found.
3032 (setq split-name (nreverse split-name))
3034 (let ((file-name-history
3035 (nconc split-name file-name-history)))
3039 (concat prompt " (`M-p' for defaults) ")
3040 gnus-article-save-directory
3042 gnus-article-save-directory)))
3043 (car (push result file-name-history)))))))
3044 ;; Create the directory.
3045 (gnus-make-directory (file-name-directory file))
3046 ;; If we have read a directory, we append the default file name.
3047 (when (file-directory-p file)
3048 (setq file (expand-file-name (file-name-nondirectory
3050 (file-name-as-directory file))))
3051 ;; Possibly translate some characters.
3052 (nnheader-translate-file-chars file))))))
3053 (gnus-make-directory (file-name-directory result))
3054 (set variable result)))
3056 (defun gnus-article-archive-name (group)
3057 "Return the first instance of an \"Archive-name\" in the current buffer."
3058 (let ((case-fold-search t))
3059 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3060 (nnheader-concat gnus-article-save-directory
3061 (match-string 1)))))
3063 (defun gnus-article-nndoc-name (group)
3064 "If GROUP is an nndoc group, return the name of the parent group."
3065 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3066 (gnus-group-get-parameter group 'save-article-group)))
3068 (defun gnus-summary-save-in-rmail (&optional filename)
3069 "Append this article to Rmail file.
3070 Optional argument FILENAME specifies file name.
3071 Directory to save to is default to `gnus-article-save-directory'."
3072 (setq filename (gnus-read-save-file-name
3073 "Save %s in rmail file:" filename
3074 gnus-rmail-save-name gnus-newsgroup-name
3075 gnus-current-headers 'gnus-newsgroup-last-rmail))
3076 (gnus-eval-in-buffer-window gnus-save-article-buffer
3080 (gnus-output-to-rmail filename))))
3083 (defun gnus-summary-save-in-mail (&optional filename)
3084 "Append this article to Unix mail file.
3085 Optional argument FILENAME specifies file name.
3086 Directory to save to is default to `gnus-article-save-directory'."
3087 (setq filename (gnus-read-save-file-name
3088 "Save %s in Unix mail file:" filename
3089 gnus-mail-save-name gnus-newsgroup-name
3090 gnus-current-headers 'gnus-newsgroup-last-mail))
3091 (gnus-eval-in-buffer-window gnus-save-article-buffer
3095 (if (and (file-readable-p filename)
3096 (file-regular-p filename)
3097 (mail-file-babyl-p filename))
3098 (rmail-output-to-rmail-file filename t)
3099 (gnus-output-to-mail filename)))))
3102 (defun gnus-summary-save-in-file (&optional filename overwrite)
3103 "Append this article to file.
3104 Optional argument FILENAME specifies file name.
3105 Directory to save to is default to `gnus-article-save-directory'."
3106 (setq filename (gnus-read-save-file-name
3107 "Save %s in file:" filename
3108 gnus-file-save-name gnus-newsgroup-name
3109 gnus-current-headers 'gnus-newsgroup-last-file))
3110 (gnus-eval-in-buffer-window gnus-save-article-buffer
3114 (when (and overwrite
3115 (file-exists-p filename))
3116 (delete-file filename))
3117 (gnus-output-to-file filename))))
3120 (defun gnus-summary-write-to-file (&optional filename)
3121 "Write this article to a file, overwriting it if the file exists.
3122 Optional argument FILENAME specifies file name.
3123 The directory to save in defaults to `gnus-article-save-directory'."
3124 (gnus-summary-save-in-file nil t))
3126 (defun gnus-summary-save-body-in-file (&optional filename)
3127 "Append this article body to a file.
3128 Optional argument FILENAME specifies file name.
3129 The directory to save in defaults to `gnus-article-save-directory'."
3130 (setq filename (gnus-read-save-file-name
3131 "Save %s body in file:" filename
3132 gnus-file-save-name gnus-newsgroup-name
3133 gnus-current-headers 'gnus-newsgroup-last-file))
3134 (gnus-eval-in-buffer-window gnus-save-article-buffer
3138 (when (article-goto-body)
3139 (narrow-to-region (point) (point-max)))
3140 (gnus-output-to-file filename))))
3143 (defun gnus-summary-save-in-pipe (&optional command)
3144 "Pipe this article to subprocess."
3146 (cond ((and (eq command 'default)
3147 gnus-last-shell-command)
3148 gnus-last-shell-command)
3153 "Shell command on %s: "
3154 (if (and gnus-number-of-articles-to-be-saved
3155 (> gnus-number-of-articles-to-be-saved 1))
3156 (format "these %d articles"
3157 gnus-number-of-articles-to-be-saved)
3159 gnus-last-shell-command))))
3160 (when (string-equal command "")
3161 (if gnus-last-shell-command
3162 (setq command gnus-last-shell-command)
3163 (error "A command is required")))
3164 (gnus-eval-in-buffer-window gnus-article-buffer
3167 (shell-command-on-region (point-min) (point-max) command nil)))
3168 (setq gnus-last-shell-command command))
3170 (defun gnus-summary-pipe-to-muttprint (&optional command)
3171 "Pipe this article to muttprint."
3172 (setq command (read-string
3173 "Print using command: " gnus-summary-muttprint-program
3174 nil gnus-summary-muttprint-program))
3175 (gnus-summary-save-in-pipe command))
3177 ;;; Article file names when saving.
3179 (defun gnus-capitalize-newsgroup (newsgroup)
3180 "Capitalize NEWSGROUP name."
3181 (when (not (zerop (length newsgroup)))
3182 (concat (char-to-string (upcase (aref newsgroup 0)))
3183 (substring newsgroup 1))))
3185 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3186 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3187 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3188 Otherwise, it is like ~/News/news/group/num."
3191 (concat (if (gnus-use-long-file-name 'not-save)
3192 (gnus-capitalize-newsgroup newsgroup)
3193 (gnus-newsgroup-directory-form newsgroup))
3194 "/" (int-to-string (mail-header-number headers)))
3195 gnus-article-save-directory)))
3197 (string-equal (file-name-directory default)
3198 (file-name-directory last-file))
3199 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3201 (or last-file default))))
3203 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3204 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3205 If variable `gnus-use-long-file-name' is non-nil, it is
3206 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3209 (concat (if (gnus-use-long-file-name 'not-save)
3211 (gnus-newsgroup-directory-form newsgroup))
3212 "/" (int-to-string (mail-header-number headers)))
3213 gnus-article-save-directory)))
3215 (string-equal (file-name-directory default)
3216 (file-name-directory last-file))
3217 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3219 (or last-file default))))
3221 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3222 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3223 If variable `gnus-use-long-file-name' is non-nil, it is
3224 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3227 (if (gnus-use-long-file-name 'not-save)
3230 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3232 gnus-article-save-directory)))
3234 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3235 "Generate file name from sender."
3236 (let ((from (mail-header-from headers)))
3238 (if (and from (string-match "\\([^ <]+\\)@" from))
3239 (match-string 1 from)
3241 gnus-article-save-directory)))
3243 (defun article-verify-x-pgp-sig ()
3246 (if (gnus-buffer-live-p gnus-original-article-buffer)
3247 (let ((sig (with-current-buffer gnus-original-article-buffer
3248 (gnus-fetch-field "X-PGP-Sig")))
3252 (mml2015-clear-verify-function))
3254 (insert-buffer gnus-original-article-buffer)
3255 (setq items (split-string sig))
3256 (message-narrow-to-head)
3257 (let ((inhibit-point-motion-hooks t)
3258 (case-fold-search t))
3259 ;; Don't verify multiple headers.
3260 (setq headers (mapconcat (lambda (header)
3262 (mail-fetch-field header) "\n"))
3263 (split-string (nth 1 items) ",") "")))
3264 (delete-region (point-min) (point-max))
3265 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3266 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3271 (if (looking-at "^-")
3274 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3275 (insert "Version: " (car items) "\n\n")
3276 (insert (mapconcat 'identity (cddr items) "\n"))
3277 (insert "\n-----END PGP SIGNATURE-----\n")
3278 (let ((mm-security-handle (list (format "multipart/signed"))))
3279 (mml2015-clean-buffer)
3280 (let ((coding-system-for-write (or gnus-newsgroup-charset
3282 (funcall (mml2015-clear-verify-function)))
3284 (or (mm-handle-multipart-ctl-parameter
3285 mm-security-handle 'gnus-details)
3286 (mm-handle-multipart-ctl-parameter
3287 mm-security-handle 'gnus-info)))))
3289 (let (buffer-read-only bface eface)
3291 (message-narrow-to-head)
3292 (goto-char (point-max))
3294 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3295 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3296 (message-remove-header "X-Gnus-PGP-Verify")
3297 (if (re-search-forward "^X-PGP-Sig:" nil t)
3299 (goto-char (point-max)))
3300 (narrow-to-region (point) (point))
3301 (insert "X-Gnus-PGP-Verify: " info "\n")
3302 (goto-char (point-min))
3305 (if (not (looking-at "^[ \t]"))
3309 (goto-char (point-min))
3310 (when (looking-at "\\([^:]+\\): *")
3311 (put-text-property (match-beginning 1) (1+ (match-end 1))
3313 (put-text-property (match-end 0) (point-max)
3314 'face eface)))))))))
3316 (defun article-verify-cancel-lock ()
3317 "Verify Cancel-Lock header."
3319 (if (gnus-buffer-live-p gnus-original-article-buffer)
3320 (canlock-verify gnus-original-article-buffer)))
3327 (setq afunc (car func)
3330 gfunc (intern (format "gnus-%s" func))))
3332 (when (fboundp afunc)
3333 `(lambda (&optional interactive &rest args)
3334 ,(documentation afunc t)
3335 (interactive (list t))
3337 (set-buffer gnus-article-buffer)
3339 (call-interactively ',afunc)
3340 (apply ',afunc args))))))))
3341 '(article-hide-headers
3342 article-verify-x-pgp-sig
3343 article-verify-cancel-lock
3344 article-hide-boring-headers
3345 article-treat-overstrike
3346 article-fill-long-lines
3347 article-capitalize-sentences
3349 article-remove-leading-whitespace
3350 article-display-x-face
3351 article-display-face
3352 article-de-quoted-unreadable
3353 article-de-base64-unreadable
3356 article-unsplit-urls
3357 article-hide-list-identifiers
3358 article-strip-banner
3361 article-hide-signature
3362 article-strip-headers-in-body
3363 article-remove-trailing-blank-lines
3364 article-strip-leading-blank-lines
3365 article-strip-multiple-blank-lines
3366 article-strip-leading-space
3367 article-strip-trailing-space
3368 article-strip-blank-lines
3369 article-strip-all-blank-lines
3371 article-date-english
3372 article-date-iso8601
3373 article-date-original
3375 article-decode-mime-words
3376 article-decode-charset
3377 article-decode-encoded-words
3381 article-treat-dumbquotes
3382 article-normalize-headers
3383 ;; (article-show-all . gnus-article-show-all-headers)
3387 ;;; Gnus article mode
3390 (put 'gnus-article-mode 'mode-class 'special)
3392 (set-keymap-parent gnus-article-mode-map widget-keymap)
3394 (gnus-define-keys gnus-article-mode-map
3395 " " gnus-article-goto-next-page
3396 "\177" gnus-article-goto-prev-page
3397 [delete] gnus-article-goto-prev-page
3398 [backspace] gnus-article-goto-prev-page
3399 "\C-c^" gnus-article-refer-article
3400 "h" gnus-article-show-summary
3401 "s" gnus-article-show-summary
3402 "\C-c\C-m" gnus-article-mail
3403 "?" gnus-article-describe-briefly
3404 "e" gnus-summary-edit-article
3405 "<" beginning-of-buffer
3407 "\C-c\C-i" gnus-info-find-node
3409 "R" gnus-article-reply-with-original
3410 "F" gnus-article-followup-with-original
3411 "\C-hk" gnus-article-describe-key
3412 "\C-hc" gnus-article-describe-key-briefly
3414 "\C-d" gnus-article-read-summary-keys
3415 "\M-*" gnus-article-read-summary-keys
3416 "\M-#" gnus-article-read-summary-keys
3417 "\M-^" gnus-article-read-summary-keys
3418 "\M-g" gnus-article-read-summary-keys)
3420 (substitute-key-definition
3421 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3423 (defun gnus-article-make-menu-bar ()
3424 (unless (boundp 'gnus-article-commands-menu)
3425 (gnus-summary-make-menu-bar))
3426 (gnus-turn-off-edit-menu 'article)
3427 (unless (boundp 'gnus-article-article-menu)
3429 gnus-article-article-menu gnus-article-mode-map ""
3431 ["Scroll forwards" gnus-article-goto-next-page t]
3432 ["Scroll backwards" gnus-article-goto-prev-page t]
3433 ["Show summary" gnus-article-show-summary t]
3434 ["Fetch Message-ID at point" gnus-article-refer-article t]
3435 ["Mail to address at point" gnus-article-mail t]
3436 ["Send a bug report" gnus-bug t]))
3439 gnus-article-treatment-menu gnus-article-mode-map ""
3440 ;; Fixme: this should use :active (and maybe :visible).
3442 ["Hide headers" gnus-article-hide-headers t]
3443 ["Hide signature" gnus-article-hide-signature t]
3444 ["Hide citation" gnus-article-hide-citation t]
3445 ["Treat overstrike" gnus-article-treat-overstrike t]
3446 ["Remove carriage return" gnus-article-remove-cr t]
3447 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3448 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3449 ["Remove base64" gnus-article-de-base64-unreadable t]
3450 ["Treat html" gnus-article-wash-html t]
3451 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3452 ["Decode HZ" gnus-article-decode-HZ t]))
3454 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3456 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3458 (gnus-run-hooks 'gnus-article-menu-hook)))
3460 (defun gnus-article-mode ()
3461 "Major mode for displaying an article.
3463 All normal editing commands are switched off.
3465 The following commands are available in addition to all summary mode
3467 \\<gnus-article-mode-map>
3468 \\[gnus-article-next-page]\t Scroll the article one page forwards
3469 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3470 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3471 \\[gnus-article-show-summary]\t Display the summary buffer
3472 \\[gnus-article-mail]\t Send a reply to the address near point
3473 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3474 \\[gnus-info-find-node]\t Go to the Gnus info node"
3476 (gnus-simplify-mode-line)
3477 (setq mode-name "Article")
3478 (setq major-mode 'gnus-article-mode)
3479 (make-local-variable 'minor-mode-alist)
3480 (use-local-map gnus-article-mode-map)
3481 (when (gnus-visual-p 'article-menu 'menu)
3482 (gnus-article-make-menu-bar)
3483 (when gnus-summary-tool-bar-map
3484 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3485 (gnus-update-format-specifications nil 'article-mode)
3486 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3487 (make-local-variable 'gnus-page-broken)
3488 (make-local-variable 'gnus-button-marker-list)
3489 (make-local-variable 'gnus-article-current-summary)
3490 (make-local-variable 'gnus-article-mime-handles)
3491 (make-local-variable 'gnus-article-decoded-p)
3492 (make-local-variable 'gnus-article-mime-handle-alist)
3493 (make-local-variable 'gnus-article-wash-types)
3494 (make-local-variable 'gnus-article-image-alist)
3495 (make-local-variable 'gnus-article-charset)
3496 (make-local-variable 'gnus-article-ignored-charsets)
3497 (gnus-set-default-directory)
3498 (buffer-disable-undo)
3499 (setq buffer-read-only t)
3500 (set-syntax-table gnus-article-mode-syntax-table)
3501 (mm-enable-multibyte)
3502 (gnus-run-hooks 'gnus-article-mode-hook))
3504 (defun gnus-article-setup-buffer ()
3505 "Initialize the article buffer."
3506 (let* ((name (if gnus-single-article-buffer "*Article*"
3507 (concat "*Article " gnus-newsgroup-name "*")))
3509 (progn (string-match "\\*Article" name)
3510 (concat " *Original Article"
3511 (substring name (match-end 0))))))
3512 (setq gnus-article-buffer name)
3513 (setq gnus-original-article-buffer original)
3514 (setq gnus-article-mime-handle-alist nil)
3515 ;; This might be a variable local to the summary buffer.
3516 (unless gnus-single-article-buffer
3518 (set-buffer gnus-summary-buffer)
3519 (setq gnus-article-buffer name)
3520 (setq gnus-original-article-buffer original)
3521 (gnus-set-global-variables)))
3522 (gnus-article-setup-highlight-words)
3523 ;; Init original article buffer.
3525 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3526 (mm-enable-multibyte)
3527 (setq major-mode 'gnus-original-article-mode)
3528 (make-local-variable 'gnus-original-article))
3529 (if (get-buffer name)
3532 (when (and gnus-article-edit-mode
3535 (y-or-n-p "Article mode edit in progress; discard? ")))
3536 (error "Action aborted"))
3537 (set (make-local-variable 'gnus-article-edit-mode) nil)
3538 (when gnus-article-mime-handles
3539 (mm-destroy-parts gnus-article-mime-handles)
3540 (setq gnus-article-mime-handles nil))
3541 ;; Set it to nil in article-buffer!
3542 (setq gnus-article-mime-handle-alist nil)
3543 (buffer-disable-undo)
3544 (setq buffer-read-only t)
3545 ;; This list just keeps growing if we don't reset it.
3546 (setq gnus-button-marker-list nil)
3547 (unless (eq major-mode 'gnus-article-mode)
3548 (gnus-article-mode))
3551 (set-buffer (gnus-get-buffer-create name))
3553 (make-local-variable 'gnus-summary-buffer)
3554 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3555 (current-buffer)))))
3557 ;; Set article window start at LINE, where LINE is the number of lines
3558 ;; from the head of the article.
3559 (defun gnus-article-set-window-start (&optional line)
3561 (gnus-get-buffer-window gnus-article-buffer t)
3563 (set-buffer gnus-article-buffer)
3564 (goto-char (point-min))
3567 (gnus-message 6 "Moved to bookmark")
3568 (search-forward "\n\n" nil t)
3572 (defun gnus-article-prepare (article &optional all-headers header)
3573 "Prepare ARTICLE in article mode buffer.
3574 ARTICLE should either be an article number or a Message-ID.
3575 If ARTICLE is an id, HEADER should be the article headers.
3576 If ALL-HEADERS is non-nil, no headers are hidden."
3578 ;; Make sure we start in a summary buffer.
3579 (unless (eq major-mode 'gnus-summary-mode)
3580 (set-buffer gnus-summary-buffer))
3581 (setq gnus-summary-buffer (current-buffer))
3582 (let* ((gnus-article (if header (mail-header-number header) article))
3583 (summary-buffer (current-buffer))
3584 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3585 (group gnus-newsgroup-name)
3588 (gnus-article-setup-buffer)
3589 (set-buffer gnus-article-buffer)
3590 ;; Deactivate active regions.
3591 (when (and (boundp 'transient-mark-mode)
3592 transient-mark-mode)
3593 (setq mark-active nil))
3594 (if (not (setq result (let ((buffer-read-only nil))
3595 (gnus-request-article-this-buffer
3597 ;; There is no such article.
3599 (when (and (numberp article)
3600 (not (memq article gnus-newsgroup-sparse)))
3601 (setq gnus-article-current
3602 (cons gnus-newsgroup-name article))
3603 (set-buffer gnus-summary-buffer)
3604 (setq gnus-current-article article)
3605 (if (and (memq article gnus-newsgroup-undownloaded)
3606 (not (gnus-online (gnus-find-method-for-group
3607 gnus-newsgroup-name))))
3609 (gnus-summary-set-agent-mark article)
3610 (message "Message marked for downloading"))
3611 (gnus-summary-mark-article article gnus-canceled-mark)
3612 (unless (memq article gnus-newsgroup-sparse)
3613 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3614 (if (or (eq result 'pseudo)
3615 (eq result 'nneething))
3618 (set-buffer summary-buffer)
3619 (push article gnus-newsgroup-history)
3620 (setq gnus-last-article gnus-current-article
3621 gnus-current-article 0
3622 gnus-current-headers nil
3623 gnus-article-current nil)
3624 (if (eq result 'nneething)
3625 (gnus-configure-windows 'summary)
3626 (gnus-configure-windows 'article))
3627 (gnus-set-global-variables))
3628 (let ((gnus-article-mime-handle-alist-1
3629 gnus-article-mime-handle-alist))
3630 (gnus-set-mode-line 'article)))
3631 ;; The result from the `request' was an actual article -
3632 ;; or at least some text that is now displayed in the
3634 (when (and (numberp article)
3635 (not (eq article gnus-current-article)))
3636 ;; Seems like a new article has been selected.
3637 ;; `gnus-current-article' must be an article number.
3639 (set-buffer summary-buffer)
3640 (push article gnus-newsgroup-history)
3641 (setq gnus-last-article gnus-current-article
3642 gnus-current-article article
3643 gnus-current-headers
3644 (gnus-summary-article-header gnus-current-article)
3645 gnus-article-current
3646 (cons gnus-newsgroup-name gnus-current-article))
3647 (unless (vectorp gnus-current-headers)
3648 (setq gnus-current-headers nil))
3649 (gnus-summary-goto-subject gnus-current-article)
3650 (when (gnus-summary-show-thread)
3651 ;; If the summary buffer really was folded, the
3652 ;; previous goto may not actually have gone to
3653 ;; the right article, but the thread root instead.
3655 (gnus-summary-goto-subject gnus-current-article))
3656 (gnus-run-hooks 'gnus-mark-article-hook)
3657 (gnus-set-mode-line 'summary)
3658 (when (gnus-visual-p 'article-highlight 'highlight)
3659 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3660 ;; Set the global newsgroup variables here.
3661 (gnus-set-global-variables)
3662 (setq gnus-have-all-headers
3663 (or all-headers gnus-show-all-headers))))
3665 (gnus-configure-windows 'article))
3666 (when (or (numberp article)
3668 (gnus-article-prepare-display)
3670 (goto-char (point-min))
3671 (setq gnus-page-broken
3672 (when gnus-break-pages
3673 (gnus-narrow-to-page)
3675 (let ((gnus-article-mime-handle-alist-1
3676 gnus-article-mime-handle-alist))
3677 (gnus-set-mode-line 'article))
3681 (set-window-point (get-buffer-window (current-buffer)) (point))
3682 (gnus-configure-windows 'article)
3686 (defun gnus-article-prepare-display ()
3687 "Make the current buffer look like a nice article."
3688 ;; Hooks for getting information from the article.
3689 ;; This hook must be called before being narrowed.
3690 (let ((gnus-article-buffer (current-buffer))
3692 (unless (eq major-mode 'gnus-article-mode)
3693 (gnus-article-mode))
3694 (setq buffer-read-only nil
3695 gnus-article-wash-types nil
3696 gnus-article-image-alist nil)
3697 (gnus-run-hooks 'gnus-tmp-internal-hook)
3698 (when gnus-display-mime-function
3699 (funcall gnus-display-mime-function))
3700 (gnus-run-hooks 'gnus-article-prepare-hook)))
3703 ;;; Gnus MIME viewing functions
3706 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3707 "Format of the MIME buttons.
3709 Valid specifiers include:
3711 %T MIME type, along with additional info
3712 %n The `name' parameter
3713 %d The description, if any
3714 %l The length of the encoded part
3715 %p The part identifier number
3716 %e Dots if the part isn't displayed
3718 General format specifiers can also be used. See Info node
3719 `(gnus)Formatting Variables'.")
3721 (defvar gnus-mime-button-line-format-alist
3722 '((?t gnus-tmp-type ?s)
3723 (?T gnus-tmp-type-long ?s)
3724 (?n gnus-tmp-name ?s)
3725 (?d gnus-tmp-description ?s)
3727 (?l gnus-tmp-length ?d)
3728 (?e gnus-tmp-dots ?s)))
3730 (defvar gnus-mime-button-commands
3731 '((gnus-article-press-button "\r" "Toggle Display")
3732 (gnus-mime-view-part "v" "View Interactively...")
3733 (gnus-mime-view-part-as-type "t" "View As Type...")
3734 (gnus-mime-view-part-as-charset "C" "View As charset...")
3735 (gnus-mime-save-part "o" "Save...")
3736 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3737 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3738 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3739 (gnus-mime-view-part-internally "E" "View Internally")
3740 (gnus-mime-view-part-externally "e" "View Externally")
3741 (gnus-mime-print-part "p" "Print")
3742 (gnus-mime-pipe-part "|" "Pipe To Command...")
3743 (gnus-mime-action-on-part "." "Take action on the part...")))
3745 (defun gnus-article-mime-part-status ()
3746 (if gnus-article-mime-handle-alist-1
3747 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3749 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3752 (defvar gnus-mime-button-map
3753 (let ((map (make-sparse-keymap)))
3754 (unless (>= (string-to-number emacs-version) 21)
3755 ;; XEmacs doesn't care.
3756 (set-keymap-parent map gnus-article-mode-map))
3757 (define-key map gnus-mouse-2 'gnus-article-push-button)
3758 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3759 (dolist (c gnus-mime-button-commands)
3760 (define-key map (cadr c) (car c)))
3763 (easy-menu-define gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
3765 ,@(mapcar (lambda (c)
3766 (vector (caddr c) (car c) :enable t)) gnus-mime-button-commands)))
3769 (define-compiler-macro popup-menu (&whole form
3770 menu &optional position prefix)
3771 (if (and (fboundp 'popup-menu)
3772 (not (memq 'popup-menu (assoc "lmenu" load-history))))
3774 ;; Gnus is probably running under Emacs 20.
3775 `(let* ((menu (cdr ,menu))
3776 (response (x-popup-menu
3778 (cons "" (mapcar (lambda (c)
3779 (cons (caddr c) (car c)))
3782 (call-interactively (nth 3 (assq response menu))))))))
3784 (defun gnus-mime-button-menu (event prefix)
3785 "Construct a context-sensitive menu of MIME commands."
3786 (interactive "e\nP")
3787 (save-window-excursion
3788 (let ((pos (event-start event)))
3789 (select-window (posn-window pos))
3790 (goto-char (posn-point pos))
3791 (gnus-article-check-buffer)
3792 (popup-menu gnus-mime-button-menu nil prefix))))
3794 (defun gnus-mime-view-all-parts (&optional handles)
3795 "View all the MIME parts."
3797 (save-current-buffer
3798 (set-buffer gnus-article-buffer)
3799 (let ((handles (or handles gnus-article-mime-handles))
3800 (mail-parse-charset gnus-newsgroup-charset)
3801 (mail-parse-ignored-charsets
3802 (with-current-buffer gnus-summary-buffer
3803 gnus-newsgroup-ignored-charsets)))
3805 (mm-remove-parts handles)
3806 (goto-char (point-min))
3807 (or (search-forward "\n\n") (goto-char (point-max)))
3808 (let (buffer-read-only)
3809 (delete-region (point) (point-max))
3810 (mm-display-parts handles))))))
3812 (defun gnus-mime-save-part-and-strip ()
3813 "Save the MIME part under point then replace it with an external body."
3815 (gnus-article-check-buffer)
3816 (let* ((data (get-text-property (point) 'gnus-data))
3818 (handles gnus-article-mime-handles))
3819 (if (mm-multiple-handles gnus-article-mime-handles)
3820 (error "This function is not implemented"))
3821 (setq file (and data (mm-save-part data)))
3823 (with-current-buffer (mm-handle-buffer data)
3825 (insert "Content-Type: " (mm-handle-media-type data))
3826 (mml-insert-parameter-string (cdr (mm-handle-type data))
3829 (insert "Content-ID: " (message-make-message-id) "\n")
3830 (insert "Content-Transfer-Encoding: binary\n")
3833 (cdr (mm-make-handle nil
3834 `("message/external-body"
3835 (access-type . "LOCAL-FILE")
3837 (set-buffer gnus-summary-buffer)
3838 (gnus-article-edit-article
3841 (let ((mail-parse-charset (or gnus-article-charset
3842 ',gnus-newsgroup-charset))
3843 (mail-parse-ignored-charsets
3844 (or gnus-article-ignored-charsets
3845 ',gnus-newsgroup-ignored-charsets))
3846 (mbl mml-buffer-list))
3847 (setq mml-buffer-list nil)
3848 (insert-buffer gnus-original-article-buffer)
3849 (mime-to-mml ',handles)
3850 (setq gnus-article-mime-handles nil)
3851 (let ((mbl1 mml-buffer-list))
3852 (setq mml-buffer-list mbl)
3853 (set (make-local-variable 'mml-buffer-list) mbl1))
3854 ;; LOCAL argument of add-hook differs between GNU Emacs
3855 ;; and XEmacs. make-local-hook makes sure they are local.
3856 (make-local-hook 'kill-buffer-hook)
3857 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3858 `(lambda (no-highlight)
3859 (let ((mail-parse-charset (or gnus-article-charset
3860 ',gnus-newsgroup-charset))
3861 (message-options message-options)
3862 (message-options-set-recipient)
3863 (mail-parse-ignored-charsets
3864 (or gnus-article-ignored-charsets
3865 ',gnus-newsgroup-ignored-charsets)))
3867 (mml-destroy-buffers)
3868 (remove-hook 'kill-buffer-hook
3869 'mml-destroy-buffers t)
3870 (kill-local-variable 'mml-buffer-list))
3871 (gnus-summary-edit-article-done
3872 ,(or (mail-header-references gnus-current-headers) "")
3873 ,(gnus-group-read-only-p)
3874 ,gnus-summary-buffer no-highlight))))))
3876 (defun gnus-mime-save-part ()
3877 "Save the MIME part under point."
3879 (gnus-article-check-buffer)
3880 (let ((data (get-text-property (point) 'gnus-data)))
3882 (mm-save-part data))))
3884 (defun gnus-mime-pipe-part ()
3885 "Pipe the MIME part under point to a process."
3887 (gnus-article-check-buffer)
3888 (let ((data (get-text-property (point) 'gnus-data)))
3890 (mm-pipe-part data))))
3892 (defun gnus-mime-view-part ()
3893 "Interactively choose a viewing method for the MIME part under point."
3895 (gnus-article-check-buffer)
3896 (let ((data (get-text-property (point) 'gnus-data)))
3898 (setq gnus-article-mime-handles
3900 gnus-article-mime-handles (setq data (copy-sequence data))))
3901 (mm-interactively-view-part data))))
3903 (defun gnus-mime-view-part-as-type-internal ()
3904 (gnus-article-check-buffer)
3905 (let* ((name (mail-content-type-get
3906 (mm-handle-type (get-text-property (point) 'gnus-data))
3908 (def-type (and name (mm-default-file-encoding name))))
3909 (and def-type (cons def-type 0))))
3911 (defun gnus-mime-view-part-as-type (&optional mime-type)
3912 "Choose a MIME media type, and view the part as such."
3915 (setq mime-type (completing-read
3916 "View as MIME type: "
3917 (mapcar #'list (mailcap-mime-types))
3919 (gnus-mime-view-part-as-type-internal))))
3920 (gnus-article-check-buffer)
3921 (let ((handle (get-text-property (point) 'gnus-data)))
3924 (mm-make-handle (mm-handle-buffer handle)
3925 (cons mime-type (cdr (mm-handle-type handle)))
3926 (mm-handle-encoding handle)
3927 (mm-handle-undisplayer handle)
3928 (mm-handle-disposition handle)
3929 (mm-handle-description handle)
3931 (mm-handle-id handle)))
3932 (setq gnus-article-mime-handles
3933 (mm-merge-handles gnus-article-mime-handles handle))
3934 (gnus-mm-display-part handle))))
3937 (require 'jka-compr))
3939 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
3940 ;; emacs can do that itself.
3942 (defun gnus-mime-jka-compr-maybe-uncompress ()
3943 "Uncompress the current buffer if `auto-compression-mode' is enabled.
3944 The uncompress method used is derived from `buffer-file-name'."
3945 (when (and (fboundp 'jka-compr-installed-p)
3946 (jka-compr-installed-p))
3947 (let ((info (jka-compr-get-compression-info buffer-file-name)))
3949 (let ((basename (file-name-nondirectory buffer-file-name))
3950 (args (jka-compr-info-uncompress-args info))
3951 (prog (jka-compr-info-uncompress-program info))
3952 (message (jka-compr-info-uncompress-message info))
3953 (err-file (jka-compr-make-temp-name)))
3955 (message "%s %s..." message basename))
3957 (unless (memq (apply 'call-process-region
3958 (point-min) (point-max)
3960 t (list t err-file) nil
3962 jka-compr-acceptable-retval-list)
3963 (jka-compr-error prog args basename message err-file))
3964 (jka-compr-delete-temp-file err-file)))))))
3966 (defun gnus-mime-copy-part (&optional handle)
3967 "Put the MIME part under point into a new buffer.
3968 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
3971 (gnus-article-check-buffer)
3972 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3973 (contents (and handle (mm-get-part handle)))
3975 (file-name-nondirectory
3977 (mail-content-type-get (mm-handle-type handle) 'name)
3978 (mail-content-type-get (mm-handle-disposition handle)
3981 (buffer (and base (generate-new-buffer base))))
3983 (switch-to-buffer buffer)
3985 ;; We do it this way to make `normal-mode' set the appropriate mode.
3988 (setq buffer-file-name (expand-file-name base))
3989 (gnus-mime-jka-compr-maybe-uncompress)
3991 (setq buffer-file-name nil))
3992 (goto-char (point-min)))))
3994 (defun gnus-mime-print-part (&optional handle filename)
3995 "Print the MIME part under point."
3996 (interactive (list nil (ps-print-preprint current-prefix-arg)))
3997 (gnus-article-check-buffer)
3998 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
3999 (contents (and handle (mm-get-part handle)))
4000 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4001 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4006 (mm-save-part-to-file handle file)
4007 (call-process shell-file-name nil
4008 (generate-new-buffer " *mm*")
4010 shell-command-switch
4012 printer file (mm-handle-type handle))))
4016 (gnus-print-buffer))
4017 (ps-despool filename)))))
4019 (defun gnus-mime-inline-part (&optional handle arg)
4020 "Insert the MIME part under point into the current buffer."
4021 (interactive (list nil current-prefix-arg))
4022 (gnus-article-check-buffer)
4023 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4028 (if (and (not arg) (mm-handle-undisplayer handle))
4029 (mm-remove-part handle)
4030 (setq contents (mm-get-part handle))
4033 (setq charset (or (mail-content-type-get
4034 (mm-handle-type handle) 'charset)
4035 gnus-newsgroup-charset)))
4037 (if (mm-handle-undisplayer handle)
4038 (mm-remove-part handle))
4041 gnus-summary-show-article-charset-alist))
4042 (mm-read-coding-system "Charset: ")))))
4044 (mm-insert-inline handle
4046 (setq charset (mm-charset-to-coding-system
4048 (not (eq charset 'ascii)))
4049 (mm-decode-coding-string contents charset)
4053 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4054 "Insert the MIME part under point into the current buffer using the
4056 (interactive (list nil current-prefix-arg))
4057 (gnus-article-check-buffer)
4058 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4063 (if (mm-handle-undisplayer handle)
4064 (mm-remove-part handle))
4065 (let ((gnus-newsgroup-charset
4067 gnus-summary-show-article-charset-alist))
4068 (mm-read-coding-system "Charset: ")))
4069 (gnus-newsgroup-ignored-charsets 'gnus-all))
4070 (gnus-article-press-button)))))
4072 (defun gnus-mime-view-part-externally (&optional handle)
4073 "View the MIME part under point with an external viewer."
4075 (gnus-article-check-buffer)
4076 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4077 (mm-user-display-methods nil)
4078 (mm-inlined-types nil)
4079 (mail-parse-charset gnus-newsgroup-charset)
4080 (mail-parse-ignored-charsets
4081 (save-excursion (set-buffer gnus-summary-buffer)
4082 gnus-newsgroup-ignored-charsets)))
4084 (if (mm-handle-undisplayer handle)
4085 (mm-remove-part handle)
4086 (mm-display-part handle)))))
4088 (defun gnus-mime-view-part-internally (&optional handle)
4089 "View the MIME part under point with an internal viewer.
4090 If no internal viewer is available, use an external viewer."
4092 (gnus-article-check-buffer)
4093 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4094 (mm-inlined-types '(".*"))
4095 (mm-inline-large-images t)
4096 (mail-parse-charset gnus-newsgroup-charset)
4097 (mail-parse-ignored-charsets
4098 (save-excursion (set-buffer gnus-summary-buffer)
4099 gnus-newsgroup-ignored-charsets))
4102 (if (mm-handle-undisplayer handle)
4103 (mm-remove-part handle)
4104 (mm-display-part handle)))))
4106 (defun gnus-mime-action-on-part (&optional action)
4107 "Do something with the MIME attachment at \(point\)."
4109 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4110 (gnus-article-check-buffer)
4111 (let ((action-pair (assoc action gnus-mime-action-alist)))
4113 (funcall (cdr action-pair)))))
4115 (defun gnus-article-part-wrapper (n function)
4116 (save-current-buffer
4117 (set-buffer gnus-article-buffer)
4118 (when (> n (length gnus-article-mime-handle-alist))
4119 (error "No such part"))
4120 (gnus-article-goto-part n)
4121 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4122 (funcall function handle))))
4124 (defun gnus-article-pipe-part (n)
4125 "Pipe MIME part N, which is the numerical prefix."
4127 (gnus-article-part-wrapper n 'mm-pipe-part))
4129 (defun gnus-article-save-part (n)
4130 "Save MIME part N, which is the numerical prefix."
4132 (gnus-article-part-wrapper n 'mm-save-part))
4134 (defun gnus-article-interactively-view-part (n)
4135 "View MIME part N interactively, which is the numerical prefix."
4137 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4139 (defun gnus-article-copy-part (n)
4140 "Copy MIME part N, which is the numerical prefix."
4142 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4144 (defun gnus-article-view-part-as-charset (n)
4145 "Copy MIME part N, which is the numerical prefix."
4147 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4149 (defun gnus-article-view-part-externally (n)
4150 "View MIME part N externally, which is the numerical prefix."
4152 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4154 (defun gnus-article-inline-part (n)
4155 "Inline MIME part N, which is the numerical prefix."
4157 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4159 (defun gnus-article-mime-match-handle-first (condition)
4161 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4162 (while (setq ihandle (pop alist))
4164 ((functionp condition)
4165 (funcall condition (cdr ihandle)))
4166 ((eq condition 'undisplayed)
4167 (not (or (mm-handle-undisplayer (cdr ihandle))
4168 (equal (mm-handle-media-type (cdr ihandle))
4169 "multipart/alternative"))))
4170 ((eq condition 'undisplayed-alternative)
4171 (not (mm-handle-undisplayer (cdr ihandle))))
4173 (gnus-article-goto-part (car ihandle))
4174 (or (not n) (< (car ihandle) n)))
4175 (setq n (car ihandle))))
4179 (defun gnus-article-view-part (&optional n)
4180 "View MIME part N, which is the numerical prefix."
4182 (save-current-buffer
4183 (set-buffer gnus-article-buffer)
4184 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4185 gnus-article-mime-match-handle-function)))
4186 (when (> n (length gnus-article-mime-handle-alist))
4187 (error "No such part"))
4188 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4189 (when (gnus-article-goto-part n)
4190 (if (equal (car handle) "multipart/alternative")
4191 (gnus-article-press-button)
4192 (when (eq (gnus-mm-display-part handle) 'internal)
4193 (gnus-set-window-start)))))))
4195 (defsubst gnus-article-mime-total-parts ()
4196 (if (bufferp (car gnus-article-mime-handles))
4198 (1- (length gnus-article-mime-handles))))
4200 (defun gnus-mm-display-part (handle)
4201 "Display HANDLE and fix MIME button."
4202 (let ((id (get-text-property (point) 'gnus-part))
4207 (let ((window (selected-window))
4208 (mail-parse-charset gnus-newsgroup-charset)
4209 (mail-parse-ignored-charsets
4210 (if (gnus-buffer-live-p gnus-summary-buffer)
4212 (set-buffer gnus-summary-buffer)
4213 gnus-newsgroup-ignored-charsets)
4217 (let ((win (gnus-get-buffer-window (current-buffer) t))
4220 (select-window win))
4223 (if (mm-handle-displayed-p handle)
4224 ;; This will remove the part.
4225 (mm-display-part handle)
4227 (narrow-to-region (point)
4228 (if (eobp) (point) (1+ (point))))
4229 (mm-display-part handle)
4230 ;; We narrow to the part itself and
4231 ;; then call the treatment functions.
4232 (goto-char (point-min))
4234 (narrow-to-region (point) (point-max))
4237 (gnus-article-mime-total-parts)
4238 (mm-handle-media-type handle)))))
4239 (if (window-live-p window)
4240 (select-window window)))))
4242 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
4243 (gnus-insert-mime-button
4244 handle id (list (mm-handle-displayed-p handle)))
4245 (goto-char point))))
4247 (defun gnus-article-goto-part (n)
4248 "Go to MIME part N."
4249 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
4251 (goto-char point))))
4253 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4254 (let ((gnus-tmp-name
4255 (or (mail-content-type-get (mm-handle-type handle) 'name)
4256 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4257 (mail-content-type-get (mm-handle-type handle) 'url)
4259 (gnus-tmp-type (mm-handle-media-type handle))
4260 (gnus-tmp-description
4261 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4264 (if (if displayed (car displayed)
4265 (mm-handle-displayed-p handle))
4267 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4269 gnus-tmp-type-long b e)
4270 (when (string-match ".*/" gnus-tmp-name)
4271 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4272 (setq gnus-tmp-type-long (concat gnus-tmp-type
4273 (and (not (equal gnus-tmp-name ""))
4274 (concat "; " gnus-tmp-name))))
4275 (unless (equal gnus-tmp-description "")
4276 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4281 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4282 `(,@(gnus-local-map-property gnus-mime-button-map)
4283 gnus-callback gnus-mm-display-part
4284 gnus-part ,gnus-tmp-id
4285 article-type annotation
4288 (widget-convert-button
4291 :action 'gnus-widget-press-button
4292 :button-keymap gnus-mime-button-map
4294 (lambda (widget/window &optional overlay pos)
4295 ;; Needed to properly clear the message due to a bug in
4296 ;; wid-edit (XEmacs only).
4297 (if (boundp 'help-echo-owns-message)
4298 (setq help-echo-owns-message t))
4300 "%S: %s the MIME part; %S: more options"
4301 (aref gnus-mouse-2 0)
4302 ;; XEmacs will get a single widget arg; Emacs 21 will get
4303 ;; window, overlay, position.
4304 (if (mm-handle-displayed-p
4306 (with-current-buffer (gnus-overlay-buffer overlay)
4307 (widget-get (widget-at (gnus-overlay-start overlay))
4309 (widget-get widget/window :mime-handle)))
4311 (aref gnus-down-mouse-3 0))))))
4313 (defun gnus-widget-press-button (elems el)
4314 (goto-char (widget-get elems :from))
4315 (gnus-article-press-button))
4317 (defvar gnus-displaying-mime nil)
4319 (defun gnus-display-mime (&optional ihandles)
4320 "Display the MIME parts."
4322 (save-selected-window
4323 (let ((window (get-buffer-window gnus-article-buffer))
4326 (select-window window)
4327 ;; We have to do this since selecting the window
4328 ;; may change the point. So we set the window point.
4329 (set-window-point window point)))
4330 (let* ((handles (or ihandles
4331 (mm-dissect-buffer nil gnus-article-loose-mime)
4332 (and gnus-article-emulate-mime
4334 buffer-read-only handle name type b e display)
4335 (when (and (not ihandles)
4336 (not gnus-displaying-mime))
4337 ;; Top-level call; we clean up.
4338 (when gnus-article-mime-handles
4339 (mm-destroy-parts gnus-article-mime-handles)
4340 (setq gnus-article-mime-handle-alist nil));; A trick.
4341 (setq gnus-article-mime-handles handles)
4342 ;; We allow users to glean info from the handles.
4343 (when gnus-article-mime-part-function
4344 (gnus-mime-part-function handles)))
4346 (or (not (stringp (car handles)))
4349 (when (and (not ihandles)
4350 (not gnus-displaying-mime))
4351 ;; Clean up for mime parts.
4353 (delete-region (point) (point-max)))
4354 (let ((gnus-displaying-mime t))
4355 (gnus-mime-display-part handles)))
4358 (narrow-to-region (point) (point-max))
4359 (gnus-treat-article nil 1 1)
4362 ;; Highlight the headers.
4366 (narrow-to-region (point-min) (point))
4367 (gnus-treat-article 'head))))))))
4369 (defvar gnus-mime-display-multipart-as-mixed nil)
4370 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
4371 (defvar gnus-mime-display-multipart-related-as-mixed nil)
4373 (defun gnus-mime-display-part (handle)
4376 ((not (stringp (car handle)))
4377 (gnus-mime-display-single handle))
4378 ;; User-defined multipart
4379 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4380 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4382 ;; multipart/alternative
4383 ((and (equal (car handle) "multipart/alternative")
4384 (not (or gnus-mime-display-multipart-as-mixed
4385 gnus-mime-display-multipart-alternative-as-mixed)))
4386 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4387 (push (cons id handle) gnus-article-mime-handle-alist)
4388 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4389 ;; multipart/related
4390 ((and (equal (car handle) "multipart/related")
4391 (not (or gnus-mime-display-multipart-as-mixed
4392 gnus-mime-display-multipart-related-as-mixed)))
4393 ;;;!!!We should find the start part, but we just default
4394 ;;;!!!to the first part.
4395 ;;(gnus-mime-display-part (cadr handle))
4396 ;;;!!! Most multipart/related is an HTML message plus images.
4397 ;;;!!! Unfortunately we are unable to let W3 display those
4398 ;;;!!! included images, so we just display it as a mixed multipart.
4399 ;;(gnus-mime-display-mixed (cdr handle))
4400 ;;;!!! No, w3 can display everything just fine.
4401 (gnus-mime-display-part (cadr handle)))
4402 ((equal (car handle) "multipart/signed")
4403 (gnus-add-wash-type 'signed)
4404 (gnus-mime-display-security handle))
4405 ((equal (car handle) "multipart/encrypted")
4406 (gnus-add-wash-type 'encrypted)
4407 (gnus-mime-display-security handle))
4408 ;; Other multiparts are handled like multipart/mixed.
4410 (gnus-mime-display-mixed (cdr handle)))))
4412 (defun gnus-mime-part-function (handles)
4413 (if (stringp (car handles))
4414 (mapcar 'gnus-mime-part-function (cdr handles))
4415 (funcall gnus-article-mime-part-function handles)))
4417 (defun gnus-mime-display-mixed (handles)
4418 (mapcar 'gnus-mime-display-part handles))
4420 (defun gnus-mime-display-single (handle)
4421 (let ((type (mm-handle-media-type handle))
4422 (ignored gnus-ignored-mime-types)
4429 (when (string-match (pop ignored) type)
4430 (throw 'ignored nil)))
4431 (if (and (setq not-attachment
4432 (and (not (mm-inline-override-p handle))
4433 (or (not (mm-handle-disposition handle))
4434 (equal (car (mm-handle-disposition handle))
4436 (mm-attachment-override-p handle))))
4437 (mm-automatic-display-p handle)
4439 (mm-inlinable-p handle)
4440 (mm-inlined-p handle))
4441 (mm-automatic-external-display-p type)))
4443 (when (equal (mm-handle-media-supertype handle) "text")
4445 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4447 (push (cons id handle) gnus-article-mime-handle-alist)
4448 (when (or (not display)
4449 (not (gnus-unbuttonized-mime-type-p type)))
4450 ;(gnus-article-insert-newline)
4451 (gnus-insert-mime-button
4452 handle id (list (or display (and not-attachment text))))
4453 (gnus-article-insert-newline)
4454 ;(gnus-article-insert-newline)
4455 ;; Remember modify the number of forward lines.
4463 (let ((mail-parse-charset gnus-newsgroup-charset)
4464 (mail-parse-ignored-charsets
4465 (save-excursion (condition-case ()
4466 (set-buffer gnus-summary-buffer)
4468 gnus-newsgroup-ignored-charsets)))
4469 (mm-display-part handle t))
4470 (goto-char (point-max)))
4471 ((and text not-attachment)
4475 (gnus-article-insert-newline)
4476 (mm-insert-inline handle (mm-get-part handle))
4477 (goto-char (point-max))))
4481 (narrow-to-region beg (point))
4484 (gnus-article-mime-total-parts)
4485 (mm-handle-media-type handle)))))))))
4487 (defun gnus-unbuttonized-mime-type-p (type)
4488 "Say whether TYPE is to be unbuttonized."
4489 (unless gnus-inhibit-mime-unbuttonizing
4491 (let ((types gnus-unbuttonized-mime-types))
4493 (when (string-match (pop types) type)
4494 (throw 'found t)))))
4496 (let ((types gnus-buttonized-mime-types))
4498 (when (string-match (pop types) type)
4499 (throw 'found t)))))))))
4501 (defun gnus-article-insert-newline ()
4502 "Insert a newline, but mark it as undeletable."
4503 (gnus-put-text-property
4504 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4506 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4507 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4510 handle buffer-read-only from props begend not-pref)
4511 (save-window-excursion
4514 (narrow-to-region (car ibegend)
4517 (goto-char (car ibegend))
4520 (delete-region (point-min) (point-max))
4521 (mm-remove-parts handles))
4522 (setq begend (list (point-marker)))
4524 (unless (setq not-pref (cadr (member preferred ihandles)))
4525 (setq not-pref (car ihandles)))
4528 (not (gnus-unbuttonized-mime-type-p
4529 "multipart/alternative")))
4530 (gnus-add-text-properties
4533 (insert (format "%d. " id))
4537 (unless ,(not ibegend)
4538 (setq gnus-article-mime-handle-alist
4539 ',gnus-article-mime-handle-alist))
4540 (gnus-mime-display-alternative
4541 ',ihandles ',not-pref ',begend ,id))
4542 ,@(gnus-local-map-property gnus-mime-button-map)
4543 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4544 face ,gnus-article-button-face
4547 (widget-convert-button 'link from (point)
4548 :action 'gnus-widget-press-button
4549 :button-keymap gnus-widget-button-keymap)
4551 (while (setq handle (pop handles))
4552 (gnus-add-text-properties
4555 (insert (format "(%c) %-18s"
4556 (if (equal handle preferred) ?* ? )
4557 (mm-handle-media-type handle)))
4561 (unless ,(not ibegend)
4562 (setq gnus-article-mime-handle-alist
4563 ',gnus-article-mime-handle-alist))
4564 (gnus-mime-display-alternative
4565 ',ihandles ',handle ',begend ,id))
4566 ,@(gnus-local-map-property gnus-mime-button-map)
4567 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4568 face ,gnus-article-button-face
4571 (widget-convert-button 'link from (point)
4572 :action 'gnus-widget-press-button
4573 :button-keymap gnus-widget-button-keymap)
4577 (if (stringp (car preferred))
4578 (gnus-display-mime preferred)
4579 (let ((mail-parse-charset gnus-newsgroup-charset)
4580 (mail-parse-ignored-charsets
4581 (save-excursion (set-buffer gnus-summary-buffer)
4582 gnus-newsgroup-ignored-charsets)))
4583 (mm-display-part preferred)
4587 (narrow-to-region (car begend) (point-max))
4589 nil (length gnus-article-mime-handle-alist)
4590 (gnus-article-mime-total-parts)
4591 (mm-handle-media-type handle))))))
4592 (goto-char (point-max))
4593 (setcdr begend (point-marker)))))
4595 (goto-char point))))
4597 (defconst gnus-article-wash-status-strings
4598 (let ((alist '((cite "c" "Possible hidden citation text"
4599 " " "All citation text visible")
4600 (headers "h" "Hidden headers"
4601 " " "All headers visible.")
4602 (pgp "p" "Encrypted or signed message status hidden"
4603 " " "No hidden encryption nor digital signature status")
4604 (signature "s" "Signature has been hidden"
4605 " " "Signature is visible")
4606 (overstrike "o" "Overstrike (^H) characters applied"
4607 " " "No overstrike characters applied")
4608 (emphasis "e" "/*_Emphasis_*/ characters applied"
4609 " " "No /*_emphasis_*/ characters applied")))
4611 (dolist (entry alist result)
4612 (let ((key (nth 0 entry))
4613 (on (copy-sequence (nth 1 entry)))
4614 (on-help (nth 2 entry))
4615 (off (copy-sequence (nth 3 entry)))
4616 (off-help (nth 4 entry)))
4617 (put-text-property 0 1 'help-echo on-help on)
4618 (put-text-property 0 1 'help-echo off-help off)
4619 (push (list key on off) result))))
4620 "Alist of strings describing wash status in the mode line.
4621 Each entry has the form (KEY ON OF), where the KEY is a symbol
4622 representing the particular washing function, ON is the string to use
4623 in the article mode line when the washing function is active, and OFF
4624 is the string to use when it is inactive.")
4626 (defun gnus-article-wash-status-entry (key value)
4627 (let ((entry (assoc key gnus-article-wash-status-strings)))
4628 (if value (nth 1 entry) (nth 2 entry))))
4630 (defun gnus-article-wash-status ()
4631 "Return a string which display status of article washing."
4633 (set-buffer gnus-article-buffer)
4634 (let ((cite (memq 'cite gnus-article-wash-types))
4635 (headers (memq 'headers gnus-article-wash-types))
4636 (boring (memq 'boring-headers gnus-article-wash-types))
4637 (pgp (memq 'pgp gnus-article-wash-types))
4638 (pem (memq 'pem gnus-article-wash-types))
4639 (signed (memq 'signed gnus-article-wash-types))
4640 (encrypted (memq 'encrypted gnus-article-wash-types))
4641 (signature (memq 'signature gnus-article-wash-types))
4642 (overstrike (memq 'overstrike gnus-article-wash-types))
4643 (emphasis (memq 'emphasis gnus-article-wash-types)))
4645 (gnus-article-wash-status-entry 'cite cite)
4646 (gnus-article-wash-status-entry 'headers (or headers boring))
4647 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4648 (gnus-article-wash-status-entry 'signature signature)
4649 (gnus-article-wash-status-entry 'overstrike overstrike)
4650 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4652 (defun gnus-add-wash-type (type)
4653 "Add a washing of TYPE to the current status."
4654 (add-to-list 'gnus-article-wash-types type))
4656 (defun gnus-delete-wash-type (type)
4657 "Add a washing of TYPE to the current status."
4658 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4660 (defun gnus-add-image (category image)
4661 "Add IMAGE of CATEGORY to the list of displayed images."
4662 (let ((entry (assq category gnus-article-image-alist)))
4664 (setq entry (list category))
4665 (push entry gnus-article-image-alist))
4666 (nconc entry (list image))))
4668 (defun gnus-delete-images (category)
4669 "Delete all images in CATEGORY."
4670 (let ((entry (assq category gnus-article-image-alist)))
4671 (dolist (image (cdr entry))
4672 (gnus-remove-image image))
4673 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
4674 (gnus-delete-wash-type category)))
4676 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
4678 (defun gnus-article-maybe-hide-headers ()
4679 "Hide unwanted headers if `gnus-have-all-headers' is nil.
4680 Provided for backwards compatibility."
4681 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
4682 (not (save-excursion (set-buffer gnus-summary-buffer)
4683 gnus-have-all-headers)))
4684 (not gnus-inhibit-hiding))
4685 (gnus-article-hide-headers)))
4689 (defun gnus-output-to-file (file-name)
4690 "Append the current article to a file named FILE-NAME."
4691 (let ((artbuf (current-buffer)))
4693 (insert-buffer-substring artbuf)
4694 ;; Append newline at end of the buffer as separator, and then
4696 (goto-char (point-max))
4698 (let ((file-name-coding-system nnmail-pathname-coding-system))
4699 (mm-append-to-file (point-min) (point-max) file-name))
4702 (defun gnus-narrow-to-page (&optional arg)
4703 "Narrow the article buffer to a page.
4704 If given a numerical ARG, move forward ARG pages."
4706 (setq arg (if arg (prefix-numeric-value arg) 0))
4708 (set-buffer gnus-article-buffer)
4709 (goto-char (point-min))
4711 ;; Remove any old next/prev buttons.
4712 (when (gnus-visual-p 'page-marker)
4713 (let ((buffer-read-only nil))
4714 (gnus-remove-text-with-property 'gnus-prev)
4715 (gnus-remove-text-with-property 'gnus-next)))
4718 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
4720 (re-search-forward page-delimiter nil 'move arg)))
4721 (goto-char (match-end 0)))
4724 (if (re-search-forward page-delimiter nil 'move)
4727 (when (and (gnus-visual-p 'page-marker)
4728 (not (= (point-min) 1)))
4730 (goto-char (point-min))
4731 (gnus-insert-prev-page-button)))
4732 (when (and (gnus-visual-p 'page-marker)
4733 (< (+ (point-max) 2) (buffer-size)))
4735 (goto-char (point-max))
4736 (gnus-insert-next-page-button)))))
4738 ;; Article mode commands
4740 (defun gnus-article-goto-next-page ()
4741 "Show the next page of the article."
4743 (gnus-eval-in-buffer-window gnus-summary-buffer
4744 (gnus-summary-next-page)))
4746 (defun gnus-article-goto-prev-page ()
4747 "Show the next page of the article."
4749 (gnus-eval-in-buffer-window gnus-summary-buffer
4750 (gnus-summary-prev-page)))
4752 (defun gnus-article-next-page (&optional lines)
4753 "Show the next page of the current article.
4754 If end of article, return non-nil. Otherwise return nil.
4755 Argument LINES specifies lines to be scrolled up."
4757 (move-to-window-line -1)
4760 (and (pos-visible-in-window-p) ;Not continuation line.
4761 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
4762 ;; Nothing in this page.
4763 (if (or (not gnus-page-broken)
4766 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
4768 (gnus-narrow-to-page 1) ;Go to next page.
4770 ;; More in this page.
4771 (let ((scroll-in-place nil))
4775 ;; Long lines may cause an end-of-buffer error.
4776 (goto-char (point-max)))))
4777 (move-to-window-line 0)
4780 (defun gnus-article-prev-page (&optional lines)
4781 "Show previous page of current article.
4782 Argument LINES specifies lines to be scrolled down."
4784 (move-to-window-line 0)
4785 (if (and gnus-page-broken
4787 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
4789 (gnus-narrow-to-page -1) ;Go to previous page.
4790 (goto-char (point-max))
4792 (let ((scroll-in-place nil))
4796 (beginning-of-buffer
4797 (goto-char (point-min))))
4798 (move-to-window-line 0)))))
4800 (defun gnus-article-only-boring-p ()
4801 "Decide whether there is only boring text remaining in the article.
4802 Something \"interesting\" is a word of at least two letters that does
4803 not have a face in `gnus-article-boring-faces'."
4804 (when (and gnus-article-skip-boring
4805 (boundp 'gnus-article-boring-faces)
4806 (symbol-value 'gnus-article-boring-faces))
4809 (while (re-search-forward "\\b\\w\\w" nil t)
4811 (when (not (gnus-intersection
4812 (gnus-faces-at (point))
4813 (symbol-value 'gnus-article-boring-faces)))
4814 (throw 'only-boring nil)))
4815 (throw 'only-boring t)))))
4817 (defun gnus-article-refer-article ()
4818 "Read article specified by message-id around point."
4821 (re-search-backward "<?news:\\|<" (gnus-point-at-bol) t)
4822 (cond ((re-search-forward
4823 gnus-button-mid-or-mail-regexp (gnus-point-at-eol) t)
4824 (let ((msg-id (concat "<" (match-string 0) ">")))
4825 (set-buffer gnus-summary-buffer)
4826 (gnus-summary-refer-article msg-id)))
4828 (error "No references around point")))))
4830 (defun gnus-article-show-summary ()
4831 "Reconfigure windows to show summary buffer."
4833 (if (not (gnus-buffer-live-p gnus-summary-buffer))
4834 (error "There is no summary buffer for this article buffer")
4835 (gnus-article-set-globals)
4836 (gnus-configure-windows 'article)
4837 (gnus-summary-goto-subject gnus-current-article)
4838 (gnus-summary-position-point)))
4840 (defun gnus-article-describe-briefly ()
4841 "Describe article mode commands briefly."
4843 (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")))
4845 (defun gnus-article-summary-command ()
4846 "Execute the last keystroke in the summary buffer."
4848 (let ((obuf (current-buffer))
4849 (owin (current-window-configuration))
4851 (switch-to-buffer gnus-article-current-summary 'norecord)
4852 (setq func (lookup-key (current-local-map) (this-command-keys)))
4853 (call-interactively func)
4855 (set-window-configuration owin)
4856 (set-window-point (get-buffer-window (current-buffer)) (point))))
4858 (defun gnus-article-summary-command-nosave ()
4859 "Execute the last keystroke in the summary buffer."
4862 (pop-to-buffer gnus-article-current-summary 'norecord)
4863 (setq func (lookup-key (current-local-map) (this-command-keys)))
4864 (call-interactively func)))
4866 (defun gnus-article-check-buffer ()
4867 "Beep if not in an article buffer."
4868 (unless (equal major-mode 'gnus-article-mode)
4869 (error "Command invoked outside of a Gnus article buffer")))
4871 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
4872 "Read a summary buffer key sequence and execute it from the article buffer."
4874 (gnus-article-check-buffer)
4876 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
4877 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
4878 "=" "^" "\M-^" "|"))
4884 '("n" "Gn" "p" "Gp"))
4887 (set-buffer gnus-article-current-summary)
4888 (let (gnus-pick-mode)
4889 (push (or key last-command-event) unread-command-events)
4890 (setq keys (if (featurep 'xemacs)
4891 (events-to-keys (read-key-sequence nil))
4892 (read-key-sequence nil)))))
4896 (if (or (member keys nosaves)
4897 (member keys nosave-but-article)
4898 (member keys nosave-in-article))
4900 (save-window-excursion
4901 (pop-to-buffer gnus-article-current-summary 'norecord)
4902 ;; We disable the pick minor mode commands.
4903 (let (gnus-pick-mode)
4904 (setq func (lookup-key (current-local-map) keys))))
4908 (unless (member keys nosave-in-article)
4909 (set-buffer gnus-article-current-summary))
4910 (call-interactively func)
4911 (setq new-sum-point (point)))
4912 (when (member keys nosave-but-article)
4913 (pop-to-buffer gnus-article-buffer 'norecord)))
4914 ;; These commands should restore window configuration.
4915 (let ((obuf (current-buffer))
4916 (owin (current-window-configuration))
4918 (summary gnus-article-current-summary)
4919 func in-buffer selected)
4920 (if not-restore-window
4921 (pop-to-buffer summary 'norecord)
4922 (switch-to-buffer summary 'norecord))
4923 (setq in-buffer (current-buffer))
4924 ;; We disable the pick minor mode commands.
4925 (if (and (setq func (let (gnus-pick-mode)
4926 (lookup-key (current-local-map) keys)))
4929 (call-interactively func)
4930 (setq new-sum-point (point))
4931 (when (eq in-buffer (current-buffer))
4932 (setq selected (gnus-summary-select-article))
4934 (unless not-restore-window
4935 (set-window-configuration owin))
4936 (when (eq selected 'old)
4938 (set-window-start (get-buffer-window (current-buffer))
4940 (set-window-point (get-buffer-window (current-buffer))
4942 (let ((win (get-buffer-window gnus-article-current-summary)))
4944 (set-window-point win new-sum-point)))) )
4945 (switch-to-buffer gnus-article-buffer)
4948 (defun gnus-article-describe-key (key)
4949 "Display documentation of the function invoked by KEY. KEY is a string."
4950 (interactive "kDescribe key: ")
4951 (gnus-article-check-buffer)
4952 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4954 (set-buffer gnus-article-current-summary)
4955 (let (gnus-pick-mode)
4956 (if (featurep 'xemacs)
4958 (push (elt key 0) unread-command-events)
4959 (setq key (events-to-keys
4960 (read-key-sequence "Describe key: "))))
4961 (setq unread-command-events
4963 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4964 (string-to-list key)))
4965 (setq key (read-key-sequence "Describe key: "))))
4967 (describe-key key)))
4969 (defun gnus-article-describe-key-briefly (key &optional insert)
4970 "Display documentation of the function invoked by KEY. KEY is a string."
4971 (interactive "kDescribe key: \nP")
4972 (gnus-article-check-buffer)
4973 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
4975 (set-buffer gnus-article-current-summary)
4976 (let (gnus-pick-mode)
4977 (if (featurep 'xemacs)
4979 (push (elt key 0) unread-command-events)
4980 (setq key (events-to-keys
4981 (read-key-sequence "Describe key: "))))
4982 (setq unread-command-events
4984 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
4985 (string-to-list key)))
4986 (setq key (read-key-sequence "Describe key: "))))
4987 (describe-key-briefly key insert))
4988 (describe-key-briefly key insert)))
4990 (defun gnus-article-reply-with-original (&optional wide)
4991 "Start composing a reply mail to the current message.
4992 The text in the region will be yanked. If the region isn't active,
4993 the entire article will be yanked."
4995 (let ((article (cdr gnus-article-current))
4997 (if (not (gnus-mark-active-p))
4998 (with-current-buffer gnus-summary-buffer
4999 (gnus-summary-reply (list (list article)) wide))
5000 (setq contents (buffer-substring (point) (mark t)))
5001 ;; Deactivate active regions.
5002 (when (and (boundp 'transient-mark-mode)
5003 transient-mark-mode)
5004 (setq mark-active nil))
5005 (with-current-buffer gnus-summary-buffer
5007 (list (list article contents)) wide)))))
5009 (defun gnus-article-followup-with-original ()
5010 "Compose a followup to the current article.
5011 The text in the region will be yanked. If the region isn't active,
5012 the entire article will be yanked."
5014 (let ((article (cdr gnus-article-current))
5016 (if (not (gnus-mark-active-p))
5017 (with-current-buffer gnus-summary-buffer
5018 (gnus-summary-followup (list (list article))))
5019 (setq contents (buffer-substring (point) (mark t)))
5020 ;; Deactivate active regions.
5021 (when (and (boundp 'transient-mark-mode)
5022 transient-mark-mode)
5023 (setq mark-active nil))
5024 (with-current-buffer gnus-summary-buffer
5025 (gnus-summary-followup
5026 (list (list article contents)))))))
5028 (defun gnus-article-hide (&optional arg force)
5029 "Hide all the gruft in the current article.
5030 This means that signatures, cited text and (some) headers will be
5032 If given a prefix, show the hidden text instead."
5033 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5034 (gnus-article-hide-headers arg)
5035 (gnus-article-hide-list-identifiers arg)
5036 (gnus-article-hide-citation-maybe arg force)
5037 (gnus-article-hide-signature arg))
5039 (defun gnus-article-maybe-highlight ()
5040 "Do some article highlighting if article highlighting is requested."
5041 (when (gnus-visual-p 'article-highlight 'highlight)
5042 (gnus-article-highlight-some)))
5044 (defun gnus-check-group-server ()
5045 ;; Make sure the connection to the server is alive.
5046 (unless (gnus-server-opened
5047 (gnus-find-method-for-group gnus-newsgroup-name))
5048 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5049 (gnus-request-group gnus-newsgroup-name t)))
5052 (autoload 'nneething-get-file-name "nneething"))
5054 (defun gnus-request-article-this-buffer (article group)
5055 "Get an article and insert it into this buffer."
5056 (let (do-update-line sparse-header)
5060 (gnus-kill-all-overlays)
5061 (setq group (or group gnus-newsgroup-name))
5063 ;; Using `gnus-request-article' directly will insert the article into
5064 ;; `nntp-server-buffer' - so we'll save some time by not having to
5065 ;; copy it from the server buffer into the article buffer.
5067 ;; We only request an article by message-id when we do not have the
5068 ;; headers for it, so we'll have to get those.
5069 (when (stringp article)
5070 (gnus-read-header article))
5072 ;; If the article number is negative, that means that this article
5073 ;; doesn't belong in this newsgroup (possibly), so we find its
5074 ;; message-id and request it by id instead of number.
5075 (when (and (numberp article)
5077 (get-buffer gnus-summary-buffer)
5078 (gnus-buffer-exists-p gnus-summary-buffer))
5080 (set-buffer gnus-summary-buffer)
5081 (let ((header (gnus-summary-article-header article)))
5084 ((memq article gnus-newsgroup-sparse)
5085 ;; This is a sparse gap article.
5086 (setq do-update-line article)
5087 (setq article (mail-header-id header))
5088 (setq sparse-header (gnus-read-header article))
5089 (setq gnus-newsgroup-sparse
5090 (delq article gnus-newsgroup-sparse)))
5092 ;; It's a real article.
5093 (setq article (mail-header-id header)))
5095 ;; It is an extracted pseudo-article.
5096 (setq article 'pseudo)
5097 (gnus-request-pseudo-article header))))
5099 (let ((method (gnus-find-method-for-group
5100 gnus-newsgroup-name)))
5101 (when (and (eq (car method) 'nneething)
5103 (let ((dir (nneething-get-file-name
5104 (mail-header-id header))))
5105 (when (and (stringp dir)
5106 (file-directory-p dir))
5107 (setq article 'nneething)
5108 (gnus-group-enter-directory dir))))))))
5111 ;; Refuse to select canceled articles.
5112 ((and (numberp article)
5114 (get-buffer gnus-summary-buffer)
5115 (gnus-buffer-exists-p gnus-summary-buffer)
5116 (eq (cdr (save-excursion
5117 (set-buffer gnus-summary-buffer)
5118 (assq article gnus-newsgroup-reads)))
5119 gnus-canceled-mark))
5121 ;; We first check `gnus-original-article-buffer'.
5122 ((and (get-buffer gnus-original-article-buffer)
5125 (set-buffer gnus-original-article-buffer)
5126 (and (equal (car gnus-original-article) group)
5127 (eq (cdr gnus-original-article) article))))
5128 (insert-buffer-substring gnus-original-article-buffer)
5130 ;; Check the backlog.
5131 ((and gnus-keep-backlog
5132 (gnus-backlog-request-article group article (current-buffer)))
5134 ;; Check asynchronous pre-fetch.
5135 ((gnus-async-request-fetched-article group article (current-buffer))
5136 (gnus-async-prefetch-next group article gnus-summary-buffer)
5137 (when (and (numberp article) gnus-keep-backlog)
5138 (gnus-backlog-enter-article group article (current-buffer)))
5141 ((and gnus-use-cache
5143 (gnus-cache-request-article article group))
5145 ;; Check the agent cache.
5146 ((and gnus-agent gnus-agent-cache gnus-plugged
5148 (gnus-agent-request-article article group))
5150 ;; Get the article and put into the article buffer.
5151 ((or (stringp article)
5153 (let ((gnus-override-method gnus-override-method)
5154 (methods (and (stringp article)
5155 gnus-refer-article-method))
5156 (backend (car (gnus-find-method-for-group
5157 gnus-newsgroup-name)))
5159 (buffer-read-only nil))
5160 (if (or (not (listp methods))
5161 (and (symbolp (car methods))
5162 (assq (car methods) nnoo-definition-alist)))
5163 (setq methods (list methods)))
5164 (when (and (null gnus-override-method)
5166 (setq gnus-override-method (pop methods)))
5168 (when (eq gnus-override-method 'current)
5169 (setq gnus-override-method
5170 (with-current-buffer gnus-summary-buffer
5171 gnus-current-select-method)))
5173 (gnus-kill-all-overlays)
5174 (let ((gnus-newsgroup-name group))
5175 (gnus-check-group-server))
5177 ((gnus-request-article article group (current-buffer))
5178 (when (numberp article)
5179 (gnus-async-prefetch-next group article
5180 gnus-summary-buffer)
5181 (when gnus-keep-backlog
5182 (gnus-backlog-enter-article
5183 group article (current-buffer))))
5184 (setq result 'article))
5186 (setq gnus-override-method (pop methods)))
5187 ((not (string-match "^400 "
5188 (nnheader-get-report backend)))
5189 ;; If we get 400 server disconnect, reconnect and
5190 ;; retry; otherwise, assume the article has expired.
5191 (setq result 'done))))
5192 (and (eq result 'article) 'article)))
5196 ;; Associate this article with the current summary buffer.
5197 (setq gnus-article-current-summary gnus-summary-buffer)
5199 ;; Take the article from the original article buffer
5200 ;; and place it in the buffer it's supposed to be in.
5201 (when (and (get-buffer gnus-article-buffer)
5202 (equal (buffer-name (current-buffer))
5203 (buffer-name (get-buffer gnus-article-buffer))))
5205 (if (get-buffer gnus-original-article-buffer)
5206 (set-buffer gnus-original-article-buffer)
5207 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5208 (buffer-disable-undo)
5209 (setq major-mode 'gnus-original-article-mode)
5210 (setq buffer-read-only t))
5211 (let (buffer-read-only)
5213 (insert-buffer-substring gnus-article-buffer))
5214 (setq gnus-original-article (cons group article)))
5217 (run-hooks 'gnus-article-decode-hook)
5218 ;; Mark article as decoded or not.
5219 (setq gnus-article-decoded-p gnus-article-decode-hook))
5221 ;; Update sparse articles.
5222 (when (and do-update-line
5223 (or (numberp article)
5225 (let ((buf (current-buffer)))
5226 (set-buffer gnus-summary-buffer)
5227 (gnus-summary-update-article do-update-line sparse-header)
5228 (gnus-summary-goto-subject do-update-line nil t)
5229 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5231 (set-buffer buf))))))
5237 (defcustom gnus-article-edit-mode-hook nil
5238 "Hook run in article edit mode buffers."
5239 :group 'gnus-article-various
5242 (defvar gnus-article-edit-done-function nil)
5244 (defvar gnus-article-edit-mode-map nil)
5245 (defvar gnus-article-edit-mode nil)
5247 ;; Should we be using derived.el for this?
5248 (unless gnus-article-edit-mode-map
5249 (setq gnus-article-edit-mode-map (make-keymap))
5250 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5252 (gnus-define-keys gnus-article-edit-mode-map
5253 "\C-c?" describe-mode
5254 "\C-c\C-c" gnus-article-edit-done
5255 "\C-c\C-k" gnus-article-edit-exit
5256 "\C-c\C-f\C-t" message-goto-to
5257 "\C-c\C-f\C-o" message-goto-from
5258 "\C-c\C-f\C-b" message-goto-bcc
5259 ;;"\C-c\C-f\C-w" message-goto-fcc
5260 "\C-c\C-f\C-c" message-goto-cc
5261 "\C-c\C-f\C-s" message-goto-subject
5262 "\C-c\C-f\C-r" message-goto-reply-to
5263 "\C-c\C-f\C-n" message-goto-newsgroups
5264 "\C-c\C-f\C-d" message-goto-distribution
5265 "\C-c\C-f\C-f" message-goto-followup-to
5266 "\C-c\C-f\C-m" message-goto-mail-followup-to
5267 "\C-c\C-f\C-k" message-goto-keywords
5268 "\C-c\C-f\C-u" message-goto-summary
5269 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5270 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5271 "\C-c\C-b" message-goto-body
5272 "\C-c\C-i" message-goto-signature
5274 "\C-c\C-t" message-insert-to
5275 "\C-c\C-n" message-insert-newsgroups
5276 "\C-c\C-o" message-sort-headers
5277 "\C-c\C-e" message-elide-region
5278 "\C-c\C-v" message-delete-not-region
5279 "\C-c\C-z" message-kill-to-signature
5280 "\M-\r" message-newline-and-reformat
5281 "\C-c\C-a" mml-attach-file
5282 "\C-a" message-beginning-of-line
5284 "\M-;" comment-region)
5286 (gnus-define-keys (gnus-article-edit-wash-map
5287 "\C-c\C-w" gnus-article-edit-mode-map)
5288 "f" gnus-article-edit-full-stops))
5291 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5293 ["Fetch To" message-insert-to t]
5294 ["Fetch Newsgroups" message-insert-newsgroups t]
5296 ["To" message-goto-to t]
5297 ["From" message-goto-from t]
5298 ["Subject" message-goto-subject t]
5299 ["Cc" message-goto-cc t]
5300 ["Reply-To" message-goto-reply-to t]
5301 ["Summary" message-goto-summary t]
5302 ["Keywords" message-goto-keywords t]
5303 ["Newsgroups" message-goto-newsgroups t]
5304 ["Followup-To" message-goto-followup-to t]
5305 ["Mail-Followup-To" message-goto-mail-followup-to t]
5306 ["Distribution" message-goto-distribution t]
5307 ["Body" message-goto-body t]
5308 ["Signature" message-goto-signature t]))
5310 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5311 "Major mode for editing articles.
5312 This is an extended text-mode.
5314 \\{gnus-article-edit-mode-map}"
5315 (make-local-variable 'gnus-article-edit-done-function)
5316 (make-local-variable 'gnus-prev-winconf)
5317 (set (make-local-variable 'font-lock-defaults)
5318 '(message-font-lock-keywords t))
5319 (set (make-local-variable 'mail-header-separator) "")
5320 (set (make-local-variable 'gnus-article-edit-mode) t)
5321 (easy-menu-add message-mode-field-menu message-mode-map)
5323 (setq buffer-read-only nil)
5324 (buffer-enable-undo)
5327 (defun gnus-article-edit (&optional force)
5328 "Edit the current article.
5329 This will have permanent effect only in mail groups.
5330 If FORCE is non-nil, allow editing of articles even in read-only
5333 (when (and (not force)
5334 (gnus-group-read-only-p))
5335 (error "The current newsgroup does not support article editing"))
5336 (gnus-article-date-original)
5337 (gnus-article-edit-article
5339 `(lambda (no-highlight)
5341 (gnus-summary-edit-article-done
5342 ,(or (mail-header-references gnus-current-headers) "")
5343 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5345 (defun gnus-article-edit-article (start-func exit-func)
5346 "Start editing the contents of the current article buffer."
5347 (let ((winconf (current-window-configuration)))
5348 (set-buffer gnus-article-buffer)
5349 (gnus-article-edit-mode)
5350 (funcall start-func)
5351 (set-buffer-modified-p nil)
5352 (gnus-configure-windows 'edit-article)
5353 (setq gnus-article-edit-done-function exit-func)
5354 (setq gnus-prev-winconf winconf)
5355 (gnus-message 6 "C-c C-c to end edits")))
5357 (defun gnus-article-edit-done (&optional arg)
5358 "Update the article edits and exit."
5360 (let ((func gnus-article-edit-done-function)
5361 (buf (current-buffer))
5362 (start (window-start))
5364 (winconf gnus-prev-winconf))
5365 (widen) ;; Widen it in case that users narrowed the buffer.
5368 ;; The cache and backlog have to be flushed somewhat.
5369 (when gnus-keep-backlog
5370 (gnus-backlog-remove-article
5371 (car gnus-article-current) (cdr gnus-article-current)))
5372 ;; Flush original article as well.
5374 (when (get-buffer gnus-original-article-buffer)
5375 (set-buffer gnus-original-article-buffer)
5376 (setq gnus-original-article nil)))
5377 (when gnus-use-cache
5378 (gnus-cache-update-article
5379 (car gnus-article-current) (cdr gnus-article-current)))
5380 ;; We remove all text props from the article buffer.
5381 (kill-all-local-variables)
5382 (gnus-set-text-properties (point-min) (point-max) nil)
5384 (set-window-configuration winconf)
5386 (set-window-start (get-buffer-window buf) start)
5387 (set-window-point (get-buffer-window buf) (point))))
5389 (defun gnus-article-edit-exit ()
5390 "Exit the article editing without updating."
5392 (when (or (not (buffer-modified-p))
5393 (yes-or-no-p "Article modified; kill anyway? "))
5394 (let ((curbuf (current-buffer))
5396 (window-start (window-start)))
5398 (if (gnus-buffer-live-p gnus-original-article-buffer)
5399 (insert-buffer gnus-original-article-buffer))
5400 (let ((winconf gnus-prev-winconf))
5401 (kill-all-local-variables)
5403 (set-window-configuration winconf)
5404 ;; Tippy-toe some to make sure that point remains where it was.
5405 (save-current-buffer
5407 (set-window-start (get-buffer-window (current-buffer)) window-start)
5410 (defun gnus-article-edit-full-stops ()
5411 "Interactively repair spacing at end of sentences."
5414 (goto-char (point-min))
5415 (search-forward-regexp "^$" nil t)
5416 (let ((case-fold-search nil))
5417 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5420 ;;; Article highlights
5423 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5425 ;;; Internal Variables:
5427 (defcustom gnus-button-url-regexp
5428 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5429 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-z0-9_.]+:[0-9]*\\)?[-a-z0-9_=!?#$@~%&*+\\/:;.,[:word:]]+[-a-z0-9_=#$@~%&*+\\/[:word:]]\\)"
5430 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-z0-9_.]+:[0-9]*\\)?\\([-a-z0-9_=!?#$@~%&*+\\/:;.,]\\|\\w\\)+\\([-a-z0-9_=#$@~%&*+\\/]\\|\\w\\)\\)")
5431 "Regular expression that matches URLs."
5432 :group 'gnus-article-buttons
5435 (defcustom gnus-button-valid-fqdn-regexp
5436 (concat "[a-z0-9][-.a-z0-9]+\\." ;; [hostname.subdomain.]domain.
5438 "\\([a-z][a-z]" ;; two letter country TDLs
5439 "\\|biz\\|com\\|edu\\|gov\\|int\\|mil\\|net\\|org"
5440 "\\|aero\\|coop\\|info\\|name\\|museum"
5441 "\\|arpa\\|pro\\|uucp\\|bitnet\\|bofh" ;; old style?
5443 "Regular expression that matches a valid FQDN."
5444 :group 'gnus-article-buttons
5447 (defcustom gnus-button-man-handler 'manual-entry
5448 "Function to use for displaying man pages.
5449 The function must take at least one argument with a string naming the
5451 :type '(choice (function-item :tag "Man" manual-entry)
5452 (function-item :tag "Woman" woman)
5453 (function :tag "Other"))
5454 :group 'gnus-article-buttons)
5456 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
5457 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
5458 If the default site is too slow, try to find a CTAN mirror, see
5459 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
5460 the variable `gnus-button-handle-ctan'."
5461 :group 'gnus-article-buttons
5462 :link '(custom-manual "(gnus)Group Parameters")
5463 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
5464 (const "http://tug.ctan.org/tex-archive/")
5465 (const "http://www.dante.de/CTAN/")
5466 (string :tag "Other")))
5468 (defcustom gnus-button-ctan-handler 'browse-url
5469 "Function to use for displaying CTAN links.
5470 The function must take one argument, the string naming the URL."
5471 :type '(choice (function-item :tag "Browse Url" browse-url)
5472 (function :tag "Other"))
5473 :group 'gnus-article-buttons)
5475 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
5476 "Bogus strings removed from CTAN URLs."
5477 :group 'gnus-article-buttons
5478 :type '(choice (const "^/?tex-archive/\\|/")
5479 (regexp :tag "Other")))
5481 (defcustom gnus-button-mid-or-mail-regexp
5482 (concat "\\b\\(<?[a-z0-9][^<>\")!;:,{}\n\t ]*@"
5483 gnus-button-valid-fqdn-regexp
5485 "Regular expression that matches a message ID or a mail address."
5486 :group 'gnus-article-buttons
5489 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
5490 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
5491 Strings like this can be either a message ID or a mail address. If it is one
5492 of the symbols `mid' or `mail', Gnus will always assume that the string is a
5493 message ID or a mail address, respectivly. If this variable is set to the
5494 symbol `ask', always query the user what do do. If it is a function, this
5495 function will be called with the string as it's only argument. The function
5496 must return `mid', `mail', `invalid' or `ask'."
5497 :group 'gnus-article-buttons
5498 :type '(choice (function-item :tag "Heuristic function"
5499 gnus-button-mid-or-mail-heuristic)
5504 (defcustom gnus-button-mid-or-mail-heuristic-alist
5505 '((-10.0 . ".+\\$.+@")
5508 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
5509 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
5510 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
5511 (-1.0 . "^[^a-z]+@")
5513 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
5514 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
5515 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
5516 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
5519 (-1.0 . "^[0-9][0-9]")
5521 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
5522 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5523 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
5524 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5526 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
5527 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
5530 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
5532 ;; compensation for TDMA dated mail addresses:
5533 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
5535 (-20.0 . "\\.fsf@") ;; Gnus
5538 (-20.0 . "_-_") ;; Subject change in thread
5540 (-20.0 . "\\.ln@") ;; leafnode
5541 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
5542 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
5544 ;; (5.0 . "") ;; $local_part_len <= 7
5545 (10.0 . "^[^0-9]+@")
5546 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
5547 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
5550 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
5552 (0.5 . "^[A-Z][a-z]")
5553 (0.5 . "^[A-Z][a-z][a-z]")
5554 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
5555 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
5556 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
5558 A negative RATE indicates a message IDs, whereas a positive indicates a mail
5559 address. The REGEXP is processed with `case-fold-search' set to `nil'."
5560 :group 'gnus-article-buttons
5561 :type '(repeat (cons (number :tag "Rate")
5562 (regexp :tag "Regexp"))))
5564 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
5565 "Guess whether MID-OR-MAIL is a message ID or a mail address.
5566 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
5567 address, `ask' if unsure and `invalid' if the string is invalid."
5568 (let ((case-fold-search nil)
5569 (list gnus-button-mid-or-mail-heuristic-alist)
5570 (result 0) rate regexp lpartlen elem)
5572 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
5573 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
5574 ;; Certain special cases...
5577 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$" "\\|"
5578 "^[0-9]+\.[0-9]+\@compuserve")
5580 (gnus-message 8 "`%s' is a known mail address.")
5581 (setq result 'mail))
5582 (when (string-match "@.*@\\| " mid-or-mail)
5583 (gnus-message 8 "`%s' is invalid.")
5584 (setq result 'invalid))
5585 ;; Nothing more to do, if result is not a number here...
5586 (when (numberp result)
5588 (setq elem (car list)
5592 (when (string-match regexp mid-or-mail)
5593 (setq result (+ result rate))
5595 9 "`%s' matched `%s', rate `%s', result `%s'."
5596 mid-or-mail regexp rate result)))
5597 (when (<= lpartlen 7)
5598 (setq result (+ result 5.0))
5599 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
5600 mid-or-mail result))
5601 (when (>= lpartlen 12)
5602 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
5604 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
5605 ;; Long local part should contain realname if e-mail address,
5606 ;; too many digits: message-id.
5607 ;; $score -= 5.0 + 0.1 * $local_part_len;
5608 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
5609 (setq result (+ result rate))
5611 9 "Many digits in `%s', rate `%s', result `%s'."
5612 mid-or-mail rate result))
5613 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
5615 ;; Too few vowels [^aeiouy]{4,}.*\@
5616 (setq result (+ result -5.0))
5618 9 "Few vowels in `%s', rate `%s', result `%s'."
5619 mid-or-mail -5.0 result))
5621 (setq result (+ result 5.0))
5623 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
5624 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
5626 ;; Maybe we should make this a customizable alist: (condition . 'result)
5627 ((< result -10.0) 'mid)
5628 ((> result 10.0) 'mail)
5631 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
5632 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
5633 (url-mid (concat "news" ":" mid-or-mail))
5634 (url-mailto (concat "mailto" ":" mid-or-mail)))
5635 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
5636 (when (fboundp pref)
5638 ;; get rid of surrounding angles...
5640 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
5641 (if (or (eq 'mid guessed) (eq 'mail guessed))
5645 (save-window-excursion
5646 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
5649 (cond ((eq pref 'mid)
5650 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
5651 (gnus-button-handle-news url-mid))
5653 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
5654 (gnus-url-mailto url-mailto))
5655 (t (gnus-message 3 "Invalid string.")))))
5657 (defun gnus-button-handle-custom (url)
5658 "Follow a Custom URL."
5659 (customize-apropos (gnus-url-unhex-string url)))
5661 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
5663 (defun gnus-button-handle-describe-function (url)
5664 "Call `describe-function' when pushing the corresponding URL button."
5667 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5669 (defun gnus-button-handle-describe-variable (url)
5670 "Call `describe-variable' when pushing the corresponding URL button."
5673 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
5675 (defun gnus-button-handle-describe-key (url)
5676 "Call `describe-key' when pushing the corresponding URL button."
5678 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
5679 (keys (ignore-errors (eval `(kbd ,key-string)))))
5682 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
5684 (defun gnus-button-handle-apropos (url)
5685 "Call `apropos' when pushing the corresponding URL button."
5686 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5688 (defun gnus-button-handle-apropos-command (url)
5689 "Call `apropos' when pushing the corresponding URL button."
5691 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5693 (defun gnus-button-handle-apropos-variable (url)
5694 "Call `apropos' when pushing the corresponding URL button."
5696 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
5697 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5699 (defun gnus-button-handle-apropos-documentation (url)
5700 "Call `apropos' when pushing the corresponding URL button."
5702 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
5703 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
5705 (defun gnus-button-handle-ctan (url)
5706 "Call `browse-url' when pushing a CTAN URL button."
5708 gnus-button-ctan-handler
5711 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
5713 (defcustom gnus-button-tex-level 5
5714 "*Integer that says how many TeX-related buttons Gnus will show.
5715 The higher the number, the more buttons will appear and the more false
5716 positives are possible. Note that you can set this variable local to
5717 specifific groups. Setting it higher in TeX groups is probably a good idea.
5718 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
5719 how to set variables in specific groups."
5720 :group 'gnus-article-buttons
5721 :link '(custom-manual "(gnus)Group Parameters")
5724 (defcustom gnus-button-man-level 5
5725 "*Integer that says how many man-related buttons Gnus will show.
5726 The higher the number, the more buttons will appear and the more false
5727 positives are possible. Note that you can set this variable local to
5728 specifific groups. Setting it higher in Unix groups is probably a good idea.
5729 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
5730 how to set variables in specific groups."
5731 :group 'gnus-article-buttons
5732 :link '(custom-manual "(gnus)Group Parameters")
5735 (defcustom gnus-button-emacs-level 5
5736 "*Integer that says how many emacs-related buttons Gnus will show.
5737 The higher the number, the more buttons will appear and the more false
5738 positives are possible. Note that you can set this variable local to
5739 specifific groups. Setting it higher in Emacs or Gnus related groups is
5740 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
5741 `gnus-parameters' on how to set variables in specific groups."
5742 :group 'gnus-article-buttons
5743 :link '(custom-manual "(gnus)Group Parameters")
5746 (defcustom gnus-button-mail-level 5
5747 "*Integer that says how many buttons for message IDs or mail addresses will appear.
5748 The higher the number, the more buttons will appear and the more false
5749 positives are possible."
5750 :group 'gnus-article-buttons
5753 (defcustom gnus-button-alist
5754 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
5755 0 t gnus-button-handle-news 3)
5756 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
5757 gnus-button-handle-news 2)
5758 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
5760 gnus-button-fetch-group 4)
5761 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
5762 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
5763 t gnus-button-message-id 3)
5764 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
5765 ("mailto:\\([-a-z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5766 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
5768 ("\\bCTAN:[ \t\n]*\\([^>)!;:,\n\t ]*\\)" 0 (>= gnus-button-tex-level 1)
5769 gnus-button-handle-ctan 1)
5771 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0
5772 (>= gnus-button-emacs-level 1) gnus-button-handle-info 2)
5774 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)" 0
5775 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
5776 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
5777 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
5778 ;; Emacs help commands
5779 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5780 ;; regexp doesn't match arguments containing ` '.
5781 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
5782 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5783 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
5784 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5785 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
5786 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5787 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
5788 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5789 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
5790 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
5791 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
5792 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'" 1
5793 ;; Unlike the other regexps we really have to require quoting
5794 ;; here to determine where it ends.
5795 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
5796 ;; This is how URLs _should_ be embedded in text...
5797 ("<URL: *\\([^<>]*\\)>" 1 t gnus-button-embedded-url 1)
5799 (gnus-button-url-regexp 0 t browse-url 0)
5801 ("\\b\\([a-z][a-z]+\\)([1-9])\\W" 0
5802 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
5803 gnus-button-handle-man 1)
5804 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
5805 ("\\b\\([a-z][-_.a-z0-9]+\\)([1-9])\\W" 0
5806 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
5807 gnus-button-handle-man 1)
5808 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
5809 ;; SoWWWAnchor(3iv), XSelectInput(3X11)
5810 ("\\b\\([a-z][-_.:a-z0-9]+\\)([1-9][X1a-z]*)\\W" 0
5811 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
5812 ;; MID or mail: To avoid too many false positives we don't try to catch
5813 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
5814 ;; at least one dot. TLD must contain two or three chars or be a know TLD
5815 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
5816 ;; so that non-ambiguous entries (see above) match first.
5817 (gnus-button-mid-or-mail-regexp
5818 0 (>= gnus-button-mail-level 5) gnus-button-handle-mid-or-mail 1))
5819 "*Alist of regexps matching buttons in article bodies.
5821 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
5822 REGEXP: is the string (case insensitive) matching text around the button (can
5823 also be lisp expression evaluating to a string),
5824 BUTTON: is the number of the regexp grouping actually matching the button,
5825 FORM: is a lisp expression which must eval to true for the button to
5827 CALLBACK: is the function to call when the user push this button, and each
5828 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
5830 CALLBACK can also be a variable, in that case the value of that
5831 variable it the real callback function."
5832 :group 'gnus-article-buttons
5833 :type '(repeat (list (choice regexp variable)
5834 (integer :tag "Button")
5836 (function :tag "Callback")
5839 (integer :tag "Regexp group")))))
5841 (defcustom gnus-header-button-alist
5842 '(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
5843 0 t gnus-button-message-id 0)
5844 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
5845 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
5846 0 t gnus-button-mailto 0)
5847 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp 0 t browse-url 0)
5848 ("^Subject:" gnus-button-url-regexp 0 t browse-url 0)
5849 ("^[^:]+:" gnus-button-url-regexp 0 t browse-url 0)
5850 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
5851 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
5852 gnus-button-message-id 3))
5853 "*Alist of headers and regexps to match buttons in article heads.
5855 This alist is very similar to `gnus-button-alist', except that each
5856 alist has an additional HEADER element first in each entry:
5858 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
5860 HEADER is a regexp to match a header. For a fuller explanation, see
5861 `gnus-button-alist'."
5862 :group 'gnus-article-buttons
5863 :group 'gnus-article-headers
5864 :type '(repeat (list (regexp :tag "Header")
5866 (integer :tag "Button")
5868 (function :tag "Callback")
5871 (integer :tag "Regexp group")))))
5873 (defvar gnus-button-regexp nil)
5874 (defvar gnus-button-marker-list nil)
5875 ;; Regexp matching any of the regexps from `gnus-button-alist'.
5877 (defvar gnus-button-last nil)
5878 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
5882 (defun gnus-article-push-button (event)
5883 "Check text under the mouse pointer for a callback function.
5884 If the text under the mouse pointer has a `gnus-callback' property,
5885 call it with the value of the `gnus-data' text property."
5887 (set-buffer (window-buffer (posn-window (event-start event))))
5888 (let* ((pos (posn-point (event-start event)))
5889 (data (get-text-property pos 'gnus-data))
5890 (fun (get-text-property pos 'gnus-callback)))
5893 (funcall fun data))))
5895 (defun gnus-article-press-button ()
5896 "Check text at point for a callback function.
5897 If the text at point has a `gnus-callback' property,
5898 call it with the value of the `gnus-data' text property."
5900 (let ((data (get-text-property (point) 'gnus-data))
5901 (fun (get-text-property (point) 'gnus-callback)))
5903 (funcall fun data))))
5905 (defun gnus-article-highlight (&optional force)
5906 "Highlight current article.
5907 This function calls `gnus-article-highlight-headers',
5908 `gnus-article-highlight-citation',
5909 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5910 do the highlighting. See the documentation for those functions."
5911 (interactive (list 'force))
5912 (gnus-article-highlight-headers)
5913 (gnus-article-highlight-citation force)
5914 (gnus-article-highlight-signature)
5915 (gnus-article-add-buttons force)
5916 (gnus-article-add-buttons-to-head))
5918 (defun gnus-article-highlight-some (&optional force)
5919 "Highlight current article.
5920 This function calls `gnus-article-highlight-headers',
5921 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
5922 do the highlighting. See the documentation for those functions."
5923 (interactive (list 'force))
5924 (gnus-article-highlight-headers)
5925 (gnus-article-highlight-signature)
5926 (gnus-article-add-buttons))
5928 (defun gnus-article-highlight-headers ()
5929 "Highlight article headers as specified by `gnus-header-face-alist'."
5932 (set-buffer gnus-article-buffer)
5934 (let ((alist gnus-header-face-alist)
5935 (buffer-read-only nil)
5936 (case-fold-search t)
5937 (inhibit-point-motion-hooks t)
5938 entry regexp header-face field-face from hpoints fpoints)
5939 (article-narrow-to-head)
5940 (while (setq entry (pop alist))
5941 (goto-char (point-min))
5942 (setq regexp (concat "^\\("
5943 (if (string-equal "" (nth 0 entry))
5947 header-face (nth 1 entry)
5948 field-face (nth 2 entry))
5949 (while (and (re-search-forward regexp nil t)
5953 (unless (search-forward ":" nil t)
5955 (when (and header-face
5956 (not (memq (point) hpoints)))
5957 (push (point) hpoints)
5958 (gnus-put-text-property from (point) 'face header-face))
5959 (when (and field-face
5960 (not (memq (setq from (point)) fpoints)))
5962 (if (re-search-forward "^[^ \t]" nil t)
5964 (goto-char (point-max)))
5965 (gnus-put-text-property from (point) 'face field-face))))))))
5967 (defun gnus-article-highlight-signature ()
5968 "Highlight the signature in an article.
5969 It does this by highlighting everything after
5970 `gnus-signature-separator' using `gnus-signature-face'."
5973 (set-buffer gnus-article-buffer)
5974 (let ((buffer-read-only nil)
5975 (inhibit-point-motion-hooks t))
5977 (when (and gnus-signature-face
5978 (gnus-article-narrow-to-signature))
5979 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
5980 'face gnus-signature-face)
5982 (gnus-article-search-signature)
5983 (let ((start (match-beginning 0))
5984 (end (set-marker (make-marker) (1+ (match-end 0)))))
5985 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
5988 (defun gnus-button-in-region-p (b e prop)
5989 "Say whether PROP exists in the region."
5990 (text-property-not-all b e prop nil))
5992 (defun gnus-article-add-buttons (&optional force)
5993 "Find external references in the article and make buttons of them.
5994 \"External references\" are things like Message-IDs and URLs, as
5995 specified by `gnus-button-alist'."
5996 (interactive (list 'force))
5998 (set-buffer gnus-article-buffer)
5999 (let ((buffer-read-only nil)
6000 (inhibit-point-motion-hooks t)
6001 (case-fold-search t)
6002 (alist gnus-button-alist)
6004 ;; Remove all old markers.
6005 (let (marker entry new-list)
6006 (while (setq marker (pop gnus-button-marker-list))
6007 (if (or (< marker (point-min)) (>= marker (point-max)))
6008 (push marker new-list)
6010 (when (setq entry (gnus-button-entry))
6011 (put-text-property (match-beginning (nth 1 entry))
6012 (match-end (nth 1 entry))
6013 'gnus-callback nil))
6014 (set-marker marker nil)))
6015 (setq gnus-button-marker-list new-list))
6016 ;; We skip the headers.
6019 (while (setq entry (pop alist))
6020 (setq regexp (eval (car entry)))
6022 (while (re-search-forward regexp nil t)
6023 (let* ((start (and entry (match-beginning (nth 1 entry))))
6024 (end (and entry (match-end (nth 1 entry))))
6025 (from (match-beginning 0)))
6026 (when (and (or (eq t (nth 2 entry))
6027 (eval (nth 2 entry)))
6028 (not (gnus-button-in-region-p
6029 start end 'gnus-callback)))
6030 ;; That optional form returned non-nil, so we add the
6032 (gnus-article-add-button
6033 start end 'gnus-button-push
6034 (car (push (set-marker (make-marker) from)
6035 gnus-button-marker-list))))))))))
6037 ;; Add buttons to the head of an article.
6038 (defun gnus-article-add-buttons-to-head ()
6039 "Add buttons to the head of the article."
6042 (set-buffer gnus-article-buffer)
6044 (let ((buffer-read-only nil)
6045 (inhibit-point-motion-hooks t)
6046 (case-fold-search t)
6047 (alist gnus-header-button-alist)
6049 (article-narrow-to-head)
6051 ;; Each alist entry.
6052 (setq entry (car alist)
6054 (goto-char (point-min))
6055 (while (re-search-forward (car entry) nil t)
6056 ;; Each header matching the entry.
6057 (setq beg (match-beginning 0))
6058 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6059 (match-beginning 0))
6062 (while (re-search-forward (eval (nth 1 entry)) end t)
6063 ;; Each match within a header.
6064 (let* ((entry (cdr entry))
6065 (start (match-beginning (nth 1 entry)))
6066 (end (match-end (nth 1 entry)))
6067 (form (nth 2 entry)))
6068 (goto-char (match-end 0))
6070 (gnus-article-add-button
6071 start end (nth 3 entry)
6072 (buffer-substring (match-beginning (nth 4 entry))
6073 (match-end (nth 4 entry)))))))
6074 (goto-char end)))))))
6076 ;;; External functions:
6078 (defun gnus-article-add-button (from to fun &optional data)
6079 "Create a button between FROM and TO with callback FUN and data DATA."
6080 (when gnus-article-button-face
6081 (gnus-overlay-put (gnus-make-overlay from to)
6082 'face gnus-article-button-face))
6083 (gnus-add-text-properties
6085 (nconc (and gnus-article-mouse-face
6086 (list gnus-mouse-face-prop gnus-article-mouse-face))
6087 (list 'gnus-callback fun)
6088 (and data (list 'gnus-data data))))
6089 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6090 :button-keymap gnus-widget-button-keymap))
6092 ;;; Internal functions:
6094 (defun gnus-article-set-globals ()
6096 (set-buffer gnus-summary-buffer)
6097 (gnus-set-global-variables)))
6099 (defun gnus-signature-toggle (end)
6101 (set-buffer gnus-article-buffer)
6102 (let ((buffer-read-only nil)
6103 (inhibit-point-motion-hooks t))
6104 (if (text-property-any end (point-max) 'article-type 'signature)
6106 (gnus-delete-wash-type 'signature)
6107 (gnus-remove-text-properties-when
6108 'article-type 'signature end (point-max)
6109 (cons 'article-type (cons 'signature
6110 gnus-hidden-properties))))
6111 (gnus-add-wash-type 'signature)
6112 (gnus-add-text-properties-when
6113 'article-type nil end (point-max)
6114 (cons 'article-type (cons 'signature
6115 gnus-hidden-properties)))))
6116 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6117 (gnus-set-mode-line 'article))))
6119 (defun gnus-button-entry ()
6120 ;; Return the first entry in `gnus-button-alist' matching this place.
6121 (let ((alist gnus-button-alist)
6124 (setq entry (pop alist))
6125 (if (looking-at (eval (car entry)))
6130 (defun gnus-button-push (marker)
6131 ;; Push button starting at MARKER.
6134 (let* ((entry (gnus-button-entry))
6135 (inhibit-point-motion-hooks t)
6137 (args (mapcar (lambda (group)
6138 (let ((string (match-string group)))
6139 (gnus-set-text-properties
6140 0 (length string) nil string)
6147 (fboundp (symbol-value fun)))
6148 (apply (symbol-value fun) args))
6150 (gnus-message 1 "You must define `%S' to use this button"
6151 (cons fun args)))))))
6153 (defun gnus-parse-news-url (url)
6154 (let (scheme server group message-id articles)
6157 (goto-char (point-min))
6158 (when (looking-at "\\([A-Za-z]+\\):")
6159 (setq scheme (match-string 1))
6160 (goto-char (match-end 0)))
6161 (when (looking-at "//\\([^/]+\\)/")
6162 (setq server (match-string 1))
6163 (goto-char (match-end 0)))
6166 ((looking-at "\\(.*@.*\\)")
6167 (setq message-id (match-string 1)))
6168 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6169 (setq group (match-string 1)
6170 articles (split-string (match-string 2) "-")))
6171 ((looking-at "\\([^/]+\\)/?")
6172 (setq group (match-string 1)))
6174 (error "Unknown news URL syntax"))))
6175 (list scheme server group message-id articles)))
6177 (defun gnus-button-handle-news (url)
6179 (destructuring-bind (scheme server group message-id articles)
6180 (gnus-parse-news-url url)
6184 (set-buffer gnus-summary-buffer)
6186 (let ((gnus-refer-article-method (list (list 'nntp server))))
6187 (gnus-summary-refer-article message-id))
6188 (gnus-summary-refer-article message-id))))
6190 (gnus-button-fetch-group url)))))
6192 (defun gnus-button-handle-man (url)
6194 (funcall gnus-button-man-handler url))
6196 (defun gnus-button-handle-info (url)
6197 "Fetch an info URL."
6199 "^\\([^:/]+\\)?/\\(.*\\)"
6201 (gnus-info-find-node
6202 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6205 (gnus-url-unhex-string (match-string 2 url))))
6206 (error "Can't parse %s" url)))
6208 (defun gnus-button-message-id (message-id)
6211 (set-buffer gnus-summary-buffer)
6212 (gnus-summary-refer-article message-id)))
6214 (defun gnus-button-fetch-group (address)
6215 "Fetch GROUP specified by ADDRESS."
6216 (if (not (string-match "[:/]" address))
6217 ;; This is just a simple group url.
6218 (gnus-group-read-ephemeral-group address gnus-select-method)
6221 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6223 (error "Can't parse %s" address)
6224 (gnus-group-read-ephemeral-group
6225 (match-string 4 address)
6226 `(nntp ,(match-string 1 address)
6227 (nntp-address ,(match-string 1 address))
6228 (nntp-port-number ,(if (match-end 3)
6229 (match-string 3 address)
6232 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
6234 (defun gnus-url-parse-query-string (query &optional downcase)
6235 (let (retval pairs cur key val)
6236 (setq pairs (split-string query "&"))
6238 (setq cur (car pairs)
6240 (if (not (string-match "=" cur))
6242 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6243 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6245 (setq key (downcase key)))
6246 (setq cur (assoc key retval))
6248 (setcdr cur (cons val (cdr cur)))
6249 (setq retval (cons (list key val) retval)))))
6252 (defun gnus-url-mailto (url)
6253 ;; Send mail to someone
6254 (when (string-match "mailto:/*\\(.*\\)" url)
6255 (setq url (substring url (match-beginning 1) nil)))
6256 (let (to args subject func)
6257 (if (string-match (regexp-quote "?") url)
6258 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
6259 args (gnus-url-parse-query-string
6260 (substring url (match-end 0) nil) t))
6261 (setq to (gnus-url-unhex-string url)))
6262 (setq args (cons (list "to" to) args)
6263 subject (cdr-safe (assoc "subject" args)))
6266 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6269 (message-position-on-field (caar args)))
6270 (insert (mapconcat 'identity (cdar args) ", "))
6271 (setq args (cdr args)))
6274 (message-goto-subject))))
6276 (defun gnus-button-embedded-url (address)
6277 "Activate ADDRESS with `browse-url'."
6278 (browse-url (gnus-strip-whitespace address)))
6280 ;;; Next/prev buttons in the article buffer.
6282 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6283 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6285 (defvar gnus-prev-page-map
6286 (let ((map (make-sparse-keymap)))
6287 (unless (>= emacs-major-version 21)
6288 ;; XEmacs doesn't care.
6289 (set-keymap-parent map gnus-article-mode-map))
6290 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6291 (define-key map "\r" 'gnus-button-prev-page)
6294 (defun gnus-insert-prev-page-button ()
6296 (buffer-read-only nil))
6298 gnus-prev-page-line-format nil
6299 `(,@(gnus-local-map-property gnus-prev-page-map)
6301 gnus-callback gnus-article-button-prev-page
6302 article-type annotation))
6303 (widget-convert-button
6305 :action 'gnus-button-prev-page
6306 :button-keymap gnus-prev-page-map)))
6308 (defvar gnus-prev-page-map
6309 (let ((map (make-sparse-keymap)))
6310 (unless (>= emacs-major-version 21)
6311 ;; XEmacs doesn't care.
6312 (set-keymap-parent map gnus-article-mode-map))
6313 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6314 (define-key map "\r" 'gnus-button-prev-page)
6317 (defvar gnus-next-page-map
6318 (let ((map (make-sparse-keymap)))
6319 (unless (>= emacs-major-version 21)
6320 ;; XEmacs doesn't care.
6321 (set-keymap-parent map gnus-article-mode-map))
6322 (define-key map gnus-mouse-2 'gnus-button-next-page)
6323 (define-key map "\r" 'gnus-button-next-page)
6326 (defun gnus-button-next-page (&optional args more-args)
6327 "Go to the next page."
6329 (let ((win (selected-window)))
6330 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6331 (gnus-article-next-page)
6332 (select-window win)))
6334 (defun gnus-button-prev-page (&optional args more-args)
6335 "Go to the prev page."
6337 (let ((win (selected-window)))
6338 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6339 (gnus-article-prev-page)
6340 (select-window win)))
6342 (defun gnus-insert-next-page-button ()
6344 (buffer-read-only nil))
6345 (gnus-eval-format gnus-next-page-line-format nil
6346 `(,@(gnus-local-map-property gnus-next-page-map)
6348 gnus-callback gnus-article-button-next-page
6349 article-type annotation))
6350 (widget-convert-button
6352 :action 'gnus-button-next-page
6353 :button-keymap gnus-next-page-map)))
6355 (defun gnus-article-button-next-page (arg)
6356 "Go to the next page."
6358 (let ((win (selected-window)))
6359 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6360 (gnus-article-next-page)
6361 (select-window win)))
6363 (defun gnus-article-button-prev-page (arg)
6364 "Go to the prev page."
6366 (let ((win (selected-window)))
6367 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6368 (gnus-article-prev-page)
6369 (select-window win)))
6371 (defvar gnus-decode-header-methods
6372 '(mail-decode-encoded-word-region)
6373 "List of methods used to decode headers.
6375 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6376 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
6377 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
6378 whose names match REGEXP.
6381 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6382 mail-decode-encoded-word-region
6383 (\"chinese\" . rfc1843-decode-region))
6386 (defvar gnus-decode-header-methods-cache nil)
6388 (defun gnus-multi-decode-header (start end)
6389 "Apply the functions from `gnus-encoded-word-methods' that match."
6390 (unless (and gnus-decode-header-methods-cache
6391 (eq gnus-newsgroup-name
6392 (car gnus-decode-header-methods-cache)))
6393 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6396 (nconc gnus-decode-header-methods-cache (list x))
6397 (if (and gnus-newsgroup-name
6398 (string-match (car x) gnus-newsgroup-name))
6399 (nconc gnus-decode-header-methods-cache
6401 gnus-decode-header-methods))
6402 (let ((xlist gnus-decode-header-methods-cache))
6405 (narrow-to-region start end)
6407 (funcall (pop xlist) (point-min) (point-max))))))
6410 ;;; Treatment top-level handling.
6413 (defun gnus-treat-article (condition &optional part-number total-parts type)
6414 (let ((length (- (point-max) (point-min)))
6415 (alist gnus-treatment-function-alist)
6416 (article-goto-body-goes-to-point-min-p t)
6420 (let ((list gnus-article-treat-types))
6422 (when (string-match (pop list) type)
6423 (throw 'found t)))))))
6424 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6426 (gnus-run-hooks 'gnus-part-display-hook)
6427 (dolist (elem alist)
6430 (when (gnus-buffer-live-p gnus-summary-buffer)
6431 (set-buffer gnus-summary-buffer))
6432 (symbol-value (car elem))))
6433 (when (and (or (consp val)
6435 (gnus-treat-predicate val)
6436 (or (not (get (car elem) 'highlight))
6439 (funcall (cadr elem)))))))
6441 ;; Dynamic variables.
6443 (defvar part-number)
6444 (defvar total-parts)
6449 (defun gnus-treat-predicate (val)
6456 (stringp (car val)))
6457 (apply 'gnus-or (mapcar `(lambda (s)
6458 (string-match s ,(or gnus-newsgroup-name "")))
6461 (let ((pred (pop val)))
6464 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
6466 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
6468 (not (gnus-treat-predicate (car val))))
6470 (equal (car val) type))
6472 (error "%S is not a valid predicate" pred)))))
6478 (eq part-number total-parts))
6482 (error "%S is not a valid value" val))))
6484 (defun gnus-article-encrypt-body (protocol &optional n)
6485 "Encrypt the article body."
6488 (or gnus-article-encrypt-protocol
6489 (completing-read "Encrypt protocol: "
6490 gnus-article-encrypt-protocol-alist
6492 current-prefix-arg))
6493 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
6495 (error (format "Can't find the encrypt protocol %s" protocol)))
6496 (if (member gnus-newsgroup-name '("nndraft:delayed"
6499 (error "Can't encrypt the article in group %s"
6500 gnus-newsgroup-name))
6501 (gnus-summary-iterate n
6503 (set-buffer gnus-summary-buffer)
6504 (let ((mail-parse-charset gnus-newsgroup-charset)
6505 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
6506 (summary-buffer gnus-summary-buffer)
6508 (gnus-set-global-variables)
6509 (when (gnus-group-read-only-p)
6510 (error "The current newsgroup does not support article encrypt"))
6511 (gnus-summary-show-article t)
6513 (or (mail-header-references gnus-current-headers) ""))
6514 (set-buffer gnus-article-buffer)
6515 (let* ((buffer-read-only nil)
6517 (mapcar (lambda (field)
6518 (and (save-restriction
6519 (message-narrow-to-head)
6520 (goto-char (point-min))
6521 (search-forward field nil t))
6523 (message-narrow-to-field)
6524 (buffer-substring (point-min) (point-max))
6525 (delete-region (point-min) (point-max))
6527 '("Content-Type:" "Content-Transfer-Encoding:"
6528 "Content-Disposition:"))))
6529 (message-narrow-to-head)
6530 (message-remove-header "MIME-Version")
6531 (goto-char (point-max))
6532 (setq point (point))
6533 (insert (apply 'concat headers))
6535 (narrow-to-region point (point-max))
6536 (let ((message-options message-options))
6537 (message-options-set 'message-sender user-mail-address)
6538 (message-options-set 'message-recipients user-mail-address)
6539 (message-options-set 'message-sign-encrypt 'not)
6541 (goto-char (point-min))
6542 (insert "MIME-Version: 1.0\n")
6544 (gnus-summary-edit-article-done
6545 references nil summary-buffer t))
6546 (when gnus-keep-backlog
6547 (gnus-backlog-remove-article
6548 (car gnus-article-current) (cdr gnus-article-current)))
6550 (when (get-buffer gnus-original-article-buffer)
6551 (set-buffer gnus-original-article-buffer)
6552 (setq gnus-original-article nil)))
6553 (when gnus-use-cache
6554 (gnus-cache-update-article
6555 (car gnus-article-current) (cdr gnus-article-current))))))))
6557 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
6558 "The following specs can be used:
6559 %t The security MIME type
6562 %D Details if button is pressed")
6564 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
6565 "The following specs can be used:
6566 %t The security MIME type
6569 %D Details if button is pressed")
6571 (defvar gnus-mime-security-button-line-format-alist
6572 '((?t gnus-tmp-type ?s)
6573 (?i gnus-tmp-info ?s)
6574 (?d gnus-tmp-details ?s)
6575 (?D gnus-tmp-pressed-details ?s)))
6577 (defvar gnus-mime-security-button-map
6578 (let ((map (make-sparse-keymap)))
6579 (unless (>= (string-to-number emacs-version) 21)
6580 (set-keymap-parent map gnus-article-mode-map))
6581 (define-key map gnus-mouse-2 'gnus-article-push-button)
6582 (define-key map "\r" 'gnus-article-press-button)
6585 (defvar gnus-mime-security-details-buffer nil)
6587 (defvar gnus-mime-security-button-pressed nil)
6589 (defvar gnus-mime-security-show-details-inline t
6590 "If non-nil, show details in the article buffer.")
6592 (defun gnus-mime-security-verify-or-decrypt (handle)
6593 (mm-remove-parts (cdr handle))
6594 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
6595 point buffer-read-only)
6597 (goto-char (car region)))
6599 (narrow-to-region (point) (point))
6600 (with-current-buffer (mm-handle-multipart-original-buffer handle)
6601 (let* ((mm-verify-option 'known)
6602 (mm-decrypt-option 'known)
6603 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
6604 (unless (eq nparts (cdr handle))
6605 (mm-destroy-parts (cdr handle))
6606 (setcdr handle nparts))))
6607 (setq point (point))
6608 (gnus-mime-display-security handle)
6609 (goto-char (point-max)))
6611 (delete-region (point) (cdr region))
6612 (set-marker (car region) nil)
6613 (set-marker (cdr region) nil))
6616 (defun gnus-mime-security-show-details (handle)
6617 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
6619 (gnus-message 5 "No details.")
6620 (if gnus-mime-security-show-details-inline
6621 (let ((gnus-mime-security-button-pressed
6622 (not (get-text-property (point) 'gnus-mime-details)))
6623 (gnus-mime-security-button-line-format
6624 (get-text-property (point) 'gnus-line-format))
6627 (while (eq (get-text-property (point) 'gnus-line-format)
6628 gnus-mime-security-button-line-format)
6632 (narrow-to-region (point) (point))
6633 (gnus-insert-mime-security-button handle))
6634 (delete-region (point)
6635 (or (text-property-not-all
6638 gnus-mime-security-button-line-format)
6641 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
6642 (with-current-buffer gnus-mime-security-details-buffer
6645 (setq gnus-mime-security-details-buffer
6646 (gnus-get-buffer-create "*MIME Security Details*")))
6647 (with-current-buffer gnus-mime-security-details-buffer
6649 (goto-char (point-min)))
6650 (pop-to-buffer gnus-mime-security-details-buffer)))))
6652 (defun gnus-mime-security-press-button (handle)
6654 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6655 (gnus-mime-security-show-details handle)
6656 (gnus-mime-security-verify-or-decrypt handle))))
6658 (defun gnus-insert-mime-security-button (handle &optional displayed)
6659 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
6662 (or (nth 2 (assoc protocol mm-verify-function-alist))
6663 (nth 2 (assoc protocol mm-decrypt-function-alist))
6665 (if (equal (car handle) "multipart/signed")
6666 " Signed" " Encrypted")
6669 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
6672 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
6673 gnus-tmp-pressed-details
6675 (setq gnus-tmp-details
6676 (if gnus-tmp-details
6677 (concat "\n" gnus-tmp-details)
6679 (setq gnus-tmp-pressed-details
6680 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
6685 gnus-mime-security-button-line-format
6686 gnus-mime-security-button-line-format-alist
6687 `(,@(gnus-local-map-property gnus-mime-security-button-map)
6688 gnus-callback gnus-mime-security-press-button
6689 gnus-line-format ,gnus-mime-security-button-line-format
6690 gnus-mime-details ,gnus-mime-security-button-pressed
6691 article-type annotation
6694 (widget-convert-button
6697 :action 'gnus-widget-press-button
6698 :button-keymap gnus-mime-security-button-map
6700 (lambda (widget/window &optional overlay pos)
6701 ;; Needed to properly clear the message due to a bug in
6702 ;; wid-edit (XEmacs only).
6703 (when (boundp 'help-echo-owns-message)
6704 (setq help-echo-owns-message t))
6707 (aref gnus-mouse-2 0))))))
6709 (defun gnus-mime-display-security (handle)
6711 (narrow-to-region (point) (point))
6712 (unless (gnus-unbuttonized-mime-type-p (car handle))
6713 (gnus-insert-mime-security-button handle))
6714 (gnus-mime-display-mixed (cdr handle))
6717 (unless (gnus-unbuttonized-mime-type-p (car handle))
6718 (let ((gnus-mime-security-button-line-format
6719 gnus-mime-security-button-end-line-format))
6720 (gnus-insert-mime-security-button handle)))
6721 (mm-set-handle-multipart-parameter
6723 (cons (set-marker (make-marker) (point-min))
6724 (set-marker (make-marker) (point-max))))))
6730 (run-hooks 'gnus-art-load-hook)
6732 ;;; gnus-art.el ends here