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."
250 :type '(choice (integer :value 200)
252 (function :value fun)
253 (regexp :value ".*"))
254 :group 'gnus-article-signature)
256 (defcustom gnus-hidden-properties '(invisible t intangible t)
257 "Property list to use for hiding text."
259 :group 'gnus-article-hiding)
261 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
262 ;; frames in a session.
263 (defcustom gnus-article-x-face-command
268 (if (or (gnus-image-type-available-p 'xface)
269 (gnus-image-type-available-p 'pbm))
270 'gnus-display-x-face-in-from
271 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -"))
272 ((and (fboundp 'image-type-available-p)
273 (module-installed-p 'x-face-e21))
274 'x-face-decode-message-header)
275 ((gnus-image-type-available-p 'pbm)
276 'gnus-display-x-face-in-from)
278 (module-installed-p 'x-face-mule))
279 'x-face-mule-gnus-article-display-x-face)
281 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
283 "*String or function to be executed to display an X-Face header.
284 If it is a string, the command will be executed in a sub-shell
285 asynchronously. The compressed face will be piped to this command."
287 ,@(let (x-face-e21 x-face-mule)
288 (if (featurep 'xemacs)
290 (setq x-face-e21 (module-installed-p 'x-face-e21)
291 x-face-mule (module-installed-p 'x-face-mule)))
295 (if (or (gnus-image-type-available-p 'xface)
296 (gnus-image-type-available-p 'pbm))
297 '(function-item gnus-display-x-face-in-from))
299 (fboundp 'image-type-available-p))
301 :tag "x-face-decode-message-header (x-face-e21)"
302 x-face-decode-message-header))
305 x-face-mule-gnus-article-display-x-face))
309 :group 'gnus-article-washing)
311 (defcustom gnus-article-x-face-too-ugly nil
312 "Regexp matching posters whose face shouldn't be shown automatically."
313 :type '(choice regexp (const nil))
314 :group 'gnus-article-washing)
316 (defcustom gnus-article-banner-alist nil
317 "Banner alist for stripping.
319 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
321 :type '(repeat (cons symbol regexp))
322 :group 'gnus-article-washing)
324 (gnus-define-group-parameter
327 "Alist of regexps (to match group names) and banner."
328 :variable-group gnus-article-washing
330 '(choice :tag "Banner"
332 (const :tag "Remove signature" signature)
333 (symbol :tag "Item in `gnus-article-banner-alist'" none)
335 (const :tag "None" nil))
337 "If non-nil, specify how to remove `banners' from articles.
339 Symbol `signature' means to remove signatures delimited by
340 `gnus-signature-separator'. Any other symbol is used to look up a
341 regular expression to match the banner in `gnus-article-banner-alist'.
342 A string is used as a regular expression to match the banner
345 (defcustom gnus-article-address-banner-alist nil
346 "Alist of mail addresses and banners.
347 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
348 to match a mail address in the From: header, BANNER is one of a symbol
349 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
350 If ADDRESS matches author's mail address, it will remove things like
351 advertisements. For example:
353 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
357 (regexp :tag "Address")
358 (choice :tag "Banner" :value nil
359 (const :tag "Remove signature" signature)
360 (symbol :tag "Item in `gnus-article-banner-alist'" none)
362 (const :tag "None" nil))))
363 :group 'gnus-article-washing)
365 (defcustom gnus-emphasis-alist
367 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
372 ("_/" "/_" underline-italic)
373 ("_\\*" "\\*_" underline-bold)
374 ("\\*/" "/\\*" bold-italic)
375 ("_\\*/" "/\\*_" underline-bold-italic))))
379 (format format (car spec) (car (cdr spec)))
380 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
382 ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
383 2 3 gnus-emphasis-strikethru)
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'."
816 (defcustom gnus-body-boundary-delimiter "_"
817 "String used to delimit header and body.
818 This variable is used by `gnus-article-treat-body-boundary' which can
819 be controlled by `gnus-treat-body-boundary'."
820 :group 'gnus-article-various
821 :type '(choice (item :tag "None" :value nil)
824 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
825 "Defines the location of the faces database.
826 For information on obtaining this database of pretty pictures, please
827 see http://www.cs.indiana.edu/picons/ftp/index.html"
828 :type '(repeat directory)
829 :link '(url-link :tag "download"
830 "http://www.cs.indiana.edu/picons/ftp/index.html")
831 :link '(custom-manual "(gnus)Picons")
834 (defun gnus-picons-installed-p ()
835 "Say whether picons are installed on your machine."
836 (let ((installed nil))
837 (dolist (database gnus-picon-databases)
838 (when (file-exists-p database)
842 (defcustom gnus-article-mime-part-function nil
843 "Function called with a MIME handle as the argument.
844 This is meant for people who want to do something automatic based
845 on parts -- for instance, adding Vcard info to a database."
846 :group 'gnus-article-mime
849 (defcustom gnus-mime-multipart-functions nil
850 "An alist of MIME types to functions to display them."
852 :group 'gnus-article-mime
855 (defcustom gnus-article-date-lapsed-new-header nil
856 "Whether the X-Sent and Date headers can coexist.
857 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
858 either replace the old \"Date:\" header (if this variable is nil), or
859 be added below it (otherwise)."
861 :group 'gnus-article-headers
864 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
865 "Function called with a MIME handle as the argument.
866 This is meant for people who want to view first matched part.
867 For `undisplayed-alternative' (default), the first undisplayed
868 part or alternative part is used. For `undisplayed', the first
869 undisplayed part is used. For a function, the first part which
870 the function return t is used. For nil, the first part is
873 :group 'gnus-article-mime
875 (item :tag "first" :value nil)
876 (item :tag "undisplayed" :value undisplayed)
877 (item :tag "undisplayed or alternative"
878 :value undisplayed-alternative)
881 (defcustom gnus-mime-action-alist
882 '(("save to file" . gnus-mime-save-part)
883 ("save and strip" . gnus-mime-save-part-and-strip)
884 ("delete part" . gnus-mime-delete-part)
885 ("display as text" . gnus-mime-inline-part)
886 ("view the part" . gnus-mime-view-part)
887 ("pipe to command" . gnus-mime-pipe-part)
888 ("toggle display" . gnus-article-press-button)
889 ("toggle display" . gnus-article-view-part-as-charset)
890 ("view as type" . gnus-mime-view-part-as-type)
891 ("view internally" . gnus-mime-view-part-internally)
892 ("view externally" . gnus-mime-view-part-externally))
893 "An alist of actions that run on the MIME attachment."
894 :group 'gnus-article-mime
895 :type '(repeat (cons (string :tag "name")
899 ;;; The treatment variables
902 (defvar gnus-part-display-hook nil
903 "Hook called on parts that are to receive treatment.")
905 (defvar gnus-article-treat-custom
906 '(choice (const :tag "Off" nil)
908 (const :tag "Header" head)
909 (const :tag "Last" last)
910 (const :tag "Mime" mime)
911 (integer :tag "Less")
912 (repeat :tag "Groups" regexp)
913 (sexp :tag "Predicate")))
915 (defvar gnus-article-treat-head-custom
916 '(choice (const :tag "Off" nil)
917 (const :tag "Header" head)))
919 (defvar gnus-article-treat-types '("text/plain")
922 (defvar gnus-inhibit-treatment nil
923 "Whether to inhibit treatment.")
925 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
926 "Highlight the signature.
927 Valid values are nil, t, `head', `last', an integer or a predicate.
928 See Info node `(gnus)Customizing Articles'."
929 :group 'gnus-article-treat
930 :link '(custom-manual "(gnus)Customizing Articles")
931 :type gnus-article-treat-custom)
932 (put 'gnus-treat-highlight-signature 'highlight t)
934 (defcustom gnus-treat-buttonize 100000
936 Valid values are nil, t, `head', `last', an integer or a predicate.
937 See Info node `(gnus)Customizing Articles'."
938 :group 'gnus-article-treat
939 :link '(custom-manual "(gnus)Customizing Articles")
940 :type gnus-article-treat-custom)
941 (put 'gnus-treat-buttonize 'highlight t)
943 (defcustom gnus-treat-buttonize-head 'head
944 "Add buttons to the head.
945 Valid values are nil, t, `head', `last', an integer or a predicate.
946 See Info node `(gnus)Customizing Articles' for details."
947 :group 'gnus-article-treat
948 :link '(custom-manual "(gnus)Customizing Articles")
949 :type gnus-article-treat-head-custom)
950 (put 'gnus-treat-buttonize-head 'highlight t)
952 (defcustom gnus-treat-emphasize
953 (and (or window-system
957 Valid values are nil, t, `head', `last', an integer or a predicate.
958 See Info node `(gnus)Customizing Articles' for details."
959 :group 'gnus-article-treat
960 :link '(custom-manual "(gnus)Customizing Articles")
961 :type gnus-article-treat-custom)
962 (put 'gnus-treat-emphasize 'highlight t)
964 (defcustom gnus-treat-strip-cr nil
965 "Remove carriage returns.
966 Valid values are nil, t, `head', `last', an integer or a predicate.
967 See Info node `(gnus)Customizing Articles' for details."
968 :group 'gnus-article-treat
969 :link '(custom-manual "(gnus)Customizing Articles")
970 :type gnus-article-treat-custom)
972 (defcustom gnus-treat-unsplit-urls nil
973 "Remove newlines from within URLs.
974 Valid values are nil, t, `head', `last', an integer or a predicate.
975 See Info node `(gnus)Customizing Articles' for details."
976 :group 'gnus-article-treat
977 :link '(custom-manual "(gnus)Customizing Articles")
978 :type gnus-article-treat-custom)
980 (defcustom gnus-treat-leading-whitespace nil
981 "Remove leading whitespace in headers.
982 Valid values are nil, t, `head', `last', an integer or a predicate.
983 See Info node `(gnus)Customizing Articles' for details."
984 :group 'gnus-article-treat
985 :link '(custom-manual "(gnus)Customizing Articles")
986 :type gnus-article-treat-custom)
988 (defcustom gnus-treat-hide-headers 'head
990 Valid values are nil, t, `head', `last', an integer or a predicate.
991 See Info node `(gnus)Customizing Articles' for details."
992 :group 'gnus-article-treat
993 :link '(custom-manual "(gnus)Customizing Articles")
994 :type gnus-article-treat-head-custom)
996 (defcustom gnus-treat-hide-boring-headers nil
997 "Hide boring headers.
998 Valid values are nil, t, `head', `last', an integer or a predicate.
999 See Info node `(gnus)Customizing Articles' for details."
1000 :group 'gnus-article-treat
1001 :link '(custom-manual "(gnus)Customizing Articles")
1002 :type gnus-article-treat-head-custom)
1004 (defcustom gnus-treat-hide-signature nil
1005 "Hide the signature.
1006 Valid values are nil, t, `head', `last', an integer or a predicate.
1007 See Info node `(gnus)Customizing Articles' for details."
1008 :group 'gnus-article-treat
1009 :link '(custom-manual "(gnus)Customizing Articles")
1010 :type gnus-article-treat-custom)
1012 (defcustom gnus-treat-fill-article nil
1014 Valid values are nil, t, `head', `last', an integer or a predicate.
1015 See Info node `(gnus)Customizing Articles' for details."
1016 :group 'gnus-article-treat
1017 :link '(custom-manual "(gnus)Customizing Articles")
1018 :type gnus-article-treat-custom)
1020 (defcustom gnus-treat-hide-citation nil
1022 Valid values are nil, t, `head', `last', an integer or a predicate.
1023 See Info node `(gnus)Customizing Articles' for details."
1024 :group 'gnus-article-treat
1025 :link '(custom-manual "(gnus)Customizing Articles")
1026 :type gnus-article-treat-custom)
1028 (defcustom gnus-treat-hide-citation-maybe nil
1030 Valid values are nil, t, `head', `last', an integer or a predicate.
1031 See Info node `(gnus)Customizing Articles' for details."
1032 :group 'gnus-article-treat
1033 :link '(custom-manual "(gnus)Customizing Articles")
1034 :type gnus-article-treat-custom)
1036 (defcustom gnus-treat-strip-list-identifiers 'head
1037 "Strip list identifiers from `gnus-list-identifiers`.
1038 Valid values are nil, t, `head', `last', an integer or a predicate.
1039 See Info node `(gnus)Customizing Articles' for details."
1041 :group 'gnus-article-treat
1042 :link '(custom-manual "(gnus)Customizing Articles")
1043 :type gnus-article-treat-custom)
1045 (make-obsolete-variable 'gnus-treat-strip-pgp
1046 "This option is obsolete in Gnus 5.10.")
1048 (defcustom gnus-treat-strip-pem nil
1049 "Strip PEM signatures.
1050 Valid values are nil, t, `head', `last', an integer or a predicate.
1051 See Info node `(gnus)Customizing Articles' for details."
1052 :group 'gnus-article-treat
1053 :link '(custom-manual "(gnus)Customizing Articles")
1054 :type gnus-article-treat-custom)
1056 (defcustom gnus-treat-strip-banner t
1057 "Strip banners from articles.
1058 The banner to be stripped is specified in the `banner' group parameter.
1059 Valid values are nil, t, `head', `last', an integer or a predicate.
1060 See Info node `(gnus)Customizing Articles' for details."
1061 :group 'gnus-article-treat
1062 :link '(custom-manual "(gnus)Customizing Articles")
1063 :type gnus-article-treat-custom)
1065 (defcustom gnus-treat-highlight-headers 'head
1066 "Highlight the headers.
1067 Valid values are nil, t, `head', `last', an integer or a predicate.
1068 See Info node `(gnus)Customizing Articles' for details."
1069 :group 'gnus-article-treat
1070 :link '(custom-manual "(gnus)Customizing Articles")
1071 :type gnus-article-treat-head-custom)
1072 (put 'gnus-treat-highlight-headers 'highlight t)
1074 (defcustom gnus-treat-highlight-citation t
1075 "Highlight cited text.
1076 Valid values are nil, t, `head', `last', an integer or a predicate.
1077 See Info node `(gnus)Customizing Articles' for details."
1078 :group 'gnus-article-treat
1079 :link '(custom-manual "(gnus)Customizing Articles")
1080 :type gnus-article-treat-custom)
1081 (put 'gnus-treat-highlight-citation 'highlight t)
1083 (defcustom gnus-treat-date-ut nil
1084 "Display the Date in UT (GMT).
1085 Valid values are nil, t, `head', `last', an integer or a predicate.
1086 See Info node `(gnus)Customizing Articles' for details."
1087 :group 'gnus-article-treat
1088 :link '(custom-manual "(gnus)Customizing Articles")
1089 :type gnus-article-treat-head-custom)
1091 (defcustom gnus-treat-date-local nil
1092 "Display the Date in the local timezone.
1093 Valid values are nil, t, `head', `last', an integer or a predicate.
1094 See Info node `(gnus)Customizing Articles' for details."
1095 :group 'gnus-article-treat
1096 :link '(custom-manual "(gnus)Customizing Articles")
1097 :type gnus-article-treat-head-custom)
1099 (defcustom gnus-treat-date-english nil
1100 "Display the Date in a format that can be read aloud in English.
1101 Valid values are nil, t, `head', `last', an integer or a predicate.
1102 See Info node `(gnus)Customizing Articles' for details."
1103 :group 'gnus-article-treat
1104 :link '(custom-manual "(gnus)Customizing Articles")
1105 :type gnus-article-treat-head-custom)
1107 (defcustom gnus-treat-date-lapsed nil
1108 "Display the Date header in a way that says how much time has elapsed.
1109 Valid values are nil, t, `head', `last', an integer or a predicate.
1110 See Info node `(gnus)Customizing Articles' for details."
1111 :group 'gnus-article-treat
1112 :link '(custom-manual "(gnus)Customizing Articles")
1113 :type gnus-article-treat-head-custom)
1115 (defcustom gnus-treat-date-original nil
1116 "Display the date in the original timezone.
1117 Valid values are nil, t, `head', `last', an integer or a predicate.
1118 See Info node `(gnus)Customizing Articles' for details."
1119 :group 'gnus-article-treat
1120 :link '(custom-manual "(gnus)Customizing Articles")
1121 :type gnus-article-treat-head-custom)
1123 (defcustom gnus-treat-date-iso8601 nil
1124 "Display the date in the ISO8601 format.
1125 Valid values are nil, t, `head', `last', an integer or a predicate.
1126 See Info node `(gnus)Customizing Articles' for details."
1128 :group 'gnus-article-treat
1129 :link '(custom-manual "(gnus)Customizing Articles")
1130 :type gnus-article-treat-head-custom)
1132 (defcustom gnus-treat-date-user-defined nil
1133 "Display the date in a user-defined format.
1134 The format is defined by the `gnus-article-time-format' variable.
1135 Valid values are nil, t, `head', `last', an integer or a predicate.
1136 See Info node `(gnus)Customizing Articles' for details."
1137 :group 'gnus-article-treat
1138 :link '(custom-manual "(gnus)Customizing Articles")
1139 :type gnus-article-treat-head-custom)
1141 (defcustom gnus-treat-strip-headers-in-body t
1142 "Strip the X-No-Archive header line from the beginning of the body.
1143 Valid values are nil, t, `head', `last', an integer or a predicate.
1144 See Info node `(gnus)Customizing Articles' for details."
1146 :group 'gnus-article-treat
1147 :link '(custom-manual "(gnus)Customizing Articles")
1148 :type gnus-article-treat-custom)
1150 (defcustom gnus-treat-strip-trailing-blank-lines nil
1151 "Strip trailing blank lines.
1152 Valid values are nil, t, `head', `last', an integer or a predicate.
1153 See Info node `(gnus)Customizing Articles' for details."
1154 :group 'gnus-article-treat
1155 :link '(custom-manual "(gnus)Customizing Articles")
1156 :type gnus-article-treat-custom)
1158 (defcustom gnus-treat-strip-leading-blank-lines nil
1159 "Strip leading blank lines.
1160 Valid values are nil, t, `head', `last', an integer or a predicate.
1161 See Info node `(gnus)Customizing Articles' for details."
1162 :group 'gnus-article-treat
1163 :link '(custom-manual "(gnus)Customizing Articles")
1164 :type gnus-article-treat-custom)
1166 (defcustom gnus-treat-strip-multiple-blank-lines nil
1167 "Strip multiple blank lines.
1168 Valid values are nil, t, `head', `last', an integer or a predicate.
1169 See Info node `(gnus)Customizing Articles' for details."
1170 :group 'gnus-article-treat
1171 :link '(custom-manual "(gnus)Customizing Articles")
1172 :type gnus-article-treat-custom)
1174 (defcustom gnus-treat-unfold-headers 'head
1175 "Unfold folded header lines.
1176 Valid values are nil, t, `head', `last', an integer or a predicate.
1177 See Info node `(gnus)Customizing Articles' for details."
1178 :group 'gnus-article-treat
1179 :link '(custom-manual "(gnus)Customizing Articles")
1180 :type gnus-article-treat-custom)
1182 (defcustom gnus-treat-fold-headers nil
1184 Valid values are nil, t, `head', `last', an integer or a predicate.
1185 See Info node `(gnus)Customizing Articles' for details."
1186 :group 'gnus-article-treat
1187 :link '(custom-manual "(gnus)Customizing Articles")
1188 :type gnus-article-treat-custom)
1190 (defcustom gnus-treat-fold-newsgroups 'head
1191 "Fold the Newsgroups and Followup-To headers.
1192 Valid values are nil, t, `head', `last', an integer or a predicate.
1193 See Info node `(gnus)Customizing Articles' for details."
1194 :group 'gnus-article-treat
1195 :link '(custom-manual "(gnus)Customizing Articles")
1196 :type gnus-article-treat-custom)
1198 (defcustom gnus-treat-overstrike t
1199 "Treat overstrike highlighting.
1200 Valid values are nil, t, `head', `last', an integer or a predicate.
1201 See Info node `(gnus)Customizing Articles' for details."
1202 :group 'gnus-article-treat
1203 :link '(custom-manual "(gnus)Customizing Articles")
1204 :type gnus-article-treat-custom)
1205 (put 'gnus-treat-overstrike 'highlight t)
1207 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1208 "Treat ANSI SGR control sequences.
1209 Valid values are nil, t, `head', `last', an integer or a predicate.
1210 See Info node `(gnus)Customizing Articles' for details."
1211 :group 'gnus-article-treat
1212 :link '(custom-manual "(gnus)Customizing Articles")
1213 :type gnus-article-treat-custom)
1215 (make-obsolete-variable 'gnus-treat-display-xface
1216 'gnus-treat-display-x-face)
1218 (defcustom gnus-treat-display-x-face
1219 (and (not noninteractive)
1220 (or (memq gnus-article-x-face-command
1221 '(x-face-decode-message-header
1222 x-face-mule-gnus-article-display-x-face))
1223 (and (fboundp 'image-type-available-p)
1224 (image-type-available-p 'xbm)
1225 (string-match "^0x" (shell-command-to-string "uncompface"))
1226 (executable-find "icontopbm"))
1227 (and (featurep 'xemacs)
1230 "Display X-Face headers.
1231 Valid values are nil, t, `head', `last', an integer or a predicate.
1232 See Info node `(gnus)Customizing Articles' and Info node
1233 `(gnus)X-Face' for details."
1234 :group 'gnus-article-treat
1236 :link '(custom-manual "(gnus)Customizing Articles")
1237 :link '(custom-manual "(gnus)X-Face")
1238 :type gnus-article-treat-head-custom
1239 :set (lambda (symbol value)
1242 (cond ((or (boundp symbol) (get symbol 'saved-value))
1244 ((boundp 'gnus-treat-display-xface)
1246 ** gnus-treat-display-xface is an obsolete variable;\
1247 use gnus-treat-display-x-face instead")
1248 (default-value 'gnus-treat-display-xface))
1249 ((get 'gnus-treat-display-xface 'saved-value)
1251 ** gnus-treat-display-xface is an obsolete variable;\
1252 use gnus-treat-display-x-face instead")
1253 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1256 (put 'gnus-treat-display-x-face 'highlight t)
1258 (defcustom gnus-article-should-use-smiley-mule
1259 (not (or (featurep 'xemacs)
1260 (gnus-image-type-available-p 'xpm)
1261 (gnus-image-type-available-p 'pbm)))
1262 "Non-nil means use `smiley-mule' to show smileys rather than `smiley'.
1263 `smiley-mule' is boundled in BITMAP-MULE package. You can set it to t
1264 even if your Emacs supports images. It has no effect on XEmacs."
1265 :group 'gnus-article-various
1267 :get (lambda (symbol)
1268 (and (not noninteractive)
1269 (default-value symbol)
1270 (not (featurep 'xemacs))
1271 (module-installed-p 'smiley-mule)
1273 :set (lambda (symbol value)
1274 (set-default symbol (and (not noninteractive)
1276 (not (featurep 'xemacs))
1277 (module-installed-p 'smiley-mule)
1280 (defvar gnus-article-smiley-mule-loaded-p nil
1281 "Internal variable used to say whether `smiley-mule' is loaded (whether
1282 smiley functions are not overridden by `smiley').")
1284 (defcustom gnus-treat-display-face
1285 (and (not noninteractive)
1286 ;; x-face-e21 handles both X-Face and Face headers.
1287 (not (and (eq gnus-article-x-face-command 'x-face-decode-message-header)
1288 (module-installed-p 'x-face-e21)))
1289 (or (and (fboundp 'image-type-available-p)
1290 (image-type-available-p 'png))
1291 (and (featurep 'xemacs)
1294 "Display Face headers.
1295 Valid values are nil, t, `head', `last', an integer or a predicate.
1296 See Info node `(gnus)Customizing Articles' and Info node
1297 `(gnus)X-Face' for details."
1298 :group 'gnus-article-treat
1300 :link '(custom-manual "(gnus)Customizing Articles")
1301 :link '(custom-manual "(gnus)X-Face")
1302 :type gnus-article-treat-head-custom)
1303 (put 'gnus-treat-display-face 'highlight t)
1305 (defcustom gnus-treat-display-smileys
1306 (if (and (not noninteractive)
1307 (or (and (featurep 'xemacs)
1309 (gnus-image-type-available-p 'xpm)
1310 (gnus-image-type-available-p 'pbm)
1311 (and (not (featurep 'xemacs))
1313 (module-installed-p 'smiley-mule))))
1317 Valid values are nil, t, `head', `last', an integer or a predicate.
1318 See Info node `(gnus)Customizing Articles' and Info node
1319 `(gnus)Smileys' for details."
1320 :group 'gnus-article-treat
1322 :link '(custom-manual "(gnus)Customizing Articles")
1323 :link '(custom-manual "(gnus)Smileys")
1324 :type gnus-article-treat-custom)
1325 (put 'gnus-treat-display-smileys 'highlight t)
1327 (defcustom gnus-treat-from-picon
1328 (if (and (gnus-image-type-available-p 'xpm)
1329 (gnus-picons-installed-p))
1331 "Display picons in the From header.
1332 Valid values are nil, t, `head', `last', an integer or a predicate.
1333 See Info node `(gnus)Customizing Articles' and Info node
1334 `(gnus)Picons' for details."
1335 :group 'gnus-article-treat
1337 :link '(custom-manual "(gnus)Customizing Articles")
1338 :link '(custom-manual "(gnus)Picons")
1339 :type gnus-article-treat-head-custom)
1340 (put 'gnus-treat-from-picon 'highlight t)
1342 (defcustom gnus-treat-mail-picon
1343 (if (and (gnus-image-type-available-p 'xpm)
1344 (gnus-picons-installed-p))
1346 "Display picons in To and Cc headers.
1347 Valid values are nil, t, `head', `last', an integer or a predicate.
1348 See Info node `(gnus)Customizing Articles' and Info node
1349 `(gnus)Picons' for details."
1350 :group 'gnus-article-treat
1352 :link '(custom-manual "(gnus)Customizing Articles")
1353 :link '(custom-manual "(gnus)Picons")
1354 :type gnus-article-treat-head-custom)
1355 (put 'gnus-treat-mail-picon 'highlight t)
1357 (defcustom gnus-treat-newsgroups-picon
1358 (if (and (gnus-image-type-available-p 'xpm)
1359 (gnus-picons-installed-p))
1361 "Display picons in the Newsgroups and Followup-To headers.
1362 Valid values are nil, t, `head', `last', an integer or a predicate.
1363 See Info node `(gnus)Customizing Articles' and Info node
1364 `(gnus)Picons' for details."
1365 :group 'gnus-article-treat
1367 :link '(custom-manual "(gnus)Customizing Articles")
1368 :link '(custom-manual "(gnus)Picons")
1369 :type gnus-article-treat-head-custom)
1370 (put 'gnus-treat-newsgroups-picon 'highlight t)
1372 (defcustom gnus-treat-body-boundary
1373 (if (or gnus-treat-newsgroups-picon
1374 gnus-treat-mail-picon
1375 gnus-treat-from-picon)
1377 "Draw a boundary at the end of the headers.
1378 Valid values are nil and `head'.
1379 See Info node `(gnus)Customizing Articles' for details."
1381 :group 'gnus-article-treat
1382 :link '(custom-manual "(gnus)Customizing Articles")
1383 :type gnus-article-treat-head-custom)
1385 (defcustom gnus-treat-capitalize-sentences nil
1386 "Capitalize sentence-starting words.
1387 Valid values are nil, t, `head', `last', an integer or a predicate.
1388 See Info node `(gnus)Customizing Articles' for details."
1390 :group 'gnus-article-treat
1391 :link '(custom-manual "(gnus)Customizing Articles")
1392 :type gnus-article-treat-custom)
1394 (defcustom gnus-treat-wash-html nil
1396 Valid values are nil, t, `head', `last', an integer or a predicate.
1397 See Info node `(gnus)Customizing Articles' for details."
1398 :group 'gnus-article-treat
1399 :link '(custom-manual "(gnus)Customizing Articles")
1400 :type gnus-article-treat-custom)
1402 (defcustom gnus-treat-fill-long-lines nil
1404 Valid values are nil, t, `head', `last', an integer or a predicate.
1405 See Info node `(gnus)Customizing Articles' for details."
1406 :group 'gnus-article-treat
1407 :link '(custom-manual "(gnus)Customizing Articles")
1408 :type gnus-article-treat-custom)
1410 (defcustom gnus-treat-play-sounds nil
1412 Valid values are nil, t, `head', `last', an integer or a predicate.
1413 See Info node `(gnus)Customizing Articles' for details."
1415 :group 'gnus-article-treat
1416 :link '(custom-manual "(gnus)Customizing Articles")
1417 :type gnus-article-treat-custom)
1419 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
1420 "Decode an article as `default-mime-charset'. For instance, if you want to
1421 attempt to decode an article even if the value of `gnus-show-mime' is nil,
1422 you could set this variable to something like: nil for don't decode, t for
1423 decode the body, '(or header t) for the whole article, etc."
1424 :group 'gnus-article-treat
1425 :type '(radio (const :tag "Off" nil)
1426 (const :tag "Decode body" t)
1427 (const :tag "Decode all" (or head t))))
1429 (defcustom gnus-treat-translate nil
1430 "Translate articles from one language to another.
1431 Valid values are nil, t, `head', `last', an integer or a predicate.
1432 See Info node `(gnus)Customizing Articles' for details."
1434 :group 'gnus-article-treat
1435 :link '(custom-manual "(gnus)Customizing Articles")
1436 :type gnus-article-treat-custom)
1438 (defcustom gnus-treat-x-pgp-sig nil
1440 To automatically treat X-PGP-Sig, set it to head.
1441 Valid values are nil, t, `head', `last', an integer or a predicate.
1442 See Info node `(gnus)Customizing Articles' for details."
1443 :group 'gnus-article-treat
1444 :group 'mime-security
1445 :type gnus-article-treat-custom)
1447 (defcustom gnus-treat-monafy nil
1448 "Display body part with mona font.
1449 Valid values are nil, t, `head', `last', an integer or a predicate.
1450 See Info node `(gnus)Customizing Articles' for details."
1451 :group 'gnus-article-treat
1452 :group 'mime-security
1453 :link '(custom-manual "(gnus)Customizing Articles")
1454 :type gnus-article-treat-custom)
1456 (defvar gnus-article-encrypt-protocol-alist
1457 '(("PGP" . mml2015-self-encrypt)))
1459 ;; Set to nil if more than one protocol added to
1460 ;; gnus-article-encrypt-protocol-alist.
1461 (defcustom gnus-article-encrypt-protocol "PGP"
1462 "The protocol used for encrypt articles.
1463 It is a string, such as \"PGP\". If nil, ask user."
1465 :group 'mime-security)
1467 (defvar gnus-article-wash-function nil
1468 "Function used for converting HTML into text.")
1470 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1471 (mm-coding-system-p 'utf-8)
1472 (executable-find idna-program))
1473 "Whether IDNA decoding of headers is used when viewing messages.
1474 This requires GNU Libidn, and by default only enabled if it is found."
1475 :group 'gnus-article-headers
1478 (defcustom gnus-article-over-scroll nil
1479 "If non-nil, allow scrolling the article buffer even when there no more text."
1480 :group 'gnus-article
1483 ;;; Internal variables
1485 (defvar gnus-english-month-names
1486 '("January" "February" "March" "April" "May" "June" "July" "August"
1487 "September" "October" "November" "December"))
1489 (defvar gnus-button-regexp nil)
1490 (defvar gnus-button-marker-list nil)
1491 ;; Regexp matching any of the regexps from `gnus-button-alist'.
1493 (defvar gnus-button-last nil)
1494 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
1496 (defvar article-goto-body-goes-to-point-min-p nil)
1497 (defvar gnus-article-wash-types nil)
1498 (defvar gnus-article-emphasis-alist nil)
1499 (defvar gnus-article-image-alist nil)
1501 (defvar gnus-article-mime-handle-alist-1 nil)
1502 (defvar gnus-treatment-function-alist
1503 '((gnus-treat-decode-article-as-default-mime-charset
1504 gnus-article-decode-article-as-default-mime-charset)
1505 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1506 (gnus-treat-monafy gnus-article-monafy)
1507 (gnus-treat-strip-banner gnus-article-strip-banner)
1508 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1509 (gnus-treat-buttonize gnus-article-add-buttons)
1510 (gnus-treat-fill-article gnus-article-fill-cited-article)
1511 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1512 (gnus-treat-strip-cr gnus-article-remove-cr)
1513 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1514 (gnus-treat-date-ut gnus-article-date-ut)
1515 (gnus-treat-date-local gnus-article-date-local)
1516 (gnus-treat-date-english gnus-article-date-english)
1517 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1518 (gnus-treat-date-original gnus-article-date-original)
1519 (gnus-treat-date-user-defined gnus-article-date-user)
1520 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1521 (gnus-treat-display-face gnus-article-display-face)
1522 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1523 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1524 (gnus-treat-hide-signature gnus-article-hide-signature)
1525 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1526 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1527 (gnus-treat-strip-pem gnus-article-hide-pem)
1528 (gnus-treat-from-picon gnus-treat-from-picon)
1529 (gnus-treat-mail-picon gnus-treat-mail-picon)
1530 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1531 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1532 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1533 (gnus-treat-strip-trailing-blank-lines
1534 gnus-article-remove-trailing-blank-lines)
1535 (gnus-treat-strip-leading-blank-lines
1536 gnus-article-strip-leading-blank-lines)
1537 (gnus-treat-strip-multiple-blank-lines
1538 gnus-article-strip-multiple-blank-lines)
1539 (gnus-treat-overstrike gnus-article-treat-overstrike)
1540 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1541 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1542 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1543 ;; Displaying X-Face should be done after unfolding headers
1544 ;; to protect bitmap lines.
1545 (gnus-treat-display-x-face gnus-article-display-x-face)
1546 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1547 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1548 (gnus-treat-display-smileys gnus-treat-smiley)
1549 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1550 (gnus-treat-wash-html gnus-article-wash-html)
1551 (gnus-treat-emphasize gnus-article-emphasize)
1552 (gnus-treat-hide-citation gnus-article-hide-citation)
1553 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1554 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1555 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1556 (gnus-treat-play-sounds gnus-earcon-display)))
1558 (defvar gnus-article-mime-handle-alist nil)
1559 (defvar article-lapsed-timer nil)
1560 (defvar gnus-article-current-summary nil)
1562 (defvar gnus-article-mode-syntax-table
1563 (let ((table (copy-syntax-table text-mode-syntax-table)))
1564 ;; This causes the citation match run O(2^n).
1565 ;; (modify-syntax-entry ?- "w" table)
1566 (modify-syntax-entry ?> ")<" table)
1567 (modify-syntax-entry ?< "(>" table)
1568 ;; make M-. in article buffers work for `foo' strings
1569 (modify-syntax-entry ?' " " table)
1570 (modify-syntax-entry ?` " " table)
1572 "Syntax table used in article mode buffers.
1573 Initialized from `text-mode-syntax-table.")
1575 (defvar gnus-save-article-buffer nil)
1577 (defvar gnus-article-mode-line-format-alist
1578 (nconc '((?w (gnus-article-wash-status) ?s)
1579 (?m (gnus-article-mime-part-status) ?s))
1580 gnus-summary-mode-line-format-alist))
1582 (defvar gnus-number-of-articles-to-be-saved nil)
1584 (defvar gnus-inhibit-hiding nil)
1586 (defvar gnus-article-edit-mode nil)
1588 ;;; Macros for dealing with the article buffer.
1590 (defmacro gnus-with-article-headers (&rest forms)
1592 (set-buffer gnus-article-buffer)
1594 (let ((buffer-read-only nil)
1595 (inhibit-point-motion-hooks t)
1596 (case-fold-search t))
1597 (article-narrow-to-head)
1600 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1601 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1603 (defmacro gnus-with-article-buffer (&rest forms)
1605 (set-buffer gnus-article-buffer)
1606 (let ((buffer-read-only nil))
1609 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1610 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1612 (defun gnus-article-goto-header (header)
1613 "Go to HEADER, which is a regular expression."
1614 (re-search-forward (concat "^\\(" header "\\):") nil t))
1616 (defsubst gnus-article-hide-text (b e props)
1617 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1618 (gnus-add-text-properties-when 'article-type nil b e props)
1619 (when (memq 'intangible props)
1621 (max (1- b) (point-min))
1622 b 'intangible (cddr (memq 'intangible props)))))
1624 (defsubst gnus-article-unhide-text (b e)
1625 "Remove hidden text properties from region between B and E."
1626 (remove-text-properties b e gnus-hidden-properties)
1627 (when (memq 'intangible gnus-hidden-properties)
1628 (put-text-property (max (1- b) (point-min))
1629 b 'intangible nil)))
1631 (defun gnus-article-hide-text-type (b e type)
1632 "Hide text of TYPE between B and E."
1633 (gnus-add-wash-type type)
1634 (gnus-article-hide-text
1635 b e (cons 'article-type (cons type gnus-hidden-properties))))
1637 (defun gnus-article-unhide-text-type (b e type)
1638 "Unhide text of TYPE between B and E."
1639 (gnus-delete-wash-type type)
1640 (remove-text-properties
1641 b e (cons 'article-type (cons type gnus-hidden-properties)))
1642 (when (memq 'intangible gnus-hidden-properties)
1643 (put-text-property (max (1- b) (point-min))
1644 b 'intangible nil)))
1646 (defun gnus-article-hide-text-of-type (type)
1647 "Hide text of TYPE in the current buffer."
1649 (let ((b (point-min))
1651 (while (setq b (text-property-any b e 'article-type type))
1652 (add-text-properties b (incf b) gnus-hidden-properties)))))
1654 (defun gnus-article-delete-text-of-type (type)
1655 "Delete text of TYPE in the current buffer."
1657 (let ((b (point-min)))
1658 (while (setq b (text-property-any b (point-max) 'article-type type))
1660 b (or (text-property-not-all b (point-max) 'article-type type)
1663 (defun gnus-article-delete-invisible-text ()
1664 "Delete all invisible text in the current buffer."
1666 (let ((b (point-min)))
1667 (while (setq b (text-property-any b (point-max) 'invisible t))
1669 b (or (text-property-not-all b (point-max) 'invisible t)
1672 (defun gnus-article-text-type-exists-p (type)
1673 "Say whether any text of type TYPE exists in the buffer."
1674 (text-property-any (point-min) (point-max) 'article-type type))
1676 (defsubst gnus-article-header-rank ()
1677 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1678 (let ((list gnus-sorted-header-list)
1681 (if (looking-at (car list))
1683 (setq list (cdr list))
1687 (defun article-hide-headers (&optional arg delete)
1688 "Hide unwanted headers and possibly sort them as well."
1689 (interactive (gnus-article-hidden-arg))
1690 ;; Lars said that this function might be inhibited.
1691 (if (gnus-article-check-hidden-text 'headers arg)
1693 ;; Show boring headers as well.
1694 (gnus-article-show-hidden-text 'boring-headers)
1695 (when (eq 1 (point-min))
1696 (set-window-start (get-buffer-window (current-buffer)) 1)))
1697 (unless gnus-inhibit-hiding
1700 (let ((inhibit-read-only t)
1701 (case-fold-search t)
1702 (max (1+ (length gnus-sorted-header-list)))
1703 (ignored (when (not gnus-visible-headers)
1704 (cond ((stringp gnus-ignored-headers)
1705 gnus-ignored-headers)
1706 ((listp gnus-ignored-headers)
1707 (mapconcat 'identity gnus-ignored-headers
1710 (cond ((stringp gnus-visible-headers)
1711 gnus-visible-headers)
1712 ((and gnus-visible-headers
1713 (listp gnus-visible-headers))
1714 (mapconcat 'identity gnus-visible-headers "\\|"))))
1715 (inhibit-point-motion-hooks t)
1717 ;; First we narrow to just the headers.
1718 (article-narrow-to-head)
1719 ;; Hide any "From " lines at the beginning of (mail) articles.
1720 (while (looking-at "From ")
1724 (delete-region (point-min) (point))
1725 (gnus-article-hide-text (point-min) (point)
1726 (nconc (list 'article-type 'headers)
1727 gnus-hidden-properties))))
1728 ;; Then treat the rest of the header lines.
1729 ;; Then we use the two regular expressions
1730 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1731 ;; select which header lines is to remain visible in the
1733 (while (re-search-forward "^[^ \t:]*:" nil t)
1735 ;; Mark the rank of the header.
1737 (point) (1+ (point)) 'message-rank
1738 (if (or (and visible (looking-at visible))
1740 (not (looking-at ignored))))
1741 (gnus-article-header-rank)
1744 (message-sort-headers-1)
1745 (when (setq beg (text-property-any
1746 (point-min) (point-max) 'message-rank (+ 2 max)))
1747 ;; We delete or make invisible the unwanted headers.
1748 (gnus-add-wash-type 'headers)
1751 (add-text-properties
1752 (point-min) (+ 5 (point-min))
1753 '(article-type headers dummy-invisible t))
1754 (delete-region beg (point-max)))
1755 (gnus-article-hide-text-type beg (point-max) 'headers)))))))))
1757 (defun article-hide-boring-headers (&optional arg)
1758 "Toggle hiding of headers that aren't very interesting.
1759 If given a negative prefix, always show; if given a positive prefix,
1761 (interactive (gnus-article-hidden-arg))
1762 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1763 (not gnus-show-all-headers))
1766 (let ((buffer-read-only nil)
1767 (list gnus-boring-article-headers)
1768 (inhibit-point-motion-hooks t)
1770 (article-narrow-to-head)
1772 (setq elem (pop list))
1773 (goto-char (point-min))
1775 ;; Hide empty headers.
1777 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1779 (gnus-article-hide-text-type
1783 (if (re-search-forward "^[^ \t]" nil t)
1787 ;; Hide boring Newsgroups header.
1788 ((eq elem 'newsgroups)
1789 (when (gnus-string-equal
1790 (gnus-fetch-field "newsgroups")
1791 (gnus-group-real-name
1792 (if (boundp 'gnus-newsgroup-name)
1795 (gnus-article-hide-header "newsgroups")))
1796 ((eq elem 'to-address)
1797 (let ((to (message-fetch-field "to"))
1799 (gnus-parameter-to-address
1800 (if (boundp 'gnus-newsgroup-name)
1801 gnus-newsgroup-name ""))))
1802 (when (and to to-address
1805 ;; only one address in To
1806 (nth 1 (mail-extract-address-components to))
1808 (gnus-article-hide-header "to"))))
1810 (let ((to (message-fetch-field "to"))
1812 (gnus-parameter-to-list
1813 (if (boundp 'gnus-newsgroup-name)
1814 gnus-newsgroup-name ""))))
1815 (when (and to to-list
1818 ;; only one address in To
1819 (nth 1 (mail-extract-address-components to))
1821 (gnus-article-hide-header "to"))))
1823 (let ((cc (message-fetch-field "cc"))
1825 (gnus-parameter-to-list
1826 (if (boundp 'gnus-newsgroup-name)
1827 gnus-newsgroup-name ""))))
1828 (when (and cc to-list
1831 ;; only one address in CC
1832 (nth 1 (mail-extract-address-components cc))
1834 (gnus-article-hide-header "cc"))))
1835 ((eq elem 'followup-to)
1836 (when (gnus-string-equal
1837 (message-fetch-field "followup-to")
1838 (message-fetch-field "newsgroups"))
1839 (gnus-article-hide-header "followup-to")))
1840 ((eq elem 'reply-to)
1841 (if (gnus-group-find-parameter
1842 gnus-newsgroup-name 'broken-reply-to)
1843 (gnus-article-hide-header "reply-to")
1844 (let ((from (message-fetch-field "from"))
1845 (reply-to (message-fetch-field "reply-to")))
1852 (lambda (x) (downcase (cadr x)))
1853 (mail-extract-address-components from t))
1856 (lambda (x) (downcase (cadr x)))
1857 (mail-extract-address-components reply-to t))
1859 (gnus-article-hide-header "reply-to")))))
1861 (let ((date (message-fetch-field "date")))
1863 (< (days-between (current-time-string) date)
1865 (gnus-article-hide-header "date"))))
1867 (let ((to (message-fetch-field "to"))
1868 (cc (message-fetch-field "cc")))
1869 (when (> (length to) 1024)
1870 (gnus-article-hide-header "to"))
1871 (when (> (length cc) 1024)
1872 (gnus-article-hide-header "cc"))))
1876 (goto-char (point-min))
1877 (while (re-search-forward "^to:" nil t)
1878 (setq to-count (1+ to-count)))
1879 (when (> to-count 1)
1880 (while (> to-count 0)
1881 (goto-char (point-min))
1883 (re-search-forward "^to:" nil nil to-count)
1885 (narrow-to-region (point) (point-max))
1886 (gnus-article-hide-header "to"))
1887 (setq to-count (1- to-count))))
1888 (goto-char (point-min))
1889 (while (re-search-forward "^cc:" nil t)
1890 (setq cc-count (1+ cc-count)))
1891 (when (> cc-count 1)
1892 (while (> cc-count 0)
1893 (goto-char (point-min))
1895 (re-search-forward "^cc:" nil nil cc-count)
1897 (narrow-to-region (point) (point-max))
1898 (gnus-article-hide-header "cc"))
1899 (setq cc-count (1- cc-count)))))))))))))
1901 (defun gnus-article-hide-header (header)
1903 (goto-char (point-min))
1904 (when (re-search-forward (concat "^" header ":") nil t)
1905 (gnus-article-hide-text-type
1909 (if (re-search-forward "^[^ \t]" nil t)
1914 (defvar gnus-article-normalized-header-length 40
1915 "Length of normalized headers.")
1917 (defun article-normalize-headers ()
1918 "Make all header lines 40 characters long."
1920 (let ((buffer-read-only nil)
1924 (article-narrow-to-head)
1927 ((< (setq column (- (point-at-eol) (point)))
1928 gnus-article-normalized-header-length)
1930 (insert (make-string
1931 (- gnus-article-normalized-header-length column)
1933 ((> column gnus-article-normalized-header-length)
1934 (gnus-put-text-property
1936 (forward-char gnus-article-normalized-header-length)
1943 (forward-line 1))))))
1945 (defun article-treat-dumbquotes ()
1946 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
1947 Note that this function guesses whether a character is a sm*rtq**t* or
1948 not, so it should only be used interactively.
1950 Sm*rtq**t*s are M****s***'s unilateral extension to the
1951 iso-8859-1 character map in an attempt to provide more quoting
1952 characters. If you see something like \\222 or \\264 where
1953 you're expecting some kind of apostrophe or quotation mark, then
1956 (article-translate-strings gnus-article-dumbquotes-map))
1958 (defun article-translate-characters (from to)
1959 "Translate all characters in the body of the article according to FROM and TO.
1960 FROM is a string of characters to translate from; to is a string of
1961 characters to translate to."
1963 (when (article-goto-body)
1964 (let ((buffer-read-only nil)
1965 (x (make-string 225 ?x))
1967 (while (< (incf i) (length x))
1970 (while (< i (length from))
1971 (aset x (aref from i) (aref to i))
1973 (translate-region (point) (point-max) x)))))
1975 (defun article-translate-strings (map)
1976 "Translate all string in the body of the article according to MAP.
1977 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1979 (when (article-goto-body)
1980 (let ((buffer-read-only nil)
1982 (while (setq elem (pop map))
1984 (while (search-forward (car elem) nil t)
1985 (replace-match (cadr elem)))))))))
1987 (defun article-treat-overstrike ()
1988 "Translate overstrikes into bold text."
1991 (when (article-goto-body)
1992 (let ((buffer-read-only nil))
1993 (while (search-forward "\b" nil t)
1994 (let ((next (char-after))
1998 previous (char-after))
2002 ;; We do the boldification/underlining by hiding the
2003 ;; overstrikes and putting the proper text property
2007 (gnus-article-hide-text-type start (point) 'overstrike)
2008 (put-text-property (point) end 'face 'bold))
2010 (gnus-article-hide-text-type
2011 (1- (point)) (1+ (point)) 'overstrike)
2013 start (1- (point)) 'face 'underline))
2015 (gnus-article-hide-text-type start (point) 'overstrike)
2017 (point) end 'face 'underline)))))))))
2019 (defun article-treat-ansi-sequences ()
2020 "Translate ANSI SGR control sequences into overlays or extents."
2023 (when (article-goto-body)
2024 (let ((buffer-read-only nil))
2025 (ansi-color-apply-on-region (point) (point-max))))))
2027 (defun gnus-article-treat-unfold-headers ()
2028 "Unfold folded message headers.
2029 Only the headers that fit into the current window width will be
2032 (gnus-with-article-headers
2036 (mail-header-narrow-to-field)
2037 (let ((header (buffer-string)))
2040 (goto-char (point-min))
2041 (while (re-search-forward "\n[\t ]" nil t)
2042 (replace-match " " t t)))
2043 (setq length (- (point-max) (point-min) 1)))
2044 (when (< length (window-width))
2045 (while (re-search-forward "\n[\t ]" nil t)
2046 (replace-match " " t t)))
2047 (goto-char (point-max)))))))
2049 (defun gnus-article-treat-fold-headers ()
2050 "Fold message headers."
2052 (gnus-with-article-headers
2055 (mail-header-narrow-to-field)
2056 (mail-header-fold-field)
2057 (goto-char (point-max))))))
2059 (defun gnus-treat-smiley ()
2060 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2062 (unless (featurep 'xemacs)
2063 (when (and (not gnus-article-should-use-smiley-mule)
2064 gnus-article-smiley-mule-loaded-p)
2065 (load "smiley" nil t)
2066 (setq gnus-article-smiley-mule-loaded-p nil))
2067 (when (and gnus-article-should-use-smiley-mule
2068 (not gnus-article-smiley-mule-loaded-p))
2069 (load "smiley-mule" nil t)
2070 (setq gnus-article-smiley-mule-loaded-p t)))
2071 (gnus-with-article-buffer
2072 (if (memq 'smiley gnus-article-wash-types)
2073 (gnus-delete-images 'smiley)
2075 (let ((images (smiley-region (point) (point-max))))
2077 (gnus-add-wash-type 'smiley)
2078 (dolist (image images)
2079 (gnus-add-image 'smiley image)))))))
2081 (defun gnus-article-remove-images ()
2082 "Remove all images from the article buffer."
2084 (gnus-with-article-buffer
2085 (dolist (elem gnus-article-image-alist)
2086 (gnus-delete-images (car elem)))))
2088 (defun gnus-article-treat-fold-newsgroups ()
2089 "Unfold folded message headers.
2090 Only the headers that fit into the current window width will be
2093 (gnus-with-article-headers
2094 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2096 (mail-header-narrow-to-field)
2097 (while (re-search-forward ", *" nil t)
2098 (replace-match ", " t t))
2099 (mail-header-fold-field)
2100 (goto-char (point-max))))))
2102 (defun gnus-article-treat-body-boundary ()
2103 "Place a boundary line at the end of the headers."
2105 (when (and gnus-body-boundary-delimiter
2106 (> (length gnus-body-boundary-delimiter) 0))
2107 (gnus-with-article-headers
2108 (goto-char (point-max))
2109 (let ((start (point)))
2110 (insert "X-Boundary: ")
2111 (gnus-add-text-properties start (point) '(invisible t intangible t))
2113 (while (>= (1- (window-width)) (length str))
2114 (setq str (concat str gnus-body-boundary-delimiter)))
2115 (substring str 0 (1- (window-width))))
2117 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2119 (defun article-fill-long-lines ()
2120 "Fill lines that are wider than the window width."
2123 (let ((buffer-read-only nil)
2124 (width (window-width (get-buffer-window (current-buffer)))))
2127 (let ((adaptive-fill-mode nil)) ;Why? -sm
2130 (when (>= (current-column) (min fill-column width))
2131 (narrow-to-region (min (1+ (point)) (point-max))
2133 (let ((goback (point-marker)))
2134 (fill-paragraph nil)
2135 (goto-char (marker-position goback)))
2137 (forward-line 1)))))))
2139 (defun article-capitalize-sentences ()
2140 "Capitalize the first word in each sentence."
2143 (let ((buffer-read-only nil)
2144 (paragraph-start "^[\n\^L]"))
2148 (forward-sentence)))))
2150 (defun article-remove-cr ()
2151 "Remove trailing CRs and then translate remaining CRs into LFs."
2154 (let ((buffer-read-only nil))
2155 (goto-char (point-min))
2156 (while (re-search-forward "\r+$" nil t)
2157 (replace-match "" t t))
2158 (goto-char (point-min))
2159 (while (search-forward "\r" nil t)
2160 (replace-match "\n" t t)))))
2162 (defun article-remove-trailing-blank-lines ()
2163 "Remove all trailing blank lines from the article."
2166 (let ((buffer-read-only nil))
2167 (goto-char (point-max))
2171 (while (and (not (bobp))
2172 (looking-at "^[ \t]*$")
2173 (not (gnus-annotation-in-region-p
2174 (point) (point-at-eol))))
2180 (defvar gnus-face-properties-alist))
2182 (defun article-display-face ()
2183 "Display any Face headers in the header."
2185 (let ((wash-face-p buffer-read-only))
2186 (gnus-with-article-headers
2187 ;; When displaying parts, this function can be called several times on
2188 ;; the same article, without any intended toggle semantic (as typing `W
2189 ;; D d' would have). So face deletion must occur only when we come from
2190 ;; an interactive command, that is when the *Article* buffer is
2192 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2193 (gnus-delete-images 'face)
2196 (when (and wash-face-p
2198 (goto-char (point-min))
2199 (not (re-search-forward "^Face:[\t ]*" nil t)))
2200 (gnus-buffer-live-p gnus-original-article-buffer))
2201 (set-buffer gnus-original-article-buffer))
2203 (mail-narrow-to-head)
2204 (while (gnus-article-goto-header "Face")
2205 (push (mail-header-field-value) faces))))
2206 (while (setq face (pop faces))
2207 (let ((png (gnus-convert-face-to-png face))
2211 (apply 'gnus-create-image png 'png t
2212 (cdr (assq 'png gnus-face-properties-alist))))
2213 (gnus-article-goto-header "from")
2215 (insert "From: [no `from' set]\n")
2217 (gnus-add-wash-type 'face)
2218 (gnus-add-image 'face image)
2219 (gnus-put-image image nil 'face))))))
2222 (defun article-display-x-face (&optional force)
2223 "Look for an X-Face header and display it if present."
2224 (interactive (list 'force))
2225 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2226 (gnus-with-article-headers
2227 ;; Delete the old process, if any.
2228 (when (process-status "article-x-face")
2229 (delete-process "article-x-face"))
2230 ;; See the comment in `article-display-face'.
2231 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2232 ;; We have already displayed X-Faces, so we remove them
2234 (gnus-delete-images 'xface)
2236 (let (x-faces from face)
2238 (when (and wash-face-p
2240 (goto-char (point-min))
2241 (not (re-search-forward
2242 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2243 (gnus-buffer-live-p gnus-original-article-buffer))
2244 ;; If type `W f', use gnus-original-article-buffer,
2245 ;; otherwise use the current buffer because displaying
2246 ;; RFC822 parts calls this function too.
2247 (set-buffer gnus-original-article-buffer))
2249 (mail-narrow-to-head)
2250 (while (gnus-article-goto-header "X-Face")
2251 (push (mail-header-field-value) x-faces))
2252 (setq from (message-fetch-field "from"))))
2253 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2254 ;; single external face.
2255 (when (stringp gnus-article-x-face-command)
2256 (setq x-faces (list (car x-faces))))
2257 (while (and (setq face (pop x-faces))
2258 gnus-article-x-face-command
2260 ;; Check whether this face is censored.
2261 (not gnus-article-x-face-too-ugly)
2262 (and gnus-article-x-face-too-ugly from
2263 (not (string-match gnus-article-x-face-too-ugly
2265 ;; We display the face.
2266 (cond ((stringp gnus-article-x-face-command)
2267 ;; The command is a string, so we interpret the command
2268 ;; as a, well, command, and fork it off.
2269 (let ((process-connection-type nil))
2270 (process-kill-without-query
2272 "article-x-face" nil shell-file-name
2273 shell-command-switch gnus-article-x-face-command))
2276 (process-send-region "article-x-face"
2277 (point-min) (point-max)))
2278 (process-send-eof "article-x-face")))
2279 ((functionp gnus-article-x-face-command)
2280 ;; The command is a lisp function, so we call it.
2281 (funcall gnus-article-x-face-command face))
2283 (error "%s is not a function"
2284 gnus-article-x-face-command)))))))))
2286 (defun article-decode-mime-words ()
2287 "Decode all MIME-encoded words in the article."
2289 (gnus-with-article-buffer
2290 (let ((inhibit-point-motion-hooks t)
2291 (mail-parse-charset gnus-newsgroup-charset)
2292 (mail-parse-ignored-charsets
2293 (with-current-buffer gnus-summary-buffer
2294 gnus-newsgroup-ignored-charsets)))
2295 (mail-decode-encoded-word-region (point-min) (point-max)))))
2297 (defun article-decode-charset (&optional prompt)
2298 "Decode charset-encoded text in the article.
2299 If PROMPT (the prefix), prompt for a coding system to use."
2301 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2303 (mail-parse-charset gnus-newsgroup-charset)
2304 (mail-parse-ignored-charsets
2305 (save-excursion (condition-case nil
2306 (set-buffer gnus-summary-buffer)
2308 gnus-newsgroup-ignored-charsets))
2309 ct cte ctl charset format)
2312 (article-narrow-to-head)
2313 (setq ct (message-fetch-field "Content-Type" t)
2314 cte (message-fetch-field "Content-Transfer-Encoding" t)
2315 ctl (and ct (ignore-errors
2316 (mail-header-parse-content-type ct)))
2319 (mm-read-coding-system "Charset to decode: "))
2321 (mail-content-type-get ctl 'charset)))
2322 format (and ctl (mail-content-type-get ctl 'format)))
2324 (setq cte (mail-header-strip cte)))
2325 (if (and ctl (not (string-match "/" (car ctl))))
2327 (goto-char (point-max)))
2330 (narrow-to-region (point) (point-max))
2331 (when (and (eq mail-parse-charset 'gnus-decoded)
2332 (eq (mm-body-7-or-8) '8bit))
2333 ;; The text code could have been decoded.
2334 (setq charset mail-parse-charset))
2335 (when (and (or (not ctl)
2336 (equal (car ctl) "text/plain"))
2337 (not format)) ;; article with format will decode later.
2339 charset (and cte (intern (downcase
2340 (gnus-strip-whitespace cte))))
2343 (defun article-decode-encoded-words ()
2344 "Remove encoded-word encoding from headers."
2345 (let (buffer-read-only)
2346 (let ((charset (save-excursion
2347 (set-buffer gnus-summary-buffer)
2348 default-mime-charset)))
2349 (mime-decode-header-in-buffer charset))))
2351 (defun article-decode-group-name ()
2352 "Decode group names in `Newsgroups:'."
2353 (let ((inhibit-point-motion-hooks t)
2355 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2356 (when (and (or gnus-group-name-charset-method-alist
2357 gnus-group-name-charset-group-alist)
2358 (gnus-buffer-live-p gnus-original-article-buffer))
2360 (article-narrow-to-head)
2361 (with-current-buffer gnus-original-article-buffer
2362 (goto-char (point-min)))
2363 (while (re-search-forward
2364 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2365 (replace-match (save-match-data
2366 (gnus-decode-newsgroups
2367 ;; XXX how to use data in article buffer?
2368 (with-current-buffer gnus-original-article-buffer
2370 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2373 gnus-newsgroup-name method))
2375 (goto-char (point-min))
2376 (with-current-buffer gnus-original-article-buffer
2377 (goto-char (point-min)))
2378 (while (re-search-forward
2379 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2380 (replace-match (save-match-data
2381 (gnus-decode-newsgroups
2382 ;; XXX how to use data in article buffer?
2383 (with-current-buffer gnus-original-article-buffer
2385 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2388 gnus-newsgroup-name method))
2391 (autoload 'idna-to-unicode "idna")
2393 (defun article-decode-idna-rhs ()
2394 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2397 (let ((inhibit-point-motion-hooks t)
2399 (article-narrow-to-head)
2400 (goto-char (point-min))
2401 (while (re-search-forward "\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2403 (when (save-match-data
2404 (and (setq ace (match-string 1))
2406 (and (re-search-backward "^[^ \t]" nil t)
2407 (looking-at "From\\|To\\|Cc")))
2408 (save-excursion (backward-char)
2409 (message-idna-inside-rhs-p))
2410 (setq unicode (idna-to-unicode ace))))
2411 (unless (string= ace unicode)
2412 (replace-match unicode nil nil nil 1)))))))))
2414 (defun article-de-quoted-unreadable (&optional force read-charset)
2415 "Translate a quoted-printable-encoded article.
2416 If FORCE, decode the article whether it is marked as quoted-printable
2418 If READ-CHARSET, ask for a coding system."
2419 (interactive (list 'force current-prefix-arg))
2421 (let ((buffer-read-only nil) type charset)
2422 (if (gnus-buffer-live-p gnus-original-article-buffer)
2423 (with-current-buffer gnus-original-article-buffer
2425 (gnus-fetch-field "content-transfer-encoding"))
2426 (let* ((ct (gnus-fetch-field "content-type"))
2429 (mail-header-parse-content-type ct)))))
2430 (setq charset (and ctl
2431 (mail-content-type-get ctl 'charset)))
2432 (if (stringp charset)
2433 (setq charset (intern (downcase charset)))))))
2435 (setq charset (mm-read-coding-system "Charset: " charset)))
2437 (setq charset gnus-newsgroup-charset))
2439 (and type (let ((case-fold-search t))
2440 (string-match "quoted-printable" type))))
2442 (quoted-printable-decode-region
2443 (point) (point-max) (mm-charset-to-coding-system charset))))))
2445 (defun article-de-base64-unreadable (&optional force read-charset)
2446 "Translate a base64 article.
2447 If FORCE, decode the article whether it is marked as base64 not.
2448 If READ-CHARSET, ask for a coding system."
2449 (interactive (list 'force current-prefix-arg))
2451 (let ((buffer-read-only nil) type charset)
2452 (if (gnus-buffer-live-p gnus-original-article-buffer)
2453 (with-current-buffer gnus-original-article-buffer
2455 (gnus-fetch-field "content-transfer-encoding"))
2456 (let* ((ct (gnus-fetch-field "content-type"))
2459 (mail-header-parse-content-type ct)))))
2460 (setq charset (and ctl
2461 (mail-content-type-get ctl 'charset)))
2462 (if (stringp charset)
2463 (setq charset (intern (downcase charset)))))))
2465 (setq charset (mm-read-coding-system "Charset: " charset)))
2467 (setq charset gnus-newsgroup-charset))
2469 (and type (let ((case-fold-search t))
2470 (string-match "base64" type))))
2473 (narrow-to-region (point) (point-max))
2474 (base64-decode-region (point-min) (point-max))
2475 (mm-decode-coding-region
2476 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2481 (defun article-decode-HZ ()
2482 "Translate a HZ-encoded article."
2486 (let ((buffer-read-only nil))
2487 (rfc1843-decode-region (point-min) (point-max)))))
2489 (defun article-unsplit-urls ()
2490 "Remove the newlines that some other mailers insert into URLs."
2493 (let ((buffer-read-only nil))
2494 (goto-char (point-min))
2495 (while (re-search-forward
2496 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2497 (replace-match "\\1\\3" t)))
2498 (when (interactive-p)
2499 (gnus-treat-article nil))))
2502 (defun article-wash-html (&optional read-charset)
2503 "Format an HTML article.
2504 If READ-CHARSET, ask for a coding system."
2507 (let ((buffer-read-only nil)
2509 (when (gnus-buffer-live-p gnus-original-article-buffer)
2510 (with-current-buffer gnus-original-article-buffer
2511 (let* ((ct (gnus-fetch-field "content-type"))
2514 (mail-header-parse-content-type ct)))))
2515 (setq charset (and ctl
2516 (mail-content-type-get ctl 'charset)))
2517 (when (stringp charset)
2518 (setq charset (intern (downcase charset)))))))
2520 (setq charset (mm-read-coding-system "Charset: " charset)))
2522 (setq charset gnus-newsgroup-charset))
2524 (save-window-excursion
2526 (narrow-to-region (point) (point-max))
2527 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2528 (entry (assq func mm-text-html-washer-alist)))
2530 (setq func (cdr entry)))
2535 (apply (car func) (cdr func))))))))))
2537 (defun gnus-article-wash-html-with-w3 ()
2538 "Wash the current buffer with w3."
2540 (let ((w3-strict-width (window-width))
2541 (url-standalone-mode t)
2542 (url-gateway-unplugged t)
2543 (w3-honor-stylesheets nil))
2545 (w3-region (point-min) (point-max))
2548 (defun gnus-article-wash-html-with-w3m ()
2549 "Wash the current buffer with emacs-w3m."
2552 (narrow-to-region (point) (point-max))
2553 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2554 w3m-force-redisplay)
2555 (w3m-region (point-min) (point-max)))
2556 (when (and mm-inline-text-html-with-w3m-keymap
2557 (boundp 'w3m-minor-mode-map)
2559 (add-text-properties
2560 (point-min) (point-max)
2561 (list 'keymap w3m-minor-mode-map
2562 ;; Put the mark meaning this part was rendered by emacs-w3m.
2563 'mm-inline-text-html-with-w3m t)))))
2565 (defun article-hide-list-identifiers ()
2566 "Remove list identifies from the Subject header.
2567 The `gnus-list-identifiers' variable specifies what to do."
2569 (let ((inhibit-point-motion-hooks t)
2570 (regexp (if (consp gnus-list-identifiers)
2571 (mapconcat 'identity gnus-list-identifiers " *\\|")
2572 gnus-list-identifiers))
2577 (article-narrow-to-head)
2578 (goto-char (point-min))
2579 (while (re-search-forward
2580 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2582 (delete-region (match-beginning 2) (match-end 0))
2583 (beginning-of-line))
2584 (when (re-search-forward
2585 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2586 (delete-region (match-beginning 1) (match-end 1))))))))
2588 (defun article-hide-pem (&optional arg)
2589 "Toggle hiding of any PEM headers and signatures in the current article.
2590 If given a negative prefix, always show; if given a positive prefix,
2592 (interactive (gnus-article-hidden-arg))
2593 (unless (gnus-article-check-hidden-text 'pem arg)
2595 (let (buffer-read-only end)
2596 (goto-char (point-min))
2597 ;; Hide the horrendously ugly "header".
2598 (when (and (search-forward
2599 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2601 (setq end (1+ (match-beginning 0))))
2602 (gnus-add-wash-type 'pem)
2603 (gnus-article-hide-text-type
2605 (if (search-forward "\n\n" nil t)
2609 ;; Hide the trailer as well
2610 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2612 (gnus-article-hide-text-type
2613 (match-beginning 0) (match-end 0) 'pem)))))))
2615 (defun article-strip-banner ()
2616 "Strip the banners specified by the `banner' group parameter and by
2617 `gnus-article-address-banner-alist'."
2621 (let ((inhibit-point-motion-hooks t))
2622 (when (gnus-parameter-banner gnus-newsgroup-name)
2623 (article-really-strip-banner
2624 (gnus-parameter-banner gnus-newsgroup-name)))
2625 (when gnus-article-address-banner-alist
2626 (article-really-strip-banner
2627 (let ((from (save-restriction
2629 (article-narrow-to-head)
2630 (mail-fetch-field "from"))))
2633 (caar (mail-header-parse-addresses from))))
2635 (dolist (pair gnus-article-address-banner-alist)
2636 (when (string-match (car pair) from)
2637 (throw 'found (cdr pair)))))))))))))
2639 (defun article-really-strip-banner (banner)
2640 "Strip the banner specified by the argument."
2643 (let ((inhibit-point-motion-hooks t)
2644 (gnus-signature-limit nil)
2648 ((eq banner 'signature)
2649 (when (gnus-article-narrow-to-signature)
2652 (delete-region (point) (point-max))))
2654 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2655 (while (re-search-forward banner nil t)
2656 (delete-region (match-beginning 0) (match-end 0)))))
2658 (while (re-search-forward banner nil t)
2659 (delete-region (match-beginning 0) (match-end 0)))))))))
2661 (defun article-babel ()
2662 "Translate article using an online translation service."
2665 (gnus-with-article-buffer
2666 (when (article-goto-body)
2667 (let* ((start (point))
2669 (orig (buffer-substring start end))
2670 (trans (babel-as-string orig)))
2672 (narrow-to-region start end)
2673 (delete-region start end)
2676 (defun article-hide-signature (&optional arg)
2677 "Hide the signature in the current article.
2678 If given a negative prefix, always show; if given a positive prefix,
2680 (interactive (gnus-article-hidden-arg))
2686 (article-goto-body))
2687 (goto-char (point-min)))
2688 (unless (gnus-article-check-hidden-text 'signature arg)
2689 (let ((buffer-read-only nil)
2691 (while (setq button (text-property-any button (point-max)
2693 'gnus-signature-toggle))
2694 (setq button (text-property-not-all button (point-max)
2696 'gnus-signature-toggle))
2697 (when (and button (not (eobp)))
2698 (gnus-article-hide-text-type
2700 (next-single-property-change (1+ button) 'mime-view-entity
2703 (gnus-set-mode-line 'article))
2705 (defun article-strip-headers-in-body ()
2706 "Strip offensive headers from bodies."
2710 (let ((case-fold-search t))
2711 (when (looking-at "x-no-archive:")
2712 (gnus-delete-line)))))
2714 (defun article-strip-leading-blank-lines ()
2715 "Remove all blank lines from the beginning of the article."
2718 (let ((inhibit-point-motion-hooks t)
2720 (when (article-goto-body)
2721 (while (and (not (eobp))
2722 (looking-at "[ \t]*$"))
2723 (gnus-delete-line))))))
2725 (defun article-narrow-to-head ()
2726 "Narrow the buffer to the head of the message.
2727 Point is left at the beginning of the narrowed-to region."
2729 (goto-char (point-min))
2730 (if (search-forward "\n\n" nil 1)
2733 (goto-char (point-min)))
2735 (defun article-goto-body ()
2736 "Place point at the start of the body."
2737 (goto-char (point-min))
2739 ;; This variable is only bound when dealing with separate
2741 (article-goto-body-goes-to-point-min-p
2743 ((search-forward "\n\n" nil t)
2746 (goto-char (point-max))
2749 (defun article-strip-multiple-blank-lines ()
2750 "Replace consecutive blank lines with one empty line."
2753 (let ((inhibit-point-motion-hooks t)
2755 ;; First make all blank lines empty.
2757 (while (re-search-forward "^[ \t]+$" nil t)
2758 (unless (gnus-annotation-in-region-p
2759 (match-beginning 0) (match-end 0))
2760 (replace-match "" nil t)))
2761 ;; Then replace multiple empty lines with a single empty line.
2763 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2764 (unless (gnus-annotation-in-region-p
2765 (match-beginning 0) (match-end 0))
2766 (delete-region (match-beginning 1) (match-end 1)))))))
2768 (defun article-strip-leading-space ()
2769 "Remove all white space from the beginning of the lines in the article."
2772 (let ((inhibit-point-motion-hooks t)
2775 (while (re-search-forward "^[ \t]+" nil t)
2776 (replace-match "" t t)))))
2778 (defun article-strip-trailing-space ()
2779 "Remove all white space from the end of the lines in the article."
2782 (let ((inhibit-point-motion-hooks t)
2785 (while (re-search-forward "[ \t]+$" nil t)
2786 (replace-match "" t t)))))
2788 (defun article-strip-blank-lines ()
2789 "Strip leading, trailing and multiple blank lines."
2791 (article-strip-leading-blank-lines)
2792 (article-remove-trailing-blank-lines)
2793 (article-strip-multiple-blank-lines))
2795 (defun article-strip-all-blank-lines ()
2796 "Strip all blank lines."
2799 (let ((inhibit-point-motion-hooks t)
2802 (while (re-search-forward "^[ \t]*\n" nil t)
2803 (replace-match "" t t)))))
2805 (defun gnus-article-narrow-to-signature ()
2806 "Narrow to the signature; return t if a signature is found, else nil."
2807 (let ((inhibit-point-motion-hooks t))
2808 (when (gnus-article-search-signature)
2810 ;; Check whether we have some limits to what we consider
2811 ;; to be a signature.
2812 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2813 (list gnus-signature-limit)))
2815 (while (setq limit (pop limits))
2816 (if (or (and (integerp limit)
2817 (< (- (point-max) (point)) limit))
2819 (< (count-lines (point) (point-max)) limit))
2820 (and (functionp limit)
2822 (and (stringp limit)
2823 (not (re-search-forward limit nil t))))
2824 () ; This limit did not succeed.
2828 (narrow-to-region (point) (point-max))
2831 (defun gnus-article-search-signature ()
2832 "Search the current buffer for the signature separator.
2833 Put point at the beginning of the signature separator."
2834 (let ((cur (point)))
2835 (goto-char (point-max))
2836 (if (if (stringp gnus-signature-separator)
2837 (re-search-backward gnus-signature-separator nil t)
2838 (let ((seps gnus-signature-separator))
2840 (not (re-search-backward (car seps) nil t)))
2847 (defun gnus-article-hidden-arg ()
2848 "Return the current prefix arg as a number, or 0 if no prefix."
2849 (list (if current-prefix-arg
2850 (prefix-numeric-value current-prefix-arg)
2853 (defun gnus-article-check-hidden-text (type arg)
2854 "Return nil if hiding is necessary.
2855 Arg can be nil or a number. nil and positive means hide, negative
2856 means show, 0 means toggle."
2859 (let ((hide (gnus-article-hidden-text-p type)))
2865 (gnus-article-show-hidden-text type)
2868 (if (eq hide 'hidden)
2870 (gnus-article-show-hidden-text type)
2874 (defun gnus-article-hidden-text-p (type)
2875 "Say whether the current buffer contains hidden text of type TYPE."
2876 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2878 (not (get-text-property pos 'invisible))
2879 (not (get-text-property pos 'dummy-invisible)))
2881 (text-property-any (1+ pos) (point-max) 'article-type type)))
2886 (defun gnus-article-show-hidden-text (type &optional dummy)
2887 "Show all hidden text of type TYPE.
2888 Originally it is hide instead of DUMMY."
2889 (let ((buffer-read-only nil)
2890 (inhibit-point-motion-hooks t))
2891 (gnus-remove-text-properties-when
2893 (point-min) (point-max)
2894 (cons 'article-type (cons type
2895 gnus-hidden-properties)))
2896 (gnus-delete-wash-type type)))
2898 (defconst article-time-units
2899 `((year . ,(* 365.25 24 60 60))
2900 (week . ,(* 7 24 60 60))
2901 (day . ,(* 24 60 60))
2905 "Mapping from time units to seconds.")
2907 (defun gnus-article-forward-header ()
2908 "Move point to the start of the next header.
2909 If the current header is a continuation header, this can be several
2914 (if (looking-at "[ \t]+[^ \t]")
2918 (defun article-date-ut (&optional type highlight header)
2919 "Convert DATE date to universal time in the current article.
2920 If TYPE is `local', convert to local time; if it is `lapsed', output
2921 how much time has lapsed since DATE. For `lapsed', the value of
2922 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2923 should replace the \"Date:\" one, or should be added below it."
2924 (interactive (list 'ut t))
2925 (let* ((header (or header
2926 (and (eq 1 (point-min))
2927 (mail-header-date (save-excursion
2928 (set-buffer gnus-summary-buffer)
2929 gnus-current-headers)))
2930 (message-fetch-field "date")
2932 (date (if (vectorp header) (mail-header-date header)
2934 (inhibit-point-motion-hooks t)
2935 bface eface date-pos)
2936 (when (and date (not (string= date "")))
2939 (article-narrow-to-head)
2940 (when (or (and (eq type 'lapsed)
2941 gnus-article-date-lapsed-new-header
2942 ;; Attempt to get the face of X-Sent first.
2943 (re-search-forward "^X-Sent:[ \t]" nil t))
2944 (re-search-forward "^Date:[ \t]" nil t)
2945 ;; If Date is missing, try again for X-Sent.
2946 (re-search-forward "^X-Sent:[ \t]" nil t))
2947 (setq bface (get-text-property (point-at-bol) 'face)
2948 date (or (get-text-property (point-at-bol)
2951 eface (get-text-property (1- (point-at-eol))
2953 (let ((buffer-read-only nil))
2954 ;; Delete any old X-Sent headers.
2955 (when (setq date-pos
2956 (text-property-any (point-min) (point-max)
2957 'article-date-lapsed t))
2958 (goto-char (setq date-pos (set-marker (make-marker) date-pos)))
2959 (delete-region (match-beginning 0)
2960 (progn (forward-line 1) (point))))
2961 (goto-char (point-min))
2962 ;; Delete any old Date headers.
2963 (while (re-search-forward "^Date:[ \t]" nil t)
2965 (setq date-pos (match-beginning 0)))
2966 (unless (and (eq type 'lapsed)
2967 gnus-article-date-lapsed-new-header)
2968 (delete-region (match-beginning 0)
2969 (progn (message-next-header) (point)))))
2972 (goto-char date-pos)
2974 ;; Possibly, Date has been deleted.
2976 (when (and (eq type 'lapsed)
2977 gnus-article-date-lapsed-new-header
2978 (looking-at "Date:"))
2980 (goto-char (point-min)))
2981 (insert (article-make-date-line date type))
2982 (when (eq type 'lapsed)
2983 (put-text-property (point-at-bol) (point)
2984 'article-date-lapsed t))
2988 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2989 (put-text-property (match-beginning 1) (1+ (match-end 1))
2990 'original-date date)
2991 (put-text-property (match-beginning 1) (1+ (match-end 1))
2993 (put-text-property (match-beginning 2) (match-end 2)
2996 (defun article-make-date-line (date type)
2997 "Return a DATE line of TYPE."
2998 (unless (memq type '(local ut original user iso8601 lapsed english))
2999 (error "Unknown conversion type: %s" type))
3001 (let ((time (date-to-time date)))
3003 ;; Convert to the local timezone.
3005 (let ((tz (car (current-time-zone time))))
3006 (format "Date: %s %s%02d%02d" (current-time-string time)
3007 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3008 (/ (% (abs tz) 3600) 60))))
3009 ;; Convert to Universal Time.
3012 (current-time-string
3013 (let* ((e (parse-time-string date))
3014 (tm (apply 'encode-time e))
3016 (ls (- (cadr tm) (car (current-time-zone time)))))
3017 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
3018 ((> ls 65535) (list (1+ ms) (- ls 65536)))
3021 ;; Get the original date from the article.
3022 ((eq type 'original)
3023 (concat "Date: " (if (string-match "\n+$" date)
3024 (substring date 0 (match-beginning 0))
3026 ;; Let the user define the format.
3028 (let ((format (or (condition-case nil
3029 (with-current-buffer gnus-summary-buffer
3030 gnus-article-time-format)
3032 gnus-article-time-format)))
3033 (if (functionp format)
3034 (funcall format time)
3035 (concat "Date: " (format-time-string format time)))))
3038 (let ((tz (car (current-time-zone time))))
3041 (format-time-string "%Y%m%dT%H%M%S" time)
3042 (format "%s%02d%02d"
3043 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3044 (/ (% (abs tz) 3600) 60)))))
3045 ;; Do an X-Sent lapsed format.
3047 ;; If the date is seriously mangled, the timezone functions are
3048 ;; liable to bug out, so we ignore all errors.
3049 (let* ((now (current-time))
3050 (real-time (subtract-time now time))
3051 (real-sec (and real-time
3052 (+ (* (float (car real-time)) 65536)
3054 (sec (and real-time (abs real-sec)))
3064 ;; This is a bit convoluted, but basically we go
3065 ;; through the time units for years, weeks, etc,
3066 ;; and divide things to see whether that results
3067 ;; in positive answers.
3070 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3071 ;; The (remaining) seconds are too few to
3072 ;; be divided into this time unit.
3074 ;; It's big enough, so we output it.
3075 (setq sec (- sec (* num (cdr unit))))
3077 (concat (if prev ", " "") (int-to-string
3079 " " (symbol-name (car unit))
3080 (if (> num 1) "s" ""))
3082 article-time-units "")
3083 ;; If dates are odd, then it might appear like the
3084 ;; article was sent in the future.
3087 " in the future"))))))
3088 ;; Display the date in proper English
3090 (let ((dtime (decode-time time)))
3093 (number-to-string (nth 3 dtime))
3094 (let ((digit (% (nth 3 dtime) 10)))
3096 ((memq (nth 3 dtime) '(11 12 13)) "th")
3102 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3104 (number-to-string (nth 5 dtime))
3106 (format "%02d" (nth 2 dtime))
3108 (format "%02d" (nth 1 dtime)))))))
3110 (format "Date: %s (from T-gnus)" date))))
3112 (defun article-date-local (&optional highlight)
3113 "Convert the current article date to the local timezone."
3114 (interactive (list t))
3115 (article-date-ut 'local highlight))
3117 (defun article-date-english (&optional highlight)
3118 "Convert the current article date to something that is proper English."
3119 (interactive (list t))
3120 (article-date-ut 'english highlight))
3122 (defun article-date-original (&optional highlight)
3123 "Convert the current article date to what it was originally.
3124 This is only useful if you have used some other date conversion
3125 function and want to see what the date was before converting."
3126 (interactive (list t))
3127 (article-date-ut 'original highlight))
3129 (defun article-date-lapsed (&optional highlight)
3130 "Convert the current article date to time lapsed since it was sent."
3131 (interactive (list t))
3132 (article-date-ut 'lapsed highlight))
3134 (defun article-update-date-lapsed ()
3135 "Function to be run from a timer to update the lapsed time line."
3136 (let (deactivate-mark)
3141 (set-buffer (window-buffer w))
3142 (when (eq major-mode 'gnus-article-mode)
3143 (let ((mark (point-marker)))
3144 (goto-char (point-min))
3145 (when (re-search-forward "^X-Sent:" nil t)
3146 (article-date-lapsed t))
3147 (goto-char (marker-position mark))
3148 (move-marker mark nil))))
3151 (defun gnus-start-date-timer (&optional n)
3152 "Start a timer to update the X-Sent header in the article buffers.
3153 The numerical prefix says how frequently (in seconds) the function
3158 (gnus-stop-date-timer)
3159 (setq article-lapsed-timer
3160 (run-at-time 1 n 'article-update-date-lapsed)))
3162 (defun gnus-stop-date-timer ()
3163 "Stop the X-Sent timer."
3165 (when article-lapsed-timer
3166 (nnheader-cancel-timer article-lapsed-timer)
3167 (setq article-lapsed-timer nil)))
3169 (defun article-date-user (&optional highlight)
3170 "Convert the current article date to the user-defined format.
3171 This format is defined by the `gnus-article-time-format' variable."
3172 (interactive (list t))
3173 (article-date-ut 'user highlight))
3175 (defun article-date-iso8601 (&optional highlight)
3176 "Convert the current article date to ISO8601."
3177 (interactive (list t))
3178 (article-date-ut 'iso8601 highlight))
3180 ;; (defun article-show-all ()
3181 ;; "Show all hidden text in the article buffer."
3185 ;; (let ((buffer-read-only nil))
3186 ;; (gnus-article-unhide-text (point-min) (point-max))
3187 ;; (gnus-remove-text-with-property 'gnus-prev)
3188 ;; (gnus-remove-text-with-property 'gnus-next))))
3190 (defun article-show-all-headers ()
3191 "Show all hidden headers in the article buffer."
3196 (article-narrow-to-head)
3197 (let ((buffer-read-only nil))
3198 (gnus-article-unhide-text (point-min) (point-max))))))
3200 (defun article-remove-leading-whitespace ()
3201 "Remove excessive whitespace from all headers."
3205 (let ((buffer-read-only nil))
3206 (article-narrow-to-head)
3207 (goto-char (point-min))
3208 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3209 (delete-region (match-beginning 1) (match-end 1)))))))
3211 (defun article-emphasize (&optional arg)
3212 "Emphasize text according to `gnus-emphasis-alist'."
3213 (interactive (gnus-article-hidden-arg))
3214 (unless (gnus-article-check-hidden-text 'emphasis arg)
3218 (with-current-buffer gnus-summary-buffer
3219 gnus-article-emphasis-alist)
3221 gnus-emphasis-alist))
3222 (buffer-read-only nil)
3223 (props (append '(article-type emphasis)
3224 gnus-hidden-properties))
3225 regexp elem beg invisible visible face)
3228 (while (setq elem (pop alist))
3230 (setq regexp (car elem)
3231 invisible (nth 1 elem)
3232 visible (nth 2 elem)
3234 (while (re-search-forward regexp nil t)
3235 (when (and (match-beginning visible) (match-beginning invisible))
3236 (gnus-article-hide-text
3237 (match-beginning invisible) (match-end invisible) props)
3238 (gnus-article-unhide-text-type
3239 (match-beginning visible) (match-end visible) 'emphasis)
3240 (gnus-put-overlay-excluding-newlines
3241 (match-beginning visible) (match-end visible) 'face face)
3242 (gnus-add-wash-type 'emphasis)
3243 (goto-char (match-end invisible)))))))))
3245 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3246 "Setup newsgroup emphasis alist."
3247 (unless gnus-article-emphasis-alist
3248 (let ((name (and gnus-newsgroup-name
3249 (gnus-group-real-name gnus-newsgroup-name))))
3250 (make-local-variable 'gnus-article-emphasis-alist)
3251 (setq gnus-article-emphasis-alist
3253 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3254 (while (setq elem (pop alist))
3255 (when (and name (string-match (car elem) name))
3257 highlight (copy-sequence (cdr elem)))))
3259 (copy-sequence highlight-words)
3260 (if gnus-newsgroup-name
3261 (copy-sequence (gnus-group-find-parameter
3262 gnus-newsgroup-name 'highlight-words t)))
3263 gnus-emphasis-alist)))))
3266 (defvar gnus-summary-article-menu)
3267 (defvar gnus-summary-post-menu))
3269 ;;; Saving functions.
3271 (defun gnus-article-save (save-buffer file &optional num)
3272 "Save the currently selected article."
3273 (unless gnus-save-all-headers
3274 ;; Remove headers according to `gnus-saved-headers'.
3275 (let ((gnus-visible-headers
3276 (or gnus-saved-headers gnus-visible-headers))
3277 (gnus-article-buffer save-buffer))
3279 (set-buffer save-buffer)
3280 (article-hide-headers 1 t))))
3281 (save-window-excursion
3282 (if (not gnus-default-article-saver)
3283 (error "No default saver is defined")
3284 ;; !!! Magic! The saving functions all save
3285 ;; `gnus-save-article-buffer' (or so they think), but we
3286 ;; bind that variable to our save-buffer.
3287 (set-buffer gnus-article-buffer)
3288 (let* ((gnus-save-article-buffer save-buffer)
3291 ((not gnus-prompt-before-saving) 'default)
3292 ((eq gnus-prompt-before-saving 'always) nil)
3294 (gnus-number-of-articles-to-be-saved
3295 (when (eq gnus-prompt-before-saving t)
3297 (set-buffer gnus-article-current-summary)
3298 (funcall gnus-default-article-saver filename)))))
3300 (defun gnus-read-save-file-name (prompt &optional filename
3301 function group headers variable)
3303 (funcall function group headers (symbol-value variable)))
3308 ((eq filename 'default)
3314 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3317 (if (and gnus-number-of-articles-to-be-saved
3318 (> gnus-number-of-articles-to-be-saved 1))
3319 (format "these %d articles"
3320 gnus-number-of-articles-to-be-saved)
3323 ;; Let the split methods have their say.
3325 ;; No split name was found.
3328 (concat prompt " (default "
3329 (file-name-nondirectory default-name) ") ")
3330 (file-name-directory default-name)
3332 ;; A single group name is returned.
3333 ((stringp split-name)
3335 (funcall function split-name headers
3336 (symbol-value variable)))
3338 (concat prompt " (default "
3339 (file-name-nondirectory default-name) ") ")
3340 (file-name-directory default-name)
3342 ;; A single split name was found
3343 ((= 1 (length split-name))
3344 (let* ((name (expand-file-name
3346 gnus-article-save-directory))
3347 (dir (cond ((file-directory-p name)
3348 (file-name-as-directory name))
3349 ((file-exists-p name) name)
3350 (t gnus-article-save-directory))))
3352 (concat prompt " (default " name ") ")
3354 ;; A list of splits was found.
3356 (setq split-name (nreverse split-name))
3358 (let ((file-name-history
3359 (nconc split-name file-name-history)))
3363 (concat prompt " (`M-p' for defaults) ")
3364 gnus-article-save-directory
3366 gnus-article-save-directory)))
3367 (car (push result file-name-history)))))))
3368 ;; Create the directory.
3369 (gnus-make-directory (file-name-directory file))
3370 ;; If we have read a directory, we append the default file name.
3371 (when (file-directory-p file)
3372 (setq file (expand-file-name (file-name-nondirectory
3374 (file-name-as-directory file))))
3375 ;; Possibly translate some characters.
3376 (nnheader-translate-file-chars file))))))
3377 (gnus-make-directory (file-name-directory result))
3378 (set variable result)))
3380 (defun gnus-article-archive-name (group)
3381 "Return the first instance of an \"Archive-name\" in the current buffer."
3382 (let ((case-fold-search t))
3383 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3384 (nnheader-concat gnus-article-save-directory
3385 (match-string 1)))))
3387 (defun gnus-article-nndoc-name (group)
3388 "If GROUP is an nndoc group, return the name of the parent group."
3389 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3390 (gnus-group-get-parameter group 'save-article-group)))
3392 (defun gnus-summary-save-in-rmail (&optional filename)
3393 "Append this article to Rmail file.
3394 Optional argument FILENAME specifies file name.
3395 Directory to save to is default to `gnus-article-save-directory'."
3396 (setq filename (gnus-read-save-file-name
3397 "Save %s in rmail file:" filename
3398 gnus-rmail-save-name gnus-newsgroup-name
3399 gnus-current-headers 'gnus-newsgroup-last-rmail))
3400 (gnus-eval-in-buffer-window gnus-save-article-buffer
3404 (gnus-output-to-rmail filename))))
3407 (defun gnus-summary-save-in-mail (&optional filename)
3408 "Append this article to Unix mail file.
3409 Optional argument FILENAME specifies file name.
3410 Directory to save to is default to `gnus-article-save-directory'."
3411 (setq filename (gnus-read-save-file-name
3412 "Save %s in Unix mail file:" filename
3413 gnus-mail-save-name gnus-newsgroup-name
3414 gnus-current-headers 'gnus-newsgroup-last-mail))
3415 (gnus-eval-in-buffer-window gnus-save-article-buffer
3419 (if (and (file-readable-p filename)
3420 (file-regular-p filename)
3421 (mail-file-babyl-p filename))
3422 (rmail-output-to-rmail-file filename t)
3423 (gnus-output-to-mail filename)))))
3426 (defun gnus-summary-save-in-file (&optional filename overwrite)
3427 "Append this article to file.
3428 Optional argument FILENAME specifies file name.
3429 Directory to save to is default to `gnus-article-save-directory'."
3430 (setq filename (gnus-read-save-file-name
3431 "Save %s in file:" filename
3432 gnus-file-save-name gnus-newsgroup-name
3433 gnus-current-headers 'gnus-newsgroup-last-file))
3434 (gnus-eval-in-buffer-window gnus-save-article-buffer
3438 (when (and overwrite
3439 (file-exists-p filename))
3440 (delete-file filename))
3441 (gnus-output-to-file filename))))
3444 (defun gnus-summary-write-to-file (&optional filename)
3445 "Write this article to a file, overwriting it if the file exists.
3446 Optional argument FILENAME specifies file name.
3447 The directory to save in defaults to `gnus-article-save-directory'."
3448 (gnus-summary-save-in-file nil t))
3450 (defun gnus-summary-save-body-in-file (&optional filename)
3451 "Append this article body to a file.
3452 Optional argument FILENAME specifies file name.
3453 The directory to save in defaults to `gnus-article-save-directory'."
3454 (setq filename (gnus-read-save-file-name
3455 "Save %s body in file:" filename
3456 gnus-file-save-name gnus-newsgroup-name
3457 gnus-current-headers 'gnus-newsgroup-last-file))
3458 (gnus-eval-in-buffer-window gnus-save-article-buffer
3462 (when (article-goto-body)
3463 (narrow-to-region (point) (point-max)))
3464 (gnus-output-to-file filename))))
3467 (defun gnus-summary-save-in-pipe (&optional command)
3468 "Pipe this article to subprocess."
3470 (cond ((and (eq command 'default)
3471 gnus-last-shell-command)
3472 gnus-last-shell-command)
3477 "Shell command on %s: "
3478 (if (and gnus-number-of-articles-to-be-saved
3479 (> gnus-number-of-articles-to-be-saved 1))
3480 (format "these %d articles"
3481 gnus-number-of-articles-to-be-saved)
3483 gnus-last-shell-command))))
3484 (when (string-equal command "")
3485 (if gnus-last-shell-command
3486 (setq command gnus-last-shell-command)
3487 (error "A command is required")))
3488 (gnus-eval-in-buffer-window gnus-article-buffer
3491 (shell-command-on-region (point-min) (point-max) command nil)))
3492 (setq gnus-last-shell-command command))
3494 (defun gnus-summary-pipe-to-muttprint (&optional command)
3495 "Pipe this article to muttprint."
3496 (setq command (read-string
3497 "Print using command: " gnus-summary-muttprint-program
3498 nil gnus-summary-muttprint-program))
3499 (gnus-summary-save-in-pipe command))
3501 ;;; Article file names when saving.
3503 (defun gnus-capitalize-newsgroup (newsgroup)
3504 "Capitalize NEWSGROUP name."
3505 (when (not (zerop (length newsgroup)))
3506 (concat (char-to-string (upcase (aref newsgroup 0)))
3507 (substring newsgroup 1))))
3509 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3510 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3511 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3512 Otherwise, it is like ~/News/news/group/num."
3515 (concat (if (gnus-use-long-file-name 'not-save)
3516 (gnus-capitalize-newsgroup newsgroup)
3517 (gnus-newsgroup-directory-form newsgroup))
3518 "/" (int-to-string (mail-header-number headers)))
3519 gnus-article-save-directory)))
3521 (string-equal (file-name-directory default)
3522 (file-name-directory last-file))
3523 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3525 (or last-file default))))
3527 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3528 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3529 If variable `gnus-use-long-file-name' is non-nil, it is
3530 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3533 (concat (if (gnus-use-long-file-name 'not-save)
3535 (gnus-newsgroup-directory-form newsgroup))
3536 "/" (int-to-string (mail-header-number headers)))
3537 gnus-article-save-directory)))
3539 (string-equal (file-name-directory default)
3540 (file-name-directory last-file))
3541 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3543 (or last-file default))))
3545 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3546 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3547 If variable `gnus-use-long-file-name' is non-nil, it is
3548 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3551 (if (gnus-use-long-file-name 'not-save)
3554 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3556 gnus-article-save-directory)))
3558 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3559 "Generate file name from sender."
3560 (let ((from (mail-header-from headers)))
3562 (if (and from (string-match "\\([^ <]+\\)@" from))
3563 (match-string 1 from)
3565 gnus-article-save-directory)))
3567 (defun article-verify-x-pgp-sig ()
3570 (if (gnus-buffer-live-p gnus-original-article-buffer)
3571 (let ((sig (with-current-buffer gnus-original-article-buffer
3572 (gnus-fetch-field "X-PGP-Sig")))
3576 (mml2015-clear-verify-function))
3578 (insert-buffer-substring gnus-original-article-buffer)
3579 (setq items (split-string sig))
3580 (message-narrow-to-head)
3581 (let ((inhibit-point-motion-hooks t)
3582 (case-fold-search t))
3583 ;; Don't verify multiple headers.
3584 (setq headers (mapconcat (lambda (header)
3586 (mail-fetch-field header)
3588 (split-string (nth 1 items) ",") "")))
3589 (delete-region (point-min) (point-max))
3590 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3591 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3596 (if (looking-at "^-")
3599 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3600 (insert "Version: " (car items) "\n\n")
3601 (insert (mapconcat 'identity (cddr items) "\n"))
3602 (insert "\n-----END PGP SIGNATURE-----\n")
3603 (let ((mm-security-handle (list (format "multipart/signed"))))
3604 (mml2015-clean-buffer)
3605 (let ((coding-system-for-write (or gnus-newsgroup-charset
3607 (funcall (mml2015-clear-verify-function)))
3609 (or (mm-handle-multipart-ctl-parameter
3610 mm-security-handle 'gnus-details)
3611 (mm-handle-multipart-ctl-parameter
3612 mm-security-handle 'gnus-info)))))
3614 (let (buffer-read-only bface eface)
3616 (message-narrow-to-head)
3617 (goto-char (point-max))
3619 (setq bface (get-text-property (point-at-bol) 'face)
3620 eface (get-text-property (1- (point-at-eol)) 'face))
3621 (message-remove-header "X-Gnus-PGP-Verify")
3622 (if (re-search-forward "^X-PGP-Sig:" nil t)
3624 (goto-char (point-max)))
3625 (narrow-to-region (point) (point))
3626 (insert "X-Gnus-PGP-Verify: " info "\n")
3627 (goto-char (point-min))
3630 (if (not (looking-at "^[ \t]"))
3634 (goto-char (point-min))
3635 (when (looking-at "\\([^:]+\\): *")
3636 (put-text-property (match-beginning 1) (1+ (match-end 1))
3638 (put-text-property (match-end 0) (point-max)
3639 'face eface)))))))))
3641 (defun article-verify-cancel-lock ()
3642 "Verify Cancel-Lock header."
3644 (if (gnus-buffer-live-p gnus-original-article-buffer)
3645 (canlock-verify gnus-original-article-buffer)))
3647 (defun article-monafy ()
3648 "Display body part with mona font."
3650 (unless (if (featurep 'xemacs)
3651 (find-face 'gnus-mona-face)
3652 (facep 'gnus-mona-face))
3653 (require 'navi2ch-mona)
3654 (set-face-font (make-face 'gnus-mona-face) navi2ch-mona-font))
3656 (let ((buffer-read-only nil))
3659 (gnus-make-overlay (point) (point-max))
3660 'face 'gnus-mona-face))))
3667 (setq afunc (car func)
3670 gfunc (intern (format "gnus-%s" func))))
3672 (when (fboundp afunc)
3673 `(lambda (&optional interactive &rest args)
3674 ,(documentation afunc t)
3675 (interactive (list t))
3677 (set-buffer gnus-article-buffer)
3679 (call-interactively ',afunc)
3680 (apply ',afunc args))))))))
3681 '(article-hide-headers
3682 article-verify-x-pgp-sig
3683 article-verify-cancel-lock
3685 article-hide-boring-headers
3686 article-treat-overstrike
3687 article-treat-ansi-sequences
3688 article-fill-long-lines
3689 article-capitalize-sentences
3691 article-remove-leading-whitespace
3692 article-display-x-face
3693 article-display-face
3694 article-de-quoted-unreadable
3695 article-de-base64-unreadable
3698 article-unsplit-urls
3699 article-hide-list-identifiers
3700 article-strip-banner
3703 article-hide-signature
3704 article-strip-headers-in-body
3705 article-remove-trailing-blank-lines
3706 article-strip-leading-blank-lines
3707 article-strip-multiple-blank-lines
3708 article-strip-leading-space
3709 article-strip-trailing-space
3710 article-strip-blank-lines
3711 article-strip-all-blank-lines
3713 article-date-english
3714 article-date-iso8601
3715 article-date-original
3717 article-decode-mime-words
3718 article-decode-charset
3719 article-decode-encoded-words
3723 article-treat-dumbquotes
3724 article-normalize-headers
3725 (article-show-all-headers . gnus-article-show-all-headers)
3726 ;; (article-show-all . gnus-article-show-all)
3730 ;;; Gnus article mode
3733 (put 'gnus-article-mode 'mode-class 'special)
3735 (gnus-define-keys gnus-article-mode-map
3736 " " gnus-article-goto-next-page
3737 "\177" gnus-article-goto-prev-page
3738 [delete] gnus-article-goto-prev-page
3739 [backspace] gnus-article-goto-prev-page
3740 "\C-c^" gnus-article-refer-article
3741 "h" gnus-article-show-summary
3742 "s" gnus-article-show-summary
3743 "\C-c\C-m" gnus-article-mail
3744 "?" gnus-article-describe-briefly
3745 "e" gnus-summary-edit-article
3746 "<" beginning-of-buffer
3748 "\C-c\C-i" gnus-info-find-node
3750 "R" gnus-article-reply-with-original
3751 "F" gnus-article-followup-with-original
3752 "\C-hk" gnus-article-describe-key
3753 "\C-hc" gnus-article-describe-key-briefly
3755 "\C-d" gnus-article-read-summary-keys
3756 "\M-*" gnus-article-read-summary-keys
3757 "\M-#" gnus-article-read-summary-keys
3758 "\M-^" gnus-article-read-summary-keys
3759 "\M-g" gnus-article-read-summary-keys)
3761 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3765 (push (char-to-string key) keys)
3767 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3768 (setq key (car elem))
3769 (when (and (> (length key) 0)
3770 (not (eq 'menu-bar (aref key 0)))
3771 (symbolp (lookup-key gnus-summary-mode-map key)))
3774 (unless (lookup-key gnus-article-mode-map key)
3775 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3777 (defun gnus-article-make-menu-bar ()
3778 (unless (boundp 'gnus-article-commands-menu)
3779 (gnus-summary-make-menu-bar))
3780 (gnus-turn-off-edit-menu 'article)
3781 (unless (boundp 'gnus-article-article-menu)
3783 gnus-article-article-menu gnus-article-mode-map ""
3785 ["Scroll forwards" gnus-article-goto-next-page t]
3786 ["Scroll backwards" gnus-article-goto-prev-page t]
3787 ["Show summary" gnus-article-show-summary t]
3788 ["Fetch Message-ID at point" gnus-article-refer-article t]
3789 ["Mail to address at point" gnus-article-mail t]
3790 ["Send a bug report" gnus-bug t]))
3793 gnus-article-treatment-menu gnus-article-mode-map ""
3794 ;; Fixme: this should use :active (and maybe :visible).
3796 ["Hide headers" gnus-article-hide-headers t]
3797 ["Hide signature" gnus-article-hide-signature t]
3798 ["Hide citation" gnus-article-hide-citation t]
3799 ["Treat overstrike" gnus-article-treat-overstrike t]
3800 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
3801 ["Remove carriage return" gnus-article-remove-cr t]
3802 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3803 ["Treat html" gnus-article-wash-html t]
3804 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3805 ["Decode HZ" gnus-article-decode-HZ t]))
3807 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3809 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3811 (gnus-run-hooks 'gnus-article-menu-hook)))
3813 (defun gnus-article-mode ()
3814 "Major mode for displaying an article.
3816 All normal editing commands are switched off.
3818 The following commands are available in addition to all summary mode
3820 \\<gnus-article-mode-map>
3821 \\[gnus-article-next-page]\t Scroll the article one page forwards
3822 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3823 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3824 \\[gnus-article-show-summary]\t Display the summary buffer
3825 \\[gnus-article-mail]\t Send a reply to the address near point
3826 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3827 \\[gnus-info-find-node]\t Go to the Gnus info node"
3829 (gnus-simplify-mode-line)
3830 (setq mode-name "Article")
3831 (setq major-mode 'gnus-article-mode)
3832 (make-local-variable 'minor-mode-alist)
3833 (unless (assq 'gnus-show-mime minor-mode-alist)
3834 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3835 (use-local-map gnus-article-mode-map)
3836 (when (gnus-visual-p 'article-menu 'menu)
3837 (gnus-article-make-menu-bar)
3838 (when gnus-summary-tool-bar-map
3839 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3840 (gnus-update-format-specifications nil 'article-mode)
3841 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3842 (set (make-local-variable 'gnus-page-broken) nil)
3843 (make-local-variable 'gnus-button-marker-list)
3844 (make-local-variable 'gnus-article-current-summary)
3845 (make-local-variable 'gnus-article-mime-handles)
3846 (make-local-variable 'gnus-article-decoded-p)
3847 (make-local-variable 'gnus-article-mime-handle-alist)
3848 (make-local-variable 'gnus-article-wash-types)
3849 (make-local-variable 'gnus-article-image-alist)
3850 (make-local-variable 'gnus-article-charset)
3851 (make-local-variable 'gnus-article-ignored-charsets)
3852 (gnus-set-default-directory)
3853 (buffer-disable-undo)
3854 (setq buffer-read-only t)
3855 (set-syntax-table gnus-article-mode-syntax-table)
3856 (gnus-run-hooks 'gnus-article-mode-hook))
3858 (defun gnus-article-setup-buffer ()
3859 "Initialize the article buffer."
3860 (let* ((name (if gnus-single-article-buffer "*Article*"
3861 (concat "*Article " gnus-newsgroup-name "*")))
3863 (progn (string-match "\\*Article" name)
3864 (concat " *Original Article"
3865 (substring name (match-end 0))))))
3866 (setq gnus-article-buffer name)
3867 (setq gnus-original-article-buffer original)
3868 (setq gnus-article-mime-handle-alist nil)
3869 ;; This might be a variable local to the summary buffer.
3870 (unless gnus-single-article-buffer
3872 (set-buffer gnus-summary-buffer)
3873 (setq gnus-article-buffer name)
3874 (setq gnus-original-article-buffer original)
3875 (gnus-set-global-variables)))
3876 (gnus-article-setup-highlight-words)
3877 ;; Init original article buffer.
3879 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3880 (set-buffer-multibyte t)
3881 (setq major-mode 'gnus-original-article-mode)
3882 (make-local-variable 'gnus-original-article))
3883 (if (get-buffer name)
3886 (when (and gnus-article-edit-mode
3889 (y-or-n-p "Article mode edit in progress; discard? ")))
3890 (error "Action aborted"))
3891 (set (make-local-variable 'gnus-article-edit-mode) nil)
3892 (buffer-disable-undo)
3893 (setq buffer-read-only t)
3894 ;; This list just keeps growing if we don't reset it.
3895 (setq gnus-button-marker-list nil)
3896 (unless (eq major-mode 'gnus-article-mode)
3897 (gnus-article-mode))
3900 (set-buffer (gnus-get-buffer-create name))
3902 (make-local-variable 'gnus-summary-buffer)
3903 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3904 (current-buffer)))))
3906 ;; Set article window start at LINE, where LINE is the number of lines
3907 ;; from the head of the article.
3908 (defun gnus-article-set-window-start (&optional line)
3910 (gnus-get-buffer-window gnus-article-buffer t)
3912 (set-buffer gnus-article-buffer)
3913 (goto-char (point-min))
3916 (gnus-message 6 "Moved to bookmark")
3917 (search-forward "\n\n" nil t)
3921 ;;; @@ article filters
3924 (defun gnus-article-display-mime-message ()
3925 "Article display method for MIME message."
3926 ;; called from `gnus-original-article-buffer'.
3927 (let (charset all-headers)
3928 (with-current-buffer gnus-summary-buffer
3929 (setq charset default-mime-charset
3930 all-headers gnus-have-all-headers))
3931 (make-local-variable 'default-mime-charset)
3932 (setq default-mime-charset charset)
3933 (with-current-buffer (get-buffer-create gnus-article-buffer)
3934 (make-local-variable 'default-mime-charset)
3935 (setq default-mime-charset charset))
3936 (mime-display-message mime-message-structure
3937 gnus-article-buffer nil gnus-article-mode-map)
3939 (gnus-article-hide-headers nil -1)))
3940 (run-hooks 'gnus-mime-article-prepare-hook))
3942 (defun gnus-article-display-traditional-message ()
3943 "Article display method for traditional message."
3944 (set-buffer gnus-article-buffer)
3945 (let (buffer-read-only)
3947 (insert-buffer-substring gnus-original-article-buffer)))
3949 (defun gnus-article-make-full-mail-header (&optional number charset)
3950 "Create a new mail header structure in a raw article buffer."
3951 (unless (and number charset)
3952 (save-current-buffer
3953 (set-buffer gnus-summary-buffer)
3955 (setq number (or (cdr gnus-article-current) 0)))
3957 (setq charset (or default-mime-charset 'x-ctext)))))
3958 (goto-char (point-min))
3959 (let ((header-end (if (search-forward "\n\n" nil t)
3961 (goto-char (point-max))))
3962 (chars (- (point-max) (point)))
3963 (lines (count-lines (point) (point-max)))
3964 (default-mime-charset charset)
3966 (narrow-to-region (point-min) header-end)
3967 (setq xref (std11-fetch-field "xref"))
3969 (make-full-mail-header
3971 (std11-fetch-field "subject")
3972 (std11-fetch-field "from")
3973 (std11-fetch-field "date")
3974 (std11-fetch-field "message-id")
3975 (std11-fetch-field "references")
3978 (when xref (concat "Xref: " xref)))
3981 (defun gnus-article-prepare (article &optional all-headers header)
3982 "Prepare ARTICLE in article mode buffer.
3983 ARTICLE should either be an article number or a Message-ID.
3984 If ARTICLE is an id, HEADER should be the article headers.
3985 If ALL-HEADERS is non-nil, no headers are hidden."
3987 ;; Make sure we start in a summary buffer.
3988 (unless (eq major-mode 'gnus-summary-mode)
3989 (set-buffer gnus-summary-buffer))
3990 (setq gnus-summary-buffer (current-buffer))
3991 (let* ((gnus-article (if header (mail-header-number header) article))
3992 (summary-buffer (current-buffer))
3993 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3994 (group gnus-newsgroup-name)
3997 (gnus-article-setup-buffer)
3998 (set-buffer gnus-article-buffer)
3999 ;; Deactivate active regions.
4000 (when (and (boundp 'transient-mark-mode)
4001 transient-mark-mode)
4002 (setq mark-active nil))
4003 (if (not (setq result (let ((buffer-read-only nil))
4004 (gnus-request-article-this-buffer
4006 ;; There is no such article.
4008 (when (and (numberp article)
4009 (not (memq article gnus-newsgroup-sparse)))
4010 (setq gnus-article-current
4011 (cons gnus-newsgroup-name article))
4012 (set-buffer gnus-summary-buffer)
4013 (setq gnus-current-article article)
4014 (if (and (memq article gnus-newsgroup-undownloaded)
4015 (not (gnus-online (gnus-find-method-for-group
4016 gnus-newsgroup-name))))
4018 (gnus-summary-set-agent-mark article)
4019 (message "Message marked for downloading"))
4020 (gnus-summary-mark-article article gnus-canceled-mark)
4021 (unless (memq article gnus-newsgroup-sparse)
4022 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4023 (if (or (eq result 'pseudo)
4024 (eq result 'nneething))
4027 (set-buffer summary-buffer)
4028 (push article gnus-newsgroup-history)
4029 (setq gnus-last-article gnus-current-article
4030 gnus-current-article 0
4031 gnus-current-headers nil
4032 gnus-article-current nil)
4033 (if (eq result 'nneething)
4034 (gnus-configure-windows 'summary)
4035 (gnus-configure-windows 'article))
4036 (gnus-set-global-variables))
4037 (let ((gnus-article-mime-handle-alist-1
4038 gnus-article-mime-handle-alist))
4039 (gnus-set-mode-line 'article)))
4040 ;; The result from the `request' was an actual article -
4041 ;; or at least some text that is now displayed in the
4043 (when (and (numberp article)
4044 (not (eq article gnus-current-article)))
4045 ;; Seems like a new article has been selected.
4046 ;; `gnus-current-article' must be an article number.
4048 (set-buffer summary-buffer)
4049 (push article gnus-newsgroup-history)
4050 (setq gnus-last-article gnus-current-article
4051 gnus-current-article article
4052 gnus-current-headers
4053 (gnus-summary-article-header gnus-current-article)
4054 gnus-article-current
4055 (cons gnus-newsgroup-name gnus-current-article))
4056 (unless (vectorp gnus-current-headers)
4057 (setq gnus-current-headers nil))
4058 (gnus-summary-goto-subject gnus-current-article)
4059 (when (gnus-summary-show-thread)
4060 ;; If the summary buffer really was folded, the
4061 ;; previous goto may not actually have gone to
4062 ;; the right article, but the thread root instead.
4064 (gnus-summary-goto-subject gnus-current-article))
4065 (gnus-run-hooks 'gnus-mark-article-hook)
4066 (gnus-set-mode-line 'summary)
4067 (when (gnus-visual-p 'article-highlight 'highlight)
4068 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4069 ;; Set the global newsgroup variables here.
4070 (gnus-set-global-variables)
4071 (setq gnus-have-all-headers
4072 (or all-headers gnus-show-all-headers))))
4074 (gnus-configure-windows 'article))
4075 (when (or (numberp article)
4077 (gnus-article-prepare-display)
4079 (goto-char (point-min))
4080 (when gnus-break-pages
4081 (gnus-narrow-to-page)))
4082 (let ((gnus-article-mime-handle-alist-1
4083 gnus-article-mime-handle-alist))
4084 (gnus-set-mode-line 'article))
4088 (set-window-point (get-buffer-window (current-buffer)) (point))
4089 (gnus-configure-windows 'article)
4092 (defun gnus-article-prepare-mime-display (&optional number)
4093 (goto-char (point-min))
4094 (when (re-search-forward "^[^\t ]+:" nil t)
4095 (goto-char (match-beginning 0)))
4096 (let ((entity (if (eq 1 (point-min))
4097 (get-text-property 1 'mime-view-entity)
4098 (get-text-property (point) 'mime-view-entity)))
4099 last-entity child-entity next type)
4100 (setq child-entity (mime-entity-children entity))
4102 (setq last-entity (nth (1- (length child-entity))
4104 (setq last-entity entity))
4106 (narrow-to-region (point)
4107 (if (search-forward "\n\n" nil t)
4110 (gnus-treat-article 'head)
4111 (put-text-property (point-min) (point-max) 'article-treated-header t)
4112 (goto-char (point-max)))
4113 (while (and (not (eobp)) entity)
4114 (setq next (set-marker
4116 (next-single-property-change (point) 'mime-view-entity
4118 (let ((types (mime-entity-content-type entity)))
4119 (while (eq 'multipart (mime-content-type-primary-type types))
4120 (setq entity (car (mime-entity-children entity))
4121 types (mime-entity-content-type entity)))
4123 (setq type (format "%s/%s"
4124 (mime-content-type-primary-type types)
4125 (mime-content-type-subtype types)))))
4126 (if (string-equal type "message/rfc822")
4129 (let ((children (mime-entity-children entity))
4132 (setq last-children (nth (1- (length children)) children))
4135 (not (eq last-children
4136 (get-text-property next 'mime-view-entity)))
4138 (next-single-property-change next
4140 nil (point-max)))))))
4141 (setq next (next-single-property-change next 'mime-view-entity
4144 (narrow-to-region (point) next)
4145 (gnus-article-prepare-mime-display)
4146 (goto-char (point-max)))
4147 (setq entity (get-text-property (point) 'mime-view-entity)))
4149 (narrow-to-region (point) next)
4150 ;; Kludge. We have to count true number, but for now,
4151 ;; part number is here only to achieve `last'.
4152 (gnus-treat-article nil 1
4153 (if (eq entity last-entity)
4156 (goto-char (point-max)))
4157 (setq entity (get-text-property next 'mime-view-entity))))))
4160 (defun gnus-article-prepare-display ()
4161 "Make the current buffer look like a nice article."
4162 (let ((gnus-article-buffer (current-buffer))
4164 (unless (eq major-mode 'gnus-article-mode)
4165 (gnus-article-mode))
4166 (setq buffer-read-only nil
4167 gnus-button-marker-list nil
4168 gnus-article-wash-types nil
4169 gnus-article-image-alist nil)
4172 (static-if (featurep 'xemacs)
4173 (map-extents (lambda (extent maparg) (delete-extent extent)))
4174 (let ((lists (overlay-lists)))
4175 (dolist (overlay (nconc (car lists) (cdr lists)))
4176 (delete-overlay overlay)))))
4177 (gnus-run-hooks 'gnus-tmp-internal-hook))
4178 (let ((show-mime (unless (member gnus-newsgroup-name '("nndraft:delayed"
4181 (inhibit-read-only t))
4182 (set-buffer gnus-original-article-buffer)
4184 (setq mime-message-structure gnus-current-headers)
4185 (mime-buffer-entity-set-buffer-internal mime-message-structure
4186 gnus-original-article-buffer)
4187 (mime-entity-set-representation-type-internal mime-message-structure
4188 'mime-buffer-entity)
4189 (luna-send mime-message-structure 'initialize-instance
4190 mime-message-structure)
4192 (let (mime-display-header-hook mime-display-text/plain-hook)
4193 (funcall gnus-article-display-method-for-mime))
4194 (funcall gnus-article-display-method-for-traditional))
4195 ;; Call the treatment functions.
4199 (gnus-article-prepare-mime-display)
4200 (narrow-to-region (goto-char (point-min))
4201 (if (search-forward "\n\n" nil t)
4204 (gnus-treat-article 'head)
4205 (put-text-property (point-min) (point-max) 'article-treated-header t)
4206 (goto-char (point-max))
4208 (narrow-to-region (point) (point-max))
4209 (gnus-treat-article nil))
4210 (put-text-property (point-min) (point-max) 'read-only nil)))
4211 (gnus-run-hooks 'gnus-article-prepare-hook))
4213 (defun gnus-article-decode-article-as-default-mime-charset ()
4214 "Decode an article as `default-mime-charset'. It won't work if the
4215 value of the variable `gnus-show-mime' is non-nil."
4216 (unless (or gnus-show-mime
4217 (member gnus-newsgroup-name '("nndraft:delayed"
4219 (set (make-local-variable 'default-mime-charset)
4220 (with-current-buffer gnus-summary-buffer
4221 default-mime-charset))
4222 (decode-mime-charset-region (point-min) (point-max)
4223 default-mime-charset)))
4226 ;;; Gnus MIME viewing functions
4229 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4230 "Format of the MIME buttons.
4232 Valid specifiers include:
4234 %T MIME type, along with additional info
4235 %n The `name' parameter
4236 %d The description, if any
4237 %l The length of the encoded part
4238 %p The part identifier number
4239 %e Dots if the part isn't displayed
4241 General format specifiers can also be used. See Info node
4242 `(gnus)Formatting Variables'.")
4244 (defvar gnus-mime-button-line-format-alist
4245 '((?t gnus-tmp-type ?s)
4246 (?T gnus-tmp-type-long ?s)
4247 (?n gnus-tmp-name ?s)
4248 (?d gnus-tmp-description ?s)
4250 (?l gnus-tmp-length ?d)
4251 (?e gnus-tmp-dots ?s)))
4253 (defvar gnus-mime-button-commands
4254 '((gnus-article-press-button "\r" "Toggle Display")
4255 (gnus-mime-view-part "v" "View Interactively...")
4256 (gnus-mime-view-part-as-type "t" "View As Type...")
4257 (gnus-mime-view-part-as-charset "C" "View As charset...")
4258 (gnus-mime-save-part "o" "Save...")
4259 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4260 (gnus-mime-delete-part "d" "Delete part")
4261 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4262 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4263 (gnus-mime-view-part-internally "E" "View Internally")
4264 (gnus-mime-view-part-externally "e" "View Externally")
4265 (gnus-mime-print-part "p" "Print")
4266 (gnus-mime-pipe-part "|" "Pipe To Command...")
4267 (gnus-mime-action-on-part "." "Take action on the part...")))
4269 (defun gnus-article-mime-part-status ()
4270 (with-current-buffer gnus-article-buffer
4271 (let ((entity (get-text-property (point-min) 'mime-view-entity))
4274 (setq children (mime-entity-children entity))
4275 (setq children (length children)))
4278 (format " (%d parts)" children))
4281 (defvar gnus-mime-button-map
4282 (let ((map (make-sparse-keymap)))
4283 (define-key map gnus-mouse-2 'gnus-article-push-button)
4284 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4285 (dolist (c gnus-mime-button-commands)
4286 (define-key map (cadr c) (car c)))
4290 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4292 ,@(mapcar (lambda (c)
4293 (vector (caddr c) (car c) :enable t))
4294 gnus-mime-button-commands)))
4296 (defun gnus-mime-button-menu (event prefix)
4297 "Construct a context-sensitive menu of MIME commands."
4298 (interactive "e\nP")
4299 (save-window-excursion
4300 (let ((pos (event-start event)))
4301 (select-window (posn-window pos))
4302 (goto-char (posn-point pos))
4303 (gnus-article-check-buffer)
4304 (popup-menu gnus-mime-button-menu nil prefix))))
4306 (defun gnus-mime-view-all-parts (&optional handles)
4307 "View all the MIME parts."
4309 (with-current-buffer gnus-article-buffer
4310 (let ((handles (or handles gnus-article-mime-handles))
4311 (mail-parse-charset gnus-newsgroup-charset)
4312 (mail-parse-ignored-charsets
4313 (with-current-buffer gnus-summary-buffer
4314 gnus-newsgroup-ignored-charsets)))
4316 (mm-remove-parts handles)
4317 (goto-char (point-min))
4318 (or (search-forward "\n\n") (goto-char (point-max)))
4319 (let (buffer-read-only)
4320 (delete-region (point) (point-max))
4321 (mm-display-parts handles))))))
4323 (defun gnus-mime-save-part-and-strip ()
4324 "Save the MIME part under point then replace it with an external body."
4326 (gnus-article-check-buffer)
4327 (let* ((data (get-text-property (point) 'gnus-data))
4329 (handles gnus-article-mime-handles))
4330 (if (mm-multiple-handles gnus-article-mime-handles)
4331 (error "This function is not implemented"))
4332 (setq file (and data (mm-save-part data)))
4334 (with-current-buffer (mm-handle-buffer data)
4336 (insert "Content-Type: " (mm-handle-media-type data))
4337 (mml-insert-parameter-string (cdr (mm-handle-type data))
4340 (insert "Content-ID: " (message-make-message-id) "\n")
4341 (insert "Content-Transfer-Encoding: binary\n")
4344 (cdr (mm-make-handle nil
4345 `("message/external-body"
4346 (access-type . "LOCAL-FILE")
4348 (set-buffer gnus-summary-buffer)
4349 (gnus-article-edit-article
4352 (let ((mail-parse-charset (or gnus-article-charset
4353 ',gnus-newsgroup-charset))
4354 (mail-parse-ignored-charsets
4355 (or gnus-article-ignored-charsets
4356 ',gnus-newsgroup-ignored-charsets))
4357 (mbl mml-buffer-list))
4358 (setq mml-buffer-list nil)
4359 (insert-buffer gnus-original-article-buffer)
4360 (mime-to-mml ',handles)
4361 (setq gnus-article-mime-handles nil)
4362 (let ((mbl1 mml-buffer-list))
4363 (setq mml-buffer-list mbl)
4364 (set (make-local-variable 'mml-buffer-list) mbl1))
4365 (gnus-make-local-hook 'kill-buffer-hook)
4366 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4367 `(lambda (no-highlight)
4368 (let ((mail-parse-charset (or gnus-article-charset
4369 ',gnus-newsgroup-charset))
4370 (message-options message-options)
4371 (message-options-set-recipient)
4372 (mail-parse-ignored-charsets
4373 (or gnus-article-ignored-charsets
4374 ',gnus-newsgroup-ignored-charsets)))
4376 (mml-destroy-buffers)
4377 (remove-hook 'kill-buffer-hook
4378 'mml-destroy-buffers t)
4379 (kill-local-variable 'mml-buffer-list))
4380 (gnus-summary-edit-article-done
4381 ,(or (mail-header-references gnus-current-headers) "")
4382 ,(gnus-group-read-only-p)
4383 ,gnus-summary-buffer no-highlight))))))
4385 (defun gnus-mime-delete-part ()
4386 "Delete the MIME part under point.
4387 Replace it with some information about the removed part."
4389 (gnus-article-check-buffer)
4390 (unless (and gnus-novice-user
4391 (not (gnus-yes-or-no-p
4392 "Really delete attachment forever? ")))
4393 (let* ((data (get-text-property (point) 'gnus-data))
4394 (handles gnus-article-mime-handles)
4398 (mail-decode-encoded-word-string (or (mm-handle-description data)
4401 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4403 (type (mm-handle-media-type data)))
4404 (if (mm-multiple-handles gnus-article-mime-handles)
4405 (error "This function is not implemented"))
4406 (with-current-buffer (mm-handle-buffer data)
4407 (let ((bsize (format "%s" (buffer-size))))
4412 "| The following attachment has been deleted:\n"
4414 "| Type: " type "\n"
4415 "| Filename: " filename "\n"
4416 "| Size (encoded): " bsize " Byte\n"
4417 "| Description: " description "\n"
4420 (cdr (mm-make-handle
4421 nil `("text/plain") nil nil
4423 (format "Deleted attachment (%s bytes)" bsize))))))
4424 (set-buffer gnus-summary-buffer)
4425 ;; FIXME: maybe some of the following code (borrowed from
4426 ;; `gnus-mime-save-part-and-strip') isn't necessary?
4427 (gnus-article-edit-article
4430 (let ((mail-parse-charset (or gnus-article-charset
4431 ',gnus-newsgroup-charset))
4432 (mail-parse-ignored-charsets
4433 (or gnus-article-ignored-charsets
4434 ',gnus-newsgroup-ignored-charsets))
4435 (mbl mml-buffer-list))
4436 (setq mml-buffer-list nil)
4437 (insert-buffer gnus-original-article-buffer)
4438 (mime-to-mml ',handles)
4439 (setq gnus-article-mime-handles nil)
4440 (let ((mbl1 mml-buffer-list))
4441 (setq mml-buffer-list mbl)
4442 (set (make-local-variable 'mml-buffer-list) mbl1))
4443 (gnus-make-local-hook 'kill-buffer-hook)
4444 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4445 `(lambda (no-highlight)
4446 (let ((mail-parse-charset (or gnus-article-charset
4447 ',gnus-newsgroup-charset))
4448 (message-options message-options)
4449 (message-options-set-recipient)
4450 (mail-parse-ignored-charsets
4451 (or gnus-article-ignored-charsets
4452 ',gnus-newsgroup-ignored-charsets)))
4454 (mml-destroy-buffers)
4455 (remove-hook 'kill-buffer-hook
4456 'mml-destroy-buffers t)
4457 (kill-local-variable 'mml-buffer-list))
4458 (gnus-summary-edit-article-done
4459 ,(or (mail-header-references gnus-current-headers) "")
4460 ,(gnus-group-read-only-p)
4461 ,gnus-summary-buffer no-highlight)))))
4462 ;; Not in `gnus-mime-save-part-and-strip':
4463 (gnus-article-edit-done)
4464 (gnus-summary-expand-window)
4465 (gnus-summary-show-article))
4467 (defun gnus-mime-save-part ()
4468 "Save the MIME part under point."
4470 (gnus-article-check-buffer)
4471 (let ((data (get-text-property (point) 'gnus-data)))
4473 (mm-save-part data))))
4475 (defun gnus-mime-pipe-part ()
4476 "Pipe the MIME part under point to a process."
4478 (gnus-article-check-buffer)
4479 (let ((data (get-text-property (point) 'gnus-data)))
4481 (mm-pipe-part data))))
4483 (defun gnus-mime-view-part ()
4484 "Interactively choose a viewing method for the MIME part under point."
4486 (gnus-article-check-buffer)
4487 (let ((data (get-text-property (point) 'gnus-data)))
4489 (setq gnus-article-mime-handles
4491 gnus-article-mime-handles (setq data (copy-sequence data))))
4492 (mm-interactively-view-part data))))
4494 (defun gnus-mime-view-part-as-type-internal ()
4495 (gnus-article-check-buffer)
4496 (let* ((name (mail-content-type-get
4497 (mm-handle-type (get-text-property (point) 'gnus-data))
4499 (def-type (and name (mm-default-file-encoding name))))
4500 (and def-type (cons def-type 0))))
4502 (defun gnus-mime-view-part-as-type (&optional mime-type)
4503 "Choose a MIME media type, and view the part as such."
4506 (setq mime-type (completing-read
4507 "View as MIME type: "
4508 (mapcar #'list (mailcap-mime-types))
4510 (gnus-mime-view-part-as-type-internal))))
4511 (gnus-article-check-buffer)
4512 (let ((handle (get-text-property (point) 'gnus-data)))
4515 (mm-make-handle (mm-handle-buffer handle)
4516 (cons mime-type (cdr (mm-handle-type handle)))
4517 (mm-handle-encoding handle)
4518 (mm-handle-undisplayer handle)
4519 (mm-handle-disposition handle)
4520 (mm-handle-description handle)
4522 (mm-handle-id handle)))
4523 (setq gnus-article-mime-handles
4524 (mm-merge-handles gnus-article-mime-handles handle))
4525 (gnus-mm-display-part handle))))
4528 (require 'jka-compr))
4530 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4531 ;; emacs can do that itself.
4533 (defun gnus-mime-jka-compr-maybe-uncompress ()
4534 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4535 The uncompress method used is derived from `buffer-file-name'."
4536 (when (and (fboundp 'jka-compr-installed-p)
4537 (jka-compr-installed-p))
4538 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4540 (let ((basename (file-name-nondirectory buffer-file-name))
4541 (args (jka-compr-info-uncompress-args info))
4542 (prog (jka-compr-info-uncompress-program info))
4543 (message (jka-compr-info-uncompress-message info))
4544 (err-file (jka-compr-make-temp-name)))
4546 (message "%s %s..." message basename))
4548 (unless (memq (apply 'call-process-region
4549 (point-min) (point-max)
4551 t (list t err-file) nil
4553 jka-compr-acceptable-retval-list)
4554 (jka-compr-error prog args basename message err-file))
4555 (jka-compr-delete-temp-file err-file)))))))
4557 (defun gnus-mime-copy-part (&optional handle)
4558 "Put the MIME part under point into a new buffer.
4559 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4562 (gnus-article-check-buffer)
4563 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4564 (contents (and handle (mm-get-part handle)))
4566 (file-name-nondirectory
4568 (mail-content-type-get (mm-handle-type handle) 'name)
4569 (mail-content-type-get (mm-handle-disposition handle)
4572 (buffer (and base (generate-new-buffer base))))
4574 (switch-to-buffer buffer)
4576 ;; We do it this way to make `normal-mode' set the appropriate mode.
4579 (setq buffer-file-name (expand-file-name base))
4580 (gnus-mime-jka-compr-maybe-uncompress)
4582 (setq buffer-file-name nil))
4583 (goto-char (point-min)))))
4585 (defun gnus-mime-print-part (&optional handle filename)
4586 "Print the MIME part under point."
4587 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4588 (gnus-article-check-buffer)
4589 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4590 (contents (and handle (mm-get-part handle)))
4591 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4592 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4597 (mm-save-part-to-file handle file)
4598 (call-process shell-file-name nil
4599 (generate-new-buffer " *mm*")
4601 shell-command-switch
4603 printer file (mm-handle-type handle))))
4607 (gnus-print-buffer))
4608 (ps-despool filename)))))
4610 (defun gnus-mime-inline-part (&optional handle arg)
4611 "Insert the MIME part under point into the current buffer."
4612 (interactive (list nil current-prefix-arg))
4613 (gnus-article-check-buffer)
4614 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4619 (if (and (not arg) (mm-handle-undisplayer handle))
4620 (mm-remove-part handle)
4621 (setq contents (mm-get-part handle))
4624 (setq charset (or (mail-content-type-get
4625 (mm-handle-type handle) 'charset)
4626 gnus-newsgroup-charset)))
4628 (if (mm-handle-undisplayer handle)
4629 (mm-remove-part handle))
4632 gnus-summary-show-article-charset-alist))
4633 (mm-read-coding-system "Charset: ")))))
4635 (mm-insert-inline handle
4637 (setq charset (mm-charset-to-coding-system
4639 (not (eq charset 'ascii)))
4640 (mm-decode-coding-string contents charset)
4644 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4645 "Insert the MIME part under point into the current buffer using the
4647 (interactive (list nil current-prefix-arg))
4648 (gnus-article-check-buffer)
4649 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4654 (if (mm-handle-undisplayer handle)
4655 (mm-remove-part handle))
4656 (let ((gnus-newsgroup-charset
4658 gnus-summary-show-article-charset-alist))
4659 (mm-read-coding-system "Charset: ")))
4660 (gnus-newsgroup-ignored-charsets 'gnus-all))
4661 (gnus-article-press-button)))))
4663 (defun gnus-mime-view-part-externally (&optional handle)
4664 "View the MIME part under point with an external viewer."
4666 (gnus-article-check-buffer)
4667 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4668 (mm-user-display-methods nil)
4669 (mm-inlined-types nil)
4670 (mail-parse-charset gnus-newsgroup-charset)
4671 (mail-parse-ignored-charsets
4672 (with-current-buffer gnus-summary-buffer
4673 gnus-newsgroup-ignored-charsets)))
4675 (if (mm-handle-undisplayer handle)
4676 (mm-remove-part handle)
4677 (mm-display-part handle)))))
4679 (defun gnus-mime-view-part-internally (&optional handle)
4680 "View the MIME part under point with an internal viewer.
4681 If no internal viewer is available, use an external viewer."
4683 (gnus-article-check-buffer)
4684 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4685 (mm-inlined-types '(".*"))
4686 (mm-inline-large-images t)
4687 (mail-parse-charset gnus-newsgroup-charset)
4688 (mail-parse-ignored-charsets
4689 (with-current-buffer gnus-summary-buffer
4690 gnus-newsgroup-ignored-charsets))
4693 (if (mm-handle-undisplayer handle)
4694 (mm-remove-part handle)
4695 (mm-display-part handle)))))
4697 (defun gnus-mime-action-on-part (&optional action)
4698 "Do something with the MIME attachment at \(point\)."
4700 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4701 (gnus-article-check-buffer)
4702 (let ((action-pair (assoc action gnus-mime-action-alist)))
4704 (funcall (cdr action-pair)))))
4706 (defun gnus-article-part-wrapper (n function)
4707 (with-current-buffer gnus-article-buffer
4708 (when (> n (length gnus-article-mime-handle-alist))
4709 (error "No such part"))
4710 (gnus-article-goto-part n)
4711 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4712 (funcall function handle))))
4714 (defun gnus-article-pipe-part (n)
4715 "Pipe MIME part N, which is the numerical prefix."
4717 (gnus-article-part-wrapper n 'mm-pipe-part))
4719 (defun gnus-article-save-part (n)
4720 "Save MIME part N, which is the numerical prefix."
4722 (gnus-article-part-wrapper n 'mm-save-part))
4724 (defun gnus-article-interactively-view-part (n)
4725 "View MIME part N interactively, which is the numerical prefix."
4727 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4729 (defun gnus-article-copy-part (n)
4730 "Copy MIME part N, which is the numerical prefix."
4732 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4734 (defun gnus-article-view-part-as-charset (n)
4735 "View MIME part N using a specified charset.
4736 N is the numerical prefix."
4738 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4740 (defun gnus-article-view-part-externally (n)
4741 "View MIME part N externally, which is the numerical prefix."
4743 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4745 (defun gnus-article-inline-part (n)
4746 "Inline MIME part N, which is the numerical prefix."
4748 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4750 (defun gnus-article-mime-match-handle-first (condition)
4752 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4753 (while (setq ihandle (pop alist))
4755 ((functionp condition)
4756 (funcall condition (cdr ihandle)))
4757 ((eq condition 'undisplayed)
4758 (not (or (mm-handle-undisplayer (cdr ihandle))
4759 (equal (mm-handle-media-type (cdr ihandle))
4760 "multipart/alternative"))))
4761 ((eq condition 'undisplayed-alternative)
4762 (not (mm-handle-undisplayer (cdr ihandle))))
4764 (gnus-article-goto-part (car ihandle))
4765 (or (not n) (< (car ihandle) n)))
4766 (setq n (car ihandle))))
4770 (defun gnus-article-view-part (&optional n)
4771 "View MIME part N, which is the numerical prefix."
4773 (with-current-buffer gnus-article-buffer
4774 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4775 gnus-article-mime-match-handle-function)))
4776 (when (> n (length gnus-article-mime-handle-alist))
4777 (error "No such part"))
4778 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4779 (when (gnus-article-goto-part n)
4780 (if (equal (car handle) "multipart/alternative")
4781 (gnus-article-press-button)
4782 (when (eq (gnus-mm-display-part handle) 'internal)
4783 (gnus-set-window-start)))))))
4785 (defsubst gnus-article-mime-total-parts ()
4786 (if (bufferp (car gnus-article-mime-handles))
4788 (1- (length gnus-article-mime-handles))))
4790 (defun gnus-mm-display-part (handle)
4791 "Display HANDLE and fix MIME button."
4792 (let ((id (get-text-property (point) 'gnus-part))
4797 (let ((window (selected-window))
4798 (mail-parse-charset gnus-newsgroup-charset)
4799 (mail-parse-ignored-charsets
4800 (if (gnus-buffer-live-p gnus-summary-buffer)
4801 (with-current-buffer gnus-summary-buffer
4802 gnus-newsgroup-ignored-charsets)
4806 (let ((win (gnus-get-buffer-window (current-buffer) t))
4809 (select-window win))
4812 (if (mm-handle-displayed-p handle)
4813 ;; This will remove the part.
4814 (mm-display-part handle)
4816 (narrow-to-region (point)
4817 (if (eobp) (point) (1+ (point))))
4818 (mm-display-part handle)
4819 ;; We narrow to the part itself and
4820 ;; then call the treatment functions.
4821 (goto-char (point-min))
4823 (narrow-to-region (point) (point-max))
4826 (gnus-article-mime-total-parts)
4827 (mm-handle-media-type handle)))))
4828 (if (window-live-p window)
4829 (select-window window)))))
4832 (gnus-insert-mime-button
4833 handle id (list (mm-handle-displayed-p handle)))
4834 (goto-char point))))
4836 (defun gnus-article-goto-part (n)
4837 "Go to MIME part N."
4838 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4840 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4841 (let ((gnus-tmp-name
4842 (or (mail-content-type-get (mm-handle-type handle) 'name)
4843 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4844 (mail-content-type-get (mm-handle-type handle) 'url)
4846 (gnus-tmp-type (mm-handle-media-type handle))
4847 (gnus-tmp-description
4848 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4851 (if (if displayed (car displayed)
4852 (mm-handle-displayed-p handle))
4854 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4856 gnus-tmp-type-long b e)
4857 (when (string-match ".*/" gnus-tmp-name)
4858 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4859 (setq gnus-tmp-type-long (concat gnus-tmp-type
4860 (and (not (equal gnus-tmp-name ""))
4861 (concat "; " gnus-tmp-name))))
4862 (unless (equal gnus-tmp-description "")
4863 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4868 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4869 `(keymap ,gnus-mime-button-map
4870 gnus-callback gnus-mm-display-part
4871 gnus-part ,gnus-tmp-id
4872 article-type annotation
4875 ;; Exclude a newline.
4878 (widget-convert-button
4881 :action 'gnus-widget-press-button
4882 :button-keymap gnus-mime-button-map
4884 (lambda (widget/window &optional overlay pos)
4885 ;; Needed to properly clear the message due to a bug in
4886 ;; wid-edit (XEmacs only).
4887 (if (boundp 'help-echo-owns-message)
4888 (setq help-echo-owns-message t))
4890 "%S: %s the MIME part; %S: more options"
4891 (aref gnus-mouse-2 0)
4892 ;; XEmacs will get a single widget arg; Emacs 21 will get
4893 ;; window, overlay, position.
4894 (if (mm-handle-displayed-p
4896 (with-current-buffer (gnus-overlay-buffer overlay)
4897 (widget-get (widget-at (gnus-overlay-start overlay))
4899 (widget-get widget/window :mime-handle)))
4901 (aref gnus-down-mouse-3 0))))))
4903 (defun gnus-widget-press-button (elems el)
4904 (goto-char (widget-get elems :from))
4905 (gnus-article-press-button))
4907 (defvar gnus-displaying-mime nil)
4909 (defun gnus-display-mime (&optional ihandles)
4910 "Display the MIME parts."
4912 (save-selected-window
4913 (let ((window (get-buffer-window gnus-article-buffer))
4916 (select-window window)
4917 ;; We have to do this since selecting the window
4918 ;; may change the point. So we set the window point.
4919 (set-window-point window point)))
4920 (let* ((handles (or ihandles
4921 (mm-dissect-buffer nil gnus-article-loose-mime)
4922 (and gnus-article-emulate-mime
4924 buffer-read-only handle name type b e display)
4925 (when (and (not ihandles)
4926 (not gnus-displaying-mime))
4927 ;; Top-level call; we clean up.
4928 (when gnus-article-mime-handles
4929 (mm-destroy-parts gnus-article-mime-handles)
4930 (setq gnus-article-mime-handle-alist nil));; A trick.
4931 (setq gnus-article-mime-handles handles)
4932 ;; We allow users to glean info from the handles.
4933 (when gnus-article-mime-part-function
4934 (gnus-mime-part-function handles)))
4936 (or (not (stringp (car handles)))
4939 (when (and (not ihandles)
4940 (not gnus-displaying-mime))
4941 ;; Clean up for mime parts.
4943 (delete-region (point) (point-max)))
4944 (let ((gnus-displaying-mime t))
4945 (gnus-mime-display-part handles)))
4948 (narrow-to-region (point) (point-max))
4949 (gnus-treat-article nil 1 1)
4952 ;; Highlight the headers.
4956 (narrow-to-region (point-min) (point))
4957 (gnus-treat-article 'head))))))))
4959 (defcustom gnus-mime-display-multipart-as-mixed nil
4960 "Display \"multipart\" parts as \"multipart/mixed\".
4962 If t, it overrides nil values of
4963 `gnus-mime-display-multipart-alternative-as-mixed' and
4964 `gnus-mime-display-multipart-related-as-mixed'."
4965 :group 'gnus-article-mime
4968 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4969 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4970 :group 'gnus-article-mime
4973 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4974 "Display \"multipart/related\" parts as \"multipart/mixed\".
4976 If displaying \"text/html\" is discouraged \(see
4977 `mm-discouraged-alternatives'\) images or other material inside a
4978 \"multipart/related\" part might be overlooked when this variable is nil."
4979 :group 'gnus-article-mime
4982 (defun gnus-mime-display-part (handle)
4985 ((not (stringp (car handle)))
4986 (gnus-mime-display-single handle))
4987 ;; User-defined multipart
4988 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4989 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4991 ;; multipart/alternative
4992 ((and (equal (car handle) "multipart/alternative")
4993 (not (or gnus-mime-display-multipart-as-mixed
4994 gnus-mime-display-multipart-alternative-as-mixed)))
4995 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4996 (push (cons id handle) gnus-article-mime-handle-alist)
4997 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4998 ;; multipart/related
4999 ((and (equal (car handle) "multipart/related")
5000 (not (or gnus-mime-display-multipart-as-mixed
5001 gnus-mime-display-multipart-related-as-mixed)))
5002 ;;;!!!We should find the start part, but we just default
5003 ;;;!!!to the first part.
5004 ;;(gnus-mime-display-part (cadr handle))
5005 ;;;!!! Most multipart/related is an HTML message plus images.
5006 ;;;!!! Unfortunately we are unable to let W3 display those
5007 ;;;!!! included images, so we just display it as a mixed multipart.
5008 ;;(gnus-mime-display-mixed (cdr handle))
5009 ;;;!!! No, w3 can display everything just fine.
5010 (gnus-mime-display-part (cadr handle)))
5011 ((equal (car handle) "multipart/signed")
5012 (gnus-add-wash-type 'signed)
5013 (gnus-mime-display-security handle))
5014 ((equal (car handle) "multipart/encrypted")
5015 (gnus-add-wash-type 'encrypted)
5016 (gnus-mime-display-security handle))
5017 ;; Other multiparts are handled like multipart/mixed.
5019 (gnus-mime-display-mixed (cdr handle)))))
5021 (defun gnus-mime-part-function (handles)
5022 (if (stringp (car handles))
5023 (mapcar 'gnus-mime-part-function (cdr handles))
5024 (funcall gnus-article-mime-part-function handles)))
5026 (defun gnus-mime-display-mixed (handles)
5027 (mapcar 'gnus-mime-display-part handles))
5029 (defun gnus-mime-display-single (handle)
5030 (let ((type (mm-handle-media-type handle))
5031 (ignored gnus-ignored-mime-types)
5038 (when (string-match (pop ignored) type)
5039 (throw 'ignored nil)))
5040 (if (and (setq not-attachment
5041 (and (not (mm-inline-override-p handle))
5042 (or (not (mm-handle-disposition handle))
5043 (equal (car (mm-handle-disposition handle))
5045 (mm-attachment-override-p handle))))
5046 (mm-automatic-display-p handle)
5048 (mm-inlinable-p handle)
5049 (mm-inlined-p handle))
5050 (mm-automatic-external-display-p type)))
5052 (when (equal (mm-handle-media-supertype handle) "text")
5054 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5056 (push (cons id handle) gnus-article-mime-handle-alist)
5057 (when (or (not display)
5058 (not (gnus-unbuttonized-mime-type-p type)))
5059 (gnus-insert-mime-button
5060 handle id (list (or display (and not-attachment text))))
5061 (gnus-article-insert-newline)
5062 ;; Remember modify the number of forward lines.
5070 (let ((mail-parse-charset gnus-newsgroup-charset)
5071 (mail-parse-ignored-charsets
5072 (save-excursion (condition-case ()
5073 (set-buffer gnus-summary-buffer)
5075 gnus-newsgroup-ignored-charsets)))
5076 (mm-display-part handle t))
5077 (goto-char (point-max)))
5078 ((and text not-attachment)
5082 (gnus-article-insert-newline)
5083 (mm-insert-inline handle (mm-get-part handle))
5084 (goto-char (point-max))))
5088 (narrow-to-region beg (point))
5091 (gnus-article-mime-total-parts)
5092 (mm-handle-media-type handle)))))))))
5094 (defun gnus-unbuttonized-mime-type-p (type)
5095 "Say whether TYPE is to be unbuttonized."
5096 (unless gnus-inhibit-mime-unbuttonizing
5098 (let ((types gnus-unbuttonized-mime-types))
5100 (when (string-match (pop types) type)
5101 (throw 'found t)))))
5103 (let ((types gnus-buttonized-mime-types))
5105 (when (string-match (pop types) type)
5106 (throw 'found t)))))))))
5108 (defun gnus-article-insert-newline ()
5109 "Insert a newline, but mark it as undeletable."
5110 (gnus-put-text-property
5111 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5113 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5114 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5117 handle buffer-read-only from props begend not-pref)
5118 (save-window-excursion
5121 (narrow-to-region (car ibegend)
5124 (goto-char (car ibegend))
5127 (delete-region (point-min) (point-max))
5128 (mm-remove-parts handles))
5129 (setq begend (list (point-marker)))
5131 (unless (setq not-pref (cadr (member preferred ihandles)))
5132 (setq not-pref (car ihandles)))
5135 (not (gnus-unbuttonized-mime-type-p
5136 "multipart/alternative")))
5137 (gnus-add-text-properties
5140 (insert (format "%d. " id))
5144 (unless ,(not ibegend)
5145 (setq gnus-article-mime-handle-alist
5146 ',gnus-article-mime-handle-alist))
5147 (gnus-mime-display-alternative
5148 ',ihandles ',not-pref ',begend ,id))
5149 keymap ,gnus-mime-button-map
5150 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5151 face ,gnus-article-button-face
5154 (widget-convert-button 'link from (point)
5155 :action 'gnus-widget-press-button
5156 :button-keymap gnus-widget-button-keymap)
5158 (while (setq handle (pop handles))
5159 (gnus-add-text-properties
5162 (insert (format "(%c) %-18s"
5163 (if (equal handle preferred) ?* ? )
5164 (mm-handle-media-type handle)))
5168 (unless ,(not ibegend)
5169 (setq gnus-article-mime-handle-alist
5170 ',gnus-article-mime-handle-alist))
5171 (gnus-mime-display-alternative
5172 ',ihandles ',handle ',begend ,id))
5173 keymap ,gnus-mime-button-map
5174 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5175 face ,gnus-article-button-face
5178 (widget-convert-button 'link from (point)
5179 :action 'gnus-widget-press-button
5180 :button-keymap gnus-widget-button-keymap)
5184 (if (stringp (car preferred))
5185 (gnus-display-mime preferred)
5186 (let ((mail-parse-charset gnus-newsgroup-charset)
5187 (mail-parse-ignored-charsets
5188 (with-current-buffer gnus-summary-buffer
5189 gnus-newsgroup-ignored-charsets)))
5190 (mm-display-part preferred)
5194 (narrow-to-region (car begend) (point-max))
5196 nil (length gnus-article-mime-handle-alist)
5197 (gnus-article-mime-total-parts)
5198 (mm-handle-media-type handle))))))
5199 (goto-char (point-max))
5200 (setcdr begend (point-marker)))))
5202 (goto-char point))))
5204 (defconst gnus-article-wash-status-strings
5205 (let ((alist '((cite "c" "Possible hidden citation text"
5206 " " "All citation text visible")
5207 (headers "h" "Hidden headers"
5208 " " "All headers visible.")
5209 (pgp "p" "Encrypted or signed message status hidden"
5210 " " "No hidden encryption nor digital signature status")
5211 (signature "s" "Signature has been hidden"
5212 " " "Signature is visible")
5213 (overstrike "o" "Overstrike (^H) characters applied"
5214 " " "No overstrike characters applied")
5215 (gnus-show-mime "m" "Mime processing is activated"
5216 " " "Mime processing is not activated")
5217 (emphasis "e" "/*_Emphasis_*/ characters applied"
5218 " " "No /*_emphasis_*/ characters applied")))
5220 (dolist (entry alist result)
5221 (let ((key (nth 0 entry))
5222 (on (copy-sequence (nth 1 entry)))
5223 (on-help (nth 2 entry))
5224 (off (copy-sequence (nth 3 entry)))
5225 (off-help (nth 4 entry)))
5226 (put-text-property 0 1 'help-echo on-help on)
5227 (put-text-property 0 1 'help-echo off-help off)
5228 (push (list key on off) result))))
5229 "Alist of strings describing wash status in the mode line.
5230 Each entry has the form (KEY ON OF), where the KEY is a symbol
5231 representing the particular washing function, ON is the string to use
5232 in the article mode line when the washing function is active, and OFF
5233 is the string to use when it is inactive.")
5235 (defun gnus-article-wash-status-entry (key value)
5236 (let ((entry (assoc key gnus-article-wash-status-strings)))
5237 (if value (nth 1 entry) (nth 2 entry))))
5239 (defun gnus-article-wash-status ()
5240 "Return a string which display status of article washing."
5241 (with-current-buffer gnus-article-buffer
5242 (let ((cite (memq 'cite gnus-article-wash-types))
5243 (headers (memq 'headers gnus-article-wash-types))
5244 (boring (memq 'boring-headers gnus-article-wash-types))
5245 (pgp (memq 'pgp gnus-article-wash-types))
5246 (pem (memq 'pem gnus-article-wash-types))
5247 (signed (memq 'signed gnus-article-wash-types))
5248 (encrypted (memq 'encrypted gnus-article-wash-types))
5249 (signature (memq 'signature gnus-article-wash-types))
5250 (overstrike (memq 'overstrike gnus-article-wash-types))
5251 (emphasis (memq 'emphasis gnus-article-wash-types)))
5253 (gnus-article-wash-status-entry 'cite cite)
5254 (gnus-article-wash-status-entry 'headers (or headers boring))
5255 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5256 (gnus-article-wash-status-entry 'signature signature)
5257 (gnus-article-wash-status-entry 'overstrike overstrike)
5258 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
5259 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5261 (defun gnus-add-wash-type (type)
5262 "Add a washing of TYPE to the current status."
5263 (add-to-list 'gnus-article-wash-types type))
5265 (defun gnus-delete-wash-type (type)
5266 "Add a washing of TYPE to the current status."
5267 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5269 (defun gnus-add-image (category image)
5270 "Add IMAGE of CATEGORY to the list of displayed images."
5271 (let ((entry (assq category gnus-article-image-alist)))
5273 (setq entry (list category))
5274 (push entry gnus-article-image-alist))
5275 (nconc entry (list image))))
5277 (defun gnus-delete-images (category)
5278 "Delete all images in CATEGORY."
5279 (let ((entry (assq category gnus-article-image-alist)))
5280 (dolist (image (cdr entry))
5281 (gnus-remove-image image category))
5282 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5283 (gnus-delete-wash-type category)))
5285 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5287 (defun gnus-article-maybe-hide-headers ()
5288 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5289 Provided for backwards compatibility."
5290 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5291 (not (with-current-buffer gnus-summary-buffer
5292 gnus-have-all-headers)))
5293 (not gnus-inhibit-hiding))
5294 (gnus-article-hide-headers)))
5298 (defun gnus-output-to-file (file-name)
5299 "Append the current article to a file named FILE-NAME."
5300 (let ((artbuf (current-buffer)))
5302 (insert-buffer-substring artbuf)
5303 ;; Append newline at end of the buffer as separator, and then
5305 (goto-char (point-max))
5307 (let ((file-name-coding-system nnmail-pathname-coding-system))
5308 (write-region-as-binary (point-min) (point-max) file-name 'append))
5311 (defun gnus-narrow-to-page (&optional arg)
5312 "Narrow the article buffer to a page.
5313 If given a numerical ARG, move forward ARG pages."
5315 (setq arg (if arg (prefix-numeric-value arg) 0))
5317 (set-buffer gnus-article-buffer)
5318 (goto-char (point-min))
5320 ;; Remove any old next/prev buttons.
5321 (when (gnus-visual-p 'page-marker)
5322 (let ((buffer-read-only nil))
5323 (gnus-remove-text-with-property 'gnus-prev)
5324 (gnus-remove-text-with-property 'gnus-next)))
5327 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5329 (re-search-forward page-delimiter nil 'move arg)))
5330 (goto-char (match-end 0))
5332 (goto-char (point-min))
5333 (setq gnus-page-broken
5334 (and (re-search-forward page-delimiter nil t) t))))
5335 (when gnus-page-broken
5338 (if (re-search-forward page-delimiter nil 'move)
5341 (when (and (gnus-visual-p 'page-marker)
5342 (not (= (point-min) 1)))
5344 (goto-char (point-min))
5345 (gnus-insert-prev-page-button)))
5346 (when (and (gnus-visual-p 'page-marker)
5347 (< (+ (point-max) 2) (buffer-size)))
5349 (goto-char (point-max))
5350 (gnus-insert-next-page-button))))))
5352 ;; Article mode commands
5354 (defun gnus-article-goto-next-page ()
5355 "Show the next page of the article."
5357 (when (gnus-article-next-page)
5358 (goto-char (point-min))
5359 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5362 (defun gnus-article-goto-prev-page ()
5363 "Show the previous page of the article."
5366 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5367 (gnus-article-prev-page nil)))
5369 ;; This is cleaner but currently breaks `gnus-pick-mode':
5371 ;; (defun gnus-article-goto-next-page ()
5372 ;; "Show the next page of the article."
5374 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5375 ;; (gnus-summary-next-page)))
5377 ;; (defun gnus-article-goto-prev-page ()
5378 ;; "Show the next page of the article."
5380 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5381 ;; (gnus-summary-prev-page)))
5383 (defun gnus-article-next-page (&optional lines)
5384 "Show the next page of the current article.
5385 If end of article, return non-nil. Otherwise return nil.
5386 Argument LINES specifies lines to be scrolled up."
5388 (move-to-window-line -1)
5391 (and (pos-visible-in-window-p) ;Not continuation line.
5392 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5393 ;; Nothing in this page.
5394 (if (or (not gnus-page-broken)
5398 (eobp)))) ;Real end-of-buffer?
5400 (when gnus-article-over-scroll
5401 (gnus-article-next-page-1 lines))
5403 (gnus-narrow-to-page 1) ;Go to next page.
5405 ;; More in this page.
5406 (gnus-article-next-page-1 lines)
5409 (defun gnus-article-next-page-1 (lines)
5410 (let ((scroll-in-place nil))
5414 ;; Long lines may cause an end-of-buffer error.
5415 (goto-char (point-max)))))
5416 (move-to-window-line 0))
5418 (defun gnus-article-prev-page (&optional lines)
5419 "Show previous page of current article.
5420 Argument LINES specifies lines to be scrolled down."
5422 (move-to-window-line 0)
5423 (if (and gnus-page-broken
5425 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5427 (gnus-narrow-to-page -1) ;Go to previous page.
5428 (goto-char (point-max))
5430 (let ((scroll-in-place nil))
5434 (beginning-of-buffer
5435 (goto-char (point-min))))
5436 (move-to-window-line 0)))))
5438 (defun gnus-article-only-boring-p ()
5439 "Decide whether there is only boring text remaining in the article.
5440 Something \"interesting\" is a word of at least two letters that does
5441 not have a face in `gnus-article-boring-faces'."
5442 (when (and gnus-article-skip-boring
5443 (boundp 'gnus-article-boring-faces)
5444 (symbol-value 'gnus-article-boring-faces))
5447 (while (re-search-forward "\\b\\w\\w" nil t)
5449 (when (not (gnus-intersection
5450 (gnus-faces-at (point))
5451 (symbol-value 'gnus-article-boring-faces)))
5452 (throw 'only-boring nil)))
5453 (throw 'only-boring t)))))
5455 (defun gnus-article-refer-article ()
5456 "Read article specified by message-id around point."
5459 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5460 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5461 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5462 (let ((msg-id (concat "<" (match-string 0) ">")))
5463 (set-buffer gnus-summary-buffer)
5464 (gnus-summary-refer-article msg-id))
5465 (error "No references around point"))))
5467 (defun gnus-article-show-summary ()
5468 "Reconfigure windows to show summary buffer."
5470 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5471 (error "There is no summary buffer for this article buffer")
5472 (gnus-article-set-globals)
5473 (gnus-configure-windows 'article)
5474 (gnus-summary-goto-subject gnus-current-article)
5475 (gnus-summary-position-point)))
5477 (defun gnus-article-describe-briefly ()
5478 "Describe article mode commands briefly."
5480 (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")))
5482 (defun gnus-article-summary-command ()
5483 "Execute the last keystroke in the summary buffer."
5485 (let ((obuf (current-buffer))
5486 (owin (current-window-configuration))
5488 (switch-to-buffer gnus-article-current-summary 'norecord)
5489 (setq func (lookup-key (current-local-map) (this-command-keys)))
5490 (call-interactively func)
5492 (set-window-configuration owin)
5493 (set-window-point (get-buffer-window (current-buffer)) (point))))
5495 (defun gnus-article-summary-command-nosave ()
5496 "Execute the last keystroke in the summary buffer."
5499 (pop-to-buffer gnus-article-current-summary 'norecord)
5500 (setq func (lookup-key (current-local-map) (this-command-keys)))
5501 (call-interactively func)))
5503 (defun gnus-article-check-buffer ()
5504 "Beep if not in an article buffer."
5505 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5506 (error "Command invoked outside of a Gnus article buffer")))
5508 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5509 "Read a summary buffer key sequence and execute it from the article buffer."
5511 (gnus-article-check-buffer)
5513 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5514 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5515 "=" "^" "\M-^" "|"))
5521 '("n" "Gn" "p" "Gp"))
5524 (set-buffer gnus-article-current-summary)
5525 (let (gnus-pick-mode)
5526 (push (or key last-command-event) unread-command-events)
5527 (setq keys (static-if (featurep 'xemacs)
5528 (events-to-keys (read-key-sequence nil))
5529 (read-key-sequence nil)))))
5532 (if (or (member keys nosaves)
5533 (member keys nosave-but-article)
5534 (member keys nosave-in-article))
5536 (save-window-excursion
5537 (pop-to-buffer gnus-article-current-summary 'norecord)
5538 ;; We disable the pick minor mode commands.
5539 (let (gnus-pick-mode)
5540 (setq func (lookup-key (current-local-map) keys))))
5544 (unless (member keys nosave-in-article)
5545 (set-buffer gnus-article-current-summary))
5546 (call-interactively func)
5547 (setq new-sum-point (point)))
5548 (when (member keys nosave-but-article)
5549 (pop-to-buffer gnus-article-buffer 'norecord)))
5550 ;; These commands should restore window configuration.
5551 (let ((obuf (current-buffer))
5552 (owin (current-window-configuration))
5554 (summary gnus-article-current-summary)
5555 func in-buffer selected)
5556 (if not-restore-window
5557 (pop-to-buffer summary 'norecord)
5558 (switch-to-buffer summary 'norecord))
5559 (setq in-buffer (current-buffer))
5560 ;; We disable the pick minor mode commands.
5561 (if (and (setq func (let (gnus-pick-mode)
5562 (lookup-key (current-local-map) keys)))
5565 (call-interactively func)
5566 (setq new-sum-point (point))
5567 (when (eq in-buffer (current-buffer))
5568 (setq selected (gnus-summary-select-article))
5570 (unless not-restore-window
5571 (set-window-configuration owin))
5572 (when (eq selected 'old)
5574 (set-window-start (get-buffer-window (current-buffer))
5576 (set-window-point (get-buffer-window (current-buffer))
5578 (let ((win (get-buffer-window gnus-article-current-summary)))
5580 (set-window-point win new-sum-point)))) )
5581 (switch-to-buffer gnus-article-buffer)
5584 (defun gnus-article-describe-key (key)
5585 "Display documentation of the function invoked by KEY. KEY is a string."
5586 (interactive "kDescribe key: ")
5587 (gnus-article-check-buffer)
5588 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5590 (set-buffer gnus-article-current-summary)
5591 (let (gnus-pick-mode)
5592 (if (featurep 'xemacs)
5594 (push (elt key 0) unread-command-events)
5595 (setq key (events-to-keys
5596 (read-key-sequence "Describe key: "))))
5597 (setq unread-command-events
5599 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5601 (setq key (read-key-sequence "Describe key: "))))
5603 (describe-key key)))
5605 (defun gnus-article-describe-key-briefly (key &optional insert)
5606 "Display documentation of the function invoked by KEY. KEY is a string."
5607 (interactive "kDescribe key: \nP")
5608 (gnus-article-check-buffer)
5609 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5611 (set-buffer gnus-article-current-summary)
5612 (let (gnus-pick-mode)
5613 (if (featurep 'xemacs)
5615 (push (elt key 0) unread-command-events)
5616 (setq key (events-to-keys
5617 (read-key-sequence "Describe key: "))))
5618 (setq unread-command-events
5620 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5622 (setq key (read-key-sequence "Describe key: "))))
5623 (describe-key-briefly key insert))
5624 (describe-key-briefly key insert)))
5626 (defun gnus-article-reply-with-original (&optional wide)
5627 "Start composing a reply mail to the current message.
5628 The text in the region will be yanked. If the region isn't active,
5629 the entire article will be yanked."
5631 (let ((article (cdr gnus-article-current))
5633 (if (not (gnus-mark-active-p))
5634 (with-current-buffer gnus-summary-buffer
5635 (gnus-summary-reply (list (list article)) wide))
5636 (setq contents (buffer-substring (point) (mark t)))
5637 ;; Deactivate active regions.
5638 (when (and (boundp 'transient-mark-mode)
5639 transient-mark-mode)
5640 (setq mark-active nil))
5641 (with-current-buffer gnus-summary-buffer
5643 (list (list article contents)) wide)))))
5645 (defun gnus-article-followup-with-original ()
5646 "Compose a followup to the current article.
5647 The text in the region will be yanked. If the region isn't active,
5648 the entire article will be yanked."
5650 (let ((article (cdr gnus-article-current))
5652 (if (not (gnus-mark-active-p))
5653 (with-current-buffer gnus-summary-buffer
5654 (gnus-summary-followup (list (list article))))
5655 (setq contents (buffer-substring (point) (mark t)))
5656 ;; Deactivate active regions.
5657 (when (and (boundp 'transient-mark-mode)
5658 transient-mark-mode)
5659 (setq mark-active nil))
5660 (with-current-buffer gnus-summary-buffer
5661 (gnus-summary-followup
5662 (list (list article contents)))))))
5664 (defun gnus-article-hide (&optional arg force)
5665 "Hide all the gruft in the current article.
5666 This means that signatures, cited text and (some) headers will be
5668 If given a prefix, show the hidden text instead."
5669 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5670 (gnus-article-hide-headers arg)
5671 (gnus-article-hide-list-identifiers arg)
5672 (gnus-article-hide-citation-maybe arg force)
5673 (gnus-article-hide-signature arg))
5675 (defun gnus-article-maybe-highlight ()
5676 "Do some article highlighting if article highlighting is requested."
5677 (when (gnus-visual-p 'article-highlight 'highlight)
5678 (gnus-article-highlight-some)))
5680 (defun gnus-check-group-server ()
5681 ;; Make sure the connection to the server is alive.
5682 (unless (gnus-server-opened
5683 (gnus-find-method-for-group gnus-newsgroup-name))
5684 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5685 (gnus-request-group gnus-newsgroup-name t)))
5688 (autoload 'nneething-get-file-name "nneething"))
5690 (defun gnus-request-article-this-buffer (article group)
5691 "Get an article and insert it into this buffer."
5692 (let (do-update-line sparse-header)
5696 (gnus-kill-all-overlays)
5697 (setq group (or group gnus-newsgroup-name))
5699 ;; Using `gnus-request-article' directly will insert the article into
5700 ;; `nntp-server-buffer' - so we'll save some time by not having to
5701 ;; copy it from the server buffer into the article buffer.
5703 ;; We only request an article by message-id when we do not have the
5704 ;; headers for it, so we'll have to get those.
5705 (when (stringp article)
5706 (gnus-read-header article))
5708 ;; If the article number is negative, that means that this article
5709 ;; doesn't belong in this newsgroup (possibly), so we find its
5710 ;; message-id and request it by id instead of number.
5711 (when (and (numberp article)
5713 (get-buffer gnus-summary-buffer)
5714 (gnus-buffer-exists-p gnus-summary-buffer))
5716 (set-buffer gnus-summary-buffer)
5717 (let ((header (gnus-summary-article-header article)))
5720 ((memq article gnus-newsgroup-sparse)
5721 ;; This is a sparse gap article.
5722 (setq do-update-line article)
5723 (setq article (mail-header-id header))
5724 (setq sparse-header (gnus-read-header article))
5725 (setq gnus-newsgroup-sparse
5726 (delq article gnus-newsgroup-sparse)))
5728 ;; It's a real article.
5729 (setq article (mail-header-id header)))
5731 ;; It is an extracted pseudo-article.
5732 (setq article 'pseudo)
5733 (gnus-request-pseudo-article header))))
5735 (let ((method (gnus-find-method-for-group
5736 gnus-newsgroup-name)))
5737 (when (and (eq (car method) 'nneething)
5739 (let ((dir (nneething-get-file-name
5740 (mail-header-id header))))
5741 (when (and (stringp dir)
5742 (file-directory-p dir))
5743 (setq article 'nneething)
5744 (gnus-group-enter-directory dir))))))))
5747 ;; Refuse to select canceled articles.
5748 ((and (numberp article)
5750 (get-buffer gnus-summary-buffer)
5751 (gnus-buffer-exists-p gnus-summary-buffer)
5752 (eq (cdr (with-current-buffer gnus-summary-buffer
5753 (assq article gnus-newsgroup-reads)))
5754 gnus-canceled-mark))
5756 ;; We first check `gnus-original-article-buffer'.
5757 ((and (get-buffer gnus-original-article-buffer)
5759 (with-current-buffer gnus-original-article-buffer
5760 (and (equal (car gnus-original-article) group)
5761 (eq (cdr gnus-original-article) article))))
5762 (insert-buffer-substring gnus-original-article-buffer)
5764 ;; Check the backlog.
5765 ((and gnus-keep-backlog
5766 (gnus-backlog-request-article group article (current-buffer)))
5768 ;; Check asynchronous pre-fetch.
5769 ((gnus-async-request-fetched-article group article (current-buffer))
5770 (gnus-async-prefetch-next group article gnus-summary-buffer)
5771 (when (and (numberp article) gnus-keep-backlog)
5772 (gnus-backlog-enter-article group article (current-buffer)))
5775 ((and gnus-use-cache
5777 (gnus-cache-request-article article group))
5779 ;; Check the agent cache.
5780 ((gnus-agent-request-article article group)
5782 ;; Get the article and put into the article buffer.
5783 ((or (stringp article)
5785 (let ((gnus-override-method gnus-override-method)
5786 (methods (and (stringp article)
5787 gnus-refer-article-method))
5788 (backend (car (gnus-find-method-for-group
5789 gnus-newsgroup-name)))
5791 (buffer-read-only nil))
5792 (if (or (not (listp methods))
5793 (and (symbolp (car methods))
5794 (assq (car methods) nnoo-definition-alist)))
5795 (setq methods (list methods)))
5796 (when (and (null gnus-override-method)
5798 (setq gnus-override-method (pop methods)))
5800 (when (eq gnus-override-method 'current)
5801 (setq gnus-override-method
5802 (with-current-buffer gnus-summary-buffer
5803 gnus-current-select-method)))
5805 (gnus-kill-all-overlays)
5806 (let ((gnus-newsgroup-name group))
5807 (gnus-check-group-server))
5809 ((gnus-request-article article group (current-buffer))
5810 (when (numberp article)
5811 (gnus-async-prefetch-next group article
5812 gnus-summary-buffer)
5813 (when gnus-keep-backlog
5814 (gnus-backlog-enter-article
5815 group article (current-buffer))))
5816 (setq result 'article))
5818 (setq gnus-override-method (pop methods)))
5819 ((not (string-match "^400 "
5820 (nnheader-get-report backend)))
5821 ;; If we get 400 server disconnect, reconnect and
5822 ;; retry; otherwise, assume the article has expired.
5823 (setq result 'done))))
5824 (and (eq result 'article) 'article)))
5828 ;; Associate this article with the current summary buffer.
5829 (setq gnus-article-current-summary gnus-summary-buffer)
5831 ;; Take the article from the original article buffer
5832 ;; and place it in the buffer it's supposed to be in.
5833 (when (and (get-buffer gnus-article-buffer)
5834 (equal (buffer-name (current-buffer))
5835 (buffer-name (get-buffer gnus-article-buffer))))
5837 (if (get-buffer gnus-original-article-buffer)
5838 (set-buffer gnus-original-article-buffer)
5839 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5840 (buffer-disable-undo)
5841 (setq major-mode 'gnus-original-article-mode)
5842 (setq buffer-read-only t))
5843 (let (buffer-read-only)
5845 (insert-buffer-substring gnus-article-buffer))
5846 (setq gnus-original-article (cons group article)))
5849 (run-hooks 'gnus-article-decode-hook)
5850 ;; Mark article as decoded or not.
5851 (setq gnus-article-decoded-p gnus-article-decode-hook))
5853 ;; Update sparse articles.
5854 (when (and do-update-line
5855 (or (numberp article)
5857 (let ((buf (current-buffer)))
5858 (set-buffer gnus-summary-buffer)
5859 (gnus-summary-update-article do-update-line sparse-header)
5860 (gnus-summary-goto-subject do-update-line nil t)
5861 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5863 (set-buffer buf))))))
5869 (defcustom gnus-article-edit-mode-hook nil
5870 "Hook run in article edit mode buffers."
5871 :group 'gnus-article-various
5874 (defcustom gnus-article-edit-article-setup-function
5875 'gnus-article-mime-edit-article-setup
5876 "Function called to setup an editing article buffer."
5877 :group 'gnus-article-various
5880 (defvar gnus-article-edit-done-function nil)
5882 (defvar gnus-article-edit-mode-map nil)
5884 ;; Should we be using derived.el for this?
5885 (unless gnus-article-edit-mode-map
5886 (setq gnus-article-edit-mode-map (make-keymap))
5887 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5889 (gnus-define-keys gnus-article-edit-mode-map
5890 "\C-c?" describe-mode
5891 "\C-c\C-c" gnus-article-edit-done
5892 "\C-c\C-k" gnus-article-edit-exit
5893 "\C-c\C-f\C-t" message-goto-to
5894 "\C-c\C-f\C-o" message-goto-from
5895 "\C-c\C-f\C-b" message-goto-bcc
5896 ;;"\C-c\C-f\C-w" message-goto-fcc
5897 "\C-c\C-f\C-c" message-goto-cc
5898 "\C-c\C-f\C-s" message-goto-subject
5899 "\C-c\C-f\C-r" message-goto-reply-to
5900 "\C-c\C-f\C-n" message-goto-newsgroups
5901 "\C-c\C-f\C-d" message-goto-distribution
5902 "\C-c\C-f\C-f" message-goto-followup-to
5903 "\C-c\C-f\C-m" message-goto-mail-followup-to
5904 "\C-c\C-f\C-k" message-goto-keywords
5905 "\C-c\C-f\C-u" message-goto-summary
5906 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5907 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5908 "\C-c\C-b" message-goto-body
5909 "\C-c\C-i" message-goto-signature
5911 "\C-c\C-t" message-insert-to
5912 "\C-c\C-n" message-insert-newsgroups
5913 "\C-c\C-o" message-sort-headers
5914 "\C-c\C-e" message-elide-region
5915 "\C-c\C-v" message-delete-not-region
5916 "\C-c\C-z" message-kill-to-signature
5917 "\M-\r" message-newline-and-reformat
5918 "\C-c\C-a" mml-attach-file
5919 "\C-a" message-beginning-of-line
5921 "\M-;" comment-region)
5923 (gnus-define-keys (gnus-article-edit-wash-map
5924 "\C-c\C-w" gnus-article-edit-mode-map)
5925 "f" gnus-article-edit-full-stops))
5928 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5930 ["Fetch To" message-insert-to t]
5931 ["Fetch Newsgroups" message-insert-newsgroups t]
5933 ["To" message-goto-to t]
5934 ["From" message-goto-from t]
5935 ["Subject" message-goto-subject t]
5936 ["Cc" message-goto-cc t]
5937 ["Reply-To" message-goto-reply-to t]
5938 ["Summary" message-goto-summary t]
5939 ["Keywords" message-goto-keywords t]
5940 ["Newsgroups" message-goto-newsgroups t]
5941 ["Followup-To" message-goto-followup-to t]
5942 ["Mail-Followup-To" message-goto-mail-followup-to t]
5943 ["Distribution" message-goto-distribution t]
5944 ["Body" message-goto-body t]
5945 ["Signature" message-goto-signature t]))
5947 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5948 "Major mode for editing articles.
5949 This is an extended text-mode.
5951 \\{gnus-article-edit-mode-map}"
5952 (make-local-variable 'gnus-article-edit-done-function)
5953 (make-local-variable 'gnus-prev-winconf)
5954 (set (make-local-variable 'font-lock-defaults)
5955 '(message-font-lock-keywords t))
5956 (set (make-local-variable 'mail-header-separator) "")
5957 (set (make-local-variable 'gnus-article-edit-mode) t)
5958 (easy-menu-add message-mode-field-menu message-mode-map)
5959 (setq buffer-read-only nil)
5960 (buffer-enable-undo)
5963 (defun gnus-article-edit (&optional force)
5964 "Edit the current article.
5965 This will have permanent effect only in mail groups.
5966 If FORCE is non-nil, allow editing of articles even in read-only
5969 (when (and (not force)
5970 (gnus-group-read-only-p))
5971 (error "The current newsgroup does not support article editing"))
5972 (gnus-article-date-original)
5973 (gnus-article-edit-article
5975 `(lambda (no-highlight)
5977 (gnus-summary-edit-article-done
5978 ,(or (mail-header-references gnus-current-headers) "")
5979 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5981 (defun gnus-article-edit-article (start-func exit-func)
5982 "Start editing the contents of the current article buffer."
5983 (let ((winconf (current-window-configuration)))
5984 (set-buffer gnus-article-buffer)
5985 (gnus-article-edit-mode)
5986 (funcall start-func)
5987 (set-buffer-modified-p nil)
5988 (gnus-configure-windows 'edit-article)
5989 (setq gnus-article-edit-done-function exit-func)
5990 (setq gnus-prev-winconf winconf)
5991 (when gnus-article-edit-article-setup-function
5992 (funcall gnus-article-edit-article-setup-function))
5993 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit")))
5995 (defun gnus-article-edit-done (&optional arg)
5996 "Update the article edits and exit."
5998 (let ((func gnus-article-edit-done-function)
5999 (buf (current-buffer))
6000 (start (window-start))
6002 (winconf gnus-prev-winconf))
6003 (remove-hook 'gnus-article-mode-hook
6004 'gnus-article-mime-edit-article-unwind)
6005 (widen) ;; Widen it in case that users narrowed the buffer.
6008 ;; The cache and backlog have to be flushed somewhat.
6009 (when gnus-keep-backlog
6010 (gnus-backlog-remove-article
6011 (car gnus-article-current) (cdr gnus-article-current)))
6012 ;; Flush original article as well.
6014 (when (get-buffer gnus-original-article-buffer)
6015 (set-buffer gnus-original-article-buffer)
6016 (setq gnus-original-article nil)))
6017 (when gnus-use-cache
6018 (gnus-cache-update-article
6019 (car gnus-article-current) (cdr gnus-article-current)))
6020 ;; We remove all text props from the article buffer.
6021 (kill-all-local-variables)
6022 (set-text-properties (point-min) (point-max) nil)
6024 (set-window-configuration winconf)
6026 (set-window-start (get-buffer-window buf) start)
6027 (set-window-point (get-buffer-window buf) (point)))
6028 (gnus-summary-show-article))
6030 (defun gnus-article-edit-exit ()
6031 "Exit the article editing without updating."
6033 (when (or (not (buffer-modified-p))
6034 (yes-or-no-p "Article modified; kill anyway? "))
6035 (let ((curbuf (current-buffer))
6037 (window-start (window-start)))
6039 (if (gnus-buffer-live-p gnus-original-article-buffer)
6040 (insert-buffer-substring gnus-original-article-buffer))
6041 (let ((winconf gnus-prev-winconf))
6042 (kill-all-local-variables)
6044 (set-window-configuration winconf)
6045 ;; Tippy-toe some to make sure that point remains where it was.
6046 (save-current-buffer
6048 (set-window-start (get-buffer-window (current-buffer)) window-start)
6050 (gnus-summary-show-article)))
6052 (defun gnus-article-edit-full-stops ()
6053 "Interactively repair spacing at end of sentences."
6056 (goto-char (point-min))
6057 (search-forward-regexp "^$" nil t)
6058 (let ((case-fold-search nil))
6059 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
6062 ;;; Article editing with MIME-Edit
6065 (defcustom gnus-article-mime-edit-article-setup-hook nil
6066 "Hook run after setting up a MIME editing article buffer."
6067 :group 'gnus-article-various
6070 (defun gnus-article-mime-edit-article-unwind ()
6071 "Unwind `gnus-article-buffer' if article editing was given up."
6072 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6073 (when (featurep 'font-lock)
6074 (setq font-lock-defaults nil)
6075 (font-lock-mode -1))
6076 (when mime-edit-mode-flag
6077 (mime-edit-exit 'nomime 'no-error)
6080 (defun gnus-article-mime-edit-article-setup ()
6081 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
6082 after replacing with the original article."
6083 (setq gnus-show-mime t)
6084 (setq gnus-article-edit-done-function
6085 `(lambda (&rest args)
6086 (when mime-edit-mode-flag
6087 (let (mime-edit-insert-user-agent-field)
6090 (goto-char (point-min))
6091 (let (case-fold-search)
6092 (when (re-search-forward
6093 (format "^%s$" (regexp-quote mail-header-separator))
6095 (replace-match "")))
6096 (apply ,gnus-article-edit-done-function args)
6099 (buffer-substring-no-properties (point-min) (point-max))
6100 (set-buffer (get-buffer-create gnus-original-article-buffer))
6102 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6103 (set-buffer gnus-article-buffer)
6104 (gnus-article-prepare-display)))
6105 (substitute-key-definition 'gnus-article-edit-done
6106 'gnus-article-mime-edit-done
6107 gnus-article-edit-mode-map)
6108 (substitute-key-definition 'gnus-article-edit-exit
6109 'gnus-article-mime-edit-exit
6110 gnus-article-edit-mode-map)
6112 (insert-buffer-substring gnus-original-article-buffer)
6113 (unless (member (with-current-buffer gnus-summary-buffer
6114 gnus-newsgroup-name)
6115 '("nndraft:delayed" "nndraft:drafts"))
6116 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
6117 (fset 'mime-edit-decode-single-part-in-buffer
6118 (lambda (&rest args)
6119 (if (let ((content-type (car args)))
6120 (and (eq 'message (mime-content-type-primary-type
6122 (eq 'rfc822 (mime-content-type-subtype
6124 (setcar (cdr args) 'not-decode-text))
6128 (fset 'mime-edit-decode-single-part-in-buffer ofn))))
6129 (when (featurep 'font-lock)
6130 (set (make-local-variable 'font-lock-defaults)
6131 '(message-font-lock-keywords t))
6132 (font-lock-set-defaults)
6133 (turn-on-font-lock))
6134 (set-buffer-modified-p nil)
6135 (delete-other-windows)
6136 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6137 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
6139 (defun gnus-article-mime-edit-done (&optional arg)
6140 "Update the article MIME edits and exit."
6142 (when (featurep 'font-lock)
6143 (setq font-lock-defaults nil)
6144 (font-lock-mode -1))
6145 (let ((inhibit-read-only t))
6146 (gnus-article-edit-done arg)))
6148 (defun gnus-article-mime-edit-exit ()
6149 "Exit the article MIME editing without updating."
6151 (when (or (not (buffer-modified-p))
6152 (yes-or-no-p "Article modified; kill anyway? "))
6153 (when (featurep 'font-lock)
6154 (setq font-lock-defaults nil)
6155 (font-lock-mode -1))
6156 (when mime-edit-mode-flag
6157 (let (mime-edit-insert-user-agent-field)
6160 (goto-char (point-min))
6161 (let (case-fold-search)
6162 (when (re-search-forward
6163 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
6164 (replace-match "")))
6165 (let ((winconf gnus-prev-winconf))
6167 (buffer-substring-no-properties (point-min) (point-max))
6168 (set-buffer (get-buffer-create gnus-original-article-buffer))
6170 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6171 (set-buffer gnus-article-buffer)
6172 (gnus-article-prepare-display)
6173 (set-window-configuration winconf))))
6176 ;;; Article highlights
6179 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6181 ;;; Internal Variables:
6183 (defcustom gnus-button-url-regexp
6184 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
6185 "\\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:]]\\)"
6186 "\\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\\)\\)")
6187 "Regular expression that matches URLs."
6188 :group 'gnus-article-buttons
6191 (defcustom gnus-button-valid-fqdn-regexp
6192 message-valid-fqdn-regexp
6193 "Regular expression that matches a valid FQDN."
6194 :group 'gnus-article-buttons
6197 (defcustom gnus-button-man-handler 'manual-entry
6198 "Function to use for displaying man pages.
6199 The function must take at least one argument with a string naming the
6201 :type '(choice (function-item :tag "Man" manual-entry)
6202 (function-item :tag "Woman" woman)
6203 (function :tag "Other"))
6204 :group 'gnus-article-buttons)
6206 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6207 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6208 If the default site is too slow, try to find a CTAN mirror, see
6209 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6210 the variable `gnus-button-handle-ctan'."
6211 :group 'gnus-article-buttons
6212 :link '(custom-manual "(gnus)Group Parameters")
6213 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6214 (const "http://tug.ctan.org/tex-archive/")
6215 (const "http://www.dante.de/CTAN/")
6216 (string :tag "Other")))
6218 (defcustom gnus-button-ctan-handler 'browse-url
6219 "Function to use for displaying CTAN links.
6220 The function must take one argument, the string naming the URL."
6221 :type '(choice (function-item :tag "Browse Url" browse-url)
6222 (function :tag "Other"))
6223 :group 'gnus-article-buttons)
6225 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6226 "Bogus strings removed from CTAN URLs."
6227 :group 'gnus-article-buttons
6228 :type '(choice (const "^/?tex-archive/\\|/")
6229 (regexp :tag "Other")))
6231 (defcustom gnus-button-ctan-directory-regexp
6234 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
6235 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
6236 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
6238 "Regular expression for ctan directories.
6239 It should match all directories in the top level of `gnus-ctan-url'."
6240 :group 'gnus-article-buttons
6243 (defcustom gnus-button-mid-or-mail-regexp
6244 (concat "\\b\\(<?[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*@"
6245 ;; Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
6246 gnus-button-valid-fqdn-regexp
6248 "Regular expression that matches a message ID or a mail address."
6249 :group 'gnus-article-buttons
6252 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6253 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6254 Strings like this can be either a message ID or a mail address. If it is one
6255 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6256 message ID or a mail address, respectively. If this variable is set to the
6257 symbol `ask', always query the user what do do. If it is a function, this
6258 function will be called with the string as it's only argument. The function
6259 must return `mid', `mail', `invalid' or `ask'."
6260 :group 'gnus-article-buttons
6261 :type '(choice (function-item :tag "Heuristic function"
6262 gnus-button-mid-or-mail-heuristic)
6267 (defcustom gnus-button-mid-or-mail-heuristic-alist
6268 '((-10.0 . ".+\\$.+@")
6271 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6272 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6273 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6274 (-1.0 . "^[^a-z]+@")
6276 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6277 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6278 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6279 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6282 (-1.0 . "^[0-9][0-9]")
6284 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6285 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6286 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6287 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6289 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6290 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6293 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6295 ;; compensation for TDMA dated mail addresses:
6296 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6298 (-20.0 . "\\.fsf@") ;; Gnus
6301 (-20.0 . "_-_") ;; Subject change in thread
6303 (-20.0 . "\\.ln@") ;; leafnode
6304 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6305 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6307 ;; (5.0 . "") ;; $local_part_len <= 7
6308 (10.0 . "^[^0-9]+@")
6309 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6310 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6313 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6315 (0.5 . "^[A-Z][a-z]")
6316 (0.5 . "^[A-Z][a-z][a-z]")
6317 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6318 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6319 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6321 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6322 address. The REGEXP is processed with `case-fold-search' set to nil."
6323 :group 'gnus-article-buttons
6324 :type '(repeat (cons (number :tag "Rate")
6325 (regexp :tag "Regexp"))))
6327 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6328 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6329 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6330 address, `ask' if unsure and `invalid' if the string is invalid."
6331 (let ((case-fold-search nil)
6332 (list gnus-button-mid-or-mail-heuristic-alist)
6333 (result 0) rate regexp lpartlen elem)
6335 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6336 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6337 ;; Certain special cases...
6340 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6341 "^[0-9]+\\.[0-9]+@compuserve\\|"
6342 "@public\\.gmane\\.org")
6344 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6345 (setq result 'mail))
6346 (when (string-match "@.*@\\| " mid-or-mail)
6347 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6348 (setq result 'invalid))
6349 ;; Nothing more to do, if result is not a number here...
6350 (when (numberp result)
6352 (setq elem (car list)
6356 (when (string-match regexp mid-or-mail)
6357 (setq result (+ result rate))
6359 9 "`%s' matched `%s', rate `%s', result `%s'."
6360 mid-or-mail regexp rate result)))
6361 (when (<= lpartlen 7)
6362 (setq result (+ result 5.0))
6363 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6364 mid-or-mail result))
6365 (when (>= lpartlen 12)
6366 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6368 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6369 ;; Long local part should contain realname if e-mail address,
6370 ;; too many digits: message-id.
6371 ;; $score -= 5.0 + 0.1 * $local_part_len;
6372 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6373 (setq result (+ result rate))
6375 9 "Many digits in `%s', rate `%s', result `%s'."
6376 mid-or-mail rate result))
6377 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6379 ;; Too few vowels [^aeiouy]{4,}.*\@
6380 (setq result (+ result -5.0))
6382 9 "Few vowels in `%s', rate `%s', result `%s'."
6383 mid-or-mail -5.0 result))
6385 (setq result (+ result 5.0))
6387 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6388 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6389 ;; Maybe we should make this a customizable alist: (condition . 'result)
6391 ((symbolp result) result)
6392 ;; Now convert number into proper results:
6393 ((< result -10.0) 'mid)
6394 ((> result 10.0) 'mail)
6397 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6398 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6399 (url-mid (concat "news" ":" mid-or-mail))
6400 (url-mailto (concat "mailto" ":" mid-or-mail)))
6401 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6402 (when (fboundp pref)
6404 ;; get rid of surrounding angles...
6406 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6407 (if (or (eq 'mid guessed) (eq 'mail guessed))
6411 (save-window-excursion
6412 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6415 (cond ((eq pref 'mid)
6416 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6417 (gnus-button-handle-news url-mid))
6419 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6420 (gnus-url-mailto url-mailto))
6421 (t (gnus-message 3 "Invalid string.")))))
6423 (defun gnus-button-handle-custom (url)
6424 "Follow a Custom URL."
6425 (customize-apropos (gnus-url-unhex-string url)))
6427 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6429 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6432 (defun gnus-button-handle-describe-function (url)
6433 "Call `describe-function' when pushing the corresponding URL button."
6436 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6438 (defun gnus-button-handle-describe-variable (url)
6439 "Call `describe-variable' when pushing the corresponding URL button."
6442 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6444 (defun gnus-button-handle-symbol (url)
6445 "Display help on variable or function.
6446 Calls `describe-variable' or `describe-function'."
6447 (let ((sym (intern url)))
6449 ((fboundp sym) (describe-function sym))
6450 ((boundp sym) (describe-variable sym))
6451 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6453 (defun gnus-button-handle-describe-key (url)
6454 "Call `describe-key' when pushing the corresponding URL button."
6456 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6457 (keys (ignore-errors (eval `(kbd ,key-string)))))
6460 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6462 (defun gnus-button-handle-apropos (url)
6463 "Call `apropos' when pushing the corresponding URL button."
6464 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6466 (defun gnus-button-handle-apropos-command (url)
6467 "Call `apropos' when pushing the corresponding URL button."
6469 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6471 (defun gnus-button-handle-apropos-variable (url)
6472 "Call `apropos' when pushing the corresponding URL button."
6474 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6475 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6477 (defun gnus-button-handle-apropos-documentation (url)
6478 "Call `apropos' when pushing the corresponding URL button."
6480 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6481 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6483 (defun gnus-button-handle-library (url)
6484 "Call `locate-library' when pushing the corresponding URL button."
6485 (gnus-message 9 "url=`%s'" url)
6486 (let* ((lib (locate-library url))
6487 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6489 (gnus-message 1 "Cannot locale library `%s'." url)
6490 (find-file-read-only file))))
6492 (defun gnus-button-handle-ctan (url)
6493 "Call `browse-url' when pushing a CTAN URL button."
6495 gnus-button-ctan-handler
6498 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6500 (defcustom gnus-button-tex-level 5
6501 "*Integer that says how many TeX-related buttons Gnus will show.
6502 The higher the number, the more buttons will appear and the more false
6503 positives are possible. Note that you can set this variable local to
6504 specific groups. Setting it higher in TeX groups is probably a good idea.
6505 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6506 how to set variables in specific groups."
6507 :group 'gnus-article-buttons
6508 :link '(custom-manual "(gnus)Group Parameters")
6511 (defcustom gnus-button-man-level 5
6512 "*Integer that says how many man-related buttons Gnus will show.
6513 The higher the number, the more buttons will appear and the more false
6514 positives are possible. Note that you can set this variable local to
6515 specific groups. Setting it higher in Unix groups is probably a good idea.
6516 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6517 how to set variables in specific groups."
6518 :group 'gnus-article-buttons
6519 :link '(custom-manual "(gnus)Group Parameters")
6522 (defcustom gnus-button-emacs-level 5
6523 "*Integer that says how many emacs-related buttons Gnus will show.
6524 The higher the number, the more buttons will appear and the more false
6525 positives are possible. Note that you can set this variable local to
6526 specific groups. Setting it higher in Emacs or Gnus related groups is
6527 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6528 `gnus-parameters' on how to set variables in specific groups."
6529 :group 'gnus-article-buttons
6530 :link '(custom-manual "(gnus)Group Parameters")
6533 (defcustom gnus-button-message-level 5
6534 "*Integer that says how many buttons for news or mail messages will appear.
6535 The higher the number, the more buttons will appear and the more false
6536 positives are possible."
6537 ;; mail addresses, MIDs, URLs for news, ...
6538 :group 'gnus-article-buttons
6541 (defcustom gnus-button-browse-level 5
6542 "*Integer that says how many buttons for browsing will appear.
6543 The higher the number, the more buttons will appear and the more false
6544 positives are possible."
6545 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6546 :group 'gnus-article-buttons
6549 (defcustom gnus-button-alist
6550 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6551 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6552 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6553 gnus-button-handle-news 2)
6554 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6555 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6556 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6557 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6558 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6559 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6560 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6561 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6562 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6563 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6564 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6565 ;; RFC 2368 (The mailto URL scheme)
6566 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6567 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6568 ("\\bmailto:\\([^ \n\t]+\\)"
6569 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6571 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6572 gnus-button-ctan-directory-regexp
6573 "[^][>)!;:,'\n\t ]+\\)")
6574 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6575 ((concat "\\btex-archive/\\("
6576 gnus-button-ctan-directory-regexp
6577 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6578 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6581 gnus-button-ctan-directory-regexp
6582 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6583 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6584 ;; This is info (home-grown style) <info://foo/bar+baz>
6585 ("\\binfo://\\([^'\">\n\t ]+\\)"
6586 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6587 ;; Info GNOME style <info:foo#bar_baz>
6588 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6589 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6590 ;; Info KDE style <info:(foo)bar baz>
6591 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6592 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6593 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6594 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6595 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6596 ;; Info links like `C-h i d m CC Mode RET'
6597 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6599 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6600 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6601 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6602 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6603 ;; Emacs help commands
6604 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6605 ;; regexp doesn't match arguments containing ` '.
6606 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6607 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6608 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6609 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6610 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6611 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6612 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6613 ;; The following entries may lead to many false positives so don't enable
6614 ;; them by default (use a high button level):
6615 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>"
6616 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6617 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6618 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6619 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6620 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6621 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6622 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6623 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6624 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6625 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6626 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6627 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6628 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6629 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6630 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6631 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6632 ;; Unlike the other regexps we really have to require quoting
6633 ;; here to determine where it ends.
6634 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6635 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6636 ("<URL: *\\([^<>]*\\)>"
6637 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6638 ;; RFC 2396 (2.4.3., delims) ...
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)
6645 (gnus-button-url-regexp
6646 0 (>= gnus-button-browse-level 0) browse-url 0)
6648 ("\\b\\([a-z][a-z]+\\)([1-9])\\W"
6649 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6650 gnus-button-handle-man 1)
6651 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6652 ("\\b\\([a-z][-_.a-z0-9]+\\)([1-9])\\W"
6653 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6654 gnus-button-handle-man 1)
6655 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6656 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6657 ("\\b\\([a-z][-+_.:a-z0-9]+\\)([1-9][X1a-z]*)\\W\\|\\b\\(X\\)([1-9])\\W"
6658 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6659 ;; MID or mail: To avoid too many false positives we don't try to catch
6660 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6661 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6662 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6663 ;; so that non-ambiguous entries (see above) match first.
6664 (gnus-button-mid-or-mail-regexp
6665 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6666 "*Alist of regexps matching buttons in article bodies.
6668 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6669 REGEXP: is the string (case insensitive) matching text around the button (can
6670 also be Lisp expression evaluating to a string),
6671 BUTTON: is the number of the regexp grouping actually matching the button,
6672 FORM: is a Lisp expression which must eval to true for the button to
6674 CALLBACK: is the function to call when the user push this button, and each
6675 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6677 CALLBACK can also be a variable, in that case the value of that
6678 variable it the real callback function."
6679 :group 'gnus-article-buttons
6680 :type '(repeat (list (choice regexp variable sexp)
6681 (integer :tag "Button")
6683 (function :tag "Callback")
6686 (integer :tag "Regexp group")))))
6688 (defcustom gnus-header-button-alist
6689 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6690 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6691 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6692 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6693 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6694 0 (>= gnus-button-message-level 0) gnus-button-mailto 0)
6695 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6696 0 (>= gnus-button-browse-level 0) browse-url 0)
6697 ("^Subject:" gnus-button-url-regexp
6698 0 (>= gnus-button-browse-level 0) browse-url 0)
6699 ("^[^:]+:" gnus-button-url-regexp
6700 0 (>= gnus-button-browse-level 0) browse-url 0)
6701 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6702 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6703 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6704 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6705 "*Alist of headers and regexps to match buttons in article heads.
6707 This alist is very similar to `gnus-button-alist', except that each
6708 alist has an additional HEADER element first in each entry:
6710 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6712 HEADER is a regexp to match a header. For a fuller explanation, see
6713 `gnus-button-alist'."
6714 :group 'gnus-article-buttons
6715 :group 'gnus-article-headers
6716 :type '(repeat (list (regexp :tag "Header")
6717 (choice regexp variable)
6718 (integer :tag "Button")
6720 (function :tag "Callback")
6723 (integer :tag "Regexp group")))))
6727 (defun gnus-article-push-button (event)
6728 "Check text under the mouse pointer for a callback function.
6729 If the text under the mouse pointer has a `gnus-callback' property,
6730 call it with the value of the `gnus-data' text property."
6732 (set-buffer (window-buffer (posn-window (event-start event))))
6733 (let* ((pos (posn-point (event-start event)))
6734 (data (get-text-property pos 'gnus-data))
6735 (fun (get-text-property pos 'gnus-callback)))
6738 (funcall fun data))))
6740 (defun gnus-article-press-button ()
6741 "Check text at point for a callback function.
6742 If the text at point has a `gnus-callback' property,
6743 call it with the value of the `gnus-data' text property."
6745 (let ((data (get-text-property (point) 'gnus-data))
6746 (fun (get-text-property (point) 'gnus-callback)))
6748 (funcall fun data))))
6750 (defun gnus-article-prev-button (n)
6751 "Move point to N buttons backward.
6752 If N is negative, move forward instead."
6754 (gnus-article-next-button (- n)))
6756 (defun gnus-article-next-button (n)
6757 "Move point to N buttons forward.
6758 If N is negative, move backward instead."
6760 (let ((function (if (< n 0) 'previous-single-property-change
6761 'next-single-property-change))
6762 (inhibit-point-motion-hooks t)
6764 (limit (if (< n 0) (point-min) (point-max))))
6766 (while (and (not (= limit (point)))
6768 ;; Skip past the current button.
6769 (when (get-text-property (point) 'gnus-callback)
6770 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6771 ;; Go to the next (or previous) button.
6772 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
6773 ;; Put point at the start of the button.
6774 (when (and backward (not (get-text-property (point) 'gnus-callback)))
6775 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6776 ;; Skip past intangible buttons.
6777 (when (get-text-property (point) 'intangible)
6781 (gnus-message 5 "No more buttons"))
6784 (defun gnus-article-highlight (&optional force)
6785 "Highlight current article.
6786 This function calls `gnus-article-highlight-headers',
6787 `gnus-article-highlight-citation',
6788 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6789 do the highlighting. See the documentation for those functions."
6790 (interactive (list 'force))
6791 (gnus-article-highlight-headers)
6792 (gnus-article-highlight-citation force)
6793 (gnus-article-highlight-signature)
6794 (gnus-article-add-buttons force)
6795 (gnus-article-add-buttons-to-head))
6797 (defun gnus-article-highlight-some (&optional force)
6798 "Highlight current article.
6799 This function calls `gnus-article-highlight-headers',
6800 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6801 do the highlighting. See the documentation for those functions."
6802 (interactive (list 'force))
6803 (gnus-article-highlight-headers)
6804 (gnus-article-highlight-signature)
6805 (gnus-article-add-buttons))
6807 (defun gnus-article-highlight-headers ()
6808 "Highlight article headers as specified by `gnus-header-face-alist'."
6810 (gnus-with-article-headers
6811 (let ((alist gnus-header-face-alist)
6812 entry regexp header-face field-face from hpoints fpoints)
6813 (while (setq entry (pop alist))
6814 (goto-char (point-min))
6815 (setq regexp (concat "^\\("
6816 (if (string-equal "" (nth 0 entry))
6820 header-face (nth 1 entry)
6821 field-face (nth 2 entry))
6822 (while (and (re-search-forward regexp nil t)
6826 (unless (search-forward ":" nil t)
6828 (when (and header-face
6829 (not (memq (point) hpoints)))
6830 (push (point) hpoints)
6831 (gnus-put-text-property from (point) 'face header-face))
6832 (when (and field-face
6833 (not (memq (setq from (point)) fpoints)))
6835 (if (re-search-forward "^[^ \t]" nil t)
6837 (goto-char (point-max)))
6838 (gnus-put-text-property from (point) 'face field-face)))))))
6840 (defun gnus-article-highlight-signature ()
6841 "Highlight the signature in an article.
6842 It does this by highlighting everything after
6843 `gnus-signature-separator' using `gnus-signature-face'."
6845 (when gnus-signature-face
6846 (gnus-with-article-buffer
6847 (let ((inhibit-point-motion-hooks t))
6849 (when (gnus-article-narrow-to-signature)
6850 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6851 'face gnus-signature-face)))))))
6853 (defun gnus-article-buttonize-signature ()
6854 "Add button to the signature."
6857 (set-buffer gnus-article-buffer)
6858 (let ((buffer-read-only nil)
6859 (inhibit-point-motion-hooks t))
6860 (when (gnus-article-search-signature)
6861 (gnus-article-add-button (match-beginning 0) (match-end 0)
6862 'gnus-signature-toggle
6863 (set-marker (make-marker)
6864 (1+ (match-end 0))))))))
6866 (defun gnus-button-in-region-p (b e prop)
6867 "Say whether PROP exists in the region."
6868 (text-property-not-all b e prop nil))
6870 (defun gnus-article-add-buttons (&optional force)
6871 "Find external references in the article and make buttons of them.
6872 \"External references\" are things like Message-IDs and URLs, as
6873 specified by `gnus-button-alist'."
6874 (interactive (list 'force))
6875 (gnus-with-article-buffer
6876 (let ((inhibit-point-motion-hooks t)
6877 (case-fold-search t)
6878 (alist gnus-button-alist)
6880 ;; Remove all old markers.
6881 (let (marker entry new-list)
6882 (while (setq marker (pop gnus-button-marker-list))
6883 (if (or (< marker (point-min)) (>= marker (point-max)))
6884 (push marker new-list)
6886 (when (setq entry (gnus-button-entry))
6887 (put-text-property (match-beginning (nth 1 entry))
6888 (match-end (nth 1 entry))
6889 'gnus-callback nil))
6890 (set-marker marker nil)))
6891 (setq gnus-button-marker-list new-list))
6892 ;; We skip the headers.
6895 (while (setq entry (pop alist))
6896 (setq regexp (eval (car entry)))
6898 (while (re-search-forward regexp nil t)
6899 (let* ((start (and entry (match-beginning (nth 1 entry))))
6900 (end (and entry (match-end (nth 1 entry))))
6901 (from (match-beginning 0)))
6902 (when (and (or (eq t (nth 2 entry))
6903 (eval (nth 2 entry)))
6904 (not (gnus-button-in-region-p
6905 start end 'gnus-callback)))
6906 ;; That optional form returned non-nil, so we add the
6908 (gnus-article-add-button
6909 start end 'gnus-button-push
6910 (car (push (set-marker (make-marker) from)
6911 gnus-button-marker-list))))))))))
6913 ;; Add buttons to the head of an article.
6914 (defun gnus-article-add-buttons-to-head ()
6915 "Add buttons to the head of the article."
6917 (gnus-with-article-headers
6918 (let ((alist gnus-header-button-alist)
6921 ;; Each alist entry.
6922 (setq entry (pop alist))
6923 (goto-char (point-min))
6924 (while (re-search-forward (car entry) nil t)
6925 ;; Each header matching the entry.
6926 (setq beg (match-beginning 0))
6927 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6928 (match-beginning 0))
6931 (while (re-search-forward (eval (nth 1 entry)) end t)
6932 ;; Each match within a header.
6933 (let* ((entry (cdr entry))
6934 (start (match-beginning (nth 1 entry)))
6935 (end (match-end (nth 1 entry)))
6936 (form (nth 2 entry)))
6937 (goto-char (match-end 0))
6939 (gnus-article-add-button
6940 start end (nth 3 entry)
6941 (buffer-substring (match-beginning (nth 4 entry))
6942 (match-end (nth 4 entry)))))))
6943 (goto-char end))))))
6945 ;;; External functions:
6947 (defun gnus-article-add-button (from to fun &optional data)
6948 "Create a button between FROM and TO with callback FUN and data DATA."
6949 (when gnus-article-button-face
6950 (gnus-overlay-put (gnus-make-overlay from to)
6951 'face gnus-article-button-face))
6952 (gnus-add-text-properties
6954 (nconc (and gnus-article-mouse-face
6955 (list gnus-mouse-face-prop gnus-article-mouse-face))
6956 (list 'gnus-callback fun)
6957 (and data (list 'gnus-data data))))
6958 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6959 :button-keymap gnus-widget-button-keymap))
6961 ;;; Internal functions:
6963 (defun gnus-article-set-globals ()
6964 (with-current-buffer gnus-summary-buffer
6965 (gnus-set-global-variables)))
6967 (defun gnus-signature-toggle (end)
6968 (gnus-with-article-buffer
6969 (let ((inhibit-point-motion-hooks t)
6970 (limit (next-single-property-change end 'mime-view-entity
6972 (if (text-property-any end limit 'article-type 'signature)
6974 (gnus-delete-wash-type 'signature)
6975 (gnus-remove-text-properties-when
6976 'article-type 'signature end limit
6977 (cons 'article-type (cons 'signature
6978 gnus-hidden-properties))))
6979 (gnus-add-wash-type 'signature)
6980 (gnus-add-text-properties-when
6981 'article-type nil end limit
6982 (cons 'article-type (cons 'signature
6983 gnus-hidden-properties)))))
6984 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6985 (gnus-set-mode-line 'article))))
6987 (defun gnus-button-entry ()
6988 ;; Return the first entry in `gnus-button-alist' matching this place.
6989 (let ((alist gnus-button-alist)
6992 (setq entry (pop alist))
6993 (if (looking-at (eval (car entry)))
6998 (defun gnus-button-push (marker)
6999 ;; Push button starting at MARKER.
7002 (let* ((entry (gnus-button-entry))
7003 (inhibit-point-motion-hooks t)
7005 (args (mapcar (lambda (group)
7006 (let ((string (match-string group)))
7007 (set-text-properties
7008 0 (length string) nil string)
7015 (fboundp (symbol-value fun)))
7016 (apply (symbol-value fun) args))
7018 (gnus-message 1 "You must define `%S' to use this button"
7019 (cons fun args)))))))
7021 (defun gnus-parse-news-url (url)
7022 (let (scheme server group message-id articles)
7025 (goto-char (point-min))
7026 (when (looking-at "\\([A-Za-z]+\\):")
7027 (setq scheme (match-string 1))
7028 (goto-char (match-end 0)))
7029 (when (looking-at "//\\([^/]+\\)/")
7030 (setq server (match-string 1))
7031 (goto-char (match-end 0)))
7034 ((looking-at "\\(.*@.*\\)")
7035 (setq message-id (match-string 1)))
7036 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7037 (setq group (match-string 1)
7038 articles (split-string (match-string 2) "-")))
7039 ((looking-at "\\([^/]+\\)/?")
7040 (setq group (match-string 1)))
7042 (error "Unknown news URL syntax"))))
7043 (list scheme server group message-id articles)))
7045 (defun gnus-button-handle-news (url)
7047 (destructuring-bind (scheme server group message-id articles)
7048 (gnus-parse-news-url url)
7052 (set-buffer gnus-summary-buffer)
7054 (let ((gnus-refer-article-method (list (list 'nntp server))))
7055 (gnus-summary-refer-article message-id))
7056 (gnus-summary-refer-article message-id))))
7058 (gnus-button-fetch-group url)))))
7060 (defun gnus-button-handle-man (url)
7062 (funcall gnus-button-man-handler url))
7064 (defun gnus-button-handle-info-url (url)
7065 "Fetch an info URL."
7066 (setq url (mm-subst-char-in-string ?+ ?\ url))
7068 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
7069 (gnus-info-find-node
7070 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
7072 ")" (gnus-url-unhex-string (match-string 2 url)))))
7073 ((string-match "([^)\"]+)[^\"]+" url)
7075 (gnus-replace-in-string
7076 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
7077 (gnus-info-find-node url))
7078 (t (error "Can't parse %s" url))))
7080 (defun gnus-button-handle-info-url-gnome (url)
7081 "Fetch GNOME style info URL."
7082 (setq url (mm-subst-char-in-string ?_ ?\ url))
7083 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
7084 (gnus-info-find-node
7086 (gnus-url-unhex-string
7087 (match-string 1 url))
7089 (or (gnus-url-unhex-string
7090 (match-string 2 url))
7092 (error "Can't parse %s" url)))
7094 (defun gnus-button-handle-info-url-kde (url)
7095 "Fetch KDE style info URL."
7096 (gnus-info-find-node (gnus-url-unhex-string url)))
7098 (defun gnus-button-handle-info-keystrokes (url)
7099 "Call `info' when pushing the corresponding URL button."
7100 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
7105 (defun gnus-button-message-id (message-id)
7107 (with-current-buffer gnus-summary-buffer
7108 (gnus-summary-refer-article message-id)))
7110 (defun gnus-button-fetch-group (address)
7111 "Fetch GROUP specified by ADDRESS."
7112 (if (not (string-match "[:/]" address))
7113 ;; This is just a simple group url.
7114 (gnus-group-read-ephemeral-group address gnus-select-method)
7117 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
7119 (error "Can't parse %s" address)
7120 (gnus-group-read-ephemeral-group
7121 (match-string 4 address)
7122 `(nntp ,(match-string 1 address)
7123 (nntp-address ,(match-string 1 address))
7124 (nntp-port-number ,(if (match-end 3)
7125 (match-string 3 address)
7128 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
7130 (defun gnus-url-parse-query-string (query &optional downcase)
7131 (let (retval pairs cur key val)
7132 (setq pairs (split-string query "&"))
7134 (setq cur (car pairs)
7136 (if (not (string-match "=" cur))
7138 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
7139 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
7141 (setq key (downcase key)))
7142 (setq cur (assoc key retval))
7144 (setcdr cur (cons val (cdr cur)))
7145 (setq retval (cons (list key val) retval)))))
7148 (defun gnus-url-mailto (url)
7149 ;; Send mail to someone
7150 (when (string-match "mailto:/*\\(.*\\)" url)
7151 (setq url (substring url (match-beginning 1) nil)))
7152 (let (to args subject func)
7153 (setq args (gnus-url-parse-query-string
7154 (if (string-match "^\\?" url)
7156 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
7157 (concat "to=" (match-string 1 url) "&"
7158 (match-string 2 url))
7159 (concat "to=" url)))
7161 subject (cdr-safe (assoc "subject" args)))
7164 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
7167 (message-position-on-field (caar args)))
7168 (insert (gnus-replace-in-string
7169 (mapconcat 'identity (reverse (cdar args)) ", ")
7171 (setq args (cdr args)))
7174 (message-goto-subject))))
7176 (defun gnus-button-embedded-url (address)
7177 "Activate ADDRESS with `browse-url'."
7178 (browse-url (gnus-strip-whitespace address)))
7180 ;;; Next/prev buttons in the article buffer.
7182 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
7183 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
7185 (defvar gnus-prev-page-map
7186 (let ((map (make-sparse-keymap)))
7187 (define-key map gnus-mouse-2 'gnus-button-prev-page)
7188 (define-key map "\r" 'gnus-button-prev-page)
7191 (defvar gnus-next-page-map
7192 (let ((map (make-sparse-keymap)))
7193 (define-key map gnus-mouse-2 'gnus-button-next-page)
7194 (define-key map "\r" 'gnus-button-next-page)
7197 (defun gnus-insert-prev-page-button ()
7199 (buffer-read-only nil)
7200 (situation (get-text-property (point-min) 'mime-view-situation)))
7202 gnus-prev-page-line-format nil
7203 `(keymap ,gnus-prev-page-map
7205 gnus-callback gnus-article-button-prev-page
7206 article-type annotation
7207 mime-view-situation ,situation))
7208 (widget-convert-button
7210 ;; Exclude a newline.
7213 :action 'gnus-button-prev-page
7214 :button-keymap gnus-prev-page-map)))
7216 (defun gnus-button-next-page (&optional args more-args)
7217 "Go to the next page."
7219 (let ((win (selected-window)))
7220 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7221 (gnus-article-next-page)
7222 (select-window win)))
7224 (defun gnus-button-prev-page (&optional args more-args)
7225 "Go to the prev page."
7227 (let ((win (selected-window)))
7228 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7229 (gnus-article-prev-page)
7230 (select-window win)))
7232 (defun gnus-insert-next-page-button ()
7234 (buffer-read-only nil)
7235 (situation (get-text-property (point-min) 'mime-view-situation)))
7236 (gnus-eval-format gnus-next-page-line-format nil
7237 `(keymap ,gnus-next-page-map
7239 gnus-callback gnus-article-button-next-page
7240 article-type annotation
7241 mime-view-situation ,situation))
7242 (widget-convert-button
7244 ;; Exclude a newline.
7247 :action 'gnus-button-next-page
7248 :button-keymap gnus-next-page-map)))
7250 (defun gnus-article-button-next-page (arg)
7251 "Go to the next page."
7253 (let ((win (selected-window)))
7254 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7255 (gnus-article-next-page)
7256 (select-window win)))
7258 (defun gnus-article-button-prev-page (arg)
7259 "Go to the prev page."
7261 (let ((win (selected-window)))
7262 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7263 (gnus-article-prev-page)
7264 (select-window win)))
7266 (defvar gnus-decode-header-methods
7267 '(mail-decode-encoded-word-region)
7268 "List of methods used to decode headers.
7270 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7271 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
7272 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
7273 whose names match REGEXP.
7276 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7277 mail-decode-encoded-word-region
7278 (\"chinese\" . rfc1843-decode-region))
7281 (defvar gnus-decode-header-methods-cache nil)
7283 (defun gnus-multi-decode-header (start end)
7284 "Apply the functions from `gnus-encoded-word-methods' that match."
7285 (unless (and gnus-decode-header-methods-cache
7286 (eq gnus-newsgroup-name
7287 (car gnus-decode-header-methods-cache)))
7288 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7291 (nconc gnus-decode-header-methods-cache (list x))
7292 (if (and gnus-newsgroup-name
7293 (string-match (car x) gnus-newsgroup-name))
7294 (nconc gnus-decode-header-methods-cache
7296 gnus-decode-header-methods))
7297 (let ((xlist gnus-decode-header-methods-cache))
7300 (narrow-to-region start end)
7302 (funcall (pop xlist) (point-min) (point-max))))))
7305 ;;; Treatment top-level handling.
7308 (defun gnus-treat-article (condition &optional part-number total-parts type)
7309 (let ((length (- (point-max) (point-min)))
7310 (alist gnus-treatment-function-alist)
7311 (article-goto-body-goes-to-point-min-p t)
7315 (let ((list gnus-article-treat-types))
7317 (when (string-match (pop list) type)
7318 (throw 'found t)))))))
7319 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7320 (entity (static-unless (featurep 'xemacs)
7321 (when (eq 'head condition)
7322 (get-text-property (point-min) 'mime-view-entity))))
7323 val elem buttonized)
7324 (gnus-run-hooks 'gnus-part-display-hook)
7325 (unless gnus-inhibit-treatment
7326 (dolist (elem alist)
7329 (when (gnus-buffer-live-p gnus-summary-buffer)
7330 (set-buffer gnus-summary-buffer))
7331 (symbol-value (car elem))))
7332 (when (and (or (consp val)
7334 (gnus-treat-predicate val)
7335 (or (not (get (car elem) 'highlight))
7337 (when (and (not buttonized)
7339 '(gnus-treat-hide-signature
7340 gnus-treat-highlight-signature)))
7341 (gnus-article-buttonize-signature)
7342 (setq buttonized t))
7344 (funcall (cadr elem)))))
7345 ;; FSF Emacsen does not inherit the existing text properties
7346 ;; in the new text, so we should do it for `mime-view-entity'.
7347 (static-unless (featurep 'xemacs)
7349 (put-text-property (point-min) (point-max)
7350 'mime-view-entity entity))))))
7352 ;; Dynamic variables.
7354 (defvar part-number)
7355 (defvar total-parts)
7360 (defun gnus-treat-predicate (val)
7365 (stringp (car val)))
7366 (apply 'gnus-or (mapcar `(lambda (s)
7367 (string-match s ,(or gnus-newsgroup-name "")))
7370 (let ((pred (pop val)))
7373 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7375 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7377 (not (gnus-treat-predicate (car val))))
7379 (equal (car val) type))
7381 (error "%S is not a valid predicate" pred)))))
7391 (eq part-number total-parts))
7395 (error "%S is not a valid value" val))))
7397 (defun gnus-article-encrypt-body (protocol &optional n)
7398 "Encrypt the article body."
7401 (or gnus-article-encrypt-protocol
7402 (completing-read "Encrypt protocol: "
7403 gnus-article-encrypt-protocol-alist
7405 current-prefix-arg))
7406 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7408 (error (format "Can't find the encrypt protocol %s" protocol)))
7409 (if (member gnus-newsgroup-name '("nndraft:delayed"
7412 (error "Can't encrypt the article in group %s"
7413 gnus-newsgroup-name))
7414 (gnus-summary-iterate n
7416 (set-buffer gnus-summary-buffer)
7417 (let ((mail-parse-charset gnus-newsgroup-charset)
7418 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7419 (summary-buffer gnus-summary-buffer)
7421 (gnus-set-global-variables)
7422 (when (gnus-group-read-only-p)
7423 (error "The current newsgroup does not support article encrypt"))
7424 (gnus-summary-show-article t)
7426 (or (mail-header-references gnus-current-headers) ""))
7427 (set-buffer gnus-article-buffer)
7428 (let* ((buffer-read-only nil)
7430 (mapcar (lambda (field)
7431 (and (save-restriction
7432 (message-narrow-to-head)
7433 (goto-char (point-min))
7434 (search-forward field nil t))
7436 (message-narrow-to-field)
7438 (delete-region (point-min) (point-max))
7440 '("Content-Type:" "Content-Transfer-Encoding:"
7441 "Content-Disposition:"))))
7442 (message-narrow-to-head)
7443 (message-remove-header "MIME-Version")
7444 (goto-char (point-max))
7445 (setq point (point))
7446 (insert (apply 'concat headers))
7448 (narrow-to-region point (point-max))
7449 (let ((message-options message-options))
7450 (message-options-set 'message-sender user-mail-address)
7451 (message-options-set 'message-recipients user-mail-address)
7452 (message-options-set 'message-sign-encrypt 'not)
7454 (goto-char (point-min))
7455 (insert "MIME-Version: 1.0\n")
7457 (gnus-summary-edit-article-done
7458 references nil summary-buffer t))
7459 (when gnus-keep-backlog
7460 (gnus-backlog-remove-article
7461 (car gnus-article-current) (cdr gnus-article-current)))
7463 (when (get-buffer gnus-original-article-buffer)
7464 (set-buffer gnus-original-article-buffer)
7465 (setq gnus-original-article nil)))
7466 (when gnus-use-cache
7467 (gnus-cache-update-article
7468 (car gnus-article-current) (cdr gnus-article-current))))))))
7470 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7471 "The following specs can be used:
7472 %t The security MIME type
7475 %D Details if button is pressed")
7477 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%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-line-format-alist
7485 '((?t gnus-tmp-type ?s)
7486 (?i gnus-tmp-info ?s)
7487 (?d gnus-tmp-details ?s)
7488 (?D gnus-tmp-pressed-details ?s)))
7490 (defvar gnus-mime-security-button-map
7491 (let ((map (make-sparse-keymap)))
7492 (define-key map gnus-mouse-2 'gnus-article-push-button)
7493 (define-key map "\r" 'gnus-article-press-button)
7496 (defvar gnus-mime-security-details-buffer nil)
7498 (defvar gnus-mime-security-button-pressed nil)
7500 (defvar gnus-mime-security-show-details-inline t
7501 "If non-nil, show details in the article buffer.")
7503 (defun gnus-mime-security-verify-or-decrypt (handle)
7504 (mm-remove-parts (cdr handle))
7505 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7506 point buffer-read-only)
7508 (goto-char (car region)))
7510 (narrow-to-region (point) (point))
7511 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7512 (let* ((mm-verify-option 'known)
7513 (mm-decrypt-option 'known)
7514 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7515 (unless (eq nparts (cdr handle))
7516 (mm-destroy-parts (cdr handle))
7517 (setcdr handle nparts))))
7518 (setq point (point))
7519 (gnus-mime-display-security handle)
7520 (goto-char (point-max)))
7522 (delete-region (point) (cdr region))
7523 (set-marker (car region) nil)
7524 (set-marker (cdr region) nil))
7527 (defun gnus-mime-security-show-details (handle)
7528 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7530 (gnus-message 5 "No details.")
7531 (if gnus-mime-security-show-details-inline
7532 (let ((gnus-mime-security-button-pressed
7533 (not (get-text-property (point) 'gnus-mime-details)))
7534 (gnus-mime-security-button-line-format
7535 (get-text-property (point) 'gnus-line-format))
7538 (while (eq (get-text-property (point) 'gnus-line-format)
7539 gnus-mime-security-button-line-format)
7543 (narrow-to-region (point) (point))
7544 (gnus-insert-mime-security-button handle))
7545 (delete-region (point)
7546 (or (text-property-not-all
7549 gnus-mime-security-button-line-format)
7552 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7553 (with-current-buffer gnus-mime-security-details-buffer
7556 (setq gnus-mime-security-details-buffer
7557 (gnus-get-buffer-create "*MIME Security Details*")))
7558 (with-current-buffer gnus-mime-security-details-buffer
7560 (goto-char (point-min)))
7561 (pop-to-buffer gnus-mime-security-details-buffer)))))
7563 (defun gnus-mime-security-press-button (handle)
7565 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7566 (gnus-mime-security-show-details handle)
7567 (gnus-mime-security-verify-or-decrypt handle))))
7569 (defun gnus-insert-mime-security-button (handle &optional displayed)
7570 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7573 (or (nth 2 (assoc protocol mm-verify-function-alist))
7574 (nth 2 (assoc protocol mm-decrypt-function-alist))
7576 (if (equal (car handle) "multipart/signed")
7577 " Signed" " Encrypted")
7580 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7583 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7584 gnus-tmp-pressed-details
7586 (setq gnus-tmp-details
7587 (if gnus-tmp-details
7588 (concat "\n" gnus-tmp-details)
7590 (setq gnus-tmp-pressed-details
7591 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7596 gnus-mime-security-button-line-format
7597 gnus-mime-security-button-line-format-alist
7598 `(keymap ,gnus-mime-security-button-map
7599 gnus-callback gnus-mime-security-press-button
7600 gnus-line-format ,gnus-mime-security-button-line-format
7601 gnus-mime-details ,gnus-mime-security-button-pressed
7602 article-type annotation
7605 ;; Exclude a newline.
7608 (widget-convert-button
7611 :action 'gnus-widget-press-button
7612 :button-keymap gnus-mime-security-button-map
7614 (lambda (widget/window &optional overlay pos)
7615 ;; Needed to properly clear the message due to a bug in
7616 ;; wid-edit (XEmacs only).
7617 (when (boundp 'help-echo-owns-message)
7618 (setq help-echo-owns-message t))
7621 (aref gnus-mouse-2 0))))))
7623 (defun gnus-mime-display-security (handle)
7625 (narrow-to-region (point) (point))
7626 (unless (gnus-unbuttonized-mime-type-p (car handle))
7627 (gnus-insert-mime-security-button handle))
7628 (gnus-mime-display-mixed (cdr handle))
7631 (unless (gnus-unbuttonized-mime-type-p (car handle))
7632 (let ((gnus-mime-security-button-line-format
7633 gnus-mime-security-button-end-line-format))
7634 (gnus-insert-mime-security-button handle)))
7635 (mm-set-handle-multipart-parameter
7637 (cons (set-marker (make-marker) (point-min))
7638 (set-marker (make-marker) (point-max))))))
7644 (defun gnus-article-header-presentation-method (entity situation)
7645 (mime-insert-header entity)
7646 (article-decode-group-name))
7648 (set-alist 'mime-header-presentation-method-alist
7649 'gnus-original-article-mode
7650 #'gnus-article-header-presentation-method)
7652 (defun gnus-mime-preview-quitting-method ()
7653 (mime-preview-kill-buffer)
7654 (delete-other-windows)
7655 (gnus-article-show-summary)
7656 (gnus-summary-select-article gnus-show-all-headers t))
7658 (set-alist 'mime-preview-quitting-method-alist
7659 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
7661 (set-alist 'mime-preview-following-method-alist
7662 'gnus-original-article-mode #'gnus-following-method)
7664 (set-alist 'mime-preview-over-to-previous-method-alist
7665 'gnus-original-article-mode
7667 (if (> (point-min) 1)
7668 (gnus-article-prev-page)
7669 (gnus-article-read-summary-keys
7670 nil (gnus-character-to-event ?P)))))
7672 (set-alist 'mime-preview-over-to-next-method-alist
7673 'gnus-original-article-mode'
7675 (if (< (point-max) (buffer-size))
7676 (gnus-article-next-page)
7677 (gnus-article-read-summary-keys
7678 nil (gnus-character-to-event ?N)))))
7688 (run-hooks 'gnus-art-load-hook)
7690 ;;; gnus-art.el ends here