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 non-graphical
257 ;; 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 (executable-find idna-program))
1438 "Whether IDNA decoding of headers is used when viewing messages.
1439 This requires GNU Libidn, and by default only enabled if it is found."
1440 :group 'gnus-article-headers
1443 (defcustom gnus-article-over-scroll nil
1444 "If non-nil, allow scrolling the article buffer even when there no more text."
1445 :group 'gnus-article
1448 ;;; Internal variables
1450 (defvar gnus-english-month-names
1451 '("January" "February" "March" "April" "May" "June" "July" "August"
1452 "September" "October" "November" "December"))
1454 (defvar article-goto-body-goes-to-point-min-p nil)
1455 (defvar gnus-article-wash-types nil)
1456 (defvar gnus-article-emphasis-alist nil)
1457 (defvar gnus-article-image-alist nil)
1459 (defvar gnus-article-mime-handle-alist-1 nil)
1460 (defvar gnus-treatment-function-alist
1461 '((gnus-treat-decode-article-as-default-mime-charset
1462 gnus-article-decode-article-as-default-mime-charset)
1463 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1464 (gnus-treat-monafy gnus-article-monafy)
1465 (gnus-treat-strip-banner gnus-article-strip-banner)
1466 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1467 (gnus-treat-buttonize gnus-article-add-buttons)
1468 (gnus-treat-fill-article gnus-article-fill-cited-article)
1469 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1470 (gnus-treat-strip-cr gnus-article-remove-cr)
1471 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1472 (gnus-treat-date-ut gnus-article-date-ut)
1473 (gnus-treat-date-local gnus-article-date-local)
1474 (gnus-treat-date-english gnus-article-date-english)
1475 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1476 (gnus-treat-date-original gnus-article-date-original)
1477 (gnus-treat-date-user-defined gnus-article-date-user)
1478 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1479 (gnus-treat-display-face gnus-article-display-face)
1480 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1481 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1482 (gnus-treat-hide-signature gnus-article-hide-signature)
1483 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1484 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1485 (gnus-treat-strip-pem gnus-article-hide-pem)
1486 (gnus-treat-from-picon gnus-treat-from-picon)
1487 (gnus-treat-mail-picon gnus-treat-mail-picon)
1488 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1489 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1490 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1491 (gnus-treat-strip-trailing-blank-lines
1492 gnus-article-remove-trailing-blank-lines)
1493 (gnus-treat-strip-leading-blank-lines
1494 gnus-article-strip-leading-blank-lines)
1495 (gnus-treat-strip-multiple-blank-lines
1496 gnus-article-strip-multiple-blank-lines)
1497 (gnus-treat-overstrike gnus-article-treat-overstrike)
1498 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1499 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1500 ;; Displaying X-Face should be done after unfolding headers
1501 ;; to protect bitmap lines.
1502 (gnus-treat-display-xface gnus-article-display-x-face)
1503 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1504 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1505 (gnus-treat-display-smileys gnus-treat-smiley)
1506 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1507 (gnus-treat-wash-html gnus-article-wash-html)
1508 (gnus-treat-emphasize gnus-article-emphasize)
1509 (gnus-treat-hide-citation gnus-article-hide-citation)
1510 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1511 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1512 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1513 (gnus-treat-play-sounds gnus-earcon-display)))
1515 (defvar gnus-article-mime-handle-alist nil)
1516 (defvar article-lapsed-timer nil)
1517 (defvar gnus-article-current-summary nil)
1519 (defvar gnus-article-mode-syntax-table
1520 (let ((table (copy-syntax-table text-mode-syntax-table)))
1521 ;; This causes the citation match run O(2^n).
1522 ;; (modify-syntax-entry ?- "w" table)
1523 (modify-syntax-entry ?> ")<" table)
1524 (modify-syntax-entry ?< "(>" table)
1525 ;; make M-. in article buffers work for `foo' strings
1526 (modify-syntax-entry ?' " " table)
1527 (modify-syntax-entry ?` " " table)
1529 "Syntax table used in article mode buffers.
1530 Initialized from `text-mode-syntax-table.")
1532 (defvar gnus-save-article-buffer nil)
1534 (defvar gnus-article-mode-line-format-alist
1535 (nconc '((?w (gnus-article-wash-status) ?s)
1536 (?m (gnus-article-mime-part-status) ?s))
1537 gnus-summary-mode-line-format-alist))
1539 (defvar gnus-number-of-articles-to-be-saved nil)
1541 (defvar gnus-inhibit-hiding nil)
1543 ;;; Macros for dealing with the article buffer.
1545 (defmacro gnus-with-article-headers (&rest forms)
1547 (set-buffer gnus-article-buffer)
1549 (let ((buffer-read-only nil)
1550 (inhibit-point-motion-hooks t)
1551 (case-fold-search t))
1552 (article-narrow-to-head)
1555 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1556 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1558 (defmacro gnus-with-article-buffer (&rest forms)
1560 (set-buffer gnus-article-buffer)
1561 (let ((buffer-read-only nil))
1564 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1565 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1567 (defun gnus-article-goto-header (header)
1568 "Go to HEADER, which is a regular expression."
1569 (re-search-forward (concat "^\\(" header "\\):") nil t))
1571 (defsubst gnus-article-hide-text (b e props)
1572 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1573 (gnus-add-text-properties-when 'article-type nil b e props)
1574 (when (memq 'intangible props)
1576 (max (1- b) (point-min))
1577 b 'intangible (cddr (memq 'intangible props)))))
1579 (defsubst gnus-article-unhide-text (b e)
1580 "Remove hidden text properties from region between B and E."
1581 (remove-text-properties b e gnus-hidden-properties)
1582 (when (memq 'intangible gnus-hidden-properties)
1583 (put-text-property (max (1- b) (point-min))
1584 b 'intangible nil)))
1586 (defun gnus-article-hide-text-type (b e type)
1587 "Hide text of TYPE between B and E."
1588 (gnus-add-wash-type type)
1589 (gnus-article-hide-text
1590 b e (cons 'article-type (cons type gnus-hidden-properties))))
1592 (defun gnus-article-unhide-text-type (b e type)
1593 "Unhide text of TYPE between B and E."
1594 (gnus-delete-wash-type type)
1595 (remove-text-properties
1596 b e (cons 'article-type (cons type gnus-hidden-properties)))
1597 (when (memq 'intangible gnus-hidden-properties)
1598 (put-text-property (max (1- b) (point-min))
1599 b 'intangible nil)))
1601 (defun gnus-article-hide-text-of-type (type)
1602 "Hide text of TYPE in the current buffer."
1604 (let ((b (point-min))
1606 (while (setq b (text-property-any b e 'article-type type))
1607 (add-text-properties b (incf b) gnus-hidden-properties)))))
1609 (defun gnus-article-delete-text-of-type (type)
1610 "Delete text of TYPE in the current buffer."
1612 (let ((b (point-min)))
1613 (while (setq b (text-property-any b (point-max) 'article-type type))
1615 b (or (text-property-not-all b (point-max) 'article-type type)
1618 (defun gnus-article-delete-invisible-text ()
1619 "Delete all invisible text in the current buffer."
1621 (let ((b (point-min)))
1622 (while (setq b (text-property-any b (point-max) 'invisible t))
1624 b (or (text-property-not-all b (point-max) 'invisible t)
1627 (defun gnus-article-text-type-exists-p (type)
1628 "Say whether any text of type TYPE exists in the buffer."
1629 (text-property-any (point-min) (point-max) 'article-type type))
1631 (defsubst gnus-article-header-rank ()
1632 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1633 (let ((list gnus-sorted-header-list)
1636 (if (looking-at (car list))
1638 (setq list (cdr list))
1642 (defun article-hide-headers (&optional arg delete)
1643 "Hide unwanted headers and possibly sort them as well."
1644 (interactive (gnus-article-hidden-arg))
1645 ;; Lars said that this function might be inhibited.
1646 (if (gnus-article-check-hidden-text 'headers arg)
1648 ;; Show boring headers as well.
1649 (gnus-article-show-hidden-text 'boring-headers)
1650 (when (eq 1 (point-min))
1651 (set-window-start (get-buffer-window (current-buffer)) 1)))
1652 (unless gnus-inhibit-hiding
1655 (let ((inhibit-read-only t)
1656 (case-fold-search t)
1657 (max (1+ (length gnus-sorted-header-list)))
1658 (ignored (when (not gnus-visible-headers)
1659 (cond ((stringp gnus-ignored-headers)
1660 gnus-ignored-headers)
1661 ((listp gnus-ignored-headers)
1662 (mapconcat 'identity gnus-ignored-headers
1665 (cond ((stringp gnus-visible-headers)
1666 gnus-visible-headers)
1667 ((and gnus-visible-headers
1668 (listp gnus-visible-headers))
1669 (mapconcat 'identity gnus-visible-headers "\\|"))))
1670 (inhibit-point-motion-hooks t)
1672 ;; First we narrow to just the headers.
1673 (article-narrow-to-head)
1674 ;; Hide any "From " lines at the beginning of (mail) articles.
1675 (while (looking-at "From ")
1679 (delete-region (point-min) (point))
1680 (gnus-article-hide-text (point-min) (point)
1681 (nconc (list 'article-type 'headers)
1682 gnus-hidden-properties))))
1683 ;; Then treat the rest of the header lines.
1684 ;; Then we use the two regular expressions
1685 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1686 ;; select which header lines is to remain visible in the
1688 (while (re-search-forward "^[^ \t:]*:" nil t)
1690 ;; Mark the rank of the header.
1692 (point) (1+ (point)) 'message-rank
1693 (if (or (and visible (looking-at visible))
1695 (not (looking-at ignored))))
1696 (gnus-article-header-rank)
1699 (message-sort-headers-1)
1700 (when (setq beg (text-property-any
1701 (point-min) (point-max) 'message-rank (+ 2 max)))
1702 ;; We delete or make invisible the unwanted headers.
1703 (gnus-add-wash-type 'headers)
1706 (add-text-properties
1707 (point-min) (+ 5 (point-min))
1708 '(article-type headers dummy-invisible t))
1709 (delete-region beg (point-max)))
1710 (gnus-article-hide-text-type beg (point-max) 'headers)))))))))
1712 (defun article-hide-boring-headers (&optional arg)
1713 "Toggle hiding of headers that aren't very interesting.
1714 If given a negative prefix, always show; if given a positive prefix,
1716 (interactive (gnus-article-hidden-arg))
1717 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1718 (not gnus-show-all-headers))
1721 (let ((buffer-read-only nil)
1722 (list gnus-boring-article-headers)
1723 (inhibit-point-motion-hooks t)
1725 (article-narrow-to-head)
1727 (setq elem (pop list))
1728 (goto-char (point-min))
1730 ;; Hide empty headers.
1732 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1734 (gnus-article-hide-text-type
1738 (if (re-search-forward "^[^ \t]" nil t)
1742 ;; Hide boring Newsgroups header.
1743 ((eq elem 'newsgroups)
1744 (when (gnus-string-equal
1745 (gnus-fetch-field "newsgroups")
1746 (gnus-group-real-name
1747 (if (boundp 'gnus-newsgroup-name)
1750 (gnus-article-hide-header "newsgroups")))
1751 ((eq elem 'to-address)
1752 (let ((to (message-fetch-field "to"))
1754 (gnus-parameter-to-address
1755 (if (boundp 'gnus-newsgroup-name)
1756 gnus-newsgroup-name ""))))
1757 (when (and to to-address
1760 ;; only one address in To
1761 (nth 1 (mail-extract-address-components to))
1763 (gnus-article-hide-header "to"))))
1765 (let ((to (message-fetch-field "to"))
1767 (gnus-parameter-to-list
1768 (if (boundp 'gnus-newsgroup-name)
1769 gnus-newsgroup-name ""))))
1770 (when (and to to-list
1773 ;; only one address in To
1774 (nth 1 (mail-extract-address-components to))
1776 (gnus-article-hide-header "to"))))
1778 (let ((cc (message-fetch-field "cc"))
1780 (gnus-parameter-to-list
1781 (if (boundp 'gnus-newsgroup-name)
1782 gnus-newsgroup-name ""))))
1783 (when (and cc to-list
1786 ;; only one address in CC
1787 (nth 1 (mail-extract-address-components cc))
1789 (gnus-article-hide-header "cc"))))
1790 ((eq elem 'followup-to)
1791 (when (gnus-string-equal
1792 (message-fetch-field "followup-to")
1793 (message-fetch-field "newsgroups"))
1794 (gnus-article-hide-header "followup-to")))
1795 ((eq elem 'reply-to)
1796 (if (gnus-group-find-parameter
1797 gnus-newsgroup-name 'broken-reply-to)
1798 (gnus-article-hide-header "reply-to")
1799 (let ((from (message-fetch-field "from"))
1800 (reply-to (message-fetch-field "reply-to")))
1805 (nth 1 (mail-extract-address-components from))
1806 (nth 1 (mail-extract-address-components reply-to)))))
1807 (gnus-article-hide-header "reply-to")))))
1809 (let ((date (message-fetch-field "date")))
1811 (< (days-between (current-time-string) date)
1813 (gnus-article-hide-header "date"))))
1815 (let ((to (message-fetch-field "to"))
1816 (cc (message-fetch-field "cc")))
1817 (when (> (length to) 1024)
1818 (gnus-article-hide-header "to"))
1819 (when (> (length cc) 1024)
1820 (gnus-article-hide-header "cc"))))
1824 (goto-char (point-min))
1825 (while (re-search-forward "^to:" nil t)
1826 (setq to-count (1+ to-count)))
1827 (when (> to-count 1)
1828 (while (> to-count 0)
1829 (goto-char (point-min))
1831 (re-search-forward "^to:" nil nil to-count)
1833 (narrow-to-region (point) (point-max))
1834 (gnus-article-hide-header "to"))
1835 (setq to-count (1- to-count))))
1836 (goto-char (point-min))
1837 (while (re-search-forward "^cc:" nil t)
1838 (setq cc-count (1+ cc-count)))
1839 (when (> cc-count 1)
1840 (while (> cc-count 0)
1841 (goto-char (point-min))
1843 (re-search-forward "^cc:" nil nil cc-count)
1845 (narrow-to-region (point) (point-max))
1846 (gnus-article-hide-header "cc"))
1847 (setq cc-count (1- cc-count)))))))))))))
1849 (defun gnus-article-hide-header (header)
1851 (goto-char (point-min))
1852 (when (re-search-forward (concat "^" header ":") nil t)
1853 (gnus-article-hide-text-type
1857 (if (re-search-forward "^[^ \t]" nil t)
1862 (defvar gnus-article-normalized-header-length 40
1863 "Length of normalized headers.")
1865 (defun article-normalize-headers ()
1866 "Make all header lines 40 characters long."
1868 (let ((buffer-read-only nil)
1872 (article-narrow-to-head)
1875 ((< (setq column (- (gnus-point-at-eol) (point)))
1876 gnus-article-normalized-header-length)
1878 (insert (make-string
1879 (- gnus-article-normalized-header-length column)
1881 ((> column gnus-article-normalized-header-length)
1882 (gnus-put-text-property
1884 (forward-char gnus-article-normalized-header-length)
1891 (forward-line 1))))))
1893 (defun article-treat-dumbquotes ()
1894 "Translate M****s*** sm*rtq**t*s into proper text.
1895 Note that this function guesses whether a character is a sm*rtq**t* or
1896 not, so it should only be used interactively.
1898 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1899 in an attempt to provide more quoting characters. If you see
1900 something like \\222 or \\264 where you're expecting some kind of
1901 apostrophe or quotation mark, then try this wash."
1903 (article-translate-strings gnus-article-dumbquotes-map))
1905 (defun article-translate-characters (from to)
1906 "Translate all characters in the body of the article according to FROM and TO.
1907 FROM is a string of characters to translate from; to is a string of
1908 characters to translate to."
1910 (when (article-goto-body)
1911 (let ((buffer-read-only nil)
1912 (x (make-string 225 ?x))
1914 (while (< (incf i) (length x))
1917 (while (< i (length from))
1918 (aset x (aref from i) (aref to i))
1920 (translate-region (point) (point-max) x)))))
1922 (defun article-translate-strings (map)
1923 "Translate all string in the body of the article according to MAP.
1924 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1926 (when (article-goto-body)
1927 (let ((buffer-read-only nil)
1929 (while (setq elem (pop map))
1931 (while (search-forward (car elem) nil t)
1932 (replace-match (cadr elem)))))))))
1934 (defun article-treat-overstrike ()
1935 "Translate overstrikes into bold text."
1938 (when (article-goto-body)
1939 (let ((buffer-read-only nil))
1940 (while (search-forward "\b" nil t)
1941 (let ((next (char-after))
1945 previous (char-after))
1949 ;; We do the boldification/underlining by hiding the
1950 ;; overstrikes and putting the proper text property
1954 (gnus-article-hide-text-type start (point) 'overstrike)
1955 (put-text-property (point) end 'face 'bold))
1957 (gnus-article-hide-text-type
1958 (1- (point)) (1+ (point)) 'overstrike)
1960 start (1- (point)) 'face 'underline))
1962 (gnus-article-hide-text-type start (point) 'overstrike)
1964 (point) end 'face 'underline)))))))))
1966 (defun gnus-article-treat-unfold-headers ()
1967 "Unfold folded message headers.
1968 Only the headers that fit into the current window width will be
1971 (gnus-with-article-headers
1975 (mail-header-narrow-to-field)
1976 (let ((header (buffer-string)))
1979 (goto-char (point-min))
1980 (while (re-search-forward "\n[\t ]" nil t)
1981 (replace-match " " t t)))
1982 (setq length (- (point-max) (point-min) 1)))
1983 (when (< length (window-width))
1984 (while (re-search-forward "\n[\t ]" nil t)
1985 (replace-match " " t t)))
1986 (goto-char (point-max)))))))
1988 (defun gnus-article-treat-fold-headers ()
1989 "Fold message headers."
1991 (gnus-with-article-headers
1994 (mail-header-narrow-to-field)
1995 (mail-header-fold-field)
1996 (goto-char (point-max))))))
1998 (defun gnus-treat-smiley ()
1999 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2001 (unless (featurep 'xemacs)
2002 (when (and (>= emacs-major-version 21)
2003 (not gnus-article-should-use-smiley-mule)
2004 gnus-article-smiley-mule-loaded-p)
2005 (load "smiley" nil t)
2006 (setq gnus-article-smiley-mule-loaded-p nil))
2007 (when (and gnus-article-should-use-smiley-mule
2008 (not gnus-article-smiley-mule-loaded-p))
2009 (load "smiley-mule" nil t)
2010 (setq gnus-article-smiley-mule-loaded-p t)))
2011 (gnus-with-article-buffer
2012 (if (memq 'smiley gnus-article-wash-types)
2013 (gnus-delete-images 'smiley)
2015 (let ((images (smiley-region (point) (point-max))))
2017 (gnus-add-wash-type 'smiley)
2018 (dolist (image images)
2019 (gnus-add-image 'smiley image)))))))
2021 (defun gnus-article-remove-images ()
2022 "Remove all images from the article buffer."
2024 (gnus-with-article-buffer
2025 (dolist (elem gnus-article-image-alist)
2026 (gnus-delete-images (car elem)))))
2028 (defun gnus-article-treat-fold-newsgroups ()
2029 "Unfold folded message headers.
2030 Only the headers that fit into the current window width will be
2033 (gnus-with-article-headers
2034 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2036 (mail-header-narrow-to-field)
2037 (while (re-search-forward ", *" nil t)
2038 (replace-match ", " t t))
2039 (mail-header-fold-field)
2040 (goto-char (point-max))))))
2042 (defun gnus-article-treat-body-boundary ()
2043 "Place a boundary line at the end of the headers."
2045 (when (and gnus-body-boundary-delimiter
2046 (> (length gnus-body-boundary-delimiter) 0))
2047 (gnus-with-article-headers
2048 (goto-char (point-max))
2049 (let ((start (point)))
2050 (insert "X-Boundary: ")
2051 (gnus-add-text-properties start (point) '(invisible t intangible t))
2053 (while (>= (1- (window-width)) (length str))
2054 (setq str (concat str gnus-body-boundary-delimiter)))
2055 (substring str 0 (1- (window-width))))
2057 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2059 (defun article-fill-long-lines ()
2060 "Fill lines that are wider than the window width."
2063 (let ((buffer-read-only nil)
2064 (width (window-width (get-buffer-window (current-buffer)))))
2067 (let ((adaptive-fill-mode nil)) ;Why? -sm
2070 (when (>= (current-column) (min fill-column width))
2071 (narrow-to-region (min (1+ (point)) (point-max))
2072 (gnus-point-at-bol))
2073 (let ((goback (point-marker)))
2074 (fill-paragraph nil)
2075 (goto-char (marker-position goback)))
2077 (forward-line 1)))))))
2079 (defun article-capitalize-sentences ()
2080 "Capitalize the first word in each sentence."
2083 (let ((buffer-read-only nil)
2084 (paragraph-start "^[\n\^L]"))
2088 (forward-sentence)))))
2090 (defun article-remove-cr ()
2091 "Remove trailing CRs and then translate remaining CRs into LFs."
2094 (let ((buffer-read-only nil))
2095 (goto-char (point-min))
2096 (while (re-search-forward "\r+$" nil t)
2097 (replace-match "" t t))
2098 (goto-char (point-min))
2099 (while (search-forward "\r" nil t)
2100 (replace-match "\n" t t)))))
2102 (defun article-remove-trailing-blank-lines ()
2103 "Remove all trailing blank lines from the article."
2106 (let ((buffer-read-only nil))
2107 (goto-char (point-max))
2111 (while (and (not (bobp))
2112 (looking-at "^[ \t]*$")
2113 (not (gnus-annotation-in-region-p
2114 (point) (gnus-point-at-eol))))
2119 (defun article-display-face ()
2120 "Display any Face headers in the header."
2122 (let ((wash-face-p buffer-read-only))
2123 (gnus-with-article-headers
2124 ;; When displaying parts, this function can be called several times on
2125 ;; the same article, without any intended toggle semantic (as typing `W
2126 ;; D d' would have). So face deletion must occur only when we come from
2127 ;; an interactive command, that is when the *Article* buffer is
2129 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2130 (gnus-delete-images 'face)
2133 (when (and wash-face-p
2135 (goto-char (point-min))
2136 (not (re-search-forward "^Face:[\t ]*" nil t)))
2137 (gnus-buffer-live-p gnus-original-article-buffer))
2138 (set-buffer gnus-original-article-buffer))
2140 (mail-narrow-to-head)
2141 (while (gnus-article-goto-header "Face")
2142 (push (mail-header-field-value) faces))))
2143 (while (setq face (pop faces))
2144 (let ((png (gnus-convert-face-to-png face))
2147 (setq image (gnus-create-image png 'png t))
2148 (gnus-article-goto-header "from")
2150 (insert "From: [no `from' set]\n")
2152 (gnus-add-wash-type 'face)
2153 (gnus-add-image 'face image)
2154 (gnus-put-image image nil 'face))))))
2157 (defun article-display-x-face (&optional force)
2158 "Look for an X-Face header and display it if present."
2159 (interactive (list 'force))
2160 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2161 (gnus-with-article-headers
2162 ;; Delete the old process, if any.
2163 (when (process-status "article-x-face")
2164 (delete-process "article-x-face"))
2165 ;; See the comment in `article-display-face'.
2166 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2167 ;; We have already displayed X-Faces, so we remove them
2169 (gnus-delete-images 'xface)
2171 (let (x-faces from face)
2173 (when (and wash-face-p
2175 (goto-char (point-min))
2176 (not (re-search-forward
2177 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2178 (gnus-buffer-live-p gnus-original-article-buffer))
2179 ;; If type `W f', use gnus-original-article-buffer,
2180 ;; otherwise use the current buffer because displaying
2181 ;; RFC822 parts calls this function too.
2182 (set-buffer gnus-original-article-buffer))
2184 (mail-narrow-to-head)
2185 (while (gnus-article-goto-header "X-Face")
2186 (push (mail-header-field-value) x-faces))
2187 (setq from (message-fetch-field "from"))))
2188 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2189 ;; single external face.
2190 (when (stringp gnus-article-x-face-command)
2191 (setq x-faces (list (car x-faces))))
2192 (while (and (setq face (pop x-faces))
2193 gnus-article-x-face-command
2195 ;; Check whether this face is censored.
2196 (not gnus-article-x-face-too-ugly)
2197 (and gnus-article-x-face-too-ugly from
2198 (not (string-match gnus-article-x-face-too-ugly
2200 ;; We display the face.
2201 (if (symbolp gnus-article-x-face-command)
2202 ;; The command is a lisp function, so we call it.
2203 (if (functionp gnus-article-x-face-command)
2204 (funcall gnus-article-x-face-command face)
2205 (error "%s is not a function" gnus-article-x-face-command))
2206 ;; The command is a string, so we interpret the command
2207 ;; as a, well, command, and fork it off.
2208 (let ((process-connection-type nil))
2209 (process-kill-without-query
2211 "article-x-face" nil shell-file-name shell-command-switch
2212 gnus-article-x-face-command))
2215 (process-send-region "article-x-face"
2216 (point-min) (point-max)))
2217 (process-send-eof "article-x-face")))))))))
2219 (defun article-decode-mime-words ()
2220 "Decode all MIME-encoded words in the article."
2223 (set-buffer gnus-article-buffer)
2224 (let ((inhibit-point-motion-hooks t)
2226 (mail-parse-charset gnus-newsgroup-charset)
2227 (mail-parse-ignored-charsets
2228 (save-excursion (set-buffer gnus-summary-buffer)
2229 gnus-newsgroup-ignored-charsets)))
2230 (mail-decode-encoded-word-region (point-min) (point-max)))))
2232 (defun article-decode-charset (&optional prompt)
2233 "Decode charset-encoded text in the article.
2234 If PROMPT (the prefix), prompt for a coding system to use."
2236 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2238 (mail-parse-charset gnus-newsgroup-charset)
2239 (mail-parse-ignored-charsets
2240 (save-excursion (condition-case nil
2241 (set-buffer gnus-summary-buffer)
2243 gnus-newsgroup-ignored-charsets))
2244 ct cte ctl charset format)
2247 (article-narrow-to-head)
2248 (setq ct (message-fetch-field "Content-Type" t)
2249 cte (message-fetch-field "Content-Transfer-Encoding" t)
2250 ctl (and ct (ignore-errors
2251 (mail-header-parse-content-type ct)))
2254 (mm-read-coding-system "Charset to decode: "))
2256 (mail-content-type-get ctl 'charset)))
2257 format (and ctl (mail-content-type-get ctl 'format)))
2259 (setq cte (mail-header-strip cte)))
2260 (if (and ctl (not (string-match "/" (car ctl))))
2262 (goto-char (point-max)))
2265 (narrow-to-region (point) (point-max))
2266 (when (and (eq mail-parse-charset 'gnus-decoded)
2267 (eq (mm-body-7-or-8) '8bit))
2268 ;; The text code could have been decoded.
2269 (setq charset mail-parse-charset))
2270 (when (and (or (not ctl)
2271 (equal (car ctl) "text/plain"))
2272 (not format)) ;; article with format will decode later.
2274 charset (and cte (intern (downcase
2275 (gnus-strip-whitespace cte))))
2278 (defun article-decode-encoded-words ()
2279 "Remove encoded-word encoding from headers."
2280 (let (buffer-read-only)
2281 (let ((charset (save-excursion
2282 (set-buffer gnus-summary-buffer)
2283 default-mime-charset)))
2284 (mime-decode-header-in-buffer charset))))
2286 (defun article-decode-group-name ()
2287 "Decode group names in `Newsgroups:'."
2288 (let ((inhibit-point-motion-hooks t)
2290 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2291 (when (and (or gnus-group-name-charset-method-alist
2292 gnus-group-name-charset-group-alist)
2293 (gnus-buffer-live-p gnus-original-article-buffer))
2295 (article-narrow-to-head)
2296 (with-current-buffer gnus-original-article-buffer
2297 (goto-char (point-min)))
2298 (while (re-search-forward
2299 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2300 (replace-match (save-match-data
2301 (gnus-decode-newsgroups
2302 ;; XXX how to use data in article buffer?
2303 (with-current-buffer gnus-original-article-buffer
2305 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2308 gnus-newsgroup-name method))
2310 (goto-char (point-min))
2311 (with-current-buffer gnus-original-article-buffer
2312 (goto-char (point-min)))
2313 (while (re-search-forward
2314 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2315 (replace-match (save-match-data
2316 (gnus-decode-newsgroups
2317 ;; XXX how to use data in article buffer?
2318 (with-current-buffer gnus-original-article-buffer
2320 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2323 gnus-newsgroup-name method))
2326 (autoload 'idna-to-unicode "idna")
2328 (defun article-decode-idna-rhs ()
2329 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2332 (let ((inhibit-point-motion-hooks t)
2334 (article-narrow-to-head)
2335 (goto-char (point-min))
2336 (while (re-search-forward "\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2338 (when (save-match-data
2339 (and (setq ace (match-string 1))
2341 (and (re-search-backward "^[^ \t]" nil t)
2342 (looking-at "From\\|To\\|Cc")))
2343 (save-excursion (backward-char)
2344 (message-idna-inside-rhs-p))
2345 (setq unicode (idna-to-unicode ace))))
2346 (unless (string= ace unicode)
2347 (replace-match unicode nil nil nil 1)))))))))
2349 (defun article-de-quoted-unreadable (&optional force read-charset)
2350 "Translate a quoted-printable-encoded article.
2351 If FORCE, decode the article whether it is marked as quoted-printable
2353 If READ-CHARSET, ask for a coding system."
2354 (interactive (list 'force current-prefix-arg))
2356 (let ((buffer-read-only nil) type charset)
2357 (if (gnus-buffer-live-p gnus-original-article-buffer)
2358 (with-current-buffer gnus-original-article-buffer
2360 (gnus-fetch-field "content-transfer-encoding"))
2361 (let* ((ct (gnus-fetch-field "content-type"))
2364 (mail-header-parse-content-type ct)))))
2365 (setq charset (and ctl
2366 (mail-content-type-get ctl 'charset)))
2367 (if (stringp charset)
2368 (setq charset (intern (downcase charset)))))))
2370 (setq charset (mm-read-coding-system "Charset: " charset)))
2372 (setq charset gnus-newsgroup-charset))
2374 (and type (let ((case-fold-search t))
2375 (string-match "quoted-printable" type))))
2377 (quoted-printable-decode-region
2378 (point) (point-max) (mm-charset-to-coding-system charset))))))
2380 (defun article-de-base64-unreadable (&optional force read-charset)
2381 "Translate a base64 article.
2382 If FORCE, decode the article whether it is marked as base64 not.
2383 If READ-CHARSET, ask for a coding system."
2384 (interactive (list 'force current-prefix-arg))
2386 (let ((buffer-read-only nil) type charset)
2387 (if (gnus-buffer-live-p gnus-original-article-buffer)
2388 (with-current-buffer gnus-original-article-buffer
2390 (gnus-fetch-field "content-transfer-encoding"))
2391 (let* ((ct (gnus-fetch-field "content-type"))
2394 (mail-header-parse-content-type ct)))))
2395 (setq charset (and ctl
2396 (mail-content-type-get ctl 'charset)))
2397 (if (stringp charset)
2398 (setq charset (intern (downcase charset)))))))
2400 (setq charset (mm-read-coding-system "Charset: " charset)))
2402 (setq charset gnus-newsgroup-charset))
2404 (and type (let ((case-fold-search t))
2405 (string-match "base64" type))))
2408 (narrow-to-region (point) (point-max))
2409 (base64-decode-region (point-min) (point-max))
2410 (mm-decode-coding-region
2411 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2416 (defun article-decode-HZ ()
2417 "Translate a HZ-encoded article."
2421 (let ((buffer-read-only nil))
2422 (rfc1843-decode-region (point-min) (point-max)))))
2424 (defun article-unsplit-urls ()
2425 "Remove the newlines that some other mailers insert into URLs."
2428 (let ((buffer-read-only nil))
2429 (goto-char (point-min))
2430 (while (re-search-forward
2431 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2432 (replace-match "\\1\\3" t)))
2433 (when (interactive-p)
2434 (gnus-treat-article nil))))
2437 (defun article-wash-html (&optional read-charset)
2438 "Format an HTML article.
2439 If READ-CHARSET, ask for a coding system."
2442 (let ((buffer-read-only nil)
2444 (when (gnus-buffer-live-p gnus-original-article-buffer)
2445 (with-current-buffer gnus-original-article-buffer
2446 (let* ((ct (gnus-fetch-field "content-type"))
2449 (mail-header-parse-content-type ct)))))
2450 (setq charset (and ctl
2451 (mail-content-type-get ctl 'charset)))
2452 (when (stringp charset)
2453 (setq charset (intern (downcase charset)))))))
2455 (setq charset (mm-read-coding-system "Charset: " charset)))
2457 (setq charset gnus-newsgroup-charset))
2459 (save-window-excursion
2461 (narrow-to-region (point) (point-max))
2462 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2463 (entry (assq func mm-text-html-washer-alist)))
2465 (setq func (cdr entry)))
2470 (apply (car func) (cdr func))))))))))
2472 (defun gnus-article-wash-html-with-w3 ()
2473 "Wash the current buffer with w3."
2475 (let ((w3-strict-width (window-width))
2476 (url-standalone-mode t)
2477 (url-gateway-unplugged t)
2478 (w3-honor-stylesheets nil))
2480 (w3-region (point-min) (point-max))
2483 (defun gnus-article-wash-html-with-w3m ()
2484 "Wash the current buffer with emacs-w3m."
2487 (narrow-to-region (point) (point-max))
2488 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2491 w3m-force-redisplay)
2492 (w3m-region (point-min) (point-max)))
2493 (when mm-inline-text-html-with-w3m-keymap
2494 (add-text-properties
2495 (point-min) (point-max)
2496 (nconc (mm-w3m-local-map-property)
2497 '(mm-inline-text-html-with-w3m t))))))
2499 (defun article-hide-list-identifiers ()
2500 "Remove list identifies from the Subject header.
2501 The `gnus-list-identifiers' variable specifies what to do."
2503 (let ((inhibit-point-motion-hooks t)
2504 (regexp (if (consp gnus-list-identifiers)
2505 (mapconcat 'identity gnus-list-identifiers " *\\|")
2506 gnus-list-identifiers))
2511 (article-narrow-to-head)
2512 (goto-char (point-min))
2513 (while (re-search-forward
2514 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2516 (delete-region (match-beginning 2) (match-end 0))
2517 (beginning-of-line))
2518 (when (re-search-forward
2519 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2520 (delete-region (match-beginning 1) (match-end 1))))))))
2522 (defun article-hide-pem (&optional arg)
2523 "Toggle hiding of any PEM headers and signatures in the current article.
2524 If given a negative prefix, always show; if given a positive prefix,
2526 (interactive (gnus-article-hidden-arg))
2527 (unless (gnus-article-check-hidden-text 'pem arg)
2529 (let (buffer-read-only end)
2530 (goto-char (point-min))
2531 ;; Hide the horrendously ugly "header".
2532 (when (and (search-forward
2533 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2535 (setq end (1+ (match-beginning 0))))
2536 (gnus-add-wash-type 'pem)
2537 (gnus-article-hide-text-type
2539 (if (search-forward "\n\n" nil t)
2543 ;; Hide the trailer as well
2544 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2546 (gnus-article-hide-text-type
2547 (match-beginning 0) (match-end 0) 'pem)))))))
2549 (defun article-strip-banner ()
2550 "Strip the banners specified by the `banner' group parameter and by
2551 `gnus-article-address-banner-alist'."
2555 (let ((inhibit-point-motion-hooks t))
2556 (when (gnus-parameter-banner gnus-newsgroup-name)
2557 (article-really-strip-banner
2558 (gnus-parameter-banner gnus-newsgroup-name)))
2559 (when gnus-article-address-banner-alist
2560 (article-really-strip-banner
2561 (let ((from (save-restriction
2563 (article-narrow-to-head)
2564 (mail-fetch-field "from"))))
2567 (caar (mail-header-parse-addresses from))))
2569 (dolist (pair gnus-article-address-banner-alist)
2570 (when (string-match (car pair) from)
2571 (throw 'found (cdr pair)))))))))))))
2573 (defun article-really-strip-banner (banner)
2574 "Strip the banner specified by the argument."
2577 (let ((inhibit-point-motion-hooks t)
2578 (gnus-signature-limit nil)
2582 ((eq banner 'signature)
2583 (when (gnus-article-narrow-to-signature)
2586 (delete-region (point) (point-max))))
2588 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2589 (while (re-search-forward banner nil t)
2590 (delete-region (match-beginning 0) (match-end 0)))))
2592 (while (re-search-forward banner nil t)
2593 (delete-region (match-beginning 0) (match-end 0)))))))))
2595 (defun article-babel ()
2596 "Translate article using an online translation service."
2600 (set-buffer gnus-article-buffer)
2601 (when (article-goto-body)
2602 (let* ((buffer-read-only nil)
2605 (orig (buffer-substring start end))
2606 (trans (babel-as-string orig)))
2608 (narrow-to-region start end)
2609 (delete-region start end)
2612 (defun article-hide-signature (&optional arg)
2613 "Hide the signature in the current article.
2614 If given a negative prefix, always show; if given a positive prefix,
2616 (interactive (gnus-article-hidden-arg))
2622 (article-goto-body))
2623 (goto-char (point-min)))
2624 (unless (gnus-article-check-hidden-text 'signature arg)
2625 (let ((buffer-read-only nil)
2627 (while (setq button (text-property-any button (point-max)
2629 'gnus-signature-toggle))
2630 (setq button (text-property-not-all button (point-max)
2632 'gnus-signature-toggle))
2633 (when (and button (not (eobp)))
2634 (gnus-article-hide-text-type
2636 (next-single-property-change (1+ button) 'mime-view-entity
2639 (gnus-set-mode-line 'article))
2641 (defun article-strip-headers-in-body ()
2642 "Strip offensive headers from bodies."
2646 (let ((case-fold-search t))
2647 (when (looking-at "x-no-archive:")
2648 (gnus-delete-line)))))
2650 (defun article-strip-leading-blank-lines ()
2651 "Remove all blank lines from the beginning of the article."
2654 (let ((inhibit-point-motion-hooks t)
2656 (when (article-goto-body)
2657 (while (and (not (eobp))
2658 (looking-at "[ \t]*$"))
2659 (gnus-delete-line))))))
2661 (defun article-narrow-to-head ()
2662 "Narrow the buffer to the head of the message.
2663 Point is left at the beginning of the narrowed-to region."
2665 (goto-char (point-min))
2666 (if (search-forward "\n\n" nil 1)
2669 (goto-char (point-min)))
2671 (defun article-goto-body ()
2672 "Place point at the start of the body."
2673 (goto-char (point-min))
2675 ;; This variable is only bound when dealing with separate
2677 (article-goto-body-goes-to-point-min-p
2679 ((search-forward "\n\n" nil t)
2682 (goto-char (point-max))
2685 (defun article-strip-multiple-blank-lines ()
2686 "Replace consecutive blank lines with one empty line."
2689 (let ((inhibit-point-motion-hooks t)
2691 ;; First make all blank lines empty.
2693 (while (re-search-forward "^[ \t]+$" nil t)
2694 (unless (gnus-annotation-in-region-p
2695 (match-beginning 0) (match-end 0))
2696 (replace-match "" nil t)))
2697 ;; Then replace multiple empty lines with a single empty line.
2699 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2700 (unless (gnus-annotation-in-region-p
2701 (match-beginning 0) (match-end 0))
2702 (delete-region (match-beginning 1) (match-end 1)))))))
2704 (defun article-strip-leading-space ()
2705 "Remove all white space from the beginning of the lines in the article."
2708 (let ((inhibit-point-motion-hooks t)
2711 (while (re-search-forward "^[ \t]+" nil t)
2712 (replace-match "" t t)))))
2714 (defun article-strip-trailing-space ()
2715 "Remove all white space from the end of the lines in the article."
2718 (let ((inhibit-point-motion-hooks t)
2721 (while (re-search-forward "[ \t]+$" nil t)
2722 (replace-match "" t t)))))
2724 (defun article-strip-blank-lines ()
2725 "Strip leading, trailing and multiple blank lines."
2727 (article-strip-leading-blank-lines)
2728 (article-remove-trailing-blank-lines)
2729 (article-strip-multiple-blank-lines))
2731 (defun article-strip-all-blank-lines ()
2732 "Strip all blank lines."
2735 (let ((inhibit-point-motion-hooks t)
2738 (while (re-search-forward "^[ \t]*\n" nil t)
2739 (replace-match "" t t)))))
2741 (defun gnus-article-narrow-to-signature ()
2742 "Narrow to the signature; return t if a signature is found, else nil."
2743 (let ((inhibit-point-motion-hooks t))
2744 (when (gnus-article-search-signature)
2746 ;; Check whether we have some limits to what we consider
2747 ;; to be a signature.
2748 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2749 (list gnus-signature-limit)))
2751 (while (setq limit (pop limits))
2752 (if (or (and (integerp limit)
2753 (< (- (point-max) (point)) limit))
2755 (< (count-lines (point) (point-max)) limit))
2756 (and (functionp limit)
2758 (and (stringp limit)
2759 (not (re-search-forward limit nil t))))
2760 () ; This limit did not succeed.
2764 (narrow-to-region (point) (point-max))
2767 (defun gnus-article-search-signature ()
2768 "Search the current buffer for the signature separator.
2769 Put point at the beginning of the signature separator."
2770 (let ((cur (point)))
2771 (goto-char (point-max))
2772 (if (if (stringp gnus-signature-separator)
2773 (re-search-backward gnus-signature-separator nil t)
2774 (let ((seps gnus-signature-separator))
2776 (not (re-search-backward (car seps) nil t)))
2783 (defun gnus-article-hidden-arg ()
2784 "Return the current prefix arg as a number, or 0 if no prefix."
2785 (list (if current-prefix-arg
2786 (prefix-numeric-value current-prefix-arg)
2789 (defun gnus-article-check-hidden-text (type arg)
2790 "Return nil if hiding is necessary.
2791 Arg can be nil or a number. nil and positive means hide, negative
2792 means show, 0 means toggle."
2795 (let ((hide (gnus-article-hidden-text-p type)))
2801 (gnus-article-show-hidden-text type)
2804 (if (eq hide 'hidden)
2806 (gnus-article-show-hidden-text type)
2810 (defun gnus-article-hidden-text-p (type)
2811 "Say whether the current buffer contains hidden text of type TYPE."
2812 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2814 (not (get-text-property pos 'invisible))
2815 (not (get-text-property pos 'dummy-invisible)))
2817 (text-property-any (1+ pos) (point-max) 'article-type type)))
2822 (defun gnus-article-show-hidden-text (type &optional dummy)
2823 "Show all hidden text of type TYPE.
2824 Originally it is hide instead of DUMMY."
2825 (let ((buffer-read-only nil)
2826 (inhibit-point-motion-hooks t))
2827 (gnus-remove-text-properties-when
2829 (point-min) (point-max)
2830 (cons 'article-type (cons type
2831 gnus-hidden-properties)))
2832 (gnus-delete-wash-type type)))
2834 (defconst article-time-units
2835 `((year . ,(* 365.25 24 60 60))
2836 (week . ,(* 7 24 60 60))
2837 (day . ,(* 24 60 60))
2841 "Mapping from time units to seconds.")
2843 (defun gnus-article-forward-header ()
2844 "Move point to the start of the next header.
2845 If the current header is a continuation header, this can be several
2850 (if (looking-at "[ \t]+[^ \t]")
2854 (defun article-date-ut (&optional type highlight header)
2855 "Convert DATE date to universal time in the current article.
2856 If TYPE is `local', convert to local time; if it is `lapsed', output
2857 how much time has lapsed since DATE. For `lapsed', the value of
2858 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2859 should replace the \"Date:\" one, or should be added below it."
2860 (interactive (list 'ut t))
2861 (let* ((header (or header
2862 (and (eq 1 (point-min))
2863 (mail-header-date (save-excursion
2864 (set-buffer gnus-summary-buffer)
2865 gnus-current-headers)))
2866 (message-fetch-field "date")
2868 (date (if (vectorp header) (mail-header-date header)
2870 (inhibit-point-motion-hooks t)
2871 bface eface date-pos)
2872 (when (and date (not (string= date "")))
2875 (article-narrow-to-head)
2876 (when (or (and (eq type 'lapsed)
2877 gnus-article-date-lapsed-new-header
2878 ;; Attempt to get the face of X-Sent first.
2879 (re-search-forward "^X-Sent:[ \t]" nil t))
2880 (re-search-forward "^Date:[ \t]" nil t)
2881 ;; If Date is missing, try again for X-Sent.
2882 (re-search-forward "^X-Sent:[ \t]" nil t))
2883 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2884 date (or (get-text-property (gnus-point-at-bol)
2887 eface (get-text-property (1- (gnus-point-at-eol))
2889 (let ((buffer-read-only nil))
2890 ;; Delete any old X-Sent headers.
2891 (when (setq date-pos
2892 (text-property-any (point-min) (point-max)
2893 'article-date-lapsed t))
2894 (goto-char (setq date-pos (set-marker (make-marker) date-pos)))
2895 (delete-region (match-beginning 0)
2896 (progn (forward-line 1) (point))))
2897 (goto-char (point-min))
2898 ;; Delete any old Date headers.
2899 (while (re-search-forward "^Date:[ \t]" nil t)
2901 (setq date-pos (match-beginning 0)))
2902 (unless (and (eq type 'lapsed)
2903 gnus-article-date-lapsed-new-header)
2904 (delete-region (match-beginning 0)
2905 (progn (message-next-header) (point)))))
2908 (goto-char date-pos)
2910 ;; Possibly, Date has been deleted.
2912 (when (and (eq type 'lapsed)
2913 gnus-article-date-lapsed-new-header
2914 (looking-at "Date:"))
2916 (goto-char (point-min)))
2917 (insert (article-make-date-line date type))
2918 (when (eq type 'lapsed)
2919 (put-text-property (gnus-point-at-bol) (point)
2920 'article-date-lapsed t))
2924 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2925 (put-text-property (match-beginning 1) (1+ (match-end 1))
2926 'original-date date)
2927 (put-text-property (match-beginning 1) (1+ (match-end 1))
2929 (put-text-property (match-beginning 2) (match-end 2)
2932 (defun article-make-date-line (date type)
2933 "Return a DATE line of TYPE."
2934 (unless (memq type '(local ut original user iso8601 lapsed english))
2935 (error "Unknown conversion type: %s" type))
2937 (let ((time (date-to-time date)))
2939 ;; Convert to the local timezone.
2941 (let ((tz (car (current-time-zone time))))
2942 (format "Date: %s %s%02d%02d" (current-time-string time)
2943 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2944 (/ (% (abs tz) 3600) 60))))
2945 ;; Convert to Universal Time.
2948 (current-time-string
2949 (let* ((e (parse-time-string date))
2950 (tm (apply 'encode-time e))
2952 (ls (- (cadr tm) (car (current-time-zone time)))))
2953 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2954 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2957 ;; Get the original date from the article.
2958 ((eq type 'original)
2959 (concat "Date: " (if (string-match "\n+$" date)
2960 (substring date 0 (match-beginning 0))
2962 ;; Let the user define the format.
2964 (let ((format (or (condition-case nil
2965 (with-current-buffer gnus-summary-buffer
2966 gnus-article-time-format)
2968 gnus-article-time-format)))
2969 (if (functionp format)
2970 (funcall format time)
2971 (concat "Date: " (format-time-string format time)))))
2974 (let ((tz (car (current-time-zone time))))
2977 (format-time-string "%Y%m%dT%H%M%S" time)
2978 (format "%s%02d%02d"
2979 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2980 (/ (% (abs tz) 3600) 60)))))
2981 ;; Do an X-Sent lapsed format.
2983 ;; If the date is seriously mangled, the timezone functions are
2984 ;; liable to bug out, so we ignore all errors.
2985 (let* ((now (current-time))
2986 (real-time (subtract-time now time))
2987 (real-sec (and real-time
2988 (+ (* (float (car real-time)) 65536)
2990 (sec (and real-time (abs real-sec)))
3000 ;; This is a bit convoluted, but basically we go
3001 ;; through the time units for years, weeks, etc,
3002 ;; and divide things to see whether that results
3003 ;; in positive answers.
3006 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3007 ;; The (remaining) seconds are too few to
3008 ;; be divided into this time unit.
3010 ;; It's big enough, so we output it.
3011 (setq sec (- sec (* num (cdr unit))))
3013 (concat (if prev ", " "") (int-to-string
3015 " " (symbol-name (car unit))
3016 (if (> num 1) "s" ""))
3018 article-time-units "")
3019 ;; If dates are odd, then it might appear like the
3020 ;; article was sent in the future.
3023 " in the future"))))))
3024 ;; Display the date in proper English
3026 (let ((dtime (decode-time time)))
3029 (number-to-string (nth 3 dtime))
3030 (let ((digit (% (nth 3 dtime) 10)))
3032 ((memq (nth 3 dtime) '(11 12 13)) "th")
3038 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3040 (number-to-string (nth 5 dtime))
3042 (format "%02d" (nth 2 dtime))
3044 (format "%02d" (nth 1 dtime)))))))
3046 (format "Date: %s (from T-gnus)" date))))
3048 (defun article-date-local (&optional highlight)
3049 "Convert the current article date to the local timezone."
3050 (interactive (list t))
3051 (article-date-ut 'local highlight))
3053 (defun article-date-english (&optional highlight)
3054 "Convert the current article date to something that is proper English."
3055 (interactive (list t))
3056 (article-date-ut 'english highlight))
3058 (defun article-date-original (&optional highlight)
3059 "Convert the current article date to what it was originally.
3060 This is only useful if you have used some other date conversion
3061 function and want to see what the date was before converting."
3062 (interactive (list t))
3063 (article-date-ut 'original highlight))
3065 (defun article-date-lapsed (&optional highlight)
3066 "Convert the current article date to time lapsed since it was sent."
3067 (interactive (list t))
3068 (article-date-ut 'lapsed highlight))
3070 (defun article-update-date-lapsed ()
3071 "Function to be run from a timer to update the lapsed time line."
3072 (let (deactivate-mark)
3077 (set-buffer (window-buffer w))
3078 (when (eq major-mode 'gnus-article-mode)
3079 (goto-char (point-min))
3080 (when (re-search-forward "^X-Sent:" nil t)
3081 (article-date-lapsed t))))
3084 (defun gnus-start-date-timer (&optional n)
3085 "Start a timer to update the X-Sent header in the article buffers.
3086 The numerical prefix says how frequently (in seconds) the function
3091 (gnus-stop-date-timer)
3092 (setq article-lapsed-timer
3093 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
3095 (defun gnus-stop-date-timer ()
3096 "Stop the X-Sent timer."
3098 (when article-lapsed-timer
3099 (nnheader-cancel-timer article-lapsed-timer)
3100 (setq article-lapsed-timer nil)))
3102 (defun article-date-user (&optional highlight)
3103 "Convert the current article date to the user-defined format.
3104 This format is defined by the `gnus-article-time-format' variable."
3105 (interactive (list t))
3106 (article-date-ut 'user highlight))
3108 (defun article-date-iso8601 (&optional highlight)
3109 "Convert the current article date to ISO8601."
3110 (interactive (list t))
3111 (article-date-ut 'iso8601 highlight))
3113 ;; (defun article-show-all ()
3114 ;; "Show all hidden text in the article buffer."
3118 ;; (let ((buffer-read-only nil))
3119 ;; (gnus-article-unhide-text (point-min) (point-max))
3120 ;; (gnus-remove-text-with-property 'gnus-prev)
3121 ;; (gnus-remove-text-with-property 'gnus-next))))
3123 (defun article-show-all-headers ()
3124 "Show all hidden headers in the article buffer."
3129 (article-narrow-to-head)
3130 (let ((buffer-read-only nil))
3131 (gnus-article-unhide-text (point-min) (point-max))))))
3133 (defun article-remove-leading-whitespace ()
3134 "Remove excessive whitespace from all headers."
3138 (let ((buffer-read-only nil))
3139 (article-narrow-to-head)
3140 (goto-char (point-min))
3141 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3142 (delete-region (match-beginning 1) (match-end 1)))))))
3144 (defun article-emphasize (&optional arg)
3145 "Emphasize text according to `gnus-emphasis-alist'."
3146 (interactive (gnus-article-hidden-arg))
3147 (unless (gnus-article-check-hidden-text 'emphasis arg)
3151 (with-current-buffer gnus-summary-buffer
3152 gnus-article-emphasis-alist)
3154 gnus-emphasis-alist))
3155 (buffer-read-only nil)
3156 (props (append '(article-type emphasis)
3157 gnus-hidden-properties))
3158 regexp elem beg invisible visible face)
3161 (while (setq elem (pop alist))
3163 (setq regexp (car elem)
3164 invisible (nth 1 elem)
3165 visible (nth 2 elem)
3167 (while (re-search-forward regexp nil t)
3168 (when (and (match-beginning visible) (match-beginning invisible))
3169 (gnus-article-hide-text
3170 (match-beginning invisible) (match-end invisible) props)
3171 (gnus-article-unhide-text-type
3172 (match-beginning visible) (match-end visible) 'emphasis)
3173 (gnus-put-overlay-excluding-newlines
3174 (match-beginning visible) (match-end visible) 'face face)
3175 (gnus-add-wash-type 'emphasis)
3176 (goto-char (match-end invisible)))))))))
3178 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3179 "Setup newsgroup emphasis alist."
3180 (unless gnus-article-emphasis-alist
3181 (let ((name (and gnus-newsgroup-name
3182 (gnus-group-real-name gnus-newsgroup-name))))
3183 (make-local-variable 'gnus-article-emphasis-alist)
3184 (setq gnus-article-emphasis-alist
3186 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3187 (while (setq elem (pop alist))
3188 (when (and name (string-match (car elem) name))
3190 highlight (copy-sequence (cdr elem)))))
3192 (copy-sequence highlight-words)
3193 (if gnus-newsgroup-name
3194 (copy-sequence (gnus-group-find-parameter
3195 gnus-newsgroup-name 'highlight-words t)))
3196 gnus-emphasis-alist)))))
3199 (defvar gnus-summary-article-menu)
3200 (defvar gnus-summary-post-menu))
3202 ;;; Saving functions.
3204 (defun gnus-article-save (save-buffer file &optional num)
3205 "Save the currently selected article."
3206 (unless gnus-save-all-headers
3207 ;; Remove headers according to `gnus-saved-headers'.
3208 (let ((gnus-visible-headers
3209 (or gnus-saved-headers gnus-visible-headers))
3210 (gnus-article-buffer save-buffer))
3212 (set-buffer save-buffer)
3213 (article-hide-headers 1 t))))
3214 (save-window-excursion
3215 (if (not gnus-default-article-saver)
3216 (error "No default saver is defined")
3217 ;; !!! Magic! The saving functions all save
3218 ;; `gnus-save-article-buffer' (or so they think), but we
3219 ;; bind that variable to our save-buffer.
3220 (set-buffer gnus-article-buffer)
3221 (let* ((gnus-save-article-buffer save-buffer)
3224 ((not gnus-prompt-before-saving) 'default)
3225 ((eq gnus-prompt-before-saving 'always) nil)
3227 (gnus-number-of-articles-to-be-saved
3228 (when (eq gnus-prompt-before-saving t)
3230 (set-buffer gnus-article-current-summary)
3231 (funcall gnus-default-article-saver filename)))))
3233 (defun gnus-read-save-file-name (prompt &optional filename
3234 function group headers variable)
3236 (funcall function group headers (symbol-value variable)))
3241 ((eq filename 'default)
3247 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3250 (if (and gnus-number-of-articles-to-be-saved
3251 (> gnus-number-of-articles-to-be-saved 1))
3252 (format "these %d articles"
3253 gnus-number-of-articles-to-be-saved)
3256 ;; Let the split methods have their say.
3258 ;; No split name was found.
3261 (concat prompt " (default "
3262 (file-name-nondirectory default-name) ") ")
3263 (file-name-directory default-name)
3265 ;; A single group name is returned.
3266 ((stringp split-name)
3268 (funcall function split-name headers
3269 (symbol-value variable)))
3271 (concat prompt " (default "
3272 (file-name-nondirectory default-name) ") ")
3273 (file-name-directory default-name)
3275 ;; A single split name was found
3276 ((= 1 (length split-name))
3277 (let* ((name (expand-file-name
3279 gnus-article-save-directory))
3280 (dir (cond ((file-directory-p name)
3281 (file-name-as-directory name))
3282 ((file-exists-p name) name)
3283 (t gnus-article-save-directory))))
3285 (concat prompt " (default " name ") ")
3287 ;; A list of splits was found.
3289 (setq split-name (nreverse split-name))
3291 (let ((file-name-history
3292 (nconc split-name file-name-history)))
3296 (concat prompt " (`M-p' for defaults) ")
3297 gnus-article-save-directory
3299 gnus-article-save-directory)))
3300 (car (push result file-name-history)))))))
3301 ;; Create the directory.
3302 (gnus-make-directory (file-name-directory file))
3303 ;; If we have read a directory, we append the default file name.
3304 (when (file-directory-p file)
3305 (setq file (expand-file-name (file-name-nondirectory
3307 (file-name-as-directory file))))
3308 ;; Possibly translate some characters.
3309 (nnheader-translate-file-chars file))))))
3310 (gnus-make-directory (file-name-directory result))
3311 (set variable result)))
3313 (defun gnus-article-archive-name (group)
3314 "Return the first instance of an \"Archive-name\" in the current buffer."
3315 (let ((case-fold-search t))
3316 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3317 (nnheader-concat gnus-article-save-directory
3318 (match-string 1)))))
3320 (defun gnus-article-nndoc-name (group)
3321 "If GROUP is an nndoc group, return the name of the parent group."
3322 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3323 (gnus-group-get-parameter group 'save-article-group)))
3325 (defun gnus-summary-save-in-rmail (&optional filename)
3326 "Append this article to Rmail file.
3327 Optional argument FILENAME specifies file name.
3328 Directory to save to is default to `gnus-article-save-directory'."
3329 (setq filename (gnus-read-save-file-name
3330 "Save %s in rmail file:" filename
3331 gnus-rmail-save-name gnus-newsgroup-name
3332 gnus-current-headers 'gnus-newsgroup-last-rmail))
3333 (gnus-eval-in-buffer-window gnus-save-article-buffer
3337 (gnus-output-to-rmail filename))))
3340 (defun gnus-summary-save-in-mail (&optional filename)
3341 "Append this article to Unix mail file.
3342 Optional argument FILENAME specifies file name.
3343 Directory to save to is default to `gnus-article-save-directory'."
3344 (setq filename (gnus-read-save-file-name
3345 "Save %s in Unix mail file:" filename
3346 gnus-mail-save-name gnus-newsgroup-name
3347 gnus-current-headers 'gnus-newsgroup-last-mail))
3348 (gnus-eval-in-buffer-window gnus-save-article-buffer
3352 (if (and (file-readable-p filename)
3353 (file-regular-p filename)
3354 (mail-file-babyl-p filename))
3355 (rmail-output-to-rmail-file filename t)
3356 (gnus-output-to-mail filename)))))
3359 (defun gnus-summary-save-in-file (&optional filename overwrite)
3360 "Append this article to file.
3361 Optional argument FILENAME specifies file name.
3362 Directory to save to is default to `gnus-article-save-directory'."
3363 (setq filename (gnus-read-save-file-name
3364 "Save %s in file:" filename
3365 gnus-file-save-name gnus-newsgroup-name
3366 gnus-current-headers 'gnus-newsgroup-last-file))
3367 (gnus-eval-in-buffer-window gnus-save-article-buffer
3371 (when (and overwrite
3372 (file-exists-p filename))
3373 (delete-file filename))
3374 (gnus-output-to-file filename))))
3377 (defun gnus-summary-write-to-file (&optional filename)
3378 "Write this article to a file, overwriting it if the file exists.
3379 Optional argument FILENAME specifies file name.
3380 The directory to save in defaults to `gnus-article-save-directory'."
3381 (gnus-summary-save-in-file nil t))
3383 (defun gnus-summary-save-body-in-file (&optional filename)
3384 "Append this article body to a file.
3385 Optional argument FILENAME specifies file name.
3386 The directory to save in defaults to `gnus-article-save-directory'."
3387 (setq filename (gnus-read-save-file-name
3388 "Save %s body in file:" filename
3389 gnus-file-save-name gnus-newsgroup-name
3390 gnus-current-headers 'gnus-newsgroup-last-file))
3391 (gnus-eval-in-buffer-window gnus-save-article-buffer
3395 (when (article-goto-body)
3396 (narrow-to-region (point) (point-max)))
3397 (gnus-output-to-file filename))))
3400 (defun gnus-summary-save-in-pipe (&optional command)
3401 "Pipe this article to subprocess."
3403 (cond ((and (eq command 'default)
3404 gnus-last-shell-command)
3405 gnus-last-shell-command)
3410 "Shell command on %s: "
3411 (if (and gnus-number-of-articles-to-be-saved
3412 (> gnus-number-of-articles-to-be-saved 1))
3413 (format "these %d articles"
3414 gnus-number-of-articles-to-be-saved)
3416 gnus-last-shell-command))))
3417 (when (string-equal command "")
3418 (if gnus-last-shell-command
3419 (setq command gnus-last-shell-command)
3420 (error "A command is required")))
3421 (gnus-eval-in-buffer-window gnus-article-buffer
3424 (shell-command-on-region (point-min) (point-max) command nil)))
3425 (setq gnus-last-shell-command command))
3427 (defmacro gnus-read-string (prompt &optional initial-contents history
3429 "Like `read-string' but allow for older XEmacsen that don't have the 5th arg."
3430 (if (and (featurep 'xemacs)
3431 (< emacs-minor-version 2))
3432 `(read-string ,prompt ,initial-contents ,history)
3433 `(read-string ,prompt ,initial-contents ,history ,default-value)))
3435 (defun gnus-summary-pipe-to-muttprint (&optional command)
3436 "Pipe this article to muttprint."
3437 (setq command (gnus-read-string
3438 "Print using command: " gnus-summary-muttprint-program
3439 nil gnus-summary-muttprint-program))
3440 (gnus-summary-save-in-pipe command))
3442 ;;; Article file names when saving.
3444 (defun gnus-capitalize-newsgroup (newsgroup)
3445 "Capitalize NEWSGROUP name."
3446 (when (not (zerop (length newsgroup)))
3447 (concat (char-to-string (upcase (aref newsgroup 0)))
3448 (substring newsgroup 1))))
3450 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3451 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3452 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3453 Otherwise, it is like ~/News/news/group/num."
3456 (concat (if (gnus-use-long-file-name 'not-save)
3457 (gnus-capitalize-newsgroup newsgroup)
3458 (gnus-newsgroup-directory-form newsgroup))
3459 "/" (int-to-string (mail-header-number headers)))
3460 gnus-article-save-directory)))
3462 (string-equal (file-name-directory default)
3463 (file-name-directory last-file))
3464 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3466 (or last-file default))))
3468 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3469 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3470 If variable `gnus-use-long-file-name' is non-nil, it is
3471 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3474 (concat (if (gnus-use-long-file-name 'not-save)
3476 (gnus-newsgroup-directory-form newsgroup))
3477 "/" (int-to-string (mail-header-number headers)))
3478 gnus-article-save-directory)))
3480 (string-equal (file-name-directory default)
3481 (file-name-directory last-file))
3482 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3484 (or last-file default))))
3486 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3487 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3488 If variable `gnus-use-long-file-name' is non-nil, it is
3489 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3492 (if (gnus-use-long-file-name 'not-save)
3495 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3497 gnus-article-save-directory)))
3499 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3500 "Generate file name from sender."
3501 (let ((from (mail-header-from headers)))
3503 (if (and from (string-match "\\([^ <]+\\)@" from))
3504 (match-string 1 from)
3506 gnus-article-save-directory)))
3508 (defun article-verify-x-pgp-sig ()
3511 (if (gnus-buffer-live-p gnus-original-article-buffer)
3512 (let ((sig (with-current-buffer gnus-original-article-buffer
3513 (gnus-fetch-field "X-PGP-Sig")))
3517 (mml2015-clear-verify-function))
3519 (insert-buffer-substring gnus-original-article-buffer)
3520 (setq items (split-string sig))
3521 (message-narrow-to-head)
3522 (let ((inhibit-point-motion-hooks t)
3523 (case-fold-search t))
3524 ;; Don't verify multiple headers.
3525 (setq headers (mapconcat (lambda (header)
3527 (mail-fetch-field header)
3529 (split-string (nth 1 items) ",") "")))
3530 (delete-region (point-min) (point-max))
3531 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3532 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3537 (if (looking-at "^-")
3540 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3541 (insert "Version: " (car items) "\n\n")
3542 (insert (mapconcat 'identity (cddr items) "\n"))
3543 (insert "\n-----END PGP SIGNATURE-----\n")
3544 (let ((mm-security-handle (list (format "multipart/signed"))))
3545 (mml2015-clean-buffer)
3546 (let ((coding-system-for-write (or gnus-newsgroup-charset
3548 (funcall (mml2015-clear-verify-function)))
3550 (or (mm-handle-multipart-ctl-parameter
3551 mm-security-handle 'gnus-details)
3552 (mm-handle-multipart-ctl-parameter
3553 mm-security-handle 'gnus-info)))))
3555 (let (buffer-read-only bface eface)
3557 (message-narrow-to-head)
3558 (goto-char (point-max))
3560 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3561 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3562 (message-remove-header "X-Gnus-PGP-Verify")
3563 (if (re-search-forward "^X-PGP-Sig:" nil t)
3565 (goto-char (point-max)))
3566 (narrow-to-region (point) (point))
3567 (insert "X-Gnus-PGP-Verify: " info "\n")
3568 (goto-char (point-min))
3571 (if (not (looking-at "^[ \t]"))
3575 (goto-char (point-min))
3576 (when (looking-at "\\([^:]+\\): *")
3577 (put-text-property (match-beginning 1) (1+ (match-end 1))
3579 (put-text-property (match-end 0) (point-max)
3580 'face eface)))))))))
3582 (defun article-verify-cancel-lock ()
3583 "Verify Cancel-Lock header."
3585 (if (gnus-buffer-live-p gnus-original-article-buffer)
3586 (canlock-verify gnus-original-article-buffer)))
3588 (defun article-monafy ()
3589 "Display body part with mona font."
3591 (unless (if (featurep 'xemacs)
3592 (find-face 'gnus-mona-face)
3593 (facep 'gnus-mona-face))
3594 (require 'navi2ch-mona)
3595 (set-face-font (make-face 'gnus-mona-face) navi2ch-mona-font))
3597 (let ((buffer-read-only nil))
3600 (gnus-make-overlay (point) (point-max))
3601 'face 'gnus-mona-face))))
3608 (setq afunc (car func)
3611 gfunc (intern (format "gnus-%s" func))))
3613 (when (fboundp afunc)
3614 `(lambda (&optional interactive &rest args)
3615 ,(documentation afunc t)
3616 (interactive (list t))
3618 (set-buffer gnus-article-buffer)
3620 (call-interactively ',afunc)
3621 (apply ',afunc args))))))))
3622 '(article-hide-headers
3623 article-verify-x-pgp-sig
3624 article-verify-cancel-lock
3626 article-hide-boring-headers
3627 article-treat-overstrike
3628 article-fill-long-lines
3629 article-capitalize-sentences
3631 article-remove-leading-whitespace
3632 article-display-x-face
3633 article-display-face
3634 article-de-quoted-unreadable
3635 article-de-base64-unreadable
3638 article-unsplit-urls
3639 article-hide-list-identifiers
3640 article-strip-banner
3643 article-hide-signature
3644 article-strip-headers-in-body
3645 article-remove-trailing-blank-lines
3646 article-strip-leading-blank-lines
3647 article-strip-multiple-blank-lines
3648 article-strip-leading-space
3649 article-strip-trailing-space
3650 article-strip-blank-lines
3651 article-strip-all-blank-lines
3653 article-date-english
3654 article-date-iso8601
3655 article-date-original
3657 article-decode-mime-words
3658 article-decode-charset
3659 article-decode-encoded-words
3663 article-treat-dumbquotes
3664 article-normalize-headers
3665 (article-show-all-headers . gnus-article-show-all-headers)
3666 ;; (article-show-all . gnus-article-show-all)
3670 ;;; Gnus article mode
3673 (put 'gnus-article-mode 'mode-class 'special)
3675 (gnus-define-keys gnus-article-mode-map
3676 " " gnus-article-goto-next-page
3677 "\177" gnus-article-goto-prev-page
3678 [delete] gnus-article-goto-prev-page
3679 [backspace] gnus-article-goto-prev-page
3680 "\C-c^" gnus-article-refer-article
3681 "h" gnus-article-show-summary
3682 "s" gnus-article-show-summary
3683 "\C-c\C-m" gnus-article-mail
3684 "?" gnus-article-describe-briefly
3685 "e" gnus-summary-edit-article
3686 "<" beginning-of-buffer
3688 "\C-c\C-i" gnus-info-find-node
3690 "R" gnus-article-reply-with-original
3691 "F" gnus-article-followup-with-original
3692 "\C-hk" gnus-article-describe-key
3693 "\C-hc" gnus-article-describe-key-briefly
3695 "\C-d" gnus-article-read-summary-keys
3696 "\M-*" gnus-article-read-summary-keys
3697 "\M-#" gnus-article-read-summary-keys
3698 "\M-^" gnus-article-read-summary-keys
3699 "\M-g" gnus-article-read-summary-keys)
3701 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3705 (push (char-to-string key) keys)
3707 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3708 (setq key (car elem))
3709 (when (and (> (length key) 0)
3710 (not (eq 'menu-bar (aref key 0)))
3711 (symbolp (lookup-key gnus-summary-mode-map key)))
3714 (unless (lookup-key gnus-article-mode-map key)
3715 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3717 (defun gnus-article-make-menu-bar ()
3718 (unless (boundp 'gnus-article-commands-menu)
3719 (gnus-summary-make-menu-bar))
3720 (gnus-turn-off-edit-menu 'article)
3721 (unless (boundp 'gnus-article-article-menu)
3723 gnus-article-article-menu gnus-article-mode-map ""
3725 ["Scroll forwards" gnus-article-goto-next-page t]
3726 ["Scroll backwards" gnus-article-goto-prev-page t]
3727 ["Show summary" gnus-article-show-summary t]
3728 ["Fetch Message-ID at point" gnus-article-refer-article t]
3729 ["Mail to address at point" gnus-article-mail t]
3730 ["Send a bug report" gnus-bug t]))
3733 gnus-article-treatment-menu gnus-article-mode-map ""
3734 ;; Fixme: this should use :active (and maybe :visible).
3736 ["Hide headers" gnus-article-hide-headers t]
3737 ["Hide signature" gnus-article-hide-signature t]
3738 ["Hide citation" gnus-article-hide-citation t]
3739 ["Treat overstrike" gnus-article-treat-overstrike t]
3740 ["Remove carriage return" gnus-article-remove-cr t]
3741 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3742 ["Treat html" gnus-article-wash-html t]
3743 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3744 ["Decode HZ" gnus-article-decode-HZ t]))
3746 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3748 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3750 (gnus-run-hooks 'gnus-article-menu-hook)))
3752 (defun gnus-article-mode ()
3753 "Major mode for displaying an article.
3755 All normal editing commands are switched off.
3757 The following commands are available in addition to all summary mode
3759 \\<gnus-article-mode-map>
3760 \\[gnus-article-next-page]\t Scroll the article one page forwards
3761 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3762 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3763 \\[gnus-article-show-summary]\t Display the summary buffer
3764 \\[gnus-article-mail]\t Send a reply to the address near point
3765 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3766 \\[gnus-info-find-node]\t Go to the Gnus info node"
3768 (gnus-simplify-mode-line)
3769 (setq mode-name "Article")
3770 (setq major-mode 'gnus-article-mode)
3771 (make-local-variable 'minor-mode-alist)
3772 (unless (assq 'gnus-show-mime minor-mode-alist)
3773 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3774 (use-local-map gnus-article-mode-map)
3775 (when (gnus-visual-p 'article-menu 'menu)
3776 (gnus-article-make-menu-bar)
3777 (when gnus-summary-tool-bar-map
3778 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3779 (gnus-update-format-specifications nil 'article-mode)
3780 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3781 (make-local-variable 'gnus-page-broken)
3782 (make-local-variable 'gnus-button-marker-list)
3783 (make-local-variable 'gnus-article-current-summary)
3784 (make-local-variable 'gnus-article-mime-handles)
3785 (make-local-variable 'gnus-article-decoded-p)
3786 (make-local-variable 'gnus-article-mime-handle-alist)
3787 (make-local-variable 'gnus-article-wash-types)
3788 (make-local-variable 'gnus-article-image-alist)
3789 (make-local-variable 'gnus-article-charset)
3790 (make-local-variable 'gnus-article-ignored-charsets)
3791 (gnus-set-default-directory)
3792 (buffer-disable-undo)
3793 (setq buffer-read-only t)
3794 (set-syntax-table gnus-article-mode-syntax-table)
3795 (gnus-run-hooks 'gnus-article-mode-hook))
3797 (defun gnus-article-setup-buffer ()
3798 "Initialize the article buffer."
3799 (let* ((name (if gnus-single-article-buffer "*Article*"
3800 (concat "*Article " gnus-newsgroup-name "*")))
3802 (progn (string-match "\\*Article" name)
3803 (concat " *Original Article"
3804 (substring name (match-end 0))))))
3805 (setq gnus-article-buffer name)
3806 (setq gnus-original-article-buffer original)
3807 (setq gnus-article-mime-handle-alist nil)
3808 ;; This might be a variable local to the summary buffer.
3809 (unless gnus-single-article-buffer
3811 (set-buffer gnus-summary-buffer)
3812 (setq gnus-article-buffer name)
3813 (setq gnus-original-article-buffer original)
3814 (gnus-set-global-variables)))
3815 (gnus-article-setup-highlight-words)
3816 ;; Init original article buffer.
3818 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3819 (set-buffer-multibyte t)
3820 (setq major-mode 'gnus-original-article-mode)
3821 (make-local-variable 'gnus-original-article))
3822 (if (get-buffer name)
3825 (when (and gnus-article-edit-mode
3828 (y-or-n-p "Article mode edit in progress; discard? ")))
3829 (error "Action aborted"))
3830 (set (make-local-variable 'gnus-article-edit-mode) nil)
3831 (buffer-disable-undo)
3832 (setq buffer-read-only t)
3833 ;; This list just keeps growing if we don't reset it.
3834 (setq gnus-button-marker-list nil)
3835 (unless (eq major-mode 'gnus-article-mode)
3836 (gnus-article-mode))
3839 (set-buffer (gnus-get-buffer-create name))
3841 (make-local-variable 'gnus-summary-buffer)
3842 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3843 (current-buffer)))))
3845 ;; Set article window start at LINE, where LINE is the number of lines
3846 ;; from the head of the article.
3847 (defun gnus-article-set-window-start (&optional line)
3849 (gnus-get-buffer-window gnus-article-buffer t)
3851 (set-buffer gnus-article-buffer)
3852 (goto-char (point-min))
3855 (gnus-message 6 "Moved to bookmark")
3856 (search-forward "\n\n" nil t)
3860 ;;; @@ article filters
3863 (defun gnus-article-display-mime-message ()
3864 "Article display method for MIME message."
3865 ;; called from `gnus-original-article-buffer'.
3866 (let (charset all-headers)
3867 (with-current-buffer gnus-summary-buffer
3868 (setq charset default-mime-charset
3869 all-headers gnus-have-all-headers))
3870 (make-local-variable 'default-mime-charset)
3871 (setq default-mime-charset charset)
3872 (with-current-buffer (get-buffer-create gnus-article-buffer)
3873 (make-local-variable 'default-mime-charset)
3874 (setq default-mime-charset charset))
3875 (mime-display-message mime-message-structure
3876 gnus-article-buffer nil gnus-article-mode-map)
3878 (gnus-article-hide-headers nil -1)))
3879 (run-hooks 'gnus-mime-article-prepare-hook))
3881 (defun gnus-article-display-traditional-message ()
3882 "Article display method for traditional message."
3883 (set-buffer gnus-article-buffer)
3884 (let (buffer-read-only)
3886 (insert-buffer-substring gnus-original-article-buffer)))
3888 (defun gnus-article-make-full-mail-header (&optional number charset)
3889 "Create a new mail header structure in a raw article buffer."
3890 (unless (and number charset)
3891 (save-current-buffer
3892 (set-buffer gnus-summary-buffer)
3894 (setq number (or (cdr gnus-article-current) 0)))
3896 (setq charset (or default-mime-charset 'x-ctext)))))
3897 (goto-char (point-min))
3898 (let ((header-end (if (search-forward "\n\n" nil t)
3900 (goto-char (point-max))))
3901 (chars (- (point-max) (point)))
3902 (lines (count-lines (point) (point-max)))
3903 (default-mime-charset charset)
3905 (narrow-to-region (point-min) header-end)
3906 (setq xref (std11-fetch-field "xref"))
3908 (make-full-mail-header
3910 (std11-fetch-field "subject")
3911 (std11-fetch-field "from")
3912 (std11-fetch-field "date")
3913 (std11-fetch-field "message-id")
3914 (std11-fetch-field "references")
3917 (when xref (concat "Xref: " xref)))
3920 (defun gnus-article-prepare (article &optional all-headers header)
3921 "Prepare ARTICLE in article mode buffer.
3922 ARTICLE should either be an article number or a Message-ID.
3923 If ARTICLE is an id, HEADER should be the article headers.
3924 If ALL-HEADERS is non-nil, no headers are hidden."
3926 ;; Make sure we start in a summary buffer.
3927 (unless (eq major-mode 'gnus-summary-mode)
3928 (set-buffer gnus-summary-buffer))
3929 (setq gnus-summary-buffer (current-buffer))
3930 (let* ((gnus-article (if header (mail-header-number header) article))
3931 (summary-buffer (current-buffer))
3932 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3933 (group gnus-newsgroup-name)
3936 (gnus-article-setup-buffer)
3937 (set-buffer gnus-article-buffer)
3938 ;; Deactivate active regions.
3939 (when (and (boundp 'transient-mark-mode)
3940 transient-mark-mode)
3941 (setq mark-active nil))
3942 (if (not (setq result (let ((buffer-read-only nil))
3943 (gnus-request-article-this-buffer
3945 ;; There is no such article.
3947 (when (and (numberp article)
3948 (not (memq article gnus-newsgroup-sparse)))
3949 (setq gnus-article-current
3950 (cons gnus-newsgroup-name article))
3951 (set-buffer gnus-summary-buffer)
3952 (setq gnus-current-article article)
3953 (if (and (memq article gnus-newsgroup-undownloaded)
3954 (not (gnus-online (gnus-find-method-for-group
3955 gnus-newsgroup-name))))
3957 (gnus-summary-set-agent-mark article)
3958 (message "Message marked for downloading"))
3959 (gnus-summary-mark-article article gnus-canceled-mark)
3960 (unless (memq article gnus-newsgroup-sparse)
3961 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3962 (if (or (eq result 'pseudo)
3963 (eq result 'nneething))
3966 (set-buffer summary-buffer)
3967 (push article gnus-newsgroup-history)
3968 (setq gnus-last-article gnus-current-article
3969 gnus-current-article 0
3970 gnus-current-headers nil
3971 gnus-article-current nil)
3972 (if (eq result 'nneething)
3973 (gnus-configure-windows 'summary)
3974 (gnus-configure-windows 'article))
3975 (gnus-set-global-variables))
3976 (let ((gnus-article-mime-handle-alist-1
3977 gnus-article-mime-handle-alist))
3978 (gnus-set-mode-line 'article)))
3979 ;; The result from the `request' was an actual article -
3980 ;; or at least some text that is now displayed in the
3982 (when (and (numberp article)
3983 (not (eq article gnus-current-article)))
3984 ;; Seems like a new article has been selected.
3985 ;; `gnus-current-article' must be an article number.
3987 (set-buffer summary-buffer)
3988 (push article gnus-newsgroup-history)
3989 (setq gnus-last-article gnus-current-article
3990 gnus-current-article article
3991 gnus-current-headers
3992 (gnus-summary-article-header gnus-current-article)
3993 gnus-article-current
3994 (cons gnus-newsgroup-name gnus-current-article))
3995 (unless (vectorp gnus-current-headers)
3996 (setq gnus-current-headers nil))
3997 (gnus-summary-goto-subject gnus-current-article)
3998 (when (gnus-summary-show-thread)
3999 ;; If the summary buffer really was folded, the
4000 ;; previous goto may not actually have gone to
4001 ;; the right article, but the thread root instead.
4003 (gnus-summary-goto-subject gnus-current-article))
4004 (gnus-run-hooks 'gnus-mark-article-hook)
4005 (gnus-set-mode-line 'summary)
4006 (when (gnus-visual-p 'article-highlight 'highlight)
4007 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4008 ;; Set the global newsgroup variables here.
4009 (gnus-set-global-variables)
4010 (setq gnus-have-all-headers
4011 (or all-headers gnus-show-all-headers))))
4013 (gnus-configure-windows 'article))
4014 (when (or (numberp article)
4016 (gnus-article-prepare-display)
4018 (goto-char (point-min))
4019 (setq gnus-page-broken
4020 (when gnus-break-pages
4021 (gnus-narrow-to-page)
4023 (let ((gnus-article-mime-handle-alist-1
4024 gnus-article-mime-handle-alist))
4025 (gnus-set-mode-line 'article))
4029 (set-window-point (get-buffer-window (current-buffer)) (point))
4030 (gnus-configure-windows 'article)
4033 (defun gnus-article-prepare-mime-display (&optional number)
4034 (goto-char (point-min))
4035 (when (re-search-forward "^[^\t ]+:" nil t)
4036 (goto-char (match-beginning 0)))
4037 (let ((entity (if (eq 1 (point-min))
4038 (get-text-property 1 'mime-view-entity)
4039 (get-text-property (point) 'mime-view-entity)))
4040 last-entity child-entity next type)
4041 (setq child-entity (mime-entity-children entity))
4043 (setq last-entity (nth (1- (length child-entity))
4045 (setq last-entity entity))
4047 (narrow-to-region (point)
4048 (if (search-forward "\n\n" nil t)
4051 (gnus-treat-article 'head)
4052 (put-text-property (point-min) (point-max) 'article-treated-header t)
4053 (goto-char (point-max)))
4054 (while (and (not (eobp)) entity)
4055 (setq next (set-marker
4057 (next-single-property-change (point) 'mime-view-entity
4059 (let ((types (mime-entity-content-type entity)))
4060 (while (eq 'multipart (mime-content-type-primary-type types))
4061 (setq entity (car (mime-entity-children entity))
4062 types (mime-entity-content-type entity)))
4064 (setq type (format "%s/%s"
4065 (mime-content-type-primary-type types)
4066 (mime-content-type-subtype types)))))
4067 (if (string-equal type "message/rfc822")
4070 (let ((children (mime-entity-children entity))
4073 (setq last-children (nth (1- (length children)) children))
4076 (not (eq last-children
4077 (get-text-property next 'mime-view-entity)))
4079 (next-single-property-change next
4081 nil (point-max)))))))
4082 (setq next (next-single-property-change next 'mime-view-entity
4085 (narrow-to-region (point) next)
4086 (gnus-article-prepare-mime-display)
4087 (goto-char (point-max)))
4088 (setq entity (get-text-property (point) 'mime-view-entity)))
4090 (narrow-to-region (point) next)
4091 ;; Kludge. We have to count true number, but for now,
4092 ;; part number is here only to achieve `last'.
4093 (gnus-treat-article nil 1
4094 (if (eq entity last-entity)
4097 (goto-char (point-max)))
4098 (setq entity (get-text-property next 'mime-view-entity))))))
4101 (defun gnus-article-prepare-display ()
4102 "Make the current buffer look like a nice article."
4103 (let ((gnus-article-buffer (current-buffer))
4105 (unless (eq major-mode 'gnus-article-mode)
4106 (gnus-article-mode))
4107 (setq buffer-read-only nil
4108 gnus-button-marker-list nil
4109 gnus-article-wash-types nil
4110 gnus-article-image-alist nil)
4113 (static-if (featurep 'xemacs)
4114 (map-extents (lambda (extent maparg) (delete-extent extent)))
4115 (let ((lists (overlay-lists)))
4116 (dolist (overlay (nconc (car lists) (cdr lists)))
4117 (delete-overlay overlay)))))
4118 (gnus-run-hooks 'gnus-tmp-internal-hook))
4119 (let ((show-mime (unless (member gnus-newsgroup-name '("nndraft:delayed"
4122 (inhibit-read-only t))
4123 (set-buffer gnus-original-article-buffer)
4125 (setq mime-message-structure gnus-current-headers)
4126 (mime-buffer-entity-set-buffer-internal mime-message-structure
4127 gnus-original-article-buffer)
4128 (mime-entity-set-representation-type-internal mime-message-structure
4129 'mime-buffer-entity)
4130 (luna-send mime-message-structure 'initialize-instance
4131 mime-message-structure)
4133 (let (mime-display-header-hook mime-display-text/plain-hook)
4134 (funcall gnus-article-display-method-for-mime))
4135 (funcall gnus-article-display-method-for-traditional))
4136 ;; Call the treatment functions.
4140 (gnus-article-prepare-mime-display)
4141 (narrow-to-region (goto-char (point-min))
4142 (if (search-forward "\n\n" nil t)
4145 (gnus-treat-article 'head)
4146 (put-text-property (point-min) (point-max) 'article-treated-header t)
4147 (goto-char (point-max))
4149 (narrow-to-region (point) (point-max))
4150 (gnus-treat-article nil))
4151 (put-text-property (point-min) (point-max) 'read-only nil)))
4152 (gnus-run-hooks 'gnus-article-prepare-hook))
4154 (defun gnus-article-decode-article-as-default-mime-charset ()
4155 "Decode an article as `default-mime-charset'. It won't work if the
4156 value of the variable `gnus-show-mime' is non-nil."
4157 (unless (or gnus-show-mime
4158 (member gnus-newsgroup-name '("nndraft:delayed"
4160 (set (make-local-variable 'default-mime-charset)
4161 (with-current-buffer gnus-summary-buffer
4162 default-mime-charset))
4163 (decode-mime-charset-region (point-min) (point-max)
4164 default-mime-charset)))
4167 ;;; Gnus MIME viewing functions
4170 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4171 "Format of the MIME buttons.
4173 Valid specifiers include:
4175 %T MIME type, along with additional info
4176 %n The `name' parameter
4177 %d The description, if any
4178 %l The length of the encoded part
4179 %p The part identifier number
4180 %e Dots if the part isn't displayed
4182 General format specifiers can also be used. See Info node
4183 `(gnus)Formatting Variables'.")
4185 (defvar gnus-mime-button-line-format-alist
4186 '((?t gnus-tmp-type ?s)
4187 (?T gnus-tmp-type-long ?s)
4188 (?n gnus-tmp-name ?s)
4189 (?d gnus-tmp-description ?s)
4191 (?l gnus-tmp-length ?d)
4192 (?e gnus-tmp-dots ?s)))
4194 (defvar gnus-mime-button-commands
4195 '((gnus-article-press-button "\r" "Toggle Display")
4196 (gnus-mime-view-part "v" "View Interactively...")
4197 (gnus-mime-view-part-as-type "t" "View As Type...")
4198 (gnus-mime-view-part-as-charset "C" "View As charset...")
4199 (gnus-mime-save-part "o" "Save...")
4200 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4201 (gnus-mime-delete-part "d" "Delete part")
4202 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4203 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4204 (gnus-mime-view-part-internally "E" "View Internally")
4205 (gnus-mime-view-part-externally "e" "View Externally")
4206 (gnus-mime-print-part "p" "Print")
4207 (gnus-mime-pipe-part "|" "Pipe To Command...")
4208 (gnus-mime-action-on-part "." "Take action on the part...")))
4210 (defun gnus-article-mime-part-status ()
4211 (with-current-buffer gnus-article-buffer
4212 (let ((entity (get-text-property (point-min) 'mime-view-entity))
4215 (setq children (mime-entity-children entity))
4216 (setq children (length children)))
4219 (format " (%d parts)" children))
4222 (defvar gnus-mime-button-map
4223 (let ((map (make-sparse-keymap)))
4224 (unless (>= (string-to-number emacs-version) 21)
4225 ;; XEmacs doesn't care.
4226 (set-keymap-parent map gnus-article-mode-map))
4227 (define-key map gnus-mouse-2 'gnus-article-push-button)
4228 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4229 (dolist (c gnus-mime-button-commands)
4230 (define-key map (cadr c) (car c)))
4234 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4236 ,@(mapcar (lambda (c)
4237 (vector (caddr c) (car c) :enable t))
4238 gnus-mime-button-commands)))
4241 (define-compiler-macro popup-menu (&whole form
4242 menu &optional position prefix)
4243 (if (and (fboundp 'popup-menu)
4244 (not (memq 'popup-menu (assoc "lmenu" load-history))))
4246 ;; Gnus is probably running under Emacs 20.
4247 `(let* ((menu (cdr ,menu))
4248 (response (x-popup-menu
4250 (cons "" (mapcar (lambda (c)
4251 (cons (caddr c) (car c)))
4254 (call-interactively (nth 3 (assq response menu))))))))
4256 (defun gnus-mime-button-menu (event prefix)
4257 "Construct a context-sensitive menu of MIME commands."
4258 (interactive "e\nP")
4259 (save-window-excursion
4260 (let ((pos (event-start event)))
4261 (select-window (posn-window pos))
4262 (goto-char (posn-point pos))
4263 (gnus-article-check-buffer)
4264 (popup-menu gnus-mime-button-menu nil prefix))))
4266 (defun gnus-mime-view-all-parts (&optional handles)
4267 "View all the MIME parts."
4269 (save-current-buffer
4270 (set-buffer gnus-article-buffer)
4271 (let ((handles (or handles gnus-article-mime-handles))
4272 (mail-parse-charset gnus-newsgroup-charset)
4273 (mail-parse-ignored-charsets
4274 (with-current-buffer gnus-summary-buffer
4275 gnus-newsgroup-ignored-charsets)))
4277 (mm-remove-parts handles)
4278 (goto-char (point-min))
4279 (or (search-forward "\n\n") (goto-char (point-max)))
4280 (let (buffer-read-only)
4281 (delete-region (point) (point-max))
4282 (mm-display-parts handles))))))
4284 (defun gnus-mime-save-part-and-strip ()
4285 "Save the MIME part under point then replace it with an external body."
4287 (gnus-article-check-buffer)
4288 (let* ((data (get-text-property (point) 'gnus-data))
4290 (handles gnus-article-mime-handles))
4291 (if (mm-multiple-handles gnus-article-mime-handles)
4292 (error "This function is not implemented"))
4293 (setq file (and data (mm-save-part data)))
4295 (with-current-buffer (mm-handle-buffer data)
4297 (insert "Content-Type: " (mm-handle-media-type data))
4298 (mml-insert-parameter-string (cdr (mm-handle-type data))
4301 (insert "Content-ID: " (message-make-message-id) "\n")
4302 (insert "Content-Transfer-Encoding: binary\n")
4305 (cdr (mm-make-handle nil
4306 `("message/external-body"
4307 (access-type . "LOCAL-FILE")
4309 (set-buffer gnus-summary-buffer)
4310 (gnus-article-edit-article
4313 (let ((mail-parse-charset (or gnus-article-charset
4314 ',gnus-newsgroup-charset))
4315 (mail-parse-ignored-charsets
4316 (or gnus-article-ignored-charsets
4317 ',gnus-newsgroup-ignored-charsets))
4318 (mbl mml-buffer-list))
4319 (setq mml-buffer-list nil)
4320 (insert-buffer gnus-original-article-buffer)
4321 (mime-to-mml ',handles)
4322 (setq gnus-article-mime-handles nil)
4323 (let ((mbl1 mml-buffer-list))
4324 (setq mml-buffer-list mbl)
4325 (set (make-local-variable 'mml-buffer-list) mbl1))
4326 (gnus-make-local-hook 'kill-buffer-hook)
4327 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4328 `(lambda (no-highlight)
4329 (let ((mail-parse-charset (or gnus-article-charset
4330 ',gnus-newsgroup-charset))
4331 (message-options message-options)
4332 (message-options-set-recipient)
4333 (mail-parse-ignored-charsets
4334 (or gnus-article-ignored-charsets
4335 ',gnus-newsgroup-ignored-charsets)))
4337 (mml-destroy-buffers)
4338 (remove-hook 'kill-buffer-hook
4339 'mml-destroy-buffers t)
4340 (kill-local-variable 'mml-buffer-list))
4341 (gnus-summary-edit-article-done
4342 ,(or (mail-header-references gnus-current-headers) "")
4343 ,(gnus-group-read-only-p)
4344 ,gnus-summary-buffer no-highlight))))))
4346 (defun gnus-mime-delete-part ()
4347 "Delete the MIME part under point.
4348 Replace it with some information about the removed part."
4350 (gnus-article-check-buffer)
4351 (unless (and gnus-novice-user
4352 (not (gnus-yes-or-no-p
4353 "Really delete attachment forever? ")))
4354 (let* ((data (get-text-property (point) 'gnus-data))
4355 (handles gnus-article-mime-handles)
4359 (mail-decode-encoded-word-string (or (mm-handle-description data)
4362 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4364 (type (mm-handle-media-type data)))
4365 (if (mm-multiple-handles gnus-article-mime-handles)
4366 (error "This function is not implemented"))
4367 (with-current-buffer (mm-handle-buffer data)
4368 (let ((bsize (format "%s" (buffer-size))))
4372 "<#part type=text/plain nofile=yes disposition=attachment"
4373 " description=\"Deleted attachment (" bsize " Byte)\">"
4375 "| The following attachment has been deleted:\n"
4377 "| Type: " type "\n"
4378 "| Filename: " filename "\n"
4379 "| Size (encoded): " bsize " Byte\n"
4380 "| Description: " description "\n"
4384 (cdr (mm-make-handle nil `("text/plain"))))))
4385 (set-buffer gnus-summary-buffer)
4386 ;; FIXME: maybe some of the following code (borrowed from
4387 ;; `gnus-mime-save-part-and-strip') isn't necessary?
4388 (gnus-article-edit-article
4391 (let ((mail-parse-charset (or gnus-article-charset
4392 ',gnus-newsgroup-charset))
4393 (mail-parse-ignored-charsets
4394 (or gnus-article-ignored-charsets
4395 ',gnus-newsgroup-ignored-charsets))
4396 (mbl mml-buffer-list))
4397 (setq mml-buffer-list nil)
4398 (insert-buffer gnus-original-article-buffer)
4399 (mime-to-mml ',handles)
4400 (setq gnus-article-mime-handles nil)
4401 (let ((mbl1 mml-buffer-list))
4402 (setq mml-buffer-list mbl)
4403 (set (make-local-variable 'mml-buffer-list) mbl1))
4404 (gnus-make-local-hook 'kill-buffer-hook)
4405 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4406 `(lambda (no-highlight)
4407 (let ((mail-parse-charset (or gnus-article-charset
4408 ',gnus-newsgroup-charset))
4409 (message-options message-options)
4410 (message-options-set-recipient)
4411 (mail-parse-ignored-charsets
4412 (or gnus-article-ignored-charsets
4413 ',gnus-newsgroup-ignored-charsets)))
4415 (mml-destroy-buffers)
4416 (remove-hook 'kill-buffer-hook
4417 'mml-destroy-buffers t)
4418 (kill-local-variable 'mml-buffer-list))
4419 (gnus-summary-edit-article-done
4420 ,(or (mail-header-references gnus-current-headers) "")
4421 ,(gnus-group-read-only-p)
4422 ,gnus-summary-buffer no-highlight)))))
4423 ;; Not in `gnus-mime-save-part-and-strip':
4424 (gnus-article-edit-done)
4425 (gnus-summary-expand-window)
4426 (gnus-summary-show-article))
4428 (defun gnus-mime-save-part ()
4429 "Save the MIME part under point."
4431 (gnus-article-check-buffer)
4432 (let ((data (get-text-property (point) 'gnus-data)))
4434 (mm-save-part data))))
4436 (defun gnus-mime-pipe-part ()
4437 "Pipe the MIME part under point to a process."
4439 (gnus-article-check-buffer)
4440 (let ((data (get-text-property (point) 'gnus-data)))
4442 (mm-pipe-part data))))
4444 (defun gnus-mime-view-part ()
4445 "Interactively choose a viewing method for the MIME part under point."
4447 (gnus-article-check-buffer)
4448 (let ((data (get-text-property (point) 'gnus-data)))
4450 (setq gnus-article-mime-handles
4452 gnus-article-mime-handles (setq data (copy-sequence data))))
4453 (mm-interactively-view-part data))))
4455 (defun gnus-mime-view-part-as-type-internal ()
4456 (gnus-article-check-buffer)
4457 (let* ((name (mail-content-type-get
4458 (mm-handle-type (get-text-property (point) 'gnus-data))
4460 (def-type (and name (mm-default-file-encoding name))))
4461 (and def-type (cons def-type 0))))
4463 (defun gnus-mime-view-part-as-type (&optional mime-type)
4464 "Choose a MIME media type, and view the part as such."
4467 (setq mime-type (completing-read
4468 "View as MIME type: "
4469 (mapcar #'list (mailcap-mime-types))
4471 (gnus-mime-view-part-as-type-internal))))
4472 (gnus-article-check-buffer)
4473 (let ((handle (get-text-property (point) 'gnus-data)))
4476 (mm-make-handle (mm-handle-buffer handle)
4477 (cons mime-type (cdr (mm-handle-type handle)))
4478 (mm-handle-encoding handle)
4479 (mm-handle-undisplayer handle)
4480 (mm-handle-disposition handle)
4481 (mm-handle-description handle)
4483 (mm-handle-id handle)))
4484 (setq gnus-article-mime-handles
4485 (mm-merge-handles gnus-article-mime-handles handle))
4486 (gnus-mm-display-part handle))))
4489 (require 'jka-compr))
4491 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4492 ;; emacs can do that itself.
4494 (defun gnus-mime-jka-compr-maybe-uncompress ()
4495 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4496 The uncompress method used is derived from `buffer-file-name'."
4497 (when (and (fboundp 'jka-compr-installed-p)
4498 (jka-compr-installed-p))
4499 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4501 (let ((basename (file-name-nondirectory buffer-file-name))
4502 (args (jka-compr-info-uncompress-args info))
4503 (prog (jka-compr-info-uncompress-program info))
4504 (message (jka-compr-info-uncompress-message info))
4505 (err-file (jka-compr-make-temp-name)))
4507 (message "%s %s..." message basename))
4509 (unless (memq (apply 'call-process-region
4510 (point-min) (point-max)
4512 t (list t err-file) nil
4514 jka-compr-acceptable-retval-list)
4515 (jka-compr-error prog args basename message err-file))
4516 (jka-compr-delete-temp-file err-file)))))))
4518 (defun gnus-mime-copy-part (&optional handle)
4519 "Put the MIME part under point into a new buffer.
4520 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4523 (gnus-article-check-buffer)
4524 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4525 (contents (and handle (mm-get-part handle)))
4527 (file-name-nondirectory
4529 (mail-content-type-get (mm-handle-type handle) 'name)
4530 (mail-content-type-get (mm-handle-disposition handle)
4533 (buffer (and base (generate-new-buffer base))))
4535 (switch-to-buffer buffer)
4537 ;; We do it this way to make `normal-mode' set the appropriate mode.
4540 (setq buffer-file-name (expand-file-name base))
4541 (gnus-mime-jka-compr-maybe-uncompress)
4543 (setq buffer-file-name nil))
4544 (goto-char (point-min)))))
4546 (defun gnus-mime-print-part (&optional handle filename)
4547 "Print the MIME part under point."
4548 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4549 (gnus-article-check-buffer)
4550 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4551 (contents (and handle (mm-get-part handle)))
4552 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4553 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4558 (mm-save-part-to-file handle file)
4559 (call-process shell-file-name nil
4560 (generate-new-buffer " *mm*")
4562 shell-command-switch
4564 printer file (mm-handle-type handle))))
4568 (gnus-print-buffer))
4569 (ps-despool filename)))))
4571 (defun gnus-mime-inline-part (&optional handle arg)
4572 "Insert the MIME part under point into the current buffer."
4573 (interactive (list nil current-prefix-arg))
4574 (gnus-article-check-buffer)
4575 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4580 (if (and (not arg) (mm-handle-undisplayer handle))
4581 (mm-remove-part handle)
4582 (setq contents (mm-get-part handle))
4585 (setq charset (or (mail-content-type-get
4586 (mm-handle-type handle) 'charset)
4587 gnus-newsgroup-charset)))
4589 (if (mm-handle-undisplayer handle)
4590 (mm-remove-part handle))
4593 gnus-summary-show-article-charset-alist))
4594 (mm-read-coding-system "Charset: ")))))
4596 (mm-insert-inline handle
4598 (setq charset (mm-charset-to-coding-system
4600 (not (eq charset 'ascii)))
4601 (mm-decode-coding-string contents charset)
4605 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4606 "Insert the MIME part under point into the current buffer using the
4608 (interactive (list nil current-prefix-arg))
4609 (gnus-article-check-buffer)
4610 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4615 (if (mm-handle-undisplayer handle)
4616 (mm-remove-part handle))
4617 (let ((gnus-newsgroup-charset
4619 gnus-summary-show-article-charset-alist))
4620 (mm-read-coding-system "Charset: ")))
4621 (gnus-newsgroup-ignored-charsets 'gnus-all))
4622 (gnus-article-press-button)))))
4624 (defun gnus-mime-view-part-externally (&optional handle)
4625 "View the MIME part under point with an external viewer."
4627 (gnus-article-check-buffer)
4628 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4629 (mm-user-display-methods nil)
4630 (mm-inlined-types nil)
4631 (mail-parse-charset gnus-newsgroup-charset)
4632 (mail-parse-ignored-charsets
4633 (save-excursion (set-buffer gnus-summary-buffer)
4634 gnus-newsgroup-ignored-charsets)))
4636 (if (mm-handle-undisplayer handle)
4637 (mm-remove-part handle)
4638 (mm-display-part handle)))))
4640 (defun gnus-mime-view-part-internally (&optional handle)
4641 "View the MIME part under point with an internal viewer.
4642 If no internal viewer is available, use an external viewer."
4644 (gnus-article-check-buffer)
4645 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4646 (mm-inlined-types '(".*"))
4647 (mm-inline-large-images t)
4648 (mail-parse-charset gnus-newsgroup-charset)
4649 (mail-parse-ignored-charsets
4650 (save-excursion (set-buffer gnus-summary-buffer)
4651 gnus-newsgroup-ignored-charsets))
4654 (if (mm-handle-undisplayer handle)
4655 (mm-remove-part handle)
4656 (mm-display-part handle)))))
4658 (defun gnus-mime-action-on-part (&optional action)
4659 "Do something with the MIME attachment at \(point\)."
4661 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4662 (gnus-article-check-buffer)
4663 (let ((action-pair (assoc action gnus-mime-action-alist)))
4665 (funcall (cdr action-pair)))))
4667 (defun gnus-article-part-wrapper (n function)
4668 (save-current-buffer
4669 (set-buffer gnus-article-buffer)
4670 (when (> n (length gnus-article-mime-handle-alist))
4671 (error "No such part"))
4672 (gnus-article-goto-part n)
4673 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4674 (funcall function handle))))
4676 (defun gnus-article-pipe-part (n)
4677 "Pipe MIME part N, which is the numerical prefix."
4679 (gnus-article-part-wrapper n 'mm-pipe-part))
4681 (defun gnus-article-save-part (n)
4682 "Save MIME part N, which is the numerical prefix."
4684 (gnus-article-part-wrapper n 'mm-save-part))
4686 (defun gnus-article-interactively-view-part (n)
4687 "View MIME part N interactively, which is the numerical prefix."
4689 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4691 (defun gnus-article-copy-part (n)
4692 "Copy MIME part N, which is the numerical prefix."
4694 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4696 (defun gnus-article-view-part-as-charset (n)
4697 "Copy MIME part N, which is the numerical prefix."
4699 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4701 (defun gnus-article-view-part-externally (n)
4702 "View MIME part N externally, which is the numerical prefix."
4704 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4706 (defun gnus-article-inline-part (n)
4707 "Inline MIME part N, which is the numerical prefix."
4709 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4711 (defun gnus-article-mime-match-handle-first (condition)
4713 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4714 (while (setq ihandle (pop alist))
4716 ((functionp condition)
4717 (funcall condition (cdr ihandle)))
4718 ((eq condition 'undisplayed)
4719 (not (or (mm-handle-undisplayer (cdr ihandle))
4720 (equal (mm-handle-media-type (cdr ihandle))
4721 "multipart/alternative"))))
4722 ((eq condition 'undisplayed-alternative)
4723 (not (mm-handle-undisplayer (cdr ihandle))))
4725 (gnus-article-goto-part (car ihandle))
4726 (or (not n) (< (car ihandle) n)))
4727 (setq n (car ihandle))))
4731 (defun gnus-article-view-part (&optional n)
4732 "View MIME part N, which is the numerical prefix."
4734 (save-current-buffer
4735 (set-buffer gnus-article-buffer)
4736 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4737 gnus-article-mime-match-handle-function)))
4738 (when (> n (length gnus-article-mime-handle-alist))
4739 (error "No such part"))
4740 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4741 (when (gnus-article-goto-part n)
4742 (if (equal (car handle) "multipart/alternative")
4743 (gnus-article-press-button)
4744 (when (eq (gnus-mm-display-part handle) 'internal)
4745 (gnus-set-window-start)))))))
4747 (defsubst gnus-article-mime-total-parts ()
4748 (if (bufferp (car gnus-article-mime-handles))
4750 (1- (length gnus-article-mime-handles))))
4752 (defun gnus-mm-display-part (handle)
4753 "Display HANDLE and fix MIME button."
4754 (let ((id (get-text-property (point) 'gnus-part))
4759 (let ((window (selected-window))
4760 (mail-parse-charset gnus-newsgroup-charset)
4761 (mail-parse-ignored-charsets
4762 (if (gnus-buffer-live-p gnus-summary-buffer)
4764 (set-buffer gnus-summary-buffer)
4765 gnus-newsgroup-ignored-charsets)
4769 (let ((win (gnus-get-buffer-window (current-buffer) t))
4772 (select-window win))
4775 (if (mm-handle-displayed-p handle)
4776 ;; This will remove the part.
4777 (mm-display-part handle)
4779 (narrow-to-region (point)
4780 (if (eobp) (point) (1+ (point))))
4781 (mm-display-part handle)
4782 ;; We narrow to the part itself and
4783 ;; then call the treatment functions.
4784 (goto-char (point-min))
4786 (narrow-to-region (point) (point-max))
4789 (gnus-article-mime-total-parts)
4790 (mm-handle-media-type handle)))))
4791 (if (window-live-p window)
4792 (select-window window)))))
4795 (gnus-insert-mime-button
4796 handle id (list (mm-handle-displayed-p handle)))
4797 (goto-char point))))
4799 (defun gnus-article-goto-part (n)
4800 "Go to MIME part N."
4801 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4803 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4804 (let ((gnus-tmp-name
4805 (or (mail-content-type-get (mm-handle-type handle) 'name)
4806 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4807 (mail-content-type-get (mm-handle-type handle) 'url)
4809 (gnus-tmp-type (mm-handle-media-type handle))
4810 (gnus-tmp-description
4811 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4814 (if (if displayed (car displayed)
4815 (mm-handle-displayed-p handle))
4817 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4819 gnus-tmp-type-long b e)
4820 (when (string-match ".*/" gnus-tmp-name)
4821 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4822 (setq gnus-tmp-type-long (concat gnus-tmp-type
4823 (and (not (equal gnus-tmp-name ""))
4824 (concat "; " gnus-tmp-name))))
4825 (unless (equal gnus-tmp-description "")
4826 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4831 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4832 `(,@(gnus-local-map-property gnus-mime-button-map)
4833 gnus-callback gnus-mm-display-part
4834 gnus-part ,gnus-tmp-id
4835 article-type annotation
4838 ;; Exclude a newline.
4841 (widget-convert-button
4844 :action 'gnus-widget-press-button
4845 :button-keymap gnus-mime-button-map
4847 (lambda (widget/window &optional overlay pos)
4848 ;; Needed to properly clear the message due to a bug in
4849 ;; wid-edit (XEmacs only).
4850 (if (boundp 'help-echo-owns-message)
4851 (setq help-echo-owns-message t))
4853 "%S: %s the MIME part; %S: more options"
4854 (aref gnus-mouse-2 0)
4855 ;; XEmacs will get a single widget arg; Emacs 21 will get
4856 ;; window, overlay, position.
4857 (if (mm-handle-displayed-p
4859 (with-current-buffer (gnus-overlay-buffer overlay)
4860 (widget-get (widget-at (gnus-overlay-start overlay))
4862 (widget-get widget/window :mime-handle)))
4864 (aref gnus-down-mouse-3 0))))))
4866 (defun gnus-widget-press-button (elems el)
4867 (goto-char (widget-get elems :from))
4868 (gnus-article-press-button))
4870 (defvar gnus-displaying-mime nil)
4872 (defun gnus-display-mime (&optional ihandles)
4873 "Display the MIME parts."
4875 (save-selected-window
4876 (let ((window (get-buffer-window gnus-article-buffer))
4879 (select-window window)
4880 ;; We have to do this since selecting the window
4881 ;; may change the point. So we set the window point.
4882 (set-window-point window point)))
4883 (let* ((handles (or ihandles
4884 (mm-dissect-buffer nil gnus-article-loose-mime)
4885 (and gnus-article-emulate-mime
4887 buffer-read-only handle name type b e display)
4888 (when (and (not ihandles)
4889 (not gnus-displaying-mime))
4890 ;; Top-level call; we clean up.
4891 (when gnus-article-mime-handles
4892 (mm-destroy-parts gnus-article-mime-handles)
4893 (setq gnus-article-mime-handle-alist nil));; A trick.
4894 (setq gnus-article-mime-handles handles)
4895 ;; We allow users to glean info from the handles.
4896 (when gnus-article-mime-part-function
4897 (gnus-mime-part-function handles)))
4899 (or (not (stringp (car handles)))
4902 (when (and (not ihandles)
4903 (not gnus-displaying-mime))
4904 ;; Clean up for mime parts.
4906 (delete-region (point) (point-max)))
4907 (let ((gnus-displaying-mime t))
4908 (gnus-mime-display-part handles)))
4911 (narrow-to-region (point) (point-max))
4912 (gnus-treat-article nil 1 1)
4915 ;; Highlight the headers.
4919 (narrow-to-region (point-min) (point))
4920 (gnus-treat-article 'head))))))))
4922 (defcustom gnus-mime-display-multipart-as-mixed nil
4923 "Display \"multipart\" parts as \"multipart/mixed\".
4925 If t, it overrides nil values of
4926 `gnus-mime-display-multipart-alternative-as-mixed' and
4927 `gnus-mime-display-multipart-related-as-mixed'."
4928 :group 'gnus-article-mime
4931 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4932 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4933 :group 'gnus-article-mime
4936 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4937 "Display \"multipart/related\" parts as \"multipart/mixed\".
4939 If displaying \"text/html\" is discouraged \(see
4940 `mm-discouraged-alternatives'\) images or other material inside a
4941 \"multipart/related\" part might be overlooked when this variable is nil."
4942 :group 'gnus-article-mime
4945 (defun gnus-mime-display-part (handle)
4948 ((not (stringp (car handle)))
4949 (gnus-mime-display-single handle))
4950 ;; User-defined multipart
4951 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4952 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4954 ;; multipart/alternative
4955 ((and (equal (car handle) "multipart/alternative")
4956 (not (or gnus-mime-display-multipart-as-mixed
4957 gnus-mime-display-multipart-alternative-as-mixed)))
4958 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4959 (push (cons id handle) gnus-article-mime-handle-alist)
4960 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4961 ;; multipart/related
4962 ((and (equal (car handle) "multipart/related")
4963 (not (or gnus-mime-display-multipart-as-mixed
4964 gnus-mime-display-multipart-related-as-mixed)))
4965 ;;;!!!We should find the start part, but we just default
4966 ;;;!!!to the first part.
4967 ;;(gnus-mime-display-part (cadr handle))
4968 ;;;!!! Most multipart/related is an HTML message plus images.
4969 ;;;!!! Unfortunately we are unable to let W3 display those
4970 ;;;!!! included images, so we just display it as a mixed multipart.
4971 ;;(gnus-mime-display-mixed (cdr handle))
4972 ;;;!!! No, w3 can display everything just fine.
4973 (gnus-mime-display-part (cadr handle)))
4974 ((equal (car handle) "multipart/signed")
4975 (gnus-add-wash-type 'signed)
4976 (gnus-mime-display-security handle))
4977 ((equal (car handle) "multipart/encrypted")
4978 (gnus-add-wash-type 'encrypted)
4979 (gnus-mime-display-security handle))
4980 ;; Other multiparts are handled like multipart/mixed.
4982 (gnus-mime-display-mixed (cdr handle)))))
4984 (defun gnus-mime-part-function (handles)
4985 (if (stringp (car handles))
4986 (mapcar 'gnus-mime-part-function (cdr handles))
4987 (funcall gnus-article-mime-part-function handles)))
4989 (defun gnus-mime-display-mixed (handles)
4990 (mapcar 'gnus-mime-display-part handles))
4992 (defun gnus-mime-display-single (handle)
4993 (let ((type (mm-handle-media-type handle))
4994 (ignored gnus-ignored-mime-types)
5001 (when (string-match (pop ignored) type)
5002 (throw 'ignored nil)))
5003 (if (and (setq not-attachment
5004 (and (not (mm-inline-override-p handle))
5005 (or (not (mm-handle-disposition handle))
5006 (equal (car (mm-handle-disposition handle))
5008 (mm-attachment-override-p handle))))
5009 (mm-automatic-display-p handle)
5011 (mm-inlinable-p handle)
5012 (mm-inlined-p handle))
5013 (mm-automatic-external-display-p type)))
5015 (when (equal (mm-handle-media-supertype handle) "text")
5017 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5019 (push (cons id handle) gnus-article-mime-handle-alist)
5020 (when (or (not display)
5021 (not (gnus-unbuttonized-mime-type-p type)))
5022 ;(gnus-article-insert-newline)
5023 (gnus-insert-mime-button
5024 handle id (list (or display (and not-attachment text))))
5025 (gnus-article-insert-newline)
5026 ;(gnus-article-insert-newline)
5027 ;; Remember modify the number of forward lines.
5035 (let ((mail-parse-charset gnus-newsgroup-charset)
5036 (mail-parse-ignored-charsets
5037 (save-excursion (condition-case ()
5038 (set-buffer gnus-summary-buffer)
5040 gnus-newsgroup-ignored-charsets)))
5041 (mm-display-part handle t))
5042 (goto-char (point-max)))
5043 ((and text not-attachment)
5047 (gnus-article-insert-newline)
5048 (mm-insert-inline handle (mm-get-part handle))
5049 (goto-char (point-max))))
5053 (narrow-to-region beg (point))
5056 (gnus-article-mime-total-parts)
5057 (mm-handle-media-type handle)))))))))
5059 (defun gnus-unbuttonized-mime-type-p (type)
5060 "Say whether TYPE is to be unbuttonized."
5061 (unless gnus-inhibit-mime-unbuttonizing
5063 (let ((types gnus-unbuttonized-mime-types))
5065 (when (string-match (pop types) type)
5066 (throw 'found t)))))
5068 (let ((types gnus-buttonized-mime-types))
5070 (when (string-match (pop types) type)
5071 (throw 'found t)))))))))
5073 (defun gnus-article-insert-newline ()
5074 "Insert a newline, but mark it as undeletable."
5075 (gnus-put-text-property
5076 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5078 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5079 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5082 handle buffer-read-only from props begend not-pref)
5083 (save-window-excursion
5086 (narrow-to-region (car ibegend)
5089 (goto-char (car ibegend))
5092 (delete-region (point-min) (point-max))
5093 (mm-remove-parts handles))
5094 (setq begend (list (point-marker)))
5096 (unless (setq not-pref (cadr (member preferred ihandles)))
5097 (setq not-pref (car ihandles)))
5100 (not (gnus-unbuttonized-mime-type-p
5101 "multipart/alternative")))
5102 (gnus-add-text-properties
5105 (insert (format "%d. " id))
5109 (unless ,(not ibegend)
5110 (setq gnus-article-mime-handle-alist
5111 ',gnus-article-mime-handle-alist))
5112 (gnus-mime-display-alternative
5113 ',ihandles ',not-pref ',begend ,id))
5114 ,@(gnus-local-map-property gnus-mime-button-map)
5115 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5116 face ,gnus-article-button-face
5119 (widget-convert-button 'link from (point)
5120 :action 'gnus-widget-press-button
5121 :button-keymap gnus-widget-button-keymap)
5123 (while (setq handle (pop handles))
5124 (gnus-add-text-properties
5127 (insert (format "(%c) %-18s"
5128 (if (equal handle preferred) ?* ? )
5129 (mm-handle-media-type handle)))
5133 (unless ,(not ibegend)
5134 (setq gnus-article-mime-handle-alist
5135 ',gnus-article-mime-handle-alist))
5136 (gnus-mime-display-alternative
5137 ',ihandles ',handle ',begend ,id))
5138 ,@(gnus-local-map-property gnus-mime-button-map)
5139 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5140 face ,gnus-article-button-face
5143 (widget-convert-button 'link from (point)
5144 :action 'gnus-widget-press-button
5145 :button-keymap gnus-widget-button-keymap)
5149 (if (stringp (car preferred))
5150 (gnus-display-mime preferred)
5151 (let ((mail-parse-charset gnus-newsgroup-charset)
5152 (mail-parse-ignored-charsets
5153 (save-excursion (set-buffer gnus-summary-buffer)
5154 gnus-newsgroup-ignored-charsets)))
5155 (mm-display-part preferred)
5159 (narrow-to-region (car begend) (point-max))
5161 nil (length gnus-article-mime-handle-alist)
5162 (gnus-article-mime-total-parts)
5163 (mm-handle-media-type handle))))))
5164 (goto-char (point-max))
5165 (setcdr begend (point-marker)))))
5167 (goto-char point))))
5169 (defconst gnus-article-wash-status-strings
5170 (let ((alist '((cite "c" "Possible hidden citation text"
5171 " " "All citation text visible")
5172 (headers "h" "Hidden headers"
5173 " " "All headers visible.")
5174 (pgp "p" "Encrypted or signed message status hidden"
5175 " " "No hidden encryption nor digital signature status")
5176 (signature "s" "Signature has been hidden"
5177 " " "Signature is visible")
5178 (overstrike "o" "Overstrike (^H) characters applied"
5179 " " "No overstrike characters applied")
5180 (gnus-show-mime "m" "Mime processing is activated"
5181 " " "Mime processing is not activated")
5182 (emphasis "e" "/*_Emphasis_*/ characters applied"
5183 " " "No /*_emphasis_*/ characters applied")))
5185 (dolist (entry alist result)
5186 (let ((key (nth 0 entry))
5187 (on (copy-sequence (nth 1 entry)))
5188 (on-help (nth 2 entry))
5189 (off (copy-sequence (nth 3 entry)))
5190 (off-help (nth 4 entry)))
5191 (put-text-property 0 1 'help-echo on-help on)
5192 (put-text-property 0 1 'help-echo off-help off)
5193 (push (list key on off) result))))
5194 "Alist of strings describing wash status in the mode line.
5195 Each entry has the form (KEY ON OF), where the KEY is a symbol
5196 representing the particular washing function, ON is the string to use
5197 in the article mode line when the washing function is active, and OFF
5198 is the string to use when it is inactive.")
5200 (defun gnus-article-wash-status-entry (key value)
5201 (let ((entry (assoc key gnus-article-wash-status-strings)))
5202 (if value (nth 1 entry) (nth 2 entry))))
5204 (defun gnus-article-wash-status ()
5205 "Return a string which display status of article washing."
5207 (set-buffer gnus-article-buffer)
5208 (let ((cite (memq 'cite gnus-article-wash-types))
5209 (headers (memq 'headers gnus-article-wash-types))
5210 (boring (memq 'boring-headers gnus-article-wash-types))
5211 (pgp (memq 'pgp gnus-article-wash-types))
5212 (pem (memq 'pem gnus-article-wash-types))
5213 (signed (memq 'signed gnus-article-wash-types))
5214 (encrypted (memq 'encrypted gnus-article-wash-types))
5215 (signature (memq 'signature gnus-article-wash-types))
5216 (overstrike (memq 'overstrike gnus-article-wash-types))
5217 (emphasis (memq 'emphasis gnus-article-wash-types)))
5219 (gnus-article-wash-status-entry 'cite cite)
5220 (gnus-article-wash-status-entry 'headers (or headers boring))
5221 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5222 (gnus-article-wash-status-entry 'signature signature)
5223 (gnus-article-wash-status-entry 'overstrike overstrike)
5224 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
5225 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5227 (defun gnus-add-wash-type (type)
5228 "Add a washing of TYPE to the current status."
5229 (add-to-list 'gnus-article-wash-types type))
5231 (defun gnus-delete-wash-type (type)
5232 "Add a washing of TYPE to the current status."
5233 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5235 (defun gnus-add-image (category image)
5236 "Add IMAGE of CATEGORY to the list of displayed images."
5237 (let ((entry (assq category gnus-article-image-alist)))
5239 (setq entry (list category))
5240 (push entry gnus-article-image-alist))
5241 (nconc entry (list image))))
5243 (defun gnus-delete-images (category)
5244 "Delete all images in CATEGORY."
5245 (let ((entry (assq category gnus-article-image-alist)))
5246 (dolist (image (cdr entry))
5247 (gnus-remove-image image category))
5248 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5249 (gnus-delete-wash-type category)))
5251 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5253 (defun gnus-article-maybe-hide-headers ()
5254 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5255 Provided for backwards compatibility."
5256 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5257 (not (save-excursion (set-buffer gnus-summary-buffer)
5258 gnus-have-all-headers)))
5259 (not gnus-inhibit-hiding))
5260 (gnus-article-hide-headers)))
5264 (defun gnus-output-to-file (file-name)
5265 "Append the current article to a file named FILE-NAME."
5266 (let ((artbuf (current-buffer)))
5268 (insert-buffer-substring artbuf)
5269 ;; Append newline at end of the buffer as separator, and then
5271 (goto-char (point-max))
5273 (let ((file-name-coding-system nnmail-pathname-coding-system)
5274 (pathname-coding-system nnmail-pathname-coding-system))
5275 (write-region-as-binary (point-min) (point-max) file-name 'append))
5278 (defun gnus-narrow-to-page (&optional arg)
5279 "Narrow the article buffer to a page.
5280 If given a numerical ARG, move forward ARG pages."
5282 (setq arg (if arg (prefix-numeric-value arg) 0))
5284 (set-buffer gnus-article-buffer)
5285 (goto-char (point-min))
5287 ;; Remove any old next/prev buttons.
5288 (when (gnus-visual-p 'page-marker)
5289 (let ((buffer-read-only nil))
5290 (gnus-remove-text-with-property 'gnus-prev)
5291 (gnus-remove-text-with-property 'gnus-next)))
5294 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5296 (re-search-forward page-delimiter nil 'move arg)))
5297 (goto-char (match-end 0)))
5300 (if (re-search-forward page-delimiter nil 'move)
5303 (when (and (gnus-visual-p 'page-marker)
5304 (not (= (point-min) 1)))
5306 (goto-char (point-min))
5307 (gnus-insert-prev-page-button)))
5308 (when (and (gnus-visual-p 'page-marker)
5309 (< (+ (point-max) 2) (buffer-size)))
5311 (goto-char (point-max))
5312 (gnus-insert-next-page-button)))))
5314 ;; Article mode commands
5316 (defun gnus-article-goto-next-page ()
5317 "Show the next page of the article."
5319 (when (gnus-article-next-page)
5320 (goto-char (point-min))
5321 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5324 (defun gnus-article-goto-prev-page ()
5325 "Show the next page of the article."
5328 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5329 (gnus-article-prev-page nil)))
5331 ;; This is cleaner but currently breaks `gnus-pick-mode':
5333 ;; (defun gnus-article-goto-next-page ()
5334 ;; "Show the next page of the article."
5336 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5337 ;; (gnus-summary-next-page)))
5339 ;; (defun gnus-article-goto-prev-page ()
5340 ;; "Show the next page of the article."
5342 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5343 ;; (gnus-summary-prev-page)))
5345 (defun gnus-article-next-page (&optional lines)
5346 "Show the next page of the current article.
5347 If end of article, return non-nil. Otherwise return nil.
5348 Argument LINES specifies lines to be scrolled up."
5350 (move-to-window-line -1)
5353 (and (pos-visible-in-window-p) ;Not continuation line.
5354 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5355 ;; Nothing in this page.
5356 (if (or (not gnus-page-broken)
5359 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
5361 (when gnus-article-over-scroll
5362 (gnus-article-next-page-1 lines))
5364 (gnus-narrow-to-page 1) ;Go to next page.
5366 ;; More in this page.
5367 (gnus-article-next-page-1 lines)
5370 (defun gnus-article-next-page-1 (lines)
5371 (let ((scroll-in-place nil))
5375 ;; Long lines may cause an end-of-buffer error.
5376 (goto-char (point-max)))))
5377 (move-to-window-line 0))
5379 (defun gnus-article-prev-page (&optional lines)
5380 "Show previous page of current article.
5381 Argument LINES specifies lines to be scrolled down."
5383 (move-to-window-line 0)
5384 (if (and gnus-page-broken
5386 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5388 (gnus-narrow-to-page -1) ;Go to previous page.
5389 (goto-char (point-max))
5391 (let ((scroll-in-place nil))
5395 (beginning-of-buffer
5396 (goto-char (point-min))))
5397 (move-to-window-line 0)))))
5399 (defun gnus-article-only-boring-p ()
5400 "Decide whether there is only boring text remaining in the article.
5401 Something \"interesting\" is a word of at least two letters that does
5402 not have a face in `gnus-article-boring-faces'."
5403 (when (and gnus-article-skip-boring
5404 (boundp 'gnus-article-boring-faces)
5405 (symbol-value 'gnus-article-boring-faces))
5408 (while (re-search-forward "\\b\\w\\w" nil t)
5410 (when (not (gnus-intersection
5411 (gnus-faces-at (point))
5412 (symbol-value 'gnus-article-boring-faces)))
5413 (throw 'only-boring nil)))
5414 (throw 'only-boring t)))))
5416 (defun gnus-article-refer-article ()
5417 "Read article specified by message-id around point."
5420 (re-search-backward "[ \t]\\|^" (gnus-point-at-bol) t)
5421 (re-search-forward "<?news:<?\\|<" (gnus-point-at-eol) t)
5422 (if (re-search-forward "[^@ ]+@[^ \t>]+" (gnus-point-at-eol) t)
5423 (let ((msg-id (concat "<" (match-string 0) ">")))
5424 (set-buffer gnus-summary-buffer)
5425 (gnus-summary-refer-article msg-id))
5426 (error "No references around point"))))
5428 (defun gnus-article-show-summary ()
5429 "Reconfigure windows to show summary buffer."
5431 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5432 (error "There is no summary buffer for this article buffer")
5433 (gnus-article-set-globals)
5434 (gnus-configure-windows 'article)
5435 (gnus-summary-goto-subject gnus-current-article)
5436 (gnus-summary-position-point)))
5438 (defun gnus-article-describe-briefly ()
5439 "Describe article mode commands briefly."
5441 (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")))
5443 (defun gnus-article-summary-command ()
5444 "Execute the last keystroke in the summary buffer."
5446 (let ((obuf (current-buffer))
5447 (owin (current-window-configuration))
5449 (switch-to-buffer gnus-article-current-summary 'norecord)
5450 (setq func (lookup-key (current-local-map) (this-command-keys)))
5451 (call-interactively func)
5453 (set-window-configuration owin)
5454 (set-window-point (get-buffer-window (current-buffer)) (point))))
5456 (defun gnus-article-summary-command-nosave ()
5457 "Execute the last keystroke in the summary buffer."
5460 (pop-to-buffer gnus-article-current-summary 'norecord)
5461 (setq func (lookup-key (current-local-map) (this-command-keys)))
5462 (call-interactively func)))
5464 (defun gnus-article-check-buffer ()
5465 "Beep if not in an article buffer."
5466 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5467 (error "Command invoked outside of a Gnus article buffer")))
5469 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5470 "Read a summary buffer key sequence and execute it from the article buffer."
5472 (gnus-article-check-buffer)
5474 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5475 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5476 "=" "^" "\M-^" "|"))
5482 '("n" "Gn" "p" "Gp"))
5485 (set-buffer gnus-article-current-summary)
5486 (let (gnus-pick-mode)
5487 (push (or key last-command-event) unread-command-events)
5488 (setq keys (static-if (featurep 'xemacs)
5489 (events-to-keys (read-key-sequence nil))
5490 (read-key-sequence nil)))))
5493 (if (or (member keys nosaves)
5494 (member keys nosave-but-article)
5495 (member keys nosave-in-article))
5497 (save-window-excursion
5498 (pop-to-buffer gnus-article-current-summary 'norecord)
5499 ;; We disable the pick minor mode commands.
5500 (let (gnus-pick-mode)
5501 (setq func (lookup-key (current-local-map) keys))))
5505 (unless (member keys nosave-in-article)
5506 (set-buffer gnus-article-current-summary))
5507 (call-interactively func)
5508 (setq new-sum-point (point)))
5509 (when (member keys nosave-but-article)
5510 (pop-to-buffer gnus-article-buffer 'norecord)))
5511 ;; These commands should restore window configuration.
5512 (let ((obuf (current-buffer))
5513 (owin (current-window-configuration))
5515 (summary gnus-article-current-summary)
5516 func in-buffer selected)
5517 (if not-restore-window
5518 (pop-to-buffer summary 'norecord)
5519 (switch-to-buffer summary 'norecord))
5520 (setq in-buffer (current-buffer))
5521 ;; We disable the pick minor mode commands.
5522 (if (and (setq func (let (gnus-pick-mode)
5523 (lookup-key (current-local-map) keys)))
5526 (call-interactively func)
5527 (setq new-sum-point (point))
5528 (when (eq in-buffer (current-buffer))
5529 (setq selected (gnus-summary-select-article))
5531 (unless not-restore-window
5532 (set-window-configuration owin))
5533 (when (eq selected 'old)
5535 (set-window-start (get-buffer-window (current-buffer))
5537 (set-window-point (get-buffer-window (current-buffer))
5539 (let ((win (get-buffer-window gnus-article-current-summary)))
5541 (set-window-point win new-sum-point)))) )
5542 (switch-to-buffer gnus-article-buffer)
5545 (defun gnus-article-describe-key (key)
5546 "Display documentation of the function invoked by KEY. KEY is a string."
5547 (interactive "kDescribe key: ")
5548 (gnus-article-check-buffer)
5549 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5551 (set-buffer gnus-article-current-summary)
5552 (let (gnus-pick-mode)
5553 (if (featurep 'xemacs)
5555 (push (elt key 0) unread-command-events)
5556 (setq key (events-to-keys
5557 (read-key-sequence "Describe key: "))))
5558 (setq unread-command-events
5560 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5562 (setq key (read-key-sequence "Describe key: "))))
5564 (describe-key key)))
5566 (defun gnus-article-describe-key-briefly (key &optional insert)
5567 "Display documentation of the function invoked by KEY. KEY is a string."
5568 (interactive "kDescribe key: \nP")
5569 (gnus-article-check-buffer)
5570 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5572 (set-buffer gnus-article-current-summary)
5573 (let (gnus-pick-mode)
5574 (if (featurep 'xemacs)
5576 (push (elt key 0) unread-command-events)
5577 (setq key (events-to-keys
5578 (read-key-sequence "Describe key: "))))
5579 (setq unread-command-events
5581 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5583 (setq key (read-key-sequence "Describe key: "))))
5584 (describe-key-briefly key insert))
5585 (describe-key-briefly key insert)))
5587 (defun gnus-article-reply-with-original (&optional wide)
5588 "Start composing a reply mail to the current message.
5589 The text in the region will be yanked. If the region isn't active,
5590 the entire article will be yanked."
5592 (let ((article (cdr gnus-article-current))
5594 (if (not (gnus-mark-active-p))
5595 (with-current-buffer gnus-summary-buffer
5596 (gnus-summary-reply (list (list article)) wide))
5597 (setq contents (buffer-substring (point) (mark t)))
5598 ;; Deactivate active regions.
5599 (when (and (boundp 'transient-mark-mode)
5600 transient-mark-mode)
5601 (setq mark-active nil))
5602 (with-current-buffer gnus-summary-buffer
5604 (list (list article contents)) wide)))))
5606 (defun gnus-article-followup-with-original ()
5607 "Compose a followup to the current article.
5608 The text in the region will be yanked. If the region isn't active,
5609 the entire article will be yanked."
5611 (let ((article (cdr gnus-article-current))
5613 (if (not (gnus-mark-active-p))
5614 (with-current-buffer gnus-summary-buffer
5615 (gnus-summary-followup (list (list article))))
5616 (setq contents (buffer-substring (point) (mark t)))
5617 ;; Deactivate active regions.
5618 (when (and (boundp 'transient-mark-mode)
5619 transient-mark-mode)
5620 (setq mark-active nil))
5621 (with-current-buffer gnus-summary-buffer
5622 (gnus-summary-followup
5623 (list (list article contents)))))))
5625 (defun gnus-article-hide (&optional arg force)
5626 "Hide all the gruft in the current article.
5627 This means that signatures, cited text and (some) headers will be
5629 If given a prefix, show the hidden text instead."
5630 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5631 (gnus-article-hide-headers arg)
5632 (gnus-article-hide-list-identifiers arg)
5633 (gnus-article-hide-citation-maybe arg force)
5634 (gnus-article-hide-signature arg))
5636 (defun gnus-article-maybe-highlight ()
5637 "Do some article highlighting if article highlighting is requested."
5638 (when (gnus-visual-p 'article-highlight 'highlight)
5639 (gnus-article-highlight-some)))
5641 (defun gnus-check-group-server ()
5642 ;; Make sure the connection to the server is alive.
5643 (unless (gnus-server-opened
5644 (gnus-find-method-for-group gnus-newsgroup-name))
5645 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5646 (gnus-request-group gnus-newsgroup-name t)))
5649 (autoload 'nneething-get-file-name "nneething"))
5651 (defun gnus-request-article-this-buffer (article group)
5652 "Get an article and insert it into this buffer."
5653 (let (do-update-line sparse-header)
5657 (gnus-kill-all-overlays)
5658 (setq group (or group gnus-newsgroup-name))
5660 ;; Using `gnus-request-article' directly will insert the article into
5661 ;; `nntp-server-buffer' - so we'll save some time by not having to
5662 ;; copy it from the server buffer into the article buffer.
5664 ;; We only request an article by message-id when we do not have the
5665 ;; headers for it, so we'll have to get those.
5666 (when (stringp article)
5667 (gnus-read-header article))
5669 ;; If the article number is negative, that means that this article
5670 ;; doesn't belong in this newsgroup (possibly), so we find its
5671 ;; message-id and request it by id instead of number.
5672 (when (and (numberp article)
5674 (get-buffer gnus-summary-buffer)
5675 (gnus-buffer-exists-p gnus-summary-buffer))
5677 (set-buffer gnus-summary-buffer)
5678 (let ((header (gnus-summary-article-header article)))
5681 ((memq article gnus-newsgroup-sparse)
5682 ;; This is a sparse gap article.
5683 (setq do-update-line article)
5684 (setq article (mail-header-id header))
5685 (setq sparse-header (gnus-read-header article))
5686 (setq gnus-newsgroup-sparse
5687 (delq article gnus-newsgroup-sparse)))
5689 ;; It's a real article.
5690 (setq article (mail-header-id header)))
5692 ;; It is an extracted pseudo-article.
5693 (setq article 'pseudo)
5694 (gnus-request-pseudo-article header))))
5696 (let ((method (gnus-find-method-for-group
5697 gnus-newsgroup-name)))
5698 (when (and (eq (car method) 'nneething)
5700 (let ((dir (nneething-get-file-name
5701 (mail-header-id header))))
5702 (when (and (stringp dir)
5703 (file-directory-p dir))
5704 (setq article 'nneething)
5705 (gnus-group-enter-directory dir))))))))
5708 ;; Refuse to select canceled articles.
5709 ((and (numberp article)
5711 (get-buffer gnus-summary-buffer)
5712 (gnus-buffer-exists-p gnus-summary-buffer)
5713 (eq (cdr (save-excursion
5714 (set-buffer gnus-summary-buffer)
5715 (assq article gnus-newsgroup-reads)))
5716 gnus-canceled-mark))
5718 ;; We first check `gnus-original-article-buffer'.
5719 ((and (get-buffer gnus-original-article-buffer)
5722 (set-buffer gnus-original-article-buffer)
5723 (and (equal (car gnus-original-article) group)
5724 (eq (cdr gnus-original-article) article))))
5725 (insert-buffer-substring gnus-original-article-buffer)
5727 ;; Check the backlog.
5728 ((and gnus-keep-backlog
5729 (gnus-backlog-request-article group article (current-buffer)))
5731 ;; Check asynchronous pre-fetch.
5732 ((gnus-async-request-fetched-article group article (current-buffer))
5733 (gnus-async-prefetch-next group article gnus-summary-buffer)
5734 (when (and (numberp article) gnus-keep-backlog)
5735 (gnus-backlog-enter-article group article (current-buffer)))
5738 ((and gnus-use-cache
5740 (gnus-cache-request-article article group))
5742 ;; Check the agent cache.
5743 ((gnus-agent-request-article article group)
5745 ;; Get the article and put into the article buffer.
5746 ((or (stringp article)
5748 (let ((gnus-override-method gnus-override-method)
5749 (methods (and (stringp article)
5750 gnus-refer-article-method))
5751 (backend (car (gnus-find-method-for-group
5752 gnus-newsgroup-name)))
5754 (buffer-read-only nil))
5755 (if (or (not (listp methods))
5756 (and (symbolp (car methods))
5757 (assq (car methods) nnoo-definition-alist)))
5758 (setq methods (list methods)))
5759 (when (and (null gnus-override-method)
5761 (setq gnus-override-method (pop methods)))
5763 (when (eq gnus-override-method 'current)
5764 (setq gnus-override-method
5765 (with-current-buffer gnus-summary-buffer
5766 gnus-current-select-method)))
5768 (gnus-kill-all-overlays)
5769 (let ((gnus-newsgroup-name group))
5770 (gnus-check-group-server))
5772 ((gnus-request-article article group (current-buffer))
5773 (when (numberp article)
5774 (gnus-async-prefetch-next group article
5775 gnus-summary-buffer)
5776 (when gnus-keep-backlog
5777 (gnus-backlog-enter-article
5778 group article (current-buffer))))
5779 (setq result 'article))
5781 (setq gnus-override-method (pop methods)))
5782 ((not (string-match "^400 "
5783 (nnheader-get-report backend)))
5784 ;; If we get 400 server disconnect, reconnect and
5785 ;; retry; otherwise, assume the article has expired.
5786 (setq result 'done))))
5787 (and (eq result 'article) 'article)))
5791 ;; Associate this article with the current summary buffer.
5792 (setq gnus-article-current-summary gnus-summary-buffer)
5794 ;; Take the article from the original article buffer
5795 ;; and place it in the buffer it's supposed to be in.
5796 (when (and (get-buffer gnus-article-buffer)
5797 (equal (buffer-name (current-buffer))
5798 (buffer-name (get-buffer gnus-article-buffer))))
5800 (if (get-buffer gnus-original-article-buffer)
5801 (set-buffer gnus-original-article-buffer)
5802 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5803 (buffer-disable-undo)
5804 (setq major-mode 'gnus-original-article-mode)
5805 (setq buffer-read-only t))
5806 (let (buffer-read-only)
5808 (insert-buffer-substring gnus-article-buffer))
5809 (setq gnus-original-article (cons group article)))
5812 (run-hooks 'gnus-article-decode-hook)
5813 ;; Mark article as decoded or not.
5814 (setq gnus-article-decoded-p gnus-article-decode-hook))
5816 ;; Update sparse articles.
5817 (when (and do-update-line
5818 (or (numberp article)
5820 (let ((buf (current-buffer)))
5821 (set-buffer gnus-summary-buffer)
5822 (gnus-summary-update-article do-update-line sparse-header)
5823 (gnus-summary-goto-subject do-update-line nil t)
5824 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5826 (set-buffer buf))))))
5832 (defcustom gnus-article-edit-mode-hook nil
5833 "Hook run in article edit mode buffers."
5834 :group 'gnus-article-various
5837 (defcustom gnus-article-edit-article-setup-function
5838 'gnus-article-mime-edit-article-setup
5839 "Function called to setup an editing article buffer."
5840 :group 'gnus-article-various
5843 (defvar gnus-article-edit-done-function nil)
5845 (defvar gnus-article-edit-mode-map nil)
5846 (defvar gnus-article-edit-mode nil)
5848 ;; Should we be using derived.el for this?
5849 (unless gnus-article-edit-mode-map
5850 (setq gnus-article-edit-mode-map (make-keymap))
5851 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5853 (gnus-define-keys gnus-article-edit-mode-map
5854 "\C-c?" describe-mode
5855 "\C-c\C-c" gnus-article-edit-done
5856 "\C-c\C-k" gnus-article-edit-exit
5857 "\C-c\C-f\C-t" message-goto-to
5858 "\C-c\C-f\C-o" message-goto-from
5859 "\C-c\C-f\C-b" message-goto-bcc
5860 ;;"\C-c\C-f\C-w" message-goto-fcc
5861 "\C-c\C-f\C-c" message-goto-cc
5862 "\C-c\C-f\C-s" message-goto-subject
5863 "\C-c\C-f\C-r" message-goto-reply-to
5864 "\C-c\C-f\C-n" message-goto-newsgroups
5865 "\C-c\C-f\C-d" message-goto-distribution
5866 "\C-c\C-f\C-f" message-goto-followup-to
5867 "\C-c\C-f\C-m" message-goto-mail-followup-to
5868 "\C-c\C-f\C-k" message-goto-keywords
5869 "\C-c\C-f\C-u" message-goto-summary
5870 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5871 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5872 "\C-c\C-b" message-goto-body
5873 "\C-c\C-i" message-goto-signature
5875 "\C-c\C-t" message-insert-to
5876 "\C-c\C-n" message-insert-newsgroups
5877 "\C-c\C-o" message-sort-headers
5878 "\C-c\C-e" message-elide-region
5879 "\C-c\C-v" message-delete-not-region
5880 "\C-c\C-z" message-kill-to-signature
5881 "\M-\r" message-newline-and-reformat
5882 "\C-c\C-a" mml-attach-file
5883 "\C-a" message-beginning-of-line
5885 "\M-;" comment-region)
5887 (gnus-define-keys (gnus-article-edit-wash-map
5888 "\C-c\C-w" gnus-article-edit-mode-map)
5889 "f" gnus-article-edit-full-stops))
5892 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5894 ["Fetch To" message-insert-to t]
5895 ["Fetch Newsgroups" message-insert-newsgroups t]
5897 ["To" message-goto-to t]
5898 ["From" message-goto-from t]
5899 ["Subject" message-goto-subject t]
5900 ["Cc" message-goto-cc t]
5901 ["Reply-To" message-goto-reply-to t]
5902 ["Summary" message-goto-summary t]
5903 ["Keywords" message-goto-keywords t]
5904 ["Newsgroups" message-goto-newsgroups t]
5905 ["Followup-To" message-goto-followup-to t]
5906 ["Mail-Followup-To" message-goto-mail-followup-to t]
5907 ["Distribution" message-goto-distribution t]
5908 ["Body" message-goto-body t]
5909 ["Signature" message-goto-signature t]))
5911 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5912 "Major mode for editing articles.
5913 This is an extended text-mode.
5915 \\{gnus-article-edit-mode-map}"
5916 (make-local-variable 'gnus-article-edit-done-function)
5917 (make-local-variable 'gnus-prev-winconf)
5918 (set (make-local-variable 'font-lock-defaults)
5919 '(message-font-lock-keywords t))
5920 (set (make-local-variable 'mail-header-separator) "")
5921 (set (make-local-variable 'gnus-article-edit-mode) t)
5922 (easy-menu-add message-mode-field-menu message-mode-map)
5923 (setq buffer-read-only nil)
5924 (buffer-enable-undo)
5927 (defun gnus-article-edit (&optional force)
5928 "Edit the current article.
5929 This will have permanent effect only in mail groups.
5930 If FORCE is non-nil, allow editing of articles even in read-only
5933 (when (and (not force)
5934 (gnus-group-read-only-p))
5935 (error "The current newsgroup does not support article editing"))
5936 (gnus-article-date-original)
5937 (gnus-article-edit-article
5939 `(lambda (no-highlight)
5941 (gnus-summary-edit-article-done
5942 ,(or (mail-header-references gnus-current-headers) "")
5943 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5945 (defun gnus-article-edit-article (start-func exit-func)
5946 "Start editing the contents of the current article buffer."
5947 (let ((winconf (current-window-configuration)))
5948 (set-buffer gnus-article-buffer)
5949 (gnus-article-edit-mode)
5950 (funcall start-func)
5951 (set-buffer-modified-p nil)
5952 (gnus-configure-windows 'edit-article)
5953 (setq gnus-article-edit-done-function exit-func)
5954 (setq gnus-prev-winconf winconf)
5955 (when gnus-article-edit-article-setup-function
5956 (funcall gnus-article-edit-article-setup-function))
5957 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit")))
5959 (defun gnus-article-edit-done (&optional arg)
5960 "Update the article edits and exit."
5962 (let ((func gnus-article-edit-done-function)
5963 (buf (current-buffer))
5964 (start (window-start))
5966 (winconf gnus-prev-winconf))
5967 (remove-hook 'gnus-article-mode-hook
5968 'gnus-article-mime-edit-article-unwind)
5969 (widen) ;; Widen it in case that users narrowed the buffer.
5972 ;; The cache and backlog have to be flushed somewhat.
5973 (when gnus-keep-backlog
5974 (gnus-backlog-remove-article
5975 (car gnus-article-current) (cdr gnus-article-current)))
5976 ;; Flush original article as well.
5978 (when (get-buffer gnus-original-article-buffer)
5979 (set-buffer gnus-original-article-buffer)
5980 (setq gnus-original-article nil)))
5981 (when gnus-use-cache
5982 (gnus-cache-update-article
5983 (car gnus-article-current) (cdr gnus-article-current)))
5984 ;; We remove all text props from the article buffer.
5985 (kill-all-local-variables)
5986 (gnus-set-text-properties (point-min) (point-max) nil)
5988 (set-window-configuration winconf)
5990 (set-window-start (get-buffer-window buf) start)
5991 (set-window-point (get-buffer-window buf) (point))))
5993 (defun gnus-article-edit-exit ()
5994 "Exit the article editing without updating."
5996 (when (or (not (buffer-modified-p))
5997 (yes-or-no-p "Article modified; kill anyway? "))
5998 (let ((curbuf (current-buffer))
6000 (window-start (window-start)))
6002 (if (gnus-buffer-live-p gnus-original-article-buffer)
6003 (insert-buffer-substring gnus-original-article-buffer))
6004 (let ((winconf gnus-prev-winconf))
6005 (kill-all-local-variables)
6007 (set-window-configuration winconf)
6008 ;; Tippy-toe some to make sure that point remains where it was.
6009 (save-current-buffer
6011 (set-window-start (get-buffer-window (current-buffer)) window-start)
6014 (defun gnus-article-edit-full-stops ()
6015 "Interactively repair spacing at end of sentences."
6018 (goto-char (point-min))
6019 (search-forward-regexp "^$" nil t)
6020 (let ((case-fold-search nil))
6021 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
6024 ;;; Article editing with MIME-Edit
6027 (defcustom gnus-article-mime-edit-article-setup-hook nil
6028 "Hook run after setting up a MIME editing article buffer."
6029 :group 'gnus-article-various
6032 (defun gnus-article-mime-edit-article-unwind ()
6033 "Unwind `gnus-article-buffer' if article editing was given up."
6034 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6035 (when (featurep 'font-lock)
6036 (setq font-lock-defaults nil)
6037 (font-lock-mode -1))
6038 (when mime-edit-mode-flag
6039 (mime-edit-exit 'nomime 'no-error)
6042 (defun gnus-article-mime-edit-article-setup ()
6043 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
6044 after replacing with the original article."
6045 (setq gnus-show-mime t)
6046 (setq gnus-article-edit-done-function
6047 `(lambda (&rest args)
6048 (when mime-edit-mode-flag
6049 (let (mime-edit-insert-user-agent-field)
6052 (goto-char (point-min))
6053 (let (case-fold-search)
6054 (when (re-search-forward
6055 (format "^%s$" (regexp-quote mail-header-separator))
6057 (replace-match "")))
6058 (apply ,gnus-article-edit-done-function args)
6061 (buffer-substring-no-properties (point-min) (point-max))
6062 (set-buffer (get-buffer-create gnus-original-article-buffer))
6064 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6065 (set-buffer gnus-article-buffer)
6066 (gnus-article-prepare-display)))
6067 (substitute-key-definition 'gnus-article-edit-done
6068 'gnus-article-mime-edit-done
6069 gnus-article-edit-mode-map)
6070 (substitute-key-definition 'gnus-article-edit-exit
6071 'gnus-article-mime-edit-exit
6072 gnus-article-edit-mode-map)
6074 (insert-buffer-substring gnus-original-article-buffer)
6075 (unless (member (with-current-buffer gnus-summary-buffer
6076 gnus-newsgroup-name)
6077 '("nndraft:delayed" "nndraft:drafts"))
6078 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
6079 (fset 'mime-edit-decode-single-part-in-buffer
6080 (lambda (&rest args)
6081 (if (let ((content-type (car args)))
6082 (and (eq 'message (mime-content-type-primary-type
6084 (eq 'rfc822 (mime-content-type-subtype
6086 (setcar (cdr args) 'not-decode-text))
6090 (fset 'mime-edit-decode-single-part-in-buffer ofn))))
6091 (when (featurep 'font-lock)
6092 (set (make-local-variable 'font-lock-defaults)
6093 '(message-font-lock-keywords t))
6094 (font-lock-set-defaults)
6095 (turn-on-font-lock))
6096 (set-buffer-modified-p nil)
6097 (delete-other-windows)
6098 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6099 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
6101 (defun gnus-article-mime-edit-done (&optional arg)
6102 "Update the article MIME edits and exit."
6104 (when (featurep 'font-lock)
6105 (setq font-lock-defaults nil)
6106 (font-lock-mode -1))
6107 (let ((inhibit-read-only t))
6108 (gnus-article-edit-done arg)))
6110 (defun gnus-article-mime-edit-exit ()
6111 "Exit the article MIME editing without updating."
6113 (when (or (not (buffer-modified-p))
6114 (yes-or-no-p "Article modified; kill anyway? "))
6115 (when (featurep 'font-lock)
6116 (setq font-lock-defaults nil)
6117 (font-lock-mode -1))
6118 (when mime-edit-mode-flag
6119 (let (mime-edit-insert-user-agent-field)
6122 (goto-char (point-min))
6123 (let (case-fold-search)
6124 (when (re-search-forward
6125 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
6126 (replace-match "")))
6127 (let ((winconf gnus-prev-winconf))
6129 (buffer-substring-no-properties (point-min) (point-max))
6130 (set-buffer (get-buffer-create gnus-original-article-buffer))
6132 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6133 (set-buffer gnus-article-buffer)
6134 (gnus-article-prepare-display)
6135 (set-window-configuration winconf))))
6138 ;;; Article highlights
6141 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6143 ;;; Internal Variables:
6145 (defcustom gnus-button-url-regexp
6146 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
6147 "\\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:]]\\)"
6148 "\\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\\)\\)")
6149 "Regular expression that matches URLs."
6150 :group 'gnus-article-buttons
6153 (defcustom gnus-button-valid-fqdn-regexp
6154 message-valid-fqdn-regexp
6155 "Regular expression that matches a valid FQDN."
6156 :group 'gnus-article-buttons
6159 (defcustom gnus-button-man-handler 'manual-entry
6160 "Function to use for displaying man pages.
6161 The function must take at least one argument with a string naming the
6163 :type '(choice (function-item :tag "Man" manual-entry)
6164 (function-item :tag "Woman" woman)
6165 (function :tag "Other"))
6166 :group 'gnus-article-buttons)
6168 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6169 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6170 If the default site is too slow, try to find a CTAN mirror, see
6171 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6172 the variable `gnus-button-handle-ctan'."
6173 :group 'gnus-article-buttons
6174 :link '(custom-manual "(gnus)Group Parameters")
6175 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6176 (const "http://tug.ctan.org/tex-archive/")
6177 (const "http://www.dante.de/CTAN/")
6178 (string :tag "Other")))
6180 (defcustom gnus-button-ctan-handler 'browse-url
6181 "Function to use for displaying CTAN links.
6182 The function must take one argument, the string naming the URL."
6183 :type '(choice (function-item :tag "Browse Url" browse-url)
6184 (function :tag "Other"))
6185 :group 'gnus-article-buttons)
6187 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6188 "Bogus strings removed from CTAN URLs."
6189 :group 'gnus-article-buttons
6190 :type '(choice (const "^/?tex-archive/\\|/")
6191 (regexp :tag "Other")))
6193 (defcustom gnus-button-ctan-directory-regexp
6195 "\\("; Cannot use `\(?: ... \)' (compatibility with Emacs 20).
6196 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
6197 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
6198 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
6200 "Regular expression for ctan directories.
6201 It should match all directories in the top level of `gnus-ctan-url'."
6202 :group 'gnus-article-buttons
6205 (defcustom gnus-button-mid-or-mail-regexp
6206 (concat "\\b\\(<?[a-z0-9][^<>\")!;:,{}\n\t ]*@"
6207 gnus-button-valid-fqdn-regexp
6209 "Regular expression that matches a message ID or a mail address."
6210 :group 'gnus-article-buttons
6213 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6214 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6215 Strings like this can be either a message ID or a mail address. If it is one
6216 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6217 message ID or a mail address, respectively. If this variable is set to the
6218 symbol `ask', always query the user what do do. If it is a function, this
6219 function will be called with the string as it's only argument. The function
6220 must return `mid', `mail', `invalid' or `ask'."
6221 :group 'gnus-article-buttons
6222 :type '(choice (function-item :tag "Heuristic function"
6223 gnus-button-mid-or-mail-heuristic)
6228 (defcustom gnus-button-mid-or-mail-heuristic-alist
6229 '((-10.0 . ".+\\$.+@")
6232 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6233 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6234 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6235 (-1.0 . "^[^a-z]+@")
6237 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6238 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6239 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6240 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6243 (-1.0 . "^[0-9][0-9]")
6245 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6246 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6247 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6248 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6250 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6251 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6254 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6256 ;; compensation for TDMA dated mail addresses:
6257 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6259 (-20.0 . "\\.fsf@") ;; Gnus
6262 (-20.0 . "_-_") ;; Subject change in thread
6264 (-20.0 . "\\.ln@") ;; leafnode
6265 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6266 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6268 ;; (5.0 . "") ;; $local_part_len <= 7
6269 (10.0 . "^[^0-9]+@")
6270 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6271 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6274 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6276 (0.5 . "^[A-Z][a-z]")
6277 (0.5 . "^[A-Z][a-z][a-z]")
6278 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6279 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6280 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6282 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6283 address. The REGEXP is processed with `case-fold-search' set to nil."
6284 :group 'gnus-article-buttons
6285 :type '(repeat (cons (number :tag "Rate")
6286 (regexp :tag "Regexp"))))
6288 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6289 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6290 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6291 address, `ask' if unsure and `invalid' if the string is invalid."
6292 (let ((case-fold-search nil)
6293 (list gnus-button-mid-or-mail-heuristic-alist)
6294 (result 0) rate regexp lpartlen elem)
6296 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6297 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6298 ;; Certain special cases...
6301 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$" "\\|"
6302 "^[0-9]+\.[0-9]+\@compuserve")
6304 (gnus-message 8 "`%s' is a known mail address.")
6305 (setq result 'mail))
6306 (when (string-match "@.*@\\| " mid-or-mail)
6307 (gnus-message 8 "`%s' is invalid.")
6308 (setq result 'invalid))
6309 ;; Nothing more to do, if result is not a number here...
6310 (when (numberp result)
6312 (setq elem (car list)
6316 (when (string-match regexp mid-or-mail)
6317 (setq result (+ result rate))
6319 9 "`%s' matched `%s', rate `%s', result `%s'."
6320 mid-or-mail regexp rate result)))
6321 (when (<= lpartlen 7)
6322 (setq result (+ result 5.0))
6323 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6324 mid-or-mail result))
6325 (when (>= lpartlen 12)
6326 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6328 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6329 ;; Long local part should contain realname if e-mail address,
6330 ;; too many digits: message-id.
6331 ;; $score -= 5.0 + 0.1 * $local_part_len;
6332 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6333 (setq result (+ result rate))
6335 9 "Many digits in `%s', rate `%s', result `%s'."
6336 mid-or-mail rate result))
6337 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6339 ;; Too few vowels [^aeiouy]{4,}.*\@
6340 (setq result (+ result -5.0))
6342 9 "Few vowels in `%s', rate `%s', result `%s'."
6343 mid-or-mail -5.0 result))
6345 (setq result (+ result 5.0))
6347 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6348 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6350 ;; Maybe we should make this a customizable alist: (condition . 'result)
6351 ((< result -10.0) 'mid)
6352 ((> result 10.0) 'mail)
6355 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6356 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6357 (url-mid (concat "news" ":" mid-or-mail))
6358 (url-mailto (concat "mailto" ":" mid-or-mail)))
6359 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6360 (when (fboundp pref)
6362 ;; get rid of surrounding angles...
6364 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6365 (if (or (eq 'mid guessed) (eq 'mail guessed))
6369 (save-window-excursion
6370 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6373 (cond ((eq pref 'mid)
6374 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6375 (gnus-button-handle-news url-mid))
6377 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6378 (gnus-url-mailto url-mailto))
6379 (t (gnus-message 3 "Invalid string.")))))
6381 (defun gnus-button-handle-custom (url)
6382 "Follow a Custom URL."
6383 (customize-apropos (gnus-url-unhex-string url)))
6385 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6387 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6390 (defun gnus-button-handle-describe-function (url)
6391 "Call `describe-function' when pushing the corresponding URL button."
6394 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6396 (defun gnus-button-handle-describe-variable (url)
6397 "Call `describe-variable' when pushing the corresponding URL button."
6400 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6402 (defun gnus-button-handle-symbol (url)
6403 "Display help on variable or function.
6404 Calls `describe-variable' or `describe-function'."
6405 (let ((sym (intern url)))
6407 ((fboundp sym) (describe-function sym))
6408 ((boundp sym) (describe-variable sym))
6409 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6411 (defun gnus-button-handle-describe-key (url)
6412 "Call `describe-key' when pushing the corresponding URL button."
6414 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6415 (keys (ignore-errors (eval `(kbd ,key-string)))))
6418 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6420 (defun gnus-button-handle-apropos (url)
6421 "Call `apropos' when pushing the corresponding URL button."
6422 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6424 (defun gnus-button-handle-apropos-command (url)
6425 "Call `apropos' when pushing the corresponding URL button."
6427 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6429 (defun gnus-button-handle-apropos-variable (url)
6430 "Call `apropos' when pushing the corresponding URL button."
6432 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6433 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6435 (defun gnus-button-handle-apropos-documentation (url)
6436 "Call `apropos' when pushing the corresponding URL button."
6438 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6439 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6441 (defun gnus-button-handle-library (url)
6442 "Call `locate-library' when pushing the corresponding URL button."
6443 (gnus-message 9 "url=`%s'" url)
6444 (let* ((lib (locate-library url))
6445 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6447 (gnus-message 1 "Cannot locale library `%s'." url)
6448 (find-file-read-only file))))
6450 (defun gnus-button-handle-ctan (url)
6451 "Call `browse-url' when pushing a CTAN URL button."
6453 gnus-button-ctan-handler
6456 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6458 (defcustom gnus-button-tex-level 5
6459 "*Integer that says how many TeX-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 TeX groups is probably a good idea.
6463 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6464 how to set variables in specific groups."
6465 :group 'gnus-article-buttons
6466 :link '(custom-manual "(gnus)Group Parameters")
6469 (defcustom gnus-button-man-level 5
6470 "*Integer that says how many man-related buttons Gnus will show.
6471 The higher the number, the more buttons will appear and the more false
6472 positives are possible. Note that you can set this variable local to
6473 specifific groups. Setting it higher in Unix groups is probably a good idea.
6474 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6475 how to set variables in specific groups."
6476 :group 'gnus-article-buttons
6477 :link '(custom-manual "(gnus)Group Parameters")
6480 (defcustom gnus-button-emacs-level 5
6481 "*Integer that says how many emacs-related buttons Gnus will show.
6482 The higher the number, the more buttons will appear and the more false
6483 positives are possible. Note that you can set this variable local to
6484 specifific groups. Setting it higher in Emacs or Gnus related groups is
6485 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6486 `gnus-parameters' on how to set variables in specific groups."
6487 :group 'gnus-article-buttons
6488 :link '(custom-manual "(gnus)Group Parameters")
6491 (defcustom gnus-button-message-level 5
6492 "*Integer that says how many buttons for news or mail messages will appear.
6493 The higher the number, the more buttons will appear and the more false
6494 positives are possible."
6495 ;; mail addresses, MIDs, URLs for news, ...
6496 :group 'gnus-article-buttons
6499 (defcustom gnus-button-browse-level 5
6500 "*Integer that says how many buttons for browsing will appear.
6501 The higher the number, the more buttons will appear and the more false
6502 positives are possible."
6503 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6504 :group 'gnus-article-buttons
6507 (defcustom gnus-button-alist
6508 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6509 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6510 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6511 gnus-button-handle-news 2)
6512 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6513 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6514 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6515 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6516 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6517 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6518 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6519 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6520 ("mailto:\\([-a-z.@_+0-9%=?]+\\)"
6521 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6522 ("\\bmailto:\\([^ \n\t]+\\)"
6523 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6525 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6526 gnus-button-ctan-directory-regexp
6527 "[^][>)!;:,'\n\t ]+\\)")
6528 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6529 ((concat "\\btex-archive/\\("
6530 gnus-button-ctan-directory-regexp
6531 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6532 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6535 gnus-button-ctan-directory-regexp
6536 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6537 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6539 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)"
6540 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6541 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6542 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6543 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6544 ;; Info links like `C-h i d m CC Mode RET'
6545 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6547 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6548 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6549 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6550 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6551 ;; Emacs help commands
6552 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6553 ;; regexp doesn't match arguments containing ` '.
6554 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6555 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6556 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6557 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6558 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6559 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6560 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6561 ;; The following entries may lead to many false positives so don't enable
6562 ;; them by default (use a high button level):
6563 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>"
6564 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6565 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6566 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6567 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6568 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6569 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6570 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6571 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6572 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6573 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6574 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6575 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6576 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6577 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6578 ;; Unlike the other regexps we really have to require quoting
6579 ;; here to determine where it ends.
6580 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6581 ;; This is how URLs _should_ be embedded in text (RFC 1738)...
6582 ("<URL: *\\([^<>]*\\)>"
6583 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6585 (gnus-button-url-regexp
6586 0 (>= gnus-button-browse-level 0) browse-url 0)
6588 ("\\b\\([a-z][a-z]+\\)([1-9])\\W"
6589 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6590 gnus-button-handle-man 1)
6591 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6592 ("\\b\\([a-z][-_.a-z0-9]+\\)([1-9])\\W"
6593 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6594 gnus-button-handle-man 1)
6595 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6596 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6597 ("\\b\\([a-z][-_.:a-z0-9]+\\)([1-9][X1a-z]*)\\W\\|\\b\\(X\\)([1-9])\\W"
6598 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6599 ;; MID or mail: To avoid too many false positives we don't try to catch
6600 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6601 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6602 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6603 ;; so that non-ambiguous entries (see above) match first.
6604 (gnus-button-mid-or-mail-regexp
6605 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6606 "*Alist of regexps matching buttons in article bodies.
6608 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6609 REGEXP: is the string (case insensitive) matching text around the button (can
6610 also be lisp expression evaluating to a string),
6611 BUTTON: is the number of the regexp grouping actually matching the button,
6612 FORM: is a lisp expression which must eval to true for the button to
6614 CALLBACK: is the function to call when the user push this button, and each
6615 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6617 CALLBACK can also be a variable, in that case the value of that
6618 variable it the real callback function."
6619 :group 'gnus-article-buttons
6620 :type '(repeat (list (choice regexp variable)
6621 (integer :tag "Button")
6623 (function :tag "Callback")
6626 (integer :tag "Regexp group")))))
6628 (defcustom gnus-header-button-alist
6629 '(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
6630 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6631 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6632 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6633 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6634 0 (>= gnus-button-message-level 0) gnus-button-mailto 0)
6635 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6636 0 (>= gnus-button-browse-level 0) browse-url 0)
6637 ("^Subject:" gnus-button-url-regexp
6638 0 (>= gnus-button-browse-level 0) browse-url 0)
6639 ("^[^:]+:" gnus-button-url-regexp
6640 0 (>= gnus-button-browse-level 0) browse-url 0)
6641 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?]+\\)"
6642 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6643 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6644 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6645 "*Alist of headers and regexps to match buttons in article heads.
6647 This alist is very similar to `gnus-button-alist', except that each
6648 alist has an additional HEADER element first in each entry:
6650 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6652 HEADER is a regexp to match a header. For a fuller explanation, see
6653 `gnus-button-alist'."
6654 :group 'gnus-article-buttons
6655 :group 'gnus-article-headers
6656 :type '(repeat (list (regexp :tag "Header")
6658 (integer :tag "Button")
6660 (function :tag "Callback")
6663 (integer :tag "Regexp group")))))
6665 (defvar gnus-button-regexp nil)
6666 (defvar gnus-button-marker-list nil)
6667 ;; Regexp matching any of the regexps from `gnus-button-alist'.
6669 (defvar gnus-button-last nil)
6670 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
6674 (defun gnus-article-push-button (event)
6675 "Check text under the mouse pointer for a callback function.
6676 If the text under the mouse pointer has a `gnus-callback' property,
6677 call it with the value of the `gnus-data' text property."
6679 (set-buffer (window-buffer (posn-window (event-start event))))
6680 (let* ((pos (posn-point (event-start event)))
6681 (data (get-text-property pos 'gnus-data))
6682 (fun (get-text-property pos 'gnus-callback)))
6685 (funcall fun data))))
6687 (defun gnus-article-press-button ()
6688 "Check text at point for a callback function.
6689 If the text at point has a `gnus-callback' property,
6690 call it with the value of the `gnus-data' text property."
6692 (let ((data (get-text-property (point) 'gnus-data))
6693 (fun (get-text-property (point) 'gnus-callback)))
6695 (funcall fun data))))
6697 (defun gnus-article-prev-button (n)
6698 "Move point to N buttons backward.
6699 If N is negative, move forward instead."
6701 (gnus-article-next-button (- n)))
6703 (defun gnus-article-next-button (n)
6704 "Move point to N buttons forward.
6705 If N is negative, move backward instead."
6707 (let ((function (if (< n 0) 'previous-single-property-change
6708 'next-single-property-change))
6709 (inhibit-point-motion-hooks t)
6711 (limit (if (< n 0) (point-min) (point-max))))
6713 (while (and (not (= limit (point)))
6715 ;; Skip past the current button.
6716 (when (get-text-property (point) 'gnus-callback)
6717 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6718 ;; Go to the next (or previous) button.
6719 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
6720 ;; Put point at the start of the button.
6721 (when (and backward (not (get-text-property (point) 'gnus-callback)))
6722 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6723 ;; Skip past intangible buttons.
6724 (when (get-text-property (point) 'intangible)
6728 (gnus-message 5 "No more buttons"))
6731 (defun gnus-article-highlight (&optional force)
6732 "Highlight current article.
6733 This function calls `gnus-article-highlight-headers',
6734 `gnus-article-highlight-citation',
6735 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6736 do the highlighting. See the documentation for those functions."
6737 (interactive (list 'force))
6738 (gnus-article-highlight-headers)
6739 (gnus-article-highlight-citation force)
6740 (gnus-article-highlight-signature)
6741 (gnus-article-add-buttons force)
6742 (gnus-article-add-buttons-to-head))
6744 (defun gnus-article-highlight-some (&optional force)
6745 "Highlight current article.
6746 This function calls `gnus-article-highlight-headers',
6747 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6748 do the highlighting. See the documentation for those functions."
6749 (interactive (list 'force))
6750 (gnus-article-highlight-headers)
6751 (gnus-article-highlight-signature)
6752 (gnus-article-add-buttons))
6754 (defun gnus-article-highlight-headers ()
6755 "Highlight article headers as specified by `gnus-header-face-alist'."
6758 (set-buffer gnus-article-buffer)
6760 (let ((alist gnus-header-face-alist)
6761 (buffer-read-only nil)
6762 (case-fold-search t)
6763 (inhibit-point-motion-hooks t)
6764 entry regexp header-face field-face from hpoints fpoints)
6765 (article-narrow-to-head)
6766 (while (setq entry (pop alist))
6767 (goto-char (point-min))
6768 (setq regexp (concat "^\\("
6769 (if (string-equal "" (nth 0 entry))
6773 header-face (nth 1 entry)
6774 field-face (nth 2 entry))
6775 (while (and (re-search-forward regexp nil t)
6779 (unless (search-forward ":" nil t)
6781 (when (and header-face
6782 (not (memq (point) hpoints)))
6783 (push (point) hpoints)
6784 (gnus-put-text-property from (point) 'face header-face))
6785 (when (and field-face
6786 (not (memq (setq from (point)) fpoints)))
6788 (if (re-search-forward "^[^ \t]" nil t)
6790 (goto-char (point-max)))
6791 (gnus-put-text-property from (point) 'face field-face))))))))
6793 (defun gnus-article-highlight-signature ()
6794 "Highlight the signature in an article.
6795 It does this by highlighting everything after
6796 `gnus-signature-separator' using `gnus-signature-face'."
6798 (when gnus-signature-face
6800 (set-buffer gnus-article-buffer)
6801 (let ((buffer-read-only nil)
6802 (inhibit-point-motion-hooks t))
6804 (when (gnus-article-narrow-to-signature)
6805 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6806 'face gnus-signature-face)))))))
6808 (defun gnus-article-buttonize-signature ()
6809 "Add button to the signature."
6812 (set-buffer gnus-article-buffer)
6813 (let ((buffer-read-only nil)
6814 (inhibit-point-motion-hooks t))
6815 (when (gnus-article-search-signature)
6816 (gnus-article-add-button (match-beginning 0) (match-end 0)
6817 'gnus-signature-toggle
6818 (set-marker (make-marker)
6819 (1+ (match-end 0))))))))
6821 (defun gnus-button-in-region-p (b e prop)
6822 "Say whether PROP exists in the region."
6823 (text-property-not-all b e prop nil))
6825 (defun gnus-article-add-buttons (&optional force)
6826 "Find external references in the article and make buttons of them.
6827 \"External references\" are things like Message-IDs and URLs, as
6828 specified by `gnus-button-alist'."
6829 (interactive (list 'force))
6831 (set-buffer gnus-article-buffer)
6832 (let ((buffer-read-only nil)
6833 (inhibit-point-motion-hooks t)
6834 (case-fold-search t)
6835 (alist gnus-button-alist)
6837 ;; Remove all old markers.
6838 (let (marker entry new-list)
6839 (while (setq marker (pop gnus-button-marker-list))
6840 (if (or (< marker (point-min)) (>= marker (point-max)))
6841 (push marker new-list)
6843 (when (setq entry (gnus-button-entry))
6844 (put-text-property (match-beginning (nth 1 entry))
6845 (match-end (nth 1 entry))
6846 'gnus-callback nil))
6847 (set-marker marker nil)))
6848 (setq gnus-button-marker-list new-list))
6849 ;; We skip the headers.
6852 (while (setq entry (pop alist))
6853 (setq regexp (eval (car entry)))
6855 (while (re-search-forward regexp nil t)
6856 (let* ((start (and entry (match-beginning (nth 1 entry))))
6857 (end (and entry (match-end (nth 1 entry))))
6858 (from (match-beginning 0)))
6859 (when (and (or (eq t (nth 2 entry))
6860 (eval (nth 2 entry)))
6861 (not (gnus-button-in-region-p
6862 start end 'gnus-callback)))
6863 ;; That optional form returned non-nil, so we add the
6865 (gnus-article-add-button
6866 start end 'gnus-button-push
6867 (car (push (set-marker (make-marker) from)
6868 gnus-button-marker-list))))))))))
6870 ;; Add buttons to the head of an article.
6871 (defun gnus-article-add-buttons-to-head ()
6872 "Add buttons to the head of the article."
6875 (set-buffer gnus-article-buffer)
6877 (let ((buffer-read-only nil)
6878 (inhibit-point-motion-hooks t)
6879 (case-fold-search t)
6880 (alist gnus-header-button-alist)
6882 (article-narrow-to-head)
6884 ;; Each alist entry.
6885 (setq entry (car alist)
6887 (goto-char (point-min))
6888 (while (re-search-forward (car entry) nil t)
6889 ;; Each header matching the entry.
6890 (setq beg (match-beginning 0))
6891 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6892 (match-beginning 0))
6895 (while (re-search-forward (eval (nth 1 entry)) end t)
6896 ;; Each match within a header.
6897 (let* ((entry (cdr entry))
6898 (start (match-beginning (nth 1 entry)))
6899 (end (match-end (nth 1 entry)))
6900 (form (nth 2 entry)))
6901 (goto-char (match-end 0))
6903 (gnus-article-add-button
6904 start end (nth 3 entry)
6905 (buffer-substring (match-beginning (nth 4 entry))
6906 (match-end (nth 4 entry)))))))
6907 (goto-char end)))))))
6909 ;;; External functions:
6911 (defun gnus-article-add-button (from to fun &optional data)
6912 "Create a button between FROM and TO with callback FUN and data DATA."
6913 (when gnus-article-button-face
6914 (gnus-overlay-put (gnus-make-overlay from to)
6915 'face gnus-article-button-face))
6916 (gnus-add-text-properties
6918 (nconc (and gnus-article-mouse-face
6919 (list gnus-mouse-face-prop gnus-article-mouse-face))
6920 (list 'gnus-callback fun)
6921 (and data (list 'gnus-data data))))
6922 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6923 ;; Quote `:button-keymap' for Mule 2.3
6924 ;; but it won't work.
6925 ':button-keymap gnus-widget-button-keymap))
6927 ;;; Internal functions:
6929 (defun gnus-article-set-globals ()
6931 (set-buffer gnus-summary-buffer)
6932 (gnus-set-global-variables)))
6934 (defun gnus-signature-toggle (end)
6936 (set-buffer gnus-article-buffer)
6937 (let ((buffer-read-only nil)
6938 (inhibit-point-motion-hooks t)
6939 (limit (next-single-property-change end 'mime-view-entity
6941 (if (text-property-any end limit 'article-type 'signature)
6943 (gnus-delete-wash-type 'signature)
6944 (gnus-remove-text-properties-when
6945 'article-type 'signature end limit
6946 (cons 'article-type (cons 'signature
6947 gnus-hidden-properties))))
6948 (gnus-add-wash-type 'signature)
6949 (gnus-add-text-properties-when
6950 'article-type nil end limit
6951 (cons 'article-type (cons 'signature
6952 gnus-hidden-properties)))))
6953 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6954 (gnus-set-mode-line 'article))))
6956 (defun gnus-button-entry ()
6957 ;; Return the first entry in `gnus-button-alist' matching this place.
6958 (let ((alist gnus-button-alist)
6961 (setq entry (pop alist))
6962 (if (looking-at (eval (car entry)))
6967 (defun gnus-button-push (marker)
6968 ;; Push button starting at MARKER.
6971 (let* ((entry (gnus-button-entry))
6972 (inhibit-point-motion-hooks t)
6974 (args (mapcar (lambda (group)
6975 (let ((string (match-string group)))
6976 (gnus-set-text-properties
6977 0 (length string) nil string)
6984 (fboundp (symbol-value fun)))
6985 (apply (symbol-value fun) args))
6987 (gnus-message 1 "You must define `%S' to use this button"
6988 (cons fun args)))))))
6990 (defun gnus-parse-news-url (url)
6991 (let (scheme server group message-id articles)
6994 (goto-char (point-min))
6995 (when (looking-at "\\([A-Za-z]+\\):")
6996 (setq scheme (match-string 1))
6997 (goto-char (match-end 0)))
6998 (when (looking-at "//\\([^/]+\\)/")
6999 (setq server (match-string 1))
7000 (goto-char (match-end 0)))
7003 ((looking-at "\\(.*@.*\\)")
7004 (setq message-id (match-string 1)))
7005 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7006 (setq group (match-string 1)
7007 articles (split-string (match-string 2) "-")))
7008 ((looking-at "\\([^/]+\\)/?")
7009 (setq group (match-string 1)))
7011 (error "Unknown news URL syntax"))))
7012 (list scheme server group message-id articles)))
7014 (defun gnus-button-handle-news (url)
7016 (destructuring-bind (scheme server group message-id articles)
7017 (gnus-parse-news-url url)
7021 (set-buffer gnus-summary-buffer)
7023 (let ((gnus-refer-article-method (list (list 'nntp server))))
7024 (gnus-summary-refer-article message-id))
7025 (gnus-summary-refer-article message-id))))
7027 (gnus-button-fetch-group url)))))
7029 (defun gnus-button-handle-man (url)
7031 (funcall gnus-button-man-handler url))
7033 (defun gnus-button-handle-info-url (url)
7034 "Fetch an info URL."
7036 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
7037 (gnus-info-find-node
7038 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
7040 ")" (gnus-url-unhex-string (match-string 2 url)))))
7041 ((string-match "([^)\"]+)[^\"]+" url)
7043 (gnus-replace-in-string
7044 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
7045 (gnus-info-find-node url))
7046 (t (error "Can't parse %s" url))))
7048 (defun gnus-button-handle-info-keystrokes (url)
7049 "Call `info' when pushing the corresponding URL button."
7050 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
7055 (defun gnus-button-message-id (message-id)
7058 (set-buffer gnus-summary-buffer)
7059 (gnus-summary-refer-article message-id)))
7061 (defun gnus-button-fetch-group (address)
7062 "Fetch GROUP specified by ADDRESS."
7063 (if (not (string-match "[:/]" address))
7064 ;; This is just a simple group url.
7065 (gnus-group-read-ephemeral-group address gnus-select-method)
7068 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
7070 (error "Can't parse %s" address)
7071 (gnus-group-read-ephemeral-group
7072 (match-string 4 address)
7073 `(nntp ,(match-string 1 address)
7074 (nntp-address ,(match-string 1 address))
7075 (nntp-port-number ,(if (match-end 3)
7076 (match-string 3 address)
7079 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
7081 (defun gnus-url-parse-query-string (query &optional downcase)
7082 (let (retval pairs cur key val)
7083 (setq pairs (split-string query "&"))
7085 (setq cur (car pairs)
7087 (if (not (string-match "=" cur))
7089 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
7090 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
7092 (setq key (downcase key)))
7093 (setq cur (assoc key retval))
7095 (setcdr cur (cons val (cdr cur)))
7096 (setq retval (cons (list key val) retval)))))
7099 (defun gnus-url-mailto (url)
7100 ;; Send mail to someone
7101 (when (string-match "mailto:/*\\(.*\\)" url)
7102 (setq url (substring url (match-beginning 1) nil)))
7103 (let (to args subject func)
7104 (if (string-match (regexp-quote "?") url)
7105 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
7106 args (gnus-url-parse-query-string
7107 (substring url (match-end 0) nil) t))
7108 (setq to (gnus-url-unhex-string url)))
7109 (setq args (cons (list "to" to) args)
7110 subject (cdr-safe (assoc "subject" args)))
7113 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
7116 (message-position-on-field (caar args)))
7117 (insert (mapconcat 'identity (cdar args) ", "))
7118 (setq args (cdr args)))
7121 (message-goto-subject))))
7123 (defun gnus-button-embedded-url (address)
7124 "Activate ADDRESS with `browse-url'."
7125 (browse-url (gnus-strip-whitespace address)))
7127 ;;; Next/prev buttons in the article buffer.
7129 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
7130 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
7132 (defvar gnus-prev-page-map
7133 (let ((map (make-sparse-keymap)))
7134 (unless (>= emacs-major-version 21)
7135 ;; XEmacs doesn't care.
7136 (set-keymap-parent map gnus-article-mode-map))
7137 (define-key map gnus-mouse-2 'gnus-button-prev-page)
7138 (define-key map "\r" 'gnus-button-prev-page)
7141 (defun gnus-insert-prev-page-button ()
7143 (buffer-read-only nil)
7144 (situation (get-text-property (point-min) 'mime-view-situation)))
7146 gnus-prev-page-line-format nil
7147 `(,@(gnus-local-map-property gnus-prev-page-map)
7149 gnus-callback gnus-article-button-prev-page
7150 article-type annotation
7151 mime-view-situation ,situation))
7152 (widget-convert-button
7154 ;; Exclude a newline.
7157 :action 'gnus-button-prev-page
7158 :button-keymap gnus-prev-page-map)))
7160 (defvar gnus-next-page-map
7161 (let ((map (make-sparse-keymap)))
7162 (unless (>= emacs-major-version 21)
7163 ;; XEmacs doesn't care.
7164 (set-keymap-parent map gnus-article-mode-map))
7165 (define-key map gnus-mouse-2 'gnus-button-next-page)
7166 (define-key map "\r" 'gnus-button-next-page)
7169 (defun gnus-button-next-page (&optional args more-args)
7170 "Go to the next page."
7172 (let ((win (selected-window)))
7173 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7174 (gnus-article-next-page)
7175 (select-window win)))
7177 (defun gnus-button-prev-page (&optional args more-args)
7178 "Go to the prev page."
7180 (let ((win (selected-window)))
7181 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7182 (gnus-article-prev-page)
7183 (select-window win)))
7185 (defun gnus-insert-next-page-button ()
7187 (buffer-read-only nil)
7188 (situation (get-text-property (point-min) 'mime-view-situation)))
7189 (gnus-eval-format gnus-next-page-line-format nil
7190 `(,@(gnus-local-map-property gnus-next-page-map)
7192 gnus-callback gnus-article-button-next-page
7193 article-type annotation
7194 mime-view-situation ,situation))
7195 (widget-convert-button
7197 ;; Exclude a newline.
7200 :action 'gnus-button-next-page
7201 :button-keymap gnus-next-page-map)))
7203 (defun gnus-article-button-next-page (arg)
7204 "Go to the next page."
7206 (let ((win (selected-window)))
7207 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7208 (gnus-article-next-page)
7209 (select-window win)))
7211 (defun gnus-article-button-prev-page (arg)
7212 "Go to the prev page."
7214 (let ((win (selected-window)))
7215 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7216 (gnus-article-prev-page)
7217 (select-window win)))
7219 (defvar gnus-decode-header-methods
7220 '(mail-decode-encoded-word-region)
7221 "List of methods used to decode headers.
7223 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7224 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
7225 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
7226 whose names match REGEXP.
7229 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7230 mail-decode-encoded-word-region
7231 (\"chinese\" . rfc1843-decode-region))
7234 (defvar gnus-decode-header-methods-cache nil)
7236 (defun gnus-multi-decode-header (start end)
7237 "Apply the functions from `gnus-encoded-word-methods' that match."
7238 (unless (and gnus-decode-header-methods-cache
7239 (eq gnus-newsgroup-name
7240 (car gnus-decode-header-methods-cache)))
7241 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7244 (nconc gnus-decode-header-methods-cache (list x))
7245 (if (and gnus-newsgroup-name
7246 (string-match (car x) gnus-newsgroup-name))
7247 (nconc gnus-decode-header-methods-cache
7249 gnus-decode-header-methods))
7250 (let ((xlist gnus-decode-header-methods-cache))
7253 (narrow-to-region start end)
7255 (funcall (pop xlist) (point-min) (point-max))))))
7258 ;;; Treatment top-level handling.
7261 (defun gnus-treat-article (condition &optional part-number total-parts type)
7262 (let ((length (- (point-max) (point-min)))
7263 (alist gnus-treatment-function-alist)
7264 (article-goto-body-goes-to-point-min-p t)
7268 (let ((list gnus-article-treat-types))
7270 (when (string-match (pop list) type)
7271 (throw 'found t)))))))
7272 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7273 (entity (static-unless (featurep 'xemacs)
7274 (when (eq 'head condition)
7275 (get-text-property (point-min) 'mime-view-entity))))
7276 val elem buttonized)
7277 (gnus-run-hooks 'gnus-part-display-hook)
7278 (unless gnus-inhibit-treatment
7279 (dolist (elem alist)
7282 (when (gnus-buffer-live-p gnus-summary-buffer)
7283 (set-buffer gnus-summary-buffer))
7284 (symbol-value (car elem))))
7285 (when (and (or (consp val)
7287 (gnus-treat-predicate val)
7288 (or (not (get (car elem) 'highlight))
7290 (when (and (not buttonized)
7292 '(gnus-treat-hide-signature
7293 gnus-treat-highlight-signature)))
7294 (gnus-article-buttonize-signature)
7295 (setq buttonized t))
7297 (funcall (cadr elem)))))
7298 ;; FSF Emacsen does not inherit the existing text properties
7299 ;; in the new text, so we should do it for `mime-view-entity'.
7300 (static-unless (featurep 'xemacs)
7302 (put-text-property (point-min) (point-max)
7303 'mime-view-entity entity))))))
7305 ;; Dynamic variables.
7307 (defvar part-number)
7308 (defvar total-parts)
7313 (defun gnus-treat-predicate (val)
7318 (stringp (car val)))
7319 (apply 'gnus-or (mapcar `(lambda (s)
7320 (string-match s ,(or gnus-newsgroup-name "")))
7323 (let ((pred (pop val)))
7326 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7328 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7330 (not (gnus-treat-predicate (car val))))
7332 (equal (car val) type))
7334 (error "%S is not a valid predicate" pred)))))
7344 (eq part-number total-parts))
7348 (error "%S is not a valid value" val))))
7350 (defun gnus-article-encrypt-body (protocol &optional n)
7351 "Encrypt the article body."
7354 (or gnus-article-encrypt-protocol
7355 (completing-read "Encrypt protocol: "
7356 gnus-article-encrypt-protocol-alist
7358 current-prefix-arg))
7359 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7361 (error (format "Can't find the encrypt protocol %s" protocol)))
7362 (if (member gnus-newsgroup-name '("nndraft:delayed"
7365 (error "Can't encrypt the article in group %s"
7366 gnus-newsgroup-name))
7367 (gnus-summary-iterate n
7369 (set-buffer gnus-summary-buffer)
7370 (let ((mail-parse-charset gnus-newsgroup-charset)
7371 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7372 (summary-buffer gnus-summary-buffer)
7374 (gnus-set-global-variables)
7375 (when (gnus-group-read-only-p)
7376 (error "The current newsgroup does not support article encrypt"))
7377 (gnus-summary-show-article t)
7379 (or (mail-header-references gnus-current-headers) ""))
7380 (set-buffer gnus-article-buffer)
7381 (let* ((buffer-read-only nil)
7383 (mapcar (lambda (field)
7384 (and (save-restriction
7385 (message-narrow-to-head)
7386 (goto-char (point-min))
7387 (search-forward field nil t))
7389 (message-narrow-to-field)
7391 (delete-region (point-min) (point-max))
7393 '("Content-Type:" "Content-Transfer-Encoding:"
7394 "Content-Disposition:"))))
7395 (message-narrow-to-head)
7396 (message-remove-header "MIME-Version")
7397 (goto-char (point-max))
7398 (setq point (point))
7399 (insert (apply 'concat headers))
7401 (narrow-to-region point (point-max))
7402 (let ((message-options message-options))
7403 (message-options-set 'message-sender user-mail-address)
7404 (message-options-set 'message-recipients user-mail-address)
7405 (message-options-set 'message-sign-encrypt 'not)
7407 (goto-char (point-min))
7408 (insert "MIME-Version: 1.0\n")
7410 (gnus-summary-edit-article-done
7411 references nil summary-buffer t))
7412 (when gnus-keep-backlog
7413 (gnus-backlog-remove-article
7414 (car gnus-article-current) (cdr gnus-article-current)))
7416 (when (get-buffer gnus-original-article-buffer)
7417 (set-buffer gnus-original-article-buffer)
7418 (setq gnus-original-article nil)))
7419 (when gnus-use-cache
7420 (gnus-cache-update-article
7421 (car gnus-article-current) (cdr gnus-article-current))))))))
7423 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7424 "The following specs can be used:
7425 %t The security MIME type
7428 %D Details if button is pressed")
7430 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7431 "The following specs can be used:
7432 %t The security MIME type
7435 %D Details if button is pressed")
7437 (defvar gnus-mime-security-button-line-format-alist
7438 '((?t gnus-tmp-type ?s)
7439 (?i gnus-tmp-info ?s)
7440 (?d gnus-tmp-details ?s)
7441 (?D gnus-tmp-pressed-details ?s)))
7443 (defvar gnus-mime-security-button-map
7444 (let ((map (make-sparse-keymap)))
7445 (unless (>= (string-to-number emacs-version) 21)
7446 (set-keymap-parent map gnus-article-mode-map))
7447 (define-key map gnus-mouse-2 'gnus-article-push-button)
7448 (define-key map "\r" 'gnus-article-press-button)
7451 (defvar gnus-mime-security-details-buffer nil)
7453 (defvar gnus-mime-security-button-pressed nil)
7455 (defvar gnus-mime-security-show-details-inline t
7456 "If non-nil, show details in the article buffer.")
7458 (defun gnus-mime-security-verify-or-decrypt (handle)
7459 (mm-remove-parts (cdr handle))
7460 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7461 point buffer-read-only)
7463 (goto-char (car region)))
7465 (narrow-to-region (point) (point))
7466 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7467 (let* ((mm-verify-option 'known)
7468 (mm-decrypt-option 'known)
7469 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7470 (unless (eq nparts (cdr handle))
7471 (mm-destroy-parts (cdr handle))
7472 (setcdr handle nparts))))
7473 (setq point (point))
7474 (gnus-mime-display-security handle)
7475 (goto-char (point-max)))
7477 (delete-region (point) (cdr region))
7478 (set-marker (car region) nil)
7479 (set-marker (cdr region) nil))
7482 (defun gnus-mime-security-show-details (handle)
7483 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7485 (gnus-message 5 "No details.")
7486 (if gnus-mime-security-show-details-inline
7487 (let ((gnus-mime-security-button-pressed
7488 (not (get-text-property (point) 'gnus-mime-details)))
7489 (gnus-mime-security-button-line-format
7490 (get-text-property (point) 'gnus-line-format))
7493 (while (eq (get-text-property (point) 'gnus-line-format)
7494 gnus-mime-security-button-line-format)
7498 (narrow-to-region (point) (point))
7499 (gnus-insert-mime-security-button handle))
7500 (delete-region (point)
7501 (or (text-property-not-all
7504 gnus-mime-security-button-line-format)
7507 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7508 (with-current-buffer gnus-mime-security-details-buffer
7511 (setq gnus-mime-security-details-buffer
7512 (gnus-get-buffer-create "*MIME Security Details*")))
7513 (with-current-buffer gnus-mime-security-details-buffer
7515 (goto-char (point-min)))
7516 (pop-to-buffer gnus-mime-security-details-buffer)))))
7518 (defun gnus-mime-security-press-button (handle)
7520 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7521 (gnus-mime-security-show-details handle)
7522 (gnus-mime-security-verify-or-decrypt handle))))
7524 (defun gnus-insert-mime-security-button (handle &optional displayed)
7525 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7528 (or (nth 2 (assoc protocol mm-verify-function-alist))
7529 (nth 2 (assoc protocol mm-decrypt-function-alist))
7531 (if (equal (car handle) "multipart/signed")
7532 " Signed" " Encrypted")
7535 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7538 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7539 gnus-tmp-pressed-details
7541 (setq gnus-tmp-details
7542 (if gnus-tmp-details
7543 (concat "\n" gnus-tmp-details)
7545 (setq gnus-tmp-pressed-details
7546 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7551 gnus-mime-security-button-line-format
7552 gnus-mime-security-button-line-format-alist
7553 `(,@(gnus-local-map-property gnus-mime-security-button-map)
7554 gnus-callback gnus-mime-security-press-button
7555 gnus-line-format ,gnus-mime-security-button-line-format
7556 gnus-mime-details ,gnus-mime-security-button-pressed
7557 article-type annotation
7560 ;; Exclude a newline.
7563 (widget-convert-button
7566 :action 'gnus-widget-press-button
7567 :button-keymap gnus-mime-security-button-map
7569 (lambda (widget/window &optional overlay pos)
7570 ;; Needed to properly clear the message due to a bug in
7571 ;; wid-edit (XEmacs only).
7572 (when (boundp 'help-echo-owns-message)
7573 (setq help-echo-owns-message t))
7576 (aref gnus-mouse-2 0))))))
7578 (defun gnus-mime-display-security (handle)
7580 (narrow-to-region (point) (point))
7581 (unless (gnus-unbuttonized-mime-type-p (car handle))
7582 (gnus-insert-mime-security-button handle))
7583 (gnus-mime-display-mixed (cdr handle))
7586 (unless (gnus-unbuttonized-mime-type-p (car handle))
7587 (let ((gnus-mime-security-button-line-format
7588 gnus-mime-security-button-end-line-format))
7589 (gnus-insert-mime-security-button handle)))
7590 (mm-set-handle-multipart-parameter
7592 (cons (set-marker (make-marker) (point-min))
7593 (set-marker (make-marker) (point-max))))))
7599 (defun gnus-article-header-presentation-method (entity situation)
7600 (mime-insert-header entity)
7601 (article-decode-group-name))
7603 (set-alist 'mime-header-presentation-method-alist
7604 'gnus-original-article-mode
7605 #'gnus-article-header-presentation-method)
7607 (defun gnus-mime-preview-quitting-method ()
7608 (mime-preview-kill-buffer)
7609 (delete-other-windows)
7610 (gnus-article-show-summary)
7611 (gnus-summary-select-article gnus-show-all-headers t))
7613 (set-alist 'mime-preview-quitting-method-alist
7614 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
7616 (set-alist 'mime-preview-following-method-alist
7617 'gnus-original-article-mode #'gnus-following-method)
7619 (set-alist 'mime-preview-over-to-previous-method-alist
7620 'gnus-original-article-mode
7622 (if (> (point-min) 1)
7623 (gnus-article-prev-page)
7624 (gnus-article-read-summary-keys
7625 nil (gnus-character-to-event ?P)))))
7627 (set-alist 'mime-preview-over-to-next-method-alist
7628 'gnus-original-article-mode'
7630 (if (< (point-max) (buffer-size))
7631 (gnus-article-next-page)
7632 (gnus-article-read-summary-keys
7633 nil (gnus-character-to-event ?N)))))
7643 (run-hooks 'gnus-art-load-hook)
7645 ;;; gnus-art.el ends here