1 ;;; gnus-art.el --- article mode commands for Semi-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>
6 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;; Katsumi Yamaoka <yamaoka@jpl.org>
8 ;; Keywords: mail, news, MIME
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
34 (defvar tool-bar-map))
46 ;; Avoid byte-compile warnings.
56 (autoload 'gnus-msg-mail "gnus-msg" nil t)
57 (autoload 'gnus-button-mailto "gnus-msg")
58 (autoload 'gnus-button-reply "gnus-msg" nil t)
60 (defgroup gnus-article nil
62 :link '(custom-manual "(gnus)The Article Buffer")
65 (defgroup gnus-article-treat nil
66 "Treating article parts."
67 :link '(custom-manual "(gnus)Article Hiding")
70 (defgroup gnus-article-hiding nil
71 "Hiding article parts."
72 :link '(custom-manual "(gnus)Article Hiding")
75 (defgroup gnus-article-highlight nil
76 "Article highlighting."
77 :link '(custom-manual "(gnus)Article Highlighting")
81 (defgroup gnus-article-signature nil
83 :link '(custom-manual "(gnus)Article Signature")
86 (defgroup gnus-article-headers nil
88 :link '(custom-manual "(gnus)Hiding Headers")
91 (defgroup gnus-article-washing nil
92 "Special commands on articles."
93 :link '(custom-manual "(gnus)Article Washing")
96 (defgroup gnus-article-emphasis nil
97 "Fontisizing articles."
98 :link '(custom-manual "(gnus)Article Fontisizing")
101 (defgroup gnus-article-saving nil
103 :link '(custom-manual "(gnus)Saving Articles")
104 :group 'gnus-article)
106 (defgroup gnus-article-mime nil
107 "Worshiping the MIME wonder."
108 :link '(custom-manual "(gnus)Using MIME")
109 :group 'gnus-article)
111 (defgroup gnus-article-buttons nil
112 "Pushable buttons in the article buffer."
113 :link '(custom-manual "(gnus)Article Buttons")
114 :group 'gnus-article)
116 (defgroup gnus-article-various nil
117 "Other article options."
118 :link '(custom-manual "(gnus)Misc Article")
119 :group 'gnus-article)
121 (defcustom gnus-ignored-headers
124 (concat "^" header ":"))
125 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
126 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
127 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
128 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
129 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
130 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
131 "X-Attribution" "X-Originating-IP" "Delivered-To"
132 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
133 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
134 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
135 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
136 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
137 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
138 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
139 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
140 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
141 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
142 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
143 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
144 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
145 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
146 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
147 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
148 "List-[A-Za-z]+" "X-Listprocessor-Version"
149 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
150 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
151 "X-Received" "Content-length" "X-precedence"
152 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
153 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
154 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
155 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
156 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
157 "X-Content-length" "X-Posting-Agent" "Original-Received"
158 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
159 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
160 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
161 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
162 "X-Abuse-and-DMCA-Info" "X-Postfilter"))
163 "*All headers that start with this regexp will be hidden.
164 This variable can also be a list of regexps of headers to be ignored.
165 If `gnus-visible-headers' is non-nil, this variable will be ignored."
166 :type '(choice :custom-show nil
169 :group 'gnus-article-hiding)
171 (defcustom gnus-visible-headers
172 "^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:"
173 "*All headers that do not match this regexp will be hidden.
174 This variable can also be a list of regexp of headers to remain visible.
175 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
176 :type '(repeat :value-to-internal (lambda (widget value)
177 (custom-split-regexp-maybe value))
178 :match (lambda (widget value)
180 (widget-editable-list-match widget value)))
182 :group 'gnus-article-hiding)
184 (defcustom gnus-sorted-header-list
185 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
186 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
187 "*This variable is a list of regular expressions.
188 If it is non-nil, headers that match the regular expressions will
189 be placed first in the article buffer in the sequence specified by
191 :type '(repeat regexp)
192 :group 'gnus-article-hiding)
194 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
195 "Headers that are only to be displayed if they have interesting data.
196 Possible values in this list are:
198 'empty Headers with no content.
199 'newsgroups Newsgroup identical to Gnus group.
200 'to-address To identical to To-address.
201 'to-list To identical to To-list.
202 'cc-list CC identical to To-list.
203 'followup-to Followup-to identical to Newsgroups.
204 'reply-to Reply-to identical to From.
205 'date Date less than four days old.
206 'long-to To and/or Cc longer than 1024 characters.
207 'many-to Multiple To and/or Cc."
208 :type '(set (const :tag "Headers with no content." empty)
209 (const :tag "Newsgroups identical to Gnus group." newsgroups)
210 (const :tag "To identical to To-address." to-address)
211 (const :tag "To identical to To-list." to-list)
212 (const :tag "CC identical to To-list." cc-list)
213 (const :tag "Followup-to identical to Newsgroups." followup-to)
214 (const :tag "Reply-to identical to From." reply-to)
215 (const :tag "Date less than four days old." date)
216 (const :tag "To and/or Cc longer than 1024 characters." long-to)
217 (const :tag "Multiple To and/or Cc headers." many-to))
218 :group 'gnus-article-hiding)
220 (defcustom gnus-article-skip-boring nil
221 "Skip over text that is not worth reading.
222 By default, if you set this t, then Gnus will display citations and
223 signatures, but will never scroll down to show you a page consisting
224 only of boring text. Boring text is controlled by
225 `gnus-article-boring-faces'."
227 :group 'gnus-article-hiding)
229 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
230 "Regexp matching signature separator.
231 This can also be a list of regexps. In that case, it will be checked
232 from head to tail looking for a separator. Searches will be done from
233 the end of the buffer."
234 :type '(repeat string)
235 :group 'gnus-article-signature)
237 (defcustom gnus-signature-limit nil
238 "Provide a limit to what is considered a signature.
239 If it is a number, no signature may not be longer (in characters) than
240 that number. If it is a floating point number, no signature may be
241 longer (in lines) than that number. If it is a function, the function
242 will be called without any parameters, and if it returns nil, there is
243 no signature in the buffer. If it is a string, it will be used as a
244 regexp. If it matches, the text in question is not a signature."
245 :type '(choice (integer :value 200)
247 (function :value fun)
248 (regexp :value ".*"))
249 :group 'gnus-article-signature)
251 (defcustom gnus-hidden-properties '(invisible t intangible t)
252 "Property list to use for hiding text."
254 :group 'gnus-article-hiding)
256 ;; Fixme: This isn't the right thing for mixed graphical and and
257 ;; non-graphical frames in a session.
258 (defcustom gnus-article-x-face-command
263 (if (or (gnus-image-type-available-p 'xface)
264 (gnus-image-type-available-p 'pbm))
265 'gnus-display-x-face-in-from
266 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -"))
267 ((and (fboundp 'image-type-available-p)
268 (module-installed-p 'x-face-e21))
269 'x-face-decode-message-header)
270 ((gnus-image-type-available-p 'pbm)
271 'gnus-display-x-face-in-from)
273 (module-installed-p 'x-face-mule))
274 'x-face-mule-gnus-article-display-x-face)
276 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
278 "*String or function to be executed to display an X-Face header.
279 If it is a string, the command will be executed in a sub-shell
280 asynchronously. The compressed face will be piped to this command."
282 ,@(let (x-face-e21 x-face-mule)
283 (if (featurep 'xemacs)
285 (setq x-face-e21 (module-installed-p 'x-face-e21)
286 x-face-mule (module-installed-p 'x-face-mule)))
290 (if (or (gnus-image-type-available-p 'xface)
291 (gnus-image-type-available-p 'pbm))
292 '(function-item gnus-display-x-face-in-from))
294 (fboundp 'image-type-available-p))
296 :tag "x-face-decode-message-header (x-face-e21)"
297 x-face-decode-message-header))
300 x-face-mule-gnus-article-display-x-face))
304 :group 'gnus-article-washing)
306 (defcustom gnus-article-x-face-too-ugly nil
307 "Regexp matching posters whose face shouldn't be shown automatically."
308 :type '(choice regexp (const nil))
309 :group 'gnus-article-washing)
311 (defcustom gnus-article-banner-alist nil
312 "Banner alist for stripping.
314 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
316 :type '(repeat (cons symbol regexp))
317 :group 'gnus-article-washing)
319 (gnus-define-group-parameter
322 "Alist of regexps (to match group names) and banner."
323 :variable-group gnus-article-washing
325 '(choice :tag "Banner"
327 (const :tag "Remove signature" signature)
328 (symbol :tag "Item in `gnus-article-banner-alist'" none)
330 (const :tag "None" nil))
332 "If non-nil, specify how to remove `banners' from articles.
334 Symbol `signature' means to remove signatures delimited by
335 `gnus-signature-separator'. Any other symbol is used to look up a
336 regular expression to match the banner in `gnus-article-banner-alist'.
337 A string is used as a regular expression to match the banner
340 (defcustom gnus-article-address-banner-alist nil
341 "Alist of mail addresses and banners.
342 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
343 to match a mail address in the From: header, BANNER is one of a symbol
344 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
345 If ADDRESS matches author's mail address, it will remove things like
346 advertisements. For example:
348 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
352 (regexp :tag "Address")
353 (choice :tag "Banner" :value nil
354 (const :tag "Remove signature" signature)
355 (symbol :tag "Item in `gnus-article-banner-alist'" none)
357 (const :tag "None" nil))))
358 :group 'gnus-article-washing)
360 (defcustom gnus-emphasis-alist
362 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
367 ("_/" "/_" underline-italic)
368 ("_\\*" "\\*_" underline-bold)
369 ("\\*/" "/\\*" bold-italic)
370 ("_\\*/" "/\\*_" underline-bold-italic))))
374 (format format (car spec) (car (cdr spec)))
375 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
377 ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
378 2 3 gnus-emphasis-strikethru)
379 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
380 2 3 gnus-emphasis-underline)))
381 "*Alist that says how to fontify certain phrases.
382 Each item looks like this:
384 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
386 The first element is a regular expression to be matched. The second
387 is a number that says what regular expression grouping used to find
388 the entire emphasized word. The third is a number that says what
389 regexp grouping should be displayed and highlighted. The fourth
390 is the face used for highlighting."
391 :type '(repeat (list :value ("" 0 0 default)
393 (integer :tag "Match group")
394 (integer :tag "Emphasize group")
396 :group 'gnus-article-emphasis)
398 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
399 "A regexp to describe whitespace which should not be emphasized.
400 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
401 The former avoids underlining of leading and trailing whitespace,
402 and the latter avoids underlining any whitespace at all."
404 :group 'gnus-article-emphasis
407 (defface gnus-emphasis-bold '((t (:bold t)))
408 "Face used for displaying strong emphasized text (*word*)."
409 :group 'gnus-article-emphasis)
411 (defface gnus-emphasis-italic '((t (:italic t)))
412 "Face used for displaying italic emphasized text (/word/)."
413 :group 'gnus-article-emphasis)
415 (defface gnus-emphasis-underline '((t (:underline t)))
416 "Face used for displaying underlined emphasized text (_word_)."
417 :group 'gnus-article-emphasis)
419 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
420 "Face used for displaying underlined bold emphasized text (_*word*_)."
421 :group 'gnus-article-emphasis)
423 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
424 "Face used for displaying underlined italic emphasized text (_/word/_)."
425 :group 'gnus-article-emphasis)
427 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
428 "Face used for displaying bold italic emphasized text (/*word*/)."
429 :group 'gnus-article-emphasis)
431 (defface gnus-emphasis-underline-bold-italic
432 '((t (:bold t :italic t :underline t)))
433 "Face used for displaying underlined bold italic emphasized text.
434 Example: (_/*word*/_)."
435 :group 'gnus-article-emphasis)
437 (defface gnus-emphasis-strikethru '((t (:strikethru t)))
438 "Face used for displaying strike-through text (-word-)."
439 :group 'gnus-article-emphasis)
441 (defface gnus-emphasis-highlight-words
442 '((t (:background "black" :foreground "yellow")))
443 "Face used for displaying highlighted words."
444 :group 'gnus-article-emphasis)
446 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
447 "Format for display of Date headers in article bodies.
448 See `format-time-string' for the possible values.
450 The variable can also be function, which should return a complete Date
451 header. The function is called with one argument, the time, which can
452 be fed to `format-time-string'."
453 :type '(choice string symbol)
454 :link '(custom-manual "(gnus)Article Date")
455 :group 'gnus-article-washing)
458 (autoload 'mail-extract-address-components "mail-extr"))
460 (defcustom gnus-save-all-headers t
461 "*If non-nil, don't remove any headers before saving."
462 :group 'gnus-article-saving
465 (defcustom gnus-prompt-before-saving 'always
466 "*This variable says how much prompting is to be done when saving articles.
467 If it is nil, no prompting will be done, and the articles will be
468 saved to the default files. If this variable is `always', each and
469 every article that is saved will be preceded by a prompt, even when
470 saving large batches of articles. If this variable is neither nil not
471 `always', there the user will be prompted once for a file name for
472 each invocation of the saving commands."
473 :group 'gnus-article-saving
474 :type '(choice (item always)
475 (item :tag "never" nil)
476 (sexp :tag "once" :format "%t\n" :value t)))
478 (defcustom gnus-saved-headers gnus-visible-headers
479 "Headers to keep if `gnus-save-all-headers' is nil.
480 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
481 If that variable is nil, however, all headers that match this regexp
482 will be kept while the rest will be deleted before saving."
483 :group 'gnus-article-saving
486 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
487 "A function to save articles in your favourite format.
488 The function must be interactively callable (in other words, it must
489 be an Emacs command).
491 Gnus provides the following functions:
493 * gnus-summary-save-in-rmail (Rmail format)
494 * gnus-summary-save-in-mail (Unix mail format)
495 * gnus-summary-save-in-folder (MH folder)
496 * gnus-summary-save-in-file (article format)
497 * gnus-summary-save-body-in-file (article body)
498 * gnus-summary-save-in-vm (use VM's folder format)
499 * gnus-summary-write-to-file (article format -- overwrite)."
500 :group 'gnus-article-saving
501 :type '(radio (function-item gnus-summary-save-in-rmail)
502 (function-item gnus-summary-save-in-mail)
503 (function-item gnus-summary-save-in-folder)
504 (function-item gnus-summary-save-in-file)
505 (function-item gnus-summary-save-body-in-file)
506 (function-item gnus-summary-save-in-vm)
507 (function-item gnus-summary-write-to-file)))
509 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
510 "A function generating a file name to save articles in Rmail format.
511 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
512 :group 'gnus-article-saving
515 (defcustom gnus-mail-save-name 'gnus-plain-save-name
516 "A function generating a file name to save articles in Unix mail format.
517 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
518 :group 'gnus-article-saving
521 (defcustom gnus-folder-save-name 'gnus-folder-save-name
522 "A function generating a file name to save articles in MH folder.
523 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
524 :group 'gnus-article-saving
527 (defcustom gnus-file-save-name 'gnus-numeric-save-name
528 "A function generating a file name to save articles in article format.
529 The function is called with NEWSGROUP, HEADERS, and optional
531 :group 'gnus-article-saving
534 (defcustom gnus-split-methods
535 '((gnus-article-archive-name)
536 (gnus-article-nndoc-name))
537 "*Variable used to suggest where articles are to be saved.
538 For instance, if you would like to save articles related to Gnus in
539 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
540 you could set this variable to something like:
542 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
543 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
545 This variable is an alist where the where the key is the match and the
546 value is a list of possible files to save in if the match is non-nil.
548 If the match is a string, it is used as a regexp match on the
549 article. If the match is a symbol, that symbol will be funcalled
550 from the buffer of the article to be saved with the newsgroup as the
551 parameter. If it is a list, it will be evaled in the same buffer.
553 If this form or function returns a string, this string will be used as
554 a possible file name; and if it returns a non-nil list, that list will
555 be used as possible file names."
556 :group 'gnus-article-saving
557 :type '(repeat (choice (list :value (fun) function)
558 (cons :value ("" "") regexp (repeat string))
561 (defcustom gnus-article-display-method-for-mime
562 'gnus-article-display-mime-message
563 "Function to display a MIME message.
564 The function is called from the article buffer."
565 :group 'gnus-article-mime
568 (defcustom gnus-article-display-method-for-traditional
569 'gnus-article-display-traditional-message
570 "*Function to display a traditional message.
571 The function is called from the article buffer."
572 :group 'gnus-article-mime
575 (defcustom gnus-page-delimiter "^\^L"
576 "*Regexp describing what to use as article page delimiters.
577 The default value is \"^\^L\", which is a form linefeed at the
578 beginning of a line."
580 :group 'gnus-article-various)
582 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
583 "*The format specification for the article mode line.
584 See `gnus-summary-mode-line-format' for a closer description.
586 The following additional specs are available:
588 %w The article washing status.
589 %m The number of MIME parts in the article."
591 :group 'gnus-article-various)
593 (defcustom gnus-article-mode-hook nil
594 "*A hook for Gnus article mode."
596 :group 'gnus-article-various)
598 (when (featurep 'xemacs)
599 ;; Extracted from gnus-xmas-define in order to preserve user settings
600 (when (fboundp 'turn-off-scroll-in-place)
601 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
602 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
603 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
605 (defcustom gnus-article-menu-hook nil
606 "*Hook run after the creation of the article mode menu."
608 :group 'gnus-article-various)
610 (defcustom gnus-article-prepare-hook nil
611 "*A hook called after an article has been prepared in the article buffer."
613 :group 'gnus-article-various)
615 (make-obsolete-variable 'gnus-article-hide-pgp-hook
616 "This variable is obsolete in Gnus 5.10.")
618 (defcustom gnus-article-button-face 'bold
619 "Face used for highlighting buttons in the article buffer.
621 An article button is a piece of text that you can activate by pressing
622 `RET' or `mouse-2' above it."
624 :group 'gnus-article-buttons)
626 (defcustom gnus-article-mouse-face 'highlight
627 "Face used for mouse highlighting in the article buffer.
629 Article buttons will be displayed in this face when the cursor is
632 :group 'gnus-article-buttons)
634 (defcustom gnus-signature-face 'gnus-signature-face
635 "Face used for highlighting a signature in the article buffer.
636 Obsolete; use the face `gnus-signature-face' for customizations instead."
638 :group 'gnus-article-highlight
639 :group 'gnus-article-signature)
641 (defface gnus-signature-face
644 "Face used for highlighting a signature in the article buffer."
645 :group 'gnus-article-highlight
646 :group 'gnus-article-signature)
648 (defface gnus-header-from-face
651 (:foreground "spring green"))
654 (:foreground "red3"))
657 "Face used for displaying from headers."
658 :group 'gnus-article-headers
659 :group 'gnus-article-highlight)
661 (defface gnus-header-subject-face
664 (:foreground "SeaGreen3"))
667 (:foreground "red4"))
669 (:bold t :italic t)))
670 "Face used for displaying subject headers."
671 :group 'gnus-article-headers
672 :group 'gnus-article-highlight)
674 (defface gnus-header-newsgroups-face
677 (:foreground "yellow" :italic t))
680 (:foreground "MidnightBlue" :italic t))
683 "Face used for displaying newsgroups headers."
684 :group 'gnus-article-headers
685 :group 'gnus-article-highlight)
687 (defface gnus-header-name-face
690 (:foreground "SeaGreen"))
693 (:foreground "maroon"))
696 "Face used for displaying header names."
697 :group 'gnus-article-headers
698 :group 'gnus-article-highlight)
700 (defface gnus-header-content-face
703 (:foreground "forest green" :italic t))
706 (:foreground "indianred4" :italic t))
709 "Face used for displaying header content."
710 :group 'gnus-article-headers
711 :group 'gnus-article-highlight)
713 (defcustom gnus-header-face-alist
714 '(("From" nil gnus-header-from-face)
715 ("Subject" nil gnus-header-subject-face)
716 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
717 ("" gnus-header-name-face gnus-header-content-face))
718 "*Controls highlighting of article header.
720 An alist of the form (HEADER NAME CONTENT).
722 HEADER is a regular expression which should match the name of an
723 header header and NAME and CONTENT are either face names or nil.
725 The name of each header field will be displayed using the face
726 specified by the first element in the list where HEADER match the
727 header name and NAME is non-nil. Similarly, the content will be
728 displayed by the first non-nil matching CONTENT face."
729 :group 'gnus-article-headers
730 :group 'gnus-article-highlight
731 :type '(repeat (list (regexp :tag "Header")
733 (item :tag "skip" nil)
734 (face :value default))
735 (choice :tag "Content"
736 (item :tag "skip" nil)
737 (face :value default)))))
739 (defcustom gnus-article-decode-hook
740 '(article-decode-group-name article-decode-idna-rhs)
741 "*Hook run to decode charsets in articles."
742 :group 'gnus-article-headers
745 (defcustom gnus-display-mime-function 'gnus-display-mime
746 "Function to display MIME articles."
747 :group 'gnus-article-mime
750 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
751 "Function used to decode headers.")
753 (defvar gnus-article-dumbquotes-map
773 "Table for MS-to-Latin1 translation.")
775 (defcustom gnus-ignored-mime-types nil
776 "List of MIME types that should be ignored by Gnus."
778 :group 'gnus-article-mime
779 :type '(repeat regexp))
781 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
782 "List of MIME types that should not be given buttons when rendered inline.
783 See also `gnus-buttonized-mime-types' which may override this variable.
784 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
786 :group 'gnus-article-mime
787 :type '(repeat regexp))
789 (defcustom gnus-buttonized-mime-types nil
790 "List of MIME types that should be given buttons when rendered inline.
791 If set, this variable overrides `gnus-unbuttonized-mime-types'.
792 To see e.g. security buttons you could set this to
793 `(\"multipart/signed\")'.
794 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
796 :group 'gnus-article-mime
797 :type '(repeat regexp))
799 (defcustom gnus-inhibit-mime-unbuttonizing nil
800 "If non-nil, all MIME parts get buttons.
801 When nil (the default value), then some MIME parts do not get buttons,
802 as described by the variables `gnus-buttonized-mime-types' and
803 `gnus-unbuttonized-mime-types'."
807 (defcustom gnus-body-boundary-delimiter "_"
808 "String used to delimit header and body.
809 This variable is used by `gnus-article-treat-body-boundary' which can
810 be controlled by `gnus-treat-body-boundary'."
811 :group 'gnus-article-various
812 :type '(choice (item :tag "None" :value nil)
815 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
816 "Defines the location of the faces database.
817 For information on obtaining this database of pretty pictures, please
818 see http://www.cs.indiana.edu/picons/ftp/index.html"
819 :type '(repeat directory)
820 :link '(url-link :tag "download"
821 "http://www.cs.indiana.edu/picons/ftp/index.html")
822 :link '(custom-manual "(gnus)Picons")
825 (defun gnus-picons-installed-p ()
826 "Say whether picons are installed on your machine."
827 (let ((installed nil))
828 (dolist (database gnus-picon-databases)
829 (when (file-exists-p database)
833 (defcustom gnus-article-mime-part-function nil
834 "Function called with a MIME handle as the argument.
835 This is meant for people who want to do something automatic based
836 on parts -- for instance, adding Vcard info to a database."
837 :group 'gnus-article-mime
840 (defcustom gnus-mime-multipart-functions nil
841 "An alist of MIME types to functions to display them."
843 :group 'gnus-article-mime
846 (defcustom gnus-article-date-lapsed-new-header nil
847 "Whether the X-Sent and Date headers can coexist.
848 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
849 either replace the old \"Date:\" header (if this variable is nil), or
850 be added below it (otherwise)."
852 :group 'gnus-article-headers
855 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
856 "Function called with a MIME handle as the argument.
857 This is meant for people who want to view first matched part.
858 For `undisplayed-alternative' (default), the first undisplayed
859 part or alternative part is used. For `undisplayed', the first
860 undisplayed part is used. For a function, the first part which
861 the function return t is used. For nil, the first part is
864 :group 'gnus-article-mime
866 (item :tag "first" :value nil)
867 (item :tag "undisplayed" :value undisplayed)
868 (item :tag "undisplayed or alternative"
869 :value undisplayed-alternative)
872 (defcustom gnus-mime-action-alist
873 '(("save to file" . gnus-mime-save-part)
874 ("save and strip" . gnus-mime-save-part-and-strip)
875 ("delete part" . gnus-mime-delete-part)
876 ("display as text" . gnus-mime-inline-part)
877 ("view the part" . gnus-mime-view-part)
878 ("pipe to command" . gnus-mime-pipe-part)
879 ("toggle display" . gnus-article-press-button)
880 ("toggle display" . gnus-article-view-part-as-charset)
881 ("view as type" . gnus-mime-view-part-as-type)
882 ("view internally" . gnus-mime-view-part-internally)
883 ("view externally" . gnus-mime-view-part-externally))
884 "An alist of actions that run on the MIME attachment."
885 :group 'gnus-article-mime
886 :type '(repeat (cons (string :tag "name")
890 ;;; The treatment variables
893 (defvar gnus-part-display-hook nil
894 "Hook called on parts that are to receive treatment.")
896 (defvar gnus-article-treat-custom
897 '(choice (const :tag "Off" nil)
899 (const :tag "Header" head)
900 (const :tag "Last" last)
901 (const :tag "Mime" mime)
902 (integer :tag "Less")
903 (repeat :tag "Groups" regexp)
904 (sexp :tag "Predicate")))
906 (defvar gnus-article-treat-head-custom
907 '(choice (const :tag "Off" nil)
908 (const :tag "Header" head)))
910 (defvar gnus-article-treat-types '("text/plain")
913 (defvar gnus-inhibit-treatment nil
914 "Whether to inhibit treatment.")
916 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
917 "Highlight the signature.
918 Valid values are nil, t, `head', `last', an integer or a predicate.
919 See Info node `(gnus)Customizing Articles'."
920 :group 'gnus-article-treat
921 :link '(custom-manual "(gnus)Customizing Articles")
922 :type gnus-article-treat-custom)
923 (put 'gnus-treat-highlight-signature 'highlight t)
925 (defcustom gnus-treat-buttonize 100000
927 Valid values are nil, t, `head', `last', an integer or a predicate.
928 See Info node `(gnus)Customizing Articles'."
929 :group 'gnus-article-treat
930 :link '(custom-manual "(gnus)Customizing Articles")
931 :type gnus-article-treat-custom)
932 (put 'gnus-treat-buttonize 'highlight t)
934 (defcustom gnus-treat-buttonize-head 'head
935 "Add buttons to the head.
936 Valid values are nil, t, `head', `last', an integer or a predicate.
937 See Info node `(gnus)Customizing Articles' for details."
938 :group 'gnus-article-treat
939 :link '(custom-manual "(gnus)Customizing Articles")
940 :type gnus-article-treat-head-custom)
941 (put 'gnus-treat-buttonize-head 'highlight t)
943 (defcustom gnus-treat-emphasize
944 (and (or window-system
946 (>= (string-to-number emacs-version) 21))
949 Valid values are nil, t, `head', `last', an integer or a predicate.
950 See Info node `(gnus)Customizing Articles' for details."
951 :group 'gnus-article-treat
952 :link '(custom-manual "(gnus)Customizing Articles")
953 :type gnus-article-treat-custom)
954 (put 'gnus-treat-emphasize 'highlight t)
956 (defcustom gnus-treat-strip-cr nil
957 "Remove carriage returns.
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-unsplit-urls nil
965 "Remove newlines from within URLs.
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-leading-whitespace nil
973 "Remove leading whitespace in headers.
974 Valid values are nil, t, `head', `last', an integer or a predicate.
975 See Info node `(gnus)Customizing Articles' for details."
976 :group 'gnus-article-treat
977 :link '(custom-manual "(gnus)Customizing Articles")
978 :type gnus-article-treat-custom)
980 (defcustom gnus-treat-hide-headers 'head
982 Valid values are nil, t, `head', `last', an integer or a predicate.
983 See Info node `(gnus)Customizing Articles' for details."
984 :group 'gnus-article-treat
985 :link '(custom-manual "(gnus)Customizing Articles")
986 :type gnus-article-treat-head-custom)
988 (defcustom gnus-treat-hide-boring-headers nil
989 "Hide boring headers.
990 Valid values are nil, t, `head', `last', an integer or a predicate.
991 See Info node `(gnus)Customizing Articles' for details."
992 :group 'gnus-article-treat
993 :link '(custom-manual "(gnus)Customizing Articles")
994 :type gnus-article-treat-head-custom)
996 (defcustom gnus-treat-hide-signature nil
998 Valid values are nil, t, `head', `last', an integer or a predicate.
999 See Info node `(gnus)Customizing Articles' for details."
1000 :group 'gnus-article-treat
1001 :link '(custom-manual "(gnus)Customizing Articles")
1002 :type gnus-article-treat-custom)
1004 (defcustom gnus-treat-fill-article nil
1006 Valid values are nil, t, `head', `last', an integer or a predicate.
1007 See Info node `(gnus)Customizing Articles' for details."
1008 :group 'gnus-article-treat
1009 :link '(custom-manual "(gnus)Customizing Articles")
1010 :type gnus-article-treat-custom)
1012 (defcustom gnus-treat-hide-citation nil
1014 Valid values are nil, t, `head', `last', an integer or a predicate.
1015 See Info node `(gnus)Customizing Articles' for details."
1016 :group 'gnus-article-treat
1017 :link '(custom-manual "(gnus)Customizing Articles")
1018 :type gnus-article-treat-custom)
1020 (defcustom gnus-treat-hide-citation-maybe nil
1022 Valid values are nil, t, `head', `last', an integer or a predicate.
1023 See Info node `(gnus)Customizing Articles' for details."
1024 :group 'gnus-article-treat
1025 :link '(custom-manual "(gnus)Customizing Articles")
1026 :type gnus-article-treat-custom)
1028 (defcustom gnus-treat-strip-list-identifiers 'head
1029 "Strip list identifiers from `gnus-list-identifiers`.
1030 Valid values are nil, t, `head', `last', an integer or a predicate.
1031 See Info node `(gnus)Customizing Articles' for details."
1033 :group 'gnus-article-treat
1034 :link '(custom-manual "(gnus)Customizing Articles")
1035 :type gnus-article-treat-custom)
1037 (make-obsolete-variable 'gnus-treat-strip-pgp
1038 "This option is obsolete in Gnus 5.10.")
1040 (defcustom gnus-treat-strip-pem nil
1041 "Strip PEM signatures.
1042 Valid values are nil, t, `head', `last', an integer or a predicate.
1043 See Info node `(gnus)Customizing Articles' for details."
1044 :group 'gnus-article-treat
1045 :link '(custom-manual "(gnus)Customizing Articles")
1046 :type gnus-article-treat-custom)
1048 (defcustom gnus-treat-strip-banner t
1049 "Strip banners from articles.
1050 The banner to be stripped is specified in the `banner' group parameter.
1051 Valid values are nil, t, `head', `last', an integer or a predicate.
1052 See Info node `(gnus)Customizing Articles' for details."
1053 :group 'gnus-article-treat
1054 :link '(custom-manual "(gnus)Customizing Articles")
1055 :type gnus-article-treat-custom)
1057 (defcustom gnus-treat-highlight-headers 'head
1058 "Highlight the headers.
1059 Valid values are nil, t, `head', `last', an integer or a predicate.
1060 See Info node `(gnus)Customizing Articles' for details."
1061 :group 'gnus-article-treat
1062 :link '(custom-manual "(gnus)Customizing Articles")
1063 :type gnus-article-treat-head-custom)
1064 (put 'gnus-treat-highlight-headers 'highlight t)
1066 (defcustom gnus-treat-highlight-citation t
1067 "Highlight cited text.
1068 Valid values are nil, t, `head', `last', an integer or a predicate.
1069 See Info node `(gnus)Customizing Articles' for details."
1070 :group 'gnus-article-treat
1071 :link '(custom-manual "(gnus)Customizing Articles")
1072 :type gnus-article-treat-custom)
1073 (put 'gnus-treat-highlight-citation 'highlight t)
1075 (defcustom gnus-treat-date-ut nil
1076 "Display the Date in UT (GMT).
1077 Valid values are nil, t, `head', `last', an integer or a predicate.
1078 See Info node `(gnus)Customizing Articles' for details."
1079 :group 'gnus-article-treat
1080 :link '(custom-manual "(gnus)Customizing Articles")
1081 :type gnus-article-treat-head-custom)
1083 (defcustom gnus-treat-date-local nil
1084 "Display the Date in the local timezone.
1085 Valid values are nil, t, `head', `last', an integer or a predicate.
1086 See Info node `(gnus)Customizing Articles' for details."
1087 :group 'gnus-article-treat
1088 :link '(custom-manual "(gnus)Customizing Articles")
1089 :type gnus-article-treat-head-custom)
1091 (defcustom gnus-treat-date-english nil
1092 "Display the Date in a format that can be read aloud in English.
1093 Valid values are nil, t, `head', `last', an integer or a predicate.
1094 See Info node `(gnus)Customizing Articles' for details."
1095 :group 'gnus-article-treat
1096 :link '(custom-manual "(gnus)Customizing Articles")
1097 :type gnus-article-treat-head-custom)
1099 (defcustom gnus-treat-date-lapsed nil
1100 "Display the Date header in a way that says how much time has elapsed.
1101 Valid values are nil, t, `head', `last', an integer or a predicate.
1102 See Info node `(gnus)Customizing Articles' for details."
1103 :group 'gnus-article-treat
1104 :link '(custom-manual "(gnus)Customizing Articles")
1105 :type gnus-article-treat-head-custom)
1107 (defcustom gnus-treat-date-original nil
1108 "Display the date in the original timezone.
1109 Valid values are nil, t, `head', `last', an integer or a predicate.
1110 See Info node `(gnus)Customizing Articles' for details."
1111 :group 'gnus-article-treat
1112 :link '(custom-manual "(gnus)Customizing Articles")
1113 :type gnus-article-treat-head-custom)
1115 (defcustom gnus-treat-date-iso8601 nil
1116 "Display the date in the ISO8601 format.
1117 Valid values are nil, t, `head', `last', an integer or a predicate.
1118 See Info node `(gnus)Customizing Articles' for details."
1120 :group 'gnus-article-treat
1121 :link '(custom-manual "(gnus)Customizing Articles")
1122 :type gnus-article-treat-head-custom)
1124 (defcustom gnus-treat-date-user-defined nil
1125 "Display the date in a user-defined format.
1126 The format is defined by the `gnus-article-time-format' variable.
1127 Valid values are nil, t, `head', `last', an integer or a predicate.
1128 See Info node `(gnus)Customizing Articles' for details."
1129 :group 'gnus-article-treat
1130 :link '(custom-manual "(gnus)Customizing Articles")
1131 :type gnus-article-treat-head-custom)
1133 (defcustom gnus-treat-strip-headers-in-body t
1134 "Strip the X-No-Archive header line from the beginning of the body.
1135 Valid values are nil, t, `head', `last', an integer or a predicate.
1136 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)
1142 (defcustom gnus-treat-strip-trailing-blank-lines nil
1143 "Strip trailing blank lines.
1144 Valid values are nil, t, `head', `last', an integer or a predicate.
1145 See Info node `(gnus)Customizing Articles' for details."
1146 :group 'gnus-article-treat
1147 :link '(custom-manual "(gnus)Customizing Articles")
1148 :type gnus-article-treat-custom)
1150 (defcustom gnus-treat-strip-leading-blank-lines nil
1151 "Strip leading blank lines.
1152 Valid values are nil, t, `head', `last', an integer or a predicate.
1153 See Info node `(gnus)Customizing Articles' for details."
1154 :group 'gnus-article-treat
1155 :link '(custom-manual "(gnus)Customizing Articles")
1156 :type gnus-article-treat-custom)
1158 (defcustom gnus-treat-strip-multiple-blank-lines nil
1159 "Strip multiple blank lines.
1160 Valid values are nil, t, `head', `last', an integer or a predicate.
1161 See Info node `(gnus)Customizing Articles' for details."
1162 :group 'gnus-article-treat
1163 :link '(custom-manual "(gnus)Customizing Articles")
1164 :type gnus-article-treat-custom)
1166 (defcustom gnus-treat-unfold-headers 'head
1167 "Unfold folded header lines.
1168 Valid values are nil, t, `head', `last', an integer or a predicate.
1169 See Info node `(gnus)Customizing Articles' for details."
1170 :group 'gnus-article-treat
1171 :link '(custom-manual "(gnus)Customizing Articles")
1172 :type gnus-article-treat-custom)
1174 (defcustom gnus-treat-fold-headers nil
1176 Valid values are nil, t, `head', `last', an integer or a predicate.
1177 See Info node `(gnus)Customizing Articles' for details."
1178 :group 'gnus-article-treat
1179 :link '(custom-manual "(gnus)Customizing Articles")
1180 :type gnus-article-treat-custom)
1182 (defcustom gnus-treat-fold-newsgroups 'head
1183 "Fold the Newsgroups and Followup-To headers.
1184 Valid values are nil, t, `head', `last', an integer or a predicate.
1185 See Info node `(gnus)Customizing Articles' for details."
1186 :group 'gnus-article-treat
1187 :link '(custom-manual "(gnus)Customizing Articles")
1188 :type gnus-article-treat-custom)
1190 (defcustom gnus-treat-overstrike t
1191 "Treat overstrike highlighting.
1192 Valid values are nil, t, `head', `last', an integer or a predicate.
1193 See Info node `(gnus)Customizing Articles' for details."
1194 :group 'gnus-article-treat
1195 :link '(custom-manual "(gnus)Customizing Articles")
1196 :type gnus-article-treat-custom)
1197 (put 'gnus-treat-overstrike 'highlight t)
1199 (defcustom gnus-treat-display-xface
1200 (and (not noninteractive)
1201 (or (memq gnus-article-x-face-command
1202 '(x-face-decode-message-header
1203 x-face-mule-gnus-article-display-x-face))
1204 (and (fboundp 'image-type-available-p)
1205 (image-type-available-p 'xbm)
1206 (string-match "^0x" (shell-command-to-string "uncompface"))
1207 (executable-find "icontopbm"))
1208 (and (featurep 'xemacs)
1211 "Display X-Face headers.
1212 Valid values are nil, t, `head', `last', an integer or a predicate.
1213 See Info node `(gnus)Customizing Articles' and Info node
1214 `(gnus)X-Face' for details."
1215 :group 'gnus-article-treat
1217 :link '(custom-manual "(gnus)Customizing Articles")
1218 :link '(custom-manual "(gnus)X-Face")
1219 :type gnus-article-treat-head-custom)
1220 (put 'gnus-treat-display-xface 'highlight t)
1222 (defcustom gnus-article-should-use-smiley-mule
1223 (not (or (featurep 'xemacs)
1224 (gnus-image-type-available-p 'xpm)
1225 (gnus-image-type-available-p 'pbm)))
1226 "If non-nil, gnus uses `smiley-mule' for displaying smileys rather than
1227 `smiley'. It defaults to t when Emacs 20 or earlier is running.
1228 `smiley-mule' is boundled in BITMAP-MULE package. You can set it to t
1229 even if you are using Emacs 21+. It has no effect on XEmacs."
1230 :group 'gnus-article-various
1232 :get (lambda (symbol)
1233 (and (not noninteractive)
1234 (default-value symbol)
1235 (not (featurep 'xemacs))
1236 (module-installed-p 'smiley-mule)
1238 :set (lambda (symbol value)
1239 (set-default symbol (and (not noninteractive)
1241 (not (featurep 'xemacs))
1242 (module-installed-p 'smiley-mule)
1245 (defvar gnus-article-smiley-mule-loaded-p nil
1246 "Internal variable used to say whether `smiley-mule' is loaded (whether
1247 smiley functions are not overridden by `smiley').")
1249 (defcustom gnus-treat-display-face
1250 (and (not noninteractive)
1251 ;; x-face-e21 handles both X-Face and Face headers.
1252 (not (and (eq gnus-article-x-face-command 'x-face-decode-message-header)
1253 (module-installed-p 'x-face-e21)))
1254 (or (and (fboundp 'image-type-available-p)
1255 (image-type-available-p 'png))
1256 (and (featurep 'xemacs)
1259 "Display Face headers.
1260 Valid values are nil, t, `head', `last', an integer or a predicate.
1261 See Info node `(gnus)Customizing Articles' and Info node
1262 `(gnus)X-Face' for details."
1263 :group 'gnus-article-treat
1265 :link '(custom-manual "(gnus)Customizing Articles")
1266 :link '(custom-manual "(gnus)X-Face")
1267 :type gnus-article-treat-head-custom)
1268 (put 'gnus-treat-display-face 'highlight t)
1270 (defcustom gnus-treat-display-smileys
1271 (if (and (not noninteractive)
1272 (or (and (featurep 'xemacs)
1274 (gnus-image-type-available-p 'xpm)
1275 (gnus-image-type-available-p 'pbm)
1276 (and (not (featurep 'xemacs))
1278 (module-installed-p 'smiley-mule))))
1282 Valid values are nil, t, `head', `last', an integer or a predicate.
1283 See Info node `(gnus)Customizing Articles' and Info node
1284 `(gnus)Smileys' for details."
1285 :group 'gnus-article-treat
1287 :link '(custom-manual "(gnus)Customizing Articles")
1288 :link '(custom-manual "(gnus)Smileys")
1289 :type gnus-article-treat-custom)
1290 (put 'gnus-treat-display-smileys 'highlight t)
1292 (defcustom gnus-treat-from-picon
1293 (if (and (gnus-image-type-available-p 'xpm)
1294 (gnus-picons-installed-p))
1296 "Display picons in the From header.
1297 Valid values are nil, t, `head', `last', an integer or a predicate.
1298 See Info node `(gnus)Customizing Articles' and Info node
1299 `(gnus)Picons' for details."
1300 :group 'gnus-article-treat
1302 :link '(custom-manual "(gnus)Customizing Articles")
1303 :link '(custom-manual "(gnus)Picons")
1304 :type gnus-article-treat-head-custom)
1305 (put 'gnus-treat-from-picon 'highlight t)
1307 (defcustom gnus-treat-mail-picon
1308 (if (and (gnus-image-type-available-p 'xpm)
1309 (gnus-picons-installed-p))
1311 "Display picons in To and Cc headers.
1312 Valid values are nil, t, `head', `last', an integer or a predicate.
1313 See Info node `(gnus)Customizing Articles' and Info node
1314 `(gnus)Picons' for details."
1315 :group 'gnus-article-treat
1317 :link '(custom-manual "(gnus)Customizing Articles")
1318 :link '(custom-manual "(gnus)Picons")
1319 :type gnus-article-treat-head-custom)
1320 (put 'gnus-treat-mail-picon 'highlight t)
1322 (defcustom gnus-treat-newsgroups-picon
1323 (if (and (gnus-image-type-available-p 'xpm)
1324 (gnus-picons-installed-p))
1326 "Display picons in the Newsgroups and Followup-To headers.
1327 Valid values are nil, t, `head', `last', an integer or a predicate.
1328 See Info node `(gnus)Customizing Articles' and Info node
1329 `(gnus)Picons' for details."
1330 :group 'gnus-article-treat
1332 :link '(custom-manual "(gnus)Customizing Articles")
1333 :link '(custom-manual "(gnus)Picons")
1334 :type gnus-article-treat-head-custom)
1335 (put 'gnus-treat-newsgroups-picon 'highlight t)
1337 (defcustom gnus-treat-body-boundary
1338 (if (or gnus-treat-newsgroups-picon
1339 gnus-treat-mail-picon
1340 gnus-treat-from-picon)
1342 "Draw a boundary at the end of the headers.
1343 Valid values are nil, t, `head', `last', an integer or a predicate.
1344 See Info node `(gnus)Customizing Articles' for details."
1346 :group 'gnus-article-treat
1347 :link '(custom-manual "(gnus)Customizing Articles")
1348 :type gnus-article-treat-custom)
1350 (defcustom gnus-treat-capitalize-sentences nil
1351 "Capitalize sentence-starting words.
1352 Valid values are nil, t, `head', `last', an integer or a predicate.
1353 See Info node `(gnus)Customizing Articles' for details."
1355 :group 'gnus-article-treat
1356 :link '(custom-manual "(gnus)Customizing Articles")
1357 :type gnus-article-treat-custom)
1359 (defcustom gnus-treat-wash-html nil
1361 Valid values are nil, t, `head', `last', an integer or a predicate.
1362 See Info node `(gnus)Customizing Articles' for details."
1363 :group 'gnus-article-treat
1364 :link '(custom-manual "(gnus)Customizing Articles")
1365 :type gnus-article-treat-custom)
1367 (defcustom gnus-treat-fill-long-lines nil
1369 Valid values are nil, t, `head', `last', an integer or a predicate.
1370 See Info node `(gnus)Customizing Articles' for details."
1371 :group 'gnus-article-treat
1372 :link '(custom-manual "(gnus)Customizing Articles")
1373 :type gnus-article-treat-custom)
1375 (defcustom gnus-treat-play-sounds nil
1377 Valid values are nil, t, `head', `last', an integer or a predicate.
1378 See Info node `(gnus)Customizing Articles' for details."
1380 :group 'gnus-article-treat
1381 :link '(custom-manual "(gnus)Customizing Articles")
1382 :type gnus-article-treat-custom)
1384 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
1385 "Decode an article as `default-mime-charset'. For instance, if you want to
1386 attempt to decode an article even if the value of `gnus-show-mime' is nil,
1387 you could set this variable to something like: nil for don't decode, t for
1388 decode the body, '(or header t) for the whole article, etc."
1389 :group 'gnus-article-treat
1390 :type '(radio (const :tag "Off" nil)
1391 (const :tag "Decode body" t)
1392 (const :tag "Decode all" (or head t))))
1394 (defcustom gnus-treat-translate nil
1395 "Translate articles from one language to another.
1396 Valid values are nil, t, `head', `last', an integer or a predicate.
1397 See Info node `(gnus)Customizing Articles' for details."
1399 :group 'gnus-article-treat
1400 :link '(custom-manual "(gnus)Customizing Articles")
1401 :type gnus-article-treat-custom)
1403 (defcustom gnus-treat-x-pgp-sig nil
1405 To automatically treat X-PGP-Sig, set it to head.
1406 Valid values are nil, t, `head', `last', an integer or a predicate.
1407 See Info node `(gnus)Customizing Articles' for details."
1408 :group 'gnus-article-treat
1409 :group 'mime-security
1410 :type gnus-article-treat-custom)
1412 (defcustom gnus-treat-monafy nil
1413 "Display body part with mona font.
1414 Valid values are nil, t, `head', `last', an integer or a predicate.
1415 See Info node `(gnus)Customizing Articles' for details."
1416 :group 'gnus-article-treat
1417 :group 'mime-security
1418 :link '(custom-manual "(gnus)Customizing Articles")
1419 :type gnus-article-treat-custom)
1421 (defvar gnus-article-encrypt-protocol-alist
1422 '(("PGP" . mml2015-self-encrypt)))
1424 ;; Set to nil if more than one protocol added to
1425 ;; gnus-article-encrypt-protocol-alist.
1426 (defcustom gnus-article-encrypt-protocol "PGP"
1427 "The protocol used for encrypt articles.
1428 It is a string, such as \"PGP\". If nil, ask user."
1430 :group 'mime-security)
1432 (defvar gnus-article-wash-function nil
1433 "Function used for converting HTML into text.")
1435 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1436 (mm-coding-system-p 'utf-8))
1437 "Whether IDNA decoding of headers is used when viewing messages.
1438 This requires GNU Libidn, and by default only enabled if it is found."
1439 :group 'gnus-article-headers
1442 (defcustom gnus-article-over-scroll nil
1443 "If non-nil, allow scrolling the article buffer even when there no more text."
1444 :group 'gnus-article
1447 ;;; Internal variables
1449 (defvar gnus-english-month-names
1450 '("January" "February" "March" "April" "May" "June" "July" "August"
1451 "September" "October" "November" "December"))
1453 (defvar article-goto-body-goes-to-point-min-p nil)
1454 (defvar gnus-article-wash-types nil)
1455 (defvar gnus-article-emphasis-alist nil)
1456 (defvar gnus-article-image-alist nil)
1458 (defvar gnus-article-mime-handle-alist-1 nil)
1459 (defvar gnus-treatment-function-alist
1460 '((gnus-treat-decode-article-as-default-mime-charset
1461 gnus-article-decode-article-as-default-mime-charset)
1462 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1463 (gnus-treat-monafy gnus-article-monafy)
1464 (gnus-treat-strip-banner gnus-article-strip-banner)
1465 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1466 (gnus-treat-buttonize gnus-article-add-buttons)
1467 (gnus-treat-fill-article gnus-article-fill-cited-article)
1468 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1469 (gnus-treat-strip-cr gnus-article-remove-cr)
1470 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1471 (gnus-treat-date-ut gnus-article-date-ut)
1472 (gnus-treat-date-local gnus-article-date-local)
1473 (gnus-treat-date-english gnus-article-date-english)
1474 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1475 (gnus-treat-date-original gnus-article-date-original)
1476 (gnus-treat-date-user-defined gnus-article-date-user)
1477 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1478 (gnus-treat-display-face gnus-article-display-face)
1479 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1480 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1481 (gnus-treat-hide-signature gnus-article-hide-signature)
1482 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1483 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1484 (gnus-treat-strip-pem gnus-article-hide-pem)
1485 (gnus-treat-from-picon gnus-treat-from-picon)
1486 (gnus-treat-mail-picon gnus-treat-mail-picon)
1487 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1488 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1489 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1490 (gnus-treat-strip-trailing-blank-lines
1491 gnus-article-remove-trailing-blank-lines)
1492 (gnus-treat-strip-leading-blank-lines
1493 gnus-article-strip-leading-blank-lines)
1494 (gnus-treat-strip-multiple-blank-lines
1495 gnus-article-strip-multiple-blank-lines)
1496 (gnus-treat-overstrike gnus-article-treat-overstrike)
1497 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1498 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1499 ;; Displaying X-Face should be done after unfolding headers
1500 ;; to protect bitmap lines.
1501 (gnus-treat-display-xface gnus-article-display-x-face)
1502 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1503 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1504 (gnus-treat-display-smileys gnus-treat-smiley)
1505 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1506 (gnus-treat-wash-html gnus-article-wash-html)
1507 (gnus-treat-emphasize gnus-article-emphasize)
1508 (gnus-treat-hide-citation gnus-article-hide-citation)
1509 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1510 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1511 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1512 (gnus-treat-play-sounds gnus-earcon-display)))
1514 (defvar gnus-article-mime-handle-alist nil)
1515 (defvar article-lapsed-timer nil)
1516 (defvar gnus-article-current-summary nil)
1518 (defvar gnus-article-mode-syntax-table
1519 (let ((table (copy-syntax-table text-mode-syntax-table)))
1520 ;; This causes the citation match run O(2^n).
1521 ;; (modify-syntax-entry ?- "w" table)
1522 (modify-syntax-entry ?> ")<" table)
1523 (modify-syntax-entry ?< "(>" table)
1524 ;; make M-. in article buffers work for `foo' strings
1525 (modify-syntax-entry ?' " " table)
1526 (modify-syntax-entry ?` " " table)
1528 "Syntax table used in article mode buffers.
1529 Initialized from `text-mode-syntax-table.")
1531 (defvar gnus-save-article-buffer nil)
1533 (defvar gnus-article-mode-line-format-alist
1534 (nconc '((?w (gnus-article-wash-status) ?s)
1535 (?m (gnus-article-mime-part-status) ?s))
1536 gnus-summary-mode-line-format-alist))
1538 (defvar gnus-number-of-articles-to-be-saved nil)
1540 (defvar gnus-inhibit-hiding nil)
1542 ;;; Macros for dealing with the article buffer.
1544 (defmacro gnus-with-article-headers (&rest forms)
1546 (set-buffer gnus-article-buffer)
1548 (let ((buffer-read-only nil)
1549 (inhibit-point-motion-hooks t)
1550 (case-fold-search t))
1551 (article-narrow-to-head)
1554 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1555 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1557 (defmacro gnus-with-article-buffer (&rest forms)
1559 (set-buffer gnus-article-buffer)
1560 (let ((buffer-read-only nil))
1563 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1564 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1566 (defun gnus-article-goto-header (header)
1567 "Go to HEADER, which is a regular expression."
1568 (re-search-forward (concat "^\\(" header "\\):") nil t))
1570 (defsubst gnus-article-hide-text (b e props)
1571 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1572 (gnus-add-text-properties-when 'article-type nil b e props)
1573 (when (memq 'intangible props)
1575 (max (1- b) (point-min))
1576 b 'intangible (cddr (memq 'intangible props)))))
1578 (defsubst gnus-article-unhide-text (b e)
1579 "Remove hidden text properties from region between B and E."
1580 (remove-text-properties b e gnus-hidden-properties)
1581 (when (memq 'intangible gnus-hidden-properties)
1582 (put-text-property (max (1- b) (point-min))
1583 b 'intangible nil)))
1585 (defun gnus-article-hide-text-type (b e type)
1586 "Hide text of TYPE between B and E."
1587 (gnus-add-wash-type type)
1588 (gnus-article-hide-text
1589 b e (cons 'article-type (cons type gnus-hidden-properties))))
1591 (defun gnus-article-unhide-text-type (b e type)
1592 "Unhide text of TYPE between B and E."
1593 (gnus-delete-wash-type type)
1594 (remove-text-properties
1595 b e (cons 'article-type (cons type gnus-hidden-properties)))
1596 (when (memq 'intangible gnus-hidden-properties)
1597 (put-text-property (max (1- b) (point-min))
1598 b 'intangible nil)))
1600 (defun gnus-article-hide-text-of-type (type)
1601 "Hide text of TYPE in the current buffer."
1603 (let ((b (point-min))
1605 (while (setq b (text-property-any b e 'article-type type))
1606 (add-text-properties b (incf b) gnus-hidden-properties)))))
1608 (defun gnus-article-delete-text-of-type (type)
1609 "Delete text of TYPE in the current buffer."
1611 (let ((b (point-min)))
1612 (while (setq b (text-property-any b (point-max) 'article-type type))
1614 b (or (text-property-not-all b (point-max) 'article-type type)
1617 (defun gnus-article-delete-invisible-text ()
1618 "Delete all invisible text in the current buffer."
1620 (let ((b (point-min)))
1621 (while (setq b (text-property-any b (point-max) 'invisible t))
1623 b (or (text-property-not-all b (point-max) 'invisible t)
1626 (defun gnus-article-text-type-exists-p (type)
1627 "Say whether any text of type TYPE exists in the buffer."
1628 (text-property-any (point-min) (point-max) 'article-type type))
1630 (defsubst gnus-article-header-rank ()
1631 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1632 (let ((list gnus-sorted-header-list)
1635 (if (looking-at (car list))
1637 (setq list (cdr list))
1641 (defun article-hide-headers (&optional arg delete)
1642 "Hide unwanted headers and possibly sort them as well."
1643 (interactive (gnus-article-hidden-arg))
1644 ;; Lars said that this function might be inhibited.
1645 (if (gnus-article-check-hidden-text 'headers arg)
1647 ;; Show boring headers as well.
1648 (gnus-article-show-hidden-text 'boring-headers)
1649 (when (eq 1 (point-min))
1650 (set-window-start (get-buffer-window (current-buffer)) 1)))
1651 (unless gnus-inhibit-hiding
1654 (let ((inhibit-read-only t)
1655 (case-fold-search t)
1656 (max (1+ (length gnus-sorted-header-list)))
1657 (ignored (when (not gnus-visible-headers)
1658 (cond ((stringp gnus-ignored-headers)
1659 gnus-ignored-headers)
1660 ((listp gnus-ignored-headers)
1661 (mapconcat 'identity gnus-ignored-headers
1664 (cond ((stringp gnus-visible-headers)
1665 gnus-visible-headers)
1666 ((and gnus-visible-headers
1667 (listp gnus-visible-headers))
1668 (mapconcat 'identity gnus-visible-headers "\\|"))))
1669 (inhibit-point-motion-hooks t)
1671 ;; First we narrow to just the headers.
1672 (article-narrow-to-head)
1673 ;; Hide any "From " lines at the beginning of (mail) articles.
1674 (while (looking-at "From ")
1678 (delete-region (point-min) (point))
1679 (gnus-article-hide-text (point-min) (point)
1680 (nconc (list 'article-type 'headers)
1681 gnus-hidden-properties))))
1682 ;; Then treat the rest of the header lines.
1683 ;; Then we use the two regular expressions
1684 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1685 ;; select which header lines is to remain visible in the
1687 (while (re-search-forward "^[^ \t:]*:" nil t)
1689 ;; Mark the rank of the header.
1691 (point) (1+ (point)) 'message-rank
1692 (if (or (and visible (looking-at visible))
1694 (not (looking-at ignored))))
1695 (gnus-article-header-rank)
1698 (message-sort-headers-1)
1699 (when (setq beg (text-property-any
1700 (point-min) (point-max) 'message-rank (+ 2 max)))
1701 ;; We delete or make invisible the unwanted headers.
1702 (gnus-add-wash-type 'headers)
1705 (add-text-properties
1706 (point-min) (+ 5 (point-min))
1707 '(article-type headers dummy-invisible t))
1708 (delete-region beg (point-max)))
1709 (gnus-article-hide-text-type beg (point-max) 'headers)))))))))
1711 (defun article-hide-boring-headers (&optional arg)
1712 "Toggle hiding of headers that aren't very interesting.
1713 If given a negative prefix, always show; if given a positive prefix,
1715 (interactive (gnus-article-hidden-arg))
1716 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1717 (not gnus-show-all-headers))
1720 (let ((buffer-read-only nil)
1721 (list gnus-boring-article-headers)
1722 (inhibit-point-motion-hooks t)
1724 (article-narrow-to-head)
1726 (setq elem (pop list))
1727 (goto-char (point-min))
1729 ;; Hide empty headers.
1731 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1733 (gnus-article-hide-text-type
1737 (if (re-search-forward "^[^ \t]" nil t)
1741 ;; Hide boring Newsgroups header.
1742 ((eq elem 'newsgroups)
1743 (when (gnus-string-equal
1744 (gnus-fetch-field "newsgroups")
1745 (gnus-group-real-name
1746 (if (boundp 'gnus-newsgroup-name)
1749 (gnus-article-hide-header "newsgroups")))
1750 ((eq elem 'to-address)
1751 (let ((to (message-fetch-field "to"))
1753 (gnus-parameter-to-address
1754 (if (boundp 'gnus-newsgroup-name)
1755 gnus-newsgroup-name ""))))
1756 (when (and to to-address
1759 ;; only one address in To
1760 (nth 1 (mail-extract-address-components to))
1762 (gnus-article-hide-header "to"))))
1764 (let ((to (message-fetch-field "to"))
1766 (gnus-parameter-to-list
1767 (if (boundp 'gnus-newsgroup-name)
1768 gnus-newsgroup-name ""))))
1769 (when (and to to-list
1772 ;; only one address in To
1773 (nth 1 (mail-extract-address-components to))
1775 (gnus-article-hide-header "to"))))
1777 (let ((cc (message-fetch-field "cc"))
1779 (gnus-parameter-to-list
1780 (if (boundp 'gnus-newsgroup-name)
1781 gnus-newsgroup-name ""))))
1782 (when (and cc to-list
1785 ;; only one address in CC
1786 (nth 1 (mail-extract-address-components cc))
1788 (gnus-article-hide-header "cc"))))
1789 ((eq elem 'followup-to)
1790 (when (gnus-string-equal
1791 (message-fetch-field "followup-to")
1792 (message-fetch-field "newsgroups"))
1793 (gnus-article-hide-header "followup-to")))
1794 ((eq elem 'reply-to)
1795 (if (gnus-group-find-parameter
1796 gnus-newsgroup-name 'broken-reply-to)
1797 (gnus-article-hide-header "reply-to")
1798 (let ((from (message-fetch-field "from"))
1799 (reply-to (message-fetch-field "reply-to")))
1804 (nth 1 (mail-extract-address-components from))
1805 (nth 1 (mail-extract-address-components reply-to)))))
1806 (gnus-article-hide-header "reply-to")))))
1808 (let ((date (message-fetch-field "date")))
1810 (< (days-between (current-time-string) date)
1812 (gnus-article-hide-header "date"))))
1814 (let ((to (message-fetch-field "to"))
1815 (cc (message-fetch-field "cc")))
1816 (when (> (length to) 1024)
1817 (gnus-article-hide-header "to"))
1818 (when (> (length cc) 1024)
1819 (gnus-article-hide-header "cc"))))
1823 (goto-char (point-min))
1824 (while (re-search-forward "^to:" nil t)
1825 (setq to-count (1+ to-count)))
1826 (when (> to-count 1)
1827 (while (> to-count 0)
1828 (goto-char (point-min))
1830 (re-search-forward "^to:" nil nil to-count)
1832 (narrow-to-region (point) (point-max))
1833 (gnus-article-hide-header "to"))
1834 (setq to-count (1- to-count))))
1835 (goto-char (point-min))
1836 (while (re-search-forward "^cc:" nil t)
1837 (setq cc-count (1+ cc-count)))
1838 (when (> cc-count 1)
1839 (while (> cc-count 0)
1840 (goto-char (point-min))
1842 (re-search-forward "^cc:" nil nil cc-count)
1844 (narrow-to-region (point) (point-max))
1845 (gnus-article-hide-header "cc"))
1846 (setq cc-count (1- cc-count)))))))))))))
1848 (defun gnus-article-hide-header (header)
1850 (goto-char (point-min))
1851 (when (re-search-forward (concat "^" header ":") nil t)
1852 (gnus-article-hide-text-type
1856 (if (re-search-forward "^[^ \t]" nil t)
1861 (defvar gnus-article-normalized-header-length 40
1862 "Length of normalized headers.")
1864 (defun article-normalize-headers ()
1865 "Make all header lines 40 characters long."
1867 (let ((buffer-read-only nil)
1871 (article-narrow-to-head)
1874 ((< (setq column (- (gnus-point-at-eol) (point)))
1875 gnus-article-normalized-header-length)
1877 (insert (make-string
1878 (- gnus-article-normalized-header-length column)
1880 ((> column gnus-article-normalized-header-length)
1881 (gnus-put-text-property
1883 (forward-char gnus-article-normalized-header-length)
1890 (forward-line 1))))))
1892 (defun article-treat-dumbquotes ()
1893 "Translate M****s*** sm*rtq**t*s into proper text.
1894 Note that this function guesses whether a character is a sm*rtq**t* or
1895 not, so it should only be used interactively.
1897 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1898 in an attempt to provide more quoting characters. If you see
1899 something like \\222 or \\264 where you're expecting some kind of
1900 apostrophe or quotation mark, then try this wash."
1902 (article-translate-strings gnus-article-dumbquotes-map))
1904 (defun article-translate-characters (from to)
1905 "Translate all characters in the body of the article according to FROM and TO.
1906 FROM is a string of characters to translate from; to is a string of
1907 characters to translate to."
1909 (when (article-goto-body)
1910 (let ((buffer-read-only nil)
1911 (x (make-string 225 ?x))
1913 (while (< (incf i) (length x))
1916 (while (< i (length from))
1917 (aset x (aref from i) (aref to i))
1919 (translate-region (point) (point-max) x)))))
1921 (defun article-translate-strings (map)
1922 "Translate all string in the body of the article according to MAP.
1923 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1925 (when (article-goto-body)
1926 (let ((buffer-read-only nil)
1928 (while (setq elem (pop map))
1930 (while (search-forward (car elem) nil t)
1931 (replace-match (cadr elem)))))))))
1933 (defun article-treat-overstrike ()
1934 "Translate overstrikes into bold text."
1937 (when (article-goto-body)
1938 (let ((buffer-read-only nil))
1939 (while (search-forward "\b" nil t)
1940 (let ((next (char-after))
1944 previous (char-after))
1948 ;; We do the boldification/underlining by hiding the
1949 ;; overstrikes and putting the proper text property
1953 (gnus-article-hide-text-type start (point) 'overstrike)
1954 (put-text-property (point) end 'face 'bold))
1956 (gnus-article-hide-text-type
1957 (1- (point)) (1+ (point)) 'overstrike)
1959 start (1- (point)) 'face 'underline))
1961 (gnus-article-hide-text-type start (point) 'overstrike)
1963 (point) end 'face 'underline)))))))))
1965 (defun gnus-article-treat-unfold-headers ()
1966 "Unfold folded message headers.
1967 Only the headers that fit into the current window width will be
1970 (gnus-with-article-headers
1974 (mail-header-narrow-to-field)
1975 (let ((header (buffer-string)))
1978 (goto-char (point-min))
1979 (while (re-search-forward "\n[\t ]" nil t)
1980 (replace-match " " t t)))
1981 (setq length (- (point-max) (point-min) 1)))
1982 (when (< length (window-width))
1983 (while (re-search-forward "\n[\t ]" nil t)
1984 (replace-match " " t t)))
1985 (goto-char (point-max)))))))
1987 (defun gnus-article-treat-fold-headers ()
1988 "Fold message headers."
1990 (gnus-with-article-headers
1993 (mail-header-narrow-to-field)
1994 (mail-header-fold-field)
1995 (goto-char (point-max))))))
1997 (defun gnus-treat-smiley ()
1998 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2000 (unless (featurep 'xemacs)
2001 (when (and (>= emacs-major-version 21)
2002 (not gnus-article-should-use-smiley-mule)
2003 gnus-article-smiley-mule-loaded-p)
2004 (load "smiley" nil t)
2005 (setq gnus-article-smiley-mule-loaded-p nil))
2006 (when (and gnus-article-should-use-smiley-mule
2007 (not gnus-article-smiley-mule-loaded-p))
2008 (load "smiley-mule" nil t)
2009 (setq gnus-article-smiley-mule-loaded-p t)))
2010 (gnus-with-article-buffer
2011 (if (memq 'smiley gnus-article-wash-types)
2012 (gnus-delete-images 'smiley)
2014 (let ((images (smiley-region (point) (point-max))))
2016 (gnus-add-wash-type 'smiley)
2017 (dolist (image images)
2018 (gnus-add-image 'smiley image)))))))
2020 (defun gnus-article-remove-images ()
2021 "Remove all images from the article buffer."
2023 (gnus-with-article-buffer
2024 (dolist (elem gnus-article-image-alist)
2025 (gnus-delete-images (car elem)))))
2027 (defun gnus-article-treat-fold-newsgroups ()
2028 "Unfold folded message headers.
2029 Only the headers that fit into the current window width will be
2032 (gnus-with-article-headers
2033 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2035 (mail-header-narrow-to-field)
2036 (while (re-search-forward ", *" nil t)
2037 (replace-match ", " t t))
2038 (mail-header-fold-field)
2039 (goto-char (point-max))))))
2041 (defun gnus-article-treat-body-boundary ()
2042 "Place a boundary line at the end of the headers."
2044 (when (and gnus-body-boundary-delimiter
2045 (> (length gnus-body-boundary-delimiter) 0))
2046 (gnus-with-article-headers
2047 (goto-char (point-max))
2048 (let ((start (point)))
2049 (insert "X-Boundary: ")
2050 (gnus-add-text-properties start (point) '(invisible t intangible t))
2052 (while (>= (1- (window-width)) (length str))
2053 (setq str (concat str gnus-body-boundary-delimiter)))
2054 (substring str 0 (1- (window-width))))
2056 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2058 (defun article-fill-long-lines ()
2059 "Fill lines that are wider than the window width."
2062 (let ((buffer-read-only nil)
2063 (width (window-width (get-buffer-window (current-buffer)))))
2066 (let ((adaptive-fill-mode nil)) ;Why? -sm
2069 (when (>= (current-column) (min fill-column width))
2070 (narrow-to-region (min (1+ (point)) (point-max))
2071 (gnus-point-at-bol))
2072 (let ((goback (point-marker)))
2073 (fill-paragraph nil)
2074 (goto-char (marker-position goback)))
2076 (forward-line 1)))))))
2078 (defun article-capitalize-sentences ()
2079 "Capitalize the first word in each sentence."
2082 (let ((buffer-read-only nil)
2083 (paragraph-start "^[\n\^L]"))
2087 (forward-sentence)))))
2089 (defun article-remove-cr ()
2090 "Remove trailing CRs and then translate remaining CRs into LFs."
2093 (let ((buffer-read-only nil))
2094 (goto-char (point-min))
2095 (while (re-search-forward "\r+$" nil t)
2096 (replace-match "" t t))
2097 (goto-char (point-min))
2098 (while (search-forward "\r" nil t)
2099 (replace-match "\n" t t)))))
2101 (defun article-remove-trailing-blank-lines ()
2102 "Remove all trailing blank lines from the article."
2105 (let ((buffer-read-only nil))
2106 (goto-char (point-max))
2110 (while (and (not (bobp))
2111 (looking-at "^[ \t]*$")
2112 (not (gnus-annotation-in-region-p
2113 (point) (gnus-point-at-eol))))
2118 (defun article-display-face ()
2119 "Display any Face headers in the header."
2121 (gnus-with-article-headers
2122 (let ((face (message-fetch-field "face")))
2124 (let ((png (gnus-convert-face-to-png face))
2127 (setq image (gnus-create-image png 'png t))
2128 (gnus-article-goto-header "from")
2130 (insert "From: [no `from' set]\n")
2132 (gnus-add-wash-type 'face)
2133 (gnus-add-image 'face image)
2134 (gnus-put-image image)))))))
2136 (defun article-display-x-face (&optional force)
2137 "Look for an X-Face header and display it if present."
2138 (interactive (list 'force))
2139 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2140 (gnus-with-article-headers
2141 ;; Delete the old process, if any.
2142 (when (process-status "article-x-face")
2143 (delete-process "article-x-face"))
2144 (if (memq 'xface gnus-article-wash-types)
2145 ;; We have already displayed X-Faces, so we remove them
2147 (gnus-delete-images 'xface)
2149 (let (x-faces from face)
2151 (when (and wash-face-p
2153 (goto-char (point-min))
2154 (not (re-search-forward
2155 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2156 (gnus-buffer-live-p gnus-original-article-buffer))
2157 ;; If type `W f', use gnus-original-article-buffer,
2158 ;; otherwise use the current buffer because displaying
2159 ;; RFC822 parts calls this function too.
2160 (set-buffer gnus-original-article-buffer))
2162 (mail-narrow-to-head)
2163 (while (gnus-article-goto-header "X-Face")
2164 (push (mail-header-field-value) x-faces))
2165 (setq from (message-fetch-field "from"))))
2166 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2167 ;; single external face.
2168 (when (stringp gnus-article-x-face-command)
2169 (setq x-faces (list (car x-faces))))
2170 (while (and (setq face (pop x-faces))
2171 gnus-article-x-face-command
2173 ;; Check whether this face is censored.
2174 (not gnus-article-x-face-too-ugly)
2175 (and gnus-article-x-face-too-ugly from
2176 (not (string-match gnus-article-x-face-too-ugly
2178 ;; We display the face.
2179 (if (symbolp gnus-article-x-face-command)
2180 ;; The command is a lisp function, so we call it.
2181 (if (functionp gnus-article-x-face-command)
2182 (funcall gnus-article-x-face-command face)
2183 (error "%s is not a function" gnus-article-x-face-command))
2184 ;; The command is a string, so we interpret the command
2185 ;; as a, well, command, and fork it off.
2186 (let ((process-connection-type nil))
2187 (process-kill-without-query
2189 "article-x-face" nil shell-file-name shell-command-switch
2190 gnus-article-x-face-command))
2193 (process-send-region "article-x-face"
2194 (point-min) (point-max)))
2195 (process-send-eof "article-x-face")))))))))
2197 (defun article-decode-mime-words ()
2198 "Decode all MIME-encoded words in the article."
2201 (set-buffer gnus-article-buffer)
2202 (let ((inhibit-point-motion-hooks t)
2204 (mail-parse-charset gnus-newsgroup-charset)
2205 (mail-parse-ignored-charsets
2206 (save-excursion (set-buffer gnus-summary-buffer)
2207 gnus-newsgroup-ignored-charsets)))
2208 (mail-decode-encoded-word-region (point-min) (point-max)))))
2210 (defun article-decode-charset (&optional prompt)
2211 "Decode charset-encoded text in the article.
2212 If PROMPT (the prefix), prompt for a coding system to use."
2214 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2216 (mail-parse-charset gnus-newsgroup-charset)
2217 (mail-parse-ignored-charsets
2218 (save-excursion (condition-case nil
2219 (set-buffer gnus-summary-buffer)
2221 gnus-newsgroup-ignored-charsets))
2222 ct cte ctl charset format)
2225 (article-narrow-to-head)
2226 (setq ct (message-fetch-field "Content-Type" t)
2227 cte (message-fetch-field "Content-Transfer-Encoding" t)
2228 ctl (and ct (ignore-errors
2229 (mail-header-parse-content-type ct)))
2232 (mm-read-coding-system "Charset to decode: "))
2234 (mail-content-type-get ctl 'charset)))
2235 format (and ctl (mail-content-type-get ctl 'format)))
2237 (setq cte (mail-header-strip cte)))
2238 (if (and ctl (not (string-match "/" (car ctl))))
2240 (goto-char (point-max)))
2243 (narrow-to-region (point) (point-max))
2244 (when (and (eq mail-parse-charset 'gnus-decoded)
2245 (eq (mm-body-7-or-8) '8bit))
2246 ;; The text code could have been decoded.
2247 (setq charset mail-parse-charset))
2248 (when (and (or (not ctl)
2249 (equal (car ctl) "text/plain"))
2250 (not format)) ;; article with format will decode later.
2252 charset (and cte (intern (downcase
2253 (gnus-strip-whitespace cte))))
2254 (car ctl) prompt))))))
2256 (defun article-decode-encoded-words ()
2257 "Remove encoded-word encoding from headers."
2258 (let (buffer-read-only)
2259 (let ((charset (save-excursion
2260 (set-buffer gnus-summary-buffer)
2261 default-mime-charset)))
2262 (mime-decode-header-in-buffer charset))))
2264 (defun article-decode-group-name ()
2265 "Decode group names in `Newsgroups:'."
2266 (let ((inhibit-point-motion-hooks t)
2268 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2269 (when (and (or gnus-group-name-charset-method-alist
2270 gnus-group-name-charset-group-alist)
2271 (gnus-buffer-live-p gnus-original-article-buffer))
2273 (article-narrow-to-head)
2274 (with-current-buffer gnus-original-article-buffer
2275 (goto-char (point-min)))
2276 (while (re-search-forward
2277 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2278 (replace-match (save-match-data
2279 (gnus-decode-newsgroups
2280 ;; XXX how to use data in article buffer?
2281 (with-current-buffer gnus-original-article-buffer
2283 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2286 gnus-newsgroup-name method))
2288 (goto-char (point-min))
2289 (with-current-buffer gnus-original-article-buffer
2290 (goto-char (point-min)))
2291 (while (re-search-forward
2292 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2293 (replace-match (save-match-data
2294 (gnus-decode-newsgroups
2295 ;; XXX how to use data in article buffer?
2296 (with-current-buffer gnus-original-article-buffer
2298 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2301 gnus-newsgroup-name method))
2304 (autoload 'idna-to-unicode "idna")
2306 (defun article-decode-idna-rhs ()
2307 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2310 (let ((inhibit-point-motion-hooks t)
2312 (article-narrow-to-head)
2313 (goto-char (point-min))
2314 (while (re-search-forward "\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2316 (when (save-match-data
2317 (and (setq ace (match-string 1))
2319 (and (re-search-backward "^[^ \t]" nil t)
2320 (looking-at "From\\|To\\|Cc")))
2321 (save-excursion (backward-char)
2322 (message-idna-inside-rhs-p))
2323 (setq unicode (idna-to-unicode ace))))
2324 (unless (string= ace unicode)
2325 (replace-match unicode nil nil nil 1)))))))))
2327 (defun article-de-quoted-unreadable (&optional force read-charset)
2328 "Translate a quoted-printable-encoded article.
2329 If FORCE, decode the article whether it is marked as quoted-printable
2331 If READ-CHARSET, ask for a coding system."
2332 (interactive (list 'force current-prefix-arg))
2334 (let ((buffer-read-only nil) type charset)
2335 (if (gnus-buffer-live-p gnus-original-article-buffer)
2336 (with-current-buffer gnus-original-article-buffer
2338 (gnus-fetch-field "content-transfer-encoding"))
2339 (let* ((ct (gnus-fetch-field "content-type"))
2342 (mail-header-parse-content-type ct)))))
2343 (setq charset (and ctl
2344 (mail-content-type-get ctl 'charset)))
2345 (if (stringp charset)
2346 (setq charset (intern (downcase charset)))))))
2348 (setq charset (mm-read-coding-system "Charset: " charset)))
2350 (setq charset gnus-newsgroup-charset))
2352 (and type (let ((case-fold-search t))
2353 (string-match "quoted-printable" type))))
2355 (quoted-printable-decode-region
2356 (point) (point-max) (mm-charset-to-coding-system charset))))))
2358 (defun article-de-base64-unreadable (&optional force read-charset)
2359 "Translate a base64 article.
2360 If FORCE, decode the article whether it is marked as base64 not.
2361 If READ-CHARSET, ask for a coding system."
2362 (interactive (list 'force current-prefix-arg))
2364 (let ((buffer-read-only nil) type charset)
2365 (if (gnus-buffer-live-p gnus-original-article-buffer)
2366 (with-current-buffer gnus-original-article-buffer
2368 (gnus-fetch-field "content-transfer-encoding"))
2369 (let* ((ct (gnus-fetch-field "content-type"))
2372 (mail-header-parse-content-type ct)))))
2373 (setq charset (and ctl
2374 (mail-content-type-get ctl 'charset)))
2375 (if (stringp charset)
2376 (setq charset (intern (downcase charset)))))))
2378 (setq charset (mm-read-coding-system "Charset: " charset)))
2380 (setq charset gnus-newsgroup-charset))
2382 (and type (let ((case-fold-search t))
2383 (string-match "base64" type))))
2386 (narrow-to-region (point) (point-max))
2387 (base64-decode-region (point-min) (point-max))
2388 (mm-decode-coding-region
2389 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2394 (defun article-decode-HZ ()
2395 "Translate a HZ-encoded article."
2399 (let ((buffer-read-only nil))
2400 (rfc1843-decode-region (point-min) (point-max)))))
2402 (defun article-unsplit-urls ()
2403 "Remove the newlines that some other mailers insert into URLs."
2406 (let ((buffer-read-only nil))
2407 (goto-char (point-min))
2408 (while (re-search-forward
2409 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2410 (replace-match "\\1\\3" t)))
2411 (when (and gnus-display-mime-function (interactive-p))
2412 (funcall gnus-display-mime-function))))
2415 (defun article-wash-html (&optional read-charset)
2416 "Format an HTML article.
2417 If READ-CHARSET, ask for a coding system."
2420 (let ((buffer-read-only nil)
2422 (when (gnus-buffer-live-p gnus-original-article-buffer)
2423 (with-current-buffer gnus-original-article-buffer
2424 (let* ((ct (gnus-fetch-field "content-type"))
2427 (mail-header-parse-content-type ct)))))
2428 (setq charset (and ctl
2429 (mail-content-type-get ctl 'charset)))
2430 (when (stringp charset)
2431 (setq charset (intern (downcase charset)))))))
2433 (setq charset (mm-read-coding-system "Charset: " charset)))
2435 (setq charset gnus-newsgroup-charset))
2437 (save-window-excursion
2439 (narrow-to-region (point) (point-max))
2440 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2441 (entry (assq func mm-text-html-washer-alist)))
2443 (setq func (cdr entry)))
2448 (apply (car func) (cdr func))))))))))
2450 (defun gnus-article-wash-html-with-w3 ()
2451 "Wash the current buffer with w3."
2453 (let ((w3-strict-width (window-width))
2454 (url-standalone-mode t)
2455 (url-gateway-unplugged t)
2456 (w3-honor-stylesheets nil))
2458 (w3-region (point-min) (point-max))
2461 (defun gnus-article-wash-html-with-w3m ()
2462 "Wash the current buffer with emacs-w3m."
2465 (narrow-to-region (point) (point-max))
2466 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2469 w3m-force-redisplay)
2470 (w3m-region (point-min) (point-max)))
2471 (when mm-inline-text-html-with-w3m-keymap
2472 (add-text-properties
2473 (point-min) (point-max)
2474 (nconc (mm-w3m-local-map-property)
2475 '(mm-inline-text-html-with-w3m t))))))
2477 (defun article-hide-list-identifiers ()
2478 "Remove list identifies from the Subject header.
2479 The `gnus-list-identifiers' variable specifies what to do."
2481 (let ((inhibit-point-motion-hooks t)
2482 (regexp (if (consp gnus-list-identifiers)
2483 (mapconcat 'identity gnus-list-identifiers " *\\|")
2484 gnus-list-identifiers))
2489 (article-narrow-to-head)
2490 (goto-char (point-min))
2491 (while (re-search-forward
2492 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2494 (delete-region (match-beginning 2) (match-end 0))
2495 (beginning-of-line))
2496 (when (re-search-forward
2497 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2498 (delete-region (match-beginning 1) (match-end 1))))))))
2500 (defun article-hide-pem (&optional arg)
2501 "Toggle hiding of any PEM headers and signatures in the current article.
2502 If given a negative prefix, always show; if given a positive prefix,
2504 (interactive (gnus-article-hidden-arg))
2505 (unless (gnus-article-check-hidden-text 'pem arg)
2507 (let (buffer-read-only end)
2508 (goto-char (point-min))
2509 ;; Hide the horrendously ugly "header".
2510 (when (and (search-forward
2511 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2513 (setq end (1+ (match-beginning 0))))
2514 (gnus-add-wash-type 'pem)
2515 (gnus-article-hide-text-type
2517 (if (search-forward "\n\n" nil t)
2521 ;; Hide the trailer as well
2522 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2524 (gnus-article-hide-text-type
2525 (match-beginning 0) (match-end 0) 'pem)))))))
2527 (defun article-strip-banner ()
2528 "Strip the banners specified by the `banner' group parameter and by
2529 `gnus-article-address-banner-alist'."
2533 (let ((inhibit-point-motion-hooks t))
2534 (when (gnus-parameter-banner gnus-newsgroup-name)
2535 (article-really-strip-banner
2536 (gnus-parameter-banner gnus-newsgroup-name)))
2537 (when gnus-article-address-banner-alist
2538 (article-really-strip-banner
2539 (let ((from (save-restriction
2541 (article-narrow-to-head)
2542 (mail-fetch-field "from"))))
2545 (caar (mail-header-parse-addresses from))))
2547 (dolist (pair gnus-article-address-banner-alist)
2548 (when (string-match (car pair) from)
2549 (throw 'found (cdr pair)))))))))))))
2551 (defun article-really-strip-banner (banner)
2552 "Strip the banner specified by the argument."
2555 (let ((inhibit-point-motion-hooks t)
2556 (gnus-signature-limit nil)
2560 ((eq banner 'signature)
2561 (when (gnus-article-narrow-to-signature)
2564 (delete-region (point) (point-max))))
2566 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2567 (while (re-search-forward banner nil t)
2568 (delete-region (match-beginning 0) (match-end 0)))))
2570 (while (re-search-forward banner nil t)
2571 (delete-region (match-beginning 0) (match-end 0)))))))))
2573 (defun article-babel ()
2574 "Translate article using an online translation service."
2578 (set-buffer gnus-article-buffer)
2579 (when (article-goto-body)
2580 (let* ((buffer-read-only nil)
2583 (orig (buffer-substring start end))
2584 (trans (babel-as-string orig)))
2586 (narrow-to-region start end)
2587 (delete-region start end)
2590 (defun article-hide-signature (&optional arg)
2591 "Hide the signature in the current article.
2592 If given a negative prefix, always show; if given a positive prefix,
2594 (interactive (gnus-article-hidden-arg))
2600 (article-goto-body))
2601 (goto-char (point-min)))
2602 (unless (gnus-article-check-hidden-text 'signature arg)
2603 (let ((buffer-read-only nil)
2605 (while (setq button (text-property-any button (point-max)
2607 'gnus-signature-toggle))
2608 (setq button (text-property-not-all button (point-max)
2610 'gnus-signature-toggle))
2611 (when (and button (not (eobp)))
2612 (gnus-article-hide-text-type
2614 (next-single-property-change (1+ button) 'mime-view-entity
2617 (gnus-set-mode-line 'article))
2619 (defun article-strip-headers-in-body ()
2620 "Strip offensive headers from bodies."
2624 (let ((case-fold-search t))
2625 (when (looking-at "x-no-archive:")
2626 (gnus-delete-line)))))
2628 (defun article-strip-leading-blank-lines ()
2629 "Remove all blank lines from the beginning of the article."
2632 (let ((inhibit-point-motion-hooks t)
2634 (when (article-goto-body)
2635 (while (and (not (eobp))
2636 (looking-at "[ \t]*$"))
2637 (gnus-delete-line))))))
2639 (defun article-narrow-to-head ()
2640 "Narrow the buffer to the head of the message.
2641 Point is left at the beginning of the narrowed-to region."
2643 (goto-char (point-min))
2644 (if (search-forward "\n\n" nil 1)
2647 (goto-char (point-min)))
2649 (defun article-goto-body ()
2650 "Place point at the start of the body."
2651 (goto-char (point-min))
2653 ;; This variable is only bound when dealing with separate
2655 (article-goto-body-goes-to-point-min-p
2657 ((search-forward "\n\n" nil t)
2660 (goto-char (point-max))
2663 (defun article-strip-multiple-blank-lines ()
2664 "Replace consecutive blank lines with one empty line."
2667 (let ((inhibit-point-motion-hooks t)
2669 ;; First make all blank lines empty.
2671 (while (re-search-forward "^[ \t]+$" nil t)
2672 (unless (gnus-annotation-in-region-p
2673 (match-beginning 0) (match-end 0))
2674 (replace-match "" nil t)))
2675 ;; Then replace multiple empty lines with a single empty line.
2677 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2678 (unless (gnus-annotation-in-region-p
2679 (match-beginning 0) (match-end 0))
2680 (delete-region (match-beginning 1) (match-end 1)))))))
2682 (defun article-strip-leading-space ()
2683 "Remove all white space from the beginning of the lines in the article."
2686 (let ((inhibit-point-motion-hooks t)
2689 (while (re-search-forward "^[ \t]+" nil t)
2690 (replace-match "" t t)))))
2692 (defun article-strip-trailing-space ()
2693 "Remove all white space from the end of the lines in the article."
2696 (let ((inhibit-point-motion-hooks t)
2699 (while (re-search-forward "[ \t]+$" nil t)
2700 (replace-match "" t t)))))
2702 (defun article-strip-blank-lines ()
2703 "Strip leading, trailing and multiple blank lines."
2705 (article-strip-leading-blank-lines)
2706 (article-remove-trailing-blank-lines)
2707 (article-strip-multiple-blank-lines))
2709 (defun article-strip-all-blank-lines ()
2710 "Strip all blank lines."
2713 (let ((inhibit-point-motion-hooks t)
2716 (while (re-search-forward "^[ \t]*\n" nil t)
2717 (replace-match "" t t)))))
2719 (defun gnus-article-narrow-to-signature ()
2720 "Narrow to the signature; return t if a signature is found, else nil."
2721 (let ((inhibit-point-motion-hooks t))
2722 (when (gnus-article-search-signature)
2724 ;; Check whether we have some limits to what we consider
2725 ;; to be a signature.
2726 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2727 (list gnus-signature-limit)))
2729 (while (setq limit (pop limits))
2730 (if (or (and (integerp limit)
2731 (< (- (point-max) (point)) limit))
2733 (< (count-lines (point) (point-max)) limit))
2734 (and (functionp limit)
2736 (and (stringp limit)
2737 (not (re-search-forward limit nil t))))
2738 () ; This limit did not succeed.
2742 (narrow-to-region (point) (point-max))
2745 (defun gnus-article-search-signature ()
2746 "Search the current buffer for the signature separator.
2747 Put point at the beginning of the signature separator."
2748 (let ((cur (point)))
2749 (goto-char (point-max))
2750 (if (if (stringp gnus-signature-separator)
2751 (re-search-backward gnus-signature-separator nil t)
2752 (let ((seps gnus-signature-separator))
2754 (not (re-search-backward (car seps) nil t)))
2761 (defun gnus-article-hidden-arg ()
2762 "Return the current prefix arg as a number, or 0 if no prefix."
2763 (list (if current-prefix-arg
2764 (prefix-numeric-value current-prefix-arg)
2767 (defun gnus-article-check-hidden-text (type arg)
2768 "Return nil if hiding is necessary.
2769 Arg can be nil or a number. nil and positive means hide, negative
2770 means show, 0 means toggle."
2773 (let ((hide (gnus-article-hidden-text-p type)))
2779 (gnus-article-show-hidden-text type)
2782 (if (eq hide 'hidden)
2784 (gnus-article-show-hidden-text type)
2788 (defun gnus-article-hidden-text-p (type)
2789 "Say whether the current buffer contains hidden text of type TYPE."
2790 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2792 (not (get-text-property pos 'invisible))
2793 (not (get-text-property pos 'dummy-invisible)))
2795 (text-property-any (1+ pos) (point-max) 'article-type type)))
2800 (defun gnus-article-show-hidden-text (type &optional dummy)
2801 "Show all hidden text of type TYPE.
2802 Originally it is hide instead of DUMMY."
2803 (let ((buffer-read-only nil)
2804 (inhibit-point-motion-hooks t))
2805 (gnus-remove-text-properties-when
2807 (point-min) (point-max)
2808 (cons 'article-type (cons type
2809 gnus-hidden-properties)))
2810 (gnus-delete-wash-type type)))
2812 (defconst article-time-units
2813 `((year . ,(* 365.25 24 60 60))
2814 (week . ,(* 7 24 60 60))
2815 (day . ,(* 24 60 60))
2819 "Mapping from time units to seconds.")
2821 (defun gnus-article-forward-header ()
2822 "Move point to the start of the next header.
2823 If the current header is a continuation header, this can be several
2828 (if (looking-at "[ \t]+[^ \t]")
2832 (defun article-date-ut (&optional type highlight header)
2833 "Convert DATE date to universal time in the current article.
2834 If TYPE is `local', convert to local time; if it is `lapsed', output
2835 how much time has lapsed since DATE. For `lapsed', the value of
2836 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2837 should replace the \"Date:\" one, or should be added below it."
2838 (interactive (list 'ut t))
2839 (let* ((header (or header
2840 (and (eq 1 (point-min))
2841 (mail-header-date (save-excursion
2842 (set-buffer gnus-summary-buffer)
2843 gnus-current-headers)))
2844 (message-fetch-field "date")
2846 (date (if (vectorp header) (mail-header-date header)
2848 (inhibit-point-motion-hooks t)
2849 bface eface date-pos)
2850 (when (and date (not (string= date "")))
2853 (article-narrow-to-head)
2854 (when (or (and (eq type 'lapsed)
2855 gnus-article-date-lapsed-new-header
2856 ;; Attempt to get the face of X-Sent first.
2857 (re-search-forward "^X-Sent:[ \t]" nil t))
2858 (re-search-forward "^Date:[ \t]" nil t)
2859 ;; If Date is missing, try again for X-Sent.
2860 (re-search-forward "^X-Sent:[ \t]" nil t))
2861 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2862 date (or (get-text-property (gnus-point-at-bol)
2865 eface (get-text-property (1- (gnus-point-at-eol))
2867 (let ((buffer-read-only nil))
2868 ;; Delete any old X-Sent headers.
2869 (when (setq date-pos
2870 (text-property-any (point-min) (point-max)
2871 'article-date-lapsed t))
2872 (goto-char (setq date-pos (set-marker (make-marker) date-pos)))
2873 (delete-region (match-beginning 0)
2874 (progn (forward-line 1) (point))))
2875 (goto-char (point-min))
2876 ;; Delete any old Date headers.
2877 (while (re-search-forward "^Date:[ \t]" nil t)
2879 (setq date-pos (match-beginning 0)))
2880 (unless (and (eq type 'lapsed)
2881 gnus-article-date-lapsed-new-header)
2882 (delete-region (match-beginning 0)
2883 (progn (message-next-header) (point)))))
2886 (goto-char date-pos)
2888 ;; Possibly, Date has been deleted.
2890 (when (and (eq type 'lapsed)
2891 gnus-article-date-lapsed-new-header
2892 (looking-at "Date:"))
2894 (goto-char (point-min)))
2895 (insert (article-make-date-line date type))
2896 (when (eq type 'lapsed)
2897 (put-text-property (gnus-point-at-bol) (point)
2898 'article-date-lapsed t))
2902 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2903 (put-text-property (match-beginning 1) (1+ (match-end 1))
2904 'original-date date)
2905 (put-text-property (match-beginning 1) (1+ (match-end 1))
2907 (put-text-property (match-beginning 2) (match-end 2)
2910 (defun article-make-date-line (date type)
2911 "Return a DATE line of TYPE."
2912 (unless (memq type '(local ut original user iso8601 lapsed english))
2913 (error "Unknown conversion type: %s" type))
2915 (let ((time (date-to-time date)))
2917 ;; Convert to the local timezone.
2919 (let ((tz (car (current-time-zone time))))
2920 (format "Date: %s %s%02d%02d" (current-time-string time)
2921 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2922 (/ (% (abs tz) 3600) 60))))
2923 ;; Convert to Universal Time.
2926 (current-time-string
2927 (let* ((e (parse-time-string date))
2928 (tm (apply 'encode-time e))
2930 (ls (- (cadr tm) (car (current-time-zone time)))))
2931 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2932 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2935 ;; Get the original date from the article.
2936 ((eq type 'original)
2937 (concat "Date: " (if (string-match "\n+$" date)
2938 (substring date 0 (match-beginning 0))
2940 ;; Let the user define the format.
2942 (let ((format (or (condition-case nil
2943 (with-current-buffer gnus-summary-buffer
2944 gnus-article-time-format)
2946 gnus-article-time-format)))
2947 (if (functionp format)
2948 (funcall format time)
2949 (concat "Date: " (format-time-string format time)))))
2952 (let ((tz (car (current-time-zone time))))
2955 (format-time-string "%Y%m%dT%H%M%S" time)
2956 (format "%s%02d%02d"
2957 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2958 (/ (% (abs tz) 3600) 60)))))
2959 ;; Do an X-Sent lapsed format.
2961 ;; If the date is seriously mangled, the timezone functions are
2962 ;; liable to bug out, so we ignore all errors.
2963 (let* ((now (current-time))
2964 (real-time (subtract-time now time))
2965 (real-sec (and real-time
2966 (+ (* (float (car real-time)) 65536)
2968 (sec (and real-time (abs real-sec)))
2978 ;; This is a bit convoluted, but basically we go
2979 ;; through the time units for years, weeks, etc,
2980 ;; and divide things to see whether that results
2981 ;; in positive answers.
2984 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2985 ;; The (remaining) seconds are too few to
2986 ;; be divided into this time unit.
2988 ;; It's big enough, so we output it.
2989 (setq sec (- sec (* num (cdr unit))))
2991 (concat (if prev ", " "") (int-to-string
2993 " " (symbol-name (car unit))
2994 (if (> num 1) "s" ""))
2996 article-time-units "")
2997 ;; If dates are odd, then it might appear like the
2998 ;; article was sent in the future.
3001 " in the future"))))))
3002 ;; Display the date in proper English
3004 (let ((dtime (decode-time time)))
3007 (number-to-string (nth 3 dtime))
3008 (let ((digit (% (nth 3 dtime) 10)))
3010 ((memq (nth 3 dtime) '(11 12 13)) "th")
3016 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3018 (number-to-string (nth 5 dtime))
3020 (format "%02d" (nth 2 dtime))
3022 (format "%02d" (nth 1 dtime)))))))
3024 (format "Date: %s (from T-gnus)" date))))
3026 (defun article-date-local (&optional highlight)
3027 "Convert the current article date to the local timezone."
3028 (interactive (list t))
3029 (article-date-ut 'local highlight))
3031 (defun article-date-english (&optional highlight)
3032 "Convert the current article date to something that is proper English."
3033 (interactive (list t))
3034 (article-date-ut 'english highlight))
3036 (defun article-date-original (&optional highlight)
3037 "Convert the current article date to what it was originally.
3038 This is only useful if you have used some other date conversion
3039 function and want to see what the date was before converting."
3040 (interactive (list t))
3041 (article-date-ut 'original highlight))
3043 (defun article-date-lapsed (&optional highlight)
3044 "Convert the current article date to time lapsed since it was sent."
3045 (interactive (list t))
3046 (article-date-ut 'lapsed highlight))
3048 (defun article-update-date-lapsed ()
3049 "Function to be run from a timer to update the lapsed time line."
3050 (let (deactivate-mark)
3055 (set-buffer (window-buffer w))
3056 (when (eq major-mode 'gnus-article-mode)
3057 (goto-char (point-min))
3058 (when (re-search-forward "^X-Sent:" nil t)
3059 (article-date-lapsed t))))
3062 (defun gnus-start-date-timer (&optional n)
3063 "Start a timer to update the X-Sent header in the article buffers.
3064 The numerical prefix says how frequently (in seconds) the function
3069 (gnus-stop-date-timer)
3070 (setq article-lapsed-timer
3071 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
3073 (defun gnus-stop-date-timer ()
3074 "Stop the X-Sent timer."
3076 (when article-lapsed-timer
3077 (nnheader-cancel-timer article-lapsed-timer)
3078 (setq article-lapsed-timer nil)))
3080 (defun article-date-user (&optional highlight)
3081 "Convert the current article date to the user-defined format.
3082 This format is defined by the `gnus-article-time-format' variable."
3083 (interactive (list t))
3084 (article-date-ut 'user highlight))
3086 (defun article-date-iso8601 (&optional highlight)
3087 "Convert the current article date to ISO8601."
3088 (interactive (list t))
3089 (article-date-ut 'iso8601 highlight))
3091 ;; (defun article-show-all ()
3092 ;; "Show all hidden text in the article buffer."
3096 ;; (let ((buffer-read-only nil))
3097 ;; (gnus-article-unhide-text (point-min) (point-max))
3098 ;; (gnus-remove-text-with-property 'gnus-prev)
3099 ;; (gnus-remove-text-with-property 'gnus-next))))
3101 (defun article-show-all-headers ()
3102 "Show all hidden headers in the article buffer."
3107 (article-narrow-to-head)
3108 (let ((buffer-read-only nil))
3109 (gnus-article-unhide-text (point-min) (point-max))))))
3111 (defun article-remove-leading-whitespace ()
3112 "Remove excessive whitespace from all headers."
3116 (let ((buffer-read-only nil))
3117 (article-narrow-to-head)
3118 (goto-char (point-min))
3119 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3120 (delete-region (match-beginning 1) (match-end 1)))))))
3122 (defun article-emphasize (&optional arg)
3123 "Emphasize text according to `gnus-emphasis-alist'."
3124 (interactive (gnus-article-hidden-arg))
3125 (unless (gnus-article-check-hidden-text 'emphasis arg)
3129 (with-current-buffer gnus-summary-buffer
3130 gnus-article-emphasis-alist)
3132 gnus-emphasis-alist))
3133 (buffer-read-only nil)
3134 (props (append '(article-type emphasis)
3135 gnus-hidden-properties))
3136 regexp elem beg invisible visible face)
3139 (while (setq elem (pop alist))
3141 (setq regexp (car elem)
3142 invisible (nth 1 elem)
3143 visible (nth 2 elem)
3145 (while (re-search-forward regexp nil t)
3146 (when (and (match-beginning visible) (match-beginning invisible))
3147 (gnus-article-hide-text
3148 (match-beginning invisible) (match-end invisible) props)
3149 (gnus-article-unhide-text-type
3150 (match-beginning visible) (match-end visible) 'emphasis)
3151 (gnus-put-overlay-excluding-newlines
3152 (match-beginning visible) (match-end visible) 'face face)
3153 (gnus-add-wash-type 'emphasis)
3154 (goto-char (match-end invisible)))))))))
3156 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3157 "Setup newsgroup emphasis alist."
3158 (unless gnus-article-emphasis-alist
3159 (let ((name (and gnus-newsgroup-name
3160 (gnus-group-real-name gnus-newsgroup-name))))
3161 (make-local-variable 'gnus-article-emphasis-alist)
3162 (setq gnus-article-emphasis-alist
3164 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3165 (while (setq elem (pop alist))
3166 (when (and name (string-match (car elem) name))
3168 highlight (copy-sequence (cdr elem)))))
3170 (copy-sequence highlight-words)
3171 (if gnus-newsgroup-name
3172 (copy-sequence (gnus-group-find-parameter
3173 gnus-newsgroup-name 'highlight-words t)))
3174 gnus-emphasis-alist)))))
3177 (defvar gnus-summary-article-menu)
3178 (defvar gnus-summary-post-menu))
3180 ;;; Saving functions.
3182 (defun gnus-article-save (save-buffer file &optional num)
3183 "Save the currently selected article."
3184 (unless gnus-save-all-headers
3185 ;; Remove headers according to `gnus-saved-headers'.
3186 (let ((gnus-visible-headers
3187 (or gnus-saved-headers gnus-visible-headers))
3188 (gnus-article-buffer save-buffer))
3190 (set-buffer save-buffer)
3191 (article-hide-headers 1 t))))
3192 (save-window-excursion
3193 (if (not gnus-default-article-saver)
3194 (error "No default saver is defined")
3195 ;; !!! Magic! The saving functions all save
3196 ;; `gnus-save-article-buffer' (or so they think), but we
3197 ;; bind that variable to our save-buffer.
3198 (set-buffer gnus-article-buffer)
3199 (let* ((gnus-save-article-buffer save-buffer)
3202 ((not gnus-prompt-before-saving) 'default)
3203 ((eq gnus-prompt-before-saving 'always) nil)
3205 (gnus-number-of-articles-to-be-saved
3206 (when (eq gnus-prompt-before-saving t)
3208 (set-buffer gnus-article-current-summary)
3209 (funcall gnus-default-article-saver filename)))))
3211 (defun gnus-read-save-file-name (prompt &optional filename
3212 function group headers variable)
3214 (funcall function group headers (symbol-value variable)))
3219 ((eq filename 'default)
3225 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3228 (if (and gnus-number-of-articles-to-be-saved
3229 (> gnus-number-of-articles-to-be-saved 1))
3230 (format "these %d articles"
3231 gnus-number-of-articles-to-be-saved)
3234 ;; Let the split methods have their say.
3236 ;; No split name was found.
3239 (concat prompt " (default "
3240 (file-name-nondirectory default-name) ") ")
3241 (file-name-directory default-name)
3243 ;; A single group name is returned.
3244 ((stringp split-name)
3246 (funcall function split-name headers
3247 (symbol-value variable)))
3249 (concat prompt " (default "
3250 (file-name-nondirectory default-name) ") ")
3251 (file-name-directory default-name)
3253 ;; A single split name was found
3254 ((= 1 (length split-name))
3255 (let* ((name (expand-file-name
3257 gnus-article-save-directory))
3258 (dir (cond ((file-directory-p name)
3259 (file-name-as-directory name))
3260 ((file-exists-p name) name)
3261 (t gnus-article-save-directory))))
3263 (concat prompt " (default " name ") ")
3265 ;; A list of splits was found.
3267 (setq split-name (nreverse split-name))
3269 (let ((file-name-history
3270 (nconc split-name file-name-history)))
3274 (concat prompt " (`M-p' for defaults) ")
3275 gnus-article-save-directory
3277 gnus-article-save-directory)))
3278 (car (push result file-name-history)))))))
3279 ;; Create the directory.
3280 (gnus-make-directory (file-name-directory file))
3281 ;; If we have read a directory, we append the default file name.
3282 (when (file-directory-p file)
3283 (setq file (expand-file-name (file-name-nondirectory
3285 (file-name-as-directory file))))
3286 ;; Possibly translate some characters.
3287 (nnheader-translate-file-chars file))))))
3288 (gnus-make-directory (file-name-directory result))
3289 (set variable result)))
3291 (defun gnus-article-archive-name (group)
3292 "Return the first instance of an \"Archive-name\" in the current buffer."
3293 (let ((case-fold-search t))
3294 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3295 (nnheader-concat gnus-article-save-directory
3296 (match-string 1)))))
3298 (defun gnus-article-nndoc-name (group)
3299 "If GROUP is an nndoc group, return the name of the parent group."
3300 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3301 (gnus-group-get-parameter group 'save-article-group)))
3303 (defun gnus-summary-save-in-rmail (&optional filename)
3304 "Append this article to Rmail file.
3305 Optional argument FILENAME specifies file name.
3306 Directory to save to is default to `gnus-article-save-directory'."
3307 (setq filename (gnus-read-save-file-name
3308 "Save %s in rmail file:" filename
3309 gnus-rmail-save-name gnus-newsgroup-name
3310 gnus-current-headers 'gnus-newsgroup-last-rmail))
3311 (gnus-eval-in-buffer-window gnus-save-article-buffer
3315 (gnus-output-to-rmail filename))))
3318 (defun gnus-summary-save-in-mail (&optional filename)
3319 "Append this article to Unix mail file.
3320 Optional argument FILENAME specifies file name.
3321 Directory to save to is default to `gnus-article-save-directory'."
3322 (setq filename (gnus-read-save-file-name
3323 "Save %s in Unix mail file:" filename
3324 gnus-mail-save-name gnus-newsgroup-name
3325 gnus-current-headers 'gnus-newsgroup-last-mail))
3326 (gnus-eval-in-buffer-window gnus-save-article-buffer
3330 (if (and (file-readable-p filename)
3331 (file-regular-p filename)
3332 (mail-file-babyl-p filename))
3333 (rmail-output-to-rmail-file filename t)
3334 (gnus-output-to-mail filename)))))
3337 (defun gnus-summary-save-in-file (&optional filename overwrite)
3338 "Append this article to file.
3339 Optional argument FILENAME specifies file name.
3340 Directory to save to is default to `gnus-article-save-directory'."
3341 (setq filename (gnus-read-save-file-name
3342 "Save %s in file:" filename
3343 gnus-file-save-name gnus-newsgroup-name
3344 gnus-current-headers 'gnus-newsgroup-last-file))
3345 (gnus-eval-in-buffer-window gnus-save-article-buffer
3349 (when (and overwrite
3350 (file-exists-p filename))
3351 (delete-file filename))
3352 (gnus-output-to-file filename))))
3355 (defun gnus-summary-write-to-file (&optional filename)
3356 "Write this article to a file, overwriting it if the file exists.
3357 Optional argument FILENAME specifies file name.
3358 The directory to save in defaults to `gnus-article-save-directory'."
3359 (gnus-summary-save-in-file nil t))
3361 (defun gnus-summary-save-body-in-file (&optional filename)
3362 "Append this article body to a file.
3363 Optional argument FILENAME specifies file name.
3364 The directory to save in defaults to `gnus-article-save-directory'."
3365 (setq filename (gnus-read-save-file-name
3366 "Save %s body in file:" filename
3367 gnus-file-save-name gnus-newsgroup-name
3368 gnus-current-headers 'gnus-newsgroup-last-file))
3369 (gnus-eval-in-buffer-window gnus-save-article-buffer
3373 (when (article-goto-body)
3374 (narrow-to-region (point) (point-max)))
3375 (gnus-output-to-file filename))))
3378 (defun gnus-summary-save-in-pipe (&optional command)
3379 "Pipe this article to subprocess."
3381 (cond ((and (eq command 'default)
3382 gnus-last-shell-command)
3383 gnus-last-shell-command)
3388 "Shell command on %s: "
3389 (if (and gnus-number-of-articles-to-be-saved
3390 (> gnus-number-of-articles-to-be-saved 1))
3391 (format "these %d articles"
3392 gnus-number-of-articles-to-be-saved)
3394 gnus-last-shell-command))))
3395 (when (string-equal command "")
3396 (if gnus-last-shell-command
3397 (setq command gnus-last-shell-command)
3398 (error "A command is required")))
3399 (gnus-eval-in-buffer-window gnus-article-buffer
3402 (shell-command-on-region (point-min) (point-max) command nil)))
3403 (setq gnus-last-shell-command command))
3405 (defmacro gnus-read-string (prompt &optional initial-contents history
3407 "Like `read-string' but allow for older XEmacsen that don't have the 5th arg."
3408 (if (and (featurep 'xemacs)
3409 (< emacs-minor-version 2))
3410 `(read-string ,prompt ,initial-contents ,history)
3411 `(read-string ,prompt ,initial-contents ,history ,default-value)))
3413 (defun gnus-summary-pipe-to-muttprint (&optional command)
3414 "Pipe this article to muttprint."
3415 (setq command (gnus-read-string
3416 "Print using command: " gnus-summary-muttprint-program
3417 nil gnus-summary-muttprint-program))
3418 (gnus-summary-save-in-pipe command))
3420 ;;; Article file names when saving.
3422 (defun gnus-capitalize-newsgroup (newsgroup)
3423 "Capitalize NEWSGROUP name."
3424 (when (not (zerop (length newsgroup)))
3425 (concat (char-to-string (upcase (aref newsgroup 0)))
3426 (substring newsgroup 1))))
3428 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3429 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3430 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3431 Otherwise, it is like ~/News/news/group/num."
3434 (concat (if (gnus-use-long-file-name 'not-save)
3435 (gnus-capitalize-newsgroup newsgroup)
3436 (gnus-newsgroup-directory-form newsgroup))
3437 "/" (int-to-string (mail-header-number headers)))
3438 gnus-article-save-directory)))
3440 (string-equal (file-name-directory default)
3441 (file-name-directory last-file))
3442 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3444 (or last-file default))))
3446 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3447 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3448 If variable `gnus-use-long-file-name' is non-nil, it is
3449 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3452 (concat (if (gnus-use-long-file-name 'not-save)
3454 (gnus-newsgroup-directory-form newsgroup))
3455 "/" (int-to-string (mail-header-number headers)))
3456 gnus-article-save-directory)))
3458 (string-equal (file-name-directory default)
3459 (file-name-directory last-file))
3460 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3462 (or last-file default))))
3464 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3465 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3466 If variable `gnus-use-long-file-name' is non-nil, it is
3467 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3470 (if (gnus-use-long-file-name 'not-save)
3473 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3475 gnus-article-save-directory)))
3477 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3478 "Generate file name from sender."
3479 (let ((from (mail-header-from headers)))
3481 (if (and from (string-match "\\([^ <]+\\)@" from))
3482 (match-string 1 from)
3484 gnus-article-save-directory)))
3486 (defun article-verify-x-pgp-sig ()
3489 (if (gnus-buffer-live-p gnus-original-article-buffer)
3490 (let ((sig (with-current-buffer gnus-original-article-buffer
3491 (gnus-fetch-field "X-PGP-Sig")))
3495 (mml2015-clear-verify-function))
3497 (insert-buffer-substring gnus-original-article-buffer)
3498 (setq items (split-string sig))
3499 (message-narrow-to-head)
3500 (let ((inhibit-point-motion-hooks t)
3501 (case-fold-search t))
3502 ;; Don't verify multiple headers.
3503 (setq headers (mapconcat (lambda (header)
3505 (mail-fetch-field header)
3507 (split-string (nth 1 items) ",") "")))
3508 (delete-region (point-min) (point-max))
3509 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3510 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3515 (if (looking-at "^-")
3518 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3519 (insert "Version: " (car items) "\n\n")
3520 (insert (mapconcat 'identity (cddr items) "\n"))
3521 (insert "\n-----END PGP SIGNATURE-----\n")
3522 (let ((mm-security-handle (list (format "multipart/signed"))))
3523 (mml2015-clean-buffer)
3524 (let ((coding-system-for-write (or gnus-newsgroup-charset
3526 (funcall (mml2015-clear-verify-function)))
3528 (or (mm-handle-multipart-ctl-parameter
3529 mm-security-handle 'gnus-details)
3530 (mm-handle-multipart-ctl-parameter
3531 mm-security-handle 'gnus-info)))))
3533 (let (buffer-read-only bface eface)
3535 (message-narrow-to-head)
3536 (goto-char (point-max))
3538 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3539 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3540 (message-remove-header "X-Gnus-PGP-Verify")
3541 (if (re-search-forward "^X-PGP-Sig:" nil t)
3543 (goto-char (point-max)))
3544 (narrow-to-region (point) (point))
3545 (insert "X-Gnus-PGP-Verify: " info "\n")
3546 (goto-char (point-min))
3549 (if (not (looking-at "^[ \t]"))
3553 (goto-char (point-min))
3554 (when (looking-at "\\([^:]+\\): *")
3555 (put-text-property (match-beginning 1) (1+ (match-end 1))
3557 (put-text-property (match-end 0) (point-max)
3558 'face eface)))))))))
3560 (defun article-verify-cancel-lock ()
3561 "Verify Cancel-Lock header."
3563 (if (gnus-buffer-live-p gnus-original-article-buffer)
3564 (canlock-verify gnus-original-article-buffer)))
3566 (defun article-monafy ()
3567 "Display body part with mona font."
3569 (unless (if (featurep 'xemacs)
3570 (find-face 'gnus-mona-face)
3571 (facep 'gnus-mona-face))
3572 (require 'navi2ch-mona)
3573 (set-face-font (make-face 'gnus-mona-face) navi2ch-mona-font))
3575 (let ((buffer-read-only nil))
3578 (gnus-make-overlay (point) (point-max))
3579 'face 'gnus-mona-face))))
3586 (setq afunc (car func)
3589 gfunc (intern (format "gnus-%s" func))))
3591 (when (fboundp afunc)
3592 `(lambda (&optional interactive &rest args)
3593 ,(documentation afunc t)
3594 (interactive (list t))
3596 (set-buffer gnus-article-buffer)
3598 (call-interactively ',afunc)
3599 (apply ',afunc args))))))))
3600 '(article-hide-headers
3601 article-verify-x-pgp-sig
3602 article-verify-cancel-lock
3604 article-hide-boring-headers
3605 article-treat-overstrike
3606 article-fill-long-lines
3607 article-capitalize-sentences
3609 article-remove-leading-whitespace
3610 article-display-x-face
3611 article-display-face
3612 article-de-quoted-unreadable
3613 article-de-base64-unreadable
3616 article-unsplit-urls
3617 article-hide-list-identifiers
3618 article-strip-banner
3621 article-hide-signature
3622 article-strip-headers-in-body
3623 article-remove-trailing-blank-lines
3624 article-strip-leading-blank-lines
3625 article-strip-multiple-blank-lines
3626 article-strip-leading-space
3627 article-strip-trailing-space
3628 article-strip-blank-lines
3629 article-strip-all-blank-lines
3631 article-date-english
3632 article-date-iso8601
3633 article-date-original
3635 article-decode-mime-words
3636 article-decode-charset
3637 article-decode-encoded-words
3641 article-treat-dumbquotes
3642 article-normalize-headers
3643 (article-show-all-headers . gnus-article-show-all-headers)
3644 ;; (article-show-all . gnus-article-show-all)
3648 ;;; Gnus article mode
3651 (put 'gnus-article-mode 'mode-class 'special)
3653 (gnus-define-keys gnus-article-mode-map
3654 " " gnus-article-goto-next-page
3655 "\177" gnus-article-goto-prev-page
3656 [delete] gnus-article-goto-prev-page
3657 [backspace] gnus-article-goto-prev-page
3658 "\C-c^" gnus-article-refer-article
3659 "h" gnus-article-show-summary
3660 "s" gnus-article-show-summary
3661 "\C-c\C-m" gnus-article-mail
3662 "?" gnus-article-describe-briefly
3663 "e" gnus-summary-edit-article
3664 "<" beginning-of-buffer
3666 "\C-c\C-i" gnus-info-find-node
3668 "R" gnus-article-reply-with-original
3669 "F" gnus-article-followup-with-original
3670 "\C-hk" gnus-article-describe-key
3671 "\C-hc" gnus-article-describe-key-briefly
3673 "\C-d" gnus-article-read-summary-keys
3674 "\M-*" gnus-article-read-summary-keys
3675 "\M-#" gnus-article-read-summary-keys
3676 "\M-^" gnus-article-read-summary-keys
3677 "\M-g" gnus-article-read-summary-keys)
3679 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3683 (push (char-to-string key) keys)
3685 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3686 (setq key (car elem))
3687 (when (and (> (length key) 0)
3688 (not (eq 'menu-bar (aref key 0)))
3689 (symbolp (lookup-key gnus-summary-mode-map key)))
3692 (unless (lookup-key gnus-article-mode-map key)
3693 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3695 (defun gnus-article-make-menu-bar ()
3696 (unless (boundp 'gnus-article-commands-menu)
3697 (gnus-summary-make-menu-bar))
3698 (gnus-turn-off-edit-menu 'article)
3699 (unless (boundp 'gnus-article-article-menu)
3701 gnus-article-article-menu gnus-article-mode-map ""
3703 ["Scroll forwards" gnus-article-goto-next-page t]
3704 ["Scroll backwards" gnus-article-goto-prev-page t]
3705 ["Show summary" gnus-article-show-summary t]
3706 ["Fetch Message-ID at point" gnus-article-refer-article t]
3707 ["Mail to address at point" gnus-article-mail t]
3708 ["Send a bug report" gnus-bug t]))
3711 gnus-article-treatment-menu gnus-article-mode-map ""
3712 ;; Fixme: this should use :active (and maybe :visible).
3714 ["Hide headers" gnus-article-hide-headers t]
3715 ["Hide signature" gnus-article-hide-signature t]
3716 ["Hide citation" gnus-article-hide-citation t]
3717 ["Treat overstrike" gnus-article-treat-overstrike t]
3718 ["Remove carriage return" gnus-article-remove-cr t]
3719 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3720 ["Treat html" gnus-article-wash-html t]
3721 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3722 ["Decode HZ" gnus-article-decode-HZ t]))
3724 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3726 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3728 (gnus-run-hooks 'gnus-article-menu-hook)))
3730 (defun gnus-article-mode ()
3731 "Major mode for displaying an article.
3733 All normal editing commands are switched off.
3735 The following commands are available in addition to all summary mode
3737 \\<gnus-article-mode-map>
3738 \\[gnus-article-next-page]\t Scroll the article one page forwards
3739 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3740 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3741 \\[gnus-article-show-summary]\t Display the summary buffer
3742 \\[gnus-article-mail]\t Send a reply to the address near point
3743 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3744 \\[gnus-info-find-node]\t Go to the Gnus info node"
3746 (gnus-simplify-mode-line)
3747 (setq mode-name "Article")
3748 (setq major-mode 'gnus-article-mode)
3749 (make-local-variable 'minor-mode-alist)
3750 (unless (assq 'gnus-show-mime minor-mode-alist)
3751 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3752 (use-local-map gnus-article-mode-map)
3753 (when (gnus-visual-p 'article-menu 'menu)
3754 (gnus-article-make-menu-bar)
3755 (when gnus-summary-tool-bar-map
3756 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3757 (gnus-update-format-specifications nil 'article-mode)
3758 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3759 (make-local-variable 'gnus-page-broken)
3760 (make-local-variable 'gnus-button-marker-list)
3761 (make-local-variable 'gnus-article-current-summary)
3762 (make-local-variable 'gnus-article-mime-handles)
3763 (make-local-variable 'gnus-article-decoded-p)
3764 (make-local-variable 'gnus-article-mime-handle-alist)
3765 (make-local-variable 'gnus-article-wash-types)
3766 (make-local-variable 'gnus-article-image-alist)
3767 (make-local-variable 'gnus-article-charset)
3768 (make-local-variable 'gnus-article-ignored-charsets)
3769 (gnus-set-default-directory)
3770 (buffer-disable-undo)
3771 (setq buffer-read-only t)
3772 (set-syntax-table gnus-article-mode-syntax-table)
3773 (gnus-run-hooks 'gnus-article-mode-hook))
3775 (defun gnus-article-setup-buffer ()
3776 "Initialize the article buffer."
3777 (let* ((name (if gnus-single-article-buffer "*Article*"
3778 (concat "*Article " gnus-newsgroup-name "*")))
3780 (progn (string-match "\\*Article" name)
3781 (concat " *Original Article"
3782 (substring name (match-end 0))))))
3783 (setq gnus-article-buffer name)
3784 (setq gnus-original-article-buffer original)
3785 (setq gnus-article-mime-handle-alist nil)
3786 ;; This might be a variable local to the summary buffer.
3787 (unless gnus-single-article-buffer
3789 (set-buffer gnus-summary-buffer)
3790 (setq gnus-article-buffer name)
3791 (setq gnus-original-article-buffer original)
3792 (gnus-set-global-variables)))
3793 (gnus-article-setup-highlight-words)
3794 ;; Init original article buffer.
3796 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3797 (set-buffer-multibyte t)
3798 (setq major-mode 'gnus-original-article-mode)
3799 (make-local-variable 'gnus-original-article))
3800 (if (get-buffer name)
3803 (when (and gnus-article-edit-mode
3806 (y-or-n-p "Article mode edit in progress; discard? ")))
3807 (error "Action aborted"))
3808 (set (make-local-variable 'gnus-article-edit-mode) nil)
3809 (buffer-disable-undo)
3810 (setq buffer-read-only t)
3811 ;; This list just keeps growing if we don't reset it.
3812 (setq gnus-button-marker-list nil)
3813 (unless (eq major-mode 'gnus-article-mode)
3814 (gnus-article-mode))
3817 (set-buffer (gnus-get-buffer-create name))
3819 (make-local-variable 'gnus-summary-buffer)
3820 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3821 (current-buffer)))))
3823 ;; Set article window start at LINE, where LINE is the number of lines
3824 ;; from the head of the article.
3825 (defun gnus-article-set-window-start (&optional line)
3827 (gnus-get-buffer-window gnus-article-buffer t)
3829 (set-buffer gnus-article-buffer)
3830 (goto-char (point-min))
3833 (gnus-message 6 "Moved to bookmark")
3834 (search-forward "\n\n" nil t)
3838 ;;; @@ article filters
3841 (defun gnus-article-display-mime-message ()
3842 "Article display method for MIME message."
3843 ;; called from `gnus-original-article-buffer'.
3844 (let (charset all-headers)
3845 (with-current-buffer gnus-summary-buffer
3846 (setq charset default-mime-charset
3847 all-headers gnus-have-all-headers))
3848 (make-local-variable 'default-mime-charset)
3849 (setq default-mime-charset charset)
3850 (with-current-buffer (get-buffer-create gnus-article-buffer)
3851 (make-local-variable 'default-mime-charset)
3852 (setq default-mime-charset charset))
3853 (mime-display-message mime-message-structure
3854 gnus-article-buffer nil gnus-article-mode-map)
3856 (gnus-article-hide-headers nil -1)))
3857 (run-hooks 'gnus-mime-article-prepare-hook))
3859 (defun gnus-article-display-traditional-message ()
3860 "Article display method for traditional message."
3861 (set-buffer gnus-article-buffer)
3862 (let (buffer-read-only)
3864 (insert-buffer-substring gnus-original-article-buffer)))
3866 (defun gnus-article-make-full-mail-header (&optional number charset)
3867 "Create a new mail header structure in a raw article buffer."
3868 (unless (and number charset)
3869 (save-current-buffer
3870 (set-buffer gnus-summary-buffer)
3872 (setq number (or (cdr gnus-article-current) 0)))
3874 (setq charset (or default-mime-charset 'x-ctext)))))
3875 (goto-char (point-min))
3876 (let ((header-end (if (search-forward "\n\n" nil t)
3878 (goto-char (point-max))))
3879 (chars (- (point-max) (point)))
3880 (lines (count-lines (point) (point-max)))
3881 (default-mime-charset charset)
3883 (narrow-to-region (point-min) header-end)
3884 (setq xref (std11-fetch-field "xref"))
3886 (make-full-mail-header
3888 (std11-fetch-field "subject")
3889 (std11-fetch-field "from")
3890 (std11-fetch-field "date")
3891 (std11-fetch-field "message-id")
3892 (std11-fetch-field "references")
3895 (when xref (concat "Xref: " xref)))
3898 (defun gnus-article-prepare (article &optional all-headers header)
3899 "Prepare ARTICLE in article mode buffer.
3900 ARTICLE should either be an article number or a Message-ID.
3901 If ARTICLE is an id, HEADER should be the article headers.
3902 If ALL-HEADERS is non-nil, no headers are hidden."
3904 ;; Make sure we start in a summary buffer.
3905 (unless (eq major-mode 'gnus-summary-mode)
3906 (set-buffer gnus-summary-buffer))
3907 (setq gnus-summary-buffer (current-buffer))
3908 (let* ((gnus-article (if header (mail-header-number header) article))
3909 (summary-buffer (current-buffer))
3910 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3911 (group gnus-newsgroup-name)
3914 (gnus-article-setup-buffer)
3915 (set-buffer gnus-article-buffer)
3916 ;; Deactivate active regions.
3917 (when (and (boundp 'transient-mark-mode)
3918 transient-mark-mode)
3919 (setq mark-active nil))
3920 (if (not (setq result (let ((buffer-read-only nil))
3921 (gnus-request-article-this-buffer
3923 ;; There is no such article.
3925 (when (and (numberp article)
3926 (not (memq article gnus-newsgroup-sparse)))
3927 (setq gnus-article-current
3928 (cons gnus-newsgroup-name article))
3929 (set-buffer gnus-summary-buffer)
3930 (setq gnus-current-article article)
3931 (if (and (memq article gnus-newsgroup-undownloaded)
3932 (not (gnus-online (gnus-find-method-for-group
3933 gnus-newsgroup-name))))
3935 (gnus-summary-set-agent-mark article)
3936 (message "Message marked for downloading"))
3937 (gnus-summary-mark-article article gnus-canceled-mark)
3938 (unless (memq article gnus-newsgroup-sparse)
3939 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3940 (if (or (eq result 'pseudo)
3941 (eq result 'nneething))
3944 (set-buffer summary-buffer)
3945 (push article gnus-newsgroup-history)
3946 (setq gnus-last-article gnus-current-article
3947 gnus-current-article 0
3948 gnus-current-headers nil
3949 gnus-article-current nil)
3950 (if (eq result 'nneething)
3951 (gnus-configure-windows 'summary)
3952 (gnus-configure-windows 'article))
3953 (gnus-set-global-variables))
3954 (let ((gnus-article-mime-handle-alist-1
3955 gnus-article-mime-handle-alist))
3956 (gnus-set-mode-line 'article)))
3957 ;; The result from the `request' was an actual article -
3958 ;; or at least some text that is now displayed in the
3960 (when (and (numberp article)
3961 (not (eq article gnus-current-article)))
3962 ;; Seems like a new article has been selected.
3963 ;; `gnus-current-article' must be an article number.
3965 (set-buffer summary-buffer)
3966 (push article gnus-newsgroup-history)
3967 (setq gnus-last-article gnus-current-article
3968 gnus-current-article article
3969 gnus-current-headers
3970 (gnus-summary-article-header gnus-current-article)
3971 gnus-article-current
3972 (cons gnus-newsgroup-name gnus-current-article))
3973 (unless (vectorp gnus-current-headers)
3974 (setq gnus-current-headers nil))
3975 (gnus-summary-goto-subject gnus-current-article)
3976 (when (gnus-summary-show-thread)
3977 ;; If the summary buffer really was folded, the
3978 ;; previous goto may not actually have gone to
3979 ;; the right article, but the thread root instead.
3981 (gnus-summary-goto-subject gnus-current-article))
3982 (gnus-run-hooks 'gnus-mark-article-hook)
3983 (gnus-set-mode-line 'summary)
3984 (when (gnus-visual-p 'article-highlight 'highlight)
3985 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3986 ;; Set the global newsgroup variables here.
3987 (gnus-set-global-variables)
3988 (setq gnus-have-all-headers
3989 (or all-headers gnus-show-all-headers))))
3991 (gnus-configure-windows 'article))
3992 (when (or (numberp article)
3994 (gnus-article-prepare-display)
3996 (goto-char (point-min))
3997 (setq gnus-page-broken
3998 (when gnus-break-pages
3999 (gnus-narrow-to-page)
4001 (let ((gnus-article-mime-handle-alist-1
4002 gnus-article-mime-handle-alist))
4003 (gnus-set-mode-line 'article))
4007 (set-window-point (get-buffer-window (current-buffer)) (point))
4008 (gnus-configure-windows 'article)
4011 (defun gnus-article-prepare-mime-display (&optional number)
4012 (goto-char (point-min))
4013 (when (re-search-forward "^[^\t ]+:" nil t)
4014 (goto-char (match-beginning 0)))
4015 (let ((entity (if (eq 1 (point-min))
4016 (get-text-property 1 'mime-view-entity)
4017 (get-text-property (point) 'mime-view-entity)))
4018 last-entity child-entity next type)
4019 (setq child-entity (mime-entity-children entity))
4021 (setq last-entity (nth (1- (length child-entity))
4023 (setq last-entity entity))
4025 (narrow-to-region (point)
4026 (if (search-forward "\n\n" nil t)
4029 (gnus-treat-article 'head)
4030 (put-text-property (point-min) (point-max) 'article-treated-header t)
4031 (goto-char (point-max)))
4032 (while (and (not (eobp)) entity)
4033 (setq next (set-marker
4035 (next-single-property-change (point) 'mime-view-entity
4037 (let ((types (mime-entity-content-type entity)))
4038 (while (eq 'multipart (mime-content-type-primary-type types))
4039 (setq entity (car (mime-entity-children entity))
4040 types (mime-entity-content-type entity)))
4042 (setq type (format "%s/%s"
4043 (mime-content-type-primary-type types)
4044 (mime-content-type-subtype types)))))
4045 (if (string-equal type "message/rfc822")
4048 (let ((children (mime-entity-children entity))
4051 (setq last-children (nth (1- (length children)) children))
4054 (not (eq last-children
4055 (get-text-property next 'mime-view-entity)))
4057 (next-single-property-change next
4059 nil (point-max)))))))
4060 (setq next (next-single-property-change next 'mime-view-entity
4063 (narrow-to-region (point) next)
4064 (gnus-article-prepare-mime-display)
4065 (goto-char (point-max)))
4066 (setq entity (get-text-property (point) 'mime-view-entity)))
4068 (narrow-to-region (point) next)
4069 ;; Kludge. We have to count true number, but for now,
4070 ;; part number is here only to achieve `last'.
4071 (gnus-treat-article nil 1
4072 (if (eq entity last-entity)
4075 (goto-char (point-max)))
4076 (setq entity (get-text-property next 'mime-view-entity))))))
4079 (defun gnus-article-prepare-display ()
4080 "Make the current buffer look like a nice article."
4081 (let ((gnus-article-buffer (current-buffer))
4083 (unless (eq major-mode 'gnus-article-mode)
4084 (gnus-article-mode))
4085 (setq buffer-read-only nil
4086 gnus-button-marker-list nil
4087 gnus-article-wash-types nil
4088 gnus-article-image-alist nil)
4091 (static-if (featurep 'xemacs)
4092 (map-extents (lambda (extent maparg) (delete-extent extent)))
4093 (let ((lists (overlay-lists)))
4094 (dolist (overlay (nconc (car lists) (cdr lists)))
4095 (delete-overlay overlay)))))
4096 (gnus-run-hooks 'gnus-tmp-internal-hook))
4097 (let ((show-mime (unless (member gnus-newsgroup-name '("nndraft:delayed"
4100 (inhibit-read-only t))
4101 (set-buffer gnus-original-article-buffer)
4103 (setq mime-message-structure gnus-current-headers)
4104 (mime-buffer-entity-set-buffer-internal mime-message-structure
4105 gnus-original-article-buffer)
4106 (mime-entity-set-representation-type-internal mime-message-structure
4107 'mime-buffer-entity)
4108 (luna-send mime-message-structure 'initialize-instance
4109 mime-message-structure)
4111 (let (mime-display-header-hook mime-display-text/plain-hook)
4112 (funcall gnus-article-display-method-for-mime))
4113 (funcall gnus-article-display-method-for-traditional))
4114 ;; Call the treatment functions.
4118 (gnus-article-prepare-mime-display)
4119 (narrow-to-region (goto-char (point-min))
4120 (if (search-forward "\n\n" nil t)
4123 (gnus-treat-article 'head)
4124 (put-text-property (point-min) (point-max) 'article-treated-header t)
4125 (goto-char (point-max))
4127 (narrow-to-region (point) (point-max))
4128 (gnus-treat-article nil))
4129 (put-text-property (point-min) (point-max) 'read-only nil)))
4130 (gnus-run-hooks 'gnus-article-prepare-hook))
4132 (defun gnus-article-decode-article-as-default-mime-charset ()
4133 "Decode an article as `default-mime-charset'. It won't work if the
4134 value of the variable `gnus-show-mime' is non-nil."
4135 (unless (or gnus-show-mime
4136 (member gnus-newsgroup-name '("nndraft:delayed"
4138 (set (make-local-variable 'default-mime-charset)
4139 (with-current-buffer gnus-summary-buffer
4140 default-mime-charset))
4141 (decode-mime-charset-region (point-min) (point-max)
4142 default-mime-charset)))
4145 ;;; Gnus MIME viewing functions
4148 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4149 "Format of the MIME buttons.
4151 Valid specifiers include:
4153 %T MIME type, along with additional info
4154 %n The `name' parameter
4155 %d The description, if any
4156 %l The length of the encoded part
4157 %p The part identifier number
4158 %e Dots if the part isn't displayed
4160 General format specifiers can also be used. See Info node
4161 `(gnus)Formatting Variables'.")
4163 (defvar gnus-mime-button-line-format-alist
4164 '((?t gnus-tmp-type ?s)
4165 (?T gnus-tmp-type-long ?s)
4166 (?n gnus-tmp-name ?s)
4167 (?d gnus-tmp-description ?s)
4169 (?l gnus-tmp-length ?d)
4170 (?e gnus-tmp-dots ?s)))
4172 (defvar gnus-mime-button-commands
4173 '((gnus-article-press-button "\r" "Toggle Display")
4174 (gnus-mime-view-part "v" "View Interactively...")
4175 (gnus-mime-view-part-as-type "t" "View As Type...")
4176 (gnus-mime-view-part-as-charset "C" "View As charset...")
4177 (gnus-mime-save-part "o" "Save...")
4178 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4179 (gnus-mime-delete-part "d" "Delete part")
4180 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4181 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4182 (gnus-mime-view-part-internally "E" "View Internally")
4183 (gnus-mime-view-part-externally "e" "View Externally")
4184 (gnus-mime-print-part "p" "Print")
4185 (gnus-mime-pipe-part "|" "Pipe To Command...")
4186 (gnus-mime-action-on-part "." "Take action on the part...")))
4188 (defun gnus-article-mime-part-status ()
4189 (with-current-buffer gnus-article-buffer
4190 (let ((entity (get-text-property (point-min) 'mime-view-entity))
4193 (setq children (mime-entity-children entity))
4194 (setq children (length children)))
4197 (format " (%d parts)" children))
4200 (defvar gnus-mime-button-map
4201 (let ((map (make-sparse-keymap)))
4202 (unless (>= (string-to-number emacs-version) 21)
4203 ;; XEmacs doesn't care.
4204 (set-keymap-parent map gnus-article-mode-map))
4205 (define-key map gnus-mouse-2 'gnus-article-push-button)
4206 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4207 (dolist (c gnus-mime-button-commands)
4208 (define-key map (cadr c) (car c)))
4212 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4214 ,@(mapcar (lambda (c)
4215 (vector (caddr c) (car c) :enable t))
4216 gnus-mime-button-commands)))
4219 (define-compiler-macro popup-menu (&whole form
4220 menu &optional position prefix)
4221 (if (and (fboundp 'popup-menu)
4222 (not (memq 'popup-menu (assoc "lmenu" load-history))))
4224 ;; Gnus is probably running under Emacs 20.
4225 `(let* ((menu (cdr ,menu))
4226 (response (x-popup-menu
4228 (cons "" (mapcar (lambda (c)
4229 (cons (caddr c) (car c)))
4232 (call-interactively (nth 3 (assq response menu))))))))
4234 (defun gnus-mime-button-menu (event prefix)
4235 "Construct a context-sensitive menu of MIME commands."
4236 (interactive "e\nP")
4237 (save-window-excursion
4238 (let ((pos (event-start event)))
4239 (select-window (posn-window pos))
4240 (goto-char (posn-point pos))
4241 (gnus-article-check-buffer)
4242 (popup-menu gnus-mime-button-menu nil prefix))))
4244 (defun gnus-mime-view-all-parts (&optional handles)
4245 "View all the MIME parts."
4247 (save-current-buffer
4248 (set-buffer gnus-article-buffer)
4249 (let ((handles (or handles gnus-article-mime-handles))
4250 (mail-parse-charset gnus-newsgroup-charset)
4251 (mail-parse-ignored-charsets
4252 (with-current-buffer gnus-summary-buffer
4253 gnus-newsgroup-ignored-charsets)))
4255 (mm-remove-parts handles)
4256 (goto-char (point-min))
4257 (or (search-forward "\n\n") (goto-char (point-max)))
4258 (let (buffer-read-only)
4259 (delete-region (point) (point-max))
4260 (mm-display-parts handles))))))
4262 (defun gnus-mime-save-part-and-strip ()
4263 "Save the MIME part under point then replace it with an external body."
4265 (gnus-article-check-buffer)
4266 (let* ((data (get-text-property (point) 'gnus-data))
4268 (handles gnus-article-mime-handles))
4269 (if (mm-multiple-handles gnus-article-mime-handles)
4270 (error "This function is not implemented"))
4271 (setq file (and data (mm-save-part data)))
4273 (with-current-buffer (mm-handle-buffer data)
4275 (insert "Content-Type: " (mm-handle-media-type data))
4276 (mml-insert-parameter-string (cdr (mm-handle-type data))
4279 (insert "Content-ID: " (message-make-message-id) "\n")
4280 (insert "Content-Transfer-Encoding: binary\n")
4283 (cdr (mm-make-handle nil
4284 `("message/external-body"
4285 (access-type . "LOCAL-FILE")
4287 (set-buffer gnus-summary-buffer)
4288 (gnus-article-edit-article
4291 (let ((mail-parse-charset (or gnus-article-charset
4292 ',gnus-newsgroup-charset))
4293 (mail-parse-ignored-charsets
4294 (or gnus-article-ignored-charsets
4295 ',gnus-newsgroup-ignored-charsets))
4296 (mbl mml-buffer-list))
4297 (setq mml-buffer-list nil)
4298 (insert-buffer gnus-original-article-buffer)
4299 (mime-to-mml ',handles)
4300 (setq gnus-article-mime-handles nil)
4301 (let ((mbl1 mml-buffer-list))
4302 (setq mml-buffer-list mbl)
4303 (set (make-local-variable 'mml-buffer-list) mbl1))
4304 (gnus-make-local-hook 'kill-buffer-hook)
4305 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4306 `(lambda (no-highlight)
4307 (let ((mail-parse-charset (or gnus-article-charset
4308 ',gnus-newsgroup-charset))
4309 (message-options message-options)
4310 (message-options-set-recipient)
4311 (mail-parse-ignored-charsets
4312 (or gnus-article-ignored-charsets
4313 ',gnus-newsgroup-ignored-charsets)))
4315 (mml-destroy-buffers)
4316 (remove-hook 'kill-buffer-hook
4317 'mml-destroy-buffers t)
4318 (kill-local-variable 'mml-buffer-list))
4319 (gnus-summary-edit-article-done
4320 ,(or (mail-header-references gnus-current-headers) "")
4321 ,(gnus-group-read-only-p)
4322 ,gnus-summary-buffer no-highlight))))))
4324 (defun gnus-mime-delete-part ()
4325 "Delete the MIME part under point.
4326 Replace it with some information about the removed part."
4328 (gnus-article-check-buffer)
4329 (unless (and gnus-novice-user
4330 (not (gnus-yes-or-no-p
4331 "Really delete attachment forever? ")))
4332 (let* ((data (get-text-property (point) 'gnus-data))
4333 (handles gnus-article-mime-handles)
4337 (mail-decode-encoded-word-string (or (mm-handle-description data)
4340 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4342 (type (mm-handle-media-type data)))
4343 (if (mm-multiple-handles gnus-article-mime-handles)
4344 (error "This function is not implemented"))
4345 (with-current-buffer (mm-handle-buffer data)
4346 (let ((bsize (format "%s" (buffer-size))))
4350 "<#part type=text/plain nofile=yes disposition=attachment"
4351 " description=\"Deleted attachment (" bsize " Byte)\">"
4353 "| The following attachment has been deleted:\n"
4355 "| Type: " type "\n"
4356 "| Filename: " filename "\n"
4357 "| Size (encoded): " bsize " Byte\n"
4358 "| Description: " description "\n"
4362 (cdr (mm-make-handle nil `("text/plain"))))))
4363 (set-buffer gnus-summary-buffer)
4364 ;; FIXME: maybe some of the following code (borrowed from
4365 ;; `gnus-mime-save-part-and-strip') isn't necessary?
4366 (gnus-article-edit-article
4369 (let ((mail-parse-charset (or gnus-article-charset
4370 ',gnus-newsgroup-charset))
4371 (mail-parse-ignored-charsets
4372 (or gnus-article-ignored-charsets
4373 ',gnus-newsgroup-ignored-charsets))
4374 (mbl mml-buffer-list))
4375 (setq mml-buffer-list nil)
4376 (insert-buffer gnus-original-article-buffer)
4377 (mime-to-mml ',handles)
4378 (setq gnus-article-mime-handles nil)
4379 (let ((mbl1 mml-buffer-list))
4380 (setq mml-buffer-list mbl)
4381 (set (make-local-variable 'mml-buffer-list) mbl1))
4382 (gnus-make-local-hook 'kill-buffer-hook)
4383 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4384 `(lambda (no-highlight)
4385 (let ((mail-parse-charset (or gnus-article-charset
4386 ',gnus-newsgroup-charset))
4387 (message-options message-options)
4388 (message-options-set-recipient)
4389 (mail-parse-ignored-charsets
4390 (or gnus-article-ignored-charsets
4391 ',gnus-newsgroup-ignored-charsets)))
4393 (mml-destroy-buffers)
4394 (remove-hook 'kill-buffer-hook
4395 'mml-destroy-buffers t)
4396 (kill-local-variable 'mml-buffer-list))
4397 (gnus-summary-edit-article-done
4398 ,(or (mail-header-references gnus-current-headers) "")
4399 ,(gnus-group-read-only-p)
4400 ,gnus-summary-buffer no-highlight)))))
4401 ;; Not in `gnus-mime-save-part-and-strip':
4402 (gnus-article-edit-done)
4403 (gnus-summary-expand-window)
4404 (gnus-summary-show-article))
4406 (defun gnus-mime-save-part ()
4407 "Save the MIME part under point."
4409 (gnus-article-check-buffer)
4410 (let ((data (get-text-property (point) 'gnus-data)))
4412 (mm-save-part data))))
4414 (defun gnus-mime-pipe-part ()
4415 "Pipe the MIME part under point to a process."
4417 (gnus-article-check-buffer)
4418 (let ((data (get-text-property (point) 'gnus-data)))
4420 (mm-pipe-part data))))
4422 (defun gnus-mime-view-part ()
4423 "Interactively choose a viewing method for the MIME part under point."
4425 (gnus-article-check-buffer)
4426 (let ((data (get-text-property (point) 'gnus-data)))
4428 (setq gnus-article-mime-handles
4430 gnus-article-mime-handles (setq data (copy-sequence data))))
4431 (mm-interactively-view-part data))))
4433 (defun gnus-mime-view-part-as-type-internal ()
4434 (gnus-article-check-buffer)
4435 (let* ((name (mail-content-type-get
4436 (mm-handle-type (get-text-property (point) 'gnus-data))
4438 (def-type (and name (mm-default-file-encoding name))))
4439 (and def-type (cons def-type 0))))
4441 (defun gnus-mime-view-part-as-type (&optional mime-type)
4442 "Choose a MIME media type, and view the part as such."
4445 (setq mime-type (completing-read
4446 "View as MIME type: "
4447 (mapcar #'list (mailcap-mime-types))
4449 (gnus-mime-view-part-as-type-internal))))
4450 (gnus-article-check-buffer)
4451 (let ((handle (get-text-property (point) 'gnus-data)))
4454 (mm-make-handle (mm-handle-buffer handle)
4455 (cons mime-type (cdr (mm-handle-type handle)))
4456 (mm-handle-encoding handle)
4457 (mm-handle-undisplayer handle)
4458 (mm-handle-disposition handle)
4459 (mm-handle-description handle)
4461 (mm-handle-id handle)))
4462 (setq gnus-article-mime-handles
4463 (mm-merge-handles gnus-article-mime-handles handle))
4464 (gnus-mm-display-part handle))))
4467 (require 'jka-compr))
4469 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4470 ;; emacs can do that itself.
4472 (defun gnus-mime-jka-compr-maybe-uncompress ()
4473 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4474 The uncompress method used is derived from `buffer-file-name'."
4475 (when (and (fboundp 'jka-compr-installed-p)
4476 (jka-compr-installed-p))
4477 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4479 (let ((basename (file-name-nondirectory buffer-file-name))
4480 (args (jka-compr-info-uncompress-args info))
4481 (prog (jka-compr-info-uncompress-program info))
4482 (message (jka-compr-info-uncompress-message info))
4483 (err-file (jka-compr-make-temp-name)))
4485 (message "%s %s..." message basename))
4487 (unless (memq (apply 'call-process-region
4488 (point-min) (point-max)
4490 t (list t err-file) nil
4492 jka-compr-acceptable-retval-list)
4493 (jka-compr-error prog args basename message err-file))
4494 (jka-compr-delete-temp-file err-file)))))))
4496 (defun gnus-mime-copy-part (&optional handle)
4497 "Put the MIME part under point into a new buffer.
4498 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4501 (gnus-article-check-buffer)
4502 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4503 (contents (and handle (mm-get-part handle)))
4505 (file-name-nondirectory
4507 (mail-content-type-get (mm-handle-type handle) 'name)
4508 (mail-content-type-get (mm-handle-disposition handle)
4511 (buffer (and base (generate-new-buffer base))))
4513 (switch-to-buffer buffer)
4515 ;; We do it this way to make `normal-mode' set the appropriate mode.
4518 (setq buffer-file-name (expand-file-name base))
4519 (gnus-mime-jka-compr-maybe-uncompress)
4521 (setq buffer-file-name nil))
4522 (goto-char (point-min)))))
4524 (defun gnus-mime-print-part (&optional handle filename)
4525 "Print the MIME part under point."
4526 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4527 (gnus-article-check-buffer)
4528 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4529 (contents (and handle (mm-get-part handle)))
4530 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4531 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4536 (mm-save-part-to-file handle file)
4537 (call-process shell-file-name nil
4538 (generate-new-buffer " *mm*")
4540 shell-command-switch
4542 printer file (mm-handle-type handle))))
4546 (gnus-print-buffer))
4547 (ps-despool filename)))))
4549 (defun gnus-mime-inline-part (&optional handle arg)
4550 "Insert the MIME part under point into the current buffer."
4551 (interactive (list nil current-prefix-arg))
4552 (gnus-article-check-buffer)
4553 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4558 (if (and (not arg) (mm-handle-undisplayer handle))
4559 (mm-remove-part handle)
4560 (setq contents (mm-get-part handle))
4563 (setq charset (or (mail-content-type-get
4564 (mm-handle-type handle) 'charset)
4565 gnus-newsgroup-charset)))
4567 (if (mm-handle-undisplayer handle)
4568 (mm-remove-part handle))
4571 gnus-summary-show-article-charset-alist))
4572 (mm-read-coding-system "Charset: ")))))
4574 (mm-insert-inline handle
4576 (setq charset (mm-charset-to-coding-system
4578 (not (eq charset 'ascii)))
4579 (mm-decode-coding-string contents charset)
4583 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4584 "Insert the MIME part under point into the current buffer using the
4586 (interactive (list nil current-prefix-arg))
4587 (gnus-article-check-buffer)
4588 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4593 (if (mm-handle-undisplayer handle)
4594 (mm-remove-part handle))
4595 (let ((gnus-newsgroup-charset
4597 gnus-summary-show-article-charset-alist))
4598 (mm-read-coding-system "Charset: ")))
4599 (gnus-newsgroup-ignored-charsets 'gnus-all))
4600 (gnus-article-press-button)))))
4602 (defun gnus-mime-view-part-externally (&optional handle)
4603 "View the MIME part under point with an external viewer."
4605 (gnus-article-check-buffer)
4606 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4607 (mm-user-display-methods nil)
4608 (mm-inlined-types nil)
4609 (mail-parse-charset gnus-newsgroup-charset)
4610 (mail-parse-ignored-charsets
4611 (save-excursion (set-buffer gnus-summary-buffer)
4612 gnus-newsgroup-ignored-charsets)))
4614 (if (mm-handle-undisplayer handle)
4615 (mm-remove-part handle)
4616 (mm-display-part handle)))))
4618 (defun gnus-mime-view-part-internally (&optional handle)
4619 "View the MIME part under point with an internal viewer.
4620 If no internal viewer is available, use an external viewer."
4622 (gnus-article-check-buffer)
4623 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4624 (mm-inlined-types '(".*"))
4625 (mm-inline-large-images t)
4626 (mail-parse-charset gnus-newsgroup-charset)
4627 (mail-parse-ignored-charsets
4628 (save-excursion (set-buffer gnus-summary-buffer)
4629 gnus-newsgroup-ignored-charsets))
4632 (if (mm-handle-undisplayer handle)
4633 (mm-remove-part handle)
4634 (mm-display-part handle)))))
4636 (defun gnus-mime-action-on-part (&optional action)
4637 "Do something with the MIME attachment at \(point\)."
4639 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4640 (gnus-article-check-buffer)
4641 (let ((action-pair (assoc action gnus-mime-action-alist)))
4643 (funcall (cdr action-pair)))))
4645 (defun gnus-article-part-wrapper (n function)
4646 (save-current-buffer
4647 (set-buffer gnus-article-buffer)
4648 (when (> n (length gnus-article-mime-handle-alist))
4649 (error "No such part"))
4650 (gnus-article-goto-part n)
4651 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4652 (funcall function handle))))
4654 (defun gnus-article-pipe-part (n)
4655 "Pipe MIME part N, which is the numerical prefix."
4657 (gnus-article-part-wrapper n 'mm-pipe-part))
4659 (defun gnus-article-save-part (n)
4660 "Save MIME part N, which is the numerical prefix."
4662 (gnus-article-part-wrapper n 'mm-save-part))
4664 (defun gnus-article-interactively-view-part (n)
4665 "View MIME part N interactively, which is the numerical prefix."
4667 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4669 (defun gnus-article-copy-part (n)
4670 "Copy MIME part N, which is the numerical prefix."
4672 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4674 (defun gnus-article-view-part-as-charset (n)
4675 "Copy MIME part N, which is the numerical prefix."
4677 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4679 (defun gnus-article-view-part-externally (n)
4680 "View MIME part N externally, which is the numerical prefix."
4682 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4684 (defun gnus-article-inline-part (n)
4685 "Inline MIME part N, which is the numerical prefix."
4687 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4689 (defun gnus-article-mime-match-handle-first (condition)
4691 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4692 (while (setq ihandle (pop alist))
4694 ((functionp condition)
4695 (funcall condition (cdr ihandle)))
4696 ((eq condition 'undisplayed)
4697 (not (or (mm-handle-undisplayer (cdr ihandle))
4698 (equal (mm-handle-media-type (cdr ihandle))
4699 "multipart/alternative"))))
4700 ((eq condition 'undisplayed-alternative)
4701 (not (mm-handle-undisplayer (cdr ihandle))))
4703 (gnus-article-goto-part (car ihandle))
4704 (or (not n) (< (car ihandle) n)))
4705 (setq n (car ihandle))))
4709 (defun gnus-article-view-part (&optional n)
4710 "View MIME part N, which is the numerical prefix."
4712 (save-current-buffer
4713 (set-buffer gnus-article-buffer)
4714 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4715 gnus-article-mime-match-handle-function)))
4716 (when (> n (length gnus-article-mime-handle-alist))
4717 (error "No such part"))
4718 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4719 (when (gnus-article-goto-part n)
4720 (if (equal (car handle) "multipart/alternative")
4721 (gnus-article-press-button)
4722 (when (eq (gnus-mm-display-part handle) 'internal)
4723 (gnus-set-window-start)))))))
4725 (defsubst gnus-article-mime-total-parts ()
4726 (if (bufferp (car gnus-article-mime-handles))
4728 (1- (length gnus-article-mime-handles))))
4730 (defun gnus-mm-display-part (handle)
4731 "Display HANDLE and fix MIME button."
4732 (let ((id (get-text-property (point) 'gnus-part))
4737 (let ((window (selected-window))
4738 (mail-parse-charset gnus-newsgroup-charset)
4739 (mail-parse-ignored-charsets
4740 (if (gnus-buffer-live-p gnus-summary-buffer)
4742 (set-buffer gnus-summary-buffer)
4743 gnus-newsgroup-ignored-charsets)
4747 (let ((win (gnus-get-buffer-window (current-buffer) t))
4750 (select-window win))
4753 (if (mm-handle-displayed-p handle)
4754 ;; This will remove the part.
4755 (mm-display-part handle)
4757 (narrow-to-region (point)
4758 (if (eobp) (point) (1+ (point))))
4759 (mm-display-part handle)
4760 ;; We narrow to the part itself and
4761 ;; then call the treatment functions.
4762 (goto-char (point-min))
4764 (narrow-to-region (point) (point-max))
4767 (gnus-article-mime-total-parts)
4768 (mm-handle-media-type handle)))))
4769 (if (window-live-p window)
4770 (select-window window)))))
4773 (gnus-insert-mime-button
4774 handle id (list (mm-handle-displayed-p handle)))
4775 (goto-char point))))
4777 (defun gnus-article-goto-part (n)
4778 "Go to MIME part N."
4779 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4781 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4782 (let ((gnus-tmp-name
4783 (or (mail-content-type-get (mm-handle-type handle) 'name)
4784 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4785 (mail-content-type-get (mm-handle-type handle) 'url)
4787 (gnus-tmp-type (mm-handle-media-type handle))
4788 (gnus-tmp-description
4789 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4792 (if (if displayed (car displayed)
4793 (mm-handle-displayed-p handle))
4795 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4797 gnus-tmp-type-long b e)
4798 (when (string-match ".*/" gnus-tmp-name)
4799 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4800 (setq gnus-tmp-type-long (concat gnus-tmp-type
4801 (and (not (equal gnus-tmp-name ""))
4802 (concat "; " gnus-tmp-name))))
4803 (unless (equal gnus-tmp-description "")
4804 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4809 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4810 `(,@(gnus-local-map-property gnus-mime-button-map)
4811 gnus-callback gnus-mm-display-part
4812 gnus-part ,gnus-tmp-id
4813 article-type annotation
4816 ;; Exclude a newline.
4819 (widget-convert-button
4822 :action 'gnus-widget-press-button
4823 :button-keymap gnus-mime-button-map
4825 (lambda (widget/window &optional overlay pos)
4826 ;; Needed to properly clear the message due to a bug in
4827 ;; wid-edit (XEmacs only).
4828 (if (boundp 'help-echo-owns-message)
4829 (setq help-echo-owns-message t))
4831 "%S: %s the MIME part; %S: more options"
4832 (aref gnus-mouse-2 0)
4833 ;; XEmacs will get a single widget arg; Emacs 21 will get
4834 ;; window, overlay, position.
4835 (if (mm-handle-displayed-p
4837 (with-current-buffer (gnus-overlay-buffer overlay)
4838 (widget-get (widget-at (gnus-overlay-start overlay))
4840 (widget-get widget/window :mime-handle)))
4842 (aref gnus-down-mouse-3 0))))))
4844 (defun gnus-widget-press-button (elems el)
4845 (goto-char (widget-get elems :from))
4846 (gnus-article-press-button))
4848 (defvar gnus-displaying-mime nil)
4850 (defun gnus-display-mime (&optional ihandles)
4851 "Display the MIME parts."
4853 (save-selected-window
4854 (let ((window (get-buffer-window gnus-article-buffer))
4857 (select-window window)
4858 ;; We have to do this since selecting the window
4859 ;; may change the point. So we set the window point.
4860 (set-window-point window point)))
4861 (let* ((handles (or ihandles
4862 (mm-dissect-buffer nil gnus-article-loose-mime)
4863 (and gnus-article-emulate-mime
4865 buffer-read-only handle name type b e display)
4866 (when (and (not ihandles)
4867 (not gnus-displaying-mime))
4868 ;; Top-level call; we clean up.
4869 (when gnus-article-mime-handles
4870 (mm-destroy-parts gnus-article-mime-handles)
4871 (setq gnus-article-mime-handle-alist nil));; A trick.
4872 (setq gnus-article-mime-handles handles)
4873 ;; We allow users to glean info from the handles.
4874 (when gnus-article-mime-part-function
4875 (gnus-mime-part-function handles)))
4877 (or (not (stringp (car handles)))
4880 (when (and (not ihandles)
4881 (not gnus-displaying-mime))
4882 ;; Clean up for mime parts.
4884 (delete-region (point) (point-max)))
4885 (let ((gnus-displaying-mime t))
4886 (gnus-mime-display-part handles)))
4889 (narrow-to-region (point) (point-max))
4890 (gnus-treat-article nil 1 1)
4893 ;; Highlight the headers.
4897 (narrow-to-region (point-min) (point))
4898 (gnus-treat-article 'head))))))))
4900 (defcustom gnus-mime-display-multipart-as-mixed nil
4901 "Display \"multipart\" parts as \"multipart/mixed\".
4903 If `t', it overrides `nil' values of
4904 `gnus-mime-display-multipart-alternative-as-mixed' and
4905 `gnus-mime-display-multipart-related-as-mixed'."
4906 :group 'gnus-article-mime
4909 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4910 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4911 :group 'gnus-article-mime
4914 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4915 "Display \"multipart/related\" parts as \"multipart/mixed\".
4917 If displaying \"text/html\" is discouraged \(see
4918 `mm-discouraged-alternatives'\) images or other material inside a
4919 \"multipart/related\" part might be overlooked when this variable is `nil'."
4920 :group 'gnus-article-mime
4923 (defun gnus-mime-display-part (handle)
4926 ((not (stringp (car handle)))
4927 (gnus-mime-display-single handle))
4928 ;; User-defined multipart
4929 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4930 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4932 ;; multipart/alternative
4933 ((and (equal (car handle) "multipart/alternative")
4934 (not (or gnus-mime-display-multipart-as-mixed
4935 gnus-mime-display-multipart-alternative-as-mixed)))
4936 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4937 (push (cons id handle) gnus-article-mime-handle-alist)
4938 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4939 ;; multipart/related
4940 ((and (equal (car handle) "multipart/related")
4941 (not (or gnus-mime-display-multipart-as-mixed
4942 gnus-mime-display-multipart-related-as-mixed)))
4943 ;;;!!!We should find the start part, but we just default
4944 ;;;!!!to the first part.
4945 ;;(gnus-mime-display-part (cadr handle))
4946 ;;;!!! Most multipart/related is an HTML message plus images.
4947 ;;;!!! Unfortunately we are unable to let W3 display those
4948 ;;;!!! included images, so we just display it as a mixed multipart.
4949 ;;(gnus-mime-display-mixed (cdr handle))
4950 ;;;!!! No, w3 can display everything just fine.
4951 (gnus-mime-display-part (cadr handle)))
4952 ((equal (car handle) "multipart/signed")
4953 (gnus-add-wash-type 'signed)
4954 (gnus-mime-display-security handle))
4955 ((equal (car handle) "multipart/encrypted")
4956 (gnus-add-wash-type 'encrypted)
4957 (gnus-mime-display-security handle))
4958 ;; Other multiparts are handled like multipart/mixed.
4960 (gnus-mime-display-mixed (cdr handle)))))
4962 (defun gnus-mime-part-function (handles)
4963 (if (stringp (car handles))
4964 (mapcar 'gnus-mime-part-function (cdr handles))
4965 (funcall gnus-article-mime-part-function handles)))
4967 (defun gnus-mime-display-mixed (handles)
4968 (mapcar 'gnus-mime-display-part handles))
4970 (defun gnus-mime-display-single (handle)
4971 (let ((type (mm-handle-media-type handle))
4972 (ignored gnus-ignored-mime-types)
4979 (when (string-match (pop ignored) type)
4980 (throw 'ignored nil)))
4981 (if (and (setq not-attachment
4982 (and (not (mm-inline-override-p handle))
4983 (or (not (mm-handle-disposition handle))
4984 (equal (car (mm-handle-disposition handle))
4986 (mm-attachment-override-p handle))))
4987 (mm-automatic-display-p handle)
4989 (mm-inlinable-p handle)
4990 (mm-inlined-p handle))
4991 (mm-automatic-external-display-p type)))
4993 (when (equal (mm-handle-media-supertype handle) "text")
4995 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4997 (push (cons id handle) gnus-article-mime-handle-alist)
4998 (when (or (not display)
4999 (not (gnus-unbuttonized-mime-type-p type)))
5000 ;(gnus-article-insert-newline)
5001 (gnus-insert-mime-button
5002 handle id (list (or display (and not-attachment text))))
5003 (gnus-article-insert-newline)
5004 ;(gnus-article-insert-newline)
5005 ;; Remember modify the number of forward lines.
5013 (let ((mail-parse-charset gnus-newsgroup-charset)
5014 (mail-parse-ignored-charsets
5015 (save-excursion (condition-case ()
5016 (set-buffer gnus-summary-buffer)
5018 gnus-newsgroup-ignored-charsets)))
5019 (mm-display-part handle t))
5020 (goto-char (point-max)))
5021 ((and text not-attachment)
5025 (gnus-article-insert-newline)
5026 (mm-insert-inline handle (mm-get-part handle))
5027 (goto-char (point-max))))
5031 (narrow-to-region beg (point))
5034 (gnus-article-mime-total-parts)
5035 (mm-handle-media-type handle)))))))))
5037 (defun gnus-unbuttonized-mime-type-p (type)
5038 "Say whether TYPE is to be unbuttonized."
5039 (unless gnus-inhibit-mime-unbuttonizing
5041 (let ((types gnus-unbuttonized-mime-types))
5043 (when (string-match (pop types) type)
5044 (throw 'found t)))))
5046 (let ((types gnus-buttonized-mime-types))
5048 (when (string-match (pop types) type)
5049 (throw 'found t)))))))))
5051 (defun gnus-article-insert-newline ()
5052 "Insert a newline, but mark it as undeletable."
5053 (gnus-put-text-property
5054 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5056 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5057 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5060 handle buffer-read-only from props begend not-pref)
5061 (save-window-excursion
5064 (narrow-to-region (car ibegend)
5067 (goto-char (car ibegend))
5070 (delete-region (point-min) (point-max))
5071 (mm-remove-parts handles))
5072 (setq begend (list (point-marker)))
5074 (unless (setq not-pref (cadr (member preferred ihandles)))
5075 (setq not-pref (car ihandles)))
5078 (not (gnus-unbuttonized-mime-type-p
5079 "multipart/alternative")))
5080 (gnus-add-text-properties
5083 (insert (format "%d. " id))
5087 (unless ,(not ibegend)
5088 (setq gnus-article-mime-handle-alist
5089 ',gnus-article-mime-handle-alist))
5090 (gnus-mime-display-alternative
5091 ',ihandles ',not-pref ',begend ,id))
5092 ,@(gnus-local-map-property gnus-mime-button-map)
5093 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5094 face ,gnus-article-button-face
5097 (widget-convert-button 'link from (point)
5098 :action 'gnus-widget-press-button
5099 :button-keymap gnus-widget-button-keymap)
5101 (while (setq handle (pop handles))
5102 (gnus-add-text-properties
5105 (insert (format "(%c) %-18s"
5106 (if (equal handle preferred) ?* ? )
5107 (mm-handle-media-type handle)))
5111 (unless ,(not ibegend)
5112 (setq gnus-article-mime-handle-alist
5113 ',gnus-article-mime-handle-alist))
5114 (gnus-mime-display-alternative
5115 ',ihandles ',handle ',begend ,id))
5116 ,@(gnus-local-map-property gnus-mime-button-map)
5117 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5118 face ,gnus-article-button-face
5121 (widget-convert-button 'link from (point)
5122 :action 'gnus-widget-press-button
5123 :button-keymap gnus-widget-button-keymap)
5127 (if (stringp (car preferred))
5128 (gnus-display-mime preferred)
5129 (let ((mail-parse-charset gnus-newsgroup-charset)
5130 (mail-parse-ignored-charsets
5131 (save-excursion (set-buffer gnus-summary-buffer)
5132 gnus-newsgroup-ignored-charsets)))
5133 (mm-display-part preferred)
5137 (narrow-to-region (car begend) (point-max))
5139 nil (length gnus-article-mime-handle-alist)
5140 (gnus-article-mime-total-parts)
5141 (mm-handle-media-type handle))))))
5142 (goto-char (point-max))
5143 (setcdr begend (point-marker)))))
5145 (goto-char point))))
5147 (defconst gnus-article-wash-status-strings
5148 (let ((alist '((cite "c" "Possible hidden citation text"
5149 " " "All citation text visible")
5150 (headers "h" "Hidden headers"
5151 " " "All headers visible.")
5152 (pgp "p" "Encrypted or signed message status hidden"
5153 " " "No hidden encryption nor digital signature status")
5154 (signature "s" "Signature has been hidden"
5155 " " "Signature is visible")
5156 (overstrike "o" "Overstrike (^H) characters applied"
5157 " " "No overstrike characters applied")
5158 (gnus-show-mime "m" "Mime processing is activated"
5159 " " "Mime processing is not activated")
5160 (emphasis "e" "/*_Emphasis_*/ characters applied"
5161 " " "No /*_emphasis_*/ characters applied")))
5163 (dolist (entry alist result)
5164 (let ((key (nth 0 entry))
5165 (on (copy-sequence (nth 1 entry)))
5166 (on-help (nth 2 entry))
5167 (off (copy-sequence (nth 3 entry)))
5168 (off-help (nth 4 entry)))
5169 (put-text-property 0 1 'help-echo on-help on)
5170 (put-text-property 0 1 'help-echo off-help off)
5171 (push (list key on off) result))))
5172 "Alist of strings describing wash status in the mode line.
5173 Each entry has the form (KEY ON OF), where the KEY is a symbol
5174 representing the particular washing function, ON is the string to use
5175 in the article mode line when the washing function is active, and OFF
5176 is the string to use when it is inactive.")
5178 (defun gnus-article-wash-status-entry (key value)
5179 (let ((entry (assoc key gnus-article-wash-status-strings)))
5180 (if value (nth 1 entry) (nth 2 entry))))
5182 (defun gnus-article-wash-status ()
5183 "Return a string which display status of article washing."
5185 (set-buffer gnus-article-buffer)
5186 (let ((cite (memq 'cite gnus-article-wash-types))
5187 (headers (memq 'headers gnus-article-wash-types))
5188 (boring (memq 'boring-headers gnus-article-wash-types))
5189 (pgp (memq 'pgp gnus-article-wash-types))
5190 (pem (memq 'pem gnus-article-wash-types))
5191 (signed (memq 'signed gnus-article-wash-types))
5192 (encrypted (memq 'encrypted gnus-article-wash-types))
5193 (signature (memq 'signature gnus-article-wash-types))
5194 (overstrike (memq 'overstrike gnus-article-wash-types))
5195 (emphasis (memq 'emphasis gnus-article-wash-types)))
5197 (gnus-article-wash-status-entry 'cite cite)
5198 (gnus-article-wash-status-entry 'headers (or headers boring))
5199 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5200 (gnus-article-wash-status-entry 'signature signature)
5201 (gnus-article-wash-status-entry 'overstrike overstrike)
5202 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
5203 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5205 (defun gnus-add-wash-type (type)
5206 "Add a washing of TYPE to the current status."
5207 (add-to-list 'gnus-article-wash-types type))
5209 (defun gnus-delete-wash-type (type)
5210 "Add a washing of TYPE to the current status."
5211 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5213 (defun gnus-add-image (category image)
5214 "Add IMAGE of CATEGORY to the list of displayed images."
5215 (let ((entry (assq category gnus-article-image-alist)))
5217 (setq entry (list category))
5218 (push entry gnus-article-image-alist))
5219 (nconc entry (list image))))
5221 (defun gnus-delete-images (category)
5222 "Delete all images in CATEGORY."
5223 (let ((entry (assq category gnus-article-image-alist)))
5224 (dolist (image (cdr entry))
5225 (gnus-remove-image image))
5226 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5227 (gnus-delete-wash-type category)))
5229 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5231 (defun gnus-article-maybe-hide-headers ()
5232 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5233 Provided for backwards compatibility."
5234 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5235 (not (save-excursion (set-buffer gnus-summary-buffer)
5236 gnus-have-all-headers)))
5237 (not gnus-inhibit-hiding))
5238 (gnus-article-hide-headers)))
5242 (defun gnus-output-to-file (file-name)
5243 "Append the current article to a file named FILE-NAME."
5244 (let ((artbuf (current-buffer)))
5246 (insert-buffer-substring artbuf)
5247 ;; Append newline at end of the buffer as separator, and then
5249 (goto-char (point-max))
5251 (let ((file-name-coding-system nnmail-pathname-coding-system)
5252 (pathname-coding-system nnmail-pathname-coding-system))
5253 (write-region-as-binary (point-min) (point-max) file-name 'append))
5256 (defun gnus-narrow-to-page (&optional arg)
5257 "Narrow the article buffer to a page.
5258 If given a numerical ARG, move forward ARG pages."
5260 (setq arg (if arg (prefix-numeric-value arg) 0))
5262 (set-buffer gnus-article-buffer)
5263 (goto-char (point-min))
5265 ;; Remove any old next/prev buttons.
5266 (when (gnus-visual-p 'page-marker)
5267 (let ((buffer-read-only nil))
5268 (gnus-remove-text-with-property 'gnus-prev)
5269 (gnus-remove-text-with-property 'gnus-next)))
5272 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5274 (re-search-forward page-delimiter nil 'move arg)))
5275 (goto-char (match-end 0)))
5278 (if (re-search-forward page-delimiter nil 'move)
5281 (when (and (gnus-visual-p 'page-marker)
5282 (not (= (point-min) 1)))
5284 (goto-char (point-min))
5285 (gnus-insert-prev-page-button)))
5286 (when (and (gnus-visual-p 'page-marker)
5287 (< (+ (point-max) 2) (buffer-size)))
5289 (goto-char (point-max))
5290 (gnus-insert-next-page-button)))))
5292 ;; Article mode commands
5294 (defun gnus-article-goto-next-page ()
5295 "Show the next page of the article."
5297 (when (gnus-article-next-page)
5298 (goto-char (point-min))
5299 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5302 (defun gnus-article-goto-prev-page ()
5303 "Show the next page of the article."
5306 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5307 (gnus-article-prev-page nil)))
5309 ;; This is cleaner but currently breaks `gnus-pick-mode':
5311 ;; (defun gnus-article-goto-next-page ()
5312 ;; "Show the next page of the article."
5314 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5315 ;; (gnus-summary-next-page)))
5317 ;; (defun gnus-article-goto-prev-page ()
5318 ;; "Show the next page of the article."
5320 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5321 ;; (gnus-summary-prev-page)))
5323 (defun gnus-article-next-page (&optional lines)
5324 "Show the next page of the current article.
5325 If end of article, return non-nil. Otherwise return nil.
5326 Argument LINES specifies lines to be scrolled up."
5328 (move-to-window-line -1)
5331 (and (pos-visible-in-window-p) ;Not continuation line.
5332 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5333 ;; Nothing in this page.
5334 (if (or (not gnus-page-broken)
5337 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
5339 (when gnus-article-over-scroll
5340 (gnus-article-next-page-1 lines))
5342 (gnus-narrow-to-page 1) ;Go to next page.
5344 ;; More in this page.
5345 (gnus-article-next-page-1 lines)
5348 (defun gnus-article-next-page-1 (lines)
5349 (let ((scroll-in-place nil))
5353 ;; Long lines may cause an end-of-buffer error.
5354 (goto-char (point-max)))))
5355 (move-to-window-line 0))
5357 (defun gnus-article-prev-page (&optional lines)
5358 "Show previous page of current article.
5359 Argument LINES specifies lines to be scrolled down."
5361 (move-to-window-line 0)
5362 (if (and gnus-page-broken
5364 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5366 (gnus-narrow-to-page -1) ;Go to previous page.
5367 (goto-char (point-max))
5369 (let ((scroll-in-place nil))
5373 (beginning-of-buffer
5374 (goto-char (point-min))))
5375 (move-to-window-line 0)))))
5377 (defun gnus-article-only-boring-p ()
5378 "Decide whether there is only boring text remaining in the article.
5379 Something \"interesting\" is a word of at least two letters that does
5380 not have a face in `gnus-article-boring-faces'."
5381 (when (and gnus-article-skip-boring
5382 (boundp 'gnus-article-boring-faces)
5383 (symbol-value 'gnus-article-boring-faces))
5386 (while (re-search-forward "\\b\\w\\w" nil t)
5388 (when (not (gnus-intersection
5389 (gnus-faces-at (point))
5390 (symbol-value 'gnus-article-boring-faces)))
5391 (throw 'only-boring nil)))
5392 (throw 'only-boring t)))))
5394 (defun gnus-article-refer-article ()
5395 "Read article specified by message-id around point."
5398 (re-search-backward "[ \t]\\|^" (gnus-point-at-bol) t)
5399 (re-search-forward "<?news:<?\\|<" (gnus-point-at-eol) t)
5400 (if (re-search-forward "[^@ ]+@[^ \t>]+" (gnus-point-at-eol) t)
5401 (let ((msg-id (concat "<" (match-string 0) ">")))
5402 (set-buffer gnus-summary-buffer)
5403 (gnus-summary-refer-article msg-id))
5404 (error "No references around point"))))
5406 (defun gnus-article-show-summary ()
5407 "Reconfigure windows to show summary buffer."
5409 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5410 (error "There is no summary buffer for this article buffer")
5411 (gnus-article-set-globals)
5412 (gnus-configure-windows 'article)
5413 (gnus-summary-goto-subject gnus-current-article)
5414 (gnus-summary-position-point)))
5416 (defun gnus-article-describe-briefly ()
5417 "Describe article mode commands briefly."
5419 (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")))
5421 (defun gnus-article-summary-command ()
5422 "Execute the last keystroke in the summary buffer."
5424 (let ((obuf (current-buffer))
5425 (owin (current-window-configuration))
5427 (switch-to-buffer gnus-article-current-summary 'norecord)
5428 (setq func (lookup-key (current-local-map) (this-command-keys)))
5429 (call-interactively func)
5431 (set-window-configuration owin)
5432 (set-window-point (get-buffer-window (current-buffer)) (point))))
5434 (defun gnus-article-summary-command-nosave ()
5435 "Execute the last keystroke in the summary buffer."
5438 (pop-to-buffer gnus-article-current-summary 'norecord)
5439 (setq func (lookup-key (current-local-map) (this-command-keys)))
5440 (call-interactively func)))
5442 (defun gnus-article-check-buffer ()
5443 "Beep if not in an article buffer."
5444 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5445 (error "Command invoked outside of a Gnus article buffer")))
5447 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5448 "Read a summary buffer key sequence and execute it from the article buffer."
5450 (gnus-article-check-buffer)
5452 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5453 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5454 "=" "^" "\M-^" "|"))
5460 '("n" "Gn" "p" "Gp"))
5463 (set-buffer gnus-article-current-summary)
5464 (let (gnus-pick-mode)
5465 (push (or key last-command-event) unread-command-events)
5466 (setq keys (static-if (featurep 'xemacs)
5467 (events-to-keys (read-key-sequence nil))
5468 (read-key-sequence nil)))))
5471 (if (or (member keys nosaves)
5472 (member keys nosave-but-article)
5473 (member keys nosave-in-article))
5475 (save-window-excursion
5476 (pop-to-buffer gnus-article-current-summary 'norecord)
5477 ;; We disable the pick minor mode commands.
5478 (let (gnus-pick-mode)
5479 (setq func (lookup-key (current-local-map) keys))))
5483 (unless (member keys nosave-in-article)
5484 (set-buffer gnus-article-current-summary))
5485 (call-interactively func)
5486 (setq new-sum-point (point)))
5487 (when (member keys nosave-but-article)
5488 (pop-to-buffer gnus-article-buffer 'norecord)))
5489 ;; These commands should restore window configuration.
5490 (let ((obuf (current-buffer))
5491 (owin (current-window-configuration))
5493 (summary gnus-article-current-summary)
5494 func in-buffer selected)
5495 (if not-restore-window
5496 (pop-to-buffer summary 'norecord)
5497 (switch-to-buffer summary 'norecord))
5498 (setq in-buffer (current-buffer))
5499 ;; We disable the pick minor mode commands.
5500 (if (and (setq func (let (gnus-pick-mode)
5501 (lookup-key (current-local-map) keys)))
5504 (call-interactively func)
5505 (setq new-sum-point (point))
5506 (when (eq in-buffer (current-buffer))
5507 (setq selected (gnus-summary-select-article))
5509 (unless not-restore-window
5510 (set-window-configuration owin))
5511 (when (eq selected 'old)
5513 (set-window-start (get-buffer-window (current-buffer))
5515 (set-window-point (get-buffer-window (current-buffer))
5517 (let ((win (get-buffer-window gnus-article-current-summary)))
5519 (set-window-point win new-sum-point)))) )
5520 (switch-to-buffer gnus-article-buffer)
5523 (defun gnus-article-describe-key (key)
5524 "Display documentation of the function invoked by KEY. KEY is a string."
5525 (interactive "kDescribe key: ")
5526 (gnus-article-check-buffer)
5527 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5529 (set-buffer gnus-article-current-summary)
5530 (let (gnus-pick-mode)
5531 (if (featurep 'xemacs)
5533 (push (elt key 0) unread-command-events)
5534 (setq key (events-to-keys
5535 (read-key-sequence "Describe key: "))))
5536 (setq unread-command-events
5538 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5540 (setq key (read-key-sequence "Describe key: "))))
5542 (describe-key key)))
5544 (defun gnus-article-describe-key-briefly (key &optional insert)
5545 "Display documentation of the function invoked by KEY. KEY is a string."
5546 (interactive "kDescribe key: \nP")
5547 (gnus-article-check-buffer)
5548 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5550 (set-buffer gnus-article-current-summary)
5551 (let (gnus-pick-mode)
5552 (if (featurep 'xemacs)
5554 (push (elt key 0) unread-command-events)
5555 (setq key (events-to-keys
5556 (read-key-sequence "Describe key: "))))
5557 (setq unread-command-events
5559 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5561 (setq key (read-key-sequence "Describe key: "))))
5562 (describe-key-briefly key insert))
5563 (describe-key-briefly key insert)))
5565 (defun gnus-article-reply-with-original (&optional wide)
5566 "Start composing a reply mail to the current message.
5567 The text in the region will be yanked. If the region isn't active,
5568 the entire article will be yanked."
5570 (let ((article (cdr gnus-article-current))
5572 (if (not (gnus-mark-active-p))
5573 (with-current-buffer gnus-summary-buffer
5574 (gnus-summary-reply (list (list article)) wide))
5575 (setq contents (buffer-substring (point) (mark t)))
5576 ;; Deactivate active regions.
5577 (when (and (boundp 'transient-mark-mode)
5578 transient-mark-mode)
5579 (setq mark-active nil))
5580 (with-current-buffer gnus-summary-buffer
5582 (list (list article contents)) wide)))))
5584 (defun gnus-article-followup-with-original ()
5585 "Compose a followup to the current article.
5586 The text in the region will be yanked. If the region isn't active,
5587 the entire article will be yanked."
5589 (let ((article (cdr gnus-article-current))
5591 (if (not (gnus-mark-active-p))
5592 (with-current-buffer gnus-summary-buffer
5593 (gnus-summary-followup (list (list article))))
5594 (setq contents (buffer-substring (point) (mark t)))
5595 ;; Deactivate active regions.
5596 (when (and (boundp 'transient-mark-mode)
5597 transient-mark-mode)
5598 (setq mark-active nil))
5599 (with-current-buffer gnus-summary-buffer
5600 (gnus-summary-followup
5601 (list (list article contents)))))))
5603 (defun gnus-article-hide (&optional arg force)
5604 "Hide all the gruft in the current article.
5605 This means that signatures, cited text and (some) headers will be
5607 If given a prefix, show the hidden text instead."
5608 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5609 (gnus-article-hide-headers arg)
5610 (gnus-article-hide-list-identifiers arg)
5611 (gnus-article-hide-citation-maybe arg force)
5612 (gnus-article-hide-signature arg))
5614 (defun gnus-article-maybe-highlight ()
5615 "Do some article highlighting if article highlighting is requested."
5616 (when (gnus-visual-p 'article-highlight 'highlight)
5617 (gnus-article-highlight-some)))
5619 (defun gnus-check-group-server ()
5620 ;; Make sure the connection to the server is alive.
5621 (unless (gnus-server-opened
5622 (gnus-find-method-for-group gnus-newsgroup-name))
5623 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5624 (gnus-request-group gnus-newsgroup-name t)))
5627 (autoload 'nneething-get-file-name "nneething"))
5629 (defun gnus-request-article-this-buffer (article group)
5630 "Get an article and insert it into this buffer."
5631 (let (do-update-line sparse-header)
5635 (gnus-kill-all-overlays)
5636 (setq group (or group gnus-newsgroup-name))
5638 ;; Using `gnus-request-article' directly will insert the article into
5639 ;; `nntp-server-buffer' - so we'll save some time by not having to
5640 ;; copy it from the server buffer into the article buffer.
5642 ;; We only request an article by message-id when we do not have the
5643 ;; headers for it, so we'll have to get those.
5644 (when (stringp article)
5645 (gnus-read-header article))
5647 ;; If the article number is negative, that means that this article
5648 ;; doesn't belong in this newsgroup (possibly), so we find its
5649 ;; message-id and request it by id instead of number.
5650 (when (and (numberp article)
5652 (get-buffer gnus-summary-buffer)
5653 (gnus-buffer-exists-p gnus-summary-buffer))
5655 (set-buffer gnus-summary-buffer)
5656 (let ((header (gnus-summary-article-header article)))
5659 ((memq article gnus-newsgroup-sparse)
5660 ;; This is a sparse gap article.
5661 (setq do-update-line article)
5662 (setq article (mail-header-id header))
5663 (setq sparse-header (gnus-read-header article))
5664 (setq gnus-newsgroup-sparse
5665 (delq article gnus-newsgroup-sparse)))
5667 ;; It's a real article.
5668 (setq article (mail-header-id header)))
5670 ;; It is an extracted pseudo-article.
5671 (setq article 'pseudo)
5672 (gnus-request-pseudo-article header))))
5674 (let ((method (gnus-find-method-for-group
5675 gnus-newsgroup-name)))
5676 (when (and (eq (car method) 'nneething)
5678 (let ((dir (nneething-get-file-name
5679 (mail-header-id header))))
5680 (when (and (stringp dir)
5681 (file-directory-p dir))
5682 (setq article 'nneething)
5683 (gnus-group-enter-directory dir))))))))
5686 ;; Refuse to select canceled articles.
5687 ((and (numberp article)
5689 (get-buffer gnus-summary-buffer)
5690 (gnus-buffer-exists-p gnus-summary-buffer)
5691 (eq (cdr (save-excursion
5692 (set-buffer gnus-summary-buffer)
5693 (assq article gnus-newsgroup-reads)))
5694 gnus-canceled-mark))
5696 ;; We first check `gnus-original-article-buffer'.
5697 ((and (get-buffer gnus-original-article-buffer)
5700 (set-buffer gnus-original-article-buffer)
5701 (and (equal (car gnus-original-article) group)
5702 (eq (cdr gnus-original-article) article))))
5703 (insert-buffer-substring gnus-original-article-buffer)
5705 ;; Check the backlog.
5706 ((and gnus-keep-backlog
5707 (gnus-backlog-request-article group article (current-buffer)))
5709 ;; Check asynchronous pre-fetch.
5710 ((gnus-async-request-fetched-article group article (current-buffer))
5711 (gnus-async-prefetch-next group article gnus-summary-buffer)
5712 (when (and (numberp article) gnus-keep-backlog)
5713 (gnus-backlog-enter-article group article (current-buffer)))
5716 ((and gnus-use-cache
5718 (gnus-cache-request-article article group))
5720 ;; Check the agent cache.
5721 ((gnus-agent-request-article article group)
5723 ;; Get the article and put into the article buffer.
5724 ((or (stringp article)
5726 (let ((gnus-override-method gnus-override-method)
5727 (methods (and (stringp article)
5728 gnus-refer-article-method))
5729 (backend (car (gnus-find-method-for-group
5730 gnus-newsgroup-name)))
5732 (buffer-read-only nil))
5733 (if (or (not (listp methods))
5734 (and (symbolp (car methods))
5735 (assq (car methods) nnoo-definition-alist)))
5736 (setq methods (list methods)))
5737 (when (and (null gnus-override-method)
5739 (setq gnus-override-method (pop methods)))
5741 (when (eq gnus-override-method 'current)
5742 (setq gnus-override-method
5743 (with-current-buffer gnus-summary-buffer
5744 gnus-current-select-method)))
5746 (gnus-kill-all-overlays)
5747 (let ((gnus-newsgroup-name group))
5748 (gnus-check-group-server))
5750 ((gnus-request-article article group (current-buffer))
5751 (when (numberp article)
5752 (gnus-async-prefetch-next group article
5753 gnus-summary-buffer)
5754 (when gnus-keep-backlog
5755 (gnus-backlog-enter-article
5756 group article (current-buffer))))
5757 (setq result 'article))
5759 (setq gnus-override-method (pop methods)))
5760 ((not (string-match "^400 "
5761 (nnheader-get-report backend)))
5762 ;; If we get 400 server disconnect, reconnect and
5763 ;; retry; otherwise, assume the article has expired.
5764 (setq result 'done))))
5765 (and (eq result 'article) 'article)))
5769 ;; Associate this article with the current summary buffer.
5770 (setq gnus-article-current-summary gnus-summary-buffer)
5772 ;; Take the article from the original article buffer
5773 ;; and place it in the buffer it's supposed to be in.
5774 (when (and (get-buffer gnus-article-buffer)
5775 (equal (buffer-name (current-buffer))
5776 (buffer-name (get-buffer gnus-article-buffer))))
5778 (if (get-buffer gnus-original-article-buffer)
5779 (set-buffer gnus-original-article-buffer)
5780 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5781 (buffer-disable-undo)
5782 (setq major-mode 'gnus-original-article-mode)
5783 (setq buffer-read-only t))
5784 (let (buffer-read-only)
5786 (insert-buffer-substring gnus-article-buffer))
5787 (setq gnus-original-article (cons group article)))
5790 (run-hooks 'gnus-article-decode-hook)
5791 ;; Mark article as decoded or not.
5792 (setq gnus-article-decoded-p gnus-article-decode-hook))
5794 ;; Update sparse articles.
5795 (when (and do-update-line
5796 (or (numberp article)
5798 (let ((buf (current-buffer)))
5799 (set-buffer gnus-summary-buffer)
5800 (gnus-summary-update-article do-update-line sparse-header)
5801 (gnus-summary-goto-subject do-update-line nil t)
5802 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5804 (set-buffer buf))))))
5810 (defcustom gnus-article-edit-mode-hook nil
5811 "Hook run in article edit mode buffers."
5812 :group 'gnus-article-various
5815 (defcustom gnus-article-edit-article-setup-function
5816 'gnus-article-mime-edit-article-setup
5817 "Function called to setup an editing article buffer."
5818 :group 'gnus-article-various
5821 (defvar gnus-article-edit-done-function nil)
5823 (defvar gnus-article-edit-mode-map nil)
5824 (defvar gnus-article-edit-mode nil)
5826 ;; Should we be using derived.el for this?
5827 (unless gnus-article-edit-mode-map
5828 (setq gnus-article-edit-mode-map (make-keymap))
5829 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5831 (gnus-define-keys gnus-article-edit-mode-map
5832 "\C-c?" describe-mode
5833 "\C-c\C-c" gnus-article-edit-done
5834 "\C-c\C-k" gnus-article-edit-exit
5835 "\C-c\C-f\C-t" message-goto-to
5836 "\C-c\C-f\C-o" message-goto-from
5837 "\C-c\C-f\C-b" message-goto-bcc
5838 ;;"\C-c\C-f\C-w" message-goto-fcc
5839 "\C-c\C-f\C-c" message-goto-cc
5840 "\C-c\C-f\C-s" message-goto-subject
5841 "\C-c\C-f\C-r" message-goto-reply-to
5842 "\C-c\C-f\C-n" message-goto-newsgroups
5843 "\C-c\C-f\C-d" message-goto-distribution
5844 "\C-c\C-f\C-f" message-goto-followup-to
5845 "\C-c\C-f\C-m" message-goto-mail-followup-to
5846 "\C-c\C-f\C-k" message-goto-keywords
5847 "\C-c\C-f\C-u" message-goto-summary
5848 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5849 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5850 "\C-c\C-b" message-goto-body
5851 "\C-c\C-i" message-goto-signature
5853 "\C-c\C-t" message-insert-to
5854 "\C-c\C-n" message-insert-newsgroups
5855 "\C-c\C-o" message-sort-headers
5856 "\C-c\C-e" message-elide-region
5857 "\C-c\C-v" message-delete-not-region
5858 "\C-c\C-z" message-kill-to-signature
5859 "\M-\r" message-newline-and-reformat
5860 "\C-c\C-a" mml-attach-file
5861 "\C-a" message-beginning-of-line
5863 "\M-;" comment-region)
5865 (gnus-define-keys (gnus-article-edit-wash-map
5866 "\C-c\C-w" gnus-article-edit-mode-map)
5867 "f" gnus-article-edit-full-stops))
5870 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5872 ["Fetch To" message-insert-to t]
5873 ["Fetch Newsgroups" message-insert-newsgroups t]
5875 ["To" message-goto-to t]
5876 ["From" message-goto-from t]
5877 ["Subject" message-goto-subject t]
5878 ["Cc" message-goto-cc t]
5879 ["Reply-To" message-goto-reply-to t]
5880 ["Summary" message-goto-summary t]
5881 ["Keywords" message-goto-keywords t]
5882 ["Newsgroups" message-goto-newsgroups t]
5883 ["Followup-To" message-goto-followup-to t]
5884 ["Mail-Followup-To" message-goto-mail-followup-to t]
5885 ["Distribution" message-goto-distribution t]
5886 ["Body" message-goto-body t]
5887 ["Signature" message-goto-signature t]))
5889 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5890 "Major mode for editing articles.
5891 This is an extended text-mode.
5893 \\{gnus-article-edit-mode-map}"
5894 (make-local-variable 'gnus-article-edit-done-function)
5895 (make-local-variable 'gnus-prev-winconf)
5896 (set (make-local-variable 'font-lock-defaults)
5897 '(message-font-lock-keywords t))
5898 (set (make-local-variable 'mail-header-separator) "")
5899 (set (make-local-variable 'gnus-article-edit-mode) t)
5900 (easy-menu-add message-mode-field-menu message-mode-map)
5901 (setq buffer-read-only nil)
5902 (buffer-enable-undo)
5905 (defun gnus-article-edit (&optional force)
5906 "Edit the current article.
5907 This will have permanent effect only in mail groups.
5908 If FORCE is non-nil, allow editing of articles even in read-only
5911 (when (and (not force)
5912 (gnus-group-read-only-p))
5913 (error "The current newsgroup does not support article editing"))
5914 (gnus-article-date-original)
5915 (gnus-article-edit-article
5917 `(lambda (no-highlight)
5919 (gnus-summary-edit-article-done
5920 ,(or (mail-header-references gnus-current-headers) "")
5921 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5923 (defun gnus-article-edit-article (start-func exit-func)
5924 "Start editing the contents of the current article buffer."
5925 (let ((winconf (current-window-configuration)))
5926 (set-buffer gnus-article-buffer)
5927 (gnus-article-edit-mode)
5928 (funcall start-func)
5929 (set-buffer-modified-p nil)
5930 (gnus-configure-windows 'edit-article)
5931 (setq gnus-article-edit-done-function exit-func)
5932 (setq gnus-prev-winconf winconf)
5933 (when gnus-article-edit-article-setup-function
5934 (funcall gnus-article-edit-article-setup-function))
5935 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit")))
5937 (defun gnus-article-edit-done (&optional arg)
5938 "Update the article edits and exit."
5940 (let ((func gnus-article-edit-done-function)
5941 (buf (current-buffer))
5942 (start (window-start))
5944 (winconf gnus-prev-winconf))
5945 (remove-hook 'gnus-article-mode-hook
5946 'gnus-article-mime-edit-article-unwind)
5947 (widen) ;; Widen it in case that users narrowed the buffer.
5950 ;; The cache and backlog have to be flushed somewhat.
5951 (when gnus-keep-backlog
5952 (gnus-backlog-remove-article
5953 (car gnus-article-current) (cdr gnus-article-current)))
5954 ;; Flush original article as well.
5956 (when (get-buffer gnus-original-article-buffer)
5957 (set-buffer gnus-original-article-buffer)
5958 (setq gnus-original-article nil)))
5959 (when gnus-use-cache
5960 (gnus-cache-update-article
5961 (car gnus-article-current) (cdr gnus-article-current)))
5962 ;; We remove all text props from the article buffer.
5963 (kill-all-local-variables)
5964 (gnus-set-text-properties (point-min) (point-max) nil)
5966 (set-window-configuration winconf)
5968 (set-window-start (get-buffer-window buf) start)
5969 (set-window-point (get-buffer-window buf) (point))))
5971 (defun gnus-article-edit-exit ()
5972 "Exit the article editing without updating."
5974 (when (or (not (buffer-modified-p))
5975 (yes-or-no-p "Article modified; kill anyway? "))
5976 (let ((curbuf (current-buffer))
5978 (window-start (window-start)))
5980 (if (gnus-buffer-live-p gnus-original-article-buffer)
5981 (insert-buffer-substring gnus-original-article-buffer))
5982 (let ((winconf gnus-prev-winconf))
5983 (kill-all-local-variables)
5985 (set-window-configuration winconf)
5986 ;; Tippy-toe some to make sure that point remains where it was.
5987 (save-current-buffer
5989 (set-window-start (get-buffer-window (current-buffer)) window-start)
5992 (defun gnus-article-edit-full-stops ()
5993 "Interactively repair spacing at end of sentences."
5996 (goto-char (point-min))
5997 (search-forward-regexp "^$" nil t)
5998 (let ((case-fold-search nil))
5999 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
6002 ;;; Article editing with MIME-Edit
6005 (defcustom gnus-article-mime-edit-article-setup-hook nil
6006 "Hook run after setting up a MIME editing article buffer."
6007 :group 'gnus-article-various
6010 (defun gnus-article-mime-edit-article-unwind ()
6011 "Unwind `gnus-article-buffer' if article editing was given up."
6012 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6013 (when (featurep 'font-lock)
6014 (setq font-lock-defaults nil)
6015 (font-lock-mode -1))
6016 (when mime-edit-mode-flag
6017 (mime-edit-exit 'nomime 'no-error)
6020 (defun gnus-article-mime-edit-article-setup ()
6021 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
6022 after replacing with the original article."
6023 (setq gnus-show-mime t)
6024 (setq gnus-article-edit-done-function
6025 `(lambda (&rest args)
6026 (when mime-edit-mode-flag
6027 (let (mime-edit-insert-user-agent-field)
6030 (goto-char (point-min))
6031 (let (case-fold-search)
6032 (when (re-search-forward
6033 (format "^%s$" (regexp-quote mail-header-separator))
6035 (replace-match "")))
6036 (apply ,gnus-article-edit-done-function args)
6039 (buffer-substring-no-properties (point-min) (point-max))
6040 (set-buffer (get-buffer-create gnus-original-article-buffer))
6042 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6043 (set-buffer gnus-article-buffer)
6044 (gnus-article-prepare-display)))
6045 (substitute-key-definition 'gnus-article-edit-done
6046 'gnus-article-mime-edit-done
6047 gnus-article-edit-mode-map)
6048 (substitute-key-definition 'gnus-article-edit-exit
6049 'gnus-article-mime-edit-exit
6050 gnus-article-edit-mode-map)
6052 (insert-buffer-substring gnus-original-article-buffer)
6053 (unless (member (with-current-buffer gnus-summary-buffer
6054 gnus-newsgroup-name)
6055 '("nndraft:delayed" "nndraft:drafts"))
6056 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
6057 (fset 'mime-edit-decode-single-part-in-buffer
6058 (lambda (&rest args)
6059 (if (let ((content-type (car args)))
6060 (and (eq 'message (mime-content-type-primary-type
6062 (eq 'rfc822 (mime-content-type-subtype
6064 (setcar (cdr args) 'not-decode-text))
6068 (fset 'mime-edit-decode-single-part-in-buffer ofn))))
6069 (when (featurep 'font-lock)
6070 (set (make-local-variable 'font-lock-defaults)
6071 '(message-font-lock-keywords t))
6072 (font-lock-set-defaults)
6073 (turn-on-font-lock))
6074 (set-buffer-modified-p nil)
6075 (delete-other-windows)
6076 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6077 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
6079 (defun gnus-article-mime-edit-done (&optional arg)
6080 "Update the article MIME edits and exit."
6082 (when (featurep 'font-lock)
6083 (setq font-lock-defaults nil)
6084 (font-lock-mode -1))
6085 (let ((inhibit-read-only t))
6086 (gnus-article-edit-done arg)))
6088 (defun gnus-article-mime-edit-exit ()
6089 "Exit the article MIME editing without updating."
6091 (when (or (not (buffer-modified-p))
6092 (yes-or-no-p "Article modified; kill anyway? "))
6093 (when (featurep 'font-lock)
6094 (setq font-lock-defaults nil)
6095 (font-lock-mode -1))
6096 (when mime-edit-mode-flag
6097 (let (mime-edit-insert-user-agent-field)
6100 (goto-char (point-min))
6101 (let (case-fold-search)
6102 (when (re-search-forward
6103 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
6104 (replace-match "")))
6105 (let ((winconf gnus-prev-winconf))
6107 (buffer-substring-no-properties (point-min) (point-max))
6108 (set-buffer (get-buffer-create gnus-original-article-buffer))
6110 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6111 (set-buffer gnus-article-buffer)
6112 (gnus-article-prepare-display)
6113 (set-window-configuration winconf))))
6116 ;;; Article highlights
6119 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6121 ;;; Internal Variables:
6123 (defcustom gnus-button-url-regexp
6124 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
6125 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-z0-9_.]+:[0-9]*\\)?[-a-z0-9_=!?#$@~%&*+\\/:;.,[:word:]]+[-a-z0-9_=#$@~%&*+\\/[:word:]]\\)"
6126 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-z0-9_.]+:[0-9]*\\)?\\([-a-z0-9_=!?#$@~%&*+\\/:;.,]\\|\\w\\)+\\([-a-z0-9_=#$@~%&*+\\/]\\|\\w\\)\\)")
6127 "Regular expression that matches URLs."
6128 :group 'gnus-article-buttons
6131 (defcustom gnus-button-valid-fqdn-regexp
6132 message-valid-fqdn-regexp
6133 "Regular expression that matches a valid FQDN."
6134 :group 'gnus-article-buttons
6137 (defcustom gnus-button-man-handler 'manual-entry
6138 "Function to use for displaying man pages.
6139 The function must take at least one argument with a string naming the
6141 :type '(choice (function-item :tag "Man" manual-entry)
6142 (function-item :tag "Woman" woman)
6143 (function :tag "Other"))
6144 :group 'gnus-article-buttons)
6146 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6147 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6148 If the default site is too slow, try to find a CTAN mirror, see
6149 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6150 the variable `gnus-button-handle-ctan'."
6151 :group 'gnus-article-buttons
6152 :link '(custom-manual "(gnus)Group Parameters")
6153 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6154 (const "http://tug.ctan.org/tex-archive/")
6155 (const "http://www.dante.de/CTAN/")
6156 (string :tag "Other")))
6158 (defcustom gnus-button-ctan-handler 'browse-url
6159 "Function to use for displaying CTAN links.
6160 The function must take one argument, the string naming the URL."
6161 :type '(choice (function-item :tag "Browse Url" browse-url)
6162 (function :tag "Other"))
6163 :group 'gnus-article-buttons)
6165 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6166 "Bogus strings removed from CTAN URLs."
6167 :group 'gnus-article-buttons
6168 :type '(choice (const "^/?tex-archive/\\|/")
6169 (regexp :tag "Other")))
6171 (defcustom gnus-button-ctan-directory-regexp
6173 "\\("; Cannot use `\(?: ... \)' (compatibility with Emacs 20).
6174 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
6175 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
6176 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
6178 "Regular expression for ctan directories.
6179 It should match all directories in the top level of `gnus-ctan-url'."
6180 :group 'gnus-article-buttons
6183 (defcustom gnus-button-mid-or-mail-regexp
6184 (concat "\\b\\(<?[a-z0-9][^<>\")!;:,{}\n\t ]*@"
6185 gnus-button-valid-fqdn-regexp
6187 "Regular expression that matches a message ID or a mail address."
6188 :group 'gnus-article-buttons
6191 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6192 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6193 Strings like this can be either a message ID or a mail address. If it is one
6194 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6195 message ID or a mail address, respectively. If this variable is set to the
6196 symbol `ask', always query the user what do do. If it is a function, this
6197 function will be called with the string as it's only argument. The function
6198 must return `mid', `mail', `invalid' or `ask'."
6199 :group 'gnus-article-buttons
6200 :type '(choice (function-item :tag "Heuristic function"
6201 gnus-button-mid-or-mail-heuristic)
6206 (defcustom gnus-button-mid-or-mail-heuristic-alist
6207 '((-10.0 . ".+\\$.+@")
6210 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6211 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6212 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6213 (-1.0 . "^[^a-z]+@")
6215 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6216 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6217 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6218 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6221 (-1.0 . "^[0-9][0-9]")
6223 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6224 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6225 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6226 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6228 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6229 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6232 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6234 ;; compensation for TDMA dated mail addresses:
6235 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6237 (-20.0 . "\\.fsf@") ;; Gnus
6240 (-20.0 . "_-_") ;; Subject change in thread
6242 (-20.0 . "\\.ln@") ;; leafnode
6243 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6244 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6246 ;; (5.0 . "") ;; $local_part_len <= 7
6247 (10.0 . "^[^0-9]+@")
6248 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6249 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6252 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6254 (0.5 . "^[A-Z][a-z]")
6255 (0.5 . "^[A-Z][a-z][a-z]")
6256 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6257 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6258 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6260 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6261 address. The REGEXP is processed with `case-fold-search' set to `nil'."
6262 :group 'gnus-article-buttons
6263 :type '(repeat (cons (number :tag "Rate")
6264 (regexp :tag "Regexp"))))
6266 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6267 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6268 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6269 address, `ask' if unsure and `invalid' if the string is invalid."
6270 (let ((case-fold-search nil)
6271 (list gnus-button-mid-or-mail-heuristic-alist)
6272 (result 0) rate regexp lpartlen elem)
6274 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6275 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6276 ;; Certain special cases...
6279 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$" "\\|"
6280 "^[0-9]+\.[0-9]+\@compuserve")
6282 (gnus-message 8 "`%s' is a known mail address.")
6283 (setq result 'mail))
6284 (when (string-match "@.*@\\| " mid-or-mail)
6285 (gnus-message 8 "`%s' is invalid.")
6286 (setq result 'invalid))
6287 ;; Nothing more to do, if result is not a number here...
6288 (when (numberp result)
6290 (setq elem (car list)
6294 (when (string-match regexp mid-or-mail)
6295 (setq result (+ result rate))
6297 9 "`%s' matched `%s', rate `%s', result `%s'."
6298 mid-or-mail regexp rate result)))
6299 (when (<= lpartlen 7)
6300 (setq result (+ result 5.0))
6301 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6302 mid-or-mail result))
6303 (when (>= lpartlen 12)
6304 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6306 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6307 ;; Long local part should contain realname if e-mail address,
6308 ;; too many digits: message-id.
6309 ;; $score -= 5.0 + 0.1 * $local_part_len;
6310 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6311 (setq result (+ result rate))
6313 9 "Many digits in `%s', rate `%s', result `%s'."
6314 mid-or-mail rate result))
6315 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6317 ;; Too few vowels [^aeiouy]{4,}.*\@
6318 (setq result (+ result -5.0))
6320 9 "Few vowels in `%s', rate `%s', result `%s'."
6321 mid-or-mail -5.0 result))
6323 (setq result (+ result 5.0))
6325 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6326 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6328 ;; Maybe we should make this a customizable alist: (condition . 'result)
6329 ((< result -10.0) 'mid)
6330 ((> result 10.0) 'mail)
6333 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6334 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6335 (url-mid (concat "news" ":" mid-or-mail))
6336 (url-mailto (concat "mailto" ":" mid-or-mail)))
6337 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6338 (when (fboundp pref)
6340 ;; get rid of surrounding angles...
6342 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6343 (if (or (eq 'mid guessed) (eq 'mail guessed))
6347 (save-window-excursion
6348 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6351 (cond ((eq pref 'mid)
6352 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6353 (gnus-button-handle-news url-mid))
6355 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6356 (gnus-url-mailto url-mailto))
6357 (t (gnus-message 3 "Invalid string.")))))
6359 (defun gnus-button-handle-custom (url)
6360 "Follow a Custom URL."
6361 (customize-apropos (gnus-url-unhex-string url)))
6363 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6365 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6368 (defun gnus-button-handle-describe-function (url)
6369 "Call `describe-function' when pushing the corresponding URL button."
6372 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6374 (defun gnus-button-handle-describe-variable (url)
6375 "Call `describe-variable' when pushing the corresponding URL button."
6378 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6380 (defun gnus-button-handle-symbol (url)
6381 "Display help on variable or function.
6382 Calls `describe-variable' or `describe-function'."
6383 (let ((sym (intern url)))
6385 ((fboundp sym) (describe-function sym))
6386 ((boundp sym) (describe-variable sym))
6387 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6389 (defun gnus-button-handle-describe-key (url)
6390 "Call `describe-key' when pushing the corresponding URL button."
6392 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6393 (keys (ignore-errors (eval `(kbd ,key-string)))))
6396 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6398 (defun gnus-button-handle-apropos (url)
6399 "Call `apropos' when pushing the corresponding URL button."
6400 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6402 (defun gnus-button-handle-apropos-command (url)
6403 "Call `apropos' when pushing the corresponding URL button."
6405 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6407 (defun gnus-button-handle-apropos-variable (url)
6408 "Call `apropos' when pushing the corresponding URL button."
6410 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6411 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6413 (defun gnus-button-handle-apropos-documentation (url)
6414 "Call `apropos' when pushing the corresponding URL button."
6416 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6417 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6419 (defun gnus-button-handle-library (url)
6420 "Call `locate-library' when pushing the corresponding URL button."
6421 (gnus-message 9 "url=`%s'" url)
6422 (let* ((lib (locate-library url))
6423 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6425 (gnus-message 1 "Cannot locale library `%s'." url)
6426 (find-file-read-only file))))
6428 (defun gnus-button-handle-ctan (url)
6429 "Call `browse-url' when pushing a CTAN URL button."
6431 gnus-button-ctan-handler
6434 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6436 (defcustom gnus-button-tex-level 5
6437 "*Integer that says how many TeX-related buttons Gnus will show.
6438 The higher the number, the more buttons will appear and the more false
6439 positives are possible. Note that you can set this variable local to
6440 specifific groups. Setting it higher in TeX groups is probably a good idea.
6441 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6442 how to set variables in specific groups."
6443 :group 'gnus-article-buttons
6444 :link '(custom-manual "(gnus)Group Parameters")
6447 (defcustom gnus-button-man-level 5
6448 "*Integer that says how many man-related buttons Gnus will show.
6449 The higher the number, the more buttons will appear and the more false
6450 positives are possible. Note that you can set this variable local to
6451 specifific groups. Setting it higher in Unix groups is probably a good idea.
6452 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6453 how to set variables in specific groups."
6454 :group 'gnus-article-buttons
6455 :link '(custom-manual "(gnus)Group Parameters")
6458 (defcustom gnus-button-emacs-level 5
6459 "*Integer that says how many emacs-related buttons Gnus will show.
6460 The higher the number, the more buttons will appear and the more false
6461 positives are possible. Note that you can set this variable local to
6462 specifific groups. Setting it higher in Emacs or Gnus related groups is
6463 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6464 `gnus-parameters' on how to set variables in specific groups."
6465 :group 'gnus-article-buttons
6466 :link '(custom-manual "(gnus)Group Parameters")
6469 (defcustom gnus-button-message-level 5
6470 "*Integer that says how many buttons for news or mail messages will appear.
6471 The higher the number, the more buttons will appear and the more false
6472 positives are possible."
6473 ;; mail addresses, MIDs, URLs for news, ...
6474 :group 'gnus-article-buttons
6477 (defcustom gnus-button-browse-level 5
6478 "*Integer that says how many buttons for browsing will appear.
6479 The higher the number, the more buttons will appear and the more false
6480 positives are possible."
6481 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6482 :group 'gnus-article-buttons
6485 (defcustom gnus-button-alist
6486 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6487 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6488 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6489 gnus-button-handle-news 2)
6490 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6491 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6492 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6493 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6494 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6495 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6496 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6497 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6498 ("mailto:\\([-a-z.@_+0-9%=?]+\\)"
6499 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6500 ("\\bmailto:\\([^ \n\t]+\\)"
6501 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6503 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6504 gnus-button-ctan-directory-regexp
6505 "[^][>)!;:,'\n\t ]+\\)")
6506 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6507 ((concat "\\btex-archive/\\("
6508 gnus-button-ctan-directory-regexp
6509 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6510 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6513 gnus-button-ctan-directory-regexp
6514 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6515 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6517 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)"
6518 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6519 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6520 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6521 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6522 ;; Info links like `C-h i d m CC Mode RET'
6523 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6525 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6526 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6527 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6528 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6529 ;; Emacs help commands
6530 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6531 ;; regexp doesn't match arguments containing ` '.
6532 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6533 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6534 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6535 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6536 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6537 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6538 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6539 ;; The following entries may lead to many false positives so don't enable
6540 ;; them by default (use a high button level):
6541 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>"
6542 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6543 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6544 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6545 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6546 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6547 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6548 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6549 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6550 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6551 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6552 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6553 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6554 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6555 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6556 ;; Unlike the other regexps we really have to require quoting
6557 ;; here to determine where it ends.
6558 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6559 ;; This is how URLs _should_ be embedded in text (RFC 1738)...
6560 ("<URL: *\\([^<>]*\\)>"
6561 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6563 (gnus-button-url-regexp
6564 0 (>= gnus-button-browse-level 0) browse-url 0)
6566 ("\\b\\([a-z][a-z]+\\)([1-9])\\W"
6567 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6568 gnus-button-handle-man 1)
6569 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6570 ("\\b\\([a-z][-_.a-z0-9]+\\)([1-9])\\W"
6571 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6572 gnus-button-handle-man 1)
6573 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6574 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6575 ("\\b\\([a-z][-_.:a-z0-9]+\\)([1-9][X1a-z]*)\\W\\|\\b\\(X\\)([1-9])\\W"
6576 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6577 ;; MID or mail: To avoid too many false positives we don't try to catch
6578 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6579 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6580 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6581 ;; so that non-ambiguous entries (see above) match first.
6582 (gnus-button-mid-or-mail-regexp
6583 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6584 "*Alist of regexps matching buttons in article bodies.
6586 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6587 REGEXP: is the string (case insensitive) matching text around the button (can
6588 also be lisp expression evaluating to a string),
6589 BUTTON: is the number of the regexp grouping actually matching the button,
6590 FORM: is a lisp expression which must eval to true for the button to
6592 CALLBACK: is the function to call when the user push this button, and each
6593 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6595 CALLBACK can also be a variable, in that case the value of that
6596 variable it the real callback function."
6597 :group 'gnus-article-buttons
6598 :type '(repeat (list (choice regexp variable)
6599 (integer :tag "Button")
6601 (function :tag "Callback")
6604 (integer :tag "Regexp group")))))
6606 (defcustom gnus-header-button-alist
6607 '(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
6608 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6609 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6610 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6611 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6612 0 (>= gnus-button-message-level 0) gnus-button-mailto 0)
6613 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6614 0 (>= gnus-button-browse-level 0) browse-url 0)
6615 ("^Subject:" gnus-button-url-regexp
6616 0 (>= gnus-button-browse-level 0) browse-url 0)
6617 ("^[^:]+:" gnus-button-url-regexp
6618 0 (>= gnus-button-browse-level 0) browse-url 0)
6619 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?]+\\)"
6620 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6621 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6622 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6623 "*Alist of headers and regexps to match buttons in article heads.
6625 This alist is very similar to `gnus-button-alist', except that each
6626 alist has an additional HEADER element first in each entry:
6628 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6630 HEADER is a regexp to match a header. For a fuller explanation, see
6631 `gnus-button-alist'."
6632 :group 'gnus-article-buttons
6633 :group 'gnus-article-headers
6634 :type '(repeat (list (regexp :tag "Header")
6636 (integer :tag "Button")
6638 (function :tag "Callback")
6641 (integer :tag "Regexp group")))))
6643 (defvar gnus-button-regexp nil)
6644 (defvar gnus-button-marker-list nil)
6645 ;; Regexp matching any of the regexps from `gnus-button-alist'.
6647 (defvar gnus-button-last nil)
6648 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
6652 (defun gnus-article-push-button (event)
6653 "Check text under the mouse pointer for a callback function.
6654 If the text under the mouse pointer has a `gnus-callback' property,
6655 call it with the value of the `gnus-data' text property."
6657 (set-buffer (window-buffer (posn-window (event-start event))))
6658 (let* ((pos (posn-point (event-start event)))
6659 (data (get-text-property pos 'gnus-data))
6660 (fun (get-text-property pos 'gnus-callback)))
6663 (funcall fun data))))
6665 (defun gnus-article-press-button ()
6666 "Check text at point for a callback function.
6667 If the text at point has a `gnus-callback' property,
6668 call it with the value of the `gnus-data' text property."
6670 (let ((data (get-text-property (point) 'gnus-data))
6671 (fun (get-text-property (point) 'gnus-callback)))
6673 (funcall fun data))))
6675 (defun gnus-article-prev-button (n)
6676 "Move point to N buttons backward.
6677 If N is negative, move forward instead."
6679 (gnus-article-next-button (- n)))
6681 (defun gnus-article-next-button (n)
6682 "Move point to N buttons forward.
6683 If N is negative, move backward instead."
6685 (let ((function (if (< n 0) 'previous-single-property-change
6686 'next-single-property-change))
6687 (inhibit-point-motion-hooks t)
6689 (limit (if (< n 0) (point-min) (point-max))))
6691 (while (and (not (= limit (point)))
6693 ;; Skip past the current button.
6694 (when (get-text-property (point) 'gnus-callback)
6695 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6696 ;; Go to the next (or previous) button.
6697 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
6698 ;; Put point at the start of the button.
6699 (when (and backward (not (get-text-property (point) 'gnus-callback)))
6700 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6701 ;; Skip past intangible buttons.
6702 (when (get-text-property (point) 'intangible)
6706 (gnus-message 5 "No more buttons"))
6709 (defun gnus-article-highlight (&optional force)
6710 "Highlight current article.
6711 This function calls `gnus-article-highlight-headers',
6712 `gnus-article-highlight-citation',
6713 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6714 do the highlighting. See the documentation for those functions."
6715 (interactive (list 'force))
6716 (gnus-article-highlight-headers)
6717 (gnus-article-highlight-citation force)
6718 (gnus-article-highlight-signature)
6719 (gnus-article-add-buttons force)
6720 (gnus-article-add-buttons-to-head))
6722 (defun gnus-article-highlight-some (&optional force)
6723 "Highlight current article.
6724 This function calls `gnus-article-highlight-headers',
6725 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6726 do the highlighting. See the documentation for those functions."
6727 (interactive (list 'force))
6728 (gnus-article-highlight-headers)
6729 (gnus-article-highlight-signature)
6730 (gnus-article-add-buttons))
6732 (defun gnus-article-highlight-headers ()
6733 "Highlight article headers as specified by `gnus-header-face-alist'."
6736 (set-buffer gnus-article-buffer)
6738 (let ((alist gnus-header-face-alist)
6739 (buffer-read-only nil)
6740 (case-fold-search t)
6741 (inhibit-point-motion-hooks t)
6742 entry regexp header-face field-face from hpoints fpoints)
6743 (article-narrow-to-head)
6744 (while (setq entry (pop alist))
6745 (goto-char (point-min))
6746 (setq regexp (concat "^\\("
6747 (if (string-equal "" (nth 0 entry))
6751 header-face (nth 1 entry)
6752 field-face (nth 2 entry))
6753 (while (and (re-search-forward regexp nil t)
6757 (unless (search-forward ":" nil t)
6759 (when (and header-face
6760 (not (memq (point) hpoints)))
6761 (push (point) hpoints)
6762 (gnus-put-text-property from (point) 'face header-face))
6763 (when (and field-face
6764 (not (memq (setq from (point)) fpoints)))
6766 (if (re-search-forward "^[^ \t]" nil t)
6768 (goto-char (point-max)))
6769 (gnus-put-text-property from (point) 'face field-face))))))))
6771 (defun gnus-article-highlight-signature ()
6772 "Highlight the signature in an article.
6773 It does this by highlighting everything after
6774 `gnus-signature-separator' using `gnus-signature-face'."
6776 (when gnus-signature-face
6778 (set-buffer gnus-article-buffer)
6779 (let ((buffer-read-only nil)
6780 (inhibit-point-motion-hooks t))
6782 (when (gnus-article-narrow-to-signature)
6783 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6784 'face gnus-signature-face)))))))
6786 (defun gnus-article-buttonize-signature ()
6787 "Add button to the signature."
6790 (set-buffer gnus-article-buffer)
6791 (let ((buffer-read-only nil)
6792 (inhibit-point-motion-hooks t))
6793 (when (gnus-article-search-signature)
6794 (gnus-article-add-button (match-beginning 0) (match-end 0)
6795 'gnus-signature-toggle
6796 (set-marker (make-marker)
6797 (1+ (match-end 0))))))))
6799 (defun gnus-button-in-region-p (b e prop)
6800 "Say whether PROP exists in the region."
6801 (text-property-not-all b e prop nil))
6803 (defun gnus-article-add-buttons (&optional force)
6804 "Find external references in the article and make buttons of them.
6805 \"External references\" are things like Message-IDs and URLs, as
6806 specified by `gnus-button-alist'."
6807 (interactive (list 'force))
6809 (set-buffer gnus-article-buffer)
6810 (let ((buffer-read-only nil)
6811 (inhibit-point-motion-hooks t)
6812 (case-fold-search t)
6813 (alist gnus-button-alist)
6815 ;; Remove all old markers.
6816 (let (marker entry new-list)
6817 (while (setq marker (pop gnus-button-marker-list))
6818 (if (or (< marker (point-min)) (>= marker (point-max)))
6819 (push marker new-list)
6821 (when (setq entry (gnus-button-entry))
6822 (put-text-property (match-beginning (nth 1 entry))
6823 (match-end (nth 1 entry))
6824 'gnus-callback nil))
6825 (set-marker marker nil)))
6826 (setq gnus-button-marker-list new-list))
6827 ;; We skip the headers.
6830 (while (setq entry (pop alist))
6831 (setq regexp (eval (car entry)))
6833 (while (re-search-forward regexp nil t)
6834 (let* ((start (and entry (match-beginning (nth 1 entry))))
6835 (end (and entry (match-end (nth 1 entry))))
6836 (from (match-beginning 0)))
6837 (when (and (or (eq t (nth 2 entry))
6838 (eval (nth 2 entry)))
6839 (not (gnus-button-in-region-p
6840 start end 'gnus-callback)))
6841 ;; That optional form returned non-nil, so we add the
6843 (gnus-article-add-button
6844 start end 'gnus-button-push
6845 (car (push (set-marker (make-marker) from)
6846 gnus-button-marker-list))))))))))
6848 ;; Add buttons to the head of an article.
6849 (defun gnus-article-add-buttons-to-head ()
6850 "Add buttons to the head of the article."
6853 (set-buffer gnus-article-buffer)
6855 (let ((buffer-read-only nil)
6856 (inhibit-point-motion-hooks t)
6857 (case-fold-search t)
6858 (alist gnus-header-button-alist)
6860 (article-narrow-to-head)
6862 ;; Each alist entry.
6863 (setq entry (car alist)
6865 (goto-char (point-min))
6866 (while (re-search-forward (car entry) nil t)
6867 ;; Each header matching the entry.
6868 (setq beg (match-beginning 0))
6869 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6870 (match-beginning 0))
6873 (while (re-search-forward (eval (nth 1 entry)) end t)
6874 ;; Each match within a header.
6875 (let* ((entry (cdr entry))
6876 (start (match-beginning (nth 1 entry)))
6877 (end (match-end (nth 1 entry)))
6878 (form (nth 2 entry)))
6879 (goto-char (match-end 0))
6881 (gnus-article-add-button
6882 start end (nth 3 entry)
6883 (buffer-substring (match-beginning (nth 4 entry))
6884 (match-end (nth 4 entry)))))))
6885 (goto-char end)))))))
6887 ;;; External functions:
6889 (defun gnus-article-add-button (from to fun &optional data)
6890 "Create a button between FROM and TO with callback FUN and data DATA."
6891 (when gnus-article-button-face
6892 (gnus-overlay-put (gnus-make-overlay from to)
6893 'face gnus-article-button-face))
6894 (gnus-add-text-properties
6896 (nconc (and gnus-article-mouse-face
6897 (list gnus-mouse-face-prop gnus-article-mouse-face))
6898 (list 'gnus-callback fun)
6899 (and data (list 'gnus-data data))))
6900 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6901 ;; Quote `:button-keymap' for Mule 2.3
6902 ;; but it won't work.
6903 ':button-keymap gnus-widget-button-keymap))
6905 ;;; Internal functions:
6907 (defun gnus-article-set-globals ()
6909 (set-buffer gnus-summary-buffer)
6910 (gnus-set-global-variables)))
6912 (defun gnus-signature-toggle (end)
6914 (set-buffer gnus-article-buffer)
6915 (let ((buffer-read-only nil)
6916 (inhibit-point-motion-hooks t)
6917 (limit (next-single-property-change end 'mime-view-entity
6919 (if (text-property-any end limit 'article-type 'signature)
6921 (gnus-delete-wash-type 'signature)
6922 (gnus-remove-text-properties-when
6923 'article-type 'signature end limit
6924 (cons 'article-type (cons 'signature
6925 gnus-hidden-properties))))
6926 (gnus-add-wash-type 'signature)
6927 (gnus-add-text-properties-when
6928 'article-type nil end limit
6929 (cons 'article-type (cons 'signature
6930 gnus-hidden-properties)))))
6931 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6932 (gnus-set-mode-line 'article))))
6934 (defun gnus-button-entry ()
6935 ;; Return the first entry in `gnus-button-alist' matching this place.
6936 (let ((alist gnus-button-alist)
6939 (setq entry (pop alist))
6940 (if (looking-at (eval (car entry)))
6945 (defun gnus-button-push (marker)
6946 ;; Push button starting at MARKER.
6949 (let* ((entry (gnus-button-entry))
6950 (inhibit-point-motion-hooks t)
6952 (args (mapcar (lambda (group)
6953 (let ((string (match-string group)))
6954 (gnus-set-text-properties
6955 0 (length string) nil string)
6962 (fboundp (symbol-value fun)))
6963 (apply (symbol-value fun) args))
6965 (gnus-message 1 "You must define `%S' to use this button"
6966 (cons fun args)))))))
6968 (defun gnus-parse-news-url (url)
6969 (let (scheme server group message-id articles)
6972 (goto-char (point-min))
6973 (when (looking-at "\\([A-Za-z]+\\):")
6974 (setq scheme (match-string 1))
6975 (goto-char (match-end 0)))
6976 (when (looking-at "//\\([^/]+\\)/")
6977 (setq server (match-string 1))
6978 (goto-char (match-end 0)))
6981 ((looking-at "\\(.*@.*\\)")
6982 (setq message-id (match-string 1)))
6983 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6984 (setq group (match-string 1)
6985 articles (split-string (match-string 2) "-")))
6986 ((looking-at "\\([^/]+\\)/?")
6987 (setq group (match-string 1)))
6989 (error "Unknown news URL syntax"))))
6990 (list scheme server group message-id articles)))
6992 (defun gnus-button-handle-news (url)
6994 (destructuring-bind (scheme server group message-id articles)
6995 (gnus-parse-news-url url)
6999 (set-buffer gnus-summary-buffer)
7001 (let ((gnus-refer-article-method (list (list 'nntp server))))
7002 (gnus-summary-refer-article message-id))
7003 (gnus-summary-refer-article message-id))))
7005 (gnus-button-fetch-group url)))))
7007 (defun gnus-button-handle-man (url)
7009 (funcall gnus-button-man-handler url))
7011 (defun gnus-button-handle-info-url (url)
7012 "Fetch an info URL."
7014 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
7015 (gnus-info-find-node
7016 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
7018 ")" (gnus-url-unhex-string (match-string 2 url)))))
7019 ((string-match "([^)\"]+)[^\"]+" url)
7021 (gnus-replace-in-string
7022 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
7023 (gnus-info-find-node url))
7024 (t (error "Can't parse %s" url))))
7026 (defun gnus-button-handle-info-keystrokes (url)
7027 "Call `info' when pushing the corresponding URL button."
7028 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
7033 (defun gnus-button-message-id (message-id)
7036 (set-buffer gnus-summary-buffer)
7037 (gnus-summary-refer-article message-id)))
7039 (defun gnus-button-fetch-group (address)
7040 "Fetch GROUP specified by ADDRESS."
7041 (if (not (string-match "[:/]" address))
7042 ;; This is just a simple group url.
7043 (gnus-group-read-ephemeral-group address gnus-select-method)
7046 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
7048 (error "Can't parse %s" address)
7049 (gnus-group-read-ephemeral-group
7050 (match-string 4 address)
7051 `(nntp ,(match-string 1 address)
7052 (nntp-address ,(match-string 1 address))
7053 (nntp-port-number ,(if (match-end 3)
7054 (match-string 3 address)
7057 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
7059 (defun gnus-url-parse-query-string (query &optional downcase)
7060 (let (retval pairs cur key val)
7061 (setq pairs (split-string query "&"))
7063 (setq cur (car pairs)
7065 (if (not (string-match "=" cur))
7067 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
7068 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
7070 (setq key (downcase key)))
7071 (setq cur (assoc key retval))
7073 (setcdr cur (cons val (cdr cur)))
7074 (setq retval (cons (list key val) retval)))))
7077 (defun gnus-url-mailto (url)
7078 ;; Send mail to someone
7079 (when (string-match "mailto:/*\\(.*\\)" url)
7080 (setq url (substring url (match-beginning 1) nil)))
7081 (let (to args subject func)
7082 (if (string-match (regexp-quote "?") url)
7083 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
7084 args (gnus-url-parse-query-string
7085 (substring url (match-end 0) nil) t))
7086 (setq to (gnus-url-unhex-string url)))
7087 (setq args (cons (list "to" to) args)
7088 subject (cdr-safe (assoc "subject" args)))
7091 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
7094 (message-position-on-field (caar args)))
7095 (insert (mapconcat 'identity (cdar args) ", "))
7096 (setq args (cdr args)))
7099 (message-goto-subject))))
7101 (defun gnus-button-embedded-url (address)
7102 "Activate ADDRESS with `browse-url'."
7103 (browse-url (gnus-strip-whitespace address)))
7105 ;;; Next/prev buttons in the article buffer.
7107 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
7108 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
7110 (defvar gnus-prev-page-map
7111 (let ((map (make-sparse-keymap)))
7112 (unless (>= emacs-major-version 21)
7113 ;; XEmacs doesn't care.
7114 (set-keymap-parent map gnus-article-mode-map))
7115 (define-key map gnus-mouse-2 'gnus-button-prev-page)
7116 (define-key map "\r" 'gnus-button-prev-page)
7119 (defun gnus-insert-prev-page-button ()
7121 (buffer-read-only nil)
7122 (situation (get-text-property (point-min) 'mime-view-situation)))
7124 gnus-prev-page-line-format nil
7125 `(,@(gnus-local-map-property gnus-prev-page-map)
7127 gnus-callback gnus-article-button-prev-page
7128 article-type annotation
7129 mime-view-situation ,situation))
7130 (widget-convert-button
7132 ;; Exclude a newline.
7135 :action 'gnus-button-prev-page
7136 :button-keymap gnus-prev-page-map)))
7138 (defvar gnus-next-page-map
7139 (let ((map (make-sparse-keymap)))
7140 (unless (>= emacs-major-version 21)
7141 ;; XEmacs doesn't care.
7142 (set-keymap-parent map gnus-article-mode-map))
7143 (define-key map gnus-mouse-2 'gnus-button-next-page)
7144 (define-key map "\r" 'gnus-button-next-page)
7147 (defun gnus-button-next-page (&optional args more-args)
7148 "Go to the next page."
7150 (let ((win (selected-window)))
7151 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7152 (gnus-article-next-page)
7153 (select-window win)))
7155 (defun gnus-button-prev-page (&optional args more-args)
7156 "Go to the prev page."
7158 (let ((win (selected-window)))
7159 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7160 (gnus-article-prev-page)
7161 (select-window win)))
7163 (defun gnus-insert-next-page-button ()
7165 (buffer-read-only nil)
7166 (situation (get-text-property (point-min) 'mime-view-situation)))
7167 (gnus-eval-format gnus-next-page-line-format nil
7168 `(,@(gnus-local-map-property gnus-next-page-map)
7170 gnus-callback gnus-article-button-next-page
7171 article-type annotation
7172 mime-view-situation ,situation))
7173 (widget-convert-button
7175 ;; Exclude a newline.
7178 :action 'gnus-button-next-page
7179 :button-keymap gnus-next-page-map)))
7181 (defun gnus-article-button-next-page (arg)
7182 "Go to the next page."
7184 (let ((win (selected-window)))
7185 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7186 (gnus-article-next-page)
7187 (select-window win)))
7189 (defun gnus-article-button-prev-page (arg)
7190 "Go to the prev page."
7192 (let ((win (selected-window)))
7193 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7194 (gnus-article-prev-page)
7195 (select-window win)))
7197 (defvar gnus-decode-header-methods
7198 '(mail-decode-encoded-word-region)
7199 "List of methods used to decode headers.
7201 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7202 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
7203 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
7204 whose names match REGEXP.
7207 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7208 mail-decode-encoded-word-region
7209 (\"chinese\" . rfc1843-decode-region))
7212 (defvar gnus-decode-header-methods-cache nil)
7214 (defun gnus-multi-decode-header (start end)
7215 "Apply the functions from `gnus-encoded-word-methods' that match."
7216 (unless (and gnus-decode-header-methods-cache
7217 (eq gnus-newsgroup-name
7218 (car gnus-decode-header-methods-cache)))
7219 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7222 (nconc gnus-decode-header-methods-cache (list x))
7223 (if (and gnus-newsgroup-name
7224 (string-match (car x) gnus-newsgroup-name))
7225 (nconc gnus-decode-header-methods-cache
7227 gnus-decode-header-methods))
7228 (let ((xlist gnus-decode-header-methods-cache))
7231 (narrow-to-region start end)
7233 (funcall (pop xlist) (point-min) (point-max))))))
7236 ;;; Treatment top-level handling.
7239 (defun gnus-treat-article (condition &optional part-number total-parts type)
7240 (let ((length (- (point-max) (point-min)))
7241 (alist gnus-treatment-function-alist)
7242 (article-goto-body-goes-to-point-min-p t)
7246 (let ((list gnus-article-treat-types))
7248 (when (string-match (pop list) type)
7249 (throw 'found t)))))))
7250 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7251 (entity (static-unless (featurep 'xemacs)
7252 (when (eq 'head condition)
7253 (get-text-property (point-min) 'mime-view-entity))))
7254 val elem buttonized)
7255 (gnus-run-hooks 'gnus-part-display-hook)
7256 (unless gnus-inhibit-treatment
7257 (dolist (elem alist)
7260 (when (gnus-buffer-live-p gnus-summary-buffer)
7261 (set-buffer gnus-summary-buffer))
7262 (symbol-value (car elem))))
7263 (when (and (or (consp val)
7265 (gnus-treat-predicate val)
7266 (or (not (get (car elem) 'highlight))
7268 (when (and (not buttonized)
7270 '(gnus-treat-hide-signature
7271 gnus-treat-highlight-signature)))
7272 (gnus-article-buttonize-signature)
7273 (setq buttonized t))
7275 (funcall (cadr elem)))))
7276 ;; FSF Emacsen does not inherit the existing text properties
7277 ;; in the new text, so we should do it for `mime-view-entity'.
7278 (static-unless (featurep 'xemacs)
7280 (put-text-property (point-min) (point-max)
7281 'mime-view-entity entity))))))
7283 ;; Dynamic variables.
7285 (defvar part-number)
7286 (defvar total-parts)
7291 (defun gnus-treat-predicate (val)
7296 (stringp (car val)))
7297 (apply 'gnus-or (mapcar `(lambda (s)
7298 (string-match s ,(or gnus-newsgroup-name "")))
7301 (let ((pred (pop val)))
7304 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7306 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7308 (not (gnus-treat-predicate (car val))))
7310 (equal (car val) type))
7312 (error "%S is not a valid predicate" pred)))))
7322 (eq part-number total-parts))
7326 (error "%S is not a valid value" val))))
7328 (defun gnus-article-encrypt-body (protocol &optional n)
7329 "Encrypt the article body."
7332 (or gnus-article-encrypt-protocol
7333 (completing-read "Encrypt protocol: "
7334 gnus-article-encrypt-protocol-alist
7336 current-prefix-arg))
7337 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7339 (error (format "Can't find the encrypt protocol %s" protocol)))
7340 (if (member gnus-newsgroup-name '("nndraft:delayed"
7343 (error "Can't encrypt the article in group %s"
7344 gnus-newsgroup-name))
7345 (gnus-summary-iterate n
7347 (set-buffer gnus-summary-buffer)
7348 (let ((mail-parse-charset gnus-newsgroup-charset)
7349 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7350 (summary-buffer gnus-summary-buffer)
7352 (gnus-set-global-variables)
7353 (when (gnus-group-read-only-p)
7354 (error "The current newsgroup does not support article encrypt"))
7355 (gnus-summary-show-article t)
7357 (or (mail-header-references gnus-current-headers) ""))
7358 (set-buffer gnus-article-buffer)
7359 (let* ((buffer-read-only nil)
7361 (mapcar (lambda (field)
7362 (and (save-restriction
7363 (message-narrow-to-head)
7364 (goto-char (point-min))
7365 (search-forward field nil t))
7367 (message-narrow-to-field)
7369 (delete-region (point-min) (point-max))
7371 '("Content-Type:" "Content-Transfer-Encoding:"
7372 "Content-Disposition:"))))
7373 (message-narrow-to-head)
7374 (message-remove-header "MIME-Version")
7375 (goto-char (point-max))
7376 (setq point (point))
7377 (insert (apply 'concat headers))
7379 (narrow-to-region point (point-max))
7380 (let ((message-options message-options))
7381 (message-options-set 'message-sender user-mail-address)
7382 (message-options-set 'message-recipients user-mail-address)
7383 (message-options-set 'message-sign-encrypt 'not)
7385 (goto-char (point-min))
7386 (insert "MIME-Version: 1.0\n")
7388 (gnus-summary-edit-article-done
7389 references nil summary-buffer t))
7390 (when gnus-keep-backlog
7391 (gnus-backlog-remove-article
7392 (car gnus-article-current) (cdr gnus-article-current)))
7394 (when (get-buffer gnus-original-article-buffer)
7395 (set-buffer gnus-original-article-buffer)
7396 (setq gnus-original-article nil)))
7397 (when gnus-use-cache
7398 (gnus-cache-update-article
7399 (car gnus-article-current) (cdr gnus-article-current))))))))
7401 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7402 "The following specs can be used:
7403 %t The security MIME type
7406 %D Details if button is pressed")
7408 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7409 "The following specs can be used:
7410 %t The security MIME type
7413 %D Details if button is pressed")
7415 (defvar gnus-mime-security-button-line-format-alist
7416 '((?t gnus-tmp-type ?s)
7417 (?i gnus-tmp-info ?s)
7418 (?d gnus-tmp-details ?s)
7419 (?D gnus-tmp-pressed-details ?s)))
7421 (defvar gnus-mime-security-button-map
7422 (let ((map (make-sparse-keymap)))
7423 (unless (>= (string-to-number emacs-version) 21)
7424 (set-keymap-parent map gnus-article-mode-map))
7425 (define-key map gnus-mouse-2 'gnus-article-push-button)
7426 (define-key map "\r" 'gnus-article-press-button)
7429 (defvar gnus-mime-security-details-buffer nil)
7431 (defvar gnus-mime-security-button-pressed nil)
7433 (defvar gnus-mime-security-show-details-inline t
7434 "If non-nil, show details in the article buffer.")
7436 (defun gnus-mime-security-verify-or-decrypt (handle)
7437 (mm-remove-parts (cdr handle))
7438 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7439 point buffer-read-only)
7441 (goto-char (car region)))
7443 (narrow-to-region (point) (point))
7444 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7445 (let* ((mm-verify-option 'known)
7446 (mm-decrypt-option 'known)
7447 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7448 (unless (eq nparts (cdr handle))
7449 (mm-destroy-parts (cdr handle))
7450 (setcdr handle nparts))))
7451 (setq point (point))
7452 (gnus-mime-display-security handle)
7453 (goto-char (point-max)))
7455 (delete-region (point) (cdr region))
7456 (set-marker (car region) nil)
7457 (set-marker (cdr region) nil))
7460 (defun gnus-mime-security-show-details (handle)
7461 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7463 (gnus-message 5 "No details.")
7464 (if gnus-mime-security-show-details-inline
7465 (let ((gnus-mime-security-button-pressed
7466 (not (get-text-property (point) 'gnus-mime-details)))
7467 (gnus-mime-security-button-line-format
7468 (get-text-property (point) 'gnus-line-format))
7471 (while (eq (get-text-property (point) 'gnus-line-format)
7472 gnus-mime-security-button-line-format)
7476 (narrow-to-region (point) (point))
7477 (gnus-insert-mime-security-button handle))
7478 (delete-region (point)
7479 (or (text-property-not-all
7482 gnus-mime-security-button-line-format)
7485 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7486 (with-current-buffer gnus-mime-security-details-buffer
7489 (setq gnus-mime-security-details-buffer
7490 (gnus-get-buffer-create "*MIME Security Details*")))
7491 (with-current-buffer gnus-mime-security-details-buffer
7493 (goto-char (point-min)))
7494 (pop-to-buffer gnus-mime-security-details-buffer)))))
7496 (defun gnus-mime-security-press-button (handle)
7498 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7499 (gnus-mime-security-show-details handle)
7500 (gnus-mime-security-verify-or-decrypt handle))))
7502 (defun gnus-insert-mime-security-button (handle &optional displayed)
7503 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7506 (or (nth 2 (assoc protocol mm-verify-function-alist))
7507 (nth 2 (assoc protocol mm-decrypt-function-alist))
7509 (if (equal (car handle) "multipart/signed")
7510 " Signed" " Encrypted")
7513 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7516 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7517 gnus-tmp-pressed-details
7519 (setq gnus-tmp-details
7520 (if gnus-tmp-details
7521 (concat "\n" gnus-tmp-details)
7523 (setq gnus-tmp-pressed-details
7524 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7529 gnus-mime-security-button-line-format
7530 gnus-mime-security-button-line-format-alist
7531 `(,@(gnus-local-map-property gnus-mime-security-button-map)
7532 gnus-callback gnus-mime-security-press-button
7533 gnus-line-format ,gnus-mime-security-button-line-format
7534 gnus-mime-details ,gnus-mime-security-button-pressed
7535 article-type annotation
7538 ;; Exclude a newline.
7541 (widget-convert-button
7544 :action 'gnus-widget-press-button
7545 :button-keymap gnus-mime-security-button-map
7547 (lambda (widget/window &optional overlay pos)
7548 ;; Needed to properly clear the message due to a bug in
7549 ;; wid-edit (XEmacs only).
7550 (when (boundp 'help-echo-owns-message)
7551 (setq help-echo-owns-message t))
7554 (aref gnus-mouse-2 0))))))
7556 (defun gnus-mime-display-security (handle)
7558 (narrow-to-region (point) (point))
7559 (unless (gnus-unbuttonized-mime-type-p (car handle))
7560 (gnus-insert-mime-security-button handle))
7561 (gnus-mime-display-mixed (cdr handle))
7564 (unless (gnus-unbuttonized-mime-type-p (car handle))
7565 (let ((gnus-mime-security-button-line-format
7566 gnus-mime-security-button-end-line-format))
7567 (gnus-insert-mime-security-button handle)))
7568 (mm-set-handle-multipart-parameter
7570 (cons (set-marker (make-marker) (point-min))
7571 (set-marker (make-marker) (point-max))))))
7577 (defun gnus-article-header-presentation-method (entity situation)
7578 (mime-insert-header entity)
7579 (article-decode-group-name))
7581 (set-alist 'mime-header-presentation-method-alist
7582 'gnus-original-article-mode
7583 #'gnus-article-header-presentation-method)
7585 (defun gnus-mime-preview-quitting-method ()
7586 (mime-preview-kill-buffer)
7587 (delete-other-windows)
7588 (gnus-article-show-summary)
7589 (gnus-summary-select-article gnus-show-all-headers t))
7591 (set-alist 'mime-preview-quitting-method-alist
7592 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
7594 (set-alist 'mime-preview-following-method-alist
7595 'gnus-original-article-mode #'gnus-following-method)
7597 (set-alist 'mime-preview-over-to-previous-method-alist
7598 'gnus-original-article-mode
7600 (if (> (point-min) 1)
7601 (gnus-article-prev-page)
7602 (gnus-article-read-summary-keys
7603 nil (gnus-character-to-event ?P)))))
7605 (set-alist 'mime-preview-over-to-next-method-alist
7606 'gnus-original-article-mode'
7608 (if (< (point-max) (buffer-size))
7609 (gnus-article-next-page)
7610 (gnus-article-read-summary-keys
7611 nil (gnus-character-to-event ?N)))))
7621 (run-hooks 'gnus-art-load-hook)
7623 ;;; gnus-art.el ends here