1 ;;; gnus-art.el --- article mode commands for Semi-gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;; Katsumi Yamaoka <yamaoka@jpl.org>
8 ;; Keywords: mail, news, MIME
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
34 (defvar tool-bar-map))
46 ;; Avoid byte-compile warnings.
56 (autoload 'gnus-msg-mail "gnus-msg" nil t)
57 (autoload 'gnus-button-mailto "gnus-msg")
58 (autoload 'gnus-button-reply "gnus-msg" nil t)
60 (defgroup gnus-article nil
62 :link '(custom-manual "(gnus)The Article Buffer")
65 (defgroup gnus-article-treat nil
66 "Treating article parts."
67 :link '(custom-manual "(gnus)Article Hiding")
70 (defgroup gnus-article-hiding nil
71 "Hiding article parts."
72 :link '(custom-manual "(gnus)Article Hiding")
75 (defgroup gnus-article-highlight nil
76 "Article highlighting."
77 :link '(custom-manual "(gnus)Article Highlighting")
81 (defgroup gnus-article-signature nil
83 :link '(custom-manual "(gnus)Article Signature")
86 (defgroup gnus-article-headers nil
88 :link '(custom-manual "(gnus)Hiding Headers")
91 (defgroup gnus-article-washing nil
92 "Special commands on articles."
93 :link '(custom-manual "(gnus)Article Washing")
96 (defgroup gnus-article-emphasis nil
97 "Fontisizing articles."
98 :link '(custom-manual "(gnus)Article Fontisizing")
101 (defgroup gnus-article-saving nil
103 :link '(custom-manual "(gnus)Saving Articles")
104 :group 'gnus-article)
106 (defgroup gnus-article-mime nil
107 "Worshiping the MIME wonder."
108 :link '(custom-manual "(gnus)Using MIME")
109 :group 'gnus-article)
111 (defgroup gnus-article-buttons nil
112 "Pushable buttons in the article buffer."
113 :link '(custom-manual "(gnus)Article Buttons")
114 :group 'gnus-article)
116 (defgroup gnus-article-various nil
117 "Other article options."
118 :link '(custom-manual "(gnus)Misc Article")
119 :group 'gnus-article)
121 (defcustom gnus-ignored-headers
124 (concat "^" header ":"))
125 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
126 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
127 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
128 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
129 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
130 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
131 "X-Attribution" "X-Originating-IP" "Delivered-To"
132 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
133 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
134 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
135 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
136 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
137 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
138 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
139 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
140 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
141 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
142 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
143 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
144 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
145 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
146 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
147 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
148 "List-[A-Za-z]+" "X-Listprocessor-Version"
149 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
150 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
151 "X-Received" "Content-length" "X-precedence"
152 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
153 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
154 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
155 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
156 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
157 "X-Content-length" "X-Posting-Agent" "Original-Received"
158 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
159 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
160 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
161 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
162 "X-Abuse-and-DMCA-Info" "X-Postfilter"))
163 "*All headers that start with this regexp will be hidden.
164 This variable can also be a list of regexps of headers to be ignored.
165 If `gnus-visible-headers' is non-nil, this variable will be ignored."
166 :type '(choice :custom-show nil
169 :group 'gnus-article-hiding)
171 (defcustom gnus-visible-headers
172 "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^[BGF]?Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Mail-Followup-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:\\|^X-Sent:"
173 "*All headers that do not match this regexp will be hidden.
174 This variable can also be a list of regexp of headers to remain visible.
175 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
176 :type '(repeat :value-to-internal (lambda (widget value)
177 (custom-split-regexp-maybe value))
178 :match (lambda (widget value)
180 (widget-editable-list-match widget value)))
182 :group 'gnus-article-hiding)
184 (defcustom gnus-sorted-header-list
185 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
186 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
187 "*This variable is a list of regular expressions.
188 If it is non-nil, headers that match the regular expressions will
189 be placed first in the article buffer in the sequence specified by
191 :type '(repeat regexp)
192 :group 'gnus-article-hiding)
194 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
195 "Headers that are only to be displayed if they have interesting data.
196 Possible values in this list are:
198 'empty Headers with no content.
199 'newsgroups Newsgroup identical to Gnus group.
200 'to-address To identical to To-address.
201 'to-list To identical to To-list.
202 'cc-list CC identical to To-list.
203 'followup-to Followup-to identical to Newsgroups.
204 'reply-to Reply-to identical to From.
205 'date Date less than four days old.
206 'long-to To and/or Cc longer than 1024 characters.
207 'many-to Multiple To and/or Cc."
208 :type '(set (const :tag "Headers with no content." empty)
209 (const :tag "Newsgroups identical to Gnus group." newsgroups)
210 (const :tag "To identical to To-address." to-address)
211 (const :tag "To identical to To-list." to-list)
212 (const :tag "CC identical to To-list." cc-list)
213 (const :tag "Followup-to identical to Newsgroups." followup-to)
214 (const :tag "Reply-to identical to From." reply-to)
215 (const :tag "Date less than four days old." date)
216 (const :tag "To and/or Cc longer than 1024 characters." long-to)
217 (const :tag "Multiple To and/or Cc headers." many-to))
218 :group 'gnus-article-hiding)
220 (defcustom gnus-article-skip-boring nil
221 "Skip over text that is not worth reading.
222 By default, if you set this t, then Gnus will display citations and
223 signatures, but will never scroll down to show you a page consisting
224 only of boring text. Boring text is controlled by
225 `gnus-article-boring-faces'."
227 :group 'gnus-article-hiding)
229 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
230 "Regexp matching signature separator.
231 This can also be a list of regexps. In that case, it will be checked
232 from head to tail looking for a separator. Searches will be done from
233 the end of the buffer."
234 :type '(repeat string)
235 :group 'gnus-article-signature)
237 (defcustom gnus-signature-limit nil
238 "Provide a limit to what is considered a signature.
239 If it is a number, no signature may not be longer (in characters) than
240 that number. If it is a floating point number, no signature may be
241 longer (in lines) than that number. If it is a function, the function
242 will be called without any parameters, and if it returns nil, there is
243 no signature in the buffer. If it is a string, it will be used as a
244 regexp. If it matches, the text in question is not a signature."
245 :type '(choice (integer :value 200)
247 (function :value fun)
248 (regexp :value ".*"))
249 :group 'gnus-article-signature)
251 (defcustom gnus-hidden-properties '(invisible t intangible t)
252 "Property list to use for hiding text."
254 :group 'gnus-article-hiding)
256 ;; Fixme: This isn't the right thing for mixed graphical and and
257 ;; non-graphical frames in a session.
258 (defcustom gnus-article-x-face-command
263 (if (or (gnus-image-type-available-p 'xface)
264 (gnus-image-type-available-p 'pbm))
265 'gnus-display-x-face-in-from
266 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -"))
267 ((and (fboundp 'image-type-available-p)
268 (module-installed-p 'x-face-e21))
269 'x-face-decode-message-header)
270 ((gnus-image-type-available-p 'pbm)
271 'gnus-display-x-face-in-from)
273 (module-installed-p 'x-face-mule))
274 'x-face-mule-gnus-article-display-x-face)
276 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
278 "*String or function to be executed to display an X-Face header.
279 If it is a string, the command will be executed in a sub-shell
280 asynchronously. The compressed face will be piped to this command."
282 ,@(let (x-face-e21 x-face-mule)
283 (if (featurep 'xemacs)
285 (setq x-face-e21 (module-installed-p 'x-face-e21)
286 x-face-mule (module-installed-p 'x-face-mule)))
290 (if (or (gnus-image-type-available-p 'xface)
291 (gnus-image-type-available-p 'pbm))
292 '(function-item gnus-display-x-face-in-from))
294 (fboundp 'image-type-available-p))
296 :tag "x-face-decode-message-header (x-face-e21)"
297 x-face-decode-message-header))
300 x-face-mule-gnus-article-display-x-face))
304 :group 'gnus-article-washing)
306 (defcustom gnus-article-x-face-too-ugly nil
307 "Regexp matching posters whose face shouldn't be shown automatically."
308 :type '(choice regexp (const nil))
309 :group 'gnus-article-washing)
311 (defcustom gnus-article-banner-alist nil
312 "Banner alist for stripping.
314 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
316 :type '(repeat (cons symbol regexp))
317 :group 'gnus-article-washing)
319 (gnus-define-group-parameter
322 "Alist of regexps (to match group names) and banner."
323 :variable-group gnus-article-washing
325 '(choice :tag "Banner"
327 (const :tag "Remove signature" signature)
328 (symbol :tag "Item in `gnus-article-banner-alist'" none)
330 (const :tag "None" nil))
332 "If non-nil, specify how to remove `banners' from articles.
334 Symbol `signature' means to remove signatures delimited by
335 `gnus-signature-separator'. Any other symbol is used to look up a
336 regular expression to match the banner in `gnus-article-banner-alist'.
337 A string is used as a regular expression to match the banner
340 (defcustom gnus-article-address-banner-alist nil
341 "Alist of mail addresses and banners.
342 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
343 to match a mail address in the From: header, BANNER is one of a symbol
344 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
345 If ADDRESS matches author's mail address, it will remove things like
346 advertisements. For example:
348 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
352 (regexp :tag "Address")
353 (choice :tag "Banner" :value nil
354 (const :tag "Remove signature" signature)
355 (symbol :tag "Item in `gnus-article-banner-alist'" none)
357 (const :tag "None" nil))))
358 :group 'gnus-article-washing)
360 (defcustom gnus-emphasis-alist
362 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
367 ("_/" "/_" underline-italic)
368 ("_\\*" "\\*_" underline-bold)
369 ("\\*/" "/\\*" bold-italic)
370 ("_\\*/" "/\\*_" underline-bold-italic))))
374 (format format (car spec) (car (cdr spec)))
375 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
377 ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
378 2 3 gnus-emphasis-strikethru)
379 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
380 2 3 gnus-emphasis-underline)))
381 "*Alist that says how to fontify certain phrases.
382 Each item looks like this:
384 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
386 The first element is a regular expression to be matched. The second
387 is a number that says what regular expression grouping used to find
388 the entire emphasized word. The third is a number that says what
389 regexp grouping should be displayed and highlighted. The fourth
390 is the face used for highlighting."
391 :type '(repeat (list :value ("" 0 0 default)
393 (integer :tag "Match group")
394 (integer :tag "Emphasize group")
396 :group 'gnus-article-emphasis)
398 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
399 "A regexp to describe whitespace which should not be emphasized.
400 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
401 The former avoids underlining of leading and trailing whitespace,
402 and the latter avoids underlining any whitespace at all."
404 :group 'gnus-article-emphasis
407 (defface gnus-emphasis-bold '((t (:bold t)))
408 "Face used for displaying strong emphasized text (*word*)."
409 :group 'gnus-article-emphasis)
411 (defface gnus-emphasis-italic '((t (:italic t)))
412 "Face used for displaying italic emphasized text (/word/)."
413 :group 'gnus-article-emphasis)
415 (defface gnus-emphasis-underline '((t (:underline t)))
416 "Face used for displaying underlined emphasized text (_word_)."
417 :group 'gnus-article-emphasis)
419 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
420 "Face used for displaying underlined bold emphasized text (_*word*_)."
421 :group 'gnus-article-emphasis)
423 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
424 "Face used for displaying underlined italic emphasized text (_/word/_)."
425 :group 'gnus-article-emphasis)
427 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
428 "Face used for displaying bold italic emphasized text (/*word*/)."
429 :group 'gnus-article-emphasis)
431 (defface gnus-emphasis-underline-bold-italic
432 '((t (:bold t :italic t :underline t)))
433 "Face used for displaying underlined bold italic emphasized text.
434 Example: (_/*word*/_)."
435 :group 'gnus-article-emphasis)
437 (defface gnus-emphasis-strikethru '((t (:strikethru t)))
438 "Face used for displaying strike-through text (-word-)."
439 :group 'gnus-article-emphasis)
441 (defface gnus-emphasis-highlight-words
442 '((t (:background "black" :foreground "yellow")))
443 "Face used for displaying highlighted words."
444 :group 'gnus-article-emphasis)
446 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
447 "Format for display of Date headers in article bodies.
448 See `format-time-string' for the possible values.
450 The variable can also be function, which should return a complete Date
451 header. The function is called with one argument, the time, which can
452 be fed to `format-time-string'."
453 :type '(choice string symbol)
454 :link '(custom-manual "(gnus)Article Date")
455 :group 'gnus-article-washing)
458 (autoload 'mail-extract-address-components "mail-extr"))
460 (defcustom gnus-save-all-headers t
461 "*If non-nil, don't remove any headers before saving."
462 :group 'gnus-article-saving
465 (defcustom gnus-prompt-before-saving 'always
466 "*This variable says how much prompting is to be done when saving articles.
467 If it is nil, no prompting will be done, and the articles will be
468 saved to the default files. If this variable is `always', each and
469 every article that is saved will be preceded by a prompt, even when
470 saving large batches of articles. If this variable is neither nil not
471 `always', there the user will be prompted once for a file name for
472 each invocation of the saving commands."
473 :group 'gnus-article-saving
474 :type '(choice (item always)
475 (item :tag "never" nil)
476 (sexp :tag "once" :format "%t\n" :value t)))
478 (defcustom gnus-saved-headers gnus-visible-headers
479 "Headers to keep if `gnus-save-all-headers' is nil.
480 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
481 If that variable is nil, however, all headers that match this regexp
482 will be kept while the rest will be deleted before saving."
483 :group 'gnus-article-saving
486 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
487 "A function to save articles in your favourite format.
488 The function must be interactively callable (in other words, it must
489 be an Emacs command).
491 Gnus provides the following functions:
493 * gnus-summary-save-in-rmail (Rmail format)
494 * gnus-summary-save-in-mail (Unix mail format)
495 * gnus-summary-save-in-folder (MH folder)
496 * gnus-summary-save-in-file (article format)
497 * gnus-summary-save-body-in-file (article body)
498 * gnus-summary-save-in-vm (use VM's folder format)
499 * gnus-summary-write-to-file (article format -- overwrite)."
500 :group 'gnus-article-saving
501 :type '(radio (function-item gnus-summary-save-in-rmail)
502 (function-item gnus-summary-save-in-mail)
503 (function-item gnus-summary-save-in-folder)
504 (function-item gnus-summary-save-in-file)
505 (function-item gnus-summary-save-body-in-file)
506 (function-item gnus-summary-save-in-vm)
507 (function-item gnus-summary-write-to-file)))
509 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
510 "A function generating a file name to save articles in Rmail format.
511 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
512 :group 'gnus-article-saving
515 (defcustom gnus-mail-save-name 'gnus-plain-save-name
516 "A function generating a file name to save articles in Unix mail format.
517 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
518 :group 'gnus-article-saving
521 (defcustom gnus-folder-save-name 'gnus-folder-save-name
522 "A function generating a file name to save articles in MH folder.
523 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
524 :group 'gnus-article-saving
527 (defcustom gnus-file-save-name 'gnus-numeric-save-name
528 "A function generating a file name to save articles in article format.
529 The function is called with NEWSGROUP, HEADERS, and optional
531 :group 'gnus-article-saving
534 (defcustom gnus-split-methods
535 '((gnus-article-archive-name)
536 (gnus-article-nndoc-name))
537 "*Variable used to suggest where articles are to be saved.
538 For instance, if you would like to save articles related to Gnus in
539 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
540 you could set this variable to something like:
542 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
543 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
545 This variable is an alist where the where the key is the match and the
546 value is a list of possible files to save in if the match is non-nil.
548 If the match is a string, it is used as a regexp match on the
549 article. If the match is a symbol, that symbol will be funcalled
550 from the buffer of the article to be saved with the newsgroup as the
551 parameter. If it is a list, it will be evaled in the same buffer.
553 If this form or function returns a string, this string will be used as
554 a possible file name; and if it returns a non-nil list, that list will
555 be used as possible file names."
556 :group 'gnus-article-saving
557 :type '(repeat (choice (list :value (fun) function)
558 (cons :value ("" "") regexp (repeat string))
561 (defcustom gnus-article-display-method-for-mime
562 'gnus-article-display-mime-message
563 "Function to display a MIME message.
564 The function is called from the article buffer."
565 :group 'gnus-article-mime
568 (defcustom gnus-article-display-method-for-traditional
569 'gnus-article-display-traditional-message
570 "*Function to display a traditional message.
571 The function is called from the article buffer."
572 :group 'gnus-article-mime
575 (defcustom gnus-page-delimiter "^\^L"
576 "*Regexp describing what to use as article page delimiters.
577 The default value is \"^\^L\", which is a form linefeed at the
578 beginning of a line."
580 :group 'gnus-article-various)
582 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
583 "*The format specification for the article mode line.
584 See `gnus-summary-mode-line-format' for a closer description.
586 The following additional specs are available:
588 %w The article washing status.
589 %m The number of MIME parts in the article."
591 :group 'gnus-article-various)
593 (defcustom gnus-article-mode-hook nil
594 "*A hook for Gnus article mode."
596 :group 'gnus-article-various)
598 (when (featurep 'xemacs)
599 ;; Extracted from gnus-xmas-define in order to preserve user settings
600 (when (fboundp 'turn-off-scroll-in-place)
601 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
602 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
603 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
605 (defcustom gnus-article-menu-hook nil
606 "*Hook run after the creation of the article mode menu."
608 :group 'gnus-article-various)
610 (defcustom gnus-article-prepare-hook nil
611 "*A hook called after an article has been prepared in the article buffer."
613 :group 'gnus-article-various)
615 (make-obsolete-variable 'gnus-article-hide-pgp-hook
616 "This variable is obsolete in Gnus 5.10.")
618 (defcustom gnus-article-button-face 'bold
619 "Face used for highlighting buttons in the article buffer.
621 An article button is a piece of text that you can activate by pressing
622 `RET' or `mouse-2' above it."
624 :group 'gnus-article-buttons)
626 (defcustom gnus-article-mouse-face 'highlight
627 "Face used for mouse highlighting in the article buffer.
629 Article buttons will be displayed in this face when the cursor is
632 :group 'gnus-article-buttons)
634 (defcustom gnus-signature-face 'gnus-signature-face
635 "Face used for highlighting a signature in the article buffer.
636 Obsolete; use the face `gnus-signature-face' for customizations instead."
638 :group 'gnus-article-highlight
639 :group 'gnus-article-signature)
641 (defface gnus-signature-face
644 "Face used for highlighting a signature in the article buffer."
645 :group 'gnus-article-highlight
646 :group 'gnus-article-signature)
648 (defface gnus-header-from-face
651 (:foreground "spring green"))
654 (:foreground "red3"))
657 "Face used for displaying from headers."
658 :group 'gnus-article-headers
659 :group 'gnus-article-highlight)
661 (defface gnus-header-subject-face
664 (:foreground "SeaGreen3"))
667 (:foreground "red4"))
669 (:bold t :italic t)))
670 "Face used for displaying subject headers."
671 :group 'gnus-article-headers
672 :group 'gnus-article-highlight)
674 (defface gnus-header-newsgroups-face
677 (:foreground "yellow" :italic t))
680 (:foreground "MidnightBlue" :italic t))
683 "Face used for displaying newsgroups headers."
684 :group 'gnus-article-headers
685 :group 'gnus-article-highlight)
687 (defface gnus-header-name-face
690 (:foreground "SeaGreen"))
693 (:foreground "maroon"))
696 "Face used for displaying header names."
697 :group 'gnus-article-headers
698 :group 'gnus-article-highlight)
700 (defface gnus-header-content-face
703 (:foreground "forest green" :italic t))
706 (:foreground "indianred4" :italic t))
709 "Face used for displaying header content."
710 :group 'gnus-article-headers
711 :group 'gnus-article-highlight)
713 (defcustom gnus-header-face-alist
714 '(("From" nil gnus-header-from-face)
715 ("Subject" nil gnus-header-subject-face)
716 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
717 ("" gnus-header-name-face gnus-header-content-face))
718 "*Controls highlighting of article header.
720 An alist of the form (HEADER NAME CONTENT).
722 HEADER is a regular expression which should match the name of an
723 header header and NAME and CONTENT are either face names or nil.
725 The name of each header field will be displayed using the face
726 specified by the first element in the list where HEADER match the
727 header name and NAME is non-nil. Similarly, the content will be
728 displayed by the first non-nil matching CONTENT face."
729 :group 'gnus-article-headers
730 :group 'gnus-article-highlight
731 :type '(repeat (list (regexp :tag "Header")
733 (item :tag "skip" nil)
734 (face :value default))
735 (choice :tag "Content"
736 (item :tag "skip" nil)
737 (face :value default)))))
739 (defcustom gnus-article-decode-hook
740 '(article-decode-group-name article-decode-idna-rhs)
741 "*Hook run to decode charsets in articles."
742 :group 'gnus-article-headers
745 (defcustom gnus-display-mime-function 'gnus-display-mime
746 "Function to display MIME articles."
747 :group 'gnus-article-mime
750 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
751 "Function used to decode headers.")
753 (defvar gnus-article-dumbquotes-map
773 "Table for MS-to-Latin1 translation.")
775 (defcustom gnus-ignored-mime-types nil
776 "List of MIME types that should be ignored by Gnus."
778 :group 'gnus-article-mime
779 :type '(repeat regexp))
781 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
782 "List of MIME types that should not be given buttons when rendered inline.
783 See also `gnus-buttonized-mime-types' which may override this variable.
784 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
786 :group 'gnus-article-mime
787 :type '(repeat regexp))
789 (defcustom gnus-buttonized-mime-types nil
790 "List of MIME types that should be given buttons when rendered inline.
791 If set, this variable overrides `gnus-unbuttonized-mime-types'.
792 To see e.g. security buttons you could set this to
793 `(\"multipart/signed\")'.
794 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
796 :group 'gnus-article-mime
797 :type '(repeat regexp))
799 (defcustom gnus-inhibit-mime-unbuttonizing nil
800 "If non-nil, all MIME parts get buttons.
801 When nil (the default value), then some MIME parts do not get buttons,
802 as described by the variables `gnus-buttonized-mime-types' and
803 `gnus-unbuttonized-mime-types'."
807 (defcustom gnus-body-boundary-delimiter "_"
808 "String used to delimit header and body.
809 This variable is used by `gnus-article-treat-body-boundary' which can
810 be controlled by `gnus-treat-body-boundary'."
811 :group 'gnus-article-various
812 :type '(choice (item :tag "None" :value nil)
815 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
816 "Defines the location of the faces database.
817 For information on obtaining this database of pretty pictures, please
818 see http://www.cs.indiana.edu/picons/ftp/index.html"
819 :type '(repeat directory)
820 :link '(url-link :tag "download"
821 "http://www.cs.indiana.edu/picons/ftp/index.html")
822 :link '(custom-manual "(gnus)Picons")
825 (defun gnus-picons-installed-p ()
826 "Say whether picons are installed on your machine."
827 (let ((installed nil))
828 (dolist (database gnus-picon-databases)
829 (when (file-exists-p database)
833 (defcustom gnus-article-mime-part-function nil
834 "Function called with a MIME handle as the argument.
835 This is meant for people who want to do something automatic based
836 on parts -- for instance, adding Vcard info to a database."
837 :group 'gnus-article-mime
840 (defcustom gnus-mime-multipart-functions nil
841 "An alist of MIME types to functions to display them."
843 :group 'gnus-article-mime
846 (defcustom gnus-article-date-lapsed-new-header nil
847 "Whether the X-Sent and Date headers can coexist.
848 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
849 either replace the old \"Date:\" header (if this variable is nil), or
850 be added below it (otherwise)."
852 :group 'gnus-article-headers
855 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
856 "Function called with a MIME handle as the argument.
857 This is meant for people who want to view first matched part.
858 For `undisplayed-alternative' (default), the first undisplayed
859 part or alternative part is used. For `undisplayed', the first
860 undisplayed part is used. For a function, the first part which
861 the function return t is used. For nil, the first part is
864 :group 'gnus-article-mime
866 (item :tag "first" :value nil)
867 (item :tag "undisplayed" :value undisplayed)
868 (item :tag "undisplayed or alternative"
869 :value undisplayed-alternative)
872 (defcustom gnus-mime-action-alist
873 '(("save to file" . gnus-mime-save-part)
874 ("save and strip" . gnus-mime-save-part-and-strip)
875 ("delete part" . gnus-mime-delete-part)
876 ("display as text" . gnus-mime-inline-part)
877 ("view the part" . gnus-mime-view-part)
878 ("pipe to command" . gnus-mime-pipe-part)
879 ("toggle display" . gnus-article-press-button)
880 ("toggle display" . gnus-article-view-part-as-charset)
881 ("view as type" . gnus-mime-view-part-as-type)
882 ("view internally" . gnus-mime-view-part-internally)
883 ("view externally" . gnus-mime-view-part-externally))
884 "An alist of actions that run on the MIME attachment."
885 :group 'gnus-article-mime
886 :type '(repeat (cons (string :tag "name")
890 ;;; The treatment variables
893 (defvar gnus-part-display-hook nil
894 "Hook called on parts that are to receive treatment.")
896 (defvar gnus-article-treat-custom
897 '(choice (const :tag "Off" nil)
899 (const :tag "Header" head)
900 (const :tag "Last" last)
901 (const :tag "Mime" mime)
902 (integer :tag "Less")
903 (repeat :tag "Groups" regexp)
904 (sexp :tag "Predicate")))
906 (defvar gnus-article-treat-head-custom
907 '(choice (const :tag "Off" nil)
908 (const :tag "Header" head)))
910 (defvar gnus-article-treat-types '("text/plain")
913 (defvar gnus-inhibit-treatment nil
914 "Whether to inhibit treatment.")
916 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
917 "Highlight the signature.
918 Valid values are nil, t, `head', `last', an integer or a predicate.
919 See Info node `(gnus)Customizing Articles'."
920 :group 'gnus-article-treat
921 :link '(custom-manual "(gnus)Customizing Articles")
922 :type gnus-article-treat-custom)
923 (put 'gnus-treat-highlight-signature 'highlight t)
925 (defcustom gnus-treat-buttonize 100000
927 Valid values are nil, t, `head', `last', an integer or a predicate.
928 See Info node `(gnus)Customizing Articles'."
929 :group 'gnus-article-treat
930 :link '(custom-manual "(gnus)Customizing Articles")
931 :type gnus-article-treat-custom)
932 (put 'gnus-treat-buttonize 'highlight t)
934 (defcustom gnus-treat-buttonize-head 'head
935 "Add buttons to the head.
936 Valid values are nil, t, `head', `last', an integer or a predicate.
937 See Info node `(gnus)Customizing Articles' for details."
938 :group 'gnus-article-treat
939 :link '(custom-manual "(gnus)Customizing Articles")
940 :type gnus-article-treat-head-custom)
941 (put 'gnus-treat-buttonize-head 'highlight t)
943 (defcustom gnus-treat-emphasize
944 (and (or window-system
946 (>= (string-to-number emacs-version) 21))
949 Valid values are nil, t, `head', `last', an integer or a predicate.
950 See Info node `(gnus)Customizing Articles' for details."
951 :group 'gnus-article-treat
952 :link '(custom-manual "(gnus)Customizing Articles")
953 :type gnus-article-treat-custom)
954 (put 'gnus-treat-emphasize 'highlight t)
956 (defcustom gnus-treat-strip-cr nil
957 "Remove carriage returns.
958 Valid values are nil, t, `head', `last', an integer or a predicate.
959 See Info node `(gnus)Customizing Articles' for details."
960 :group 'gnus-article-treat
961 :link '(custom-manual "(gnus)Customizing Articles")
962 :type gnus-article-treat-custom)
964 (defcustom gnus-treat-unsplit-urls nil
965 "Remove newlines from within URLs.
966 Valid values are nil, t, `head', `last', an integer or a predicate.
967 See Info node `(gnus)Customizing Articles' for details."
968 :group 'gnus-article-treat
969 :link '(custom-manual "(gnus)Customizing Articles")
970 :type gnus-article-treat-custom)
972 (defcustom gnus-treat-leading-whitespace nil
973 "Remove leading whitespace in headers.
974 Valid values are nil, t, `head', `last', an integer or a predicate.
975 See Info node `(gnus)Customizing Articles' for details."
976 :group 'gnus-article-treat
977 :link '(custom-manual "(gnus)Customizing Articles")
978 :type gnus-article-treat-custom)
980 (defcustom gnus-treat-hide-headers 'head
982 Valid values are nil, t, `head', `last', an integer or a predicate.
983 See Info node `(gnus)Customizing Articles' for details."
984 :group 'gnus-article-treat
985 :link '(custom-manual "(gnus)Customizing Articles")
986 :type gnus-article-treat-head-custom)
988 (defcustom gnus-treat-hide-boring-headers nil
989 "Hide boring headers.
990 Valid values are nil, t, `head', `last', an integer or a predicate.
991 See Info node `(gnus)Customizing Articles' for details."
992 :group 'gnus-article-treat
993 :link '(custom-manual "(gnus)Customizing Articles")
994 :type gnus-article-treat-head-custom)
996 (defcustom gnus-treat-hide-signature nil
998 Valid values are nil, t, `head', `last', an integer or a predicate.
999 See Info node `(gnus)Customizing Articles' for details."
1000 :group 'gnus-article-treat
1001 :link '(custom-manual "(gnus)Customizing Articles")
1002 :type gnus-article-treat-custom)
1004 (defcustom gnus-treat-fill-article nil
1006 Valid values are nil, t, `head', `last', an integer or a predicate.
1007 See Info node `(gnus)Customizing Articles' for details."
1008 :group 'gnus-article-treat
1009 :link '(custom-manual "(gnus)Customizing Articles")
1010 :type gnus-article-treat-custom)
1012 (defcustom gnus-treat-hide-citation nil
1014 Valid values are nil, t, `head', `last', an integer or a predicate.
1015 See Info node `(gnus)Customizing Articles' for details."
1016 :group 'gnus-article-treat
1017 :link '(custom-manual "(gnus)Customizing Articles")
1018 :type gnus-article-treat-custom)
1020 (defcustom gnus-treat-hide-citation-maybe nil
1022 Valid values are nil, t, `head', `last', an integer or a predicate.
1023 See Info node `(gnus)Customizing Articles' for details."
1024 :group 'gnus-article-treat
1025 :link '(custom-manual "(gnus)Customizing Articles")
1026 :type gnus-article-treat-custom)
1028 (defcustom gnus-treat-strip-list-identifiers 'head
1029 "Strip list identifiers from `gnus-list-identifiers`.
1030 Valid values are nil, t, `head', `last', an integer or a predicate.
1031 See Info node `(gnus)Customizing Articles' for details."
1033 :group 'gnus-article-treat
1034 :link '(custom-manual "(gnus)Customizing Articles")
1035 :type gnus-article-treat-custom)
1037 (make-obsolete-variable 'gnus-treat-strip-pgp
1038 "This option is obsolete in Gnus 5.10.")
1040 (defcustom gnus-treat-strip-pem nil
1041 "Strip PEM signatures.
1042 Valid values are nil, t, `head', `last', an integer or a predicate.
1043 See Info node `(gnus)Customizing Articles' for details."
1044 :group 'gnus-article-treat
1045 :link '(custom-manual "(gnus)Customizing Articles")
1046 :type gnus-article-treat-custom)
1048 (defcustom gnus-treat-strip-banner t
1049 "Strip banners from articles.
1050 The banner to be stripped is specified in the `banner' group parameter.
1051 Valid values are nil, t, `head', `last', an integer or a predicate.
1052 See Info node `(gnus)Customizing Articles' for details."
1053 :group 'gnus-article-treat
1054 :link '(custom-manual "(gnus)Customizing Articles")
1055 :type gnus-article-treat-custom)
1057 (defcustom gnus-treat-highlight-headers 'head
1058 "Highlight the headers.
1059 Valid values are nil, t, `head', `last', an integer or a predicate.
1060 See Info node `(gnus)Customizing Articles' for details."
1061 :group 'gnus-article-treat
1062 :link '(custom-manual "(gnus)Customizing Articles")
1063 :type gnus-article-treat-head-custom)
1064 (put 'gnus-treat-highlight-headers 'highlight t)
1066 (defcustom gnus-treat-highlight-citation t
1067 "Highlight cited text.
1068 Valid values are nil, t, `head', `last', an integer or a predicate.
1069 See Info node `(gnus)Customizing Articles' for details."
1070 :group 'gnus-article-treat
1071 :link '(custom-manual "(gnus)Customizing Articles")
1072 :type gnus-article-treat-custom)
1073 (put 'gnus-treat-highlight-citation 'highlight t)
1075 (defcustom gnus-treat-date-ut nil
1076 "Display the Date in UT (GMT).
1077 Valid values are nil, t, `head', `last', an integer or a predicate.
1078 See Info node `(gnus)Customizing Articles' for details."
1079 :group 'gnus-article-treat
1080 :link '(custom-manual "(gnus)Customizing Articles")
1081 :type gnus-article-treat-head-custom)
1083 (defcustom gnus-treat-date-local nil
1084 "Display the Date in the local timezone.
1085 Valid values are nil, t, `head', `last', an integer or a predicate.
1086 See Info node `(gnus)Customizing Articles' for details."
1087 :group 'gnus-article-treat
1088 :link '(custom-manual "(gnus)Customizing Articles")
1089 :type gnus-article-treat-head-custom)
1091 (defcustom gnus-treat-date-english nil
1092 "Display the Date in a format that can be read aloud in English.
1093 Valid values are nil, t, `head', `last', an integer or a predicate.
1094 See Info node `(gnus)Customizing Articles' for details."
1095 :group 'gnus-article-treat
1096 :link '(custom-manual "(gnus)Customizing Articles")
1097 :type gnus-article-treat-head-custom)
1099 (defcustom gnus-treat-date-lapsed nil
1100 "Display the Date header in a way that says how much time has elapsed.
1101 Valid values are nil, t, `head', `last', an integer or a predicate.
1102 See Info node `(gnus)Customizing Articles' for details."
1103 :group 'gnus-article-treat
1104 :link '(custom-manual "(gnus)Customizing Articles")
1105 :type gnus-article-treat-head-custom)
1107 (defcustom gnus-treat-date-original nil
1108 "Display the date in the original timezone.
1109 Valid values are nil, t, `head', `last', an integer or a predicate.
1110 See Info node `(gnus)Customizing Articles' for details."
1111 :group 'gnus-article-treat
1112 :link '(custom-manual "(gnus)Customizing Articles")
1113 :type gnus-article-treat-head-custom)
1115 (defcustom gnus-treat-date-iso8601 nil
1116 "Display the date in the ISO8601 format.
1117 Valid values are nil, t, `head', `last', an integer or a predicate.
1118 See Info node `(gnus)Customizing Articles' for details."
1120 :group 'gnus-article-treat
1121 :link '(custom-manual "(gnus)Customizing Articles")
1122 :type gnus-article-treat-head-custom)
1124 (defcustom gnus-treat-date-user-defined nil
1125 "Display the date in a user-defined format.
1126 The format is defined by the `gnus-article-time-format' variable.
1127 Valid values are nil, t, `head', `last', an integer or a predicate.
1128 See Info node `(gnus)Customizing Articles' for details."
1129 :group 'gnus-article-treat
1130 :link '(custom-manual "(gnus)Customizing Articles")
1131 :type gnus-article-treat-head-custom)
1133 (defcustom gnus-treat-strip-headers-in-body t
1134 "Strip the X-No-Archive header line from the beginning of the body.
1135 Valid values are nil, t, `head', `last', an integer or a predicate.
1136 See Info node `(gnus)Customizing Articles' for details."
1138 :group 'gnus-article-treat
1139 :link '(custom-manual "(gnus)Customizing Articles")
1140 :type gnus-article-treat-custom)
1142 (defcustom gnus-treat-strip-trailing-blank-lines nil
1143 "Strip trailing blank lines.
1144 Valid values are nil, t, `head', `last', an integer or a predicate.
1145 See Info node `(gnus)Customizing Articles' for details."
1146 :group 'gnus-article-treat
1147 :link '(custom-manual "(gnus)Customizing Articles")
1148 :type gnus-article-treat-custom)
1150 (defcustom gnus-treat-strip-leading-blank-lines nil
1151 "Strip leading blank lines.
1152 Valid values are nil, t, `head', `last', an integer or a predicate.
1153 See Info node `(gnus)Customizing Articles' for details."
1154 :group 'gnus-article-treat
1155 :link '(custom-manual "(gnus)Customizing Articles")
1156 :type gnus-article-treat-custom)
1158 (defcustom gnus-treat-strip-multiple-blank-lines nil
1159 "Strip multiple blank lines.
1160 Valid values are nil, t, `head', `last', an integer or a predicate.
1161 See Info node `(gnus)Customizing Articles' for details."
1162 :group 'gnus-article-treat
1163 :link '(custom-manual "(gnus)Customizing Articles")
1164 :type gnus-article-treat-custom)
1166 (defcustom gnus-treat-unfold-headers 'head
1167 "Unfold folded header lines.
1168 Valid values are nil, t, `head', `last', an integer or a predicate.
1169 See Info node `(gnus)Customizing Articles' for details."
1170 :group 'gnus-article-treat
1171 :link '(custom-manual "(gnus)Customizing Articles")
1172 :type gnus-article-treat-custom)
1174 (defcustom gnus-treat-fold-headers nil
1176 Valid values are nil, t, `head', `last', an integer or a predicate.
1177 See Info node `(gnus)Customizing Articles' for details."
1178 :group 'gnus-article-treat
1179 :link '(custom-manual "(gnus)Customizing Articles")
1180 :type gnus-article-treat-custom)
1182 (defcustom gnus-treat-fold-newsgroups 'head
1183 "Fold the Newsgroups and Followup-To headers.
1184 Valid values are nil, t, `head', `last', an integer or a predicate.
1185 See Info node `(gnus)Customizing Articles' for details."
1186 :group 'gnus-article-treat
1187 :link '(custom-manual "(gnus)Customizing Articles")
1188 :type gnus-article-treat-custom)
1190 (defcustom gnus-treat-overstrike t
1191 "Treat overstrike highlighting.
1192 Valid values are nil, t, `head', `last', an integer or a predicate.
1193 See Info node `(gnus)Customizing Articles' for details."
1194 :group 'gnus-article-treat
1195 :link '(custom-manual "(gnus)Customizing Articles")
1196 :type gnus-article-treat-custom)
1197 (put 'gnus-treat-overstrike 'highlight t)
1199 (defcustom gnus-treat-display-xface
1200 (and (not noninteractive)
1201 (or (memq gnus-article-x-face-command
1202 '(x-face-decode-message-header
1203 x-face-mule-gnus-article-display-x-face))
1204 (and (fboundp 'image-type-available-p)
1205 (image-type-available-p 'xbm)
1206 (string-match "^0x" (shell-command-to-string "uncompface"))
1207 (executable-find "icontopbm"))
1208 (and (featurep 'xemacs)
1211 "Display X-Face headers.
1212 Valid values are nil, t, `head', `last', an integer or a predicate.
1213 See Info node `(gnus)Customizing Articles' and Info node
1214 `(gnus)X-Face' for details."
1215 :group 'gnus-article-treat
1217 :link '(custom-manual "(gnus)Customizing Articles")
1218 :link '(custom-manual "(gnus)X-Face")
1219 :type gnus-article-treat-head-custom)
1220 (put 'gnus-treat-display-xface 'highlight t)
1222 (defcustom gnus-article-should-use-smiley-mule
1223 (not (or (featurep 'xemacs)
1224 (gnus-image-type-available-p 'xpm)
1225 (gnus-image-type-available-p 'pbm)))
1226 "If non-nil, gnus uses `smiley-mule' for displaying smileys rather than
1227 `smiley'. It defaults to t when Emacs 20 or earlier is running.
1228 `smiley-mule' is boundled in BITMAP-MULE package. You can set it to t
1229 even if you are using Emacs 21+. It has no effect on XEmacs."
1230 :group 'gnus-article-various
1232 :get (lambda (symbol)
1233 (and (not noninteractive)
1234 (default-value symbol)
1235 (not (featurep 'xemacs))
1236 (module-installed-p 'smiley-mule)
1238 :set (lambda (symbol value)
1239 (set-default symbol (and (not noninteractive)
1241 (not (featurep 'xemacs))
1242 (module-installed-p 'smiley-mule)
1245 (defvar gnus-article-smiley-mule-loaded-p nil
1246 "Internal variable used to say whether `smiley-mule' is loaded (whether
1247 smiley functions are not overridden by `smiley').")
1249 (defcustom gnus-treat-display-face
1250 (and (not noninteractive)
1251 ;; x-face-e21 handles both X-Face and Face headers.
1252 (not (and (eq gnus-article-x-face-command 'x-face-decode-message-header)
1253 (module-installed-p 'x-face-e21)))
1254 (or (and (fboundp 'image-type-available-p)
1255 (image-type-available-p 'png))
1256 (and (featurep 'xemacs)
1259 "Display Face headers.
1260 Valid values are nil, t, `head', `last', an integer or a predicate.
1261 See Info node `(gnus)Customizing Articles' and Info node
1262 `(gnus)X-Face' for details."
1263 :group 'gnus-article-treat
1265 :link '(custom-manual "(gnus)Customizing Articles")
1266 :link '(custom-manual "(gnus)X-Face")
1267 :type gnus-article-treat-head-custom)
1268 (put 'gnus-treat-display-face 'highlight t)
1270 (defcustom gnus-treat-display-smileys
1271 (if (and (not noninteractive)
1272 (or (and (featurep 'xemacs)
1274 (gnus-image-type-available-p 'xpm)
1275 (gnus-image-type-available-p 'pbm)
1276 (and (not (featurep 'xemacs))
1278 (module-installed-p 'smiley-mule))))
1282 Valid values are nil, t, `head', `last', an integer or a predicate.
1283 See Info node `(gnus)Customizing Articles' and Info node
1284 `(gnus)Smileys' for details."
1285 :group 'gnus-article-treat
1287 :link '(custom-manual "(gnus)Customizing Articles")
1288 :link '(custom-manual "(gnus)Smileys")
1289 :type gnus-article-treat-custom)
1290 (put 'gnus-treat-display-smileys 'highlight t)
1292 (defcustom gnus-treat-from-picon
1293 (if (and (gnus-image-type-available-p 'xpm)
1294 (gnus-picons-installed-p))
1296 "Display picons in the From header.
1297 Valid values are nil, t, `head', `last', an integer or a predicate.
1298 See Info node `(gnus)Customizing Articles' and Info node
1299 `(gnus)Picons' for details."
1300 :group 'gnus-article-treat
1302 :link '(custom-manual "(gnus)Customizing Articles")
1303 :link '(custom-manual "(gnus)Picons")
1304 :type gnus-article-treat-head-custom)
1305 (put 'gnus-treat-from-picon 'highlight t)
1307 (defcustom gnus-treat-mail-picon
1308 (if (and (gnus-image-type-available-p 'xpm)
1309 (gnus-picons-installed-p))
1311 "Display picons in To and Cc headers.
1312 Valid values are nil, t, `head', `last', an integer or a predicate.
1313 See Info node `(gnus)Customizing Articles' and Info node
1314 `(gnus)Picons' for details."
1315 :group 'gnus-article-treat
1317 :link '(custom-manual "(gnus)Customizing Articles")
1318 :link '(custom-manual "(gnus)Picons")
1319 :type gnus-article-treat-head-custom)
1320 (put 'gnus-treat-mail-picon 'highlight t)
1322 (defcustom gnus-treat-newsgroups-picon
1323 (if (and (gnus-image-type-available-p 'xpm)
1324 (gnus-picons-installed-p))
1326 "Display picons in the Newsgroups and Followup-To headers.
1327 Valid values are nil, t, `head', `last', an integer or a predicate.
1328 See Info node `(gnus)Customizing Articles' and Info node
1329 `(gnus)Picons' for details."
1330 :group 'gnus-article-treat
1332 :link '(custom-manual "(gnus)Customizing Articles")
1333 :link '(custom-manual "(gnus)Picons")
1334 :type gnus-article-treat-head-custom)
1335 (put 'gnus-treat-newsgroups-picon 'highlight t)
1337 (defcustom gnus-treat-body-boundary
1338 (if (or gnus-treat-newsgroups-picon
1339 gnus-treat-mail-picon
1340 gnus-treat-from-picon)
1342 "Draw a boundary at the end of the headers.
1343 Valid values are nil, t, `head', `last', an integer or a predicate.
1344 See Info node `(gnus)Customizing Articles' for details."
1346 :group 'gnus-article-treat
1347 :link '(custom-manual "(gnus)Customizing Articles")
1348 :type gnus-article-treat-custom)
1350 (defcustom gnus-treat-capitalize-sentences nil
1351 "Capitalize sentence-starting words.
1352 Valid values are nil, t, `head', `last', an integer or a predicate.
1353 See Info node `(gnus)Customizing Articles' for details."
1355 :group 'gnus-article-treat
1356 :link '(custom-manual "(gnus)Customizing Articles")
1357 :type gnus-article-treat-custom)
1359 (defcustom gnus-treat-wash-html nil
1361 Valid values are nil, t, `head', `last', an integer or a predicate.
1362 See Info node `(gnus)Customizing Articles' for details."
1363 :group 'gnus-article-treat
1364 :link '(custom-manual "(gnus)Customizing Articles")
1365 :type gnus-article-treat-custom)
1367 (defcustom gnus-treat-fill-long-lines nil
1369 Valid values are nil, t, `head', `last', an integer or a predicate.
1370 See Info node `(gnus)Customizing Articles' for details."
1371 :group 'gnus-article-treat
1372 :link '(custom-manual "(gnus)Customizing Articles")
1373 :type gnus-article-treat-custom)
1375 (defcustom gnus-treat-play-sounds nil
1377 Valid values are nil, t, `head', `last', an integer or a predicate.
1378 See Info node `(gnus)Customizing Articles' for details."
1380 :group 'gnus-article-treat
1381 :link '(custom-manual "(gnus)Customizing Articles")
1382 :type gnus-article-treat-custom)
1384 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
1385 "Decode an article as `default-mime-charset'. For instance, if you want to
1386 attempt to decode an article even if the value of `gnus-show-mime' is nil,
1387 you could set this variable to something like: nil for don't decode, t for
1388 decode the body, '(or header t) for the whole article, etc."
1389 :group 'gnus-article-treat
1390 :type '(radio (const :tag "Off" nil)
1391 (const :tag "Decode body" t)
1392 (const :tag "Decode all" (or head t))))
1394 (defcustom gnus-treat-translate nil
1395 "Translate articles from one language to another.
1396 Valid values are nil, t, `head', `last', an integer or a predicate.
1397 See Info node `(gnus)Customizing Articles' for details."
1399 :group 'gnus-article-treat
1400 :link '(custom-manual "(gnus)Customizing Articles")
1401 :type gnus-article-treat-custom)
1403 (defcustom gnus-treat-x-pgp-sig nil
1405 To automatically treat X-PGP-Sig, set it to head.
1406 Valid values are nil, t, `head', `last', an integer or a predicate.
1407 See Info node `(gnus)Customizing Articles' for details."
1408 :group 'gnus-article-treat
1409 :group 'mime-security
1410 :type gnus-article-treat-custom)
1412 (defcustom gnus-treat-monafy nil
1413 "Display body part with mona font.
1414 Valid values are nil, t, `head', `last', an integer or a predicate.
1415 See Info node `(gnus)Customizing Articles' for details."
1416 :group 'gnus-article-treat
1417 :group 'mime-security
1418 :link '(custom-manual "(gnus)Customizing Articles")
1419 :type gnus-article-treat-custom)
1421 (defvar gnus-article-encrypt-protocol-alist
1422 '(("PGP" . mml2015-self-encrypt)))
1424 ;; Set to nil if more than one protocol added to
1425 ;; gnus-article-encrypt-protocol-alist.
1426 (defcustom gnus-article-encrypt-protocol "PGP"
1427 "The protocol used for encrypt articles.
1428 It is a string, such as \"PGP\". If nil, ask user."
1430 :group 'mime-security)
1432 (defvar gnus-article-wash-function nil
1433 "Function used for converting HTML into text.")
1435 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1436 (mm-coding-system-p 'utf-8))
1437 "Whether IDNA decoding of headers is used when viewing messages.
1438 This requires GNU Libidn, and by default only enabled if it is found."
1439 :group 'gnus-article-headers
1442 (defcustom gnus-article-over-scroll nil
1443 "If non-nil, allow scrolling the article buffer even when there no more text."
1444 :group 'gnus-article
1447 ;;; Internal variables
1449 (defvar gnus-english-month-names
1450 '("January" "February" "March" "April" "May" "June" "July" "August"
1451 "September" "October" "November" "December"))
1453 (defvar article-goto-body-goes-to-point-min-p nil)
1454 (defvar gnus-article-wash-types nil)
1455 (defvar gnus-article-emphasis-alist nil)
1456 (defvar gnus-article-image-alist nil)
1458 (defvar gnus-article-mime-handle-alist-1 nil)
1459 (defvar gnus-treatment-function-alist
1460 '((gnus-treat-decode-article-as-default-mime-charset
1461 gnus-article-decode-article-as-default-mime-charset)
1462 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1463 (gnus-treat-monafy gnus-article-monafy)
1464 (gnus-treat-strip-banner gnus-article-strip-banner)
1465 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1466 (gnus-treat-buttonize gnus-article-add-buttons)
1467 (gnus-treat-fill-article gnus-article-fill-cited-article)
1468 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1469 (gnus-treat-strip-cr gnus-article-remove-cr)
1470 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1471 (gnus-treat-date-ut gnus-article-date-ut)
1472 (gnus-treat-date-local gnus-article-date-local)
1473 (gnus-treat-date-english gnus-article-date-english)
1474 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1475 (gnus-treat-date-original gnus-article-date-original)
1476 (gnus-treat-date-user-defined gnus-article-date-user)
1477 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1478 (gnus-treat-display-face gnus-article-display-face)
1479 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1480 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1481 (gnus-treat-hide-signature gnus-article-hide-signature)
1482 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1483 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1484 (gnus-treat-strip-pem gnus-article-hide-pem)
1485 (gnus-treat-from-picon gnus-treat-from-picon)
1486 (gnus-treat-mail-picon gnus-treat-mail-picon)
1487 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1488 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1489 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1490 (gnus-treat-strip-trailing-blank-lines
1491 gnus-article-remove-trailing-blank-lines)
1492 (gnus-treat-strip-leading-blank-lines
1493 gnus-article-strip-leading-blank-lines)
1494 (gnus-treat-strip-multiple-blank-lines
1495 gnus-article-strip-multiple-blank-lines)
1496 (gnus-treat-overstrike gnus-article-treat-overstrike)
1497 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1498 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1499 ;; Displaying X-Face should be done after unfolding headers
1500 ;; to protect bitmap lines.
1501 (gnus-treat-display-xface gnus-article-display-x-face)
1502 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1503 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1504 (gnus-treat-display-smileys gnus-treat-smiley)
1505 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1506 (gnus-treat-wash-html gnus-article-wash-html)
1507 (gnus-treat-emphasize gnus-article-emphasize)
1508 (gnus-treat-hide-citation gnus-article-hide-citation)
1509 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1510 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1511 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1512 (gnus-treat-play-sounds gnus-earcon-display)))
1514 (defvar gnus-article-mime-handle-alist nil)
1515 (defvar article-lapsed-timer nil)
1516 (defvar gnus-article-current-summary nil)
1518 (defvar gnus-article-mode-syntax-table
1519 (let ((table (copy-syntax-table text-mode-syntax-table)))
1520 ;; This causes the citation match run O(2^n).
1521 ;; (modify-syntax-entry ?- "w" table)
1522 (modify-syntax-entry ?> ")<" table)
1523 (modify-syntax-entry ?< "(>" table)
1524 ;; make M-. in article buffers work for `foo' strings
1525 (modify-syntax-entry ?' " " table)
1526 (modify-syntax-entry ?` " " table)
1528 "Syntax table used in article mode buffers.
1529 Initialized from `text-mode-syntax-table.")
1531 (defvar gnus-save-article-buffer nil)
1533 (defvar gnus-article-mode-line-format-alist
1534 (nconc '((?w (gnus-article-wash-status) ?s)
1535 (?m (gnus-article-mime-part-status) ?s))
1536 gnus-summary-mode-line-format-alist))
1538 (defvar gnus-number-of-articles-to-be-saved nil)
1540 (defvar gnus-inhibit-hiding nil)
1542 ;;; Macros for dealing with the article buffer.
1544 (defmacro gnus-with-article-headers (&rest forms)
1546 (set-buffer gnus-article-buffer)
1548 (let ((buffer-read-only nil)
1549 (inhibit-point-motion-hooks t)
1550 (case-fold-search t))
1551 (article-narrow-to-head)
1554 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1555 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1557 (defmacro gnus-with-article-buffer (&rest forms)
1559 (set-buffer gnus-article-buffer)
1560 (let ((buffer-read-only nil))
1563 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1564 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1566 (defun gnus-article-goto-header (header)
1567 "Go to HEADER, which is a regular expression."
1568 (re-search-forward (concat "^\\(" header "\\):") nil t))
1570 (defsubst gnus-article-hide-text (b e props)
1571 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1572 (gnus-add-text-properties-when 'article-type nil b e props)
1573 (when (memq 'intangible props)
1575 (max (1- b) (point-min))
1576 b 'intangible (cddr (memq 'intangible props)))))
1578 (defsubst gnus-article-unhide-text (b e)
1579 "Remove hidden text properties from region between B and E."
1580 (remove-text-properties b e gnus-hidden-properties)
1581 (when (memq 'intangible gnus-hidden-properties)
1582 (put-text-property (max (1- b) (point-min))
1583 b 'intangible nil)))
1585 (defun gnus-article-hide-text-type (b e type)
1586 "Hide text of TYPE between B and E."
1587 (gnus-add-wash-type type)
1588 (gnus-article-hide-text
1589 b e (cons 'article-type (cons type gnus-hidden-properties))))
1591 (defun gnus-article-unhide-text-type (b e type)
1592 "Unhide text of TYPE between B and E."
1593 (gnus-delete-wash-type type)
1594 (remove-text-properties
1595 b e (cons 'article-type (cons type gnus-hidden-properties)))
1596 (when (memq 'intangible gnus-hidden-properties)
1597 (put-text-property (max (1- b) (point-min))
1598 b 'intangible nil)))
1600 (defun gnus-article-hide-text-of-type (type)
1601 "Hide text of TYPE in the current buffer."
1603 (let ((b (point-min))
1605 (while (setq b (text-property-any b e 'article-type type))
1606 (add-text-properties b (incf b) gnus-hidden-properties)))))
1608 (defun gnus-article-delete-text-of-type (type)
1609 "Delete text of TYPE in the current buffer."
1611 (let ((b (point-min)))
1612 (while (setq b (text-property-any b (point-max) 'article-type type))
1614 b (or (text-property-not-all b (point-max) 'article-type type)
1617 (defun gnus-article-delete-invisible-text ()
1618 "Delete all invisible text in the current buffer."
1620 (let ((b (point-min)))
1621 (while (setq b (text-property-any b (point-max) 'invisible t))
1623 b (or (text-property-not-all b (point-max) 'invisible t)
1626 (defun gnus-article-text-type-exists-p (type)
1627 "Say whether any text of type TYPE exists in the buffer."
1628 (text-property-any (point-min) (point-max) 'article-type type))
1630 (defsubst gnus-article-header-rank ()
1631 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1632 (let ((list gnus-sorted-header-list)
1635 (if (looking-at (car list))
1637 (setq list (cdr list))
1641 (defun article-hide-headers (&optional arg delete)
1642 "Hide unwanted headers and possibly sort them as well."
1643 (interactive (gnus-article-hidden-arg))
1644 ;; Lars said that this function might be inhibited.
1645 (if (gnus-article-check-hidden-text 'headers arg)
1647 ;; Show boring headers as well.
1648 (gnus-article-show-hidden-text 'boring-headers)
1649 (when (eq 1 (point-min))
1650 (set-window-start (get-buffer-window (current-buffer)) 1)))
1651 (unless gnus-inhibit-hiding
1654 (let ((inhibit-read-only t)
1655 (case-fold-search t)
1656 (max (1+ (length gnus-sorted-header-list)))
1657 (ignored (when (not gnus-visible-headers)
1658 (cond ((stringp gnus-ignored-headers)
1659 gnus-ignored-headers)
1660 ((listp gnus-ignored-headers)
1661 (mapconcat 'identity gnus-ignored-headers
1664 (cond ((stringp gnus-visible-headers)
1665 gnus-visible-headers)
1666 ((and gnus-visible-headers
1667 (listp gnus-visible-headers))
1668 (mapconcat 'identity gnus-visible-headers "\\|"))))
1669 (inhibit-point-motion-hooks t)
1671 ;; First we narrow to just the headers.
1672 (article-narrow-to-head)
1673 ;; Hide any "From " lines at the beginning of (mail) articles.
1674 (while (looking-at "From ")
1678 (delete-region (point-min) (point))
1679 (gnus-article-hide-text (point-min) (point)
1680 (nconc (list 'article-type 'headers)
1681 gnus-hidden-properties))))
1682 ;; Then treat the rest of the header lines.
1683 ;; Then we use the two regular expressions
1684 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1685 ;; select which header lines is to remain visible in the
1687 (while (re-search-forward "^[^ \t:]*:" nil t)
1689 ;; Mark the rank of the header.
1691 (point) (1+ (point)) 'message-rank
1692 (if (or (and visible (looking-at visible))
1694 (not (looking-at ignored))))
1695 (gnus-article-header-rank)
1698 (message-sort-headers-1)
1699 (when (setq beg (text-property-any
1700 (point-min) (point-max) 'message-rank (+ 2 max)))
1701 ;; We delete or make invisible the unwanted headers.
1702 (gnus-add-wash-type 'headers)
1705 (add-text-properties
1706 (point-min) (+ 5 (point-min))
1707 '(article-type headers dummy-invisible t))
1708 (delete-region beg (point-max)))
1709 (gnus-article-hide-text-type beg (point-max) 'headers)))))))))
1711 (defun article-hide-boring-headers (&optional arg)
1712 "Toggle hiding of headers that aren't very interesting.
1713 If given a negative prefix, always show; if given a positive prefix,
1715 (interactive (gnus-article-hidden-arg))
1716 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1717 (not gnus-show-all-headers))
1720 (let ((buffer-read-only nil)
1721 (list gnus-boring-article-headers)
1722 (inhibit-point-motion-hooks t)
1724 (article-narrow-to-head)
1726 (setq elem (pop list))
1727 (goto-char (point-min))
1729 ;; Hide empty headers.
1731 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1733 (gnus-article-hide-text-type
1737 (if (re-search-forward "^[^ \t]" nil t)
1741 ;; Hide boring Newsgroups header.
1742 ((eq elem 'newsgroups)
1743 (when (gnus-string-equal
1744 (gnus-fetch-field "newsgroups")
1745 (gnus-group-real-name
1746 (if (boundp 'gnus-newsgroup-name)
1749 (gnus-article-hide-header "newsgroups")))
1750 ((eq elem 'to-address)
1751 (let ((to (message-fetch-field "to"))
1753 (gnus-parameter-to-address
1754 (if (boundp 'gnus-newsgroup-name)
1755 gnus-newsgroup-name ""))))
1756 (when (and to to-address
1759 ;; only one address in To
1760 (nth 1 (mail-extract-address-components to))
1762 (gnus-article-hide-header "to"))))
1764 (let ((to (message-fetch-field "to"))
1766 (gnus-parameter-to-list
1767 (if (boundp 'gnus-newsgroup-name)
1768 gnus-newsgroup-name ""))))
1769 (when (and to to-list
1772 ;; only one address in To
1773 (nth 1 (mail-extract-address-components to))
1775 (gnus-article-hide-header "to"))))
1777 (let ((cc (message-fetch-field "cc"))
1779 (gnus-parameter-to-list
1780 (if (boundp 'gnus-newsgroup-name)
1781 gnus-newsgroup-name ""))))
1782 (when (and cc to-list
1785 ;; only one address in CC
1786 (nth 1 (mail-extract-address-components cc))
1788 (gnus-article-hide-header "cc"))))
1789 ((eq elem 'followup-to)
1790 (when (gnus-string-equal
1791 (message-fetch-field "followup-to")
1792 (message-fetch-field "newsgroups"))
1793 (gnus-article-hide-header "followup-to")))
1794 ((eq elem 'reply-to)
1795 (if (gnus-group-find-parameter
1796 gnus-newsgroup-name 'broken-reply-to)
1797 (gnus-article-hide-header "reply-to")
1798 (let ((from (message-fetch-field "from"))
1799 (reply-to (message-fetch-field "reply-to")))
1804 (nth 1 (mail-extract-address-components from))
1805 (nth 1 (mail-extract-address-components reply-to)))))
1806 (gnus-article-hide-header "reply-to")))))
1808 (let ((date (message-fetch-field "date")))
1810 (< (days-between (current-time-string) date)
1812 (gnus-article-hide-header "date"))))
1814 (let ((to (message-fetch-field "to"))
1815 (cc (message-fetch-field "cc")))
1816 (when (> (length to) 1024)
1817 (gnus-article-hide-header "to"))
1818 (when (> (length cc) 1024)
1819 (gnus-article-hide-header "cc"))))
1823 (goto-char (point-min))
1824 (while (re-search-forward "^to:" nil t)
1825 (setq to-count (1+ to-count)))
1826 (when (> to-count 1)
1827 (while (> to-count 0)
1828 (goto-char (point-min))
1830 (re-search-forward "^to:" nil nil to-count)
1832 (narrow-to-region (point) (point-max))
1833 (gnus-article-hide-header "to"))
1834 (setq to-count (1- to-count))))
1835 (goto-char (point-min))
1836 (while (re-search-forward "^cc:" nil t)
1837 (setq cc-count (1+ cc-count)))
1838 (when (> cc-count 1)
1839 (while (> cc-count 0)
1840 (goto-char (point-min))
1842 (re-search-forward "^cc:" nil nil cc-count)
1844 (narrow-to-region (point) (point-max))
1845 (gnus-article-hide-header "cc"))
1846 (setq cc-count (1- cc-count)))))))))))))
1848 (defun gnus-article-hide-header (header)
1850 (goto-char (point-min))
1851 (when (re-search-forward (concat "^" header ":") nil t)
1852 (gnus-article-hide-text-type
1856 (if (re-search-forward "^[^ \t]" nil t)
1861 (defvar gnus-article-normalized-header-length 40
1862 "Length of normalized headers.")
1864 (defun article-normalize-headers ()
1865 "Make all header lines 40 characters long."
1867 (let ((buffer-read-only nil)
1871 (article-narrow-to-head)
1874 ((< (setq column (- (gnus-point-at-eol) (point)))
1875 gnus-article-normalized-header-length)
1877 (insert (make-string
1878 (- gnus-article-normalized-header-length column)
1880 ((> column gnus-article-normalized-header-length)
1881 (gnus-put-text-property
1883 (forward-char gnus-article-normalized-header-length)
1890 (forward-line 1))))))
1892 (defun article-treat-dumbquotes ()
1893 "Translate M****s*** sm*rtq**t*s into proper text.
1894 Note that this function guesses whether a character is a sm*rtq**t* or
1895 not, so it should only be used interactively.
1897 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1898 in an attempt to provide more quoting characters. If you see
1899 something like \\222 or \\264 where you're expecting some kind of
1900 apostrophe or quotation mark, then try this wash."
1902 (article-translate-strings gnus-article-dumbquotes-map))
1904 (defun article-translate-characters (from to)
1905 "Translate all characters in the body of the article according to FROM and TO.
1906 FROM is a string of characters to translate from; to is a string of
1907 characters to translate to."
1909 (when (article-goto-body)
1910 (let ((buffer-read-only nil)
1911 (x (make-string 225 ?x))
1913 (while (< (incf i) (length x))
1916 (while (< i (length from))
1917 (aset x (aref from i) (aref to i))
1919 (translate-region (point) (point-max) x)))))
1921 (defun article-translate-strings (map)
1922 "Translate all string in the body of the article according to MAP.
1923 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1925 (when (article-goto-body)
1926 (let ((buffer-read-only nil)
1928 (while (setq elem (pop map))
1930 (while (search-forward (car elem) nil t)
1931 (replace-match (cadr elem)))))))))
1933 (defun article-treat-overstrike ()
1934 "Translate overstrikes into bold text."
1937 (when (article-goto-body)
1938 (let ((buffer-read-only nil))
1939 (while (search-forward "\b" nil t)
1940 (let ((next (char-after))
1944 previous (char-after))
1948 ;; We do the boldification/underlining by hiding the
1949 ;; overstrikes and putting the proper text property
1953 (gnus-article-hide-text-type start (point) 'overstrike)
1954 (put-text-property (point) end 'face 'bold))
1956 (gnus-article-hide-text-type
1957 (1- (point)) (1+ (point)) 'overstrike)
1959 start (1- (point)) 'face 'underline))
1961 (gnus-article-hide-text-type start (point) 'overstrike)
1963 (point) end 'face 'underline)))))))))
1965 (defun gnus-article-treat-unfold-headers ()
1966 "Unfold folded message headers.
1967 Only the headers that fit into the current window width will be
1970 (gnus-with-article-headers
1974 (mail-header-narrow-to-field)
1975 (let ((header (buffer-string)))
1978 (goto-char (point-min))
1979 (while (re-search-forward "\n[\t ]" nil t)
1980 (replace-match " " t t)))
1981 (setq length (- (point-max) (point-min) 1)))
1982 (when (< length (window-width))
1983 (while (re-search-forward "\n[\t ]" nil t)
1984 (replace-match " " t t)))
1985 (goto-char (point-max)))))))
1987 (defun gnus-article-treat-fold-headers ()
1988 "Fold message headers."
1990 (gnus-with-article-headers
1993 (mail-header-narrow-to-field)
1994 (mail-header-fold-field)
1995 (goto-char (point-max))))))
1997 (defun gnus-treat-smiley ()
1998 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2000 (unless (featurep 'xemacs)
2001 (when (and (>= emacs-major-version 21)
2002 (not gnus-article-should-use-smiley-mule)
2003 gnus-article-smiley-mule-loaded-p)
2004 (load "smiley" nil t)
2005 (setq gnus-article-smiley-mule-loaded-p nil))
2006 (when (and gnus-article-should-use-smiley-mule
2007 (not gnus-article-smiley-mule-loaded-p))
2008 (load "smiley-mule" nil t)
2009 (setq gnus-article-smiley-mule-loaded-p t)))
2010 (gnus-with-article-buffer
2011 (if (memq 'smiley gnus-article-wash-types)
2012 (gnus-delete-images 'smiley)
2014 (let ((images (smiley-region (point) (point-max))))
2016 (gnus-add-wash-type 'smiley)
2017 (dolist (image images)
2018 (gnus-add-image 'smiley image)))))))
2020 (defun gnus-article-remove-images ()
2021 "Remove all images from the article buffer."
2023 (gnus-with-article-buffer
2024 (dolist (elem gnus-article-image-alist)
2025 (gnus-delete-images (car elem)))))
2027 (defun gnus-article-treat-fold-newsgroups ()
2028 "Unfold folded message headers.
2029 Only the headers that fit into the current window width will be
2032 (gnus-with-article-headers
2033 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2035 (mail-header-narrow-to-field)
2036 (while (re-search-forward ", *" nil t)
2037 (replace-match ", " t t))
2038 (mail-header-fold-field)
2039 (goto-char (point-max))))))
2041 (defun gnus-article-treat-body-boundary ()
2042 "Place a boundary line at the end of the headers."
2044 (when (and gnus-body-boundary-delimiter
2045 (> (length gnus-body-boundary-delimiter) 0))
2046 (gnus-with-article-headers
2047 (goto-char (point-max))
2048 (let ((start (point)))
2049 (insert "X-Boundary: ")
2050 (gnus-add-text-properties start (point) '(invisible t intangible t))
2052 (while (>= (1- (window-width)) (length str))
2053 (setq str (concat str gnus-body-boundary-delimiter)))
2054 (substring str 0 (1- (window-width))))
2056 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2058 (defun article-fill-long-lines ()
2059 "Fill lines that are wider than the window width."
2062 (let ((buffer-read-only nil)
2063 (width (window-width (get-buffer-window (current-buffer)))))
2066 (let ((adaptive-fill-mode nil)) ;Why? -sm
2069 (when (>= (current-column) (min fill-column width))
2070 (narrow-to-region (min (1+ (point)) (point-max))
2071 (gnus-point-at-bol))
2072 (let ((goback (point-marker)))
2073 (fill-paragraph nil)
2074 (goto-char (marker-position goback)))
2076 (forward-line 1)))))))
2078 (defun article-capitalize-sentences ()
2079 "Capitalize the first word in each sentence."
2082 (let ((buffer-read-only nil)
2083 (paragraph-start "^[\n\^L]"))
2087 (forward-sentence)))))
2089 (defun article-remove-cr ()
2090 "Remove trailing CRs and then translate remaining CRs into LFs."
2093 (let ((buffer-read-only nil))
2094 (goto-char (point-min))
2095 (while (re-search-forward "\r+$" nil t)
2096 (replace-match "" t t))
2097 (goto-char (point-min))
2098 (while (search-forward "\r" nil t)
2099 (replace-match "\n" t t)))))
2101 (defun article-remove-trailing-blank-lines ()
2102 "Remove all trailing blank lines from the article."
2105 (let ((buffer-read-only nil))
2106 (goto-char (point-max))
2110 (while (and (not (bobp))
2111 (looking-at "^[ \t]*$")
2112 (not (gnus-annotation-in-region-p
2113 (point) (gnus-point-at-eol))))
2118 (defun article-display-face ()
2119 "Display any Face headers in the header."
2121 (gnus-with-article-headers
2122 (let ((face (message-fetch-field "face")))
2124 (let ((png (gnus-convert-face-to-png face))
2127 (setq image (gnus-create-image png 'png t))
2128 (gnus-article-goto-header "from")
2130 (insert "From: [no `from' set]\n")
2132 (gnus-add-wash-type 'face)
2133 (gnus-add-image 'face image)
2134 (gnus-put-image image)))))))
2136 (defun article-display-x-face (&optional force)
2137 "Look for an X-Face header and display it if present."
2138 (interactive (list 'force))
2139 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2140 (gnus-with-article-headers
2141 ;; Delete the old process, if any.
2142 (when (process-status "article-x-face")
2143 (delete-process "article-x-face"))
2144 (if (memq 'xface gnus-article-wash-types)
2145 ;; We have already displayed X-Faces, so we remove them
2147 (gnus-delete-images 'xface)
2149 (let (x-faces from face)
2151 (when (and wash-face-p
2153 (goto-char (point-min))
2154 (not (re-search-forward
2155 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2156 (gnus-buffer-live-p gnus-original-article-buffer))
2157 ;; If type `W f', use gnus-original-article-buffer,
2158 ;; otherwise use the current buffer because displaying
2159 ;; RFC822 parts calls this function too.
2160 (set-buffer gnus-original-article-buffer))
2162 (mail-narrow-to-head)
2163 (while (gnus-article-goto-header "X-Face")
2164 (push (mail-header-field-value) x-faces))
2165 (setq from (message-fetch-field "from"))))
2166 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2167 ;; single external face.
2168 (when (stringp gnus-article-x-face-command)
2169 (setq x-faces (list (car x-faces))))
2170 (while (and (setq face (pop x-faces))
2171 gnus-article-x-face-command
2173 ;; Check whether this face is censored.
2174 (not gnus-article-x-face-too-ugly)
2175 (and gnus-article-x-face-too-ugly from
2176 (not (string-match gnus-article-x-face-too-ugly
2178 ;; We display the face.
2179 (if (symbolp gnus-article-x-face-command)
2180 ;; The command is a lisp function, so we call it.
2181 (if (functionp gnus-article-x-face-command)
2182 (funcall gnus-article-x-face-command face)
2183 (error "%s is not a function" gnus-article-x-face-command))
2184 ;; The command is a string, so we interpret the command
2185 ;; as a, well, command, and fork it off.
2186 (let ((process-connection-type nil))
2187 (process-kill-without-query
2189 "article-x-face" nil shell-file-name shell-command-switch
2190 gnus-article-x-face-command))
2193 (process-send-region "article-x-face"
2194 (point-min) (point-max)))
2195 (process-send-eof "article-x-face")))))))))
2197 (defun article-decode-mime-words ()
2198 "Decode all MIME-encoded words in the article."
2201 (set-buffer gnus-article-buffer)
2202 (let ((inhibit-point-motion-hooks t)
2204 (mail-parse-charset gnus-newsgroup-charset)
2205 (mail-parse-ignored-charsets
2206 (save-excursion (set-buffer gnus-summary-buffer)
2207 gnus-newsgroup-ignored-charsets)))
2208 (mail-decode-encoded-word-region (point-min) (point-max)))))
2210 (defun article-decode-charset (&optional prompt)
2211 "Decode charset-encoded text in the article.
2212 If PROMPT (the prefix), prompt for a coding system to use."
2214 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2216 (mail-parse-charset gnus-newsgroup-charset)
2217 (mail-parse-ignored-charsets
2218 (save-excursion (condition-case nil
2219 (set-buffer gnus-summary-buffer)
2221 gnus-newsgroup-ignored-charsets))
2222 ct cte ctl charset format)
2225 (article-narrow-to-head)
2226 (setq ct (message-fetch-field "Content-Type" t)
2227 cte (message-fetch-field "Content-Transfer-Encoding" t)
2228 ctl (and ct (ignore-errors
2229 (mail-header-parse-content-type ct)))
2232 (mm-read-coding-system "Charset to decode: "))
2234 (mail-content-type-get ctl 'charset)))
2235 format (and ctl (mail-content-type-get ctl 'format)))
2237 (setq cte (mail-header-strip cte)))
2238 (if (and ctl (not (string-match "/" (car ctl))))
2240 (goto-char (point-max)))
2243 (narrow-to-region (point) (point-max))
2244 (when (and (eq mail-parse-charset 'gnus-decoded)
2245 (eq (mm-body-7-or-8) '8bit))
2246 ;; The text code could have been decoded.
2247 (setq charset mail-parse-charset))
2248 (when (and (or (not ctl)
2249 (equal (car ctl) "text/plain"))
2250 (not format)) ;; article with format will decode later.
2252 charset (and cte (intern (downcase
2253 (gnus-strip-whitespace cte))))
2254 (car ctl) prompt))))))
2256 (defun article-decode-encoded-words ()
2257 "Remove encoded-word encoding from headers."
2258 (let (buffer-read-only)
2259 (let ((charset (save-excursion
2260 (set-buffer gnus-summary-buffer)
2261 default-mime-charset)))
2262 (mime-decode-header-in-buffer charset))))
2264 (defun article-decode-group-name ()
2265 "Decode group names in `Newsgroups:'."
2266 (let ((inhibit-point-motion-hooks t)
2268 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2269 (when (and (or gnus-group-name-charset-method-alist
2270 gnus-group-name-charset-group-alist)
2271 (gnus-buffer-live-p gnus-original-article-buffer))
2273 (article-narrow-to-head)
2274 (with-current-buffer gnus-original-article-buffer
2275 (goto-char (point-min)))
2276 (while (re-search-forward
2277 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2278 (replace-match (save-match-data
2279 (gnus-decode-newsgroups
2280 ;; XXX how to use data in article buffer?
2281 (with-current-buffer gnus-original-article-buffer
2283 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2286 gnus-newsgroup-name method))
2288 (goto-char (point-min))
2289 (with-current-buffer gnus-original-article-buffer
2290 (goto-char (point-min)))
2291 (while (re-search-forward
2292 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2293 (replace-match (save-match-data
2294 (gnus-decode-newsgroups
2295 ;; XXX how to use data in article buffer?
2296 (with-current-buffer gnus-original-article-buffer
2298 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2301 gnus-newsgroup-name method))
2304 (autoload 'idna-to-unicode "idna")
2306 (defun article-decode-idna-rhs ()
2307 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2310 (let ((inhibit-point-motion-hooks t)
2312 (article-narrow-to-head)
2313 (goto-char (point-min))
2314 (while (re-search-forward "\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2316 (when (save-match-data
2317 (and (setq ace (match-string 1))
2319 (and (re-search-backward "^[^ \t]" nil t)
2320 (looking-at "From\\|To\\|Cc")))
2321 (save-excursion (backward-char)
2322 (message-idna-inside-rhs-p))
2323 (setq unicode (idna-to-unicode ace))))
2324 (unless (string= ace unicode)
2325 (replace-match unicode nil nil nil 1)))))))))
2327 (defun article-de-quoted-unreadable (&optional force read-charset)
2328 "Translate a quoted-printable-encoded article.
2329 If FORCE, decode the article whether it is marked as quoted-printable
2331 If READ-CHARSET, ask for a coding system."
2332 (interactive (list 'force current-prefix-arg))
2334 (let ((buffer-read-only nil) type charset)
2335 (if (gnus-buffer-live-p gnus-original-article-buffer)
2336 (with-current-buffer gnus-original-article-buffer
2338 (gnus-fetch-field "content-transfer-encoding"))
2339 (let* ((ct (gnus-fetch-field "content-type"))
2342 (mail-header-parse-content-type ct)))))
2343 (setq charset (and ctl
2344 (mail-content-type-get ctl 'charset)))
2345 (if (stringp charset)
2346 (setq charset (intern (downcase charset)))))))
2348 (setq charset (mm-read-coding-system "Charset: " charset)))
2350 (setq charset gnus-newsgroup-charset))
2352 (and type (let ((case-fold-search t))
2353 (string-match "quoted-printable" type))))
2355 (quoted-printable-decode-region
2356 (point) (point-max) (mm-charset-to-coding-system charset))))))
2358 (defun article-de-base64-unreadable (&optional force read-charset)
2359 "Translate a base64 article.
2360 If FORCE, decode the article whether it is marked as base64 not.
2361 If READ-CHARSET, ask for a coding system."
2362 (interactive (list 'force current-prefix-arg))
2364 (let ((buffer-read-only nil) type charset)
2365 (if (gnus-buffer-live-p gnus-original-article-buffer)
2366 (with-current-buffer gnus-original-article-buffer
2368 (gnus-fetch-field "content-transfer-encoding"))
2369 (let* ((ct (gnus-fetch-field "content-type"))
2372 (mail-header-parse-content-type ct)))))
2373 (setq charset (and ctl
2374 (mail-content-type-get ctl 'charset)))
2375 (if (stringp charset)
2376 (setq charset (intern (downcase charset)))))))
2378 (setq charset (mm-read-coding-system "Charset: " charset)))
2380 (setq charset gnus-newsgroup-charset))
2382 (and type (let ((case-fold-search t))
2383 (string-match "base64" type))))
2386 (narrow-to-region (point) (point-max))
2387 (base64-decode-region (point-min) (point-max))
2388 (mm-decode-coding-region
2389 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2394 (defun article-decode-HZ ()
2395 "Translate a HZ-encoded article."
2399 (let ((buffer-read-only nil))
2400 (rfc1843-decode-region (point-min) (point-max)))))
2402 (defun article-unsplit-urls ()
2403 "Remove the newlines that some other mailers insert into URLs."
2406 (let ((buffer-read-only nil))
2407 (goto-char (point-min))
2408 (while (re-search-forward
2409 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2410 (replace-match "\\1\\3" t)))
2411 (when (and gnus-display-mime-function (interactive-p))
2412 (funcall gnus-display-mime-function))))
2415 (defun article-wash-html (&optional read-charset)
2416 "Format an HTML article.
2417 If READ-CHARSET, ask for a coding system."
2420 (let ((buffer-read-only nil)
2422 (when (gnus-buffer-live-p gnus-original-article-buffer)
2423 (with-current-buffer gnus-original-article-buffer
2424 (let* ((ct (gnus-fetch-field "content-type"))
2427 (mail-header-parse-content-type ct)))))
2428 (setq charset (and ctl
2429 (mail-content-type-get ctl 'charset)))
2430 (when (stringp charset)
2431 (setq charset (intern (downcase charset)))))))
2433 (setq charset (mm-read-coding-system "Charset: " charset)))
2435 (setq charset gnus-newsgroup-charset))
2437 (save-window-excursion
2439 (narrow-to-region (point) (point-max))
2440 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2441 (entry (assq func mm-text-html-washer-alist)))
2443 (setq func (cdr entry)))
2448 (apply (car func) (cdr func))))))))))
2450 (defun gnus-article-wash-html-with-w3 ()
2451 "Wash the current buffer with w3."
2453 (let ((w3-strict-width (window-width))
2454 (url-standalone-mode t)
2455 (url-gateway-unplugged t)
2456 (w3-honor-stylesheets nil))
2458 (w3-region (point-min) (point-max))
2461 (defun gnus-article-wash-html-with-w3m ()
2462 "Wash the current buffer with emacs-w3m."
2465 (narrow-to-region (point) (point-max))
2466 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2469 w3m-force-redisplay)
2470 (w3m-region (point-min) (point-max)))
2471 (when mm-inline-text-html-with-w3m-keymap
2472 (add-text-properties
2473 (point-min) (point-max)
2474 (nconc (mm-w3m-local-map-property)
2475 '(mm-inline-text-html-with-w3m t))))))
2477 (defun article-hide-list-identifiers ()
2478 "Remove list identifies from the Subject header.
2479 The `gnus-list-identifiers' variable specifies what to do."
2481 (let ((inhibit-point-motion-hooks t)
2482 (regexp (if (consp gnus-list-identifiers)
2483 (mapconcat 'identity gnus-list-identifiers " *\\|")
2484 gnus-list-identifiers))
2489 (article-narrow-to-head)
2490 (goto-char (point-min))
2491 (while (re-search-forward
2492 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2494 (delete-region (match-beginning 2) (match-end 0))
2495 (beginning-of-line))
2496 (when (re-search-forward
2497 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2498 (delete-region (match-beginning 1) (match-end 1))))))))
2500 (defun article-hide-pem (&optional arg)
2501 "Toggle hiding of any PEM headers and signatures in the current article.
2502 If given a negative prefix, always show; if given a positive prefix,
2504 (interactive (gnus-article-hidden-arg))
2505 (unless (gnus-article-check-hidden-text 'pem arg)
2507 (let (buffer-read-only end)
2508 (goto-char (point-min))
2509 ;; Hide the horrendously ugly "header".
2510 (when (and (search-forward
2511 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2513 (setq end (1+ (match-beginning 0))))
2514 (gnus-add-wash-type 'pem)
2515 (gnus-article-hide-text-type
2517 (if (search-forward "\n\n" nil t)
2521 ;; Hide the trailer as well
2522 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2524 (gnus-article-hide-text-type
2525 (match-beginning 0) (match-end 0) 'pem)))))))
2527 (defun article-strip-banner ()
2528 "Strip the banners specified by the `banner' group parameter and by
2529 `gnus-article-address-banner-alist'."
2533 (let ((inhibit-point-motion-hooks t))
2534 (when (gnus-parameter-banner gnus-newsgroup-name)
2535 (article-really-strip-banner
2536 (gnus-parameter-banner gnus-newsgroup-name)))
2537 (when gnus-article-address-banner-alist
2538 (article-really-strip-banner
2539 (let ((from (save-restriction
2541 (article-narrow-to-head)
2542 (mail-fetch-field "from"))))
2545 (caar (mail-header-parse-addresses from))))
2547 (dolist (pair gnus-article-address-banner-alist)
2548 (when (string-match (car pair) from)
2549 (throw 'found (cdr pair)))))))))))))
2551 (defun article-really-strip-banner (banner)
2552 "Strip the banner specified by the argument."
2555 (let ((inhibit-point-motion-hooks t)
2556 (gnus-signature-limit nil)
2560 ((eq banner 'signature)
2561 (when (gnus-article-narrow-to-signature)
2564 (delete-region (point) (point-max))))
2566 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2567 (while (re-search-forward banner nil t)
2568 (delete-region (match-beginning 0) (match-end 0)))))
2570 (while (re-search-forward banner nil t)
2571 (delete-region (match-beginning 0) (match-end 0)))))))))
2573 (defun article-babel ()
2574 "Translate article using an online translation service."
2578 (set-buffer gnus-article-buffer)
2579 (when (article-goto-body)
2580 (let* ((buffer-read-only nil)
2583 (orig (buffer-substring start end))
2584 (trans (babel-as-string orig)))
2586 (narrow-to-region start end)
2587 (delete-region start end)
2590 (defun article-hide-signature (&optional arg)
2591 "Hide the signature in the current article.
2592 If given a negative prefix, always show; if given a positive prefix,
2594 (interactive (gnus-article-hidden-arg))
2600 (article-goto-body))
2601 (goto-char (point-min)))
2602 (unless (gnus-article-check-hidden-text 'signature arg)
2603 (let ((buffer-read-only nil)
2605 (while (setq button (text-property-any button (point-max)
2607 'gnus-signature-toggle))
2608 (setq button (text-property-not-all button (point-max)
2610 'gnus-signature-toggle))
2611 (when (and button (not (eobp)))
2612 (gnus-article-hide-text-type
2614 (next-single-property-change (1+ button) 'mime-view-entity
2617 (gnus-set-mode-line 'article))
2619 (defun article-strip-headers-in-body ()
2620 "Strip offensive headers from bodies."
2624 (let ((case-fold-search t))
2625 (when (looking-at "x-no-archive:")
2626 (gnus-delete-line)))))
2628 (defun article-strip-leading-blank-lines ()
2629 "Remove all blank lines from the beginning of the article."
2632 (let ((inhibit-point-motion-hooks t)
2634 (when (article-goto-body)
2635 (while (and (not (eobp))
2636 (looking-at "[ \t]*$"))
2637 (gnus-delete-line))))))
2639 (defun article-narrow-to-head ()
2640 "Narrow the buffer to the head of the message.
2641 Point is left at the beginning of the narrowed-to region."
2643 (goto-char (point-min))
2644 (if (search-forward "\n\n" nil 1)
2647 (goto-char (point-min)))
2649 (defun article-goto-body ()
2650 "Place point at the start of the body."
2651 (goto-char (point-min))
2653 ;; This variable is only bound when dealing with separate
2655 (article-goto-body-goes-to-point-min-p
2657 ((search-forward "\n\n" nil t)
2660 (goto-char (point-max))
2663 (defun article-strip-multiple-blank-lines ()
2664 "Replace consecutive blank lines with one empty line."
2667 (let ((inhibit-point-motion-hooks t)
2669 ;; First make all blank lines empty.
2671 (while (re-search-forward "^[ \t]+$" nil t)
2672 (unless (gnus-annotation-in-region-p
2673 (match-beginning 0) (match-end 0))
2674 (replace-match "" nil t)))
2675 ;; Then replace multiple empty lines with a single empty line.
2677 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2678 (unless (gnus-annotation-in-region-p
2679 (match-beginning 0) (match-end 0))
2680 (delete-region (match-beginning 1) (match-end 1)))))))
2682 (defun article-strip-leading-space ()
2683 "Remove all white space from the beginning of the lines in the article."
2686 (let ((inhibit-point-motion-hooks t)
2689 (while (re-search-forward "^[ \t]+" nil t)
2690 (replace-match "" t t)))))
2692 (defun article-strip-trailing-space ()
2693 "Remove all white space from the end of the lines in the article."
2696 (let ((inhibit-point-motion-hooks t)
2699 (while (re-search-forward "[ \t]+$" nil t)
2700 (replace-match "" t t)))))
2702 (defun article-strip-blank-lines ()
2703 "Strip leading, trailing and multiple blank lines."
2705 (article-strip-leading-blank-lines)
2706 (article-remove-trailing-blank-lines)
2707 (article-strip-multiple-blank-lines))
2709 (defun article-strip-all-blank-lines ()
2710 "Strip all blank lines."
2713 (let ((inhibit-point-motion-hooks t)
2716 (while (re-search-forward "^[ \t]*\n" nil t)
2717 (replace-match "" t t)))))
2719 (defun gnus-article-narrow-to-signature ()
2720 "Narrow to the signature; return t if a signature is found, else nil."
2721 (let ((inhibit-point-motion-hooks t))
2722 (when (gnus-article-search-signature)
2724 ;; Check whether we have some limits to what we consider
2725 ;; to be a signature.
2726 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2727 (list gnus-signature-limit)))
2729 (while (setq limit (pop limits))
2730 (if (or (and (integerp limit)
2731 (< (- (point-max) (point)) limit))
2733 (< (count-lines (point) (point-max)) limit))
2734 (and (functionp limit)
2736 (and (stringp limit)
2737 (not (re-search-forward limit nil t))))
2738 () ; This limit did not succeed.
2742 (narrow-to-region (point) (point-max))
2745 (defun gnus-article-search-signature ()
2746 "Search the current buffer for the signature separator.
2747 Put point at the beginning of the signature separator."
2748 (let ((cur (point)))
2749 (goto-char (point-max))
2750 (if (if (stringp gnus-signature-separator)
2751 (re-search-backward gnus-signature-separator nil t)
2752 (let ((seps gnus-signature-separator))
2754 (not (re-search-backward (car seps) nil t)))
2761 (defun gnus-article-hidden-arg ()
2762 "Return the current prefix arg as a number, or 0 if no prefix."
2763 (list (if current-prefix-arg
2764 (prefix-numeric-value current-prefix-arg)
2767 (defun gnus-article-check-hidden-text (type arg)
2768 "Return nil if hiding is necessary.
2769 Arg can be nil or a number. nil and positive means hide, negative
2770 means show, 0 means toggle."
2773 (let ((hide (gnus-article-hidden-text-p type)))
2779 (gnus-article-show-hidden-text type)
2782 (if (eq hide 'hidden)
2784 (gnus-article-show-hidden-text type)
2788 (defun gnus-article-hidden-text-p (type)
2789 "Say whether the current buffer contains hidden text of type TYPE."
2790 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2792 (not (get-text-property pos 'invisible))
2793 (not (get-text-property pos 'dummy-invisible)))
2795 (text-property-any (1+ pos) (point-max) 'article-type type)))
2800 (defun gnus-article-show-hidden-text (type &optional dummy)
2801 "Show all hidden text of type TYPE.
2802 Originally it is hide instead of DUMMY."
2803 (let ((buffer-read-only nil)
2804 (inhibit-point-motion-hooks t))
2805 (gnus-remove-text-properties-when
2807 (point-min) (point-max)
2808 (cons 'article-type (cons type
2809 gnus-hidden-properties)))
2810 (gnus-delete-wash-type type)))
2812 (defconst article-time-units
2813 `((year . ,(* 365.25 24 60 60))
2814 (week . ,(* 7 24 60 60))
2815 (day . ,(* 24 60 60))
2819 "Mapping from time units to seconds.")
2821 (defun gnus-article-forward-header ()
2822 "Move point to the start of the next header.
2823 If the current header is a continuation header, this can be several
2828 (if (looking-at "[ \t]+[^ \t]")
2832 (defun article-date-ut (&optional type highlight header)
2833 "Convert DATE date to universal time in the current article.
2834 If TYPE is `local', convert to local time; if it is `lapsed', output
2835 how much time has lapsed since DATE. For `lapsed', the value of
2836 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2837 should replace the \"Date:\" one, or should be added below it."
2838 (interactive (list 'ut t))
2839 (let* ((header (or header
2840 (and (eq 1 (point-min))
2841 (mail-header-date (save-excursion
2842 (set-buffer gnus-summary-buffer)
2843 gnus-current-headers)))
2844 (message-fetch-field "date")
2846 (date (if (vectorp header) (mail-header-date header)
2848 (inhibit-point-motion-hooks t)
2849 bface eface date-pos)
2850 (when (and date (not (string= date "")))
2853 (article-narrow-to-head)
2854 (when (or (and (eq type 'lapsed)
2855 gnus-article-date-lapsed-new-header
2856 ;; Attempt to get the face of X-Sent first.
2857 (re-search-forward "^X-Sent:[ \t]" nil t))
2858 (re-search-forward "^Date:[ \t]" nil t)
2859 ;; If Date is missing, try again for X-Sent.
2860 (re-search-forward "^X-Sent:[ \t]" nil t))
2861 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2862 date (or (get-text-property (gnus-point-at-bol)
2865 eface (get-text-property (1- (gnus-point-at-eol))
2867 (let ((buffer-read-only nil))
2868 ;; Delete any old X-Sent headers.
2869 (when (setq date-pos
2870 (text-property-any (point-min) (point-max)
2871 'article-date-lapsed t))
2872 (goto-char (setq date-pos (set-marker (make-marker) date-pos)))
2873 (delete-region (match-beginning 0)
2874 (progn (forward-line 1) (point))))
2875 (goto-char (point-min))
2876 ;; Delete any old Date headers.
2877 (while (re-search-forward "^Date:[ \t]" nil t)
2879 (setq date-pos (match-beginning 0)))
2880 (unless (and (eq type 'lapsed)
2881 gnus-article-date-lapsed-new-header)
2882 (delete-region (match-beginning 0)
2883 (progn (message-next-header) (point)))))
2886 (goto-char date-pos)
2888 ;; Possibly, Date has been deleted.
2890 (when (and (eq type 'lapsed)
2891 gnus-article-date-lapsed-new-header
2892 (looking-at "Date:"))
2894 (goto-char (point-min)))
2895 (insert (article-make-date-line date type))
2896 (when (eq type 'lapsed)
2897 (put-text-property (gnus-point-at-bol) (point)
2898 'article-date-lapsed t))
2902 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2903 (put-text-property (match-beginning 1) (1+ (match-end 1))
2904 'original-date date)
2905 (put-text-property (match-beginning 1) (1+ (match-end 1))
2907 (put-text-property (match-beginning 2) (match-end 2)
2910 (defun article-make-date-line (date type)
2911 "Return a DATE line of TYPE."
2912 (unless (memq type '(local ut original user iso8601 lapsed english))
2913 (error "Unknown conversion type: %s" type))
2915 (let ((time (date-to-time date)))
2917 ;; Convert to the local timezone.
2919 (let ((tz (car (current-time-zone time))))
2920 (format "Date: %s %s%02d%02d" (current-time-string time)
2921 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2922 (/ (% (abs tz) 3600) 60))))
2923 ;; Convert to Universal Time.
2926 (current-time-string
2927 (let* ((e (parse-time-string date))
2928 (tm (apply 'encode-time e))
2930 (ls (- (cadr tm) (car (current-time-zone time)))))
2931 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2932 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2935 ;; Get the original date from the article.
2936 ((eq type 'original)
2937 (concat "Date: " (if (string-match "\n+$" date)
2938 (substring date 0 (match-beginning 0))
2940 ;; Let the user define the format.
2942 (let ((format (or (condition-case nil
2943 (with-current-buffer gnus-summary-buffer
2944 gnus-article-time-format)
2946 gnus-article-time-format)))
2947 (if (functionp format)
2948 (funcall format time)
2949 (concat "Date: " (format-time-string format time)))))
2952 (let ((tz (car (current-time-zone time))))
2955 (format-time-string "%Y%m%dT%H%M%S" time)
2956 (format "%s%02d%02d"
2957 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2958 (/ (% (abs tz) 3600) 60)))))
2959 ;; Do an X-Sent lapsed format.
2961 ;; If the date is seriously mangled, the timezone functions are
2962 ;; liable to bug out, so we ignore all errors.
2963 (let* ((now (current-time))
2964 (real-time (subtract-time now time))
2965 (real-sec (and real-time
2966 (+ (* (float (car real-time)) 65536)
2968 (sec (and real-time (abs real-sec)))
2978 ;; This is a bit convoluted, but basically we go
2979 ;; through the time units for years, weeks, etc,
2980 ;; and divide things to see whether that results
2981 ;; in positive answers.
2984 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2985 ;; The (remaining) seconds are too few to
2986 ;; be divided into this time unit.
2988 ;; It's big enough, so we output it.
2989 (setq sec (- sec (* num (cdr unit))))
2991 (concat (if prev ", " "") (int-to-string
2993 " " (symbol-name (car unit))
2994 (if (> num 1) "s" ""))
2996 article-time-units "")
2997 ;; If dates are odd, then it might appear like the
2998 ;; article was sent in the future.
3001 " in the future"))))))
3002 ;; Display the date in proper English
3004 (let ((dtime (decode-time time)))
3007 (number-to-string (nth 3 dtime))
3008 (let ((digit (% (nth 3 dtime) 10)))
3010 ((memq (nth 3 dtime) '(11 12 13)) "th")
3016 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3018 (number-to-string (nth 5 dtime))
3020 (format "%02d" (nth 2 dtime))
3022 (format "%02d" (nth 1 dtime)))))))
3024 (format "Date: %s (from T-gnus)" date))))
3026 (defun article-date-local (&optional highlight)
3027 "Convert the current article date to the local timezone."
3028 (interactive (list t))
3029 (article-date-ut 'local highlight))
3031 (defun article-date-english (&optional highlight)
3032 "Convert the current article date to something that is proper English."
3033 (interactive (list t))
3034 (article-date-ut 'english highlight))
3036 (defun article-date-original (&optional highlight)
3037 "Convert the current article date to what it was originally.
3038 This is only useful if you have used some other date conversion
3039 function and want to see what the date was before converting."
3040 (interactive (list t))
3041 (article-date-ut 'original highlight))
3043 (defun article-date-lapsed (&optional highlight)
3044 "Convert the current article date to time lapsed since it was sent."
3045 (interactive (list t))
3046 (article-date-ut 'lapsed highlight))
3048 (defun article-update-date-lapsed ()
3049 "Function to be run from a timer to update the lapsed time line."
3050 (let (deactivate-mark)
3055 (set-buffer (window-buffer w))
3056 (when (eq major-mode 'gnus-article-mode)
3057 (goto-char (point-min))
3058 (when (re-search-forward "^X-Sent:" nil t)
3059 (article-date-lapsed t))))
3062 (defun gnus-start-date-timer (&optional n)
3063 "Start a timer to update the X-Sent header in the article buffers.
3064 The numerical prefix says how frequently (in seconds) the function
3069 (gnus-stop-date-timer)
3070 (setq article-lapsed-timer
3071 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
3073 (defun gnus-stop-date-timer ()
3074 "Stop the X-Sent timer."
3076 (when article-lapsed-timer
3077 (nnheader-cancel-timer article-lapsed-timer)
3078 (setq article-lapsed-timer nil)))
3080 (defun article-date-user (&optional highlight)
3081 "Convert the current article date to the user-defined format.
3082 This format is defined by the `gnus-article-time-format' variable."
3083 (interactive (list t))
3084 (article-date-ut 'user highlight))
3086 (defun article-date-iso8601 (&optional highlight)
3087 "Convert the current article date to ISO8601."
3088 (interactive (list t))
3089 (article-date-ut 'iso8601 highlight))
3091 ;; (defun article-show-all ()
3092 ;; "Show all hidden text in the article buffer."
3096 ;; (let ((buffer-read-only nil))
3097 ;; (gnus-article-unhide-text (point-min) (point-max))
3098 ;; (gnus-remove-text-with-property 'gnus-prev)
3099 ;; (gnus-remove-text-with-property 'gnus-next))))
3101 (defun article-show-all-headers ()
3102 "Show all hidden headers in the article buffer."
3107 (article-narrow-to-head)
3108 (let ((buffer-read-only nil))
3109 (gnus-article-unhide-text (point-min) (point-max))))))
3111 (defun article-remove-leading-whitespace ()
3112 "Remove excessive whitespace from all headers."
3116 (let ((buffer-read-only nil))
3117 (article-narrow-to-head)
3118 (goto-char (point-min))
3119 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3120 (delete-region (match-beginning 1) (match-end 1)))))))
3122 (defun article-emphasize (&optional arg)
3123 "Emphasize text according to `gnus-emphasis-alist'."
3124 (interactive (gnus-article-hidden-arg))
3125 (unless (gnus-article-check-hidden-text 'emphasis arg)
3129 (with-current-buffer gnus-summary-buffer
3130 gnus-article-emphasis-alist)
3132 gnus-emphasis-alist))
3133 (buffer-read-only nil)
3134 (props (append '(article-type emphasis)
3135 gnus-hidden-properties))
3136 regexp elem beg invisible visible face)
3139 (while (setq elem (pop alist))
3141 (setq regexp (car elem)
3142 invisible (nth 1 elem)
3143 visible (nth 2 elem)
3145 (while (re-search-forward regexp nil t)
3146 (when (and (match-beginning visible) (match-beginning invisible))
3147 (gnus-article-hide-text
3148 (match-beginning invisible) (match-end invisible) props)
3149 (gnus-article-unhide-text-type
3150 (match-beginning visible) (match-end visible) 'emphasis)
3151 (gnus-put-overlay-excluding-newlines
3152 (match-beginning visible) (match-end visible) 'face face)
3153 (gnus-add-wash-type 'emphasis)
3154 (goto-char (match-end invisible)))))))))
3156 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3157 "Setup newsgroup emphasis alist."
3158 (unless gnus-article-emphasis-alist
3159 (let ((name (and gnus-newsgroup-name
3160 (gnus-group-real-name gnus-newsgroup-name))))
3161 (make-local-variable 'gnus-article-emphasis-alist)
3162 (setq gnus-article-emphasis-alist
3164 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3165 (while (setq elem (pop alist))
3166 (when (and name (string-match (car elem) name))
3168 highlight (copy-sequence (cdr elem)))))
3170 (copy-sequence highlight-words)
3171 (if gnus-newsgroup-name
3172 (copy-sequence (gnus-group-find-parameter
3173 gnus-newsgroup-name 'highlight-words t)))
3174 gnus-emphasis-alist)))))
3177 (defvar gnus-summary-article-menu)
3178 (defvar gnus-summary-post-menu))
3180 ;;; Saving functions.
3182 (defun gnus-article-save (save-buffer file &optional num)
3183 "Save the currently selected article."
3184 (unless gnus-save-all-headers
3185 ;; Remove headers according to `gnus-saved-headers'.
3186 (let ((gnus-visible-headers
3187 (or gnus-saved-headers gnus-visible-headers))
3188 (gnus-article-buffer save-buffer))
3190 (set-buffer save-buffer)
3191 (article-hide-headers 1 t))))
3192 (save-window-excursion
3193 (if (not gnus-default-article-saver)
3194 (error "No default saver is defined")
3195 ;; !!! Magic! The saving functions all save
3196 ;; `gnus-save-article-buffer' (or so they think), but we
3197 ;; bind that variable to our save-buffer.
3198 (set-buffer gnus-article-buffer)
3199 (let* ((gnus-save-article-buffer save-buffer)
3202 ((not gnus-prompt-before-saving) 'default)
3203 ((eq gnus-prompt-before-saving 'always) nil)
3205 (gnus-number-of-articles-to-be-saved
3206 (when (eq gnus-prompt-before-saving t)
3208 (set-buffer gnus-article-current-summary)
3209 (funcall gnus-default-article-saver filename)))))
3211 (defun gnus-read-save-file-name (prompt &optional filename
3212 function group headers variable)
3214 (funcall function group headers (symbol-value variable)))
3219 ((eq filename 'default)
3225 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3228 (if (and gnus-number-of-articles-to-be-saved
3229 (> gnus-number-of-articles-to-be-saved 1))
3230 (format "these %d articles"
3231 gnus-number-of-articles-to-be-saved)
3234 ;; Let the split methods have their say.
3236 ;; No split name was found.
3239 (concat prompt " (default "
3240 (file-name-nondirectory default-name) ") ")
3241 (file-name-directory default-name)
3243 ;; A single group name is returned.
3244 ((stringp split-name)
3246 (funcall function split-name headers
3247 (symbol-value variable)))
3249 (concat prompt " (default "
3250 (file-name-nondirectory default-name) ") ")
3251 (file-name-directory default-name)
3253 ;; A single split name was found
3254 ((= 1 (length split-name))
3255 (let* ((name (expand-file-name
3257 gnus-article-save-directory))
3258 (dir (cond ((file-directory-p name)
3259 (file-name-as-directory name))
3260 ((file-exists-p name) name)
3261 (t gnus-article-save-directory))))
3263 (concat prompt " (default " name ") ")
3265 ;; A list of splits was found.
3267 (setq split-name (nreverse split-name))
3269 (let ((file-name-history
3270 (nconc split-name file-name-history)))
3274 (concat prompt " (`M-p' for defaults) ")
3275 gnus-article-save-directory
3277 gnus-article-save-directory)))
3278 (car (push result file-name-history)))))))
3279 ;; Create the directory.
3280 (gnus-make-directory (file-name-directory file))
3281 ;; If we have read a directory, we append the default file name.
3282 (when (file-directory-p file)
3283 (setq file (expand-file-name (file-name-nondirectory
3285 (file-name-as-directory file))))
3286 ;; Possibly translate some characters.
3287 (nnheader-translate-file-chars file))))))
3288 (gnus-make-directory (file-name-directory result))
3289 (set variable result)))
3291 (defun gnus-article-archive-name (group)
3292 "Return the first instance of an \"Archive-name\" in the current buffer."
3293 (let ((case-fold-search t))
3294 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3295 (nnheader-concat gnus-article-save-directory
3296 (match-string 1)))))
3298 (defun gnus-article-nndoc-name (group)
3299 "If GROUP is an nndoc group, return the name of the parent group."
3300 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3301 (gnus-group-get-parameter group 'save-article-group)))
3303 (defun gnus-summary-save-in-rmail (&optional filename)
3304 "Append this article to Rmail file.
3305 Optional argument FILENAME specifies file name.
3306 Directory to save to is default to `gnus-article-save-directory'."
3307 (setq filename (gnus-read-save-file-name
3308 "Save %s in rmail file:" filename
3309 gnus-rmail-save-name gnus-newsgroup-name
3310 gnus-current-headers 'gnus-newsgroup-last-rmail))
3311 (gnus-eval-in-buffer-window gnus-save-article-buffer
3315 (gnus-output-to-rmail filename))))
3318 (defun gnus-summary-save-in-mail (&optional filename)
3319 "Append this article to Unix mail file.
3320 Optional argument FILENAME specifies file name.
3321 Directory to save to is default to `gnus-article-save-directory'."
3322 (setq filename (gnus-read-save-file-name
3323 "Save %s in Unix mail file:" filename
3324 gnus-mail-save-name gnus-newsgroup-name
3325 gnus-current-headers 'gnus-newsgroup-last-mail))
3326 (gnus-eval-in-buffer-window gnus-save-article-buffer
3330 (if (and (file-readable-p filename)
3331 (file-regular-p filename)
3332 (mail-file-babyl-p filename))
3333 (rmail-output-to-rmail-file filename t)
3334 (gnus-output-to-mail filename)))))
3337 (defun gnus-summary-save-in-file (&optional filename overwrite)
3338 "Append this article to file.
3339 Optional argument FILENAME specifies file name.
3340 Directory to save to is default to `gnus-article-save-directory'."
3341 (setq filename (gnus-read-save-file-name
3342 "Save %s in file:" filename
3343 gnus-file-save-name gnus-newsgroup-name
3344 gnus-current-headers 'gnus-newsgroup-last-file))
3345 (gnus-eval-in-buffer-window gnus-save-article-buffer
3349 (when (and overwrite
3350 (file-exists-p filename))
3351 (delete-file filename))
3352 (gnus-output-to-file filename))))
3355 (defun gnus-summary-write-to-file (&optional filename)
3356 "Write this article to a file, overwriting it if the file exists.
3357 Optional argument FILENAME specifies file name.
3358 The directory to save in defaults to `gnus-article-save-directory'."
3359 (gnus-summary-save-in-file nil t))
3361 (defun gnus-summary-save-body-in-file (&optional filename)
3362 "Append this article body to a file.
3363 Optional argument FILENAME specifies file name.
3364 The directory to save in defaults to `gnus-article-save-directory'."
3365 (setq filename (gnus-read-save-file-name
3366 "Save %s body in file:" filename
3367 gnus-file-save-name gnus-newsgroup-name
3368 gnus-current-headers 'gnus-newsgroup-last-file))
3369 (gnus-eval-in-buffer-window gnus-save-article-buffer
3373 (when (article-goto-body)
3374 (narrow-to-region (point) (point-max)))
3375 (gnus-output-to-file filename))))
3378 (defun gnus-summary-save-in-pipe (&optional command)
3379 "Pipe this article to subprocess."
3381 (cond ((and (eq command 'default)
3382 gnus-last-shell-command)
3383 gnus-last-shell-command)
3388 "Shell command on %s: "
3389 (if (and gnus-number-of-articles-to-be-saved
3390 (> gnus-number-of-articles-to-be-saved 1))
3391 (format "these %d articles"
3392 gnus-number-of-articles-to-be-saved)
3394 gnus-last-shell-command))))
3395 (when (string-equal command "")
3396 (if gnus-last-shell-command
3397 (setq command gnus-last-shell-command)
3398 (error "A command is required")))
3399 (gnus-eval-in-buffer-window gnus-article-buffer
3402 (shell-command-on-region (point-min) (point-max) command nil)))
3403 (setq gnus-last-shell-command command))
3405 (defun gnus-summary-pipe-to-muttprint (&optional command)
3406 "Pipe this article to muttprint."
3407 (setq command (read-string
3408 "Print using command: " gnus-summary-muttprint-program
3409 nil gnus-summary-muttprint-program))
3410 (gnus-summary-save-in-pipe command))
3412 ;;; Article file names when saving.
3414 (defun gnus-capitalize-newsgroup (newsgroup)
3415 "Capitalize NEWSGROUP name."
3416 (when (not (zerop (length newsgroup)))
3417 (concat (char-to-string (upcase (aref newsgroup 0)))
3418 (substring newsgroup 1))))
3420 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3421 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3422 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3423 Otherwise, it is like ~/News/news/group/num."
3426 (concat (if (gnus-use-long-file-name 'not-save)
3427 (gnus-capitalize-newsgroup newsgroup)
3428 (gnus-newsgroup-directory-form newsgroup))
3429 "/" (int-to-string (mail-header-number headers)))
3430 gnus-article-save-directory)))
3432 (string-equal (file-name-directory default)
3433 (file-name-directory last-file))
3434 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3436 (or last-file default))))
3438 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3439 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3440 If variable `gnus-use-long-file-name' is non-nil, it is
3441 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3444 (concat (if (gnus-use-long-file-name 'not-save)
3446 (gnus-newsgroup-directory-form newsgroup))
3447 "/" (int-to-string (mail-header-number headers)))
3448 gnus-article-save-directory)))
3450 (string-equal (file-name-directory default)
3451 (file-name-directory last-file))
3452 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3454 (or last-file default))))
3456 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3457 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3458 If variable `gnus-use-long-file-name' is non-nil, it is
3459 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3462 (if (gnus-use-long-file-name 'not-save)
3465 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3467 gnus-article-save-directory)))
3469 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3470 "Generate file name from sender."
3471 (let ((from (mail-header-from headers)))
3473 (if (and from (string-match "\\([^ <]+\\)@" from))
3474 (match-string 1 from)
3476 gnus-article-save-directory)))
3478 (defun article-verify-x-pgp-sig ()
3481 (if (gnus-buffer-live-p gnus-original-article-buffer)
3482 (let ((sig (with-current-buffer gnus-original-article-buffer
3483 (gnus-fetch-field "X-PGP-Sig")))
3487 (mml2015-clear-verify-function))
3489 (insert-buffer-substring gnus-original-article-buffer)
3490 (setq items (split-string sig))
3491 (message-narrow-to-head)
3492 (let ((inhibit-point-motion-hooks t)
3493 (case-fold-search t))
3494 ;; Don't verify multiple headers.
3495 (setq headers (mapconcat (lambda (header)
3497 (mail-fetch-field header)
3499 (split-string (nth 1 items) ",") "")))
3500 (delete-region (point-min) (point-max))
3501 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3502 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3507 (if (looking-at "^-")
3510 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3511 (insert "Version: " (car items) "\n\n")
3512 (insert (mapconcat 'identity (cddr items) "\n"))
3513 (insert "\n-----END PGP SIGNATURE-----\n")
3514 (let ((mm-security-handle (list (format "multipart/signed"))))
3515 (mml2015-clean-buffer)
3516 (let ((coding-system-for-write (or gnus-newsgroup-charset
3518 (funcall (mml2015-clear-verify-function)))
3520 (or (mm-handle-multipart-ctl-parameter
3521 mm-security-handle 'gnus-details)
3522 (mm-handle-multipart-ctl-parameter
3523 mm-security-handle 'gnus-info)))))
3525 (let (buffer-read-only bface eface)
3527 (message-narrow-to-head)
3528 (goto-char (point-max))
3530 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3531 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3532 (message-remove-header "X-Gnus-PGP-Verify")
3533 (if (re-search-forward "^X-PGP-Sig:" nil t)
3535 (goto-char (point-max)))
3536 (narrow-to-region (point) (point))
3537 (insert "X-Gnus-PGP-Verify: " info "\n")
3538 (goto-char (point-min))
3541 (if (not (looking-at "^[ \t]"))
3545 (goto-char (point-min))
3546 (when (looking-at "\\([^:]+\\): *")
3547 (put-text-property (match-beginning 1) (1+ (match-end 1))
3549 (put-text-property (match-end 0) (point-max)
3550 'face eface)))))))))
3552 (defun article-verify-cancel-lock ()
3553 "Verify Cancel-Lock header."
3555 (if (gnus-buffer-live-p gnus-original-article-buffer)
3556 (canlock-verify gnus-original-article-buffer)))
3558 (defun article-monafy ()
3559 "Display body part with mona font."
3561 (unless (if (featurep 'xemacs)
3562 (find-face 'gnus-mona-face)
3563 (facep 'gnus-mona-face))
3564 (require 'navi2ch-mona)
3565 (set-face-font (make-face 'gnus-mona-face) navi2ch-mona-font))
3567 (let ((buffer-read-only nil))
3570 (gnus-make-overlay (point) (point-max))
3571 'face 'gnus-mona-face))))
3578 (setq afunc (car func)
3581 gfunc (intern (format "gnus-%s" func))))
3583 (when (fboundp afunc)
3584 `(lambda (&optional interactive &rest args)
3585 ,(documentation afunc t)
3586 (interactive (list t))
3588 (set-buffer gnus-article-buffer)
3590 (call-interactively ',afunc)
3591 (apply ',afunc args))))))))
3592 '(article-hide-headers
3593 article-verify-x-pgp-sig
3594 article-verify-cancel-lock
3596 article-hide-boring-headers
3597 article-treat-overstrike
3598 article-fill-long-lines
3599 article-capitalize-sentences
3601 article-remove-leading-whitespace
3602 article-display-x-face
3603 article-display-face
3604 article-de-quoted-unreadable
3605 article-de-base64-unreadable
3608 article-unsplit-urls
3609 article-hide-list-identifiers
3610 article-strip-banner
3613 article-hide-signature
3614 article-strip-headers-in-body
3615 article-remove-trailing-blank-lines
3616 article-strip-leading-blank-lines
3617 article-strip-multiple-blank-lines
3618 article-strip-leading-space
3619 article-strip-trailing-space
3620 article-strip-blank-lines
3621 article-strip-all-blank-lines
3623 article-date-english
3624 article-date-iso8601
3625 article-date-original
3627 article-decode-mime-words
3628 article-decode-charset
3629 article-decode-encoded-words
3633 article-treat-dumbquotes
3634 article-normalize-headers
3635 (article-show-all-headers . gnus-article-show-all-headers)
3636 ;; (article-show-all . gnus-article-show-all)
3640 ;;; Gnus article mode
3643 (put 'gnus-article-mode 'mode-class 'special)
3645 (gnus-define-keys gnus-article-mode-map
3646 " " gnus-article-goto-next-page
3647 "\177" gnus-article-goto-prev-page
3648 [delete] gnus-article-goto-prev-page
3649 [backspace] gnus-article-goto-prev-page
3650 "\C-c^" gnus-article-refer-article
3651 "h" gnus-article-show-summary
3652 "s" gnus-article-show-summary
3653 "\C-c\C-m" gnus-article-mail
3654 "?" gnus-article-describe-briefly
3655 "e" gnus-summary-edit-article
3656 "<" beginning-of-buffer
3658 "\C-c\C-i" gnus-info-find-node
3660 "R" gnus-article-reply-with-original
3661 "F" gnus-article-followup-with-original
3662 "\C-hk" gnus-article-describe-key
3663 "\C-hc" gnus-article-describe-key-briefly
3665 "\C-d" gnus-article-read-summary-keys
3666 "\M-*" gnus-article-read-summary-keys
3667 "\M-#" gnus-article-read-summary-keys
3668 "\M-^" gnus-article-read-summary-keys
3669 "\M-g" gnus-article-read-summary-keys)
3671 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3675 (push (char-to-string key) keys)
3677 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3678 (setq key (car elem))
3679 (when (and (> (length key) 0)
3680 (not (eq 'menu-bar (aref key 0)))
3681 (symbolp (lookup-key gnus-summary-mode-map key)))
3684 (unless (lookup-key gnus-article-mode-map key)
3685 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3687 (defun gnus-article-make-menu-bar ()
3688 (unless (boundp 'gnus-article-commands-menu)
3689 (gnus-summary-make-menu-bar))
3690 (gnus-turn-off-edit-menu 'article)
3691 (unless (boundp 'gnus-article-article-menu)
3693 gnus-article-article-menu gnus-article-mode-map ""
3695 ["Scroll forwards" gnus-article-goto-next-page t]
3696 ["Scroll backwards" gnus-article-goto-prev-page t]
3697 ["Show summary" gnus-article-show-summary t]
3698 ["Fetch Message-ID at point" gnus-article-refer-article t]
3699 ["Mail to address at point" gnus-article-mail t]
3700 ["Send a bug report" gnus-bug t]))
3703 gnus-article-treatment-menu gnus-article-mode-map ""
3704 ;; Fixme: this should use :active (and maybe :visible).
3706 ["Hide headers" gnus-article-hide-headers t]
3707 ["Hide signature" gnus-article-hide-signature t]
3708 ["Hide citation" gnus-article-hide-citation t]
3709 ["Treat overstrike" gnus-article-treat-overstrike t]
3710 ["Remove carriage return" gnus-article-remove-cr t]
3711 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3712 ["Treat html" gnus-article-wash-html t]
3713 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3714 ["Decode HZ" gnus-article-decode-HZ t]))
3716 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3718 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3720 (gnus-run-hooks 'gnus-article-menu-hook)))
3722 (defun gnus-article-mode ()
3723 "Major mode for displaying an article.
3725 All normal editing commands are switched off.
3727 The following commands are available in addition to all summary mode
3729 \\<gnus-article-mode-map>
3730 \\[gnus-article-next-page]\t Scroll the article one page forwards
3731 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3732 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3733 \\[gnus-article-show-summary]\t Display the summary buffer
3734 \\[gnus-article-mail]\t Send a reply to the address near point
3735 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3736 \\[gnus-info-find-node]\t Go to the Gnus info node"
3738 (gnus-simplify-mode-line)
3739 (setq mode-name "Article")
3740 (setq major-mode 'gnus-article-mode)
3741 (make-local-variable 'minor-mode-alist)
3742 (unless (assq 'gnus-show-mime minor-mode-alist)
3743 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3744 (use-local-map gnus-article-mode-map)
3745 (when (gnus-visual-p 'article-menu 'menu)
3746 (gnus-article-make-menu-bar)
3747 (when gnus-summary-tool-bar-map
3748 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3749 (gnus-update-format-specifications nil 'article-mode)
3750 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3751 (make-local-variable 'gnus-page-broken)
3752 (make-local-variable 'gnus-button-marker-list)
3753 (make-local-variable 'gnus-article-current-summary)
3754 (make-local-variable 'gnus-article-mime-handles)
3755 (make-local-variable 'gnus-article-decoded-p)
3756 (make-local-variable 'gnus-article-mime-handle-alist)
3757 (make-local-variable 'gnus-article-wash-types)
3758 (make-local-variable 'gnus-article-image-alist)
3759 (make-local-variable 'gnus-article-charset)
3760 (make-local-variable 'gnus-article-ignored-charsets)
3761 (gnus-set-default-directory)
3762 (buffer-disable-undo)
3763 (setq buffer-read-only t)
3764 (set-syntax-table gnus-article-mode-syntax-table)
3765 (gnus-run-hooks 'gnus-article-mode-hook))
3767 (defun gnus-article-setup-buffer ()
3768 "Initialize the article buffer."
3769 (let* ((name (if gnus-single-article-buffer "*Article*"
3770 (concat "*Article " gnus-newsgroup-name "*")))
3772 (progn (string-match "\\*Article" name)
3773 (concat " *Original Article"
3774 (substring name (match-end 0))))))
3775 (setq gnus-article-buffer name)
3776 (setq gnus-original-article-buffer original)
3777 (setq gnus-article-mime-handle-alist nil)
3778 ;; This might be a variable local to the summary buffer.
3779 (unless gnus-single-article-buffer
3781 (set-buffer gnus-summary-buffer)
3782 (setq gnus-article-buffer name)
3783 (setq gnus-original-article-buffer original)
3784 (gnus-set-global-variables)))
3785 (gnus-article-setup-highlight-words)
3786 ;; Init original article buffer.
3788 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3789 (set-buffer-multibyte t)
3790 (setq major-mode 'gnus-original-article-mode)
3791 (make-local-variable 'gnus-original-article))
3792 (if (get-buffer name)
3795 (when (and gnus-article-edit-mode
3798 (y-or-n-p "Article mode edit in progress; discard? ")))
3799 (error "Action aborted"))
3800 (set (make-local-variable 'gnus-article-edit-mode) nil)
3801 (buffer-disable-undo)
3802 (setq buffer-read-only t)
3803 ;; This list just keeps growing if we don't reset it.
3804 (setq gnus-button-marker-list nil)
3805 (unless (eq major-mode 'gnus-article-mode)
3806 (gnus-article-mode))
3809 (set-buffer (gnus-get-buffer-create name))
3811 (make-local-variable 'gnus-summary-buffer)
3812 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3813 (current-buffer)))))
3815 ;; Set article window start at LINE, where LINE is the number of lines
3816 ;; from the head of the article.
3817 (defun gnus-article-set-window-start (&optional line)
3819 (gnus-get-buffer-window gnus-article-buffer t)
3821 (set-buffer gnus-article-buffer)
3822 (goto-char (point-min))
3825 (gnus-message 6 "Moved to bookmark")
3826 (search-forward "\n\n" nil t)
3830 ;;; @@ article filters
3833 (defun gnus-article-display-mime-message ()
3834 "Article display method for MIME message."
3835 ;; called from `gnus-original-article-buffer'.
3836 (let (charset all-headers)
3837 (with-current-buffer gnus-summary-buffer
3838 (setq charset default-mime-charset
3839 all-headers gnus-have-all-headers))
3840 (make-local-variable 'default-mime-charset)
3841 (setq default-mime-charset charset)
3842 (with-current-buffer (get-buffer-create gnus-article-buffer)
3843 (make-local-variable 'default-mime-charset)
3844 (setq default-mime-charset charset))
3845 (mime-display-message mime-message-structure
3846 gnus-article-buffer nil gnus-article-mode-map)
3848 (gnus-article-hide-headers nil -1)))
3849 (run-hooks 'gnus-mime-article-prepare-hook))
3851 (defun gnus-article-display-traditional-message ()
3852 "Article display method for traditional message."
3853 (set-buffer gnus-article-buffer)
3854 (let (buffer-read-only)
3856 (insert-buffer-substring gnus-original-article-buffer)))
3858 (defun gnus-article-make-full-mail-header (&optional number charset)
3859 "Create a new mail header structure in a raw article buffer."
3860 (unless (and number charset)
3861 (save-current-buffer
3862 (set-buffer gnus-summary-buffer)
3864 (setq number (or (cdr gnus-article-current) 0)))
3866 (setq charset (or default-mime-charset 'x-ctext)))))
3867 (goto-char (point-min))
3868 (let ((header-end (if (search-forward "\n\n" nil t)
3870 (goto-char (point-max))))
3871 (chars (- (point-max) (point)))
3872 (lines (count-lines (point) (point-max)))
3873 (default-mime-charset charset)
3875 (narrow-to-region (point-min) header-end)
3876 (setq xref (std11-fetch-field "xref"))
3878 (make-full-mail-header
3880 (std11-fetch-field "subject")
3881 (std11-fetch-field "from")
3882 (std11-fetch-field "date")
3883 (std11-fetch-field "message-id")
3884 (std11-fetch-field "references")
3887 (when xref (concat "Xref: " xref)))
3890 (defun gnus-article-prepare (article &optional all-headers header)
3891 "Prepare ARTICLE in article mode buffer.
3892 ARTICLE should either be an article number or a Message-ID.
3893 If ARTICLE is an id, HEADER should be the article headers.
3894 If ALL-HEADERS is non-nil, no headers are hidden."
3896 ;; Make sure we start in a summary buffer.
3897 (unless (eq major-mode 'gnus-summary-mode)
3898 (set-buffer gnus-summary-buffer))
3899 (setq gnus-summary-buffer (current-buffer))
3900 (let* ((gnus-article (if header (mail-header-number header) article))
3901 (summary-buffer (current-buffer))
3902 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3903 (group gnus-newsgroup-name)
3906 (gnus-article-setup-buffer)
3907 (set-buffer gnus-article-buffer)
3908 ;; Deactivate active regions.
3909 (when (and (boundp 'transient-mark-mode)
3910 transient-mark-mode)
3911 (setq mark-active nil))
3912 (if (not (setq result (let ((buffer-read-only nil))
3913 (gnus-request-article-this-buffer
3915 ;; There is no such article.
3917 (when (and (numberp article)
3918 (not (memq article gnus-newsgroup-sparse)))
3919 (setq gnus-article-current
3920 (cons gnus-newsgroup-name article))
3921 (set-buffer gnus-summary-buffer)
3922 (setq gnus-current-article article)
3923 (if (and (memq article gnus-newsgroup-undownloaded)
3924 (not (gnus-online (gnus-find-method-for-group
3925 gnus-newsgroup-name))))
3927 (gnus-summary-set-agent-mark article)
3928 (message "Message marked for downloading"))
3929 (gnus-summary-mark-article article gnus-canceled-mark)
3930 (unless (memq article gnus-newsgroup-sparse)
3931 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3932 (if (or (eq result 'pseudo)
3933 (eq result 'nneething))
3936 (set-buffer summary-buffer)
3937 (push article gnus-newsgroup-history)
3938 (setq gnus-last-article gnus-current-article
3939 gnus-current-article 0
3940 gnus-current-headers nil
3941 gnus-article-current nil)
3942 (if (eq result 'nneething)
3943 (gnus-configure-windows 'summary)
3944 (gnus-configure-windows 'article))
3945 (gnus-set-global-variables))
3946 (let ((gnus-article-mime-handle-alist-1
3947 gnus-article-mime-handle-alist))
3948 (gnus-set-mode-line 'article)))
3949 ;; The result from the `request' was an actual article -
3950 ;; or at least some text that is now displayed in the
3952 (when (and (numberp article)
3953 (not (eq article gnus-current-article)))
3954 ;; Seems like a new article has been selected.
3955 ;; `gnus-current-article' must be an article number.
3957 (set-buffer summary-buffer)
3958 (push article gnus-newsgroup-history)
3959 (setq gnus-last-article gnus-current-article
3960 gnus-current-article article
3961 gnus-current-headers
3962 (gnus-summary-article-header gnus-current-article)
3963 gnus-article-current
3964 (cons gnus-newsgroup-name gnus-current-article))
3965 (unless (vectorp gnus-current-headers)
3966 (setq gnus-current-headers nil))
3967 (gnus-summary-goto-subject gnus-current-article)
3968 (when (gnus-summary-show-thread)
3969 ;; If the summary buffer really was folded, the
3970 ;; previous goto may not actually have gone to
3971 ;; the right article, but the thread root instead.
3973 (gnus-summary-goto-subject gnus-current-article))
3974 (gnus-run-hooks 'gnus-mark-article-hook)
3975 (gnus-set-mode-line 'summary)
3976 (when (gnus-visual-p 'article-highlight 'highlight)
3977 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3978 ;; Set the global newsgroup variables here.
3979 (gnus-set-global-variables)
3980 (setq gnus-have-all-headers
3981 (or all-headers gnus-show-all-headers))))
3983 (gnus-configure-windows 'article))
3984 (when (or (numberp article)
3986 (gnus-article-prepare-display)
3988 (goto-char (point-min))
3989 (setq gnus-page-broken
3990 (when gnus-break-pages
3991 (gnus-narrow-to-page)
3993 (let ((gnus-article-mime-handle-alist-1
3994 gnus-article-mime-handle-alist))
3995 (gnus-set-mode-line 'article))
3999 (set-window-point (get-buffer-window (current-buffer)) (point))
4000 (gnus-configure-windows 'article)
4003 (defun gnus-article-prepare-mime-display (&optional number)
4004 (goto-char (point-min))
4005 (when (re-search-forward "^[^\t ]+:" nil t)
4006 (goto-char (match-beginning 0)))
4007 (let ((entity (if (eq 1 (point-min))
4008 (get-text-property 1 'mime-view-entity)
4009 (get-text-property (point) 'mime-view-entity)))
4010 last-entity child-entity next type)
4011 (setq child-entity (mime-entity-children entity))
4013 (setq last-entity (nth (1- (length child-entity))
4015 (setq last-entity entity))
4017 (narrow-to-region (point)
4018 (if (search-forward "\n\n" nil t)
4021 (gnus-treat-article 'head)
4022 (put-text-property (point-min) (point-max) 'article-treated-header t)
4023 (goto-char (point-max)))
4024 (while (and (not (eobp)) entity)
4025 (setq next (set-marker
4027 (next-single-property-change (point) 'mime-view-entity
4029 (let ((types (mime-entity-content-type entity)))
4030 (while (eq 'multipart (mime-content-type-primary-type types))
4031 (setq entity (car (mime-entity-children entity))
4032 types (mime-entity-content-type entity)))
4034 (setq type (format "%s/%s"
4035 (mime-content-type-primary-type types)
4036 (mime-content-type-subtype types)))))
4037 (if (string-equal type "message/rfc822")
4040 (let ((children (mime-entity-children entity))
4043 (setq last-children (nth (1- (length children)) children))
4046 (not (eq last-children
4047 (get-text-property next 'mime-view-entity)))
4049 (next-single-property-change next
4051 nil (point-max)))))))
4052 (setq next (next-single-property-change next 'mime-view-entity
4055 (narrow-to-region (point) next)
4056 (gnus-article-prepare-mime-display)
4057 (goto-char (point-max)))
4058 (setq entity (get-text-property (point) 'mime-view-entity)))
4060 (narrow-to-region (point) next)
4061 ;; Kludge. We have to count true number, but for now,
4062 ;; part number is here only to achieve `last'.
4063 (gnus-treat-article nil 1
4064 (if (eq entity last-entity)
4067 (goto-char (point-max)))
4068 (setq entity (get-text-property next 'mime-view-entity))))))
4071 (defun gnus-article-prepare-display ()
4072 "Make the current buffer look like a nice article."
4073 (let ((gnus-article-buffer (current-buffer))
4075 (unless (eq major-mode 'gnus-article-mode)
4076 (gnus-article-mode))
4077 (setq buffer-read-only nil
4078 gnus-button-marker-list nil
4079 gnus-article-wash-types nil
4080 gnus-article-image-alist nil)
4083 (static-if (featurep 'xemacs)
4084 (map-extents (lambda (extent maparg) (delete-extent extent)))
4085 (let ((lists (overlay-lists)))
4086 (dolist (overlay (nconc (car lists) (cdr lists)))
4087 (delete-overlay overlay)))))
4088 (gnus-run-hooks 'gnus-tmp-internal-hook))
4089 (let ((show-mime (unless (member gnus-newsgroup-name '("nndraft:delayed"
4092 (inhibit-read-only t))
4093 (set-buffer gnus-original-article-buffer)
4095 (setq mime-message-structure gnus-current-headers)
4096 (mime-buffer-entity-set-buffer-internal mime-message-structure
4097 gnus-original-article-buffer)
4098 (mime-entity-set-representation-type-internal mime-message-structure
4099 'mime-buffer-entity)
4100 (luna-send mime-message-structure 'initialize-instance
4101 mime-message-structure)
4103 (let (mime-display-header-hook mime-display-text/plain-hook)
4104 (funcall gnus-article-display-method-for-mime))
4105 (funcall gnus-article-display-method-for-traditional))
4106 ;; Call the treatment functions.
4110 (gnus-article-prepare-mime-display)
4111 (narrow-to-region (goto-char (point-min))
4112 (if (search-forward "\n\n" nil t)
4115 (gnus-treat-article 'head)
4116 (put-text-property (point-min) (point-max) 'article-treated-header t)
4117 (goto-char (point-max))
4119 (narrow-to-region (point) (point-max))
4120 (gnus-treat-article nil))
4121 (put-text-property (point-min) (point-max) 'read-only nil)))
4122 (gnus-run-hooks 'gnus-article-prepare-hook))
4124 (defun gnus-article-decode-article-as-default-mime-charset ()
4125 "Decode an article as `default-mime-charset'. It won't work if the
4126 value of the variable `gnus-show-mime' is non-nil."
4127 (unless (or gnus-show-mime
4128 (member gnus-newsgroup-name '("nndraft:delayed"
4130 (set (make-local-variable 'default-mime-charset)
4131 (with-current-buffer gnus-summary-buffer
4132 default-mime-charset))
4133 (decode-mime-charset-region (point-min) (point-max)
4134 default-mime-charset)))
4137 ;;; Gnus MIME viewing functions
4140 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4141 "Format of the MIME buttons.
4143 Valid specifiers include:
4145 %T MIME type, along with additional info
4146 %n The `name' parameter
4147 %d The description, if any
4148 %l The length of the encoded part
4149 %p The part identifier number
4150 %e Dots if the part isn't displayed
4152 General format specifiers can also be used. See Info node
4153 `(gnus)Formatting Variables'.")
4155 (defvar gnus-mime-button-line-format-alist
4156 '((?t gnus-tmp-type ?s)
4157 (?T gnus-tmp-type-long ?s)
4158 (?n gnus-tmp-name ?s)
4159 (?d gnus-tmp-description ?s)
4161 (?l gnus-tmp-length ?d)
4162 (?e gnus-tmp-dots ?s)))
4164 (defvar gnus-mime-button-commands
4165 '((gnus-article-press-button "\r" "Toggle Display")
4166 (gnus-mime-view-part "v" "View Interactively...")
4167 (gnus-mime-view-part-as-type "t" "View As Type...")
4168 (gnus-mime-view-part-as-charset "C" "View As charset...")
4169 (gnus-mime-save-part "o" "Save...")
4170 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4171 (gnus-mime-delete-part "d" "Delete part")
4172 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4173 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4174 (gnus-mime-view-part-internally "E" "View Internally")
4175 (gnus-mime-view-part-externally "e" "View Externally")
4176 (gnus-mime-print-part "p" "Print")
4177 (gnus-mime-pipe-part "|" "Pipe To Command...")
4178 (gnus-mime-action-on-part "." "Take action on the part...")))
4180 (defun gnus-article-mime-part-status ()
4181 (with-current-buffer gnus-article-buffer
4182 (let ((entity (get-text-property (point-min) 'mime-view-entity))
4185 (setq children (mime-entity-children entity))
4186 (setq children (length children)))
4189 (format " (%d parts)" children))
4192 (defvar gnus-mime-button-map
4193 (let ((map (make-sparse-keymap)))
4194 (unless (>= (string-to-number emacs-version) 21)
4195 ;; XEmacs doesn't care.
4196 (set-keymap-parent map gnus-article-mode-map))
4197 (define-key map gnus-mouse-2 'gnus-article-push-button)
4198 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4199 (dolist (c gnus-mime-button-commands)
4200 (define-key map (cadr c) (car c)))
4204 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4206 ,@(mapcar (lambda (c)
4207 (vector (caddr c) (car c) :enable t))
4208 gnus-mime-button-commands)))
4211 (define-compiler-macro popup-menu (&whole form
4212 menu &optional position prefix)
4213 (if (and (fboundp 'popup-menu)
4214 (not (memq 'popup-menu (assoc "lmenu" load-history))))
4216 ;; Gnus is probably running under Emacs 20.
4217 `(let* ((menu (cdr ,menu))
4218 (response (x-popup-menu
4220 (cons "" (mapcar (lambda (c)
4221 (cons (caddr c) (car c)))
4224 (call-interactively (nth 3 (assq response menu))))))))
4226 (defun gnus-mime-button-menu (event prefix)
4227 "Construct a context-sensitive menu of MIME commands."
4228 (interactive "e\nP")
4229 (save-window-excursion
4230 (let ((pos (event-start event)))
4231 (select-window (posn-window pos))
4232 (goto-char (posn-point pos))
4233 (gnus-article-check-buffer)
4234 (popup-menu gnus-mime-button-menu nil prefix))))
4236 (defun gnus-mime-view-all-parts (&optional handles)
4237 "View all the MIME parts."
4239 (save-current-buffer
4240 (set-buffer gnus-article-buffer)
4241 (let ((handles (or handles gnus-article-mime-handles))
4242 (mail-parse-charset gnus-newsgroup-charset)
4243 (mail-parse-ignored-charsets
4244 (with-current-buffer gnus-summary-buffer
4245 gnus-newsgroup-ignored-charsets)))
4247 (mm-remove-parts handles)
4248 (goto-char (point-min))
4249 (or (search-forward "\n\n") (goto-char (point-max)))
4250 (let (buffer-read-only)
4251 (delete-region (point) (point-max))
4252 (mm-display-parts handles))))))
4254 (defun gnus-mime-save-part-and-strip ()
4255 "Save the MIME part under point then replace it with an external body."
4257 (gnus-article-check-buffer)
4258 (let* ((data (get-text-property (point) 'gnus-data))
4260 (handles gnus-article-mime-handles))
4261 (if (mm-multiple-handles gnus-article-mime-handles)
4262 (error "This function is not implemented"))
4263 (setq file (and data (mm-save-part data)))
4265 (with-current-buffer (mm-handle-buffer data)
4267 (insert "Content-Type: " (mm-handle-media-type data))
4268 (mml-insert-parameter-string (cdr (mm-handle-type data))
4271 (insert "Content-ID: " (message-make-message-id) "\n")
4272 (insert "Content-Transfer-Encoding: binary\n")
4275 (cdr (mm-make-handle nil
4276 `("message/external-body"
4277 (access-type . "LOCAL-FILE")
4279 (set-buffer gnus-summary-buffer)
4280 (gnus-article-edit-article
4283 (let ((mail-parse-charset (or gnus-article-charset
4284 ',gnus-newsgroup-charset))
4285 (mail-parse-ignored-charsets
4286 (or gnus-article-ignored-charsets
4287 ',gnus-newsgroup-ignored-charsets))
4288 (mbl mml-buffer-list))
4289 (setq mml-buffer-list nil)
4290 (insert-buffer gnus-original-article-buffer)
4291 (mime-to-mml ',handles)
4292 (setq gnus-article-mime-handles nil)
4293 (let ((mbl1 mml-buffer-list))
4294 (setq mml-buffer-list mbl)
4295 (set (make-local-variable 'mml-buffer-list) mbl1))
4296 (gnus-make-local-hook 'kill-buffer-hook)
4297 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4298 `(lambda (no-highlight)
4299 (let ((mail-parse-charset (or gnus-article-charset
4300 ',gnus-newsgroup-charset))
4301 (message-options message-options)
4302 (message-options-set-recipient)
4303 (mail-parse-ignored-charsets
4304 (or gnus-article-ignored-charsets
4305 ',gnus-newsgroup-ignored-charsets)))
4307 (mml-destroy-buffers)
4308 (remove-hook 'kill-buffer-hook
4309 'mml-destroy-buffers t)
4310 (kill-local-variable 'mml-buffer-list))
4311 (gnus-summary-edit-article-done
4312 ,(or (mail-header-references gnus-current-headers) "")
4313 ,(gnus-group-read-only-p)
4314 ,gnus-summary-buffer no-highlight))))))
4316 (defun gnus-mime-delete-part ()
4317 "Delete the MIME part under point.
4318 Replace it with some information about the removed part."
4320 (gnus-article-check-buffer)
4321 (unless (and gnus-novice-user
4322 (not (gnus-yes-or-no-p
4323 "Really delete attachment forever? ")))
4324 (let* ((data (get-text-property (point) 'gnus-data))
4325 (handles gnus-article-mime-handles)
4329 (mail-decode-encoded-word-string (or (mm-handle-description data)
4332 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4334 (type (mm-handle-media-type data)))
4335 (if (mm-multiple-handles gnus-article-mime-handles)
4336 (error "This function is not implemented"))
4337 (with-current-buffer (mm-handle-buffer data)
4338 (let ((bsize (format "%s" (buffer-size))))
4342 "<#part type=text/plain nofile=yes disposition=attachment"
4343 " description=\"Deleted attachment (" bsize " Byte)\">"
4345 "| The following attachment has been deleted:\n"
4347 "| Type: " type "\n"
4348 "| Filename: " filename "\n"
4349 "| Size (encoded): " bsize " Byte\n"
4350 "| Description: " description "\n"
4354 (cdr (mm-make-handle nil `("text/plain"))))))
4355 (set-buffer gnus-summary-buffer)
4356 ;; FIXME: maybe some of the following code (borrowed from
4357 ;; `gnus-mime-save-part-and-strip') isn't necessary?
4358 (gnus-article-edit-article
4361 (let ((mail-parse-charset (or gnus-article-charset
4362 ',gnus-newsgroup-charset))
4363 (mail-parse-ignored-charsets
4364 (or gnus-article-ignored-charsets
4365 ',gnus-newsgroup-ignored-charsets))
4366 (mbl mml-buffer-list))
4367 (setq mml-buffer-list nil)
4368 (insert-buffer gnus-original-article-buffer)
4369 (mime-to-mml ',handles)
4370 (setq gnus-article-mime-handles nil)
4371 (let ((mbl1 mml-buffer-list))
4372 (setq mml-buffer-list mbl)
4373 (set (make-local-variable 'mml-buffer-list) mbl1))
4374 (gnus-make-local-hook 'kill-buffer-hook)
4375 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4376 `(lambda (no-highlight)
4377 (let ((mail-parse-charset (or gnus-article-charset
4378 ',gnus-newsgroup-charset))
4379 (message-options message-options)
4380 (message-options-set-recipient)
4381 (mail-parse-ignored-charsets
4382 (or gnus-article-ignored-charsets
4383 ',gnus-newsgroup-ignored-charsets)))
4385 (mml-destroy-buffers)
4386 (remove-hook 'kill-buffer-hook
4387 'mml-destroy-buffers t)
4388 (kill-local-variable 'mml-buffer-list))
4389 (gnus-summary-edit-article-done
4390 ,(or (mail-header-references gnus-current-headers) "")
4391 ,(gnus-group-read-only-p)
4392 ,gnus-summary-buffer no-highlight)))))
4393 ;; Not in `gnus-mime-save-part-and-strip':
4394 (gnus-article-edit-done)
4395 (gnus-summary-expand-window)
4396 (gnus-summary-show-article))
4398 (defun gnus-mime-save-part ()
4399 "Save the MIME part under point."
4401 (gnus-article-check-buffer)
4402 (let ((data (get-text-property (point) 'gnus-data)))
4404 (mm-save-part data))))
4406 (defun gnus-mime-pipe-part ()
4407 "Pipe the MIME part under point to a process."
4409 (gnus-article-check-buffer)
4410 (let ((data (get-text-property (point) 'gnus-data)))
4412 (mm-pipe-part data))))
4414 (defun gnus-mime-view-part ()
4415 "Interactively choose a viewing method for the MIME part under point."
4417 (gnus-article-check-buffer)
4418 (let ((data (get-text-property (point) 'gnus-data)))
4420 (setq gnus-article-mime-handles
4422 gnus-article-mime-handles (setq data (copy-sequence data))))
4423 (mm-interactively-view-part data))))
4425 (defun gnus-mime-view-part-as-type-internal ()
4426 (gnus-article-check-buffer)
4427 (let* ((name (mail-content-type-get
4428 (mm-handle-type (get-text-property (point) 'gnus-data))
4430 (def-type (and name (mm-default-file-encoding name))))
4431 (and def-type (cons def-type 0))))
4433 (defun gnus-mime-view-part-as-type (&optional mime-type)
4434 "Choose a MIME media type, and view the part as such."
4437 (setq mime-type (completing-read
4438 "View as MIME type: "
4439 (mapcar #'list (mailcap-mime-types))
4441 (gnus-mime-view-part-as-type-internal))))
4442 (gnus-article-check-buffer)
4443 (let ((handle (get-text-property (point) 'gnus-data)))
4446 (mm-make-handle (mm-handle-buffer handle)
4447 (cons mime-type (cdr (mm-handle-type handle)))
4448 (mm-handle-encoding handle)
4449 (mm-handle-undisplayer handle)
4450 (mm-handle-disposition handle)
4451 (mm-handle-description handle)
4453 (mm-handle-id handle)))
4454 (setq gnus-article-mime-handles
4455 (mm-merge-handles gnus-article-mime-handles handle))
4456 (gnus-mm-display-part handle))))
4459 (require 'jka-compr))
4461 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4462 ;; emacs can do that itself.
4464 (defun gnus-mime-jka-compr-maybe-uncompress ()
4465 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4466 The uncompress method used is derived from `buffer-file-name'."
4467 (when (and (fboundp 'jka-compr-installed-p)
4468 (jka-compr-installed-p))
4469 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4471 (let ((basename (file-name-nondirectory buffer-file-name))
4472 (args (jka-compr-info-uncompress-args info))
4473 (prog (jka-compr-info-uncompress-program info))
4474 (message (jka-compr-info-uncompress-message info))
4475 (err-file (jka-compr-make-temp-name)))
4477 (message "%s %s..." message basename))
4479 (unless (memq (apply 'call-process-region
4480 (point-min) (point-max)
4482 t (list t err-file) nil
4484 jka-compr-acceptable-retval-list)
4485 (jka-compr-error prog args basename message err-file))
4486 (jka-compr-delete-temp-file err-file)))))))
4488 (defun gnus-mime-copy-part (&optional handle)
4489 "Put the MIME part under point into a new buffer.
4490 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4493 (gnus-article-check-buffer)
4494 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4495 (contents (and handle (mm-get-part handle)))
4497 (file-name-nondirectory
4499 (mail-content-type-get (mm-handle-type handle) 'name)
4500 (mail-content-type-get (mm-handle-disposition handle)
4503 (buffer (and base (generate-new-buffer base))))
4505 (switch-to-buffer buffer)
4507 ;; We do it this way to make `normal-mode' set the appropriate mode.
4510 (setq buffer-file-name (expand-file-name base))
4511 (gnus-mime-jka-compr-maybe-uncompress)
4513 (setq buffer-file-name nil))
4514 (goto-char (point-min)))))
4516 (defun gnus-mime-print-part (&optional handle filename)
4517 "Print the MIME part under point."
4518 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4519 (gnus-article-check-buffer)
4520 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4521 (contents (and handle (mm-get-part handle)))
4522 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4523 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4528 (mm-save-part-to-file handle file)
4529 (call-process shell-file-name nil
4530 (generate-new-buffer " *mm*")
4532 shell-command-switch
4534 printer file (mm-handle-type handle))))
4538 (gnus-print-buffer))
4539 (ps-despool filename)))))
4541 (defun gnus-mime-inline-part (&optional handle arg)
4542 "Insert the MIME part under point into the current buffer."
4543 (interactive (list nil current-prefix-arg))
4544 (gnus-article-check-buffer)
4545 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4550 (if (and (not arg) (mm-handle-undisplayer handle))
4551 (mm-remove-part handle)
4552 (setq contents (mm-get-part handle))
4555 (setq charset (or (mail-content-type-get
4556 (mm-handle-type handle) 'charset)
4557 gnus-newsgroup-charset)))
4559 (if (mm-handle-undisplayer handle)
4560 (mm-remove-part handle))
4563 gnus-summary-show-article-charset-alist))
4564 (mm-read-coding-system "Charset: ")))))
4566 (mm-insert-inline handle
4568 (setq charset (mm-charset-to-coding-system
4570 (not (eq charset 'ascii)))
4571 (mm-decode-coding-string contents charset)
4575 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4576 "Insert the MIME part under point into the current buffer using the
4578 (interactive (list nil current-prefix-arg))
4579 (gnus-article-check-buffer)
4580 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4585 (if (mm-handle-undisplayer handle)
4586 (mm-remove-part handle))
4587 (let ((gnus-newsgroup-charset
4589 gnus-summary-show-article-charset-alist))
4590 (mm-read-coding-system "Charset: ")))
4591 (gnus-newsgroup-ignored-charsets 'gnus-all))
4592 (gnus-article-press-button)))))
4594 (defun gnus-mime-view-part-externally (&optional handle)
4595 "View the MIME part under point with an external viewer."
4597 (gnus-article-check-buffer)
4598 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4599 (mm-user-display-methods nil)
4600 (mm-inlined-types nil)
4601 (mail-parse-charset gnus-newsgroup-charset)
4602 (mail-parse-ignored-charsets
4603 (save-excursion (set-buffer gnus-summary-buffer)
4604 gnus-newsgroup-ignored-charsets)))
4606 (if (mm-handle-undisplayer handle)
4607 (mm-remove-part handle)
4608 (mm-display-part handle)))))
4610 (defun gnus-mime-view-part-internally (&optional handle)
4611 "View the MIME part under point with an internal viewer.
4612 If no internal viewer is available, use an external viewer."
4614 (gnus-article-check-buffer)
4615 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4616 (mm-inlined-types '(".*"))
4617 (mm-inline-large-images t)
4618 (mail-parse-charset gnus-newsgroup-charset)
4619 (mail-parse-ignored-charsets
4620 (save-excursion (set-buffer gnus-summary-buffer)
4621 gnus-newsgroup-ignored-charsets))
4624 (if (mm-handle-undisplayer handle)
4625 (mm-remove-part handle)
4626 (mm-display-part handle)))))
4628 (defun gnus-mime-action-on-part (&optional action)
4629 "Do something with the MIME attachment at \(point\)."
4631 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4632 (gnus-article-check-buffer)
4633 (let ((action-pair (assoc action gnus-mime-action-alist)))
4635 (funcall (cdr action-pair)))))
4637 (defun gnus-article-part-wrapper (n function)
4638 (save-current-buffer
4639 (set-buffer gnus-article-buffer)
4640 (when (> n (length gnus-article-mime-handle-alist))
4641 (error "No such part"))
4642 (gnus-article-goto-part n)
4643 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4644 (funcall function handle))))
4646 (defun gnus-article-pipe-part (n)
4647 "Pipe MIME part N, which is the numerical prefix."
4649 (gnus-article-part-wrapper n 'mm-pipe-part))
4651 (defun gnus-article-save-part (n)
4652 "Save MIME part N, which is the numerical prefix."
4654 (gnus-article-part-wrapper n 'mm-save-part))
4656 (defun gnus-article-interactively-view-part (n)
4657 "View MIME part N interactively, which is the numerical prefix."
4659 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4661 (defun gnus-article-copy-part (n)
4662 "Copy MIME part N, which is the numerical prefix."
4664 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4666 (defun gnus-article-view-part-as-charset (n)
4667 "Copy MIME part N, which is the numerical prefix."
4669 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4671 (defun gnus-article-view-part-externally (n)
4672 "View MIME part N externally, which is the numerical prefix."
4674 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4676 (defun gnus-article-inline-part (n)
4677 "Inline MIME part N, which is the numerical prefix."
4679 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4681 (defun gnus-article-mime-match-handle-first (condition)
4683 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4684 (while (setq ihandle (pop alist))
4686 ((functionp condition)
4687 (funcall condition (cdr ihandle)))
4688 ((eq condition 'undisplayed)
4689 (not (or (mm-handle-undisplayer (cdr ihandle))
4690 (equal (mm-handle-media-type (cdr ihandle))
4691 "multipart/alternative"))))
4692 ((eq condition 'undisplayed-alternative)
4693 (not (mm-handle-undisplayer (cdr ihandle))))
4695 (gnus-article-goto-part (car ihandle))
4696 (or (not n) (< (car ihandle) n)))
4697 (setq n (car ihandle))))
4701 (defun gnus-article-view-part (&optional n)
4702 "View MIME part N, which is the numerical prefix."
4704 (save-current-buffer
4705 (set-buffer gnus-article-buffer)
4706 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4707 gnus-article-mime-match-handle-function)))
4708 (when (> n (length gnus-article-mime-handle-alist))
4709 (error "No such part"))
4710 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4711 (when (gnus-article-goto-part n)
4712 (if (equal (car handle) "multipart/alternative")
4713 (gnus-article-press-button)
4714 (when (eq (gnus-mm-display-part handle) 'internal)
4715 (gnus-set-window-start)))))))
4717 (defsubst gnus-article-mime-total-parts ()
4718 (if (bufferp (car gnus-article-mime-handles))
4720 (1- (length gnus-article-mime-handles))))
4722 (defun gnus-mm-display-part (handle)
4723 "Display HANDLE and fix MIME button."
4724 (let ((id (get-text-property (point) 'gnus-part))
4729 (let ((window (selected-window))
4730 (mail-parse-charset gnus-newsgroup-charset)
4731 (mail-parse-ignored-charsets
4732 (if (gnus-buffer-live-p gnus-summary-buffer)
4734 (set-buffer gnus-summary-buffer)
4735 gnus-newsgroup-ignored-charsets)
4739 (let ((win (gnus-get-buffer-window (current-buffer) t))
4742 (select-window win))
4745 (if (mm-handle-displayed-p handle)
4746 ;; This will remove the part.
4747 (mm-display-part handle)
4749 (narrow-to-region (point)
4750 (if (eobp) (point) (1+ (point))))
4751 (mm-display-part handle)
4752 ;; We narrow to the part itself and
4753 ;; then call the treatment functions.
4754 (goto-char (point-min))
4756 (narrow-to-region (point) (point-max))
4759 (gnus-article-mime-total-parts)
4760 (mm-handle-media-type handle)))))
4761 (if (window-live-p window)
4762 (select-window window)))))
4765 (gnus-insert-mime-button
4766 handle id (list (mm-handle-displayed-p handle)))
4767 (goto-char point))))
4769 (defun gnus-article-goto-part (n)
4770 "Go to MIME part N."
4771 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4773 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4774 (let ((gnus-tmp-name
4775 (or (mail-content-type-get (mm-handle-type handle) 'name)
4776 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4777 (mail-content-type-get (mm-handle-type handle) 'url)
4779 (gnus-tmp-type (mm-handle-media-type handle))
4780 (gnus-tmp-description
4781 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4784 (if (if displayed (car displayed)
4785 (mm-handle-displayed-p handle))
4787 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4789 gnus-tmp-type-long b e)
4790 (when (string-match ".*/" gnus-tmp-name)
4791 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4792 (setq gnus-tmp-type-long (concat gnus-tmp-type
4793 (and (not (equal gnus-tmp-name ""))
4794 (concat "; " gnus-tmp-name))))
4795 (unless (equal gnus-tmp-description "")
4796 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4801 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4802 `(,@(gnus-local-map-property gnus-mime-button-map)
4803 gnus-callback gnus-mm-display-part
4804 gnus-part ,gnus-tmp-id
4805 article-type annotation
4808 ;; Exclude a newline.
4811 (widget-convert-button
4814 :action 'gnus-widget-press-button
4815 :button-keymap gnus-mime-button-map
4817 (lambda (widget/window &optional overlay pos)
4818 ;; Needed to properly clear the message due to a bug in
4819 ;; wid-edit (XEmacs only).
4820 (if (boundp 'help-echo-owns-message)
4821 (setq help-echo-owns-message t))
4823 "%S: %s the MIME part; %S: more options"
4824 (aref gnus-mouse-2 0)
4825 ;; XEmacs will get a single widget arg; Emacs 21 will get
4826 ;; window, overlay, position.
4827 (if (mm-handle-displayed-p
4829 (with-current-buffer (gnus-overlay-buffer overlay)
4830 (widget-get (widget-at (gnus-overlay-start overlay))
4832 (widget-get widget/window :mime-handle)))
4834 (aref gnus-down-mouse-3 0))))))
4836 (defun gnus-widget-press-button (elems el)
4837 (goto-char (widget-get elems :from))
4838 (gnus-article-press-button))
4840 (defvar gnus-displaying-mime nil)
4842 (defun gnus-display-mime (&optional ihandles)
4843 "Display the MIME parts."
4845 (save-selected-window
4846 (let ((window (get-buffer-window gnus-article-buffer))
4849 (select-window window)
4850 ;; We have to do this since selecting the window
4851 ;; may change the point. So we set the window point.
4852 (set-window-point window point)))
4853 (let* ((handles (or ihandles
4854 (mm-dissect-buffer nil gnus-article-loose-mime)
4855 (and gnus-article-emulate-mime
4857 buffer-read-only handle name type b e display)
4858 (when (and (not ihandles)
4859 (not gnus-displaying-mime))
4860 ;; Top-level call; we clean up.
4861 (when gnus-article-mime-handles
4862 (mm-destroy-parts gnus-article-mime-handles)
4863 (setq gnus-article-mime-handle-alist nil));; A trick.
4864 (setq gnus-article-mime-handles handles)
4865 ;; We allow users to glean info from the handles.
4866 (when gnus-article-mime-part-function
4867 (gnus-mime-part-function handles)))
4869 (or (not (stringp (car handles)))
4872 (when (and (not ihandles)
4873 (not gnus-displaying-mime))
4874 ;; Clean up for mime parts.
4876 (delete-region (point) (point-max)))
4877 (let ((gnus-displaying-mime t))
4878 (gnus-mime-display-part handles)))
4881 (narrow-to-region (point) (point-max))
4882 (gnus-treat-article nil 1 1)
4885 ;; Highlight the headers.
4889 (narrow-to-region (point-min) (point))
4890 (gnus-treat-article 'head))))))))
4892 (defvar gnus-mime-display-multipart-as-mixed nil)
4893 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
4894 (defvar gnus-mime-display-multipart-related-as-mixed nil)
4896 (defun gnus-mime-display-part (handle)
4899 ((not (stringp (car handle)))
4900 (gnus-mime-display-single handle))
4901 ;; User-defined multipart
4902 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4903 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4905 ;; multipart/alternative
4906 ((and (equal (car handle) "multipart/alternative")
4907 (not (or gnus-mime-display-multipart-as-mixed
4908 gnus-mime-display-multipart-alternative-as-mixed)))
4909 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4910 (push (cons id handle) gnus-article-mime-handle-alist)
4911 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4912 ;; multipart/related
4913 ((and (equal (car handle) "multipart/related")
4914 (not (or gnus-mime-display-multipart-as-mixed
4915 gnus-mime-display-multipart-related-as-mixed)))
4916 ;;;!!!We should find the start part, but we just default
4917 ;;;!!!to the first part.
4918 ;;(gnus-mime-display-part (cadr handle))
4919 ;;;!!! Most multipart/related is an HTML message plus images.
4920 ;;;!!! Unfortunately we are unable to let W3 display those
4921 ;;;!!! included images, so we just display it as a mixed multipart.
4922 ;;(gnus-mime-display-mixed (cdr handle))
4923 ;;;!!! No, w3 can display everything just fine.
4924 (gnus-mime-display-part (cadr handle)))
4925 ((equal (car handle) "multipart/signed")
4926 (gnus-add-wash-type 'signed)
4927 (gnus-mime-display-security handle))
4928 ((equal (car handle) "multipart/encrypted")
4929 (gnus-add-wash-type 'encrypted)
4930 (gnus-mime-display-security handle))
4931 ;; Other multiparts are handled like multipart/mixed.
4933 (gnus-mime-display-mixed (cdr handle)))))
4935 (defun gnus-mime-part-function (handles)
4936 (if (stringp (car handles))
4937 (mapcar 'gnus-mime-part-function (cdr handles))
4938 (funcall gnus-article-mime-part-function handles)))
4940 (defun gnus-mime-display-mixed (handles)
4941 (mapcar 'gnus-mime-display-part handles))
4943 (defun gnus-mime-display-single (handle)
4944 (let ((type (mm-handle-media-type handle))
4945 (ignored gnus-ignored-mime-types)
4952 (when (string-match (pop ignored) type)
4953 (throw 'ignored nil)))
4954 (if (and (setq not-attachment
4955 (and (not (mm-inline-override-p handle))
4956 (or (not (mm-handle-disposition handle))
4957 (equal (car (mm-handle-disposition handle))
4959 (mm-attachment-override-p handle))))
4960 (mm-automatic-display-p handle)
4962 (mm-inlinable-p handle)
4963 (mm-inlined-p handle))
4964 (mm-automatic-external-display-p type)))
4966 (when (equal (mm-handle-media-supertype handle) "text")
4968 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4970 (push (cons id handle) gnus-article-mime-handle-alist)
4971 (when (or (not display)
4972 (not (gnus-unbuttonized-mime-type-p type)))
4973 ;(gnus-article-insert-newline)
4974 (gnus-insert-mime-button
4975 handle id (list (or display (and not-attachment text))))
4976 (gnus-article-insert-newline)
4977 ;(gnus-article-insert-newline)
4978 ;; Remember modify the number of forward lines.
4986 (let ((mail-parse-charset gnus-newsgroup-charset)
4987 (mail-parse-ignored-charsets
4988 (save-excursion (condition-case ()
4989 (set-buffer gnus-summary-buffer)
4991 gnus-newsgroup-ignored-charsets)))
4992 (mm-display-part handle t))
4993 (goto-char (point-max)))
4994 ((and text not-attachment)
4998 (gnus-article-insert-newline)
4999 (mm-insert-inline handle (mm-get-part handle))
5000 (goto-char (point-max))))
5004 (narrow-to-region beg (point))
5007 (gnus-article-mime-total-parts)
5008 (mm-handle-media-type handle)))))))))
5010 (defun gnus-unbuttonized-mime-type-p (type)
5011 "Say whether TYPE is to be unbuttonized."
5012 (unless gnus-inhibit-mime-unbuttonizing
5014 (let ((types gnus-unbuttonized-mime-types))
5016 (when (string-match (pop types) type)
5017 (throw 'found t)))))
5019 (let ((types gnus-buttonized-mime-types))
5021 (when (string-match (pop types) type)
5022 (throw 'found t)))))))))
5024 (defun gnus-article-insert-newline ()
5025 "Insert a newline, but mark it as undeletable."
5026 (gnus-put-text-property
5027 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5029 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5030 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5033 handle buffer-read-only from props begend not-pref)
5034 (save-window-excursion
5037 (narrow-to-region (car ibegend)
5040 (goto-char (car ibegend))
5043 (delete-region (point-min) (point-max))
5044 (mm-remove-parts handles))
5045 (setq begend (list (point-marker)))
5047 (unless (setq not-pref (cadr (member preferred ihandles)))
5048 (setq not-pref (car ihandles)))
5051 (not (gnus-unbuttonized-mime-type-p
5052 "multipart/alternative")))
5053 (gnus-add-text-properties
5056 (insert (format "%d. " id))
5060 (unless ,(not ibegend)
5061 (setq gnus-article-mime-handle-alist
5062 ',gnus-article-mime-handle-alist))
5063 (gnus-mime-display-alternative
5064 ',ihandles ',not-pref ',begend ,id))
5065 ,@(gnus-local-map-property gnus-mime-button-map)
5066 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5067 face ,gnus-article-button-face
5070 (widget-convert-button 'link from (point)
5071 :action 'gnus-widget-press-button
5072 :button-keymap gnus-widget-button-keymap)
5074 (while (setq handle (pop handles))
5075 (gnus-add-text-properties
5078 (insert (format "(%c) %-18s"
5079 (if (equal handle preferred) ?* ? )
5080 (mm-handle-media-type handle)))
5084 (unless ,(not ibegend)
5085 (setq gnus-article-mime-handle-alist
5086 ',gnus-article-mime-handle-alist))
5087 (gnus-mime-display-alternative
5088 ',ihandles ',handle ',begend ,id))
5089 ,@(gnus-local-map-property gnus-mime-button-map)
5090 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5091 face ,gnus-article-button-face
5094 (widget-convert-button 'link from (point)
5095 :action 'gnus-widget-press-button
5096 :button-keymap gnus-widget-button-keymap)
5100 (if (stringp (car preferred))
5101 (gnus-display-mime preferred)
5102 (let ((mail-parse-charset gnus-newsgroup-charset)
5103 (mail-parse-ignored-charsets
5104 (save-excursion (set-buffer gnus-summary-buffer)
5105 gnus-newsgroup-ignored-charsets)))
5106 (mm-display-part preferred)
5110 (narrow-to-region (car begend) (point-max))
5112 nil (length gnus-article-mime-handle-alist)
5113 (gnus-article-mime-total-parts)
5114 (mm-handle-media-type handle))))))
5115 (goto-char (point-max))
5116 (setcdr begend (point-marker)))))
5118 (goto-char point))))
5120 (defconst gnus-article-wash-status-strings
5121 (let ((alist '((cite "c" "Possible hidden citation text"
5122 " " "All citation text visible")
5123 (headers "h" "Hidden headers"
5124 " " "All headers visible.")
5125 (pgp "p" "Encrypted or signed message status hidden"
5126 " " "No hidden encryption nor digital signature status")
5127 (signature "s" "Signature has been hidden"
5128 " " "Signature is visible")
5129 (overstrike "o" "Overstrike (^H) characters applied"
5130 " " "No overstrike characters applied")
5131 (gnus-show-mime "m" "Mime processing is activated"
5132 " " "Mime processing is not activated")
5133 (emphasis "e" "/*_Emphasis_*/ characters applied"
5134 " " "No /*_emphasis_*/ characters applied")))
5136 (dolist (entry alist result)
5137 (let ((key (nth 0 entry))
5138 (on (copy-sequence (nth 1 entry)))
5139 (on-help (nth 2 entry))
5140 (off (copy-sequence (nth 3 entry)))
5141 (off-help (nth 4 entry)))
5142 (put-text-property 0 1 'help-echo on-help on)
5143 (put-text-property 0 1 'help-echo off-help off)
5144 (push (list key on off) result))))
5145 "Alist of strings describing wash status in the mode line.
5146 Each entry has the form (KEY ON OF), where the KEY is a symbol
5147 representing the particular washing function, ON is the string to use
5148 in the article mode line when the washing function is active, and OFF
5149 is the string to use when it is inactive.")
5151 (defun gnus-article-wash-status-entry (key value)
5152 (let ((entry (assoc key gnus-article-wash-status-strings)))
5153 (if value (nth 1 entry) (nth 2 entry))))
5155 (defun gnus-article-wash-status ()
5156 "Return a string which display status of article washing."
5158 (set-buffer gnus-article-buffer)
5159 (let ((cite (memq 'cite gnus-article-wash-types))
5160 (headers (memq 'headers gnus-article-wash-types))
5161 (boring (memq 'boring-headers gnus-article-wash-types))
5162 (pgp (memq 'pgp gnus-article-wash-types))
5163 (pem (memq 'pem gnus-article-wash-types))
5164 (signed (memq 'signed gnus-article-wash-types))
5165 (encrypted (memq 'encrypted gnus-article-wash-types))
5166 (signature (memq 'signature gnus-article-wash-types))
5167 (overstrike (memq 'overstrike gnus-article-wash-types))
5168 (emphasis (memq 'emphasis gnus-article-wash-types)))
5170 (gnus-article-wash-status-entry 'cite cite)
5171 (gnus-article-wash-status-entry 'headers (or headers boring))
5172 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5173 (gnus-article-wash-status-entry 'signature signature)
5174 (gnus-article-wash-status-entry 'overstrike overstrike)
5175 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
5176 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5178 (defun gnus-add-wash-type (type)
5179 "Add a washing of TYPE to the current status."
5180 (add-to-list 'gnus-article-wash-types type))
5182 (defun gnus-delete-wash-type (type)
5183 "Add a washing of TYPE to the current status."
5184 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5186 (defun gnus-add-image (category image)
5187 "Add IMAGE of CATEGORY to the list of displayed images."
5188 (let ((entry (assq category gnus-article-image-alist)))
5190 (setq entry (list category))
5191 (push entry gnus-article-image-alist))
5192 (nconc entry (list image))))
5194 (defun gnus-delete-images (category)
5195 "Delete all images in CATEGORY."
5196 (let ((entry (assq category gnus-article-image-alist)))
5197 (dolist (image (cdr entry))
5198 (gnus-remove-image image))
5199 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5200 (gnus-delete-wash-type category)))
5202 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5204 (defun gnus-article-maybe-hide-headers ()
5205 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5206 Provided for backwards compatibility."
5207 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5208 (not (save-excursion (set-buffer gnus-summary-buffer)
5209 gnus-have-all-headers)))
5210 (not gnus-inhibit-hiding))
5211 (gnus-article-hide-headers)))
5215 (defun gnus-output-to-file (file-name)
5216 "Append the current article to a file named FILE-NAME."
5217 (let ((artbuf (current-buffer)))
5219 (insert-buffer-substring artbuf)
5220 ;; Append newline at end of the buffer as separator, and then
5222 (goto-char (point-max))
5224 (let ((file-name-coding-system nnmail-pathname-coding-system)
5225 (pathname-coding-system nnmail-pathname-coding-system))
5226 (write-region-as-binary (point-min) (point-max) file-name 'append))
5229 (defun gnus-narrow-to-page (&optional arg)
5230 "Narrow the article buffer to a page.
5231 If given a numerical ARG, move forward ARG pages."
5233 (setq arg (if arg (prefix-numeric-value arg) 0))
5235 (set-buffer gnus-article-buffer)
5236 (goto-char (point-min))
5238 ;; Remove any old next/prev buttons.
5239 (when (gnus-visual-p 'page-marker)
5240 (let ((buffer-read-only nil))
5241 (gnus-remove-text-with-property 'gnus-prev)
5242 (gnus-remove-text-with-property 'gnus-next)))
5245 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5247 (re-search-forward page-delimiter nil 'move arg)))
5248 (goto-char (match-end 0)))
5251 (if (re-search-forward page-delimiter nil 'move)
5254 (when (and (gnus-visual-p 'page-marker)
5255 (not (= (point-min) 1)))
5257 (goto-char (point-min))
5258 (gnus-insert-prev-page-button)))
5259 (when (and (gnus-visual-p 'page-marker)
5260 (< (+ (point-max) 2) (buffer-size)))
5262 (goto-char (point-max))
5263 (gnus-insert-next-page-button)))))
5265 ;; Article mode commands
5267 (defun gnus-article-goto-next-page ()
5268 "Show the next page of the article."
5270 (gnus-eval-in-buffer-window gnus-summary-buffer
5271 (gnus-summary-next-page)))
5273 (defun gnus-article-goto-prev-page ()
5274 "Show the next page of the article."
5276 (gnus-eval-in-buffer-window gnus-summary-buffer
5277 (gnus-summary-prev-page)))
5279 (defun gnus-article-next-page (&optional lines)
5280 "Show the next page of the current article.
5281 If end of article, return non-nil. Otherwise return nil.
5282 Argument LINES specifies lines to be scrolled up."
5284 (move-to-window-line -1)
5287 (and (pos-visible-in-window-p) ;Not continuation line.
5288 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5289 ;; Nothing in this page.
5290 (if (or (not gnus-page-broken)
5293 (widen) (forward-line 1) (eobp)))) ;Real end-of-buffer?
5295 (when gnus-article-over-scroll
5296 (gnus-article-next-page-1 lines))
5298 (gnus-narrow-to-page 1) ;Go to next page.
5300 ;; More in this page.
5301 (gnus-article-next-page-1 lines)
5304 (defun gnus-article-next-page-1 (lines)
5305 (let ((scroll-in-place nil))
5309 ;; Long lines may cause an end-of-buffer error.
5310 (goto-char (point-max)))))
5311 (move-to-window-line 0))
5313 (defun gnus-article-prev-page (&optional lines)
5314 "Show previous page of current article.
5315 Argument LINES specifies lines to be scrolled down."
5317 (move-to-window-line 0)
5318 (if (and gnus-page-broken
5320 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5322 (gnus-narrow-to-page -1) ;Go to previous page.
5323 (goto-char (point-max))
5325 (let ((scroll-in-place nil))
5329 (beginning-of-buffer
5330 (goto-char (point-min))))
5331 (move-to-window-line 0)))))
5333 (defun gnus-article-only-boring-p ()
5334 "Decide whether there is only boring text remaining in the article.
5335 Something \"interesting\" is a word of at least two letters that does
5336 not have a face in `gnus-article-boring-faces'."
5337 (when (and gnus-article-skip-boring
5338 (boundp 'gnus-article-boring-faces)
5339 (symbol-value 'gnus-article-boring-faces))
5342 (while (re-search-forward "\\b\\w\\w" nil t)
5344 (when (not (gnus-intersection
5345 (gnus-faces-at (point))
5346 (symbol-value 'gnus-article-boring-faces)))
5347 (throw 'only-boring nil)))
5348 (throw 'only-boring t)))))
5350 (defun gnus-article-refer-article ()
5351 "Read article specified by message-id around point."
5354 (re-search-backward "[ \t]\\|^" (gnus-point-at-bol) t)
5355 (re-search-forward "<?news:<?\\|<" (gnus-point-at-eol) t)
5356 (if (re-search-forward "[^@ ]+@[^ \t>]+" (gnus-point-at-eol) t)
5357 (let ((msg-id (concat "<" (match-string 0) ">")))
5358 (set-buffer gnus-summary-buffer)
5359 (gnus-summary-refer-article msg-id))
5360 (error "No references around point"))))
5362 (defun gnus-article-show-summary ()
5363 "Reconfigure windows to show summary buffer."
5365 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5366 (error "There is no summary buffer for this article buffer")
5367 (gnus-article-set-globals)
5368 (gnus-configure-windows 'article)
5369 (gnus-summary-goto-subject gnus-current-article)
5370 (gnus-summary-position-point)))
5372 (defun gnus-article-describe-briefly ()
5373 "Describe article mode commands briefly."
5375 (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")))
5377 (defun gnus-article-summary-command ()
5378 "Execute the last keystroke in the summary buffer."
5380 (let ((obuf (current-buffer))
5381 (owin (current-window-configuration))
5383 (switch-to-buffer gnus-article-current-summary 'norecord)
5384 (setq func (lookup-key (current-local-map) (this-command-keys)))
5385 (call-interactively func)
5387 (set-window-configuration owin)
5388 (set-window-point (get-buffer-window (current-buffer)) (point))))
5390 (defun gnus-article-summary-command-nosave ()
5391 "Execute the last keystroke in the summary buffer."
5394 (pop-to-buffer gnus-article-current-summary 'norecord)
5395 (setq func (lookup-key (current-local-map) (this-command-keys)))
5396 (call-interactively func)))
5398 (defun gnus-article-check-buffer ()
5399 "Beep if not in an article buffer."
5400 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5401 (error "Command invoked outside of a Gnus article buffer")))
5403 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5404 "Read a summary buffer key sequence and execute it from the article buffer."
5406 (gnus-article-check-buffer)
5408 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5409 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5410 "=" "^" "\M-^" "|"))
5416 '("n" "Gn" "p" "Gp"))
5419 (set-buffer gnus-article-current-summary)
5420 (let (gnus-pick-mode)
5421 (push (or key last-command-event) unread-command-events)
5422 (setq keys (static-if (featurep 'xemacs)
5423 (events-to-keys (read-key-sequence nil))
5424 (read-key-sequence nil)))))
5427 (if (or (member keys nosaves)
5428 (member keys nosave-but-article)
5429 (member keys nosave-in-article))
5431 (save-window-excursion
5432 (pop-to-buffer gnus-article-current-summary 'norecord)
5433 ;; We disable the pick minor mode commands.
5434 (let (gnus-pick-mode)
5435 (setq func (lookup-key (current-local-map) keys))))
5439 (unless (member keys nosave-in-article)
5440 (set-buffer gnus-article-current-summary))
5441 (call-interactively func)
5442 (setq new-sum-point (point)))
5443 (when (member keys nosave-but-article)
5444 (pop-to-buffer gnus-article-buffer 'norecord)))
5445 ;; These commands should restore window configuration.
5446 (let ((obuf (current-buffer))
5447 (owin (current-window-configuration))
5449 (summary gnus-article-current-summary)
5450 func in-buffer selected)
5451 (if not-restore-window
5452 (pop-to-buffer summary 'norecord)
5453 (switch-to-buffer summary 'norecord))
5454 (setq in-buffer (current-buffer))
5455 ;; We disable the pick minor mode commands.
5456 (if (and (setq func (let (gnus-pick-mode)
5457 (lookup-key (current-local-map) keys)))
5460 (call-interactively func)
5461 (setq new-sum-point (point))
5462 (when (eq in-buffer (current-buffer))
5463 (setq selected (gnus-summary-select-article))
5465 (unless not-restore-window
5466 (set-window-configuration owin))
5467 (when (eq selected 'old)
5469 (set-window-start (get-buffer-window (current-buffer))
5471 (set-window-point (get-buffer-window (current-buffer))
5473 (let ((win (get-buffer-window gnus-article-current-summary)))
5475 (set-window-point win new-sum-point)))) )
5476 (switch-to-buffer gnus-article-buffer)
5479 (defun gnus-article-describe-key (key)
5480 "Display documentation of the function invoked by KEY. KEY is a string."
5481 (interactive "kDescribe key: ")
5482 (gnus-article-check-buffer)
5483 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5485 (set-buffer gnus-article-current-summary)
5486 (let (gnus-pick-mode)
5487 (if (featurep 'xemacs)
5489 (push (elt key 0) unread-command-events)
5490 (setq key (events-to-keys
5491 (read-key-sequence "Describe key: "))))
5492 (setq unread-command-events
5494 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5496 (setq key (read-key-sequence "Describe key: "))))
5498 (describe-key key)))
5500 (defun gnus-article-describe-key-briefly (key &optional insert)
5501 "Display documentation of the function invoked by KEY. KEY is a string."
5502 (interactive "kDescribe key: \nP")
5503 (gnus-article-check-buffer)
5504 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5506 (set-buffer gnus-article-current-summary)
5507 (let (gnus-pick-mode)
5508 (if (featurep 'xemacs)
5510 (push (elt key 0) unread-command-events)
5511 (setq key (events-to-keys
5512 (read-key-sequence "Describe key: "))))
5513 (setq unread-command-events
5515 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5517 (setq key (read-key-sequence "Describe key: "))))
5518 (describe-key-briefly key insert))
5519 (describe-key-briefly key insert)))
5521 (defun gnus-article-reply-with-original (&optional wide)
5522 "Start composing a reply mail to the current message.
5523 The text in the region will be yanked. If the region isn't active,
5524 the entire article will be yanked."
5526 (let ((article (cdr gnus-article-current))
5528 (if (not (gnus-mark-active-p))
5529 (with-current-buffer gnus-summary-buffer
5530 (gnus-summary-reply (list (list article)) wide))
5531 (setq contents (buffer-substring (point) (mark t)))
5532 ;; Deactivate active regions.
5533 (when (and (boundp 'transient-mark-mode)
5534 transient-mark-mode)
5535 (setq mark-active nil))
5536 (with-current-buffer gnus-summary-buffer
5538 (list (list article contents)) wide)))))
5540 (defun gnus-article-followup-with-original ()
5541 "Compose a followup to the current article.
5542 The text in the region will be yanked. If the region isn't active,
5543 the entire article will be yanked."
5545 (let ((article (cdr gnus-article-current))
5547 (if (not (gnus-mark-active-p))
5548 (with-current-buffer gnus-summary-buffer
5549 (gnus-summary-followup (list (list article))))
5550 (setq contents (buffer-substring (point) (mark t)))
5551 ;; Deactivate active regions.
5552 (when (and (boundp 'transient-mark-mode)
5553 transient-mark-mode)
5554 (setq mark-active nil))
5555 (with-current-buffer gnus-summary-buffer
5556 (gnus-summary-followup
5557 (list (list article contents)))))))
5559 (defun gnus-article-hide (&optional arg force)
5560 "Hide all the gruft in the current article.
5561 This means that signatures, cited text and (some) headers will be
5563 If given a prefix, show the hidden text instead."
5564 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5565 (gnus-article-hide-headers arg)
5566 (gnus-article-hide-list-identifiers arg)
5567 (gnus-article-hide-citation-maybe arg force)
5568 (gnus-article-hide-signature arg))
5570 (defun gnus-article-maybe-highlight ()
5571 "Do some article highlighting if article highlighting is requested."
5572 (when (gnus-visual-p 'article-highlight 'highlight)
5573 (gnus-article-highlight-some)))
5575 (defun gnus-check-group-server ()
5576 ;; Make sure the connection to the server is alive.
5577 (unless (gnus-server-opened
5578 (gnus-find-method-for-group gnus-newsgroup-name))
5579 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5580 (gnus-request-group gnus-newsgroup-name t)))
5583 (autoload 'nneething-get-file-name "nneething"))
5585 (defun gnus-request-article-this-buffer (article group)
5586 "Get an article and insert it into this buffer."
5587 (let (do-update-line sparse-header)
5591 (gnus-kill-all-overlays)
5592 (setq group (or group gnus-newsgroup-name))
5594 ;; Using `gnus-request-article' directly will insert the article into
5595 ;; `nntp-server-buffer' - so we'll save some time by not having to
5596 ;; copy it from the server buffer into the article buffer.
5598 ;; We only request an article by message-id when we do not have the
5599 ;; headers for it, so we'll have to get those.
5600 (when (stringp article)
5601 (gnus-read-header article))
5603 ;; If the article number is negative, that means that this article
5604 ;; doesn't belong in this newsgroup (possibly), so we find its
5605 ;; message-id and request it by id instead of number.
5606 (when (and (numberp article)
5608 (get-buffer gnus-summary-buffer)
5609 (gnus-buffer-exists-p gnus-summary-buffer))
5611 (set-buffer gnus-summary-buffer)
5612 (let ((header (gnus-summary-article-header article)))
5615 ((memq article gnus-newsgroup-sparse)
5616 ;; This is a sparse gap article.
5617 (setq do-update-line article)
5618 (setq article (mail-header-id header))
5619 (setq sparse-header (gnus-read-header article))
5620 (setq gnus-newsgroup-sparse
5621 (delq article gnus-newsgroup-sparse)))
5623 ;; It's a real article.
5624 (setq article (mail-header-id header)))
5626 ;; It is an extracted pseudo-article.
5627 (setq article 'pseudo)
5628 (gnus-request-pseudo-article header))))
5630 (let ((method (gnus-find-method-for-group
5631 gnus-newsgroup-name)))
5632 (when (and (eq (car method) 'nneething)
5634 (let ((dir (nneething-get-file-name
5635 (mail-header-id header))))
5636 (when (and (stringp dir)
5637 (file-directory-p dir))
5638 (setq article 'nneething)
5639 (gnus-group-enter-directory dir))))))))
5642 ;; Refuse to select canceled articles.
5643 ((and (numberp article)
5645 (get-buffer gnus-summary-buffer)
5646 (gnus-buffer-exists-p gnus-summary-buffer)
5647 (eq (cdr (save-excursion
5648 (set-buffer gnus-summary-buffer)
5649 (assq article gnus-newsgroup-reads)))
5650 gnus-canceled-mark))
5652 ;; We first check `gnus-original-article-buffer'.
5653 ((and (get-buffer gnus-original-article-buffer)
5656 (set-buffer gnus-original-article-buffer)
5657 (and (equal (car gnus-original-article) group)
5658 (eq (cdr gnus-original-article) article))))
5659 (insert-buffer-substring gnus-original-article-buffer)
5661 ;; Check the backlog.
5662 ((and gnus-keep-backlog
5663 (gnus-backlog-request-article group article (current-buffer)))
5665 ;; Check asynchronous pre-fetch.
5666 ((gnus-async-request-fetched-article group article (current-buffer))
5667 (gnus-async-prefetch-next group article gnus-summary-buffer)
5668 (when (and (numberp article) gnus-keep-backlog)
5669 (gnus-backlog-enter-article group article (current-buffer)))
5672 ((and gnus-use-cache
5674 (gnus-cache-request-article article group))
5676 ;; Check the agent cache.
5677 ((gnus-agent-request-article article group)
5679 ;; Get the article and put into the article buffer.
5680 ((or (stringp article)
5682 (let ((gnus-override-method gnus-override-method)
5683 (methods (and (stringp article)
5684 gnus-refer-article-method))
5685 (backend (car (gnus-find-method-for-group
5686 gnus-newsgroup-name)))
5688 (buffer-read-only nil))
5689 (if (or (not (listp methods))
5690 (and (symbolp (car methods))
5691 (assq (car methods) nnoo-definition-alist)))
5692 (setq methods (list methods)))
5693 (when (and (null gnus-override-method)
5695 (setq gnus-override-method (pop methods)))
5697 (when (eq gnus-override-method 'current)
5698 (setq gnus-override-method
5699 (with-current-buffer gnus-summary-buffer
5700 gnus-current-select-method)))
5702 (gnus-kill-all-overlays)
5703 (let ((gnus-newsgroup-name group))
5704 (gnus-check-group-server))
5706 ((gnus-request-article article group (current-buffer))
5707 (when (numberp article)
5708 (gnus-async-prefetch-next group article
5709 gnus-summary-buffer)
5710 (when gnus-keep-backlog
5711 (gnus-backlog-enter-article
5712 group article (current-buffer))))
5713 (setq result 'article))
5715 (setq gnus-override-method (pop methods)))
5716 ((not (string-match "^400 "
5717 (nnheader-get-report backend)))
5718 ;; If we get 400 server disconnect, reconnect and
5719 ;; retry; otherwise, assume the article has expired.
5720 (setq result 'done))))
5721 (and (eq result 'article) 'article)))
5725 ;; Associate this article with the current summary buffer.
5726 (setq gnus-article-current-summary gnus-summary-buffer)
5728 ;; Take the article from the original article buffer
5729 ;; and place it in the buffer it's supposed to be in.
5730 (when (and (get-buffer gnus-article-buffer)
5731 (equal (buffer-name (current-buffer))
5732 (buffer-name (get-buffer gnus-article-buffer))))
5734 (if (get-buffer gnus-original-article-buffer)
5735 (set-buffer gnus-original-article-buffer)
5736 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5737 (buffer-disable-undo)
5738 (setq major-mode 'gnus-original-article-mode)
5739 (setq buffer-read-only t))
5740 (let (buffer-read-only)
5742 (insert-buffer-substring gnus-article-buffer))
5743 (setq gnus-original-article (cons group article)))
5746 (run-hooks 'gnus-article-decode-hook)
5747 ;; Mark article as decoded or not.
5748 (setq gnus-article-decoded-p gnus-article-decode-hook))
5750 ;; Update sparse articles.
5751 (when (and do-update-line
5752 (or (numberp article)
5754 (let ((buf (current-buffer)))
5755 (set-buffer gnus-summary-buffer)
5756 (gnus-summary-update-article do-update-line sparse-header)
5757 (gnus-summary-goto-subject do-update-line nil t)
5758 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5760 (set-buffer buf))))))
5766 (defcustom gnus-article-edit-mode-hook nil
5767 "Hook run in article edit mode buffers."
5768 :group 'gnus-article-various
5771 (defcustom gnus-article-edit-article-setup-function
5772 'gnus-article-mime-edit-article-setup
5773 "Function called to setup an editing article buffer."
5774 :group 'gnus-article-various
5777 (defvar gnus-article-edit-done-function nil)
5779 (defvar gnus-article-edit-mode-map nil)
5780 (defvar gnus-article-edit-mode nil)
5782 ;; Should we be using derived.el for this?
5783 (unless gnus-article-edit-mode-map
5784 (setq gnus-article-edit-mode-map (make-keymap))
5785 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5787 (gnus-define-keys gnus-article-edit-mode-map
5788 "\C-c?" describe-mode
5789 "\C-c\C-c" gnus-article-edit-done
5790 "\C-c\C-k" gnus-article-edit-exit
5791 "\C-c\C-f\C-t" message-goto-to
5792 "\C-c\C-f\C-o" message-goto-from
5793 "\C-c\C-f\C-b" message-goto-bcc
5794 ;;"\C-c\C-f\C-w" message-goto-fcc
5795 "\C-c\C-f\C-c" message-goto-cc
5796 "\C-c\C-f\C-s" message-goto-subject
5797 "\C-c\C-f\C-r" message-goto-reply-to
5798 "\C-c\C-f\C-n" message-goto-newsgroups
5799 "\C-c\C-f\C-d" message-goto-distribution
5800 "\C-c\C-f\C-f" message-goto-followup-to
5801 "\C-c\C-f\C-m" message-goto-mail-followup-to
5802 "\C-c\C-f\C-k" message-goto-keywords
5803 "\C-c\C-f\C-u" message-goto-summary
5804 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5805 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5806 "\C-c\C-b" message-goto-body
5807 "\C-c\C-i" message-goto-signature
5809 "\C-c\C-t" message-insert-to
5810 "\C-c\C-n" message-insert-newsgroups
5811 "\C-c\C-o" message-sort-headers
5812 "\C-c\C-e" message-elide-region
5813 "\C-c\C-v" message-delete-not-region
5814 "\C-c\C-z" message-kill-to-signature
5815 "\M-\r" message-newline-and-reformat
5816 "\C-c\C-a" mml-attach-file
5817 "\C-a" message-beginning-of-line
5819 "\M-;" comment-region)
5821 (gnus-define-keys (gnus-article-edit-wash-map
5822 "\C-c\C-w" gnus-article-edit-mode-map)
5823 "f" gnus-article-edit-full-stops))
5826 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5828 ["Fetch To" message-insert-to t]
5829 ["Fetch Newsgroups" message-insert-newsgroups t]
5831 ["To" message-goto-to t]
5832 ["From" message-goto-from t]
5833 ["Subject" message-goto-subject t]
5834 ["Cc" message-goto-cc t]
5835 ["Reply-To" message-goto-reply-to t]
5836 ["Summary" message-goto-summary t]
5837 ["Keywords" message-goto-keywords t]
5838 ["Newsgroups" message-goto-newsgroups t]
5839 ["Followup-To" message-goto-followup-to t]
5840 ["Mail-Followup-To" message-goto-mail-followup-to t]
5841 ["Distribution" message-goto-distribution t]
5842 ["Body" message-goto-body t]
5843 ["Signature" message-goto-signature t]))
5845 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5846 "Major mode for editing articles.
5847 This is an extended text-mode.
5849 \\{gnus-article-edit-mode-map}"
5850 (make-local-variable 'gnus-article-edit-done-function)
5851 (make-local-variable 'gnus-prev-winconf)
5852 (set (make-local-variable 'font-lock-defaults)
5853 '(message-font-lock-keywords t))
5854 (set (make-local-variable 'mail-header-separator) "")
5855 (set (make-local-variable 'gnus-article-edit-mode) t)
5856 (easy-menu-add message-mode-field-menu message-mode-map)
5857 (setq buffer-read-only nil)
5858 (buffer-enable-undo)
5861 (defun gnus-article-edit (&optional force)
5862 "Edit the current article.
5863 This will have permanent effect only in mail groups.
5864 If FORCE is non-nil, allow editing of articles even in read-only
5867 (when (and (not force)
5868 (gnus-group-read-only-p))
5869 (error "The current newsgroup does not support article editing"))
5870 (gnus-article-date-original)
5871 (gnus-article-edit-article
5873 `(lambda (no-highlight)
5875 (gnus-summary-edit-article-done
5876 ,(or (mail-header-references gnus-current-headers) "")
5877 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5879 (defun gnus-article-edit-article (start-func exit-func)
5880 "Start editing the contents of the current article buffer."
5881 (let ((winconf (current-window-configuration)))
5882 (set-buffer gnus-article-buffer)
5883 (gnus-article-edit-mode)
5884 (funcall start-func)
5885 (set-buffer-modified-p nil)
5886 (gnus-configure-windows 'edit-article)
5887 (setq gnus-article-edit-done-function exit-func)
5888 (setq gnus-prev-winconf winconf)
5889 (when gnus-article-edit-article-setup-function
5890 (funcall gnus-article-edit-article-setup-function))
5891 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit")))
5893 (defun gnus-article-edit-done (&optional arg)
5894 "Update the article edits and exit."
5896 (let ((func gnus-article-edit-done-function)
5897 (buf (current-buffer))
5898 (start (window-start))
5900 (winconf gnus-prev-winconf))
5901 (remove-hook 'gnus-article-mode-hook
5902 'gnus-article-mime-edit-article-unwind)
5903 (widen) ;; Widen it in case that users narrowed the buffer.
5906 ;; The cache and backlog have to be flushed somewhat.
5907 (when gnus-keep-backlog
5908 (gnus-backlog-remove-article
5909 (car gnus-article-current) (cdr gnus-article-current)))
5910 ;; Flush original article as well.
5912 (when (get-buffer gnus-original-article-buffer)
5913 (set-buffer gnus-original-article-buffer)
5914 (setq gnus-original-article nil)))
5915 (when gnus-use-cache
5916 (gnus-cache-update-article
5917 (car gnus-article-current) (cdr gnus-article-current)))
5918 ;; We remove all text props from the article buffer.
5919 (kill-all-local-variables)
5920 (gnus-set-text-properties (point-min) (point-max) nil)
5922 (set-window-configuration winconf)
5924 (set-window-start (get-buffer-window buf) start)
5925 (set-window-point (get-buffer-window buf) (point))))
5927 (defun gnus-article-edit-exit ()
5928 "Exit the article editing without updating."
5930 (when (or (not (buffer-modified-p))
5931 (yes-or-no-p "Article modified; kill anyway? "))
5932 (let ((curbuf (current-buffer))
5934 (window-start (window-start)))
5936 (if (gnus-buffer-live-p gnus-original-article-buffer)
5937 (insert-buffer-substring gnus-original-article-buffer))
5938 (let ((winconf gnus-prev-winconf))
5939 (kill-all-local-variables)
5941 (set-window-configuration winconf)
5942 ;; Tippy-toe some to make sure that point remains where it was.
5943 (save-current-buffer
5945 (set-window-start (get-buffer-window (current-buffer)) window-start)
5948 (defun gnus-article-edit-full-stops ()
5949 "Interactively repair spacing at end of sentences."
5952 (goto-char (point-min))
5953 (search-forward-regexp "^$" nil t)
5954 (let ((case-fold-search nil))
5955 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5958 ;;; Article editing with MIME-Edit
5961 (defcustom gnus-article-mime-edit-article-setup-hook nil
5962 "Hook run after setting up a MIME editing article buffer."
5963 :group 'gnus-article-various
5966 (defun gnus-article-mime-edit-article-unwind ()
5967 "Unwind `gnus-article-buffer' if article editing was given up."
5968 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
5969 (when (featurep 'font-lock)
5970 (setq font-lock-defaults nil)
5971 (font-lock-mode -1))
5972 (when mime-edit-mode-flag
5973 (mime-edit-exit 'nomime 'no-error)
5976 (defun gnus-article-mime-edit-article-setup ()
5977 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
5978 after replacing with the original article."
5979 (setq gnus-show-mime t)
5980 (setq gnus-article-edit-done-function
5981 `(lambda (&rest args)
5982 (when mime-edit-mode-flag
5983 (let (mime-edit-insert-user-agent-field)
5986 (goto-char (point-min))
5987 (let (case-fold-search)
5988 (when (re-search-forward
5989 (format "^%s$" (regexp-quote mail-header-separator))
5991 (replace-match "")))
5992 (apply ,gnus-article-edit-done-function args)
5995 (buffer-substring-no-properties (point-min) (point-max))
5996 (set-buffer (get-buffer-create gnus-original-article-buffer))
5998 (setq gnus-current-headers (gnus-article-make-full-mail-header))
5999 (set-buffer gnus-article-buffer)
6000 (gnus-article-prepare-display)))
6001 (substitute-key-definition 'gnus-article-edit-done
6002 'gnus-article-mime-edit-done
6003 gnus-article-edit-mode-map)
6004 (substitute-key-definition 'gnus-article-edit-exit
6005 'gnus-article-mime-edit-exit
6006 gnus-article-edit-mode-map)
6008 (insert-buffer-substring gnus-original-article-buffer)
6009 (unless (member (with-current-buffer gnus-summary-buffer
6010 gnus-newsgroup-name)
6011 '("nndraft:delayed" "nndraft:drafts"))
6012 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
6013 (fset 'mime-edit-decode-single-part-in-buffer
6014 (lambda (&rest args)
6015 (if (let ((content-type (car args)))
6016 (and (eq 'message (mime-content-type-primary-type
6018 (eq 'rfc822 (mime-content-type-subtype
6020 (setcar (cdr args) 'not-decode-text))
6024 (fset 'mime-edit-decode-single-part-in-buffer ofn))))
6025 (when (featurep 'font-lock)
6026 (set (make-local-variable 'font-lock-defaults)
6027 '(message-font-lock-keywords t))
6028 (font-lock-set-defaults)
6029 (turn-on-font-lock))
6030 (set-buffer-modified-p nil)
6031 (delete-other-windows)
6032 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6033 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
6035 (defun gnus-article-mime-edit-done (&optional arg)
6036 "Update the article MIME edits and exit."
6038 (when (featurep 'font-lock)
6039 (setq font-lock-defaults nil)
6040 (font-lock-mode -1))
6041 (let ((inhibit-read-only t))
6042 (gnus-article-edit-done arg)))
6044 (defun gnus-article-mime-edit-exit ()
6045 "Exit the article MIME editing without updating."
6047 (when (or (not (buffer-modified-p))
6048 (yes-or-no-p "Article modified; kill anyway? "))
6049 (when (featurep 'font-lock)
6050 (setq font-lock-defaults nil)
6051 (font-lock-mode -1))
6052 (when mime-edit-mode-flag
6053 (let (mime-edit-insert-user-agent-field)
6056 (goto-char (point-min))
6057 (let (case-fold-search)
6058 (when (re-search-forward
6059 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
6060 (replace-match "")))
6061 (let ((winconf gnus-prev-winconf))
6063 (buffer-substring-no-properties (point-min) (point-max))
6064 (set-buffer (get-buffer-create gnus-original-article-buffer))
6066 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6067 (set-buffer gnus-article-buffer)
6068 (gnus-article-prepare-display)
6069 (set-window-configuration winconf))))
6072 ;;; Article highlights
6075 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6077 ;;; Internal Variables:
6079 (defcustom gnus-button-url-regexp
6080 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
6081 "\\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:]]\\)"
6082 "\\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\\)\\)")
6083 "Regular expression that matches URLs."
6084 :group 'gnus-article-buttons
6087 (defcustom gnus-button-valid-fqdn-regexp
6088 message-valid-fqdn-regexp
6089 "Regular expression that matches a valid FQDN."
6090 :group 'gnus-article-buttons
6093 (defcustom gnus-button-man-handler 'manual-entry
6094 "Function to use for displaying man pages.
6095 The function must take at least one argument with a string naming the
6097 :type '(choice (function-item :tag "Man" manual-entry)
6098 (function-item :tag "Woman" woman)
6099 (function :tag "Other"))
6100 :group 'gnus-article-buttons)
6102 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6103 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6104 If the default site is too slow, try to find a CTAN mirror, see
6105 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6106 the variable `gnus-button-handle-ctan'."
6107 :group 'gnus-article-buttons
6108 :link '(custom-manual "(gnus)Group Parameters")
6109 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6110 (const "http://tug.ctan.org/tex-archive/")
6111 (const "http://www.dante.de/CTAN/")
6112 (string :tag "Other")))
6114 (defcustom gnus-button-ctan-handler 'browse-url
6115 "Function to use for displaying CTAN links.
6116 The function must take one argument, the string naming the URL."
6117 :type '(choice (function-item :tag "Browse Url" browse-url)
6118 (function :tag "Other"))
6119 :group 'gnus-article-buttons)
6121 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6122 "Bogus strings removed from CTAN URLs."
6123 :group 'gnus-article-buttons
6124 :type '(choice (const "^/?tex-archive/\\|/")
6125 (regexp :tag "Other")))
6127 (defcustom gnus-button-ctan-directory-regexp
6129 "\\("; Cannot use `\(?: ... \)' (compatibility with Emacs 20).
6130 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
6131 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
6132 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
6134 "Regular expression for ctan directories.
6135 It should match all directories in the top level of `gnus-ctan-url'."
6136 :group 'gnus-article-buttons
6139 (defcustom gnus-button-mid-or-mail-regexp
6140 (concat "\\b\\(<?[a-z0-9][^<>\")!;:,{}\n\t ]*@"
6141 gnus-button-valid-fqdn-regexp
6143 "Regular expression that matches a message ID or a mail address."
6144 :group 'gnus-article-buttons
6147 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6148 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6149 Strings like this can be either a message ID or a mail address. If it is one
6150 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6151 message ID or a mail address, respectivly. If this variable is set to the
6152 symbol `ask', always query the user what do do. If it is a function, this
6153 function will be called with the string as it's only argument. The function
6154 must return `mid', `mail', `invalid' or `ask'."
6155 :group 'gnus-article-buttons
6156 :type '(choice (function-item :tag "Heuristic function"
6157 gnus-button-mid-or-mail-heuristic)
6162 (defcustom gnus-button-mid-or-mail-heuristic-alist
6163 '((-10.0 . ".+\\$.+@")
6166 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6167 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6168 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6169 (-1.0 . "^[^a-z]+@")
6171 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6172 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6173 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6174 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6177 (-1.0 . "^[0-9][0-9]")
6179 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6180 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6181 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6182 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6184 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6185 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6188 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6190 ;; compensation for TDMA dated mail addresses:
6191 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6193 (-20.0 . "\\.fsf@") ;; Gnus
6196 (-20.0 . "_-_") ;; Subject change in thread
6198 (-20.0 . "\\.ln@") ;; leafnode
6199 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6200 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6202 ;; (5.0 . "") ;; $local_part_len <= 7
6203 (10.0 . "^[^0-9]+@")
6204 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6205 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6208 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6210 (0.5 . "^[A-Z][a-z]")
6211 (0.5 . "^[A-Z][a-z][a-z]")
6212 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6213 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6214 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6216 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6217 address. The REGEXP is processed with `case-fold-search' set to `nil'."
6218 :group 'gnus-article-buttons
6219 :type '(repeat (cons (number :tag "Rate")
6220 (regexp :tag "Regexp"))))
6222 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6223 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6224 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6225 address, `ask' if unsure and `invalid' if the string is invalid."
6226 (let ((case-fold-search nil)
6227 (list gnus-button-mid-or-mail-heuristic-alist)
6228 (result 0) rate regexp lpartlen elem)
6230 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6231 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6232 ;; Certain special cases...
6235 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$" "\\|"
6236 "^[0-9]+\.[0-9]+\@compuserve")
6238 (gnus-message 8 "`%s' is a known mail address.")
6239 (setq result 'mail))
6240 (when (string-match "@.*@\\| " mid-or-mail)
6241 (gnus-message 8 "`%s' is invalid.")
6242 (setq result 'invalid))
6243 ;; Nothing more to do, if result is not a number here...
6244 (when (numberp result)
6246 (setq elem (car list)
6250 (when (string-match regexp mid-or-mail)
6251 (setq result (+ result rate))
6253 9 "`%s' matched `%s', rate `%s', result `%s'."
6254 mid-or-mail regexp rate result)))
6255 (when (<= lpartlen 7)
6256 (setq result (+ result 5.0))
6257 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6258 mid-or-mail result))
6259 (when (>= lpartlen 12)
6260 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6262 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6263 ;; Long local part should contain realname if e-mail address,
6264 ;; too many digits: message-id.
6265 ;; $score -= 5.0 + 0.1 * $local_part_len;
6266 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6267 (setq result (+ result rate))
6269 9 "Many digits in `%s', rate `%s', result `%s'."
6270 mid-or-mail rate result))
6271 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6273 ;; Too few vowels [^aeiouy]{4,}.*\@
6274 (setq result (+ result -5.0))
6276 9 "Few vowels in `%s', rate `%s', result `%s'."
6277 mid-or-mail -5.0 result))
6279 (setq result (+ result 5.0))
6281 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6282 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6284 ;; Maybe we should make this a customizable alist: (condition . 'result)
6285 ((< result -10.0) 'mid)
6286 ((> result 10.0) 'mail)
6289 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6290 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6291 (url-mid (concat "news" ":" mid-or-mail))
6292 (url-mailto (concat "mailto" ":" mid-or-mail)))
6293 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6294 (when (fboundp pref)
6296 ;; get rid of surrounding angles...
6298 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6299 (if (or (eq 'mid guessed) (eq 'mail guessed))
6303 (save-window-excursion
6304 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6307 (cond ((eq pref 'mid)
6308 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6309 (gnus-button-handle-news url-mid))
6311 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6312 (gnus-url-mailto url-mailto))
6313 (t (gnus-message 3 "Invalid string.")))))
6315 (defun gnus-button-handle-custom (url)
6316 "Follow a Custom URL."
6317 (customize-apropos (gnus-url-unhex-string url)))
6319 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6321 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6324 (defun gnus-button-handle-describe-function (url)
6325 "Call `describe-function' when pushing the corresponding URL button."
6328 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6330 (defun gnus-button-handle-describe-variable (url)
6331 "Call `describe-variable' when pushing the corresponding URL button."
6334 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6336 (defun gnus-button-handle-symbol (url)
6337 "Display help on variable or function.
6338 Calls `describe-variable' or `describe-function'."
6339 (let ((sym (intern url)))
6341 ((fboundp sym) (describe-function sym))
6342 ((boundp sym) (describe-variable sym))
6343 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6345 (defun gnus-button-handle-describe-key (url)
6346 "Call `describe-key' when pushing the corresponding URL button."
6348 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6349 (keys (ignore-errors (eval `(kbd ,key-string)))))
6352 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6354 (defun gnus-button-handle-apropos (url)
6355 "Call `apropos' when pushing the corresponding URL button."
6356 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6358 (defun gnus-button-handle-apropos-command (url)
6359 "Call `apropos' when pushing the corresponding URL button."
6361 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6363 (defun gnus-button-handle-apropos-variable (url)
6364 "Call `apropos' when pushing the corresponding URL button."
6366 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6367 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6369 (defun gnus-button-handle-apropos-documentation (url)
6370 "Call `apropos' when pushing the corresponding URL button."
6372 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6373 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6375 (defun gnus-button-handle-library (url)
6376 "Call `locate-library' when pushing the corresponding URL button."
6377 (gnus-message 9 "url=`%s'" url)
6378 (let* ((lib (locate-library url))
6379 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6381 (gnus-message 1 "Cannot locale library `%s'." url)
6382 (find-file-read-only file))))
6384 (defun gnus-button-handle-ctan (url)
6385 "Call `browse-url' when pushing a CTAN URL button."
6387 gnus-button-ctan-handler
6390 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6392 (defcustom gnus-button-tex-level 5
6393 "*Integer that says how many TeX-related buttons Gnus will show.
6394 The higher the number, the more buttons will appear and the more false
6395 positives are possible. Note that you can set this variable local to
6396 specifific groups. Setting it higher in TeX groups is probably a good idea.
6397 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6398 how to set variables in specific groups."
6399 :group 'gnus-article-buttons
6400 :link '(custom-manual "(gnus)Group Parameters")
6403 (defcustom gnus-button-man-level 5
6404 "*Integer that says how many man-related buttons Gnus will show.
6405 The higher the number, the more buttons will appear and the more false
6406 positives are possible. Note that you can set this variable local to
6407 specifific groups. Setting it higher in Unix groups is probably a good idea.
6408 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6409 how to set variables in specific groups."
6410 :group 'gnus-article-buttons
6411 :link '(custom-manual "(gnus)Group Parameters")
6414 (defcustom gnus-button-emacs-level 5
6415 "*Integer that says how many emacs-related buttons Gnus will show.
6416 The higher the number, the more buttons will appear and the more false
6417 positives are possible. Note that you can set this variable local to
6418 specifific groups. Setting it higher in Emacs or Gnus related groups is
6419 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6420 `gnus-parameters' on how to set variables in specific groups."
6421 :group 'gnus-article-buttons
6422 :link '(custom-manual "(gnus)Group Parameters")
6425 (defcustom gnus-button-message-level 5
6426 "*Integer that says how many buttons for news or mail messages will appear.
6427 The higher the number, the more buttons will appear and the more false
6428 positives are possible."
6429 ;; mail addresses, MIDs, URLs for news, ...
6430 :group 'gnus-article-buttons
6433 (defcustom gnus-button-browse-level 5
6434 "*Integer that says how many buttons for browsing will appear.
6435 The higher the number, the more buttons will appear and the more false
6436 positives are possible."
6437 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6438 :group 'gnus-article-buttons
6441 (defcustom gnus-button-alist
6442 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6443 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6444 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6445 gnus-button-handle-news 2)
6446 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6447 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6448 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6449 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6450 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6451 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6452 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6453 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6454 ("mailto:\\([-a-z.@_+0-9%=?]+\\)"
6455 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6456 ("\\bmailto:\\([^ \n\t]+\\)"
6457 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6459 ("\\bCTAN:[ \t\n]*\\([^>)!;:,'\n\t ]*\\)"
6460 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6461 ((concat "\\btex-archive/\\("
6462 gnus-button-ctan-directory-regexp
6463 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6464 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6467 gnus-button-ctan-directory-regexp
6468 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6469 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6471 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)"
6472 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6473 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6474 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6475 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6476 ;; Info links like `C-h i d m CC Mode RET'
6477 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6479 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6480 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6481 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6482 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6483 ;; Emacs help commands
6484 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6485 ;; regexp doesn't match arguments containing ` '.
6486 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6487 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6488 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6489 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6490 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6491 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6492 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6493 ;; The following entries may lead to many false positives so don't enable
6494 ;; them by default (use a high button level):
6495 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>"
6496 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6497 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6498 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6499 ("`\\([a-z]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6500 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6501 ("`\\([a-z]+-[a-z]+\\)'"
6502 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6503 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6504 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6505 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6506 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6507 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6508 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6509 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6510 ;; Unlike the other regexps we really have to require quoting
6511 ;; here to determine where it ends.
6512 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6513 ;; This is how URLs _should_ be embedded in text (RFC 1738)...
6514 ("<URL: *\\([^<>]*\\)>"
6515 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6517 (gnus-button-url-regexp
6518 0 (>= gnus-button-browse-level 0) browse-url 0)
6520 ("\\b\\([a-z][a-z]+\\)([1-9])\\W"
6521 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6522 gnus-button-handle-man 1)
6523 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6524 ("\\b\\([a-z][-_.a-z0-9]+\\)([1-9])\\W"
6525 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6526 gnus-button-handle-man 1)
6527 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6528 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6529 ("\\b\\([a-z][-_.:a-z0-9]+\\)([1-9][X1a-z]*)\\W\\|\\b\\(X\\)([1-9])\\W"
6530 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6531 ;; MID or mail: To avoid too many false positives we don't try to catch
6532 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6533 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6534 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6535 ;; so that non-ambiguous entries (see above) match first.
6536 (gnus-button-mid-or-mail-regexp
6537 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6538 "*Alist of regexps matching buttons in article bodies.
6540 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6541 REGEXP: is the string (case insensitive) matching text around the button (can
6542 also be lisp expression evaluating to a string),
6543 BUTTON: is the number of the regexp grouping actually matching the button,
6544 FORM: is a lisp expression which must eval to true for the button to
6546 CALLBACK: is the function to call when the user push this button, and each
6547 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6549 CALLBACK can also be a variable, in that case the value of that
6550 variable it the real callback function."
6551 :group 'gnus-article-buttons
6552 :type '(repeat (list (choice regexp variable)
6553 (integer :tag "Button")
6555 (function :tag "Callback")
6558 (integer :tag "Regexp group")))))
6560 (defcustom gnus-header-button-alist
6561 '(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
6562 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6563 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6564 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6565 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6566 0 (>= gnus-button-message-level 0) gnus-button-mailto 0)
6567 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6568 0 (>= gnus-button-browse-level 0) browse-url 0)
6569 ("^Subject:" gnus-button-url-regexp
6570 0 (>= gnus-button-browse-level 0) browse-url 0)
6571 ("^[^:]+:" gnus-button-url-regexp
6572 0 (>= gnus-button-browse-level 0) browse-url 0)
6573 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?]+\\)"
6574 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6575 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6576 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6577 "*Alist of headers and regexps to match buttons in article heads.
6579 This alist is very similar to `gnus-button-alist', except that each
6580 alist has an additional HEADER element first in each entry:
6582 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6584 HEADER is a regexp to match a header. For a fuller explanation, see
6585 `gnus-button-alist'."
6586 :group 'gnus-article-buttons
6587 :group 'gnus-article-headers
6588 :type '(repeat (list (regexp :tag "Header")
6590 (integer :tag "Button")
6592 (function :tag "Callback")
6595 (integer :tag "Regexp group")))))
6597 (defvar gnus-button-regexp nil)
6598 (defvar gnus-button-marker-list nil)
6599 ;; Regexp matching any of the regexps from `gnus-button-alist'.
6601 (defvar gnus-button-last nil)
6602 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
6606 (defun gnus-article-push-button (event)
6607 "Check text under the mouse pointer for a callback function.
6608 If the text under the mouse pointer has a `gnus-callback' property,
6609 call it with the value of the `gnus-data' text property."
6611 (set-buffer (window-buffer (posn-window (event-start event))))
6612 (let* ((pos (posn-point (event-start event)))
6613 (data (get-text-property pos 'gnus-data))
6614 (fun (get-text-property pos 'gnus-callback)))
6617 (funcall fun data))))
6619 (defun gnus-article-press-button ()
6620 "Check text at point for a callback function.
6621 If the text at point has a `gnus-callback' property,
6622 call it with the value of the `gnus-data' text property."
6624 (let ((data (get-text-property (point) 'gnus-data))
6625 (fun (get-text-property (point) 'gnus-callback)))
6627 (funcall fun data))))
6629 (defun gnus-article-prev-button (n)
6630 "Move point to N buttons backward.
6631 If N is negative, move forward instead."
6633 (gnus-article-next-button (- n)))
6635 (defun gnus-article-next-button (n)
6636 "Move point to N buttons forward.
6637 If N is negative, move backward instead."
6639 (let ((function (if (< n 0) 'previous-single-property-change
6640 'next-single-property-change))
6641 (inhibit-point-motion-hooks t)
6643 (limit (if (< n 0) (point-min) (point-max))))
6645 (while (and (not (= limit (point)))
6647 ;; Skip past the current button.
6648 (when (get-text-property (point) 'gnus-callback)
6649 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6650 ;; Go to the next (or previous) button.
6651 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
6652 ;; Put point at the start of the button.
6653 (when (and backward (not (get-text-property (point) 'gnus-callback)))
6654 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6655 ;; Skip past intangible buttons.
6656 (when (get-text-property (point) 'intangible)
6660 (gnus-message 5 "No more buttons"))
6663 (defun gnus-article-highlight (&optional force)
6664 "Highlight current article.
6665 This function calls `gnus-article-highlight-headers',
6666 `gnus-article-highlight-citation',
6667 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6668 do the highlighting. See the documentation for those functions."
6669 (interactive (list 'force))
6670 (gnus-article-highlight-headers)
6671 (gnus-article-highlight-citation force)
6672 (gnus-article-highlight-signature)
6673 (gnus-article-add-buttons force)
6674 (gnus-article-add-buttons-to-head))
6676 (defun gnus-article-highlight-some (&optional force)
6677 "Highlight current article.
6678 This function calls `gnus-article-highlight-headers',
6679 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6680 do the highlighting. See the documentation for those functions."
6681 (interactive (list 'force))
6682 (gnus-article-highlight-headers)
6683 (gnus-article-highlight-signature)
6684 (gnus-article-add-buttons))
6686 (defun gnus-article-highlight-headers ()
6687 "Highlight article headers as specified by `gnus-header-face-alist'."
6690 (set-buffer gnus-article-buffer)
6692 (let ((alist gnus-header-face-alist)
6693 (buffer-read-only nil)
6694 (case-fold-search t)
6695 (inhibit-point-motion-hooks t)
6696 entry regexp header-face field-face from hpoints fpoints)
6697 (article-narrow-to-head)
6698 (while (setq entry (pop alist))
6699 (goto-char (point-min))
6700 (setq regexp (concat "^\\("
6701 (if (string-equal "" (nth 0 entry))
6705 header-face (nth 1 entry)
6706 field-face (nth 2 entry))
6707 (while (and (re-search-forward regexp nil t)
6711 (unless (search-forward ":" nil t)
6713 (when (and header-face
6714 (not (memq (point) hpoints)))
6715 (push (point) hpoints)
6716 (gnus-put-text-property from (point) 'face header-face))
6717 (when (and field-face
6718 (not (memq (setq from (point)) fpoints)))
6720 (if (re-search-forward "^[^ \t]" nil t)
6722 (goto-char (point-max)))
6723 (gnus-put-text-property from (point) 'face field-face))))))))
6725 (defun gnus-article-highlight-signature ()
6726 "Highlight the signature in an article.
6727 It does this by highlighting everything after
6728 `gnus-signature-separator' using `gnus-signature-face'."
6730 (when gnus-signature-face
6732 (set-buffer gnus-article-buffer)
6733 (let ((buffer-read-only nil)
6734 (inhibit-point-motion-hooks t))
6736 (when (gnus-article-narrow-to-signature)
6737 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6738 'face gnus-signature-face)))))))
6740 (defun gnus-article-buttonize-signature ()
6741 "Add button to the signature."
6744 (set-buffer gnus-article-buffer)
6745 (let ((buffer-read-only nil)
6746 (inhibit-point-motion-hooks t))
6747 (when (gnus-article-search-signature)
6748 (gnus-article-add-button (match-beginning 0) (match-end 0)
6749 'gnus-signature-toggle
6750 (set-marker (make-marker)
6751 (1+ (match-end 0))))))))
6753 (defun gnus-button-in-region-p (b e prop)
6754 "Say whether PROP exists in the region."
6755 (text-property-not-all b e prop nil))
6757 (defun gnus-article-add-buttons (&optional force)
6758 "Find external references in the article and make buttons of them.
6759 \"External references\" are things like Message-IDs and URLs, as
6760 specified by `gnus-button-alist'."
6761 (interactive (list 'force))
6763 (set-buffer gnus-article-buffer)
6764 (let ((buffer-read-only nil)
6765 (inhibit-point-motion-hooks t)
6766 (case-fold-search t)
6767 (alist gnus-button-alist)
6769 ;; Remove all old markers.
6770 (let (marker entry new-list)
6771 (while (setq marker (pop gnus-button-marker-list))
6772 (if (or (< marker (point-min)) (>= marker (point-max)))
6773 (push marker new-list)
6775 (when (setq entry (gnus-button-entry))
6776 (put-text-property (match-beginning (nth 1 entry))
6777 (match-end (nth 1 entry))
6778 'gnus-callback nil))
6779 (set-marker marker nil)))
6780 (setq gnus-button-marker-list new-list))
6781 ;; We skip the headers.
6784 (while (setq entry (pop alist))
6785 (setq regexp (eval (car entry)))
6787 (while (re-search-forward regexp nil t)
6788 (let* ((start (and entry (match-beginning (nth 1 entry))))
6789 (end (and entry (match-end (nth 1 entry))))
6790 (from (match-beginning 0)))
6791 (when (and (or (eq t (nth 2 entry))
6792 (eval (nth 2 entry)))
6793 (not (gnus-button-in-region-p
6794 start end 'gnus-callback)))
6795 ;; That optional form returned non-nil, so we add the
6797 (gnus-article-add-button
6798 start end 'gnus-button-push
6799 (car (push (set-marker (make-marker) from)
6800 gnus-button-marker-list))))))))))
6802 ;; Add buttons to the head of an article.
6803 (defun gnus-article-add-buttons-to-head ()
6804 "Add buttons to the head of the article."
6807 (set-buffer gnus-article-buffer)
6809 (let ((buffer-read-only nil)
6810 (inhibit-point-motion-hooks t)
6811 (case-fold-search t)
6812 (alist gnus-header-button-alist)
6814 (article-narrow-to-head)
6816 ;; Each alist entry.
6817 (setq entry (car alist)
6819 (goto-char (point-min))
6820 (while (re-search-forward (car entry) nil t)
6821 ;; Each header matching the entry.
6822 (setq beg (match-beginning 0))
6823 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6824 (match-beginning 0))
6827 (while (re-search-forward (eval (nth 1 entry)) end t)
6828 ;; Each match within a header.
6829 (let* ((entry (cdr entry))
6830 (start (match-beginning (nth 1 entry)))
6831 (end (match-end (nth 1 entry)))
6832 (form (nth 2 entry)))
6833 (goto-char (match-end 0))
6835 (gnus-article-add-button
6836 start end (nth 3 entry)
6837 (buffer-substring (match-beginning (nth 4 entry))
6838 (match-end (nth 4 entry)))))))
6839 (goto-char end)))))))
6841 ;;; External functions:
6843 (defun gnus-article-add-button (from to fun &optional data)
6844 "Create a button between FROM and TO with callback FUN and data DATA."
6845 (when gnus-article-button-face
6846 (gnus-overlay-put (gnus-make-overlay from to)
6847 'face gnus-article-button-face))
6848 (gnus-add-text-properties
6850 (nconc (and gnus-article-mouse-face
6851 (list gnus-mouse-face-prop gnus-article-mouse-face))
6852 (list 'gnus-callback fun)
6853 (and data (list 'gnus-data data))))
6854 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6855 ;; Quote `:button-keymap' for Mule 2.3
6856 ;; but it won't work.
6857 ':button-keymap gnus-widget-button-keymap))
6859 ;;; Internal functions:
6861 (defun gnus-article-set-globals ()
6863 (set-buffer gnus-summary-buffer)
6864 (gnus-set-global-variables)))
6866 (defun gnus-signature-toggle (end)
6868 (set-buffer gnus-article-buffer)
6869 (let ((buffer-read-only nil)
6870 (inhibit-point-motion-hooks t)
6871 (limit (next-single-property-change end 'mime-view-entity
6873 (if (text-property-any end limit 'article-type 'signature)
6875 (gnus-delete-wash-type 'signature)
6876 (gnus-remove-text-properties-when
6877 'article-type 'signature end limit
6878 (cons 'article-type (cons 'signature
6879 gnus-hidden-properties))))
6880 (gnus-add-wash-type 'signature)
6881 (gnus-add-text-properties-when
6882 'article-type nil end limit
6883 (cons 'article-type (cons 'signature
6884 gnus-hidden-properties)))))
6885 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6886 (gnus-set-mode-line 'article))))
6888 (defun gnus-button-entry ()
6889 ;; Return the first entry in `gnus-button-alist' matching this place.
6890 (let ((alist gnus-button-alist)
6893 (setq entry (pop alist))
6894 (if (looking-at (eval (car entry)))
6899 (defun gnus-button-push (marker)
6900 ;; Push button starting at MARKER.
6903 (let* ((entry (gnus-button-entry))
6904 (inhibit-point-motion-hooks t)
6906 (args (mapcar (lambda (group)
6907 (let ((string (match-string group)))
6908 (gnus-set-text-properties
6909 0 (length string) nil string)
6916 (fboundp (symbol-value fun)))
6917 (apply (symbol-value fun) args))
6919 (gnus-message 1 "You must define `%S' to use this button"
6920 (cons fun args)))))))
6922 (defun gnus-parse-news-url (url)
6923 (let (scheme server group message-id articles)
6926 (goto-char (point-min))
6927 (when (looking-at "\\([A-Za-z]+\\):")
6928 (setq scheme (match-string 1))
6929 (goto-char (match-end 0)))
6930 (when (looking-at "//\\([^/]+\\)/")
6931 (setq server (match-string 1))
6932 (goto-char (match-end 0)))
6935 ((looking-at "\\(.*@.*\\)")
6936 (setq message-id (match-string 1)))
6937 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6938 (setq group (match-string 1)
6939 articles (split-string (match-string 2) "-")))
6940 ((looking-at "\\([^/]+\\)/?")
6941 (setq group (match-string 1)))
6943 (error "Unknown news URL syntax"))))
6944 (list scheme server group message-id articles)))
6946 (defun gnus-button-handle-news (url)
6948 (destructuring-bind (scheme server group message-id articles)
6949 (gnus-parse-news-url url)
6953 (set-buffer gnus-summary-buffer)
6955 (let ((gnus-refer-article-method (list (list 'nntp server))))
6956 (gnus-summary-refer-article message-id))
6957 (gnus-summary-refer-article message-id))))
6959 (gnus-button-fetch-group url)))))
6961 (defun gnus-button-handle-man (url)
6963 (funcall gnus-button-man-handler url))
6965 (defun gnus-button-handle-info-url (url)
6966 "Fetch an info URL."
6968 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
6969 (gnus-info-find-node
6970 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6972 ")" (gnus-url-unhex-string (match-string 2 url)))))
6973 ((string-match "([^)\"]+)[^\"]+" url)
6975 (gnus-replace-in-string
6976 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
6977 (gnus-info-find-node url))
6978 (t (error "Can't parse %s" url))))
6980 (defun gnus-button-handle-info-keystrokes (url)
6981 "Call `info' when pushing the corresponding URL button."
6982 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
6987 (defun gnus-button-message-id (message-id)
6990 (set-buffer gnus-summary-buffer)
6991 (gnus-summary-refer-article message-id)))
6993 (defun gnus-button-fetch-group (address)
6994 "Fetch GROUP specified by ADDRESS."
6995 (if (not (string-match "[:/]" address))
6996 ;; This is just a simple group url.
6997 (gnus-group-read-ephemeral-group address gnus-select-method)
7000 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
7002 (error "Can't parse %s" address)
7003 (gnus-group-read-ephemeral-group
7004 (match-string 4 address)
7005 `(nntp ,(match-string 1 address)
7006 (nntp-address ,(match-string 1 address))
7007 (nntp-port-number ,(if (match-end 3)
7008 (match-string 3 address)
7011 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
7013 (defun gnus-url-parse-query-string (query &optional downcase)
7014 (let (retval pairs cur key val)
7015 (setq pairs (split-string query "&"))
7017 (setq cur (car pairs)
7019 (if (not (string-match "=" cur))
7021 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
7022 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
7024 (setq key (downcase key)))
7025 (setq cur (assoc key retval))
7027 (setcdr cur (cons val (cdr cur)))
7028 (setq retval (cons (list key val) retval)))))
7031 (defun gnus-url-mailto (url)
7032 ;; Send mail to someone
7033 (when (string-match "mailto:/*\\(.*\\)" url)
7034 (setq url (substring url (match-beginning 1) nil)))
7035 (let (to args subject func)
7036 (if (string-match (regexp-quote "?") url)
7037 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
7038 args (gnus-url-parse-query-string
7039 (substring url (match-end 0) nil) t))
7040 (setq to (gnus-url-unhex-string url)))
7041 (setq args (cons (list "to" to) args)
7042 subject (cdr-safe (assoc "subject" args)))
7045 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
7048 (message-position-on-field (caar args)))
7049 (insert (mapconcat 'identity (cdar args) ", "))
7050 (setq args (cdr args)))
7053 (message-goto-subject))))
7055 (defun gnus-button-embedded-url (address)
7056 "Activate ADDRESS with `browse-url'."
7057 (browse-url (gnus-strip-whitespace address)))
7059 ;;; Next/prev buttons in the article buffer.
7061 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
7062 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
7064 (defvar gnus-prev-page-map
7065 (let ((map (make-sparse-keymap)))
7066 (unless (>= emacs-major-version 21)
7067 ;; XEmacs doesn't care.
7068 (set-keymap-parent map gnus-article-mode-map))
7069 (define-key map gnus-mouse-2 'gnus-button-prev-page)
7070 (define-key map "\r" 'gnus-button-prev-page)
7073 (defun gnus-insert-prev-page-button ()
7075 (buffer-read-only nil)
7076 (situation (get-text-property (point-min) 'mime-view-situation)))
7078 gnus-prev-page-line-format nil
7079 `(,@(gnus-local-map-property gnus-prev-page-map)
7081 gnus-callback gnus-article-button-prev-page
7082 article-type annotation
7083 mime-view-situation ,situation))
7084 (widget-convert-button
7086 ;; Exclude a newline.
7089 :action 'gnus-button-prev-page
7090 :button-keymap gnus-prev-page-map)))
7092 (defvar gnus-next-page-map
7093 (let ((map (make-sparse-keymap)))
7094 (unless (>= emacs-major-version 21)
7095 ;; XEmacs doesn't care.
7096 (set-keymap-parent map gnus-article-mode-map))
7097 (define-key map gnus-mouse-2 'gnus-button-next-page)
7098 (define-key map "\r" 'gnus-button-next-page)
7101 (defun gnus-button-next-page (&optional args more-args)
7102 "Go to the next page."
7104 (let ((win (selected-window)))
7105 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7106 (gnus-article-next-page)
7107 (select-window win)))
7109 (defun gnus-button-prev-page (&optional args more-args)
7110 "Go to the prev page."
7112 (let ((win (selected-window)))
7113 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7114 (gnus-article-prev-page)
7115 (select-window win)))
7117 (defun gnus-insert-next-page-button ()
7119 (buffer-read-only nil)
7120 (situation (get-text-property (point-min) 'mime-view-situation)))
7121 (gnus-eval-format gnus-next-page-line-format nil
7122 `(,@(gnus-local-map-property gnus-next-page-map)
7124 gnus-callback gnus-article-button-next-page
7125 article-type annotation
7126 mime-view-situation ,situation))
7127 (widget-convert-button
7129 ;; Exclude a newline.
7132 :action 'gnus-button-next-page
7133 :button-keymap gnus-next-page-map)))
7135 (defun gnus-article-button-next-page (arg)
7136 "Go to the next page."
7138 (let ((win (selected-window)))
7139 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7140 (gnus-article-next-page)
7141 (select-window win)))
7143 (defun gnus-article-button-prev-page (arg)
7144 "Go to the prev page."
7146 (let ((win (selected-window)))
7147 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7148 (gnus-article-prev-page)
7149 (select-window win)))
7151 (defvar gnus-decode-header-methods
7152 '(mail-decode-encoded-word-region)
7153 "List of methods used to decode headers.
7155 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7156 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
7157 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
7158 whose names match REGEXP.
7161 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7162 mail-decode-encoded-word-region
7163 (\"chinese\" . rfc1843-decode-region))
7166 (defvar gnus-decode-header-methods-cache nil)
7168 (defun gnus-multi-decode-header (start end)
7169 "Apply the functions from `gnus-encoded-word-methods' that match."
7170 (unless (and gnus-decode-header-methods-cache
7171 (eq gnus-newsgroup-name
7172 (car gnus-decode-header-methods-cache)))
7173 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7176 (nconc gnus-decode-header-methods-cache (list x))
7177 (if (and gnus-newsgroup-name
7178 (string-match (car x) gnus-newsgroup-name))
7179 (nconc gnus-decode-header-methods-cache
7181 gnus-decode-header-methods))
7182 (let ((xlist gnus-decode-header-methods-cache))
7185 (narrow-to-region start end)
7187 (funcall (pop xlist) (point-min) (point-max))))))
7190 ;;; Treatment top-level handling.
7193 (defun gnus-treat-article (condition &optional part-number total-parts type)
7194 (let ((length (- (point-max) (point-min)))
7195 (alist gnus-treatment-function-alist)
7196 (article-goto-body-goes-to-point-min-p t)
7200 (let ((list gnus-article-treat-types))
7202 (when (string-match (pop list) type)
7203 (throw 'found t)))))))
7204 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7205 (entity (static-unless (featurep 'xemacs)
7206 (when (eq 'head condition)
7207 (get-text-property (point-min) 'mime-view-entity))))
7208 val elem buttonized)
7209 (gnus-run-hooks 'gnus-part-display-hook)
7210 (unless gnus-inhibit-treatment
7211 (dolist (elem alist)
7214 (when (gnus-buffer-live-p gnus-summary-buffer)
7215 (set-buffer gnus-summary-buffer))
7216 (symbol-value (car elem))))
7217 (when (and (or (consp val)
7219 (gnus-treat-predicate val)
7220 (or (not (get (car elem) 'highlight))
7222 (when (and (not buttonized)
7224 '(gnus-treat-hide-signature
7225 gnus-treat-highlight-signature)))
7226 (gnus-article-buttonize-signature)
7227 (setq buttonized t))
7229 (funcall (cadr elem)))))
7230 ;; FSF Emacsen does not inherit the existing text properties
7231 ;; in the new text, so we should do it for `mime-view-entity'.
7232 (static-unless (featurep 'xemacs)
7234 (put-text-property (point-min) (point-max)
7235 'mime-view-entity entity))))))
7237 ;; Dynamic variables.
7239 (defvar part-number)
7240 (defvar total-parts)
7245 (defun gnus-treat-predicate (val)
7250 (stringp (car val)))
7251 (apply 'gnus-or (mapcar `(lambda (s)
7252 (string-match s ,(or gnus-newsgroup-name "")))
7255 (let ((pred (pop val)))
7258 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7260 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7262 (not (gnus-treat-predicate (car val))))
7264 (equal (car val) type))
7266 (error "%S is not a valid predicate" pred)))))
7276 (eq part-number total-parts))
7280 (error "%S is not a valid value" val))))
7282 (defun gnus-article-encrypt-body (protocol &optional n)
7283 "Encrypt the article body."
7286 (or gnus-article-encrypt-protocol
7287 (completing-read "Encrypt protocol: "
7288 gnus-article-encrypt-protocol-alist
7290 current-prefix-arg))
7291 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7293 (error (format "Can't find the encrypt protocol %s" protocol)))
7294 (if (member gnus-newsgroup-name '("nndraft:delayed"
7297 (error "Can't encrypt the article in group %s"
7298 gnus-newsgroup-name))
7299 (gnus-summary-iterate n
7301 (set-buffer gnus-summary-buffer)
7302 (let ((mail-parse-charset gnus-newsgroup-charset)
7303 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7304 (summary-buffer gnus-summary-buffer)
7306 (gnus-set-global-variables)
7307 (when (gnus-group-read-only-p)
7308 (error "The current newsgroup does not support article encrypt"))
7309 (gnus-summary-show-article t)
7311 (or (mail-header-references gnus-current-headers) ""))
7312 (set-buffer gnus-article-buffer)
7313 (let* ((buffer-read-only nil)
7315 (mapcar (lambda (field)
7316 (and (save-restriction
7317 (message-narrow-to-head)
7318 (goto-char (point-min))
7319 (search-forward field nil t))
7321 (message-narrow-to-field)
7323 (delete-region (point-min) (point-max))
7325 '("Content-Type:" "Content-Transfer-Encoding:"
7326 "Content-Disposition:"))))
7327 (message-narrow-to-head)
7328 (message-remove-header "MIME-Version")
7329 (goto-char (point-max))
7330 (setq point (point))
7331 (insert (apply 'concat headers))
7333 (narrow-to-region point (point-max))
7334 (let ((message-options message-options))
7335 (message-options-set 'message-sender user-mail-address)
7336 (message-options-set 'message-recipients user-mail-address)
7337 (message-options-set 'message-sign-encrypt 'not)
7339 (goto-char (point-min))
7340 (insert "MIME-Version: 1.0\n")
7342 (gnus-summary-edit-article-done
7343 references nil summary-buffer t))
7344 (when gnus-keep-backlog
7345 (gnus-backlog-remove-article
7346 (car gnus-article-current) (cdr gnus-article-current)))
7348 (when (get-buffer gnus-original-article-buffer)
7349 (set-buffer gnus-original-article-buffer)
7350 (setq gnus-original-article nil)))
7351 (when gnus-use-cache
7352 (gnus-cache-update-article
7353 (car gnus-article-current) (cdr gnus-article-current))))))))
7355 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7356 "The following specs can be used:
7357 %t The security MIME type
7360 %D Details if button is pressed")
7362 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7363 "The following specs can be used:
7364 %t The security MIME type
7367 %D Details if button is pressed")
7369 (defvar gnus-mime-security-button-line-format-alist
7370 '((?t gnus-tmp-type ?s)
7371 (?i gnus-tmp-info ?s)
7372 (?d gnus-tmp-details ?s)
7373 (?D gnus-tmp-pressed-details ?s)))
7375 (defvar gnus-mime-security-button-map
7376 (let ((map (make-sparse-keymap)))
7377 (unless (>= (string-to-number emacs-version) 21)
7378 (set-keymap-parent map gnus-article-mode-map))
7379 (define-key map gnus-mouse-2 'gnus-article-push-button)
7380 (define-key map "\r" 'gnus-article-press-button)
7383 (defvar gnus-mime-security-details-buffer nil)
7385 (defvar gnus-mime-security-button-pressed nil)
7387 (defvar gnus-mime-security-show-details-inline t
7388 "If non-nil, show details in the article buffer.")
7390 (defun gnus-mime-security-verify-or-decrypt (handle)
7391 (mm-remove-parts (cdr handle))
7392 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7393 point buffer-read-only)
7395 (goto-char (car region)))
7397 (narrow-to-region (point) (point))
7398 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7399 (let* ((mm-verify-option 'known)
7400 (mm-decrypt-option 'known)
7401 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7402 (unless (eq nparts (cdr handle))
7403 (mm-destroy-parts (cdr handle))
7404 (setcdr handle nparts))))
7405 (setq point (point))
7406 (gnus-mime-display-security handle)
7407 (goto-char (point-max)))
7409 (delete-region (point) (cdr region))
7410 (set-marker (car region) nil)
7411 (set-marker (cdr region) nil))
7414 (defun gnus-mime-security-show-details (handle)
7415 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7417 (gnus-message 5 "No details.")
7418 (if gnus-mime-security-show-details-inline
7419 (let ((gnus-mime-security-button-pressed
7420 (not (get-text-property (point) 'gnus-mime-details)))
7421 (gnus-mime-security-button-line-format
7422 (get-text-property (point) 'gnus-line-format))
7425 (while (eq (get-text-property (point) 'gnus-line-format)
7426 gnus-mime-security-button-line-format)
7430 (narrow-to-region (point) (point))
7431 (gnus-insert-mime-security-button handle))
7432 (delete-region (point)
7433 (or (text-property-not-all
7436 gnus-mime-security-button-line-format)
7439 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7440 (with-current-buffer gnus-mime-security-details-buffer
7443 (setq gnus-mime-security-details-buffer
7444 (gnus-get-buffer-create "*MIME Security Details*")))
7445 (with-current-buffer gnus-mime-security-details-buffer
7447 (goto-char (point-min)))
7448 (pop-to-buffer gnus-mime-security-details-buffer)))))
7450 (defun gnus-mime-security-press-button (handle)
7452 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7453 (gnus-mime-security-show-details handle)
7454 (gnus-mime-security-verify-or-decrypt handle))))
7456 (defun gnus-insert-mime-security-button (handle &optional displayed)
7457 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7460 (or (nth 2 (assoc protocol mm-verify-function-alist))
7461 (nth 2 (assoc protocol mm-decrypt-function-alist))
7463 (if (equal (car handle) "multipart/signed")
7464 " Signed" " Encrypted")
7467 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7470 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7471 gnus-tmp-pressed-details
7473 (setq gnus-tmp-details
7474 (if gnus-tmp-details
7475 (concat "\n" gnus-tmp-details)
7477 (setq gnus-tmp-pressed-details
7478 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7483 gnus-mime-security-button-line-format
7484 gnus-mime-security-button-line-format-alist
7485 `(,@(gnus-local-map-property gnus-mime-security-button-map)
7486 gnus-callback gnus-mime-security-press-button
7487 gnus-line-format ,gnus-mime-security-button-line-format
7488 gnus-mime-details ,gnus-mime-security-button-pressed
7489 article-type annotation
7492 ;; Exclude a newline.
7495 (widget-convert-button
7498 :action 'gnus-widget-press-button
7499 :button-keymap gnus-mime-security-button-map
7501 (lambda (widget/window &optional overlay pos)
7502 ;; Needed to properly clear the message due to a bug in
7503 ;; wid-edit (XEmacs only).
7504 (when (boundp 'help-echo-owns-message)
7505 (setq help-echo-owns-message t))
7508 (aref gnus-mouse-2 0))))))
7510 (defun gnus-mime-display-security (handle)
7512 (narrow-to-region (point) (point))
7513 (unless (gnus-unbuttonized-mime-type-p (car handle))
7514 (gnus-insert-mime-security-button handle))
7515 (gnus-mime-display-mixed (cdr handle))
7518 (unless (gnus-unbuttonized-mime-type-p (car handle))
7519 (let ((gnus-mime-security-button-line-format
7520 gnus-mime-security-button-end-line-format))
7521 (gnus-insert-mime-security-button handle)))
7522 (mm-set-handle-multipart-parameter
7524 (cons (set-marker (make-marker) (point-min))
7525 (set-marker (make-marker) (point-max))))))
7531 (defun gnus-article-header-presentation-method (entity situation)
7532 (mime-insert-header entity)
7533 (article-decode-group-name))
7535 (set-alist 'mime-header-presentation-method-alist
7536 'gnus-original-article-mode
7537 #'gnus-article-header-presentation-method)
7539 (defun gnus-mime-preview-quitting-method ()
7540 (mime-preview-kill-buffer)
7541 (delete-other-windows)
7542 (gnus-article-show-summary)
7543 (gnus-summary-select-article gnus-show-all-headers t))
7545 (set-alist 'mime-preview-quitting-method-alist
7546 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
7548 (set-alist 'mime-preview-following-method-alist
7549 'gnus-original-article-mode #'gnus-following-method)
7551 (set-alist 'mime-preview-over-to-previous-method-alist
7552 'gnus-original-article-mode
7554 (if (> (point-min) 1)
7555 (gnus-article-prev-page)
7556 (gnus-article-read-summary-keys
7557 nil (gnus-character-to-event ?P)))))
7559 (set-alist 'mime-preview-over-to-next-method-alist
7560 'gnus-original-article-mode'
7562 (if (< (point-max) (buffer-size))
7563 (gnus-article-next-page)
7564 (gnus-article-read-summary-keys
7565 nil (gnus-character-to-event ?N)))))
7575 (run-hooks 'gnus-art-load-hook)
7577 ;;; gnus-art.el ends here