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" "X-Gpg-.*" "X-Disclaimer"))
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 (make-obsolete-variable 'gnus-treat-display-xface
1202 'gnus-treat-display-x-face)
1204 (defcustom gnus-treat-display-x-face
1205 (and (not noninteractive)
1206 (or (memq gnus-article-x-face-command
1207 '(x-face-decode-message-header
1208 x-face-mule-gnus-article-display-x-face))
1209 (and (fboundp 'image-type-available-p)
1210 (image-type-available-p 'xbm)
1211 (string-match "^0x" (shell-command-to-string "uncompface"))
1212 (executable-find "icontopbm"))
1213 (and (featurep 'xemacs)
1216 "Display X-Face headers.
1217 Valid values are nil, t, `head', `last', an integer or a predicate.
1218 See Info node `(gnus)Customizing Articles' and Info node
1219 `(gnus)X-Face' for details."
1220 :group 'gnus-article-treat
1222 :link '(custom-manual "(gnus)Customizing Articles")
1223 :link '(custom-manual "(gnus)X-Face")
1224 :type gnus-article-treat-head-custom
1225 :set (lambda (symbol value)
1228 (cond ((or (boundp symbol) (get symbol 'saved-value))
1230 ((boundp 'gnus-treat-display-xface)
1232 ** gnus-treat-display-xface is an obsolete variable;\
1233 use gnus-treat-display-x-face instead")
1234 (default-value 'gnus-treat-display-xface))
1235 ((get 'gnus-treat-display-xface 'saved-value)
1237 ** gnus-treat-display-xface is an obsolete variable;\
1238 use gnus-treat-display-x-face instead")
1239 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1242 (put 'gnus-treat-display-x-face 'highlight t)
1244 (defcustom gnus-article-should-use-smiley-mule
1245 (not (or (featurep 'xemacs)
1246 (gnus-image-type-available-p 'xpm)
1247 (gnus-image-type-available-p 'pbm)))
1248 "If non-nil, gnus uses `smiley-mule' for displaying smileys rather than
1249 `smiley'. It defaults to t when Emacs 20 or earlier is running.
1250 `smiley-mule' is boundled in BITMAP-MULE package. You can set it to t
1251 even if you are using Emacs 21+. It has no effect on XEmacs."
1252 :group 'gnus-article-various
1254 :get (lambda (symbol)
1255 (and (not noninteractive)
1256 (default-value symbol)
1257 (not (featurep 'xemacs))
1258 (module-installed-p 'smiley-mule)
1260 :set (lambda (symbol value)
1261 (set-default symbol (and (not noninteractive)
1263 (not (featurep 'xemacs))
1264 (module-installed-p 'smiley-mule)
1267 (defvar gnus-article-smiley-mule-loaded-p nil
1268 "Internal variable used to say whether `smiley-mule' is loaded (whether
1269 smiley functions are not overridden by `smiley').")
1271 (defcustom gnus-treat-display-face
1272 (and (not noninteractive)
1273 ;; x-face-e21 handles both X-Face and Face headers.
1274 (not (and (eq gnus-article-x-face-command 'x-face-decode-message-header)
1275 (module-installed-p 'x-face-e21)))
1276 (or (and (fboundp 'image-type-available-p)
1277 (image-type-available-p 'png))
1278 (and (featurep 'xemacs)
1281 "Display Face headers.
1282 Valid values are nil, t, `head', `last', an integer or a predicate.
1283 See Info node `(gnus)Customizing Articles' and Info node
1284 `(gnus)X-Face' for details."
1285 :group 'gnus-article-treat
1287 :link '(custom-manual "(gnus)Customizing Articles")
1288 :link '(custom-manual "(gnus)X-Face")
1289 :type gnus-article-treat-head-custom)
1290 (put 'gnus-treat-display-face 'highlight t)
1292 (defcustom gnus-treat-display-smileys
1293 (if (and (not noninteractive)
1294 (or (and (featurep 'xemacs)
1296 (gnus-image-type-available-p 'xpm)
1297 (gnus-image-type-available-p 'pbm)
1298 (and (not (featurep 'xemacs))
1300 (module-installed-p 'smiley-mule))))
1304 Valid values are nil, t, `head', `last', an integer or a predicate.
1305 See Info node `(gnus)Customizing Articles' and Info node
1306 `(gnus)Smileys' for details."
1307 :group 'gnus-article-treat
1309 :link '(custom-manual "(gnus)Customizing Articles")
1310 :link '(custom-manual "(gnus)Smileys")
1311 :type gnus-article-treat-custom)
1312 (put 'gnus-treat-display-smileys 'highlight t)
1314 (defcustom gnus-treat-from-picon
1315 (if (and (gnus-image-type-available-p 'xpm)
1316 (gnus-picons-installed-p))
1318 "Display picons in the From header.
1319 Valid values are nil, t, `head', `last', an integer or a predicate.
1320 See Info node `(gnus)Customizing Articles' and Info node
1321 `(gnus)Picons' for details."
1322 :group 'gnus-article-treat
1324 :link '(custom-manual "(gnus)Customizing Articles")
1325 :link '(custom-manual "(gnus)Picons")
1326 :type gnus-article-treat-head-custom)
1327 (put 'gnus-treat-from-picon 'highlight t)
1329 (defcustom gnus-treat-mail-picon
1330 (if (and (gnus-image-type-available-p 'xpm)
1331 (gnus-picons-installed-p))
1333 "Display picons in To and Cc headers.
1334 Valid values are nil, t, `head', `last', an integer or a predicate.
1335 See Info node `(gnus)Customizing Articles' and Info node
1336 `(gnus)Picons' for details."
1337 :group 'gnus-article-treat
1339 :link '(custom-manual "(gnus)Customizing Articles")
1340 :link '(custom-manual "(gnus)Picons")
1341 :type gnus-article-treat-head-custom)
1342 (put 'gnus-treat-mail-picon 'highlight t)
1344 (defcustom gnus-treat-newsgroups-picon
1345 (if (and (gnus-image-type-available-p 'xpm)
1346 (gnus-picons-installed-p))
1348 "Display picons in the Newsgroups and Followup-To headers.
1349 Valid values are nil, t, `head', `last', an integer or a predicate.
1350 See Info node `(gnus)Customizing Articles' and Info node
1351 `(gnus)Picons' for details."
1352 :group 'gnus-article-treat
1354 :link '(custom-manual "(gnus)Customizing Articles")
1355 :link '(custom-manual "(gnus)Picons")
1356 :type gnus-article-treat-head-custom)
1357 (put 'gnus-treat-newsgroups-picon 'highlight t)
1359 (defcustom gnus-treat-body-boundary
1360 (if (or gnus-treat-newsgroups-picon
1361 gnus-treat-mail-picon
1362 gnus-treat-from-picon)
1364 "Draw a boundary at the end of the headers.
1365 Valid values are nil, t, `head', `last', an integer or a predicate.
1366 See Info node `(gnus)Customizing Articles' for details."
1368 :group 'gnus-article-treat
1369 :link '(custom-manual "(gnus)Customizing Articles")
1370 :type gnus-article-treat-custom)
1372 (defcustom gnus-treat-capitalize-sentences nil
1373 "Capitalize sentence-starting words.
1374 Valid values are nil, t, `head', `last', an integer or a predicate.
1375 See Info node `(gnus)Customizing Articles' for details."
1377 :group 'gnus-article-treat
1378 :link '(custom-manual "(gnus)Customizing Articles")
1379 :type gnus-article-treat-custom)
1381 (defcustom gnus-treat-wash-html nil
1383 Valid values are nil, t, `head', `last', an integer or a predicate.
1384 See Info node `(gnus)Customizing Articles' for details."
1385 :group 'gnus-article-treat
1386 :link '(custom-manual "(gnus)Customizing Articles")
1387 :type gnus-article-treat-custom)
1389 (defcustom gnus-treat-fill-long-lines nil
1391 Valid values are nil, t, `head', `last', an integer or a predicate.
1392 See Info node `(gnus)Customizing Articles' for details."
1393 :group 'gnus-article-treat
1394 :link '(custom-manual "(gnus)Customizing Articles")
1395 :type gnus-article-treat-custom)
1397 (defcustom gnus-treat-play-sounds nil
1399 Valid values are nil, t, `head', `last', an integer or a predicate.
1400 See Info node `(gnus)Customizing Articles' for details."
1402 :group 'gnus-article-treat
1403 :link '(custom-manual "(gnus)Customizing Articles")
1404 :type gnus-article-treat-custom)
1406 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
1407 "Decode an article as `default-mime-charset'. For instance, if you want to
1408 attempt to decode an article even if the value of `gnus-show-mime' is nil,
1409 you could set this variable to something like: nil for don't decode, t for
1410 decode the body, '(or header t) for the whole article, etc."
1411 :group 'gnus-article-treat
1412 :type '(radio (const :tag "Off" nil)
1413 (const :tag "Decode body" t)
1414 (const :tag "Decode all" (or head t))))
1416 (defcustom gnus-treat-translate nil
1417 "Translate articles from one language to another.
1418 Valid values are nil, t, `head', `last', an integer or a predicate.
1419 See Info node `(gnus)Customizing Articles' for details."
1421 :group 'gnus-article-treat
1422 :link '(custom-manual "(gnus)Customizing Articles")
1423 :type gnus-article-treat-custom)
1425 (defcustom gnus-treat-x-pgp-sig nil
1427 To automatically treat X-PGP-Sig, set it to head.
1428 Valid values are nil, t, `head', `last', an integer or a predicate.
1429 See Info node `(gnus)Customizing Articles' for details."
1430 :group 'gnus-article-treat
1431 :group 'mime-security
1432 :type gnus-article-treat-custom)
1434 (defcustom gnus-treat-monafy nil
1435 "Display body part with mona font.
1436 Valid values are nil, t, `head', `last', an integer or a predicate.
1437 See Info node `(gnus)Customizing Articles' for details."
1438 :group 'gnus-article-treat
1439 :group 'mime-security
1440 :link '(custom-manual "(gnus)Customizing Articles")
1441 :type gnus-article-treat-custom)
1443 (defvar gnus-article-encrypt-protocol-alist
1444 '(("PGP" . mml2015-self-encrypt)))
1446 ;; Set to nil if more than one protocol added to
1447 ;; gnus-article-encrypt-protocol-alist.
1448 (defcustom gnus-article-encrypt-protocol "PGP"
1449 "The protocol used for encrypt articles.
1450 It is a string, such as \"PGP\". If nil, ask user."
1452 :group 'mime-security)
1454 (defvar gnus-article-wash-function nil
1455 "Function used for converting HTML into text.")
1457 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1458 (mm-coding-system-p 'utf-8)
1459 (executable-find idna-program))
1460 "Whether IDNA decoding of headers is used when viewing messages.
1461 This requires GNU Libidn, and by default only enabled if it is found."
1462 :group 'gnus-article-headers
1465 (defcustom gnus-article-over-scroll nil
1466 "If non-nil, allow scrolling the article buffer even when there no more text."
1467 :group 'gnus-article
1470 ;;; Internal variables
1472 (defvar gnus-english-month-names
1473 '("January" "February" "March" "April" "May" "June" "July" "August"
1474 "September" "October" "November" "December"))
1476 (defvar article-goto-body-goes-to-point-min-p nil)
1477 (defvar gnus-article-wash-types nil)
1478 (defvar gnus-article-emphasis-alist nil)
1479 (defvar gnus-article-image-alist nil)
1481 (defvar gnus-article-mime-handle-alist-1 nil)
1482 (defvar gnus-treatment-function-alist
1483 '((gnus-treat-decode-article-as-default-mime-charset
1484 gnus-article-decode-article-as-default-mime-charset)
1485 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1486 (gnus-treat-monafy gnus-article-monafy)
1487 (gnus-treat-strip-banner gnus-article-strip-banner)
1488 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1489 (gnus-treat-buttonize gnus-article-add-buttons)
1490 (gnus-treat-fill-article gnus-article-fill-cited-article)
1491 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1492 (gnus-treat-strip-cr gnus-article-remove-cr)
1493 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1494 (gnus-treat-date-ut gnus-article-date-ut)
1495 (gnus-treat-date-local gnus-article-date-local)
1496 (gnus-treat-date-english gnus-article-date-english)
1497 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1498 (gnus-treat-date-original gnus-article-date-original)
1499 (gnus-treat-date-user-defined gnus-article-date-user)
1500 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1501 (gnus-treat-display-face gnus-article-display-face)
1502 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1503 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1504 (gnus-treat-hide-signature gnus-article-hide-signature)
1505 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1506 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1507 (gnus-treat-strip-pem gnus-article-hide-pem)
1508 (gnus-treat-from-picon gnus-treat-from-picon)
1509 (gnus-treat-mail-picon gnus-treat-mail-picon)
1510 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1511 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1512 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1513 (gnus-treat-strip-trailing-blank-lines
1514 gnus-article-remove-trailing-blank-lines)
1515 (gnus-treat-strip-leading-blank-lines
1516 gnus-article-strip-leading-blank-lines)
1517 (gnus-treat-strip-multiple-blank-lines
1518 gnus-article-strip-multiple-blank-lines)
1519 (gnus-treat-overstrike gnus-article-treat-overstrike)
1520 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1521 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1522 ;; Displaying X-Face should be done after unfolding headers
1523 ;; to protect bitmap lines.
1524 (gnus-treat-display-x-face gnus-article-display-x-face)
1525 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1526 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1527 (gnus-treat-display-smileys gnus-treat-smiley)
1528 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1529 (gnus-treat-wash-html gnus-article-wash-html)
1530 (gnus-treat-emphasize gnus-article-emphasize)
1531 (gnus-treat-hide-citation gnus-article-hide-citation)
1532 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1533 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1534 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1535 (gnus-treat-play-sounds gnus-earcon-display)))
1537 (defvar gnus-article-mime-handle-alist nil)
1538 (defvar article-lapsed-timer nil)
1539 (defvar gnus-article-current-summary nil)
1541 (defvar gnus-article-mode-syntax-table
1542 (let ((table (copy-syntax-table text-mode-syntax-table)))
1543 ;; This causes the citation match run O(2^n).
1544 ;; (modify-syntax-entry ?- "w" table)
1545 (modify-syntax-entry ?> ")<" table)
1546 (modify-syntax-entry ?< "(>" table)
1547 ;; make M-. in article buffers work for `foo' strings
1548 (modify-syntax-entry ?' " " table)
1549 (modify-syntax-entry ?` " " table)
1551 "Syntax table used in article mode buffers.
1552 Initialized from `text-mode-syntax-table.")
1554 (defvar gnus-save-article-buffer nil)
1556 (defvar gnus-article-mode-line-format-alist
1557 (nconc '((?w (gnus-article-wash-status) ?s)
1558 (?m (gnus-article-mime-part-status) ?s))
1559 gnus-summary-mode-line-format-alist))
1561 (defvar gnus-number-of-articles-to-be-saved nil)
1563 (defvar gnus-inhibit-hiding nil)
1565 ;;; Macros for dealing with the article buffer.
1567 (defmacro gnus-with-article-headers (&rest forms)
1569 (set-buffer gnus-article-buffer)
1571 (let ((buffer-read-only nil)
1572 (inhibit-point-motion-hooks t)
1573 (case-fold-search t))
1574 (article-narrow-to-head)
1577 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1578 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1580 (defmacro gnus-with-article-buffer (&rest forms)
1582 (set-buffer gnus-article-buffer)
1583 (let ((buffer-read-only nil))
1586 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1587 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1589 (defun gnus-article-goto-header (header)
1590 "Go to HEADER, which is a regular expression."
1591 (re-search-forward (concat "^\\(" header "\\):") nil t))
1593 (defsubst gnus-article-hide-text (b e props)
1594 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1595 (gnus-add-text-properties-when 'article-type nil b e props)
1596 (when (memq 'intangible props)
1598 (max (1- b) (point-min))
1599 b 'intangible (cddr (memq 'intangible props)))))
1601 (defsubst gnus-article-unhide-text (b e)
1602 "Remove hidden text properties from region between B and E."
1603 (remove-text-properties b e gnus-hidden-properties)
1604 (when (memq 'intangible gnus-hidden-properties)
1605 (put-text-property (max (1- b) (point-min))
1606 b 'intangible nil)))
1608 (defun gnus-article-hide-text-type (b e type)
1609 "Hide text of TYPE between B and E."
1610 (gnus-add-wash-type type)
1611 (gnus-article-hide-text
1612 b e (cons 'article-type (cons type gnus-hidden-properties))))
1614 (defun gnus-article-unhide-text-type (b e type)
1615 "Unhide text of TYPE between B and E."
1616 (gnus-delete-wash-type type)
1617 (remove-text-properties
1618 b e (cons 'article-type (cons type gnus-hidden-properties)))
1619 (when (memq 'intangible gnus-hidden-properties)
1620 (put-text-property (max (1- b) (point-min))
1621 b 'intangible nil)))
1623 (defun gnus-article-hide-text-of-type (type)
1624 "Hide text of TYPE in the current buffer."
1626 (let ((b (point-min))
1628 (while (setq b (text-property-any b e 'article-type type))
1629 (add-text-properties b (incf b) gnus-hidden-properties)))))
1631 (defun gnus-article-delete-text-of-type (type)
1632 "Delete text of TYPE in the current buffer."
1634 (let ((b (point-min)))
1635 (while (setq b (text-property-any b (point-max) 'article-type type))
1637 b (or (text-property-not-all b (point-max) 'article-type type)
1640 (defun gnus-article-delete-invisible-text ()
1641 "Delete all invisible text in the current buffer."
1643 (let ((b (point-min)))
1644 (while (setq b (text-property-any b (point-max) 'invisible t))
1646 b (or (text-property-not-all b (point-max) 'invisible t)
1649 (defun gnus-article-text-type-exists-p (type)
1650 "Say whether any text of type TYPE exists in the buffer."
1651 (text-property-any (point-min) (point-max) 'article-type type))
1653 (defsubst gnus-article-header-rank ()
1654 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1655 (let ((list gnus-sorted-header-list)
1658 (if (looking-at (car list))
1660 (setq list (cdr list))
1664 (defun article-hide-headers (&optional arg delete)
1665 "Hide unwanted headers and possibly sort them as well."
1666 (interactive (gnus-article-hidden-arg))
1667 ;; Lars said that this function might be inhibited.
1668 (if (gnus-article-check-hidden-text 'headers arg)
1670 ;; Show boring headers as well.
1671 (gnus-article-show-hidden-text 'boring-headers)
1672 (when (eq 1 (point-min))
1673 (set-window-start (get-buffer-window (current-buffer)) 1)))
1674 (unless gnus-inhibit-hiding
1677 (let ((inhibit-read-only t)
1678 (case-fold-search t)
1679 (max (1+ (length gnus-sorted-header-list)))
1680 (ignored (when (not gnus-visible-headers)
1681 (cond ((stringp gnus-ignored-headers)
1682 gnus-ignored-headers)
1683 ((listp gnus-ignored-headers)
1684 (mapconcat 'identity gnus-ignored-headers
1687 (cond ((stringp gnus-visible-headers)
1688 gnus-visible-headers)
1689 ((and gnus-visible-headers
1690 (listp gnus-visible-headers))
1691 (mapconcat 'identity gnus-visible-headers "\\|"))))
1692 (inhibit-point-motion-hooks t)
1694 ;; First we narrow to just the headers.
1695 (article-narrow-to-head)
1696 ;; Hide any "From " lines at the beginning of (mail) articles.
1697 (while (looking-at "From ")
1701 (delete-region (point-min) (point))
1702 (gnus-article-hide-text (point-min) (point)
1703 (nconc (list 'article-type 'headers)
1704 gnus-hidden-properties))))
1705 ;; Then treat the rest of the header lines.
1706 ;; Then we use the two regular expressions
1707 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1708 ;; select which header lines is to remain visible in the
1710 (while (re-search-forward "^[^ \t:]*:" nil t)
1712 ;; Mark the rank of the header.
1714 (point) (1+ (point)) 'message-rank
1715 (if (or (and visible (looking-at visible))
1717 (not (looking-at ignored))))
1718 (gnus-article-header-rank)
1721 (message-sort-headers-1)
1722 (when (setq beg (text-property-any
1723 (point-min) (point-max) 'message-rank (+ 2 max)))
1724 ;; We delete or make invisible the unwanted headers.
1725 (gnus-add-wash-type 'headers)
1728 (add-text-properties
1729 (point-min) (+ 5 (point-min))
1730 '(article-type headers dummy-invisible t))
1731 (delete-region beg (point-max)))
1732 (gnus-article-hide-text-type beg (point-max) 'headers)))))))))
1734 (defun article-hide-boring-headers (&optional arg)
1735 "Toggle hiding of headers that aren't very interesting.
1736 If given a negative prefix, always show; if given a positive prefix,
1738 (interactive (gnus-article-hidden-arg))
1739 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1740 (not gnus-show-all-headers))
1743 (let ((buffer-read-only nil)
1744 (list gnus-boring-article-headers)
1745 (inhibit-point-motion-hooks t)
1747 (article-narrow-to-head)
1749 (setq elem (pop list))
1750 (goto-char (point-min))
1752 ;; Hide empty headers.
1754 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1756 (gnus-article-hide-text-type
1760 (if (re-search-forward "^[^ \t]" nil t)
1764 ;; Hide boring Newsgroups header.
1765 ((eq elem 'newsgroups)
1766 (when (gnus-string-equal
1767 (gnus-fetch-field "newsgroups")
1768 (gnus-group-real-name
1769 (if (boundp 'gnus-newsgroup-name)
1772 (gnus-article-hide-header "newsgroups")))
1773 ((eq elem 'to-address)
1774 (let ((to (message-fetch-field "to"))
1776 (gnus-parameter-to-address
1777 (if (boundp 'gnus-newsgroup-name)
1778 gnus-newsgroup-name ""))))
1779 (when (and to to-address
1782 ;; only one address in To
1783 (nth 1 (mail-extract-address-components to))
1785 (gnus-article-hide-header "to"))))
1787 (let ((to (message-fetch-field "to"))
1789 (gnus-parameter-to-list
1790 (if (boundp 'gnus-newsgroup-name)
1791 gnus-newsgroup-name ""))))
1792 (when (and to to-list
1795 ;; only one address in To
1796 (nth 1 (mail-extract-address-components to))
1798 (gnus-article-hide-header "to"))))
1800 (let ((cc (message-fetch-field "cc"))
1802 (gnus-parameter-to-list
1803 (if (boundp 'gnus-newsgroup-name)
1804 gnus-newsgroup-name ""))))
1805 (when (and cc to-list
1808 ;; only one address in CC
1809 (nth 1 (mail-extract-address-components cc))
1811 (gnus-article-hide-header "cc"))))
1812 ((eq elem 'followup-to)
1813 (when (gnus-string-equal
1814 (message-fetch-field "followup-to")
1815 (message-fetch-field "newsgroups"))
1816 (gnus-article-hide-header "followup-to")))
1817 ((eq elem 'reply-to)
1818 (if (gnus-group-find-parameter
1819 gnus-newsgroup-name 'broken-reply-to)
1820 (gnus-article-hide-header "reply-to")
1821 (let ((from (message-fetch-field "from"))
1822 (reply-to (message-fetch-field "reply-to")))
1827 (nth 1 (mail-extract-address-components from))
1828 (nth 1 (mail-extract-address-components reply-to)))))
1829 (gnus-article-hide-header "reply-to")))))
1831 (let ((date (message-fetch-field "date")))
1833 (< (days-between (current-time-string) date)
1835 (gnus-article-hide-header "date"))))
1837 (let ((to (message-fetch-field "to"))
1838 (cc (message-fetch-field "cc")))
1839 (when (> (length to) 1024)
1840 (gnus-article-hide-header "to"))
1841 (when (> (length cc) 1024)
1842 (gnus-article-hide-header "cc"))))
1846 (goto-char (point-min))
1847 (while (re-search-forward "^to:" nil t)
1848 (setq to-count (1+ to-count)))
1849 (when (> to-count 1)
1850 (while (> to-count 0)
1851 (goto-char (point-min))
1853 (re-search-forward "^to:" nil nil to-count)
1855 (narrow-to-region (point) (point-max))
1856 (gnus-article-hide-header "to"))
1857 (setq to-count (1- to-count))))
1858 (goto-char (point-min))
1859 (while (re-search-forward "^cc:" nil t)
1860 (setq cc-count (1+ cc-count)))
1861 (when (> cc-count 1)
1862 (while (> cc-count 0)
1863 (goto-char (point-min))
1865 (re-search-forward "^cc:" nil nil cc-count)
1867 (narrow-to-region (point) (point-max))
1868 (gnus-article-hide-header "cc"))
1869 (setq cc-count (1- cc-count)))))))))))))
1871 (defun gnus-article-hide-header (header)
1873 (goto-char (point-min))
1874 (when (re-search-forward (concat "^" header ":") nil t)
1875 (gnus-article-hide-text-type
1879 (if (re-search-forward "^[^ \t]" nil t)
1884 (defvar gnus-article-normalized-header-length 40
1885 "Length of normalized headers.")
1887 (defun article-normalize-headers ()
1888 "Make all header lines 40 characters long."
1890 (let ((buffer-read-only nil)
1894 (article-narrow-to-head)
1897 ((< (setq column (- (gnus-point-at-eol) (point)))
1898 gnus-article-normalized-header-length)
1900 (insert (make-string
1901 (- gnus-article-normalized-header-length column)
1903 ((> column gnus-article-normalized-header-length)
1904 (gnus-put-text-property
1906 (forward-char gnus-article-normalized-header-length)
1913 (forward-line 1))))))
1915 (defun article-treat-dumbquotes ()
1916 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
1917 Note that this function guesses whether a character is a sm*rtq**t* or
1918 not, so it should only be used interactively.
1920 Sm*rtq**t*s are M****s***'s unilateral extension to the
1921 iso-8859-1 character map in an attempt to provide more quoting
1922 characters. If you see something like \\222 or \\264 where
1923 you're expecting some kind of apostrophe or quotation mark, then
1926 (article-translate-strings gnus-article-dumbquotes-map))
1928 (defun article-translate-characters (from to)
1929 "Translate all characters in the body of the article according to FROM and TO.
1930 FROM is a string of characters to translate from; to is a string of
1931 characters to translate to."
1933 (when (article-goto-body)
1934 (let ((buffer-read-only nil)
1935 (x (make-string 225 ?x))
1937 (while (< (incf i) (length x))
1940 (while (< i (length from))
1941 (aset x (aref from i) (aref to i))
1943 (translate-region (point) (point-max) x)))))
1945 (defun article-translate-strings (map)
1946 "Translate all string in the body of the article according to MAP.
1947 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1949 (when (article-goto-body)
1950 (let ((buffer-read-only nil)
1952 (while (setq elem (pop map))
1954 (while (search-forward (car elem) nil t)
1955 (replace-match (cadr elem)))))))))
1957 (defun article-treat-overstrike ()
1958 "Translate overstrikes into bold text."
1961 (when (article-goto-body)
1962 (let ((buffer-read-only nil))
1963 (while (search-forward "\b" nil t)
1964 (let ((next (char-after))
1968 previous (char-after))
1972 ;; We do the boldification/underlining by hiding the
1973 ;; overstrikes and putting the proper text property
1977 (gnus-article-hide-text-type start (point) 'overstrike)
1978 (put-text-property (point) end 'face 'bold))
1980 (gnus-article-hide-text-type
1981 (1- (point)) (1+ (point)) 'overstrike)
1983 start (1- (point)) 'face 'underline))
1985 (gnus-article-hide-text-type start (point) 'overstrike)
1987 (point) end 'face 'underline)))))))))
1989 (defun gnus-article-treat-unfold-headers ()
1990 "Unfold folded message headers.
1991 Only the headers that fit into the current window width will be
1994 (gnus-with-article-headers
1998 (mail-header-narrow-to-field)
1999 (let ((header (buffer-string)))
2002 (goto-char (point-min))
2003 (while (re-search-forward "\n[\t ]" nil t)
2004 (replace-match " " t t)))
2005 (setq length (- (point-max) (point-min) 1)))
2006 (when (< length (window-width))
2007 (while (re-search-forward "\n[\t ]" nil t)
2008 (replace-match " " t t)))
2009 (goto-char (point-max)))))))
2011 (defun gnus-article-treat-fold-headers ()
2012 "Fold message headers."
2014 (gnus-with-article-headers
2017 (mail-header-narrow-to-field)
2018 (mail-header-fold-field)
2019 (goto-char (point-max))))))
2021 (defun gnus-treat-smiley ()
2022 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2024 (unless (featurep 'xemacs)
2025 (when (and (>= emacs-major-version 21)
2026 (not gnus-article-should-use-smiley-mule)
2027 gnus-article-smiley-mule-loaded-p)
2028 (load "smiley" nil t)
2029 (setq gnus-article-smiley-mule-loaded-p nil))
2030 (when (and gnus-article-should-use-smiley-mule
2031 (not gnus-article-smiley-mule-loaded-p))
2032 (load "smiley-mule" nil t)
2033 (setq gnus-article-smiley-mule-loaded-p t)))
2034 (gnus-with-article-buffer
2035 (if (memq 'smiley gnus-article-wash-types)
2036 (gnus-delete-images 'smiley)
2038 (let ((images (smiley-region (point) (point-max))))
2040 (gnus-add-wash-type 'smiley)
2041 (dolist (image images)
2042 (gnus-add-image 'smiley image)))))))
2044 (defun gnus-article-remove-images ()
2045 "Remove all images from the article buffer."
2047 (gnus-with-article-buffer
2048 (dolist (elem gnus-article-image-alist)
2049 (gnus-delete-images (car elem)))))
2051 (defun gnus-article-treat-fold-newsgroups ()
2052 "Unfold folded message headers.
2053 Only the headers that fit into the current window width will be
2056 (gnus-with-article-headers
2057 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2059 (mail-header-narrow-to-field)
2060 (while (re-search-forward ", *" nil t)
2061 (replace-match ", " t t))
2062 (mail-header-fold-field)
2063 (goto-char (point-max))))))
2065 (defun gnus-article-treat-body-boundary ()
2066 "Place a boundary line at the end of the headers."
2068 (when (and gnus-body-boundary-delimiter
2069 (> (length gnus-body-boundary-delimiter) 0))
2070 (gnus-with-article-headers
2071 (goto-char (point-max))
2072 (let ((start (point)))
2073 (insert "X-Boundary: ")
2074 (gnus-add-text-properties start (point) '(invisible t intangible t))
2076 (while (>= (1- (window-width)) (length str))
2077 (setq str (concat str gnus-body-boundary-delimiter)))
2078 (substring str 0 (1- (window-width))))
2080 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2082 (defun article-fill-long-lines ()
2083 "Fill lines that are wider than the window width."
2086 (let ((buffer-read-only nil)
2087 (width (window-width (get-buffer-window (current-buffer)))))
2090 (let ((adaptive-fill-mode nil)) ;Why? -sm
2093 (when (>= (current-column) (min fill-column width))
2094 (narrow-to-region (min (1+ (point)) (point-max))
2095 (gnus-point-at-bol))
2096 (let ((goback (point-marker)))
2097 (fill-paragraph nil)
2098 (goto-char (marker-position goback)))
2100 (forward-line 1)))))))
2102 (defun article-capitalize-sentences ()
2103 "Capitalize the first word in each sentence."
2106 (let ((buffer-read-only nil)
2107 (paragraph-start "^[\n\^L]"))
2111 (forward-sentence)))))
2113 (defun article-remove-cr ()
2114 "Remove trailing CRs and then translate remaining CRs into LFs."
2117 (let ((buffer-read-only nil))
2118 (goto-char (point-min))
2119 (while (re-search-forward "\r+$" nil t)
2120 (replace-match "" t t))
2121 (goto-char (point-min))
2122 (while (search-forward "\r" nil t)
2123 (replace-match "\n" t t)))))
2125 (defun article-remove-trailing-blank-lines ()
2126 "Remove all trailing blank lines from the article."
2129 (let ((buffer-read-only nil))
2130 (goto-char (point-max))
2134 (while (and (not (bobp))
2135 (looking-at "^[ \t]*$")
2136 (not (gnus-annotation-in-region-p
2137 (point) (gnus-point-at-eol))))
2142 (defun article-display-face ()
2143 "Display any Face headers in the header."
2145 (let ((wash-face-p buffer-read-only))
2146 (gnus-with-article-headers
2147 ;; When displaying parts, this function can be called several times on
2148 ;; the same article, without any intended toggle semantic (as typing `W
2149 ;; D d' would have). So face deletion must occur only when we come from
2150 ;; an interactive command, that is when the *Article* buffer is
2152 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2153 (gnus-delete-images 'face)
2156 (when (and wash-face-p
2158 (goto-char (point-min))
2159 (not (re-search-forward "^Face:[\t ]*" nil t)))
2160 (gnus-buffer-live-p gnus-original-article-buffer))
2161 (set-buffer gnus-original-article-buffer))
2163 (mail-narrow-to-head)
2164 (while (gnus-article-goto-header "Face")
2165 (push (mail-header-field-value) faces))))
2166 (while (setq face (pop faces))
2167 (let ((png (gnus-convert-face-to-png face))
2170 (setq image (gnus-create-image png 'png t))
2171 (gnus-article-goto-header "from")
2173 (insert "From: [no `from' set]\n")
2175 (gnus-add-wash-type 'face)
2176 (gnus-add-image 'face image)
2177 (gnus-put-image image nil 'face))))))
2180 (defun article-display-x-face (&optional force)
2181 "Look for an X-Face header and display it if present."
2182 (interactive (list 'force))
2183 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2184 (gnus-with-article-headers
2185 ;; Delete the old process, if any.
2186 (when (process-status "article-x-face")
2187 (delete-process "article-x-face"))
2188 ;; See the comment in `article-display-face'.
2189 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2190 ;; We have already displayed X-Faces, so we remove them
2192 (gnus-delete-images 'xface)
2194 (let (x-faces from face)
2196 (when (and wash-face-p
2198 (goto-char (point-min))
2199 (not (re-search-forward
2200 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2201 (gnus-buffer-live-p gnus-original-article-buffer))
2202 ;; If type `W f', use gnus-original-article-buffer,
2203 ;; otherwise use the current buffer because displaying
2204 ;; RFC822 parts calls this function too.
2205 (set-buffer gnus-original-article-buffer))
2207 (mail-narrow-to-head)
2208 (while (gnus-article-goto-header "X-Face")
2209 (push (mail-header-field-value) x-faces))
2210 (setq from (message-fetch-field "from"))))
2211 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2212 ;; single external face.
2213 (when (stringp gnus-article-x-face-command)
2214 (setq x-faces (list (car x-faces))))
2215 (while (and (setq face (pop x-faces))
2216 gnus-article-x-face-command
2218 ;; Check whether this face is censored.
2219 (not gnus-article-x-face-too-ugly)
2220 (and gnus-article-x-face-too-ugly from
2221 (not (string-match gnus-article-x-face-too-ugly
2223 ;; We display the face.
2224 (cond ((stringp gnus-article-x-face-command)
2225 ;; The command is a string, so we interpret the command
2226 ;; as a, well, command, and fork it off.
2227 (let ((process-connection-type nil))
2228 (process-kill-without-query
2230 "article-x-face" nil shell-file-name
2231 shell-command-switch gnus-article-x-face-command))
2234 (process-send-region "article-x-face"
2235 (point-min) (point-max)))
2236 (process-send-eof "article-x-face")))
2237 ((functionp gnus-article-x-face-command)
2238 ;; The command is a lisp function, so we call it.
2239 (funcall gnus-article-x-face-command face))
2241 (error "%s is not a function"
2242 gnus-article-x-face-command)))))))))
2244 (defun article-decode-mime-words ()
2245 "Decode all MIME-encoded words in the article."
2248 (set-buffer gnus-article-buffer)
2249 (let ((inhibit-point-motion-hooks t)
2251 (mail-parse-charset gnus-newsgroup-charset)
2252 (mail-parse-ignored-charsets
2253 (save-excursion (set-buffer gnus-summary-buffer)
2254 gnus-newsgroup-ignored-charsets)))
2255 (mail-decode-encoded-word-region (point-min) (point-max)))))
2257 (defun article-decode-charset (&optional prompt)
2258 "Decode charset-encoded text in the article.
2259 If PROMPT (the prefix), prompt for a coding system to use."
2261 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2263 (mail-parse-charset gnus-newsgroup-charset)
2264 (mail-parse-ignored-charsets
2265 (save-excursion (condition-case nil
2266 (set-buffer gnus-summary-buffer)
2268 gnus-newsgroup-ignored-charsets))
2269 ct cte ctl charset format)
2272 (article-narrow-to-head)
2273 (setq ct (message-fetch-field "Content-Type" t)
2274 cte (message-fetch-field "Content-Transfer-Encoding" t)
2275 ctl (and ct (ignore-errors
2276 (mail-header-parse-content-type ct)))
2279 (mm-read-coding-system "Charset to decode: "))
2281 (mail-content-type-get ctl 'charset)))
2282 format (and ctl (mail-content-type-get ctl 'format)))
2284 (setq cte (mail-header-strip cte)))
2285 (if (and ctl (not (string-match "/" (car ctl))))
2287 (goto-char (point-max)))
2290 (narrow-to-region (point) (point-max))
2291 (when (and (eq mail-parse-charset 'gnus-decoded)
2292 (eq (mm-body-7-or-8) '8bit))
2293 ;; The text code could have been decoded.
2294 (setq charset mail-parse-charset))
2295 (when (and (or (not ctl)
2296 (equal (car ctl) "text/plain"))
2297 (not format)) ;; article with format will decode later.
2299 charset (and cte (intern (downcase
2300 (gnus-strip-whitespace cte))))
2303 (defun article-decode-encoded-words ()
2304 "Remove encoded-word encoding from headers."
2305 (let (buffer-read-only)
2306 (let ((charset (save-excursion
2307 (set-buffer gnus-summary-buffer)
2308 default-mime-charset)))
2309 (mime-decode-header-in-buffer charset))))
2311 (defun article-decode-group-name ()
2312 "Decode group names in `Newsgroups:'."
2313 (let ((inhibit-point-motion-hooks t)
2315 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2316 (when (and (or gnus-group-name-charset-method-alist
2317 gnus-group-name-charset-group-alist)
2318 (gnus-buffer-live-p gnus-original-article-buffer))
2320 (article-narrow-to-head)
2321 (with-current-buffer gnus-original-article-buffer
2322 (goto-char (point-min)))
2323 (while (re-search-forward
2324 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2325 (replace-match (save-match-data
2326 (gnus-decode-newsgroups
2327 ;; XXX how to use data in article buffer?
2328 (with-current-buffer gnus-original-article-buffer
2330 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2333 gnus-newsgroup-name method))
2335 (goto-char (point-min))
2336 (with-current-buffer gnus-original-article-buffer
2337 (goto-char (point-min)))
2338 (while (re-search-forward
2339 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2340 (replace-match (save-match-data
2341 (gnus-decode-newsgroups
2342 ;; XXX how to use data in article buffer?
2343 (with-current-buffer gnus-original-article-buffer
2345 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2348 gnus-newsgroup-name method))
2351 (autoload 'idna-to-unicode "idna")
2353 (defun article-decode-idna-rhs ()
2354 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2357 (let ((inhibit-point-motion-hooks t)
2359 (article-narrow-to-head)
2360 (goto-char (point-min))
2361 (while (re-search-forward "\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2363 (when (save-match-data
2364 (and (setq ace (match-string 1))
2366 (and (re-search-backward "^[^ \t]" nil t)
2367 (looking-at "From\\|To\\|Cc")))
2368 (save-excursion (backward-char)
2369 (message-idna-inside-rhs-p))
2370 (setq unicode (idna-to-unicode ace))))
2371 (unless (string= ace unicode)
2372 (replace-match unicode nil nil nil 1)))))))))
2374 (defun article-de-quoted-unreadable (&optional force read-charset)
2375 "Translate a quoted-printable-encoded article.
2376 If FORCE, decode the article whether it is marked as quoted-printable
2378 If READ-CHARSET, ask for a coding system."
2379 (interactive (list 'force current-prefix-arg))
2381 (let ((buffer-read-only nil) type charset)
2382 (if (gnus-buffer-live-p gnus-original-article-buffer)
2383 (with-current-buffer gnus-original-article-buffer
2385 (gnus-fetch-field "content-transfer-encoding"))
2386 (let* ((ct (gnus-fetch-field "content-type"))
2389 (mail-header-parse-content-type ct)))))
2390 (setq charset (and ctl
2391 (mail-content-type-get ctl 'charset)))
2392 (if (stringp charset)
2393 (setq charset (intern (downcase charset)))))))
2395 (setq charset (mm-read-coding-system "Charset: " charset)))
2397 (setq charset gnus-newsgroup-charset))
2399 (and type (let ((case-fold-search t))
2400 (string-match "quoted-printable" type))))
2402 (quoted-printable-decode-region
2403 (point) (point-max) (mm-charset-to-coding-system charset))))))
2405 (defun article-de-base64-unreadable (&optional force read-charset)
2406 "Translate a base64 article.
2407 If FORCE, decode the article whether it is marked as base64 not.
2408 If READ-CHARSET, ask for a coding system."
2409 (interactive (list 'force current-prefix-arg))
2411 (let ((buffer-read-only nil) type charset)
2412 (if (gnus-buffer-live-p gnus-original-article-buffer)
2413 (with-current-buffer gnus-original-article-buffer
2415 (gnus-fetch-field "content-transfer-encoding"))
2416 (let* ((ct (gnus-fetch-field "content-type"))
2419 (mail-header-parse-content-type ct)))))
2420 (setq charset (and ctl
2421 (mail-content-type-get ctl 'charset)))
2422 (if (stringp charset)
2423 (setq charset (intern (downcase charset)))))))
2425 (setq charset (mm-read-coding-system "Charset: " charset)))
2427 (setq charset gnus-newsgroup-charset))
2429 (and type (let ((case-fold-search t))
2430 (string-match "base64" type))))
2433 (narrow-to-region (point) (point-max))
2434 (base64-decode-region (point-min) (point-max))
2435 (mm-decode-coding-region
2436 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2441 (defun article-decode-HZ ()
2442 "Translate a HZ-encoded article."
2446 (let ((buffer-read-only nil))
2447 (rfc1843-decode-region (point-min) (point-max)))))
2449 (defun article-unsplit-urls ()
2450 "Remove the newlines that some other mailers insert into URLs."
2453 (let ((buffer-read-only nil))
2454 (goto-char (point-min))
2455 (while (re-search-forward
2456 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2457 (replace-match "\\1\\3" t)))
2458 (when (interactive-p)
2459 (gnus-treat-article nil))))
2462 (defun article-wash-html (&optional read-charset)
2463 "Format an HTML article.
2464 If READ-CHARSET, ask for a coding system."
2467 (let ((buffer-read-only nil)
2469 (when (gnus-buffer-live-p gnus-original-article-buffer)
2470 (with-current-buffer gnus-original-article-buffer
2471 (let* ((ct (gnus-fetch-field "content-type"))
2474 (mail-header-parse-content-type ct)))))
2475 (setq charset (and ctl
2476 (mail-content-type-get ctl 'charset)))
2477 (when (stringp charset)
2478 (setq charset (intern (downcase charset)))))))
2480 (setq charset (mm-read-coding-system "Charset: " charset)))
2482 (setq charset gnus-newsgroup-charset))
2484 (save-window-excursion
2486 (narrow-to-region (point) (point-max))
2487 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2488 (entry (assq func mm-text-html-washer-alist)))
2490 (setq func (cdr entry)))
2495 (apply (car func) (cdr func))))))))))
2497 (defun gnus-article-wash-html-with-w3 ()
2498 "Wash the current buffer with w3."
2500 (let ((w3-strict-width (window-width))
2501 (url-standalone-mode t)
2502 (url-gateway-unplugged t)
2503 (w3-honor-stylesheets nil))
2505 (w3-region (point-min) (point-max))
2508 (defun gnus-article-wash-html-with-w3m ()
2509 "Wash the current buffer with emacs-w3m."
2512 (narrow-to-region (point) (point-max))
2513 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2516 w3m-force-redisplay)
2517 (w3m-region (point-min) (point-max)))
2518 (when mm-inline-text-html-with-w3m-keymap
2519 (add-text-properties
2520 (point-min) (point-max)
2521 (nconc (mm-w3m-local-map-property)
2522 '(mm-inline-text-html-with-w3m t))))))
2524 (defun article-hide-list-identifiers ()
2525 "Remove list identifies from the Subject header.
2526 The `gnus-list-identifiers' variable specifies what to do."
2528 (let ((inhibit-point-motion-hooks t)
2529 (regexp (if (consp gnus-list-identifiers)
2530 (mapconcat 'identity gnus-list-identifiers " *\\|")
2531 gnus-list-identifiers))
2536 (article-narrow-to-head)
2537 (goto-char (point-min))
2538 (while (re-search-forward
2539 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2541 (delete-region (match-beginning 2) (match-end 0))
2542 (beginning-of-line))
2543 (when (re-search-forward
2544 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2545 (delete-region (match-beginning 1) (match-end 1))))))))
2547 (defun article-hide-pem (&optional arg)
2548 "Toggle hiding of any PEM headers and signatures in the current article.
2549 If given a negative prefix, always show; if given a positive prefix,
2551 (interactive (gnus-article-hidden-arg))
2552 (unless (gnus-article-check-hidden-text 'pem arg)
2554 (let (buffer-read-only end)
2555 (goto-char (point-min))
2556 ;; Hide the horrendously ugly "header".
2557 (when (and (search-forward
2558 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2560 (setq end (1+ (match-beginning 0))))
2561 (gnus-add-wash-type 'pem)
2562 (gnus-article-hide-text-type
2564 (if (search-forward "\n\n" nil t)
2568 ;; Hide the trailer as well
2569 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2571 (gnus-article-hide-text-type
2572 (match-beginning 0) (match-end 0) 'pem)))))))
2574 (defun article-strip-banner ()
2575 "Strip the banners specified by the `banner' group parameter and by
2576 `gnus-article-address-banner-alist'."
2580 (let ((inhibit-point-motion-hooks t))
2581 (when (gnus-parameter-banner gnus-newsgroup-name)
2582 (article-really-strip-banner
2583 (gnus-parameter-banner gnus-newsgroup-name)))
2584 (when gnus-article-address-banner-alist
2585 (article-really-strip-banner
2586 (let ((from (save-restriction
2588 (article-narrow-to-head)
2589 (mail-fetch-field "from"))))
2592 (caar (mail-header-parse-addresses from))))
2594 (dolist (pair gnus-article-address-banner-alist)
2595 (when (string-match (car pair) from)
2596 (throw 'found (cdr pair)))))))))))))
2598 (defun article-really-strip-banner (banner)
2599 "Strip the banner specified by the argument."
2602 (let ((inhibit-point-motion-hooks t)
2603 (gnus-signature-limit nil)
2607 ((eq banner 'signature)
2608 (when (gnus-article-narrow-to-signature)
2611 (delete-region (point) (point-max))))
2613 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2614 (while (re-search-forward banner nil t)
2615 (delete-region (match-beginning 0) (match-end 0)))))
2617 (while (re-search-forward banner nil t)
2618 (delete-region (match-beginning 0) (match-end 0)))))))))
2620 (defun article-babel ()
2621 "Translate article using an online translation service."
2625 (set-buffer gnus-article-buffer)
2626 (when (article-goto-body)
2627 (let* ((buffer-read-only nil)
2630 (orig (buffer-substring start end))
2631 (trans (babel-as-string orig)))
2633 (narrow-to-region start end)
2634 (delete-region start end)
2637 (defun article-hide-signature (&optional arg)
2638 "Hide the signature in the current article.
2639 If given a negative prefix, always show; if given a positive prefix,
2641 (interactive (gnus-article-hidden-arg))
2647 (article-goto-body))
2648 (goto-char (point-min)))
2649 (unless (gnus-article-check-hidden-text 'signature arg)
2650 (let ((buffer-read-only nil)
2652 (while (setq button (text-property-any button (point-max)
2654 'gnus-signature-toggle))
2655 (setq button (text-property-not-all button (point-max)
2657 'gnus-signature-toggle))
2658 (when (and button (not (eobp)))
2659 (gnus-article-hide-text-type
2661 (next-single-property-change (1+ button) 'mime-view-entity
2664 (gnus-set-mode-line 'article))
2666 (defun article-strip-headers-in-body ()
2667 "Strip offensive headers from bodies."
2671 (let ((case-fold-search t))
2672 (when (looking-at "x-no-archive:")
2673 (gnus-delete-line)))))
2675 (defun article-strip-leading-blank-lines ()
2676 "Remove all blank lines from the beginning of the article."
2679 (let ((inhibit-point-motion-hooks t)
2681 (when (article-goto-body)
2682 (while (and (not (eobp))
2683 (looking-at "[ \t]*$"))
2684 (gnus-delete-line))))))
2686 (defun article-narrow-to-head ()
2687 "Narrow the buffer to the head of the message.
2688 Point is left at the beginning of the narrowed-to region."
2690 (goto-char (point-min))
2691 (if (search-forward "\n\n" nil 1)
2694 (goto-char (point-min)))
2696 (defun article-goto-body ()
2697 "Place point at the start of the body."
2698 (goto-char (point-min))
2700 ;; This variable is only bound when dealing with separate
2702 (article-goto-body-goes-to-point-min-p
2704 ((search-forward "\n\n" nil t)
2707 (goto-char (point-max))
2710 (defun article-strip-multiple-blank-lines ()
2711 "Replace consecutive blank lines with one empty line."
2714 (let ((inhibit-point-motion-hooks t)
2716 ;; First make all blank lines empty.
2718 (while (re-search-forward "^[ \t]+$" nil t)
2719 (unless (gnus-annotation-in-region-p
2720 (match-beginning 0) (match-end 0))
2721 (replace-match "" nil t)))
2722 ;; Then replace multiple empty lines with a single empty line.
2724 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2725 (unless (gnus-annotation-in-region-p
2726 (match-beginning 0) (match-end 0))
2727 (delete-region (match-beginning 1) (match-end 1)))))))
2729 (defun article-strip-leading-space ()
2730 "Remove all white space from the beginning of the lines in the article."
2733 (let ((inhibit-point-motion-hooks t)
2736 (while (re-search-forward "^[ \t]+" nil t)
2737 (replace-match "" t t)))))
2739 (defun article-strip-trailing-space ()
2740 "Remove all white space from the end of the lines in the article."
2743 (let ((inhibit-point-motion-hooks t)
2746 (while (re-search-forward "[ \t]+$" nil t)
2747 (replace-match "" t t)))))
2749 (defun article-strip-blank-lines ()
2750 "Strip leading, trailing and multiple blank lines."
2752 (article-strip-leading-blank-lines)
2753 (article-remove-trailing-blank-lines)
2754 (article-strip-multiple-blank-lines))
2756 (defun article-strip-all-blank-lines ()
2757 "Strip all blank lines."
2760 (let ((inhibit-point-motion-hooks t)
2763 (while (re-search-forward "^[ \t]*\n" nil t)
2764 (replace-match "" t t)))))
2766 (defun gnus-article-narrow-to-signature ()
2767 "Narrow to the signature; return t if a signature is found, else nil."
2768 (let ((inhibit-point-motion-hooks t))
2769 (when (gnus-article-search-signature)
2771 ;; Check whether we have some limits to what we consider
2772 ;; to be a signature.
2773 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2774 (list gnus-signature-limit)))
2776 (while (setq limit (pop limits))
2777 (if (or (and (integerp limit)
2778 (< (- (point-max) (point)) limit))
2780 (< (count-lines (point) (point-max)) limit))
2781 (and (functionp limit)
2783 (and (stringp limit)
2784 (not (re-search-forward limit nil t))))
2785 () ; This limit did not succeed.
2789 (narrow-to-region (point) (point-max))
2792 (defun gnus-article-search-signature ()
2793 "Search the current buffer for the signature separator.
2794 Put point at the beginning of the signature separator."
2795 (let ((cur (point)))
2796 (goto-char (point-max))
2797 (if (if (stringp gnus-signature-separator)
2798 (re-search-backward gnus-signature-separator nil t)
2799 (let ((seps gnus-signature-separator))
2801 (not (re-search-backward (car seps) nil t)))
2808 (defun gnus-article-hidden-arg ()
2809 "Return the current prefix arg as a number, or 0 if no prefix."
2810 (list (if current-prefix-arg
2811 (prefix-numeric-value current-prefix-arg)
2814 (defun gnus-article-check-hidden-text (type arg)
2815 "Return nil if hiding is necessary.
2816 Arg can be nil or a number. nil and positive means hide, negative
2817 means show, 0 means toggle."
2820 (let ((hide (gnus-article-hidden-text-p type)))
2826 (gnus-article-show-hidden-text type)
2829 (if (eq hide 'hidden)
2831 (gnus-article-show-hidden-text type)
2835 (defun gnus-article-hidden-text-p (type)
2836 "Say whether the current buffer contains hidden text of type TYPE."
2837 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2839 (not (get-text-property pos 'invisible))
2840 (not (get-text-property pos 'dummy-invisible)))
2842 (text-property-any (1+ pos) (point-max) 'article-type type)))
2847 (defun gnus-article-show-hidden-text (type &optional dummy)
2848 "Show all hidden text of type TYPE.
2849 Originally it is hide instead of DUMMY."
2850 (let ((buffer-read-only nil)
2851 (inhibit-point-motion-hooks t))
2852 (gnus-remove-text-properties-when
2854 (point-min) (point-max)
2855 (cons 'article-type (cons type
2856 gnus-hidden-properties)))
2857 (gnus-delete-wash-type type)))
2859 (defconst article-time-units
2860 `((year . ,(* 365.25 24 60 60))
2861 (week . ,(* 7 24 60 60))
2862 (day . ,(* 24 60 60))
2866 "Mapping from time units to seconds.")
2868 (defun gnus-article-forward-header ()
2869 "Move point to the start of the next header.
2870 If the current header is a continuation header, this can be several
2875 (if (looking-at "[ \t]+[^ \t]")
2879 (defun article-date-ut (&optional type highlight header)
2880 "Convert DATE date to universal time in the current article.
2881 If TYPE is `local', convert to local time; if it is `lapsed', output
2882 how much time has lapsed since DATE. For `lapsed', the value of
2883 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2884 should replace the \"Date:\" one, or should be added below it."
2885 (interactive (list 'ut t))
2886 (let* ((header (or header
2887 (and (eq 1 (point-min))
2888 (mail-header-date (save-excursion
2889 (set-buffer gnus-summary-buffer)
2890 gnus-current-headers)))
2891 (message-fetch-field "date")
2893 (date (if (vectorp header) (mail-header-date header)
2895 (inhibit-point-motion-hooks t)
2896 bface eface date-pos)
2897 (when (and date (not (string= date "")))
2900 (article-narrow-to-head)
2901 (when (or (and (eq type 'lapsed)
2902 gnus-article-date-lapsed-new-header
2903 ;; Attempt to get the face of X-Sent first.
2904 (re-search-forward "^X-Sent:[ \t]" nil t))
2905 (re-search-forward "^Date:[ \t]" nil t)
2906 ;; If Date is missing, try again for X-Sent.
2907 (re-search-forward "^X-Sent:[ \t]" nil t))
2908 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2909 date (or (get-text-property (gnus-point-at-bol)
2912 eface (get-text-property (1- (gnus-point-at-eol))
2914 (let ((buffer-read-only nil))
2915 ;; Delete any old X-Sent headers.
2916 (when (setq date-pos
2917 (text-property-any (point-min) (point-max)
2918 'article-date-lapsed t))
2919 (goto-char (setq date-pos (set-marker (make-marker) date-pos)))
2920 (delete-region (match-beginning 0)
2921 (progn (forward-line 1) (point))))
2922 (goto-char (point-min))
2923 ;; Delete any old Date headers.
2924 (while (re-search-forward "^Date:[ \t]" nil t)
2926 (setq date-pos (match-beginning 0)))
2927 (unless (and (eq type 'lapsed)
2928 gnus-article-date-lapsed-new-header)
2929 (delete-region (match-beginning 0)
2930 (progn (message-next-header) (point)))))
2933 (goto-char date-pos)
2935 ;; Possibly, Date has been deleted.
2937 (when (and (eq type 'lapsed)
2938 gnus-article-date-lapsed-new-header
2939 (looking-at "Date:"))
2941 (goto-char (point-min)))
2942 (insert (article-make-date-line date type))
2943 (when (eq type 'lapsed)
2944 (put-text-property (gnus-point-at-bol) (point)
2945 'article-date-lapsed t))
2949 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2950 (put-text-property (match-beginning 1) (1+ (match-end 1))
2951 'original-date date)
2952 (put-text-property (match-beginning 1) (1+ (match-end 1))
2954 (put-text-property (match-beginning 2) (match-end 2)
2957 (defun article-make-date-line (date type)
2958 "Return a DATE line of TYPE."
2959 (unless (memq type '(local ut original user iso8601 lapsed english))
2960 (error "Unknown conversion type: %s" type))
2962 (let ((time (date-to-time date)))
2964 ;; Convert to the local timezone.
2966 (let ((tz (car (current-time-zone time))))
2967 (format "Date: %s %s%02d%02d" (current-time-string time)
2968 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2969 (/ (% (abs tz) 3600) 60))))
2970 ;; Convert to Universal Time.
2973 (current-time-string
2974 (let* ((e (parse-time-string date))
2975 (tm (apply 'encode-time e))
2977 (ls (- (cadr tm) (car (current-time-zone time)))))
2978 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2979 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2982 ;; Get the original date from the article.
2983 ((eq type 'original)
2984 (concat "Date: " (if (string-match "\n+$" date)
2985 (substring date 0 (match-beginning 0))
2987 ;; Let the user define the format.
2989 (let ((format (or (condition-case nil
2990 (with-current-buffer gnus-summary-buffer
2991 gnus-article-time-format)
2993 gnus-article-time-format)))
2994 (if (functionp format)
2995 (funcall format time)
2996 (concat "Date: " (format-time-string format time)))))
2999 (let ((tz (car (current-time-zone time))))
3002 (format-time-string "%Y%m%dT%H%M%S" time)
3003 (format "%s%02d%02d"
3004 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3005 (/ (% (abs tz) 3600) 60)))))
3006 ;; Do an X-Sent lapsed format.
3008 ;; If the date is seriously mangled, the timezone functions are
3009 ;; liable to bug out, so we ignore all errors.
3010 (let* ((now (current-time))
3011 (real-time (subtract-time now time))
3012 (real-sec (and real-time
3013 (+ (* (float (car real-time)) 65536)
3015 (sec (and real-time (abs real-sec)))
3025 ;; This is a bit convoluted, but basically we go
3026 ;; through the time units for years, weeks, etc,
3027 ;; and divide things to see whether that results
3028 ;; in positive answers.
3031 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3032 ;; The (remaining) seconds are too few to
3033 ;; be divided into this time unit.
3035 ;; It's big enough, so we output it.
3036 (setq sec (- sec (* num (cdr unit))))
3038 (concat (if prev ", " "") (int-to-string
3040 " " (symbol-name (car unit))
3041 (if (> num 1) "s" ""))
3043 article-time-units "")
3044 ;; If dates are odd, then it might appear like the
3045 ;; article was sent in the future.
3048 " in the future"))))))
3049 ;; Display the date in proper English
3051 (let ((dtime (decode-time time)))
3054 (number-to-string (nth 3 dtime))
3055 (let ((digit (% (nth 3 dtime) 10)))
3057 ((memq (nth 3 dtime) '(11 12 13)) "th")
3063 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3065 (number-to-string (nth 5 dtime))
3067 (format "%02d" (nth 2 dtime))
3069 (format "%02d" (nth 1 dtime)))))))
3071 (format "Date: %s (from T-gnus)" date))))
3073 (defun article-date-local (&optional highlight)
3074 "Convert the current article date to the local timezone."
3075 (interactive (list t))
3076 (article-date-ut 'local highlight))
3078 (defun article-date-english (&optional highlight)
3079 "Convert the current article date to something that is proper English."
3080 (interactive (list t))
3081 (article-date-ut 'english highlight))
3083 (defun article-date-original (&optional highlight)
3084 "Convert the current article date to what it was originally.
3085 This is only useful if you have used some other date conversion
3086 function and want to see what the date was before converting."
3087 (interactive (list t))
3088 (article-date-ut 'original highlight))
3090 (defun article-date-lapsed (&optional highlight)
3091 "Convert the current article date to time lapsed since it was sent."
3092 (interactive (list t))
3093 (article-date-ut 'lapsed highlight))
3095 (defun article-update-date-lapsed ()
3096 "Function to be run from a timer to update the lapsed time line."
3097 (let (deactivate-mark)
3102 (set-buffer (window-buffer w))
3103 (when (eq major-mode 'gnus-article-mode)
3104 (let ((mark (point-marker)))
3105 (goto-char (point-min))
3106 (when (re-search-forward "^X-Sent:" nil t)
3107 (article-date-lapsed t))
3108 (goto-char (marker-position mark))
3109 (move-marker mark nil))))
3112 (defun gnus-start-date-timer (&optional n)
3113 "Start a timer to update the X-Sent header in the article buffers.
3114 The numerical prefix says how frequently (in seconds) the function
3119 (gnus-stop-date-timer)
3120 (setq article-lapsed-timer
3121 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
3123 (defun gnus-stop-date-timer ()
3124 "Stop the X-Sent timer."
3126 (when article-lapsed-timer
3127 (nnheader-cancel-timer article-lapsed-timer)
3128 (setq article-lapsed-timer nil)))
3130 (defun article-date-user (&optional highlight)
3131 "Convert the current article date to the user-defined format.
3132 This format is defined by the `gnus-article-time-format' variable."
3133 (interactive (list t))
3134 (article-date-ut 'user highlight))
3136 (defun article-date-iso8601 (&optional highlight)
3137 "Convert the current article date to ISO8601."
3138 (interactive (list t))
3139 (article-date-ut 'iso8601 highlight))
3141 ;; (defun article-show-all ()
3142 ;; "Show all hidden text in the article buffer."
3146 ;; (let ((buffer-read-only nil))
3147 ;; (gnus-article-unhide-text (point-min) (point-max))
3148 ;; (gnus-remove-text-with-property 'gnus-prev)
3149 ;; (gnus-remove-text-with-property 'gnus-next))))
3151 (defun article-show-all-headers ()
3152 "Show all hidden headers in the article buffer."
3157 (article-narrow-to-head)
3158 (let ((buffer-read-only nil))
3159 (gnus-article-unhide-text (point-min) (point-max))))))
3161 (defun article-remove-leading-whitespace ()
3162 "Remove excessive whitespace from all headers."
3166 (let ((buffer-read-only nil))
3167 (article-narrow-to-head)
3168 (goto-char (point-min))
3169 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3170 (delete-region (match-beginning 1) (match-end 1)))))))
3172 (defun article-emphasize (&optional arg)
3173 "Emphasize text according to `gnus-emphasis-alist'."
3174 (interactive (gnus-article-hidden-arg))
3175 (unless (gnus-article-check-hidden-text 'emphasis arg)
3179 (with-current-buffer gnus-summary-buffer
3180 gnus-article-emphasis-alist)
3182 gnus-emphasis-alist))
3183 (buffer-read-only nil)
3184 (props (append '(article-type emphasis)
3185 gnus-hidden-properties))
3186 regexp elem beg invisible visible face)
3189 (while (setq elem (pop alist))
3191 (setq regexp (car elem)
3192 invisible (nth 1 elem)
3193 visible (nth 2 elem)
3195 (while (re-search-forward regexp nil t)
3196 (when (and (match-beginning visible) (match-beginning invisible))
3197 (gnus-article-hide-text
3198 (match-beginning invisible) (match-end invisible) props)
3199 (gnus-article-unhide-text-type
3200 (match-beginning visible) (match-end visible) 'emphasis)
3201 (gnus-put-overlay-excluding-newlines
3202 (match-beginning visible) (match-end visible) 'face face)
3203 (gnus-add-wash-type 'emphasis)
3204 (goto-char (match-end invisible)))))))))
3206 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3207 "Setup newsgroup emphasis alist."
3208 (unless gnus-article-emphasis-alist
3209 (let ((name (and gnus-newsgroup-name
3210 (gnus-group-real-name gnus-newsgroup-name))))
3211 (make-local-variable 'gnus-article-emphasis-alist)
3212 (setq gnus-article-emphasis-alist
3214 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3215 (while (setq elem (pop alist))
3216 (when (and name (string-match (car elem) name))
3218 highlight (copy-sequence (cdr elem)))))
3220 (copy-sequence highlight-words)
3221 (if gnus-newsgroup-name
3222 (copy-sequence (gnus-group-find-parameter
3223 gnus-newsgroup-name 'highlight-words t)))
3224 gnus-emphasis-alist)))))
3227 (defvar gnus-summary-article-menu)
3228 (defvar gnus-summary-post-menu))
3230 ;;; Saving functions.
3232 (defun gnus-article-save (save-buffer file &optional num)
3233 "Save the currently selected article."
3234 (unless gnus-save-all-headers
3235 ;; Remove headers according to `gnus-saved-headers'.
3236 (let ((gnus-visible-headers
3237 (or gnus-saved-headers gnus-visible-headers))
3238 (gnus-article-buffer save-buffer))
3240 (set-buffer save-buffer)
3241 (article-hide-headers 1 t))))
3242 (save-window-excursion
3243 (if (not gnus-default-article-saver)
3244 (error "No default saver is defined")
3245 ;; !!! Magic! The saving functions all save
3246 ;; `gnus-save-article-buffer' (or so they think), but we
3247 ;; bind that variable to our save-buffer.
3248 (set-buffer gnus-article-buffer)
3249 (let* ((gnus-save-article-buffer save-buffer)
3252 ((not gnus-prompt-before-saving) 'default)
3253 ((eq gnus-prompt-before-saving 'always) nil)
3255 (gnus-number-of-articles-to-be-saved
3256 (when (eq gnus-prompt-before-saving t)
3258 (set-buffer gnus-article-current-summary)
3259 (funcall gnus-default-article-saver filename)))))
3261 (defun gnus-read-save-file-name (prompt &optional filename
3262 function group headers variable)
3264 (funcall function group headers (symbol-value variable)))
3269 ((eq filename 'default)
3275 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3278 (if (and gnus-number-of-articles-to-be-saved
3279 (> gnus-number-of-articles-to-be-saved 1))
3280 (format "these %d articles"
3281 gnus-number-of-articles-to-be-saved)
3284 ;; Let the split methods have their say.
3286 ;; No split name was found.
3289 (concat prompt " (default "
3290 (file-name-nondirectory default-name) ") ")
3291 (file-name-directory default-name)
3293 ;; A single group name is returned.
3294 ((stringp split-name)
3296 (funcall function split-name headers
3297 (symbol-value variable)))
3299 (concat prompt " (default "
3300 (file-name-nondirectory default-name) ") ")
3301 (file-name-directory default-name)
3303 ;; A single split name was found
3304 ((= 1 (length split-name))
3305 (let* ((name (expand-file-name
3307 gnus-article-save-directory))
3308 (dir (cond ((file-directory-p name)
3309 (file-name-as-directory name))
3310 ((file-exists-p name) name)
3311 (t gnus-article-save-directory))))
3313 (concat prompt " (default " name ") ")
3315 ;; A list of splits was found.
3317 (setq split-name (nreverse split-name))
3319 (let ((file-name-history
3320 (nconc split-name file-name-history)))
3324 (concat prompt " (`M-p' for defaults) ")
3325 gnus-article-save-directory
3327 gnus-article-save-directory)))
3328 (car (push result file-name-history)))))))
3329 ;; Create the directory.
3330 (gnus-make-directory (file-name-directory file))
3331 ;; If we have read a directory, we append the default file name.
3332 (when (file-directory-p file)
3333 (setq file (expand-file-name (file-name-nondirectory
3335 (file-name-as-directory file))))
3336 ;; Possibly translate some characters.
3337 (nnheader-translate-file-chars file))))))
3338 (gnus-make-directory (file-name-directory result))
3339 (set variable result)))
3341 (defun gnus-article-archive-name (group)
3342 "Return the first instance of an \"Archive-name\" in the current buffer."
3343 (let ((case-fold-search t))
3344 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3345 (nnheader-concat gnus-article-save-directory
3346 (match-string 1)))))
3348 (defun gnus-article-nndoc-name (group)
3349 "If GROUP is an nndoc group, return the name of the parent group."
3350 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3351 (gnus-group-get-parameter group 'save-article-group)))
3353 (defun gnus-summary-save-in-rmail (&optional filename)
3354 "Append this article to Rmail file.
3355 Optional argument FILENAME specifies file name.
3356 Directory to save to is default to `gnus-article-save-directory'."
3357 (setq filename (gnus-read-save-file-name
3358 "Save %s in rmail file:" filename
3359 gnus-rmail-save-name gnus-newsgroup-name
3360 gnus-current-headers 'gnus-newsgroup-last-rmail))
3361 (gnus-eval-in-buffer-window gnus-save-article-buffer
3365 (gnus-output-to-rmail filename))))
3368 (defun gnus-summary-save-in-mail (&optional filename)
3369 "Append this article to Unix mail file.
3370 Optional argument FILENAME specifies file name.
3371 Directory to save to is default to `gnus-article-save-directory'."
3372 (setq filename (gnus-read-save-file-name
3373 "Save %s in Unix mail file:" filename
3374 gnus-mail-save-name gnus-newsgroup-name
3375 gnus-current-headers 'gnus-newsgroup-last-mail))
3376 (gnus-eval-in-buffer-window gnus-save-article-buffer
3380 (if (and (file-readable-p filename)
3381 (file-regular-p filename)
3382 (mail-file-babyl-p filename))
3383 (rmail-output-to-rmail-file filename t)
3384 (gnus-output-to-mail filename)))))
3387 (defun gnus-summary-save-in-file (&optional filename overwrite)
3388 "Append this article to file.
3389 Optional argument FILENAME specifies file name.
3390 Directory to save to is default to `gnus-article-save-directory'."
3391 (setq filename (gnus-read-save-file-name
3392 "Save %s in file:" filename
3393 gnus-file-save-name gnus-newsgroup-name
3394 gnus-current-headers 'gnus-newsgroup-last-file))
3395 (gnus-eval-in-buffer-window gnus-save-article-buffer
3399 (when (and overwrite
3400 (file-exists-p filename))
3401 (delete-file filename))
3402 (gnus-output-to-file filename))))
3405 (defun gnus-summary-write-to-file (&optional filename)
3406 "Write this article to a file, overwriting it if the file exists.
3407 Optional argument FILENAME specifies file name.
3408 The directory to save in defaults to `gnus-article-save-directory'."
3409 (gnus-summary-save-in-file nil t))
3411 (defun gnus-summary-save-body-in-file (&optional filename)
3412 "Append this article body to a file.
3413 Optional argument FILENAME specifies file name.
3414 The directory to save in defaults to `gnus-article-save-directory'."
3415 (setq filename (gnus-read-save-file-name
3416 "Save %s body in file:" filename
3417 gnus-file-save-name gnus-newsgroup-name
3418 gnus-current-headers 'gnus-newsgroup-last-file))
3419 (gnus-eval-in-buffer-window gnus-save-article-buffer
3423 (when (article-goto-body)
3424 (narrow-to-region (point) (point-max)))
3425 (gnus-output-to-file filename))))
3428 (defun gnus-summary-save-in-pipe (&optional command)
3429 "Pipe this article to subprocess."
3431 (cond ((and (eq command 'default)
3432 gnus-last-shell-command)
3433 gnus-last-shell-command)
3438 "Shell command on %s: "
3439 (if (and gnus-number-of-articles-to-be-saved
3440 (> gnus-number-of-articles-to-be-saved 1))
3441 (format "these %d articles"
3442 gnus-number-of-articles-to-be-saved)
3444 gnus-last-shell-command))))
3445 (when (string-equal command "")
3446 (if gnus-last-shell-command
3447 (setq command gnus-last-shell-command)
3448 (error "A command is required")))
3449 (gnus-eval-in-buffer-window gnus-article-buffer
3452 (shell-command-on-region (point-min) (point-max) command nil)))
3453 (setq gnus-last-shell-command command))
3455 (defmacro gnus-read-string (prompt &optional initial-contents history
3457 "Like `read-string' but allow for older XEmacsen that don't have the 5th arg."
3458 (if (and (featurep 'xemacs)
3459 (< emacs-minor-version 2))
3460 `(read-string ,prompt ,initial-contents ,history)
3461 `(read-string ,prompt ,initial-contents ,history ,default-value)))
3463 (defun gnus-summary-pipe-to-muttprint (&optional command)
3464 "Pipe this article to muttprint."
3465 (setq command (gnus-read-string
3466 "Print using command: " gnus-summary-muttprint-program
3467 nil gnus-summary-muttprint-program))
3468 (gnus-summary-save-in-pipe command))
3470 ;;; Article file names when saving.
3472 (defun gnus-capitalize-newsgroup (newsgroup)
3473 "Capitalize NEWSGROUP name."
3474 (when (not (zerop (length newsgroup)))
3475 (concat (char-to-string (upcase (aref newsgroup 0)))
3476 (substring newsgroup 1))))
3478 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3479 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3480 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3481 Otherwise, it is like ~/News/news/group/num."
3484 (concat (if (gnus-use-long-file-name 'not-save)
3485 (gnus-capitalize-newsgroup newsgroup)
3486 (gnus-newsgroup-directory-form newsgroup))
3487 "/" (int-to-string (mail-header-number headers)))
3488 gnus-article-save-directory)))
3490 (string-equal (file-name-directory default)
3491 (file-name-directory last-file))
3492 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3494 (or last-file default))))
3496 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3497 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3498 If variable `gnus-use-long-file-name' is non-nil, it is
3499 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3502 (concat (if (gnus-use-long-file-name 'not-save)
3504 (gnus-newsgroup-directory-form newsgroup))
3505 "/" (int-to-string (mail-header-number headers)))
3506 gnus-article-save-directory)))
3508 (string-equal (file-name-directory default)
3509 (file-name-directory last-file))
3510 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3512 (or last-file default))))
3514 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3515 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3516 If variable `gnus-use-long-file-name' is non-nil, it is
3517 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3520 (if (gnus-use-long-file-name 'not-save)
3523 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3525 gnus-article-save-directory)))
3527 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3528 "Generate file name from sender."
3529 (let ((from (mail-header-from headers)))
3531 (if (and from (string-match "\\([^ <]+\\)@" from))
3532 (match-string 1 from)
3534 gnus-article-save-directory)))
3536 (defun article-verify-x-pgp-sig ()
3539 (if (gnus-buffer-live-p gnus-original-article-buffer)
3540 (let ((sig (with-current-buffer gnus-original-article-buffer
3541 (gnus-fetch-field "X-PGP-Sig")))
3545 (mml2015-clear-verify-function))
3547 (insert-buffer-substring gnus-original-article-buffer)
3548 (setq items (split-string sig))
3549 (message-narrow-to-head)
3550 (let ((inhibit-point-motion-hooks t)
3551 (case-fold-search t))
3552 ;; Don't verify multiple headers.
3553 (setq headers (mapconcat (lambda (header)
3555 (mail-fetch-field header)
3557 (split-string (nth 1 items) ",") "")))
3558 (delete-region (point-min) (point-max))
3559 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3560 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3565 (if (looking-at "^-")
3568 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3569 (insert "Version: " (car items) "\n\n")
3570 (insert (mapconcat 'identity (cddr items) "\n"))
3571 (insert "\n-----END PGP SIGNATURE-----\n")
3572 (let ((mm-security-handle (list (format "multipart/signed"))))
3573 (mml2015-clean-buffer)
3574 (let ((coding-system-for-write (or gnus-newsgroup-charset
3576 (funcall (mml2015-clear-verify-function)))
3578 (or (mm-handle-multipart-ctl-parameter
3579 mm-security-handle 'gnus-details)
3580 (mm-handle-multipart-ctl-parameter
3581 mm-security-handle 'gnus-info)))))
3583 (let (buffer-read-only bface eface)
3585 (message-narrow-to-head)
3586 (goto-char (point-max))
3588 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3589 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3590 (message-remove-header "X-Gnus-PGP-Verify")
3591 (if (re-search-forward "^X-PGP-Sig:" nil t)
3593 (goto-char (point-max)))
3594 (narrow-to-region (point) (point))
3595 (insert "X-Gnus-PGP-Verify: " info "\n")
3596 (goto-char (point-min))
3599 (if (not (looking-at "^[ \t]"))
3603 (goto-char (point-min))
3604 (when (looking-at "\\([^:]+\\): *")
3605 (put-text-property (match-beginning 1) (1+ (match-end 1))
3607 (put-text-property (match-end 0) (point-max)
3608 'face eface)))))))))
3610 (defun article-verify-cancel-lock ()
3611 "Verify Cancel-Lock header."
3613 (if (gnus-buffer-live-p gnus-original-article-buffer)
3614 (canlock-verify gnus-original-article-buffer)))
3616 (defun article-monafy ()
3617 "Display body part with mona font."
3619 (unless (if (featurep 'xemacs)
3620 (find-face 'gnus-mona-face)
3621 (facep 'gnus-mona-face))
3622 (require 'navi2ch-mona)
3623 (set-face-font (make-face 'gnus-mona-face) navi2ch-mona-font))
3625 (let ((buffer-read-only nil))
3628 (gnus-make-overlay (point) (point-max))
3629 'face 'gnus-mona-face))))
3636 (setq afunc (car func)
3639 gfunc (intern (format "gnus-%s" func))))
3641 (when (fboundp afunc)
3642 `(lambda (&optional interactive &rest args)
3643 ,(documentation afunc t)
3644 (interactive (list t))
3646 (set-buffer gnus-article-buffer)
3648 (call-interactively ',afunc)
3649 (apply ',afunc args))))))))
3650 '(article-hide-headers
3651 article-verify-x-pgp-sig
3652 article-verify-cancel-lock
3654 article-hide-boring-headers
3655 article-treat-overstrike
3656 article-fill-long-lines
3657 article-capitalize-sentences
3659 article-remove-leading-whitespace
3660 article-display-x-face
3661 article-display-face
3662 article-de-quoted-unreadable
3663 article-de-base64-unreadable
3666 article-unsplit-urls
3667 article-hide-list-identifiers
3668 article-strip-banner
3671 article-hide-signature
3672 article-strip-headers-in-body
3673 article-remove-trailing-blank-lines
3674 article-strip-leading-blank-lines
3675 article-strip-multiple-blank-lines
3676 article-strip-leading-space
3677 article-strip-trailing-space
3678 article-strip-blank-lines
3679 article-strip-all-blank-lines
3681 article-date-english
3682 article-date-iso8601
3683 article-date-original
3685 article-decode-mime-words
3686 article-decode-charset
3687 article-decode-encoded-words
3691 article-treat-dumbquotes
3692 article-normalize-headers
3693 (article-show-all-headers . gnus-article-show-all-headers)
3694 ;; (article-show-all . gnus-article-show-all)
3698 ;;; Gnus article mode
3701 (put 'gnus-article-mode 'mode-class 'special)
3703 (gnus-define-keys gnus-article-mode-map
3704 " " gnus-article-goto-next-page
3705 "\177" gnus-article-goto-prev-page
3706 [delete] gnus-article-goto-prev-page
3707 [backspace] gnus-article-goto-prev-page
3708 "\C-c^" gnus-article-refer-article
3709 "h" gnus-article-show-summary
3710 "s" gnus-article-show-summary
3711 "\C-c\C-m" gnus-article-mail
3712 "?" gnus-article-describe-briefly
3713 "e" gnus-summary-edit-article
3714 "<" beginning-of-buffer
3716 "\C-c\C-i" gnus-info-find-node
3718 "R" gnus-article-reply-with-original
3719 "F" gnus-article-followup-with-original
3720 "\C-hk" gnus-article-describe-key
3721 "\C-hc" gnus-article-describe-key-briefly
3723 "\C-d" gnus-article-read-summary-keys
3724 "\M-*" gnus-article-read-summary-keys
3725 "\M-#" gnus-article-read-summary-keys
3726 "\M-^" gnus-article-read-summary-keys
3727 "\M-g" gnus-article-read-summary-keys)
3729 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3733 (push (char-to-string key) keys)
3735 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3736 (setq key (car elem))
3737 (when (and (> (length key) 0)
3738 (not (eq 'menu-bar (aref key 0)))
3739 (symbolp (lookup-key gnus-summary-mode-map key)))
3742 (unless (lookup-key gnus-article-mode-map key)
3743 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3745 (defun gnus-article-make-menu-bar ()
3746 (unless (boundp 'gnus-article-commands-menu)
3747 (gnus-summary-make-menu-bar))
3748 (gnus-turn-off-edit-menu 'article)
3749 (unless (boundp 'gnus-article-article-menu)
3751 gnus-article-article-menu gnus-article-mode-map ""
3753 ["Scroll forwards" gnus-article-goto-next-page t]
3754 ["Scroll backwards" gnus-article-goto-prev-page t]
3755 ["Show summary" gnus-article-show-summary t]
3756 ["Fetch Message-ID at point" gnus-article-refer-article t]
3757 ["Mail to address at point" gnus-article-mail t]
3758 ["Send a bug report" gnus-bug t]))
3761 gnus-article-treatment-menu gnus-article-mode-map ""
3762 ;; Fixme: this should use :active (and maybe :visible).
3764 ["Hide headers" gnus-article-hide-headers t]
3765 ["Hide signature" gnus-article-hide-signature t]
3766 ["Hide citation" gnus-article-hide-citation t]
3767 ["Treat overstrike" gnus-article-treat-overstrike t]
3768 ["Remove carriage return" gnus-article-remove-cr t]
3769 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3770 ["Treat html" gnus-article-wash-html t]
3771 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3772 ["Decode HZ" gnus-article-decode-HZ t]))
3774 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3776 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3778 (gnus-run-hooks 'gnus-article-menu-hook)))
3780 (defun gnus-article-mode ()
3781 "Major mode for displaying an article.
3783 All normal editing commands are switched off.
3785 The following commands are available in addition to all summary mode
3787 \\<gnus-article-mode-map>
3788 \\[gnus-article-next-page]\t Scroll the article one page forwards
3789 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3790 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3791 \\[gnus-article-show-summary]\t Display the summary buffer
3792 \\[gnus-article-mail]\t Send a reply to the address near point
3793 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3794 \\[gnus-info-find-node]\t Go to the Gnus info node"
3796 (gnus-simplify-mode-line)
3797 (setq mode-name "Article")
3798 (setq major-mode 'gnus-article-mode)
3799 (make-local-variable 'minor-mode-alist)
3800 (unless (assq 'gnus-show-mime minor-mode-alist)
3801 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3802 (use-local-map gnus-article-mode-map)
3803 (when (gnus-visual-p 'article-menu 'menu)
3804 (gnus-article-make-menu-bar)
3805 (when gnus-summary-tool-bar-map
3806 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3807 (gnus-update-format-specifications nil 'article-mode)
3808 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3809 (set (make-local-variable 'gnus-page-broken) nil)
3810 (make-local-variable 'gnus-button-marker-list)
3811 (make-local-variable 'gnus-article-current-summary)
3812 (make-local-variable 'gnus-article-mime-handles)
3813 (make-local-variable 'gnus-article-decoded-p)
3814 (make-local-variable 'gnus-article-mime-handle-alist)
3815 (make-local-variable 'gnus-article-wash-types)
3816 (make-local-variable 'gnus-article-image-alist)
3817 (make-local-variable 'gnus-article-charset)
3818 (make-local-variable 'gnus-article-ignored-charsets)
3819 (gnus-set-default-directory)
3820 (buffer-disable-undo)
3821 (setq buffer-read-only t)
3822 (set-syntax-table gnus-article-mode-syntax-table)
3823 (gnus-run-hooks 'gnus-article-mode-hook))
3825 (defun gnus-article-setup-buffer ()
3826 "Initialize the article buffer."
3827 (let* ((name (if gnus-single-article-buffer "*Article*"
3828 (concat "*Article " gnus-newsgroup-name "*")))
3830 (progn (string-match "\\*Article" name)
3831 (concat " *Original Article"
3832 (substring name (match-end 0))))))
3833 (setq gnus-article-buffer name)
3834 (setq gnus-original-article-buffer original)
3835 (setq gnus-article-mime-handle-alist nil)
3836 ;; This might be a variable local to the summary buffer.
3837 (unless gnus-single-article-buffer
3839 (set-buffer gnus-summary-buffer)
3840 (setq gnus-article-buffer name)
3841 (setq gnus-original-article-buffer original)
3842 (gnus-set-global-variables)))
3843 (gnus-article-setup-highlight-words)
3844 ;; Init original article buffer.
3846 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3847 (set-buffer-multibyte t)
3848 (setq major-mode 'gnus-original-article-mode)
3849 (make-local-variable 'gnus-original-article))
3850 (if (get-buffer name)
3853 (when (and gnus-article-edit-mode
3856 (y-or-n-p "Article mode edit in progress; discard? ")))
3857 (error "Action aborted"))
3858 (set (make-local-variable 'gnus-article-edit-mode) nil)
3859 (buffer-disable-undo)
3860 (setq buffer-read-only t)
3861 ;; This list just keeps growing if we don't reset it.
3862 (setq gnus-button-marker-list nil)
3863 (unless (eq major-mode 'gnus-article-mode)
3864 (gnus-article-mode))
3867 (set-buffer (gnus-get-buffer-create name))
3869 (make-local-variable 'gnus-summary-buffer)
3870 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3871 (current-buffer)))))
3873 ;; Set article window start at LINE, where LINE is the number of lines
3874 ;; from the head of the article.
3875 (defun gnus-article-set-window-start (&optional line)
3877 (gnus-get-buffer-window gnus-article-buffer t)
3879 (set-buffer gnus-article-buffer)
3880 (goto-char (point-min))
3883 (gnus-message 6 "Moved to bookmark")
3884 (search-forward "\n\n" nil t)
3888 ;;; @@ article filters
3891 (defun gnus-article-display-mime-message ()
3892 "Article display method for MIME message."
3893 ;; called from `gnus-original-article-buffer'.
3894 (let (charset all-headers)
3895 (with-current-buffer gnus-summary-buffer
3896 (setq charset default-mime-charset
3897 all-headers gnus-have-all-headers))
3898 (make-local-variable 'default-mime-charset)
3899 (setq default-mime-charset charset)
3900 (with-current-buffer (get-buffer-create gnus-article-buffer)
3901 (make-local-variable 'default-mime-charset)
3902 (setq default-mime-charset charset))
3903 (mime-display-message mime-message-structure
3904 gnus-article-buffer nil gnus-article-mode-map)
3906 (gnus-article-hide-headers nil -1)))
3907 (run-hooks 'gnus-mime-article-prepare-hook))
3909 (defun gnus-article-display-traditional-message ()
3910 "Article display method for traditional message."
3911 (set-buffer gnus-article-buffer)
3912 (let (buffer-read-only)
3914 (insert-buffer-substring gnus-original-article-buffer)))
3916 (defun gnus-article-make-full-mail-header (&optional number charset)
3917 "Create a new mail header structure in a raw article buffer."
3918 (unless (and number charset)
3919 (save-current-buffer
3920 (set-buffer gnus-summary-buffer)
3922 (setq number (or (cdr gnus-article-current) 0)))
3924 (setq charset (or default-mime-charset 'x-ctext)))))
3925 (goto-char (point-min))
3926 (let ((header-end (if (search-forward "\n\n" nil t)
3928 (goto-char (point-max))))
3929 (chars (- (point-max) (point)))
3930 (lines (count-lines (point) (point-max)))
3931 (default-mime-charset charset)
3933 (narrow-to-region (point-min) header-end)
3934 (setq xref (std11-fetch-field "xref"))
3936 (make-full-mail-header
3938 (std11-fetch-field "subject")
3939 (std11-fetch-field "from")
3940 (std11-fetch-field "date")
3941 (std11-fetch-field "message-id")
3942 (std11-fetch-field "references")
3945 (when xref (concat "Xref: " xref)))
3948 (defun gnus-article-prepare (article &optional all-headers header)
3949 "Prepare ARTICLE in article mode buffer.
3950 ARTICLE should either be an article number or a Message-ID.
3951 If ARTICLE is an id, HEADER should be the article headers.
3952 If ALL-HEADERS is non-nil, no headers are hidden."
3954 ;; Make sure we start in a summary buffer.
3955 (unless (eq major-mode 'gnus-summary-mode)
3956 (set-buffer gnus-summary-buffer))
3957 (setq gnus-summary-buffer (current-buffer))
3958 (let* ((gnus-article (if header (mail-header-number header) article))
3959 (summary-buffer (current-buffer))
3960 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3961 (group gnus-newsgroup-name)
3964 (gnus-article-setup-buffer)
3965 (set-buffer gnus-article-buffer)
3966 ;; Deactivate active regions.
3967 (when (and (boundp 'transient-mark-mode)
3968 transient-mark-mode)
3969 (setq mark-active nil))
3970 (if (not (setq result (let ((buffer-read-only nil))
3971 (gnus-request-article-this-buffer
3973 ;; There is no such article.
3975 (when (and (numberp article)
3976 (not (memq article gnus-newsgroup-sparse)))
3977 (setq gnus-article-current
3978 (cons gnus-newsgroup-name article))
3979 (set-buffer gnus-summary-buffer)
3980 (setq gnus-current-article article)
3981 (if (and (memq article gnus-newsgroup-undownloaded)
3982 (not (gnus-online (gnus-find-method-for-group
3983 gnus-newsgroup-name))))
3985 (gnus-summary-set-agent-mark article)
3986 (message "Message marked for downloading"))
3987 (gnus-summary-mark-article article gnus-canceled-mark)
3988 (unless (memq article gnus-newsgroup-sparse)
3989 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3990 (if (or (eq result 'pseudo)
3991 (eq result 'nneething))
3994 (set-buffer summary-buffer)
3995 (push article gnus-newsgroup-history)
3996 (setq gnus-last-article gnus-current-article
3997 gnus-current-article 0
3998 gnus-current-headers nil
3999 gnus-article-current nil)
4000 (if (eq result 'nneething)
4001 (gnus-configure-windows 'summary)
4002 (gnus-configure-windows 'article))
4003 (gnus-set-global-variables))
4004 (let ((gnus-article-mime-handle-alist-1
4005 gnus-article-mime-handle-alist))
4006 (gnus-set-mode-line 'article)))
4007 ;; The result from the `request' was an actual article -
4008 ;; or at least some text that is now displayed in the
4010 (when (and (numberp article)
4011 (not (eq article gnus-current-article)))
4012 ;; Seems like a new article has been selected.
4013 ;; `gnus-current-article' must be an article number.
4015 (set-buffer summary-buffer)
4016 (push article gnus-newsgroup-history)
4017 (setq gnus-last-article gnus-current-article
4018 gnus-current-article article
4019 gnus-current-headers
4020 (gnus-summary-article-header gnus-current-article)
4021 gnus-article-current
4022 (cons gnus-newsgroup-name gnus-current-article))
4023 (unless (vectorp gnus-current-headers)
4024 (setq gnus-current-headers nil))
4025 (gnus-summary-goto-subject gnus-current-article)
4026 (when (gnus-summary-show-thread)
4027 ;; If the summary buffer really was folded, the
4028 ;; previous goto may not actually have gone to
4029 ;; the right article, but the thread root instead.
4031 (gnus-summary-goto-subject gnus-current-article))
4032 (gnus-run-hooks 'gnus-mark-article-hook)
4033 (gnus-set-mode-line 'summary)
4034 (when (gnus-visual-p 'article-highlight 'highlight)
4035 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4036 ;; Set the global newsgroup variables here.
4037 (gnus-set-global-variables)
4038 (setq gnus-have-all-headers
4039 (or all-headers gnus-show-all-headers))))
4041 (gnus-configure-windows 'article))
4042 (when (or (numberp article)
4044 (gnus-article-prepare-display)
4046 (goto-char (point-min))
4047 (when gnus-break-pages
4048 (gnus-narrow-to-page)))
4049 (let ((gnus-article-mime-handle-alist-1
4050 gnus-article-mime-handle-alist))
4051 (gnus-set-mode-line 'article))
4055 (set-window-point (get-buffer-window (current-buffer)) (point))
4056 (gnus-configure-windows 'article)
4059 (defun gnus-article-prepare-mime-display (&optional number)
4060 (goto-char (point-min))
4061 (when (re-search-forward "^[^\t ]+:" nil t)
4062 (goto-char (match-beginning 0)))
4063 (let ((entity (if (eq 1 (point-min))
4064 (get-text-property 1 'mime-view-entity)
4065 (get-text-property (point) 'mime-view-entity)))
4066 last-entity child-entity next type)
4067 (setq child-entity (mime-entity-children entity))
4069 (setq last-entity (nth (1- (length child-entity))
4071 (setq last-entity entity))
4073 (narrow-to-region (point)
4074 (if (search-forward "\n\n" nil t)
4077 (gnus-treat-article 'head)
4078 (put-text-property (point-min) (point-max) 'article-treated-header t)
4079 (goto-char (point-max)))
4080 (while (and (not (eobp)) entity)
4081 (setq next (set-marker
4083 (next-single-property-change (point) 'mime-view-entity
4085 (let ((types (mime-entity-content-type entity)))
4086 (while (eq 'multipart (mime-content-type-primary-type types))
4087 (setq entity (car (mime-entity-children entity))
4088 types (mime-entity-content-type entity)))
4090 (setq type (format "%s/%s"
4091 (mime-content-type-primary-type types)
4092 (mime-content-type-subtype types)))))
4093 (if (string-equal type "message/rfc822")
4096 (let ((children (mime-entity-children entity))
4099 (setq last-children (nth (1- (length children)) children))
4102 (not (eq last-children
4103 (get-text-property next 'mime-view-entity)))
4105 (next-single-property-change next
4107 nil (point-max)))))))
4108 (setq next (next-single-property-change next 'mime-view-entity
4111 (narrow-to-region (point) next)
4112 (gnus-article-prepare-mime-display)
4113 (goto-char (point-max)))
4114 (setq entity (get-text-property (point) 'mime-view-entity)))
4116 (narrow-to-region (point) next)
4117 ;; Kludge. We have to count true number, but for now,
4118 ;; part number is here only to achieve `last'.
4119 (gnus-treat-article nil 1
4120 (if (eq entity last-entity)
4123 (goto-char (point-max)))
4124 (setq entity (get-text-property next 'mime-view-entity))))))
4127 (defun gnus-article-prepare-display ()
4128 "Make the current buffer look like a nice article."
4129 (let ((gnus-article-buffer (current-buffer))
4131 (unless (eq major-mode 'gnus-article-mode)
4132 (gnus-article-mode))
4133 (setq buffer-read-only nil
4134 gnus-button-marker-list nil
4135 gnus-article-wash-types nil
4136 gnus-article-image-alist nil)
4139 (static-if (featurep 'xemacs)
4140 (map-extents (lambda (extent maparg) (delete-extent extent)))
4141 (let ((lists (overlay-lists)))
4142 (dolist (overlay (nconc (car lists) (cdr lists)))
4143 (delete-overlay overlay)))))
4144 (gnus-run-hooks 'gnus-tmp-internal-hook))
4145 (let ((show-mime (unless (member gnus-newsgroup-name '("nndraft:delayed"
4148 (inhibit-read-only t))
4149 (set-buffer gnus-original-article-buffer)
4151 (setq mime-message-structure gnus-current-headers)
4152 (mime-buffer-entity-set-buffer-internal mime-message-structure
4153 gnus-original-article-buffer)
4154 (mime-entity-set-representation-type-internal mime-message-structure
4155 'mime-buffer-entity)
4156 (luna-send mime-message-structure 'initialize-instance
4157 mime-message-structure)
4159 (let (mime-display-header-hook mime-display-text/plain-hook)
4160 (funcall gnus-article-display-method-for-mime))
4161 (funcall gnus-article-display-method-for-traditional))
4162 ;; Call the treatment functions.
4166 (gnus-article-prepare-mime-display)
4167 (narrow-to-region (goto-char (point-min))
4168 (if (search-forward "\n\n" nil t)
4171 (gnus-treat-article 'head)
4172 (put-text-property (point-min) (point-max) 'article-treated-header t)
4173 (goto-char (point-max))
4175 (narrow-to-region (point) (point-max))
4176 (gnus-treat-article nil))
4177 (put-text-property (point-min) (point-max) 'read-only nil)))
4178 (gnus-run-hooks 'gnus-article-prepare-hook))
4180 (defun gnus-article-decode-article-as-default-mime-charset ()
4181 "Decode an article as `default-mime-charset'. It won't work if the
4182 value of the variable `gnus-show-mime' is non-nil."
4183 (unless (or gnus-show-mime
4184 (member gnus-newsgroup-name '("nndraft:delayed"
4186 (set (make-local-variable 'default-mime-charset)
4187 (with-current-buffer gnus-summary-buffer
4188 default-mime-charset))
4189 (decode-mime-charset-region (point-min) (point-max)
4190 default-mime-charset)))
4193 ;;; Gnus MIME viewing functions
4196 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4197 "Format of the MIME buttons.
4199 Valid specifiers include:
4201 %T MIME type, along with additional info
4202 %n The `name' parameter
4203 %d The description, if any
4204 %l The length of the encoded part
4205 %p The part identifier number
4206 %e Dots if the part isn't displayed
4208 General format specifiers can also be used. See Info node
4209 `(gnus)Formatting Variables'.")
4211 (defvar gnus-mime-button-line-format-alist
4212 '((?t gnus-tmp-type ?s)
4213 (?T gnus-tmp-type-long ?s)
4214 (?n gnus-tmp-name ?s)
4215 (?d gnus-tmp-description ?s)
4217 (?l gnus-tmp-length ?d)
4218 (?e gnus-tmp-dots ?s)))
4220 (defvar gnus-mime-button-commands
4221 '((gnus-article-press-button "\r" "Toggle Display")
4222 (gnus-mime-view-part "v" "View Interactively...")
4223 (gnus-mime-view-part-as-type "t" "View As Type...")
4224 (gnus-mime-view-part-as-charset "C" "View As charset...")
4225 (gnus-mime-save-part "o" "Save...")
4226 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4227 (gnus-mime-delete-part "d" "Delete part")
4228 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4229 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4230 (gnus-mime-view-part-internally "E" "View Internally")
4231 (gnus-mime-view-part-externally "e" "View Externally")
4232 (gnus-mime-print-part "p" "Print")
4233 (gnus-mime-pipe-part "|" "Pipe To Command...")
4234 (gnus-mime-action-on-part "." "Take action on the part...")))
4236 (defun gnus-article-mime-part-status ()
4237 (with-current-buffer gnus-article-buffer
4238 (let ((entity (get-text-property (point-min) 'mime-view-entity))
4241 (setq children (mime-entity-children entity))
4242 (setq children (length children)))
4245 (format " (%d parts)" children))
4248 (defvar gnus-mime-button-map
4249 (let ((map (make-sparse-keymap)))
4250 (unless (>= (string-to-number emacs-version) 21)
4251 ;; XEmacs doesn't care.
4252 (set-keymap-parent map gnus-article-mode-map))
4253 (define-key map gnus-mouse-2 'gnus-article-push-button)
4254 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4255 (dolist (c gnus-mime-button-commands)
4256 (define-key map (cadr c) (car c)))
4260 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4262 ,@(mapcar (lambda (c)
4263 (vector (caddr c) (car c) :enable t))
4264 gnus-mime-button-commands)))
4267 (define-compiler-macro popup-menu (&whole form
4268 menu &optional position prefix)
4269 (if (and (fboundp 'popup-menu)
4270 (not (memq 'popup-menu (assoc "lmenu" load-history))))
4272 ;; Gnus is probably running under Emacs 20.
4273 `(let* ((menu (cdr ,menu))
4274 (response (x-popup-menu
4276 (cons "" (mapcar (lambda (c)
4277 (cons (caddr c) (car c)))
4280 (call-interactively (nth 3 (assq response menu))))))))
4282 (defun gnus-mime-button-menu (event prefix)
4283 "Construct a context-sensitive menu of MIME commands."
4284 (interactive "e\nP")
4285 (save-window-excursion
4286 (let ((pos (event-start event)))
4287 (select-window (posn-window pos))
4288 (goto-char (posn-point pos))
4289 (gnus-article-check-buffer)
4290 (popup-menu gnus-mime-button-menu nil prefix))))
4292 (defun gnus-mime-view-all-parts (&optional handles)
4293 "View all the MIME parts."
4295 (save-current-buffer
4296 (set-buffer gnus-article-buffer)
4297 (let ((handles (or handles gnus-article-mime-handles))
4298 (mail-parse-charset gnus-newsgroup-charset)
4299 (mail-parse-ignored-charsets
4300 (with-current-buffer gnus-summary-buffer
4301 gnus-newsgroup-ignored-charsets)))
4303 (mm-remove-parts handles)
4304 (goto-char (point-min))
4305 (or (search-forward "\n\n") (goto-char (point-max)))
4306 (let (buffer-read-only)
4307 (delete-region (point) (point-max))
4308 (mm-display-parts handles))))))
4310 (defun gnus-mime-save-part-and-strip ()
4311 "Save the MIME part under point then replace it with an external body."
4313 (gnus-article-check-buffer)
4314 (let* ((data (get-text-property (point) 'gnus-data))
4316 (handles gnus-article-mime-handles))
4317 (if (mm-multiple-handles gnus-article-mime-handles)
4318 (error "This function is not implemented"))
4319 (setq file (and data (mm-save-part data)))
4321 (with-current-buffer (mm-handle-buffer data)
4323 (insert "Content-Type: " (mm-handle-media-type data))
4324 (mml-insert-parameter-string (cdr (mm-handle-type data))
4327 (insert "Content-ID: " (message-make-message-id) "\n")
4328 (insert "Content-Transfer-Encoding: binary\n")
4331 (cdr (mm-make-handle nil
4332 `("message/external-body"
4333 (access-type . "LOCAL-FILE")
4335 (set-buffer gnus-summary-buffer)
4336 (gnus-article-edit-article
4339 (let ((mail-parse-charset (or gnus-article-charset
4340 ',gnus-newsgroup-charset))
4341 (mail-parse-ignored-charsets
4342 (or gnus-article-ignored-charsets
4343 ',gnus-newsgroup-ignored-charsets))
4344 (mbl mml-buffer-list))
4345 (setq mml-buffer-list nil)
4346 (insert-buffer gnus-original-article-buffer)
4347 (mime-to-mml ',handles)
4348 (setq gnus-article-mime-handles nil)
4349 (let ((mbl1 mml-buffer-list))
4350 (setq mml-buffer-list mbl)
4351 (set (make-local-variable 'mml-buffer-list) mbl1))
4352 (gnus-make-local-hook 'kill-buffer-hook)
4353 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4354 `(lambda (no-highlight)
4355 (let ((mail-parse-charset (or gnus-article-charset
4356 ',gnus-newsgroup-charset))
4357 (message-options message-options)
4358 (message-options-set-recipient)
4359 (mail-parse-ignored-charsets
4360 (or gnus-article-ignored-charsets
4361 ',gnus-newsgroup-ignored-charsets)))
4363 (mml-destroy-buffers)
4364 (remove-hook 'kill-buffer-hook
4365 'mml-destroy-buffers t)
4366 (kill-local-variable 'mml-buffer-list))
4367 (gnus-summary-edit-article-done
4368 ,(or (mail-header-references gnus-current-headers) "")
4369 ,(gnus-group-read-only-p)
4370 ,gnus-summary-buffer no-highlight))))))
4372 (defun gnus-mime-delete-part ()
4373 "Delete the MIME part under point.
4374 Replace it with some information about the removed part."
4376 (gnus-article-check-buffer)
4377 (unless (and gnus-novice-user
4378 (not (gnus-yes-or-no-p
4379 "Really delete attachment forever? ")))
4380 (let* ((data (get-text-property (point) 'gnus-data))
4381 (handles gnus-article-mime-handles)
4385 (mail-decode-encoded-word-string (or (mm-handle-description data)
4388 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4390 (type (mm-handle-media-type data)))
4391 (if (mm-multiple-handles gnus-article-mime-handles)
4392 (error "This function is not implemented"))
4393 (with-current-buffer (mm-handle-buffer data)
4394 (let ((bsize (format "%s" (buffer-size))))
4399 "| The following attachment has been deleted:\n"
4401 "| Type: " type "\n"
4402 "| Filename: " filename "\n"
4403 "| Size (encoded): " bsize " Byte\n"
4404 "| Description: " description "\n"
4407 (cdr (mm-make-handle
4408 nil `("text/plain") nil nil
4410 (format "Deleted attachment (%s bytes)" bsize))))))
4411 (set-buffer gnus-summary-buffer)
4412 ;; FIXME: maybe some of the following code (borrowed from
4413 ;; `gnus-mime-save-part-and-strip') isn't necessary?
4414 (gnus-article-edit-article
4417 (let ((mail-parse-charset (or gnus-article-charset
4418 ',gnus-newsgroup-charset))
4419 (mail-parse-ignored-charsets
4420 (or gnus-article-ignored-charsets
4421 ',gnus-newsgroup-ignored-charsets))
4422 (mbl mml-buffer-list))
4423 (setq mml-buffer-list nil)
4424 (insert-buffer gnus-original-article-buffer)
4425 (mime-to-mml ',handles)
4426 (setq gnus-article-mime-handles nil)
4427 (let ((mbl1 mml-buffer-list))
4428 (setq mml-buffer-list mbl)
4429 (set (make-local-variable 'mml-buffer-list) mbl1))
4430 (gnus-make-local-hook 'kill-buffer-hook)
4431 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4432 `(lambda (no-highlight)
4433 (let ((mail-parse-charset (or gnus-article-charset
4434 ',gnus-newsgroup-charset))
4435 (message-options message-options)
4436 (message-options-set-recipient)
4437 (mail-parse-ignored-charsets
4438 (or gnus-article-ignored-charsets
4439 ',gnus-newsgroup-ignored-charsets)))
4441 (mml-destroy-buffers)
4442 (remove-hook 'kill-buffer-hook
4443 'mml-destroy-buffers t)
4444 (kill-local-variable 'mml-buffer-list))
4445 (gnus-summary-edit-article-done
4446 ,(or (mail-header-references gnus-current-headers) "")
4447 ,(gnus-group-read-only-p)
4448 ,gnus-summary-buffer no-highlight)))))
4449 ;; Not in `gnus-mime-save-part-and-strip':
4450 (gnus-article-edit-done)
4451 (gnus-summary-expand-window)
4452 (gnus-summary-show-article))
4454 (defun gnus-mime-save-part ()
4455 "Save the MIME part under point."
4457 (gnus-article-check-buffer)
4458 (let ((data (get-text-property (point) 'gnus-data)))
4460 (mm-save-part data))))
4462 (defun gnus-mime-pipe-part ()
4463 "Pipe the MIME part under point to a process."
4465 (gnus-article-check-buffer)
4466 (let ((data (get-text-property (point) 'gnus-data)))
4468 (mm-pipe-part data))))
4470 (defun gnus-mime-view-part ()
4471 "Interactively choose a viewing method for the MIME part under point."
4473 (gnus-article-check-buffer)
4474 (let ((data (get-text-property (point) 'gnus-data)))
4476 (setq gnus-article-mime-handles
4478 gnus-article-mime-handles (setq data (copy-sequence data))))
4479 (mm-interactively-view-part data))))
4481 (defun gnus-mime-view-part-as-type-internal ()
4482 (gnus-article-check-buffer)
4483 (let* ((name (mail-content-type-get
4484 (mm-handle-type (get-text-property (point) 'gnus-data))
4486 (def-type (and name (mm-default-file-encoding name))))
4487 (and def-type (cons def-type 0))))
4489 (defun gnus-mime-view-part-as-type (&optional mime-type)
4490 "Choose a MIME media type, and view the part as such."
4493 (setq mime-type (completing-read
4494 "View as MIME type: "
4495 (mapcar #'list (mailcap-mime-types))
4497 (gnus-mime-view-part-as-type-internal))))
4498 (gnus-article-check-buffer)
4499 (let ((handle (get-text-property (point) 'gnus-data)))
4502 (mm-make-handle (mm-handle-buffer handle)
4503 (cons mime-type (cdr (mm-handle-type handle)))
4504 (mm-handle-encoding handle)
4505 (mm-handle-undisplayer handle)
4506 (mm-handle-disposition handle)
4507 (mm-handle-description handle)
4509 (mm-handle-id handle)))
4510 (setq gnus-article-mime-handles
4511 (mm-merge-handles gnus-article-mime-handles handle))
4512 (gnus-mm-display-part handle))))
4515 (require 'jka-compr))
4517 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4518 ;; emacs can do that itself.
4520 (defun gnus-mime-jka-compr-maybe-uncompress ()
4521 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4522 The uncompress method used is derived from `buffer-file-name'."
4523 (when (and (fboundp 'jka-compr-installed-p)
4524 (jka-compr-installed-p))
4525 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4527 (let ((basename (file-name-nondirectory buffer-file-name))
4528 (args (jka-compr-info-uncompress-args info))
4529 (prog (jka-compr-info-uncompress-program info))
4530 (message (jka-compr-info-uncompress-message info))
4531 (err-file (jka-compr-make-temp-name)))
4533 (message "%s %s..." message basename))
4535 (unless (memq (apply 'call-process-region
4536 (point-min) (point-max)
4538 t (list t err-file) nil
4540 jka-compr-acceptable-retval-list)
4541 (jka-compr-error prog args basename message err-file))
4542 (jka-compr-delete-temp-file err-file)))))))
4544 (defun gnus-mime-copy-part (&optional handle)
4545 "Put the MIME part under point into a new buffer.
4546 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4549 (gnus-article-check-buffer)
4550 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4551 (contents (and handle (mm-get-part handle)))
4553 (file-name-nondirectory
4555 (mail-content-type-get (mm-handle-type handle) 'name)
4556 (mail-content-type-get (mm-handle-disposition handle)
4559 (buffer (and base (generate-new-buffer base))))
4561 (switch-to-buffer buffer)
4563 ;; We do it this way to make `normal-mode' set the appropriate mode.
4566 (setq buffer-file-name (expand-file-name base))
4567 (gnus-mime-jka-compr-maybe-uncompress)
4569 (setq buffer-file-name nil))
4570 (goto-char (point-min)))))
4572 (defun gnus-mime-print-part (&optional handle filename)
4573 "Print the MIME part under point."
4574 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4575 (gnus-article-check-buffer)
4576 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4577 (contents (and handle (mm-get-part handle)))
4578 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4579 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4584 (mm-save-part-to-file handle file)
4585 (call-process shell-file-name nil
4586 (generate-new-buffer " *mm*")
4588 shell-command-switch
4590 printer file (mm-handle-type handle))))
4594 (gnus-print-buffer))
4595 (ps-despool filename)))))
4597 (defun gnus-mime-inline-part (&optional handle arg)
4598 "Insert the MIME part under point into the current buffer."
4599 (interactive (list nil current-prefix-arg))
4600 (gnus-article-check-buffer)
4601 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4606 (if (and (not arg) (mm-handle-undisplayer handle))
4607 (mm-remove-part handle)
4608 (setq contents (mm-get-part handle))
4611 (setq charset (or (mail-content-type-get
4612 (mm-handle-type handle) 'charset)
4613 gnus-newsgroup-charset)))
4615 (if (mm-handle-undisplayer handle)
4616 (mm-remove-part handle))
4619 gnus-summary-show-article-charset-alist))
4620 (mm-read-coding-system "Charset: ")))))
4622 (mm-insert-inline handle
4624 (setq charset (mm-charset-to-coding-system
4626 (not (eq charset 'ascii)))
4627 (mm-decode-coding-string contents charset)
4631 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4632 "Insert the MIME part under point into the current buffer using the
4634 (interactive (list nil current-prefix-arg))
4635 (gnus-article-check-buffer)
4636 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4641 (if (mm-handle-undisplayer handle)
4642 (mm-remove-part handle))
4643 (let ((gnus-newsgroup-charset
4645 gnus-summary-show-article-charset-alist))
4646 (mm-read-coding-system "Charset: ")))
4647 (gnus-newsgroup-ignored-charsets 'gnus-all))
4648 (gnus-article-press-button)))))
4650 (defun gnus-mime-view-part-externally (&optional handle)
4651 "View the MIME part under point with an external viewer."
4653 (gnus-article-check-buffer)
4654 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4655 (mm-user-display-methods nil)
4656 (mm-inlined-types nil)
4657 (mail-parse-charset gnus-newsgroup-charset)
4658 (mail-parse-ignored-charsets
4659 (save-excursion (set-buffer gnus-summary-buffer)
4660 gnus-newsgroup-ignored-charsets)))
4662 (if (mm-handle-undisplayer handle)
4663 (mm-remove-part handle)
4664 (mm-display-part handle)))))
4666 (defun gnus-mime-view-part-internally (&optional handle)
4667 "View the MIME part under point with an internal viewer.
4668 If no internal viewer is available, use an external viewer."
4670 (gnus-article-check-buffer)
4671 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4672 (mm-inlined-types '(".*"))
4673 (mm-inline-large-images t)
4674 (mail-parse-charset gnus-newsgroup-charset)
4675 (mail-parse-ignored-charsets
4676 (save-excursion (set-buffer gnus-summary-buffer)
4677 gnus-newsgroup-ignored-charsets))
4680 (if (mm-handle-undisplayer handle)
4681 (mm-remove-part handle)
4682 (mm-display-part handle)))))
4684 (defun gnus-mime-action-on-part (&optional action)
4685 "Do something with the MIME attachment at \(point\)."
4687 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4688 (gnus-article-check-buffer)
4689 (let ((action-pair (assoc action gnus-mime-action-alist)))
4691 (funcall (cdr action-pair)))))
4693 (defun gnus-article-part-wrapper (n function)
4694 (save-current-buffer
4695 (set-buffer gnus-article-buffer)
4696 (when (> n (length gnus-article-mime-handle-alist))
4697 (error "No such part"))
4698 (gnus-article-goto-part n)
4699 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4700 (funcall function handle))))
4702 (defun gnus-article-pipe-part (n)
4703 "Pipe MIME part N, which is the numerical prefix."
4705 (gnus-article-part-wrapper n 'mm-pipe-part))
4707 (defun gnus-article-save-part (n)
4708 "Save MIME part N, which is the numerical prefix."
4710 (gnus-article-part-wrapper n 'mm-save-part))
4712 (defun gnus-article-interactively-view-part (n)
4713 "View MIME part N interactively, which is the numerical prefix."
4715 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4717 (defun gnus-article-copy-part (n)
4718 "Copy MIME part N, which is the numerical prefix."
4720 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4722 (defun gnus-article-view-part-as-charset (n)
4723 "View MIME part N using a specified charset.
4724 N is the numerical prefix."
4726 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4728 (defun gnus-article-view-part-externally (n)
4729 "View MIME part N externally, which is the numerical prefix."
4731 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4733 (defun gnus-article-inline-part (n)
4734 "Inline MIME part N, which is the numerical prefix."
4736 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4738 (defun gnus-article-mime-match-handle-first (condition)
4740 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4741 (while (setq ihandle (pop alist))
4743 ((functionp condition)
4744 (funcall condition (cdr ihandle)))
4745 ((eq condition 'undisplayed)
4746 (not (or (mm-handle-undisplayer (cdr ihandle))
4747 (equal (mm-handle-media-type (cdr ihandle))
4748 "multipart/alternative"))))
4749 ((eq condition 'undisplayed-alternative)
4750 (not (mm-handle-undisplayer (cdr ihandle))))
4752 (gnus-article-goto-part (car ihandle))
4753 (or (not n) (< (car ihandle) n)))
4754 (setq n (car ihandle))))
4758 (defun gnus-article-view-part (&optional n)
4759 "View MIME part N, which is the numerical prefix."
4761 (save-current-buffer
4762 (set-buffer gnus-article-buffer)
4763 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4764 gnus-article-mime-match-handle-function)))
4765 (when (> n (length gnus-article-mime-handle-alist))
4766 (error "No such part"))
4767 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4768 (when (gnus-article-goto-part n)
4769 (if (equal (car handle) "multipart/alternative")
4770 (gnus-article-press-button)
4771 (when (eq (gnus-mm-display-part handle) 'internal)
4772 (gnus-set-window-start)))))))
4774 (defsubst gnus-article-mime-total-parts ()
4775 (if (bufferp (car gnus-article-mime-handles))
4777 (1- (length gnus-article-mime-handles))))
4779 (defun gnus-mm-display-part (handle)
4780 "Display HANDLE and fix MIME button."
4781 (let ((id (get-text-property (point) 'gnus-part))
4786 (let ((window (selected-window))
4787 (mail-parse-charset gnus-newsgroup-charset)
4788 (mail-parse-ignored-charsets
4789 (if (gnus-buffer-live-p gnus-summary-buffer)
4791 (set-buffer gnus-summary-buffer)
4792 gnus-newsgroup-ignored-charsets)
4796 (let ((win (gnus-get-buffer-window (current-buffer) t))
4799 (select-window win))
4802 (if (mm-handle-displayed-p handle)
4803 ;; This will remove the part.
4804 (mm-display-part handle)
4806 (narrow-to-region (point)
4807 (if (eobp) (point) (1+ (point))))
4808 (mm-display-part handle)
4809 ;; We narrow to the part itself and
4810 ;; then call the treatment functions.
4811 (goto-char (point-min))
4813 (narrow-to-region (point) (point-max))
4816 (gnus-article-mime-total-parts)
4817 (mm-handle-media-type handle)))))
4818 (if (window-live-p window)
4819 (select-window window)))))
4822 (gnus-insert-mime-button
4823 handle id (list (mm-handle-displayed-p handle)))
4824 (goto-char point))))
4826 (defun gnus-article-goto-part (n)
4827 "Go to MIME part N."
4828 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4830 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4831 (let ((gnus-tmp-name
4832 (or (mail-content-type-get (mm-handle-type handle) 'name)
4833 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4834 (mail-content-type-get (mm-handle-type handle) 'url)
4836 (gnus-tmp-type (mm-handle-media-type handle))
4837 (gnus-tmp-description
4838 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4841 (if (if displayed (car displayed)
4842 (mm-handle-displayed-p handle))
4844 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4846 gnus-tmp-type-long b e)
4847 (when (string-match ".*/" gnus-tmp-name)
4848 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4849 (setq gnus-tmp-type-long (concat gnus-tmp-type
4850 (and (not (equal gnus-tmp-name ""))
4851 (concat "; " gnus-tmp-name))))
4852 (unless (equal gnus-tmp-description "")
4853 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4858 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4859 `(,@(gnus-local-map-property gnus-mime-button-map)
4860 gnus-callback gnus-mm-display-part
4861 gnus-part ,gnus-tmp-id
4862 article-type annotation
4865 ;; Exclude a newline.
4868 (widget-convert-button
4871 :action 'gnus-widget-press-button
4872 :button-keymap gnus-mime-button-map
4874 (lambda (widget/window &optional overlay pos)
4875 ;; Needed to properly clear the message due to a bug in
4876 ;; wid-edit (XEmacs only).
4877 (if (boundp 'help-echo-owns-message)
4878 (setq help-echo-owns-message t))
4880 "%S: %s the MIME part; %S: more options"
4881 (aref gnus-mouse-2 0)
4882 ;; XEmacs will get a single widget arg; Emacs 21 will get
4883 ;; window, overlay, position.
4884 (if (mm-handle-displayed-p
4886 (with-current-buffer (gnus-overlay-buffer overlay)
4887 (widget-get (widget-at (gnus-overlay-start overlay))
4889 (widget-get widget/window :mime-handle)))
4891 (aref gnus-down-mouse-3 0))))))
4893 (defun gnus-widget-press-button (elems el)
4894 (goto-char (widget-get elems :from))
4895 (gnus-article-press-button))
4897 (defvar gnus-displaying-mime nil)
4899 (defun gnus-display-mime (&optional ihandles)
4900 "Display the MIME parts."
4902 (save-selected-window
4903 (let ((window (get-buffer-window gnus-article-buffer))
4906 (select-window window)
4907 ;; We have to do this since selecting the window
4908 ;; may change the point. So we set the window point.
4909 (set-window-point window point)))
4910 (let* ((handles (or ihandles
4911 (mm-dissect-buffer nil gnus-article-loose-mime)
4912 (and gnus-article-emulate-mime
4914 buffer-read-only handle name type b e display)
4915 (when (and (not ihandles)
4916 (not gnus-displaying-mime))
4917 ;; Top-level call; we clean up.
4918 (when gnus-article-mime-handles
4919 (mm-destroy-parts gnus-article-mime-handles)
4920 (setq gnus-article-mime-handle-alist nil));; A trick.
4921 (setq gnus-article-mime-handles handles)
4922 ;; We allow users to glean info from the handles.
4923 (when gnus-article-mime-part-function
4924 (gnus-mime-part-function handles)))
4926 (or (not (stringp (car handles)))
4929 (when (and (not ihandles)
4930 (not gnus-displaying-mime))
4931 ;; Clean up for mime parts.
4933 (delete-region (point) (point-max)))
4934 (let ((gnus-displaying-mime t))
4935 (gnus-mime-display-part handles)))
4938 (narrow-to-region (point) (point-max))
4939 (gnus-treat-article nil 1 1)
4942 ;; Highlight the headers.
4946 (narrow-to-region (point-min) (point))
4947 (gnus-treat-article 'head))))))))
4949 (defcustom gnus-mime-display-multipart-as-mixed nil
4950 "Display \"multipart\" parts as \"multipart/mixed\".
4952 If t, it overrides nil values of
4953 `gnus-mime-display-multipart-alternative-as-mixed' and
4954 `gnus-mime-display-multipart-related-as-mixed'."
4955 :group 'gnus-article-mime
4958 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4959 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4960 :group 'gnus-article-mime
4963 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4964 "Display \"multipart/related\" parts as \"multipart/mixed\".
4966 If displaying \"text/html\" is discouraged \(see
4967 `mm-discouraged-alternatives'\) images or other material inside a
4968 \"multipart/related\" part might be overlooked when this variable is nil."
4969 :group 'gnus-article-mime
4972 (defun gnus-mime-display-part (handle)
4975 ((not (stringp (car handle)))
4976 (gnus-mime-display-single handle))
4977 ;; User-defined multipart
4978 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4979 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4981 ;; multipart/alternative
4982 ((and (equal (car handle) "multipart/alternative")
4983 (not (or gnus-mime-display-multipart-as-mixed
4984 gnus-mime-display-multipart-alternative-as-mixed)))
4985 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4986 (push (cons id handle) gnus-article-mime-handle-alist)
4987 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4988 ;; multipart/related
4989 ((and (equal (car handle) "multipart/related")
4990 (not (or gnus-mime-display-multipart-as-mixed
4991 gnus-mime-display-multipart-related-as-mixed)))
4992 ;;;!!!We should find the start part, but we just default
4993 ;;;!!!to the first part.
4994 ;;(gnus-mime-display-part (cadr handle))
4995 ;;;!!! Most multipart/related is an HTML message plus images.
4996 ;;;!!! Unfortunately we are unable to let W3 display those
4997 ;;;!!! included images, so we just display it as a mixed multipart.
4998 ;;(gnus-mime-display-mixed (cdr handle))
4999 ;;;!!! No, w3 can display everything just fine.
5000 (gnus-mime-display-part (cadr handle)))
5001 ((equal (car handle) "multipart/signed")
5002 (gnus-add-wash-type 'signed)
5003 (gnus-mime-display-security handle))
5004 ((equal (car handle) "multipart/encrypted")
5005 (gnus-add-wash-type 'encrypted)
5006 (gnus-mime-display-security handle))
5007 ;; Other multiparts are handled like multipart/mixed.
5009 (gnus-mime-display-mixed (cdr handle)))))
5011 (defun gnus-mime-part-function (handles)
5012 (if (stringp (car handles))
5013 (mapcar 'gnus-mime-part-function (cdr handles))
5014 (funcall gnus-article-mime-part-function handles)))
5016 (defun gnus-mime-display-mixed (handles)
5017 (mapcar 'gnus-mime-display-part handles))
5019 (defun gnus-mime-display-single (handle)
5020 (let ((type (mm-handle-media-type handle))
5021 (ignored gnus-ignored-mime-types)
5028 (when (string-match (pop ignored) type)
5029 (throw 'ignored nil)))
5030 (if (and (setq not-attachment
5031 (and (not (mm-inline-override-p handle))
5032 (or (not (mm-handle-disposition handle))
5033 (equal (car (mm-handle-disposition handle))
5035 (mm-attachment-override-p handle))))
5036 (mm-automatic-display-p handle)
5038 (mm-inlinable-p handle)
5039 (mm-inlined-p handle))
5040 (mm-automatic-external-display-p type)))
5042 (when (equal (mm-handle-media-supertype handle) "text")
5044 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5046 (push (cons id handle) gnus-article-mime-handle-alist)
5047 (when (or (not display)
5048 (not (gnus-unbuttonized-mime-type-p type)))
5049 ;(gnus-article-insert-newline)
5050 (gnus-insert-mime-button
5051 handle id (list (or display (and not-attachment text))))
5052 (gnus-article-insert-newline)
5053 ;(gnus-article-insert-newline)
5054 ;; Remember modify the number of forward lines.
5062 (let ((mail-parse-charset gnus-newsgroup-charset)
5063 (mail-parse-ignored-charsets
5064 (save-excursion (condition-case ()
5065 (set-buffer gnus-summary-buffer)
5067 gnus-newsgroup-ignored-charsets)))
5068 (mm-display-part handle t))
5069 (goto-char (point-max)))
5070 ((and text not-attachment)
5074 (gnus-article-insert-newline)
5075 (mm-insert-inline handle (mm-get-part handle))
5076 (goto-char (point-max))))
5080 (narrow-to-region beg (point))
5083 (gnus-article-mime-total-parts)
5084 (mm-handle-media-type handle)))))))))
5086 (defun gnus-unbuttonized-mime-type-p (type)
5087 "Say whether TYPE is to be unbuttonized."
5088 (unless gnus-inhibit-mime-unbuttonizing
5090 (let ((types gnus-unbuttonized-mime-types))
5092 (when (string-match (pop types) type)
5093 (throw 'found t)))))
5095 (let ((types gnus-buttonized-mime-types))
5097 (when (string-match (pop types) type)
5098 (throw 'found t)))))))))
5100 (defun gnus-article-insert-newline ()
5101 "Insert a newline, but mark it as undeletable."
5102 (gnus-put-text-property
5103 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5105 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5106 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5109 handle buffer-read-only from props begend not-pref)
5110 (save-window-excursion
5113 (narrow-to-region (car ibegend)
5116 (goto-char (car ibegend))
5119 (delete-region (point-min) (point-max))
5120 (mm-remove-parts handles))
5121 (setq begend (list (point-marker)))
5123 (unless (setq not-pref (cadr (member preferred ihandles)))
5124 (setq not-pref (car ihandles)))
5127 (not (gnus-unbuttonized-mime-type-p
5128 "multipart/alternative")))
5129 (gnus-add-text-properties
5132 (insert (format "%d. " id))
5136 (unless ,(not ibegend)
5137 (setq gnus-article-mime-handle-alist
5138 ',gnus-article-mime-handle-alist))
5139 (gnus-mime-display-alternative
5140 ',ihandles ',not-pref ',begend ,id))
5141 ,@(gnus-local-map-property gnus-mime-button-map)
5142 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5143 face ,gnus-article-button-face
5146 (widget-convert-button 'link from (point)
5147 :action 'gnus-widget-press-button
5148 :button-keymap gnus-widget-button-keymap)
5150 (while (setq handle (pop handles))
5151 (gnus-add-text-properties
5154 (insert (format "(%c) %-18s"
5155 (if (equal handle preferred) ?* ? )
5156 (mm-handle-media-type handle)))
5160 (unless ,(not ibegend)
5161 (setq gnus-article-mime-handle-alist
5162 ',gnus-article-mime-handle-alist))
5163 (gnus-mime-display-alternative
5164 ',ihandles ',handle ',begend ,id))
5165 ,@(gnus-local-map-property gnus-mime-button-map)
5166 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5167 face ,gnus-article-button-face
5170 (widget-convert-button 'link from (point)
5171 :action 'gnus-widget-press-button
5172 :button-keymap gnus-widget-button-keymap)
5176 (if (stringp (car preferred))
5177 (gnus-display-mime preferred)
5178 (let ((mail-parse-charset gnus-newsgroup-charset)
5179 (mail-parse-ignored-charsets
5180 (save-excursion (set-buffer gnus-summary-buffer)
5181 gnus-newsgroup-ignored-charsets)))
5182 (mm-display-part preferred)
5186 (narrow-to-region (car begend) (point-max))
5188 nil (length gnus-article-mime-handle-alist)
5189 (gnus-article-mime-total-parts)
5190 (mm-handle-media-type handle))))))
5191 (goto-char (point-max))
5192 (setcdr begend (point-marker)))))
5194 (goto-char point))))
5196 (defconst gnus-article-wash-status-strings
5197 (let ((alist '((cite "c" "Possible hidden citation text"
5198 " " "All citation text visible")
5199 (headers "h" "Hidden headers"
5200 " " "All headers visible.")
5201 (pgp "p" "Encrypted or signed message status hidden"
5202 " " "No hidden encryption nor digital signature status")
5203 (signature "s" "Signature has been hidden"
5204 " " "Signature is visible")
5205 (overstrike "o" "Overstrike (^H) characters applied"
5206 " " "No overstrike characters applied")
5207 (gnus-show-mime "m" "Mime processing is activated"
5208 " " "Mime processing is not activated")
5209 (emphasis "e" "/*_Emphasis_*/ characters applied"
5210 " " "No /*_emphasis_*/ characters applied")))
5212 (dolist (entry alist result)
5213 (let ((key (nth 0 entry))
5214 (on (copy-sequence (nth 1 entry)))
5215 (on-help (nth 2 entry))
5216 (off (copy-sequence (nth 3 entry)))
5217 (off-help (nth 4 entry)))
5218 (put-text-property 0 1 'help-echo on-help on)
5219 (put-text-property 0 1 'help-echo off-help off)
5220 (push (list key on off) result))))
5221 "Alist of strings describing wash status in the mode line.
5222 Each entry has the form (KEY ON OF), where the KEY is a symbol
5223 representing the particular washing function, ON is the string to use
5224 in the article mode line when the washing function is active, and OFF
5225 is the string to use when it is inactive.")
5227 (defun gnus-article-wash-status-entry (key value)
5228 (let ((entry (assoc key gnus-article-wash-status-strings)))
5229 (if value (nth 1 entry) (nth 2 entry))))
5231 (defun gnus-article-wash-status ()
5232 "Return a string which display status of article washing."
5234 (set-buffer gnus-article-buffer)
5235 (let ((cite (memq 'cite gnus-article-wash-types))
5236 (headers (memq 'headers gnus-article-wash-types))
5237 (boring (memq 'boring-headers gnus-article-wash-types))
5238 (pgp (memq 'pgp gnus-article-wash-types))
5239 (pem (memq 'pem gnus-article-wash-types))
5240 (signed (memq 'signed gnus-article-wash-types))
5241 (encrypted (memq 'encrypted gnus-article-wash-types))
5242 (signature (memq 'signature gnus-article-wash-types))
5243 (overstrike (memq 'overstrike gnus-article-wash-types))
5244 (emphasis (memq 'emphasis gnus-article-wash-types)))
5246 (gnus-article-wash-status-entry 'cite cite)
5247 (gnus-article-wash-status-entry 'headers (or headers boring))
5248 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5249 (gnus-article-wash-status-entry 'signature signature)
5250 (gnus-article-wash-status-entry 'overstrike overstrike)
5251 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
5252 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5254 (defun gnus-add-wash-type (type)
5255 "Add a washing of TYPE to the current status."
5256 (add-to-list 'gnus-article-wash-types type))
5258 (defun gnus-delete-wash-type (type)
5259 "Add a washing of TYPE to the current status."
5260 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5262 (defun gnus-add-image (category image)
5263 "Add IMAGE of CATEGORY to the list of displayed images."
5264 (let ((entry (assq category gnus-article-image-alist)))
5266 (setq entry (list category))
5267 (push entry gnus-article-image-alist))
5268 (nconc entry (list image))))
5270 (defun gnus-delete-images (category)
5271 "Delete all images in CATEGORY."
5272 (let ((entry (assq category gnus-article-image-alist)))
5273 (dolist (image (cdr entry))
5274 (gnus-remove-image image category))
5275 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5276 (gnus-delete-wash-type category)))
5278 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5280 (defun gnus-article-maybe-hide-headers ()
5281 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5282 Provided for backwards compatibility."
5283 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5284 (not (save-excursion (set-buffer gnus-summary-buffer)
5285 gnus-have-all-headers)))
5286 (not gnus-inhibit-hiding))
5287 (gnus-article-hide-headers)))
5291 (defun gnus-output-to-file (file-name)
5292 "Append the current article to a file named FILE-NAME."
5293 (let ((artbuf (current-buffer)))
5295 (insert-buffer-substring artbuf)
5296 ;; Append newline at end of the buffer as separator, and then
5298 (goto-char (point-max))
5300 (let ((file-name-coding-system nnmail-pathname-coding-system)
5301 (pathname-coding-system nnmail-pathname-coding-system))
5302 (write-region-as-binary (point-min) (point-max) file-name 'append))
5305 (defun gnus-narrow-to-page (&optional arg)
5306 "Narrow the article buffer to a page.
5307 If given a numerical ARG, move forward ARG pages."
5309 (setq arg (if arg (prefix-numeric-value arg) 0))
5311 (set-buffer gnus-article-buffer)
5312 (goto-char (point-min))
5314 ;; Remove any old next/prev buttons.
5315 (when (gnus-visual-p 'page-marker)
5316 (let ((buffer-read-only nil))
5317 (gnus-remove-text-with-property 'gnus-prev)
5318 (gnus-remove-text-with-property 'gnus-next)))
5321 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5323 (re-search-forward page-delimiter nil 'move arg)))
5324 (goto-char (match-end 0))
5326 (goto-char (point-min))
5327 (setq gnus-page-broken
5328 (and (re-search-forward page-delimiter nil t) t))))
5329 (when gnus-page-broken
5332 (if (re-search-forward page-delimiter nil 'move)
5335 (when (and (gnus-visual-p 'page-marker)
5336 (not (= (point-min) 1)))
5338 (goto-char (point-min))
5339 (gnus-insert-prev-page-button)))
5340 (when (and (gnus-visual-p 'page-marker)
5341 (< (+ (point-max) 2) (buffer-size)))
5343 (goto-char (point-max))
5344 (gnus-insert-next-page-button))))))
5346 ;; Article mode commands
5348 (defun gnus-article-goto-next-page ()
5349 "Show the next page of the article."
5351 (when (gnus-article-next-page)
5352 (goto-char (point-min))
5353 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5356 (defun gnus-article-goto-prev-page ()
5357 "Show the next page of the article."
5360 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5361 (gnus-article-prev-page nil)))
5363 ;; This is cleaner but currently breaks `gnus-pick-mode':
5365 ;; (defun gnus-article-goto-next-page ()
5366 ;; "Show the next page of the article."
5368 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5369 ;; (gnus-summary-next-page)))
5371 ;; (defun gnus-article-goto-prev-page ()
5372 ;; "Show the next page of the article."
5374 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5375 ;; (gnus-summary-prev-page)))
5377 (defun gnus-article-next-page (&optional lines)
5378 "Show the next page of the current article.
5379 If end of article, return non-nil. Otherwise return nil.
5380 Argument LINES specifies lines to be scrolled up."
5382 (move-to-window-line -1)
5385 (and (pos-visible-in-window-p) ;Not continuation line.
5386 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5387 ;; Nothing in this page.
5388 (if (or (not gnus-page-broken)
5392 (eobp)))) ;Real end-of-buffer?
5394 (when gnus-article-over-scroll
5395 (gnus-article-next-page-1 lines))
5397 (gnus-narrow-to-page 1) ;Go to next page.
5399 ;; More in this page.
5400 (gnus-article-next-page-1 lines)
5403 (defun gnus-article-next-page-1 (lines)
5404 (let ((scroll-in-place nil))
5408 ;; Long lines may cause an end-of-buffer error.
5409 (goto-char (point-max)))))
5410 (move-to-window-line 0))
5412 (defun gnus-article-prev-page (&optional lines)
5413 "Show previous page of current article.
5414 Argument LINES specifies lines to be scrolled down."
5416 (move-to-window-line 0)
5417 (if (and gnus-page-broken
5419 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5421 (gnus-narrow-to-page -1) ;Go to previous page.
5422 (goto-char (point-max))
5424 (let ((scroll-in-place nil))
5428 (beginning-of-buffer
5429 (goto-char (point-min))))
5430 (move-to-window-line 0)))))
5432 (defun gnus-article-only-boring-p ()
5433 "Decide whether there is only boring text remaining in the article.
5434 Something \"interesting\" is a word of at least two letters that does
5435 not have a face in `gnus-article-boring-faces'."
5436 (when (and gnus-article-skip-boring
5437 (boundp 'gnus-article-boring-faces)
5438 (symbol-value 'gnus-article-boring-faces))
5441 (while (re-search-forward "\\b\\w\\w" nil t)
5443 (when (not (gnus-intersection
5444 (gnus-faces-at (point))
5445 (symbol-value 'gnus-article-boring-faces)))
5446 (throw 'only-boring nil)))
5447 (throw 'only-boring t)))))
5449 (defun gnus-article-refer-article ()
5450 "Read article specified by message-id around point."
5453 (re-search-backward "[ \t]\\|^" (gnus-point-at-bol) t)
5454 (re-search-forward "<?news:<?\\|<" (gnus-point-at-eol) t)
5455 (if (re-search-forward "[^@ ]+@[^ \t>]+" (gnus-point-at-eol) t)
5456 (let ((msg-id (concat "<" (match-string 0) ">")))
5457 (set-buffer gnus-summary-buffer)
5458 (gnus-summary-refer-article msg-id))
5459 (error "No references around point"))))
5461 (defun gnus-article-show-summary ()
5462 "Reconfigure windows to show summary buffer."
5464 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5465 (error "There is no summary buffer for this article buffer")
5466 (gnus-article-set-globals)
5467 (gnus-configure-windows 'article)
5468 (gnus-summary-goto-subject gnus-current-article)
5469 (gnus-summary-position-point)))
5471 (defun gnus-article-describe-briefly ()
5472 "Describe article mode commands briefly."
5474 (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")))
5476 (defun gnus-article-summary-command ()
5477 "Execute the last keystroke in the summary buffer."
5479 (let ((obuf (current-buffer))
5480 (owin (current-window-configuration))
5482 (switch-to-buffer gnus-article-current-summary 'norecord)
5483 (setq func (lookup-key (current-local-map) (this-command-keys)))
5484 (call-interactively func)
5486 (set-window-configuration owin)
5487 (set-window-point (get-buffer-window (current-buffer)) (point))))
5489 (defun gnus-article-summary-command-nosave ()
5490 "Execute the last keystroke in the summary buffer."
5493 (pop-to-buffer gnus-article-current-summary 'norecord)
5494 (setq func (lookup-key (current-local-map) (this-command-keys)))
5495 (call-interactively func)))
5497 (defun gnus-article-check-buffer ()
5498 "Beep if not in an article buffer."
5499 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5500 (error "Command invoked outside of a Gnus article buffer")))
5502 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5503 "Read a summary buffer key sequence and execute it from the article buffer."
5505 (gnus-article-check-buffer)
5507 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5508 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5509 "=" "^" "\M-^" "|"))
5515 '("n" "Gn" "p" "Gp"))
5518 (set-buffer gnus-article-current-summary)
5519 (let (gnus-pick-mode)
5520 (push (or key last-command-event) unread-command-events)
5521 (setq keys (static-if (featurep 'xemacs)
5522 (events-to-keys (read-key-sequence nil))
5523 (read-key-sequence nil)))))
5526 (if (or (member keys nosaves)
5527 (member keys nosave-but-article)
5528 (member keys nosave-in-article))
5530 (save-window-excursion
5531 (pop-to-buffer gnus-article-current-summary 'norecord)
5532 ;; We disable the pick minor mode commands.
5533 (let (gnus-pick-mode)
5534 (setq func (lookup-key (current-local-map) keys))))
5538 (unless (member keys nosave-in-article)
5539 (set-buffer gnus-article-current-summary))
5540 (call-interactively func)
5541 (setq new-sum-point (point)))
5542 (when (member keys nosave-but-article)
5543 (pop-to-buffer gnus-article-buffer 'norecord)))
5544 ;; These commands should restore window configuration.
5545 (let ((obuf (current-buffer))
5546 (owin (current-window-configuration))
5548 (summary gnus-article-current-summary)
5549 func in-buffer selected)
5550 (if not-restore-window
5551 (pop-to-buffer summary 'norecord)
5552 (switch-to-buffer summary 'norecord))
5553 (setq in-buffer (current-buffer))
5554 ;; We disable the pick minor mode commands.
5555 (if (and (setq func (let (gnus-pick-mode)
5556 (lookup-key (current-local-map) keys)))
5559 (call-interactively func)
5560 (setq new-sum-point (point))
5561 (when (eq in-buffer (current-buffer))
5562 (setq selected (gnus-summary-select-article))
5564 (unless not-restore-window
5565 (set-window-configuration owin))
5566 (when (eq selected 'old)
5568 (set-window-start (get-buffer-window (current-buffer))
5570 (set-window-point (get-buffer-window (current-buffer))
5572 (let ((win (get-buffer-window gnus-article-current-summary)))
5574 (set-window-point win new-sum-point)))) )
5575 (switch-to-buffer gnus-article-buffer)
5578 (defun gnus-article-describe-key (key)
5579 "Display documentation of the function invoked by KEY. KEY is a string."
5580 (interactive "kDescribe key: ")
5581 (gnus-article-check-buffer)
5582 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5584 (set-buffer gnus-article-current-summary)
5585 (let (gnus-pick-mode)
5586 (if (featurep 'xemacs)
5588 (push (elt key 0) unread-command-events)
5589 (setq key (events-to-keys
5590 (read-key-sequence "Describe key: "))))
5591 (setq unread-command-events
5593 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5595 (setq key (read-key-sequence "Describe key: "))))
5597 (describe-key key)))
5599 (defun gnus-article-describe-key-briefly (key &optional insert)
5600 "Display documentation of the function invoked by KEY. KEY is a string."
5601 (interactive "kDescribe key: \nP")
5602 (gnus-article-check-buffer)
5603 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5605 (set-buffer gnus-article-current-summary)
5606 (let (gnus-pick-mode)
5607 (if (featurep 'xemacs)
5609 (push (elt key 0) unread-command-events)
5610 (setq key (events-to-keys
5611 (read-key-sequence "Describe key: "))))
5612 (setq unread-command-events
5614 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5616 (setq key (read-key-sequence "Describe key: "))))
5617 (describe-key-briefly key insert))
5618 (describe-key-briefly key insert)))
5620 (defun gnus-article-reply-with-original (&optional wide)
5621 "Start composing a reply mail to the current message.
5622 The text in the region will be yanked. If the region isn't active,
5623 the entire article will be yanked."
5625 (let ((article (cdr gnus-article-current))
5627 (if (not (gnus-mark-active-p))
5628 (with-current-buffer gnus-summary-buffer
5629 (gnus-summary-reply (list (list article)) wide))
5630 (setq contents (buffer-substring (point) (mark t)))
5631 ;; Deactivate active regions.
5632 (when (and (boundp 'transient-mark-mode)
5633 transient-mark-mode)
5634 (setq mark-active nil))
5635 (with-current-buffer gnus-summary-buffer
5637 (list (list article contents)) wide)))))
5639 (defun gnus-article-followup-with-original ()
5640 "Compose a followup to the current article.
5641 The text in the region will be yanked. If the region isn't active,
5642 the entire article will be yanked."
5644 (let ((article (cdr gnus-article-current))
5646 (if (not (gnus-mark-active-p))
5647 (with-current-buffer gnus-summary-buffer
5648 (gnus-summary-followup (list (list article))))
5649 (setq contents (buffer-substring (point) (mark t)))
5650 ;; Deactivate active regions.
5651 (when (and (boundp 'transient-mark-mode)
5652 transient-mark-mode)
5653 (setq mark-active nil))
5654 (with-current-buffer gnus-summary-buffer
5655 (gnus-summary-followup
5656 (list (list article contents)))))))
5658 (defun gnus-article-hide (&optional arg force)
5659 "Hide all the gruft in the current article.
5660 This means that signatures, cited text and (some) headers will be
5662 If given a prefix, show the hidden text instead."
5663 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5664 (gnus-article-hide-headers arg)
5665 (gnus-article-hide-list-identifiers arg)
5666 (gnus-article-hide-citation-maybe arg force)
5667 (gnus-article-hide-signature arg))
5669 (defun gnus-article-maybe-highlight ()
5670 "Do some article highlighting if article highlighting is requested."
5671 (when (gnus-visual-p 'article-highlight 'highlight)
5672 (gnus-article-highlight-some)))
5674 (defun gnus-check-group-server ()
5675 ;; Make sure the connection to the server is alive.
5676 (unless (gnus-server-opened
5677 (gnus-find-method-for-group gnus-newsgroup-name))
5678 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5679 (gnus-request-group gnus-newsgroup-name t)))
5682 (autoload 'nneething-get-file-name "nneething"))
5684 (defun gnus-request-article-this-buffer (article group)
5685 "Get an article and insert it into this buffer."
5686 (let (do-update-line sparse-header)
5690 (gnus-kill-all-overlays)
5691 (setq group (or group gnus-newsgroup-name))
5693 ;; Using `gnus-request-article' directly will insert the article into
5694 ;; `nntp-server-buffer' - so we'll save some time by not having to
5695 ;; copy it from the server buffer into the article buffer.
5697 ;; We only request an article by message-id when we do not have the
5698 ;; headers for it, so we'll have to get those.
5699 (when (stringp article)
5700 (gnus-read-header article))
5702 ;; If the article number is negative, that means that this article
5703 ;; doesn't belong in this newsgroup (possibly), so we find its
5704 ;; message-id and request it by id instead of number.
5705 (when (and (numberp article)
5707 (get-buffer gnus-summary-buffer)
5708 (gnus-buffer-exists-p gnus-summary-buffer))
5710 (set-buffer gnus-summary-buffer)
5711 (let ((header (gnus-summary-article-header article)))
5714 ((memq article gnus-newsgroup-sparse)
5715 ;; This is a sparse gap article.
5716 (setq do-update-line article)
5717 (setq article (mail-header-id header))
5718 (setq sparse-header (gnus-read-header article))
5719 (setq gnus-newsgroup-sparse
5720 (delq article gnus-newsgroup-sparse)))
5722 ;; It's a real article.
5723 (setq article (mail-header-id header)))
5725 ;; It is an extracted pseudo-article.
5726 (setq article 'pseudo)
5727 (gnus-request-pseudo-article header))))
5729 (let ((method (gnus-find-method-for-group
5730 gnus-newsgroup-name)))
5731 (when (and (eq (car method) 'nneething)
5733 (let ((dir (nneething-get-file-name
5734 (mail-header-id header))))
5735 (when (and (stringp dir)
5736 (file-directory-p dir))
5737 (setq article 'nneething)
5738 (gnus-group-enter-directory dir))))))))
5741 ;; Refuse to select canceled articles.
5742 ((and (numberp article)
5744 (get-buffer gnus-summary-buffer)
5745 (gnus-buffer-exists-p gnus-summary-buffer)
5746 (eq (cdr (save-excursion
5747 (set-buffer gnus-summary-buffer)
5748 (assq article gnus-newsgroup-reads)))
5749 gnus-canceled-mark))
5751 ;; We first check `gnus-original-article-buffer'.
5752 ((and (get-buffer gnus-original-article-buffer)
5755 (set-buffer gnus-original-article-buffer)
5756 (and (equal (car gnus-original-article) group)
5757 (eq (cdr gnus-original-article) article))))
5758 (insert-buffer-substring gnus-original-article-buffer)
5760 ;; Check the backlog.
5761 ((and gnus-keep-backlog
5762 (gnus-backlog-request-article group article (current-buffer)))
5764 ;; Check asynchronous pre-fetch.
5765 ((gnus-async-request-fetched-article group article (current-buffer))
5766 (gnus-async-prefetch-next group article gnus-summary-buffer)
5767 (when (and (numberp article) gnus-keep-backlog)
5768 (gnus-backlog-enter-article group article (current-buffer)))
5771 ((and gnus-use-cache
5773 (gnus-cache-request-article article group))
5775 ;; Check the agent cache.
5776 ((gnus-agent-request-article article group)
5778 ;; Get the article and put into the article buffer.
5779 ((or (stringp article)
5781 (let ((gnus-override-method gnus-override-method)
5782 (methods (and (stringp article)
5783 gnus-refer-article-method))
5784 (backend (car (gnus-find-method-for-group
5785 gnus-newsgroup-name)))
5787 (buffer-read-only nil))
5788 (if (or (not (listp methods))
5789 (and (symbolp (car methods))
5790 (assq (car methods) nnoo-definition-alist)))
5791 (setq methods (list methods)))
5792 (when (and (null gnus-override-method)
5794 (setq gnus-override-method (pop methods)))
5796 (when (eq gnus-override-method 'current)
5797 (setq gnus-override-method
5798 (with-current-buffer gnus-summary-buffer
5799 gnus-current-select-method)))
5801 (gnus-kill-all-overlays)
5802 (let ((gnus-newsgroup-name group))
5803 (gnus-check-group-server))
5805 ((gnus-request-article article group (current-buffer))
5806 (when (numberp article)
5807 (gnus-async-prefetch-next group article
5808 gnus-summary-buffer)
5809 (when gnus-keep-backlog
5810 (gnus-backlog-enter-article
5811 group article (current-buffer))))
5812 (setq result 'article))
5814 (setq gnus-override-method (pop methods)))
5815 ((not (string-match "^400 "
5816 (nnheader-get-report backend)))
5817 ;; If we get 400 server disconnect, reconnect and
5818 ;; retry; otherwise, assume the article has expired.
5819 (setq result 'done))))
5820 (and (eq result 'article) 'article)))
5824 ;; Associate this article with the current summary buffer.
5825 (setq gnus-article-current-summary gnus-summary-buffer)
5827 ;; Take the article from the original article buffer
5828 ;; and place it in the buffer it's supposed to be in.
5829 (when (and (get-buffer gnus-article-buffer)
5830 (equal (buffer-name (current-buffer))
5831 (buffer-name (get-buffer gnus-article-buffer))))
5833 (if (get-buffer gnus-original-article-buffer)
5834 (set-buffer gnus-original-article-buffer)
5835 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5836 (buffer-disable-undo)
5837 (setq major-mode 'gnus-original-article-mode)
5838 (setq buffer-read-only t))
5839 (let (buffer-read-only)
5841 (insert-buffer-substring gnus-article-buffer))
5842 (setq gnus-original-article (cons group article)))
5845 (run-hooks 'gnus-article-decode-hook)
5846 ;; Mark article as decoded or not.
5847 (setq gnus-article-decoded-p gnus-article-decode-hook))
5849 ;; Update sparse articles.
5850 (when (and do-update-line
5851 (or (numberp article)
5853 (let ((buf (current-buffer)))
5854 (set-buffer gnus-summary-buffer)
5855 (gnus-summary-update-article do-update-line sparse-header)
5856 (gnus-summary-goto-subject do-update-line nil t)
5857 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5859 (set-buffer buf))))))
5865 (defcustom gnus-article-edit-mode-hook nil
5866 "Hook run in article edit mode buffers."
5867 :group 'gnus-article-various
5870 (defcustom gnus-article-edit-article-setup-function
5871 'gnus-article-mime-edit-article-setup
5872 "Function called to setup an editing article buffer."
5873 :group 'gnus-article-various
5876 (defvar gnus-article-edit-done-function nil)
5878 (defvar gnus-article-edit-mode-map nil)
5879 (defvar gnus-article-edit-mode nil)
5881 ;; Should we be using derived.el for this?
5882 (unless gnus-article-edit-mode-map
5883 (setq gnus-article-edit-mode-map (make-keymap))
5884 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5886 (gnus-define-keys gnus-article-edit-mode-map
5887 "\C-c?" describe-mode
5888 "\C-c\C-c" gnus-article-edit-done
5889 "\C-c\C-k" gnus-article-edit-exit
5890 "\C-c\C-f\C-t" message-goto-to
5891 "\C-c\C-f\C-o" message-goto-from
5892 "\C-c\C-f\C-b" message-goto-bcc
5893 ;;"\C-c\C-f\C-w" message-goto-fcc
5894 "\C-c\C-f\C-c" message-goto-cc
5895 "\C-c\C-f\C-s" message-goto-subject
5896 "\C-c\C-f\C-r" message-goto-reply-to
5897 "\C-c\C-f\C-n" message-goto-newsgroups
5898 "\C-c\C-f\C-d" message-goto-distribution
5899 "\C-c\C-f\C-f" message-goto-followup-to
5900 "\C-c\C-f\C-m" message-goto-mail-followup-to
5901 "\C-c\C-f\C-k" message-goto-keywords
5902 "\C-c\C-f\C-u" message-goto-summary
5903 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5904 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5905 "\C-c\C-b" message-goto-body
5906 "\C-c\C-i" message-goto-signature
5908 "\C-c\C-t" message-insert-to
5909 "\C-c\C-n" message-insert-newsgroups
5910 "\C-c\C-o" message-sort-headers
5911 "\C-c\C-e" message-elide-region
5912 "\C-c\C-v" message-delete-not-region
5913 "\C-c\C-z" message-kill-to-signature
5914 "\M-\r" message-newline-and-reformat
5915 "\C-c\C-a" mml-attach-file
5916 "\C-a" message-beginning-of-line
5918 "\M-;" comment-region)
5920 (gnus-define-keys (gnus-article-edit-wash-map
5921 "\C-c\C-w" gnus-article-edit-mode-map)
5922 "f" gnus-article-edit-full-stops))
5925 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5927 ["Fetch To" message-insert-to t]
5928 ["Fetch Newsgroups" message-insert-newsgroups t]
5930 ["To" message-goto-to t]
5931 ["From" message-goto-from t]
5932 ["Subject" message-goto-subject t]
5933 ["Cc" message-goto-cc t]
5934 ["Reply-To" message-goto-reply-to t]
5935 ["Summary" message-goto-summary t]
5936 ["Keywords" message-goto-keywords t]
5937 ["Newsgroups" message-goto-newsgroups t]
5938 ["Followup-To" message-goto-followup-to t]
5939 ["Mail-Followup-To" message-goto-mail-followup-to t]
5940 ["Distribution" message-goto-distribution t]
5941 ["Body" message-goto-body t]
5942 ["Signature" message-goto-signature t]))
5944 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5945 "Major mode for editing articles.
5946 This is an extended text-mode.
5948 \\{gnus-article-edit-mode-map}"
5949 (make-local-variable 'gnus-article-edit-done-function)
5950 (make-local-variable 'gnus-prev-winconf)
5951 (set (make-local-variable 'font-lock-defaults)
5952 '(message-font-lock-keywords t))
5953 (set (make-local-variable 'mail-header-separator) "")
5954 (set (make-local-variable 'gnus-article-edit-mode) t)
5955 (easy-menu-add message-mode-field-menu message-mode-map)
5956 (setq buffer-read-only nil)
5957 (buffer-enable-undo)
5960 (defun gnus-article-edit (&optional force)
5961 "Edit the current article.
5962 This will have permanent effect only in mail groups.
5963 If FORCE is non-nil, allow editing of articles even in read-only
5966 (when (and (not force)
5967 (gnus-group-read-only-p))
5968 (error "The current newsgroup does not support article editing"))
5969 (gnus-article-date-original)
5970 (gnus-article-edit-article
5972 `(lambda (no-highlight)
5974 (gnus-summary-edit-article-done
5975 ,(or (mail-header-references gnus-current-headers) "")
5976 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5978 (defun gnus-article-edit-article (start-func exit-func)
5979 "Start editing the contents of the current article buffer."
5980 (let ((winconf (current-window-configuration)))
5981 (set-buffer gnus-article-buffer)
5982 (gnus-article-edit-mode)
5983 (funcall start-func)
5984 (set-buffer-modified-p nil)
5985 (gnus-configure-windows 'edit-article)
5986 (setq gnus-article-edit-done-function exit-func)
5987 (setq gnus-prev-winconf winconf)
5988 (when gnus-article-edit-article-setup-function
5989 (funcall gnus-article-edit-article-setup-function))
5990 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit")))
5992 (defun gnus-article-edit-done (&optional arg)
5993 "Update the article edits and exit."
5995 (let ((func gnus-article-edit-done-function)
5996 (buf (current-buffer))
5997 (start (window-start))
5999 (winconf gnus-prev-winconf))
6000 (remove-hook 'gnus-article-mode-hook
6001 'gnus-article-mime-edit-article-unwind)
6002 (widen) ;; Widen it in case that users narrowed the buffer.
6005 ;; The cache and backlog have to be flushed somewhat.
6006 (when gnus-keep-backlog
6007 (gnus-backlog-remove-article
6008 (car gnus-article-current) (cdr gnus-article-current)))
6009 ;; Flush original article as well.
6011 (when (get-buffer gnus-original-article-buffer)
6012 (set-buffer gnus-original-article-buffer)
6013 (setq gnus-original-article nil)))
6014 (when gnus-use-cache
6015 (gnus-cache-update-article
6016 (car gnus-article-current) (cdr gnus-article-current)))
6017 ;; We remove all text props from the article buffer.
6018 (kill-all-local-variables)
6019 (gnus-set-text-properties (point-min) (point-max) nil)
6021 (set-window-configuration winconf)
6023 (set-window-start (get-buffer-window buf) start)
6024 (set-window-point (get-buffer-window buf) (point)))
6025 (gnus-summary-show-article))
6027 (defun gnus-article-edit-exit ()
6028 "Exit the article editing without updating."
6030 (when (or (not (buffer-modified-p))
6031 (yes-or-no-p "Article modified; kill anyway? "))
6032 (let ((curbuf (current-buffer))
6034 (window-start (window-start)))
6036 (if (gnus-buffer-live-p gnus-original-article-buffer)
6037 (insert-buffer-substring gnus-original-article-buffer))
6038 (let ((winconf gnus-prev-winconf))
6039 (kill-all-local-variables)
6041 (set-window-configuration winconf)
6042 ;; Tippy-toe some to make sure that point remains where it was.
6043 (save-current-buffer
6045 (set-window-start (get-buffer-window (current-buffer)) window-start)
6047 (gnus-summary-show-article)))
6049 (defun gnus-article-edit-full-stops ()
6050 "Interactively repair spacing at end of sentences."
6053 (goto-char (point-min))
6054 (search-forward-regexp "^$" nil t)
6055 (let ((case-fold-search nil))
6056 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
6059 ;;; Article editing with MIME-Edit
6062 (defcustom gnus-article-mime-edit-article-setup-hook nil
6063 "Hook run after setting up a MIME editing article buffer."
6064 :group 'gnus-article-various
6067 (defun gnus-article-mime-edit-article-unwind ()
6068 "Unwind `gnus-article-buffer' if article editing was given up."
6069 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6070 (when (featurep 'font-lock)
6071 (setq font-lock-defaults nil)
6072 (font-lock-mode -1))
6073 (when mime-edit-mode-flag
6074 (mime-edit-exit 'nomime 'no-error)
6077 (defun gnus-article-mime-edit-article-setup ()
6078 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
6079 after replacing with the original article."
6080 (setq gnus-show-mime t)
6081 (setq gnus-article-edit-done-function
6082 `(lambda (&rest args)
6083 (when mime-edit-mode-flag
6084 (let (mime-edit-insert-user-agent-field)
6087 (goto-char (point-min))
6088 (let (case-fold-search)
6089 (when (re-search-forward
6090 (format "^%s$" (regexp-quote mail-header-separator))
6092 (replace-match "")))
6093 (apply ,gnus-article-edit-done-function args)
6096 (buffer-substring-no-properties (point-min) (point-max))
6097 (set-buffer (get-buffer-create gnus-original-article-buffer))
6099 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6100 (set-buffer gnus-article-buffer)
6101 (gnus-article-prepare-display)))
6102 (substitute-key-definition 'gnus-article-edit-done
6103 'gnus-article-mime-edit-done
6104 gnus-article-edit-mode-map)
6105 (substitute-key-definition 'gnus-article-edit-exit
6106 'gnus-article-mime-edit-exit
6107 gnus-article-edit-mode-map)
6109 (insert-buffer-substring gnus-original-article-buffer)
6110 (unless (member (with-current-buffer gnus-summary-buffer
6111 gnus-newsgroup-name)
6112 '("nndraft:delayed" "nndraft:drafts"))
6113 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
6114 (fset 'mime-edit-decode-single-part-in-buffer
6115 (lambda (&rest args)
6116 (if (let ((content-type (car args)))
6117 (and (eq 'message (mime-content-type-primary-type
6119 (eq 'rfc822 (mime-content-type-subtype
6121 (setcar (cdr args) 'not-decode-text))
6125 (fset 'mime-edit-decode-single-part-in-buffer ofn))))
6126 (when (featurep 'font-lock)
6127 (set (make-local-variable 'font-lock-defaults)
6128 '(message-font-lock-keywords t))
6129 (font-lock-set-defaults)
6130 (turn-on-font-lock))
6131 (set-buffer-modified-p nil)
6132 (delete-other-windows)
6133 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6134 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
6136 (defun gnus-article-mime-edit-done (&optional arg)
6137 "Update the article MIME edits and exit."
6139 (when (featurep 'font-lock)
6140 (setq font-lock-defaults nil)
6141 (font-lock-mode -1))
6142 (let ((inhibit-read-only t))
6143 (gnus-article-edit-done arg)))
6145 (defun gnus-article-mime-edit-exit ()
6146 "Exit the article MIME editing without updating."
6148 (when (or (not (buffer-modified-p))
6149 (yes-or-no-p "Article modified; kill anyway? "))
6150 (when (featurep 'font-lock)
6151 (setq font-lock-defaults nil)
6152 (font-lock-mode -1))
6153 (when mime-edit-mode-flag
6154 (let (mime-edit-insert-user-agent-field)
6157 (goto-char (point-min))
6158 (let (case-fold-search)
6159 (when (re-search-forward
6160 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
6161 (replace-match "")))
6162 (let ((winconf gnus-prev-winconf))
6164 (buffer-substring-no-properties (point-min) (point-max))
6165 (set-buffer (get-buffer-create gnus-original-article-buffer))
6167 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6168 (set-buffer gnus-article-buffer)
6169 (gnus-article-prepare-display)
6170 (set-window-configuration winconf))))
6173 ;;; Article highlights
6176 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6178 ;;; Internal Variables:
6180 (defcustom gnus-button-url-regexp
6181 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
6182 "\\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:]]\\)"
6183 "\\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\\)\\)")
6184 "Regular expression that matches URLs."
6185 :group 'gnus-article-buttons
6188 (defcustom gnus-button-valid-fqdn-regexp
6189 message-valid-fqdn-regexp
6190 "Regular expression that matches a valid FQDN."
6191 :group 'gnus-article-buttons
6194 (defcustom gnus-button-man-handler 'manual-entry
6195 "Function to use for displaying man pages.
6196 The function must take at least one argument with a string naming the
6198 :type '(choice (function-item :tag "Man" manual-entry)
6199 (function-item :tag "Woman" woman)
6200 (function :tag "Other"))
6201 :group 'gnus-article-buttons)
6203 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6204 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6205 If the default site is too slow, try to find a CTAN mirror, see
6206 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6207 the variable `gnus-button-handle-ctan'."
6208 :group 'gnus-article-buttons
6209 :link '(custom-manual "(gnus)Group Parameters")
6210 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6211 (const "http://tug.ctan.org/tex-archive/")
6212 (const "http://www.dante.de/CTAN/")
6213 (string :tag "Other")))
6215 (defcustom gnus-button-ctan-handler 'browse-url
6216 "Function to use for displaying CTAN links.
6217 The function must take one argument, the string naming the URL."
6218 :type '(choice (function-item :tag "Browse Url" browse-url)
6219 (function :tag "Other"))
6220 :group 'gnus-article-buttons)
6222 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6223 "Bogus strings removed from CTAN URLs."
6224 :group 'gnus-article-buttons
6225 :type '(choice (const "^/?tex-archive/\\|/")
6226 (regexp :tag "Other")))
6228 (defcustom gnus-button-ctan-directory-regexp
6230 "\\("; Cannot use `\(?: ... \)' (compatibility with Emacs 20).
6231 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
6232 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
6233 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
6235 "Regular expression for ctan directories.
6236 It should match all directories in the top level of `gnus-ctan-url'."
6237 :group 'gnus-article-buttons
6240 (defcustom gnus-button-mid-or-mail-regexp
6241 (concat "\\b\\(<?[a-z0-9][^<>\")!;:,{}\n\t ]*@"
6242 gnus-button-valid-fqdn-regexp
6244 "Regular expression that matches a message ID or a mail address."
6245 :group 'gnus-article-buttons
6248 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6249 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6250 Strings like this can be either a message ID or a mail address. If it is one
6251 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6252 message ID or a mail address, respectively. If this variable is set to the
6253 symbol `ask', always query the user what do do. If it is a function, this
6254 function will be called with the string as it's only argument. The function
6255 must return `mid', `mail', `invalid' or `ask'."
6256 :group 'gnus-article-buttons
6257 :type '(choice (function-item :tag "Heuristic function"
6258 gnus-button-mid-or-mail-heuristic)
6263 (defcustom gnus-button-mid-or-mail-heuristic-alist
6264 '((-10.0 . ".+\\$.+@")
6267 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6268 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6269 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6270 (-1.0 . "^[^a-z]+@")
6272 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6273 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6274 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6275 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6278 (-1.0 . "^[0-9][0-9]")
6280 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6281 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6282 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6283 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6285 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6286 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6289 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6291 ;; compensation for TDMA dated mail addresses:
6292 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6294 (-20.0 . "\\.fsf@") ;; Gnus
6297 (-20.0 . "_-_") ;; Subject change in thread
6299 (-20.0 . "\\.ln@") ;; leafnode
6300 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6301 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6303 ;; (5.0 . "") ;; $local_part_len <= 7
6304 (10.0 . "^[^0-9]+@")
6305 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6306 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6309 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6311 (0.5 . "^[A-Z][a-z]")
6312 (0.5 . "^[A-Z][a-z][a-z]")
6313 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6314 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6315 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6317 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6318 address. The REGEXP is processed with `case-fold-search' set to nil."
6319 :group 'gnus-article-buttons
6320 :type '(repeat (cons (number :tag "Rate")
6321 (regexp :tag "Regexp"))))
6323 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6324 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6325 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6326 address, `ask' if unsure and `invalid' if the string is invalid."
6327 (let ((case-fold-search nil)
6328 (list gnus-button-mid-or-mail-heuristic-alist)
6329 (result 0) rate regexp lpartlen elem)
6331 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6332 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6333 ;; Certain special cases...
6336 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$" "\\|"
6337 "^[0-9]+\.[0-9]+\@compuserve")
6339 (gnus-message 8 "`%s' is a known mail address.")
6340 (setq result 'mail))
6341 (when (string-match "@.*@\\| " mid-or-mail)
6342 (gnus-message 8 "`%s' is invalid.")
6343 (setq result 'invalid))
6344 ;; Nothing more to do, if result is not a number here...
6345 (when (numberp result)
6347 (setq elem (car list)
6351 (when (string-match regexp mid-or-mail)
6352 (setq result (+ result rate))
6354 9 "`%s' matched `%s', rate `%s', result `%s'."
6355 mid-or-mail regexp rate result)))
6356 (when (<= lpartlen 7)
6357 (setq result (+ result 5.0))
6358 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6359 mid-or-mail result))
6360 (when (>= lpartlen 12)
6361 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6363 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6364 ;; Long local part should contain realname if e-mail address,
6365 ;; too many digits: message-id.
6366 ;; $score -= 5.0 + 0.1 * $local_part_len;
6367 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6368 (setq result (+ result rate))
6370 9 "Many digits in `%s', rate `%s', result `%s'."
6371 mid-or-mail rate result))
6372 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6374 ;; Too few vowels [^aeiouy]{4,}.*\@
6375 (setq result (+ result -5.0))
6377 9 "Few vowels in `%s', rate `%s', result `%s'."
6378 mid-or-mail -5.0 result))
6380 (setq result (+ result 5.0))
6382 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6383 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6385 ;; Maybe we should make this a customizable alist: (condition . 'result)
6386 ((< result -10.0) 'mid)
6387 ((> result 10.0) 'mail)
6390 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6391 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6392 (url-mid (concat "news" ":" mid-or-mail))
6393 (url-mailto (concat "mailto" ":" mid-or-mail)))
6394 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6395 (when (fboundp pref)
6397 ;; get rid of surrounding angles...
6399 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6400 (if (or (eq 'mid guessed) (eq 'mail guessed))
6404 (save-window-excursion
6405 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6408 (cond ((eq pref 'mid)
6409 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6410 (gnus-button-handle-news url-mid))
6412 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6413 (gnus-url-mailto url-mailto))
6414 (t (gnus-message 3 "Invalid string.")))))
6416 (defun gnus-button-handle-custom (url)
6417 "Follow a Custom URL."
6418 (customize-apropos (gnus-url-unhex-string url)))
6420 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6422 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6425 (defun gnus-button-handle-describe-function (url)
6426 "Call `describe-function' when pushing the corresponding URL button."
6429 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6431 (defun gnus-button-handle-describe-variable (url)
6432 "Call `describe-variable' when pushing the corresponding URL button."
6435 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6437 (defun gnus-button-handle-symbol (url)
6438 "Display help on variable or function.
6439 Calls `describe-variable' or `describe-function'."
6440 (let ((sym (intern url)))
6442 ((fboundp sym) (describe-function sym))
6443 ((boundp sym) (describe-variable sym))
6444 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6446 (defun gnus-button-handle-describe-key (url)
6447 "Call `describe-key' when pushing the corresponding URL button."
6449 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6450 (keys (ignore-errors (eval `(kbd ,key-string)))))
6453 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6455 (defun gnus-button-handle-apropos (url)
6456 "Call `apropos' when pushing the corresponding URL button."
6457 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6459 (defun gnus-button-handle-apropos-command (url)
6460 "Call `apropos' when pushing the corresponding URL button."
6462 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6464 (defun gnus-button-handle-apropos-variable (url)
6465 "Call `apropos' when pushing the corresponding URL button."
6467 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6468 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6470 (defun gnus-button-handle-apropos-documentation (url)
6471 "Call `apropos' when pushing the corresponding URL button."
6473 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6474 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6476 (defun gnus-button-handle-library (url)
6477 "Call `locate-library' when pushing the corresponding URL button."
6478 (gnus-message 9 "url=`%s'" url)
6479 (let* ((lib (locate-library url))
6480 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6482 (gnus-message 1 "Cannot locale library `%s'." url)
6483 (find-file-read-only file))))
6485 (defun gnus-button-handle-ctan (url)
6486 "Call `browse-url' when pushing a CTAN URL button."
6488 gnus-button-ctan-handler
6491 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6493 (defcustom gnus-button-tex-level 5
6494 "*Integer that says how many TeX-related buttons Gnus will show.
6495 The higher the number, the more buttons will appear and the more false
6496 positives are possible. Note that you can set this variable local to
6497 specific groups. Setting it higher in TeX groups is probably a good idea.
6498 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6499 how to set variables in specific groups."
6500 :group 'gnus-article-buttons
6501 :link '(custom-manual "(gnus)Group Parameters")
6504 (defcustom gnus-button-man-level 5
6505 "*Integer that says how many man-related buttons Gnus will show.
6506 The higher the number, the more buttons will appear and the more false
6507 positives are possible. Note that you can set this variable local to
6508 specific groups. Setting it higher in Unix groups is probably a good idea.
6509 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6510 how to set variables in specific groups."
6511 :group 'gnus-article-buttons
6512 :link '(custom-manual "(gnus)Group Parameters")
6515 (defcustom gnus-button-emacs-level 5
6516 "*Integer that says how many emacs-related buttons Gnus will show.
6517 The higher the number, the more buttons will appear and the more false
6518 positives are possible. Note that you can set this variable local to
6519 specific groups. Setting it higher in Emacs or Gnus related groups is
6520 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6521 `gnus-parameters' on how to set variables in specific groups."
6522 :group 'gnus-article-buttons
6523 :link '(custom-manual "(gnus)Group Parameters")
6526 (defcustom gnus-button-message-level 5
6527 "*Integer that says how many buttons for news or mail messages will appear.
6528 The higher the number, the more buttons will appear and the more false
6529 positives are possible."
6530 ;; mail addresses, MIDs, URLs for news, ...
6531 :group 'gnus-article-buttons
6534 (defcustom gnus-button-browse-level 5
6535 "*Integer that says how many buttons for browsing will appear.
6536 The higher the number, the more buttons will appear and the more false
6537 positives are possible."
6538 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6539 :group 'gnus-article-buttons
6542 (defcustom gnus-button-alist
6543 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6544 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6545 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6546 gnus-button-handle-news 2)
6547 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6548 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6549 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6550 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6551 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6552 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6553 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6554 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6555 ("mailto:\\([-a-z.@_+0-9%=?]+\\)"
6556 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6557 ("\\bmailto:\\([^ \n\t]+\\)"
6558 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6560 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6561 gnus-button-ctan-directory-regexp
6562 "[^][>)!;:,'\n\t ]+\\)")
6563 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6564 ((concat "\\btex-archive/\\("
6565 gnus-button-ctan-directory-regexp
6566 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6567 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6570 gnus-button-ctan-directory-regexp
6571 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6572 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6573 ;; This is info (home-grown style) <info://foo/bar+baz>
6574 ("\\binfo://\\([^'\">\n\t ]+\\)"
6575 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6576 ;; Info GNOME style <info:foo#bar_baz>
6577 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6578 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6579 ;; Info KDE style <info:(foo)bar baz>
6580 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6581 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6582 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6583 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6584 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6585 ;; Info links like `C-h i d m CC Mode RET'
6586 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6588 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6589 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6590 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6591 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6592 ;; Emacs help commands
6593 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6594 ;; regexp doesn't match arguments containing ` '.
6595 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6596 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6597 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6598 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6599 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6600 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6601 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6602 ;; The following entries may lead to many false positives so don't enable
6603 ;; them by default (use a high button level):
6604 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>"
6605 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6606 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6607 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6608 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6609 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6610 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6611 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6612 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6613 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6614 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6615 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6616 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6617 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6618 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6619 ;; Unlike the other regexps we really have to require quoting
6620 ;; here to determine where it ends.
6621 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6622 ;; This is how URLs _should_ be embedded in text (RFC 1738)...
6623 ("<URL: *\\([^<>]*\\)>"
6624 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6626 (gnus-button-url-regexp
6627 0 (>= gnus-button-browse-level 0) browse-url 0)
6629 ("\\b\\([a-z][a-z]+\\)([1-9])\\W"
6630 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6631 gnus-button-handle-man 1)
6632 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6633 ("\\b\\([a-z][-_.a-z0-9]+\\)([1-9])\\W"
6634 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6635 gnus-button-handle-man 1)
6636 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6637 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6638 ("\\b\\([a-z][-+_.:a-z0-9]+\\)([1-9][X1a-z]*)\\W\\|\\b\\(X\\)([1-9])\\W"
6639 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6640 ;; MID or mail: To avoid too many false positives we don't try to catch
6641 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6642 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6643 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6644 ;; so that non-ambiguous entries (see above) match first.
6645 (gnus-button-mid-or-mail-regexp
6646 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6647 "*Alist of regexps matching buttons in article bodies.
6649 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6650 REGEXP: is the string (case insensitive) matching text around the button (can
6651 also be Lisp expression evaluating to a string),
6652 BUTTON: is the number of the regexp grouping actually matching the button,
6653 FORM: is a Lisp expression which must eval to true for the button to
6655 CALLBACK: is the function to call when the user push this button, and each
6656 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6658 CALLBACK can also be a variable, in that case the value of that
6659 variable it the real callback function."
6660 :group 'gnus-article-buttons
6661 :type '(repeat (list (choice regexp variable sexp)
6662 (integer :tag "Button")
6664 (function :tag "Callback")
6667 (integer :tag "Regexp group")))))
6669 (defcustom gnus-header-button-alist
6670 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6671 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6672 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6673 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6674 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6675 0 (>= gnus-button-message-level 0) gnus-button-mailto 0)
6676 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6677 0 (>= gnus-button-browse-level 0) browse-url 0)
6678 ("^Subject:" gnus-button-url-regexp
6679 0 (>= gnus-button-browse-level 0) browse-url 0)
6680 ("^[^:]+:" gnus-button-url-regexp
6681 0 (>= gnus-button-browse-level 0) browse-url 0)
6682 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?]+\\)"
6683 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6684 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6685 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6686 "*Alist of headers and regexps to match buttons in article heads.
6688 This alist is very similar to `gnus-button-alist', except that each
6689 alist has an additional HEADER element first in each entry:
6691 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6693 HEADER is a regexp to match a header. For a fuller explanation, see
6694 `gnus-button-alist'."
6695 :group 'gnus-article-buttons
6696 :group 'gnus-article-headers
6697 :type '(repeat (list (regexp :tag "Header")
6698 (choice regexp variable)
6699 (integer :tag "Button")
6701 (function :tag "Callback")
6704 (integer :tag "Regexp group")))))
6706 (defvar gnus-button-regexp nil)
6707 (defvar gnus-button-marker-list nil)
6708 ;; Regexp matching any of the regexps from `gnus-button-alist'.
6710 (defvar gnus-button-last nil)
6711 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
6715 (defun gnus-article-push-button (event)
6716 "Check text under the mouse pointer for a callback function.
6717 If the text under the mouse pointer has a `gnus-callback' property,
6718 call it with the value of the `gnus-data' text property."
6720 (set-buffer (window-buffer (posn-window (event-start event))))
6721 (let* ((pos (posn-point (event-start event)))
6722 (data (get-text-property pos 'gnus-data))
6723 (fun (get-text-property pos 'gnus-callback)))
6726 (funcall fun data))))
6728 (defun gnus-article-press-button ()
6729 "Check text at point for a callback function.
6730 If the text at point has a `gnus-callback' property,
6731 call it with the value of the `gnus-data' text property."
6733 (let ((data (get-text-property (point) 'gnus-data))
6734 (fun (get-text-property (point) 'gnus-callback)))
6736 (funcall fun data))))
6738 (defun gnus-article-prev-button (n)
6739 "Move point to N buttons backward.
6740 If N is negative, move forward instead."
6742 (gnus-article-next-button (- n)))
6744 (defun gnus-article-next-button (n)
6745 "Move point to N buttons forward.
6746 If N is negative, move backward instead."
6748 (let ((function (if (< n 0) 'previous-single-property-change
6749 'next-single-property-change))
6750 (inhibit-point-motion-hooks t)
6752 (limit (if (< n 0) (point-min) (point-max))))
6754 (while (and (not (= limit (point)))
6756 ;; Skip past the current button.
6757 (when (get-text-property (point) 'gnus-callback)
6758 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6759 ;; Go to the next (or previous) button.
6760 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
6761 ;; Put point at the start of the button.
6762 (when (and backward (not (get-text-property (point) 'gnus-callback)))
6763 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6764 ;; Skip past intangible buttons.
6765 (when (get-text-property (point) 'intangible)
6769 (gnus-message 5 "No more buttons"))
6772 (defun gnus-article-highlight (&optional force)
6773 "Highlight current article.
6774 This function calls `gnus-article-highlight-headers',
6775 `gnus-article-highlight-citation',
6776 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6777 do the highlighting. See the documentation for those functions."
6778 (interactive (list 'force))
6779 (gnus-article-highlight-headers)
6780 (gnus-article-highlight-citation force)
6781 (gnus-article-highlight-signature)
6782 (gnus-article-add-buttons force)
6783 (gnus-article-add-buttons-to-head))
6785 (defun gnus-article-highlight-some (&optional force)
6786 "Highlight current article.
6787 This function calls `gnus-article-highlight-headers',
6788 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6789 do the highlighting. See the documentation for those functions."
6790 (interactive (list 'force))
6791 (gnus-article-highlight-headers)
6792 (gnus-article-highlight-signature)
6793 (gnus-article-add-buttons))
6795 (defun gnus-article-highlight-headers ()
6796 "Highlight article headers as specified by `gnus-header-face-alist'."
6799 (set-buffer gnus-article-buffer)
6801 (let ((alist gnus-header-face-alist)
6802 (buffer-read-only nil)
6803 (case-fold-search t)
6804 (inhibit-point-motion-hooks t)
6805 entry regexp header-face field-face from hpoints fpoints)
6806 (article-narrow-to-head)
6807 (while (setq entry (pop alist))
6808 (goto-char (point-min))
6809 (setq regexp (concat "^\\("
6810 (if (string-equal "" (nth 0 entry))
6814 header-face (nth 1 entry)
6815 field-face (nth 2 entry))
6816 (while (and (re-search-forward regexp nil t)
6820 (unless (search-forward ":" nil t)
6822 (when (and header-face
6823 (not (memq (point) hpoints)))
6824 (push (point) hpoints)
6825 (gnus-put-text-property from (point) 'face header-face))
6826 (when (and field-face
6827 (not (memq (setq from (point)) fpoints)))
6829 (if (re-search-forward "^[^ \t]" nil t)
6831 (goto-char (point-max)))
6832 (gnus-put-text-property from (point) 'face field-face))))))))
6834 (defun gnus-article-highlight-signature ()
6835 "Highlight the signature in an article.
6836 It does this by highlighting everything after
6837 `gnus-signature-separator' using `gnus-signature-face'."
6839 (when gnus-signature-face
6841 (set-buffer gnus-article-buffer)
6842 (let ((buffer-read-only nil)
6843 (inhibit-point-motion-hooks t))
6845 (when (gnus-article-narrow-to-signature)
6846 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6847 'face gnus-signature-face)))))))
6849 (defun gnus-article-buttonize-signature ()
6850 "Add button to the signature."
6853 (set-buffer gnus-article-buffer)
6854 (let ((buffer-read-only nil)
6855 (inhibit-point-motion-hooks t))
6856 (when (gnus-article-search-signature)
6857 (gnus-article-add-button (match-beginning 0) (match-end 0)
6858 'gnus-signature-toggle
6859 (set-marker (make-marker)
6860 (1+ (match-end 0))))))))
6862 (defun gnus-button-in-region-p (b e prop)
6863 "Say whether PROP exists in the region."
6864 (text-property-not-all b e prop nil))
6866 (defun gnus-article-add-buttons (&optional force)
6867 "Find external references in the article and make buttons of them.
6868 \"External references\" are things like Message-IDs and URLs, as
6869 specified by `gnus-button-alist'."
6870 (interactive (list 'force))
6872 (set-buffer gnus-article-buffer)
6873 (let ((buffer-read-only nil)
6874 (inhibit-point-motion-hooks t)
6875 (case-fold-search t)
6876 (alist gnus-button-alist)
6878 ;; Remove all old markers.
6879 (let (marker entry new-list)
6880 (while (setq marker (pop gnus-button-marker-list))
6881 (if (or (< marker (point-min)) (>= marker (point-max)))
6882 (push marker new-list)
6884 (when (setq entry (gnus-button-entry))
6885 (put-text-property (match-beginning (nth 1 entry))
6886 (match-end (nth 1 entry))
6887 'gnus-callback nil))
6888 (set-marker marker nil)))
6889 (setq gnus-button-marker-list new-list))
6890 ;; We skip the headers.
6893 (while (setq entry (pop alist))
6894 (setq regexp (eval (car entry)))
6896 (while (re-search-forward regexp nil t)
6897 (let* ((start (and entry (match-beginning (nth 1 entry))))
6898 (end (and entry (match-end (nth 1 entry))))
6899 (from (match-beginning 0)))
6900 (when (and (or (eq t (nth 2 entry))
6901 (eval (nth 2 entry)))
6902 (not (gnus-button-in-region-p
6903 start end 'gnus-callback)))
6904 ;; That optional form returned non-nil, so we add the
6906 (gnus-article-add-button
6907 start end 'gnus-button-push
6908 (car (push (set-marker (make-marker) from)
6909 gnus-button-marker-list))))))))))
6911 ;; Add buttons to the head of an article.
6912 (defun gnus-article-add-buttons-to-head ()
6913 "Add buttons to the head of the article."
6916 (set-buffer gnus-article-buffer)
6918 (let ((buffer-read-only nil)
6919 (inhibit-point-motion-hooks t)
6920 (case-fold-search t)
6921 (alist gnus-header-button-alist)
6923 (article-narrow-to-head)
6925 ;; Each alist entry.
6926 (setq entry (car alist)
6928 (goto-char (point-min))
6929 (while (re-search-forward (car entry) nil t)
6930 ;; Each header matching the entry.
6931 (setq beg (match-beginning 0))
6932 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6933 (match-beginning 0))
6936 (while (re-search-forward (eval (nth 1 entry)) end t)
6937 ;; Each match within a header.
6938 (let* ((entry (cdr entry))
6939 (start (match-beginning (nth 1 entry)))
6940 (end (match-end (nth 1 entry)))
6941 (form (nth 2 entry)))
6942 (goto-char (match-end 0))
6944 (gnus-article-add-button
6945 start end (nth 3 entry)
6946 (buffer-substring (match-beginning (nth 4 entry))
6947 (match-end (nth 4 entry)))))))
6948 (goto-char end)))))))
6950 ;;; External functions:
6952 (defun gnus-article-add-button (from to fun &optional data)
6953 "Create a button between FROM and TO with callback FUN and data DATA."
6954 (when gnus-article-button-face
6955 (gnus-overlay-put (gnus-make-overlay from to)
6956 'face gnus-article-button-face))
6957 (gnus-add-text-properties
6959 (nconc (and gnus-article-mouse-face
6960 (list gnus-mouse-face-prop gnus-article-mouse-face))
6961 (list 'gnus-callback fun)
6962 (and data (list 'gnus-data data))))
6963 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6964 ;; Quote `:button-keymap' for Mule 2.3
6965 ;; but it won't work.
6966 ':button-keymap gnus-widget-button-keymap))
6968 ;;; Internal functions:
6970 (defun gnus-article-set-globals ()
6972 (set-buffer gnus-summary-buffer)
6973 (gnus-set-global-variables)))
6975 (defun gnus-signature-toggle (end)
6977 (set-buffer gnus-article-buffer)
6978 (let ((buffer-read-only nil)
6979 (inhibit-point-motion-hooks t)
6980 (limit (next-single-property-change end 'mime-view-entity
6982 (if (text-property-any end limit 'article-type 'signature)
6984 (gnus-delete-wash-type 'signature)
6985 (gnus-remove-text-properties-when
6986 'article-type 'signature end limit
6987 (cons 'article-type (cons 'signature
6988 gnus-hidden-properties))))
6989 (gnus-add-wash-type 'signature)
6990 (gnus-add-text-properties-when
6991 'article-type nil end limit
6992 (cons 'article-type (cons 'signature
6993 gnus-hidden-properties)))))
6994 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6995 (gnus-set-mode-line 'article))))
6997 (defun gnus-button-entry ()
6998 ;; Return the first entry in `gnus-button-alist' matching this place.
6999 (let ((alist gnus-button-alist)
7002 (setq entry (pop alist))
7003 (if (looking-at (eval (car entry)))
7008 (defun gnus-button-push (marker)
7009 ;; Push button starting at MARKER.
7012 (let* ((entry (gnus-button-entry))
7013 (inhibit-point-motion-hooks t)
7015 (args (mapcar (lambda (group)
7016 (let ((string (match-string group)))
7017 (gnus-set-text-properties
7018 0 (length string) nil string)
7025 (fboundp (symbol-value fun)))
7026 (apply (symbol-value fun) args))
7028 (gnus-message 1 "You must define `%S' to use this button"
7029 (cons fun args)))))))
7031 (defun gnus-parse-news-url (url)
7032 (let (scheme server group message-id articles)
7035 (goto-char (point-min))
7036 (when (looking-at "\\([A-Za-z]+\\):")
7037 (setq scheme (match-string 1))
7038 (goto-char (match-end 0)))
7039 (when (looking-at "//\\([^/]+\\)/")
7040 (setq server (match-string 1))
7041 (goto-char (match-end 0)))
7044 ((looking-at "\\(.*@.*\\)")
7045 (setq message-id (match-string 1)))
7046 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7047 (setq group (match-string 1)
7048 articles (split-string (match-string 2) "-")))
7049 ((looking-at "\\([^/]+\\)/?")
7050 (setq group (match-string 1)))
7052 (error "Unknown news URL syntax"))))
7053 (list scheme server group message-id articles)))
7055 (defun gnus-button-handle-news (url)
7057 (destructuring-bind (scheme server group message-id articles)
7058 (gnus-parse-news-url url)
7062 (set-buffer gnus-summary-buffer)
7064 (let ((gnus-refer-article-method (list (list 'nntp server))))
7065 (gnus-summary-refer-article message-id))
7066 (gnus-summary-refer-article message-id))))
7068 (gnus-button-fetch-group url)))))
7070 (defun gnus-button-handle-man (url)
7072 (funcall gnus-button-man-handler url))
7074 (defun gnus-button-handle-info-url (url)
7075 "Fetch an info URL."
7076 (setq url (mm-subst-char-in-string ?+ ?\ url))
7078 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
7079 (gnus-info-find-node
7080 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
7082 ")" (gnus-url-unhex-string (match-string 2 url)))))
7083 ((string-match "([^)\"]+)[^\"]+" url)
7085 (gnus-replace-in-string
7086 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
7087 (gnus-info-find-node url))
7088 (t (error "Can't parse %s" url))))
7090 (defun gnus-button-handle-info-url-gnome (url)
7091 "Fetch GNOME style info URL."
7092 (setq url (mm-subst-char-in-string ?_ ?\ url))
7093 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
7094 (gnus-info-find-node
7096 (gnus-url-unhex-string
7097 (match-string 1 url))
7099 (or (gnus-url-unhex-string
7100 (match-string 2 url))
7102 (error "Can't parse %s" url)))
7104 (defun gnus-button-handle-info-url-kde (url)
7105 "Fetch KDE style info URL."
7106 (gnus-info-find-node (gnus-url-unhex-string url)))
7108 (defun gnus-button-handle-info-keystrokes (url)
7109 "Call `info' when pushing the corresponding URL button."
7110 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
7115 (defun gnus-button-message-id (message-id)
7118 (set-buffer gnus-summary-buffer)
7119 (gnus-summary-refer-article message-id)))
7121 (defun gnus-button-fetch-group (address)
7122 "Fetch GROUP specified by ADDRESS."
7123 (if (not (string-match "[:/]" address))
7124 ;; This is just a simple group url.
7125 (gnus-group-read-ephemeral-group address gnus-select-method)
7128 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
7130 (error "Can't parse %s" address)
7131 (gnus-group-read-ephemeral-group
7132 (match-string 4 address)
7133 `(nntp ,(match-string 1 address)
7134 (nntp-address ,(match-string 1 address))
7135 (nntp-port-number ,(if (match-end 3)
7136 (match-string 3 address)
7139 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
7141 (defun gnus-url-parse-query-string (query &optional downcase)
7142 (let (retval pairs cur key val)
7143 (setq pairs (split-string query "&"))
7145 (setq cur (car pairs)
7147 (if (not (string-match "=" cur))
7149 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
7150 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
7152 (setq key (downcase key)))
7153 (setq cur (assoc key retval))
7155 (setcdr cur (cons val (cdr cur)))
7156 (setq retval (cons (list key val) retval)))))
7159 (defun gnus-url-mailto (url)
7160 ;; Send mail to someone
7161 (when (string-match "mailto:/*\\(.*\\)" url)
7162 (setq url (substring url (match-beginning 1) nil)))
7163 (let (to args subject func)
7164 (if (string-match (regexp-quote "?") url)
7165 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
7166 args (gnus-url-parse-query-string
7167 (substring url (match-end 0) nil) t))
7168 (setq to (gnus-url-unhex-string url)))
7169 (setq args (cons (list "to" to) args)
7170 subject (cdr-safe (assoc "subject" args)))
7173 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
7176 (message-position-on-field (caar args)))
7177 (insert (mapconcat 'identity (cdar args) ", "))
7178 (setq args (cdr args)))
7181 (message-goto-subject))))
7183 (defun gnus-button-embedded-url (address)
7184 "Activate ADDRESS with `browse-url'."
7185 (browse-url (gnus-strip-whitespace address)))
7187 ;;; Next/prev buttons in the article buffer.
7189 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
7190 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
7192 (defvar gnus-prev-page-map
7193 (let ((map (make-sparse-keymap)))
7194 (unless (>= emacs-major-version 21)
7195 ;; XEmacs doesn't care.
7196 (set-keymap-parent map gnus-article-mode-map))
7197 (define-key map gnus-mouse-2 'gnus-button-prev-page)
7198 (define-key map "\r" 'gnus-button-prev-page)
7201 (defun gnus-insert-prev-page-button ()
7203 (buffer-read-only nil)
7204 (situation (get-text-property (point-min) 'mime-view-situation)))
7206 gnus-prev-page-line-format nil
7207 `(,@(gnus-local-map-property gnus-prev-page-map)
7209 gnus-callback gnus-article-button-prev-page
7210 article-type annotation
7211 mime-view-situation ,situation))
7212 (widget-convert-button
7214 ;; Exclude a newline.
7217 :action 'gnus-button-prev-page
7218 :button-keymap gnus-prev-page-map)))
7220 (defvar gnus-next-page-map
7221 (let ((map (make-sparse-keymap)))
7222 (unless (>= emacs-major-version 21)
7223 ;; XEmacs doesn't care.
7224 (set-keymap-parent map gnus-article-mode-map))
7225 (define-key map gnus-mouse-2 'gnus-button-next-page)
7226 (define-key map "\r" 'gnus-button-next-page)
7229 (defun gnus-button-next-page (&optional args more-args)
7230 "Go to the next page."
7232 (let ((win (selected-window)))
7233 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7234 (gnus-article-next-page)
7235 (select-window win)))
7237 (defun gnus-button-prev-page (&optional args more-args)
7238 "Go to the prev page."
7240 (let ((win (selected-window)))
7241 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7242 (gnus-article-prev-page)
7243 (select-window win)))
7245 (defun gnus-insert-next-page-button ()
7247 (buffer-read-only nil)
7248 (situation (get-text-property (point-min) 'mime-view-situation)))
7249 (gnus-eval-format gnus-next-page-line-format nil
7250 `(,@(gnus-local-map-property gnus-next-page-map)
7252 gnus-callback gnus-article-button-next-page
7253 article-type annotation
7254 mime-view-situation ,situation))
7255 (widget-convert-button
7257 ;; Exclude a newline.
7260 :action 'gnus-button-next-page
7261 :button-keymap gnus-next-page-map)))
7263 (defun gnus-article-button-next-page (arg)
7264 "Go to the next page."
7266 (let ((win (selected-window)))
7267 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7268 (gnus-article-next-page)
7269 (select-window win)))
7271 (defun gnus-article-button-prev-page (arg)
7272 "Go to the prev page."
7274 (let ((win (selected-window)))
7275 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7276 (gnus-article-prev-page)
7277 (select-window win)))
7279 (defvar gnus-decode-header-methods
7280 '(mail-decode-encoded-word-region)
7281 "List of methods used to decode headers.
7283 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7284 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
7285 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
7286 whose names match REGEXP.
7289 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7290 mail-decode-encoded-word-region
7291 (\"chinese\" . rfc1843-decode-region))
7294 (defvar gnus-decode-header-methods-cache nil)
7296 (defun gnus-multi-decode-header (start end)
7297 "Apply the functions from `gnus-encoded-word-methods' that match."
7298 (unless (and gnus-decode-header-methods-cache
7299 (eq gnus-newsgroup-name
7300 (car gnus-decode-header-methods-cache)))
7301 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7304 (nconc gnus-decode-header-methods-cache (list x))
7305 (if (and gnus-newsgroup-name
7306 (string-match (car x) gnus-newsgroup-name))
7307 (nconc gnus-decode-header-methods-cache
7309 gnus-decode-header-methods))
7310 (let ((xlist gnus-decode-header-methods-cache))
7313 (narrow-to-region start end)
7315 (funcall (pop xlist) (point-min) (point-max))))))
7318 ;;; Treatment top-level handling.
7321 (defun gnus-treat-article (condition &optional part-number total-parts type)
7322 (let ((length (- (point-max) (point-min)))
7323 (alist gnus-treatment-function-alist)
7324 (article-goto-body-goes-to-point-min-p t)
7328 (let ((list gnus-article-treat-types))
7330 (when (string-match (pop list) type)
7331 (throw 'found t)))))))
7332 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7333 (entity (static-unless (featurep 'xemacs)
7334 (when (eq 'head condition)
7335 (get-text-property (point-min) 'mime-view-entity))))
7336 val elem buttonized)
7337 (gnus-run-hooks 'gnus-part-display-hook)
7338 (unless gnus-inhibit-treatment
7339 (dolist (elem alist)
7342 (when (gnus-buffer-live-p gnus-summary-buffer)
7343 (set-buffer gnus-summary-buffer))
7344 (symbol-value (car elem))))
7345 (when (and (or (consp val)
7347 (gnus-treat-predicate val)
7348 (or (not (get (car elem) 'highlight))
7350 (when (and (not buttonized)
7352 '(gnus-treat-hide-signature
7353 gnus-treat-highlight-signature)))
7354 (gnus-article-buttonize-signature)
7355 (setq buttonized t))
7357 (funcall (cadr elem)))))
7358 ;; FSF Emacsen does not inherit the existing text properties
7359 ;; in the new text, so we should do it for `mime-view-entity'.
7360 (static-unless (featurep 'xemacs)
7362 (put-text-property (point-min) (point-max)
7363 'mime-view-entity entity))))))
7365 ;; Dynamic variables.
7367 (defvar part-number)
7368 (defvar total-parts)
7373 (defun gnus-treat-predicate (val)
7378 (stringp (car val)))
7379 (apply 'gnus-or (mapcar `(lambda (s)
7380 (string-match s ,(or gnus-newsgroup-name "")))
7383 (let ((pred (pop val)))
7386 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7388 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7390 (not (gnus-treat-predicate (car val))))
7392 (equal (car val) type))
7394 (error "%S is not a valid predicate" pred)))))
7404 (eq part-number total-parts))
7408 (error "%S is not a valid value" val))))
7410 (defun gnus-article-encrypt-body (protocol &optional n)
7411 "Encrypt the article body."
7414 (or gnus-article-encrypt-protocol
7415 (completing-read "Encrypt protocol: "
7416 gnus-article-encrypt-protocol-alist
7418 current-prefix-arg))
7419 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7421 (error (format "Can't find the encrypt protocol %s" protocol)))
7422 (if (member gnus-newsgroup-name '("nndraft:delayed"
7425 (error "Can't encrypt the article in group %s"
7426 gnus-newsgroup-name))
7427 (gnus-summary-iterate n
7429 (set-buffer gnus-summary-buffer)
7430 (let ((mail-parse-charset gnus-newsgroup-charset)
7431 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7432 (summary-buffer gnus-summary-buffer)
7434 (gnus-set-global-variables)
7435 (when (gnus-group-read-only-p)
7436 (error "The current newsgroup does not support article encrypt"))
7437 (gnus-summary-show-article t)
7439 (or (mail-header-references gnus-current-headers) ""))
7440 (set-buffer gnus-article-buffer)
7441 (let* ((buffer-read-only nil)
7443 (mapcar (lambda (field)
7444 (and (save-restriction
7445 (message-narrow-to-head)
7446 (goto-char (point-min))
7447 (search-forward field nil t))
7449 (message-narrow-to-field)
7451 (delete-region (point-min) (point-max))
7453 '("Content-Type:" "Content-Transfer-Encoding:"
7454 "Content-Disposition:"))))
7455 (message-narrow-to-head)
7456 (message-remove-header "MIME-Version")
7457 (goto-char (point-max))
7458 (setq point (point))
7459 (insert (apply 'concat headers))
7461 (narrow-to-region point (point-max))
7462 (let ((message-options message-options))
7463 (message-options-set 'message-sender user-mail-address)
7464 (message-options-set 'message-recipients user-mail-address)
7465 (message-options-set 'message-sign-encrypt 'not)
7467 (goto-char (point-min))
7468 (insert "MIME-Version: 1.0\n")
7470 (gnus-summary-edit-article-done
7471 references nil summary-buffer t))
7472 (when gnus-keep-backlog
7473 (gnus-backlog-remove-article
7474 (car gnus-article-current) (cdr gnus-article-current)))
7476 (when (get-buffer gnus-original-article-buffer)
7477 (set-buffer gnus-original-article-buffer)
7478 (setq gnus-original-article nil)))
7479 (when gnus-use-cache
7480 (gnus-cache-update-article
7481 (car gnus-article-current) (cdr gnus-article-current))))))))
7483 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7484 "The following specs can be used:
7485 %t The security MIME type
7488 %D Details if button is pressed")
7490 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7491 "The following specs can be used:
7492 %t The security MIME type
7495 %D Details if button is pressed")
7497 (defvar gnus-mime-security-button-line-format-alist
7498 '((?t gnus-tmp-type ?s)
7499 (?i gnus-tmp-info ?s)
7500 (?d gnus-tmp-details ?s)
7501 (?D gnus-tmp-pressed-details ?s)))
7503 (defvar gnus-mime-security-button-map
7504 (let ((map (make-sparse-keymap)))
7505 (unless (>= (string-to-number emacs-version) 21)
7506 (set-keymap-parent map gnus-article-mode-map))
7507 (define-key map gnus-mouse-2 'gnus-article-push-button)
7508 (define-key map "\r" 'gnus-article-press-button)
7511 (defvar gnus-mime-security-details-buffer nil)
7513 (defvar gnus-mime-security-button-pressed nil)
7515 (defvar gnus-mime-security-show-details-inline t
7516 "If non-nil, show details in the article buffer.")
7518 (defun gnus-mime-security-verify-or-decrypt (handle)
7519 (mm-remove-parts (cdr handle))
7520 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7521 point buffer-read-only)
7523 (goto-char (car region)))
7525 (narrow-to-region (point) (point))
7526 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7527 (let* ((mm-verify-option 'known)
7528 (mm-decrypt-option 'known)
7529 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7530 (unless (eq nparts (cdr handle))
7531 (mm-destroy-parts (cdr handle))
7532 (setcdr handle nparts))))
7533 (setq point (point))
7534 (gnus-mime-display-security handle)
7535 (goto-char (point-max)))
7537 (delete-region (point) (cdr region))
7538 (set-marker (car region) nil)
7539 (set-marker (cdr region) nil))
7542 (defun gnus-mime-security-show-details (handle)
7543 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7545 (gnus-message 5 "No details.")
7546 (if gnus-mime-security-show-details-inline
7547 (let ((gnus-mime-security-button-pressed
7548 (not (get-text-property (point) 'gnus-mime-details)))
7549 (gnus-mime-security-button-line-format
7550 (get-text-property (point) 'gnus-line-format))
7553 (while (eq (get-text-property (point) 'gnus-line-format)
7554 gnus-mime-security-button-line-format)
7558 (narrow-to-region (point) (point))
7559 (gnus-insert-mime-security-button handle))
7560 (delete-region (point)
7561 (or (text-property-not-all
7564 gnus-mime-security-button-line-format)
7567 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7568 (with-current-buffer gnus-mime-security-details-buffer
7571 (setq gnus-mime-security-details-buffer
7572 (gnus-get-buffer-create "*MIME Security Details*")))
7573 (with-current-buffer gnus-mime-security-details-buffer
7575 (goto-char (point-min)))
7576 (pop-to-buffer gnus-mime-security-details-buffer)))))
7578 (defun gnus-mime-security-press-button (handle)
7580 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7581 (gnus-mime-security-show-details handle)
7582 (gnus-mime-security-verify-or-decrypt handle))))
7584 (defun gnus-insert-mime-security-button (handle &optional displayed)
7585 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7588 (or (nth 2 (assoc protocol mm-verify-function-alist))
7589 (nth 2 (assoc protocol mm-decrypt-function-alist))
7591 (if (equal (car handle) "multipart/signed")
7592 " Signed" " Encrypted")
7595 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7598 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7599 gnus-tmp-pressed-details
7601 (setq gnus-tmp-details
7602 (if gnus-tmp-details
7603 (concat "\n" gnus-tmp-details)
7605 (setq gnus-tmp-pressed-details
7606 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7611 gnus-mime-security-button-line-format
7612 gnus-mime-security-button-line-format-alist
7613 `(,@(gnus-local-map-property gnus-mime-security-button-map)
7614 gnus-callback gnus-mime-security-press-button
7615 gnus-line-format ,gnus-mime-security-button-line-format
7616 gnus-mime-details ,gnus-mime-security-button-pressed
7617 article-type annotation
7620 ;; Exclude a newline.
7623 (widget-convert-button
7626 :action 'gnus-widget-press-button
7627 :button-keymap gnus-mime-security-button-map
7629 (lambda (widget/window &optional overlay pos)
7630 ;; Needed to properly clear the message due to a bug in
7631 ;; wid-edit (XEmacs only).
7632 (when (boundp 'help-echo-owns-message)
7633 (setq help-echo-owns-message t))
7636 (aref gnus-mouse-2 0))))))
7638 (defun gnus-mime-display-security (handle)
7640 (narrow-to-region (point) (point))
7641 (unless (gnus-unbuttonized-mime-type-p (car handle))
7642 (gnus-insert-mime-security-button handle))
7643 (gnus-mime-display-mixed (cdr handle))
7646 (unless (gnus-unbuttonized-mime-type-p (car handle))
7647 (let ((gnus-mime-security-button-line-format
7648 gnus-mime-security-button-end-line-format))
7649 (gnus-insert-mime-security-button handle)))
7650 (mm-set-handle-multipart-parameter
7652 (cons (set-marker (make-marker) (point-min))
7653 (set-marker (make-marker) (point-max))))))
7659 (defun gnus-article-header-presentation-method (entity situation)
7660 (mime-insert-header entity)
7661 (article-decode-group-name))
7663 (set-alist 'mime-header-presentation-method-alist
7664 'gnus-original-article-mode
7665 #'gnus-article-header-presentation-method)
7667 (defun gnus-mime-preview-quitting-method ()
7668 (mime-preview-kill-buffer)
7669 (delete-other-windows)
7670 (gnus-article-show-summary)
7671 (gnus-summary-select-article gnus-show-all-headers t))
7673 (set-alist 'mime-preview-quitting-method-alist
7674 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
7676 (set-alist 'mime-preview-following-method-alist
7677 'gnus-original-article-mode #'gnus-following-method)
7679 (set-alist 'mime-preview-over-to-previous-method-alist
7680 'gnus-original-article-mode
7682 (if (> (point-min) 1)
7683 (gnus-article-prev-page)
7684 (gnus-article-read-summary-keys
7685 nil (gnus-character-to-event ?P)))))
7687 (set-alist 'mime-preview-over-to-next-method-alist
7688 'gnus-original-article-mode'
7690 (if (< (point-max) (buffer-size))
7691 (gnus-article-next-page)
7692 (gnus-article-read-summary-keys
7693 nil (gnus-character-to-event ?N)))))
7703 (run-hooks 'gnus-art-load-hook)
7705 ;;; gnus-art.el ends here