1 ;;; gnus-art.el --- article mode commands for Semi-gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
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))
44 (when (static-if (featurep 'xemacs)
45 (console-on-window-system-p)
47 (require 'mime-image))
50 ;; Avoid byte-compile warnings.
60 (autoload 'gnus-msg-mail "gnus-msg" nil t)
61 (autoload 'gnus-button-mailto "gnus-msg")
62 (autoload 'gnus-button-reply "gnus-msg" nil t)
63 (autoload 'ansi-color-apply-on-region "ansi-color")
65 (defgroup gnus-article nil
67 :link '(custom-manual "(gnus)Article Buffer")
70 (defgroup gnus-article-treat nil
71 "Treating article parts."
72 :link '(custom-manual "(gnus)Article Hiding")
75 (defgroup gnus-article-hiding nil
76 "Hiding article parts."
77 :link '(custom-manual "(gnus)Article Hiding")
80 (defgroup gnus-article-highlight nil
81 "Article highlighting."
82 :link '(custom-manual "(gnus)Article Highlighting")
86 (defgroup gnus-article-signature nil
88 :link '(custom-manual "(gnus)Article Signature")
91 (defgroup gnus-article-headers nil
93 :link '(custom-manual "(gnus)Hiding Headers")
96 (defgroup gnus-article-washing nil
97 "Special commands on articles."
98 :link '(custom-manual "(gnus)Article Washing")
101 (defgroup gnus-article-emphasis nil
102 "Fontisizing articles."
103 :link '(custom-manual "(gnus)Article Fontisizing")
104 :group 'gnus-article)
106 (defgroup gnus-article-saving nil
108 :link '(custom-manual "(gnus)Saving Articles")
109 :group 'gnus-article)
111 (defgroup gnus-article-mime nil
112 "Worshiping the MIME wonder."
113 :link '(custom-manual "(gnus)Using MIME")
114 :group 'gnus-article)
116 (defgroup gnus-article-buttons nil
117 "Pushable buttons in the article buffer."
118 :link '(custom-manual "(gnus)Article Buttons")
119 :group 'gnus-article)
121 (defgroup gnus-article-various nil
122 "Other article options."
123 :link '(custom-manual "(gnus)Misc Article")
124 :group 'gnus-article)
126 (defcustom gnus-ignored-headers
129 (concat "^" header ":"))
130 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
131 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
132 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
133 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
134 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
135 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
136 "X-Attribution" "X-Originating-IP" "Delivered-To"
137 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
138 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
139 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
140 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
141 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
142 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
143 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
144 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
145 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
146 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
147 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
148 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
149 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
150 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
151 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
152 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
153 "List-[A-Za-z]+" "X-Listprocessor-Version"
154 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
155 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
156 "X-Received" "Content-length" "X-precedence"
157 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
158 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
159 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
160 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
161 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
162 "X-Content-length" "X-Posting-Agent" "Original-Received"
163 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
164 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
165 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
166 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
167 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"))
168 "*All headers that start with this regexp will be hidden.
169 This variable can also be a list of regexps of headers to be ignored.
170 If `gnus-visible-headers' is non-nil, this variable will be ignored."
171 :type '(choice :custom-show nil
174 :group 'gnus-article-hiding)
176 (defcustom gnus-visible-headers
177 "^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:"
178 "*All headers that do not match this regexp will be hidden.
179 This variable can also be a list of regexp of headers to remain visible.
180 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
181 :type '(repeat :value-to-internal (lambda (widget value)
182 (custom-split-regexp-maybe value))
183 :match (lambda (widget value)
185 (widget-editable-list-match widget value)))
187 :group 'gnus-article-hiding)
189 (defcustom gnus-sorted-header-list
190 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
191 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
192 "*This variable is a list of regular expressions.
193 If it is non-nil, headers that match the regular expressions will
194 be placed first in the article buffer in the sequence specified by
196 :type '(repeat regexp)
197 :group 'gnus-article-hiding)
199 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
200 "Headers that are only to be displayed if they have interesting data.
201 Possible values in this list are:
203 'empty Headers with no content.
204 'newsgroups Newsgroup identical to Gnus group.
205 'to-address To identical to To-address.
206 'to-list To identical to To-list.
207 'cc-list CC identical to To-list.
208 'followup-to Followup-to identical to Newsgroups.
209 'reply-to Reply-to identical to From.
210 'date Date less than four days old.
211 'long-to To and/or Cc longer than 1024 characters.
212 'many-to Multiple To and/or Cc."
213 :type '(set (const :tag "Headers with no content." empty)
214 (const :tag "Newsgroups identical to Gnus group." newsgroups)
215 (const :tag "To identical to To-address." to-address)
216 (const :tag "To identical to To-list." to-list)
217 (const :tag "CC identical to To-list." cc-list)
218 (const :tag "Followup-to identical to Newsgroups." followup-to)
219 (const :tag "Reply-to identical to From." reply-to)
220 (const :tag "Date less than four days old." date)
221 (const :tag "To and/or Cc longer than 1024 characters." long-to)
222 (const :tag "Multiple To and/or Cc headers." many-to))
223 :group 'gnus-article-hiding)
225 (defcustom gnus-article-skip-boring nil
226 "Skip over text that is not worth reading.
227 By default, if you set this t, then Gnus will display citations and
228 signatures, but will never scroll down to show you a page consisting
229 only of boring text. Boring text is controlled by
230 `gnus-article-boring-faces'."
232 :group 'gnus-article-hiding)
234 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
235 "Regexp matching signature separator.
236 This can also be a list of regexps. In that case, it will be checked
237 from head to tail looking for a separator. Searches will be done from
238 the end of the buffer."
239 :type '(repeat string)
240 :group 'gnus-article-signature)
242 (defcustom gnus-signature-limit nil
243 "Provide a limit to what is considered a signature.
244 If it is a number, no signature may not be longer (in characters) than
245 that number. If it is a floating point number, no signature may be
246 longer (in lines) than that number. If it is a function, the function
247 will be called without any parameters, and if it returns nil, there is
248 no signature in the buffer. If it is a string, it will be used as a
249 regexp. If it matches, the text in question is not a signature.
251 This can also be a list of the above values."
252 :type '(choice (integer :value 200)
254 (function :value fun)
255 (regexp :value ".*"))
256 :group 'gnus-article-signature)
258 (defcustom gnus-hidden-properties '(invisible t intangible t)
259 "Property list to use for hiding text."
261 :group 'gnus-article-hiding)
263 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
264 ;; frames in a session.
265 (defcustom gnus-article-x-face-command
270 (if (or (gnus-image-type-available-p 'xface)
271 (gnus-image-type-available-p 'pbm))
272 'gnus-display-x-face-in-from
273 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -"))
274 ((and (fboundp 'image-type-available-p)
275 (module-installed-p 'x-face-e21))
276 'x-face-decode-message-header)
277 ((gnus-image-type-available-p 'pbm)
278 'gnus-display-x-face-in-from)
280 (module-installed-p 'x-face-mule))
281 'x-face-mule-gnus-article-display-x-face)
283 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
285 "*String or function to be executed to display an X-Face header.
286 If it is a string, the command will be executed in a sub-shell
287 asynchronously. The compressed face will be piped to this command."
289 ,@(let (x-face-e21 x-face-mule)
290 (if (featurep 'xemacs)
292 (setq x-face-e21 (module-installed-p 'x-face-e21)
293 x-face-mule (module-installed-p 'x-face-mule)))
297 (if (or (gnus-image-type-available-p 'xface)
298 (gnus-image-type-available-p 'pbm))
299 '(function-item gnus-display-x-face-in-from))
301 (fboundp 'image-type-available-p))
303 :tag "x-face-decode-message-header (x-face-e21)"
304 x-face-decode-message-header))
307 x-face-mule-gnus-article-display-x-face))
311 :group 'gnus-article-washing)
313 (defcustom gnus-article-x-face-too-ugly nil
314 "Regexp matching posters whose face shouldn't be shown automatically."
315 :type '(choice regexp (const nil))
316 :group 'gnus-article-washing)
318 (defcustom gnus-article-banner-alist nil
319 "Banner alist for stripping.
321 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
323 :type '(repeat (cons symbol regexp))
324 :group 'gnus-article-washing)
326 (gnus-define-group-parameter
329 "Alist of regexps (to match group names) and banner."
330 :variable-group gnus-article-washing
332 '(choice :tag "Banner"
334 (const :tag "Remove signature" signature)
335 (symbol :tag "Item in `gnus-article-banner-alist'" none)
337 (const :tag "None" nil))
339 "If non-nil, specify how to remove `banners' from articles.
341 Symbol `signature' means to remove signatures delimited by
342 `gnus-signature-separator'. Any other symbol is used to look up a
343 regular expression to match the banner in `gnus-article-banner-alist'.
344 A string is used as a regular expression to match the banner
347 (defcustom gnus-article-address-banner-alist nil
348 "Alist of mail addresses and banners.
349 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
350 to match a mail address in the From: header, BANNER is one of a symbol
351 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
352 If ADDRESS matches author's mail address, it will remove things like
353 advertisements. For example:
355 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
359 (regexp :tag "Address")
360 (choice :tag "Banner" :value nil
361 (const :tag "Remove signature" signature)
362 (symbol :tag "Item in `gnus-article-banner-alist'" none)
364 (const :tag "None" nil))))
365 :group 'gnus-article-washing)
367 (defcustom gnus-emphasis-alist
369 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
374 ("_/" "/_" underline-italic)
375 ("_\\*" "\\*_" underline-bold)
376 ("\\*/" "/\\*" bold-italic)
377 ("_\\*/" "/\\*_" underline-bold-italic))))
381 (format format (car spec) (car (cdr spec)))
382 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
384 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
385 2 3 gnus-emphasis-underline)))
386 "*Alist that says how to fontify certain phrases.
387 Each item looks like this:
389 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
391 The first element is a regular expression to be matched. The second
392 is a number that says what regular expression grouping used to find
393 the entire emphasized word. The third is a number that says what
394 regexp grouping should be displayed and highlighted. The fourth
395 is the face used for highlighting."
396 :type '(repeat (list :value ("" 0 0 default)
398 (integer :tag "Match group")
399 (integer :tag "Emphasize group")
401 :group 'gnus-article-emphasis)
403 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
404 "A regexp to describe whitespace which should not be emphasized.
405 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
406 The former avoids underlining of leading and trailing whitespace,
407 and the latter avoids underlining any whitespace at all."
409 :group 'gnus-article-emphasis
412 (defface gnus-emphasis-bold '((t (:bold t)))
413 "Face used for displaying strong emphasized text (*word*)."
414 :group 'gnus-article-emphasis)
416 (defface gnus-emphasis-italic '((t (:italic t)))
417 "Face used for displaying italic emphasized text (/word/)."
418 :group 'gnus-article-emphasis)
420 (defface gnus-emphasis-underline '((t (:underline t)))
421 "Face used for displaying underlined emphasized text (_word_)."
422 :group 'gnus-article-emphasis)
424 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
425 "Face used for displaying underlined bold emphasized text (_*word*_)."
426 :group 'gnus-article-emphasis)
428 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
429 "Face used for displaying underlined italic emphasized text (_/word/_)."
430 :group 'gnus-article-emphasis)
432 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
433 "Face used for displaying bold italic emphasized text (/*word*/)."
434 :group 'gnus-article-emphasis)
436 (defface gnus-emphasis-underline-bold-italic
437 '((t (:bold t :italic t :underline t)))
438 "Face used for displaying underlined bold italic emphasized text.
439 Example: (_/*word*/_)."
440 :group 'gnus-article-emphasis)
442 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
443 '((t (:strikethru t)))
444 '((t (:strike-through t))))
445 "Face used for displaying strike-through text (-word-)."
446 :group 'gnus-article-emphasis)
448 (defface gnus-emphasis-highlight-words
449 '((t (:background "black" :foreground "yellow")))
450 "Face used for displaying highlighted words."
451 :group 'gnus-article-emphasis)
453 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
454 "Format for display of Date headers in article bodies.
455 See `format-time-string' for the possible values.
457 The variable can also be function, which should return a complete Date
458 header. The function is called with one argument, the time, which can
459 be fed to `format-time-string'."
460 :type '(choice string symbol)
461 :link '(custom-manual "(gnus)Article Date")
462 :group 'gnus-article-washing)
465 (autoload 'mail-extract-address-components "mail-extr"))
467 (defcustom gnus-save-all-headers t
468 "*If non-nil, don't remove any headers before saving."
469 :group 'gnus-article-saving
472 (defcustom gnus-prompt-before-saving 'always
473 "*This variable says how much prompting is to be done when saving articles.
474 If it is nil, no prompting will be done, and the articles will be
475 saved to the default files. If this variable is `always', each and
476 every article that is saved will be preceded by a prompt, even when
477 saving large batches of articles. If this variable is neither nil not
478 `always', there the user will be prompted once for a file name for
479 each invocation of the saving commands."
480 :group 'gnus-article-saving
481 :type '(choice (item always)
482 (item :tag "never" nil)
483 (sexp :tag "once" :format "%t\n" :value t)))
485 (defcustom gnus-saved-headers gnus-visible-headers
486 "Headers to keep if `gnus-save-all-headers' is nil.
487 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
488 If that variable is nil, however, all headers that match this regexp
489 will be kept while the rest will be deleted before saving."
490 :group 'gnus-article-saving
493 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
494 "A function to save articles in your favourite format.
495 The function must be interactively callable (in other words, it must
496 be an Emacs command).
498 Gnus provides the following functions:
500 * gnus-summary-save-in-rmail (Rmail format)
501 * gnus-summary-save-in-mail (Unix mail format)
502 * gnus-summary-save-in-folder (MH folder)
503 * gnus-summary-save-in-file (article format)
504 * gnus-summary-save-body-in-file (article body)
505 * gnus-summary-save-in-vm (use VM's folder format)
506 * gnus-summary-write-to-file (article format -- overwrite)."
507 :group 'gnus-article-saving
508 :type '(radio (function-item gnus-summary-save-in-rmail)
509 (function-item gnus-summary-save-in-mail)
510 (function-item gnus-summary-save-in-folder)
511 (function-item gnus-summary-save-in-file)
512 (function-item gnus-summary-save-body-in-file)
513 (function-item gnus-summary-save-in-vm)
514 (function-item gnus-summary-write-to-file)))
516 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
517 "A function generating a file name to save articles in Rmail format.
518 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
519 :group 'gnus-article-saving
522 (defcustom gnus-mail-save-name 'gnus-plain-save-name
523 "A function generating a file name to save articles in Unix mail format.
524 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
525 :group 'gnus-article-saving
528 (defcustom gnus-folder-save-name 'gnus-folder-save-name
529 "A function generating a file name to save articles in MH folder.
530 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
531 :group 'gnus-article-saving
534 (defcustom gnus-file-save-name 'gnus-numeric-save-name
535 "A function generating a file name to save articles in article format.
536 The function is called with NEWSGROUP, HEADERS, and optional
538 :group 'gnus-article-saving
541 (defcustom gnus-split-methods
542 '((gnus-article-archive-name)
543 (gnus-article-nndoc-name))
544 "*Variable used to suggest where articles are to be saved.
545 For instance, if you would like to save articles related to Gnus in
546 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
547 you could set this variable to something like:
549 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
550 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
552 This variable is an alist where the where the key is the match and the
553 value is a list of possible files to save in if the match is non-nil.
555 If the match is a string, it is used as a regexp match on the
556 article. If the match is a symbol, that symbol will be funcalled
557 from the buffer of the article to be saved with the newsgroup as the
558 parameter. If it is a list, it will be evaled in the same buffer.
560 If this form or function returns a string, this string will be used as
561 a possible file name; and if it returns a non-nil list, that list will
562 be used as possible file names."
563 :group 'gnus-article-saving
564 :type '(repeat (choice (list :value (fun) function)
565 (cons :value ("" "") regexp (repeat string))
568 (defcustom gnus-article-display-method-for-mime
569 'gnus-article-display-mime-message
570 "Function to display a MIME message.
571 The function is called from the article buffer."
572 :group 'gnus-article-mime
575 (defcustom gnus-article-display-method-for-traditional
576 'gnus-article-display-traditional-message
577 "*Function to display a traditional message.
578 The function is called from the article buffer."
579 :group 'gnus-article-mime
582 (defcustom gnus-page-delimiter "^\^L"
583 "*Regexp describing what to use as article page delimiters.
584 The default value is \"^\^L\", which is a form linefeed at the
585 beginning of a line."
587 :group 'gnus-article-various)
589 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
590 "*The format specification for the article mode line.
591 See `gnus-summary-mode-line-format' for a closer description.
593 The following additional specs are available:
595 %w The article washing status.
596 %m The number of MIME parts in the article."
598 :group 'gnus-article-various)
600 (defcustom gnus-article-mode-hook nil
601 "*A hook for Gnus article mode."
603 :group 'gnus-article-various)
605 (when (featurep 'xemacs)
606 ;; Extracted from gnus-xmas-define in order to preserve user settings
607 (when (fboundp 'turn-off-scroll-in-place)
608 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
609 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
610 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
612 (defcustom gnus-article-menu-hook nil
613 "*Hook run after the creation of the article mode menu."
615 :group 'gnus-article-various)
617 (defcustom gnus-article-prepare-hook nil
618 "*A hook called after an article has been prepared in the article buffer."
620 :group 'gnus-article-various)
622 (make-obsolete-variable 'gnus-article-hide-pgp-hook
623 "This variable is obsolete in Gnus 5.10.")
625 (defcustom gnus-article-button-face 'bold
626 "Face used for highlighting buttons in the article buffer.
628 An article button is a piece of text that you can activate by pressing
629 `RET' or `mouse-2' above it."
631 :group 'gnus-article-buttons)
633 (defcustom gnus-article-mouse-face 'highlight
634 "Face used for mouse highlighting in the article buffer.
636 Article buttons will be displayed in this face when the cursor is
639 :group 'gnus-article-buttons)
641 (defcustom gnus-signature-face 'gnus-signature-face
642 "Face used for highlighting a signature in the article buffer.
643 Obsolete; use the face `gnus-signature-face' for customizations instead."
645 :group 'gnus-article-highlight
646 :group 'gnus-article-signature)
648 (defface gnus-signature-face
651 "Face used for highlighting a signature in the article buffer."
652 :group 'gnus-article-highlight
653 :group 'gnus-article-signature)
655 (defface gnus-header-from-face
658 (:foreground "spring green"))
661 (:foreground "red3"))
664 "Face used for displaying from headers."
665 :group 'gnus-article-headers
666 :group 'gnus-article-highlight)
668 (defface gnus-header-subject-face
671 (:foreground "SeaGreen3"))
674 (:foreground "red4"))
676 (:bold t :italic t)))
677 "Face used for displaying subject headers."
678 :group 'gnus-article-headers
679 :group 'gnus-article-highlight)
681 (defface gnus-header-newsgroups-face
684 (:foreground "yellow" :italic t))
687 (:foreground "MidnightBlue" :italic t))
690 "Face used for displaying newsgroups headers.
691 In the default setup this face is only used for crossposted
693 :group 'gnus-article-headers
694 :group 'gnus-article-highlight)
696 (defface gnus-header-name-face
699 (:foreground "SeaGreen"))
702 (:foreground "maroon"))
705 "Face used for displaying header names."
706 :group 'gnus-article-headers
707 :group 'gnus-article-highlight)
709 (defface gnus-header-content-face
712 (:foreground "forest green" :italic t))
715 (:foreground "indianred4" :italic t))
718 "Face used for displaying header content."
719 :group 'gnus-article-headers
720 :group 'gnus-article-highlight)
722 (defcustom gnus-header-face-alist
723 '(("From" nil gnus-header-from-face)
724 ("Subject" nil gnus-header-subject-face)
725 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
726 ("" gnus-header-name-face gnus-header-content-face))
727 "*Controls highlighting of article headers.
729 An alist of the form (HEADER NAME CONTENT).
731 HEADER is a regular expression which should match the name of a
732 header and NAME and CONTENT are either face names or nil.
734 The name of each header field will be displayed using the face
735 specified by the first element in the list where HEADER matches
736 the header name and NAME is non-nil. Similarly, the content will
737 be displayed by the first non-nil matching CONTENT face."
738 :group 'gnus-article-headers
739 :group 'gnus-article-highlight
740 :type '(repeat (list (regexp :tag "Header")
742 (item :tag "skip" nil)
743 (face :value default))
744 (choice :tag "Content"
745 (item :tag "skip" nil)
746 (face :value default)))))
748 (defcustom gnus-article-decode-hook
749 '(article-decode-group-name article-decode-idna-rhs)
750 "*Hook run to decode charsets in articles."
751 :group 'gnus-article-headers
754 (defcustom gnus-display-mime-function 'gnus-display-mime
755 "Function to display MIME articles."
756 :group 'gnus-article-mime
759 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
760 "Function used to decode headers.")
762 (defvar gnus-article-dumbquotes-map
782 "Table for MS-to-Latin1 translation.")
784 (defcustom gnus-ignored-mime-types nil
785 "List of MIME types that should be ignored by Gnus."
787 :group 'gnus-article-mime
788 :type '(repeat regexp))
790 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
791 "List of MIME types that should not be given buttons when rendered inline.
792 See also `gnus-buttonized-mime-types' which may override this variable.
793 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
795 :group 'gnus-article-mime
796 :type '(repeat regexp))
798 (defcustom gnus-buttonized-mime-types nil
799 "List of MIME types that should be given buttons when rendered inline.
800 If set, this variable overrides `gnus-unbuttonized-mime-types'.
801 To see e.g. security buttons you could set this to
802 `(\"multipart/signed\")'.
803 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
805 :group 'gnus-article-mime
806 :type '(repeat regexp))
808 (defcustom gnus-inhibit-mime-unbuttonizing nil
809 "If non-nil, all MIME parts get buttons.
810 When nil (the default value), then some MIME parts do not get buttons,
811 as described by the variables `gnus-buttonized-mime-types' and
812 `gnus-unbuttonized-mime-types'."
814 :group 'gnus-article-mime
817 (defcustom gnus-body-boundary-delimiter "_"
818 "String used to delimit header and body.
819 This variable is used by `gnus-article-treat-body-boundary' which can
820 be controlled by `gnus-treat-body-boundary'."
821 :group 'gnus-article-various
822 :type '(choice (item :tag "None" :value nil)
825 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
827 "Defines the location of the faces database.
828 For information on obtaining this database of pretty pictures, please
829 see http://www.cs.indiana.edu/picons/ftp/index.html"
830 :type '(repeat directory)
831 :link '(url-link :tag "download"
832 "http://www.cs.indiana.edu/picons/ftp/index.html")
833 :link '(custom-manual "(gnus)Picons")
836 (defun gnus-picons-installed-p ()
837 "Say whether picons are installed on your machine."
838 (let ((installed nil))
839 (dolist (database gnus-picon-databases)
840 (when (file-exists-p database)
844 (defcustom gnus-article-mime-part-function nil
845 "Function called with a MIME handle as the argument.
846 This is meant for people who want to do something automatic based
847 on parts -- for instance, adding Vcard info to a database."
848 :group 'gnus-article-mime
851 (defcustom gnus-mime-multipart-functions nil
852 "An alist of MIME types to functions to display them."
854 :group 'gnus-article-mime
855 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
857 (defcustom gnus-article-date-lapsed-new-header nil
858 "Whether the X-Sent and Date headers can coexist.
859 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
860 either replace the old \"Date:\" header (if this variable is nil), or
861 be added below it (otherwise)."
863 :group 'gnus-article-headers
866 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
867 "Function called with a MIME handle as the argument.
868 This is meant for people who want to view first matched part.
869 For `undisplayed-alternative' (default), the first undisplayed
870 part or alternative part is used. For `undisplayed', the first
871 undisplayed part is used. For a function, the first part which
872 the function return t is used. For nil, the first part is
875 :group 'gnus-article-mime
877 (item :tag "first" :value nil)
878 (item :tag "undisplayed" :value undisplayed)
879 (item :tag "undisplayed or alternative"
880 :value undisplayed-alternative)
883 (defcustom gnus-mime-action-alist
884 '(("save to file" . gnus-mime-save-part)
885 ("save and strip" . gnus-mime-save-part-and-strip)
886 ("delete part" . gnus-mime-delete-part)
887 ("display as text" . gnus-mime-inline-part)
888 ("view the part" . gnus-mime-view-part)
889 ("pipe to command" . gnus-mime-pipe-part)
890 ("toggle display" . gnus-article-press-button)
891 ("toggle display" . gnus-article-view-part-as-charset)
892 ("view as type" . gnus-mime-view-part-as-type)
893 ("view internally" . gnus-mime-view-part-internally)
894 ("view externally" . gnus-mime-view-part-externally))
895 "An alist of actions that run on the MIME attachment."
896 :group 'gnus-article-mime
897 :type '(repeat (cons (string :tag "name")
901 ;;; The treatment variables
904 (defvar gnus-part-display-hook nil
905 "Hook called on parts that are to receive treatment.")
907 (defvar gnus-article-treat-custom
908 '(choice (const :tag "Off" nil)
910 (const :tag "Header" head)
911 (const :tag "Last" last)
912 (const :tag "Mime" mime)
913 (integer :tag "Less")
914 (repeat :tag "Groups" regexp)
915 (sexp :tag "Predicate")))
917 (defvar gnus-article-treat-head-custom
918 '(choice (const :tag "Off" nil)
919 (const :tag "Header" head)))
921 (defvar gnus-article-treat-types '("text/plain")
924 (defvar gnus-inhibit-treatment nil
925 "Whether to inhibit treatment.")
927 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
928 "Highlight the signature.
929 Valid values are nil, t, `head', `last', an integer or a predicate.
930 See Info node `(gnus)Customizing Articles'."
931 :group 'gnus-article-treat
932 :link '(custom-manual "(gnus)Customizing Articles")
933 :type gnus-article-treat-custom)
934 (put 'gnus-treat-highlight-signature 'highlight t)
936 (defcustom gnus-treat-buttonize 100000
938 Valid values are nil, t, `head', `last', an integer or a predicate.
939 See Info node `(gnus)Customizing Articles'."
940 :group 'gnus-article-treat
941 :link '(custom-manual "(gnus)Customizing Articles")
942 :type gnus-article-treat-custom)
943 (put 'gnus-treat-buttonize 'highlight t)
945 (defcustom gnus-treat-buttonize-head 'head
946 "Add buttons to the head.
947 Valid values are nil, t, `head', `last', an integer or a predicate.
948 See Info node `(gnus)Customizing Articles' for details."
949 :group 'gnus-article-treat
950 :link '(custom-manual "(gnus)Customizing Articles")
951 :type gnus-article-treat-head-custom)
952 (put 'gnus-treat-buttonize-head 'highlight t)
954 (defcustom gnus-treat-emphasize
955 (and (or window-system
959 Valid values are nil, t, `head', `last', an integer or a predicate.
960 See Info node `(gnus)Customizing Articles' for details."
961 :group 'gnus-article-treat
962 :link '(custom-manual "(gnus)Customizing Articles")
963 :type gnus-article-treat-custom)
964 (put 'gnus-treat-emphasize 'highlight t)
966 (defcustom gnus-treat-strip-cr nil
967 "Remove carriage returns.
968 Valid values are nil, t, `head', `last', an integer or a predicate.
969 See Info node `(gnus)Customizing Articles' for details."
970 :group 'gnus-article-treat
971 :link '(custom-manual "(gnus)Customizing Articles")
972 :type gnus-article-treat-custom)
974 (defcustom gnus-treat-unsplit-urls nil
975 "Remove newlines from within URLs.
976 Valid values are nil, t, `head', `last', an integer or a predicate.
977 See Info node `(gnus)Customizing Articles' for details."
978 :group 'gnus-article-treat
979 :link '(custom-manual "(gnus)Customizing Articles")
980 :type gnus-article-treat-custom)
982 (defcustom gnus-treat-leading-whitespace nil
983 "Remove leading whitespace in headers.
984 Valid values are nil, t, `head', `last', an integer or a predicate.
985 See Info node `(gnus)Customizing Articles' for details."
986 :group 'gnus-article-treat
987 :link '(custom-manual "(gnus)Customizing Articles")
988 :type gnus-article-treat-custom)
990 (defcustom gnus-treat-hide-headers 'head
992 Valid values are nil, t, `head', `last', an integer or a predicate.
993 See Info node `(gnus)Customizing Articles' for details."
994 :group 'gnus-article-treat
995 :link '(custom-manual "(gnus)Customizing Articles")
996 :type gnus-article-treat-head-custom)
998 (defcustom gnus-treat-hide-boring-headers nil
999 "Hide boring headers.
1000 Valid values are nil, t, `head', `last', an integer or a predicate.
1001 See Info node `(gnus)Customizing Articles' for details."
1002 :group 'gnus-article-treat
1003 :link '(custom-manual "(gnus)Customizing Articles")
1004 :type gnus-article-treat-head-custom)
1006 (defcustom gnus-treat-hide-signature nil
1007 "Hide the signature.
1008 Valid values are nil, t, `head', `last', an integer or a predicate.
1009 See Info node `(gnus)Customizing Articles' for details."
1010 :group 'gnus-article-treat
1011 :link '(custom-manual "(gnus)Customizing Articles")
1012 :type gnus-article-treat-custom)
1014 (defcustom gnus-treat-fill-article nil
1016 Valid values are nil, t, `head', `last', an integer or a predicate.
1017 See Info node `(gnus)Customizing Articles' for details."
1018 :group 'gnus-article-treat
1019 :link '(custom-manual "(gnus)Customizing Articles")
1020 :type gnus-article-treat-custom)
1022 (defcustom gnus-treat-hide-citation nil
1024 Valid values are nil, t, `head', `last', an integer or a predicate.
1025 See Info node `(gnus)Customizing Articles' for details."
1026 :group 'gnus-article-treat
1027 :link '(custom-manual "(gnus)Customizing Articles")
1028 :type gnus-article-treat-custom)
1030 (defcustom gnus-treat-hide-citation-maybe nil
1032 Valid values are nil, t, `head', `last', an integer or a predicate.
1033 See Info node `(gnus)Customizing Articles' for details."
1034 :group 'gnus-article-treat
1035 :link '(custom-manual "(gnus)Customizing Articles")
1036 :type gnus-article-treat-custom)
1038 (defcustom gnus-treat-strip-list-identifiers 'head
1039 "Strip list identifiers from `gnus-list-identifiers`.
1040 Valid values are nil, t, `head', `last', an integer or a predicate.
1041 See Info node `(gnus)Customizing Articles' for details."
1043 :group 'gnus-article-treat
1044 :link '(custom-manual "(gnus)Customizing Articles")
1045 :type gnus-article-treat-custom)
1047 (make-obsolete-variable 'gnus-treat-strip-pgp
1048 "This option is obsolete in Gnus 5.10.")
1050 (defcustom gnus-treat-strip-pem nil
1051 "Strip PEM signatures.
1052 Valid values are nil, t, `head', `last', an integer or a predicate.
1053 See Info node `(gnus)Customizing Articles' for details."
1054 :group 'gnus-article-treat
1055 :link '(custom-manual "(gnus)Customizing Articles")
1056 :type gnus-article-treat-custom)
1058 (defcustom gnus-treat-strip-banner t
1059 "Strip banners from articles.
1060 The banner to be stripped is specified in the `banner' group parameter.
1061 Valid values are nil, t, `head', `last', an integer or a predicate.
1062 See Info node `(gnus)Customizing Articles' for details."
1063 :group 'gnus-article-treat
1064 :link '(custom-manual "(gnus)Customizing Articles")
1065 :type gnus-article-treat-custom)
1067 (defcustom gnus-treat-highlight-headers 'head
1068 "Highlight the headers.
1069 Valid values are nil, t, `head', `last', an integer or a predicate.
1070 See Info node `(gnus)Customizing Articles' for details."
1071 :group 'gnus-article-treat
1072 :link '(custom-manual "(gnus)Customizing Articles")
1073 :type gnus-article-treat-head-custom)
1074 (put 'gnus-treat-highlight-headers 'highlight t)
1076 (defcustom gnus-treat-highlight-citation t
1077 "Highlight cited text.
1078 Valid values are nil, t, `head', `last', an integer or a predicate.
1079 See Info node `(gnus)Customizing Articles' for details."
1080 :group 'gnus-article-treat
1081 :link '(custom-manual "(gnus)Customizing Articles")
1082 :type gnus-article-treat-custom)
1083 (put 'gnus-treat-highlight-citation 'highlight t)
1085 (defcustom gnus-treat-date-ut nil
1086 "Display the Date in UT (GMT).
1087 Valid values are nil, t, `head', `last', an integer or a predicate.
1088 See Info node `(gnus)Customizing Articles' for details."
1089 :group 'gnus-article-treat
1090 :link '(custom-manual "(gnus)Customizing Articles")
1091 :type gnus-article-treat-head-custom)
1093 (defcustom gnus-treat-date-local nil
1094 "Display the Date in the local timezone.
1095 Valid values are nil, t, `head', `last', an integer or a predicate.
1096 See Info node `(gnus)Customizing Articles' for details."
1097 :group 'gnus-article-treat
1098 :link '(custom-manual "(gnus)Customizing Articles")
1099 :type gnus-article-treat-head-custom)
1101 (defcustom gnus-treat-date-english nil
1102 "Display the Date in a format that can be read aloud in English.
1103 Valid values are nil, t, `head', `last', an integer or a predicate.
1104 See Info node `(gnus)Customizing Articles' for details."
1105 :group 'gnus-article-treat
1106 :link '(custom-manual "(gnus)Customizing Articles")
1107 :type gnus-article-treat-head-custom)
1109 (defcustom gnus-treat-date-lapsed nil
1110 "Display the Date header in a way that says how much time has elapsed.
1111 Valid values are nil, t, `head', `last', an integer or a predicate.
1112 See Info node `(gnus)Customizing Articles' for details."
1113 :group 'gnus-article-treat
1114 :link '(custom-manual "(gnus)Customizing Articles")
1115 :type gnus-article-treat-head-custom)
1117 (defcustom gnus-treat-date-original nil
1118 "Display the date in the original timezone.
1119 Valid values are nil, t, `head', `last', an integer or a predicate.
1120 See Info node `(gnus)Customizing Articles' for details."
1121 :group 'gnus-article-treat
1122 :link '(custom-manual "(gnus)Customizing Articles")
1123 :type gnus-article-treat-head-custom)
1125 (defcustom gnus-treat-date-iso8601 nil
1126 "Display the date in the ISO8601 format.
1127 Valid values are nil, t, `head', `last', an integer or a predicate.
1128 See Info node `(gnus)Customizing Articles' for details."
1130 :group 'gnus-article-treat
1131 :link '(custom-manual "(gnus)Customizing Articles")
1132 :type gnus-article-treat-head-custom)
1134 (defcustom gnus-treat-date-user-defined nil
1135 "Display the date in a user-defined format.
1136 The format is defined by the `gnus-article-time-format' variable.
1137 Valid values are nil, t, `head', `last', an integer or a predicate.
1138 See Info node `(gnus)Customizing Articles' for details."
1139 :group 'gnus-article-treat
1140 :link '(custom-manual "(gnus)Customizing Articles")
1141 :type gnus-article-treat-head-custom)
1143 (defcustom gnus-treat-strip-headers-in-body t
1144 "Strip the X-No-Archive header line from the beginning of the body.
1145 Valid values are nil, t, `head', `last', an integer or a predicate.
1146 See Info node `(gnus)Customizing Articles' for details."
1148 :group 'gnus-article-treat
1149 :link '(custom-manual "(gnus)Customizing Articles")
1150 :type gnus-article-treat-custom)
1152 (defcustom gnus-treat-strip-trailing-blank-lines nil
1153 "Strip trailing blank lines.
1154 Valid values are nil, t, `head', `last', an integer or a predicate.
1155 See Info node `(gnus)Customizing Articles' for details."
1156 :group 'gnus-article-treat
1157 :link '(custom-manual "(gnus)Customizing Articles")
1158 :type gnus-article-treat-custom)
1160 (defcustom gnus-treat-strip-leading-blank-lines nil
1161 "Strip leading blank lines.
1162 Valid values are nil, t, `head', `last', an integer or a predicate.
1163 See Info node `(gnus)Customizing Articles' for details."
1164 :group 'gnus-article-treat
1165 :link '(custom-manual "(gnus)Customizing Articles")
1166 :type gnus-article-treat-custom)
1168 (defcustom gnus-treat-strip-multiple-blank-lines nil
1169 "Strip multiple blank lines.
1170 Valid values are nil, t, `head', `last', an integer or a predicate.
1171 See Info node `(gnus)Customizing Articles' for details."
1172 :group 'gnus-article-treat
1173 :link '(custom-manual "(gnus)Customizing Articles")
1174 :type gnus-article-treat-custom)
1176 (defcustom gnus-treat-unfold-headers 'head
1177 "Unfold folded header lines.
1178 Valid values are nil, t, `head', `last', an integer or a predicate.
1179 See Info node `(gnus)Customizing Articles' for details."
1180 :group 'gnus-article-treat
1181 :link '(custom-manual "(gnus)Customizing Articles")
1182 :type gnus-article-treat-custom)
1184 (defcustom gnus-treat-fold-headers nil
1186 Valid values are nil, t, `head', `last', an integer or a predicate.
1187 See Info node `(gnus)Customizing Articles' for details."
1188 :group 'gnus-article-treat
1189 :link '(custom-manual "(gnus)Customizing Articles")
1190 :type gnus-article-treat-custom)
1192 (defcustom gnus-treat-fold-newsgroups 'head
1193 "Fold the Newsgroups and Followup-To headers.
1194 Valid values are nil, t, `head', `last', an integer or a predicate.
1195 See Info node `(gnus)Customizing Articles' for details."
1196 :group 'gnus-article-treat
1197 :link '(custom-manual "(gnus)Customizing Articles")
1198 :type gnus-article-treat-custom)
1200 (defcustom gnus-treat-overstrike t
1201 "Treat overstrike highlighting.
1202 Valid values are nil, t, `head', `last', an integer or a predicate.
1203 See Info node `(gnus)Customizing Articles' for details."
1204 :group 'gnus-article-treat
1205 :link '(custom-manual "(gnus)Customizing Articles")
1206 :type gnus-article-treat-custom)
1207 (put 'gnus-treat-overstrike 'highlight t)
1209 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1210 "Treat ANSI SGR control sequences.
1211 Valid values are nil, t, `head', `last', an integer or a predicate.
1212 See Info node `(gnus)Customizing Articles' for details."
1213 :group 'gnus-article-treat
1214 :link '(custom-manual "(gnus)Customizing Articles")
1215 :type gnus-article-treat-custom)
1217 (make-obsolete-variable 'gnus-treat-display-xface
1218 'gnus-treat-display-x-face)
1220 (defcustom gnus-treat-display-x-face
1221 (and (not noninteractive)
1222 (or (memq gnus-article-x-face-command
1223 '(x-face-decode-message-header
1224 x-face-mule-gnus-article-display-x-face))
1225 (and (fboundp 'image-type-available-p)
1226 (image-type-available-p 'xbm)
1227 (string-match "^0x" (shell-command-to-string "uncompface"))
1228 (executable-find "icontopbm"))
1229 (and (featurep 'xemacs)
1232 "Display X-Face headers.
1233 Valid values are nil, t, `head', `last', an integer or a predicate.
1234 See Info node `(gnus)Customizing Articles' and Info node
1235 `(gnus)X-Face' for details."
1236 :group 'gnus-article-treat
1238 :link '(custom-manual "(gnus)Customizing Articles")
1239 :link '(custom-manual "(gnus)X-Face")
1240 :type gnus-article-treat-head-custom
1241 :set (lambda (symbol value)
1244 (cond ((or (boundp symbol) (get symbol 'saved-value))
1246 ((boundp 'gnus-treat-display-xface)
1248 ** gnus-treat-display-xface is an obsolete variable;\
1249 use gnus-treat-display-x-face instead")
1250 (default-value 'gnus-treat-display-xface))
1251 ((get 'gnus-treat-display-xface 'saved-value)
1253 ** gnus-treat-display-xface is an obsolete variable;\
1254 use gnus-treat-display-x-face instead")
1255 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1258 (put 'gnus-treat-display-x-face 'highlight t)
1260 (defcustom gnus-article-should-use-smiley-mule
1261 (not (or (featurep 'xemacs)
1262 (gnus-image-type-available-p 'xpm)
1263 (gnus-image-type-available-p 'pbm)))
1264 "Non-nil means use `smiley-mule' to show smileys rather than `smiley'.
1265 `smiley-mule' is boundled in BITMAP-MULE package. You can set it to t
1266 even if your Emacs supports images. It has no effect on XEmacs."
1267 :group 'gnus-article-various
1269 :get (lambda (symbol)
1270 (and (not noninteractive)
1271 (default-value symbol)
1272 (not (featurep 'xemacs))
1273 (module-installed-p 'smiley-mule)
1275 :set (lambda (symbol value)
1276 (set-default symbol (and (not noninteractive)
1278 (not (featurep 'xemacs))
1279 (module-installed-p 'smiley-mule)
1282 (defvar gnus-article-smiley-mule-loaded-p nil
1283 "Internal variable used to say whether `smiley-mule' is loaded (whether
1284 smiley functions are not overridden by `smiley').")
1286 (defcustom gnus-treat-display-face
1287 (and (not noninteractive)
1288 ;; x-face-e21 handles both X-Face and Face headers.
1289 (not (and (eq gnus-article-x-face-command 'x-face-decode-message-header)
1290 (module-installed-p 'x-face-e21)))
1291 (or (and (fboundp 'image-type-available-p)
1292 (image-type-available-p 'png))
1293 (and (featurep 'xemacs)
1296 "Display Face headers.
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)X-Face' for details."
1300 :group 'gnus-article-treat
1302 :link '(custom-manual "(gnus)Customizing Articles")
1303 :link '(custom-manual "(gnus)X-Face")
1304 :type gnus-article-treat-head-custom)
1305 (put 'gnus-treat-display-face 'highlight t)
1307 (defcustom gnus-treat-display-smileys
1308 (if (and (not noninteractive)
1309 (or (and (featurep 'xemacs)
1311 (gnus-image-type-available-p 'xpm)
1312 (gnus-image-type-available-p 'pbm)
1313 (and (not (featurep 'xemacs))
1315 (module-installed-p 'smiley-mule))))
1319 Valid values are nil, t, `head', `last', an integer or a predicate.
1320 See Info node `(gnus)Customizing Articles' and Info node
1321 `(gnus)Smileys' for details."
1322 :group 'gnus-article-treat
1324 :link '(custom-manual "(gnus)Customizing Articles")
1325 :link '(custom-manual "(gnus)Smileys")
1326 :type gnus-article-treat-custom)
1327 (put 'gnus-treat-display-smileys 'highlight t)
1329 (defcustom gnus-treat-from-picon
1330 (if (and (gnus-image-type-available-p 'xpm)
1331 (gnus-picons-installed-p))
1333 "Display picons in the From header.
1334 Valid values are nil, t, `head', `last', an integer or a predicate.
1335 See Info node `(gnus)Customizing Articles' and Info node
1336 `(gnus)Picons' for details."
1337 :group 'gnus-article-treat
1339 :link '(custom-manual "(gnus)Customizing Articles")
1340 :link '(custom-manual "(gnus)Picons")
1341 :type gnus-article-treat-head-custom)
1342 (put 'gnus-treat-from-picon 'highlight t)
1344 (defcustom gnus-treat-mail-picon
1345 (if (and (gnus-image-type-available-p 'xpm)
1346 (gnus-picons-installed-p))
1348 "Display picons in To and Cc headers.
1349 Valid values are nil, t, `head', `last', an integer or a predicate.
1350 See Info node `(gnus)Customizing Articles' and Info node
1351 `(gnus)Picons' for details."
1352 :group 'gnus-article-treat
1354 :link '(custom-manual "(gnus)Customizing Articles")
1355 :link '(custom-manual "(gnus)Picons")
1356 :type gnus-article-treat-head-custom)
1357 (put 'gnus-treat-mail-picon 'highlight t)
1359 (defcustom gnus-treat-newsgroups-picon
1360 (if (and (gnus-image-type-available-p 'xpm)
1361 (gnus-picons-installed-p))
1363 "Display picons in the Newsgroups and Followup-To headers.
1364 Valid values are nil, t, `head', `last', an integer or a predicate.
1365 See Info node `(gnus)Customizing Articles' and Info node
1366 `(gnus)Picons' for details."
1367 :group 'gnus-article-treat
1369 :link '(custom-manual "(gnus)Customizing Articles")
1370 :link '(custom-manual "(gnus)Picons")
1371 :type gnus-article-treat-head-custom)
1372 (put 'gnus-treat-newsgroups-picon 'highlight t)
1374 (defcustom gnus-treat-body-boundary
1375 (if (or gnus-treat-newsgroups-picon
1376 gnus-treat-mail-picon
1377 gnus-treat-from-picon)
1379 "Draw a boundary at the end of the headers.
1380 Valid values are nil and `head'.
1381 See Info node `(gnus)Customizing Articles' for details."
1383 :group 'gnus-article-treat
1384 :link '(custom-manual "(gnus)Customizing Articles")
1385 :type gnus-article-treat-head-custom)
1387 (defcustom gnus-treat-capitalize-sentences nil
1388 "Capitalize sentence-starting words.
1389 Valid values are nil, t, `head', `last', an integer or a predicate.
1390 See Info node `(gnus)Customizing Articles' for details."
1392 :group 'gnus-article-treat
1393 :link '(custom-manual "(gnus)Customizing Articles")
1394 :type gnus-article-treat-custom)
1396 (defcustom gnus-treat-wash-html nil
1398 Valid values are nil, t, `head', `last', an integer or a predicate.
1399 See Info node `(gnus)Customizing Articles' for details."
1400 :group 'gnus-article-treat
1401 :link '(custom-manual "(gnus)Customizing Articles")
1402 :type gnus-article-treat-custom)
1404 (defcustom gnus-treat-fill-long-lines nil
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 :link '(custom-manual "(gnus)Customizing Articles")
1410 :type gnus-article-treat-custom)
1412 (defcustom gnus-treat-play-sounds nil
1414 Valid values are nil, t, `head', `last', an integer or a predicate.
1415 See Info node `(gnus)Customizing Articles' for details."
1417 :group 'gnus-article-treat
1418 :link '(custom-manual "(gnus)Customizing Articles")
1419 :type gnus-article-treat-custom)
1421 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
1422 "Decode an article as `default-mime-charset'. For instance, if you want to
1423 attempt to decode an article even if the value of `gnus-show-mime' is nil,
1424 you could set this variable to something like: nil for don't decode, t for
1425 decode the body, '(or header t) for the whole article, etc."
1426 :group 'gnus-article-treat
1427 :type '(radio (const :tag "Off" nil)
1428 (const :tag "Decode body" t)
1429 (const :tag "Decode all" (or head t))))
1431 (defcustom gnus-treat-translate nil
1432 "Translate articles from one language to another.
1433 Valid values are nil, t, `head', `last', an integer or a predicate.
1434 See Info node `(gnus)Customizing Articles' for details."
1436 :group 'gnus-article-treat
1437 :link '(custom-manual "(gnus)Customizing Articles")
1438 :type gnus-article-treat-custom)
1440 (defcustom gnus-treat-x-pgp-sig nil
1442 To automatically treat X-PGP-Sig, set it to head.
1443 Valid values are nil, t, `head', `last', an integer or a predicate.
1444 See Info node `(gnus)Customizing Articles' for details."
1445 :group 'gnus-article-treat
1446 :group 'mime-security
1447 :type gnus-article-treat-custom)
1449 (defcustom gnus-treat-monafy nil
1450 "Display body part with mona font.
1451 Valid values are nil, t, `head', `last', an integer or a predicate.
1452 See Info node `(gnus)Customizing Articles' for details."
1453 :group 'gnus-article-treat
1454 :group 'mime-security
1455 :link '(custom-manual "(gnus)Customizing Articles")
1456 :type gnus-article-treat-custom)
1458 (defvar gnus-article-encrypt-protocol-alist
1459 '(("PGP" . mml2015-self-encrypt)))
1461 ;; Set to nil if more than one protocol added to
1462 ;; gnus-article-encrypt-protocol-alist.
1463 (defcustom gnus-article-encrypt-protocol "PGP"
1464 "The protocol used for encrypt articles.
1465 It is a string, such as \"PGP\". If nil, ask user."
1467 :group 'mime-security)
1469 (defvar gnus-article-wash-function nil
1470 "Function used for converting HTML into text.")
1472 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1473 (mm-coding-system-p 'utf-8)
1474 (executable-find idna-program))
1475 "Whether IDNA decoding of headers is used when viewing messages.
1476 This requires GNU Libidn, and by default only enabled if it is found."
1477 :group 'gnus-article-headers
1480 (defcustom gnus-article-over-scroll nil
1481 "If non-nil, allow scrolling the article buffer even when there no more text."
1482 :group 'gnus-article
1485 ;;; Internal variables
1487 (defvar gnus-english-month-names
1488 '("January" "February" "March" "April" "May" "June" "July" "August"
1489 "September" "October" "November" "December"))
1491 (defvar gnus-button-regexp nil)
1492 (defvar gnus-button-marker-list nil)
1493 ;; Regexp matching any of the regexps from `gnus-button-alist'.
1495 (defvar gnus-button-last nil)
1496 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
1498 (defvar article-goto-body-goes-to-point-min-p nil)
1499 (defvar gnus-article-wash-types nil)
1500 (defvar gnus-article-emphasis-alist nil)
1501 (defvar gnus-article-image-alist nil)
1503 (defvar gnus-article-mime-handle-alist-1 nil)
1504 (defvar gnus-treatment-function-alist
1505 '((gnus-treat-decode-article-as-default-mime-charset
1506 gnus-article-decode-article-as-default-mime-charset)
1507 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1508 (gnus-treat-monafy gnus-article-monafy)
1509 (gnus-treat-strip-banner gnus-article-strip-banner)
1510 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1511 (gnus-treat-buttonize gnus-article-add-buttons)
1512 (gnus-treat-fill-article gnus-article-fill-cited-article)
1513 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1514 (gnus-treat-strip-cr gnus-article-remove-cr)
1515 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1516 (gnus-treat-date-ut gnus-article-date-ut)
1517 (gnus-treat-date-local gnus-article-date-local)
1518 (gnus-treat-date-english gnus-article-date-english)
1519 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1520 (gnus-treat-date-original gnus-article-date-original)
1521 (gnus-treat-date-user-defined gnus-article-date-user)
1522 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1523 (gnus-treat-display-face gnus-article-display-face)
1524 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1525 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1526 (gnus-treat-hide-signature gnus-article-hide-signature)
1527 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1528 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1529 (gnus-treat-strip-pem gnus-article-hide-pem)
1530 (gnus-treat-from-picon gnus-treat-from-picon)
1531 (gnus-treat-mail-picon gnus-treat-mail-picon)
1532 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1533 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1534 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1535 (gnus-treat-strip-trailing-blank-lines
1536 gnus-article-remove-trailing-blank-lines)
1537 (gnus-treat-strip-leading-blank-lines
1538 gnus-article-strip-leading-blank-lines)
1539 (gnus-treat-strip-multiple-blank-lines
1540 gnus-article-strip-multiple-blank-lines)
1541 (gnus-treat-overstrike gnus-article-treat-overstrike)
1542 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1543 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1544 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1545 ;; Displaying X-Face should be done after unfolding headers
1546 ;; to protect bitmap lines.
1547 (gnus-treat-display-x-face gnus-article-display-x-face)
1548 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1549 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1550 (gnus-treat-display-smileys gnus-treat-smiley)
1551 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1552 (gnus-treat-wash-html gnus-article-wash-html)
1553 (gnus-treat-emphasize gnus-article-emphasize)
1554 (gnus-treat-hide-citation gnus-article-hide-citation)
1555 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1556 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1557 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1558 (gnus-treat-play-sounds gnus-earcon-display)))
1560 (defvar gnus-article-mime-handle-alist nil)
1561 (defvar article-lapsed-timer nil)
1562 (defvar gnus-article-current-summary nil)
1564 (defvar gnus-article-mode-syntax-table
1565 (let ((table (copy-syntax-table text-mode-syntax-table)))
1566 ;; This causes the citation match run O(2^n).
1567 ;; (modify-syntax-entry ?- "w" table)
1568 (modify-syntax-entry ?> ")<" table)
1569 (modify-syntax-entry ?< "(>" table)
1570 ;; make M-. in article buffers work for `foo' strings
1571 (modify-syntax-entry ?' " " table)
1572 (modify-syntax-entry ?` " " table)
1574 "Syntax table used in article mode buffers.
1575 Initialized from `text-mode-syntax-table.")
1577 (defvar gnus-save-article-buffer nil)
1579 (defvar gnus-article-mode-line-format-alist
1580 (nconc '((?w (gnus-article-wash-status) ?s)
1581 (?m (gnus-article-mime-part-status) ?s))
1582 gnus-summary-mode-line-format-alist))
1584 (defvar gnus-number-of-articles-to-be-saved nil)
1586 (defvar gnus-inhibit-hiding nil)
1588 (defvar gnus-article-edit-mode nil)
1590 ;;; Macros for dealing with the article buffer.
1592 (defmacro gnus-with-article-headers (&rest forms)
1594 (set-buffer gnus-article-buffer)
1596 (let ((buffer-read-only nil)
1597 (inhibit-point-motion-hooks t)
1598 (case-fold-search t))
1599 (article-narrow-to-head)
1602 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1603 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1605 (defmacro gnus-with-article-buffer (&rest forms)
1607 (set-buffer gnus-article-buffer)
1608 (let ((buffer-read-only nil))
1611 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1612 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1614 (defun gnus-article-goto-header (header)
1615 "Go to HEADER, which is a regular expression."
1616 (re-search-forward (concat "^\\(" header "\\):") nil t))
1618 (defsubst gnus-article-hide-text (b e props)
1619 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1620 (gnus-add-text-properties-when 'article-type nil b e props)
1621 (when (memq 'intangible props)
1623 (max (1- b) (point-min))
1624 b 'intangible (cddr (memq 'intangible props)))))
1626 (defsubst gnus-article-unhide-text (b e)
1627 "Remove hidden text properties from region between B and E."
1628 (remove-text-properties b e gnus-hidden-properties)
1629 (when (memq 'intangible gnus-hidden-properties)
1630 (put-text-property (max (1- b) (point-min))
1631 b 'intangible nil)))
1633 (defun gnus-article-hide-text-type (b e type)
1634 "Hide text of TYPE between B and E."
1635 (gnus-add-wash-type type)
1636 (gnus-article-hide-text
1637 b e (cons 'article-type (cons type gnus-hidden-properties))))
1639 (defun gnus-article-unhide-text-type (b e type)
1640 "Unhide text of TYPE between B and E."
1641 (gnus-delete-wash-type type)
1642 (remove-text-properties
1643 b e (cons 'article-type (cons type gnus-hidden-properties)))
1644 (when (memq 'intangible gnus-hidden-properties)
1645 (put-text-property (max (1- b) (point-min))
1646 b 'intangible nil)))
1648 (defun gnus-article-hide-text-of-type (type)
1649 "Hide text of TYPE in the current buffer."
1651 (let ((b (point-min))
1653 (while (setq b (text-property-any b e 'article-type type))
1654 (add-text-properties b (incf b) gnus-hidden-properties)))))
1656 (defun gnus-article-delete-text-of-type (type)
1657 "Delete text of TYPE in the current buffer."
1659 (let ((b (point-min)))
1660 (while (setq b (text-property-any b (point-max) 'article-type type))
1662 b (or (text-property-not-all b (point-max) 'article-type type)
1665 (defun gnus-article-delete-invisible-text ()
1666 "Delete all invisible text in the current buffer."
1668 (let ((b (point-min)))
1669 (while (setq b (text-property-any b (point-max) 'invisible t))
1671 b (or (text-property-not-all b (point-max) 'invisible t)
1674 (defun gnus-article-text-type-exists-p (type)
1675 "Say whether any text of type TYPE exists in the buffer."
1676 (text-property-any (point-min) (point-max) 'article-type type))
1678 (defsubst gnus-article-header-rank ()
1679 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1680 (let ((list gnus-sorted-header-list)
1683 (if (looking-at (car list))
1685 (setq list (cdr list))
1689 (defun article-hide-headers (&optional arg delete)
1690 "Hide unwanted headers and possibly sort them as well."
1691 (interactive (gnus-article-hidden-arg))
1692 ;; Lars said that this function might be inhibited.
1693 (if (gnus-article-check-hidden-text 'headers arg)
1695 ;; Show boring headers as well.
1696 (gnus-article-show-hidden-text 'boring-headers)
1697 (when (eq 1 (point-min))
1698 (set-window-start (get-buffer-window (current-buffer)) 1)))
1699 (unless gnus-inhibit-hiding
1700 (let ((inhibit-read-only t)
1701 (case-fold-search t)
1702 (max (1+ (length gnus-sorted-header-list)))
1703 (inhibit-point-motion-hooks t)
1704 ignored visible beg)
1706 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1707 ;; group parameters, so we should go to the summary buffer.
1710 (progn (set-buffer gnus-summary-buffer) t)
1712 (setq ignored (when (not gnus-visible-headers)
1713 (cond ((stringp gnus-ignored-headers)
1714 gnus-ignored-headers)
1715 ((listp gnus-ignored-headers)
1716 (mapconcat 'identity
1717 gnus-ignored-headers
1719 visible (cond ((stringp gnus-visible-headers)
1720 gnus-visible-headers)
1721 ((and gnus-visible-headers
1722 (listp gnus-visible-headers))
1723 (mapconcat 'identity
1724 gnus-visible-headers
1726 (set-buffer gnus-article-buffer))
1728 ;; First we narrow to just the headers.
1729 (article-narrow-to-head)
1730 ;; Hide any "From " lines at the beginning of (mail) articles.
1731 (while (looking-at "From ")
1735 (delete-region (point-min) (point))
1736 (gnus-article-hide-text (point-min) (point)
1737 (nconc (list 'article-type 'headers)
1738 gnus-hidden-properties))))
1739 ;; Then treat the rest of the header lines.
1740 ;; Then we use the two regular expressions
1741 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1742 ;; select which header lines is to remain visible in the
1744 (while (re-search-forward "^[^ \t:]*:" nil t)
1746 ;; Mark the rank of the header.
1748 (point) (1+ (point)) 'message-rank
1749 (if (or (and visible (looking-at visible))
1751 (not (looking-at ignored))))
1752 (gnus-article-header-rank)
1755 (message-sort-headers-1)
1756 (when (setq beg (text-property-any
1757 (point-min) (point-max) 'message-rank (+ 2 max)))
1758 ;; We delete or make invisible the unwanted headers.
1759 (gnus-add-wash-type 'headers)
1762 (add-text-properties
1763 (point-min) (+ 5 (point-min))
1764 '(article-type headers dummy-invisible t))
1765 (delete-region beg (point-max)))
1766 (gnus-article-hide-text-type beg (point-max) 'headers)))))))))
1768 (defun article-hide-boring-headers (&optional arg)
1769 "Toggle hiding of headers that aren't very interesting.
1770 If given a negative prefix, always show; if given a positive prefix,
1772 (interactive (gnus-article-hidden-arg))
1773 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1774 (not gnus-show-all-headers))
1777 (let ((buffer-read-only nil)
1778 (list gnus-boring-article-headers)
1779 (inhibit-point-motion-hooks t)
1781 (article-narrow-to-head)
1783 (setq elem (pop list))
1784 (goto-char (point-min))
1786 ;; Hide empty headers.
1788 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1790 (gnus-article-hide-text-type
1794 (if (re-search-forward "^[^ \t]" nil t)
1798 ;; Hide boring Newsgroups header.
1799 ((eq elem 'newsgroups)
1800 (when (gnus-string-equal
1801 (gnus-fetch-field "newsgroups")
1802 (gnus-group-real-name
1803 (if (boundp 'gnus-newsgroup-name)
1806 (gnus-article-hide-header "newsgroups")))
1807 ((eq elem 'to-address)
1808 (let ((to (message-fetch-field "to"))
1810 (gnus-parameter-to-address
1811 (if (boundp 'gnus-newsgroup-name)
1812 gnus-newsgroup-name ""))))
1813 (when (and to to-address
1816 ;; only one address in To
1817 (nth 1 (mail-extract-address-components to))
1819 (gnus-article-hide-header "to"))))
1821 (let ((to (message-fetch-field "to"))
1823 (gnus-parameter-to-list
1824 (if (boundp 'gnus-newsgroup-name)
1825 gnus-newsgroup-name ""))))
1826 (when (and to to-list
1829 ;; only one address in To
1830 (nth 1 (mail-extract-address-components to))
1832 (gnus-article-hide-header "to"))))
1834 (let ((cc (message-fetch-field "cc"))
1836 (gnus-parameter-to-list
1837 (if (boundp 'gnus-newsgroup-name)
1838 gnus-newsgroup-name ""))))
1839 (when (and cc to-list
1842 ;; only one address in CC
1843 (nth 1 (mail-extract-address-components cc))
1845 (gnus-article-hide-header "cc"))))
1846 ((eq elem 'followup-to)
1847 (when (gnus-string-equal
1848 (message-fetch-field "followup-to")
1849 (message-fetch-field "newsgroups"))
1850 (gnus-article-hide-header "followup-to")))
1851 ((eq elem 'reply-to)
1852 (if (gnus-group-find-parameter
1853 gnus-newsgroup-name 'broken-reply-to)
1854 (gnus-article-hide-header "reply-to")
1855 (let ((from (message-fetch-field "from"))
1856 (reply-to (message-fetch-field "reply-to")))
1863 (lambda (x) (downcase (cadr x)))
1864 (mail-extract-address-components from t))
1867 (lambda (x) (downcase (cadr x)))
1868 (mail-extract-address-components reply-to t))
1870 (gnus-article-hide-header "reply-to")))))
1872 (let ((date (message-fetch-field "date")))
1874 (< (days-between (current-time-string) date)
1876 (gnus-article-hide-header "date"))))
1878 (let ((to (message-fetch-field "to"))
1879 (cc (message-fetch-field "cc")))
1880 (when (> (length to) 1024)
1881 (gnus-article-hide-header "to"))
1882 (when (> (length cc) 1024)
1883 (gnus-article-hide-header "cc"))))
1887 (goto-char (point-min))
1888 (while (re-search-forward "^to:" nil t)
1889 (setq to-count (1+ to-count)))
1890 (when (> to-count 1)
1891 (while (> to-count 0)
1892 (goto-char (point-min))
1894 (re-search-forward "^to:" nil nil to-count)
1896 (narrow-to-region (point) (point-max))
1897 (gnus-article-hide-header "to"))
1898 (setq to-count (1- to-count))))
1899 (goto-char (point-min))
1900 (while (re-search-forward "^cc:" nil t)
1901 (setq cc-count (1+ cc-count)))
1902 (when (> cc-count 1)
1903 (while (> cc-count 0)
1904 (goto-char (point-min))
1906 (re-search-forward "^cc:" nil nil cc-count)
1908 (narrow-to-region (point) (point-max))
1909 (gnus-article-hide-header "cc"))
1910 (setq cc-count (1- cc-count)))))))))))))
1912 (defun gnus-article-hide-header (header)
1914 (goto-char (point-min))
1915 (when (re-search-forward (concat "^" header ":") nil t)
1916 (gnus-article-hide-text-type
1920 (if (re-search-forward "^[^ \t]" nil t)
1925 (defvar gnus-article-normalized-header-length 40
1926 "Length of normalized headers.")
1928 (defun article-normalize-headers ()
1929 "Make all header lines 40 characters long."
1931 (let ((buffer-read-only nil)
1935 (article-narrow-to-head)
1938 ((< (setq column (- (point-at-eol) (point)))
1939 gnus-article-normalized-header-length)
1941 (insert (make-string
1942 (- gnus-article-normalized-header-length column)
1944 ((> column gnus-article-normalized-header-length)
1945 (gnus-put-text-property
1947 (forward-char gnus-article-normalized-header-length)
1954 (forward-line 1))))))
1956 (defun article-treat-dumbquotes ()
1957 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
1958 Note that this function guesses whether a character is a sm*rtq**t* or
1959 not, so it should only be used interactively.
1961 Sm*rtq**t*s are M****s***'s unilateral extension to the
1962 iso-8859-1 character map in an attempt to provide more quoting
1963 characters. If you see something like \\222 or \\264 where
1964 you're expecting some kind of apostrophe or quotation mark, then
1967 (article-translate-strings gnus-article-dumbquotes-map))
1969 (defun article-translate-characters (from to)
1970 "Translate all characters in the body of the article according to FROM and TO.
1971 FROM is a string of characters to translate from; to is a string of
1972 characters to translate to."
1974 (when (article-goto-body)
1975 (let ((buffer-read-only nil)
1976 (x (make-string 225 ?x))
1978 (while (< (incf i) (length x))
1981 (while (< i (length from))
1982 (aset x (aref from i) (aref to i))
1984 (translate-region (point) (point-max) x)))))
1986 (defun article-translate-strings (map)
1987 "Translate all string in the body of the article according to MAP.
1988 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1990 (when (article-goto-body)
1991 (let ((buffer-read-only nil)
1993 (while (setq elem (pop map))
1995 (while (search-forward (car elem) nil t)
1996 (replace-match (cadr elem)))))))))
1998 (defun article-treat-overstrike ()
1999 "Translate overstrikes into bold text."
2002 (when (article-goto-body)
2003 (let ((buffer-read-only nil))
2004 (while (search-forward "\b" nil t)
2005 (let ((next (char-after))
2009 previous (char-after))
2013 ;; We do the boldification/underlining by hiding the
2014 ;; overstrikes and putting the proper text property
2018 (gnus-article-hide-text-type start (point) 'overstrike)
2019 (put-text-property (point) end 'face 'bold))
2021 (gnus-article-hide-text-type
2022 (1- (point)) (1+ (point)) 'overstrike)
2024 start (1- (point)) 'face 'underline))
2026 (gnus-article-hide-text-type start (point) 'overstrike)
2028 (point) end 'face 'underline)))))))))
2030 (defun article-treat-ansi-sequences ()
2031 "Translate ANSI SGR control sequences into overlays or extents."
2034 (when (article-goto-body)
2035 (let ((buffer-read-only nil))
2036 (ansi-color-apply-on-region (point) (point-max))))))
2038 (defun gnus-article-treat-unfold-headers ()
2039 "Unfold folded message headers.
2040 Only the headers that fit into the current window width will be
2043 (gnus-with-article-headers
2047 (mail-header-narrow-to-field)
2048 (let ((header (buffer-string)))
2051 (goto-char (point-min))
2052 (while (re-search-forward "\n[\t ]" nil t)
2053 (replace-match " " t t)))
2054 (setq length (- (point-max) (point-min) 1)))
2055 (when (< length (window-width))
2056 (while (re-search-forward "\n[\t ]" nil t)
2057 (replace-match " " t t)))
2058 (goto-char (point-max)))))))
2060 (defun gnus-article-treat-fold-headers ()
2061 "Fold message headers."
2063 (gnus-with-article-headers
2066 (mail-header-narrow-to-field)
2067 (mail-header-fold-field)
2068 (goto-char (point-max))))))
2070 (defun gnus-treat-smiley ()
2071 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2073 (unless (featurep 'xemacs)
2074 (when (and (not gnus-article-should-use-smiley-mule)
2075 gnus-article-smiley-mule-loaded-p)
2076 (load "smiley" nil t)
2077 (setq gnus-article-smiley-mule-loaded-p nil))
2078 (when (and gnus-article-should-use-smiley-mule
2079 (not gnus-article-smiley-mule-loaded-p))
2080 (load "smiley-mule" nil t)
2081 (setq gnus-article-smiley-mule-loaded-p t)))
2082 (gnus-with-article-buffer
2083 (if (memq 'smiley gnus-article-wash-types)
2084 (gnus-delete-images 'smiley)
2086 (let ((images (smiley-region (point) (point-max))))
2088 (gnus-add-wash-type 'smiley)
2089 (dolist (image images)
2090 (gnus-add-image 'smiley image)))))))
2092 (defun gnus-article-remove-images ()
2093 "Remove all images from the article buffer."
2095 (gnus-with-article-buffer
2096 (dolist (elem gnus-article-image-alist)
2097 (gnus-delete-images (car elem)))))
2099 (defun gnus-article-treat-fold-newsgroups ()
2100 "Unfold folded message headers.
2101 Only the headers that fit into the current window width will be
2104 (gnus-with-article-headers
2105 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2107 (mail-header-narrow-to-field)
2108 (while (re-search-forward ", *" nil t)
2109 (replace-match ", " t t))
2110 (mail-header-fold-field)
2111 (goto-char (point-max))))))
2113 (defun gnus-article-treat-body-boundary ()
2114 "Place a boundary line at the end of the headers."
2116 (when (and gnus-body-boundary-delimiter
2117 (> (length gnus-body-boundary-delimiter) 0))
2118 (gnus-with-article-headers
2119 (goto-char (point-max))
2120 (let ((start (point)))
2121 (insert "X-Boundary: ")
2122 (gnus-add-text-properties start (point) '(invisible t intangible t))
2124 (while (>= (1- (window-width)) (length str))
2125 (setq str (concat str gnus-body-boundary-delimiter)))
2126 (substring str 0 (1- (window-width))))
2128 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2130 (defun article-fill-long-lines ()
2131 "Fill lines that are wider than the window width."
2134 (let ((buffer-read-only nil)
2135 (width (window-width (get-buffer-window (current-buffer)))))
2138 (let ((adaptive-fill-mode nil)) ;Why? -sm
2141 (when (>= (current-column) (min fill-column width))
2142 (narrow-to-region (min (1+ (point)) (point-max))
2144 (let ((goback (point-marker)))
2145 (fill-paragraph nil)
2146 (goto-char (marker-position goback)))
2148 (forward-line 1)))))))
2150 (defun article-capitalize-sentences ()
2151 "Capitalize the first word in each sentence."
2154 (let ((buffer-read-only nil)
2155 (paragraph-start "^[\n\^L]"))
2159 (forward-sentence)))))
2161 (defun article-remove-cr ()
2162 "Remove trailing CRs and then translate remaining CRs into LFs."
2165 (let ((buffer-read-only nil))
2166 (goto-char (point-min))
2167 (while (re-search-forward "\r+$" nil t)
2168 (replace-match "" t t))
2169 (goto-char (point-min))
2170 (while (search-forward "\r" nil t)
2171 (replace-match "\n" t t)))))
2173 (defun article-remove-trailing-blank-lines ()
2174 "Remove all trailing blank lines from the article."
2177 (let ((buffer-read-only nil))
2178 (goto-char (point-max))
2182 (while (and (not (bobp))
2183 (looking-at "^[ \t]*$")
2184 (not (gnus-annotation-in-region-p
2185 (point) (point-at-eol))))
2191 (defvar gnus-face-properties-alist))
2193 (defun article-display-face ()
2194 "Display any Face headers in the header."
2196 (let ((wash-face-p buffer-read-only))
2197 (gnus-with-article-headers
2198 ;; When displaying parts, this function can be called several times on
2199 ;; the same article, without any intended toggle semantic (as typing `W
2200 ;; D d' would have). So face deletion must occur only when we come from
2201 ;; an interactive command, that is when the *Article* buffer is
2203 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2204 (gnus-delete-images 'face)
2207 (when (and wash-face-p
2209 (goto-char (point-min))
2210 (not (re-search-forward "^Face:[\t ]*" nil t)))
2211 (gnus-buffer-live-p gnus-original-article-buffer))
2212 (set-buffer gnus-original-article-buffer))
2214 (mail-narrow-to-head)
2215 (while (gnus-article-goto-header "Face")
2216 (setq faces (nconc faces (list (mail-header-field-value)))))))
2217 (while (setq face (pop faces))
2218 (let ((png (gnus-convert-face-to-png face))
2222 (apply 'gnus-create-image png 'png t
2223 (cdr (assq 'png gnus-face-properties-alist))))
2224 (gnus-article-goto-header "from")
2226 (insert "From: [no `from' set]\n")
2228 (gnus-add-wash-type 'face)
2229 (gnus-add-image 'face image)
2230 (gnus-put-image image nil 'face))))))
2233 (defun article-display-x-face (&optional force)
2234 "Look for an X-Face header and display it if present."
2235 (interactive (list 'force))
2236 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2237 (gnus-with-article-headers
2238 ;; Delete the old process, if any.
2239 (when (process-status "article-x-face")
2240 (delete-process "article-x-face"))
2241 ;; See the comment in `article-display-face'.
2242 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2243 ;; We have already displayed X-Faces, so we remove them
2245 (gnus-delete-images 'xface)
2247 (let (x-faces from face)
2249 (when (and wash-face-p
2251 (goto-char (point-min))
2252 (not (re-search-forward
2253 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2254 (gnus-buffer-live-p gnus-original-article-buffer))
2255 ;; If type `W f', use gnus-original-article-buffer,
2256 ;; otherwise use the current buffer because displaying
2257 ;; RFC822 parts calls this function too.
2258 (set-buffer gnus-original-article-buffer))
2260 (mail-narrow-to-head)
2261 (while (gnus-article-goto-header "X-Face")
2262 (push (mail-header-field-value) x-faces))
2263 (setq from (message-fetch-field "from"))))
2264 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2265 ;; single external face.
2266 (when (stringp gnus-article-x-face-command)
2267 (setq x-faces (list (car x-faces))))
2268 (while (and (setq face (pop x-faces))
2269 gnus-article-x-face-command
2271 ;; Check whether this face is censored.
2272 (not gnus-article-x-face-too-ugly)
2273 (and gnus-article-x-face-too-ugly from
2274 (not (string-match gnus-article-x-face-too-ugly
2276 ;; We display the face.
2277 (cond ((stringp gnus-article-x-face-command)
2278 ;; The command is a string, so we interpret the command
2279 ;; as a, well, command, and fork it off.
2280 (let ((process-connection-type nil))
2281 (process-kill-without-query
2283 "article-x-face" nil shell-file-name
2284 shell-command-switch gnus-article-x-face-command))
2287 (process-send-region "article-x-face"
2288 (point-min) (point-max)))
2289 (process-send-eof "article-x-face")))
2290 ((functionp gnus-article-x-face-command)
2291 ;; The command is a lisp function, so we call it.
2292 (funcall gnus-article-x-face-command face))
2294 (error "%s is not a function"
2295 gnus-article-x-face-command)))))))))
2297 (defun article-decode-mime-words ()
2298 "Decode all MIME-encoded words in the article."
2300 (gnus-with-article-buffer
2301 (let ((inhibit-point-motion-hooks t)
2302 (mail-parse-charset gnus-newsgroup-charset)
2303 (mail-parse-ignored-charsets
2304 (with-current-buffer gnus-summary-buffer
2305 gnus-newsgroup-ignored-charsets)))
2306 (mail-decode-encoded-word-region (point-min) (point-max)))))
2308 (defun article-decode-charset (&optional prompt)
2309 "Decode charset-encoded text in the article.
2310 If PROMPT (the prefix), prompt for a coding system to use."
2312 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2314 (mail-parse-charset gnus-newsgroup-charset)
2315 (mail-parse-ignored-charsets
2316 (save-excursion (condition-case nil
2317 (set-buffer gnus-summary-buffer)
2319 gnus-newsgroup-ignored-charsets))
2320 ct cte ctl charset format)
2323 (article-narrow-to-head)
2324 (setq ct (message-fetch-field "Content-Type" t)
2325 cte (message-fetch-field "Content-Transfer-Encoding" t)
2326 ctl (and ct (ignore-errors
2327 (mail-header-parse-content-type ct)))
2330 (mm-read-coding-system "Charset to decode: "))
2332 (mail-content-type-get ctl 'charset)))
2333 format (and ctl (mail-content-type-get ctl 'format)))
2335 (setq cte (mail-header-strip cte)))
2336 (if (and ctl (not (string-match "/" (car ctl))))
2338 (goto-char (point-max)))
2341 (narrow-to-region (point) (point-max))
2342 (when (and (eq mail-parse-charset 'gnus-decoded)
2343 (eq (mm-body-7-or-8) '8bit))
2344 ;; The text code could have been decoded.
2345 (setq charset mail-parse-charset))
2346 (when (and (or (not ctl)
2347 (equal (car ctl) "text/plain"))
2348 (not format)) ;; article with format will decode later.
2350 charset (and cte (intern (downcase
2351 (gnus-strip-whitespace cte))))
2354 (defun article-decode-encoded-words ()
2355 "Remove encoded-word encoding from headers."
2356 (let (buffer-read-only)
2357 (let ((charset (save-excursion
2358 (set-buffer gnus-summary-buffer)
2359 default-mime-charset)))
2360 (mime-decode-header-in-buffer charset))))
2362 (defun article-decode-group-name ()
2363 "Decode group names in `Newsgroups:'."
2364 (let ((inhibit-point-motion-hooks t)
2366 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2367 (when (and (or gnus-group-name-charset-method-alist
2368 gnus-group-name-charset-group-alist)
2369 (gnus-buffer-live-p gnus-original-article-buffer))
2371 (article-narrow-to-head)
2372 (with-current-buffer gnus-original-article-buffer
2373 (goto-char (point-min)))
2374 (while (re-search-forward
2375 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2376 (replace-match (save-match-data
2377 (gnus-decode-newsgroups
2378 ;; XXX how to use data in article buffer?
2379 (with-current-buffer gnus-original-article-buffer
2381 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2384 gnus-newsgroup-name method))
2386 (goto-char (point-min))
2387 (with-current-buffer gnus-original-article-buffer
2388 (goto-char (point-min)))
2389 (while (re-search-forward
2390 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2391 (replace-match (save-match-data
2392 (gnus-decode-newsgroups
2393 ;; XXX how to use data in article buffer?
2394 (with-current-buffer gnus-original-article-buffer
2396 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2399 gnus-newsgroup-name method))
2402 (autoload 'idna-to-unicode "idna")
2404 (defun article-decode-idna-rhs ()
2405 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2408 (let ((inhibit-point-motion-hooks t)
2410 (article-narrow-to-head)
2411 (goto-char (point-min))
2412 (while (re-search-forward "@.*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2414 (when (save-match-data
2415 (and (setq ace (match-string 1))
2417 (and (re-search-backward "^[^ \t]" nil t)
2418 (looking-at "From\\|To\\|Cc")))
2419 (setq unicode (idna-to-unicode ace))))
2420 (unless (string= ace unicode)
2421 (replace-match unicode nil nil nil 1)))))))))
2423 (defun article-de-quoted-unreadable (&optional force read-charset)
2424 "Translate a quoted-printable-encoded article.
2425 If FORCE, decode the article whether it is marked as quoted-printable
2427 If READ-CHARSET, ask for a coding system."
2428 (interactive (list 'force current-prefix-arg))
2430 (let ((buffer-read-only nil) type charset)
2431 (if (gnus-buffer-live-p gnus-original-article-buffer)
2432 (with-current-buffer gnus-original-article-buffer
2434 (gnus-fetch-field "content-transfer-encoding"))
2435 (let* ((ct (gnus-fetch-field "content-type"))
2438 (mail-header-parse-content-type ct)))))
2439 (setq charset (and ctl
2440 (mail-content-type-get ctl 'charset)))
2441 (if (stringp charset)
2442 (setq charset (intern (downcase charset)))))))
2444 (setq charset (mm-read-coding-system "Charset: " charset)))
2446 (setq charset gnus-newsgroup-charset))
2448 (and type (let ((case-fold-search t))
2449 (string-match "quoted-printable" type))))
2451 (quoted-printable-decode-region
2452 (point) (point-max) (mm-charset-to-coding-system charset))))))
2454 (defun article-de-base64-unreadable (&optional force read-charset)
2455 "Translate a base64 article.
2456 If FORCE, decode the article whether it is marked as base64 not.
2457 If READ-CHARSET, ask for a coding system."
2458 (interactive (list 'force current-prefix-arg))
2460 (let ((buffer-read-only nil) type charset)
2461 (if (gnus-buffer-live-p gnus-original-article-buffer)
2462 (with-current-buffer gnus-original-article-buffer
2464 (gnus-fetch-field "content-transfer-encoding"))
2465 (let* ((ct (gnus-fetch-field "content-type"))
2468 (mail-header-parse-content-type ct)))))
2469 (setq charset (and ctl
2470 (mail-content-type-get ctl 'charset)))
2471 (if (stringp charset)
2472 (setq charset (intern (downcase charset)))))))
2474 (setq charset (mm-read-coding-system "Charset: " charset)))
2476 (setq charset gnus-newsgroup-charset))
2478 (and type (let ((case-fold-search t))
2479 (string-match "base64" type))))
2482 (narrow-to-region (point) (point-max))
2483 (base64-decode-region (point-min) (point-max))
2484 (mm-decode-coding-region
2485 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2490 (defun article-decode-HZ ()
2491 "Translate a HZ-encoded article."
2495 (let ((buffer-read-only nil))
2496 (rfc1843-decode-region (point-min) (point-max)))))
2498 (defun article-unsplit-urls ()
2499 "Remove the newlines that some other mailers insert into URLs."
2502 (let ((buffer-read-only nil))
2503 (goto-char (point-min))
2504 (while (re-search-forward
2505 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2506 (replace-match "\\1\\3" t)))
2507 (when (interactive-p)
2508 (gnus-treat-article nil))))
2511 (defun article-wash-html (&optional read-charset)
2512 "Format an HTML article.
2513 If READ-CHARSET, ask for a coding system."
2516 (let ((buffer-read-only nil)
2518 (when (gnus-buffer-live-p gnus-original-article-buffer)
2519 (with-current-buffer gnus-original-article-buffer
2520 (let* ((ct (gnus-fetch-field "content-type"))
2523 (mail-header-parse-content-type ct)))))
2524 (setq charset (and ctl
2525 (mail-content-type-get ctl 'charset)))
2526 (when (stringp charset)
2527 (setq charset (intern (downcase charset)))))))
2529 (setq charset (mm-read-coding-system "Charset: " charset)))
2531 (setq charset gnus-newsgroup-charset))
2533 (save-window-excursion
2535 (narrow-to-region (point) (point-max))
2536 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2537 (entry (assq func mm-text-html-washer-alist)))
2539 (setq func (cdr entry)))
2544 (apply (car func) (cdr func))))))))))
2546 (defun gnus-article-wash-html-with-w3 ()
2547 "Wash the current buffer with w3."
2549 (let ((w3-strict-width (window-width))
2550 (url-standalone-mode t)
2551 (url-gateway-unplugged t)
2552 (w3-honor-stylesheets nil))
2554 (w3-region (point-min) (point-max))
2557 (defun gnus-article-wash-html-with-w3m ()
2558 "Wash the current buffer with emacs-w3m."
2561 (narrow-to-region (point) (point-max))
2562 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2563 w3m-force-redisplay)
2564 (w3m-region (point-min) (point-max)))
2565 (when (and mm-inline-text-html-with-w3m-keymap
2566 (boundp 'w3m-minor-mode-map)
2568 (add-text-properties
2569 (point-min) (point-max)
2570 (list 'keymap w3m-minor-mode-map
2571 ;; Put the mark meaning this part was rendered by emacs-w3m.
2572 'mm-inline-text-html-with-w3m t)))))
2574 (defun article-hide-list-identifiers ()
2575 "Remove list identifies from the Subject header.
2576 The `gnus-list-identifiers' variable specifies what to do."
2578 (let ((inhibit-point-motion-hooks t)
2579 (regexp (if (consp gnus-list-identifiers)
2580 (mapconcat 'identity gnus-list-identifiers " *\\|")
2581 gnus-list-identifiers))
2586 (article-narrow-to-head)
2587 (goto-char (point-min))
2588 (while (re-search-forward
2589 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2591 (delete-region (match-beginning 2) (match-end 0))
2592 (beginning-of-line))
2593 (when (re-search-forward
2594 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2595 (delete-region (match-beginning 1) (match-end 1))))))))
2597 (defun article-hide-pem (&optional arg)
2598 "Toggle hiding of any PEM headers and signatures in the current article.
2599 If given a negative prefix, always show; if given a positive prefix,
2601 (interactive (gnus-article-hidden-arg))
2602 (unless (gnus-article-check-hidden-text 'pem arg)
2604 (let (buffer-read-only end)
2605 (goto-char (point-min))
2606 ;; Hide the horrendously ugly "header".
2607 (when (and (search-forward
2608 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2610 (setq end (1+ (match-beginning 0))))
2611 (gnus-add-wash-type 'pem)
2612 (gnus-article-hide-text-type
2614 (if (search-forward "\n\n" nil t)
2618 ;; Hide the trailer as well
2619 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2621 (gnus-article-hide-text-type
2622 (match-beginning 0) (match-end 0) 'pem)))))))
2624 (defun article-strip-banner ()
2625 "Strip the banners specified by the `banner' group parameter and by
2626 `gnus-article-address-banner-alist'."
2630 (let ((inhibit-point-motion-hooks t))
2631 (when (gnus-parameter-banner gnus-newsgroup-name)
2632 (article-really-strip-banner
2633 (gnus-parameter-banner gnus-newsgroup-name)))
2634 (when gnus-article-address-banner-alist
2635 ;; It is necessary to encode from fields before checking,
2636 ;; because `mail-header-parse-addresses' does not work
2637 ;; (reliably) on decoded headers. And more, it is
2638 ;; impossible to use `gnus-fetch-original-field' here,
2639 ;; because `article-strip-banner' may be called in draft
2640 ;; buffers to preview them.
2641 (let ((from (save-restriction
2643 (article-narrow-to-head)
2644 (mail-fetch-field "from"))))
2647 (caar (mail-header-parse-addresses
2648 (mail-encode-encoded-word-string from)))))
2650 (dolist (pair gnus-article-address-banner-alist)
2651 (when (string-match (car pair) from)
2653 (article-really-strip-banner (cdr pair)))))))))))))
2655 (defun article-really-strip-banner (banner)
2656 "Strip the banner specified by the argument."
2659 (let ((inhibit-point-motion-hooks t)
2660 (gnus-signature-limit nil)
2664 ((eq banner 'signature)
2665 (when (gnus-article-narrow-to-signature)
2668 (delete-region (point) (point-max))))
2670 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2671 (while (re-search-forward banner nil t)
2672 (delete-region (match-beginning 0) (match-end 0)))))
2674 (while (re-search-forward banner nil t)
2675 (delete-region (match-beginning 0) (match-end 0)))))))))
2677 (defun article-babel ()
2678 "Translate article using an online translation service."
2681 (gnus-with-article-buffer
2682 (when (article-goto-body)
2683 (let* ((start (point))
2685 (orig (buffer-substring start end))
2686 (trans (babel-as-string orig)))
2688 (narrow-to-region start end)
2689 (delete-region start end)
2692 (defun article-hide-signature (&optional arg)
2693 "Hide the signature in the current article.
2694 If given a negative prefix, always show; if given a positive prefix,
2696 (interactive (gnus-article-hidden-arg))
2702 (article-goto-body))
2703 (goto-char (point-min)))
2704 (unless (gnus-article-check-hidden-text 'signature arg)
2705 (let ((buffer-read-only nil)
2707 (while (setq button (text-property-any button (point-max)
2709 'gnus-signature-toggle))
2710 (setq button (text-property-not-all button (point-max)
2712 'gnus-signature-toggle))
2713 (when (and button (not (eobp)))
2714 (gnus-article-hide-text-type
2716 (next-single-property-change (1+ button) 'mime-view-entity
2719 (gnus-set-mode-line 'article))
2721 (defun article-strip-headers-in-body ()
2722 "Strip offensive headers from bodies."
2726 (let ((case-fold-search t))
2727 (when (looking-at "x-no-archive:")
2728 (gnus-delete-line)))))
2730 (defun article-strip-leading-blank-lines ()
2731 "Remove all blank lines from the beginning of the article."
2734 (let ((inhibit-point-motion-hooks t)
2736 (when (article-goto-body)
2737 (while (and (not (eobp))
2738 (looking-at "[ \t]*$"))
2739 (gnus-delete-line))))))
2741 (defun article-narrow-to-head ()
2742 "Narrow the buffer to the head of the message.
2743 Point is left at the beginning of the narrowed-to region."
2745 (goto-char (point-min))
2746 (if (search-forward "\n\n" nil 1)
2749 (goto-char (point-min)))
2751 (defun article-goto-body ()
2752 "Place point at the start of the body."
2753 (goto-char (point-min))
2755 ;; This variable is only bound when dealing with separate
2757 (article-goto-body-goes-to-point-min-p
2759 ((search-forward "\n\n" nil t)
2762 (goto-char (point-max))
2765 (defun article-strip-multiple-blank-lines ()
2766 "Replace consecutive blank lines with one empty line."
2769 (let ((inhibit-point-motion-hooks t)
2771 ;; First make all blank lines empty.
2773 (while (re-search-forward "^[ \t]+$" nil t)
2774 (unless (gnus-annotation-in-region-p
2775 (match-beginning 0) (match-end 0))
2776 (replace-match "" nil t)))
2777 ;; Then replace multiple empty lines with a single empty line.
2779 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2780 (unless (gnus-annotation-in-region-p
2781 (match-beginning 0) (match-end 0))
2782 (delete-region (match-beginning 1) (match-end 1)))))))
2784 (defun article-strip-leading-space ()
2785 "Remove all white space from the beginning of the lines in the article."
2788 (let ((inhibit-point-motion-hooks t)
2791 (while (re-search-forward "^[ \t]+" nil t)
2792 (replace-match "" t t)))))
2794 (defun article-strip-trailing-space ()
2795 "Remove all white space from the end of the lines in the article."
2798 (let ((inhibit-point-motion-hooks t)
2801 (while (re-search-forward "[ \t]+$" nil t)
2802 (replace-match "" t t)))))
2804 (defun article-strip-blank-lines ()
2805 "Strip leading, trailing and multiple blank lines."
2807 (article-strip-leading-blank-lines)
2808 (article-remove-trailing-blank-lines)
2809 (article-strip-multiple-blank-lines))
2811 (defun article-strip-all-blank-lines ()
2812 "Strip all blank lines."
2815 (let ((inhibit-point-motion-hooks t)
2818 (while (re-search-forward "^[ \t]*\n" nil t)
2819 (replace-match "" t t)))))
2821 (defun gnus-article-narrow-to-signature ()
2822 "Narrow to the signature; return t if a signature is found, else nil."
2823 (let ((inhibit-point-motion-hooks t))
2824 (when (gnus-article-search-signature)
2826 ;; Check whether we have some limits to what we consider
2827 ;; to be a signature.
2828 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2829 (list gnus-signature-limit)))
2831 (while (setq limit (pop limits))
2832 (if (or (and (integerp limit)
2833 (< (- (point-max) (point)) limit))
2835 (< (count-lines (point) (point-max)) limit))
2836 (and (functionp limit)
2838 (and (stringp limit)
2839 (not (re-search-forward limit nil t))))
2840 () ; This limit did not succeed.
2844 (narrow-to-region (point) (point-max))
2847 (defun gnus-article-search-signature ()
2848 "Search the current buffer for the signature separator.
2849 Put point at the beginning of the signature separator."
2850 (let ((cur (point)))
2851 (goto-char (point-max))
2852 (if (if (stringp gnus-signature-separator)
2853 (re-search-backward gnus-signature-separator nil t)
2854 (let ((seps gnus-signature-separator))
2856 (not (re-search-backward (car seps) nil t)))
2863 (defun gnus-article-hidden-arg ()
2864 "Return the current prefix arg as a number, or 0 if no prefix."
2865 (list (if current-prefix-arg
2866 (prefix-numeric-value current-prefix-arg)
2869 (defun gnus-article-check-hidden-text (type arg)
2870 "Return nil if hiding is necessary.
2871 Arg can be nil or a number. nil and positive means hide, negative
2872 means show, 0 means toggle."
2875 (let ((hide (gnus-article-hidden-text-p type)))
2881 (gnus-article-show-hidden-text type)
2884 (if (eq hide 'hidden)
2886 (gnus-article-show-hidden-text type)
2890 (defun gnus-article-hidden-text-p (type)
2891 "Say whether the current buffer contains hidden text of type TYPE."
2892 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2894 (not (get-text-property pos 'invisible))
2895 (not (get-text-property pos 'dummy-invisible)))
2897 (text-property-any (1+ pos) (point-max) 'article-type type)))
2902 (defun gnus-article-show-hidden-text (type &optional dummy)
2903 "Show all hidden text of type TYPE.
2904 Originally it is hide instead of DUMMY."
2905 (let ((buffer-read-only nil)
2906 (inhibit-point-motion-hooks t))
2907 (gnus-remove-text-properties-when
2909 (point-min) (point-max)
2910 (cons 'article-type (cons type
2911 gnus-hidden-properties)))
2912 (gnus-delete-wash-type type)))
2914 (defconst article-time-units
2915 `((year . ,(* 365.25 24 60 60))
2916 (week . ,(* 7 24 60 60))
2917 (day . ,(* 24 60 60))
2921 "Mapping from time units to seconds.")
2923 (defun gnus-article-forward-header ()
2924 "Move point to the start of the next header.
2925 If the current header is a continuation header, this can be several
2930 (if (looking-at "[ \t]+[^ \t]")
2934 (defun article-date-ut (&optional type highlight header)
2935 "Convert DATE date to universal time in the current article.
2936 If TYPE is `local', convert to local time; if it is `lapsed', output
2937 how much time has lapsed since DATE. For `lapsed', the value of
2938 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2939 should replace the \"Date:\" one, or should be added below it."
2940 (interactive (list 'ut t))
2941 (let* ((header (or header
2942 (and (eq 1 (point-min))
2943 (mail-header-date (save-excursion
2944 (set-buffer gnus-summary-buffer)
2945 gnus-current-headers)))
2946 (message-fetch-field "date")
2948 (date (if (vectorp header) (mail-header-date header)
2950 (inhibit-point-motion-hooks t)
2951 bface eface date-pos)
2952 (when (and date (not (string= date "")))
2955 (article-narrow-to-head)
2956 (when (or (and (eq type 'lapsed)
2957 gnus-article-date-lapsed-new-header
2958 ;; Attempt to get the face of X-Sent first.
2959 (re-search-forward "^X-Sent:[ \t]" nil t))
2960 (re-search-forward "^Date:[ \t]" nil t)
2961 ;; If Date is missing, try again for X-Sent.
2962 (re-search-forward "^X-Sent:[ \t]" nil t))
2963 (setq bface (get-text-property (point-at-bol) 'face)
2964 date (or (get-text-property (point-at-bol)
2967 eface (get-text-property (1- (point-at-eol))
2969 (let ((buffer-read-only nil))
2970 ;; Delete any old X-Sent headers.
2971 (when (setq date-pos
2972 (text-property-any (point-min) (point-max)
2973 'article-date-lapsed t))
2974 (goto-char (setq date-pos (set-marker (make-marker) date-pos)))
2975 (delete-region (match-beginning 0)
2976 (progn (forward-line 1) (point))))
2977 (goto-char (point-min))
2978 ;; Delete any old Date headers.
2979 (while (re-search-forward "^Date:[ \t]" nil t)
2981 (setq date-pos (match-beginning 0)))
2982 (unless (and (eq type 'lapsed)
2983 gnus-article-date-lapsed-new-header)
2984 (delete-region (match-beginning 0)
2985 (progn (message-next-header) (point)))))
2988 (goto-char date-pos)
2990 ;; Possibly, Date has been deleted.
2992 (when (and (eq type 'lapsed)
2993 gnus-article-date-lapsed-new-header
2994 (looking-at "Date:"))
2996 (goto-char (point-min)))
2997 (insert (article-make-date-line date type))
2998 (when (eq type 'lapsed)
2999 (put-text-property (point-at-bol) (point)
3000 'article-date-lapsed t))
3004 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
3005 (put-text-property (match-beginning 1) (1+ (match-end 1))
3006 'original-date date)
3007 (put-text-property (match-beginning 1) (1+ (match-end 1))
3009 (put-text-property (match-beginning 2) (match-end 2)
3012 (defun article-make-date-line (date type)
3013 "Return a DATE line of TYPE."
3014 (unless (memq type '(local ut original user iso8601 lapsed english))
3015 (error "Unknown conversion type: %s" type))
3017 (let ((time (date-to-time date)))
3019 ;; Convert to the local timezone.
3021 (let ((tz (car (current-time-zone time))))
3022 (format "Date: %s %s%02d%02d" (current-time-string time)
3023 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3024 (/ (% (abs tz) 3600) 60))))
3025 ;; Convert to Universal Time.
3028 (current-time-string
3029 (let* ((e (parse-time-string date))
3030 (tm (apply 'encode-time e))
3032 (ls (- (cadr tm) (car (current-time-zone time)))))
3033 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
3034 ((> ls 65535) (list (1+ ms) (- ls 65536)))
3037 ;; Get the original date from the article.
3038 ((eq type 'original)
3039 (concat "Date: " (if (string-match "\n+$" date)
3040 (substring date 0 (match-beginning 0))
3042 ;; Let the user define the format.
3044 (let ((format (or (condition-case nil
3045 (with-current-buffer gnus-summary-buffer
3046 gnus-article-time-format)
3048 gnus-article-time-format)))
3049 (if (functionp format)
3050 (funcall format time)
3051 (concat "Date: " (format-time-string format time)))))
3054 (let ((tz (car (current-time-zone time))))
3057 (format-time-string "%Y%m%dT%H%M%S" time)
3058 (format "%s%02d%02d"
3059 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3060 (/ (% (abs tz) 3600) 60)))))
3061 ;; Do an X-Sent lapsed format.
3063 ;; If the date is seriously mangled, the timezone functions are
3064 ;; liable to bug out, so we ignore all errors.
3065 (let* ((now (current-time))
3066 (real-time (subtract-time now time))
3067 (real-sec (and real-time
3068 (+ (* (float (car real-time)) 65536)
3070 (sec (and real-time (abs real-sec)))
3080 ;; This is a bit convoluted, but basically we go
3081 ;; through the time units for years, weeks, etc,
3082 ;; and divide things to see whether that results
3083 ;; in positive answers.
3086 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3087 ;; The (remaining) seconds are too few to
3088 ;; be divided into this time unit.
3090 ;; It's big enough, so we output it.
3091 (setq sec (- sec (* num (cdr unit))))
3093 (concat (if prev ", " "") (int-to-string
3095 " " (symbol-name (car unit))
3096 (if (> num 1) "s" ""))
3098 article-time-units "")
3099 ;; If dates are odd, then it might appear like the
3100 ;; article was sent in the future.
3103 " in the future"))))))
3104 ;; Display the date in proper English
3106 (let ((dtime (decode-time time)))
3109 (number-to-string (nth 3 dtime))
3110 (let ((digit (% (nth 3 dtime) 10)))
3112 ((memq (nth 3 dtime) '(11 12 13)) "th")
3118 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3120 (number-to-string (nth 5 dtime))
3122 (format "%02d" (nth 2 dtime))
3124 (format "%02d" (nth 1 dtime)))))))
3126 (format "Date: %s (from T-gnus)" date))))
3128 (defun article-date-local (&optional highlight)
3129 "Convert the current article date to the local timezone."
3130 (interactive (list t))
3131 (article-date-ut 'local highlight))
3133 (defun article-date-english (&optional highlight)
3134 "Convert the current article date to something that is proper English."
3135 (interactive (list t))
3136 (article-date-ut 'english highlight))
3138 (defun article-date-original (&optional highlight)
3139 "Convert the current article date to what it was originally.
3140 This is only useful if you have used some other date conversion
3141 function and want to see what the date was before converting."
3142 (interactive (list t))
3143 (article-date-ut 'original highlight))
3145 (defun article-date-lapsed (&optional highlight)
3146 "Convert the current article date to time lapsed since it was sent."
3147 (interactive (list t))
3148 (article-date-ut 'lapsed highlight))
3150 (defun article-update-date-lapsed ()
3151 "Function to be run from a timer to update the lapsed time line."
3152 (let (deactivate-mark)
3157 (set-buffer (window-buffer w))
3158 (when (eq major-mode 'gnus-article-mode)
3159 (let ((mark (point-marker)))
3160 (goto-char (point-min))
3161 (when (re-search-forward "^X-Sent:" nil t)
3162 (article-date-lapsed t))
3163 (goto-char (marker-position mark))
3164 (move-marker mark nil))))
3167 (defun gnus-start-date-timer (&optional n)
3168 "Start a timer to update the X-Sent header in the article buffers.
3169 The numerical prefix says how frequently (in seconds) the function
3174 (gnus-stop-date-timer)
3175 (setq article-lapsed-timer
3176 (run-at-time 1 n 'article-update-date-lapsed)))
3178 (defun gnus-stop-date-timer ()
3179 "Stop the X-Sent timer."
3181 (when article-lapsed-timer
3182 (nnheader-cancel-timer article-lapsed-timer)
3183 (setq article-lapsed-timer nil)))
3185 (defun article-date-user (&optional highlight)
3186 "Convert the current article date to the user-defined format.
3187 This format is defined by the `gnus-article-time-format' variable."
3188 (interactive (list t))
3189 (article-date-ut 'user highlight))
3191 (defun article-date-iso8601 (&optional highlight)
3192 "Convert the current article date to ISO8601."
3193 (interactive (list t))
3194 (article-date-ut 'iso8601 highlight))
3196 ;; (defun article-show-all ()
3197 ;; "Show all hidden text in the article buffer."
3201 ;; (let ((buffer-read-only nil))
3202 ;; (gnus-article-unhide-text (point-min) (point-max))
3203 ;; (gnus-remove-text-with-property 'gnus-prev)
3204 ;; (gnus-remove-text-with-property 'gnus-next))))
3206 (defun article-show-all-headers ()
3207 "Show all hidden headers in the article buffer."
3212 (article-narrow-to-head)
3213 (let ((buffer-read-only nil))
3214 (gnus-article-unhide-text (point-min) (point-max))))))
3216 (defun article-remove-leading-whitespace ()
3217 "Remove excessive whitespace from all headers."
3221 (let ((buffer-read-only nil))
3222 (article-narrow-to-head)
3223 (goto-char (point-min))
3224 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3225 (delete-region (match-beginning 1) (match-end 1)))))))
3227 (defun article-emphasize (&optional arg)
3228 "Emphasize text according to `gnus-emphasis-alist'."
3229 (interactive (gnus-article-hidden-arg))
3230 (unless (gnus-article-check-hidden-text 'emphasis arg)
3234 (with-current-buffer gnus-summary-buffer
3235 gnus-article-emphasis-alist)
3237 gnus-emphasis-alist))
3238 (buffer-read-only nil)
3239 (props (append '(article-type emphasis)
3240 gnus-hidden-properties))
3241 regexp elem beg invisible visible face)
3244 (while (setq elem (pop alist))
3246 (setq regexp (car elem)
3247 invisible (nth 1 elem)
3248 visible (nth 2 elem)
3250 (while (re-search-forward regexp nil t)
3251 (when (and (match-beginning visible) (match-beginning invisible))
3252 (gnus-article-hide-text
3253 (match-beginning invisible) (match-end invisible) props)
3254 (gnus-article-unhide-text-type
3255 (match-beginning visible) (match-end visible) 'emphasis)
3256 (gnus-put-overlay-excluding-newlines
3257 (match-beginning visible) (match-end visible) 'face face)
3258 (gnus-add-wash-type 'emphasis)
3259 (goto-char (match-end invisible)))))))))
3261 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3262 "Setup newsgroup emphasis alist."
3263 (unless gnus-article-emphasis-alist
3264 (let ((name (and gnus-newsgroup-name
3265 (gnus-group-real-name gnus-newsgroup-name))))
3266 (make-local-variable 'gnus-article-emphasis-alist)
3267 (setq gnus-article-emphasis-alist
3269 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3270 (while (setq elem (pop alist))
3271 (when (and name (string-match (car elem) name))
3273 highlight (copy-sequence (cdr elem)))))
3275 (copy-sequence highlight-words)
3276 (if gnus-newsgroup-name
3277 (copy-sequence (gnus-group-find-parameter
3278 gnus-newsgroup-name 'highlight-words t)))
3279 gnus-emphasis-alist)))))
3282 (defvar gnus-summary-article-menu)
3283 (defvar gnus-summary-post-menu))
3285 ;;; Saving functions.
3287 (defun gnus-article-save (save-buffer file &optional num)
3288 "Save the currently selected article."
3289 (unless gnus-save-all-headers
3290 ;; Remove headers according to `gnus-saved-headers'.
3291 (let ((gnus-visible-headers
3292 (or gnus-saved-headers gnus-visible-headers))
3293 (gnus-article-buffer save-buffer))
3295 (set-buffer save-buffer)
3296 (article-hide-headers 1 t))))
3297 (save-window-excursion
3298 (if (not gnus-default-article-saver)
3299 (error "No default saver is defined")
3300 ;; !!! Magic! The saving functions all save
3301 ;; `gnus-save-article-buffer' (or so they think), but we
3302 ;; bind that variable to our save-buffer.
3303 (set-buffer gnus-article-buffer)
3304 (let* ((gnus-save-article-buffer save-buffer)
3307 ((not gnus-prompt-before-saving) 'default)
3308 ((eq gnus-prompt-before-saving 'always) nil)
3310 (gnus-number-of-articles-to-be-saved
3311 (when (eq gnus-prompt-before-saving t)
3313 (set-buffer gnus-article-current-summary)
3314 (funcall gnus-default-article-saver filename)))))
3316 (defun gnus-read-save-file-name (prompt &optional filename
3317 function group headers variable)
3319 (funcall function group headers (symbol-value variable)))
3324 ((eq filename 'default)
3330 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3333 (if (and gnus-number-of-articles-to-be-saved
3334 (> gnus-number-of-articles-to-be-saved 1))
3335 (format "these %d articles"
3336 gnus-number-of-articles-to-be-saved)
3339 ;; Let the split methods have their say.
3341 ;; No split name was found.
3344 (concat prompt " (default "
3345 (file-name-nondirectory default-name) ") ")
3346 (file-name-directory default-name)
3348 ;; A single group name is returned.
3349 ((stringp split-name)
3351 (funcall function split-name headers
3352 (symbol-value variable)))
3354 (concat prompt " (default "
3355 (file-name-nondirectory default-name) ") ")
3356 (file-name-directory default-name)
3358 ;; A single split name was found
3359 ((= 1 (length split-name))
3360 (let* ((name (expand-file-name
3362 gnus-article-save-directory))
3363 (dir (cond ((file-directory-p name)
3364 (file-name-as-directory name))
3365 ((file-exists-p name) name)
3366 (t gnus-article-save-directory))))
3368 (concat prompt " (default " name ") ")
3370 ;; A list of splits was found.
3372 (setq split-name (nreverse split-name))
3374 (let ((file-name-history
3375 (nconc split-name file-name-history)))
3379 (concat prompt " (`M-p' for defaults) ")
3380 gnus-article-save-directory
3382 gnus-article-save-directory)))
3383 (car (push result file-name-history)))))))
3384 ;; Create the directory.
3385 (gnus-make-directory (file-name-directory file))
3386 ;; If we have read a directory, we append the default file name.
3387 (when (file-directory-p file)
3388 (setq file (expand-file-name (file-name-nondirectory
3390 (file-name-as-directory file))))
3391 ;; Possibly translate some characters.
3392 (nnheader-translate-file-chars file))))))
3393 (gnus-make-directory (file-name-directory result))
3394 (set variable result)))
3396 (defun gnus-article-archive-name (group)
3397 "Return the first instance of an \"Archive-name\" in the current buffer."
3398 (let ((case-fold-search t))
3399 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3400 (nnheader-concat gnus-article-save-directory
3401 (match-string 1)))))
3403 (defun gnus-article-nndoc-name (group)
3404 "If GROUP is an nndoc group, return the name of the parent group."
3405 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3406 (gnus-group-get-parameter group 'save-article-group)))
3408 (defun gnus-summary-save-in-rmail (&optional filename)
3409 "Append this article to Rmail file.
3410 Optional argument FILENAME specifies file name.
3411 Directory to save to is default to `gnus-article-save-directory'."
3412 (setq filename (gnus-read-save-file-name
3413 "Save %s in rmail file:" filename
3414 gnus-rmail-save-name gnus-newsgroup-name
3415 gnus-current-headers 'gnus-newsgroup-last-rmail))
3416 (gnus-eval-in-buffer-window gnus-save-article-buffer
3420 (gnus-output-to-rmail filename))))
3423 (defun gnus-summary-save-in-mail (&optional filename)
3424 "Append this article to Unix mail file.
3425 Optional argument FILENAME specifies file name.
3426 Directory to save to is default to `gnus-article-save-directory'."
3427 (setq filename (gnus-read-save-file-name
3428 "Save %s in Unix mail file:" filename
3429 gnus-mail-save-name gnus-newsgroup-name
3430 gnus-current-headers 'gnus-newsgroup-last-mail))
3431 (gnus-eval-in-buffer-window gnus-save-article-buffer
3435 (if (and (file-readable-p filename)
3436 (file-regular-p filename)
3437 (mail-file-babyl-p filename))
3438 (rmail-output-to-rmail-file filename t)
3439 (gnus-output-to-mail filename)))))
3442 (defun gnus-summary-save-in-file (&optional filename overwrite)
3443 "Append this article to file.
3444 Optional argument FILENAME specifies file name.
3445 Directory to save to is default to `gnus-article-save-directory'."
3446 (setq filename (gnus-read-save-file-name
3447 "Save %s in file:" filename
3448 gnus-file-save-name gnus-newsgroup-name
3449 gnus-current-headers 'gnus-newsgroup-last-file))
3450 (gnus-eval-in-buffer-window gnus-save-article-buffer
3454 (when (and overwrite
3455 (file-exists-p filename))
3456 (delete-file filename))
3457 (gnus-output-to-file filename))))
3460 (defun gnus-summary-write-to-file (&optional filename)
3461 "Write this article to a file, overwriting it if the file exists.
3462 Optional argument FILENAME specifies file name.
3463 The directory to save in defaults to `gnus-article-save-directory'."
3464 (gnus-summary-save-in-file nil t))
3466 (defun gnus-summary-save-body-in-file (&optional filename)
3467 "Append this article body to a file.
3468 Optional argument FILENAME specifies file name.
3469 The directory to save in defaults to `gnus-article-save-directory'."
3470 (setq filename (gnus-read-save-file-name
3471 "Save %s body in file:" filename
3472 gnus-file-save-name gnus-newsgroup-name
3473 gnus-current-headers 'gnus-newsgroup-last-file))
3474 (gnus-eval-in-buffer-window gnus-save-article-buffer
3478 (when (article-goto-body)
3479 (narrow-to-region (point) (point-max)))
3480 (gnus-output-to-file filename))))
3483 (defun gnus-summary-save-in-pipe (&optional command)
3484 "Pipe this article to subprocess."
3486 (cond ((and (eq command 'default)
3487 gnus-last-shell-command)
3488 gnus-last-shell-command)
3493 "Shell command on %s: "
3494 (if (and gnus-number-of-articles-to-be-saved
3495 (> gnus-number-of-articles-to-be-saved 1))
3496 (format "these %d articles"
3497 gnus-number-of-articles-to-be-saved)
3499 gnus-last-shell-command))))
3500 (when (string-equal command "")
3501 (if gnus-last-shell-command
3502 (setq command gnus-last-shell-command)
3503 (error "A command is required")))
3504 (gnus-eval-in-buffer-window gnus-article-buffer
3507 (shell-command-on-region (point-min) (point-max) command nil)))
3508 (setq gnus-last-shell-command command))
3510 (defun gnus-summary-pipe-to-muttprint (&optional command)
3511 "Pipe this article to muttprint."
3512 (setq command (read-string
3513 "Print using command: " gnus-summary-muttprint-program
3514 nil gnus-summary-muttprint-program))
3515 (gnus-summary-save-in-pipe command))
3517 ;;; Article file names when saving.
3519 (defun gnus-capitalize-newsgroup (newsgroup)
3520 "Capitalize NEWSGROUP name."
3521 (when (not (zerop (length newsgroup)))
3522 (concat (char-to-string (upcase (aref newsgroup 0)))
3523 (substring newsgroup 1))))
3525 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3526 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3527 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3528 Otherwise, it is like ~/News/news/group/num."
3531 (concat (if (gnus-use-long-file-name 'not-save)
3532 (gnus-capitalize-newsgroup newsgroup)
3533 (gnus-newsgroup-directory-form newsgroup))
3534 "/" (int-to-string (mail-header-number headers)))
3535 gnus-article-save-directory)))
3537 (string-equal (file-name-directory default)
3538 (file-name-directory last-file))
3539 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3541 (or last-file default))))
3543 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3544 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3545 If variable `gnus-use-long-file-name' is non-nil, it is
3546 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3549 (concat (if (gnus-use-long-file-name 'not-save)
3551 (gnus-newsgroup-directory-form newsgroup))
3552 "/" (int-to-string (mail-header-number headers)))
3553 gnus-article-save-directory)))
3555 (string-equal (file-name-directory default)
3556 (file-name-directory last-file))
3557 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3559 (or last-file default))))
3561 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3562 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3563 If variable `gnus-use-long-file-name' is non-nil, it is
3564 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3567 (if (gnus-use-long-file-name 'not-save)
3570 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3572 gnus-article-save-directory)))
3574 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3575 "Generate file name from sender."
3576 (let ((from (mail-header-from headers)))
3578 (if (and from (string-match "\\([^ <]+\\)@" from))
3579 (match-string 1 from)
3581 gnus-article-save-directory)))
3583 (defun article-verify-x-pgp-sig ()
3586 (if (gnus-buffer-live-p gnus-original-article-buffer)
3587 (let ((sig (with-current-buffer gnus-original-article-buffer
3588 (gnus-fetch-field "X-PGP-Sig")))
3592 (mml2015-clear-verify-function))
3594 (insert-buffer-substring gnus-original-article-buffer)
3595 (setq items (split-string sig))
3596 (message-narrow-to-head)
3597 (let ((inhibit-point-motion-hooks t)
3598 (case-fold-search t))
3599 ;; Don't verify multiple headers.
3600 (setq headers (mapconcat (lambda (header)
3602 (mail-fetch-field header)
3604 (split-string (nth 1 items) ",") "")))
3605 (delete-region (point-min) (point-max))
3606 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3607 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3612 (if (looking-at "^-")
3615 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3616 (insert "Version: " (car items) "\n\n")
3617 (insert (mapconcat 'identity (cddr items) "\n"))
3618 (insert "\n-----END PGP SIGNATURE-----\n")
3619 (let ((mm-security-handle (list (format "multipart/signed"))))
3620 (mml2015-clean-buffer)
3621 (let ((coding-system-for-write (or gnus-newsgroup-charset
3623 (funcall (mml2015-clear-verify-function)))
3625 (or (mm-handle-multipart-ctl-parameter
3626 mm-security-handle 'gnus-details)
3627 (mm-handle-multipart-ctl-parameter
3628 mm-security-handle 'gnus-info)))))
3630 (let (buffer-read-only bface eface)
3632 (message-narrow-to-head)
3633 (goto-char (point-max))
3635 (setq bface (get-text-property (point-at-bol) 'face)
3636 eface (get-text-property (1- (point-at-eol)) 'face))
3637 (message-remove-header "X-Gnus-PGP-Verify")
3638 (if (re-search-forward "^X-PGP-Sig:" nil t)
3640 (goto-char (point-max)))
3641 (narrow-to-region (point) (point))
3642 (insert "X-Gnus-PGP-Verify: " info "\n")
3643 (goto-char (point-min))
3646 (if (not (looking-at "^[ \t]"))
3650 (goto-char (point-min))
3651 (when (looking-at "\\([^:]+\\): *")
3652 (put-text-property (match-beginning 1) (1+ (match-end 1))
3654 (put-text-property (match-end 0) (point-max)
3655 'face eface)))))))))
3657 (defun article-verify-cancel-lock ()
3658 "Verify Cancel-Lock header."
3660 (if (gnus-buffer-live-p gnus-original-article-buffer)
3661 (canlock-verify gnus-original-article-buffer)))
3663 (defun article-monafy ()
3664 "Display body part with mona font."
3666 (unless (if (featurep 'xemacs)
3667 (find-face 'gnus-mona-face)
3668 (facep 'gnus-mona-face))
3669 (require 'navi2ch-mona)
3670 (set-face-font (make-face 'gnus-mona-face) navi2ch-mona-font))
3672 (let ((buffer-read-only nil))
3675 (gnus-make-overlay (point) (point-max))
3676 'face 'gnus-mona-face))))
3683 (setq afunc (car func)
3686 gfunc (intern (format "gnus-%s" func))))
3688 (when (fboundp afunc)
3689 `(lambda (&optional interactive &rest args)
3690 ,(documentation afunc t)
3691 (interactive (list t))
3693 (set-buffer gnus-article-buffer)
3695 (call-interactively ',afunc)
3696 (apply ',afunc args))))))))
3697 '(article-hide-headers
3698 article-verify-x-pgp-sig
3699 article-verify-cancel-lock
3701 article-hide-boring-headers
3702 article-treat-overstrike
3703 article-treat-ansi-sequences
3704 article-fill-long-lines
3705 article-capitalize-sentences
3707 article-remove-leading-whitespace
3708 article-display-x-face
3709 article-display-face
3710 article-de-quoted-unreadable
3711 article-de-base64-unreadable
3714 article-unsplit-urls
3715 article-hide-list-identifiers
3716 article-strip-banner
3719 article-hide-signature
3720 article-strip-headers-in-body
3721 article-remove-trailing-blank-lines
3722 article-strip-leading-blank-lines
3723 article-strip-multiple-blank-lines
3724 article-strip-leading-space
3725 article-strip-trailing-space
3726 article-strip-blank-lines
3727 article-strip-all-blank-lines
3729 article-date-english
3730 article-date-iso8601
3731 article-date-original
3733 article-decode-mime-words
3734 article-decode-charset
3735 article-decode-encoded-words
3739 article-treat-dumbquotes
3740 article-normalize-headers
3741 (article-show-all-headers . gnus-article-show-all-headers)
3742 ;; (article-show-all . gnus-article-show-all)
3746 ;;; Gnus article mode
3749 (put 'gnus-article-mode 'mode-class 'special)
3751 (gnus-define-keys gnus-article-mode-map
3752 " " gnus-article-goto-next-page
3753 "\177" gnus-article-goto-prev-page
3754 [delete] gnus-article-goto-prev-page
3755 [backspace] gnus-article-goto-prev-page
3756 "\C-c^" gnus-article-refer-article
3757 "h" gnus-article-show-summary
3758 "s" gnus-article-show-summary
3759 "\C-c\C-m" gnus-article-mail
3760 "?" gnus-article-describe-briefly
3761 "e" gnus-summary-edit-article
3762 "<" beginning-of-buffer
3764 "\C-c\C-i" gnus-info-find-node
3766 "R" gnus-article-reply-with-original
3767 "F" gnus-article-followup-with-original
3768 "\C-hk" gnus-article-describe-key
3769 "\C-hc" gnus-article-describe-key-briefly
3771 "\C-d" gnus-article-read-summary-keys
3772 "\M-*" gnus-article-read-summary-keys
3773 "\M-#" gnus-article-read-summary-keys
3774 "\M-^" gnus-article-read-summary-keys
3775 "\M-g" gnus-article-read-summary-keys)
3777 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3781 (push (char-to-string key) keys)
3783 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3784 (setq key (car elem))
3785 (when (and (> (length key) 0)
3786 (not (eq 'menu-bar (aref key 0)))
3787 (symbolp (lookup-key gnus-summary-mode-map key)))
3790 (unless (lookup-key gnus-article-mode-map key)
3791 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3793 (defun gnus-article-make-menu-bar ()
3794 (unless (boundp 'gnus-article-commands-menu)
3795 (gnus-summary-make-menu-bar))
3796 (gnus-turn-off-edit-menu 'article)
3797 (unless (boundp 'gnus-article-article-menu)
3799 gnus-article-article-menu gnus-article-mode-map ""
3801 ["Scroll forwards" gnus-article-goto-next-page t]
3802 ["Scroll backwards" gnus-article-goto-prev-page t]
3803 ["Show summary" gnus-article-show-summary t]
3804 ["Fetch Message-ID at point" gnus-article-refer-article t]
3805 ["Mail to address at point" gnus-article-mail t]
3806 ["Send a bug report" gnus-bug t]))
3809 gnus-article-treatment-menu gnus-article-mode-map ""
3810 ;; Fixme: this should use :active (and maybe :visible).
3812 ["Hide headers" gnus-article-hide-headers t]
3813 ["Hide signature" gnus-article-hide-signature t]
3814 ["Hide citation" gnus-article-hide-citation t]
3815 ["Treat overstrike" gnus-article-treat-overstrike t]
3816 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
3817 ["Remove carriage return" gnus-article-remove-cr t]
3818 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3819 ["Treat html" gnus-article-wash-html t]
3820 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3821 ["Decode HZ" gnus-article-decode-HZ t]))
3823 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3825 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3827 (gnus-run-hooks 'gnus-article-menu-hook)))
3829 (defun gnus-article-mode ()
3830 "Major mode for displaying an article.
3832 All normal editing commands are switched off.
3834 The following commands are available in addition to all summary mode
3836 \\<gnus-article-mode-map>
3837 \\[gnus-article-next-page]\t Scroll the article one page forwards
3838 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3839 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3840 \\[gnus-article-show-summary]\t Display the summary buffer
3841 \\[gnus-article-mail]\t Send a reply to the address near point
3842 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3843 \\[gnus-info-find-node]\t Go to the Gnus info node"
3845 (gnus-simplify-mode-line)
3846 (setq mode-name "Article")
3847 (setq major-mode 'gnus-article-mode)
3848 (make-local-variable 'minor-mode-alist)
3849 (unless (assq 'gnus-show-mime minor-mode-alist)
3850 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3851 (use-local-map gnus-article-mode-map)
3852 (when (gnus-visual-p 'article-menu 'menu)
3853 (gnus-article-make-menu-bar)
3854 (when gnus-summary-tool-bar-map
3855 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3856 (gnus-update-format-specifications nil 'article-mode)
3857 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3858 (set (make-local-variable 'gnus-page-broken) nil)
3859 (make-local-variable 'gnus-button-marker-list)
3860 (make-local-variable 'gnus-article-current-summary)
3861 (make-local-variable 'gnus-article-mime-handles)
3862 (make-local-variable 'gnus-article-decoded-p)
3863 (make-local-variable 'gnus-article-mime-handle-alist)
3864 (make-local-variable 'gnus-article-wash-types)
3865 (make-local-variable 'gnus-article-image-alist)
3866 (make-local-variable 'gnus-article-charset)
3867 (make-local-variable 'gnus-article-ignored-charsets)
3868 (gnus-set-default-directory)
3869 (buffer-disable-undo)
3870 (setq buffer-read-only t
3871 show-trailing-whitespace nil)
3872 (set-syntax-table gnus-article-mode-syntax-table)
3873 (gnus-run-hooks 'gnus-article-mode-hook))
3875 (defun gnus-article-setup-buffer ()
3876 "Initialize the article buffer."
3877 (let* ((name (if gnus-single-article-buffer "*Article*"
3878 (concat "*Article " gnus-newsgroup-name "*")))
3880 (progn (string-match "\\*Article" name)
3881 (concat " *Original Article"
3882 (substring name (match-end 0))))))
3883 (setq gnus-article-buffer name)
3884 (setq gnus-original-article-buffer original)
3885 (setq gnus-article-mime-handle-alist nil)
3886 ;; This might be a variable local to the summary buffer.
3887 (unless gnus-single-article-buffer
3889 (set-buffer gnus-summary-buffer)
3890 (setq gnus-article-buffer name)
3891 (setq gnus-original-article-buffer original)
3892 (gnus-set-global-variables)))
3893 (gnus-article-setup-highlight-words)
3894 ;; Init original article buffer.
3896 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3897 (set-buffer-multibyte t)
3898 (setq major-mode 'gnus-original-article-mode)
3899 (make-local-variable 'gnus-original-article))
3900 (if (get-buffer name)
3903 (when (and gnus-article-edit-mode
3906 (y-or-n-p "Article mode edit in progress; discard? ")))
3907 (error "Action aborted"))
3908 (set (make-local-variable 'gnus-article-edit-mode) nil)
3909 (buffer-disable-undo)
3910 (setq buffer-read-only t)
3911 ;; This list just keeps growing if we don't reset it.
3912 (setq gnus-button-marker-list nil)
3913 (unless (eq major-mode 'gnus-article-mode)
3914 (gnus-article-mode))
3917 (set-buffer (gnus-get-buffer-create name))
3919 (make-local-variable 'gnus-summary-buffer)
3920 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3921 (current-buffer)))))
3923 ;; Set article window start at LINE, where LINE is the number of lines
3924 ;; from the head of the article.
3925 (defun gnus-article-set-window-start (&optional line)
3927 (gnus-get-buffer-window gnus-article-buffer t)
3929 (set-buffer gnus-article-buffer)
3930 (goto-char (point-min))
3933 (gnus-message 6 "Moved to bookmark")
3934 (search-forward "\n\n" nil t)
3938 ;;; @@ article filters
3941 (defun gnus-article-display-mime-message ()
3942 "Article display method for MIME message."
3943 ;; called from `gnus-original-article-buffer'.
3944 (let (charset all-headers)
3945 (with-current-buffer gnus-summary-buffer
3946 (setq charset default-mime-charset
3947 all-headers gnus-have-all-headers))
3948 (make-local-variable 'default-mime-charset)
3949 (setq default-mime-charset charset)
3950 (with-current-buffer (get-buffer-create gnus-article-buffer)
3951 (make-local-variable 'default-mime-charset)
3952 (setq default-mime-charset charset))
3953 (mime-display-message mime-message-structure
3954 gnus-article-buffer nil gnus-article-mode-map)
3956 (gnus-article-hide-headers nil -1)))
3957 (run-hooks 'gnus-mime-article-prepare-hook))
3959 (defun gnus-article-display-traditional-message ()
3960 "Article display method for traditional message."
3961 (set-buffer gnus-article-buffer)
3962 (let (buffer-read-only)
3964 (insert-buffer-substring gnus-original-article-buffer)))
3966 (defun gnus-article-make-full-mail-header (&optional number charset)
3967 "Create a new mail header structure in a raw article buffer."
3968 (unless (and number charset)
3969 (save-current-buffer
3970 (set-buffer gnus-summary-buffer)
3972 (setq number (or (cdr gnus-article-current) 0)))
3974 (setq charset (or default-mime-charset 'x-ctext)))))
3975 (goto-char (point-min))
3976 (let ((header-end (if (search-forward "\n\n" nil t)
3978 (goto-char (point-max))))
3979 (chars (- (point-max) (point)))
3980 (lines (count-lines (point) (point-max)))
3981 (default-mime-charset charset)
3983 (narrow-to-region (point-min) header-end)
3984 (setq xref (std11-fetch-field "xref"))
3986 (make-full-mail-header
3988 (std11-fetch-field "subject")
3989 (std11-fetch-field "from")
3990 (std11-fetch-field "date")
3991 (std11-fetch-field "message-id")
3992 (std11-fetch-field "references")
3995 (when xref (concat "Xref: " xref)))
3998 (defun gnus-article-prepare (article &optional all-headers header)
3999 "Prepare ARTICLE in article mode buffer.
4000 ARTICLE should either be an article number or a Message-ID.
4001 If ARTICLE is an id, HEADER should be the article headers.
4002 If ALL-HEADERS is non-nil, no headers are hidden."
4004 ;; Make sure we start in a summary buffer.
4005 (unless (eq major-mode 'gnus-summary-mode)
4006 (set-buffer gnus-summary-buffer))
4007 (setq gnus-summary-buffer (current-buffer))
4008 (let* ((gnus-article (if header (mail-header-number header) article))
4009 (summary-buffer (current-buffer))
4010 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4011 (group gnus-newsgroup-name)
4014 (gnus-article-setup-buffer)
4015 (set-buffer gnus-article-buffer)
4016 ;; Deactivate active regions.
4017 (when (and (boundp 'transient-mark-mode)
4018 transient-mark-mode)
4019 (setq mark-active nil))
4020 (if (not (setq result (let ((buffer-read-only nil))
4021 (gnus-request-article-this-buffer
4023 ;; There is no such article.
4025 (when (and (numberp article)
4026 (not (memq article gnus-newsgroup-sparse)))
4027 (setq gnus-article-current
4028 (cons gnus-newsgroup-name article))
4029 (set-buffer gnus-summary-buffer)
4030 (setq gnus-current-article article)
4031 (if (and (memq article gnus-newsgroup-undownloaded)
4032 (not (gnus-online (gnus-find-method-for-group
4033 gnus-newsgroup-name))))
4035 (gnus-summary-set-agent-mark article)
4036 (message "Message marked for downloading"))
4037 (gnus-summary-mark-article article gnus-canceled-mark)
4038 (unless (memq article gnus-newsgroup-sparse)
4039 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4040 (if (or (eq result 'pseudo)
4041 (eq result 'nneething))
4044 (set-buffer summary-buffer)
4045 (push article gnus-newsgroup-history)
4046 (setq gnus-last-article gnus-current-article
4047 gnus-current-article 0
4048 gnus-current-headers nil
4049 gnus-article-current nil)
4050 (if (eq result 'nneething)
4051 (gnus-configure-windows 'summary)
4052 (gnus-configure-windows 'article))
4053 (gnus-set-global-variables))
4054 (let ((gnus-article-mime-handle-alist-1
4055 gnus-article-mime-handle-alist))
4056 (gnus-set-mode-line 'article)))
4057 ;; The result from the `request' was an actual article -
4058 ;; or at least some text that is now displayed in the
4060 (when (and (numberp article)
4061 (not (eq article gnus-current-article)))
4062 ;; Seems like a new article has been selected.
4063 ;; `gnus-current-article' must be an article number.
4065 (set-buffer summary-buffer)
4066 (push article gnus-newsgroup-history)
4067 (setq gnus-last-article gnus-current-article
4068 gnus-current-article article
4069 gnus-current-headers
4070 (gnus-summary-article-header gnus-current-article)
4071 gnus-article-current
4072 (cons gnus-newsgroup-name gnus-current-article))
4073 (unless (vectorp gnus-current-headers)
4074 (setq gnus-current-headers nil))
4075 (gnus-summary-goto-subject gnus-current-article)
4076 (when (gnus-summary-show-thread)
4077 ;; If the summary buffer really was folded, the
4078 ;; previous goto may not actually have gone to
4079 ;; the right article, but the thread root instead.
4081 (gnus-summary-goto-subject gnus-current-article))
4082 (gnus-run-hooks 'gnus-mark-article-hook)
4083 (gnus-set-mode-line 'summary)
4084 (when (gnus-visual-p 'article-highlight 'highlight)
4085 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4086 ;; Set the global newsgroup variables here.
4087 (gnus-set-global-variables)
4088 (setq gnus-have-all-headers
4089 (or all-headers gnus-show-all-headers))))
4091 (gnus-configure-windows 'article))
4092 (when (or (numberp article)
4094 (gnus-article-prepare-display)
4096 (goto-char (point-min))
4097 (when gnus-break-pages
4098 (gnus-narrow-to-page)))
4099 (let ((gnus-article-mime-handle-alist-1
4100 gnus-article-mime-handle-alist))
4101 (gnus-set-mode-line 'article))
4105 (set-window-point (get-buffer-window (current-buffer)) (point))
4106 (gnus-configure-windows 'article)
4109 (defun gnus-article-prepare-mime-display (&optional number)
4110 (goto-char (point-min))
4111 (when (re-search-forward "^[^\t ]+:" nil t)
4112 (goto-char (match-beginning 0)))
4113 (let ((entity (if (eq 1 (point-min))
4114 (get-text-property 1 'mime-view-entity)
4115 (get-text-property (point) 'mime-view-entity)))
4116 last-entity child-entity next type)
4117 (setq child-entity (mime-entity-children entity))
4119 (setq last-entity (nth (1- (length child-entity))
4121 (setq last-entity entity))
4123 (narrow-to-region (point)
4124 (if (search-forward "\n\n" nil t)
4127 (gnus-treat-article 'head)
4128 (put-text-property (point-min) (point-max) 'article-treated-header t)
4129 (goto-char (point-max)))
4130 (while (and (not (eobp)) entity)
4131 (setq next (set-marker
4133 (next-single-property-change (point) 'mime-view-entity
4135 (let ((types (mime-entity-content-type entity)))
4136 (while (eq 'multipart (mime-content-type-primary-type types))
4137 (setq entity (car (mime-entity-children entity))
4138 types (mime-entity-content-type entity)))
4140 (setq type (format "%s/%s"
4141 (mime-content-type-primary-type types)
4142 (mime-content-type-subtype types)))))
4143 (if (string-equal type "message/rfc822")
4146 (let ((children (mime-entity-children entity))
4149 (setq last-children (nth (1- (length children)) children))
4152 (not (eq last-children
4153 (get-text-property next 'mime-view-entity)))
4155 (next-single-property-change next
4157 nil (point-max)))))))
4158 (setq next (next-single-property-change next 'mime-view-entity
4161 (narrow-to-region (point) next)
4162 (gnus-article-prepare-mime-display)
4163 (goto-char (point-max)))
4164 (setq entity (get-text-property (point) 'mime-view-entity)))
4166 (narrow-to-region (point) next)
4167 ;; Kludge. We have to count true number, but for now,
4168 ;; part number is here only to achieve `last'.
4169 (gnus-treat-article nil 1
4170 (if (eq entity last-entity)
4173 (goto-char (point-max)))
4174 (setq entity (get-text-property next 'mime-view-entity))))))
4177 (defun gnus-article-prepare-display ()
4178 "Make the current buffer look like a nice article."
4179 (let ((gnus-article-buffer (current-buffer))
4181 (unless (eq major-mode 'gnus-article-mode)
4182 (gnus-article-mode))
4183 (setq buffer-read-only nil
4184 gnus-button-marker-list nil
4185 gnus-article-wash-types nil
4186 gnus-article-image-alist nil)
4189 (static-if (featurep 'xemacs)
4190 (map-extents (lambda (extent maparg) (delete-extent extent)))
4191 (let ((lists (overlay-lists)))
4192 (dolist (overlay (nconc (car lists) (cdr lists)))
4193 (delete-overlay overlay)))))
4194 (gnus-run-hooks 'gnus-tmp-internal-hook))
4195 (let ((show-mime (unless (member gnus-newsgroup-name '("nndraft:delayed"
4198 (inhibit-read-only t))
4199 (set-buffer gnus-original-article-buffer)
4201 (setq mime-message-structure gnus-current-headers)
4202 (mime-buffer-entity-set-buffer-internal mime-message-structure
4203 gnus-original-article-buffer)
4204 (mime-entity-set-representation-type-internal mime-message-structure
4205 'mime-buffer-entity)
4206 (luna-send mime-message-structure 'initialize-instance
4207 mime-message-structure)
4209 (let (mime-display-header-hook mime-display-text/plain-hook)
4210 (funcall gnus-article-display-method-for-mime))
4211 (funcall gnus-article-display-method-for-traditional))
4212 ;; Call the treatment functions.
4216 (gnus-article-prepare-mime-display)
4217 (narrow-to-region (goto-char (point-min))
4218 (if (search-forward "\n\n" nil t)
4221 (gnus-treat-article 'head)
4222 (put-text-property (point-min) (point-max) 'article-treated-header t)
4223 (goto-char (point-max))
4225 (narrow-to-region (point) (point-max))
4226 (gnus-treat-article nil))
4227 (put-text-property (point-min) (point-max) 'read-only nil)))
4228 (gnus-run-hooks 'gnus-article-prepare-hook))
4230 (defun gnus-article-decode-article-as-default-mime-charset ()
4231 "Decode an article as `default-mime-charset'. It won't work if the
4232 value of the variable `gnus-show-mime' is non-nil."
4233 (unless (or gnus-show-mime
4234 (member gnus-newsgroup-name '("nndraft:delayed"
4236 (set (make-local-variable 'default-mime-charset)
4237 (with-current-buffer gnus-summary-buffer
4238 default-mime-charset))
4239 (decode-mime-charset-region (point-min) (point-max)
4240 default-mime-charset)))
4243 ;;; Gnus MIME viewing functions
4246 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4247 "Format of the MIME buttons.
4249 Valid specifiers include:
4251 %T MIME type, along with additional info
4252 %n The `name' parameter
4253 %d The description, if any
4254 %l The length of the encoded part
4255 %p The part identifier number
4256 %e Dots if the part isn't displayed
4258 General format specifiers can also be used. See Info node
4259 `(gnus)Formatting Variables'.")
4261 (defvar gnus-mime-button-line-format-alist
4262 '((?t gnus-tmp-type ?s)
4263 (?T gnus-tmp-type-long ?s)
4264 (?n gnus-tmp-name ?s)
4265 (?d gnus-tmp-description ?s)
4267 (?l gnus-tmp-length ?d)
4268 (?e gnus-tmp-dots ?s)))
4270 (defvar gnus-mime-button-commands
4271 '((gnus-article-press-button "\r" "Toggle Display")
4272 (gnus-mime-view-part "v" "View Interactively...")
4273 (gnus-mime-view-part-as-type "t" "View As Type...")
4274 (gnus-mime-view-part-as-charset "C" "View As charset...")
4275 (gnus-mime-save-part "o" "Save...")
4276 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4277 (gnus-mime-delete-part "d" "Delete part")
4278 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4279 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4280 (gnus-mime-view-part-internally "E" "View Internally")
4281 (gnus-mime-view-part-externally "e" "View Externally")
4282 (gnus-mime-print-part "p" "Print")
4283 (gnus-mime-pipe-part "|" "Pipe To Command...")
4284 (gnus-mime-action-on-part "." "Take action on the part...")))
4286 (defun gnus-article-mime-part-status ()
4287 (with-current-buffer gnus-article-buffer
4288 (let ((entity (get-text-property (point-min) 'mime-view-entity))
4291 (setq children (mime-entity-children entity))
4292 (setq children (length children)))
4295 (format " (%d parts)" children))
4298 (defvar gnus-mime-button-map
4299 (let ((map (make-sparse-keymap)))
4300 (define-key map gnus-mouse-2 'gnus-article-push-button)
4301 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4302 (dolist (c gnus-mime-button-commands)
4303 (define-key map (cadr c) (car c)))
4307 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4309 ,@(mapcar (lambda (c)
4310 (vector (caddr c) (car c) :enable t))
4311 gnus-mime-button-commands)))
4313 (defun gnus-mime-button-menu (event prefix)
4314 "Construct a context-sensitive menu of MIME commands."
4315 (interactive "e\nP")
4316 (save-window-excursion
4317 (let ((pos (event-start event)))
4318 (select-window (posn-window pos))
4319 (goto-char (posn-point pos))
4320 (gnus-article-check-buffer)
4321 (popup-menu gnus-mime-button-menu nil prefix))))
4323 (defun gnus-mime-view-all-parts (&optional handles)
4324 "View all the MIME parts."
4326 (with-current-buffer gnus-article-buffer
4327 (let ((handles (or handles gnus-article-mime-handles))
4328 (mail-parse-charset gnus-newsgroup-charset)
4329 (mail-parse-ignored-charsets
4330 (with-current-buffer gnus-summary-buffer
4331 gnus-newsgroup-ignored-charsets)))
4333 (mm-remove-parts handles)
4334 (goto-char (point-min))
4335 (or (search-forward "\n\n") (goto-char (point-max)))
4336 (let (buffer-read-only)
4337 (delete-region (point) (point-max))
4338 (mm-display-parts handles))))))
4341 (defsubst gnus-article-edit-part (handles)
4342 "Edit an article in order to delete a mime part.
4343 This function is exclusively used by `gnus-mime-save-part-and-strip'
4344 and `gnus-mime-delete-part', and not provided at run-time normally."
4345 (gnus-article-edit-article
4348 (let ((mail-parse-charset (or gnus-article-charset
4349 ',gnus-newsgroup-charset))
4350 (mail-parse-ignored-charsets
4351 (or gnus-article-ignored-charsets
4352 ',gnus-newsgroup-ignored-charsets))
4353 (mbl mml-buffer-list))
4354 (setq mml-buffer-list nil)
4355 (insert-buffer gnus-original-article-buffer)
4356 (mime-to-mml ',handles)
4357 (setq gnus-article-mime-handles nil)
4358 (let ((mbl1 mml-buffer-list))
4359 (setq mml-buffer-list mbl)
4360 (set (make-local-variable 'mml-buffer-list) mbl1))
4361 (gnus-make-local-hook 'kill-buffer-hook)
4362 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4363 `(lambda (no-highlight)
4364 (let ((mail-parse-charset (or gnus-article-charset
4365 ',gnus-newsgroup-charset))
4366 (message-options message-options)
4367 (message-options-set-recipient)
4368 (mail-parse-ignored-charsets
4369 (or gnus-article-ignored-charsets
4370 ',gnus-newsgroup-ignored-charsets)))
4372 (mml-destroy-buffers)
4373 (remove-hook 'kill-buffer-hook
4374 'mml-destroy-buffers t)
4375 (kill-local-variable 'mml-buffer-list))
4376 (gnus-summary-edit-article-done
4377 ,(or (mail-header-references gnus-current-headers) "")
4378 ,(gnus-group-read-only-p)
4379 ,gnus-summary-buffer no-highlight)))
4380 (gnus-article-edit-done)
4381 (gnus-summary-expand-window)
4382 (gnus-summary-show-article)))
4384 (defun gnus-mime-save-part-and-strip ()
4385 "Save the MIME part under point then replace it with an external body."
4387 (gnus-article-check-buffer)
4388 (when (gnus-group-read-only-p)
4389 (error "The current group does not support deleting of parts"))
4390 (when (mm-complicated-handles gnus-article-mime-handles)
4392 The current article has a complicated MIME structure, giving up..."))
4393 (when (gnus-yes-or-no-p "\
4394 Deleting parts may malfunction or destroy the article; continue? ")
4395 (let* ((data (get-text-property (point) 'gnus-data))
4397 (handles gnus-article-mime-handles))
4398 (setq file (and data (mm-save-part data)))
4400 (with-current-buffer (mm-handle-buffer data)
4402 (insert "Content-Type: " (mm-handle-media-type data))
4403 (mml-insert-parameter-string (cdr (mm-handle-type data))
4406 (insert "Content-ID: " (message-make-message-id) "\n")
4407 (insert "Content-Transfer-Encoding: binary\n")
4410 (cdr (mm-make-handle nil
4411 `("message/external-body"
4412 (access-type . "LOCAL-FILE")
4414 (set-buffer gnus-summary-buffer)
4415 (gnus-article-edit-part handles)))))
4417 (defun gnus-mime-delete-part ()
4418 "Delete the MIME part under point.
4419 Replace it with some information about the removed part."
4421 (gnus-article-check-buffer)
4422 (when (gnus-group-read-only-p)
4423 (error "The current group does not support deleting of parts"))
4424 (when (mm-complicated-handles gnus-article-mime-handles)
4426 The current article has a complicated MIME structure, giving up..."))
4427 (when (gnus-yes-or-no-p "\
4428 Deleting parts may malfunction or destroy the article; continue? ")
4429 (let* ((data (get-text-property (point) 'gnus-data))
4430 (handles gnus-article-mime-handles)
4434 (mail-decode-encoded-word-string (or (mm-handle-description data)
4437 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4439 (type (mm-handle-media-type data)))
4441 (error "No MIME part under point"))
4442 (with-current-buffer (mm-handle-buffer data)
4443 (let ((bsize (format "%s" (buffer-size))))
4448 "| The following attachment has been deleted:\n"
4450 "| Type: " type "\n"
4451 "| Filename: " filename "\n"
4452 "| Size (encoded): " bsize " Byte\n"
4453 "| Description: " description "\n"
4456 (cdr (mm-make-handle
4457 nil `("text/plain") nil nil
4459 (format "Deleted attachment (%s bytes)" bsize))))))
4460 (set-buffer gnus-summary-buffer)
4461 (gnus-article-edit-part handles))))
4463 (defun gnus-mime-save-part ()
4464 "Save the MIME part under point."
4466 (gnus-article-check-buffer)
4467 (let ((data (get-text-property (point) 'gnus-data)))
4469 (mm-save-part data))))
4471 (defun gnus-mime-pipe-part ()
4472 "Pipe the MIME part under point to a process."
4474 (gnus-article-check-buffer)
4475 (let ((data (get-text-property (point) 'gnus-data)))
4477 (mm-pipe-part data))))
4479 (defun gnus-mime-view-part ()
4480 "Interactively choose a viewing method for the MIME part under point."
4482 (gnus-article-check-buffer)
4483 (let ((data (get-text-property (point) 'gnus-data)))
4485 (setq gnus-article-mime-handles
4487 gnus-article-mime-handles (setq data (copy-sequence data))))
4488 (mm-interactively-view-part data))))
4490 (defun gnus-mime-view-part-as-type-internal ()
4491 (gnus-article-check-buffer)
4492 (let* ((name (mail-content-type-get
4493 (mm-handle-type (get-text-property (point) 'gnus-data))
4495 (def-type (and name (mm-default-file-encoding name))))
4496 (and def-type (cons def-type 0))))
4498 (defun gnus-mime-view-part-as-type (&optional mime-type)
4499 "Choose a MIME media type, and view the part as such."
4502 (setq mime-type (completing-read
4503 "View as MIME type: "
4504 (mapcar #'list (mailcap-mime-types))
4506 (gnus-mime-view-part-as-type-internal))))
4507 (gnus-article-check-buffer)
4508 (let ((handle (get-text-property (point) 'gnus-data)))
4511 (mm-make-handle (mm-handle-buffer handle)
4512 (cons mime-type (cdr (mm-handle-type handle)))
4513 (mm-handle-encoding handle)
4514 (mm-handle-undisplayer handle)
4515 (mm-handle-disposition handle)
4516 (mm-handle-description handle)
4518 (mm-handle-id handle)))
4519 (setq gnus-article-mime-handles
4520 (mm-merge-handles gnus-article-mime-handles handle))
4521 (gnus-mm-display-part handle))))
4524 (require 'jka-compr))
4526 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4527 ;; emacs can do that itself.
4529 (defun gnus-mime-jka-compr-maybe-uncompress ()
4530 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4531 The uncompress method used is derived from `buffer-file-name'."
4532 (when (and (fboundp 'jka-compr-installed-p)
4533 (jka-compr-installed-p))
4534 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4536 (let ((basename (file-name-nondirectory buffer-file-name))
4537 (args (jka-compr-info-uncompress-args info))
4538 (prog (jka-compr-info-uncompress-program info))
4539 (message (jka-compr-info-uncompress-message info))
4540 (err-file (jka-compr-make-temp-name)))
4542 (message "%s %s..." message basename))
4544 (unless (memq (apply 'call-process-region
4545 (point-min) (point-max)
4547 t (list t err-file) nil
4549 jka-compr-acceptable-retval-list)
4550 (jka-compr-error prog args basename message err-file))
4551 (jka-compr-delete-temp-file err-file)))))))
4553 (defun gnus-mime-copy-part (&optional handle)
4554 "Put the MIME part under point into a new buffer.
4555 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4558 (gnus-article-check-buffer)
4559 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4560 (contents (and handle (mm-get-part handle)))
4562 (file-name-nondirectory
4564 (mail-content-type-get (mm-handle-type handle) 'name)
4565 (mail-content-type-get (mm-handle-disposition handle)
4568 (buffer (and base (generate-new-buffer base))))
4570 (switch-to-buffer buffer)
4572 ;; We do it this way to make `normal-mode' set the appropriate mode.
4575 (setq buffer-file-name (expand-file-name base))
4576 (gnus-mime-jka-compr-maybe-uncompress)
4578 (setq buffer-file-name nil))
4579 (goto-char (point-min)))))
4581 (defun gnus-mime-print-part (&optional handle filename)
4582 "Print the MIME part under point."
4583 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4584 (gnus-article-check-buffer)
4585 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4586 (contents (and handle (mm-get-part handle)))
4587 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4588 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4593 (mm-save-part-to-file handle file)
4594 (call-process shell-file-name nil
4595 (generate-new-buffer " *mm*")
4597 shell-command-switch
4599 printer file (mm-handle-type handle))))
4603 (gnus-print-buffer))
4604 (ps-despool filename)))))
4606 (defun gnus-mime-inline-part (&optional handle arg)
4607 "Insert the MIME part under point into the current buffer."
4608 (interactive (list nil current-prefix-arg))
4609 (gnus-article-check-buffer)
4610 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4615 (if (and (not arg) (mm-handle-undisplayer handle))
4616 (mm-remove-part handle)
4617 (setq contents (mm-get-part handle))
4620 (setq charset (or (mail-content-type-get
4621 (mm-handle-type handle) 'charset)
4622 gnus-newsgroup-charset)))
4624 (if (mm-handle-undisplayer handle)
4625 (mm-remove-part handle))
4628 gnus-summary-show-article-charset-alist))
4629 (mm-read-coding-system "Charset: ")))))
4631 (mm-insert-inline handle
4633 (setq charset (mm-charset-to-coding-system
4635 (not (eq charset 'ascii)))
4636 (mm-decode-coding-string contents charset)
4640 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4641 "Insert the MIME part under point into the current buffer using the
4643 (interactive (list nil current-prefix-arg))
4644 (gnus-article-check-buffer)
4645 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4650 (if (mm-handle-undisplayer handle)
4651 (mm-remove-part handle))
4652 (let ((gnus-newsgroup-charset
4654 gnus-summary-show-article-charset-alist))
4655 (mm-read-coding-system "Charset: ")))
4656 (gnus-newsgroup-ignored-charsets 'gnus-all))
4657 (gnus-article-press-button)))))
4659 (defun gnus-mime-view-part-externally (&optional handle)
4660 "View the MIME part under point with an external viewer."
4662 (gnus-article-check-buffer)
4663 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4664 (mm-user-display-methods nil)
4665 (mm-inlined-types nil)
4666 (mail-parse-charset gnus-newsgroup-charset)
4667 (mail-parse-ignored-charsets
4668 (with-current-buffer gnus-summary-buffer
4669 gnus-newsgroup-ignored-charsets)))
4671 (if (mm-handle-undisplayer handle)
4672 (mm-remove-part handle)
4673 (mm-display-part handle)))))
4675 (defun gnus-mime-view-part-internally (&optional handle)
4676 "View the MIME part under point with an internal viewer.
4677 If no internal viewer is available, use an external viewer."
4679 (gnus-article-check-buffer)
4680 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4681 (mm-inlined-types '(".*"))
4682 (mm-inline-large-images t)
4683 (mail-parse-charset gnus-newsgroup-charset)
4684 (mail-parse-ignored-charsets
4685 (with-current-buffer gnus-summary-buffer
4686 gnus-newsgroup-ignored-charsets))
4689 (if (mm-handle-undisplayer handle)
4690 (mm-remove-part handle)
4691 (mm-display-part handle)))))
4693 (defun gnus-mime-action-on-part (&optional action)
4694 "Do something with the MIME attachment at \(point\)."
4696 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4697 (gnus-article-check-buffer)
4698 (let ((action-pair (assoc action gnus-mime-action-alist)))
4700 (funcall (cdr action-pair)))))
4702 (defun gnus-article-part-wrapper (n function)
4703 (with-current-buffer gnus-article-buffer
4704 (when (> n (length gnus-article-mime-handle-alist))
4705 (error "No such part"))
4706 (gnus-article-goto-part n)
4707 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4708 (funcall function handle))))
4710 (defun gnus-article-pipe-part (n)
4711 "Pipe MIME part N, which is the numerical prefix."
4713 (gnus-article-part-wrapper n 'mm-pipe-part))
4715 (defun gnus-article-save-part (n)
4716 "Save MIME part N, which is the numerical prefix."
4718 (gnus-article-part-wrapper n 'mm-save-part))
4720 (defun gnus-article-interactively-view-part (n)
4721 "View MIME part N interactively, which is the numerical prefix."
4723 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4725 (defun gnus-article-copy-part (n)
4726 "Copy MIME part N, which is the numerical prefix."
4728 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4730 (defun gnus-article-view-part-as-charset (n)
4731 "View MIME part N using a specified charset.
4732 N is the numerical prefix."
4734 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4736 (defun gnus-article-view-part-externally (n)
4737 "View MIME part N externally, which is the numerical prefix."
4739 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4741 (defun gnus-article-inline-part (n)
4742 "Inline MIME part N, which is the numerical prefix."
4744 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4746 (defun gnus-article-mime-match-handle-first (condition)
4748 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4749 (while (setq ihandle (pop alist))
4751 ((functionp condition)
4752 (funcall condition (cdr ihandle)))
4753 ((eq condition 'undisplayed)
4754 (not (or (mm-handle-undisplayer (cdr ihandle))
4755 (equal (mm-handle-media-type (cdr ihandle))
4756 "multipart/alternative"))))
4757 ((eq condition 'undisplayed-alternative)
4758 (not (mm-handle-undisplayer (cdr ihandle))))
4760 (gnus-article-goto-part (car ihandle))
4761 (or (not n) (< (car ihandle) n)))
4762 (setq n (car ihandle))))
4766 (defun gnus-article-view-part (&optional n)
4767 "View MIME part N, which is the numerical prefix."
4769 (with-current-buffer gnus-article-buffer
4770 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4771 gnus-article-mime-match-handle-function)))
4772 (when (> n (length gnus-article-mime-handle-alist))
4773 (error "No such part"))
4774 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4775 (when (gnus-article-goto-part n)
4776 (if (equal (car handle) "multipart/alternative")
4777 (gnus-article-press-button)
4778 (when (eq (gnus-mm-display-part handle) 'internal)
4779 (gnus-set-window-start)))))))
4781 (defsubst gnus-article-mime-total-parts ()
4782 (if (bufferp (car gnus-article-mime-handles))
4784 (1- (length gnus-article-mime-handles))))
4786 (defun gnus-mm-display-part (handle)
4787 "Display HANDLE and fix MIME button."
4788 (let ((id (get-text-property (point) 'gnus-part))
4793 (let ((window (selected-window))
4794 (mail-parse-charset gnus-newsgroup-charset)
4795 (mail-parse-ignored-charsets
4796 (if (gnus-buffer-live-p gnus-summary-buffer)
4797 (with-current-buffer gnus-summary-buffer
4798 gnus-newsgroup-ignored-charsets)
4802 (let ((win (gnus-get-buffer-window (current-buffer) t))
4805 (select-window win))
4808 (if (mm-handle-displayed-p handle)
4809 ;; This will remove the part.
4810 (mm-display-part handle)
4812 (narrow-to-region (point)
4813 (if (eobp) (point) (1+ (point))))
4814 (mm-display-part handle)
4815 ;; We narrow to the part itself and
4816 ;; then call the treatment functions.
4817 (goto-char (point-min))
4819 (narrow-to-region (point) (point-max))
4822 (gnus-article-mime-total-parts)
4823 (mm-handle-media-type handle)))))
4824 (if (window-live-p window)
4825 (select-window window)))))
4828 (gnus-insert-mime-button
4829 handle id (list (mm-handle-displayed-p handle)))
4830 (goto-char point))))
4832 (defun gnus-article-goto-part (n)
4833 "Go to MIME part N."
4834 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4836 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4837 (let ((gnus-tmp-name
4838 (or (mail-content-type-get (mm-handle-type handle) 'name)
4839 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4840 (mail-content-type-get (mm-handle-type handle) 'url)
4842 (gnus-tmp-type (mm-handle-media-type handle))
4843 (gnus-tmp-description
4844 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4847 (if (if displayed (car displayed)
4848 (mm-handle-displayed-p handle))
4850 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4852 gnus-tmp-type-long b e)
4853 (when (string-match ".*/" gnus-tmp-name)
4854 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4855 (setq gnus-tmp-type-long (concat gnus-tmp-type
4856 (and (not (equal gnus-tmp-name ""))
4857 (concat "; " gnus-tmp-name))))
4858 (unless (equal gnus-tmp-description "")
4859 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4864 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4865 `(keymap ,gnus-mime-button-map
4866 gnus-callback gnus-mm-display-part
4867 gnus-part ,gnus-tmp-id
4868 article-type annotation
4871 ;; Exclude a newline.
4874 (widget-convert-button
4877 :action 'gnus-widget-press-button
4878 :button-keymap gnus-mime-button-map
4880 (lambda (widget/window &optional overlay pos)
4881 ;; Needed to properly clear the message due to a bug in
4882 ;; wid-edit (XEmacs only).
4883 (if (boundp 'help-echo-owns-message)
4884 (setq help-echo-owns-message t))
4886 "%S: %s the MIME part; %S: more options"
4887 (aref gnus-mouse-2 0)
4888 ;; XEmacs will get a single widget arg; Emacs 21 will get
4889 ;; window, overlay, position.
4890 (if (mm-handle-displayed-p
4892 (with-current-buffer (gnus-overlay-buffer overlay)
4893 (widget-get (widget-at (gnus-overlay-start overlay))
4895 (widget-get widget/window :mime-handle)))
4897 (aref gnus-down-mouse-3 0))))))
4899 (defun gnus-widget-press-button (elems el)
4900 (goto-char (widget-get elems :from))
4901 (gnus-article-press-button))
4903 (defvar gnus-displaying-mime nil)
4905 (defun gnus-display-mime (&optional ihandles)
4906 "Display the MIME parts."
4908 (save-selected-window
4909 (let ((window (get-buffer-window gnus-article-buffer))
4912 (select-window window)
4913 ;; We have to do this since selecting the window
4914 ;; may change the point. So we set the window point.
4915 (set-window-point window point)))
4916 (let* ((handles (or ihandles
4917 (mm-dissect-buffer nil gnus-article-loose-mime)
4918 (and gnus-article-emulate-mime
4920 buffer-read-only handle name type b e display)
4921 (when (and (not ihandles)
4922 (not gnus-displaying-mime))
4923 ;; Top-level call; we clean up.
4924 (when gnus-article-mime-handles
4925 (mm-destroy-parts gnus-article-mime-handles)
4926 (setq gnus-article-mime-handle-alist nil));; A trick.
4927 (setq gnus-article-mime-handles handles)
4928 ;; We allow users to glean info from the handles.
4929 (when gnus-article-mime-part-function
4930 (gnus-mime-part-function handles)))
4932 (or (not (stringp (car handles)))
4935 (when (and (not ihandles)
4936 (not gnus-displaying-mime))
4937 ;; Clean up for mime parts.
4939 (delete-region (point) (point-max)))
4940 (let ((gnus-displaying-mime t))
4941 (gnus-mime-display-part handles)))
4944 (narrow-to-region (point) (point-max))
4945 (gnus-treat-article nil 1 1)
4948 ;; Highlight the headers.
4952 (narrow-to-region (point-min) (point))
4953 (gnus-treat-article 'head))))))))
4955 (defcustom gnus-mime-display-multipart-as-mixed nil
4956 "Display \"multipart\" parts as \"multipart/mixed\".
4958 If t, it overrides nil values of
4959 `gnus-mime-display-multipart-alternative-as-mixed' and
4960 `gnus-mime-display-multipart-related-as-mixed'."
4961 :group 'gnus-article-mime
4964 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4965 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4966 :group 'gnus-article-mime
4969 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4970 "Display \"multipart/related\" parts as \"multipart/mixed\".
4972 If displaying \"text/html\" is discouraged \(see
4973 `mm-discouraged-alternatives'\) images or other material inside a
4974 \"multipart/related\" part might be overlooked when this variable is nil."
4975 :group 'gnus-article-mime
4978 (defun gnus-mime-display-part (handle)
4981 ((not (stringp (car handle)))
4982 (gnus-mime-display-single handle))
4983 ;; User-defined multipart
4984 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4985 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4987 ;; multipart/alternative
4988 ((and (equal (car handle) "multipart/alternative")
4989 (not (or gnus-mime-display-multipart-as-mixed
4990 gnus-mime-display-multipart-alternative-as-mixed)))
4991 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4992 (push (cons id handle) gnus-article-mime-handle-alist)
4993 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4994 ;; multipart/related
4995 ((and (equal (car handle) "multipart/related")
4996 (not (or gnus-mime-display-multipart-as-mixed
4997 gnus-mime-display-multipart-related-as-mixed)))
4998 ;;;!!!We should find the start part, but we just default
4999 ;;;!!!to the first part.
5000 ;;(gnus-mime-display-part (cadr handle))
5001 ;;;!!! Most multipart/related is an HTML message plus images.
5002 ;;;!!! Unfortunately we are unable to let W3 display those
5003 ;;;!!! included images, so we just display it as a mixed multipart.
5004 ;;(gnus-mime-display-mixed (cdr handle))
5005 ;;;!!! No, w3 can display everything just fine.
5006 (gnus-mime-display-part (cadr handle)))
5007 ((equal (car handle) "multipart/signed")
5008 (gnus-add-wash-type 'signed)
5009 (gnus-mime-display-security handle))
5010 ((equal (car handle) "multipart/encrypted")
5011 (gnus-add-wash-type 'encrypted)
5012 (gnus-mime-display-security handle))
5013 ;; Other multiparts are handled like multipart/mixed.
5015 (gnus-mime-display-mixed (cdr handle)))))
5017 (defun gnus-mime-part-function (handles)
5018 (if (stringp (car handles))
5019 (mapcar 'gnus-mime-part-function (cdr handles))
5020 (funcall gnus-article-mime-part-function handles)))
5022 (defun gnus-mime-display-mixed (handles)
5023 (mapcar 'gnus-mime-display-part handles))
5025 (defun gnus-mime-display-single (handle)
5026 (let ((type (mm-handle-media-type handle))
5027 (ignored gnus-ignored-mime-types)
5034 (when (string-match (pop ignored) type)
5035 (throw 'ignored nil)))
5036 (if (and (setq not-attachment
5037 (and (not (mm-inline-override-p handle))
5038 (or (not (mm-handle-disposition handle))
5039 (equal (car (mm-handle-disposition handle))
5041 (mm-attachment-override-p handle))))
5042 (mm-automatic-display-p handle)
5044 (mm-inlinable-p handle)
5045 (mm-inlined-p handle))
5046 (mm-automatic-external-display-p type)))
5048 (when (equal (mm-handle-media-supertype handle) "text")
5050 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5052 (push (cons id handle) gnus-article-mime-handle-alist)
5053 (when (or (not display)
5054 (not (gnus-unbuttonized-mime-type-p type)))
5055 (gnus-insert-mime-button
5056 handle id (list (or display (and not-attachment text))))
5057 (gnus-article-insert-newline)
5058 ;; Remember modify the number of forward lines.
5066 (let ((mail-parse-charset gnus-newsgroup-charset)
5067 (mail-parse-ignored-charsets
5068 (save-excursion (condition-case ()
5069 (set-buffer gnus-summary-buffer)
5071 gnus-newsgroup-ignored-charsets)))
5072 (mm-display-part handle t))
5073 (goto-char (point-max)))
5074 ((and text not-attachment)
5078 (gnus-article-insert-newline)
5079 (mm-insert-inline handle (mm-get-part handle))
5080 (goto-char (point-max))))
5084 (narrow-to-region beg (point))
5087 (gnus-article-mime-total-parts)
5088 (mm-handle-media-type handle)))))))))
5090 (defun gnus-unbuttonized-mime-type-p (type)
5091 "Say whether TYPE is to be unbuttonized."
5092 (unless gnus-inhibit-mime-unbuttonizing
5094 (let ((types gnus-unbuttonized-mime-types))
5096 (when (string-match (pop types) type)
5097 (throw 'found t)))))
5099 (let ((types gnus-buttonized-mime-types))
5101 (when (string-match (pop types) type)
5102 (throw 'found t)))))))))
5104 (defun gnus-article-insert-newline ()
5105 "Insert a newline, but mark it as undeletable."
5106 (gnus-put-text-property
5107 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5109 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5110 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5113 handle buffer-read-only from props begend not-pref)
5114 (save-window-excursion
5117 (narrow-to-region (car ibegend)
5120 (goto-char (car ibegend))
5123 (delete-region (point-min) (point-max))
5124 (mm-remove-parts handles))
5125 (setq begend (list (point-marker)))
5127 (unless (setq not-pref (cadr (member preferred ihandles)))
5128 (setq not-pref (car ihandles)))
5131 (not (gnus-unbuttonized-mime-type-p
5132 "multipart/alternative")))
5133 (gnus-add-text-properties
5136 (insert (format "%d. " id))
5140 (unless ,(not ibegend)
5141 (setq gnus-article-mime-handle-alist
5142 ',gnus-article-mime-handle-alist))
5143 (gnus-mime-display-alternative
5144 ',ihandles ',not-pref ',begend ,id))
5145 keymap ,gnus-mime-button-map
5146 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5147 face ,gnus-article-button-face
5150 (widget-convert-button 'link from (point)
5151 :action 'gnus-widget-press-button
5152 :button-keymap gnus-widget-button-keymap)
5154 (while (setq handle (pop handles))
5155 (gnus-add-text-properties
5158 (insert (format "(%c) %-18s"
5159 (if (equal handle preferred) ?* ? )
5160 (mm-handle-media-type handle)))
5164 (unless ,(not ibegend)
5165 (setq gnus-article-mime-handle-alist
5166 ',gnus-article-mime-handle-alist))
5167 (gnus-mime-display-alternative
5168 ',ihandles ',handle ',begend ,id))
5169 keymap ,gnus-mime-button-map
5170 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5171 face ,gnus-article-button-face
5174 (widget-convert-button 'link from (point)
5175 :action 'gnus-widget-press-button
5176 :button-keymap gnus-widget-button-keymap)
5180 (if (stringp (car preferred))
5181 (gnus-display-mime preferred)
5182 (let ((mail-parse-charset gnus-newsgroup-charset)
5183 (mail-parse-ignored-charsets
5184 (with-current-buffer gnus-summary-buffer
5185 gnus-newsgroup-ignored-charsets)))
5186 (mm-display-part preferred)
5190 (narrow-to-region (car begend) (point-max))
5192 nil (length gnus-article-mime-handle-alist)
5193 (gnus-article-mime-total-parts)
5194 (mm-handle-media-type handle))))))
5195 (goto-char (point-max))
5196 (setcdr begend (point-marker)))))
5198 (goto-char point))))
5200 (defconst gnus-article-wash-status-strings
5201 (let ((alist '((cite "c" "Possible hidden citation text"
5202 " " "All citation text visible")
5203 (headers "h" "Hidden headers"
5204 " " "All headers visible.")
5205 (pgp "p" "Encrypted or signed message status hidden"
5206 " " "No hidden encryption nor digital signature status")
5207 (signature "s" "Signature has been hidden"
5208 " " "Signature is visible")
5209 (overstrike "o" "Overstrike (^H) characters applied"
5210 " " "No overstrike characters applied")
5211 (gnus-show-mime "m" "Mime processing is activated"
5212 " " "Mime processing is not activated")
5213 (emphasis "e" "/*_Emphasis_*/ characters applied"
5214 " " "No /*_emphasis_*/ characters applied")))
5216 (dolist (entry alist result)
5217 (let ((key (nth 0 entry))
5218 (on (copy-sequence (nth 1 entry)))
5219 (on-help (nth 2 entry))
5220 (off (copy-sequence (nth 3 entry)))
5221 (off-help (nth 4 entry)))
5222 (put-text-property 0 1 'help-echo on-help on)
5223 (put-text-property 0 1 'help-echo off-help off)
5224 (push (list key on off) result))))
5225 "Alist of strings describing wash status in the mode line.
5226 Each entry has the form (KEY ON OF), where the KEY is a symbol
5227 representing the particular washing function, ON is the string to use
5228 in the article mode line when the washing function is active, and OFF
5229 is the string to use when it is inactive.")
5231 (defun gnus-article-wash-status-entry (key value)
5232 (let ((entry (assoc key gnus-article-wash-status-strings)))
5233 (if value (nth 1 entry) (nth 2 entry))))
5235 (defun gnus-article-wash-status ()
5236 "Return a string which display status of article washing."
5237 (with-current-buffer gnus-article-buffer
5238 (let ((cite (memq 'cite gnus-article-wash-types))
5239 (headers (memq 'headers gnus-article-wash-types))
5240 (boring (memq 'boring-headers gnus-article-wash-types))
5241 (pgp (memq 'pgp gnus-article-wash-types))
5242 (pem (memq 'pem gnus-article-wash-types))
5243 (signed (memq 'signed gnus-article-wash-types))
5244 (encrypted (memq 'encrypted gnus-article-wash-types))
5245 (signature (memq 'signature gnus-article-wash-types))
5246 (overstrike (memq 'overstrike gnus-article-wash-types))
5247 (emphasis (memq 'emphasis gnus-article-wash-types)))
5249 (gnus-article-wash-status-entry 'cite cite)
5250 (gnus-article-wash-status-entry 'headers (or headers boring))
5251 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5252 (gnus-article-wash-status-entry 'signature signature)
5253 (gnus-article-wash-status-entry 'overstrike overstrike)
5254 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
5255 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5257 (defun gnus-add-wash-type (type)
5258 "Add a washing of TYPE to the current status."
5259 (add-to-list 'gnus-article-wash-types type))
5261 (defun gnus-delete-wash-type (type)
5262 "Add a washing of TYPE to the current status."
5263 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5265 (defun gnus-add-image (category image)
5266 "Add IMAGE of CATEGORY to the list of displayed images."
5267 (let ((entry (assq category gnus-article-image-alist)))
5269 (setq entry (list category))
5270 (push entry gnus-article-image-alist))
5271 (nconc entry (list image))))
5273 (defun gnus-delete-images (category)
5274 "Delete all images in CATEGORY."
5275 (let ((entry (assq category gnus-article-image-alist)))
5276 (dolist (image (cdr entry))
5277 (gnus-remove-image image category))
5278 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5279 (gnus-delete-wash-type category)))
5281 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5283 (defun gnus-article-maybe-hide-headers ()
5284 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5285 Provided for backwards compatibility."
5286 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5287 (not (with-current-buffer gnus-summary-buffer
5288 gnus-have-all-headers)))
5289 (not gnus-inhibit-hiding))
5290 (gnus-article-hide-headers)))
5294 (defun gnus-output-to-file (file-name)
5295 "Append the current article to a file named FILE-NAME."
5296 (let ((artbuf (current-buffer)))
5298 (insert-buffer-substring artbuf)
5299 ;; Append newline at end of the buffer as separator, and then
5301 (goto-char (point-max))
5303 (let ((file-name-coding-system nnmail-pathname-coding-system))
5304 (write-region-as-binary (point-min) (point-max) file-name 'append))
5307 (defun gnus-narrow-to-page (&optional arg)
5308 "Narrow the article buffer to a page.
5309 If given a numerical ARG, move forward ARG pages."
5311 (setq arg (if arg (prefix-numeric-value arg) 0))
5313 (set-buffer gnus-article-buffer)
5314 (goto-char (point-min))
5316 ;; Remove any old next/prev buttons.
5317 (when (gnus-visual-p 'page-marker)
5318 (let ((buffer-read-only nil))
5319 (gnus-remove-text-with-property 'gnus-prev)
5320 (gnus-remove-text-with-property 'gnus-next)))
5323 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5325 (re-search-forward page-delimiter nil 'move arg)))
5326 (goto-char (match-end 0))
5328 (goto-char (point-min))
5329 (setq gnus-page-broken
5330 (and (re-search-forward page-delimiter nil t) t))))
5331 (when gnus-page-broken
5334 (if (re-search-forward page-delimiter nil 'move)
5337 (when (and (gnus-visual-p 'page-marker)
5338 (not (= (point-min) 1)))
5340 (goto-char (point-min))
5341 (gnus-insert-prev-page-button)))
5342 (when (and (gnus-visual-p 'page-marker)
5343 (< (+ (point-max) 2) (buffer-size)))
5345 (goto-char (point-max))
5346 (gnus-insert-next-page-button))))))
5348 ;; Article mode commands
5350 (defun gnus-article-goto-next-page ()
5351 "Show the next page of the article."
5353 (when (gnus-article-next-page)
5354 (goto-char (point-min))
5355 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5358 (defun gnus-article-goto-prev-page ()
5359 "Show the previous page of the article."
5362 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5363 (gnus-article-prev-page nil)))
5365 ;; This is cleaner but currently breaks `gnus-pick-mode':
5367 ;; (defun gnus-article-goto-next-page ()
5368 ;; "Show the next page of the article."
5370 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5371 ;; (gnus-summary-next-page)))
5373 ;; (defun gnus-article-goto-prev-page ()
5374 ;; "Show the next page of the article."
5376 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5377 ;; (gnus-summary-prev-page)))
5379 (defun gnus-article-next-page (&optional lines)
5380 "Show the next page of the current article.
5381 If end of article, return non-nil. Otherwise return nil.
5382 Argument LINES specifies lines to be scrolled up."
5384 (move-to-window-line -1)
5387 (and (pos-visible-in-window-p) ;Not continuation line.
5388 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5389 ;; Nothing in this page.
5390 (if (or (not gnus-page-broken)
5394 (eobp)))) ;Real end-of-buffer?
5396 (when gnus-article-over-scroll
5397 (gnus-article-next-page-1 lines))
5399 (gnus-narrow-to-page 1) ;Go to next page.
5401 ;; More in this page.
5402 (gnus-article-next-page-1 lines)
5405 (defun gnus-article-next-page-1 (lines)
5406 (let ((scroll-in-place nil))
5410 ;; Long lines may cause an end-of-buffer error.
5411 (goto-char (point-max)))))
5412 (move-to-window-line 0))
5414 (defun gnus-article-prev-page (&optional lines)
5415 "Show previous page of current article.
5416 Argument LINES specifies lines to be scrolled down."
5418 (move-to-window-line 0)
5419 (if (and gnus-page-broken
5421 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5423 (gnus-narrow-to-page -1) ;Go to previous page.
5424 (goto-char (point-max))
5426 (let ((scroll-in-place nil))
5430 (beginning-of-buffer
5431 (goto-char (point-min))))
5432 (move-to-window-line 0)))))
5434 (defun gnus-article-only-boring-p ()
5435 "Decide whether there is only boring text remaining in the article.
5436 Something \"interesting\" is a word of at least two letters that does
5437 not have a face in `gnus-article-boring-faces'."
5438 (when (and gnus-article-skip-boring
5439 (boundp 'gnus-article-boring-faces)
5440 (symbol-value 'gnus-article-boring-faces))
5443 (while (re-search-forward "\\b\\w\\w" nil t)
5445 (when (not (gnus-intersection
5446 (gnus-faces-at (point))
5447 (symbol-value 'gnus-article-boring-faces)))
5448 (throw 'only-boring nil)))
5449 (throw 'only-boring t)))))
5451 (defun gnus-article-refer-article ()
5452 "Read article specified by message-id around point."
5455 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5456 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5457 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5458 (let ((msg-id (concat "<" (match-string 0) ">")))
5459 (set-buffer gnus-summary-buffer)
5460 (gnus-summary-refer-article msg-id))
5461 (error "No references around point"))))
5463 (defun gnus-article-show-summary ()
5464 "Reconfigure windows to show summary buffer."
5466 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5467 (error "There is no summary buffer for this article buffer")
5468 (gnus-article-set-globals)
5469 (gnus-configure-windows 'article)
5470 (gnus-summary-goto-subject gnus-current-article)
5471 (gnus-summary-position-point)))
5473 (defun gnus-article-describe-briefly ()
5474 "Describe article mode commands briefly."
5476 (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")))
5478 (defun gnus-article-summary-command ()
5479 "Execute the last keystroke in the summary buffer."
5481 (let ((obuf (current-buffer))
5482 (owin (current-window-configuration))
5484 (switch-to-buffer gnus-article-current-summary 'norecord)
5485 (setq func (lookup-key (current-local-map) (this-command-keys)))
5486 (call-interactively func)
5488 (set-window-configuration owin)
5489 (set-window-point (get-buffer-window (current-buffer)) (point))))
5491 (defun gnus-article-summary-command-nosave ()
5492 "Execute the last keystroke in the summary buffer."
5495 (pop-to-buffer gnus-article-current-summary 'norecord)
5496 (setq func (lookup-key (current-local-map) (this-command-keys)))
5497 (call-interactively func)))
5499 (defun gnus-article-check-buffer ()
5500 "Beep if not in an article buffer."
5501 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5502 (error "Command invoked outside of a Gnus article buffer")))
5504 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5505 "Read a summary buffer key sequence and execute it from the article buffer."
5507 (gnus-article-check-buffer)
5509 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5510 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5511 "=" "^" "\M-^" "|"))
5517 '("n" "Gn" "p" "Gp"))
5520 (set-buffer gnus-article-current-summary)
5521 (let (gnus-pick-mode)
5522 (push (or key last-command-event) unread-command-events)
5523 (setq keys (static-if (featurep 'xemacs)
5524 (events-to-keys (read-key-sequence nil))
5525 (read-key-sequence nil)))))
5528 (if (or (member keys nosaves)
5529 (member keys nosave-but-article)
5530 (member keys nosave-in-article))
5532 (save-window-excursion
5533 (pop-to-buffer gnus-article-current-summary 'norecord)
5534 ;; We disable the pick minor mode commands.
5535 (let (gnus-pick-mode)
5536 (setq func (lookup-key (current-local-map) keys))))
5540 (unless (member keys nosave-in-article)
5541 (set-buffer gnus-article-current-summary))
5542 (call-interactively func)
5543 (setq new-sum-point (point)))
5544 (when (member keys nosave-but-article)
5545 (pop-to-buffer gnus-article-buffer 'norecord)))
5546 ;; These commands should restore window configuration.
5547 (let ((obuf (current-buffer))
5548 (owin (current-window-configuration))
5550 win func in-buffer selected new-sum-start new-sum-hscroll)
5551 (cond (not-restore-window
5552 (pop-to-buffer gnus-article-current-summary 'norecord))
5553 ((setq win (get-buffer-window gnus-article-current-summary))
5554 (select-window win))
5556 (switch-to-buffer gnus-article-current-summary 'norecord)))
5557 (setq in-buffer (current-buffer))
5558 ;; We disable the pick minor mode commands.
5559 (if (and (setq func (let (gnus-pick-mode)
5560 (lookup-key (current-local-map) keys)))
5563 (call-interactively func)
5564 (when (eq win (selected-window))
5565 (setq new-sum-point (point)
5566 new-sum-start (window-start win)
5567 new-sum-hscroll (window-hscroll win))
5568 (when (eq in-buffer (current-buffer))
5569 (setq selected (gnus-summary-select-article))
5571 (unless not-restore-window
5572 (set-window-configuration owin))
5573 (when (eq selected 'old)
5575 (set-window-start (get-buffer-window (current-buffer))
5577 (set-window-point (get-buffer-window (current-buffer))
5579 (when (and (not not-restore-window)
5581 (set-window-point win new-sum-point)
5582 (set-window-start win new-sum-start)
5583 (set-window-hscroll win new-sum-hscroll)))))
5584 (set-window-configuration owin)
5587 (defun gnus-article-describe-key (key)
5588 "Display documentation of the function invoked by KEY. KEY is a string."
5589 (interactive "kDescribe key: ")
5590 (gnus-article-check-buffer)
5591 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5593 (set-buffer gnus-article-current-summary)
5594 (let (gnus-pick-mode)
5595 (if (featurep 'xemacs)
5597 (push (elt key 0) unread-command-events)
5598 (setq key (events-to-keys
5599 (read-key-sequence "Describe key: "))))
5600 (setq unread-command-events
5602 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5604 (setq key (read-key-sequence "Describe key: "))))
5606 (describe-key key)))
5608 (defun gnus-article-describe-key-briefly (key &optional insert)
5609 "Display documentation of the function invoked by KEY. KEY is a string."
5610 (interactive "kDescribe key: \nP")
5611 (gnus-article-check-buffer)
5612 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5614 (set-buffer gnus-article-current-summary)
5615 (let (gnus-pick-mode)
5616 (if (featurep 'xemacs)
5618 (push (elt key 0) unread-command-events)
5619 (setq key (events-to-keys
5620 (read-key-sequence "Describe key: "))))
5621 (setq unread-command-events
5623 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5625 (setq key (read-key-sequence "Describe key: "))))
5626 (describe-key-briefly key insert))
5627 (describe-key-briefly key insert)))
5629 (defun gnus-article-reply-with-original (&optional wide)
5630 "Start composing a reply mail to the current message.
5631 The text in the region will be yanked. If the region isn't active,
5632 the entire article will be yanked."
5634 (let ((article (cdr gnus-article-current))
5636 (if (not (gnus-region-active-p))
5637 (with-current-buffer gnus-summary-buffer
5638 (gnus-summary-reply (list (list article)) wide))
5639 (setq contents (buffer-substring (point) (mark t)))
5640 ;; Deactivate active regions.
5641 (when (and (boundp 'transient-mark-mode)
5642 transient-mark-mode)
5643 (setq mark-active nil))
5644 (with-current-buffer gnus-summary-buffer
5646 (list (list article contents)) wide)))))
5648 (defun gnus-article-followup-with-original ()
5649 "Compose a followup to the current article.
5650 The text in the region will be yanked. If the region isn't active,
5651 the entire article will be yanked."
5653 (let ((article (cdr gnus-article-current))
5655 (if (not (gnus-region-active-p))
5656 (with-current-buffer gnus-summary-buffer
5657 (gnus-summary-followup (list (list article))))
5658 (setq contents (buffer-substring (point) (mark t)))
5659 ;; Deactivate active regions.
5660 (when (and (boundp 'transient-mark-mode)
5661 transient-mark-mode)
5662 (setq mark-active nil))
5663 (with-current-buffer gnus-summary-buffer
5664 (gnus-summary-followup
5665 (list (list article contents)))))))
5667 (defun gnus-article-hide (&optional arg force)
5668 "Hide all the gruft in the current article.
5669 This means that signatures, cited text and (some) headers will be
5671 If given a prefix, show the hidden text instead."
5672 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5673 (gnus-article-hide-headers arg)
5674 (gnus-article-hide-list-identifiers arg)
5675 (gnus-article-hide-citation-maybe arg force)
5676 (gnus-article-hide-signature arg))
5678 (defun gnus-article-maybe-highlight ()
5679 "Do some article highlighting if article highlighting is requested."
5680 (when (gnus-visual-p 'article-highlight 'highlight)
5681 (gnus-article-highlight-some)))
5683 (defun gnus-check-group-server ()
5684 ;; Make sure the connection to the server is alive.
5685 (unless (gnus-server-opened
5686 (gnus-find-method-for-group gnus-newsgroup-name))
5687 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5688 (gnus-request-group gnus-newsgroup-name t)))
5691 (autoload 'nneething-get-file-name "nneething"))
5693 (defun gnus-request-article-this-buffer (article group)
5694 "Get an article and insert it into this buffer."
5695 (let (do-update-line sparse-header)
5699 (gnus-kill-all-overlays)
5700 (setq group (or group gnus-newsgroup-name))
5702 ;; Using `gnus-request-article' directly will insert the article into
5703 ;; `nntp-server-buffer' - so we'll save some time by not having to
5704 ;; copy it from the server buffer into the article buffer.
5706 ;; We only request an article by message-id when we do not have the
5707 ;; headers for it, so we'll have to get those.
5708 (when (stringp article)
5709 (gnus-read-header article))
5711 ;; If the article number is negative, that means that this article
5712 ;; doesn't belong in this newsgroup (possibly), so we find its
5713 ;; message-id and request it by id instead of number.
5714 (when (and (numberp article)
5716 (get-buffer gnus-summary-buffer)
5717 (gnus-buffer-exists-p gnus-summary-buffer))
5719 (set-buffer gnus-summary-buffer)
5720 (let ((header (gnus-summary-article-header article)))
5723 ((memq article gnus-newsgroup-sparse)
5724 ;; This is a sparse gap article.
5725 (setq do-update-line article)
5726 (setq article (mail-header-id header))
5727 (setq sparse-header (gnus-read-header article))
5728 (setq gnus-newsgroup-sparse
5729 (delq article gnus-newsgroup-sparse)))
5731 ;; It's a real article.
5732 (setq article (mail-header-id header)))
5734 ;; It is an extracted pseudo-article.
5735 (setq article 'pseudo)
5736 (gnus-request-pseudo-article header))))
5738 (let ((method (gnus-find-method-for-group
5739 gnus-newsgroup-name)))
5740 (when (and (eq (car method) 'nneething)
5742 (let ((dir (nneething-get-file-name
5743 (mail-header-id header))))
5744 (when (and (stringp dir)
5745 (file-directory-p dir))
5746 (setq article 'nneething)
5747 (gnus-group-enter-directory dir))))))))
5750 ;; Refuse to select canceled articles.
5751 ((and (numberp article)
5753 (get-buffer gnus-summary-buffer)
5754 (gnus-buffer-exists-p gnus-summary-buffer)
5755 (eq (cdr (with-current-buffer gnus-summary-buffer
5756 (assq article gnus-newsgroup-reads)))
5757 gnus-canceled-mark))
5759 ;; We first check `gnus-original-article-buffer'.
5760 ((and (get-buffer gnus-original-article-buffer)
5762 (with-current-buffer gnus-original-article-buffer
5763 (and (equal (car gnus-original-article) group)
5764 (eq (cdr gnus-original-article) article))))
5765 (insert-buffer-substring gnus-original-article-buffer)
5767 ;; Check the backlog.
5768 ((and gnus-keep-backlog
5769 (gnus-backlog-request-article group article (current-buffer)))
5771 ;; Check asynchronous pre-fetch.
5772 ((gnus-async-request-fetched-article group article (current-buffer))
5773 (gnus-async-prefetch-next group article gnus-summary-buffer)
5774 (when (and (numberp article) gnus-keep-backlog)
5775 (gnus-backlog-enter-article group article (current-buffer)))
5778 ((and gnus-use-cache
5780 (gnus-cache-request-article article group))
5782 ;; Check the agent cache.
5783 ((gnus-agent-request-article article group)
5785 ;; Get the article and put into the article buffer.
5786 ((or (stringp article)
5788 (let ((gnus-override-method gnus-override-method)
5789 (methods (and (stringp article)
5790 gnus-refer-article-method))
5791 (backend (car (gnus-find-method-for-group
5792 gnus-newsgroup-name)))
5794 (buffer-read-only nil))
5795 (if (or (not (listp methods))
5796 (and (symbolp (car methods))
5797 (assq (car methods) nnoo-definition-alist)))
5798 (setq methods (list methods)))
5799 (when (and (null gnus-override-method)
5801 (setq gnus-override-method (pop methods)))
5803 (when (eq gnus-override-method 'current)
5804 (setq gnus-override-method
5805 (with-current-buffer gnus-summary-buffer
5806 gnus-current-select-method)))
5808 (gnus-kill-all-overlays)
5809 (let ((gnus-newsgroup-name group))
5810 (gnus-check-group-server))
5812 ((gnus-request-article article group (current-buffer))
5813 (when (numberp article)
5814 (gnus-async-prefetch-next group article
5815 gnus-summary-buffer)
5816 (when gnus-keep-backlog
5817 (gnus-backlog-enter-article
5818 group article (current-buffer))))
5819 (setq result 'article))
5821 (setq gnus-override-method (pop methods)))
5822 ((not (string-match "^400 "
5823 (nnheader-get-report backend)))
5824 ;; If we get 400 server disconnect, reconnect and
5825 ;; retry; otherwise, assume the article has expired.
5826 (setq result 'done))))
5827 (and (eq result 'article) 'article)))
5831 ;; Associate this article with the current summary buffer.
5832 (setq gnus-article-current-summary gnus-summary-buffer)
5834 ;; Take the article from the original article buffer
5835 ;; and place it in the buffer it's supposed to be in.
5836 (when (and (get-buffer gnus-article-buffer)
5837 (equal (buffer-name (current-buffer))
5838 (buffer-name (get-buffer gnus-article-buffer))))
5840 (if (get-buffer gnus-original-article-buffer)
5841 (set-buffer gnus-original-article-buffer)
5842 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5843 (buffer-disable-undo)
5844 (setq major-mode 'gnus-original-article-mode)
5845 (setq buffer-read-only t))
5846 (let (buffer-read-only)
5848 (insert-buffer-substring gnus-article-buffer))
5849 (setq gnus-original-article (cons group article)))
5852 (run-hooks 'gnus-article-decode-hook)
5853 ;; Mark article as decoded or not.
5854 (setq gnus-article-decoded-p gnus-article-decode-hook))
5856 ;; Update sparse articles.
5857 (when (and do-update-line
5858 (or (numberp article)
5860 (let ((buf (current-buffer)))
5861 (set-buffer gnus-summary-buffer)
5862 (gnus-summary-update-article do-update-line sparse-header)
5863 (gnus-summary-goto-subject do-update-line nil t)
5864 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5866 (set-buffer buf))))))
5872 (defcustom gnus-article-edit-mode-hook nil
5873 "Hook run in article edit mode buffers."
5874 :group 'gnus-article-various
5877 (defcustom gnus-article-edit-article-setup-function
5878 'gnus-article-mime-edit-article-setup
5879 "Function called to setup an editing article buffer."
5880 :group 'gnus-article-various
5883 (defvar gnus-article-edit-done-function nil)
5885 (defvar gnus-article-edit-mode-map nil)
5887 ;; Should we be using derived.el for this?
5888 (unless gnus-article-edit-mode-map
5889 (setq gnus-article-edit-mode-map (make-keymap))
5890 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5892 (gnus-define-keys gnus-article-edit-mode-map
5893 "\C-c?" describe-mode
5894 "\C-c\C-c" gnus-article-edit-done
5895 "\C-c\C-k" gnus-article-edit-exit
5896 "\C-c\C-f\C-t" message-goto-to
5897 "\C-c\C-f\C-o" message-goto-from
5898 "\C-c\C-f\C-b" message-goto-bcc
5899 ;;"\C-c\C-f\C-w" message-goto-fcc
5900 "\C-c\C-f\C-c" message-goto-cc
5901 "\C-c\C-f\C-s" message-goto-subject
5902 "\C-c\C-f\C-r" message-goto-reply-to
5903 "\C-c\C-f\C-n" message-goto-newsgroups
5904 "\C-c\C-f\C-d" message-goto-distribution
5905 "\C-c\C-f\C-f" message-goto-followup-to
5906 "\C-c\C-f\C-m" message-goto-mail-followup-to
5907 "\C-c\C-f\C-k" message-goto-keywords
5908 "\C-c\C-f\C-u" message-goto-summary
5909 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5910 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5911 "\C-c\C-b" message-goto-body
5912 "\C-c\C-i" message-goto-signature
5914 "\C-c\C-t" message-insert-to
5915 "\C-c\C-n" message-insert-newsgroups
5916 "\C-c\C-o" message-sort-headers
5917 "\C-c\C-e" message-elide-region
5918 "\C-c\C-v" message-delete-not-region
5919 "\C-c\C-z" message-kill-to-signature
5920 "\M-\r" message-newline-and-reformat
5921 "\C-c\C-a" mml-attach-file
5922 "\C-a" message-beginning-of-line
5924 "\M-;" comment-region)
5926 (gnus-define-keys (gnus-article-edit-wash-map
5927 "\C-c\C-w" gnus-article-edit-mode-map)
5928 "f" gnus-article-edit-full-stops))
5931 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5933 ["Fetch To" message-insert-to t]
5934 ["Fetch Newsgroups" message-insert-newsgroups t]
5936 ["To" message-goto-to t]
5937 ["From" message-goto-from t]
5938 ["Subject" message-goto-subject t]
5939 ["Cc" message-goto-cc t]
5940 ["Reply-To" message-goto-reply-to t]
5941 ["Summary" message-goto-summary t]
5942 ["Keywords" message-goto-keywords t]
5943 ["Newsgroups" message-goto-newsgroups t]
5944 ["Followup-To" message-goto-followup-to t]
5945 ["Mail-Followup-To" message-goto-mail-followup-to t]
5946 ["Distribution" message-goto-distribution t]
5947 ["Body" message-goto-body t]
5948 ["Signature" message-goto-signature t]))
5950 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5951 "Major mode for editing articles.
5952 This is an extended text-mode.
5954 \\{gnus-article-edit-mode-map}"
5955 (make-local-variable 'gnus-article-edit-done-function)
5956 (make-local-variable 'gnus-prev-winconf)
5957 (set (make-local-variable 'font-lock-defaults)
5958 '(message-font-lock-keywords t))
5959 (set (make-local-variable 'mail-header-separator) "")
5960 (set (make-local-variable 'gnus-article-edit-mode) t)
5961 (easy-menu-add message-mode-field-menu message-mode-map)
5962 (setq buffer-read-only nil)
5963 (buffer-enable-undo)
5966 (defun gnus-article-edit (&optional force)
5967 "Edit the current article.
5968 This will have permanent effect only in mail groups.
5969 If FORCE is non-nil, allow editing of articles even in read-only
5972 (when (and (not force)
5973 (gnus-group-read-only-p))
5974 (error "The current newsgroup does not support article editing"))
5975 (gnus-article-date-original)
5976 (gnus-article-edit-article
5978 `(lambda (no-highlight)
5980 (gnus-summary-edit-article-done
5981 ,(or (mail-header-references gnus-current-headers) "")
5982 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5984 (defun gnus-article-edit-article (start-func exit-func)
5985 "Start editing the contents of the current article buffer."
5986 (let ((winconf (current-window-configuration)))
5987 (set-buffer gnus-article-buffer)
5988 (gnus-article-edit-mode)
5989 (funcall start-func)
5990 (set-buffer-modified-p nil)
5991 (gnus-configure-windows 'edit-article)
5992 (setq gnus-article-edit-done-function exit-func)
5993 (setq gnus-prev-winconf winconf)
5994 (when gnus-article-edit-article-setup-function
5995 (funcall gnus-article-edit-article-setup-function))
5996 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit")))
5998 (defun gnus-article-edit-done (&optional arg)
5999 "Update the article edits and exit."
6001 (let ((func gnus-article-edit-done-function)
6002 (buf (current-buffer))
6003 (start (window-start))
6005 (winconf gnus-prev-winconf))
6006 (remove-hook 'gnus-article-mode-hook
6007 'gnus-article-mime-edit-article-unwind)
6008 (widen) ;; Widen it in case that users narrowed the buffer.
6011 ;; The cache and backlog have to be flushed somewhat.
6012 (when gnus-keep-backlog
6013 (gnus-backlog-remove-article
6014 (car gnus-article-current) (cdr gnus-article-current)))
6015 ;; Flush original article as well.
6017 (when (get-buffer gnus-original-article-buffer)
6018 (set-buffer gnus-original-article-buffer)
6019 (setq gnus-original-article nil)))
6020 (when gnus-use-cache
6021 (gnus-cache-update-article
6022 (car gnus-article-current) (cdr gnus-article-current)))
6023 ;; We remove all text props from the article buffer.
6024 (kill-all-local-variables)
6025 (set-text-properties (point-min) (point-max) nil)
6027 (set-window-configuration winconf)
6029 (set-window-start (get-buffer-window buf) start)
6030 (set-window-point (get-buffer-window buf) (point)))
6031 (gnus-summary-show-article))
6033 (defun gnus-article-edit-exit ()
6034 "Exit the article editing without updating."
6036 (when (or (not (buffer-modified-p))
6037 (yes-or-no-p "Article modified; kill anyway? "))
6038 (let ((curbuf (current-buffer))
6040 (window-start (window-start)))
6042 (if (gnus-buffer-live-p gnus-original-article-buffer)
6043 (insert-buffer-substring gnus-original-article-buffer))
6044 (let ((winconf gnus-prev-winconf))
6045 (kill-all-local-variables)
6047 (set-window-configuration winconf)
6048 ;; Tippy-toe some to make sure that point remains where it was.
6049 (save-current-buffer
6051 (set-window-start (get-buffer-window (current-buffer)) window-start)
6053 (gnus-summary-show-article)))
6055 (defun gnus-article-edit-full-stops ()
6056 "Interactively repair spacing at end of sentences."
6059 (goto-char (point-min))
6060 (search-forward-regexp "^$" nil t)
6061 (let ((case-fold-search nil))
6062 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
6065 ;;; Article editing with MIME-Edit
6068 (defcustom gnus-article-mime-edit-article-setup-hook nil
6069 "Hook run after setting up a MIME editing article buffer."
6070 :group 'gnus-article-various
6073 (defun gnus-article-mime-edit-article-unwind ()
6074 "Unwind `gnus-article-buffer' if article editing was given up."
6075 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6076 (when (featurep 'font-lock)
6077 (setq font-lock-defaults nil)
6078 (font-lock-mode -1))
6079 (when mime-edit-mode-flag
6080 (mime-edit-exit 'nomime 'no-error)
6083 (defun gnus-article-mime-edit-article-setup ()
6084 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
6085 after replacing with the original article."
6086 (setq gnus-show-mime t)
6087 (setq gnus-article-edit-done-function
6088 `(lambda (&rest args)
6089 (when mime-edit-mode-flag
6090 (let (mime-edit-insert-user-agent-field)
6093 (goto-char (point-min))
6094 (let (case-fold-search)
6095 (when (re-search-forward
6096 (format "^%s$" (regexp-quote mail-header-separator))
6098 (replace-match "")))
6099 (apply ,gnus-article-edit-done-function args)
6102 (buffer-substring-no-properties (point-min) (point-max))
6103 (set-buffer (get-buffer-create gnus-original-article-buffer))
6105 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6106 (set-buffer gnus-article-buffer)
6107 (gnus-article-prepare-display)))
6108 (substitute-key-definition 'gnus-article-edit-done
6109 'gnus-article-mime-edit-done
6110 gnus-article-edit-mode-map)
6111 (substitute-key-definition 'gnus-article-edit-exit
6112 'gnus-article-mime-edit-exit
6113 gnus-article-edit-mode-map)
6115 (insert-buffer-substring gnus-original-article-buffer)
6116 (unless (member (with-current-buffer gnus-summary-buffer
6117 gnus-newsgroup-name)
6118 '("nndraft:delayed" "nndraft:drafts"))
6119 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
6120 (fset 'mime-edit-decode-single-part-in-buffer
6121 (lambda (&rest args)
6122 (if (let ((content-type (car args)))
6123 (and (eq 'message (mime-content-type-primary-type
6125 (eq 'rfc822 (mime-content-type-subtype
6127 (setcar (cdr args) 'not-decode-text))
6131 (fset 'mime-edit-decode-single-part-in-buffer ofn))))
6132 (when (featurep 'font-lock)
6133 (set (make-local-variable 'font-lock-defaults)
6134 '(message-font-lock-keywords t))
6135 (font-lock-set-defaults)
6136 (turn-on-font-lock))
6137 (set-buffer-modified-p nil)
6138 (delete-other-windows)
6139 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6140 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
6142 (defun gnus-article-mime-edit-done (&optional arg)
6143 "Update the article MIME edits and exit."
6145 (when (featurep 'font-lock)
6146 (setq font-lock-defaults nil)
6147 (font-lock-mode -1))
6148 (let ((inhibit-read-only t))
6149 (gnus-article-edit-done arg)))
6151 (defun gnus-article-mime-edit-exit ()
6152 "Exit the article MIME editing without updating."
6154 (when (or (not (buffer-modified-p))
6155 (yes-or-no-p "Article modified; kill anyway? "))
6156 (when (featurep 'font-lock)
6157 (setq font-lock-defaults nil)
6158 (font-lock-mode -1))
6159 (when mime-edit-mode-flag
6160 (let (mime-edit-insert-user-agent-field)
6163 (goto-char (point-min))
6164 (let (case-fold-search)
6165 (when (re-search-forward
6166 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
6167 (replace-match "")))
6168 (let ((winconf gnus-prev-winconf))
6170 (buffer-substring-no-properties (point-min) (point-max))
6171 (set-buffer (get-buffer-create gnus-original-article-buffer))
6173 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6174 (set-buffer gnus-article-buffer)
6175 (gnus-article-prepare-display)
6176 (set-window-configuration winconf))))
6179 ;;; Article highlights
6182 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6184 ;;; Internal Variables:
6186 (defcustom gnus-button-url-regexp
6187 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
6188 "\\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:]]\\)"
6189 "\\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\\)\\)")
6190 "Regular expression that matches URLs."
6191 :group 'gnus-article-buttons
6194 (defcustom gnus-button-valid-fqdn-regexp
6195 message-valid-fqdn-regexp
6196 "Regular expression that matches a valid FQDN."
6197 :group 'gnus-article-buttons
6200 (defcustom gnus-button-man-handler 'manual-entry
6201 "Function to use for displaying man pages.
6202 The function must take at least one argument with a string naming the
6204 :type '(choice (function-item :tag "Man" manual-entry)
6205 (function-item :tag "Woman" woman)
6206 (function :tag "Other"))
6207 :group 'gnus-article-buttons)
6209 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6210 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6211 If the default site is too slow, try to find a CTAN mirror, see
6212 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6213 the variable `gnus-button-handle-ctan'."
6214 :group 'gnus-article-buttons
6215 :link '(custom-manual "(gnus)Group Parameters")
6216 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6217 (const "http://tug.ctan.org/tex-archive/")
6218 (const "http://www.dante.de/CTAN/")
6219 (string :tag "Other")))
6221 (defcustom gnus-button-ctan-handler 'browse-url
6222 "Function to use for displaying CTAN links.
6223 The function must take one argument, the string naming the URL."
6224 :type '(choice (function-item :tag "Browse Url" browse-url)
6225 (function :tag "Other"))
6226 :group 'gnus-article-buttons)
6228 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6229 "Bogus strings removed from CTAN URLs."
6230 :group 'gnus-article-buttons
6231 :type '(choice (const "^/?tex-archive/\\|/")
6232 (regexp :tag "Other")))
6234 (defcustom gnus-button-ctan-directory-regexp
6237 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
6238 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
6239 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
6241 "Regular expression for ctan directories.
6242 It should match all directories in the top level of `gnus-ctan-url'."
6243 :group 'gnus-article-buttons
6246 (defcustom gnus-button-mid-or-mail-regexp
6247 (concat "\\b\\(<?[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*@"
6248 ;; Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
6249 gnus-button-valid-fqdn-regexp
6251 "Regular expression that matches a message ID or a mail address."
6252 :group 'gnus-article-buttons
6255 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6256 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6257 Strings like this can be either a message ID or a mail address. If it is one
6258 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6259 message ID or a mail address, respectively. If this variable is set to the
6260 symbol `ask', always query the user what do do. If it is a function, this
6261 function will be called with the string as it's only argument. The function
6262 must return `mid', `mail', `invalid' or `ask'."
6263 :group 'gnus-article-buttons
6264 :type '(choice (function-item :tag "Heuristic function"
6265 gnus-button-mid-or-mail-heuristic)
6270 (defcustom gnus-button-mid-or-mail-heuristic-alist
6271 '((-10.0 . ".+\\$.+@")
6274 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6275 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6276 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6277 (-1.0 . "^[^a-z]+@")
6279 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6280 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6281 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6282 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6285 (-1.0 . "^[0-9][0-9]")
6287 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6288 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6289 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6290 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6292 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6293 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6296 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6298 ;; compensation for TDMA dated mail addresses:
6299 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6301 (-20.0 . "\\.fsf@") ;; Gnus
6304 (-20.0 . "_-_") ;; Subject change in thread
6306 (-20.0 . "\\.ln@") ;; leafnode
6307 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6308 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6310 ;; (5.0 . "") ;; $local_part_len <= 7
6311 (10.0 . "^[^0-9]+@")
6312 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6313 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6316 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6318 (0.5 . "^[A-Z][a-z]")
6319 (0.5 . "^[A-Z][a-z][a-z]")
6320 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6321 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6322 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6324 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6325 address. The REGEXP is processed with `case-fold-search' set to nil."
6326 :group 'gnus-article-buttons
6327 :type '(repeat (cons (number :tag "Rate")
6328 (regexp :tag "Regexp"))))
6330 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6331 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6332 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6333 address, `ask' if unsure and `invalid' if the string is invalid."
6334 (let ((case-fold-search nil)
6335 (list gnus-button-mid-or-mail-heuristic-alist)
6336 (result 0) rate regexp lpartlen elem)
6338 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6339 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6340 ;; Certain special cases...
6343 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6344 "^[0-9]+\\.[0-9]+@compuserve\\|"
6345 "@public\\.gmane\\.org")
6347 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6348 (setq result 'mail))
6349 (when (string-match "@.*@\\| " mid-or-mail)
6350 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6351 (setq result 'invalid))
6352 ;; Nothing more to do, if result is not a number here...
6353 (when (numberp result)
6355 (setq elem (car list)
6359 (when (string-match regexp mid-or-mail)
6360 (setq result (+ result rate))
6362 9 "`%s' matched `%s', rate `%s', result `%s'."
6363 mid-or-mail regexp rate result)))
6364 (when (<= lpartlen 7)
6365 (setq result (+ result 5.0))
6366 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6367 mid-or-mail result))
6368 (when (>= lpartlen 12)
6369 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6371 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6372 ;; Long local part should contain realname if e-mail address,
6373 ;; too many digits: message-id.
6374 ;; $score -= 5.0 + 0.1 * $local_part_len;
6375 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6376 (setq result (+ result rate))
6378 9 "Many digits in `%s', rate `%s', result `%s'."
6379 mid-or-mail rate result))
6380 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6382 ;; Too few vowels [^aeiouy]{4,}.*\@
6383 (setq result (+ result -5.0))
6385 9 "Few vowels in `%s', rate `%s', result `%s'."
6386 mid-or-mail -5.0 result))
6388 (setq result (+ result 5.0))
6390 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6391 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6392 ;; Maybe we should make this a customizable alist: (condition . 'result)
6394 ((symbolp result) result)
6395 ;; Now convert number into proper results:
6396 ((< result -10.0) 'mid)
6397 ((> result 10.0) 'mail)
6400 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6401 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6402 (url-mid (concat "news" ":" mid-or-mail))
6403 (url-mailto (concat "mailto" ":" mid-or-mail)))
6404 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6405 (when (fboundp pref)
6407 ;; get rid of surrounding angles...
6409 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6410 (if (or (eq 'mid guessed) (eq 'mail guessed))
6414 (save-window-excursion
6415 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6418 (cond ((eq pref 'mid)
6419 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6420 (gnus-button-handle-news url-mid))
6422 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6423 (gnus-url-mailto url-mailto))
6424 (t (gnus-message 3 "Invalid string.")))))
6426 (defun gnus-button-handle-custom (url)
6427 "Follow a Custom URL."
6428 (customize-apropos (gnus-url-unhex-string url)))
6430 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6432 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6435 (defun gnus-button-handle-describe-function (url)
6436 "Call `describe-function' when pushing the corresponding URL button."
6439 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6441 (defun gnus-button-handle-describe-variable (url)
6442 "Call `describe-variable' when pushing the corresponding URL button."
6445 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6447 (defun gnus-button-handle-symbol (url)
6448 "Display help on variable or function.
6449 Calls `describe-variable' or `describe-function'."
6450 (let ((sym (intern url)))
6452 ((fboundp sym) (describe-function sym))
6453 ((boundp sym) (describe-variable sym))
6454 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6456 (defun gnus-button-handle-describe-key (url)
6457 "Call `describe-key' when pushing the corresponding URL button."
6459 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6460 (keys (ignore-errors (eval `(kbd ,key-string)))))
6463 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6465 (defun gnus-button-handle-apropos (url)
6466 "Call `apropos' when pushing the corresponding URL button."
6467 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6469 (defun gnus-button-handle-apropos-command (url)
6470 "Call `apropos' when pushing the corresponding URL button."
6472 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6474 (defun gnus-button-handle-apropos-variable (url)
6475 "Call `apropos' when pushing the corresponding URL button."
6477 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6478 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6480 (defun gnus-button-handle-apropos-documentation (url)
6481 "Call `apropos' when pushing the corresponding URL button."
6483 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6484 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6486 (defun gnus-button-handle-library (url)
6487 "Call `locate-library' when pushing the corresponding URL button."
6488 (gnus-message 9 "url=`%s'" url)
6489 (let* ((lib (locate-library url))
6490 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6492 (gnus-message 1 "Cannot locale library `%s'." url)
6493 (find-file-read-only file))))
6495 (defun gnus-button-handle-ctan (url)
6496 "Call `browse-url' when pushing a CTAN URL button."
6498 gnus-button-ctan-handler
6501 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6503 (defcustom gnus-button-tex-level 5
6504 "*Integer that says how many TeX-related buttons Gnus will show.
6505 The higher the number, the more buttons will appear and the more false
6506 positives are possible. Note that you can set this variable local to
6507 specific groups. Setting it higher in TeX groups is probably a good idea.
6508 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6509 how to set variables in specific groups."
6510 :group 'gnus-article-buttons
6511 :link '(custom-manual "(gnus)Group Parameters")
6514 (defcustom gnus-button-man-level 5
6515 "*Integer that says how many man-related buttons Gnus will show.
6516 The higher the number, the more buttons will appear and the more false
6517 positives are possible. Note that you can set this variable local to
6518 specific groups. Setting it higher in Unix groups is probably a good idea.
6519 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6520 how to set variables in specific groups."
6521 :group 'gnus-article-buttons
6522 :link '(custom-manual "(gnus)Group Parameters")
6525 (defcustom gnus-button-emacs-level 5
6526 "*Integer that says how many emacs-related buttons Gnus will show.
6527 The higher the number, the more buttons will appear and the more false
6528 positives are possible. Note that you can set this variable local to
6529 specific groups. Setting it higher in Emacs or Gnus related groups is
6530 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6531 `gnus-parameters' on how to set variables in specific groups."
6532 :group 'gnus-article-buttons
6533 :link '(custom-manual "(gnus)Group Parameters")
6536 (defcustom gnus-button-message-level 5
6537 "*Integer that says how many buttons for news or mail messages will appear.
6538 The higher the number, the more buttons will appear and the more false
6539 positives are possible."
6540 ;; mail addresses, MIDs, URLs for news, ...
6541 :group 'gnus-article-buttons
6544 (defcustom gnus-button-browse-level 5
6545 "*Integer that says how many buttons for browsing will appear.
6546 The higher the number, the more buttons will appear and the more false
6547 positives are possible."
6548 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6549 :group 'gnus-article-buttons
6552 (defcustom gnus-button-alist
6553 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6554 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6555 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6556 gnus-button-handle-news 2)
6557 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6558 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6559 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6560 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6561 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6562 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6563 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6564 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6565 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6566 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6567 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6568 ;; RFC 2368 (The mailto URL scheme)
6569 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6570 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6571 ("\\bmailto:\\([^ \n\t]+\\)"
6572 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6574 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6575 gnus-button-ctan-directory-regexp
6576 "[^][>)!;:,'\n\t ]+\\)")
6577 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6578 ((concat "\\btex-archive/\\("
6579 gnus-button-ctan-directory-regexp
6580 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6581 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6584 gnus-button-ctan-directory-regexp
6585 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6586 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6587 ;; This is info (home-grown style) <info://foo/bar+baz>
6588 ("\\binfo://\\([^'\">\n\t ]+\\)"
6589 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6590 ;; Info GNOME style <info:foo#bar_baz>
6591 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6592 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6593 ;; Info KDE style <info:(foo)bar baz>
6594 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6595 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6596 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6597 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6598 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6599 ;; Info links like `C-h i d m CC Mode RET'
6600 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6602 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6603 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6604 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6605 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6606 ;; Emacs help commands
6607 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6608 ;; regexp doesn't match arguments containing ` '.
6609 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6610 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6611 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6612 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6613 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6614 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6615 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6616 ;; The following entries may lead to many false positives so don't enable
6617 ;; them by default (use a high button level):
6618 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>"
6619 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6620 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6621 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6622 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6623 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6624 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6625 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6626 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6627 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6628 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6629 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6630 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6631 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6632 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6633 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6634 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6635 ;; Unlike the other regexps we really have to require quoting
6636 ;; here to determine where it ends.
6637 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6638 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6639 ("<URL: *\\([^<>]*\\)>"
6640 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6641 ;; RFC 2396 (2.4.3., delims) ...
6642 ("\"URL: *\\([^\"]*\\)\""
6643 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6644 ;; RFC 2396 (2.4.3., delims) ...
6645 ("\"URL: *\\([^\"]*\\)\""
6646 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6648 (gnus-button-url-regexp
6649 0 (>= gnus-button-browse-level 0) browse-url 0)
6651 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6652 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6653 gnus-button-handle-man 1)
6654 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6655 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6656 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6657 gnus-button-handle-man 1)
6658 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6659 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6660 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6661 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6662 ;; MID or mail: To avoid too many false positives we don't try to catch
6663 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6664 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6665 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6666 ;; so that non-ambiguous entries (see above) match first.
6667 (gnus-button-mid-or-mail-regexp
6668 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6669 "*Alist of regexps matching buttons in article bodies.
6671 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6672 REGEXP: is the string (case insensitive) matching text around the button (can
6673 also be Lisp expression evaluating to a string),
6674 BUTTON: is the number of the regexp grouping actually matching the button,
6675 FORM: is a Lisp expression which must eval to true for the button to
6677 CALLBACK: is the function to call when the user push this button, and each
6678 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6680 CALLBACK can also be a variable, in that case the value of that
6681 variable it the real callback function."
6682 :group 'gnus-article-buttons
6683 :type '(repeat (list (choice regexp variable sexp)
6684 (integer :tag "Button")
6686 (function :tag "Callback")
6689 (integer :tag "Regexp group")))))
6691 (defcustom gnus-header-button-alist
6692 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6693 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6694 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6695 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6696 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6697 0 (>= gnus-button-message-level 0) gnus-button-mailto 0)
6698 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6699 0 (>= gnus-button-browse-level 0) browse-url 0)
6700 ("^Subject:" gnus-button-url-regexp
6701 0 (>= gnus-button-browse-level 0) browse-url 0)
6702 ("^[^:]+:" gnus-button-url-regexp
6703 0 (>= gnus-button-browse-level 0) browse-url 0)
6704 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6705 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6706 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6707 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6708 "*Alist of headers and regexps to match buttons in article heads.
6710 This alist is very similar to `gnus-button-alist', except that each
6711 alist has an additional HEADER element first in each entry:
6713 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6715 HEADER is a regexp to match a header. For a fuller explanation, see
6716 `gnus-button-alist'."
6717 :group 'gnus-article-buttons
6718 :group 'gnus-article-headers
6719 :type '(repeat (list (regexp :tag "Header")
6720 (choice regexp variable)
6721 (integer :tag "Button")
6723 (function :tag "Callback")
6726 (integer :tag "Regexp group")))))
6730 (defun gnus-article-push-button (event)
6731 "Check text under the mouse pointer for a callback function.
6732 If the text under the mouse pointer has a `gnus-callback' property,
6733 call it with the value of the `gnus-data' text property."
6735 (set-buffer (window-buffer (posn-window (event-start event))))
6736 (let* ((pos (posn-point (event-start event)))
6737 (data (get-text-property pos 'gnus-data))
6738 (fun (get-text-property pos 'gnus-callback)))
6741 (funcall fun data))))
6743 (defun gnus-article-press-button ()
6744 "Check text at point for a callback function.
6745 If the text at point has a `gnus-callback' property,
6746 call it with the value of the `gnus-data' text property."
6748 (let ((data (get-text-property (point) 'gnus-data))
6749 (fun (get-text-property (point) 'gnus-callback)))
6751 (funcall fun data))))
6753 (defun gnus-article-prev-button (n)
6754 "Move point to N buttons backward.
6755 If N is negative, move forward instead."
6757 (gnus-article-next-button (- n)))
6759 (defun gnus-article-next-button (n)
6760 "Move point to N buttons forward.
6761 If N is negative, move backward instead."
6763 (let ((function (if (< n 0) 'previous-single-property-change
6764 'next-single-property-change))
6765 (inhibit-point-motion-hooks t)
6767 (limit (if (< n 0) (point-min) (point-max))))
6769 (while (and (not (= limit (point)))
6771 ;; Skip past the current button.
6772 (when (get-text-property (point) 'gnus-callback)
6773 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6774 ;; Go to the next (or previous) button.
6775 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
6776 ;; Put point at the start of the button.
6777 (when (and backward (not (get-text-property (point) 'gnus-callback)))
6778 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6779 ;; Skip past intangible buttons.
6780 (when (get-text-property (point) 'intangible)
6784 (gnus-message 5 "No more buttons"))
6787 (defun gnus-article-highlight (&optional force)
6788 "Highlight current article.
6789 This function calls `gnus-article-highlight-headers',
6790 `gnus-article-highlight-citation',
6791 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6792 do the highlighting. See the documentation for those functions."
6793 (interactive (list 'force))
6794 (gnus-article-highlight-headers)
6795 (gnus-article-highlight-citation force)
6796 (gnus-article-highlight-signature)
6797 (gnus-article-add-buttons force)
6798 (gnus-article-add-buttons-to-head))
6800 (defun gnus-article-highlight-some (&optional force)
6801 "Highlight current article.
6802 This function calls `gnus-article-highlight-headers',
6803 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6804 do the highlighting. See the documentation for those functions."
6805 (interactive (list 'force))
6806 (gnus-article-highlight-headers)
6807 (gnus-article-highlight-signature)
6808 (gnus-article-add-buttons))
6810 (defun gnus-article-highlight-headers ()
6811 "Highlight article headers as specified by `gnus-header-face-alist'."
6813 (gnus-with-article-headers
6814 (let ((alist gnus-header-face-alist)
6815 entry regexp header-face field-face from hpoints fpoints)
6816 (while (setq entry (pop alist))
6817 (goto-char (point-min))
6818 (setq regexp (concat "^\\("
6819 (if (string-equal "" (nth 0 entry))
6823 header-face (nth 1 entry)
6824 field-face (nth 2 entry))
6825 (while (and (re-search-forward regexp nil t)
6829 (unless (search-forward ":" nil t)
6831 (when (and header-face
6832 (not (memq (point) hpoints)))
6833 (push (point) hpoints)
6834 (gnus-put-text-property from (point) 'face header-face))
6835 (when (and field-face
6836 (not (memq (setq from (point)) fpoints)))
6838 (if (re-search-forward "^[^ \t]" nil t)
6840 (goto-char (point-max)))
6841 (gnus-put-text-property from (point) 'face field-face)))))))
6843 (defun gnus-article-highlight-signature ()
6844 "Highlight the signature in an article.
6845 It does this by highlighting everything after
6846 `gnus-signature-separator' using `gnus-signature-face'."
6848 (when gnus-signature-face
6849 (gnus-with-article-buffer
6850 (let ((inhibit-point-motion-hooks t))
6852 (when (gnus-article-narrow-to-signature)
6853 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6854 'face gnus-signature-face)))))))
6856 (defun gnus-article-buttonize-signature ()
6857 "Add button to the signature."
6860 (set-buffer gnus-article-buffer)
6861 (let ((buffer-read-only nil)
6862 (inhibit-point-motion-hooks t))
6863 (when (gnus-article-search-signature)
6864 (gnus-article-add-button (match-beginning 0) (match-end 0)
6865 'gnus-signature-toggle
6866 (set-marker (make-marker)
6867 (1+ (match-end 0))))))))
6869 (defun gnus-button-in-region-p (b e prop)
6870 "Say whether PROP exists in the region."
6871 (text-property-not-all b e prop nil))
6873 (defun gnus-article-add-buttons (&optional force)
6874 "Find external references in the article and make buttons of them.
6875 \"External references\" are things like Message-IDs and URLs, as
6876 specified by `gnus-button-alist'."
6877 (interactive (list 'force))
6878 (gnus-with-article-buffer
6879 (let ((inhibit-point-motion-hooks t)
6880 (case-fold-search t)
6881 (alist gnus-button-alist)
6883 ;; Remove all old markers.
6884 (let (marker entry new-list)
6885 (while (setq marker (pop gnus-button-marker-list))
6886 (if (or (< marker (point-min)) (>= marker (point-max)))
6887 (push marker new-list)
6889 (when (setq entry (gnus-button-entry))
6890 (put-text-property (match-beginning (nth 1 entry))
6891 (match-end (nth 1 entry))
6892 'gnus-callback nil))
6893 (set-marker marker nil)))
6894 (setq gnus-button-marker-list new-list))
6895 ;; We skip the headers.
6898 (while (setq entry (pop alist))
6899 (setq regexp (eval (car entry)))
6901 (while (re-search-forward regexp nil t)
6902 (let* ((start (and entry (match-beginning (nth 1 entry))))
6903 (end (and entry (match-end (nth 1 entry))))
6904 (from (match-beginning 0)))
6905 (when (and (or (eq t (nth 2 entry))
6906 (eval (nth 2 entry)))
6907 (not (gnus-button-in-region-p
6908 start end 'gnus-callback)))
6909 ;; That optional form returned non-nil, so we add the
6911 (gnus-article-add-button
6912 start end 'gnus-button-push
6913 (car (push (set-marker (make-marker) from)
6914 gnus-button-marker-list))))))))))
6916 ;; Add buttons to the head of an article.
6917 (defun gnus-article-add-buttons-to-head ()
6918 "Add buttons to the head of the article."
6920 (gnus-with-article-headers
6921 (let ((alist gnus-header-button-alist)
6924 ;; Each alist entry.
6925 (setq entry (pop alist))
6926 (goto-char (point-min))
6927 (while (re-search-forward (car entry) nil t)
6928 ;; Each header matching the entry.
6929 (setq beg (match-beginning 0))
6930 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6931 (match-beginning 0))
6934 (while (re-search-forward (eval (nth 1 entry)) end t)
6935 ;; Each match within a header.
6936 (let* ((entry (cdr entry))
6937 (start (match-beginning (nth 1 entry)))
6938 (end (match-end (nth 1 entry)))
6939 (form (nth 2 entry)))
6940 (goto-char (match-end 0))
6942 (gnus-article-add-button
6943 start end (nth 3 entry)
6944 (buffer-substring (match-beginning (nth 4 entry))
6945 (match-end (nth 4 entry)))))))
6946 (goto-char end))))))
6948 ;;; External functions:
6950 (defun gnus-article-add-button (from to fun &optional data)
6951 "Create a button between FROM and TO with callback FUN and data DATA."
6952 (when gnus-article-button-face
6953 (gnus-overlay-put (gnus-make-overlay from to)
6954 'face gnus-article-button-face))
6955 (gnus-add-text-properties
6957 (nconc (and gnus-article-mouse-face
6958 (list gnus-mouse-face-prop gnus-article-mouse-face))
6959 (list 'gnus-callback fun)
6960 (and data (list 'gnus-data data))))
6961 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6962 :button-keymap gnus-widget-button-keymap))
6964 ;;; Internal functions:
6966 (defun gnus-article-set-globals ()
6967 (with-current-buffer gnus-summary-buffer
6968 (gnus-set-global-variables)))
6970 (defun gnus-signature-toggle (end)
6971 (gnus-with-article-buffer
6972 (let ((inhibit-point-motion-hooks t)
6973 (limit (next-single-property-change end 'mime-view-entity
6975 (if (text-property-any end limit 'article-type 'signature)
6977 (gnus-delete-wash-type 'signature)
6978 (gnus-remove-text-properties-when
6979 'article-type 'signature end limit
6980 (cons 'article-type (cons 'signature
6981 gnus-hidden-properties))))
6982 (gnus-add-wash-type 'signature)
6983 (gnus-add-text-properties-when
6984 'article-type nil end limit
6985 (cons 'article-type (cons 'signature
6986 gnus-hidden-properties)))))
6987 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6988 (gnus-set-mode-line 'article))))
6990 (defun gnus-button-entry ()
6991 ;; Return the first entry in `gnus-button-alist' matching this place.
6992 (let ((alist gnus-button-alist)
6995 (setq entry (pop alist))
6996 (if (looking-at (eval (car entry)))
7001 (defun gnus-button-push (marker)
7002 ;; Push button starting at MARKER.
7005 (let* ((entry (gnus-button-entry))
7006 (inhibit-point-motion-hooks t)
7008 (args (mapcar (lambda (group)
7009 (let ((string (match-string group)))
7010 (set-text-properties
7011 0 (length string) nil string)
7018 (fboundp (symbol-value fun)))
7019 (apply (symbol-value fun) args))
7021 (gnus-message 1 "You must define `%S' to use this button"
7022 (cons fun args)))))))
7024 (defun gnus-parse-news-url (url)
7025 (let (scheme server group message-id articles)
7028 (goto-char (point-min))
7029 (when (looking-at "\\([A-Za-z]+\\):")
7030 (setq scheme (match-string 1))
7031 (goto-char (match-end 0)))
7032 (when (looking-at "//\\([^/]+\\)/")
7033 (setq server (match-string 1))
7034 (goto-char (match-end 0)))
7037 ((looking-at "\\(.*@.*\\)")
7038 (setq message-id (match-string 1)))
7039 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7040 (setq group (match-string 1)
7041 articles (split-string (match-string 2) "-")))
7042 ((looking-at "\\([^/]+\\)/?")
7043 (setq group (match-string 1)))
7045 (error "Unknown news URL syntax"))))
7046 (list scheme server group message-id articles)))
7048 (defun gnus-button-handle-news (url)
7050 (destructuring-bind (scheme server group message-id articles)
7051 (gnus-parse-news-url url)
7055 (set-buffer gnus-summary-buffer)
7057 (let ((gnus-refer-article-method (list (list 'nntp server))))
7058 (gnus-summary-refer-article message-id))
7059 (gnus-summary-refer-article message-id))))
7061 (gnus-button-fetch-group url)))))
7063 (defun gnus-button-handle-man (url)
7065 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7066 (when (eq gnus-button-man-handler 'woman)
7067 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
7068 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7069 (funcall gnus-button-man-handler url))
7071 (defun gnus-button-handle-info-url (url)
7072 "Fetch an info URL."
7073 (setq url (mm-subst-char-in-string ?+ ?\ url))
7075 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
7076 (gnus-info-find-node
7077 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
7079 ")" (gnus-url-unhex-string (match-string 2 url)))))
7080 ((string-match "([^)\"]+)[^\"]+" url)
7082 (gnus-replace-in-string
7083 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
7084 (gnus-info-find-node url))
7085 (t (error "Can't parse %s" url))))
7087 (defun gnus-button-handle-info-url-gnome (url)
7088 "Fetch GNOME style info URL."
7089 (setq url (mm-subst-char-in-string ?_ ?\ url))
7090 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
7091 (gnus-info-find-node
7093 (gnus-url-unhex-string
7094 (match-string 1 url))
7096 (or (gnus-url-unhex-string
7097 (match-string 2 url))
7099 (error "Can't parse %s" url)))
7101 (defun gnus-button-handle-info-url-kde (url)
7102 "Fetch KDE style info URL."
7103 (gnus-info-find-node (gnus-url-unhex-string url)))
7105 (defun gnus-button-handle-info-keystrokes (url)
7106 "Call `info' when pushing the corresponding URL button."
7107 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
7112 (defun gnus-button-message-id (message-id)
7114 (with-current-buffer gnus-summary-buffer
7115 (gnus-summary-refer-article message-id)))
7117 (defun gnus-button-fetch-group (address)
7118 "Fetch GROUP specified by ADDRESS."
7119 (if (not (string-match "[:/]" address))
7120 ;; This is just a simple group url.
7121 (gnus-group-read-ephemeral-group address gnus-select-method)
7124 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
7126 (error "Can't parse %s" address)
7127 (gnus-group-read-ephemeral-group
7128 (match-string 4 address)
7129 `(nntp ,(match-string 1 address)
7130 (nntp-address ,(match-string 1 address))
7131 (nntp-port-number ,(if (match-end 3)
7132 (match-string 3 address)
7135 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
7137 (defun gnus-url-parse-query-string (query &optional downcase)
7138 (let (retval pairs cur key val)
7139 (setq pairs (split-string query "&"))
7141 (setq cur (car pairs)
7143 (if (not (string-match "=" cur))
7145 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
7146 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
7148 (setq key (downcase key)))
7149 (setq cur (assoc key retval))
7151 (setcdr cur (cons val (cdr cur)))
7152 (setq retval (cons (list key val) retval)))))
7155 (defun gnus-url-mailto (url)
7156 ;; Send mail to someone
7157 (when (string-match "mailto:/*\\(.*\\)" url)
7158 (setq url (substring url (match-beginning 1) nil)))
7159 (let (to args subject func)
7160 (setq args (gnus-url-parse-query-string
7161 (if (string-match "^\\?" url)
7163 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
7164 (concat "to=" (match-string 1 url) "&"
7165 (match-string 2 url))
7166 (concat "to=" url)))
7168 subject (cdr-safe (assoc "subject" args)))
7171 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
7174 (message-position-on-field (caar args)))
7175 (insert (gnus-replace-in-string
7176 (mapconcat 'identity (reverse (cdar args)) ", ")
7178 (setq args (cdr args)))
7181 (message-goto-subject))))
7183 (defun gnus-button-embedded-url (address)
7184 "Activate ADDRESS with `browse-url'."
7185 (browse-url (gnus-strip-whitespace address)))
7187 ;;; Next/prev buttons in the article buffer.
7189 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
7190 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
7192 (defvar gnus-prev-page-map
7193 (let ((map (make-sparse-keymap)))
7194 (define-key map gnus-mouse-2 'gnus-button-prev-page)
7195 (define-key map "\r" 'gnus-button-prev-page)
7198 (defvar gnus-next-page-map
7199 (let ((map (make-sparse-keymap)))
7200 (define-key map gnus-mouse-2 'gnus-button-next-page)
7201 (define-key map "\r" 'gnus-button-next-page)
7204 (defun gnus-insert-prev-page-button ()
7206 (buffer-read-only nil)
7207 (situation (get-text-property (point-min) 'mime-view-situation)))
7209 gnus-prev-page-line-format nil
7210 `(keymap ,gnus-prev-page-map
7212 gnus-callback gnus-article-button-prev-page
7213 article-type annotation
7214 mime-view-situation ,situation))
7215 (widget-convert-button
7217 ;; Exclude a newline.
7220 :action 'gnus-button-prev-page
7221 :button-keymap gnus-prev-page-map)))
7223 (defun gnus-button-next-page (&optional args more-args)
7224 "Go to the next page."
7226 (let ((win (selected-window)))
7227 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7228 (gnus-article-next-page)
7229 (select-window win)))
7231 (defun gnus-button-prev-page (&optional args more-args)
7232 "Go to the prev page."
7234 (let ((win (selected-window)))
7235 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7236 (gnus-article-prev-page)
7237 (select-window win)))
7239 (defun gnus-insert-next-page-button ()
7241 (buffer-read-only nil)
7242 (situation (get-text-property (point-min) 'mime-view-situation)))
7243 (gnus-eval-format gnus-next-page-line-format nil
7244 `(keymap ,gnus-next-page-map
7246 gnus-callback gnus-article-button-next-page
7247 article-type annotation
7248 mime-view-situation ,situation))
7249 (widget-convert-button
7251 ;; Exclude a newline.
7254 :action 'gnus-button-next-page
7255 :button-keymap gnus-next-page-map)))
7257 (defun gnus-article-button-next-page (arg)
7258 "Go to the next page."
7260 (let ((win (selected-window)))
7261 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7262 (gnus-article-next-page)
7263 (select-window win)))
7265 (defun gnus-article-button-prev-page (arg)
7266 "Go to the prev page."
7268 (let ((win (selected-window)))
7269 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7270 (gnus-article-prev-page)
7271 (select-window win)))
7273 (defvar gnus-decode-header-methods
7274 '(mail-decode-encoded-word-region)
7275 "List of methods used to decode headers.
7277 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7278 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
7279 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
7280 whose names match REGEXP.
7283 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7284 mail-decode-encoded-word-region
7285 (\"chinese\" . rfc1843-decode-region))
7288 (defvar gnus-decode-header-methods-cache nil)
7290 (defun gnus-multi-decode-header (start end)
7291 "Apply the functions from `gnus-encoded-word-methods' that match."
7292 (unless (and gnus-decode-header-methods-cache
7293 (eq gnus-newsgroup-name
7294 (car gnus-decode-header-methods-cache)))
7295 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7298 (nconc gnus-decode-header-methods-cache (list x))
7299 (if (and gnus-newsgroup-name
7300 (string-match (car x) gnus-newsgroup-name))
7301 (nconc gnus-decode-header-methods-cache
7303 gnus-decode-header-methods))
7304 (let ((xlist gnus-decode-header-methods-cache))
7307 (narrow-to-region start end)
7309 (funcall (pop xlist) (point-min) (point-max))))))
7312 ;;; Treatment top-level handling.
7315 (defun gnus-treat-article (condition &optional part-number total-parts type)
7316 (let ((length (- (point-max) (point-min)))
7317 (alist gnus-treatment-function-alist)
7318 (article-goto-body-goes-to-point-min-p t)
7322 (let ((list gnus-article-treat-types))
7324 (when (string-match (pop list) type)
7325 (throw 'found t)))))))
7326 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7327 (entity (static-unless (featurep 'xemacs)
7328 (when (eq 'head condition)
7329 (get-text-property (point-min) 'mime-view-entity))))
7330 val elem buttonized)
7331 (gnus-run-hooks 'gnus-part-display-hook)
7332 (unless gnus-inhibit-treatment
7333 (dolist (elem alist)
7336 (when (gnus-buffer-live-p gnus-summary-buffer)
7337 (set-buffer gnus-summary-buffer))
7338 (symbol-value (car elem))))
7339 (when (and (or (consp val)
7341 (gnus-treat-predicate val)
7342 (or (not (get (car elem) 'highlight))
7344 (when (and (not buttonized)
7346 '(gnus-treat-hide-signature
7347 gnus-treat-highlight-signature)))
7348 (gnus-article-buttonize-signature)
7349 (setq buttonized t))
7351 (funcall (cadr elem)))))
7352 ;; FSF Emacsen does not inherit the existing text properties
7353 ;; in the new text, so we should do it for `mime-view-entity'.
7354 (static-unless (featurep 'xemacs)
7356 (put-text-property (point-min) (point-max)
7357 'mime-view-entity entity))))))
7359 ;; Dynamic variables.
7361 (defvar part-number)
7362 (defvar total-parts)
7367 (defun gnus-treat-predicate (val)
7372 (stringp (car val)))
7373 (apply 'gnus-or (mapcar `(lambda (s)
7374 (string-match s ,(or gnus-newsgroup-name "")))
7377 (let ((pred (pop val)))
7380 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7382 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7384 (not (gnus-treat-predicate (car val))))
7386 (equal (car val) type))
7388 (error "%S is not a valid predicate" pred)))))
7398 (eq part-number total-parts))
7402 (error "%S is not a valid value" val))))
7404 (defun gnus-article-encrypt-body (protocol &optional n)
7405 "Encrypt the article body."
7408 (or gnus-article-encrypt-protocol
7409 (completing-read "Encrypt protocol: "
7410 gnus-article-encrypt-protocol-alist
7412 current-prefix-arg))
7413 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7415 (error (format "Can't find the encrypt protocol %s" protocol)))
7416 (if (member gnus-newsgroup-name '("nndraft:delayed"
7419 (error "Can't encrypt the article in group %s"
7420 gnus-newsgroup-name))
7421 (gnus-summary-iterate n
7423 (set-buffer gnus-summary-buffer)
7424 (let ((mail-parse-charset gnus-newsgroup-charset)
7425 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7426 (summary-buffer gnus-summary-buffer)
7428 (gnus-set-global-variables)
7429 (when (gnus-group-read-only-p)
7430 (error "The current newsgroup does not support article encrypt"))
7431 (gnus-summary-show-article t)
7433 (or (mail-header-references gnus-current-headers) ""))
7434 (set-buffer gnus-article-buffer)
7435 (let* ((buffer-read-only nil)
7437 (mapcar (lambda (field)
7438 (and (save-restriction
7439 (message-narrow-to-head)
7440 (goto-char (point-min))
7441 (search-forward field nil t))
7443 (message-narrow-to-field)
7445 (delete-region (point-min) (point-max))
7447 '("Content-Type:" "Content-Transfer-Encoding:"
7448 "Content-Disposition:"))))
7449 (message-narrow-to-head)
7450 (message-remove-header "MIME-Version")
7451 (goto-char (point-max))
7452 (setq point (point))
7453 (insert (apply 'concat headers))
7455 (narrow-to-region point (point-max))
7456 (let ((message-options message-options))
7457 (message-options-set 'message-sender user-mail-address)
7458 (message-options-set 'message-recipients user-mail-address)
7459 (message-options-set 'message-sign-encrypt 'not)
7461 (goto-char (point-min))
7462 (insert "MIME-Version: 1.0\n")
7464 (gnus-summary-edit-article-done
7465 references nil summary-buffer t))
7466 (when gnus-keep-backlog
7467 (gnus-backlog-remove-article
7468 (car gnus-article-current) (cdr gnus-article-current)))
7470 (when (get-buffer gnus-original-article-buffer)
7471 (set-buffer gnus-original-article-buffer)
7472 (setq gnus-original-article nil)))
7473 (when gnus-use-cache
7474 (gnus-cache-update-article
7475 (car gnus-article-current) (cdr gnus-article-current))))))))
7477 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7478 "The following specs can be used:
7479 %t The security MIME type
7482 %D Details if button is pressed")
7484 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7485 "The following specs can be used:
7486 %t The security MIME type
7489 %D Details if button is pressed")
7491 (defvar gnus-mime-security-button-line-format-alist
7492 '((?t gnus-tmp-type ?s)
7493 (?i gnus-tmp-info ?s)
7494 (?d gnus-tmp-details ?s)
7495 (?D gnus-tmp-pressed-details ?s)))
7497 (defvar gnus-mime-security-button-map
7498 (let ((map (make-sparse-keymap)))
7499 (define-key map gnus-mouse-2 'gnus-article-push-button)
7500 (define-key map "\r" 'gnus-article-press-button)
7503 (defvar gnus-mime-security-details-buffer nil)
7505 (defvar gnus-mime-security-button-pressed nil)
7507 (defvar gnus-mime-security-show-details-inline t
7508 "If non-nil, show details in the article buffer.")
7510 (defun gnus-mime-security-verify-or-decrypt (handle)
7511 (mm-remove-parts (cdr handle))
7512 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7513 point buffer-read-only)
7515 (goto-char (car region)))
7517 (narrow-to-region (point) (point))
7518 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7519 (let* ((mm-verify-option 'known)
7520 (mm-decrypt-option 'known)
7521 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7522 (unless (eq nparts (cdr handle))
7523 (mm-destroy-parts (cdr handle))
7524 (setcdr handle nparts))))
7525 (setq point (point))
7526 (gnus-mime-display-security handle)
7527 (goto-char (point-max)))
7529 (delete-region (point) (cdr region))
7530 (set-marker (car region) nil)
7531 (set-marker (cdr region) nil))
7534 (defun gnus-mime-security-show-details (handle)
7535 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7537 (gnus-message 5 "No details.")
7538 (if gnus-mime-security-show-details-inline
7539 (let ((gnus-mime-security-button-pressed
7540 (not (get-text-property (point) 'gnus-mime-details)))
7541 (gnus-mime-security-button-line-format
7542 (get-text-property (point) 'gnus-line-format))
7545 (while (eq (get-text-property (point) 'gnus-line-format)
7546 gnus-mime-security-button-line-format)
7550 (narrow-to-region (point) (point))
7551 (gnus-insert-mime-security-button handle))
7552 (delete-region (point)
7553 (or (text-property-not-all
7556 gnus-mime-security-button-line-format)
7559 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7560 (with-current-buffer gnus-mime-security-details-buffer
7563 (setq gnus-mime-security-details-buffer
7564 (gnus-get-buffer-create "*MIME Security Details*")))
7565 (with-current-buffer gnus-mime-security-details-buffer
7567 (goto-char (point-min)))
7568 (pop-to-buffer gnus-mime-security-details-buffer)))))
7570 (defun gnus-mime-security-press-button (handle)
7572 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7573 (gnus-mime-security-show-details handle)
7574 (gnus-mime-security-verify-or-decrypt handle))))
7576 (defun gnus-insert-mime-security-button (handle &optional displayed)
7577 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7580 (or (nth 2 (assoc protocol mm-verify-function-alist))
7581 (nth 2 (assoc protocol mm-decrypt-function-alist))
7583 (if (equal (car handle) "multipart/signed")
7584 " Signed" " Encrypted")
7587 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7590 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7591 gnus-tmp-pressed-details
7593 (setq gnus-tmp-details
7594 (if gnus-tmp-details
7595 (concat "\n" gnus-tmp-details)
7597 (setq gnus-tmp-pressed-details
7598 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7603 gnus-mime-security-button-line-format
7604 gnus-mime-security-button-line-format-alist
7605 `(keymap ,gnus-mime-security-button-map
7606 gnus-callback gnus-mime-security-press-button
7607 gnus-line-format ,gnus-mime-security-button-line-format
7608 gnus-mime-details ,gnus-mime-security-button-pressed
7609 article-type annotation
7612 ;; Exclude a newline.
7615 (widget-convert-button
7618 :action 'gnus-widget-press-button
7619 :button-keymap gnus-mime-security-button-map
7621 (lambda (widget/window &optional overlay pos)
7622 ;; Needed to properly clear the message due to a bug in
7623 ;; wid-edit (XEmacs only).
7624 (when (boundp 'help-echo-owns-message)
7625 (setq help-echo-owns-message t))
7628 (aref gnus-mouse-2 0))))))
7630 (defun gnus-mime-display-security (handle)
7632 (narrow-to-region (point) (point))
7633 (unless (gnus-unbuttonized-mime-type-p (car handle))
7634 (gnus-insert-mime-security-button handle))
7635 (gnus-mime-display-mixed (cdr handle))
7638 (unless (gnus-unbuttonized-mime-type-p (car handle))
7639 (let ((gnus-mime-security-button-line-format
7640 gnus-mime-security-button-end-line-format))
7641 (gnus-insert-mime-security-button handle)))
7642 (mm-set-handle-multipart-parameter
7644 (cons (set-marker (make-marker) (point-min))
7645 (set-marker (make-marker) (point-max))))))
7651 (defun gnus-article-header-presentation-method (entity situation)
7652 (mime-insert-header entity)
7653 (article-decode-group-name))
7655 (set-alist 'mime-header-presentation-method-alist
7656 'gnus-original-article-mode
7657 #'gnus-article-header-presentation-method)
7659 (defun gnus-mime-preview-quitting-method ()
7660 (mime-preview-kill-buffer)
7661 (delete-other-windows)
7662 (gnus-article-show-summary)
7663 (gnus-summary-select-article gnus-show-all-headers t))
7665 (set-alist 'mime-preview-quitting-method-alist
7666 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
7668 (set-alist 'mime-preview-following-method-alist
7669 'gnus-original-article-mode #'gnus-following-method)
7671 (set-alist 'mime-preview-over-to-previous-method-alist
7672 'gnus-original-article-mode
7674 (if (> (point-min) 1)
7675 (gnus-article-prev-page)
7676 (gnus-article-read-summary-keys
7677 nil (gnus-character-to-event ?P)))))
7679 (set-alist 'mime-preview-over-to-next-method-alist
7680 'gnus-original-article-mode'
7682 (if (< (point-max) (buffer-size))
7683 (gnus-article-next-page)
7684 (gnus-article-read-summary-keys
7685 nil (gnus-character-to-event ?N)))))
7695 (run-hooks 'gnus-art-load-hook)
7697 ;;; gnus-art.el ends here