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 In the default setup this face is only used for crossposted
686 :group 'gnus-article-headers
687 :group 'gnus-article-highlight)
689 (defface gnus-header-name-face
692 (:foreground "SeaGreen"))
695 (:foreground "maroon"))
698 "Face used for displaying header names."
699 :group 'gnus-article-headers
700 :group 'gnus-article-highlight)
702 (defface gnus-header-content-face
705 (:foreground "forest green" :italic t))
708 (:foreground "indianred4" :italic t))
711 "Face used for displaying header content."
712 :group 'gnus-article-headers
713 :group 'gnus-article-highlight)
715 (defcustom gnus-header-face-alist
716 '(("From" nil gnus-header-from-face)
717 ("Subject" nil gnus-header-subject-face)
718 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
719 ("" gnus-header-name-face gnus-header-content-face))
720 "*Controls highlighting of article headers.
722 An alist of the form (HEADER NAME CONTENT).
724 HEADER is a regular expression which should match the name of a
725 header and NAME and CONTENT are either face names or nil.
727 The name of each header field will be displayed using the face
728 specified by the first element in the list where HEADER matches
729 the header name and NAME is non-nil. Similarly, the content will
730 be displayed by the first non-nil matching CONTENT face."
731 :group 'gnus-article-headers
732 :group 'gnus-article-highlight
733 :type '(repeat (list (regexp :tag "Header")
735 (item :tag "skip" nil)
736 (face :value default))
737 (choice :tag "Content"
738 (item :tag "skip" nil)
739 (face :value default)))))
741 (defcustom gnus-article-decode-hook
742 '(article-decode-group-name article-decode-idna-rhs)
743 "*Hook run to decode charsets in articles."
744 :group 'gnus-article-headers
747 (defcustom gnus-display-mime-function 'gnus-display-mime
748 "Function to display MIME articles."
749 :group 'gnus-article-mime
752 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
753 "Function used to decode headers.")
755 (defvar gnus-article-dumbquotes-map
775 "Table for MS-to-Latin1 translation.")
777 (defcustom gnus-ignored-mime-types nil
778 "List of MIME types that should be ignored by Gnus."
780 :group 'gnus-article-mime
781 :type '(repeat regexp))
783 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
784 "List of MIME types that should not be given buttons when rendered inline.
785 See also `gnus-buttonized-mime-types' which may override this variable.
786 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
788 :group 'gnus-article-mime
789 :type '(repeat regexp))
791 (defcustom gnus-buttonized-mime-types nil
792 "List of MIME types that should be given buttons when rendered inline.
793 If set, this variable overrides `gnus-unbuttonized-mime-types'.
794 To see e.g. security buttons you could set this to
795 `(\"multipart/signed\")'.
796 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
798 :group 'gnus-article-mime
799 :type '(repeat regexp))
801 (defcustom gnus-inhibit-mime-unbuttonizing nil
802 "If non-nil, all MIME parts get buttons.
803 When nil (the default value), then some MIME parts do not get buttons,
804 as described by the variables `gnus-buttonized-mime-types' and
805 `gnus-unbuttonized-mime-types'."
809 (defcustom gnus-body-boundary-delimiter "_"
810 "String used to delimit header and body.
811 This variable is used by `gnus-article-treat-body-boundary' which can
812 be controlled by `gnus-treat-body-boundary'."
813 :group 'gnus-article-various
814 :type '(choice (item :tag "None" :value nil)
817 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
818 "Defines the location of the faces database.
819 For information on obtaining this database of pretty pictures, please
820 see http://www.cs.indiana.edu/picons/ftp/index.html"
821 :type '(repeat directory)
822 :link '(url-link :tag "download"
823 "http://www.cs.indiana.edu/picons/ftp/index.html")
824 :link '(custom-manual "(gnus)Picons")
827 (defun gnus-picons-installed-p ()
828 "Say whether picons are installed on your machine."
829 (let ((installed nil))
830 (dolist (database gnus-picon-databases)
831 (when (file-exists-p database)
835 (defcustom gnus-article-mime-part-function nil
836 "Function called with a MIME handle as the argument.
837 This is meant for people who want to do something automatic based
838 on parts -- for instance, adding Vcard info to a database."
839 :group 'gnus-article-mime
842 (defcustom gnus-mime-multipart-functions nil
843 "An alist of MIME types to functions to display them."
845 :group 'gnus-article-mime
848 (defcustom gnus-article-date-lapsed-new-header nil
849 "Whether the X-Sent and Date headers can coexist.
850 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
851 either replace the old \"Date:\" header (if this variable is nil), or
852 be added below it (otherwise)."
854 :group 'gnus-article-headers
857 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
858 "Function called with a MIME handle as the argument.
859 This is meant for people who want to view first matched part.
860 For `undisplayed-alternative' (default), the first undisplayed
861 part or alternative part is used. For `undisplayed', the first
862 undisplayed part is used. For a function, the first part which
863 the function return t is used. For nil, the first part is
866 :group 'gnus-article-mime
868 (item :tag "first" :value nil)
869 (item :tag "undisplayed" :value undisplayed)
870 (item :tag "undisplayed or alternative"
871 :value undisplayed-alternative)
874 (defcustom gnus-mime-action-alist
875 '(("save to file" . gnus-mime-save-part)
876 ("save and strip" . gnus-mime-save-part-and-strip)
877 ("delete part" . gnus-mime-delete-part)
878 ("display as text" . gnus-mime-inline-part)
879 ("view the part" . gnus-mime-view-part)
880 ("pipe to command" . gnus-mime-pipe-part)
881 ("toggle display" . gnus-article-press-button)
882 ("toggle display" . gnus-article-view-part-as-charset)
883 ("view as type" . gnus-mime-view-part-as-type)
884 ("view internally" . gnus-mime-view-part-internally)
885 ("view externally" . gnus-mime-view-part-externally))
886 "An alist of actions that run on the MIME attachment."
887 :group 'gnus-article-mime
888 :type '(repeat (cons (string :tag "name")
892 ;;; The treatment variables
895 (defvar gnus-part-display-hook nil
896 "Hook called on parts that are to receive treatment.")
898 (defvar gnus-article-treat-custom
899 '(choice (const :tag "Off" nil)
901 (const :tag "Header" head)
902 (const :tag "Last" last)
903 (const :tag "Mime" mime)
904 (integer :tag "Less")
905 (repeat :tag "Groups" regexp)
906 (sexp :tag "Predicate")))
908 (defvar gnus-article-treat-head-custom
909 '(choice (const :tag "Off" nil)
910 (const :tag "Header" head)))
912 (defvar gnus-article-treat-types '("text/plain")
915 (defvar gnus-inhibit-treatment nil
916 "Whether to inhibit treatment.")
918 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
919 "Highlight the signature.
920 Valid values are nil, t, `head', `last', an integer or a predicate.
921 See Info node `(gnus)Customizing Articles'."
922 :group 'gnus-article-treat
923 :link '(custom-manual "(gnus)Customizing Articles")
924 :type gnus-article-treat-custom)
925 (put 'gnus-treat-highlight-signature 'highlight t)
927 (defcustom gnus-treat-buttonize 100000
929 Valid values are nil, t, `head', `last', an integer or a predicate.
930 See Info node `(gnus)Customizing Articles'."
931 :group 'gnus-article-treat
932 :link '(custom-manual "(gnus)Customizing Articles")
933 :type gnus-article-treat-custom)
934 (put 'gnus-treat-buttonize 'highlight t)
936 (defcustom gnus-treat-buttonize-head 'head
937 "Add buttons to the head.
938 Valid values are nil, t, `head', `last', an integer or a predicate.
939 See Info node `(gnus)Customizing Articles' for details."
940 :group 'gnus-article-treat
941 :link '(custom-manual "(gnus)Customizing Articles")
942 :type gnus-article-treat-head-custom)
943 (put 'gnus-treat-buttonize-head 'highlight t)
945 (defcustom gnus-treat-emphasize
946 (and (or window-system
948 (>= (string-to-number emacs-version) 21))
951 Valid values are nil, t, `head', `last', an integer or a predicate.
952 See Info node `(gnus)Customizing Articles' for details."
953 :group 'gnus-article-treat
954 :link '(custom-manual "(gnus)Customizing Articles")
955 :type gnus-article-treat-custom)
956 (put 'gnus-treat-emphasize 'highlight t)
958 (defcustom gnus-treat-strip-cr nil
959 "Remove carriage returns.
960 Valid values are nil, t, `head', `last', an integer or a predicate.
961 See Info node `(gnus)Customizing Articles' for details."
962 :group 'gnus-article-treat
963 :link '(custom-manual "(gnus)Customizing Articles")
964 :type gnus-article-treat-custom)
966 (defcustom gnus-treat-unsplit-urls nil
967 "Remove newlines from within URLs.
968 Valid values are nil, t, `head', `last', an integer or a predicate.
969 See Info node `(gnus)Customizing Articles' for details."
970 :group 'gnus-article-treat
971 :link '(custom-manual "(gnus)Customizing Articles")
972 :type gnus-article-treat-custom)
974 (defcustom gnus-treat-leading-whitespace nil
975 "Remove leading whitespace in headers.
976 Valid values are nil, t, `head', `last', an integer or a predicate.
977 See Info node `(gnus)Customizing Articles' for details."
978 :group 'gnus-article-treat
979 :link '(custom-manual "(gnus)Customizing Articles")
980 :type gnus-article-treat-custom)
982 (defcustom gnus-treat-hide-headers 'head
984 Valid values are nil, t, `head', `last', an integer or a predicate.
985 See Info node `(gnus)Customizing Articles' for details."
986 :group 'gnus-article-treat
987 :link '(custom-manual "(gnus)Customizing Articles")
988 :type gnus-article-treat-head-custom)
990 (defcustom gnus-treat-hide-boring-headers nil
991 "Hide boring headers.
992 Valid values are nil, t, `head', `last', an integer or a predicate.
993 See Info node `(gnus)Customizing Articles' for details."
994 :group 'gnus-article-treat
995 :link '(custom-manual "(gnus)Customizing Articles")
996 :type gnus-article-treat-head-custom)
998 (defcustom gnus-treat-hide-signature nil
1000 Valid values are nil, t, `head', `last', an integer or a predicate.
1001 See Info node `(gnus)Customizing Articles' for details."
1002 :group 'gnus-article-treat
1003 :link '(custom-manual "(gnus)Customizing Articles")
1004 :type gnus-article-treat-custom)
1006 (defcustom gnus-treat-fill-article nil
1008 Valid values are nil, t, `head', `last', an integer or a predicate.
1009 See Info node `(gnus)Customizing Articles' for details."
1010 :group 'gnus-article-treat
1011 :link '(custom-manual "(gnus)Customizing Articles")
1012 :type gnus-article-treat-custom)
1014 (defcustom gnus-treat-hide-citation nil
1016 Valid values are nil, t, `head', `last', an integer or a predicate.
1017 See Info node `(gnus)Customizing Articles' for details."
1018 :group 'gnus-article-treat
1019 :link '(custom-manual "(gnus)Customizing Articles")
1020 :type gnus-article-treat-custom)
1022 (defcustom gnus-treat-hide-citation-maybe nil
1024 Valid values are nil, t, `head', `last', an integer or a predicate.
1025 See Info node `(gnus)Customizing Articles' for details."
1026 :group 'gnus-article-treat
1027 :link '(custom-manual "(gnus)Customizing Articles")
1028 :type gnus-article-treat-custom)
1030 (defcustom gnus-treat-strip-list-identifiers 'head
1031 "Strip list identifiers from `gnus-list-identifiers`.
1032 Valid values are nil, t, `head', `last', an integer or a predicate.
1033 See Info node `(gnus)Customizing Articles' for details."
1035 :group 'gnus-article-treat
1036 :link '(custom-manual "(gnus)Customizing Articles")
1037 :type gnus-article-treat-custom)
1039 (make-obsolete-variable 'gnus-treat-strip-pgp
1040 "This option is obsolete in Gnus 5.10.")
1042 (defcustom gnus-treat-strip-pem nil
1043 "Strip PEM signatures.
1044 Valid values are nil, t, `head', `last', an integer or a predicate.
1045 See Info node `(gnus)Customizing Articles' for details."
1046 :group 'gnus-article-treat
1047 :link '(custom-manual "(gnus)Customizing Articles")
1048 :type gnus-article-treat-custom)
1050 (defcustom gnus-treat-strip-banner t
1051 "Strip banners from articles.
1052 The banner to be stripped is specified in the `banner' group parameter.
1053 Valid values are nil, t, `head', `last', an integer or a predicate.
1054 See Info node `(gnus)Customizing Articles' for details."
1055 :group 'gnus-article-treat
1056 :link '(custom-manual "(gnus)Customizing Articles")
1057 :type gnus-article-treat-custom)
1059 (defcustom gnus-treat-highlight-headers 'head
1060 "Highlight the headers.
1061 Valid values are nil, t, `head', `last', an integer or a predicate.
1062 See Info node `(gnus)Customizing Articles' for details."
1063 :group 'gnus-article-treat
1064 :link '(custom-manual "(gnus)Customizing Articles")
1065 :type gnus-article-treat-head-custom)
1066 (put 'gnus-treat-highlight-headers 'highlight t)
1068 (defcustom gnus-treat-highlight-citation t
1069 "Highlight cited text.
1070 Valid values are nil, t, `head', `last', an integer or a predicate.
1071 See Info node `(gnus)Customizing Articles' for details."
1072 :group 'gnus-article-treat
1073 :link '(custom-manual "(gnus)Customizing Articles")
1074 :type gnus-article-treat-custom)
1075 (put 'gnus-treat-highlight-citation 'highlight t)
1077 (defcustom gnus-treat-date-ut nil
1078 "Display the Date in UT (GMT).
1079 Valid values are nil, t, `head', `last', an integer or a predicate.
1080 See Info node `(gnus)Customizing Articles' for details."
1081 :group 'gnus-article-treat
1082 :link '(custom-manual "(gnus)Customizing Articles")
1083 :type gnus-article-treat-head-custom)
1085 (defcustom gnus-treat-date-local nil
1086 "Display the Date in the local timezone.
1087 Valid values are nil, t, `head', `last', an integer or a predicate.
1088 See Info node `(gnus)Customizing Articles' for details."
1089 :group 'gnus-article-treat
1090 :link '(custom-manual "(gnus)Customizing Articles")
1091 :type gnus-article-treat-head-custom)
1093 (defcustom gnus-treat-date-english nil
1094 "Display the Date in a format that can be read aloud in English.
1095 Valid values are nil, t, `head', `last', an integer or a predicate.
1096 See Info node `(gnus)Customizing Articles' for details."
1097 :group 'gnus-article-treat
1098 :link '(custom-manual "(gnus)Customizing Articles")
1099 :type gnus-article-treat-head-custom)
1101 (defcustom gnus-treat-date-lapsed nil
1102 "Display the Date header in a way that says how much time has elapsed.
1103 Valid values are nil, t, `head', `last', an integer or a predicate.
1104 See Info node `(gnus)Customizing Articles' for details."
1105 :group 'gnus-article-treat
1106 :link '(custom-manual "(gnus)Customizing Articles")
1107 :type gnus-article-treat-head-custom)
1109 (defcustom gnus-treat-date-original nil
1110 "Display the date in the original timezone.
1111 Valid values are nil, t, `head', `last', an integer or a predicate.
1112 See Info node `(gnus)Customizing Articles' for details."
1113 :group 'gnus-article-treat
1114 :link '(custom-manual "(gnus)Customizing Articles")
1115 :type gnus-article-treat-head-custom)
1117 (defcustom gnus-treat-date-iso8601 nil
1118 "Display the date in the ISO8601 format.
1119 Valid values are nil, t, `head', `last', an integer or a predicate.
1120 See Info node `(gnus)Customizing Articles' for details."
1122 :group 'gnus-article-treat
1123 :link '(custom-manual "(gnus)Customizing Articles")
1124 :type gnus-article-treat-head-custom)
1126 (defcustom gnus-treat-date-user-defined nil
1127 "Display the date in a user-defined format.
1128 The format is defined by the `gnus-article-time-format' variable.
1129 Valid values are nil, t, `head', `last', an integer or a predicate.
1130 See Info node `(gnus)Customizing Articles' for details."
1131 :group 'gnus-article-treat
1132 :link '(custom-manual "(gnus)Customizing Articles")
1133 :type gnus-article-treat-head-custom)
1135 (defcustom gnus-treat-strip-headers-in-body t
1136 "Strip the X-No-Archive header line from the beginning of the body.
1137 Valid values are nil, t, `head', `last', an integer or a predicate.
1138 See Info node `(gnus)Customizing Articles' for details."
1140 :group 'gnus-article-treat
1141 :link '(custom-manual "(gnus)Customizing Articles")
1142 :type gnus-article-treat-custom)
1144 (defcustom gnus-treat-strip-trailing-blank-lines nil
1145 "Strip trailing blank lines.
1146 Valid values are nil, t, `head', `last', an integer or a predicate.
1147 See Info node `(gnus)Customizing Articles' for details."
1148 :group 'gnus-article-treat
1149 :link '(custom-manual "(gnus)Customizing Articles")
1150 :type gnus-article-treat-custom)
1152 (defcustom gnus-treat-strip-leading-blank-lines nil
1153 "Strip leading blank lines.
1154 Valid values are nil, t, `head', `last', an integer or a predicate.
1155 See Info node `(gnus)Customizing Articles' for details."
1156 :group 'gnus-article-treat
1157 :link '(custom-manual "(gnus)Customizing Articles")
1158 :type gnus-article-treat-custom)
1160 (defcustom gnus-treat-strip-multiple-blank-lines nil
1161 "Strip multiple blank lines.
1162 Valid values are nil, t, `head', `last', an integer or a predicate.
1163 See Info node `(gnus)Customizing Articles' for details."
1164 :group 'gnus-article-treat
1165 :link '(custom-manual "(gnus)Customizing Articles")
1166 :type gnus-article-treat-custom)
1168 (defcustom gnus-treat-unfold-headers 'head
1169 "Unfold folded header lines.
1170 Valid values are nil, t, `head', `last', an integer or a predicate.
1171 See Info node `(gnus)Customizing Articles' for details."
1172 :group 'gnus-article-treat
1173 :link '(custom-manual "(gnus)Customizing Articles")
1174 :type gnus-article-treat-custom)
1176 (defcustom gnus-treat-fold-headers nil
1178 Valid values are nil, t, `head', `last', an integer or a predicate.
1179 See Info node `(gnus)Customizing Articles' for details."
1180 :group 'gnus-article-treat
1181 :link '(custom-manual "(gnus)Customizing Articles")
1182 :type gnus-article-treat-custom)
1184 (defcustom gnus-treat-fold-newsgroups 'head
1185 "Fold the Newsgroups and Followup-To headers.
1186 Valid values are nil, t, `head', `last', an integer or a predicate.
1187 See Info node `(gnus)Customizing Articles' for details."
1188 :group 'gnus-article-treat
1189 :link '(custom-manual "(gnus)Customizing Articles")
1190 :type gnus-article-treat-custom)
1192 (defcustom gnus-treat-overstrike t
1193 "Treat overstrike highlighting.
1194 Valid values are nil, t, `head', `last', an integer or a predicate.
1195 See Info node `(gnus)Customizing Articles' for details."
1196 :group 'gnus-article-treat
1197 :link '(custom-manual "(gnus)Customizing Articles")
1198 :type gnus-article-treat-custom)
1199 (put 'gnus-treat-overstrike 'highlight t)
1201 (defcustom gnus-treat-display-xface
1202 (and (not noninteractive)
1203 (or (memq gnus-article-x-face-command
1204 '(x-face-decode-message-header
1205 x-face-mule-gnus-article-display-x-face))
1206 (and (fboundp 'image-type-available-p)
1207 (image-type-available-p 'xbm)
1208 (string-match "^0x" (shell-command-to-string "uncompface"))
1209 (executable-find "icontopbm"))
1210 (and (featurep 'xemacs)
1213 "Display X-Face headers.
1214 Valid values are nil, t, `head', `last', an integer or a predicate.
1215 See Info node `(gnus)Customizing Articles' and Info node
1216 `(gnus)X-Face' for details."
1217 :group 'gnus-article-treat
1219 :link '(custom-manual "(gnus)Customizing Articles")
1220 :link '(custom-manual "(gnus)X-Face")
1221 :type gnus-article-treat-head-custom)
1222 (put 'gnus-treat-display-xface 'highlight t)
1224 (defcustom gnus-article-should-use-smiley-mule
1225 (not (or (featurep 'xemacs)
1226 (gnus-image-type-available-p 'xpm)
1227 (gnus-image-type-available-p 'pbm)))
1228 "If non-nil, gnus uses `smiley-mule' for displaying smileys rather than
1229 `smiley'. It defaults to t when Emacs 20 or earlier is running.
1230 `smiley-mule' is boundled in BITMAP-MULE package. You can set it to t
1231 even if you are using Emacs 21+. It has no effect on XEmacs."
1232 :group 'gnus-article-various
1234 :get (lambda (symbol)
1235 (and (not noninteractive)
1236 (default-value symbol)
1237 (not (featurep 'xemacs))
1238 (module-installed-p 'smiley-mule)
1240 :set (lambda (symbol value)
1241 (set-default symbol (and (not noninteractive)
1243 (not (featurep 'xemacs))
1244 (module-installed-p 'smiley-mule)
1247 (defvar gnus-article-smiley-mule-loaded-p nil
1248 "Internal variable used to say whether `smiley-mule' is loaded (whether
1249 smiley functions are not overridden by `smiley').")
1251 (defcustom gnus-treat-display-face
1252 (and (not noninteractive)
1253 ;; x-face-e21 handles both X-Face and Face headers.
1254 (not (and (eq gnus-article-x-face-command 'x-face-decode-message-header)
1255 (module-installed-p 'x-face-e21)))
1256 (or (and (fboundp 'image-type-available-p)
1257 (image-type-available-p 'png))
1258 (and (featurep 'xemacs)
1261 "Display Face headers.
1262 Valid values are nil, t, `head', `last', an integer or a predicate.
1263 See Info node `(gnus)Customizing Articles' and Info node
1264 `(gnus)X-Face' for details."
1265 :group 'gnus-article-treat
1267 :link '(custom-manual "(gnus)Customizing Articles")
1268 :link '(custom-manual "(gnus)X-Face")
1269 :type gnus-article-treat-head-custom)
1270 (put 'gnus-treat-display-face 'highlight t)
1272 (defcustom gnus-treat-display-smileys
1273 (if (and (not noninteractive)
1274 (or (and (featurep 'xemacs)
1276 (gnus-image-type-available-p 'xpm)
1277 (gnus-image-type-available-p 'pbm)
1278 (and (not (featurep 'xemacs))
1280 (module-installed-p 'smiley-mule))))
1284 Valid values are nil, t, `head', `last', an integer or a predicate.
1285 See Info node `(gnus)Customizing Articles' and Info node
1286 `(gnus)Smileys' for details."
1287 :group 'gnus-article-treat
1289 :link '(custom-manual "(gnus)Customizing Articles")
1290 :link '(custom-manual "(gnus)Smileys")
1291 :type gnus-article-treat-custom)
1292 (put 'gnus-treat-display-smileys 'highlight t)
1294 (defcustom gnus-treat-from-picon
1295 (if (and (gnus-image-type-available-p 'xpm)
1296 (gnus-picons-installed-p))
1298 "Display picons in the From header.
1299 Valid values are nil, t, `head', `last', an integer or a predicate.
1300 See Info node `(gnus)Customizing Articles' and Info node
1301 `(gnus)Picons' for details."
1302 :group 'gnus-article-treat
1304 :link '(custom-manual "(gnus)Customizing Articles")
1305 :link '(custom-manual "(gnus)Picons")
1306 :type gnus-article-treat-head-custom)
1307 (put 'gnus-treat-from-picon 'highlight t)
1309 (defcustom gnus-treat-mail-picon
1310 (if (and (gnus-image-type-available-p 'xpm)
1311 (gnus-picons-installed-p))
1313 "Display picons in To and Cc headers.
1314 Valid values are nil, t, `head', `last', an integer or a predicate.
1315 See Info node `(gnus)Customizing Articles' and Info node
1316 `(gnus)Picons' for details."
1317 :group 'gnus-article-treat
1319 :link '(custom-manual "(gnus)Customizing Articles")
1320 :link '(custom-manual "(gnus)Picons")
1321 :type gnus-article-treat-head-custom)
1322 (put 'gnus-treat-mail-picon 'highlight t)
1324 (defcustom gnus-treat-newsgroups-picon
1325 (if (and (gnus-image-type-available-p 'xpm)
1326 (gnus-picons-installed-p))
1328 "Display picons in the Newsgroups and Followup-To headers.
1329 Valid values are nil, t, `head', `last', an integer or a predicate.
1330 See Info node `(gnus)Customizing Articles' and Info node
1331 `(gnus)Picons' for details."
1332 :group 'gnus-article-treat
1334 :link '(custom-manual "(gnus)Customizing Articles")
1335 :link '(custom-manual "(gnus)Picons")
1336 :type gnus-article-treat-head-custom)
1337 (put 'gnus-treat-newsgroups-picon 'highlight t)
1339 (defcustom gnus-treat-body-boundary
1340 (if (or gnus-treat-newsgroups-picon
1341 gnus-treat-mail-picon
1342 gnus-treat-from-picon)
1344 "Draw a boundary at the end of the headers.
1345 Valid values are nil, t, `head', `last', an integer or a predicate.
1346 See Info node `(gnus)Customizing Articles' for details."
1348 :group 'gnus-article-treat
1349 :link '(custom-manual "(gnus)Customizing Articles")
1350 :type gnus-article-treat-custom)
1352 (defcustom gnus-treat-capitalize-sentences nil
1353 "Capitalize sentence-starting words.
1354 Valid values are nil, t, `head', `last', an integer or a predicate.
1355 See Info node `(gnus)Customizing Articles' for details."
1357 :group 'gnus-article-treat
1358 :link '(custom-manual "(gnus)Customizing Articles")
1359 :type gnus-article-treat-custom)
1361 (defcustom gnus-treat-wash-html nil
1363 Valid values are nil, t, `head', `last', an integer or a predicate.
1364 See Info node `(gnus)Customizing Articles' for details."
1365 :group 'gnus-article-treat
1366 :link '(custom-manual "(gnus)Customizing Articles")
1367 :type gnus-article-treat-custom)
1369 (defcustom gnus-treat-fill-long-lines nil
1371 Valid values are nil, t, `head', `last', an integer or a predicate.
1372 See Info node `(gnus)Customizing Articles' for details."
1373 :group 'gnus-article-treat
1374 :link '(custom-manual "(gnus)Customizing Articles")
1375 :type gnus-article-treat-custom)
1377 (defcustom gnus-treat-play-sounds nil
1379 Valid values are nil, t, `head', `last', an integer or a predicate.
1380 See Info node `(gnus)Customizing Articles' for details."
1382 :group 'gnus-article-treat
1383 :link '(custom-manual "(gnus)Customizing Articles")
1384 :type gnus-article-treat-custom)
1386 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
1387 "Decode an article as `default-mime-charset'. For instance, if you want to
1388 attempt to decode an article even if the value of `gnus-show-mime' is nil,
1389 you could set this variable to something like: nil for don't decode, t for
1390 decode the body, '(or header t) for the whole article, etc."
1391 :group 'gnus-article-treat
1392 :type '(radio (const :tag "Off" nil)
1393 (const :tag "Decode body" t)
1394 (const :tag "Decode all" (or head t))))
1396 (defcustom gnus-treat-translate nil
1397 "Translate articles from one language to another.
1398 Valid values are nil, t, `head', `last', an integer or a predicate.
1399 See Info node `(gnus)Customizing Articles' for details."
1401 :group 'gnus-article-treat
1402 :link '(custom-manual "(gnus)Customizing Articles")
1403 :type gnus-article-treat-custom)
1405 (defcustom gnus-treat-x-pgp-sig nil
1407 To automatically treat X-PGP-Sig, set it to head.
1408 Valid values are nil, t, `head', `last', an integer or a predicate.
1409 See Info node `(gnus)Customizing Articles' for details."
1410 :group 'gnus-article-treat
1411 :group 'mime-security
1412 :type gnus-article-treat-custom)
1414 (defcustom gnus-treat-monafy nil
1415 "Display body part with mona font.
1416 Valid values are nil, t, `head', `last', an integer or a predicate.
1417 See Info node `(gnus)Customizing Articles' for details."
1418 :group 'gnus-article-treat
1419 :group 'mime-security
1420 :link '(custom-manual "(gnus)Customizing Articles")
1421 :type gnus-article-treat-custom)
1423 (defvar gnus-article-encrypt-protocol-alist
1424 '(("PGP" . mml2015-self-encrypt)))
1426 ;; Set to nil if more than one protocol added to
1427 ;; gnus-article-encrypt-protocol-alist.
1428 (defcustom gnus-article-encrypt-protocol "PGP"
1429 "The protocol used for encrypt articles.
1430 It is a string, such as \"PGP\". If nil, ask user."
1432 :group 'mime-security)
1434 (defvar gnus-article-wash-function nil
1435 "Function used for converting HTML into text.")
1437 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1438 (mm-coding-system-p 'utf-8)
1439 (executable-find idna-program))
1440 "Whether IDNA decoding of headers is used when viewing messages.
1441 This requires GNU Libidn, and by default only enabled if it is found."
1442 :group 'gnus-article-headers
1445 (defcustom gnus-article-over-scroll nil
1446 "If non-nil, allow scrolling the article buffer even when there no more text."
1447 :group 'gnus-article
1450 ;;; Internal variables
1452 (defvar gnus-english-month-names
1453 '("January" "February" "March" "April" "May" "June" "July" "August"
1454 "September" "October" "November" "December"))
1456 (defvar article-goto-body-goes-to-point-min-p nil)
1457 (defvar gnus-article-wash-types nil)
1458 (defvar gnus-article-emphasis-alist nil)
1459 (defvar gnus-article-image-alist nil)
1461 (defvar gnus-article-mime-handle-alist-1 nil)
1462 (defvar gnus-treatment-function-alist
1463 '((gnus-treat-decode-article-as-default-mime-charset
1464 gnus-article-decode-article-as-default-mime-charset)
1465 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1466 (gnus-treat-monafy gnus-article-monafy)
1467 (gnus-treat-strip-banner gnus-article-strip-banner)
1468 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1469 (gnus-treat-buttonize gnus-article-add-buttons)
1470 (gnus-treat-fill-article gnus-article-fill-cited-article)
1471 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1472 (gnus-treat-strip-cr gnus-article-remove-cr)
1473 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1474 (gnus-treat-date-ut gnus-article-date-ut)
1475 (gnus-treat-date-local gnus-article-date-local)
1476 (gnus-treat-date-english gnus-article-date-english)
1477 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1478 (gnus-treat-date-original gnus-article-date-original)
1479 (gnus-treat-date-user-defined gnus-article-date-user)
1480 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1481 (gnus-treat-display-face gnus-article-display-face)
1482 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1483 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1484 (gnus-treat-hide-signature gnus-article-hide-signature)
1485 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1486 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1487 (gnus-treat-strip-pem gnus-article-hide-pem)
1488 (gnus-treat-from-picon gnus-treat-from-picon)
1489 (gnus-treat-mail-picon gnus-treat-mail-picon)
1490 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1491 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1492 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1493 (gnus-treat-strip-trailing-blank-lines
1494 gnus-article-remove-trailing-blank-lines)
1495 (gnus-treat-strip-leading-blank-lines
1496 gnus-article-strip-leading-blank-lines)
1497 (gnus-treat-strip-multiple-blank-lines
1498 gnus-article-strip-multiple-blank-lines)
1499 (gnus-treat-overstrike gnus-article-treat-overstrike)
1500 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1501 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1502 ;; Displaying X-Face should be done after unfolding headers
1503 ;; to protect bitmap lines.
1504 (gnus-treat-display-xface gnus-article-display-x-face)
1505 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1506 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1507 (gnus-treat-display-smileys gnus-treat-smiley)
1508 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1509 (gnus-treat-wash-html gnus-article-wash-html)
1510 (gnus-treat-emphasize gnus-article-emphasize)
1511 (gnus-treat-hide-citation gnus-article-hide-citation)
1512 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1513 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1514 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1515 (gnus-treat-play-sounds gnus-earcon-display)))
1517 (defvar gnus-article-mime-handle-alist nil)
1518 (defvar article-lapsed-timer nil)
1519 (defvar gnus-article-current-summary nil)
1521 (defvar gnus-article-mode-syntax-table
1522 (let ((table (copy-syntax-table text-mode-syntax-table)))
1523 ;; This causes the citation match run O(2^n).
1524 ;; (modify-syntax-entry ?- "w" table)
1525 (modify-syntax-entry ?> ")<" table)
1526 (modify-syntax-entry ?< "(>" table)
1527 ;; make M-. in article buffers work for `foo' strings
1528 (modify-syntax-entry ?' " " table)
1529 (modify-syntax-entry ?` " " table)
1531 "Syntax table used in article mode buffers.
1532 Initialized from `text-mode-syntax-table.")
1534 (defvar gnus-save-article-buffer nil)
1536 (defvar gnus-article-mode-line-format-alist
1537 (nconc '((?w (gnus-article-wash-status) ?s)
1538 (?m (gnus-article-mime-part-status) ?s))
1539 gnus-summary-mode-line-format-alist))
1541 (defvar gnus-number-of-articles-to-be-saved nil)
1543 (defvar gnus-inhibit-hiding nil)
1545 ;;; Macros for dealing with the article buffer.
1547 (defmacro gnus-with-article-headers (&rest forms)
1549 (set-buffer gnus-article-buffer)
1551 (let ((buffer-read-only nil)
1552 (inhibit-point-motion-hooks t)
1553 (case-fold-search t))
1554 (article-narrow-to-head)
1557 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1558 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1560 (defmacro gnus-with-article-buffer (&rest forms)
1562 (set-buffer gnus-article-buffer)
1563 (let ((buffer-read-only nil))
1566 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1567 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1569 (defun gnus-article-goto-header (header)
1570 "Go to HEADER, which is a regular expression."
1571 (re-search-forward (concat "^\\(" header "\\):") nil t))
1573 (defsubst gnus-article-hide-text (b e props)
1574 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1575 (gnus-add-text-properties-when 'article-type nil b e props)
1576 (when (memq 'intangible props)
1578 (max (1- b) (point-min))
1579 b 'intangible (cddr (memq 'intangible props)))))
1581 (defsubst gnus-article-unhide-text (b e)
1582 "Remove hidden text properties from region between B and E."
1583 (remove-text-properties b e gnus-hidden-properties)
1584 (when (memq 'intangible gnus-hidden-properties)
1585 (put-text-property (max (1- b) (point-min))
1586 b 'intangible nil)))
1588 (defun gnus-article-hide-text-type (b e type)
1589 "Hide text of TYPE between B and E."
1590 (gnus-add-wash-type type)
1591 (gnus-article-hide-text
1592 b e (cons 'article-type (cons type gnus-hidden-properties))))
1594 (defun gnus-article-unhide-text-type (b e type)
1595 "Unhide text of TYPE between B and E."
1596 (gnus-delete-wash-type type)
1597 (remove-text-properties
1598 b e (cons 'article-type (cons type gnus-hidden-properties)))
1599 (when (memq 'intangible gnus-hidden-properties)
1600 (put-text-property (max (1- b) (point-min))
1601 b 'intangible nil)))
1603 (defun gnus-article-hide-text-of-type (type)
1604 "Hide text of TYPE in the current buffer."
1606 (let ((b (point-min))
1608 (while (setq b (text-property-any b e 'article-type type))
1609 (add-text-properties b (incf b) gnus-hidden-properties)))))
1611 (defun gnus-article-delete-text-of-type (type)
1612 "Delete text of TYPE in the current buffer."
1614 (let ((b (point-min)))
1615 (while (setq b (text-property-any b (point-max) 'article-type type))
1617 b (or (text-property-not-all b (point-max) 'article-type type)
1620 (defun gnus-article-delete-invisible-text ()
1621 "Delete all invisible text in the current buffer."
1623 (let ((b (point-min)))
1624 (while (setq b (text-property-any b (point-max) 'invisible t))
1626 b (or (text-property-not-all b (point-max) 'invisible t)
1629 (defun gnus-article-text-type-exists-p (type)
1630 "Say whether any text of type TYPE exists in the buffer."
1631 (text-property-any (point-min) (point-max) 'article-type type))
1633 (defsubst gnus-article-header-rank ()
1634 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1635 (let ((list gnus-sorted-header-list)
1638 (if (looking-at (car list))
1640 (setq list (cdr list))
1644 (defun article-hide-headers (&optional arg delete)
1645 "Hide unwanted headers and possibly sort them as well."
1646 (interactive (gnus-article-hidden-arg))
1647 ;; Lars said that this function might be inhibited.
1648 (if (gnus-article-check-hidden-text 'headers arg)
1650 ;; Show boring headers as well.
1651 (gnus-article-show-hidden-text 'boring-headers)
1652 (when (eq 1 (point-min))
1653 (set-window-start (get-buffer-window (current-buffer)) 1)))
1654 (unless gnus-inhibit-hiding
1657 (let ((inhibit-read-only t)
1658 (case-fold-search t)
1659 (max (1+ (length gnus-sorted-header-list)))
1660 (ignored (when (not gnus-visible-headers)
1661 (cond ((stringp gnus-ignored-headers)
1662 gnus-ignored-headers)
1663 ((listp gnus-ignored-headers)
1664 (mapconcat 'identity gnus-ignored-headers
1667 (cond ((stringp gnus-visible-headers)
1668 gnus-visible-headers)
1669 ((and gnus-visible-headers
1670 (listp gnus-visible-headers))
1671 (mapconcat 'identity gnus-visible-headers "\\|"))))
1672 (inhibit-point-motion-hooks t)
1674 ;; First we narrow to just the headers.
1675 (article-narrow-to-head)
1676 ;; Hide any "From " lines at the beginning of (mail) articles.
1677 (while (looking-at "From ")
1681 (delete-region (point-min) (point))
1682 (gnus-article-hide-text (point-min) (point)
1683 (nconc (list 'article-type 'headers)
1684 gnus-hidden-properties))))
1685 ;; Then treat the rest of the header lines.
1686 ;; Then we use the two regular expressions
1687 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1688 ;; select which header lines is to remain visible in the
1690 (while (re-search-forward "^[^ \t:]*:" nil t)
1692 ;; Mark the rank of the header.
1694 (point) (1+ (point)) 'message-rank
1695 (if (or (and visible (looking-at visible))
1697 (not (looking-at ignored))))
1698 (gnus-article-header-rank)
1701 (message-sort-headers-1)
1702 (when (setq beg (text-property-any
1703 (point-min) (point-max) 'message-rank (+ 2 max)))
1704 ;; We delete or make invisible the unwanted headers.
1705 (gnus-add-wash-type 'headers)
1708 (add-text-properties
1709 (point-min) (+ 5 (point-min))
1710 '(article-type headers dummy-invisible t))
1711 (delete-region beg (point-max)))
1712 (gnus-article-hide-text-type beg (point-max) 'headers)))))))))
1714 (defun article-hide-boring-headers (&optional arg)
1715 "Toggle hiding of headers that aren't very interesting.
1716 If given a negative prefix, always show; if given a positive prefix,
1718 (interactive (gnus-article-hidden-arg))
1719 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1720 (not gnus-show-all-headers))
1723 (let ((buffer-read-only nil)
1724 (list gnus-boring-article-headers)
1725 (inhibit-point-motion-hooks t)
1727 (article-narrow-to-head)
1729 (setq elem (pop list))
1730 (goto-char (point-min))
1732 ;; Hide empty headers.
1734 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1736 (gnus-article-hide-text-type
1740 (if (re-search-forward "^[^ \t]" nil t)
1744 ;; Hide boring Newsgroups header.
1745 ((eq elem 'newsgroups)
1746 (when (gnus-string-equal
1747 (gnus-fetch-field "newsgroups")
1748 (gnus-group-real-name
1749 (if (boundp 'gnus-newsgroup-name)
1752 (gnus-article-hide-header "newsgroups")))
1753 ((eq elem 'to-address)
1754 (let ((to (message-fetch-field "to"))
1756 (gnus-parameter-to-address
1757 (if (boundp 'gnus-newsgroup-name)
1758 gnus-newsgroup-name ""))))
1759 (when (and to to-address
1762 ;; only one address in To
1763 (nth 1 (mail-extract-address-components to))
1765 (gnus-article-hide-header "to"))))
1767 (let ((to (message-fetch-field "to"))
1769 (gnus-parameter-to-list
1770 (if (boundp 'gnus-newsgroup-name)
1771 gnus-newsgroup-name ""))))
1772 (when (and to to-list
1775 ;; only one address in To
1776 (nth 1 (mail-extract-address-components to))
1778 (gnus-article-hide-header "to"))))
1780 (let ((cc (message-fetch-field "cc"))
1782 (gnus-parameter-to-list
1783 (if (boundp 'gnus-newsgroup-name)
1784 gnus-newsgroup-name ""))))
1785 (when (and cc to-list
1788 ;; only one address in CC
1789 (nth 1 (mail-extract-address-components cc))
1791 (gnus-article-hide-header "cc"))))
1792 ((eq elem 'followup-to)
1793 (when (gnus-string-equal
1794 (message-fetch-field "followup-to")
1795 (message-fetch-field "newsgroups"))
1796 (gnus-article-hide-header "followup-to")))
1797 ((eq elem 'reply-to)
1798 (if (gnus-group-find-parameter
1799 gnus-newsgroup-name 'broken-reply-to)
1800 (gnus-article-hide-header "reply-to")
1801 (let ((from (message-fetch-field "from"))
1802 (reply-to (message-fetch-field "reply-to")))
1807 (nth 1 (mail-extract-address-components from))
1808 (nth 1 (mail-extract-address-components reply-to)))))
1809 (gnus-article-hide-header "reply-to")))))
1811 (let ((date (message-fetch-field "date")))
1813 (< (days-between (current-time-string) date)
1815 (gnus-article-hide-header "date"))))
1817 (let ((to (message-fetch-field "to"))
1818 (cc (message-fetch-field "cc")))
1819 (when (> (length to) 1024)
1820 (gnus-article-hide-header "to"))
1821 (when (> (length cc) 1024)
1822 (gnus-article-hide-header "cc"))))
1826 (goto-char (point-min))
1827 (while (re-search-forward "^to:" nil t)
1828 (setq to-count (1+ to-count)))
1829 (when (> to-count 1)
1830 (while (> to-count 0)
1831 (goto-char (point-min))
1833 (re-search-forward "^to:" nil nil to-count)
1835 (narrow-to-region (point) (point-max))
1836 (gnus-article-hide-header "to"))
1837 (setq to-count (1- to-count))))
1838 (goto-char (point-min))
1839 (while (re-search-forward "^cc:" nil t)
1840 (setq cc-count (1+ cc-count)))
1841 (when (> cc-count 1)
1842 (while (> cc-count 0)
1843 (goto-char (point-min))
1845 (re-search-forward "^cc:" nil nil cc-count)
1847 (narrow-to-region (point) (point-max))
1848 (gnus-article-hide-header "cc"))
1849 (setq cc-count (1- cc-count)))))))))))))
1851 (defun gnus-article-hide-header (header)
1853 (goto-char (point-min))
1854 (when (re-search-forward (concat "^" header ":") nil t)
1855 (gnus-article-hide-text-type
1859 (if (re-search-forward "^[^ \t]" nil t)
1864 (defvar gnus-article-normalized-header-length 40
1865 "Length of normalized headers.")
1867 (defun article-normalize-headers ()
1868 "Make all header lines 40 characters long."
1870 (let ((buffer-read-only nil)
1874 (article-narrow-to-head)
1877 ((< (setq column (- (gnus-point-at-eol) (point)))
1878 gnus-article-normalized-header-length)
1880 (insert (make-string
1881 (- gnus-article-normalized-header-length column)
1883 ((> column gnus-article-normalized-header-length)
1884 (gnus-put-text-property
1886 (forward-char gnus-article-normalized-header-length)
1893 (forward-line 1))))))
1895 (defun article-treat-dumbquotes ()
1896 "Translate M****s*** sm*rtq**t*s into proper text.
1897 Note that this function guesses whether a character is a sm*rtq**t* or
1898 not, so it should only be used interactively.
1900 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1901 in an attempt to provide more quoting characters. If you see
1902 something like \\222 or \\264 where you're expecting some kind of
1903 apostrophe or quotation mark, then try this wash."
1905 (article-translate-strings gnus-article-dumbquotes-map))
1907 (defun article-translate-characters (from to)
1908 "Translate all characters in the body of the article according to FROM and TO.
1909 FROM is a string of characters to translate from; to is a string of
1910 characters to translate to."
1912 (when (article-goto-body)
1913 (let ((buffer-read-only nil)
1914 (x (make-string 225 ?x))
1916 (while (< (incf i) (length x))
1919 (while (< i (length from))
1920 (aset x (aref from i) (aref to i))
1922 (translate-region (point) (point-max) x)))))
1924 (defun article-translate-strings (map)
1925 "Translate all string in the body of the article according to MAP.
1926 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1928 (when (article-goto-body)
1929 (let ((buffer-read-only nil)
1931 (while (setq elem (pop map))
1933 (while (search-forward (car elem) nil t)
1934 (replace-match (cadr elem)))))))))
1936 (defun article-treat-overstrike ()
1937 "Translate overstrikes into bold text."
1940 (when (article-goto-body)
1941 (let ((buffer-read-only nil))
1942 (while (search-forward "\b" nil t)
1943 (let ((next (char-after))
1947 previous (char-after))
1951 ;; We do the boldification/underlining by hiding the
1952 ;; overstrikes and putting the proper text property
1956 (gnus-article-hide-text-type start (point) 'overstrike)
1957 (put-text-property (point) end 'face 'bold))
1959 (gnus-article-hide-text-type
1960 (1- (point)) (1+ (point)) 'overstrike)
1962 start (1- (point)) 'face 'underline))
1964 (gnus-article-hide-text-type start (point) 'overstrike)
1966 (point) end 'face 'underline)))))))))
1968 (defun gnus-article-treat-unfold-headers ()
1969 "Unfold folded message headers.
1970 Only the headers that fit into the current window width will be
1973 (gnus-with-article-headers
1977 (mail-header-narrow-to-field)
1978 (let ((header (buffer-string)))
1981 (goto-char (point-min))
1982 (while (re-search-forward "\n[\t ]" nil t)
1983 (replace-match " " t t)))
1984 (setq length (- (point-max) (point-min) 1)))
1985 (when (< length (window-width))
1986 (while (re-search-forward "\n[\t ]" nil t)
1987 (replace-match " " t t)))
1988 (goto-char (point-max)))))))
1990 (defun gnus-article-treat-fold-headers ()
1991 "Fold message headers."
1993 (gnus-with-article-headers
1996 (mail-header-narrow-to-field)
1997 (mail-header-fold-field)
1998 (goto-char (point-max))))))
2000 (defun gnus-treat-smiley ()
2001 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2003 (unless (featurep 'xemacs)
2004 (when (and (>= emacs-major-version 21)
2005 (not gnus-article-should-use-smiley-mule)
2006 gnus-article-smiley-mule-loaded-p)
2007 (load "smiley" nil t)
2008 (setq gnus-article-smiley-mule-loaded-p nil))
2009 (when (and gnus-article-should-use-smiley-mule
2010 (not gnus-article-smiley-mule-loaded-p))
2011 (load "smiley-mule" nil t)
2012 (setq gnus-article-smiley-mule-loaded-p t)))
2013 (gnus-with-article-buffer
2014 (if (memq 'smiley gnus-article-wash-types)
2015 (gnus-delete-images 'smiley)
2017 (let ((images (smiley-region (point) (point-max))))
2019 (gnus-add-wash-type 'smiley)
2020 (dolist (image images)
2021 (gnus-add-image 'smiley image)))))))
2023 (defun gnus-article-remove-images ()
2024 "Remove all images from the article buffer."
2026 (gnus-with-article-buffer
2027 (dolist (elem gnus-article-image-alist)
2028 (gnus-delete-images (car elem)))))
2030 (defun gnus-article-treat-fold-newsgroups ()
2031 "Unfold folded message headers.
2032 Only the headers that fit into the current window width will be
2035 (gnus-with-article-headers
2036 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2038 (mail-header-narrow-to-field)
2039 (while (re-search-forward ", *" nil t)
2040 (replace-match ", " t t))
2041 (mail-header-fold-field)
2042 (goto-char (point-max))))))
2044 (defun gnus-article-treat-body-boundary ()
2045 "Place a boundary line at the end of the headers."
2047 (when (and gnus-body-boundary-delimiter
2048 (> (length gnus-body-boundary-delimiter) 0))
2049 (gnus-with-article-headers
2050 (goto-char (point-max))
2051 (let ((start (point)))
2052 (insert "X-Boundary: ")
2053 (gnus-add-text-properties start (point) '(invisible t intangible t))
2055 (while (>= (1- (window-width)) (length str))
2056 (setq str (concat str gnus-body-boundary-delimiter)))
2057 (substring str 0 (1- (window-width))))
2059 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2061 (defun article-fill-long-lines ()
2062 "Fill lines that are wider than the window width."
2065 (let ((buffer-read-only nil)
2066 (width (window-width (get-buffer-window (current-buffer)))))
2069 (let ((adaptive-fill-mode nil)) ;Why? -sm
2072 (when (>= (current-column) (min fill-column width))
2073 (narrow-to-region (min (1+ (point)) (point-max))
2074 (gnus-point-at-bol))
2075 (let ((goback (point-marker)))
2076 (fill-paragraph nil)
2077 (goto-char (marker-position goback)))
2079 (forward-line 1)))))))
2081 (defun article-capitalize-sentences ()
2082 "Capitalize the first word in each sentence."
2085 (let ((buffer-read-only nil)
2086 (paragraph-start "^[\n\^L]"))
2090 (forward-sentence)))))
2092 (defun article-remove-cr ()
2093 "Remove trailing CRs and then translate remaining CRs into LFs."
2096 (let ((buffer-read-only nil))
2097 (goto-char (point-min))
2098 (while (re-search-forward "\r+$" nil t)
2099 (replace-match "" t t))
2100 (goto-char (point-min))
2101 (while (search-forward "\r" nil t)
2102 (replace-match "\n" t t)))))
2104 (defun article-remove-trailing-blank-lines ()
2105 "Remove all trailing blank lines from the article."
2108 (let ((buffer-read-only nil))
2109 (goto-char (point-max))
2113 (while (and (not (bobp))
2114 (looking-at "^[ \t]*$")
2115 (not (gnus-annotation-in-region-p
2116 (point) (gnus-point-at-eol))))
2121 (defun article-display-face ()
2122 "Display any Face headers in the header."
2124 (let ((wash-face-p buffer-read-only))
2125 (gnus-with-article-headers
2126 ;; When displaying parts, this function can be called several times on
2127 ;; the same article, without any intended toggle semantic (as typing `W
2128 ;; D d' would have). So face deletion must occur only when we come from
2129 ;; an interactive command, that is when the *Article* buffer is
2131 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2132 (gnus-delete-images 'face)
2135 (when (and wash-face-p
2137 (goto-char (point-min))
2138 (not (re-search-forward "^Face:[\t ]*" nil t)))
2139 (gnus-buffer-live-p gnus-original-article-buffer))
2140 (set-buffer gnus-original-article-buffer))
2142 (mail-narrow-to-head)
2143 (while (gnus-article-goto-header "Face")
2144 (push (mail-header-field-value) faces))))
2145 (while (setq face (pop faces))
2146 (let ((png (gnus-convert-face-to-png face))
2149 (setq image (gnus-create-image png 'png t))
2150 (gnus-article-goto-header "from")
2152 (insert "From: [no `from' set]\n")
2154 (gnus-add-wash-type 'face)
2155 (gnus-add-image 'face image)
2156 (gnus-put-image image nil 'face))))))
2159 (defun article-display-x-face (&optional force)
2160 "Look for an X-Face header and display it if present."
2161 (interactive (list 'force))
2162 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2163 (gnus-with-article-headers
2164 ;; Delete the old process, if any.
2165 (when (process-status "article-x-face")
2166 (delete-process "article-x-face"))
2167 ;; See the comment in `article-display-face'.
2168 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2169 ;; We have already displayed X-Faces, so we remove them
2171 (gnus-delete-images 'xface)
2173 (let (x-faces from face)
2175 (when (and wash-face-p
2177 (goto-char (point-min))
2178 (not (re-search-forward
2179 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2180 (gnus-buffer-live-p gnus-original-article-buffer))
2181 ;; If type `W f', use gnus-original-article-buffer,
2182 ;; otherwise use the current buffer because displaying
2183 ;; RFC822 parts calls this function too.
2184 (set-buffer gnus-original-article-buffer))
2186 (mail-narrow-to-head)
2187 (while (gnus-article-goto-header "X-Face")
2188 (push (mail-header-field-value) x-faces))
2189 (setq from (message-fetch-field "from"))))
2190 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2191 ;; single external face.
2192 (when (stringp gnus-article-x-face-command)
2193 (setq x-faces (list (car x-faces))))
2194 (while (and (setq face (pop x-faces))
2195 gnus-article-x-face-command
2197 ;; Check whether this face is censored.
2198 (not gnus-article-x-face-too-ugly)
2199 (and gnus-article-x-face-too-ugly from
2200 (not (string-match gnus-article-x-face-too-ugly
2202 ;; We display the face.
2203 (if (symbolp gnus-article-x-face-command)
2204 ;; The command is a lisp function, so we call it.
2205 (if (functionp gnus-article-x-face-command)
2206 (funcall gnus-article-x-face-command face)
2207 (error "%s is not a function" gnus-article-x-face-command))
2208 ;; The command is a string, so we interpret the command
2209 ;; as a, well, command, and fork it off.
2210 (let ((process-connection-type nil))
2211 (process-kill-without-query
2213 "article-x-face" nil shell-file-name shell-command-switch
2214 gnus-article-x-face-command))
2217 (process-send-region "article-x-face"
2218 (point-min) (point-max)))
2219 (process-send-eof "article-x-face")))))))))
2221 (defun article-decode-mime-words ()
2222 "Decode all MIME-encoded words in the article."
2225 (set-buffer gnus-article-buffer)
2226 (let ((inhibit-point-motion-hooks t)
2228 (mail-parse-charset gnus-newsgroup-charset)
2229 (mail-parse-ignored-charsets
2230 (save-excursion (set-buffer gnus-summary-buffer)
2231 gnus-newsgroup-ignored-charsets)))
2232 (mail-decode-encoded-word-region (point-min) (point-max)))))
2234 (defun article-decode-charset (&optional prompt)
2235 "Decode charset-encoded text in the article.
2236 If PROMPT (the prefix), prompt for a coding system to use."
2238 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2240 (mail-parse-charset gnus-newsgroup-charset)
2241 (mail-parse-ignored-charsets
2242 (save-excursion (condition-case nil
2243 (set-buffer gnus-summary-buffer)
2245 gnus-newsgroup-ignored-charsets))
2246 ct cte ctl charset format)
2249 (article-narrow-to-head)
2250 (setq ct (message-fetch-field "Content-Type" t)
2251 cte (message-fetch-field "Content-Transfer-Encoding" t)
2252 ctl (and ct (ignore-errors
2253 (mail-header-parse-content-type ct)))
2256 (mm-read-coding-system "Charset to decode: "))
2258 (mail-content-type-get ctl 'charset)))
2259 format (and ctl (mail-content-type-get ctl 'format)))
2261 (setq cte (mail-header-strip cte)))
2262 (if (and ctl (not (string-match "/" (car ctl))))
2264 (goto-char (point-max)))
2267 (narrow-to-region (point) (point-max))
2268 (when (and (eq mail-parse-charset 'gnus-decoded)
2269 (eq (mm-body-7-or-8) '8bit))
2270 ;; The text code could have been decoded.
2271 (setq charset mail-parse-charset))
2272 (when (and (or (not ctl)
2273 (equal (car ctl) "text/plain"))
2274 (not format)) ;; article with format will decode later.
2276 charset (and cte (intern (downcase
2277 (gnus-strip-whitespace cte))))
2280 (defun article-decode-encoded-words ()
2281 "Remove encoded-word encoding from headers."
2282 (let (buffer-read-only)
2283 (let ((charset (save-excursion
2284 (set-buffer gnus-summary-buffer)
2285 default-mime-charset)))
2286 (mime-decode-header-in-buffer charset))))
2288 (defun article-decode-group-name ()
2289 "Decode group names in `Newsgroups:'."
2290 (let ((inhibit-point-motion-hooks t)
2292 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2293 (when (and (or gnus-group-name-charset-method-alist
2294 gnus-group-name-charset-group-alist)
2295 (gnus-buffer-live-p gnus-original-article-buffer))
2297 (article-narrow-to-head)
2298 (with-current-buffer gnus-original-article-buffer
2299 (goto-char (point-min)))
2300 (while (re-search-forward
2301 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2302 (replace-match (save-match-data
2303 (gnus-decode-newsgroups
2304 ;; XXX how to use data in article buffer?
2305 (with-current-buffer gnus-original-article-buffer
2307 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2310 gnus-newsgroup-name method))
2312 (goto-char (point-min))
2313 (with-current-buffer gnus-original-article-buffer
2314 (goto-char (point-min)))
2315 (while (re-search-forward
2316 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2317 (replace-match (save-match-data
2318 (gnus-decode-newsgroups
2319 ;; XXX how to use data in article buffer?
2320 (with-current-buffer gnus-original-article-buffer
2322 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2325 gnus-newsgroup-name method))
2328 (autoload 'idna-to-unicode "idna")
2330 (defun article-decode-idna-rhs ()
2331 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2334 (let ((inhibit-point-motion-hooks t)
2336 (article-narrow-to-head)
2337 (goto-char (point-min))
2338 (while (re-search-forward "\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2340 (when (save-match-data
2341 (and (setq ace (match-string 1))
2343 (and (re-search-backward "^[^ \t]" nil t)
2344 (looking-at "From\\|To\\|Cc")))
2345 (save-excursion (backward-char)
2346 (message-idna-inside-rhs-p))
2347 (setq unicode (idna-to-unicode ace))))
2348 (unless (string= ace unicode)
2349 (replace-match unicode nil nil nil 1)))))))))
2351 (defun article-de-quoted-unreadable (&optional force read-charset)
2352 "Translate a quoted-printable-encoded article.
2353 If FORCE, decode the article whether it is marked as quoted-printable
2355 If READ-CHARSET, ask for a coding system."
2356 (interactive (list 'force current-prefix-arg))
2358 (let ((buffer-read-only nil) type charset)
2359 (if (gnus-buffer-live-p gnus-original-article-buffer)
2360 (with-current-buffer gnus-original-article-buffer
2362 (gnus-fetch-field "content-transfer-encoding"))
2363 (let* ((ct (gnus-fetch-field "content-type"))
2366 (mail-header-parse-content-type ct)))))
2367 (setq charset (and ctl
2368 (mail-content-type-get ctl 'charset)))
2369 (if (stringp charset)
2370 (setq charset (intern (downcase charset)))))))
2372 (setq charset (mm-read-coding-system "Charset: " charset)))
2374 (setq charset gnus-newsgroup-charset))
2376 (and type (let ((case-fold-search t))
2377 (string-match "quoted-printable" type))))
2379 (quoted-printable-decode-region
2380 (point) (point-max) (mm-charset-to-coding-system charset))))))
2382 (defun article-de-base64-unreadable (&optional force read-charset)
2383 "Translate a base64 article.
2384 If FORCE, decode the article whether it is marked as base64 not.
2385 If READ-CHARSET, ask for a coding system."
2386 (interactive (list 'force current-prefix-arg))
2388 (let ((buffer-read-only nil) type charset)
2389 (if (gnus-buffer-live-p gnus-original-article-buffer)
2390 (with-current-buffer gnus-original-article-buffer
2392 (gnus-fetch-field "content-transfer-encoding"))
2393 (let* ((ct (gnus-fetch-field "content-type"))
2396 (mail-header-parse-content-type ct)))))
2397 (setq charset (and ctl
2398 (mail-content-type-get ctl 'charset)))
2399 (if (stringp charset)
2400 (setq charset (intern (downcase charset)))))))
2402 (setq charset (mm-read-coding-system "Charset: " charset)))
2404 (setq charset gnus-newsgroup-charset))
2406 (and type (let ((case-fold-search t))
2407 (string-match "base64" type))))
2410 (narrow-to-region (point) (point-max))
2411 (base64-decode-region (point-min) (point-max))
2412 (mm-decode-coding-region
2413 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2418 (defun article-decode-HZ ()
2419 "Translate a HZ-encoded article."
2423 (let ((buffer-read-only nil))
2424 (rfc1843-decode-region (point-min) (point-max)))))
2426 (defun article-unsplit-urls ()
2427 "Remove the newlines that some other mailers insert into URLs."
2430 (let ((buffer-read-only nil))
2431 (goto-char (point-min))
2432 (while (re-search-forward
2433 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2434 (replace-match "\\1\\3" t)))
2435 (when (interactive-p)
2436 (gnus-treat-article nil))))
2439 (defun article-wash-html (&optional read-charset)
2440 "Format an HTML article.
2441 If READ-CHARSET, ask for a coding system."
2444 (let ((buffer-read-only nil)
2446 (when (gnus-buffer-live-p gnus-original-article-buffer)
2447 (with-current-buffer gnus-original-article-buffer
2448 (let* ((ct (gnus-fetch-field "content-type"))
2451 (mail-header-parse-content-type ct)))))
2452 (setq charset (and ctl
2453 (mail-content-type-get ctl 'charset)))
2454 (when (stringp charset)
2455 (setq charset (intern (downcase charset)))))))
2457 (setq charset (mm-read-coding-system "Charset: " charset)))
2459 (setq charset gnus-newsgroup-charset))
2461 (save-window-excursion
2463 (narrow-to-region (point) (point-max))
2464 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2465 (entry (assq func mm-text-html-washer-alist)))
2467 (setq func (cdr entry)))
2472 (apply (car func) (cdr func))))))))))
2474 (defun gnus-article-wash-html-with-w3 ()
2475 "Wash the current buffer with w3."
2477 (let ((w3-strict-width (window-width))
2478 (url-standalone-mode t)
2479 (url-gateway-unplugged t)
2480 (w3-honor-stylesheets nil))
2482 (w3-region (point-min) (point-max))
2485 (defun gnus-article-wash-html-with-w3m ()
2486 "Wash the current buffer with emacs-w3m."
2489 (narrow-to-region (point) (point-max))
2490 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2493 w3m-force-redisplay)
2494 (w3m-region (point-min) (point-max)))
2495 (when mm-inline-text-html-with-w3m-keymap
2496 (add-text-properties
2497 (point-min) (point-max)
2498 (nconc (mm-w3m-local-map-property)
2499 '(mm-inline-text-html-with-w3m t))))))
2501 (defun article-hide-list-identifiers ()
2502 "Remove list identifies from the Subject header.
2503 The `gnus-list-identifiers' variable specifies what to do."
2505 (let ((inhibit-point-motion-hooks t)
2506 (regexp (if (consp gnus-list-identifiers)
2507 (mapconcat 'identity gnus-list-identifiers " *\\|")
2508 gnus-list-identifiers))
2513 (article-narrow-to-head)
2514 (goto-char (point-min))
2515 (while (re-search-forward
2516 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2518 (delete-region (match-beginning 2) (match-end 0))
2519 (beginning-of-line))
2520 (when (re-search-forward
2521 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2522 (delete-region (match-beginning 1) (match-end 1))))))))
2524 (defun article-hide-pem (&optional arg)
2525 "Toggle hiding of any PEM headers and signatures in the current article.
2526 If given a negative prefix, always show; if given a positive prefix,
2528 (interactive (gnus-article-hidden-arg))
2529 (unless (gnus-article-check-hidden-text 'pem arg)
2531 (let (buffer-read-only end)
2532 (goto-char (point-min))
2533 ;; Hide the horrendously ugly "header".
2534 (when (and (search-forward
2535 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2537 (setq end (1+ (match-beginning 0))))
2538 (gnus-add-wash-type 'pem)
2539 (gnus-article-hide-text-type
2541 (if (search-forward "\n\n" nil t)
2545 ;; Hide the trailer as well
2546 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2548 (gnus-article-hide-text-type
2549 (match-beginning 0) (match-end 0) 'pem)))))))
2551 (defun article-strip-banner ()
2552 "Strip the banners specified by the `banner' group parameter and by
2553 `gnus-article-address-banner-alist'."
2557 (let ((inhibit-point-motion-hooks t))
2558 (when (gnus-parameter-banner gnus-newsgroup-name)
2559 (article-really-strip-banner
2560 (gnus-parameter-banner gnus-newsgroup-name)))
2561 (when gnus-article-address-banner-alist
2562 (article-really-strip-banner
2563 (let ((from (save-restriction
2565 (article-narrow-to-head)
2566 (mail-fetch-field "from"))))
2569 (caar (mail-header-parse-addresses from))))
2571 (dolist (pair gnus-article-address-banner-alist)
2572 (when (string-match (car pair) from)
2573 (throw 'found (cdr pair)))))))))))))
2575 (defun article-really-strip-banner (banner)
2576 "Strip the banner specified by the argument."
2579 (let ((inhibit-point-motion-hooks t)
2580 (gnus-signature-limit nil)
2584 ((eq banner 'signature)
2585 (when (gnus-article-narrow-to-signature)
2588 (delete-region (point) (point-max))))
2590 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2591 (while (re-search-forward banner nil t)
2592 (delete-region (match-beginning 0) (match-end 0)))))
2594 (while (re-search-forward banner nil t)
2595 (delete-region (match-beginning 0) (match-end 0)))))))))
2597 (defun article-babel ()
2598 "Translate article using an online translation service."
2602 (set-buffer gnus-article-buffer)
2603 (when (article-goto-body)
2604 (let* ((buffer-read-only nil)
2607 (orig (buffer-substring start end))
2608 (trans (babel-as-string orig)))
2610 (narrow-to-region start end)
2611 (delete-region start end)
2614 (defun article-hide-signature (&optional arg)
2615 "Hide the signature in the current article.
2616 If given a negative prefix, always show; if given a positive prefix,
2618 (interactive (gnus-article-hidden-arg))
2624 (article-goto-body))
2625 (goto-char (point-min)))
2626 (unless (gnus-article-check-hidden-text 'signature arg)
2627 (let ((buffer-read-only nil)
2629 (while (setq button (text-property-any button (point-max)
2631 'gnus-signature-toggle))
2632 (setq button (text-property-not-all button (point-max)
2634 'gnus-signature-toggle))
2635 (when (and button (not (eobp)))
2636 (gnus-article-hide-text-type
2638 (next-single-property-change (1+ button) 'mime-view-entity
2641 (gnus-set-mode-line 'article))
2643 (defun article-strip-headers-in-body ()
2644 "Strip offensive headers from bodies."
2648 (let ((case-fold-search t))
2649 (when (looking-at "x-no-archive:")
2650 (gnus-delete-line)))))
2652 (defun article-strip-leading-blank-lines ()
2653 "Remove all blank lines from the beginning of the article."
2656 (let ((inhibit-point-motion-hooks t)
2658 (when (article-goto-body)
2659 (while (and (not (eobp))
2660 (looking-at "[ \t]*$"))
2661 (gnus-delete-line))))))
2663 (defun article-narrow-to-head ()
2664 "Narrow the buffer to the head of the message.
2665 Point is left at the beginning of the narrowed-to region."
2667 (goto-char (point-min))
2668 (if (search-forward "\n\n" nil 1)
2671 (goto-char (point-min)))
2673 (defun article-goto-body ()
2674 "Place point at the start of the body."
2675 (goto-char (point-min))
2677 ;; This variable is only bound when dealing with separate
2679 (article-goto-body-goes-to-point-min-p
2681 ((search-forward "\n\n" nil t)
2684 (goto-char (point-max))
2687 (defun article-strip-multiple-blank-lines ()
2688 "Replace consecutive blank lines with one empty line."
2691 (let ((inhibit-point-motion-hooks t)
2693 ;; First make all blank lines empty.
2695 (while (re-search-forward "^[ \t]+$" nil t)
2696 (unless (gnus-annotation-in-region-p
2697 (match-beginning 0) (match-end 0))
2698 (replace-match "" nil t)))
2699 ;; Then replace multiple empty lines with a single empty line.
2701 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2702 (unless (gnus-annotation-in-region-p
2703 (match-beginning 0) (match-end 0))
2704 (delete-region (match-beginning 1) (match-end 1)))))))
2706 (defun article-strip-leading-space ()
2707 "Remove all white space from the beginning of the lines in the article."
2710 (let ((inhibit-point-motion-hooks t)
2713 (while (re-search-forward "^[ \t]+" nil t)
2714 (replace-match "" t t)))))
2716 (defun article-strip-trailing-space ()
2717 "Remove all white space from the end of the lines in the article."
2720 (let ((inhibit-point-motion-hooks t)
2723 (while (re-search-forward "[ \t]+$" nil t)
2724 (replace-match "" t t)))))
2726 (defun article-strip-blank-lines ()
2727 "Strip leading, trailing and multiple blank lines."
2729 (article-strip-leading-blank-lines)
2730 (article-remove-trailing-blank-lines)
2731 (article-strip-multiple-blank-lines))
2733 (defun article-strip-all-blank-lines ()
2734 "Strip all blank lines."
2737 (let ((inhibit-point-motion-hooks t)
2740 (while (re-search-forward "^[ \t]*\n" nil t)
2741 (replace-match "" t t)))))
2743 (defun gnus-article-narrow-to-signature ()
2744 "Narrow to the signature; return t if a signature is found, else nil."
2745 (let ((inhibit-point-motion-hooks t))
2746 (when (gnus-article-search-signature)
2748 ;; Check whether we have some limits to what we consider
2749 ;; to be a signature.
2750 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2751 (list gnus-signature-limit)))
2753 (while (setq limit (pop limits))
2754 (if (or (and (integerp limit)
2755 (< (- (point-max) (point)) limit))
2757 (< (count-lines (point) (point-max)) limit))
2758 (and (functionp limit)
2760 (and (stringp limit)
2761 (not (re-search-forward limit nil t))))
2762 () ; This limit did not succeed.
2766 (narrow-to-region (point) (point-max))
2769 (defun gnus-article-search-signature ()
2770 "Search the current buffer for the signature separator.
2771 Put point at the beginning of the signature separator."
2772 (let ((cur (point)))
2773 (goto-char (point-max))
2774 (if (if (stringp gnus-signature-separator)
2775 (re-search-backward gnus-signature-separator nil t)
2776 (let ((seps gnus-signature-separator))
2778 (not (re-search-backward (car seps) nil t)))
2785 (defun gnus-article-hidden-arg ()
2786 "Return the current prefix arg as a number, or 0 if no prefix."
2787 (list (if current-prefix-arg
2788 (prefix-numeric-value current-prefix-arg)
2791 (defun gnus-article-check-hidden-text (type arg)
2792 "Return nil if hiding is necessary.
2793 Arg can be nil or a number. nil and positive means hide, negative
2794 means show, 0 means toggle."
2797 (let ((hide (gnus-article-hidden-text-p type)))
2803 (gnus-article-show-hidden-text type)
2806 (if (eq hide 'hidden)
2808 (gnus-article-show-hidden-text type)
2812 (defun gnus-article-hidden-text-p (type)
2813 "Say whether the current buffer contains hidden text of type TYPE."
2814 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2816 (not (get-text-property pos 'invisible))
2817 (not (get-text-property pos 'dummy-invisible)))
2819 (text-property-any (1+ pos) (point-max) 'article-type type)))
2824 (defun gnus-article-show-hidden-text (type &optional dummy)
2825 "Show all hidden text of type TYPE.
2826 Originally it is hide instead of DUMMY."
2827 (let ((buffer-read-only nil)
2828 (inhibit-point-motion-hooks t))
2829 (gnus-remove-text-properties-when
2831 (point-min) (point-max)
2832 (cons 'article-type (cons type
2833 gnus-hidden-properties)))
2834 (gnus-delete-wash-type type)))
2836 (defconst article-time-units
2837 `((year . ,(* 365.25 24 60 60))
2838 (week . ,(* 7 24 60 60))
2839 (day . ,(* 24 60 60))
2843 "Mapping from time units to seconds.")
2845 (defun gnus-article-forward-header ()
2846 "Move point to the start of the next header.
2847 If the current header is a continuation header, this can be several
2852 (if (looking-at "[ \t]+[^ \t]")
2856 (defun article-date-ut (&optional type highlight header)
2857 "Convert DATE date to universal time in the current article.
2858 If TYPE is `local', convert to local time; if it is `lapsed', output
2859 how much time has lapsed since DATE. For `lapsed', the value of
2860 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2861 should replace the \"Date:\" one, or should be added below it."
2862 (interactive (list 'ut t))
2863 (let* ((header (or header
2864 (and (eq 1 (point-min))
2865 (mail-header-date (save-excursion
2866 (set-buffer gnus-summary-buffer)
2867 gnus-current-headers)))
2868 (message-fetch-field "date")
2870 (date (if (vectorp header) (mail-header-date header)
2872 (inhibit-point-motion-hooks t)
2873 bface eface date-pos)
2874 (when (and date (not (string= date "")))
2877 (article-narrow-to-head)
2878 (when (or (and (eq type 'lapsed)
2879 gnus-article-date-lapsed-new-header
2880 ;; Attempt to get the face of X-Sent first.
2881 (re-search-forward "^X-Sent:[ \t]" nil t))
2882 (re-search-forward "^Date:[ \t]" nil t)
2883 ;; If Date is missing, try again for X-Sent.
2884 (re-search-forward "^X-Sent:[ \t]" nil t))
2885 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2886 date (or (get-text-property (gnus-point-at-bol)
2889 eface (get-text-property (1- (gnus-point-at-eol))
2891 (let ((buffer-read-only nil))
2892 ;; Delete any old X-Sent headers.
2893 (when (setq date-pos
2894 (text-property-any (point-min) (point-max)
2895 'article-date-lapsed t))
2896 (goto-char (setq date-pos (set-marker (make-marker) date-pos)))
2897 (delete-region (match-beginning 0)
2898 (progn (forward-line 1) (point))))
2899 (goto-char (point-min))
2900 ;; Delete any old Date headers.
2901 (while (re-search-forward "^Date:[ \t]" nil t)
2903 (setq date-pos (match-beginning 0)))
2904 (unless (and (eq type 'lapsed)
2905 gnus-article-date-lapsed-new-header)
2906 (delete-region (match-beginning 0)
2907 (progn (message-next-header) (point)))))
2910 (goto-char date-pos)
2912 ;; Possibly, Date has been deleted.
2914 (when (and (eq type 'lapsed)
2915 gnus-article-date-lapsed-new-header
2916 (looking-at "Date:"))
2918 (goto-char (point-min)))
2919 (insert (article-make-date-line date type))
2920 (when (eq type 'lapsed)
2921 (put-text-property (gnus-point-at-bol) (point)
2922 'article-date-lapsed t))
2926 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2927 (put-text-property (match-beginning 1) (1+ (match-end 1))
2928 'original-date date)
2929 (put-text-property (match-beginning 1) (1+ (match-end 1))
2931 (put-text-property (match-beginning 2) (match-end 2)
2934 (defun article-make-date-line (date type)
2935 "Return a DATE line of TYPE."
2936 (unless (memq type '(local ut original user iso8601 lapsed english))
2937 (error "Unknown conversion type: %s" type))
2939 (let ((time (date-to-time date)))
2941 ;; Convert to the local timezone.
2943 (let ((tz (car (current-time-zone time))))
2944 (format "Date: %s %s%02d%02d" (current-time-string time)
2945 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2946 (/ (% (abs tz) 3600) 60))))
2947 ;; Convert to Universal Time.
2950 (current-time-string
2951 (let* ((e (parse-time-string date))
2952 (tm (apply 'encode-time e))
2954 (ls (- (cadr tm) (car (current-time-zone time)))))
2955 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2956 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2959 ;; Get the original date from the article.
2960 ((eq type 'original)
2961 (concat "Date: " (if (string-match "\n+$" date)
2962 (substring date 0 (match-beginning 0))
2964 ;; Let the user define the format.
2966 (let ((format (or (condition-case nil
2967 (with-current-buffer gnus-summary-buffer
2968 gnus-article-time-format)
2970 gnus-article-time-format)))
2971 (if (functionp format)
2972 (funcall format time)
2973 (concat "Date: " (format-time-string format time)))))
2976 (let ((tz (car (current-time-zone time))))
2979 (format-time-string "%Y%m%dT%H%M%S" time)
2980 (format "%s%02d%02d"
2981 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2982 (/ (% (abs tz) 3600) 60)))))
2983 ;; Do an X-Sent lapsed format.
2985 ;; If the date is seriously mangled, the timezone functions are
2986 ;; liable to bug out, so we ignore all errors.
2987 (let* ((now (current-time))
2988 (real-time (subtract-time now time))
2989 (real-sec (and real-time
2990 (+ (* (float (car real-time)) 65536)
2992 (sec (and real-time (abs real-sec)))
3002 ;; This is a bit convoluted, but basically we go
3003 ;; through the time units for years, weeks, etc,
3004 ;; and divide things to see whether that results
3005 ;; in positive answers.
3008 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3009 ;; The (remaining) seconds are too few to
3010 ;; be divided into this time unit.
3012 ;; It's big enough, so we output it.
3013 (setq sec (- sec (* num (cdr unit))))
3015 (concat (if prev ", " "") (int-to-string
3017 " " (symbol-name (car unit))
3018 (if (> num 1) "s" ""))
3020 article-time-units "")
3021 ;; If dates are odd, then it might appear like the
3022 ;; article was sent in the future.
3025 " in the future"))))))
3026 ;; Display the date in proper English
3028 (let ((dtime (decode-time time)))
3031 (number-to-string (nth 3 dtime))
3032 (let ((digit (% (nth 3 dtime) 10)))
3034 ((memq (nth 3 dtime) '(11 12 13)) "th")
3040 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3042 (number-to-string (nth 5 dtime))
3044 (format "%02d" (nth 2 dtime))
3046 (format "%02d" (nth 1 dtime)))))))
3048 (format "Date: %s (from T-gnus)" date))))
3050 (defun article-date-local (&optional highlight)
3051 "Convert the current article date to the local timezone."
3052 (interactive (list t))
3053 (article-date-ut 'local highlight))
3055 (defun article-date-english (&optional highlight)
3056 "Convert the current article date to something that is proper English."
3057 (interactive (list t))
3058 (article-date-ut 'english highlight))
3060 (defun article-date-original (&optional highlight)
3061 "Convert the current article date to what it was originally.
3062 This is only useful if you have used some other date conversion
3063 function and want to see what the date was before converting."
3064 (interactive (list t))
3065 (article-date-ut 'original highlight))
3067 (defun article-date-lapsed (&optional highlight)
3068 "Convert the current article date to time lapsed since it was sent."
3069 (interactive (list t))
3070 (article-date-ut 'lapsed highlight))
3072 (defun article-update-date-lapsed ()
3073 "Function to be run from a timer to update the lapsed time line."
3074 (let (deactivate-mark)
3079 (set-buffer (window-buffer w))
3080 (when (eq major-mode 'gnus-article-mode)
3081 (goto-char (point-min))
3082 (when (re-search-forward "^X-Sent:" nil t)
3083 (article-date-lapsed t))))
3086 (defun gnus-start-date-timer (&optional n)
3087 "Start a timer to update the X-Sent header in the article buffers.
3088 The numerical prefix says how frequently (in seconds) the function
3093 (gnus-stop-date-timer)
3094 (setq article-lapsed-timer
3095 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
3097 (defun gnus-stop-date-timer ()
3098 "Stop the X-Sent timer."
3100 (when article-lapsed-timer
3101 (nnheader-cancel-timer article-lapsed-timer)
3102 (setq article-lapsed-timer nil)))
3104 (defun article-date-user (&optional highlight)
3105 "Convert the current article date to the user-defined format.
3106 This format is defined by the `gnus-article-time-format' variable."
3107 (interactive (list t))
3108 (article-date-ut 'user highlight))
3110 (defun article-date-iso8601 (&optional highlight)
3111 "Convert the current article date to ISO8601."
3112 (interactive (list t))
3113 (article-date-ut 'iso8601 highlight))
3115 ;; (defun article-show-all ()
3116 ;; "Show all hidden text in the article buffer."
3120 ;; (let ((buffer-read-only nil))
3121 ;; (gnus-article-unhide-text (point-min) (point-max))
3122 ;; (gnus-remove-text-with-property 'gnus-prev)
3123 ;; (gnus-remove-text-with-property 'gnus-next))))
3125 (defun article-show-all-headers ()
3126 "Show all hidden headers in the article buffer."
3131 (article-narrow-to-head)
3132 (let ((buffer-read-only nil))
3133 (gnus-article-unhide-text (point-min) (point-max))))))
3135 (defun article-remove-leading-whitespace ()
3136 "Remove excessive whitespace from all headers."
3140 (let ((buffer-read-only nil))
3141 (article-narrow-to-head)
3142 (goto-char (point-min))
3143 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3144 (delete-region (match-beginning 1) (match-end 1)))))))
3146 (defun article-emphasize (&optional arg)
3147 "Emphasize text according to `gnus-emphasis-alist'."
3148 (interactive (gnus-article-hidden-arg))
3149 (unless (gnus-article-check-hidden-text 'emphasis arg)
3153 (with-current-buffer gnus-summary-buffer
3154 gnus-article-emphasis-alist)
3156 gnus-emphasis-alist))
3157 (buffer-read-only nil)
3158 (props (append '(article-type emphasis)
3159 gnus-hidden-properties))
3160 regexp elem beg invisible visible face)
3163 (while (setq elem (pop alist))
3165 (setq regexp (car elem)
3166 invisible (nth 1 elem)
3167 visible (nth 2 elem)
3169 (while (re-search-forward regexp nil t)
3170 (when (and (match-beginning visible) (match-beginning invisible))
3171 (gnus-article-hide-text
3172 (match-beginning invisible) (match-end invisible) props)
3173 (gnus-article-unhide-text-type
3174 (match-beginning visible) (match-end visible) 'emphasis)
3175 (gnus-put-overlay-excluding-newlines
3176 (match-beginning visible) (match-end visible) 'face face)
3177 (gnus-add-wash-type 'emphasis)
3178 (goto-char (match-end invisible)))))))))
3180 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3181 "Setup newsgroup emphasis alist."
3182 (unless gnus-article-emphasis-alist
3183 (let ((name (and gnus-newsgroup-name
3184 (gnus-group-real-name gnus-newsgroup-name))))
3185 (make-local-variable 'gnus-article-emphasis-alist)
3186 (setq gnus-article-emphasis-alist
3188 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3189 (while (setq elem (pop alist))
3190 (when (and name (string-match (car elem) name))
3192 highlight (copy-sequence (cdr elem)))))
3194 (copy-sequence highlight-words)
3195 (if gnus-newsgroup-name
3196 (copy-sequence (gnus-group-find-parameter
3197 gnus-newsgroup-name 'highlight-words t)))
3198 gnus-emphasis-alist)))))
3201 (defvar gnus-summary-article-menu)
3202 (defvar gnus-summary-post-menu))
3204 ;;; Saving functions.
3206 (defun gnus-article-save (save-buffer file &optional num)
3207 "Save the currently selected article."
3208 (unless gnus-save-all-headers
3209 ;; Remove headers according to `gnus-saved-headers'.
3210 (let ((gnus-visible-headers
3211 (or gnus-saved-headers gnus-visible-headers))
3212 (gnus-article-buffer save-buffer))
3214 (set-buffer save-buffer)
3215 (article-hide-headers 1 t))))
3216 (save-window-excursion
3217 (if (not gnus-default-article-saver)
3218 (error "No default saver is defined")
3219 ;; !!! Magic! The saving functions all save
3220 ;; `gnus-save-article-buffer' (or so they think), but we
3221 ;; bind that variable to our save-buffer.
3222 (set-buffer gnus-article-buffer)
3223 (let* ((gnus-save-article-buffer save-buffer)
3226 ((not gnus-prompt-before-saving) 'default)
3227 ((eq gnus-prompt-before-saving 'always) nil)
3229 (gnus-number-of-articles-to-be-saved
3230 (when (eq gnus-prompt-before-saving t)
3232 (set-buffer gnus-article-current-summary)
3233 (funcall gnus-default-article-saver filename)))))
3235 (defun gnus-read-save-file-name (prompt &optional filename
3236 function group headers variable)
3238 (funcall function group headers (symbol-value variable)))
3243 ((eq filename 'default)
3249 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3252 (if (and gnus-number-of-articles-to-be-saved
3253 (> gnus-number-of-articles-to-be-saved 1))
3254 (format "these %d articles"
3255 gnus-number-of-articles-to-be-saved)
3258 ;; Let the split methods have their say.
3260 ;; No split name was found.
3263 (concat prompt " (default "
3264 (file-name-nondirectory default-name) ") ")
3265 (file-name-directory default-name)
3267 ;; A single group name is returned.
3268 ((stringp split-name)
3270 (funcall function split-name headers
3271 (symbol-value variable)))
3273 (concat prompt " (default "
3274 (file-name-nondirectory default-name) ") ")
3275 (file-name-directory default-name)
3277 ;; A single split name was found
3278 ((= 1 (length split-name))
3279 (let* ((name (expand-file-name
3281 gnus-article-save-directory))
3282 (dir (cond ((file-directory-p name)
3283 (file-name-as-directory name))
3284 ((file-exists-p name) name)
3285 (t gnus-article-save-directory))))
3287 (concat prompt " (default " name ") ")
3289 ;; A list of splits was found.
3291 (setq split-name (nreverse split-name))
3293 (let ((file-name-history
3294 (nconc split-name file-name-history)))
3298 (concat prompt " (`M-p' for defaults) ")
3299 gnus-article-save-directory
3301 gnus-article-save-directory)))
3302 (car (push result file-name-history)))))))
3303 ;; Create the directory.
3304 (gnus-make-directory (file-name-directory file))
3305 ;; If we have read a directory, we append the default file name.
3306 (when (file-directory-p file)
3307 (setq file (expand-file-name (file-name-nondirectory
3309 (file-name-as-directory file))))
3310 ;; Possibly translate some characters.
3311 (nnheader-translate-file-chars file))))))
3312 (gnus-make-directory (file-name-directory result))
3313 (set variable result)))
3315 (defun gnus-article-archive-name (group)
3316 "Return the first instance of an \"Archive-name\" in the current buffer."
3317 (let ((case-fold-search t))
3318 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3319 (nnheader-concat gnus-article-save-directory
3320 (match-string 1)))))
3322 (defun gnus-article-nndoc-name (group)
3323 "If GROUP is an nndoc group, return the name of the parent group."
3324 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3325 (gnus-group-get-parameter group 'save-article-group)))
3327 (defun gnus-summary-save-in-rmail (&optional filename)
3328 "Append this article to Rmail file.
3329 Optional argument FILENAME specifies file name.
3330 Directory to save to is default to `gnus-article-save-directory'."
3331 (setq filename (gnus-read-save-file-name
3332 "Save %s in rmail file:" filename
3333 gnus-rmail-save-name gnus-newsgroup-name
3334 gnus-current-headers 'gnus-newsgroup-last-rmail))
3335 (gnus-eval-in-buffer-window gnus-save-article-buffer
3339 (gnus-output-to-rmail filename))))
3342 (defun gnus-summary-save-in-mail (&optional filename)
3343 "Append this article to Unix mail file.
3344 Optional argument FILENAME specifies file name.
3345 Directory to save to is default to `gnus-article-save-directory'."
3346 (setq filename (gnus-read-save-file-name
3347 "Save %s in Unix mail file:" filename
3348 gnus-mail-save-name gnus-newsgroup-name
3349 gnus-current-headers 'gnus-newsgroup-last-mail))
3350 (gnus-eval-in-buffer-window gnus-save-article-buffer
3354 (if (and (file-readable-p filename)
3355 (file-regular-p filename)
3356 (mail-file-babyl-p filename))
3357 (rmail-output-to-rmail-file filename t)
3358 (gnus-output-to-mail filename)))))
3361 (defun gnus-summary-save-in-file (&optional filename overwrite)
3362 "Append this article to file.
3363 Optional argument FILENAME specifies file name.
3364 Directory to save to is default to `gnus-article-save-directory'."
3365 (setq filename (gnus-read-save-file-name
3366 "Save %s in file:" filename
3367 gnus-file-save-name gnus-newsgroup-name
3368 gnus-current-headers 'gnus-newsgroup-last-file))
3369 (gnus-eval-in-buffer-window gnus-save-article-buffer
3373 (when (and overwrite
3374 (file-exists-p filename))
3375 (delete-file filename))
3376 (gnus-output-to-file filename))))
3379 (defun gnus-summary-write-to-file (&optional filename)
3380 "Write this article to a file, overwriting it if the file exists.
3381 Optional argument FILENAME specifies file name.
3382 The directory to save in defaults to `gnus-article-save-directory'."
3383 (gnus-summary-save-in-file nil t))
3385 (defun gnus-summary-save-body-in-file (&optional filename)
3386 "Append this article body to a file.
3387 Optional argument FILENAME specifies file name.
3388 The directory to save in defaults to `gnus-article-save-directory'."
3389 (setq filename (gnus-read-save-file-name
3390 "Save %s body in file:" filename
3391 gnus-file-save-name gnus-newsgroup-name
3392 gnus-current-headers 'gnus-newsgroup-last-file))
3393 (gnus-eval-in-buffer-window gnus-save-article-buffer
3397 (when (article-goto-body)
3398 (narrow-to-region (point) (point-max)))
3399 (gnus-output-to-file filename))))
3402 (defun gnus-summary-save-in-pipe (&optional command)
3403 "Pipe this article to subprocess."
3405 (cond ((and (eq command 'default)
3406 gnus-last-shell-command)
3407 gnus-last-shell-command)
3412 "Shell command on %s: "
3413 (if (and gnus-number-of-articles-to-be-saved
3414 (> gnus-number-of-articles-to-be-saved 1))
3415 (format "these %d articles"
3416 gnus-number-of-articles-to-be-saved)
3418 gnus-last-shell-command))))
3419 (when (string-equal command "")
3420 (if gnus-last-shell-command
3421 (setq command gnus-last-shell-command)
3422 (error "A command is required")))
3423 (gnus-eval-in-buffer-window gnus-article-buffer
3426 (shell-command-on-region (point-min) (point-max) command nil)))
3427 (setq gnus-last-shell-command command))
3429 (defmacro gnus-read-string (prompt &optional initial-contents history
3431 "Like `read-string' but allow for older XEmacsen that don't have the 5th arg."
3432 (if (and (featurep 'xemacs)
3433 (< emacs-minor-version 2))
3434 `(read-string ,prompt ,initial-contents ,history)
3435 `(read-string ,prompt ,initial-contents ,history ,default-value)))
3437 (defun gnus-summary-pipe-to-muttprint (&optional command)
3438 "Pipe this article to muttprint."
3439 (setq command (gnus-read-string
3440 "Print using command: " gnus-summary-muttprint-program
3441 nil gnus-summary-muttprint-program))
3442 (gnus-summary-save-in-pipe command))
3444 ;;; Article file names when saving.
3446 (defun gnus-capitalize-newsgroup (newsgroup)
3447 "Capitalize NEWSGROUP name."
3448 (when (not (zerop (length newsgroup)))
3449 (concat (char-to-string (upcase (aref newsgroup 0)))
3450 (substring newsgroup 1))))
3452 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3453 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3454 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3455 Otherwise, it is like ~/News/news/group/num."
3458 (concat (if (gnus-use-long-file-name 'not-save)
3459 (gnus-capitalize-newsgroup newsgroup)
3460 (gnus-newsgroup-directory-form newsgroup))
3461 "/" (int-to-string (mail-header-number headers)))
3462 gnus-article-save-directory)))
3464 (string-equal (file-name-directory default)
3465 (file-name-directory last-file))
3466 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3468 (or last-file default))))
3470 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3471 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3472 If variable `gnus-use-long-file-name' is non-nil, it is
3473 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3476 (concat (if (gnus-use-long-file-name 'not-save)
3478 (gnus-newsgroup-directory-form newsgroup))
3479 "/" (int-to-string (mail-header-number headers)))
3480 gnus-article-save-directory)))
3482 (string-equal (file-name-directory default)
3483 (file-name-directory last-file))
3484 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3486 (or last-file default))))
3488 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3489 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3490 If variable `gnus-use-long-file-name' is non-nil, it is
3491 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3494 (if (gnus-use-long-file-name 'not-save)
3497 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3499 gnus-article-save-directory)))
3501 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3502 "Generate file name from sender."
3503 (let ((from (mail-header-from headers)))
3505 (if (and from (string-match "\\([^ <]+\\)@" from))
3506 (match-string 1 from)
3508 gnus-article-save-directory)))
3510 (defun article-verify-x-pgp-sig ()
3513 (if (gnus-buffer-live-p gnus-original-article-buffer)
3514 (let ((sig (with-current-buffer gnus-original-article-buffer
3515 (gnus-fetch-field "X-PGP-Sig")))
3519 (mml2015-clear-verify-function))
3521 (insert-buffer-substring gnus-original-article-buffer)
3522 (setq items (split-string sig))
3523 (message-narrow-to-head)
3524 (let ((inhibit-point-motion-hooks t)
3525 (case-fold-search t))
3526 ;; Don't verify multiple headers.
3527 (setq headers (mapconcat (lambda (header)
3529 (mail-fetch-field header)
3531 (split-string (nth 1 items) ",") "")))
3532 (delete-region (point-min) (point-max))
3533 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3534 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3539 (if (looking-at "^-")
3542 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3543 (insert "Version: " (car items) "\n\n")
3544 (insert (mapconcat 'identity (cddr items) "\n"))
3545 (insert "\n-----END PGP SIGNATURE-----\n")
3546 (let ((mm-security-handle (list (format "multipart/signed"))))
3547 (mml2015-clean-buffer)
3548 (let ((coding-system-for-write (or gnus-newsgroup-charset
3550 (funcall (mml2015-clear-verify-function)))
3552 (or (mm-handle-multipart-ctl-parameter
3553 mm-security-handle 'gnus-details)
3554 (mm-handle-multipart-ctl-parameter
3555 mm-security-handle 'gnus-info)))))
3557 (let (buffer-read-only bface eface)
3559 (message-narrow-to-head)
3560 (goto-char (point-max))
3562 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3563 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3564 (message-remove-header "X-Gnus-PGP-Verify")
3565 (if (re-search-forward "^X-PGP-Sig:" nil t)
3567 (goto-char (point-max)))
3568 (narrow-to-region (point) (point))
3569 (insert "X-Gnus-PGP-Verify: " info "\n")
3570 (goto-char (point-min))
3573 (if (not (looking-at "^[ \t]"))
3577 (goto-char (point-min))
3578 (when (looking-at "\\([^:]+\\): *")
3579 (put-text-property (match-beginning 1) (1+ (match-end 1))
3581 (put-text-property (match-end 0) (point-max)
3582 'face eface)))))))))
3584 (defun article-verify-cancel-lock ()
3585 "Verify Cancel-Lock header."
3587 (if (gnus-buffer-live-p gnus-original-article-buffer)
3588 (canlock-verify gnus-original-article-buffer)))
3590 (defun article-monafy ()
3591 "Display body part with mona font."
3593 (unless (if (featurep 'xemacs)
3594 (find-face 'gnus-mona-face)
3595 (facep 'gnus-mona-face))
3596 (require 'navi2ch-mona)
3597 (set-face-font (make-face 'gnus-mona-face) navi2ch-mona-font))
3599 (let ((buffer-read-only nil))
3602 (gnus-make-overlay (point) (point-max))
3603 'face 'gnus-mona-face))))
3610 (setq afunc (car func)
3613 gfunc (intern (format "gnus-%s" func))))
3615 (when (fboundp afunc)
3616 `(lambda (&optional interactive &rest args)
3617 ,(documentation afunc t)
3618 (interactive (list t))
3620 (set-buffer gnus-article-buffer)
3622 (call-interactively ',afunc)
3623 (apply ',afunc args))))))))
3624 '(article-hide-headers
3625 article-verify-x-pgp-sig
3626 article-verify-cancel-lock
3628 article-hide-boring-headers
3629 article-treat-overstrike
3630 article-fill-long-lines
3631 article-capitalize-sentences
3633 article-remove-leading-whitespace
3634 article-display-x-face
3635 article-display-face
3636 article-de-quoted-unreadable
3637 article-de-base64-unreadable
3640 article-unsplit-urls
3641 article-hide-list-identifiers
3642 article-strip-banner
3645 article-hide-signature
3646 article-strip-headers-in-body
3647 article-remove-trailing-blank-lines
3648 article-strip-leading-blank-lines
3649 article-strip-multiple-blank-lines
3650 article-strip-leading-space
3651 article-strip-trailing-space
3652 article-strip-blank-lines
3653 article-strip-all-blank-lines
3655 article-date-english
3656 article-date-iso8601
3657 article-date-original
3659 article-decode-mime-words
3660 article-decode-charset
3661 article-decode-encoded-words
3665 article-treat-dumbquotes
3666 article-normalize-headers
3667 (article-show-all-headers . gnus-article-show-all-headers)
3668 ;; (article-show-all . gnus-article-show-all)
3672 ;;; Gnus article mode
3675 (put 'gnus-article-mode 'mode-class 'special)
3677 (gnus-define-keys gnus-article-mode-map
3678 " " gnus-article-goto-next-page
3679 "\177" gnus-article-goto-prev-page
3680 [delete] gnus-article-goto-prev-page
3681 [backspace] gnus-article-goto-prev-page
3682 "\C-c^" gnus-article-refer-article
3683 "h" gnus-article-show-summary
3684 "s" gnus-article-show-summary
3685 "\C-c\C-m" gnus-article-mail
3686 "?" gnus-article-describe-briefly
3687 "e" gnus-summary-edit-article
3688 "<" beginning-of-buffer
3690 "\C-c\C-i" gnus-info-find-node
3692 "R" gnus-article-reply-with-original
3693 "F" gnus-article-followup-with-original
3694 "\C-hk" gnus-article-describe-key
3695 "\C-hc" gnus-article-describe-key-briefly
3697 "\C-d" gnus-article-read-summary-keys
3698 "\M-*" gnus-article-read-summary-keys
3699 "\M-#" gnus-article-read-summary-keys
3700 "\M-^" gnus-article-read-summary-keys
3701 "\M-g" gnus-article-read-summary-keys)
3703 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3707 (push (char-to-string key) keys)
3709 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3710 (setq key (car elem))
3711 (when (and (> (length key) 0)
3712 (not (eq 'menu-bar (aref key 0)))
3713 (symbolp (lookup-key gnus-summary-mode-map key)))
3716 (unless (lookup-key gnus-article-mode-map key)
3717 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3719 (defun gnus-article-make-menu-bar ()
3720 (unless (boundp 'gnus-article-commands-menu)
3721 (gnus-summary-make-menu-bar))
3722 (gnus-turn-off-edit-menu 'article)
3723 (unless (boundp 'gnus-article-article-menu)
3725 gnus-article-article-menu gnus-article-mode-map ""
3727 ["Scroll forwards" gnus-article-goto-next-page t]
3728 ["Scroll backwards" gnus-article-goto-prev-page t]
3729 ["Show summary" gnus-article-show-summary t]
3730 ["Fetch Message-ID at point" gnus-article-refer-article t]
3731 ["Mail to address at point" gnus-article-mail t]
3732 ["Send a bug report" gnus-bug t]))
3735 gnus-article-treatment-menu gnus-article-mode-map ""
3736 ;; Fixme: this should use :active (and maybe :visible).
3738 ["Hide headers" gnus-article-hide-headers t]
3739 ["Hide signature" gnus-article-hide-signature t]
3740 ["Hide citation" gnus-article-hide-citation t]
3741 ["Treat overstrike" gnus-article-treat-overstrike t]
3742 ["Remove carriage return" gnus-article-remove-cr t]
3743 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3744 ["Treat html" gnus-article-wash-html t]
3745 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3746 ["Decode HZ" gnus-article-decode-HZ t]))
3748 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3750 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3752 (gnus-run-hooks 'gnus-article-menu-hook)))
3754 (defun gnus-article-mode ()
3755 "Major mode for displaying an article.
3757 All normal editing commands are switched off.
3759 The following commands are available in addition to all summary mode
3761 \\<gnus-article-mode-map>
3762 \\[gnus-article-next-page]\t Scroll the article one page forwards
3763 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3764 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3765 \\[gnus-article-show-summary]\t Display the summary buffer
3766 \\[gnus-article-mail]\t Send a reply to the address near point
3767 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3768 \\[gnus-info-find-node]\t Go to the Gnus info node"
3770 (gnus-simplify-mode-line)
3771 (setq mode-name "Article")
3772 (setq major-mode 'gnus-article-mode)
3773 (make-local-variable 'minor-mode-alist)
3774 (unless (assq 'gnus-show-mime minor-mode-alist)
3775 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3776 (use-local-map gnus-article-mode-map)
3777 (when (gnus-visual-p 'article-menu 'menu)
3778 (gnus-article-make-menu-bar)
3779 (when gnus-summary-tool-bar-map
3780 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3781 (gnus-update-format-specifications nil 'article-mode)
3782 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3783 (make-local-variable 'gnus-page-broken)
3784 (make-local-variable 'gnus-button-marker-list)
3785 (make-local-variable 'gnus-article-current-summary)
3786 (make-local-variable 'gnus-article-mime-handles)
3787 (make-local-variable 'gnus-article-decoded-p)
3788 (make-local-variable 'gnus-article-mime-handle-alist)
3789 (make-local-variable 'gnus-article-wash-types)
3790 (make-local-variable 'gnus-article-image-alist)
3791 (make-local-variable 'gnus-article-charset)
3792 (make-local-variable 'gnus-article-ignored-charsets)
3793 (gnus-set-default-directory)
3794 (buffer-disable-undo)
3795 (setq buffer-read-only t)
3796 (set-syntax-table gnus-article-mode-syntax-table)
3797 (gnus-run-hooks 'gnus-article-mode-hook))
3799 (defun gnus-article-setup-buffer ()
3800 "Initialize the article buffer."
3801 (let* ((name (if gnus-single-article-buffer "*Article*"
3802 (concat "*Article " gnus-newsgroup-name "*")))
3804 (progn (string-match "\\*Article" name)
3805 (concat " *Original Article"
3806 (substring name (match-end 0))))))
3807 (setq gnus-article-buffer name)
3808 (setq gnus-original-article-buffer original)
3809 (setq gnus-article-mime-handle-alist nil)
3810 ;; This might be a variable local to the summary buffer.
3811 (unless gnus-single-article-buffer
3813 (set-buffer gnus-summary-buffer)
3814 (setq gnus-article-buffer name)
3815 (setq gnus-original-article-buffer original)
3816 (gnus-set-global-variables)))
3817 (gnus-article-setup-highlight-words)
3818 ;; Init original article buffer.
3820 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3821 (set-buffer-multibyte t)
3822 (setq major-mode 'gnus-original-article-mode)
3823 (make-local-variable 'gnus-original-article))
3824 (if (get-buffer name)
3827 (when (and gnus-article-edit-mode
3830 (y-or-n-p "Article mode edit in progress; discard? ")))
3831 (error "Action aborted"))
3832 (set (make-local-variable 'gnus-article-edit-mode) nil)
3833 (buffer-disable-undo)
3834 (setq buffer-read-only t)
3835 ;; This list just keeps growing if we don't reset it.
3836 (setq gnus-button-marker-list nil)
3837 (unless (eq major-mode 'gnus-article-mode)
3838 (gnus-article-mode))
3841 (set-buffer (gnus-get-buffer-create name))
3843 (make-local-variable 'gnus-summary-buffer)
3844 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3845 (current-buffer)))))
3847 ;; Set article window start at LINE, where LINE is the number of lines
3848 ;; from the head of the article.
3849 (defun gnus-article-set-window-start (&optional line)
3851 (gnus-get-buffer-window gnus-article-buffer t)
3853 (set-buffer gnus-article-buffer)
3854 (goto-char (point-min))
3857 (gnus-message 6 "Moved to bookmark")
3858 (search-forward "\n\n" nil t)
3862 ;;; @@ article filters
3865 (defun gnus-article-display-mime-message ()
3866 "Article display method for MIME message."
3867 ;; called from `gnus-original-article-buffer'.
3868 (let (charset all-headers)
3869 (with-current-buffer gnus-summary-buffer
3870 (setq charset default-mime-charset
3871 all-headers gnus-have-all-headers))
3872 (make-local-variable 'default-mime-charset)
3873 (setq default-mime-charset charset)
3874 (with-current-buffer (get-buffer-create gnus-article-buffer)
3875 (make-local-variable 'default-mime-charset)
3876 (setq default-mime-charset charset))
3877 (mime-display-message mime-message-structure
3878 gnus-article-buffer nil gnus-article-mode-map)
3880 (gnus-article-hide-headers nil -1)))
3881 (run-hooks 'gnus-mime-article-prepare-hook))
3883 (defun gnus-article-display-traditional-message ()
3884 "Article display method for traditional message."
3885 (set-buffer gnus-article-buffer)
3886 (let (buffer-read-only)
3888 (insert-buffer-substring gnus-original-article-buffer)))
3890 (defun gnus-article-make-full-mail-header (&optional number charset)
3891 "Create a new mail header structure in a raw article buffer."
3892 (unless (and number charset)
3893 (save-current-buffer
3894 (set-buffer gnus-summary-buffer)
3896 (setq number (or (cdr gnus-article-current) 0)))
3898 (setq charset (or default-mime-charset 'x-ctext)))))
3899 (goto-char (point-min))
3900 (let ((header-end (if (search-forward "\n\n" nil t)
3902 (goto-char (point-max))))
3903 (chars (- (point-max) (point)))
3904 (lines (count-lines (point) (point-max)))
3905 (default-mime-charset charset)
3907 (narrow-to-region (point-min) header-end)
3908 (setq xref (std11-fetch-field "xref"))
3910 (make-full-mail-header
3912 (std11-fetch-field "subject")
3913 (std11-fetch-field "from")
3914 (std11-fetch-field "date")
3915 (std11-fetch-field "message-id")
3916 (std11-fetch-field "references")
3919 (when xref (concat "Xref: " xref)))
3922 (defun gnus-article-prepare (article &optional all-headers header)
3923 "Prepare ARTICLE in article mode buffer.
3924 ARTICLE should either be an article number or a Message-ID.
3925 If ARTICLE is an id, HEADER should be the article headers.
3926 If ALL-HEADERS is non-nil, no headers are hidden."
3928 ;; Make sure we start in a summary buffer.
3929 (unless (eq major-mode 'gnus-summary-mode)
3930 (set-buffer gnus-summary-buffer))
3931 (setq gnus-summary-buffer (current-buffer))
3932 (let* ((gnus-article (if header (mail-header-number header) article))
3933 (summary-buffer (current-buffer))
3934 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3935 (group gnus-newsgroup-name)
3938 (gnus-article-setup-buffer)
3939 (set-buffer gnus-article-buffer)
3940 ;; Deactivate active regions.
3941 (when (and (boundp 'transient-mark-mode)
3942 transient-mark-mode)
3943 (setq mark-active nil))
3944 (if (not (setq result (let ((buffer-read-only nil))
3945 (gnus-request-article-this-buffer
3947 ;; There is no such article.
3949 (when (and (numberp article)
3950 (not (memq article gnus-newsgroup-sparse)))
3951 (setq gnus-article-current
3952 (cons gnus-newsgroup-name article))
3953 (set-buffer gnus-summary-buffer)
3954 (setq gnus-current-article article)
3955 (if (and (memq article gnus-newsgroup-undownloaded)
3956 (not (gnus-online (gnus-find-method-for-group
3957 gnus-newsgroup-name))))
3959 (gnus-summary-set-agent-mark article)
3960 (message "Message marked for downloading"))
3961 (gnus-summary-mark-article article gnus-canceled-mark)
3962 (unless (memq article gnus-newsgroup-sparse)
3963 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3964 (if (or (eq result 'pseudo)
3965 (eq result 'nneething))
3968 (set-buffer summary-buffer)
3969 (push article gnus-newsgroup-history)
3970 (setq gnus-last-article gnus-current-article
3971 gnus-current-article 0
3972 gnus-current-headers nil
3973 gnus-article-current nil)
3974 (if (eq result 'nneething)
3975 (gnus-configure-windows 'summary)
3976 (gnus-configure-windows 'article))
3977 (gnus-set-global-variables))
3978 (let ((gnus-article-mime-handle-alist-1
3979 gnus-article-mime-handle-alist))
3980 (gnus-set-mode-line 'article)))
3981 ;; The result from the `request' was an actual article -
3982 ;; or at least some text that is now displayed in the
3984 (when (and (numberp article)
3985 (not (eq article gnus-current-article)))
3986 ;; Seems like a new article has been selected.
3987 ;; `gnus-current-article' must be an article number.
3989 (set-buffer summary-buffer)
3990 (push article gnus-newsgroup-history)
3991 (setq gnus-last-article gnus-current-article
3992 gnus-current-article article
3993 gnus-current-headers
3994 (gnus-summary-article-header gnus-current-article)
3995 gnus-article-current
3996 (cons gnus-newsgroup-name gnus-current-article))
3997 (unless (vectorp gnus-current-headers)
3998 (setq gnus-current-headers nil))
3999 (gnus-summary-goto-subject gnus-current-article)
4000 (when (gnus-summary-show-thread)
4001 ;; If the summary buffer really was folded, the
4002 ;; previous goto may not actually have gone to
4003 ;; the right article, but the thread root instead.
4005 (gnus-summary-goto-subject gnus-current-article))
4006 (gnus-run-hooks 'gnus-mark-article-hook)
4007 (gnus-set-mode-line 'summary)
4008 (when (gnus-visual-p 'article-highlight 'highlight)
4009 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4010 ;; Set the global newsgroup variables here.
4011 (gnus-set-global-variables)
4012 (setq gnus-have-all-headers
4013 (or all-headers gnus-show-all-headers))))
4015 (gnus-configure-windows 'article))
4016 (when (or (numberp article)
4018 (gnus-article-prepare-display)
4020 (goto-char (point-min))
4021 (setq gnus-page-broken
4022 (when gnus-break-pages
4023 (gnus-narrow-to-page)
4025 (let ((gnus-article-mime-handle-alist-1
4026 gnus-article-mime-handle-alist))
4027 (gnus-set-mode-line 'article))
4031 (set-window-point (get-buffer-window (current-buffer)) (point))
4032 (gnus-configure-windows 'article)
4035 (defun gnus-article-prepare-mime-display (&optional number)
4036 (goto-char (point-min))
4037 (when (re-search-forward "^[^\t ]+:" nil t)
4038 (goto-char (match-beginning 0)))
4039 (let ((entity (if (eq 1 (point-min))
4040 (get-text-property 1 'mime-view-entity)
4041 (get-text-property (point) 'mime-view-entity)))
4042 last-entity child-entity next type)
4043 (setq child-entity (mime-entity-children entity))
4045 (setq last-entity (nth (1- (length child-entity))
4047 (setq last-entity entity))
4049 (narrow-to-region (point)
4050 (if (search-forward "\n\n" nil t)
4053 (gnus-treat-article 'head)
4054 (put-text-property (point-min) (point-max) 'article-treated-header t)
4055 (goto-char (point-max)))
4056 (while (and (not (eobp)) entity)
4057 (setq next (set-marker
4059 (next-single-property-change (point) 'mime-view-entity
4061 (let ((types (mime-entity-content-type entity)))
4062 (while (eq 'multipart (mime-content-type-primary-type types))
4063 (setq entity (car (mime-entity-children entity))
4064 types (mime-entity-content-type entity)))
4066 (setq type (format "%s/%s"
4067 (mime-content-type-primary-type types)
4068 (mime-content-type-subtype types)))))
4069 (if (string-equal type "message/rfc822")
4072 (let ((children (mime-entity-children entity))
4075 (setq last-children (nth (1- (length children)) children))
4078 (not (eq last-children
4079 (get-text-property next 'mime-view-entity)))
4081 (next-single-property-change next
4083 nil (point-max)))))))
4084 (setq next (next-single-property-change next 'mime-view-entity
4087 (narrow-to-region (point) next)
4088 (gnus-article-prepare-mime-display)
4089 (goto-char (point-max)))
4090 (setq entity (get-text-property (point) 'mime-view-entity)))
4092 (narrow-to-region (point) next)
4093 ;; Kludge. We have to count true number, but for now,
4094 ;; part number is here only to achieve `last'.
4095 (gnus-treat-article nil 1
4096 (if (eq entity last-entity)
4099 (goto-char (point-max)))
4100 (setq entity (get-text-property next 'mime-view-entity))))))
4103 (defun gnus-article-prepare-display ()
4104 "Make the current buffer look like a nice article."
4105 (let ((gnus-article-buffer (current-buffer))
4107 (unless (eq major-mode 'gnus-article-mode)
4108 (gnus-article-mode))
4109 (setq buffer-read-only nil
4110 gnus-button-marker-list nil
4111 gnus-article-wash-types nil
4112 gnus-article-image-alist nil)
4115 (static-if (featurep 'xemacs)
4116 (map-extents (lambda (extent maparg) (delete-extent extent)))
4117 (let ((lists (overlay-lists)))
4118 (dolist (overlay (nconc (car lists) (cdr lists)))
4119 (delete-overlay overlay)))))
4120 (gnus-run-hooks 'gnus-tmp-internal-hook))
4121 (let ((show-mime (unless (member gnus-newsgroup-name '("nndraft:delayed"
4124 (inhibit-read-only t))
4125 (set-buffer gnus-original-article-buffer)
4127 (setq mime-message-structure gnus-current-headers)
4128 (mime-buffer-entity-set-buffer-internal mime-message-structure
4129 gnus-original-article-buffer)
4130 (mime-entity-set-representation-type-internal mime-message-structure
4131 'mime-buffer-entity)
4132 (luna-send mime-message-structure 'initialize-instance
4133 mime-message-structure)
4135 (let (mime-display-header-hook mime-display-text/plain-hook)
4136 (funcall gnus-article-display-method-for-mime))
4137 (funcall gnus-article-display-method-for-traditional))
4138 ;; Call the treatment functions.
4142 (gnus-article-prepare-mime-display)
4143 (narrow-to-region (goto-char (point-min))
4144 (if (search-forward "\n\n" nil t)
4147 (gnus-treat-article 'head)
4148 (put-text-property (point-min) (point-max) 'article-treated-header t)
4149 (goto-char (point-max))
4151 (narrow-to-region (point) (point-max))
4152 (gnus-treat-article nil))
4153 (put-text-property (point-min) (point-max) 'read-only nil)))
4154 (gnus-run-hooks 'gnus-article-prepare-hook))
4156 (defun gnus-article-decode-article-as-default-mime-charset ()
4157 "Decode an article as `default-mime-charset'. It won't work if the
4158 value of the variable `gnus-show-mime' is non-nil."
4159 (unless (or gnus-show-mime
4160 (member gnus-newsgroup-name '("nndraft:delayed"
4162 (set (make-local-variable 'default-mime-charset)
4163 (with-current-buffer gnus-summary-buffer
4164 default-mime-charset))
4165 (decode-mime-charset-region (point-min) (point-max)
4166 default-mime-charset)))
4169 ;;; Gnus MIME viewing functions
4172 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4173 "Format of the MIME buttons.
4175 Valid specifiers include:
4177 %T MIME type, along with additional info
4178 %n The `name' parameter
4179 %d The description, if any
4180 %l The length of the encoded part
4181 %p The part identifier number
4182 %e Dots if the part isn't displayed
4184 General format specifiers can also be used. See Info node
4185 `(gnus)Formatting Variables'.")
4187 (defvar gnus-mime-button-line-format-alist
4188 '((?t gnus-tmp-type ?s)
4189 (?T gnus-tmp-type-long ?s)
4190 (?n gnus-tmp-name ?s)
4191 (?d gnus-tmp-description ?s)
4193 (?l gnus-tmp-length ?d)
4194 (?e gnus-tmp-dots ?s)))
4196 (defvar gnus-mime-button-commands
4197 '((gnus-article-press-button "\r" "Toggle Display")
4198 (gnus-mime-view-part "v" "View Interactively...")
4199 (gnus-mime-view-part-as-type "t" "View As Type...")
4200 (gnus-mime-view-part-as-charset "C" "View As charset...")
4201 (gnus-mime-save-part "o" "Save...")
4202 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4203 (gnus-mime-delete-part "d" "Delete part")
4204 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4205 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4206 (gnus-mime-view-part-internally "E" "View Internally")
4207 (gnus-mime-view-part-externally "e" "View Externally")
4208 (gnus-mime-print-part "p" "Print")
4209 (gnus-mime-pipe-part "|" "Pipe To Command...")
4210 (gnus-mime-action-on-part "." "Take action on the part...")))
4212 (defun gnus-article-mime-part-status ()
4213 (with-current-buffer gnus-article-buffer
4214 (let ((entity (get-text-property (point-min) 'mime-view-entity))
4217 (setq children (mime-entity-children entity))
4218 (setq children (length children)))
4221 (format " (%d parts)" children))
4224 (defvar gnus-mime-button-map
4225 (let ((map (make-sparse-keymap)))
4226 (unless (>= (string-to-number emacs-version) 21)
4227 ;; XEmacs doesn't care.
4228 (set-keymap-parent map gnus-article-mode-map))
4229 (define-key map gnus-mouse-2 'gnus-article-push-button)
4230 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4231 (dolist (c gnus-mime-button-commands)
4232 (define-key map (cadr c) (car c)))
4236 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4238 ,@(mapcar (lambda (c)
4239 (vector (caddr c) (car c) :enable t))
4240 gnus-mime-button-commands)))
4243 (define-compiler-macro popup-menu (&whole form
4244 menu &optional position prefix)
4245 (if (and (fboundp 'popup-menu)
4246 (not (memq 'popup-menu (assoc "lmenu" load-history))))
4248 ;; Gnus is probably running under Emacs 20.
4249 `(let* ((menu (cdr ,menu))
4250 (response (x-popup-menu
4252 (cons "" (mapcar (lambda (c)
4253 (cons (caddr c) (car c)))
4256 (call-interactively (nth 3 (assq response menu))))))))
4258 (defun gnus-mime-button-menu (event prefix)
4259 "Construct a context-sensitive menu of MIME commands."
4260 (interactive "e\nP")
4261 (save-window-excursion
4262 (let ((pos (event-start event)))
4263 (select-window (posn-window pos))
4264 (goto-char (posn-point pos))
4265 (gnus-article-check-buffer)
4266 (popup-menu gnus-mime-button-menu nil prefix))))
4268 (defun gnus-mime-view-all-parts (&optional handles)
4269 "View all the MIME parts."
4271 (save-current-buffer
4272 (set-buffer gnus-article-buffer)
4273 (let ((handles (or handles gnus-article-mime-handles))
4274 (mail-parse-charset gnus-newsgroup-charset)
4275 (mail-parse-ignored-charsets
4276 (with-current-buffer gnus-summary-buffer
4277 gnus-newsgroup-ignored-charsets)))
4279 (mm-remove-parts handles)
4280 (goto-char (point-min))
4281 (or (search-forward "\n\n") (goto-char (point-max)))
4282 (let (buffer-read-only)
4283 (delete-region (point) (point-max))
4284 (mm-display-parts handles))))))
4286 (defun gnus-mime-save-part-and-strip ()
4287 "Save the MIME part under point then replace it with an external body."
4289 (gnus-article-check-buffer)
4290 (let* ((data (get-text-property (point) 'gnus-data))
4292 (handles gnus-article-mime-handles))
4293 (if (mm-multiple-handles gnus-article-mime-handles)
4294 (error "This function is not implemented"))
4295 (setq file (and data (mm-save-part data)))
4297 (with-current-buffer (mm-handle-buffer data)
4299 (insert "Content-Type: " (mm-handle-media-type data))
4300 (mml-insert-parameter-string (cdr (mm-handle-type data))
4303 (insert "Content-ID: " (message-make-message-id) "\n")
4304 (insert "Content-Transfer-Encoding: binary\n")
4307 (cdr (mm-make-handle nil
4308 `("message/external-body"
4309 (access-type . "LOCAL-FILE")
4311 (set-buffer gnus-summary-buffer)
4312 (gnus-article-edit-article
4315 (let ((mail-parse-charset (or gnus-article-charset
4316 ',gnus-newsgroup-charset))
4317 (mail-parse-ignored-charsets
4318 (or gnus-article-ignored-charsets
4319 ',gnus-newsgroup-ignored-charsets))
4320 (mbl mml-buffer-list))
4321 (setq mml-buffer-list nil)
4322 (insert-buffer gnus-original-article-buffer)
4323 (mime-to-mml ',handles)
4324 (setq gnus-article-mime-handles nil)
4325 (let ((mbl1 mml-buffer-list))
4326 (setq mml-buffer-list mbl)
4327 (set (make-local-variable 'mml-buffer-list) mbl1))
4328 (gnus-make-local-hook 'kill-buffer-hook)
4329 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4330 `(lambda (no-highlight)
4331 (let ((mail-parse-charset (or gnus-article-charset
4332 ',gnus-newsgroup-charset))
4333 (message-options message-options)
4334 (message-options-set-recipient)
4335 (mail-parse-ignored-charsets
4336 (or gnus-article-ignored-charsets
4337 ',gnus-newsgroup-ignored-charsets)))
4339 (mml-destroy-buffers)
4340 (remove-hook 'kill-buffer-hook
4341 'mml-destroy-buffers t)
4342 (kill-local-variable 'mml-buffer-list))
4343 (gnus-summary-edit-article-done
4344 ,(or (mail-header-references gnus-current-headers) "")
4345 ,(gnus-group-read-only-p)
4346 ,gnus-summary-buffer no-highlight))))))
4348 (defun gnus-mime-delete-part ()
4349 "Delete the MIME part under point.
4350 Replace it with some information about the removed part."
4352 (gnus-article-check-buffer)
4353 (unless (and gnus-novice-user
4354 (not (gnus-yes-or-no-p
4355 "Really delete attachment forever? ")))
4356 (let* ((data (get-text-property (point) 'gnus-data))
4357 (handles gnus-article-mime-handles)
4361 (mail-decode-encoded-word-string (or (mm-handle-description data)
4364 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4366 (type (mm-handle-media-type data)))
4367 (if (mm-multiple-handles gnus-article-mime-handles)
4368 (error "This function is not implemented"))
4369 (with-current-buffer (mm-handle-buffer data)
4370 (let ((bsize (format "%s" (buffer-size))))
4374 "<#part type=text/plain nofile=yes disposition=attachment"
4375 " description=\"Deleted attachment (" bsize " Byte)\">"
4377 "| The following attachment has been deleted:\n"
4379 "| Type: " type "\n"
4380 "| Filename: " filename "\n"
4381 "| Size (encoded): " bsize " Byte\n"
4382 "| Description: " description "\n"
4386 (cdr (mm-make-handle nil `("text/plain"))))))
4387 (set-buffer gnus-summary-buffer)
4388 ;; FIXME: maybe some of the following code (borrowed from
4389 ;; `gnus-mime-save-part-and-strip') isn't necessary?
4390 (gnus-article-edit-article
4393 (let ((mail-parse-charset (or gnus-article-charset
4394 ',gnus-newsgroup-charset))
4395 (mail-parse-ignored-charsets
4396 (or gnus-article-ignored-charsets
4397 ',gnus-newsgroup-ignored-charsets))
4398 (mbl mml-buffer-list))
4399 (setq mml-buffer-list nil)
4400 (insert-buffer gnus-original-article-buffer)
4401 (mime-to-mml ',handles)
4402 (setq gnus-article-mime-handles nil)
4403 (let ((mbl1 mml-buffer-list))
4404 (setq mml-buffer-list mbl)
4405 (set (make-local-variable 'mml-buffer-list) mbl1))
4406 (gnus-make-local-hook 'kill-buffer-hook)
4407 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4408 `(lambda (no-highlight)
4409 (let ((mail-parse-charset (or gnus-article-charset
4410 ',gnus-newsgroup-charset))
4411 (message-options message-options)
4412 (message-options-set-recipient)
4413 (mail-parse-ignored-charsets
4414 (or gnus-article-ignored-charsets
4415 ',gnus-newsgroup-ignored-charsets)))
4417 (mml-destroy-buffers)
4418 (remove-hook 'kill-buffer-hook
4419 'mml-destroy-buffers t)
4420 (kill-local-variable 'mml-buffer-list))
4421 (gnus-summary-edit-article-done
4422 ,(or (mail-header-references gnus-current-headers) "")
4423 ,(gnus-group-read-only-p)
4424 ,gnus-summary-buffer no-highlight)))))
4425 ;; Not in `gnus-mime-save-part-and-strip':
4426 (gnus-article-edit-done)
4427 (gnus-summary-expand-window)
4428 (gnus-summary-show-article))
4430 (defun gnus-mime-save-part ()
4431 "Save the MIME part under point."
4433 (gnus-article-check-buffer)
4434 (let ((data (get-text-property (point) 'gnus-data)))
4436 (mm-save-part data))))
4438 (defun gnus-mime-pipe-part ()
4439 "Pipe the MIME part under point to a process."
4441 (gnus-article-check-buffer)
4442 (let ((data (get-text-property (point) 'gnus-data)))
4444 (mm-pipe-part data))))
4446 (defun gnus-mime-view-part ()
4447 "Interactively choose a viewing method for the MIME part under point."
4449 (gnus-article-check-buffer)
4450 (let ((data (get-text-property (point) 'gnus-data)))
4452 (setq gnus-article-mime-handles
4454 gnus-article-mime-handles (setq data (copy-sequence data))))
4455 (mm-interactively-view-part data))))
4457 (defun gnus-mime-view-part-as-type-internal ()
4458 (gnus-article-check-buffer)
4459 (let* ((name (mail-content-type-get
4460 (mm-handle-type (get-text-property (point) 'gnus-data))
4462 (def-type (and name (mm-default-file-encoding name))))
4463 (and def-type (cons def-type 0))))
4465 (defun gnus-mime-view-part-as-type (&optional mime-type)
4466 "Choose a MIME media type, and view the part as such."
4469 (setq mime-type (completing-read
4470 "View as MIME type: "
4471 (mapcar #'list (mailcap-mime-types))
4473 (gnus-mime-view-part-as-type-internal))))
4474 (gnus-article-check-buffer)
4475 (let ((handle (get-text-property (point) 'gnus-data)))
4478 (mm-make-handle (mm-handle-buffer handle)
4479 (cons mime-type (cdr (mm-handle-type handle)))
4480 (mm-handle-encoding handle)
4481 (mm-handle-undisplayer handle)
4482 (mm-handle-disposition handle)
4483 (mm-handle-description handle)
4485 (mm-handle-id handle)))
4486 (setq gnus-article-mime-handles
4487 (mm-merge-handles gnus-article-mime-handles handle))
4488 (gnus-mm-display-part handle))))
4491 (require 'jka-compr))
4493 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4494 ;; emacs can do that itself.
4496 (defun gnus-mime-jka-compr-maybe-uncompress ()
4497 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4498 The uncompress method used is derived from `buffer-file-name'."
4499 (when (and (fboundp 'jka-compr-installed-p)
4500 (jka-compr-installed-p))
4501 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4503 (let ((basename (file-name-nondirectory buffer-file-name))
4504 (args (jka-compr-info-uncompress-args info))
4505 (prog (jka-compr-info-uncompress-program info))
4506 (message (jka-compr-info-uncompress-message info))
4507 (err-file (jka-compr-make-temp-name)))
4509 (message "%s %s..." message basename))
4511 (unless (memq (apply 'call-process-region
4512 (point-min) (point-max)
4514 t (list t err-file) nil
4516 jka-compr-acceptable-retval-list)
4517 (jka-compr-error prog args basename message err-file))
4518 (jka-compr-delete-temp-file err-file)))))))
4520 (defun gnus-mime-copy-part (&optional handle)
4521 "Put the MIME part under point into a new buffer.
4522 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4525 (gnus-article-check-buffer)
4526 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4527 (contents (and handle (mm-get-part handle)))
4529 (file-name-nondirectory
4531 (mail-content-type-get (mm-handle-type handle) 'name)
4532 (mail-content-type-get (mm-handle-disposition handle)
4535 (buffer (and base (generate-new-buffer base))))
4537 (switch-to-buffer buffer)
4539 ;; We do it this way to make `normal-mode' set the appropriate mode.
4542 (setq buffer-file-name (expand-file-name base))
4543 (gnus-mime-jka-compr-maybe-uncompress)
4545 (setq buffer-file-name nil))
4546 (goto-char (point-min)))))
4548 (defun gnus-mime-print-part (&optional handle filename)
4549 "Print the MIME part under point."
4550 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4551 (gnus-article-check-buffer)
4552 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4553 (contents (and handle (mm-get-part handle)))
4554 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4555 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4560 (mm-save-part-to-file handle file)
4561 (call-process shell-file-name nil
4562 (generate-new-buffer " *mm*")
4564 shell-command-switch
4566 printer file (mm-handle-type handle))))
4570 (gnus-print-buffer))
4571 (ps-despool filename)))))
4573 (defun gnus-mime-inline-part (&optional handle arg)
4574 "Insert the MIME part under point into the current buffer."
4575 (interactive (list nil current-prefix-arg))
4576 (gnus-article-check-buffer)
4577 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4582 (if (and (not arg) (mm-handle-undisplayer handle))
4583 (mm-remove-part handle)
4584 (setq contents (mm-get-part handle))
4587 (setq charset (or (mail-content-type-get
4588 (mm-handle-type handle) 'charset)
4589 gnus-newsgroup-charset)))
4591 (if (mm-handle-undisplayer handle)
4592 (mm-remove-part handle))
4595 gnus-summary-show-article-charset-alist))
4596 (mm-read-coding-system "Charset: ")))))
4598 (mm-insert-inline handle
4600 (setq charset (mm-charset-to-coding-system
4602 (not (eq charset 'ascii)))
4603 (mm-decode-coding-string contents charset)
4607 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4608 "Insert the MIME part under point into the current buffer using the
4610 (interactive (list nil current-prefix-arg))
4611 (gnus-article-check-buffer)
4612 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4617 (if (mm-handle-undisplayer handle)
4618 (mm-remove-part handle))
4619 (let ((gnus-newsgroup-charset
4621 gnus-summary-show-article-charset-alist))
4622 (mm-read-coding-system "Charset: ")))
4623 (gnus-newsgroup-ignored-charsets 'gnus-all))
4624 (gnus-article-press-button)))))
4626 (defun gnus-mime-view-part-externally (&optional handle)
4627 "View the MIME part under point with an external viewer."
4629 (gnus-article-check-buffer)
4630 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4631 (mm-user-display-methods nil)
4632 (mm-inlined-types nil)
4633 (mail-parse-charset gnus-newsgroup-charset)
4634 (mail-parse-ignored-charsets
4635 (save-excursion (set-buffer gnus-summary-buffer)
4636 gnus-newsgroup-ignored-charsets)))
4638 (if (mm-handle-undisplayer handle)
4639 (mm-remove-part handle)
4640 (mm-display-part handle)))))
4642 (defun gnus-mime-view-part-internally (&optional handle)
4643 "View the MIME part under point with an internal viewer.
4644 If no internal viewer is available, use an external viewer."
4646 (gnus-article-check-buffer)
4647 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4648 (mm-inlined-types '(".*"))
4649 (mm-inline-large-images t)
4650 (mail-parse-charset gnus-newsgroup-charset)
4651 (mail-parse-ignored-charsets
4652 (save-excursion (set-buffer gnus-summary-buffer)
4653 gnus-newsgroup-ignored-charsets))
4656 (if (mm-handle-undisplayer handle)
4657 (mm-remove-part handle)
4658 (mm-display-part handle)))))
4660 (defun gnus-mime-action-on-part (&optional action)
4661 "Do something with the MIME attachment at \(point\)."
4663 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4664 (gnus-article-check-buffer)
4665 (let ((action-pair (assoc action gnus-mime-action-alist)))
4667 (funcall (cdr action-pair)))))
4669 (defun gnus-article-part-wrapper (n function)
4670 (save-current-buffer
4671 (set-buffer gnus-article-buffer)
4672 (when (> n (length gnus-article-mime-handle-alist))
4673 (error "No such part"))
4674 (gnus-article-goto-part n)
4675 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4676 (funcall function handle))))
4678 (defun gnus-article-pipe-part (n)
4679 "Pipe MIME part N, which is the numerical prefix."
4681 (gnus-article-part-wrapper n 'mm-pipe-part))
4683 (defun gnus-article-save-part (n)
4684 "Save MIME part N, which is the numerical prefix."
4686 (gnus-article-part-wrapper n 'mm-save-part))
4688 (defun gnus-article-interactively-view-part (n)
4689 "View MIME part N interactively, which is the numerical prefix."
4691 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4693 (defun gnus-article-copy-part (n)
4694 "Copy MIME part N, which is the numerical prefix."
4696 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4698 (defun gnus-article-view-part-as-charset (n)
4699 "Copy MIME part N, which is the numerical prefix."
4701 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4703 (defun gnus-article-view-part-externally (n)
4704 "View MIME part N externally, which is the numerical prefix."
4706 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4708 (defun gnus-article-inline-part (n)
4709 "Inline MIME part N, which is the numerical prefix."
4711 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4713 (defun gnus-article-mime-match-handle-first (condition)
4715 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4716 (while (setq ihandle (pop alist))
4718 ((functionp condition)
4719 (funcall condition (cdr ihandle)))
4720 ((eq condition 'undisplayed)
4721 (not (or (mm-handle-undisplayer (cdr ihandle))
4722 (equal (mm-handle-media-type (cdr ihandle))
4723 "multipart/alternative"))))
4724 ((eq condition 'undisplayed-alternative)
4725 (not (mm-handle-undisplayer (cdr ihandle))))
4727 (gnus-article-goto-part (car ihandle))
4728 (or (not n) (< (car ihandle) n)))
4729 (setq n (car ihandle))))
4733 (defun gnus-article-view-part (&optional n)
4734 "View MIME part N, which is the numerical prefix."
4736 (save-current-buffer
4737 (set-buffer gnus-article-buffer)
4738 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4739 gnus-article-mime-match-handle-function)))
4740 (when (> n (length gnus-article-mime-handle-alist))
4741 (error "No such part"))
4742 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4743 (when (gnus-article-goto-part n)
4744 (if (equal (car handle) "multipart/alternative")
4745 (gnus-article-press-button)
4746 (when (eq (gnus-mm-display-part handle) 'internal)
4747 (gnus-set-window-start)))))))
4749 (defsubst gnus-article-mime-total-parts ()
4750 (if (bufferp (car gnus-article-mime-handles))
4752 (1- (length gnus-article-mime-handles))))
4754 (defun gnus-mm-display-part (handle)
4755 "Display HANDLE and fix MIME button."
4756 (let ((id (get-text-property (point) 'gnus-part))
4761 (let ((window (selected-window))
4762 (mail-parse-charset gnus-newsgroup-charset)
4763 (mail-parse-ignored-charsets
4764 (if (gnus-buffer-live-p gnus-summary-buffer)
4766 (set-buffer gnus-summary-buffer)
4767 gnus-newsgroup-ignored-charsets)
4771 (let ((win (gnus-get-buffer-window (current-buffer) t))
4774 (select-window win))
4777 (if (mm-handle-displayed-p handle)
4778 ;; This will remove the part.
4779 (mm-display-part handle)
4781 (narrow-to-region (point)
4782 (if (eobp) (point) (1+ (point))))
4783 (mm-display-part handle)
4784 ;; We narrow to the part itself and
4785 ;; then call the treatment functions.
4786 (goto-char (point-min))
4788 (narrow-to-region (point) (point-max))
4791 (gnus-article-mime-total-parts)
4792 (mm-handle-media-type handle)))))
4793 (if (window-live-p window)
4794 (select-window window)))))
4797 (gnus-insert-mime-button
4798 handle id (list (mm-handle-displayed-p handle)))
4799 (goto-char point))))
4801 (defun gnus-article-goto-part (n)
4802 "Go to MIME part N."
4803 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4805 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4806 (let ((gnus-tmp-name
4807 (or (mail-content-type-get (mm-handle-type handle) 'name)
4808 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4809 (mail-content-type-get (mm-handle-type handle) 'url)
4811 (gnus-tmp-type (mm-handle-media-type handle))
4812 (gnus-tmp-description
4813 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4816 (if (if displayed (car displayed)
4817 (mm-handle-displayed-p handle))
4819 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4821 gnus-tmp-type-long b e)
4822 (when (string-match ".*/" gnus-tmp-name)
4823 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4824 (setq gnus-tmp-type-long (concat gnus-tmp-type
4825 (and (not (equal gnus-tmp-name ""))
4826 (concat "; " gnus-tmp-name))))
4827 (unless (equal gnus-tmp-description "")
4828 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4833 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4834 `(,@(gnus-local-map-property gnus-mime-button-map)
4835 gnus-callback gnus-mm-display-part
4836 gnus-part ,gnus-tmp-id
4837 article-type annotation
4840 ;; Exclude a newline.
4843 (widget-convert-button
4846 :action 'gnus-widget-press-button
4847 :button-keymap gnus-mime-button-map
4849 (lambda (widget/window &optional overlay pos)
4850 ;; Needed to properly clear the message due to a bug in
4851 ;; wid-edit (XEmacs only).
4852 (if (boundp 'help-echo-owns-message)
4853 (setq help-echo-owns-message t))
4855 "%S: %s the MIME part; %S: more options"
4856 (aref gnus-mouse-2 0)
4857 ;; XEmacs will get a single widget arg; Emacs 21 will get
4858 ;; window, overlay, position.
4859 (if (mm-handle-displayed-p
4861 (with-current-buffer (gnus-overlay-buffer overlay)
4862 (widget-get (widget-at (gnus-overlay-start overlay))
4864 (widget-get widget/window :mime-handle)))
4866 (aref gnus-down-mouse-3 0))))))
4868 (defun gnus-widget-press-button (elems el)
4869 (goto-char (widget-get elems :from))
4870 (gnus-article-press-button))
4872 (defvar gnus-displaying-mime nil)
4874 (defun gnus-display-mime (&optional ihandles)
4875 "Display the MIME parts."
4877 (save-selected-window
4878 (let ((window (get-buffer-window gnus-article-buffer))
4881 (select-window window)
4882 ;; We have to do this since selecting the window
4883 ;; may change the point. So we set the window point.
4884 (set-window-point window point)))
4885 (let* ((handles (or ihandles
4886 (mm-dissect-buffer nil gnus-article-loose-mime)
4887 (and gnus-article-emulate-mime
4889 buffer-read-only handle name type b e display)
4890 (when (and (not ihandles)
4891 (not gnus-displaying-mime))
4892 ;; Top-level call; we clean up.
4893 (when gnus-article-mime-handles
4894 (mm-destroy-parts gnus-article-mime-handles)
4895 (setq gnus-article-mime-handle-alist nil));; A trick.
4896 (setq gnus-article-mime-handles handles)
4897 ;; We allow users to glean info from the handles.
4898 (when gnus-article-mime-part-function
4899 (gnus-mime-part-function handles)))
4901 (or (not (stringp (car handles)))
4904 (when (and (not ihandles)
4905 (not gnus-displaying-mime))
4906 ;; Clean up for mime parts.
4908 (delete-region (point) (point-max)))
4909 (let ((gnus-displaying-mime t))
4910 (gnus-mime-display-part handles)))
4913 (narrow-to-region (point) (point-max))
4914 (gnus-treat-article nil 1 1)
4917 ;; Highlight the headers.
4921 (narrow-to-region (point-min) (point))
4922 (gnus-treat-article 'head))))))))
4924 (defcustom gnus-mime-display-multipart-as-mixed nil
4925 "Display \"multipart\" parts as \"multipart/mixed\".
4927 If t, it overrides nil values of
4928 `gnus-mime-display-multipart-alternative-as-mixed' and
4929 `gnus-mime-display-multipart-related-as-mixed'."
4930 :group 'gnus-article-mime
4933 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4934 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4935 :group 'gnus-article-mime
4938 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4939 "Display \"multipart/related\" parts as \"multipart/mixed\".
4941 If displaying \"text/html\" is discouraged \(see
4942 `mm-discouraged-alternatives'\) images or other material inside a
4943 \"multipart/related\" part might be overlooked when this variable is nil."
4944 :group 'gnus-article-mime
4947 (defun gnus-mime-display-part (handle)
4950 ((not (stringp (car handle)))
4951 (gnus-mime-display-single handle))
4952 ;; User-defined multipart
4953 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4954 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4956 ;; multipart/alternative
4957 ((and (equal (car handle) "multipart/alternative")
4958 (not (or gnus-mime-display-multipart-as-mixed
4959 gnus-mime-display-multipart-alternative-as-mixed)))
4960 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4961 (push (cons id handle) gnus-article-mime-handle-alist)
4962 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4963 ;; multipart/related
4964 ((and (equal (car handle) "multipart/related")
4965 (not (or gnus-mime-display-multipart-as-mixed
4966 gnus-mime-display-multipart-related-as-mixed)))
4967 ;;;!!!We should find the start part, but we just default
4968 ;;;!!!to the first part.
4969 ;;(gnus-mime-display-part (cadr handle))
4970 ;;;!!! Most multipart/related is an HTML message plus images.
4971 ;;;!!! Unfortunately we are unable to let W3 display those
4972 ;;;!!! included images, so we just display it as a mixed multipart.
4973 ;;(gnus-mime-display-mixed (cdr handle))
4974 ;;;!!! No, w3 can display everything just fine.
4975 (gnus-mime-display-part (cadr handle)))
4976 ((equal (car handle) "multipart/signed")
4977 (gnus-add-wash-type 'signed)
4978 (gnus-mime-display-security handle))
4979 ((equal (car handle) "multipart/encrypted")
4980 (gnus-add-wash-type 'encrypted)
4981 (gnus-mime-display-security handle))
4982 ;; Other multiparts are handled like multipart/mixed.
4984 (gnus-mime-display-mixed (cdr handle)))))
4986 (defun gnus-mime-part-function (handles)
4987 (if (stringp (car handles))
4988 (mapcar 'gnus-mime-part-function (cdr handles))
4989 (funcall gnus-article-mime-part-function handles)))
4991 (defun gnus-mime-display-mixed (handles)
4992 (mapcar 'gnus-mime-display-part handles))
4994 (defun gnus-mime-display-single (handle)
4995 (let ((type (mm-handle-media-type handle))
4996 (ignored gnus-ignored-mime-types)
5003 (when (string-match (pop ignored) type)
5004 (throw 'ignored nil)))
5005 (if (and (setq not-attachment
5006 (and (not (mm-inline-override-p handle))
5007 (or (not (mm-handle-disposition handle))
5008 (equal (car (mm-handle-disposition handle))
5010 (mm-attachment-override-p handle))))
5011 (mm-automatic-display-p handle)
5013 (mm-inlinable-p handle)
5014 (mm-inlined-p handle))
5015 (mm-automatic-external-display-p type)))
5017 (when (equal (mm-handle-media-supertype handle) "text")
5019 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5021 (push (cons id handle) gnus-article-mime-handle-alist)
5022 (when (or (not display)
5023 (not (gnus-unbuttonized-mime-type-p type)))
5024 ;(gnus-article-insert-newline)
5025 (gnus-insert-mime-button
5026 handle id (list (or display (and not-attachment text))))
5027 (gnus-article-insert-newline)
5028 ;(gnus-article-insert-newline)
5029 ;; Remember modify the number of forward lines.
5037 (let ((mail-parse-charset gnus-newsgroup-charset)
5038 (mail-parse-ignored-charsets
5039 (save-excursion (condition-case ()
5040 (set-buffer gnus-summary-buffer)
5042 gnus-newsgroup-ignored-charsets)))
5043 (mm-display-part handle t))
5044 (goto-char (point-max)))
5045 ((and text not-attachment)
5049 (gnus-article-insert-newline)
5050 (mm-insert-inline handle (mm-get-part handle))
5051 (goto-char (point-max))))
5055 (narrow-to-region beg (point))
5058 (gnus-article-mime-total-parts)
5059 (mm-handle-media-type handle)))))))))
5061 (defun gnus-unbuttonized-mime-type-p (type)
5062 "Say whether TYPE is to be unbuttonized."
5063 (unless gnus-inhibit-mime-unbuttonizing
5065 (let ((types gnus-unbuttonized-mime-types))
5067 (when (string-match (pop types) type)
5068 (throw 'found t)))))
5070 (let ((types gnus-buttonized-mime-types))
5072 (when (string-match (pop types) type)
5073 (throw 'found t)))))))))
5075 (defun gnus-article-insert-newline ()
5076 "Insert a newline, but mark it as undeletable."
5077 (gnus-put-text-property
5078 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5080 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5081 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5084 handle buffer-read-only from props begend not-pref)
5085 (save-window-excursion
5088 (narrow-to-region (car ibegend)
5091 (goto-char (car ibegend))
5094 (delete-region (point-min) (point-max))
5095 (mm-remove-parts handles))
5096 (setq begend (list (point-marker)))
5098 (unless (setq not-pref (cadr (member preferred ihandles)))
5099 (setq not-pref (car ihandles)))
5102 (not (gnus-unbuttonized-mime-type-p
5103 "multipart/alternative")))
5104 (gnus-add-text-properties
5107 (insert (format "%d. " id))
5111 (unless ,(not ibegend)
5112 (setq gnus-article-mime-handle-alist
5113 ',gnus-article-mime-handle-alist))
5114 (gnus-mime-display-alternative
5115 ',ihandles ',not-pref ',begend ,id))
5116 ,@(gnus-local-map-property gnus-mime-button-map)
5117 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5118 face ,gnus-article-button-face
5121 (widget-convert-button 'link from (point)
5122 :action 'gnus-widget-press-button
5123 :button-keymap gnus-widget-button-keymap)
5125 (while (setq handle (pop handles))
5126 (gnus-add-text-properties
5129 (insert (format "(%c) %-18s"
5130 (if (equal handle preferred) ?* ? )
5131 (mm-handle-media-type handle)))
5135 (unless ,(not ibegend)
5136 (setq gnus-article-mime-handle-alist
5137 ',gnus-article-mime-handle-alist))
5138 (gnus-mime-display-alternative
5139 ',ihandles ',handle ',begend ,id))
5140 ,@(gnus-local-map-property gnus-mime-button-map)
5141 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5142 face ,gnus-article-button-face
5145 (widget-convert-button 'link from (point)
5146 :action 'gnus-widget-press-button
5147 :button-keymap gnus-widget-button-keymap)
5151 (if (stringp (car preferred))
5152 (gnus-display-mime preferred)
5153 (let ((mail-parse-charset gnus-newsgroup-charset)
5154 (mail-parse-ignored-charsets
5155 (save-excursion (set-buffer gnus-summary-buffer)
5156 gnus-newsgroup-ignored-charsets)))
5157 (mm-display-part preferred)
5161 (narrow-to-region (car begend) (point-max))
5163 nil (length gnus-article-mime-handle-alist)
5164 (gnus-article-mime-total-parts)
5165 (mm-handle-media-type handle))))))
5166 (goto-char (point-max))
5167 (setcdr begend (point-marker)))))
5169 (goto-char point))))
5171 (defconst gnus-article-wash-status-strings
5172 (let ((alist '((cite "c" "Possible hidden citation text"
5173 " " "All citation text visible")
5174 (headers "h" "Hidden headers"
5175 " " "All headers visible.")
5176 (pgp "p" "Encrypted or signed message status hidden"
5177 " " "No hidden encryption nor digital signature status")
5178 (signature "s" "Signature has been hidden"
5179 " " "Signature is visible")
5180 (overstrike "o" "Overstrike (^H) characters applied"
5181 " " "No overstrike characters applied")
5182 (gnus-show-mime "m" "Mime processing is activated"
5183 " " "Mime processing is not activated")
5184 (emphasis "e" "/*_Emphasis_*/ characters applied"
5185 " " "No /*_emphasis_*/ characters applied")))
5187 (dolist (entry alist result)
5188 (let ((key (nth 0 entry))
5189 (on (copy-sequence (nth 1 entry)))
5190 (on-help (nth 2 entry))
5191 (off (copy-sequence (nth 3 entry)))
5192 (off-help (nth 4 entry)))
5193 (put-text-property 0 1 'help-echo on-help on)
5194 (put-text-property 0 1 'help-echo off-help off)
5195 (push (list key on off) result))))
5196 "Alist of strings describing wash status in the mode line.
5197 Each entry has the form (KEY ON OF), where the KEY is a symbol
5198 representing the particular washing function, ON is the string to use
5199 in the article mode line when the washing function is active, and OFF
5200 is the string to use when it is inactive.")
5202 (defun gnus-article-wash-status-entry (key value)
5203 (let ((entry (assoc key gnus-article-wash-status-strings)))
5204 (if value (nth 1 entry) (nth 2 entry))))
5206 (defun gnus-article-wash-status ()
5207 "Return a string which display status of article washing."
5209 (set-buffer gnus-article-buffer)
5210 (let ((cite (memq 'cite gnus-article-wash-types))
5211 (headers (memq 'headers gnus-article-wash-types))
5212 (boring (memq 'boring-headers gnus-article-wash-types))
5213 (pgp (memq 'pgp gnus-article-wash-types))
5214 (pem (memq 'pem gnus-article-wash-types))
5215 (signed (memq 'signed gnus-article-wash-types))
5216 (encrypted (memq 'encrypted gnus-article-wash-types))
5217 (signature (memq 'signature gnus-article-wash-types))
5218 (overstrike (memq 'overstrike gnus-article-wash-types))
5219 (emphasis (memq 'emphasis gnus-article-wash-types)))
5221 (gnus-article-wash-status-entry 'cite cite)
5222 (gnus-article-wash-status-entry 'headers (or headers boring))
5223 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5224 (gnus-article-wash-status-entry 'signature signature)
5225 (gnus-article-wash-status-entry 'overstrike overstrike)
5226 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
5227 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5229 (defun gnus-add-wash-type (type)
5230 "Add a washing of TYPE to the current status."
5231 (add-to-list 'gnus-article-wash-types type))
5233 (defun gnus-delete-wash-type (type)
5234 "Add a washing of TYPE to the current status."
5235 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5237 (defun gnus-add-image (category image)
5238 "Add IMAGE of CATEGORY to the list of displayed images."
5239 (let ((entry (assq category gnus-article-image-alist)))
5241 (setq entry (list category))
5242 (push entry gnus-article-image-alist))
5243 (nconc entry (list image))))
5245 (defun gnus-delete-images (category)
5246 "Delete all images in CATEGORY."
5247 (let ((entry (assq category gnus-article-image-alist)))
5248 (dolist (image (cdr entry))
5249 (gnus-remove-image image category))
5250 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5251 (gnus-delete-wash-type category)))
5253 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5255 (defun gnus-article-maybe-hide-headers ()
5256 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5257 Provided for backwards compatibility."
5258 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5259 (not (save-excursion (set-buffer gnus-summary-buffer)
5260 gnus-have-all-headers)))
5261 (not gnus-inhibit-hiding))
5262 (gnus-article-hide-headers)))
5266 (defun gnus-output-to-file (file-name)
5267 "Append the current article to a file named FILE-NAME."
5268 (let ((artbuf (current-buffer)))
5270 (insert-buffer-substring artbuf)
5271 ;; Append newline at end of the buffer as separator, and then
5273 (goto-char (point-max))
5275 (let ((file-name-coding-system nnmail-pathname-coding-system)
5276 (pathname-coding-system nnmail-pathname-coding-system))
5277 (write-region-as-binary (point-min) (point-max) file-name 'append))
5280 (defun gnus-narrow-to-page (&optional arg)
5281 "Narrow the article buffer to a page.
5282 If given a numerical ARG, move forward ARG pages."
5284 (setq arg (if arg (prefix-numeric-value arg) 0))
5286 (set-buffer gnus-article-buffer)
5287 (goto-char (point-min))
5289 ;; Remove any old next/prev buttons.
5290 (when (gnus-visual-p 'page-marker)
5291 (let ((buffer-read-only nil))
5292 (gnus-remove-text-with-property 'gnus-prev)
5293 (gnus-remove-text-with-property 'gnus-next)))
5296 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5298 (re-search-forward page-delimiter nil 'move arg)))
5299 (goto-char (match-end 0)))
5302 (if (re-search-forward page-delimiter nil 'move)
5305 (when (and (gnus-visual-p 'page-marker)
5306 (not (= (point-min) 1)))
5308 (goto-char (point-min))
5309 (gnus-insert-prev-page-button)))
5310 (when (and (gnus-visual-p 'page-marker)
5311 (< (+ (point-max) 2) (buffer-size)))
5313 (goto-char (point-max))
5314 (gnus-insert-next-page-button)))))
5316 ;; Article mode commands
5318 (defun gnus-article-goto-next-page ()
5319 "Show the next page of the article."
5321 (when (gnus-article-next-page)
5322 (goto-char (point-min))
5323 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5326 (defun gnus-article-goto-prev-page ()
5327 "Show the next page of the article."
5330 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5331 (gnus-article-prev-page nil)))
5333 ;; This is cleaner but currently breaks `gnus-pick-mode':
5335 ;; (defun gnus-article-goto-next-page ()
5336 ;; "Show the next page of the article."
5338 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5339 ;; (gnus-summary-next-page)))
5341 ;; (defun gnus-article-goto-prev-page ()
5342 ;; "Show the next page of the article."
5344 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5345 ;; (gnus-summary-prev-page)))
5347 (defun gnus-article-next-page (&optional lines)
5348 "Show the next page of the current article.
5349 If end of article, return non-nil. Otherwise return nil.
5350 Argument LINES specifies lines to be scrolled up."
5352 (move-to-window-line -1)
5355 (and (pos-visible-in-window-p) ;Not continuation line.
5356 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5357 ;; Nothing in this page.
5358 (if (or (not gnus-page-broken)
5361 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
5363 (when gnus-article-over-scroll
5364 (gnus-article-next-page-1 lines))
5366 (gnus-narrow-to-page 1) ;Go to next page.
5368 ;; More in this page.
5369 (gnus-article-next-page-1 lines)
5372 (defun gnus-article-next-page-1 (lines)
5373 (let ((scroll-in-place nil))
5377 ;; Long lines may cause an end-of-buffer error.
5378 (goto-char (point-max)))))
5379 (move-to-window-line 0))
5381 (defun gnus-article-prev-page (&optional lines)
5382 "Show previous page of current article.
5383 Argument LINES specifies lines to be scrolled down."
5385 (move-to-window-line 0)
5386 (if (and gnus-page-broken
5388 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5390 (gnus-narrow-to-page -1) ;Go to previous page.
5391 (goto-char (point-max))
5393 (let ((scroll-in-place nil))
5397 (beginning-of-buffer
5398 (goto-char (point-min))))
5399 (move-to-window-line 0)))))
5401 (defun gnus-article-only-boring-p ()
5402 "Decide whether there is only boring text remaining in the article.
5403 Something \"interesting\" is a word of at least two letters that does
5404 not have a face in `gnus-article-boring-faces'."
5405 (when (and gnus-article-skip-boring
5406 (boundp 'gnus-article-boring-faces)
5407 (symbol-value 'gnus-article-boring-faces))
5410 (while (re-search-forward "\\b\\w\\w" nil t)
5412 (when (not (gnus-intersection
5413 (gnus-faces-at (point))
5414 (symbol-value 'gnus-article-boring-faces)))
5415 (throw 'only-boring nil)))
5416 (throw 'only-boring t)))))
5418 (defun gnus-article-refer-article ()
5419 "Read article specified by message-id around point."
5422 (re-search-backward "[ \t]\\|^" (gnus-point-at-bol) t)
5423 (re-search-forward "<?news:<?\\|<" (gnus-point-at-eol) t)
5424 (if (re-search-forward "[^@ ]+@[^ \t>]+" (gnus-point-at-eol) t)
5425 (let ((msg-id (concat "<" (match-string 0) ">")))
5426 (set-buffer gnus-summary-buffer)
5427 (gnus-summary-refer-article msg-id))
5428 (error "No references around point"))))
5430 (defun gnus-article-show-summary ()
5431 "Reconfigure windows to show summary buffer."
5433 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5434 (error "There is no summary buffer for this article buffer")
5435 (gnus-article-set-globals)
5436 (gnus-configure-windows 'article)
5437 (gnus-summary-goto-subject gnus-current-article)
5438 (gnus-summary-position-point)))
5440 (defun gnus-article-describe-briefly ()
5441 "Describe article mode commands briefly."
5443 (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")))
5445 (defun gnus-article-summary-command ()
5446 "Execute the last keystroke in the summary buffer."
5448 (let ((obuf (current-buffer))
5449 (owin (current-window-configuration))
5451 (switch-to-buffer gnus-article-current-summary 'norecord)
5452 (setq func (lookup-key (current-local-map) (this-command-keys)))
5453 (call-interactively func)
5455 (set-window-configuration owin)
5456 (set-window-point (get-buffer-window (current-buffer)) (point))))
5458 (defun gnus-article-summary-command-nosave ()
5459 "Execute the last keystroke in the summary buffer."
5462 (pop-to-buffer gnus-article-current-summary 'norecord)
5463 (setq func (lookup-key (current-local-map) (this-command-keys)))
5464 (call-interactively func)))
5466 (defun gnus-article-check-buffer ()
5467 "Beep if not in an article buffer."
5468 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5469 (error "Command invoked outside of a Gnus article buffer")))
5471 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5472 "Read a summary buffer key sequence and execute it from the article buffer."
5474 (gnus-article-check-buffer)
5476 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5477 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5478 "=" "^" "\M-^" "|"))
5484 '("n" "Gn" "p" "Gp"))
5487 (set-buffer gnus-article-current-summary)
5488 (let (gnus-pick-mode)
5489 (push (or key last-command-event) unread-command-events)
5490 (setq keys (static-if (featurep 'xemacs)
5491 (events-to-keys (read-key-sequence nil))
5492 (read-key-sequence nil)))))
5495 (if (or (member keys nosaves)
5496 (member keys nosave-but-article)
5497 (member keys nosave-in-article))
5499 (save-window-excursion
5500 (pop-to-buffer gnus-article-current-summary 'norecord)
5501 ;; We disable the pick minor mode commands.
5502 (let (gnus-pick-mode)
5503 (setq func (lookup-key (current-local-map) keys))))
5507 (unless (member keys nosave-in-article)
5508 (set-buffer gnus-article-current-summary))
5509 (call-interactively func)
5510 (setq new-sum-point (point)))
5511 (when (member keys nosave-but-article)
5512 (pop-to-buffer gnus-article-buffer 'norecord)))
5513 ;; These commands should restore window configuration.
5514 (let ((obuf (current-buffer))
5515 (owin (current-window-configuration))
5517 (summary gnus-article-current-summary)
5518 func in-buffer selected)
5519 (if not-restore-window
5520 (pop-to-buffer summary 'norecord)
5521 (switch-to-buffer summary 'norecord))
5522 (setq in-buffer (current-buffer))
5523 ;; We disable the pick minor mode commands.
5524 (if (and (setq func (let (gnus-pick-mode)
5525 (lookup-key (current-local-map) keys)))
5528 (call-interactively func)
5529 (setq new-sum-point (point))
5530 (when (eq in-buffer (current-buffer))
5531 (setq selected (gnus-summary-select-article))
5533 (unless not-restore-window
5534 (set-window-configuration owin))
5535 (when (eq selected 'old)
5537 (set-window-start (get-buffer-window (current-buffer))
5539 (set-window-point (get-buffer-window (current-buffer))
5541 (let ((win (get-buffer-window gnus-article-current-summary)))
5543 (set-window-point win new-sum-point)))) )
5544 (switch-to-buffer gnus-article-buffer)
5547 (defun gnus-article-describe-key (key)
5548 "Display documentation of the function invoked by KEY. KEY is a string."
5549 (interactive "kDescribe key: ")
5550 (gnus-article-check-buffer)
5551 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5553 (set-buffer gnus-article-current-summary)
5554 (let (gnus-pick-mode)
5555 (if (featurep 'xemacs)
5557 (push (elt key 0) unread-command-events)
5558 (setq key (events-to-keys
5559 (read-key-sequence "Describe key: "))))
5560 (setq unread-command-events
5562 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5564 (setq key (read-key-sequence "Describe key: "))))
5566 (describe-key key)))
5568 (defun gnus-article-describe-key-briefly (key &optional insert)
5569 "Display documentation of the function invoked by KEY. KEY is a string."
5570 (interactive "kDescribe key: \nP")
5571 (gnus-article-check-buffer)
5572 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5574 (set-buffer gnus-article-current-summary)
5575 (let (gnus-pick-mode)
5576 (if (featurep 'xemacs)
5578 (push (elt key 0) unread-command-events)
5579 (setq key (events-to-keys
5580 (read-key-sequence "Describe key: "))))
5581 (setq unread-command-events
5583 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5585 (setq key (read-key-sequence "Describe key: "))))
5586 (describe-key-briefly key insert))
5587 (describe-key-briefly key insert)))
5589 (defun gnus-article-reply-with-original (&optional wide)
5590 "Start composing a reply mail to the current message.
5591 The text in the region will be yanked. If the region isn't active,
5592 the entire article will be yanked."
5594 (let ((article (cdr gnus-article-current))
5596 (if (not (gnus-mark-active-p))
5597 (with-current-buffer gnus-summary-buffer
5598 (gnus-summary-reply (list (list article)) wide))
5599 (setq contents (buffer-substring (point) (mark t)))
5600 ;; Deactivate active regions.
5601 (when (and (boundp 'transient-mark-mode)
5602 transient-mark-mode)
5603 (setq mark-active nil))
5604 (with-current-buffer gnus-summary-buffer
5606 (list (list article contents)) wide)))))
5608 (defun gnus-article-followup-with-original ()
5609 "Compose a followup to the current article.
5610 The text in the region will be yanked. If the region isn't active,
5611 the entire article will be yanked."
5613 (let ((article (cdr gnus-article-current))
5615 (if (not (gnus-mark-active-p))
5616 (with-current-buffer gnus-summary-buffer
5617 (gnus-summary-followup (list (list article))))
5618 (setq contents (buffer-substring (point) (mark t)))
5619 ;; Deactivate active regions.
5620 (when (and (boundp 'transient-mark-mode)
5621 transient-mark-mode)
5622 (setq mark-active nil))
5623 (with-current-buffer gnus-summary-buffer
5624 (gnus-summary-followup
5625 (list (list article contents)))))))
5627 (defun gnus-article-hide (&optional arg force)
5628 "Hide all the gruft in the current article.
5629 This means that signatures, cited text and (some) headers will be
5631 If given a prefix, show the hidden text instead."
5632 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5633 (gnus-article-hide-headers arg)
5634 (gnus-article-hide-list-identifiers arg)
5635 (gnus-article-hide-citation-maybe arg force)
5636 (gnus-article-hide-signature arg))
5638 (defun gnus-article-maybe-highlight ()
5639 "Do some article highlighting if article highlighting is requested."
5640 (when (gnus-visual-p 'article-highlight 'highlight)
5641 (gnus-article-highlight-some)))
5643 (defun gnus-check-group-server ()
5644 ;; Make sure the connection to the server is alive.
5645 (unless (gnus-server-opened
5646 (gnus-find-method-for-group gnus-newsgroup-name))
5647 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5648 (gnus-request-group gnus-newsgroup-name t)))
5651 (autoload 'nneething-get-file-name "nneething"))
5653 (defun gnus-request-article-this-buffer (article group)
5654 "Get an article and insert it into this buffer."
5655 (let (do-update-line sparse-header)
5659 (gnus-kill-all-overlays)
5660 (setq group (or group gnus-newsgroup-name))
5662 ;; Using `gnus-request-article' directly will insert the article into
5663 ;; `nntp-server-buffer' - so we'll save some time by not having to
5664 ;; copy it from the server buffer into the article buffer.
5666 ;; We only request an article by message-id when we do not have the
5667 ;; headers for it, so we'll have to get those.
5668 (when (stringp article)
5669 (gnus-read-header article))
5671 ;; If the article number is negative, that means that this article
5672 ;; doesn't belong in this newsgroup (possibly), so we find its
5673 ;; message-id and request it by id instead of number.
5674 (when (and (numberp article)
5676 (get-buffer gnus-summary-buffer)
5677 (gnus-buffer-exists-p gnus-summary-buffer))
5679 (set-buffer gnus-summary-buffer)
5680 (let ((header (gnus-summary-article-header article)))
5683 ((memq article gnus-newsgroup-sparse)
5684 ;; This is a sparse gap article.
5685 (setq do-update-line article)
5686 (setq article (mail-header-id header))
5687 (setq sparse-header (gnus-read-header article))
5688 (setq gnus-newsgroup-sparse
5689 (delq article gnus-newsgroup-sparse)))
5691 ;; It's a real article.
5692 (setq article (mail-header-id header)))
5694 ;; It is an extracted pseudo-article.
5695 (setq article 'pseudo)
5696 (gnus-request-pseudo-article header))))
5698 (let ((method (gnus-find-method-for-group
5699 gnus-newsgroup-name)))
5700 (when (and (eq (car method) 'nneething)
5702 (let ((dir (nneething-get-file-name
5703 (mail-header-id header))))
5704 (when (and (stringp dir)
5705 (file-directory-p dir))
5706 (setq article 'nneething)
5707 (gnus-group-enter-directory dir))))))))
5710 ;; Refuse to select canceled articles.
5711 ((and (numberp article)
5713 (get-buffer gnus-summary-buffer)
5714 (gnus-buffer-exists-p gnus-summary-buffer)
5715 (eq (cdr (save-excursion
5716 (set-buffer gnus-summary-buffer)
5717 (assq article gnus-newsgroup-reads)))
5718 gnus-canceled-mark))
5720 ;; We first check `gnus-original-article-buffer'.
5721 ((and (get-buffer gnus-original-article-buffer)
5724 (set-buffer gnus-original-article-buffer)
5725 (and (equal (car gnus-original-article) group)
5726 (eq (cdr gnus-original-article) article))))
5727 (insert-buffer-substring gnus-original-article-buffer)
5729 ;; Check the backlog.
5730 ((and gnus-keep-backlog
5731 (gnus-backlog-request-article group article (current-buffer)))
5733 ;; Check asynchronous pre-fetch.
5734 ((gnus-async-request-fetched-article group article (current-buffer))
5735 (gnus-async-prefetch-next group article gnus-summary-buffer)
5736 (when (and (numberp article) gnus-keep-backlog)
5737 (gnus-backlog-enter-article group article (current-buffer)))
5740 ((and gnus-use-cache
5742 (gnus-cache-request-article article group))
5744 ;; Check the agent cache.
5745 ((gnus-agent-request-article article group)
5747 ;; Get the article and put into the article buffer.
5748 ((or (stringp article)
5750 (let ((gnus-override-method gnus-override-method)
5751 (methods (and (stringp article)
5752 gnus-refer-article-method))
5753 (backend (car (gnus-find-method-for-group
5754 gnus-newsgroup-name)))
5756 (buffer-read-only nil))
5757 (if (or (not (listp methods))
5758 (and (symbolp (car methods))
5759 (assq (car methods) nnoo-definition-alist)))
5760 (setq methods (list methods)))
5761 (when (and (null gnus-override-method)
5763 (setq gnus-override-method (pop methods)))
5765 (when (eq gnus-override-method 'current)
5766 (setq gnus-override-method
5767 (with-current-buffer gnus-summary-buffer
5768 gnus-current-select-method)))
5770 (gnus-kill-all-overlays)
5771 (let ((gnus-newsgroup-name group))
5772 (gnus-check-group-server))
5774 ((gnus-request-article article group (current-buffer))
5775 (when (numberp article)
5776 (gnus-async-prefetch-next group article
5777 gnus-summary-buffer)
5778 (when gnus-keep-backlog
5779 (gnus-backlog-enter-article
5780 group article (current-buffer))))
5781 (setq result 'article))
5783 (setq gnus-override-method (pop methods)))
5784 ((not (string-match "^400 "
5785 (nnheader-get-report backend)))
5786 ;; If we get 400 server disconnect, reconnect and
5787 ;; retry; otherwise, assume the article has expired.
5788 (setq result 'done))))
5789 (and (eq result 'article) 'article)))
5793 ;; Associate this article with the current summary buffer.
5794 (setq gnus-article-current-summary gnus-summary-buffer)
5796 ;; Take the article from the original article buffer
5797 ;; and place it in the buffer it's supposed to be in.
5798 (when (and (get-buffer gnus-article-buffer)
5799 (equal (buffer-name (current-buffer))
5800 (buffer-name (get-buffer gnus-article-buffer))))
5802 (if (get-buffer gnus-original-article-buffer)
5803 (set-buffer gnus-original-article-buffer)
5804 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5805 (buffer-disable-undo)
5806 (setq major-mode 'gnus-original-article-mode)
5807 (setq buffer-read-only t))
5808 (let (buffer-read-only)
5810 (insert-buffer-substring gnus-article-buffer))
5811 (setq gnus-original-article (cons group article)))
5814 (run-hooks 'gnus-article-decode-hook)
5815 ;; Mark article as decoded or not.
5816 (setq gnus-article-decoded-p gnus-article-decode-hook))
5818 ;; Update sparse articles.
5819 (when (and do-update-line
5820 (or (numberp article)
5822 (let ((buf (current-buffer)))
5823 (set-buffer gnus-summary-buffer)
5824 (gnus-summary-update-article do-update-line sparse-header)
5825 (gnus-summary-goto-subject do-update-line nil t)
5826 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5828 (set-buffer buf))))))
5834 (defcustom gnus-article-edit-mode-hook nil
5835 "Hook run in article edit mode buffers."
5836 :group 'gnus-article-various
5839 (defcustom gnus-article-edit-article-setup-function
5840 'gnus-article-mime-edit-article-setup
5841 "Function called to setup an editing article buffer."
5842 :group 'gnus-article-various
5845 (defvar gnus-article-edit-done-function nil)
5847 (defvar gnus-article-edit-mode-map nil)
5848 (defvar gnus-article-edit-mode nil)
5850 ;; Should we be using derived.el for this?
5851 (unless gnus-article-edit-mode-map
5852 (setq gnus-article-edit-mode-map (make-keymap))
5853 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5855 (gnus-define-keys gnus-article-edit-mode-map
5856 "\C-c?" describe-mode
5857 "\C-c\C-c" gnus-article-edit-done
5858 "\C-c\C-k" gnus-article-edit-exit
5859 "\C-c\C-f\C-t" message-goto-to
5860 "\C-c\C-f\C-o" message-goto-from
5861 "\C-c\C-f\C-b" message-goto-bcc
5862 ;;"\C-c\C-f\C-w" message-goto-fcc
5863 "\C-c\C-f\C-c" message-goto-cc
5864 "\C-c\C-f\C-s" message-goto-subject
5865 "\C-c\C-f\C-r" message-goto-reply-to
5866 "\C-c\C-f\C-n" message-goto-newsgroups
5867 "\C-c\C-f\C-d" message-goto-distribution
5868 "\C-c\C-f\C-f" message-goto-followup-to
5869 "\C-c\C-f\C-m" message-goto-mail-followup-to
5870 "\C-c\C-f\C-k" message-goto-keywords
5871 "\C-c\C-f\C-u" message-goto-summary
5872 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5873 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5874 "\C-c\C-b" message-goto-body
5875 "\C-c\C-i" message-goto-signature
5877 "\C-c\C-t" message-insert-to
5878 "\C-c\C-n" message-insert-newsgroups
5879 "\C-c\C-o" message-sort-headers
5880 "\C-c\C-e" message-elide-region
5881 "\C-c\C-v" message-delete-not-region
5882 "\C-c\C-z" message-kill-to-signature
5883 "\M-\r" message-newline-and-reformat
5884 "\C-c\C-a" mml-attach-file
5885 "\C-a" message-beginning-of-line
5887 "\M-;" comment-region)
5889 (gnus-define-keys (gnus-article-edit-wash-map
5890 "\C-c\C-w" gnus-article-edit-mode-map)
5891 "f" gnus-article-edit-full-stops))
5894 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5896 ["Fetch To" message-insert-to t]
5897 ["Fetch Newsgroups" message-insert-newsgroups t]
5899 ["To" message-goto-to t]
5900 ["From" message-goto-from t]
5901 ["Subject" message-goto-subject t]
5902 ["Cc" message-goto-cc t]
5903 ["Reply-To" message-goto-reply-to t]
5904 ["Summary" message-goto-summary t]
5905 ["Keywords" message-goto-keywords t]
5906 ["Newsgroups" message-goto-newsgroups t]
5907 ["Followup-To" message-goto-followup-to t]
5908 ["Mail-Followup-To" message-goto-mail-followup-to t]
5909 ["Distribution" message-goto-distribution t]
5910 ["Body" message-goto-body t]
5911 ["Signature" message-goto-signature t]))
5913 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5914 "Major mode for editing articles.
5915 This is an extended text-mode.
5917 \\{gnus-article-edit-mode-map}"
5918 (make-local-variable 'gnus-article-edit-done-function)
5919 (make-local-variable 'gnus-prev-winconf)
5920 (set (make-local-variable 'font-lock-defaults)
5921 '(message-font-lock-keywords t))
5922 (set (make-local-variable 'mail-header-separator) "")
5923 (set (make-local-variable 'gnus-article-edit-mode) t)
5924 (easy-menu-add message-mode-field-menu message-mode-map)
5925 (setq buffer-read-only nil)
5926 (buffer-enable-undo)
5929 (defun gnus-article-edit (&optional force)
5930 "Edit the current article.
5931 This will have permanent effect only in mail groups.
5932 If FORCE is non-nil, allow editing of articles even in read-only
5935 (when (and (not force)
5936 (gnus-group-read-only-p))
5937 (error "The current newsgroup does not support article editing"))
5938 (gnus-article-date-original)
5939 (gnus-article-edit-article
5941 `(lambda (no-highlight)
5943 (gnus-summary-edit-article-done
5944 ,(or (mail-header-references gnus-current-headers) "")
5945 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5947 (defun gnus-article-edit-article (start-func exit-func)
5948 "Start editing the contents of the current article buffer."
5949 (let ((winconf (current-window-configuration)))
5950 (set-buffer gnus-article-buffer)
5951 (gnus-article-edit-mode)
5952 (funcall start-func)
5953 (set-buffer-modified-p nil)
5954 (gnus-configure-windows 'edit-article)
5955 (setq gnus-article-edit-done-function exit-func)
5956 (setq gnus-prev-winconf winconf)
5957 (when gnus-article-edit-article-setup-function
5958 (funcall gnus-article-edit-article-setup-function))
5959 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit")))
5961 (defun gnus-article-edit-done (&optional arg)
5962 "Update the article edits and exit."
5964 (let ((func gnus-article-edit-done-function)
5965 (buf (current-buffer))
5966 (start (window-start))
5968 (winconf gnus-prev-winconf))
5969 (remove-hook 'gnus-article-mode-hook
5970 'gnus-article-mime-edit-article-unwind)
5971 (widen) ;; Widen it in case that users narrowed the buffer.
5974 ;; The cache and backlog have to be flushed somewhat.
5975 (when gnus-keep-backlog
5976 (gnus-backlog-remove-article
5977 (car gnus-article-current) (cdr gnus-article-current)))
5978 ;; Flush original article as well.
5980 (when (get-buffer gnus-original-article-buffer)
5981 (set-buffer gnus-original-article-buffer)
5982 (setq gnus-original-article nil)))
5983 (when gnus-use-cache
5984 (gnus-cache-update-article
5985 (car gnus-article-current) (cdr gnus-article-current)))
5986 ;; We remove all text props from the article buffer.
5987 (kill-all-local-variables)
5988 (gnus-set-text-properties (point-min) (point-max) nil)
5990 (set-window-configuration winconf)
5992 (set-window-start (get-buffer-window buf) start)
5993 (set-window-point (get-buffer-window buf) (point)))
5994 (gnus-summary-show-article))
5996 (defun gnus-article-edit-exit ()
5997 "Exit the article editing without updating."
5999 (when (or (not (buffer-modified-p))
6000 (yes-or-no-p "Article modified; kill anyway? "))
6001 (let ((curbuf (current-buffer))
6003 (window-start (window-start)))
6005 (if (gnus-buffer-live-p gnus-original-article-buffer)
6006 (insert-buffer-substring gnus-original-article-buffer))
6007 (let ((winconf gnus-prev-winconf))
6008 (kill-all-local-variables)
6010 (set-window-configuration winconf)
6011 ;; Tippy-toe some to make sure that point remains where it was.
6012 (save-current-buffer
6014 (set-window-start (get-buffer-window (current-buffer)) window-start)
6016 (gnus-summary-show-article)))
6018 (defun gnus-article-edit-full-stops ()
6019 "Interactively repair spacing at end of sentences."
6022 (goto-char (point-min))
6023 (search-forward-regexp "^$" nil t)
6024 (let ((case-fold-search nil))
6025 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
6028 ;;; Article editing with MIME-Edit
6031 (defcustom gnus-article-mime-edit-article-setup-hook nil
6032 "Hook run after setting up a MIME editing article buffer."
6033 :group 'gnus-article-various
6036 (defun gnus-article-mime-edit-article-unwind ()
6037 "Unwind `gnus-article-buffer' if article editing was given up."
6038 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6039 (when (featurep 'font-lock)
6040 (setq font-lock-defaults nil)
6041 (font-lock-mode -1))
6042 (when mime-edit-mode-flag
6043 (mime-edit-exit 'nomime 'no-error)
6046 (defun gnus-article-mime-edit-article-setup ()
6047 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
6048 after replacing with the original article."
6049 (setq gnus-show-mime t)
6050 (setq gnus-article-edit-done-function
6051 `(lambda (&rest args)
6052 (when mime-edit-mode-flag
6053 (let (mime-edit-insert-user-agent-field)
6056 (goto-char (point-min))
6057 (let (case-fold-search)
6058 (when (re-search-forward
6059 (format "^%s$" (regexp-quote mail-header-separator))
6061 (replace-match "")))
6062 (apply ,gnus-article-edit-done-function args)
6065 (buffer-substring-no-properties (point-min) (point-max))
6066 (set-buffer (get-buffer-create gnus-original-article-buffer))
6068 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6069 (set-buffer gnus-article-buffer)
6070 (gnus-article-prepare-display)))
6071 (substitute-key-definition 'gnus-article-edit-done
6072 'gnus-article-mime-edit-done
6073 gnus-article-edit-mode-map)
6074 (substitute-key-definition 'gnus-article-edit-exit
6075 'gnus-article-mime-edit-exit
6076 gnus-article-edit-mode-map)
6078 (insert-buffer-substring gnus-original-article-buffer)
6079 (unless (member (with-current-buffer gnus-summary-buffer
6080 gnus-newsgroup-name)
6081 '("nndraft:delayed" "nndraft:drafts"))
6082 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
6083 (fset 'mime-edit-decode-single-part-in-buffer
6084 (lambda (&rest args)
6085 (if (let ((content-type (car args)))
6086 (and (eq 'message (mime-content-type-primary-type
6088 (eq 'rfc822 (mime-content-type-subtype
6090 (setcar (cdr args) 'not-decode-text))
6094 (fset 'mime-edit-decode-single-part-in-buffer ofn))))
6095 (when (featurep 'font-lock)
6096 (set (make-local-variable 'font-lock-defaults)
6097 '(message-font-lock-keywords t))
6098 (font-lock-set-defaults)
6099 (turn-on-font-lock))
6100 (set-buffer-modified-p nil)
6101 (delete-other-windows)
6102 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6103 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
6105 (defun gnus-article-mime-edit-done (&optional arg)
6106 "Update the article MIME edits and exit."
6108 (when (featurep 'font-lock)
6109 (setq font-lock-defaults nil)
6110 (font-lock-mode -1))
6111 (let ((inhibit-read-only t))
6112 (gnus-article-edit-done arg)))
6114 (defun gnus-article-mime-edit-exit ()
6115 "Exit the article MIME editing without updating."
6117 (when (or (not (buffer-modified-p))
6118 (yes-or-no-p "Article modified; kill anyway? "))
6119 (when (featurep 'font-lock)
6120 (setq font-lock-defaults nil)
6121 (font-lock-mode -1))
6122 (when mime-edit-mode-flag
6123 (let (mime-edit-insert-user-agent-field)
6126 (goto-char (point-min))
6127 (let (case-fold-search)
6128 (when (re-search-forward
6129 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
6130 (replace-match "")))
6131 (let ((winconf gnus-prev-winconf))
6133 (buffer-substring-no-properties (point-min) (point-max))
6134 (set-buffer (get-buffer-create gnus-original-article-buffer))
6136 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6137 (set-buffer gnus-article-buffer)
6138 (gnus-article-prepare-display)
6139 (set-window-configuration winconf))))
6142 ;;; Article highlights
6145 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6147 ;;; Internal Variables:
6149 (defcustom gnus-button-url-regexp
6150 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
6151 "\\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:]]\\)"
6152 "\\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\\)\\)")
6153 "Regular expression that matches URLs."
6154 :group 'gnus-article-buttons
6157 (defcustom gnus-button-valid-fqdn-regexp
6158 message-valid-fqdn-regexp
6159 "Regular expression that matches a valid FQDN."
6160 :group 'gnus-article-buttons
6163 (defcustom gnus-button-man-handler 'manual-entry
6164 "Function to use for displaying man pages.
6165 The function must take at least one argument with a string naming the
6167 :type '(choice (function-item :tag "Man" manual-entry)
6168 (function-item :tag "Woman" woman)
6169 (function :tag "Other"))
6170 :group 'gnus-article-buttons)
6172 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6173 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6174 If the default site is too slow, try to find a CTAN mirror, see
6175 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6176 the variable `gnus-button-handle-ctan'."
6177 :group 'gnus-article-buttons
6178 :link '(custom-manual "(gnus)Group Parameters")
6179 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6180 (const "http://tug.ctan.org/tex-archive/")
6181 (const "http://www.dante.de/CTAN/")
6182 (string :tag "Other")))
6184 (defcustom gnus-button-ctan-handler 'browse-url
6185 "Function to use for displaying CTAN links.
6186 The function must take one argument, the string naming the URL."
6187 :type '(choice (function-item :tag "Browse Url" browse-url)
6188 (function :tag "Other"))
6189 :group 'gnus-article-buttons)
6191 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6192 "Bogus strings removed from CTAN URLs."
6193 :group 'gnus-article-buttons
6194 :type '(choice (const "^/?tex-archive/\\|/")
6195 (regexp :tag "Other")))
6197 (defcustom gnus-button-ctan-directory-regexp
6199 "\\("; Cannot use `\(?: ... \)' (compatibility with Emacs 20).
6200 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
6201 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
6202 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
6204 "Regular expression for ctan directories.
6205 It should match all directories in the top level of `gnus-ctan-url'."
6206 :group 'gnus-article-buttons
6209 (defcustom gnus-button-mid-or-mail-regexp
6210 (concat "\\b\\(<?[a-z0-9][^<>\")!;:,{}\n\t ]*@"
6211 gnus-button-valid-fqdn-regexp
6213 "Regular expression that matches a message ID or a mail address."
6214 :group 'gnus-article-buttons
6217 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6218 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6219 Strings like this can be either a message ID or a mail address. If it is one
6220 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6221 message ID or a mail address, respectively. If this variable is set to the
6222 symbol `ask', always query the user what do do. If it is a function, this
6223 function will be called with the string as it's only argument. The function
6224 must return `mid', `mail', `invalid' or `ask'."
6225 :group 'gnus-article-buttons
6226 :type '(choice (function-item :tag "Heuristic function"
6227 gnus-button-mid-or-mail-heuristic)
6232 (defcustom gnus-button-mid-or-mail-heuristic-alist
6233 '((-10.0 . ".+\\$.+@")
6236 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6237 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6238 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6239 (-1.0 . "^[^a-z]+@")
6241 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6242 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6243 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6244 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6247 (-1.0 . "^[0-9][0-9]")
6249 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6250 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6251 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6252 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6254 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6255 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6258 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6260 ;; compensation for TDMA dated mail addresses:
6261 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6263 (-20.0 . "\\.fsf@") ;; Gnus
6266 (-20.0 . "_-_") ;; Subject change in thread
6268 (-20.0 . "\\.ln@") ;; leafnode
6269 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6270 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6272 ;; (5.0 . "") ;; $local_part_len <= 7
6273 (10.0 . "^[^0-9]+@")
6274 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6275 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6278 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6280 (0.5 . "^[A-Z][a-z]")
6281 (0.5 . "^[A-Z][a-z][a-z]")
6282 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6283 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6284 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6286 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6287 address. The REGEXP is processed with `case-fold-search' set to nil."
6288 :group 'gnus-article-buttons
6289 :type '(repeat (cons (number :tag "Rate")
6290 (regexp :tag "Regexp"))))
6292 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6293 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6294 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6295 address, `ask' if unsure and `invalid' if the string is invalid."
6296 (let ((case-fold-search nil)
6297 (list gnus-button-mid-or-mail-heuristic-alist)
6298 (result 0) rate regexp lpartlen elem)
6300 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6301 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6302 ;; Certain special cases...
6305 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$" "\\|"
6306 "^[0-9]+\.[0-9]+\@compuserve")
6308 (gnus-message 8 "`%s' is a known mail address.")
6309 (setq result 'mail))
6310 (when (string-match "@.*@\\| " mid-or-mail)
6311 (gnus-message 8 "`%s' is invalid.")
6312 (setq result 'invalid))
6313 ;; Nothing more to do, if result is not a number here...
6314 (when (numberp result)
6316 (setq elem (car list)
6320 (when (string-match regexp mid-or-mail)
6321 (setq result (+ result rate))
6323 9 "`%s' matched `%s', rate `%s', result `%s'."
6324 mid-or-mail regexp rate result)))
6325 (when (<= lpartlen 7)
6326 (setq result (+ result 5.0))
6327 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6328 mid-or-mail result))
6329 (when (>= lpartlen 12)
6330 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6332 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6333 ;; Long local part should contain realname if e-mail address,
6334 ;; too many digits: message-id.
6335 ;; $score -= 5.0 + 0.1 * $local_part_len;
6336 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6337 (setq result (+ result rate))
6339 9 "Many digits in `%s', rate `%s', result `%s'."
6340 mid-or-mail rate result))
6341 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6343 ;; Too few vowels [^aeiouy]{4,}.*\@
6344 (setq result (+ result -5.0))
6346 9 "Few vowels in `%s', rate `%s', result `%s'."
6347 mid-or-mail -5.0 result))
6349 (setq result (+ result 5.0))
6351 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6352 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6354 ;; Maybe we should make this a customizable alist: (condition . 'result)
6355 ((< result -10.0) 'mid)
6356 ((> result 10.0) 'mail)
6359 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6360 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6361 (url-mid (concat "news" ":" mid-or-mail))
6362 (url-mailto (concat "mailto" ":" mid-or-mail)))
6363 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6364 (when (fboundp pref)
6366 ;; get rid of surrounding angles...
6368 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6369 (if (or (eq 'mid guessed) (eq 'mail guessed))
6373 (save-window-excursion
6374 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6377 (cond ((eq pref 'mid)
6378 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6379 (gnus-button-handle-news url-mid))
6381 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6382 (gnus-url-mailto url-mailto))
6383 (t (gnus-message 3 "Invalid string.")))))
6385 (defun gnus-button-handle-custom (url)
6386 "Follow a Custom URL."
6387 (customize-apropos (gnus-url-unhex-string url)))
6389 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6391 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6394 (defun gnus-button-handle-describe-function (url)
6395 "Call `describe-function' when pushing the corresponding URL button."
6398 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6400 (defun gnus-button-handle-describe-variable (url)
6401 "Call `describe-variable' when pushing the corresponding URL button."
6404 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6406 (defun gnus-button-handle-symbol (url)
6407 "Display help on variable or function.
6408 Calls `describe-variable' or `describe-function'."
6409 (let ((sym (intern url)))
6411 ((fboundp sym) (describe-function sym))
6412 ((boundp sym) (describe-variable sym))
6413 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6415 (defun gnus-button-handle-describe-key (url)
6416 "Call `describe-key' when pushing the corresponding URL button."
6418 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6419 (keys (ignore-errors (eval `(kbd ,key-string)))))
6422 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6424 (defun gnus-button-handle-apropos (url)
6425 "Call `apropos' when pushing the corresponding URL button."
6426 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6428 (defun gnus-button-handle-apropos-command (url)
6429 "Call `apropos' when pushing the corresponding URL button."
6431 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6433 (defun gnus-button-handle-apropos-variable (url)
6434 "Call `apropos' when pushing the corresponding URL button."
6436 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6437 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6439 (defun gnus-button-handle-apropos-documentation (url)
6440 "Call `apropos' when pushing the corresponding URL button."
6442 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6443 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6445 (defun gnus-button-handle-library (url)
6446 "Call `locate-library' when pushing the corresponding URL button."
6447 (gnus-message 9 "url=`%s'" url)
6448 (let* ((lib (locate-library url))
6449 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6451 (gnus-message 1 "Cannot locale library `%s'." url)
6452 (find-file-read-only file))))
6454 (defun gnus-button-handle-ctan (url)
6455 "Call `browse-url' when pushing a CTAN URL button."
6457 gnus-button-ctan-handler
6460 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6462 (defcustom gnus-button-tex-level 5
6463 "*Integer that says how many TeX-related buttons Gnus will show.
6464 The higher the number, the more buttons will appear and the more false
6465 positives are possible. Note that you can set this variable local to
6466 specific groups. Setting it higher in TeX groups is probably a good idea.
6467 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6468 how to set variables in specific groups."
6469 :group 'gnus-article-buttons
6470 :link '(custom-manual "(gnus)Group Parameters")
6473 (defcustom gnus-button-man-level 5
6474 "*Integer that says how many man-related buttons Gnus will show.
6475 The higher the number, the more buttons will appear and the more false
6476 positives are possible. Note that you can set this variable local to
6477 specific groups. Setting it higher in Unix groups is probably a good idea.
6478 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6479 how to set variables in specific groups."
6480 :group 'gnus-article-buttons
6481 :link '(custom-manual "(gnus)Group Parameters")
6484 (defcustom gnus-button-emacs-level 5
6485 "*Integer that says how many emacs-related buttons Gnus will show.
6486 The higher the number, the more buttons will appear and the more false
6487 positives are possible. Note that you can set this variable local to
6488 specific groups. Setting it higher in Emacs or Gnus related groups is
6489 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6490 `gnus-parameters' on how to set variables in specific groups."
6491 :group 'gnus-article-buttons
6492 :link '(custom-manual "(gnus)Group Parameters")
6495 (defcustom gnus-button-message-level 5
6496 "*Integer that says how many buttons for news or mail messages will appear.
6497 The higher the number, the more buttons will appear and the more false
6498 positives are possible."
6499 ;; mail addresses, MIDs, URLs for news, ...
6500 :group 'gnus-article-buttons
6503 (defcustom gnus-button-browse-level 5
6504 "*Integer that says how many buttons for browsing will appear.
6505 The higher the number, the more buttons will appear and the more false
6506 positives are possible."
6507 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6508 :group 'gnus-article-buttons
6511 (defcustom gnus-button-alist
6512 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6513 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6514 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6515 gnus-button-handle-news 2)
6516 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6517 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6518 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6519 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6520 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6521 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6522 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6523 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6524 ("mailto:\\([-a-z.@_+0-9%=?]+\\)"
6525 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6526 ("\\bmailto:\\([^ \n\t]+\\)"
6527 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6529 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6530 gnus-button-ctan-directory-regexp
6531 "[^][>)!;:,'\n\t ]+\\)")
6532 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6533 ((concat "\\btex-archive/\\("
6534 gnus-button-ctan-directory-regexp
6535 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6536 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6539 gnus-button-ctan-directory-regexp
6540 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6541 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6543 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)"
6544 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6545 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6546 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6547 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6548 ;; Info links like `C-h i d m CC Mode RET'
6549 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6551 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6552 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6553 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6554 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6555 ;; Emacs help commands
6556 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6557 ;; regexp doesn't match arguments containing ` '.
6558 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6559 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6560 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6561 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6562 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6563 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6564 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6565 ;; The following entries may lead to many false positives so don't enable
6566 ;; them by default (use a high button level):
6567 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>"
6568 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6569 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6570 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6571 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6572 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6573 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6574 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6575 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6576 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6577 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6578 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6579 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6580 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6581 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6582 ;; Unlike the other regexps we really have to require quoting
6583 ;; here to determine where it ends.
6584 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6585 ;; This is how URLs _should_ be embedded in text (RFC 1738)...
6586 ("<URL: *\\([^<>]*\\)>"
6587 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6589 (gnus-button-url-regexp
6590 0 (>= gnus-button-browse-level 0) browse-url 0)
6592 ("\\b\\([a-z][a-z]+\\)([1-9])\\W"
6593 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6594 gnus-button-handle-man 1)
6595 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6596 ("\\b\\([a-z][-_.a-z0-9]+\\)([1-9])\\W"
6597 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6598 gnus-button-handle-man 1)
6599 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6600 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6601 ("\\b\\([a-z][-+_.:a-z0-9]+\\)([1-9][X1a-z]*)\\W\\|\\b\\(X\\)([1-9])\\W"
6602 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6603 ;; MID or mail: To avoid too many false positives we don't try to catch
6604 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6605 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6606 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6607 ;; so that non-ambiguous entries (see above) match first.
6608 (gnus-button-mid-or-mail-regexp
6609 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6610 "*Alist of regexps matching buttons in article bodies.
6612 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6613 REGEXP: is the string (case insensitive) matching text around the button (can
6614 also be Lisp expression evaluating to a string),
6615 BUTTON: is the number of the regexp grouping actually matching the button,
6616 FORM: is a Lisp expression which must eval to true for the button to
6618 CALLBACK: is the function to call when the user push this button, and each
6619 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6621 CALLBACK can also be a variable, in that case the value of that
6622 variable it the real callback function."
6623 :group 'gnus-article-buttons
6624 :type '(repeat (list (choice regexp variable sexp)
6625 (integer :tag "Button")
6627 (function :tag "Callback")
6630 (integer :tag "Regexp group")))))
6632 (defcustom gnus-header-button-alist
6633 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6634 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6635 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6636 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6637 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6638 0 (>= gnus-button-message-level 0) gnus-button-mailto 0)
6639 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6640 0 (>= gnus-button-browse-level 0) browse-url 0)
6641 ("^Subject:" gnus-button-url-regexp
6642 0 (>= gnus-button-browse-level 0) browse-url 0)
6643 ("^[^:]+:" gnus-button-url-regexp
6644 0 (>= gnus-button-browse-level 0) browse-url 0)
6645 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?]+\\)"
6646 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6647 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6648 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6649 "*Alist of headers and regexps to match buttons in article heads.
6651 This alist is very similar to `gnus-button-alist', except that each
6652 alist has an additional HEADER element first in each entry:
6654 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6656 HEADER is a regexp to match a header. For a fuller explanation, see
6657 `gnus-button-alist'."
6658 :group 'gnus-article-buttons
6659 :group 'gnus-article-headers
6660 :type '(repeat (list (regexp :tag "Header")
6661 (choice regexp variable)
6662 (integer :tag "Button")
6664 (function :tag "Callback")
6667 (integer :tag "Regexp group")))))
6669 (defvar gnus-button-regexp nil)
6670 (defvar gnus-button-marker-list nil)
6671 ;; Regexp matching any of the regexps from `gnus-button-alist'.
6673 (defvar gnus-button-last nil)
6674 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
6678 (defun gnus-article-push-button (event)
6679 "Check text under the mouse pointer for a callback function.
6680 If the text under the mouse pointer has a `gnus-callback' property,
6681 call it with the value of the `gnus-data' text property."
6683 (set-buffer (window-buffer (posn-window (event-start event))))
6684 (let* ((pos (posn-point (event-start event)))
6685 (data (get-text-property pos 'gnus-data))
6686 (fun (get-text-property pos 'gnus-callback)))
6689 (funcall fun data))))
6691 (defun gnus-article-press-button ()
6692 "Check text at point for a callback function.
6693 If the text at point has a `gnus-callback' property,
6694 call it with the value of the `gnus-data' text property."
6696 (let ((data (get-text-property (point) 'gnus-data))
6697 (fun (get-text-property (point) 'gnus-callback)))
6699 (funcall fun data))))
6701 (defun gnus-article-prev-button (n)
6702 "Move point to N buttons backward.
6703 If N is negative, move forward instead."
6705 (gnus-article-next-button (- n)))
6707 (defun gnus-article-next-button (n)
6708 "Move point to N buttons forward.
6709 If N is negative, move backward instead."
6711 (let ((function (if (< n 0) 'previous-single-property-change
6712 'next-single-property-change))
6713 (inhibit-point-motion-hooks t)
6715 (limit (if (< n 0) (point-min) (point-max))))
6717 (while (and (not (= limit (point)))
6719 ;; Skip past the current button.
6720 (when (get-text-property (point) 'gnus-callback)
6721 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6722 ;; Go to the next (or previous) button.
6723 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
6724 ;; Put point at the start of the button.
6725 (when (and backward (not (get-text-property (point) 'gnus-callback)))
6726 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6727 ;; Skip past intangible buttons.
6728 (when (get-text-property (point) 'intangible)
6732 (gnus-message 5 "No more buttons"))
6735 (defun gnus-article-highlight (&optional force)
6736 "Highlight current article.
6737 This function calls `gnus-article-highlight-headers',
6738 `gnus-article-highlight-citation',
6739 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6740 do the highlighting. See the documentation for those functions."
6741 (interactive (list 'force))
6742 (gnus-article-highlight-headers)
6743 (gnus-article-highlight-citation force)
6744 (gnus-article-highlight-signature)
6745 (gnus-article-add-buttons force)
6746 (gnus-article-add-buttons-to-head))
6748 (defun gnus-article-highlight-some (&optional force)
6749 "Highlight current article.
6750 This function calls `gnus-article-highlight-headers',
6751 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6752 do the highlighting. See the documentation for those functions."
6753 (interactive (list 'force))
6754 (gnus-article-highlight-headers)
6755 (gnus-article-highlight-signature)
6756 (gnus-article-add-buttons))
6758 (defun gnus-article-highlight-headers ()
6759 "Highlight article headers as specified by `gnus-header-face-alist'."
6762 (set-buffer gnus-article-buffer)
6764 (let ((alist gnus-header-face-alist)
6765 (buffer-read-only nil)
6766 (case-fold-search t)
6767 (inhibit-point-motion-hooks t)
6768 entry regexp header-face field-face from hpoints fpoints)
6769 (article-narrow-to-head)
6770 (while (setq entry (pop alist))
6771 (goto-char (point-min))
6772 (setq regexp (concat "^\\("
6773 (if (string-equal "" (nth 0 entry))
6777 header-face (nth 1 entry)
6778 field-face (nth 2 entry))
6779 (while (and (re-search-forward regexp nil t)
6783 (unless (search-forward ":" nil t)
6785 (when (and header-face
6786 (not (memq (point) hpoints)))
6787 (push (point) hpoints)
6788 (gnus-put-text-property from (point) 'face header-face))
6789 (when (and field-face
6790 (not (memq (setq from (point)) fpoints)))
6792 (if (re-search-forward "^[^ \t]" nil t)
6794 (goto-char (point-max)))
6795 (gnus-put-text-property from (point) 'face field-face))))))))
6797 (defun gnus-article-highlight-signature ()
6798 "Highlight the signature in an article.
6799 It does this by highlighting everything after
6800 `gnus-signature-separator' using `gnus-signature-face'."
6802 (when gnus-signature-face
6804 (set-buffer gnus-article-buffer)
6805 (let ((buffer-read-only nil)
6806 (inhibit-point-motion-hooks t))
6808 (when (gnus-article-narrow-to-signature)
6809 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6810 'face gnus-signature-face)))))))
6812 (defun gnus-article-buttonize-signature ()
6813 "Add button to the signature."
6816 (set-buffer gnus-article-buffer)
6817 (let ((buffer-read-only nil)
6818 (inhibit-point-motion-hooks t))
6819 (when (gnus-article-search-signature)
6820 (gnus-article-add-button (match-beginning 0) (match-end 0)
6821 'gnus-signature-toggle
6822 (set-marker (make-marker)
6823 (1+ (match-end 0))))))))
6825 (defun gnus-button-in-region-p (b e prop)
6826 "Say whether PROP exists in the region."
6827 (text-property-not-all b e prop nil))
6829 (defun gnus-article-add-buttons (&optional force)
6830 "Find external references in the article and make buttons of them.
6831 \"External references\" are things like Message-IDs and URLs, as
6832 specified by `gnus-button-alist'."
6833 (interactive (list 'force))
6835 (set-buffer gnus-article-buffer)
6836 (let ((buffer-read-only nil)
6837 (inhibit-point-motion-hooks t)
6838 (case-fold-search t)
6839 (alist gnus-button-alist)
6841 ;; Remove all old markers.
6842 (let (marker entry new-list)
6843 (while (setq marker (pop gnus-button-marker-list))
6844 (if (or (< marker (point-min)) (>= marker (point-max)))
6845 (push marker new-list)
6847 (when (setq entry (gnus-button-entry))
6848 (put-text-property (match-beginning (nth 1 entry))
6849 (match-end (nth 1 entry))
6850 'gnus-callback nil))
6851 (set-marker marker nil)))
6852 (setq gnus-button-marker-list new-list))
6853 ;; We skip the headers.
6856 (while (setq entry (pop alist))
6857 (setq regexp (eval (car entry)))
6859 (while (re-search-forward regexp nil t)
6860 (let* ((start (and entry (match-beginning (nth 1 entry))))
6861 (end (and entry (match-end (nth 1 entry))))
6862 (from (match-beginning 0)))
6863 (when (and (or (eq t (nth 2 entry))
6864 (eval (nth 2 entry)))
6865 (not (gnus-button-in-region-p
6866 start end 'gnus-callback)))
6867 ;; That optional form returned non-nil, so we add the
6869 (gnus-article-add-button
6870 start end 'gnus-button-push
6871 (car (push (set-marker (make-marker) from)
6872 gnus-button-marker-list))))))))))
6874 ;; Add buttons to the head of an article.
6875 (defun gnus-article-add-buttons-to-head ()
6876 "Add buttons to the head of the article."
6879 (set-buffer gnus-article-buffer)
6881 (let ((buffer-read-only nil)
6882 (inhibit-point-motion-hooks t)
6883 (case-fold-search t)
6884 (alist gnus-header-button-alist)
6886 (article-narrow-to-head)
6888 ;; Each alist entry.
6889 (setq entry (car alist)
6891 (goto-char (point-min))
6892 (while (re-search-forward (car entry) nil t)
6893 ;; Each header matching the entry.
6894 (setq beg (match-beginning 0))
6895 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6896 (match-beginning 0))
6899 (while (re-search-forward (eval (nth 1 entry)) end t)
6900 ;; Each match within a header.
6901 (let* ((entry (cdr entry))
6902 (start (match-beginning (nth 1 entry)))
6903 (end (match-end (nth 1 entry)))
6904 (form (nth 2 entry)))
6905 (goto-char (match-end 0))
6907 (gnus-article-add-button
6908 start end (nth 3 entry)
6909 (buffer-substring (match-beginning (nth 4 entry))
6910 (match-end (nth 4 entry)))))))
6911 (goto-char end)))))))
6913 ;;; External functions:
6915 (defun gnus-article-add-button (from to fun &optional data)
6916 "Create a button between FROM and TO with callback FUN and data DATA."
6917 (when gnus-article-button-face
6918 (gnus-overlay-put (gnus-make-overlay from to)
6919 'face gnus-article-button-face))
6920 (gnus-add-text-properties
6922 (nconc (and gnus-article-mouse-face
6923 (list gnus-mouse-face-prop gnus-article-mouse-face))
6924 (list 'gnus-callback fun)
6925 (and data (list 'gnus-data data))))
6926 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6927 ;; Quote `:button-keymap' for Mule 2.3
6928 ;; but it won't work.
6929 ':button-keymap gnus-widget-button-keymap))
6931 ;;; Internal functions:
6933 (defun gnus-article-set-globals ()
6935 (set-buffer gnus-summary-buffer)
6936 (gnus-set-global-variables)))
6938 (defun gnus-signature-toggle (end)
6940 (set-buffer gnus-article-buffer)
6941 (let ((buffer-read-only nil)
6942 (inhibit-point-motion-hooks t)
6943 (limit (next-single-property-change end 'mime-view-entity
6945 (if (text-property-any end limit 'article-type 'signature)
6947 (gnus-delete-wash-type 'signature)
6948 (gnus-remove-text-properties-when
6949 'article-type 'signature end limit
6950 (cons 'article-type (cons 'signature
6951 gnus-hidden-properties))))
6952 (gnus-add-wash-type 'signature)
6953 (gnus-add-text-properties-when
6954 'article-type nil end limit
6955 (cons 'article-type (cons 'signature
6956 gnus-hidden-properties)))))
6957 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6958 (gnus-set-mode-line 'article))))
6960 (defun gnus-button-entry ()
6961 ;; Return the first entry in `gnus-button-alist' matching this place.
6962 (let ((alist gnus-button-alist)
6965 (setq entry (pop alist))
6966 (if (looking-at (eval (car entry)))
6971 (defun gnus-button-push (marker)
6972 ;; Push button starting at MARKER.
6975 (let* ((entry (gnus-button-entry))
6976 (inhibit-point-motion-hooks t)
6978 (args (mapcar (lambda (group)
6979 (let ((string (match-string group)))
6980 (gnus-set-text-properties
6981 0 (length string) nil string)
6988 (fboundp (symbol-value fun)))
6989 (apply (symbol-value fun) args))
6991 (gnus-message 1 "You must define `%S' to use this button"
6992 (cons fun args)))))))
6994 (defun gnus-parse-news-url (url)
6995 (let (scheme server group message-id articles)
6998 (goto-char (point-min))
6999 (when (looking-at "\\([A-Za-z]+\\):")
7000 (setq scheme (match-string 1))
7001 (goto-char (match-end 0)))
7002 (when (looking-at "//\\([^/]+\\)/")
7003 (setq server (match-string 1))
7004 (goto-char (match-end 0)))
7007 ((looking-at "\\(.*@.*\\)")
7008 (setq message-id (match-string 1)))
7009 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7010 (setq group (match-string 1)
7011 articles (split-string (match-string 2) "-")))
7012 ((looking-at "\\([^/]+\\)/?")
7013 (setq group (match-string 1)))
7015 (error "Unknown news URL syntax"))))
7016 (list scheme server group message-id articles)))
7018 (defun gnus-button-handle-news (url)
7020 (destructuring-bind (scheme server group message-id articles)
7021 (gnus-parse-news-url url)
7025 (set-buffer gnus-summary-buffer)
7027 (let ((gnus-refer-article-method (list (list 'nntp server))))
7028 (gnus-summary-refer-article message-id))
7029 (gnus-summary-refer-article message-id))))
7031 (gnus-button-fetch-group url)))))
7033 (defun gnus-button-handle-man (url)
7035 (funcall gnus-button-man-handler url))
7037 (defun gnus-button-handle-info-url (url)
7038 "Fetch an info URL."
7040 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
7041 (gnus-info-find-node
7042 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
7044 ")" (gnus-url-unhex-string (match-string 2 url)))))
7045 ((string-match "([^)\"]+)[^\"]+" url)
7047 (gnus-replace-in-string
7048 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
7049 (gnus-info-find-node url))
7050 (t (error "Can't parse %s" url))))
7052 (defun gnus-button-handle-info-keystrokes (url)
7053 "Call `info' when pushing the corresponding URL button."
7054 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
7059 (defun gnus-button-message-id (message-id)
7062 (set-buffer gnus-summary-buffer)
7063 (gnus-summary-refer-article message-id)))
7065 (defun gnus-button-fetch-group (address)
7066 "Fetch GROUP specified by ADDRESS."
7067 (if (not (string-match "[:/]" address))
7068 ;; This is just a simple group url.
7069 (gnus-group-read-ephemeral-group address gnus-select-method)
7072 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
7074 (error "Can't parse %s" address)
7075 (gnus-group-read-ephemeral-group
7076 (match-string 4 address)
7077 `(nntp ,(match-string 1 address)
7078 (nntp-address ,(match-string 1 address))
7079 (nntp-port-number ,(if (match-end 3)
7080 (match-string 3 address)
7083 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
7085 (defun gnus-url-parse-query-string (query &optional downcase)
7086 (let (retval pairs cur key val)
7087 (setq pairs (split-string query "&"))
7089 (setq cur (car pairs)
7091 (if (not (string-match "=" cur))
7093 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
7094 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
7096 (setq key (downcase key)))
7097 (setq cur (assoc key retval))
7099 (setcdr cur (cons val (cdr cur)))
7100 (setq retval (cons (list key val) retval)))))
7103 (defun gnus-url-mailto (url)
7104 ;; Send mail to someone
7105 (when (string-match "mailto:/*\\(.*\\)" url)
7106 (setq url (substring url (match-beginning 1) nil)))
7107 (let (to args subject func)
7108 (if (string-match (regexp-quote "?") url)
7109 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
7110 args (gnus-url-parse-query-string
7111 (substring url (match-end 0) nil) t))
7112 (setq to (gnus-url-unhex-string url)))
7113 (setq args (cons (list "to" to) args)
7114 subject (cdr-safe (assoc "subject" args)))
7117 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
7120 (message-position-on-field (caar args)))
7121 (insert (mapconcat 'identity (cdar args) ", "))
7122 (setq args (cdr args)))
7125 (message-goto-subject))))
7127 (defun gnus-button-embedded-url (address)
7128 "Activate ADDRESS with `browse-url'."
7129 (browse-url (gnus-strip-whitespace address)))
7131 ;;; Next/prev buttons in the article buffer.
7133 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
7134 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
7136 (defvar gnus-prev-page-map
7137 (let ((map (make-sparse-keymap)))
7138 (unless (>= emacs-major-version 21)
7139 ;; XEmacs doesn't care.
7140 (set-keymap-parent map gnus-article-mode-map))
7141 (define-key map gnus-mouse-2 'gnus-button-prev-page)
7142 (define-key map "\r" 'gnus-button-prev-page)
7145 (defun gnus-insert-prev-page-button ()
7147 (buffer-read-only nil)
7148 (situation (get-text-property (point-min) 'mime-view-situation)))
7150 gnus-prev-page-line-format nil
7151 `(,@(gnus-local-map-property gnus-prev-page-map)
7153 gnus-callback gnus-article-button-prev-page
7154 article-type annotation
7155 mime-view-situation ,situation))
7156 (widget-convert-button
7158 ;; Exclude a newline.
7161 :action 'gnus-button-prev-page
7162 :button-keymap gnus-prev-page-map)))
7164 (defvar gnus-next-page-map
7165 (let ((map (make-sparse-keymap)))
7166 (unless (>= emacs-major-version 21)
7167 ;; XEmacs doesn't care.
7168 (set-keymap-parent map gnus-article-mode-map))
7169 (define-key map gnus-mouse-2 'gnus-button-next-page)
7170 (define-key map "\r" 'gnus-button-next-page)
7173 (defun gnus-button-next-page (&optional args more-args)
7174 "Go to the next page."
7176 (let ((win (selected-window)))
7177 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7178 (gnus-article-next-page)
7179 (select-window win)))
7181 (defun gnus-button-prev-page (&optional args more-args)
7182 "Go to the prev page."
7184 (let ((win (selected-window)))
7185 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7186 (gnus-article-prev-page)
7187 (select-window win)))
7189 (defun gnus-insert-next-page-button ()
7191 (buffer-read-only nil)
7192 (situation (get-text-property (point-min) 'mime-view-situation)))
7193 (gnus-eval-format gnus-next-page-line-format nil
7194 `(,@(gnus-local-map-property gnus-next-page-map)
7196 gnus-callback gnus-article-button-next-page
7197 article-type annotation
7198 mime-view-situation ,situation))
7199 (widget-convert-button
7201 ;; Exclude a newline.
7204 :action 'gnus-button-next-page
7205 :button-keymap gnus-next-page-map)))
7207 (defun gnus-article-button-next-page (arg)
7208 "Go to the next page."
7210 (let ((win (selected-window)))
7211 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7212 (gnus-article-next-page)
7213 (select-window win)))
7215 (defun gnus-article-button-prev-page (arg)
7216 "Go to the prev page."
7218 (let ((win (selected-window)))
7219 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7220 (gnus-article-prev-page)
7221 (select-window win)))
7223 (defvar gnus-decode-header-methods
7224 '(mail-decode-encoded-word-region)
7225 "List of methods used to decode headers.
7227 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7228 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
7229 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
7230 whose names match REGEXP.
7233 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7234 mail-decode-encoded-word-region
7235 (\"chinese\" . rfc1843-decode-region))
7238 (defvar gnus-decode-header-methods-cache nil)
7240 (defun gnus-multi-decode-header (start end)
7241 "Apply the functions from `gnus-encoded-word-methods' that match."
7242 (unless (and gnus-decode-header-methods-cache
7243 (eq gnus-newsgroup-name
7244 (car gnus-decode-header-methods-cache)))
7245 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7248 (nconc gnus-decode-header-methods-cache (list x))
7249 (if (and gnus-newsgroup-name
7250 (string-match (car x) gnus-newsgroup-name))
7251 (nconc gnus-decode-header-methods-cache
7253 gnus-decode-header-methods))
7254 (let ((xlist gnus-decode-header-methods-cache))
7257 (narrow-to-region start end)
7259 (funcall (pop xlist) (point-min) (point-max))))))
7262 ;;; Treatment top-level handling.
7265 (defun gnus-treat-article (condition &optional part-number total-parts type)
7266 (let ((length (- (point-max) (point-min)))
7267 (alist gnus-treatment-function-alist)
7268 (article-goto-body-goes-to-point-min-p t)
7272 (let ((list gnus-article-treat-types))
7274 (when (string-match (pop list) type)
7275 (throw 'found t)))))))
7276 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7277 (entity (static-unless (featurep 'xemacs)
7278 (when (eq 'head condition)
7279 (get-text-property (point-min) 'mime-view-entity))))
7280 val elem buttonized)
7281 (gnus-run-hooks 'gnus-part-display-hook)
7282 (unless gnus-inhibit-treatment
7283 (dolist (elem alist)
7286 (when (gnus-buffer-live-p gnus-summary-buffer)
7287 (set-buffer gnus-summary-buffer))
7288 (symbol-value (car elem))))
7289 (when (and (or (consp val)
7291 (gnus-treat-predicate val)
7292 (or (not (get (car elem) 'highlight))
7294 (when (and (not buttonized)
7296 '(gnus-treat-hide-signature
7297 gnus-treat-highlight-signature)))
7298 (gnus-article-buttonize-signature)
7299 (setq buttonized t))
7301 (funcall (cadr elem)))))
7302 ;; FSF Emacsen does not inherit the existing text properties
7303 ;; in the new text, so we should do it for `mime-view-entity'.
7304 (static-unless (featurep 'xemacs)
7306 (put-text-property (point-min) (point-max)
7307 'mime-view-entity entity))))))
7309 ;; Dynamic variables.
7311 (defvar part-number)
7312 (defvar total-parts)
7317 (defun gnus-treat-predicate (val)
7322 (stringp (car val)))
7323 (apply 'gnus-or (mapcar `(lambda (s)
7324 (string-match s ,(or gnus-newsgroup-name "")))
7327 (let ((pred (pop val)))
7330 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7332 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7334 (not (gnus-treat-predicate (car val))))
7336 (equal (car val) type))
7338 (error "%S is not a valid predicate" pred)))))
7348 (eq part-number total-parts))
7352 (error "%S is not a valid value" val))))
7354 (defun gnus-article-encrypt-body (protocol &optional n)
7355 "Encrypt the article body."
7358 (or gnus-article-encrypt-protocol
7359 (completing-read "Encrypt protocol: "
7360 gnus-article-encrypt-protocol-alist
7362 current-prefix-arg))
7363 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7365 (error (format "Can't find the encrypt protocol %s" protocol)))
7366 (if (member gnus-newsgroup-name '("nndraft:delayed"
7369 (error "Can't encrypt the article in group %s"
7370 gnus-newsgroup-name))
7371 (gnus-summary-iterate n
7373 (set-buffer gnus-summary-buffer)
7374 (let ((mail-parse-charset gnus-newsgroup-charset)
7375 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7376 (summary-buffer gnus-summary-buffer)
7378 (gnus-set-global-variables)
7379 (when (gnus-group-read-only-p)
7380 (error "The current newsgroup does not support article encrypt"))
7381 (gnus-summary-show-article t)
7383 (or (mail-header-references gnus-current-headers) ""))
7384 (set-buffer gnus-article-buffer)
7385 (let* ((buffer-read-only nil)
7387 (mapcar (lambda (field)
7388 (and (save-restriction
7389 (message-narrow-to-head)
7390 (goto-char (point-min))
7391 (search-forward field nil t))
7393 (message-narrow-to-field)
7395 (delete-region (point-min) (point-max))
7397 '("Content-Type:" "Content-Transfer-Encoding:"
7398 "Content-Disposition:"))))
7399 (message-narrow-to-head)
7400 (message-remove-header "MIME-Version")
7401 (goto-char (point-max))
7402 (setq point (point))
7403 (insert (apply 'concat headers))
7405 (narrow-to-region point (point-max))
7406 (let ((message-options message-options))
7407 (message-options-set 'message-sender user-mail-address)
7408 (message-options-set 'message-recipients user-mail-address)
7409 (message-options-set 'message-sign-encrypt 'not)
7411 (goto-char (point-min))
7412 (insert "MIME-Version: 1.0\n")
7414 (gnus-summary-edit-article-done
7415 references nil summary-buffer t))
7416 (when gnus-keep-backlog
7417 (gnus-backlog-remove-article
7418 (car gnus-article-current) (cdr gnus-article-current)))
7420 (when (get-buffer gnus-original-article-buffer)
7421 (set-buffer gnus-original-article-buffer)
7422 (setq gnus-original-article nil)))
7423 (when gnus-use-cache
7424 (gnus-cache-update-article
7425 (car gnus-article-current) (cdr gnus-article-current))))))))
7427 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7428 "The following specs can be used:
7429 %t The security MIME type
7432 %D Details if button is pressed")
7434 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7435 "The following specs can be used:
7436 %t The security MIME type
7439 %D Details if button is pressed")
7441 (defvar gnus-mime-security-button-line-format-alist
7442 '((?t gnus-tmp-type ?s)
7443 (?i gnus-tmp-info ?s)
7444 (?d gnus-tmp-details ?s)
7445 (?D gnus-tmp-pressed-details ?s)))
7447 (defvar gnus-mime-security-button-map
7448 (let ((map (make-sparse-keymap)))
7449 (unless (>= (string-to-number emacs-version) 21)
7450 (set-keymap-parent map gnus-article-mode-map))
7451 (define-key map gnus-mouse-2 'gnus-article-push-button)
7452 (define-key map "\r" 'gnus-article-press-button)
7455 (defvar gnus-mime-security-details-buffer nil)
7457 (defvar gnus-mime-security-button-pressed nil)
7459 (defvar gnus-mime-security-show-details-inline t
7460 "If non-nil, show details in the article buffer.")
7462 (defun gnus-mime-security-verify-or-decrypt (handle)
7463 (mm-remove-parts (cdr handle))
7464 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7465 point buffer-read-only)
7467 (goto-char (car region)))
7469 (narrow-to-region (point) (point))
7470 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7471 (let* ((mm-verify-option 'known)
7472 (mm-decrypt-option 'known)
7473 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7474 (unless (eq nparts (cdr handle))
7475 (mm-destroy-parts (cdr handle))
7476 (setcdr handle nparts))))
7477 (setq point (point))
7478 (gnus-mime-display-security handle)
7479 (goto-char (point-max)))
7481 (delete-region (point) (cdr region))
7482 (set-marker (car region) nil)
7483 (set-marker (cdr region) nil))
7486 (defun gnus-mime-security-show-details (handle)
7487 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7489 (gnus-message 5 "No details.")
7490 (if gnus-mime-security-show-details-inline
7491 (let ((gnus-mime-security-button-pressed
7492 (not (get-text-property (point) 'gnus-mime-details)))
7493 (gnus-mime-security-button-line-format
7494 (get-text-property (point) 'gnus-line-format))
7497 (while (eq (get-text-property (point) 'gnus-line-format)
7498 gnus-mime-security-button-line-format)
7502 (narrow-to-region (point) (point))
7503 (gnus-insert-mime-security-button handle))
7504 (delete-region (point)
7505 (or (text-property-not-all
7508 gnus-mime-security-button-line-format)
7511 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7512 (with-current-buffer gnus-mime-security-details-buffer
7515 (setq gnus-mime-security-details-buffer
7516 (gnus-get-buffer-create "*MIME Security Details*")))
7517 (with-current-buffer gnus-mime-security-details-buffer
7519 (goto-char (point-min)))
7520 (pop-to-buffer gnus-mime-security-details-buffer)))))
7522 (defun gnus-mime-security-press-button (handle)
7524 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7525 (gnus-mime-security-show-details handle)
7526 (gnus-mime-security-verify-or-decrypt handle))))
7528 (defun gnus-insert-mime-security-button (handle &optional displayed)
7529 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7532 (or (nth 2 (assoc protocol mm-verify-function-alist))
7533 (nth 2 (assoc protocol mm-decrypt-function-alist))
7535 (if (equal (car handle) "multipart/signed")
7536 " Signed" " Encrypted")
7539 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7542 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7543 gnus-tmp-pressed-details
7545 (setq gnus-tmp-details
7546 (if gnus-tmp-details
7547 (concat "\n" gnus-tmp-details)
7549 (setq gnus-tmp-pressed-details
7550 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7555 gnus-mime-security-button-line-format
7556 gnus-mime-security-button-line-format-alist
7557 `(,@(gnus-local-map-property gnus-mime-security-button-map)
7558 gnus-callback gnus-mime-security-press-button
7559 gnus-line-format ,gnus-mime-security-button-line-format
7560 gnus-mime-details ,gnus-mime-security-button-pressed
7561 article-type annotation
7564 ;; Exclude a newline.
7567 (widget-convert-button
7570 :action 'gnus-widget-press-button
7571 :button-keymap gnus-mime-security-button-map
7573 (lambda (widget/window &optional overlay pos)
7574 ;; Needed to properly clear the message due to a bug in
7575 ;; wid-edit (XEmacs only).
7576 (when (boundp 'help-echo-owns-message)
7577 (setq help-echo-owns-message t))
7580 (aref gnus-mouse-2 0))))))
7582 (defun gnus-mime-display-security (handle)
7584 (narrow-to-region (point) (point))
7585 (unless (gnus-unbuttonized-mime-type-p (car handle))
7586 (gnus-insert-mime-security-button handle))
7587 (gnus-mime-display-mixed (cdr handle))
7590 (unless (gnus-unbuttonized-mime-type-p (car handle))
7591 (let ((gnus-mime-security-button-line-format
7592 gnus-mime-security-button-end-line-format))
7593 (gnus-insert-mime-security-button handle)))
7594 (mm-set-handle-multipart-parameter
7596 (cons (set-marker (make-marker) (point-min))
7597 (set-marker (make-marker) (point-max))))))
7603 (defun gnus-article-header-presentation-method (entity situation)
7604 (mime-insert-header entity)
7605 (article-decode-group-name))
7607 (set-alist 'mime-header-presentation-method-alist
7608 'gnus-original-article-mode
7609 #'gnus-article-header-presentation-method)
7611 (defun gnus-mime-preview-quitting-method ()
7612 (mime-preview-kill-buffer)
7613 (delete-other-windows)
7614 (gnus-article-show-summary)
7615 (gnus-summary-select-article gnus-show-all-headers t))
7617 (set-alist 'mime-preview-quitting-method-alist
7618 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
7620 (set-alist 'mime-preview-following-method-alist
7621 'gnus-original-article-mode #'gnus-following-method)
7623 (set-alist 'mime-preview-over-to-previous-method-alist
7624 'gnus-original-article-mode
7626 (if (> (point-min) 1)
7627 (gnus-article-prev-page)
7628 (gnus-article-read-summary-keys
7629 nil (gnus-character-to-event ?P)))))
7631 (set-alist 'mime-preview-over-to-next-method-alist
7632 'gnus-original-article-mode'
7634 (if (< (point-max) (buffer-size))
7635 (gnus-article-next-page)
7636 (gnus-article-read-summary-keys
7637 nil (gnus-character-to-event ?N)))))
7647 (run-hooks 'gnus-art-load-hook)
7649 ;;; gnus-art.el ends here