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))))))
4324 (defsubst gnus-article-edit-part (handles)
4325 "Edit an article in order to delete a mime part.
4326 This function is exclusively used by `gnus-mime-save-part-and-strip'
4327 and `gnus-mime-delete-part', and not provided at run-time normally."
4328 (gnus-article-edit-article
4331 (let ((mail-parse-charset (or gnus-article-charset
4332 ',gnus-newsgroup-charset))
4333 (mail-parse-ignored-charsets
4334 (or gnus-article-ignored-charsets
4335 ',gnus-newsgroup-ignored-charsets))
4336 (mbl mml-buffer-list))
4337 (setq mml-buffer-list nil)
4338 (insert-buffer gnus-original-article-buffer)
4339 (mime-to-mml ',handles)
4340 (setq gnus-article-mime-handles nil)
4341 (let ((mbl1 mml-buffer-list))
4342 (setq mml-buffer-list mbl)
4343 (set (make-local-variable 'mml-buffer-list) mbl1))
4344 (gnus-make-local-hook 'kill-buffer-hook)
4345 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4346 `(lambda (no-highlight)
4347 (let ((mail-parse-charset (or gnus-article-charset
4348 ',gnus-newsgroup-charset))
4349 (message-options message-options)
4350 (message-options-set-recipient)
4351 (mail-parse-ignored-charsets
4352 (or gnus-article-ignored-charsets
4353 ',gnus-newsgroup-ignored-charsets)))
4355 (mml-destroy-buffers)
4356 (remove-hook 'kill-buffer-hook
4357 'mml-destroy-buffers t)
4358 (kill-local-variable 'mml-buffer-list))
4359 (gnus-summary-edit-article-done
4360 ,(or (mail-header-references gnus-current-headers) "")
4361 ,(gnus-group-read-only-p)
4362 ,gnus-summary-buffer no-highlight)))
4363 (gnus-article-edit-done)
4364 (gnus-summary-expand-window)
4365 (gnus-summary-show-article)))
4367 (defun gnus-mime-save-part-and-strip ()
4368 "Save the MIME part under point then replace it with an external body."
4370 (gnus-article-check-buffer)
4371 (when (gnus-group-read-only-p)
4372 (error "The current group does not support deleting of parts"))
4373 (when (mm-complicated-handles gnus-article-mime-handles)
4375 The current article has a complicated MIME structure, giving up..."))
4376 (when (gnus-yes-or-no-p "\
4377 Deleting parts may malfunction or destroy the article; continue? ")
4378 (let* ((data (get-text-property (point) 'gnus-data))
4380 (handles gnus-article-mime-handles))
4381 (setq file (and data (mm-save-part data)))
4383 (with-current-buffer (mm-handle-buffer data)
4385 (insert "Content-Type: " (mm-handle-media-type data))
4386 (mml-insert-parameter-string (cdr (mm-handle-type data))
4389 (insert "Content-ID: " (message-make-message-id) "\n")
4390 (insert "Content-Transfer-Encoding: binary\n")
4393 (cdr (mm-make-handle nil
4394 `("message/external-body"
4395 (access-type . "LOCAL-FILE")
4397 (set-buffer gnus-summary-buffer)
4398 (gnus-article-edit-part handles)))))
4400 (defun gnus-mime-delete-part ()
4401 "Delete the MIME part under point.
4402 Replace it with some information about the removed part."
4404 (gnus-article-check-buffer)
4405 (when (gnus-group-read-only-p)
4406 (error "The current group does not support deleting of parts"))
4407 (when (mm-complicated-handles gnus-article-mime-handles)
4409 The current article has a complicated MIME structure, giving up..."))
4410 (when (gnus-yes-or-no-p "\
4411 Deleting parts may malfunction or destroy the article; continue? ")
4412 (let* ((data (get-text-property (point) 'gnus-data))
4413 (handles gnus-article-mime-handles)
4417 (mail-decode-encoded-word-string (or (mm-handle-description data)
4420 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4422 (type (mm-handle-media-type data)))
4423 (with-current-buffer (mm-handle-buffer data)
4424 (let ((bsize (format "%s" (buffer-size))))
4429 "| The following attachment has been deleted:\n"
4431 "| Type: " type "\n"
4432 "| Filename: " filename "\n"
4433 "| Size (encoded): " bsize " Byte\n"
4434 "| Description: " description "\n"
4437 (cdr (mm-make-handle
4438 nil `("text/plain") nil nil
4440 (format "Deleted attachment (%s bytes)" bsize))))))
4441 (set-buffer gnus-summary-buffer)
4442 (gnus-article-edit-part handles))))
4444 (defun gnus-mime-save-part ()
4445 "Save the MIME part under point."
4447 (gnus-article-check-buffer)
4448 (let ((data (get-text-property (point) 'gnus-data)))
4450 (mm-save-part data))))
4452 (defun gnus-mime-pipe-part ()
4453 "Pipe the MIME part under point to a process."
4455 (gnus-article-check-buffer)
4456 (let ((data (get-text-property (point) 'gnus-data)))
4458 (mm-pipe-part data))))
4460 (defun gnus-mime-view-part ()
4461 "Interactively choose a viewing method for the MIME part under point."
4463 (gnus-article-check-buffer)
4464 (let ((data (get-text-property (point) 'gnus-data)))
4466 (setq gnus-article-mime-handles
4468 gnus-article-mime-handles (setq data (copy-sequence data))))
4469 (mm-interactively-view-part data))))
4471 (defun gnus-mime-view-part-as-type-internal ()
4472 (gnus-article-check-buffer)
4473 (let* ((name (mail-content-type-get
4474 (mm-handle-type (get-text-property (point) 'gnus-data))
4476 (def-type (and name (mm-default-file-encoding name))))
4477 (and def-type (cons def-type 0))))
4479 (defun gnus-mime-view-part-as-type (&optional mime-type)
4480 "Choose a MIME media type, and view the part as such."
4483 (setq mime-type (completing-read
4484 "View as MIME type: "
4485 (mapcar #'list (mailcap-mime-types))
4487 (gnus-mime-view-part-as-type-internal))))
4488 (gnus-article-check-buffer)
4489 (let ((handle (get-text-property (point) 'gnus-data)))
4492 (mm-make-handle (mm-handle-buffer handle)
4493 (cons mime-type (cdr (mm-handle-type handle)))
4494 (mm-handle-encoding handle)
4495 (mm-handle-undisplayer handle)
4496 (mm-handle-disposition handle)
4497 (mm-handle-description handle)
4499 (mm-handle-id handle)))
4500 (setq gnus-article-mime-handles
4501 (mm-merge-handles gnus-article-mime-handles handle))
4502 (gnus-mm-display-part handle))))
4505 (require 'jka-compr))
4507 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4508 ;; emacs can do that itself.
4510 (defun gnus-mime-jka-compr-maybe-uncompress ()
4511 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4512 The uncompress method used is derived from `buffer-file-name'."
4513 (when (and (fboundp 'jka-compr-installed-p)
4514 (jka-compr-installed-p))
4515 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4517 (let ((basename (file-name-nondirectory buffer-file-name))
4518 (args (jka-compr-info-uncompress-args info))
4519 (prog (jka-compr-info-uncompress-program info))
4520 (message (jka-compr-info-uncompress-message info))
4521 (err-file (jka-compr-make-temp-name)))
4523 (message "%s %s..." message basename))
4525 (unless (memq (apply 'call-process-region
4526 (point-min) (point-max)
4528 t (list t err-file) nil
4530 jka-compr-acceptable-retval-list)
4531 (jka-compr-error prog args basename message err-file))
4532 (jka-compr-delete-temp-file err-file)))))))
4534 (defun gnus-mime-copy-part (&optional handle)
4535 "Put the MIME part under point into a new buffer.
4536 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4539 (gnus-article-check-buffer)
4540 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4541 (contents (and handle (mm-get-part handle)))
4543 (file-name-nondirectory
4545 (mail-content-type-get (mm-handle-type handle) 'name)
4546 (mail-content-type-get (mm-handle-disposition handle)
4549 (buffer (and base (generate-new-buffer base))))
4551 (switch-to-buffer buffer)
4553 ;; We do it this way to make `normal-mode' set the appropriate mode.
4556 (setq buffer-file-name (expand-file-name base))
4557 (gnus-mime-jka-compr-maybe-uncompress)
4559 (setq buffer-file-name nil))
4560 (goto-char (point-min)))))
4562 (defun gnus-mime-print-part (&optional handle filename)
4563 "Print the MIME part under point."
4564 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4565 (gnus-article-check-buffer)
4566 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4567 (contents (and handle (mm-get-part handle)))
4568 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4569 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4574 (mm-save-part-to-file handle file)
4575 (call-process shell-file-name nil
4576 (generate-new-buffer " *mm*")
4578 shell-command-switch
4580 printer file (mm-handle-type handle))))
4584 (gnus-print-buffer))
4585 (ps-despool filename)))))
4587 (defun gnus-mime-inline-part (&optional handle arg)
4588 "Insert the MIME part under point into the current buffer."
4589 (interactive (list nil current-prefix-arg))
4590 (gnus-article-check-buffer)
4591 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4596 (if (and (not arg) (mm-handle-undisplayer handle))
4597 (mm-remove-part handle)
4598 (setq contents (mm-get-part handle))
4601 (setq charset (or (mail-content-type-get
4602 (mm-handle-type handle) 'charset)
4603 gnus-newsgroup-charset)))
4605 (if (mm-handle-undisplayer handle)
4606 (mm-remove-part handle))
4609 gnus-summary-show-article-charset-alist))
4610 (mm-read-coding-system "Charset: ")))))
4612 (mm-insert-inline handle
4614 (setq charset (mm-charset-to-coding-system
4616 (not (eq charset 'ascii)))
4617 (mm-decode-coding-string contents charset)
4621 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4622 "Insert the MIME part under point into the current buffer using the
4624 (interactive (list nil current-prefix-arg))
4625 (gnus-article-check-buffer)
4626 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4631 (if (mm-handle-undisplayer handle)
4632 (mm-remove-part handle))
4633 (let ((gnus-newsgroup-charset
4635 gnus-summary-show-article-charset-alist))
4636 (mm-read-coding-system "Charset: ")))
4637 (gnus-newsgroup-ignored-charsets 'gnus-all))
4638 (gnus-article-press-button)))))
4640 (defun gnus-mime-view-part-externally (&optional handle)
4641 "View the MIME part under point with an external viewer."
4643 (gnus-article-check-buffer)
4644 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4645 (mm-user-display-methods nil)
4646 (mm-inlined-types nil)
4647 (mail-parse-charset gnus-newsgroup-charset)
4648 (mail-parse-ignored-charsets
4649 (with-current-buffer gnus-summary-buffer
4650 gnus-newsgroup-ignored-charsets)))
4652 (if (mm-handle-undisplayer handle)
4653 (mm-remove-part handle)
4654 (mm-display-part handle)))))
4656 (defun gnus-mime-view-part-internally (&optional handle)
4657 "View the MIME part under point with an internal viewer.
4658 If no internal viewer is available, use an external viewer."
4660 (gnus-article-check-buffer)
4661 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4662 (mm-inlined-types '(".*"))
4663 (mm-inline-large-images t)
4664 (mail-parse-charset gnus-newsgroup-charset)
4665 (mail-parse-ignored-charsets
4666 (with-current-buffer gnus-summary-buffer
4667 gnus-newsgroup-ignored-charsets))
4670 (if (mm-handle-undisplayer handle)
4671 (mm-remove-part handle)
4672 (mm-display-part handle)))))
4674 (defun gnus-mime-action-on-part (&optional action)
4675 "Do something with the MIME attachment at \(point\)."
4677 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4678 (gnus-article-check-buffer)
4679 (let ((action-pair (assoc action gnus-mime-action-alist)))
4681 (funcall (cdr action-pair)))))
4683 (defun gnus-article-part-wrapper (n function)
4684 (with-current-buffer gnus-article-buffer
4685 (when (> n (length gnus-article-mime-handle-alist))
4686 (error "No such part"))
4687 (gnus-article-goto-part n)
4688 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4689 (funcall function handle))))
4691 (defun gnus-article-pipe-part (n)
4692 "Pipe MIME part N, which is the numerical prefix."
4694 (gnus-article-part-wrapper n 'mm-pipe-part))
4696 (defun gnus-article-save-part (n)
4697 "Save MIME part N, which is the numerical prefix."
4699 (gnus-article-part-wrapper n 'mm-save-part))
4701 (defun gnus-article-interactively-view-part (n)
4702 "View MIME part N interactively, which is the numerical prefix."
4704 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4706 (defun gnus-article-copy-part (n)
4707 "Copy MIME part N, which is the numerical prefix."
4709 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4711 (defun gnus-article-view-part-as-charset (n)
4712 "View MIME part N using a specified charset.
4713 N is the numerical prefix."
4715 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4717 (defun gnus-article-view-part-externally (n)
4718 "View MIME part N externally, which is the numerical prefix."
4720 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4722 (defun gnus-article-inline-part (n)
4723 "Inline MIME part N, which is the numerical prefix."
4725 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4727 (defun gnus-article-mime-match-handle-first (condition)
4729 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4730 (while (setq ihandle (pop alist))
4732 ((functionp condition)
4733 (funcall condition (cdr ihandle)))
4734 ((eq condition 'undisplayed)
4735 (not (or (mm-handle-undisplayer (cdr ihandle))
4736 (equal (mm-handle-media-type (cdr ihandle))
4737 "multipart/alternative"))))
4738 ((eq condition 'undisplayed-alternative)
4739 (not (mm-handle-undisplayer (cdr ihandle))))
4741 (gnus-article-goto-part (car ihandle))
4742 (or (not n) (< (car ihandle) n)))
4743 (setq n (car ihandle))))
4747 (defun gnus-article-view-part (&optional n)
4748 "View MIME part N, which is the numerical prefix."
4750 (with-current-buffer gnus-article-buffer
4751 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4752 gnus-article-mime-match-handle-function)))
4753 (when (> n (length gnus-article-mime-handle-alist))
4754 (error "No such part"))
4755 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4756 (when (gnus-article-goto-part n)
4757 (if (equal (car handle) "multipart/alternative")
4758 (gnus-article-press-button)
4759 (when (eq (gnus-mm-display-part handle) 'internal)
4760 (gnus-set-window-start)))))))
4762 (defsubst gnus-article-mime-total-parts ()
4763 (if (bufferp (car gnus-article-mime-handles))
4765 (1- (length gnus-article-mime-handles))))
4767 (defun gnus-mm-display-part (handle)
4768 "Display HANDLE and fix MIME button."
4769 (let ((id (get-text-property (point) 'gnus-part))
4774 (let ((window (selected-window))
4775 (mail-parse-charset gnus-newsgroup-charset)
4776 (mail-parse-ignored-charsets
4777 (if (gnus-buffer-live-p gnus-summary-buffer)
4778 (with-current-buffer gnus-summary-buffer
4779 gnus-newsgroup-ignored-charsets)
4783 (let ((win (gnus-get-buffer-window (current-buffer) t))
4786 (select-window win))
4789 (if (mm-handle-displayed-p handle)
4790 ;; This will remove the part.
4791 (mm-display-part handle)
4793 (narrow-to-region (point)
4794 (if (eobp) (point) (1+ (point))))
4795 (mm-display-part handle)
4796 ;; We narrow to the part itself and
4797 ;; then call the treatment functions.
4798 (goto-char (point-min))
4800 (narrow-to-region (point) (point-max))
4803 (gnus-article-mime-total-parts)
4804 (mm-handle-media-type handle)))))
4805 (if (window-live-p window)
4806 (select-window window)))))
4809 (gnus-insert-mime-button
4810 handle id (list (mm-handle-displayed-p handle)))
4811 (goto-char point))))
4813 (defun gnus-article-goto-part (n)
4814 "Go to MIME part N."
4815 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4817 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4818 (let ((gnus-tmp-name
4819 (or (mail-content-type-get (mm-handle-type handle) 'name)
4820 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4821 (mail-content-type-get (mm-handle-type handle) 'url)
4823 (gnus-tmp-type (mm-handle-media-type handle))
4824 (gnus-tmp-description
4825 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4828 (if (if displayed (car displayed)
4829 (mm-handle-displayed-p handle))
4831 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4833 gnus-tmp-type-long b e)
4834 (when (string-match ".*/" gnus-tmp-name)
4835 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4836 (setq gnus-tmp-type-long (concat gnus-tmp-type
4837 (and (not (equal gnus-tmp-name ""))
4838 (concat "; " gnus-tmp-name))))
4839 (unless (equal gnus-tmp-description "")
4840 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4845 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4846 `(keymap ,gnus-mime-button-map
4847 gnus-callback gnus-mm-display-part
4848 gnus-part ,gnus-tmp-id
4849 article-type annotation
4852 ;; Exclude a newline.
4855 (widget-convert-button
4858 :action 'gnus-widget-press-button
4859 :button-keymap gnus-mime-button-map
4861 (lambda (widget/window &optional overlay pos)
4862 ;; Needed to properly clear the message due to a bug in
4863 ;; wid-edit (XEmacs only).
4864 (if (boundp 'help-echo-owns-message)
4865 (setq help-echo-owns-message t))
4867 "%S: %s the MIME part; %S: more options"
4868 (aref gnus-mouse-2 0)
4869 ;; XEmacs will get a single widget arg; Emacs 21 will get
4870 ;; window, overlay, position.
4871 (if (mm-handle-displayed-p
4873 (with-current-buffer (gnus-overlay-buffer overlay)
4874 (widget-get (widget-at (gnus-overlay-start overlay))
4876 (widget-get widget/window :mime-handle)))
4878 (aref gnus-down-mouse-3 0))))))
4880 (defun gnus-widget-press-button (elems el)
4881 (goto-char (widget-get elems :from))
4882 (gnus-article-press-button))
4884 (defvar gnus-displaying-mime nil)
4886 (defun gnus-display-mime (&optional ihandles)
4887 "Display the MIME parts."
4889 (save-selected-window
4890 (let ((window (get-buffer-window gnus-article-buffer))
4893 (select-window window)
4894 ;; We have to do this since selecting the window
4895 ;; may change the point. So we set the window point.
4896 (set-window-point window point)))
4897 (let* ((handles (or ihandles
4898 (mm-dissect-buffer nil gnus-article-loose-mime)
4899 (and gnus-article-emulate-mime
4901 buffer-read-only handle name type b e display)
4902 (when (and (not ihandles)
4903 (not gnus-displaying-mime))
4904 ;; Top-level call; we clean up.
4905 (when gnus-article-mime-handles
4906 (mm-destroy-parts gnus-article-mime-handles)
4907 (setq gnus-article-mime-handle-alist nil));; A trick.
4908 (setq gnus-article-mime-handles handles)
4909 ;; We allow users to glean info from the handles.
4910 (when gnus-article-mime-part-function
4911 (gnus-mime-part-function handles)))
4913 (or (not (stringp (car handles)))
4916 (when (and (not ihandles)
4917 (not gnus-displaying-mime))
4918 ;; Clean up for mime parts.
4920 (delete-region (point) (point-max)))
4921 (let ((gnus-displaying-mime t))
4922 (gnus-mime-display-part handles)))
4925 (narrow-to-region (point) (point-max))
4926 (gnus-treat-article nil 1 1)
4929 ;; Highlight the headers.
4933 (narrow-to-region (point-min) (point))
4934 (gnus-treat-article 'head))))))))
4936 (defcustom gnus-mime-display-multipart-as-mixed nil
4937 "Display \"multipart\" parts as \"multipart/mixed\".
4939 If t, it overrides nil values of
4940 `gnus-mime-display-multipart-alternative-as-mixed' and
4941 `gnus-mime-display-multipart-related-as-mixed'."
4942 :group 'gnus-article-mime
4945 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4946 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4947 :group 'gnus-article-mime
4950 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4951 "Display \"multipart/related\" parts as \"multipart/mixed\".
4953 If displaying \"text/html\" is discouraged \(see
4954 `mm-discouraged-alternatives'\) images or other material inside a
4955 \"multipart/related\" part might be overlooked when this variable is nil."
4956 :group 'gnus-article-mime
4959 (defun gnus-mime-display-part (handle)
4962 ((not (stringp (car handle)))
4963 (gnus-mime-display-single handle))
4964 ;; User-defined multipart
4965 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4966 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4968 ;; multipart/alternative
4969 ((and (equal (car handle) "multipart/alternative")
4970 (not (or gnus-mime-display-multipart-as-mixed
4971 gnus-mime-display-multipart-alternative-as-mixed)))
4972 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4973 (push (cons id handle) gnus-article-mime-handle-alist)
4974 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4975 ;; multipart/related
4976 ((and (equal (car handle) "multipart/related")
4977 (not (or gnus-mime-display-multipart-as-mixed
4978 gnus-mime-display-multipart-related-as-mixed)))
4979 ;;;!!!We should find the start part, but we just default
4980 ;;;!!!to the first part.
4981 ;;(gnus-mime-display-part (cadr handle))
4982 ;;;!!! Most multipart/related is an HTML message plus images.
4983 ;;;!!! Unfortunately we are unable to let W3 display those
4984 ;;;!!! included images, so we just display it as a mixed multipart.
4985 ;;(gnus-mime-display-mixed (cdr handle))
4986 ;;;!!! No, w3 can display everything just fine.
4987 (gnus-mime-display-part (cadr handle)))
4988 ((equal (car handle) "multipart/signed")
4989 (gnus-add-wash-type 'signed)
4990 (gnus-mime-display-security handle))
4991 ((equal (car handle) "multipart/encrypted")
4992 (gnus-add-wash-type 'encrypted)
4993 (gnus-mime-display-security handle))
4994 ;; Other multiparts are handled like multipart/mixed.
4996 (gnus-mime-display-mixed (cdr handle)))))
4998 (defun gnus-mime-part-function (handles)
4999 (if (stringp (car handles))
5000 (mapcar 'gnus-mime-part-function (cdr handles))
5001 (funcall gnus-article-mime-part-function handles)))
5003 (defun gnus-mime-display-mixed (handles)
5004 (mapcar 'gnus-mime-display-part handles))
5006 (defun gnus-mime-display-single (handle)
5007 (let ((type (mm-handle-media-type handle))
5008 (ignored gnus-ignored-mime-types)
5015 (when (string-match (pop ignored) type)
5016 (throw 'ignored nil)))
5017 (if (and (setq not-attachment
5018 (and (not (mm-inline-override-p handle))
5019 (or (not (mm-handle-disposition handle))
5020 (equal (car (mm-handle-disposition handle))
5022 (mm-attachment-override-p handle))))
5023 (mm-automatic-display-p handle)
5025 (mm-inlinable-p handle)
5026 (mm-inlined-p handle))
5027 (mm-automatic-external-display-p type)))
5029 (when (equal (mm-handle-media-supertype handle) "text")
5031 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5033 (push (cons id handle) gnus-article-mime-handle-alist)
5034 (when (or (not display)
5035 (not (gnus-unbuttonized-mime-type-p type)))
5036 (gnus-insert-mime-button
5037 handle id (list (or display (and not-attachment text))))
5038 (gnus-article-insert-newline)
5039 ;; Remember modify the number of forward lines.
5047 (let ((mail-parse-charset gnus-newsgroup-charset)
5048 (mail-parse-ignored-charsets
5049 (save-excursion (condition-case ()
5050 (set-buffer gnus-summary-buffer)
5052 gnus-newsgroup-ignored-charsets)))
5053 (mm-display-part handle t))
5054 (goto-char (point-max)))
5055 ((and text not-attachment)
5059 (gnus-article-insert-newline)
5060 (mm-insert-inline handle (mm-get-part handle))
5061 (goto-char (point-max))))
5065 (narrow-to-region beg (point))
5068 (gnus-article-mime-total-parts)
5069 (mm-handle-media-type handle)))))))))
5071 (defun gnus-unbuttonized-mime-type-p (type)
5072 "Say whether TYPE is to be unbuttonized."
5073 (unless gnus-inhibit-mime-unbuttonizing
5075 (let ((types gnus-unbuttonized-mime-types))
5077 (when (string-match (pop types) type)
5078 (throw 'found t)))))
5080 (let ((types gnus-buttonized-mime-types))
5082 (when (string-match (pop types) type)
5083 (throw 'found t)))))))))
5085 (defun gnus-article-insert-newline ()
5086 "Insert a newline, but mark it as undeletable."
5087 (gnus-put-text-property
5088 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5090 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5091 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5094 handle buffer-read-only from props begend not-pref)
5095 (save-window-excursion
5098 (narrow-to-region (car ibegend)
5101 (goto-char (car ibegend))
5104 (delete-region (point-min) (point-max))
5105 (mm-remove-parts handles))
5106 (setq begend (list (point-marker)))
5108 (unless (setq not-pref (cadr (member preferred ihandles)))
5109 (setq not-pref (car ihandles)))
5112 (not (gnus-unbuttonized-mime-type-p
5113 "multipart/alternative")))
5114 (gnus-add-text-properties
5117 (insert (format "%d. " id))
5121 (unless ,(not ibegend)
5122 (setq gnus-article-mime-handle-alist
5123 ',gnus-article-mime-handle-alist))
5124 (gnus-mime-display-alternative
5125 ',ihandles ',not-pref ',begend ,id))
5126 keymap ,gnus-mime-button-map
5127 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5128 face ,gnus-article-button-face
5131 (widget-convert-button 'link from (point)
5132 :action 'gnus-widget-press-button
5133 :button-keymap gnus-widget-button-keymap)
5135 (while (setq handle (pop handles))
5136 (gnus-add-text-properties
5139 (insert (format "(%c) %-18s"
5140 (if (equal handle preferred) ?* ? )
5141 (mm-handle-media-type handle)))
5145 (unless ,(not ibegend)
5146 (setq gnus-article-mime-handle-alist
5147 ',gnus-article-mime-handle-alist))
5148 (gnus-mime-display-alternative
5149 ',ihandles ',handle ',begend ,id))
5150 keymap ,gnus-mime-button-map
5151 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5152 face ,gnus-article-button-face
5155 (widget-convert-button 'link from (point)
5156 :action 'gnus-widget-press-button
5157 :button-keymap gnus-widget-button-keymap)
5161 (if (stringp (car preferred))
5162 (gnus-display-mime preferred)
5163 (let ((mail-parse-charset gnus-newsgroup-charset)
5164 (mail-parse-ignored-charsets
5165 (with-current-buffer gnus-summary-buffer
5166 gnus-newsgroup-ignored-charsets)))
5167 (mm-display-part preferred)
5171 (narrow-to-region (car begend) (point-max))
5173 nil (length gnus-article-mime-handle-alist)
5174 (gnus-article-mime-total-parts)
5175 (mm-handle-media-type handle))))))
5176 (goto-char (point-max))
5177 (setcdr begend (point-marker)))))
5179 (goto-char point))))
5181 (defconst gnus-article-wash-status-strings
5182 (let ((alist '((cite "c" "Possible hidden citation text"
5183 " " "All citation text visible")
5184 (headers "h" "Hidden headers"
5185 " " "All headers visible.")
5186 (pgp "p" "Encrypted or signed message status hidden"
5187 " " "No hidden encryption nor digital signature status")
5188 (signature "s" "Signature has been hidden"
5189 " " "Signature is visible")
5190 (overstrike "o" "Overstrike (^H) characters applied"
5191 " " "No overstrike characters applied")
5192 (gnus-show-mime "m" "Mime processing is activated"
5193 " " "Mime processing is not activated")
5194 (emphasis "e" "/*_Emphasis_*/ characters applied"
5195 " " "No /*_emphasis_*/ characters applied")))
5197 (dolist (entry alist result)
5198 (let ((key (nth 0 entry))
5199 (on (copy-sequence (nth 1 entry)))
5200 (on-help (nth 2 entry))
5201 (off (copy-sequence (nth 3 entry)))
5202 (off-help (nth 4 entry)))
5203 (put-text-property 0 1 'help-echo on-help on)
5204 (put-text-property 0 1 'help-echo off-help off)
5205 (push (list key on off) result))))
5206 "Alist of strings describing wash status in the mode line.
5207 Each entry has the form (KEY ON OF), where the KEY is a symbol
5208 representing the particular washing function, ON is the string to use
5209 in the article mode line when the washing function is active, and OFF
5210 is the string to use when it is inactive.")
5212 (defun gnus-article-wash-status-entry (key value)
5213 (let ((entry (assoc key gnus-article-wash-status-strings)))
5214 (if value (nth 1 entry) (nth 2 entry))))
5216 (defun gnus-article-wash-status ()
5217 "Return a string which display status of article washing."
5218 (with-current-buffer gnus-article-buffer
5219 (let ((cite (memq 'cite gnus-article-wash-types))
5220 (headers (memq 'headers gnus-article-wash-types))
5221 (boring (memq 'boring-headers gnus-article-wash-types))
5222 (pgp (memq 'pgp gnus-article-wash-types))
5223 (pem (memq 'pem gnus-article-wash-types))
5224 (signed (memq 'signed gnus-article-wash-types))
5225 (encrypted (memq 'encrypted gnus-article-wash-types))
5226 (signature (memq 'signature gnus-article-wash-types))
5227 (overstrike (memq 'overstrike gnus-article-wash-types))
5228 (emphasis (memq 'emphasis gnus-article-wash-types)))
5230 (gnus-article-wash-status-entry 'cite cite)
5231 (gnus-article-wash-status-entry 'headers (or headers boring))
5232 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5233 (gnus-article-wash-status-entry 'signature signature)
5234 (gnus-article-wash-status-entry 'overstrike overstrike)
5235 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
5236 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5238 (defun gnus-add-wash-type (type)
5239 "Add a washing of TYPE to the current status."
5240 (add-to-list 'gnus-article-wash-types type))
5242 (defun gnus-delete-wash-type (type)
5243 "Add a washing of TYPE to the current status."
5244 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5246 (defun gnus-add-image (category image)
5247 "Add IMAGE of CATEGORY to the list of displayed images."
5248 (let ((entry (assq category gnus-article-image-alist)))
5250 (setq entry (list category))
5251 (push entry gnus-article-image-alist))
5252 (nconc entry (list image))))
5254 (defun gnus-delete-images (category)
5255 "Delete all images in CATEGORY."
5256 (let ((entry (assq category gnus-article-image-alist)))
5257 (dolist (image (cdr entry))
5258 (gnus-remove-image image category))
5259 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5260 (gnus-delete-wash-type category)))
5262 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5264 (defun gnus-article-maybe-hide-headers ()
5265 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5266 Provided for backwards compatibility."
5267 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5268 (not (with-current-buffer gnus-summary-buffer
5269 gnus-have-all-headers)))
5270 (not gnus-inhibit-hiding))
5271 (gnus-article-hide-headers)))
5275 (defun gnus-output-to-file (file-name)
5276 "Append the current article to a file named FILE-NAME."
5277 (let ((artbuf (current-buffer)))
5279 (insert-buffer-substring artbuf)
5280 ;; Append newline at end of the buffer as separator, and then
5282 (goto-char (point-max))
5284 (let ((file-name-coding-system nnmail-pathname-coding-system))
5285 (write-region-as-binary (point-min) (point-max) file-name 'append))
5288 (defun gnus-narrow-to-page (&optional arg)
5289 "Narrow the article buffer to a page.
5290 If given a numerical ARG, move forward ARG pages."
5292 (setq arg (if arg (prefix-numeric-value arg) 0))
5294 (set-buffer gnus-article-buffer)
5295 (goto-char (point-min))
5297 ;; Remove any old next/prev buttons.
5298 (when (gnus-visual-p 'page-marker)
5299 (let ((buffer-read-only nil))
5300 (gnus-remove-text-with-property 'gnus-prev)
5301 (gnus-remove-text-with-property 'gnus-next)))
5304 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5306 (re-search-forward page-delimiter nil 'move arg)))
5307 (goto-char (match-end 0))
5309 (goto-char (point-min))
5310 (setq gnus-page-broken
5311 (and (re-search-forward page-delimiter nil t) t))))
5312 (when gnus-page-broken
5315 (if (re-search-forward page-delimiter nil 'move)
5318 (when (and (gnus-visual-p 'page-marker)
5319 (not (= (point-min) 1)))
5321 (goto-char (point-min))
5322 (gnus-insert-prev-page-button)))
5323 (when (and (gnus-visual-p 'page-marker)
5324 (< (+ (point-max) 2) (buffer-size)))
5326 (goto-char (point-max))
5327 (gnus-insert-next-page-button))))))
5329 ;; Article mode commands
5331 (defun gnus-article-goto-next-page ()
5332 "Show the next page of the article."
5334 (when (gnus-article-next-page)
5335 (goto-char (point-min))
5336 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5339 (defun gnus-article-goto-prev-page ()
5340 "Show the previous page of the article."
5343 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5344 (gnus-article-prev-page nil)))
5346 ;; This is cleaner but currently breaks `gnus-pick-mode':
5348 ;; (defun gnus-article-goto-next-page ()
5349 ;; "Show the next page of the article."
5351 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5352 ;; (gnus-summary-next-page)))
5354 ;; (defun gnus-article-goto-prev-page ()
5355 ;; "Show the next page of the article."
5357 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5358 ;; (gnus-summary-prev-page)))
5360 (defun gnus-article-next-page (&optional lines)
5361 "Show the next page of the current article.
5362 If end of article, return non-nil. Otherwise return nil.
5363 Argument LINES specifies lines to be scrolled up."
5365 (move-to-window-line -1)
5368 (and (pos-visible-in-window-p) ;Not continuation line.
5369 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5370 ;; Nothing in this page.
5371 (if (or (not gnus-page-broken)
5375 (eobp)))) ;Real end-of-buffer?
5377 (when gnus-article-over-scroll
5378 (gnus-article-next-page-1 lines))
5380 (gnus-narrow-to-page 1) ;Go to next page.
5382 ;; More in this page.
5383 (gnus-article-next-page-1 lines)
5386 (defun gnus-article-next-page-1 (lines)
5387 (let ((scroll-in-place nil))
5391 ;; Long lines may cause an end-of-buffer error.
5392 (goto-char (point-max)))))
5393 (move-to-window-line 0))
5395 (defun gnus-article-prev-page (&optional lines)
5396 "Show previous page of current article.
5397 Argument LINES specifies lines to be scrolled down."
5399 (move-to-window-line 0)
5400 (if (and gnus-page-broken
5402 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5404 (gnus-narrow-to-page -1) ;Go to previous page.
5405 (goto-char (point-max))
5407 (let ((scroll-in-place nil))
5411 (beginning-of-buffer
5412 (goto-char (point-min))))
5413 (move-to-window-line 0)))))
5415 (defun gnus-article-only-boring-p ()
5416 "Decide whether there is only boring text remaining in the article.
5417 Something \"interesting\" is a word of at least two letters that does
5418 not have a face in `gnus-article-boring-faces'."
5419 (when (and gnus-article-skip-boring
5420 (boundp 'gnus-article-boring-faces)
5421 (symbol-value 'gnus-article-boring-faces))
5424 (while (re-search-forward "\\b\\w\\w" nil t)
5426 (when (not (gnus-intersection
5427 (gnus-faces-at (point))
5428 (symbol-value 'gnus-article-boring-faces)))
5429 (throw 'only-boring nil)))
5430 (throw 'only-boring t)))))
5432 (defun gnus-article-refer-article ()
5433 "Read article specified by message-id around point."
5436 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5437 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5438 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5439 (let ((msg-id (concat "<" (match-string 0) ">")))
5440 (set-buffer gnus-summary-buffer)
5441 (gnus-summary-refer-article msg-id))
5442 (error "No references around point"))))
5444 (defun gnus-article-show-summary ()
5445 "Reconfigure windows to show summary buffer."
5447 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5448 (error "There is no summary buffer for this article buffer")
5449 (gnus-article-set-globals)
5450 (gnus-configure-windows 'article)
5451 (gnus-summary-goto-subject gnus-current-article)
5452 (gnus-summary-position-point)))
5454 (defun gnus-article-describe-briefly ()
5455 "Describe article mode commands briefly."
5457 (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")))
5459 (defun gnus-article-summary-command ()
5460 "Execute the last keystroke in the summary buffer."
5462 (let ((obuf (current-buffer))
5463 (owin (current-window-configuration))
5465 (switch-to-buffer gnus-article-current-summary 'norecord)
5466 (setq func (lookup-key (current-local-map) (this-command-keys)))
5467 (call-interactively func)
5469 (set-window-configuration owin)
5470 (set-window-point (get-buffer-window (current-buffer)) (point))))
5472 (defun gnus-article-summary-command-nosave ()
5473 "Execute the last keystroke in the summary buffer."
5476 (pop-to-buffer gnus-article-current-summary 'norecord)
5477 (setq func (lookup-key (current-local-map) (this-command-keys)))
5478 (call-interactively func)))
5480 (defun gnus-article-check-buffer ()
5481 "Beep if not in an article buffer."
5482 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5483 (error "Command invoked outside of a Gnus article buffer")))
5485 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5486 "Read a summary buffer key sequence and execute it from the article buffer."
5488 (gnus-article-check-buffer)
5490 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5491 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5492 "=" "^" "\M-^" "|"))
5498 '("n" "Gn" "p" "Gp"))
5501 (set-buffer gnus-article-current-summary)
5502 (let (gnus-pick-mode)
5503 (push (or key last-command-event) unread-command-events)
5504 (setq keys (static-if (featurep 'xemacs)
5505 (events-to-keys (read-key-sequence nil))
5506 (read-key-sequence nil)))))
5509 (if (or (member keys nosaves)
5510 (member keys nosave-but-article)
5511 (member keys nosave-in-article))
5513 (save-window-excursion
5514 (pop-to-buffer gnus-article-current-summary 'norecord)
5515 ;; We disable the pick minor mode commands.
5516 (let (gnus-pick-mode)
5517 (setq func (lookup-key (current-local-map) keys))))
5521 (unless (member keys nosave-in-article)
5522 (set-buffer gnus-article-current-summary))
5523 (call-interactively func)
5524 (setq new-sum-point (point)))
5525 (when (member keys nosave-but-article)
5526 (pop-to-buffer gnus-article-buffer 'norecord)))
5527 ;; These commands should restore window configuration.
5528 (let ((obuf (current-buffer))
5529 (owin (current-window-configuration))
5531 win func in-buffer selected new-sum-start new-sum-hscroll)
5532 (cond (not-restore-window
5533 (pop-to-buffer gnus-article-current-summary 'norecord))
5534 ((setq win (get-buffer-window gnus-article-current-summary))
5535 (select-window win))
5537 (switch-to-buffer gnus-article-current-summary 'norecord)))
5538 (setq in-buffer (current-buffer))
5539 ;; We disable the pick minor mode commands.
5540 (if (and (setq func (let (gnus-pick-mode)
5541 (lookup-key (current-local-map) keys)))
5544 (call-interactively func)
5545 (when (eq win (selected-window))
5546 (setq new-sum-point (point)
5547 new-sum-start (window-start win)
5548 new-sum-hscroll (window-hscroll win))
5549 (when (eq in-buffer (current-buffer))
5550 (setq selected (gnus-summary-select-article))
5552 (unless not-restore-window
5553 (set-window-configuration owin))
5554 (when (eq selected 'old)
5556 (set-window-start (get-buffer-window (current-buffer))
5558 (set-window-point (get-buffer-window (current-buffer))
5560 (when (and (not not-restore-window)
5562 (set-window-point win new-sum-point)
5563 (set-window-start win new-sum-start)
5564 (set-window-hscroll win new-sum-hscroll)))))
5565 (set-window-configuration owin)
5568 (defun gnus-article-describe-key (key)
5569 "Display documentation of the function invoked by KEY. KEY is a string."
5570 (interactive "kDescribe key: ")
5571 (gnus-article-check-buffer)
5572 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5574 (set-buffer gnus-article-current-summary)
5575 (let (gnus-pick-mode)
5576 (if (featurep 'xemacs)
5578 (push (elt key 0) unread-command-events)
5579 (setq key (events-to-keys
5580 (read-key-sequence "Describe key: "))))
5581 (setq unread-command-events
5583 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5585 (setq key (read-key-sequence "Describe key: "))))
5587 (describe-key key)))
5589 (defun gnus-article-describe-key-briefly (key &optional insert)
5590 "Display documentation of the function invoked by KEY. KEY is a string."
5591 (interactive "kDescribe key: \nP")
5592 (gnus-article-check-buffer)
5593 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5595 (set-buffer gnus-article-current-summary)
5596 (let (gnus-pick-mode)
5597 (if (featurep 'xemacs)
5599 (push (elt key 0) unread-command-events)
5600 (setq key (events-to-keys
5601 (read-key-sequence "Describe key: "))))
5602 (setq unread-command-events
5604 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5606 (setq key (read-key-sequence "Describe key: "))))
5607 (describe-key-briefly key insert))
5608 (describe-key-briefly key insert)))
5610 (defun gnus-article-reply-with-original (&optional wide)
5611 "Start composing a reply mail to the current message.
5612 The text in the region will be yanked. If the region isn't active,
5613 the entire article will be yanked."
5615 (let ((article (cdr gnus-article-current))
5617 (if (not (gnus-mark-active-p))
5618 (with-current-buffer gnus-summary-buffer
5619 (gnus-summary-reply (list (list article)) wide))
5620 (setq contents (buffer-substring (point) (mark t)))
5621 ;; Deactivate active regions.
5622 (when (and (boundp 'transient-mark-mode)
5623 transient-mark-mode)
5624 (setq mark-active nil))
5625 (with-current-buffer gnus-summary-buffer
5627 (list (list article contents)) wide)))))
5629 (defun gnus-article-followup-with-original ()
5630 "Compose a followup to the current article.
5631 The text in the region will be yanked. If the region isn't active,
5632 the entire article will be yanked."
5634 (let ((article (cdr gnus-article-current))
5636 (if (not (gnus-mark-active-p))
5637 (with-current-buffer gnus-summary-buffer
5638 (gnus-summary-followup (list (list article))))
5639 (setq contents (buffer-substring (point) (mark t)))
5640 ;; Deactivate active regions.
5641 (when (and (boundp 'transient-mark-mode)
5642 transient-mark-mode)
5643 (setq mark-active nil))
5644 (with-current-buffer gnus-summary-buffer
5645 (gnus-summary-followup
5646 (list (list article contents)))))))
5648 (defun gnus-article-hide (&optional arg force)
5649 "Hide all the gruft in the current article.
5650 This means that signatures, cited text and (some) headers will be
5652 If given a prefix, show the hidden text instead."
5653 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5654 (gnus-article-hide-headers arg)
5655 (gnus-article-hide-list-identifiers arg)
5656 (gnus-article-hide-citation-maybe arg force)
5657 (gnus-article-hide-signature arg))
5659 (defun gnus-article-maybe-highlight ()
5660 "Do some article highlighting if article highlighting is requested."
5661 (when (gnus-visual-p 'article-highlight 'highlight)
5662 (gnus-article-highlight-some)))
5664 (defun gnus-check-group-server ()
5665 ;; Make sure the connection to the server is alive.
5666 (unless (gnus-server-opened
5667 (gnus-find-method-for-group gnus-newsgroup-name))
5668 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5669 (gnus-request-group gnus-newsgroup-name t)))
5672 (autoload 'nneething-get-file-name "nneething"))
5674 (defun gnus-request-article-this-buffer (article group)
5675 "Get an article and insert it into this buffer."
5676 (let (do-update-line sparse-header)
5680 (gnus-kill-all-overlays)
5681 (setq group (or group gnus-newsgroup-name))
5683 ;; Using `gnus-request-article' directly will insert the article into
5684 ;; `nntp-server-buffer' - so we'll save some time by not having to
5685 ;; copy it from the server buffer into the article buffer.
5687 ;; We only request an article by message-id when we do not have the
5688 ;; headers for it, so we'll have to get those.
5689 (when (stringp article)
5690 (gnus-read-header article))
5692 ;; If the article number is negative, that means that this article
5693 ;; doesn't belong in this newsgroup (possibly), so we find its
5694 ;; message-id and request it by id instead of number.
5695 (when (and (numberp article)
5697 (get-buffer gnus-summary-buffer)
5698 (gnus-buffer-exists-p gnus-summary-buffer))
5700 (set-buffer gnus-summary-buffer)
5701 (let ((header (gnus-summary-article-header article)))
5704 ((memq article gnus-newsgroup-sparse)
5705 ;; This is a sparse gap article.
5706 (setq do-update-line article)
5707 (setq article (mail-header-id header))
5708 (setq sparse-header (gnus-read-header article))
5709 (setq gnus-newsgroup-sparse
5710 (delq article gnus-newsgroup-sparse)))
5712 ;; It's a real article.
5713 (setq article (mail-header-id header)))
5715 ;; It is an extracted pseudo-article.
5716 (setq article 'pseudo)
5717 (gnus-request-pseudo-article header))))
5719 (let ((method (gnus-find-method-for-group
5720 gnus-newsgroup-name)))
5721 (when (and (eq (car method) 'nneething)
5723 (let ((dir (nneething-get-file-name
5724 (mail-header-id header))))
5725 (when (and (stringp dir)
5726 (file-directory-p dir))
5727 (setq article 'nneething)
5728 (gnus-group-enter-directory dir))))))))
5731 ;; Refuse to select canceled articles.
5732 ((and (numberp article)
5734 (get-buffer gnus-summary-buffer)
5735 (gnus-buffer-exists-p gnus-summary-buffer)
5736 (eq (cdr (with-current-buffer gnus-summary-buffer
5737 (assq article gnus-newsgroup-reads)))
5738 gnus-canceled-mark))
5740 ;; We first check `gnus-original-article-buffer'.
5741 ((and (get-buffer gnus-original-article-buffer)
5743 (with-current-buffer gnus-original-article-buffer
5744 (and (equal (car gnus-original-article) group)
5745 (eq (cdr gnus-original-article) article))))
5746 (insert-buffer-substring gnus-original-article-buffer)
5748 ;; Check the backlog.
5749 ((and gnus-keep-backlog
5750 (gnus-backlog-request-article group article (current-buffer)))
5752 ;; Check asynchronous pre-fetch.
5753 ((gnus-async-request-fetched-article group article (current-buffer))
5754 (gnus-async-prefetch-next group article gnus-summary-buffer)
5755 (when (and (numberp article) gnus-keep-backlog)
5756 (gnus-backlog-enter-article group article (current-buffer)))
5759 ((and gnus-use-cache
5761 (gnus-cache-request-article article group))
5763 ;; Check the agent cache.
5764 ((gnus-agent-request-article article group)
5766 ;; Get the article and put into the article buffer.
5767 ((or (stringp article)
5769 (let ((gnus-override-method gnus-override-method)
5770 (methods (and (stringp article)
5771 gnus-refer-article-method))
5772 (backend (car (gnus-find-method-for-group
5773 gnus-newsgroup-name)))
5775 (buffer-read-only nil))
5776 (if (or (not (listp methods))
5777 (and (symbolp (car methods))
5778 (assq (car methods) nnoo-definition-alist)))
5779 (setq methods (list methods)))
5780 (when (and (null gnus-override-method)
5782 (setq gnus-override-method (pop methods)))
5784 (when (eq gnus-override-method 'current)
5785 (setq gnus-override-method
5786 (with-current-buffer gnus-summary-buffer
5787 gnus-current-select-method)))
5789 (gnus-kill-all-overlays)
5790 (let ((gnus-newsgroup-name group))
5791 (gnus-check-group-server))
5793 ((gnus-request-article article group (current-buffer))
5794 (when (numberp article)
5795 (gnus-async-prefetch-next group article
5796 gnus-summary-buffer)
5797 (when gnus-keep-backlog
5798 (gnus-backlog-enter-article
5799 group article (current-buffer))))
5800 (setq result 'article))
5802 (setq gnus-override-method (pop methods)))
5803 ((not (string-match "^400 "
5804 (nnheader-get-report backend)))
5805 ;; If we get 400 server disconnect, reconnect and
5806 ;; retry; otherwise, assume the article has expired.
5807 (setq result 'done))))
5808 (and (eq result 'article) 'article)))
5812 ;; Associate this article with the current summary buffer.
5813 (setq gnus-article-current-summary gnus-summary-buffer)
5815 ;; Take the article from the original article buffer
5816 ;; and place it in the buffer it's supposed to be in.
5817 (when (and (get-buffer gnus-article-buffer)
5818 (equal (buffer-name (current-buffer))
5819 (buffer-name (get-buffer gnus-article-buffer))))
5821 (if (get-buffer gnus-original-article-buffer)
5822 (set-buffer gnus-original-article-buffer)
5823 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5824 (buffer-disable-undo)
5825 (setq major-mode 'gnus-original-article-mode)
5826 (setq buffer-read-only t))
5827 (let (buffer-read-only)
5829 (insert-buffer-substring gnus-article-buffer))
5830 (setq gnus-original-article (cons group article)))
5833 (run-hooks 'gnus-article-decode-hook)
5834 ;; Mark article as decoded or not.
5835 (setq gnus-article-decoded-p gnus-article-decode-hook))
5837 ;; Update sparse articles.
5838 (when (and do-update-line
5839 (or (numberp article)
5841 (let ((buf (current-buffer)))
5842 (set-buffer gnus-summary-buffer)
5843 (gnus-summary-update-article do-update-line sparse-header)
5844 (gnus-summary-goto-subject do-update-line nil t)
5845 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5847 (set-buffer buf))))))
5853 (defcustom gnus-article-edit-mode-hook nil
5854 "Hook run in article edit mode buffers."
5855 :group 'gnus-article-various
5858 (defcustom gnus-article-edit-article-setup-function
5859 'gnus-article-mime-edit-article-setup
5860 "Function called to setup an editing article buffer."
5861 :group 'gnus-article-various
5864 (defvar gnus-article-edit-done-function nil)
5866 (defvar gnus-article-edit-mode-map nil)
5868 ;; Should we be using derived.el for this?
5869 (unless gnus-article-edit-mode-map
5870 (setq gnus-article-edit-mode-map (make-keymap))
5871 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5873 (gnus-define-keys gnus-article-edit-mode-map
5874 "\C-c?" describe-mode
5875 "\C-c\C-c" gnus-article-edit-done
5876 "\C-c\C-k" gnus-article-edit-exit
5877 "\C-c\C-f\C-t" message-goto-to
5878 "\C-c\C-f\C-o" message-goto-from
5879 "\C-c\C-f\C-b" message-goto-bcc
5880 ;;"\C-c\C-f\C-w" message-goto-fcc
5881 "\C-c\C-f\C-c" message-goto-cc
5882 "\C-c\C-f\C-s" message-goto-subject
5883 "\C-c\C-f\C-r" message-goto-reply-to
5884 "\C-c\C-f\C-n" message-goto-newsgroups
5885 "\C-c\C-f\C-d" message-goto-distribution
5886 "\C-c\C-f\C-f" message-goto-followup-to
5887 "\C-c\C-f\C-m" message-goto-mail-followup-to
5888 "\C-c\C-f\C-k" message-goto-keywords
5889 "\C-c\C-f\C-u" message-goto-summary
5890 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5891 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5892 "\C-c\C-b" message-goto-body
5893 "\C-c\C-i" message-goto-signature
5895 "\C-c\C-t" message-insert-to
5896 "\C-c\C-n" message-insert-newsgroups
5897 "\C-c\C-o" message-sort-headers
5898 "\C-c\C-e" message-elide-region
5899 "\C-c\C-v" message-delete-not-region
5900 "\C-c\C-z" message-kill-to-signature
5901 "\M-\r" message-newline-and-reformat
5902 "\C-c\C-a" mml-attach-file
5903 "\C-a" message-beginning-of-line
5905 "\M-;" comment-region)
5907 (gnus-define-keys (gnus-article-edit-wash-map
5908 "\C-c\C-w" gnus-article-edit-mode-map)
5909 "f" gnus-article-edit-full-stops))
5912 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5914 ["Fetch To" message-insert-to t]
5915 ["Fetch Newsgroups" message-insert-newsgroups t]
5917 ["To" message-goto-to t]
5918 ["From" message-goto-from t]
5919 ["Subject" message-goto-subject t]
5920 ["Cc" message-goto-cc t]
5921 ["Reply-To" message-goto-reply-to t]
5922 ["Summary" message-goto-summary t]
5923 ["Keywords" message-goto-keywords t]
5924 ["Newsgroups" message-goto-newsgroups t]
5925 ["Followup-To" message-goto-followup-to t]
5926 ["Mail-Followup-To" message-goto-mail-followup-to t]
5927 ["Distribution" message-goto-distribution t]
5928 ["Body" message-goto-body t]
5929 ["Signature" message-goto-signature t]))
5931 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5932 "Major mode for editing articles.
5933 This is an extended text-mode.
5935 \\{gnus-article-edit-mode-map}"
5936 (make-local-variable 'gnus-article-edit-done-function)
5937 (make-local-variable 'gnus-prev-winconf)
5938 (set (make-local-variable 'font-lock-defaults)
5939 '(message-font-lock-keywords t))
5940 (set (make-local-variable 'mail-header-separator) "")
5941 (set (make-local-variable 'gnus-article-edit-mode) t)
5942 (easy-menu-add message-mode-field-menu message-mode-map)
5943 (setq buffer-read-only nil)
5944 (buffer-enable-undo)
5947 (defun gnus-article-edit (&optional force)
5948 "Edit the current article.
5949 This will have permanent effect only in mail groups.
5950 If FORCE is non-nil, allow editing of articles even in read-only
5953 (when (and (not force)
5954 (gnus-group-read-only-p))
5955 (error "The current newsgroup does not support article editing"))
5956 (gnus-article-date-original)
5957 (gnus-article-edit-article
5959 `(lambda (no-highlight)
5961 (gnus-summary-edit-article-done
5962 ,(or (mail-header-references gnus-current-headers) "")
5963 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5965 (defun gnus-article-edit-article (start-func exit-func)
5966 "Start editing the contents of the current article buffer."
5967 (let ((winconf (current-window-configuration)))
5968 (set-buffer gnus-article-buffer)
5969 (gnus-article-edit-mode)
5970 (funcall start-func)
5971 (set-buffer-modified-p nil)
5972 (gnus-configure-windows 'edit-article)
5973 (setq gnus-article-edit-done-function exit-func)
5974 (setq gnus-prev-winconf winconf)
5975 (when gnus-article-edit-article-setup-function
5976 (funcall gnus-article-edit-article-setup-function))
5977 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit")))
5979 (defun gnus-article-edit-done (&optional arg)
5980 "Update the article edits and exit."
5982 (let ((func gnus-article-edit-done-function)
5983 (buf (current-buffer))
5984 (start (window-start))
5986 (winconf gnus-prev-winconf))
5987 (remove-hook 'gnus-article-mode-hook
5988 'gnus-article-mime-edit-article-unwind)
5989 (widen) ;; Widen it in case that users narrowed the buffer.
5992 ;; The cache and backlog have to be flushed somewhat.
5993 (when gnus-keep-backlog
5994 (gnus-backlog-remove-article
5995 (car gnus-article-current) (cdr gnus-article-current)))
5996 ;; Flush original article as well.
5998 (when (get-buffer gnus-original-article-buffer)
5999 (set-buffer gnus-original-article-buffer)
6000 (setq gnus-original-article nil)))
6001 (when gnus-use-cache
6002 (gnus-cache-update-article
6003 (car gnus-article-current) (cdr gnus-article-current)))
6004 ;; We remove all text props from the article buffer.
6005 (kill-all-local-variables)
6006 (set-text-properties (point-min) (point-max) nil)
6008 (set-window-configuration winconf)
6010 (set-window-start (get-buffer-window buf) start)
6011 (set-window-point (get-buffer-window buf) (point)))
6012 (gnus-summary-show-article))
6014 (defun gnus-article-edit-exit ()
6015 "Exit the article editing without updating."
6017 (when (or (not (buffer-modified-p))
6018 (yes-or-no-p "Article modified; kill anyway? "))
6019 (let ((curbuf (current-buffer))
6021 (window-start (window-start)))
6023 (if (gnus-buffer-live-p gnus-original-article-buffer)
6024 (insert-buffer-substring gnus-original-article-buffer))
6025 (let ((winconf gnus-prev-winconf))
6026 (kill-all-local-variables)
6028 (set-window-configuration winconf)
6029 ;; Tippy-toe some to make sure that point remains where it was.
6030 (save-current-buffer
6032 (set-window-start (get-buffer-window (current-buffer)) window-start)
6034 (gnus-summary-show-article)))
6036 (defun gnus-article-edit-full-stops ()
6037 "Interactively repair spacing at end of sentences."
6040 (goto-char (point-min))
6041 (search-forward-regexp "^$" nil t)
6042 (let ((case-fold-search nil))
6043 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
6046 ;;; Article editing with MIME-Edit
6049 (defcustom gnus-article-mime-edit-article-setup-hook nil
6050 "Hook run after setting up a MIME editing article buffer."
6051 :group 'gnus-article-various
6054 (defun gnus-article-mime-edit-article-unwind ()
6055 "Unwind `gnus-article-buffer' if article editing was given up."
6056 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6057 (when (featurep 'font-lock)
6058 (setq font-lock-defaults nil)
6059 (font-lock-mode -1))
6060 (when mime-edit-mode-flag
6061 (mime-edit-exit 'nomime 'no-error)
6064 (defun gnus-article-mime-edit-article-setup ()
6065 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
6066 after replacing with the original article."
6067 (setq gnus-show-mime t)
6068 (setq gnus-article-edit-done-function
6069 `(lambda (&rest args)
6070 (when mime-edit-mode-flag
6071 (let (mime-edit-insert-user-agent-field)
6074 (goto-char (point-min))
6075 (let (case-fold-search)
6076 (when (re-search-forward
6077 (format "^%s$" (regexp-quote mail-header-separator))
6079 (replace-match "")))
6080 (apply ,gnus-article-edit-done-function args)
6083 (buffer-substring-no-properties (point-min) (point-max))
6084 (set-buffer (get-buffer-create gnus-original-article-buffer))
6086 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6087 (set-buffer gnus-article-buffer)
6088 (gnus-article-prepare-display)))
6089 (substitute-key-definition 'gnus-article-edit-done
6090 'gnus-article-mime-edit-done
6091 gnus-article-edit-mode-map)
6092 (substitute-key-definition 'gnus-article-edit-exit
6093 'gnus-article-mime-edit-exit
6094 gnus-article-edit-mode-map)
6096 (insert-buffer-substring gnus-original-article-buffer)
6097 (unless (member (with-current-buffer gnus-summary-buffer
6098 gnus-newsgroup-name)
6099 '("nndraft:delayed" "nndraft:drafts"))
6100 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
6101 (fset 'mime-edit-decode-single-part-in-buffer
6102 (lambda (&rest args)
6103 (if (let ((content-type (car args)))
6104 (and (eq 'message (mime-content-type-primary-type
6106 (eq 'rfc822 (mime-content-type-subtype
6108 (setcar (cdr args) 'not-decode-text))
6112 (fset 'mime-edit-decode-single-part-in-buffer ofn))))
6113 (when (featurep 'font-lock)
6114 (set (make-local-variable 'font-lock-defaults)
6115 '(message-font-lock-keywords t))
6116 (font-lock-set-defaults)
6117 (turn-on-font-lock))
6118 (set-buffer-modified-p nil)
6119 (delete-other-windows)
6120 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6121 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
6123 (defun gnus-article-mime-edit-done (&optional arg)
6124 "Update the article MIME edits and exit."
6126 (when (featurep 'font-lock)
6127 (setq font-lock-defaults nil)
6128 (font-lock-mode -1))
6129 (let ((inhibit-read-only t))
6130 (gnus-article-edit-done arg)))
6132 (defun gnus-article-mime-edit-exit ()
6133 "Exit the article MIME editing without updating."
6135 (when (or (not (buffer-modified-p))
6136 (yes-or-no-p "Article modified; kill anyway? "))
6137 (when (featurep 'font-lock)
6138 (setq font-lock-defaults nil)
6139 (font-lock-mode -1))
6140 (when mime-edit-mode-flag
6141 (let (mime-edit-insert-user-agent-field)
6144 (goto-char (point-min))
6145 (let (case-fold-search)
6146 (when (re-search-forward
6147 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
6148 (replace-match "")))
6149 (let ((winconf gnus-prev-winconf))
6151 (buffer-substring-no-properties (point-min) (point-max))
6152 (set-buffer (get-buffer-create gnus-original-article-buffer))
6154 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6155 (set-buffer gnus-article-buffer)
6156 (gnus-article-prepare-display)
6157 (set-window-configuration winconf))))
6160 ;;; Article highlights
6163 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6165 ;;; Internal Variables:
6167 (defcustom gnus-button-url-regexp
6168 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
6169 "\\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:]]\\)"
6170 "\\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\\)\\)")
6171 "Regular expression that matches URLs."
6172 :group 'gnus-article-buttons
6175 (defcustom gnus-button-valid-fqdn-regexp
6176 message-valid-fqdn-regexp
6177 "Regular expression that matches a valid FQDN."
6178 :group 'gnus-article-buttons
6181 (defcustom gnus-button-man-handler 'manual-entry
6182 "Function to use for displaying man pages.
6183 The function must take at least one argument with a string naming the
6185 :type '(choice (function-item :tag "Man" manual-entry)
6186 (function-item :tag "Woman" woman)
6187 (function :tag "Other"))
6188 :group 'gnus-article-buttons)
6190 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6191 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6192 If the default site is too slow, try to find a CTAN mirror, see
6193 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6194 the variable `gnus-button-handle-ctan'."
6195 :group 'gnus-article-buttons
6196 :link '(custom-manual "(gnus)Group Parameters")
6197 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6198 (const "http://tug.ctan.org/tex-archive/")
6199 (const "http://www.dante.de/CTAN/")
6200 (string :tag "Other")))
6202 (defcustom gnus-button-ctan-handler 'browse-url
6203 "Function to use for displaying CTAN links.
6204 The function must take one argument, the string naming the URL."
6205 :type '(choice (function-item :tag "Browse Url" browse-url)
6206 (function :tag "Other"))
6207 :group 'gnus-article-buttons)
6209 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6210 "Bogus strings removed from CTAN URLs."
6211 :group 'gnus-article-buttons
6212 :type '(choice (const "^/?tex-archive/\\|/")
6213 (regexp :tag "Other")))
6215 (defcustom gnus-button-ctan-directory-regexp
6218 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
6219 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
6220 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
6222 "Regular expression for ctan directories.
6223 It should match all directories in the top level of `gnus-ctan-url'."
6224 :group 'gnus-article-buttons
6227 (defcustom gnus-button-mid-or-mail-regexp
6228 (concat "\\b\\(<?[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*@"
6229 ;; Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
6230 gnus-button-valid-fqdn-regexp
6232 "Regular expression that matches a message ID or a mail address."
6233 :group 'gnus-article-buttons
6236 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6237 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6238 Strings like this can be either a message ID or a mail address. If it is one
6239 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6240 message ID or a mail address, respectively. If this variable is set to the
6241 symbol `ask', always query the user what do do. If it is a function, this
6242 function will be called with the string as it's only argument. The function
6243 must return `mid', `mail', `invalid' or `ask'."
6244 :group 'gnus-article-buttons
6245 :type '(choice (function-item :tag "Heuristic function"
6246 gnus-button-mid-or-mail-heuristic)
6251 (defcustom gnus-button-mid-or-mail-heuristic-alist
6252 '((-10.0 . ".+\\$.+@")
6255 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6256 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6257 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6258 (-1.0 . "^[^a-z]+@")
6260 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6261 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6262 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6263 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6266 (-1.0 . "^[0-9][0-9]")
6268 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6269 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6270 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6271 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6273 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6274 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6277 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6279 ;; compensation for TDMA dated mail addresses:
6280 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6282 (-20.0 . "\\.fsf@") ;; Gnus
6285 (-20.0 . "_-_") ;; Subject change in thread
6287 (-20.0 . "\\.ln@") ;; leafnode
6288 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6289 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6291 ;; (5.0 . "") ;; $local_part_len <= 7
6292 (10.0 . "^[^0-9]+@")
6293 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6294 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6297 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6299 (0.5 . "^[A-Z][a-z]")
6300 (0.5 . "^[A-Z][a-z][a-z]")
6301 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6302 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6303 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6305 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6306 address. The REGEXP is processed with `case-fold-search' set to nil."
6307 :group 'gnus-article-buttons
6308 :type '(repeat (cons (number :tag "Rate")
6309 (regexp :tag "Regexp"))))
6311 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6312 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6313 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6314 address, `ask' if unsure and `invalid' if the string is invalid."
6315 (let ((case-fold-search nil)
6316 (list gnus-button-mid-or-mail-heuristic-alist)
6317 (result 0) rate regexp lpartlen elem)
6319 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6320 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6321 ;; Certain special cases...
6324 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6325 "^[0-9]+\\.[0-9]+@compuserve\\|"
6326 "@public\\.gmane\\.org")
6328 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6329 (setq result 'mail))
6330 (when (string-match "@.*@\\| " mid-or-mail)
6331 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6332 (setq result 'invalid))
6333 ;; Nothing more to do, if result is not a number here...
6334 (when (numberp result)
6336 (setq elem (car list)
6340 (when (string-match regexp mid-or-mail)
6341 (setq result (+ result rate))
6343 9 "`%s' matched `%s', rate `%s', result `%s'."
6344 mid-or-mail regexp rate result)))
6345 (when (<= lpartlen 7)
6346 (setq result (+ result 5.0))
6347 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6348 mid-or-mail result))
6349 (when (>= lpartlen 12)
6350 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6352 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6353 ;; Long local part should contain realname if e-mail address,
6354 ;; too many digits: message-id.
6355 ;; $score -= 5.0 + 0.1 * $local_part_len;
6356 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6357 (setq result (+ result rate))
6359 9 "Many digits in `%s', rate `%s', result `%s'."
6360 mid-or-mail rate result))
6361 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6363 ;; Too few vowels [^aeiouy]{4,}.*\@
6364 (setq result (+ result -5.0))
6366 9 "Few vowels in `%s', rate `%s', result `%s'."
6367 mid-or-mail -5.0 result))
6369 (setq result (+ result 5.0))
6371 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6372 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6373 ;; Maybe we should make this a customizable alist: (condition . 'result)
6375 ((symbolp result) result)
6376 ;; Now convert number into proper results:
6377 ((< result -10.0) 'mid)
6378 ((> result 10.0) 'mail)
6381 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6382 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6383 (url-mid (concat "news" ":" mid-or-mail))
6384 (url-mailto (concat "mailto" ":" mid-or-mail)))
6385 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6386 (when (fboundp pref)
6388 ;; get rid of surrounding angles...
6390 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6391 (if (or (eq 'mid guessed) (eq 'mail guessed))
6395 (save-window-excursion
6396 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6399 (cond ((eq pref 'mid)
6400 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6401 (gnus-button-handle-news url-mid))
6403 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6404 (gnus-url-mailto url-mailto))
6405 (t (gnus-message 3 "Invalid string.")))))
6407 (defun gnus-button-handle-custom (url)
6408 "Follow a Custom URL."
6409 (customize-apropos (gnus-url-unhex-string url)))
6411 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6413 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6416 (defun gnus-button-handle-describe-function (url)
6417 "Call `describe-function' when pushing the corresponding URL button."
6420 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6422 (defun gnus-button-handle-describe-variable (url)
6423 "Call `describe-variable' when pushing the corresponding URL button."
6426 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6428 (defun gnus-button-handle-symbol (url)
6429 "Display help on variable or function.
6430 Calls `describe-variable' or `describe-function'."
6431 (let ((sym (intern url)))
6433 ((fboundp sym) (describe-function sym))
6434 ((boundp sym) (describe-variable sym))
6435 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6437 (defun gnus-button-handle-describe-key (url)
6438 "Call `describe-key' when pushing the corresponding URL button."
6440 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6441 (keys (ignore-errors (eval `(kbd ,key-string)))))
6444 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6446 (defun gnus-button-handle-apropos (url)
6447 "Call `apropos' when pushing the corresponding URL button."
6448 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6450 (defun gnus-button-handle-apropos-command (url)
6451 "Call `apropos' when pushing the corresponding URL button."
6453 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6455 (defun gnus-button-handle-apropos-variable (url)
6456 "Call `apropos' when pushing the corresponding URL button."
6458 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6459 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6461 (defun gnus-button-handle-apropos-documentation (url)
6462 "Call `apropos' when pushing the corresponding URL button."
6464 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6465 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6467 (defun gnus-button-handle-library (url)
6468 "Call `locate-library' when pushing the corresponding URL button."
6469 (gnus-message 9 "url=`%s'" url)
6470 (let* ((lib (locate-library url))
6471 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6473 (gnus-message 1 "Cannot locale library `%s'." url)
6474 (find-file-read-only file))))
6476 (defun gnus-button-handle-ctan (url)
6477 "Call `browse-url' when pushing a CTAN URL button."
6479 gnus-button-ctan-handler
6482 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6484 (defcustom gnus-button-tex-level 5
6485 "*Integer that says how many TeX-related buttons Gnus will show.
6486 The higher the number, the more buttons will appear and the more false
6487 positives are possible. Note that you can set this variable local to
6488 specific groups. Setting it higher in TeX groups is probably a good idea.
6489 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6490 how to set variables in specific groups."
6491 :group 'gnus-article-buttons
6492 :link '(custom-manual "(gnus)Group Parameters")
6495 (defcustom gnus-button-man-level 5
6496 "*Integer that says how many man-related buttons Gnus will show.
6497 The higher the number, the more buttons will appear and the more false
6498 positives are possible. Note that you can set this variable local to
6499 specific groups. Setting it higher in Unix groups is probably a good idea.
6500 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6501 how to set variables in specific groups."
6502 :group 'gnus-article-buttons
6503 :link '(custom-manual "(gnus)Group Parameters")
6506 (defcustom gnus-button-emacs-level 5
6507 "*Integer that says how many emacs-related buttons Gnus will show.
6508 The higher the number, the more buttons will appear and the more false
6509 positives are possible. Note that you can set this variable local to
6510 specific groups. Setting it higher in Emacs or Gnus related groups is
6511 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6512 `gnus-parameters' on how to set variables in specific groups."
6513 :group 'gnus-article-buttons
6514 :link '(custom-manual "(gnus)Group Parameters")
6517 (defcustom gnus-button-message-level 5
6518 "*Integer that says how many buttons for news or mail messages will appear.
6519 The higher the number, the more buttons will appear and the more false
6520 positives are possible."
6521 ;; mail addresses, MIDs, URLs for news, ...
6522 :group 'gnus-article-buttons
6525 (defcustom gnus-button-browse-level 5
6526 "*Integer that says how many buttons for browsing will appear.
6527 The higher the number, the more buttons will appear and the more false
6528 positives are possible."
6529 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6530 :group 'gnus-article-buttons
6533 (defcustom gnus-button-alist
6534 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6535 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6536 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6537 gnus-button-handle-news 2)
6538 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6539 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6540 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6541 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6542 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6543 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6544 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6545 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6546 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6547 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6548 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6549 ;; RFC 2368 (The mailto URL scheme)
6550 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6551 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6552 ("\\bmailto:\\([^ \n\t]+\\)"
6553 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6555 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6556 gnus-button-ctan-directory-regexp
6557 "[^][>)!;:,'\n\t ]+\\)")
6558 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6559 ((concat "\\btex-archive/\\("
6560 gnus-button-ctan-directory-regexp
6561 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6562 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6565 gnus-button-ctan-directory-regexp
6566 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6567 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6568 ;; This is info (home-grown style) <info://foo/bar+baz>
6569 ("\\binfo://\\([^'\">\n\t ]+\\)"
6570 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6571 ;; Info GNOME style <info:foo#bar_baz>
6572 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6573 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6574 ;; Info KDE style <info:(foo)bar baz>
6575 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6576 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6577 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6578 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6579 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6580 ;; Info links like `C-h i d m CC Mode RET'
6581 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6583 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6584 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6585 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6586 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6587 ;; Emacs help commands
6588 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6589 ;; regexp doesn't match arguments containing ` '.
6590 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6591 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6592 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6593 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6594 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6595 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6596 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6597 ;; The following entries may lead to many false positives so don't enable
6598 ;; them by default (use a high button level):
6599 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>"
6600 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6601 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6602 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6603 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6604 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6605 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6606 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6607 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6608 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6609 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6610 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6611 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6612 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6613 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6614 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6615 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6616 ;; Unlike the other regexps we really have to require quoting
6617 ;; here to determine where it ends.
6618 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6619 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6620 ("<URL: *\\([^<>]*\\)>"
6621 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6622 ;; RFC 2396 (2.4.3., delims) ...
6623 ("\"URL: *\\([^\"]*\\)\""
6624 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6625 ;; RFC 2396 (2.4.3., delims) ...
6626 ("\"URL: *\\([^\"]*\\)\""
6627 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6629 (gnus-button-url-regexp
6630 0 (>= gnus-button-browse-level 0) browse-url 0)
6632 ("\\b\\([a-z][a-z]+\\)([1-9])\\W"
6633 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6634 gnus-button-handle-man 1)
6635 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6636 ("\\b\\([a-z][-_.a-z0-9]+\\)([1-9])\\W"
6637 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6638 gnus-button-handle-man 1)
6639 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6640 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6641 ("\\b\\([a-z][-+_.:a-z0-9]+\\)([1-9][X1a-z]*)\\W\\|\\b\\(X\\)([1-9])\\W"
6642 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6643 ;; MID or mail: To avoid too many false positives we don't try to catch
6644 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6645 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6646 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6647 ;; so that non-ambiguous entries (see above) match first.
6648 (gnus-button-mid-or-mail-regexp
6649 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6650 "*Alist of regexps matching buttons in article bodies.
6652 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6653 REGEXP: is the string (case insensitive) matching text around the button (can
6654 also be Lisp expression evaluating to a string),
6655 BUTTON: is the number of the regexp grouping actually matching the button,
6656 FORM: is a Lisp expression which must eval to true for the button to
6658 CALLBACK: is the function to call when the user push this button, and each
6659 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6661 CALLBACK can also be a variable, in that case the value of that
6662 variable it the real callback function."
6663 :group 'gnus-article-buttons
6664 :type '(repeat (list (choice regexp variable sexp)
6665 (integer :tag "Button")
6667 (function :tag "Callback")
6670 (integer :tag "Regexp group")))))
6672 (defcustom gnus-header-button-alist
6673 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6674 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6675 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6676 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6677 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6678 0 (>= gnus-button-message-level 0) gnus-button-mailto 0)
6679 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6680 0 (>= gnus-button-browse-level 0) browse-url 0)
6681 ("^Subject:" gnus-button-url-regexp
6682 0 (>= gnus-button-browse-level 0) browse-url 0)
6683 ("^[^:]+:" gnus-button-url-regexp
6684 0 (>= gnus-button-browse-level 0) browse-url 0)
6685 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6686 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6687 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6688 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6689 "*Alist of headers and regexps to match buttons in article heads.
6691 This alist is very similar to `gnus-button-alist', except that each
6692 alist has an additional HEADER element first in each entry:
6694 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6696 HEADER is a regexp to match a header. For a fuller explanation, see
6697 `gnus-button-alist'."
6698 :group 'gnus-article-buttons
6699 :group 'gnus-article-headers
6700 :type '(repeat (list (regexp :tag "Header")
6701 (choice regexp variable)
6702 (integer :tag "Button")
6704 (function :tag "Callback")
6707 (integer :tag "Regexp group")))))
6711 (defun gnus-article-push-button (event)
6712 "Check text under the mouse pointer for a callback function.
6713 If the text under the mouse pointer has a `gnus-callback' property,
6714 call it with the value of the `gnus-data' text property."
6716 (set-buffer (window-buffer (posn-window (event-start event))))
6717 (let* ((pos (posn-point (event-start event)))
6718 (data (get-text-property pos 'gnus-data))
6719 (fun (get-text-property pos 'gnus-callback)))
6722 (funcall fun data))))
6724 (defun gnus-article-press-button ()
6725 "Check text at point for a callback function.
6726 If the text at point has a `gnus-callback' property,
6727 call it with the value of the `gnus-data' text property."
6729 (let ((data (get-text-property (point) 'gnus-data))
6730 (fun (get-text-property (point) 'gnus-callback)))
6732 (funcall fun data))))
6734 (defun gnus-article-prev-button (n)
6735 "Move point to N buttons backward.
6736 If N is negative, move forward instead."
6738 (gnus-article-next-button (- n)))
6740 (defun gnus-article-next-button (n)
6741 "Move point to N buttons forward.
6742 If N is negative, move backward instead."
6744 (let ((function (if (< n 0) 'previous-single-property-change
6745 'next-single-property-change))
6746 (inhibit-point-motion-hooks t)
6748 (limit (if (< n 0) (point-min) (point-max))))
6750 (while (and (not (= limit (point)))
6752 ;; Skip past the current button.
6753 (when (get-text-property (point) 'gnus-callback)
6754 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6755 ;; Go to the next (or previous) button.
6756 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
6757 ;; Put point at the start of the button.
6758 (when (and backward (not (get-text-property (point) 'gnus-callback)))
6759 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6760 ;; Skip past intangible buttons.
6761 (when (get-text-property (point) 'intangible)
6765 (gnus-message 5 "No more buttons"))
6768 (defun gnus-article-highlight (&optional force)
6769 "Highlight current article.
6770 This function calls `gnus-article-highlight-headers',
6771 `gnus-article-highlight-citation',
6772 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6773 do the highlighting. See the documentation for those functions."
6774 (interactive (list 'force))
6775 (gnus-article-highlight-headers)
6776 (gnus-article-highlight-citation force)
6777 (gnus-article-highlight-signature)
6778 (gnus-article-add-buttons force)
6779 (gnus-article-add-buttons-to-head))
6781 (defun gnus-article-highlight-some (&optional force)
6782 "Highlight current article.
6783 This function calls `gnus-article-highlight-headers',
6784 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6785 do the highlighting. See the documentation for those functions."
6786 (interactive (list 'force))
6787 (gnus-article-highlight-headers)
6788 (gnus-article-highlight-signature)
6789 (gnus-article-add-buttons))
6791 (defun gnus-article-highlight-headers ()
6792 "Highlight article headers as specified by `gnus-header-face-alist'."
6794 (gnus-with-article-headers
6795 (let ((alist gnus-header-face-alist)
6796 entry regexp header-face field-face from hpoints fpoints)
6797 (while (setq entry (pop alist))
6798 (goto-char (point-min))
6799 (setq regexp (concat "^\\("
6800 (if (string-equal "" (nth 0 entry))
6804 header-face (nth 1 entry)
6805 field-face (nth 2 entry))
6806 (while (and (re-search-forward regexp nil t)
6810 (unless (search-forward ":" nil t)
6812 (when (and header-face
6813 (not (memq (point) hpoints)))
6814 (push (point) hpoints)
6815 (gnus-put-text-property from (point) 'face header-face))
6816 (when (and field-face
6817 (not (memq (setq from (point)) fpoints)))
6819 (if (re-search-forward "^[^ \t]" nil t)
6821 (goto-char (point-max)))
6822 (gnus-put-text-property from (point) 'face field-face)))))))
6824 (defun gnus-article-highlight-signature ()
6825 "Highlight the signature in an article.
6826 It does this by highlighting everything after
6827 `gnus-signature-separator' using `gnus-signature-face'."
6829 (when gnus-signature-face
6830 (gnus-with-article-buffer
6831 (let ((inhibit-point-motion-hooks t))
6833 (when (gnus-article-narrow-to-signature)
6834 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6835 'face gnus-signature-face)))))))
6837 (defun gnus-article-buttonize-signature ()
6838 "Add button to the signature."
6841 (set-buffer gnus-article-buffer)
6842 (let ((buffer-read-only nil)
6843 (inhibit-point-motion-hooks t))
6844 (when (gnus-article-search-signature)
6845 (gnus-article-add-button (match-beginning 0) (match-end 0)
6846 'gnus-signature-toggle
6847 (set-marker (make-marker)
6848 (1+ (match-end 0))))))))
6850 (defun gnus-button-in-region-p (b e prop)
6851 "Say whether PROP exists in the region."
6852 (text-property-not-all b e prop nil))
6854 (defun gnus-article-add-buttons (&optional force)
6855 "Find external references in the article and make buttons of them.
6856 \"External references\" are things like Message-IDs and URLs, as
6857 specified by `gnus-button-alist'."
6858 (interactive (list 'force))
6859 (gnus-with-article-buffer
6860 (let ((inhibit-point-motion-hooks t)
6861 (case-fold-search t)
6862 (alist gnus-button-alist)
6864 ;; Remove all old markers.
6865 (let (marker entry new-list)
6866 (while (setq marker (pop gnus-button-marker-list))
6867 (if (or (< marker (point-min)) (>= marker (point-max)))
6868 (push marker new-list)
6870 (when (setq entry (gnus-button-entry))
6871 (put-text-property (match-beginning (nth 1 entry))
6872 (match-end (nth 1 entry))
6873 'gnus-callback nil))
6874 (set-marker marker nil)))
6875 (setq gnus-button-marker-list new-list))
6876 ;; We skip the headers.
6879 (while (setq entry (pop alist))
6880 (setq regexp (eval (car entry)))
6882 (while (re-search-forward regexp nil t)
6883 (let* ((start (and entry (match-beginning (nth 1 entry))))
6884 (end (and entry (match-end (nth 1 entry))))
6885 (from (match-beginning 0)))
6886 (when (and (or (eq t (nth 2 entry))
6887 (eval (nth 2 entry)))
6888 (not (gnus-button-in-region-p
6889 start end 'gnus-callback)))
6890 ;; That optional form returned non-nil, so we add the
6892 (gnus-article-add-button
6893 start end 'gnus-button-push
6894 (car (push (set-marker (make-marker) from)
6895 gnus-button-marker-list))))))))))
6897 ;; Add buttons to the head of an article.
6898 (defun gnus-article-add-buttons-to-head ()
6899 "Add buttons to the head of the article."
6901 (gnus-with-article-headers
6902 (let ((alist gnus-header-button-alist)
6905 ;; Each alist entry.
6906 (setq entry (pop alist))
6907 (goto-char (point-min))
6908 (while (re-search-forward (car entry) nil t)
6909 ;; Each header matching the entry.
6910 (setq beg (match-beginning 0))
6911 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6912 (match-beginning 0))
6915 (while (re-search-forward (eval (nth 1 entry)) end t)
6916 ;; Each match within a header.
6917 (let* ((entry (cdr entry))
6918 (start (match-beginning (nth 1 entry)))
6919 (end (match-end (nth 1 entry)))
6920 (form (nth 2 entry)))
6921 (goto-char (match-end 0))
6923 (gnus-article-add-button
6924 start end (nth 3 entry)
6925 (buffer-substring (match-beginning (nth 4 entry))
6926 (match-end (nth 4 entry)))))))
6927 (goto-char end))))))
6929 ;;; External functions:
6931 (defun gnus-article-add-button (from to fun &optional data)
6932 "Create a button between FROM and TO with callback FUN and data DATA."
6933 (when gnus-article-button-face
6934 (gnus-overlay-put (gnus-make-overlay from to)
6935 'face gnus-article-button-face))
6936 (gnus-add-text-properties
6938 (nconc (and gnus-article-mouse-face
6939 (list gnus-mouse-face-prop gnus-article-mouse-face))
6940 (list 'gnus-callback fun)
6941 (and data (list 'gnus-data data))))
6942 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6943 :button-keymap gnus-widget-button-keymap))
6945 ;;; Internal functions:
6947 (defun gnus-article-set-globals ()
6948 (with-current-buffer gnus-summary-buffer
6949 (gnus-set-global-variables)))
6951 (defun gnus-signature-toggle (end)
6952 (gnus-with-article-buffer
6953 (let ((inhibit-point-motion-hooks t)
6954 (limit (next-single-property-change end 'mime-view-entity
6956 (if (text-property-any end limit 'article-type 'signature)
6958 (gnus-delete-wash-type 'signature)
6959 (gnus-remove-text-properties-when
6960 'article-type 'signature end limit
6961 (cons 'article-type (cons 'signature
6962 gnus-hidden-properties))))
6963 (gnus-add-wash-type 'signature)
6964 (gnus-add-text-properties-when
6965 'article-type nil end limit
6966 (cons 'article-type (cons 'signature
6967 gnus-hidden-properties)))))
6968 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6969 (gnus-set-mode-line 'article))))
6971 (defun gnus-button-entry ()
6972 ;; Return the first entry in `gnus-button-alist' matching this place.
6973 (let ((alist gnus-button-alist)
6976 (setq entry (pop alist))
6977 (if (looking-at (eval (car entry)))
6982 (defun gnus-button-push (marker)
6983 ;; Push button starting at MARKER.
6986 (let* ((entry (gnus-button-entry))
6987 (inhibit-point-motion-hooks t)
6989 (args (mapcar (lambda (group)
6990 (let ((string (match-string group)))
6991 (set-text-properties
6992 0 (length string) nil string)
6999 (fboundp (symbol-value fun)))
7000 (apply (symbol-value fun) args))
7002 (gnus-message 1 "You must define `%S' to use this button"
7003 (cons fun args)))))))
7005 (defun gnus-parse-news-url (url)
7006 (let (scheme server group message-id articles)
7009 (goto-char (point-min))
7010 (when (looking-at "\\([A-Za-z]+\\):")
7011 (setq scheme (match-string 1))
7012 (goto-char (match-end 0)))
7013 (when (looking-at "//\\([^/]+\\)/")
7014 (setq server (match-string 1))
7015 (goto-char (match-end 0)))
7018 ((looking-at "\\(.*@.*\\)")
7019 (setq message-id (match-string 1)))
7020 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7021 (setq group (match-string 1)
7022 articles (split-string (match-string 2) "-")))
7023 ((looking-at "\\([^/]+\\)/?")
7024 (setq group (match-string 1)))
7026 (error "Unknown news URL syntax"))))
7027 (list scheme server group message-id articles)))
7029 (defun gnus-button-handle-news (url)
7031 (destructuring-bind (scheme server group message-id articles)
7032 (gnus-parse-news-url url)
7036 (set-buffer gnus-summary-buffer)
7038 (let ((gnus-refer-article-method (list (list 'nntp server))))
7039 (gnus-summary-refer-article message-id))
7040 (gnus-summary-refer-article message-id))))
7042 (gnus-button-fetch-group url)))))
7044 (defun gnus-button-handle-man (url)
7046 (funcall gnus-button-man-handler url))
7048 (defun gnus-button-handle-info-url (url)
7049 "Fetch an info URL."
7050 (setq url (mm-subst-char-in-string ?+ ?\ url))
7052 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
7053 (gnus-info-find-node
7054 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
7056 ")" (gnus-url-unhex-string (match-string 2 url)))))
7057 ((string-match "([^)\"]+)[^\"]+" url)
7059 (gnus-replace-in-string
7060 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
7061 (gnus-info-find-node url))
7062 (t (error "Can't parse %s" url))))
7064 (defun gnus-button-handle-info-url-gnome (url)
7065 "Fetch GNOME style info URL."
7066 (setq url (mm-subst-char-in-string ?_ ?\ url))
7067 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
7068 (gnus-info-find-node
7070 (gnus-url-unhex-string
7071 (match-string 1 url))
7073 (or (gnus-url-unhex-string
7074 (match-string 2 url))
7076 (error "Can't parse %s" url)))
7078 (defun gnus-button-handle-info-url-kde (url)
7079 "Fetch KDE style info URL."
7080 (gnus-info-find-node (gnus-url-unhex-string url)))
7082 (defun gnus-button-handle-info-keystrokes (url)
7083 "Call `info' when pushing the corresponding URL button."
7084 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
7089 (defun gnus-button-message-id (message-id)
7091 (with-current-buffer gnus-summary-buffer
7092 (gnus-summary-refer-article message-id)))
7094 (defun gnus-button-fetch-group (address)
7095 "Fetch GROUP specified by ADDRESS."
7096 (if (not (string-match "[:/]" address))
7097 ;; This is just a simple group url.
7098 (gnus-group-read-ephemeral-group address gnus-select-method)
7101 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
7103 (error "Can't parse %s" address)
7104 (gnus-group-read-ephemeral-group
7105 (match-string 4 address)
7106 `(nntp ,(match-string 1 address)
7107 (nntp-address ,(match-string 1 address))
7108 (nntp-port-number ,(if (match-end 3)
7109 (match-string 3 address)
7112 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
7114 (defun gnus-url-parse-query-string (query &optional downcase)
7115 (let (retval pairs cur key val)
7116 (setq pairs (split-string query "&"))
7118 (setq cur (car pairs)
7120 (if (not (string-match "=" cur))
7122 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
7123 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
7125 (setq key (downcase key)))
7126 (setq cur (assoc key retval))
7128 (setcdr cur (cons val (cdr cur)))
7129 (setq retval (cons (list key val) retval)))))
7132 (defun gnus-url-mailto (url)
7133 ;; Send mail to someone
7134 (when (string-match "mailto:/*\\(.*\\)" url)
7135 (setq url (substring url (match-beginning 1) nil)))
7136 (let (to args subject func)
7137 (setq args (gnus-url-parse-query-string
7138 (if (string-match "^\\?" url)
7140 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
7141 (concat "to=" (match-string 1 url) "&"
7142 (match-string 2 url))
7143 (concat "to=" url)))
7145 subject (cdr-safe (assoc "subject" args)))
7148 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
7151 (message-position-on-field (caar args)))
7152 (insert (gnus-replace-in-string
7153 (mapconcat 'identity (reverse (cdar args)) ", ")
7155 (setq args (cdr args)))
7158 (message-goto-subject))))
7160 (defun gnus-button-embedded-url (address)
7161 "Activate ADDRESS with `browse-url'."
7162 (browse-url (gnus-strip-whitespace address)))
7164 ;;; Next/prev buttons in the article buffer.
7166 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
7167 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
7169 (defvar gnus-prev-page-map
7170 (let ((map (make-sparse-keymap)))
7171 (define-key map gnus-mouse-2 'gnus-button-prev-page)
7172 (define-key map "\r" 'gnus-button-prev-page)
7175 (defvar gnus-next-page-map
7176 (let ((map (make-sparse-keymap)))
7177 (define-key map gnus-mouse-2 'gnus-button-next-page)
7178 (define-key map "\r" 'gnus-button-next-page)
7181 (defun gnus-insert-prev-page-button ()
7183 (buffer-read-only nil)
7184 (situation (get-text-property (point-min) 'mime-view-situation)))
7186 gnus-prev-page-line-format nil
7187 `(keymap ,gnus-prev-page-map
7189 gnus-callback gnus-article-button-prev-page
7190 article-type annotation
7191 mime-view-situation ,situation))
7192 (widget-convert-button
7194 ;; Exclude a newline.
7197 :action 'gnus-button-prev-page
7198 :button-keymap gnus-prev-page-map)))
7200 (defun gnus-button-next-page (&optional args more-args)
7201 "Go to the next page."
7203 (let ((win (selected-window)))
7204 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7205 (gnus-article-next-page)
7206 (select-window win)))
7208 (defun gnus-button-prev-page (&optional args more-args)
7209 "Go to the prev page."
7211 (let ((win (selected-window)))
7212 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7213 (gnus-article-prev-page)
7214 (select-window win)))
7216 (defun gnus-insert-next-page-button ()
7218 (buffer-read-only nil)
7219 (situation (get-text-property (point-min) 'mime-view-situation)))
7220 (gnus-eval-format gnus-next-page-line-format nil
7221 `(keymap ,gnus-next-page-map
7223 gnus-callback gnus-article-button-next-page
7224 article-type annotation
7225 mime-view-situation ,situation))
7226 (widget-convert-button
7228 ;; Exclude a newline.
7231 :action 'gnus-button-next-page
7232 :button-keymap gnus-next-page-map)))
7234 (defun gnus-article-button-next-page (arg)
7235 "Go to the next page."
7237 (let ((win (selected-window)))
7238 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7239 (gnus-article-next-page)
7240 (select-window win)))
7242 (defun gnus-article-button-prev-page (arg)
7243 "Go to the prev page."
7245 (let ((win (selected-window)))
7246 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7247 (gnus-article-prev-page)
7248 (select-window win)))
7250 (defvar gnus-decode-header-methods
7251 '(mail-decode-encoded-word-region)
7252 "List of methods used to decode headers.
7254 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7255 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
7256 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
7257 whose names match REGEXP.
7260 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7261 mail-decode-encoded-word-region
7262 (\"chinese\" . rfc1843-decode-region))
7265 (defvar gnus-decode-header-methods-cache nil)
7267 (defun gnus-multi-decode-header (start end)
7268 "Apply the functions from `gnus-encoded-word-methods' that match."
7269 (unless (and gnus-decode-header-methods-cache
7270 (eq gnus-newsgroup-name
7271 (car gnus-decode-header-methods-cache)))
7272 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7275 (nconc gnus-decode-header-methods-cache (list x))
7276 (if (and gnus-newsgroup-name
7277 (string-match (car x) gnus-newsgroup-name))
7278 (nconc gnus-decode-header-methods-cache
7280 gnus-decode-header-methods))
7281 (let ((xlist gnus-decode-header-methods-cache))
7284 (narrow-to-region start end)
7286 (funcall (pop xlist) (point-min) (point-max))))))
7289 ;;; Treatment top-level handling.
7292 (defun gnus-treat-article (condition &optional part-number total-parts type)
7293 (let ((length (- (point-max) (point-min)))
7294 (alist gnus-treatment-function-alist)
7295 (article-goto-body-goes-to-point-min-p t)
7299 (let ((list gnus-article-treat-types))
7301 (when (string-match (pop list) type)
7302 (throw 'found t)))))))
7303 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7304 (entity (static-unless (featurep 'xemacs)
7305 (when (eq 'head condition)
7306 (get-text-property (point-min) 'mime-view-entity))))
7307 val elem buttonized)
7308 (gnus-run-hooks 'gnus-part-display-hook)
7309 (unless gnus-inhibit-treatment
7310 (dolist (elem alist)
7313 (when (gnus-buffer-live-p gnus-summary-buffer)
7314 (set-buffer gnus-summary-buffer))
7315 (symbol-value (car elem))))
7316 (when (and (or (consp val)
7318 (gnus-treat-predicate val)
7319 (or (not (get (car elem) 'highlight))
7321 (when (and (not buttonized)
7323 '(gnus-treat-hide-signature
7324 gnus-treat-highlight-signature)))
7325 (gnus-article-buttonize-signature)
7326 (setq buttonized t))
7328 (funcall (cadr elem)))))
7329 ;; FSF Emacsen does not inherit the existing text properties
7330 ;; in the new text, so we should do it for `mime-view-entity'.
7331 (static-unless (featurep 'xemacs)
7333 (put-text-property (point-min) (point-max)
7334 'mime-view-entity entity))))))
7336 ;; Dynamic variables.
7338 (defvar part-number)
7339 (defvar total-parts)
7344 (defun gnus-treat-predicate (val)
7349 (stringp (car val)))
7350 (apply 'gnus-or (mapcar `(lambda (s)
7351 (string-match s ,(or gnus-newsgroup-name "")))
7354 (let ((pred (pop val)))
7357 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7359 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7361 (not (gnus-treat-predicate (car val))))
7363 (equal (car val) type))
7365 (error "%S is not a valid predicate" pred)))))
7375 (eq part-number total-parts))
7379 (error "%S is not a valid value" val))))
7381 (defun gnus-article-encrypt-body (protocol &optional n)
7382 "Encrypt the article body."
7385 (or gnus-article-encrypt-protocol
7386 (completing-read "Encrypt protocol: "
7387 gnus-article-encrypt-protocol-alist
7389 current-prefix-arg))
7390 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7392 (error (format "Can't find the encrypt protocol %s" protocol)))
7393 (if (member gnus-newsgroup-name '("nndraft:delayed"
7396 (error "Can't encrypt the article in group %s"
7397 gnus-newsgroup-name))
7398 (gnus-summary-iterate n
7400 (set-buffer gnus-summary-buffer)
7401 (let ((mail-parse-charset gnus-newsgroup-charset)
7402 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7403 (summary-buffer gnus-summary-buffer)
7405 (gnus-set-global-variables)
7406 (when (gnus-group-read-only-p)
7407 (error "The current newsgroup does not support article encrypt"))
7408 (gnus-summary-show-article t)
7410 (or (mail-header-references gnus-current-headers) ""))
7411 (set-buffer gnus-article-buffer)
7412 (let* ((buffer-read-only nil)
7414 (mapcar (lambda (field)
7415 (and (save-restriction
7416 (message-narrow-to-head)
7417 (goto-char (point-min))
7418 (search-forward field nil t))
7420 (message-narrow-to-field)
7422 (delete-region (point-min) (point-max))
7424 '("Content-Type:" "Content-Transfer-Encoding:"
7425 "Content-Disposition:"))))
7426 (message-narrow-to-head)
7427 (message-remove-header "MIME-Version")
7428 (goto-char (point-max))
7429 (setq point (point))
7430 (insert (apply 'concat headers))
7432 (narrow-to-region point (point-max))
7433 (let ((message-options message-options))
7434 (message-options-set 'message-sender user-mail-address)
7435 (message-options-set 'message-recipients user-mail-address)
7436 (message-options-set 'message-sign-encrypt 'not)
7438 (goto-char (point-min))
7439 (insert "MIME-Version: 1.0\n")
7441 (gnus-summary-edit-article-done
7442 references nil summary-buffer t))
7443 (when gnus-keep-backlog
7444 (gnus-backlog-remove-article
7445 (car gnus-article-current) (cdr gnus-article-current)))
7447 (when (get-buffer gnus-original-article-buffer)
7448 (set-buffer gnus-original-article-buffer)
7449 (setq gnus-original-article nil)))
7450 (when gnus-use-cache
7451 (gnus-cache-update-article
7452 (car gnus-article-current) (cdr gnus-article-current))))))))
7454 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7455 "The following specs can be used:
7456 %t The security MIME type
7459 %D Details if button is pressed")
7461 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7462 "The following specs can be used:
7463 %t The security MIME type
7466 %D Details if button is pressed")
7468 (defvar gnus-mime-security-button-line-format-alist
7469 '((?t gnus-tmp-type ?s)
7470 (?i gnus-tmp-info ?s)
7471 (?d gnus-tmp-details ?s)
7472 (?D gnus-tmp-pressed-details ?s)))
7474 (defvar gnus-mime-security-button-map
7475 (let ((map (make-sparse-keymap)))
7476 (define-key map gnus-mouse-2 'gnus-article-push-button)
7477 (define-key map "\r" 'gnus-article-press-button)
7480 (defvar gnus-mime-security-details-buffer nil)
7482 (defvar gnus-mime-security-button-pressed nil)
7484 (defvar gnus-mime-security-show-details-inline t
7485 "If non-nil, show details in the article buffer.")
7487 (defun gnus-mime-security-verify-or-decrypt (handle)
7488 (mm-remove-parts (cdr handle))
7489 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7490 point buffer-read-only)
7492 (goto-char (car region)))
7494 (narrow-to-region (point) (point))
7495 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7496 (let* ((mm-verify-option 'known)
7497 (mm-decrypt-option 'known)
7498 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7499 (unless (eq nparts (cdr handle))
7500 (mm-destroy-parts (cdr handle))
7501 (setcdr handle nparts))))
7502 (setq point (point))
7503 (gnus-mime-display-security handle)
7504 (goto-char (point-max)))
7506 (delete-region (point) (cdr region))
7507 (set-marker (car region) nil)
7508 (set-marker (cdr region) nil))
7511 (defun gnus-mime-security-show-details (handle)
7512 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7514 (gnus-message 5 "No details.")
7515 (if gnus-mime-security-show-details-inline
7516 (let ((gnus-mime-security-button-pressed
7517 (not (get-text-property (point) 'gnus-mime-details)))
7518 (gnus-mime-security-button-line-format
7519 (get-text-property (point) 'gnus-line-format))
7522 (while (eq (get-text-property (point) 'gnus-line-format)
7523 gnus-mime-security-button-line-format)
7527 (narrow-to-region (point) (point))
7528 (gnus-insert-mime-security-button handle))
7529 (delete-region (point)
7530 (or (text-property-not-all
7533 gnus-mime-security-button-line-format)
7536 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7537 (with-current-buffer gnus-mime-security-details-buffer
7540 (setq gnus-mime-security-details-buffer
7541 (gnus-get-buffer-create "*MIME Security Details*")))
7542 (with-current-buffer gnus-mime-security-details-buffer
7544 (goto-char (point-min)))
7545 (pop-to-buffer gnus-mime-security-details-buffer)))))
7547 (defun gnus-mime-security-press-button (handle)
7549 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7550 (gnus-mime-security-show-details handle)
7551 (gnus-mime-security-verify-or-decrypt handle))))
7553 (defun gnus-insert-mime-security-button (handle &optional displayed)
7554 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7557 (or (nth 2 (assoc protocol mm-verify-function-alist))
7558 (nth 2 (assoc protocol mm-decrypt-function-alist))
7560 (if (equal (car handle) "multipart/signed")
7561 " Signed" " Encrypted")
7564 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7567 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7568 gnus-tmp-pressed-details
7570 (setq gnus-tmp-details
7571 (if gnus-tmp-details
7572 (concat "\n" gnus-tmp-details)
7574 (setq gnus-tmp-pressed-details
7575 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7580 gnus-mime-security-button-line-format
7581 gnus-mime-security-button-line-format-alist
7582 `(keymap ,gnus-mime-security-button-map
7583 gnus-callback gnus-mime-security-press-button
7584 gnus-line-format ,gnus-mime-security-button-line-format
7585 gnus-mime-details ,gnus-mime-security-button-pressed
7586 article-type annotation
7589 ;; Exclude a newline.
7592 (widget-convert-button
7595 :action 'gnus-widget-press-button
7596 :button-keymap gnus-mime-security-button-map
7598 (lambda (widget/window &optional overlay pos)
7599 ;; Needed to properly clear the message due to a bug in
7600 ;; wid-edit (XEmacs only).
7601 (when (boundp 'help-echo-owns-message)
7602 (setq help-echo-owns-message t))
7605 (aref gnus-mouse-2 0))))))
7607 (defun gnus-mime-display-security (handle)
7609 (narrow-to-region (point) (point))
7610 (unless (gnus-unbuttonized-mime-type-p (car handle))
7611 (gnus-insert-mime-security-button handle))
7612 (gnus-mime-display-mixed (cdr handle))
7615 (unless (gnus-unbuttonized-mime-type-p (car handle))
7616 (let ((gnus-mime-security-button-line-format
7617 gnus-mime-security-button-end-line-format))
7618 (gnus-insert-mime-security-button handle)))
7619 (mm-set-handle-multipart-parameter
7621 (cons (set-marker (make-marker) (point-min))
7622 (set-marker (make-marker) (point-max))))))
7628 (defun gnus-article-header-presentation-method (entity situation)
7629 (mime-insert-header entity)
7630 (article-decode-group-name))
7632 (set-alist 'mime-header-presentation-method-alist
7633 'gnus-original-article-mode
7634 #'gnus-article-header-presentation-method)
7636 (defun gnus-mime-preview-quitting-method ()
7637 (mime-preview-kill-buffer)
7638 (delete-other-windows)
7639 (gnus-article-show-summary)
7640 (gnus-summary-select-article gnus-show-all-headers t))
7642 (set-alist 'mime-preview-quitting-method-alist
7643 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
7645 (set-alist 'mime-preview-following-method-alist
7646 'gnus-original-article-mode #'gnus-following-method)
7648 (set-alist 'mime-preview-over-to-previous-method-alist
7649 'gnus-original-article-mode
7651 (if (> (point-min) 1)
7652 (gnus-article-prev-page)
7653 (gnus-article-read-summary-keys
7654 nil (gnus-character-to-event ?P)))))
7656 (set-alist 'mime-preview-over-to-next-method-alist
7657 'gnus-original-article-mode'
7659 (if (< (point-max) (buffer-size))
7660 (gnus-article-next-page)
7661 (gnus-article-read-summary-keys
7662 nil (gnus-character-to-event ?N)))))
7672 (run-hooks 'gnus-art-load-hook)
7674 ;;; gnus-art.el ends here