1 ;;; gnus-art.el --- article mode commands for Semi-gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;; Katsumi Yamaoka <yamaoka@jpl.org>
8 ;; Keywords: mail, news, MIME
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
31 (eval-when-compile (require 'cl))
32 (eval-when-compile (require 'static))
44 ;; Avoid byte-compile warnings.
52 (autoload 'gnus-msg-mail "gnus-msg" nil t)
53 (autoload 'gnus-button-mailto "gnus-msg")
54 (autoload 'gnus-button-reply "gnus-msg" nil t)
56 (defgroup gnus-article nil
58 :link '(custom-manual "(gnus)The Article Buffer")
61 (defgroup gnus-article-treat nil
62 "Treating article parts."
63 :link '(custom-manual "(gnus)Article Hiding")
66 (defgroup gnus-article-hiding nil
67 "Hiding article parts."
68 :link '(custom-manual "(gnus)Article Hiding")
71 (defgroup gnus-article-highlight nil
72 "Article highlighting."
73 :link '(custom-manual "(gnus)Article Highlighting")
77 (defgroup gnus-article-signature nil
79 :link '(custom-manual "(gnus)Article Signature")
82 (defgroup gnus-article-headers nil
84 :link '(custom-manual "(gnus)Hiding Headers")
87 (defgroup gnus-article-washing nil
88 "Special commands on articles."
89 :link '(custom-manual "(gnus)Article Washing")
92 (defgroup gnus-article-emphasis nil
93 "Fontisizing articles."
94 :link '(custom-manual "(gnus)Article Fontisizing")
97 (defgroup gnus-article-saving nil
99 :link '(custom-manual "(gnus)Saving Articles")
100 :group 'gnus-article)
102 (defgroup gnus-article-mime nil
103 "Worshiping the MIME wonder."
104 :link '(custom-manual "(gnus)Using MIME")
105 :group 'gnus-article)
107 (defgroup gnus-article-buttons nil
108 "Pushable buttons in the article buffer."
109 :link '(custom-manual "(gnus)Article Buttons")
110 :group 'gnus-article)
112 (defgroup gnus-article-various nil
113 "Other article options."
114 :link '(custom-manual "(gnus)Misc Article")
115 :group 'gnus-article)
117 (defcustom gnus-ignored-headers
120 (concat "^" header ":"))
121 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
122 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
123 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
124 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
125 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
126 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
127 "X-Attribution" "X-Originating-IP" "Delivered-To"
128 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
129 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
130 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
131 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
132 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
133 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
134 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
135 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
136 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
137 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
138 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
139 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
140 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
141 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
142 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
143 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
144 "List-[A-Za-z]+" "X-Listprocessor-Version"
145 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
146 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
147 "X-Received" "Content-length" "X-precedence"
148 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
149 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
150 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
151 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
152 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
153 "X-Content-length" "X-Posting-Agent" "Original-Received"
154 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
155 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
156 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
157 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
158 "X-Abuse-and-DMCA-Info" "X-Postfilter"))
159 "*All headers that start with this regexp will be hidden.
160 This variable can also be a list of regexps of headers to be ignored.
161 If `gnus-visible-headers' is non-nil, this variable will be ignored."
162 :type '(choice :custom-show nil
165 :group 'gnus-article-hiding)
167 (defcustom gnus-visible-headers
168 "^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:"
169 "*All headers that do not match this regexp will be hidden.
170 This variable can also be a list of regexp of headers to remain visible.
171 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
172 :type '(repeat :value-to-internal (lambda (widget value)
173 (custom-split-regexp-maybe value))
174 :match (lambda (widget value)
176 (widget-editable-list-match widget value)))
178 :group 'gnus-article-hiding)
180 (defcustom gnus-sorted-header-list
181 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
182 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
183 "*This variable is a list of regular expressions.
184 If it is non-nil, headers that match the regular expressions will
185 be placed first in the article buffer in the sequence specified by
187 :type '(repeat regexp)
188 :group 'gnus-article-hiding)
190 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
191 "Headers that are only to be displayed if they have interesting data.
192 Possible values in this list are:
194 'empty Headers with no content.
195 'newsgroups Newsgroup identical to Gnus group.
196 'to-address To identical to To-address.
197 'followup-to Followup-to identical to Newsgroups.
198 'reply-to Reply-to identical to From.
199 'date Date less than four days old.
200 'long-to To and/or Cc longer than 1024 characters.
201 'many-to Multiple To and/or Cc."
202 :type '(set (const :tag "Headers with no content." empty)
203 (const :tag "Newsgroups identical to Gnus group." newsgroups)
204 (const :tag "To identical to To-address." to-address)
205 (const :tag "Followup-to identical to Newsgroups." followup-to)
206 (const :tag "Reply-to identical to From." reply-to)
207 (const :tag "Date less than four days old." date)
208 (const :tag "To and/or Cc longer than 1024 characters." long-to)
209 (const :tag "Multiple To and/or Cc headers." many-to))
210 :group 'gnus-article-hiding)
212 (defcustom gnus-article-skip-boring nil
213 "Skip over text that is not worth reading.
214 By default, if you set this t, then Gnus will display citations and
215 signatures, but will never scroll down to show you a page consisting
216 only of boring text. Boring text is controlled by
217 `gnus-article-boring-faces'."
219 :group 'gnus-article-hiding)
221 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
222 "Regexp matching signature separator.
223 This can also be a list of regexps. In that case, it will be checked
224 from head to tail looking for a separator. Searches will be done from
225 the end of the buffer."
226 :type '(repeat string)
227 :group 'gnus-article-signature)
229 (defcustom gnus-signature-limit nil
230 "Provide a limit to what is considered a signature.
231 If it is a number, no signature may not be longer (in characters) than
232 that number. If it is a floating point number, no signature may be
233 longer (in lines) than that number. If it is a function, the function
234 will be called without any parameters, and if it returns nil, there is
235 no signature in the buffer. If it is a string, it will be used as a
236 regexp. If it matches, the text in question is not a signature."
237 :type '(choice (integer :value 200)
239 (function :value fun)
240 (regexp :value ".*"))
241 :group 'gnus-article-signature)
243 (defcustom gnus-hidden-properties '(invisible t intangible t)
244 "Property list to use for hiding text."
246 :group 'gnus-article-hiding)
248 ;; Fixme: This isn't the right thing for mixed graphical and and
249 ;; non-graphical frames in a session.
250 (defcustom gnus-article-x-face-command
253 (if (or (gnus-image-type-available-p 'xface)
254 (gnus-image-type-available-p 'pbm))
255 'gnus-display-x-face-in-from
256 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -"))
257 ((and (fboundp 'image-type-available-p)
258 (module-installed-p 'x-face-e21))
259 'x-face-decode-message-header)
260 ((gnus-image-type-available-p 'pbm)
261 'gnus-display-x-face-in-from)
263 (module-installed-p 'x-face-mule))
264 'x-face-mule-gnus-article-display-x-face)
266 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
268 "*String or function to be executed to display an X-Face header.
269 If it is a string, the command will be executed in a sub-shell
270 asynchronously. The compressed face will be piped to this command."
272 ,@(let (x-face-e21 x-face-mule)
273 (if (featurep 'xemacs)
275 (setq x-face-e21 (module-installed-p 'x-face-e21)
276 x-face-mule (module-installed-p 'x-face-mule)))
280 (if (or (gnus-image-type-available-p 'xface)
281 (gnus-image-type-available-p 'pbm))
282 '(function-item gnus-display-x-face-in-from))
284 (fboundp 'image-type-available-p))
286 :tag "x-face-decode-message-header (x-face-e21)"
287 x-face-decode-message-header))
290 x-face-mule-gnus-article-display-x-face))
294 :group 'gnus-article-washing)
296 (defcustom gnus-article-x-face-too-ugly nil
297 "Regexp matching posters whose face shouldn't be shown automatically."
298 :type '(choice regexp (const nil))
299 :group 'gnus-article-washing)
301 (defcustom gnus-article-banner-alist nil
302 "Banner alist for stripping.
304 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
306 :type '(repeat (cons symbol regexp))
307 :group 'gnus-article-washing)
309 (gnus-define-group-parameter
312 "Alist of regexps (to match group names) and banner."
313 :variable-group gnus-article-washing
315 '(choice :tag "Banner"
317 (const :tag "Remove signature" signature)
318 (symbol :tag "Item in `gnus-article-banner-alist'" none)
320 (const :tag "None" nil))
322 "If non-nil, specify how to remove `banners' from articles.
324 Symbol `signature' means to remove signatures delimited by
325 `gnus-signature-separator'. Any other symbol is used to look up a
326 regular expression to match the banner in `gnus-article-banner-alist'.
327 A string is used as a regular expression to match the banner
330 (defcustom gnus-article-address-banner-alist nil
331 "Alist of mail addresses and banners.
332 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
333 to match a mail address in the From: header, BANNER is one of a symbol
334 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
335 If ADDRESS matches author's mail address, it will remove things like
336 advertisements. For example:
338 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
342 (regexp :tag "Address")
343 (choice :tag "Banner" :value nil
344 (const :tag "Remove signature" signature)
345 (symbol :tag "Item in `gnus-article-banner-alist'" none)
347 (const :tag "None" nil))))
348 :group 'gnus-article-washing)
350 (defcustom gnus-emphasis-alist
352 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
357 ("_/" "/_" underline-italic)
358 ("_\\*" "\\*_" underline-bold)
359 ("\\*/" "/\\*" bold-italic)
360 ("_\\*/" "/\\*_" underline-bold-italic))))
364 (format format (car spec) (car (cdr spec)))
365 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
367 ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
368 2 3 gnus-emphasis-strikethru)
369 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
370 2 3 gnus-emphasis-underline)))
371 "*Alist that says how to fontify certain phrases.
372 Each item looks like this:
374 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
376 The first element is a regular expression to be matched. The second
377 is a number that says what regular expression grouping used to find
378 the entire emphasized word. The third is a number that says what
379 regexp grouping should be displayed and highlighted. The fourth
380 is the face used for highlighting."
381 :type '(repeat (list :value ("" 0 0 default)
383 (integer :tag "Match group")
384 (integer :tag "Emphasize group")
386 :group 'gnus-article-emphasis)
388 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
389 "A regexp to describe whitespace which should not be emphasized.
390 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
391 The former avoids underlining of leading and trailing whitespace,
392 and the latter avoids underlining any whitespace at all."
394 :group 'gnus-article-emphasis
397 (defface gnus-emphasis-bold '((t (:bold t)))
398 "Face used for displaying strong emphasized text (*word*)."
399 :group 'gnus-article-emphasis)
401 (defface gnus-emphasis-italic '((t (:italic t)))
402 "Face used for displaying italic emphasized text (/word/)."
403 :group 'gnus-article-emphasis)
405 (defface gnus-emphasis-underline '((t (:underline t)))
406 "Face used for displaying underlined emphasized text (_word_)."
407 :group 'gnus-article-emphasis)
409 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
410 "Face used for displaying underlined bold emphasized text (_*word*_)."
411 :group 'gnus-article-emphasis)
413 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
414 "Face used for displaying underlined italic emphasized text (_/word/_)."
415 :group 'gnus-article-emphasis)
417 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
418 "Face used for displaying bold italic emphasized text (/*word*/)."
419 :group 'gnus-article-emphasis)
421 (defface gnus-emphasis-underline-bold-italic
422 '((t (:bold t :italic t :underline t)))
423 "Face used for displaying underlined bold italic emphasized text.
424 Example: (_/*word*/_)."
425 :group 'gnus-article-emphasis)
427 (defface gnus-emphasis-strikethru '((t (:strikethru t)))
428 "Face used for displaying strike-through text (-word-)."
429 :group 'gnus-article-emphasis)
431 (defface gnus-emphasis-highlight-words
432 '((t (:background "black" :foreground "yellow")))
433 "Face used for displaying highlighted words."
434 :group 'gnus-article-emphasis)
436 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
437 "Format for display of Date headers in article bodies.
438 See `format-time-string' for the possible values.
440 The variable can also be function, which should return a complete Date
441 header. The function is called with one argument, the time, which can
442 be fed to `format-time-string'."
443 :type '(choice string symbol)
444 :link '(custom-manual "(gnus)Article Date")
445 :group 'gnus-article-washing)
448 (autoload 'mail-extract-address-components "mail-extr"))
450 (defcustom gnus-save-all-headers t
451 "*If non-nil, don't remove any headers before saving."
452 :group 'gnus-article-saving
455 (defcustom gnus-prompt-before-saving 'always
456 "*This variable says how much prompting is to be done when saving articles.
457 If it is nil, no prompting will be done, and the articles will be
458 saved to the default files. If this variable is `always', each and
459 every article that is saved will be preceded by a prompt, even when
460 saving large batches of articles. If this variable is neither nil not
461 `always', there the user will be prompted once for a file name for
462 each invocation of the saving commands."
463 :group 'gnus-article-saving
464 :type '(choice (item always)
465 (item :tag "never" nil)
466 (sexp :tag "once" :format "%t\n" :value t)))
468 (defcustom gnus-saved-headers gnus-visible-headers
469 "Headers to keep if `gnus-save-all-headers' is nil.
470 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
471 If that variable is nil, however, all headers that match this regexp
472 will be kept while the rest will be deleted before saving."
473 :group 'gnus-article-saving
476 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
477 "A function to save articles in your favourite format.
478 The function must be interactively callable (in other words, it must
479 be an Emacs command).
481 Gnus provides the following functions:
483 * gnus-summary-save-in-rmail (Rmail format)
484 * gnus-summary-save-in-mail (Unix mail format)
485 * gnus-summary-save-in-folder (MH folder)
486 * gnus-summary-save-in-file (article format)
487 * gnus-summary-save-body-in-file (article body)
488 * gnus-summary-save-in-vm (use VM's folder format)
489 * gnus-summary-write-to-file (article format -- overwrite)."
490 :group 'gnus-article-saving
491 :type '(radio (function-item gnus-summary-save-in-rmail)
492 (function-item gnus-summary-save-in-mail)
493 (function-item gnus-summary-save-in-folder)
494 (function-item gnus-summary-save-in-file)
495 (function-item gnus-summary-save-body-in-file)
496 (function-item gnus-summary-save-in-vm)
497 (function-item gnus-summary-write-to-file)))
499 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
500 "A function generating a file name to save articles in Rmail format.
501 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
502 :group 'gnus-article-saving
505 (defcustom gnus-mail-save-name 'gnus-plain-save-name
506 "A function generating a file name to save articles in Unix mail format.
507 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
508 :group 'gnus-article-saving
511 (defcustom gnus-folder-save-name 'gnus-folder-save-name
512 "A function generating a file name to save articles in MH folder.
513 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
514 :group 'gnus-article-saving
517 (defcustom gnus-file-save-name 'gnus-numeric-save-name
518 "A function generating a file name to save articles in article format.
519 The function is called with NEWSGROUP, HEADERS, and optional
521 :group 'gnus-article-saving
524 (defcustom gnus-split-methods
525 '((gnus-article-archive-name)
526 (gnus-article-nndoc-name))
527 "*Variable used to suggest where articles are to be saved.
528 For instance, if you would like to save articles related to Gnus in
529 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
530 you could set this variable to something like:
532 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
533 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
535 This variable is an alist where the where the key is the match and the
536 value is a list of possible files to save in if the match is non-nil.
538 If the match is a string, it is used as a regexp match on the
539 article. If the match is a symbol, that symbol will be funcalled
540 from the buffer of the article to be saved with the newsgroup as the
541 parameter. If it is a list, it will be evaled in the same buffer.
543 If this form or function returns a string, this string will be used as
544 a possible file name; and if it returns a non-nil list, that list will
545 be used as possible file names."
546 :group 'gnus-article-saving
547 :type '(repeat (choice (list :value (fun) function)
548 (cons :value ("" "") regexp (repeat string))
551 (defcustom gnus-article-display-method-for-mime
552 'gnus-article-display-mime-message
553 "Function to display a MIME message.
554 The function is called from the article buffer."
555 :group 'gnus-article-mime
558 (defcustom gnus-article-display-method-for-traditional
559 'gnus-article-display-traditional-message
560 "*Function to display a traditional message.
561 The function is called from the article buffer."
562 :group 'gnus-article-mime
565 (defcustom gnus-page-delimiter "^\^L"
566 "*Regexp describing what to use as article page delimiters.
567 The default value is \"^\^L\", which is a form linefeed at the
568 beginning of a line."
570 :group 'gnus-article-various)
572 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
573 "*The format specification for the article mode line.
574 See `gnus-summary-mode-line-format' for a closer description.
576 The following additional specs are available:
578 %w The article washing status.
579 %m The number of MIME parts in the article."
581 :group 'gnus-article-various)
583 (defcustom gnus-article-mode-hook nil
584 "*A hook for Gnus article mode."
586 :group 'gnus-article-various)
588 (when (featurep 'xemacs)
589 ;; Extracted from gnus-xmas-define in order to preserve user settings
590 (when (fboundp 'turn-off-scroll-in-place)
591 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
592 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
593 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
595 (defcustom gnus-article-menu-hook nil
596 "*Hook run after the creation of the article mode menu."
598 :group 'gnus-article-various)
600 (defcustom gnus-article-prepare-hook nil
601 "*A hook called after an article has been prepared in the article buffer."
603 :group 'gnus-article-various)
605 (defvar gnus-article-hide-pgp-hook nil)
606 (make-obsolete-variable 'gnus-article-hide-pgp-hook
607 "This variable is obsolete in Gnus 5.10.")
609 (defcustom gnus-article-button-face 'bold
610 "Face used for highlighting buttons in the article buffer.
612 An article button is a piece of text that you can activate by pressing
613 `RET' or `mouse-2' above it."
615 :group 'gnus-article-buttons)
617 (defcustom gnus-article-mouse-face 'highlight
618 "Face used for mouse highlighting in the article buffer.
620 Article buttons will be displayed in this face when the cursor is
623 :group 'gnus-article-buttons)
625 (defcustom gnus-signature-face 'gnus-signature-face
626 "Face used for highlighting a signature in the article buffer.
627 Obsolete; use the face `gnus-signature-face' for customizations instead."
629 :group 'gnus-article-highlight
630 :group 'gnus-article-signature)
632 (defface gnus-signature-face
635 "Face used for highlighting a signature in the article buffer."
636 :group 'gnus-article-highlight
637 :group 'gnus-article-signature)
639 (defface gnus-header-from-face
642 (:foreground "spring green"))
645 (:foreground "red3"))
648 "Face used for displaying from headers."
649 :group 'gnus-article-headers
650 :group 'gnus-article-highlight)
652 (defface gnus-header-subject-face
655 (:foreground "SeaGreen3"))
658 (:foreground "red4"))
660 (:bold t :italic t)))
661 "Face used for displaying subject headers."
662 :group 'gnus-article-headers
663 :group 'gnus-article-highlight)
665 (defface gnus-header-newsgroups-face
668 (:foreground "yellow" :italic t))
671 (:foreground "MidnightBlue" :italic t))
674 "Face used for displaying newsgroups headers."
675 :group 'gnus-article-headers
676 :group 'gnus-article-highlight)
678 (defface gnus-header-name-face
681 (:foreground "SeaGreen"))
684 (:foreground "maroon"))
687 "Face used for displaying header names."
688 :group 'gnus-article-headers
689 :group 'gnus-article-highlight)
691 (defface gnus-header-content-face
694 (:foreground "forest green" :italic t))
697 (:foreground "indianred4" :italic t))
700 "Face used for displaying header content."
701 :group 'gnus-article-headers
702 :group 'gnus-article-highlight)
704 (defcustom gnus-header-face-alist
705 '(("From" nil gnus-header-from-face)
706 ("Subject" nil gnus-header-subject-face)
707 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
708 ("" gnus-header-name-face gnus-header-content-face))
709 "*Controls highlighting of article header.
711 An alist of the form (HEADER NAME CONTENT).
713 HEADER is a regular expression which should match the name of an
714 header header and NAME and CONTENT are either face names or nil.
716 The name of each header field will be displayed using the face
717 specified by the first element in the list where HEADER match the
718 header name and NAME is non-nil. Similarly, the content will be
719 displayed by the first non-nil matching CONTENT face."
720 :group 'gnus-article-headers
721 :group 'gnus-article-highlight
722 :type '(repeat (list (regexp :tag "Header")
724 (item :tag "skip" nil)
725 (face :value default))
726 (choice :tag "Content"
727 (item :tag "skip" nil)
728 (face :value default)))))
730 (defcustom gnus-article-decode-hook nil
731 "*Hook run to decode charsets in articles."
732 :group 'gnus-article-headers
735 (defcustom gnus-display-mime-function 'gnus-display-mime
736 "Function to display MIME articles."
737 :group 'gnus-article-mime
740 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
741 "Function used to decode headers.")
743 (defvar gnus-article-dumbquotes-map
763 "Table for MS-to-Latin1 translation.")
765 (defcustom gnus-ignored-mime-types nil
766 "List of MIME types that should be ignored by Gnus."
768 :group 'gnus-article-mime
769 :type '(repeat regexp))
771 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
772 "List of MIME types that should not be given buttons when rendered inline.
773 See also `gnus-buttonized-mime-types' which may override this variable.
774 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
776 :group 'gnus-article-mime
777 :type '(repeat regexp))
779 (defcustom gnus-buttonized-mime-types nil
780 "List of MIME types that should be given buttons when rendered inline.
781 If set, this variable overrides `gnus-unbuttonized-mime-types'.
782 To see e.g. security buttons you could set this to
783 `(\"multipart/signed\")'.
784 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
786 :group 'gnus-article-mime
787 :type '(repeat regexp))
789 (defcustom gnus-inhibit-mime-unbuttonizing nil
790 "If non-nil, all MIME parts get buttons.
791 When nil (the default value), then some MIME parts do not get buttons,
792 as described by the variables `gnus-buttonized-mime-types' and
793 `gnus-unbuttonized-mime-types'."
797 (defcustom gnus-body-boundary-delimiter "_"
798 "String used to delimit header and body.
799 This variable is used by `gnus-article-treat-body-boundary' which can
800 be controlled by `gnus-treat-body-boundary'."
801 :group 'gnus-article-various
802 :type '(choice (item :tag "None" :value nil)
805 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
806 "Defines the location of the faces database.
807 For information on obtaining this database of pretty pictures, please
808 see http://www.cs.indiana.edu/picons/ftp/index.html"
809 :type '(repeat directory)
810 :link '(url-link :tag "download"
811 "http://www.cs.indiana.edu/picons/ftp/index.html")
812 :link '(custom-manual "(gnus)Picons")
815 (defun gnus-picons-installed-p ()
816 "Say whether picons are installed on your machine."
817 (let ((installed nil))
818 (dolist (database gnus-picon-databases)
819 (when (file-exists-p database)
823 (defcustom gnus-article-mime-part-function nil
824 "Function called with a MIME handle as the argument.
825 This is meant for people who want to do something automatic based
826 on parts -- for instance, adding Vcard info to a database."
827 :group 'gnus-article-mime
830 (defcustom gnus-mime-multipart-functions nil
831 "An alist of MIME types to functions to display them."
833 :group 'gnus-article-mime
836 (defcustom gnus-article-date-lapsed-new-header nil
837 "Whether the X-Sent and Date headers can coexist.
838 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
839 either replace the old \"Date:\" header (if this variable is nil), or
840 be added below it (otherwise)."
842 :group 'gnus-article-headers
845 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
846 "Function called with a MIME handle as the argument.
847 This is meant for people who want to view first matched part.
848 For `undisplayed-alternative' (default), the first undisplayed
849 part or alternative part is used. For `undisplayed', the first
850 undisplayed part is used. For a function, the first part which
851 the function return t is used. For nil, the first part is
854 :group 'gnus-article-mime
856 (item :tag "first" :value nil)
857 (item :tag "undisplayed" :value undisplayed)
858 (item :tag "undisplayed or alternative"
859 :value undisplayed-alternative)
862 (defcustom gnus-mime-action-alist
863 '(("save to file" . gnus-mime-save-part)
864 ("save and strip" . gnus-mime-save-part-and-strip)
865 ("display as text" . gnus-mime-inline-part)
866 ("view the part" . gnus-mime-view-part)
867 ("pipe to command" . gnus-mime-pipe-part)
868 ("toggle display" . gnus-article-press-button)
869 ("toggle display" . gnus-article-view-part-as-charset)
870 ("view as type" . gnus-mime-view-part-as-type)
871 ("view internally" . gnus-mime-view-part-internally)
872 ("view externally" . gnus-mime-view-part-externally))
873 "An alist of actions that run on the MIME attachment."
874 :group 'gnus-article-mime
875 :type '(repeat (cons (string :tag "name")
879 ;;; The treatment variables
882 (defvar gnus-part-display-hook nil
883 "Hook called on parts that are to receive treatment.")
885 (defvar gnus-article-treat-custom
886 '(choice (const :tag "Off" nil)
888 (const :tag "Header" head)
889 (const :tag "Last" last)
890 (const :tag "Mime" mime)
891 (integer :tag "Less")
892 (repeat :tag "Groups" regexp)
893 (sexp :tag "Predicate")))
895 (defvar gnus-article-treat-head-custom
896 '(choice (const :tag "Off" nil)
897 (const :tag "Header" head)))
899 (defvar gnus-article-treat-types '("text/plain")
902 (defvar gnus-inhibit-treatment nil
903 "Whether to inhibit treatment.")
905 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
906 "Highlight the signature.
907 Valid values are nil, t, `head', `last', an integer or a predicate.
908 See Info node `(gnus)Customizing Articles'."
909 :group 'gnus-article-treat
910 :link '(custom-manual "(gnus)Customizing Articles")
911 :type gnus-article-treat-custom)
912 (put 'gnus-treat-highlight-signature 'highlight t)
914 (defcustom gnus-treat-buttonize 100000
916 Valid values are nil, t, `head', `last', an integer or a predicate.
917 See Info node `(gnus)Customizing Articles'."
918 :group 'gnus-article-treat
919 :link '(custom-manual "(gnus)Customizing Articles")
920 :type gnus-article-treat-custom)
921 (put 'gnus-treat-buttonize 'highlight t)
923 (defcustom gnus-treat-buttonize-head 'head
924 "Add buttons to the head.
925 Valid values are nil, t, `head', `last', an integer or a predicate.
926 See Info node `(gnus)Customizing Articles' for details."
927 :group 'gnus-article-treat
928 :link '(custom-manual "(gnus)Customizing Articles")
929 :type gnus-article-treat-head-custom)
930 (put 'gnus-treat-buttonize-head 'highlight t)
932 (defcustom gnus-treat-emphasize
933 (and (or window-system
935 (>= (string-to-number emacs-version) 21))
938 Valid values are nil, t, `head', `last', an integer or a predicate.
939 See Info node `(gnus)Customizing Articles' for details."
940 :group 'gnus-article-treat
941 :link '(custom-manual "(gnus)Customizing Articles")
942 :type gnus-article-treat-custom)
943 (put 'gnus-treat-emphasize 'highlight t)
945 (defcustom gnus-treat-strip-cr nil
946 "Remove carriage returns.
947 Valid values are nil, t, `head', `last', an integer or a predicate.
948 See Info node `(gnus)Customizing Articles' for details."
949 :group 'gnus-article-treat
950 :link '(custom-manual "(gnus)Customizing Articles")
951 :type gnus-article-treat-custom)
953 (defcustom gnus-treat-unsplit-urls nil
954 "Remove newlines from within URLs.
955 Valid values are nil, t, `head', `last', an integer or a predicate.
956 See Info node `(gnus)Customizing Articles' for details."
957 :group 'gnus-article-treat
958 :link '(custom-manual "(gnus)Customizing Articles")
959 :type gnus-article-treat-custom)
961 (defcustom gnus-treat-leading-whitespace nil
962 "Remove leading whitespace in headers.
963 Valid values are nil, t, `head', `last', an integer or a predicate.
964 See Info node `(gnus)Customizing Articles' for details."
965 :group 'gnus-article-treat
966 :link '(custom-manual "(gnus)Customizing Articles")
967 :type gnus-article-treat-custom)
969 (defcustom gnus-treat-hide-headers 'head
971 Valid values are nil, t, `head', `last', an integer or a predicate.
972 See Info node `(gnus)Customizing Articles' for details."
973 :group 'gnus-article-treat
974 :link '(custom-manual "(gnus)Customizing Articles")
975 :type gnus-article-treat-head-custom)
977 (defcustom gnus-treat-hide-boring-headers nil
978 "Hide boring headers.
979 Valid values are nil, t, `head', `last', an integer or a predicate.
980 See Info node `(gnus)Customizing Articles' for details."
981 :group 'gnus-article-treat
982 :link '(custom-manual "(gnus)Customizing Articles")
983 :type gnus-article-treat-head-custom)
985 (defcustom gnus-treat-hide-signature nil
987 Valid values are nil, t, `head', `last', an integer or a predicate.
988 See Info node `(gnus)Customizing Articles' for details."
989 :group 'gnus-article-treat
990 :link '(custom-manual "(gnus)Customizing Articles")
991 :type gnus-article-treat-custom)
993 (defcustom gnus-treat-fill-article nil
995 Valid values are nil, t, `head', `last', an integer or a predicate.
996 See Info node `(gnus)Customizing Articles' for details."
997 :group 'gnus-article-treat
998 :link '(custom-manual "(gnus)Customizing Articles")
999 :type gnus-article-treat-custom)
1001 (defcustom gnus-treat-hide-citation nil
1003 Valid values are nil, t, `head', `last', an integer or a predicate.
1004 See Info node `(gnus)Customizing Articles' for details."
1005 :group 'gnus-article-treat
1006 :link '(custom-manual "(gnus)Customizing Articles")
1007 :type gnus-article-treat-custom)
1009 (defcustom gnus-treat-hide-citation-maybe nil
1011 Valid values are nil, t, `head', `last', an integer or a predicate.
1012 See Info node `(gnus)Customizing Articles' for details."
1013 :group 'gnus-article-treat
1014 :link '(custom-manual "(gnus)Customizing Articles")
1015 :type gnus-article-treat-custom)
1017 (defcustom gnus-treat-strip-list-identifiers 'head
1018 "Strip list identifiers from `gnus-list-identifiers`.
1019 Valid values are nil, t, `head', `last', an integer or a predicate.
1020 See Info node `(gnus)Customizing Articles' for details."
1022 :group 'gnus-article-treat
1023 :link '(custom-manual "(gnus)Customizing Articles")
1024 :type gnus-article-treat-custom)
1026 (make-obsolete-variable 'gnus-treat-strip-pgp
1027 "This option is obsolete in Gnus 5.10.")
1029 (defcustom gnus-treat-strip-pem nil
1030 "Strip PEM signatures.
1031 Valid values are nil, t, `head', `last', an integer or a predicate.
1032 See Info node `(gnus)Customizing Articles' for details."
1033 :group 'gnus-article-treat
1034 :link '(custom-manual "(gnus)Customizing Articles")
1035 :type gnus-article-treat-custom)
1037 (defcustom gnus-treat-strip-banner t
1038 "Strip banners from articles.
1039 The banner to be stripped is specified in the `banner' group parameter.
1040 Valid values are nil, t, `head', `last', an integer or a predicate.
1041 See Info node `(gnus)Customizing Articles' for details."
1042 :group 'gnus-article-treat
1043 :link '(custom-manual "(gnus)Customizing Articles")
1044 :type gnus-article-treat-custom)
1046 (defcustom gnus-treat-highlight-headers 'head
1047 "Highlight the headers.
1048 Valid values are nil, t, `head', `last', an integer or a predicate.
1049 See Info node `(gnus)Customizing Articles' for details."
1050 :group 'gnus-article-treat
1051 :link '(custom-manual "(gnus)Customizing Articles")
1052 :type gnus-article-treat-head-custom)
1053 (put 'gnus-treat-highlight-headers 'highlight t)
1055 (defcustom gnus-treat-highlight-citation t
1056 "Highlight cited text.
1057 Valid values are nil, t, `head', `last', an integer or a predicate.
1058 See Info node `(gnus)Customizing Articles' for details."
1059 :group 'gnus-article-treat
1060 :link '(custom-manual "(gnus)Customizing Articles")
1061 :type gnus-article-treat-custom)
1062 (put 'gnus-treat-highlight-citation 'highlight t)
1064 (defcustom gnus-treat-date-ut nil
1065 "Display the Date in UT (GMT).
1066 Valid values are nil, t, `head', `last', an integer or a predicate.
1067 See Info node `(gnus)Customizing Articles' for details."
1068 :group 'gnus-article-treat
1069 :link '(custom-manual "(gnus)Customizing Articles")
1070 :type gnus-article-treat-head-custom)
1072 (defcustom gnus-treat-date-local nil
1073 "Display the Date in the local timezone.
1074 Valid values are nil, t, `head', `last', an integer or a predicate.
1075 See Info node `(gnus)Customizing Articles' for details."
1076 :group 'gnus-article-treat
1077 :link '(custom-manual "(gnus)Customizing Articles")
1078 :type gnus-article-treat-head-custom)
1080 (defcustom gnus-treat-date-english nil
1081 "Display the Date in a format that can be read aloud in English.
1082 Valid values are nil, t, `head', `last', an integer or a predicate.
1083 See Info node `(gnus)Customizing Articles' for details."
1084 :group 'gnus-article-treat
1085 :link '(custom-manual "(gnus)Customizing Articles")
1086 :type gnus-article-treat-head-custom)
1088 (defcustom gnus-treat-date-lapsed nil
1089 "Display the Date header in a way that says how much time has elapsed.
1090 Valid values are nil, t, `head', `last', an integer or a predicate.
1091 See Info node `(gnus)Customizing Articles' for details."
1092 :group 'gnus-article-treat
1093 :link '(custom-manual "(gnus)Customizing Articles")
1094 :type gnus-article-treat-head-custom)
1096 (defcustom gnus-treat-date-original nil
1097 "Display the date in the original timezone.
1098 Valid values are nil, t, `head', `last', an integer or a predicate.
1099 See Info node `(gnus)Customizing Articles' for details."
1100 :group 'gnus-article-treat
1101 :link '(custom-manual "(gnus)Customizing Articles")
1102 :type gnus-article-treat-head-custom)
1104 (defcustom gnus-treat-date-iso8601 nil
1105 "Display the date in the ISO8601 format.
1106 Valid values are nil, t, `head', `last', an integer or a predicate.
1107 See Info node `(gnus)Customizing Articles' for details."
1109 :group 'gnus-article-treat
1110 :link '(custom-manual "(gnus)Customizing Articles")
1111 :type gnus-article-treat-head-custom)
1113 (defcustom gnus-treat-date-user-defined nil
1114 "Display the date in a user-defined format.
1115 The format is defined by the `gnus-article-time-format' variable.
1116 Valid values are nil, t, `head', `last', an integer or a predicate.
1117 See Info node `(gnus)Customizing Articles' for details."
1118 :group 'gnus-article-treat
1119 :link '(custom-manual "(gnus)Customizing Articles")
1120 :type gnus-article-treat-head-custom)
1122 (defcustom gnus-treat-strip-headers-in-body t
1123 "Strip the X-No-Archive header line from the beginning of the body.
1124 Valid values are nil, t, `head', `last', an integer or a predicate.
1125 See Info node `(gnus)Customizing Articles' for details."
1127 :group 'gnus-article-treat
1128 :link '(custom-manual "(gnus)Customizing Articles")
1129 :type gnus-article-treat-custom)
1131 (defcustom gnus-treat-strip-trailing-blank-lines nil
1132 "Strip trailing blank lines.
1133 Valid values are nil, t, `head', `last', an integer or a predicate.
1134 See Info node `(gnus)Customizing Articles' for details."
1135 :group 'gnus-article-treat
1136 :link '(custom-manual "(gnus)Customizing Articles")
1137 :type gnus-article-treat-custom)
1139 (defcustom gnus-treat-strip-leading-blank-lines nil
1140 "Strip leading blank lines.
1141 Valid values are nil, t, `head', `last', an integer or a predicate.
1142 See Info node `(gnus)Customizing Articles' for details."
1143 :group 'gnus-article-treat
1144 :link '(custom-manual "(gnus)Customizing Articles")
1145 :type gnus-article-treat-custom)
1147 (defcustom gnus-treat-strip-multiple-blank-lines nil
1148 "Strip multiple blank lines.
1149 Valid values are nil, t, `head', `last', an integer or a predicate.
1150 See Info node `(gnus)Customizing Articles' for details."
1151 :group 'gnus-article-treat
1152 :link '(custom-manual "(gnus)Customizing Articles")
1153 :type gnus-article-treat-custom)
1155 (defcustom gnus-treat-unfold-headers 'head
1156 "Unfold folded header lines.
1157 Valid values are nil, t, `head', `last', an integer or a predicate.
1158 See Info node `(gnus)Customizing Articles' for details."
1159 :group 'gnus-article-treat
1160 :link '(custom-manual "(gnus)Customizing Articles")
1161 :type gnus-article-treat-custom)
1163 (defcustom gnus-treat-fold-headers nil
1165 Valid values are nil, t, `head', `last', an integer or a predicate.
1166 See Info node `(gnus)Customizing Articles' for details."
1167 :group 'gnus-article-treat
1168 :link '(custom-manual "(gnus)Customizing Articles")
1169 :type gnus-article-treat-custom)
1171 (defcustom gnus-treat-fold-newsgroups 'head
1172 "Fold the Newsgroups and Followup-To headers.
1173 Valid values are nil, t, `head', `last', an integer or a predicate.
1174 See Info node `(gnus)Customizing Articles' for details."
1175 :group 'gnus-article-treat
1176 :link '(custom-manual "(gnus)Customizing Articles")
1177 :type gnus-article-treat-custom)
1179 (defcustom gnus-treat-overstrike t
1180 "Treat overstrike highlighting.
1181 Valid values are nil, t, `head', `last', an integer or a predicate.
1182 See Info node `(gnus)Customizing Articles' for details."
1183 :group 'gnus-article-treat
1184 :link '(custom-manual "(gnus)Customizing Articles")
1185 :type gnus-article-treat-custom)
1186 (put 'gnus-treat-overstrike 'highlight t)
1188 (defcustom gnus-treat-display-xface
1189 (and (not noninteractive)
1190 (or (and (fboundp 'image-type-available-p)
1191 (image-type-available-p 'xbm)
1192 (string-match "^0x" (shell-command-to-string "uncompface")))
1193 (and (featurep 'xemacs)
1195 (eq 'x-face-mule-gnus-article-display-x-face
1196 gnus-article-x-face-command))
1198 "Display X-Face headers.
1199 Valid values are nil, t, `head', `last', an integer or a predicate.
1200 See Info node `(gnus)Customizing Articles' and Info node
1201 `(gnus)X-Face' for details."
1202 :group 'gnus-article-treat
1204 :link '(custom-manual "(gnus)Customizing Articles")
1205 :link '(custom-manual "(gnus)X-Face")
1206 :type gnus-article-treat-head-custom)
1207 (put 'gnus-treat-display-xface 'highlight t)
1209 (defcustom gnus-article-should-use-smiley-mule
1210 (not (or (featurep 'xemacs)
1211 (gnus-image-type-available-p 'xpm)
1212 (gnus-image-type-available-p 'pbm)))
1213 "If non-nil, gnus uses `smiley-mule' for displaying smileys rather than
1214 `smiley'. It defaults to t when Emacs 20 or earlier is running.
1215 `smiley-mule' is boundled in BITMAP-MULE package. You can set it to t
1216 even if you are using Emacs 21+. It has no effect on XEmacs."
1217 :group 'gnus-article-various
1219 :get (lambda (symbol)
1220 (and (default-value symbol)
1221 (not (featurep 'xemacs))
1222 (module-installed-p 'smiley-mule)
1224 :set (lambda (symbol value)
1225 (set-default symbol (and value
1226 (not (featurep 'xemacs))
1227 (module-installed-p 'smiley-mule)
1230 (defvar gnus-article-smiley-mule-loaded-p nil
1231 "Internal variable used to say whether `smiley-mule' is loaded (whether
1232 smiley functions are not overridden by `smiley').")
1234 (defcustom gnus-treat-display-face
1235 (and (not noninteractive)
1236 (or (and (fboundp 'image-type-available-p)
1237 (image-type-available-p 'png))
1238 (and (featurep 'xemacs)
1241 "Display Face headers.
1242 Valid values are nil, t, `head', `last', an integer or a predicate.
1243 See Info node `(gnus)Customizing Articles' and Info node
1244 `(gnus)X-Face' for details."
1245 :group 'gnus-article-treat
1247 :link '(custom-manual "(gnus)Customizing Articles")
1248 :link '(custom-manual "(gnus)X-Face")
1249 :type gnus-article-treat-head-custom)
1250 (put 'gnus-treat-display-face 'highlight t)
1252 (defcustom gnus-treat-display-smileys
1253 (if (or (and (featurep 'xemacs)
1255 (gnus-image-type-available-p 'xpm)
1256 (gnus-image-type-available-p 'pbm)
1257 (and (not (featurep 'xemacs))
1259 (module-installed-p 'smiley-mule)))
1263 Valid values are nil, t, `head', `last', an integer or a predicate.
1264 See Info node `(gnus)Customizing Articles' and Info node
1265 `(gnus)Smileys' for details."
1266 :group 'gnus-article-treat
1268 :link '(custom-manual "(gnus)Customizing Articles")
1269 :link '(custom-manual "(gnus)Smileys")
1270 :type gnus-article-treat-custom)
1271 (put 'gnus-treat-display-smileys 'highlight t)
1273 (defcustom gnus-treat-from-picon
1274 (if (and (gnus-image-type-available-p 'xpm)
1275 (gnus-picons-installed-p))
1277 "Display picons in the From header.
1278 Valid values are nil, t, `head', `last', an integer or a predicate.
1279 See Info node `(gnus)Customizing Articles' and Info node
1280 `(gnus)Picons' for details."
1281 :group 'gnus-article-treat
1283 :link '(custom-manual "(gnus)Customizing Articles")
1284 :link '(custom-manual "(gnus)Picons")
1285 :type gnus-article-treat-head-custom)
1286 (put 'gnus-treat-from-picon 'highlight t)
1288 (defcustom gnus-treat-mail-picon
1289 (if (and (gnus-image-type-available-p 'xpm)
1290 (gnus-picons-installed-p))
1292 "Display picons in To and Cc headers.
1293 Valid values are nil, t, `head', `last', an integer or a predicate.
1294 See Info node `(gnus)Customizing Articles' and Info node
1295 `(gnus)Picons' for details."
1296 :group 'gnus-article-treat
1298 :link '(custom-manual "(gnus)Customizing Articles")
1299 :link '(custom-manual "(gnus)Picons")
1300 :type gnus-article-treat-head-custom)
1301 (put 'gnus-treat-mail-picon 'highlight t)
1303 (defcustom gnus-treat-newsgroups-picon
1304 (if (and (gnus-image-type-available-p 'xpm)
1305 (gnus-picons-installed-p))
1307 "Display picons in the Newsgroups and Followup-To headers.
1308 Valid values are nil, t, `head', `last', an integer or a predicate.
1309 See Info node `(gnus)Customizing Articles' and Info node
1310 `(gnus)Picons' for details."
1311 :group 'gnus-article-treat
1313 :link '(custom-manual "(gnus)Customizing Articles")
1314 :link '(custom-manual "(gnus)Picons")
1315 :type gnus-article-treat-head-custom)
1316 (put 'gnus-treat-newsgroups-picon 'highlight t)
1318 (defcustom gnus-treat-body-boundary
1319 (if (or gnus-treat-newsgroups-picon
1320 gnus-treat-mail-picon
1321 gnus-treat-from-picon)
1323 "Draw a boundary at the end of the headers.
1324 Valid values are nil, t, `head', `last', an integer or a predicate.
1325 See Info node `(gnus)Customizing Articles' for details."
1327 :group 'gnus-article-treat
1328 :link '(custom-manual "(gnus)Customizing Articles")
1329 :type gnus-article-treat-custom)
1331 (defcustom gnus-treat-capitalize-sentences nil
1332 "Capitalize sentence-starting words.
1333 Valid values are nil, t, `head', `last', an integer or a predicate.
1334 See Info node `(gnus)Customizing Articles' for details."
1336 :group 'gnus-article-treat
1337 :link '(custom-manual "(gnus)Customizing Articles")
1338 :type gnus-article-treat-custom)
1340 (defcustom gnus-treat-wash-html nil
1342 Valid values are nil, t, `head', `last', an integer or a predicate.
1343 See Info node `(gnus)Customizing Articles' for details."
1344 :group 'gnus-article-treat
1345 :link '(custom-manual "(gnus)Customizing Articles")
1346 :type gnus-article-treat-custom)
1348 (defcustom gnus-treat-fill-long-lines nil
1350 Valid values are nil, t, `head', `last', an integer or a predicate.
1351 See Info node `(gnus)Customizing Articles' for details."
1352 :group 'gnus-article-treat
1353 :link '(custom-manual "(gnus)Customizing Articles")
1354 :type gnus-article-treat-custom)
1356 (defcustom gnus-treat-play-sounds nil
1358 Valid values are nil, t, `head', `last', an integer or a predicate.
1359 See Info node `(gnus)Customizing Articles' for details."
1361 :group 'gnus-article-treat
1362 :link '(custom-manual "(gnus)Customizing Articles")
1363 :type gnus-article-treat-custom)
1365 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
1366 "Decode an article as `default-mime-charset'. For instance, if you want to
1367 attempt to decode an article even if the value of `gnus-show-mime' is nil,
1368 you could set this variable to something like: nil for don't decode, t for
1369 decode the body, '(or header t) for the whole article, etc."
1370 :group 'gnus-article-treat
1371 :type '(radio (const :tag "Off" nil)
1372 (const :tag "Decode body" t)
1373 (const :tag "Decode all" (or head t))))
1375 (defcustom gnus-treat-translate nil
1376 "Translate articles from one language to another.
1377 Valid values are nil, t, `head', `last', an integer or a predicate.
1378 See Info node `(gnus)Customizing Articles' for details."
1380 :group 'gnus-article-treat
1381 :link '(custom-manual "(gnus)Customizing Articles")
1382 :type gnus-article-treat-custom)
1384 (defcustom gnus-treat-x-pgp-sig nil
1386 To automatically treat X-PGP-Sig, set it to head.
1387 Valid values are nil, t, `head', `last', an integer or a predicate.
1388 See Info node `(gnus)Customizing Articles' for details."
1389 :group 'gnus-article-treat
1390 :group 'mime-security
1391 :type gnus-article-treat-custom)
1393 (defcustom gnus-treat-monafy nil
1394 "Display body part with mona font.
1395 Valid values are nil, t, `head', `last', an integer or a predicate.
1396 See Info node `(gnus)Customizing Articles' for details."
1397 :group 'gnus-article-treat
1398 :group 'mime-security
1399 :link '(custom-manual "(gnus)Customizing Articles")
1400 :type gnus-article-treat-custom)
1402 (defvar gnus-article-encrypt-protocol-alist
1403 '(("PGP" . mml2015-self-encrypt)))
1405 ;; Set to nil if more than one protocol added to
1406 ;; gnus-article-encrypt-protocol-alist.
1407 (defcustom gnus-article-encrypt-protocol "PGP"
1408 "The protocol used for encrypt articles.
1409 It is a string, such as \"PGP\". If nil, ask user."
1411 :group 'mime-security)
1413 (defvar gnus-article-wash-function nil
1414 "Function used for converting HTML into text.")
1416 ;;; Internal variables
1418 (defvar gnus-english-month-names
1419 '("January" "February" "March" "April" "May" "June" "July" "August"
1420 "September" "October" "November" "December"))
1422 (defvar article-goto-body-goes-to-point-min-p nil)
1423 (defvar gnus-article-wash-types nil)
1424 (defvar gnus-article-emphasis-alist nil)
1425 (defvar gnus-article-image-alist nil)
1427 (defvar gnus-article-mime-handle-alist-1 nil)
1428 (defvar gnus-treatment-function-alist
1429 '((gnus-treat-decode-article-as-default-mime-charset
1430 gnus-article-decode-article-as-default-mime-charset)
1431 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1432 (gnus-treat-monafy gnus-article-monafy)
1433 (gnus-treat-strip-banner gnus-article-strip-banner)
1434 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1435 (gnus-treat-buttonize gnus-article-add-buttons)
1436 (gnus-treat-fill-article gnus-article-fill-cited-article)
1437 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1438 (gnus-treat-strip-cr gnus-article-remove-cr)
1439 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1440 (gnus-treat-date-ut gnus-article-date-ut)
1441 (gnus-treat-date-local gnus-article-date-local)
1442 (gnus-treat-date-english gnus-article-date-english)
1443 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1444 (gnus-treat-date-original gnus-article-date-original)
1445 (gnus-treat-date-user-defined gnus-article-date-user)
1446 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1447 (gnus-treat-display-face gnus-article-display-face)
1448 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1449 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1450 (gnus-treat-hide-signature gnus-article-hide-signature)
1451 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1452 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1453 (gnus-treat-strip-pem gnus-article-hide-pem)
1454 (gnus-treat-from-picon gnus-treat-from-picon)
1455 (gnus-treat-mail-picon gnus-treat-mail-picon)
1456 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1457 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1458 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1459 (gnus-treat-strip-trailing-blank-lines
1460 gnus-article-remove-trailing-blank-lines)
1461 (gnus-treat-strip-leading-blank-lines
1462 gnus-article-strip-leading-blank-lines)
1463 (gnus-treat-strip-multiple-blank-lines
1464 gnus-article-strip-multiple-blank-lines)
1465 (gnus-treat-overstrike gnus-article-treat-overstrike)
1466 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1467 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1468 ;; Displaying X-Face should be done after unfolding headers
1469 ;; to protect bitmap lines.
1470 (gnus-treat-display-xface gnus-article-display-x-face)
1471 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1472 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1473 (gnus-treat-display-smileys gnus-treat-smiley)
1474 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1475 (gnus-treat-wash-html gnus-article-wash-html)
1476 (gnus-treat-emphasize gnus-article-emphasize)
1477 (gnus-treat-hide-citation gnus-article-hide-citation)
1478 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1479 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1480 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1481 (gnus-treat-play-sounds gnus-earcon-display)))
1483 (defvar gnus-article-mime-handle-alist nil)
1484 (defvar article-lapsed-timer nil)
1485 (defvar gnus-article-current-summary nil)
1487 (defvar gnus-article-mode-syntax-table
1488 (let ((table (copy-syntax-table text-mode-syntax-table)))
1489 ;; This causes the citation match run O(2^n).
1490 ;; (modify-syntax-entry ?- "w" table)
1491 (modify-syntax-entry ?> ")<" table)
1492 (modify-syntax-entry ?< "(>" table)
1493 ;; make M-. in article buffers work for `foo' strings
1494 (modify-syntax-entry ?' " " table)
1495 (modify-syntax-entry ?` " " table)
1497 "Syntax table used in article mode buffers.
1498 Initialized from `text-mode-syntax-table.")
1500 (defvar gnus-save-article-buffer nil)
1502 (defvar gnus-article-mode-line-format-alist
1503 (nconc '((?w (gnus-article-wash-status) ?s)
1504 (?m (gnus-article-mime-part-status) ?s))
1505 gnus-summary-mode-line-format-alist))
1507 (defvar gnus-number-of-articles-to-be-saved nil)
1509 (defvar gnus-inhibit-hiding nil)
1511 ;;; Macros for dealing with the article buffer.
1513 (defmacro gnus-with-article-headers (&rest forms)
1515 (set-buffer gnus-article-buffer)
1517 (let ((buffer-read-only nil)
1518 (inhibit-point-motion-hooks t)
1519 (case-fold-search t))
1520 (article-narrow-to-head)
1523 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1524 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1526 (defmacro gnus-with-article-buffer (&rest forms)
1528 (set-buffer gnus-article-buffer)
1529 (let ((buffer-read-only nil))
1532 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1533 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1535 (defun gnus-article-goto-header (header)
1536 "Go to HEADER, which is a regular expression."
1537 (re-search-forward (concat "^\\(" header "\\):") nil t))
1539 (defsubst gnus-article-hide-text (b e props)
1540 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1541 (gnus-add-text-properties-when 'article-type nil b e props)
1542 (when (memq 'intangible props)
1544 (max (1- b) (point-min))
1545 b 'intangible (cddr (memq 'intangible props)))))
1547 (defsubst gnus-article-unhide-text (b e)
1548 "Remove hidden text properties from region between B and E."
1549 (remove-text-properties b e gnus-hidden-properties)
1550 (when (memq 'intangible gnus-hidden-properties)
1551 (put-text-property (max (1- b) (point-min))
1552 b 'intangible nil)))
1554 (defun gnus-article-hide-text-type (b e type)
1555 "Hide text of TYPE between B and E."
1556 (gnus-add-wash-type type)
1557 (gnus-article-hide-text
1558 b e (cons 'article-type (cons type gnus-hidden-properties))))
1560 (defun gnus-article-unhide-text-type (b e type)
1561 "Unhide text of TYPE between B and E."
1562 (gnus-delete-wash-type type)
1563 (remove-text-properties
1564 b e (cons 'article-type (cons type gnus-hidden-properties)))
1565 (when (memq 'intangible gnus-hidden-properties)
1566 (put-text-property (max (1- b) (point-min))
1567 b 'intangible nil)))
1569 (defun gnus-article-hide-text-of-type (type)
1570 "Hide text of TYPE in the current buffer."
1572 (let ((b (point-min))
1574 (while (setq b (text-property-any b e 'article-type type))
1575 (add-text-properties b (incf b) gnus-hidden-properties)))))
1577 (defun gnus-article-delete-text-of-type (type)
1578 "Delete text of TYPE in the current buffer."
1580 (let ((b (point-min)))
1581 (while (setq b (text-property-any b (point-max) 'article-type type))
1583 b (or (text-property-not-all b (point-max) 'article-type type)
1586 (defun gnus-article-delete-invisible-text ()
1587 "Delete all invisible text in the current buffer."
1589 (let ((b (point-min)))
1590 (while (setq b (text-property-any b (point-max) 'invisible t))
1592 b (or (text-property-not-all b (point-max) 'invisible t)
1595 (defun gnus-article-text-type-exists-p (type)
1596 "Say whether any text of type TYPE exists in the buffer."
1597 (text-property-any (point-min) (point-max) 'article-type type))
1599 (defsubst gnus-article-header-rank ()
1600 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1601 (let ((list gnus-sorted-header-list)
1604 (if (looking-at (car list))
1606 (setq list (cdr list))
1610 (defun article-hide-headers (&optional arg delete)
1611 "Hide unwanted headers and possibly sort them as well."
1612 (interactive (gnus-article-hidden-arg))
1613 ;; Lars said that this function might be inhibited.
1614 (if (gnus-article-check-hidden-text 'headers arg)
1616 ;; Show boring headers as well.
1617 (gnus-article-show-hidden-text 'boring-headers)
1618 (when (eq 1 (point-min))
1619 (set-window-start (get-buffer-window (current-buffer)) 1)))
1620 (unless gnus-inhibit-hiding
1623 (let ((inhibit-read-only t)
1624 (case-fold-search t)
1625 (max (1+ (length gnus-sorted-header-list)))
1626 (ignored (when (not gnus-visible-headers)
1627 (cond ((stringp gnus-ignored-headers)
1628 gnus-ignored-headers)
1629 ((listp gnus-ignored-headers)
1630 (mapconcat 'identity gnus-ignored-headers
1633 (cond ((stringp gnus-visible-headers)
1634 gnus-visible-headers)
1635 ((and gnus-visible-headers
1636 (listp gnus-visible-headers))
1637 (mapconcat 'identity gnus-visible-headers "\\|"))))
1638 (inhibit-point-motion-hooks t)
1640 ;; First we narrow to just the headers.
1641 (article-narrow-to-head)
1642 ;; Hide any "From " lines at the beginning of (mail) articles.
1643 (while (looking-at "From ")
1647 (delete-region (point-min) (point))
1648 (gnus-article-hide-text (point-min) (point)
1649 (nconc (list 'article-type 'headers)
1650 gnus-hidden-properties))))
1651 ;; Then treat the rest of the header lines.
1652 ;; Then we use the two regular expressions
1653 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1654 ;; select which header lines is to remain visible in the
1656 (while (re-search-forward "^[^ \t:]*:" nil t)
1658 ;; Mark the rank of the header.
1660 (point) (1+ (point)) 'message-rank
1661 (if (or (and visible (looking-at visible))
1663 (not (looking-at ignored))))
1664 (gnus-article-header-rank)
1667 (message-sort-headers-1)
1668 (when (setq beg (text-property-any
1669 (point-min) (point-max) 'message-rank (+ 2 max)))
1670 ;; We delete or make invisible the unwanted headers.
1671 (gnus-add-wash-type 'headers)
1674 (add-text-properties
1675 (point-min) (+ 5 (point-min))
1676 '(article-type headers dummy-invisible t))
1677 (delete-region beg (point-max)))
1678 (gnus-article-hide-text-type beg (point-max) 'headers)))))))))
1680 (defun article-hide-boring-headers (&optional arg)
1681 "Toggle hiding of headers that aren't very interesting.
1682 If given a negative prefix, always show; if given a positive prefix,
1684 (interactive (gnus-article-hidden-arg))
1685 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1686 (not gnus-show-all-headers))
1689 (let ((buffer-read-only nil)
1690 (list gnus-boring-article-headers)
1691 (inhibit-point-motion-hooks t)
1693 (article-narrow-to-head)
1695 (setq elem (pop list))
1696 (goto-char (point-min))
1698 ;; Hide empty headers.
1700 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1702 (gnus-article-hide-text-type
1703 (progn (beginning-of-line) (point))
1706 (if (re-search-forward "^[^ \t]" nil t)
1710 ;; Hide boring Newsgroups header.
1711 ((eq elem 'newsgroups)
1712 (when (gnus-string-equal
1713 (gnus-fetch-field "newsgroups")
1714 (gnus-group-real-name
1715 (if (boundp 'gnus-newsgroup-name)
1718 (gnus-article-hide-header "newsgroups")))
1719 ((eq elem 'to-address)
1720 (let ((to (message-fetch-field "to"))
1722 (gnus-parameter-to-address
1723 (if (boundp 'gnus-newsgroup-name)
1724 gnus-newsgroup-name ""))))
1725 (when (and to to-address
1728 ;; only one address in To
1729 (nth 1 (mail-extract-address-components to))
1731 (gnus-article-hide-header "to"))))
1732 ((eq elem 'followup-to)
1733 (when (gnus-string-equal
1734 (message-fetch-field "followup-to")
1735 (message-fetch-field "newsgroups"))
1736 (gnus-article-hide-header "followup-to")))
1737 ((eq elem 'reply-to)
1738 (let ((from (message-fetch-field "from"))
1739 (reply-to (message-fetch-field "reply-to")))
1744 (nth 1 (mail-extract-address-components from))
1745 (nth 1 (mail-extract-address-components reply-to)))))
1746 (gnus-article-hide-header "reply-to"))))
1748 (let ((date (message-fetch-field "date")))
1750 (< (days-between (current-time-string) date)
1752 (gnus-article-hide-header "date"))))
1754 (let ((to (message-fetch-field "to"))
1755 (cc (message-fetch-field "cc")))
1756 (when (> (length to) 1024)
1757 (gnus-article-hide-header "to"))
1758 (when (> (length cc) 1024)
1759 (gnus-article-hide-header "cc"))))
1763 (goto-char (point-min))
1764 (while (re-search-forward "^to:" nil t)
1765 (setq to-count (1+ to-count)))
1766 (when (> to-count 1)
1767 (while (> to-count 0)
1768 (goto-char (point-min))
1770 (re-search-forward "^to:" nil nil to-count)
1772 (narrow-to-region (point) (point-max))
1773 (gnus-article-hide-header "to"))
1774 (setq to-count (1- to-count))))
1775 (goto-char (point-min))
1776 (while (re-search-forward "^cc:" nil t)
1777 (setq cc-count (1+ cc-count)))
1778 (when (> cc-count 1)
1779 (while (> cc-count 0)
1780 (goto-char (point-min))
1782 (re-search-forward "^cc:" nil nil cc-count)
1784 (narrow-to-region (point) (point-max))
1785 (gnus-article-hide-header "cc"))
1786 (setq cc-count (1- cc-count)))))))))))))
1788 (defun gnus-article-hide-header (header)
1790 (goto-char (point-min))
1791 (when (re-search-forward (concat "^" header ":") nil t)
1792 (gnus-article-hide-text-type
1793 (progn (beginning-of-line) (point))
1796 (if (re-search-forward "^[^ \t]" nil t)
1801 (defvar gnus-article-normalized-header-length 40
1802 "Length of normalized headers.")
1804 (defun article-normalize-headers ()
1805 "Make all header lines 40 characters long."
1807 (let ((buffer-read-only nil)
1811 (article-narrow-to-head)
1814 ((< (setq column (- (gnus-point-at-eol) (point)))
1815 gnus-article-normalized-header-length)
1817 (insert (make-string
1818 (- gnus-article-normalized-header-length column)
1820 ((> column gnus-article-normalized-header-length)
1821 (gnus-put-text-property
1823 (forward-char gnus-article-normalized-header-length)
1830 (forward-line 1))))))
1832 (defun article-treat-dumbquotes ()
1833 "Translate M****s*** sm*rtq**t*s into proper text.
1834 Note that this function guesses whether a character is a sm*rtq**t* or
1835 not, so it should only be used interactively.
1837 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1838 in an attempt to provide more quoting characters. If you see
1839 something like \\222 or \\264 where you're expecting some kind of
1840 apostrophe or quotation mark, then try this wash."
1842 (article-translate-strings gnus-article-dumbquotes-map))
1844 (defun article-translate-characters (from to)
1845 "Translate all characters in the body of the article according to FROM and TO.
1846 FROM is a string of characters to translate from; to is a string of
1847 characters to translate to."
1849 (when (article-goto-body)
1850 (let ((buffer-read-only nil)
1851 (x (make-string 225 ?x))
1853 (while (< (incf i) (length x))
1856 (while (< i (length from))
1857 (aset x (aref from i) (aref to i))
1859 (translate-region (point) (point-max) x)))))
1861 (defun article-translate-strings (map)
1862 "Translate all string in the body of the article according to MAP.
1863 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1865 (when (article-goto-body)
1866 (let ((buffer-read-only nil)
1868 (while (setq elem (pop map))
1870 (while (search-forward (car elem) nil t)
1871 (replace-match (cadr elem)))))))))
1873 (defun article-treat-overstrike ()
1874 "Translate overstrikes into bold text."
1877 (when (article-goto-body)
1878 (let ((buffer-read-only nil))
1879 (while (search-forward "\b" nil t)
1880 (let ((next (char-after))
1884 previous (char-after))
1888 ;; We do the boldification/underlining by hiding the
1889 ;; overstrikes and putting the proper text property
1893 (gnus-article-hide-text-type start (point) 'overstrike)
1894 (put-text-property (point) end 'face 'bold))
1896 (gnus-article-hide-text-type
1897 (1- (point)) (1+ (point)) 'overstrike)
1899 start (1- (point)) 'face 'underline))
1901 (gnus-article-hide-text-type start (point) 'overstrike)
1903 (point) end 'face 'underline)))))))))
1905 (defun gnus-article-treat-unfold-headers ()
1906 "Unfold folded message headers.
1907 Only the headers that fit into the current window width will be
1910 (gnus-with-article-headers
1914 (mail-header-narrow-to-field)
1915 (let ((header (buffer-substring (point-min) (point-max))))
1918 (goto-char (point-min))
1919 (while (re-search-forward "\n[\t ]" nil t)
1920 (replace-match " " t t)))
1921 (setq length (- (point-max) (point-min) 1)))
1922 (when (< length (window-width))
1923 (while (re-search-forward "\n[\t ]" nil t)
1924 (replace-match " " t t)))
1925 (goto-char (point-max)))))))
1927 (defun gnus-article-treat-fold-headers ()
1928 "Fold message headers."
1930 (gnus-with-article-headers
1933 (mail-header-narrow-to-field)
1934 (mail-header-fold-field)
1935 (goto-char (point-max))))))
1937 (defun gnus-treat-smiley ()
1938 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1940 (unless (featurep 'xemacs)
1941 (when (and (>= emacs-major-version 21)
1942 (not gnus-article-should-use-smiley-mule)
1943 gnus-article-smiley-mule-loaded-p)
1944 (load "smiley" nil t)
1945 (setq gnus-article-smiley-mule-loaded-p nil))
1946 (when (and gnus-article-should-use-smiley-mule
1947 (not gnus-article-smiley-mule-loaded-p))
1948 (load "smiley-mule" nil t)
1949 (setq gnus-article-smiley-mule-loaded-p t)))
1950 (gnus-with-article-buffer
1951 (if (memq 'smiley gnus-article-wash-types)
1952 (gnus-delete-images 'smiley)
1954 (let ((images (smiley-region (point) (point-max))))
1956 (gnus-add-wash-type 'smiley)
1957 (dolist (image images)
1958 (gnus-add-image 'smiley image)))))))
1960 (defun gnus-article-remove-images ()
1961 "Remove all images from the article buffer."
1963 (gnus-with-article-buffer
1964 (dolist (elem gnus-article-image-alist)
1965 (gnus-delete-images (car elem)))))
1967 (defun gnus-article-treat-fold-newsgroups ()
1968 "Unfold folded message headers.
1969 Only the headers that fit into the current window width will be
1972 (gnus-with-article-headers
1973 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1975 (mail-header-narrow-to-field)
1976 (while (re-search-forward ", *" nil t)
1977 (replace-match ", " t t))
1978 (mail-header-fold-field)
1979 (goto-char (point-max))))))
1981 (defun gnus-article-treat-body-boundary ()
1982 "Place a boundary line at the end of the headers."
1984 (when (and gnus-body-boundary-delimiter
1985 (> (length gnus-body-boundary-delimiter) 0))
1986 (gnus-with-article-headers
1987 (goto-char (point-max))
1988 (let ((start (point)))
1989 (insert "X-Boundary: ")
1990 (gnus-add-text-properties start (point) '(invisible t intangible t))
1992 (while (>= (1- (window-width)) (length str))
1993 (setq str (concat str gnus-body-boundary-delimiter)))
1994 (substring str 0 (1- (window-width))))
1996 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
1998 (defun article-fill-long-lines ()
1999 "Fill lines that are wider than the window width."
2002 (let ((buffer-read-only nil)
2003 (width (window-width (get-buffer-window (current-buffer)))))
2006 (let ((adaptive-fill-mode nil)) ;Why? -sm
2009 (when (>= (current-column) (min fill-column width))
2010 (narrow-to-region (min (1+ (point)) (point-max))
2011 (gnus-point-at-bol))
2012 (let ((goback (point-marker)))
2013 (fill-paragraph nil)
2014 (goto-char (marker-position goback)))
2016 (forward-line 1)))))))
2018 (defun article-capitalize-sentences ()
2019 "Capitalize the first word in each sentence."
2022 (let ((buffer-read-only nil)
2023 (paragraph-start "^[\n\^L]"))
2027 (forward-sentence)))))
2029 (defun article-remove-cr ()
2030 "Remove trailing CRs and then translate remaining CRs into LFs."
2033 (let ((buffer-read-only nil))
2034 (goto-char (point-min))
2035 (while (re-search-forward "\r+$" nil t)
2036 (replace-match "" t t))
2037 (goto-char (point-min))
2038 (while (search-forward "\r" nil t)
2039 (replace-match "\n" t t)))))
2041 (defun article-remove-trailing-blank-lines ()
2042 "Remove all trailing blank lines from the article."
2045 (let ((buffer-read-only nil))
2046 (goto-char (point-max))
2050 (while (and (not (bobp))
2051 (looking-at "^[ \t]*$")
2052 (not (gnus-annotation-in-region-p
2053 (point) (gnus-point-at-eol))))
2058 (defun article-display-face ()
2059 "Display any Face headers in the header."
2061 (gnus-with-article-headers
2062 (let ((face (message-fetch-field "face")))
2064 (let ((png (gnus-convert-face-to-png face))
2067 (setq image (gnus-create-image png 'png t))
2068 (gnus-article-goto-header "from")
2070 (insert "From: [no `from' set]\n")
2072 (gnus-add-wash-type 'face)
2073 (gnus-add-image 'face image)
2074 (gnus-put-image image)))))))
2076 (defun article-display-x-face (&optional force)
2077 "Look for an X-Face header and display it if present."
2078 (interactive (list 'force))
2079 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2080 (gnus-with-article-headers
2081 ;; Delete the old process, if any.
2082 (when (process-status "article-x-face")
2083 (delete-process "article-x-face"))
2084 (if (memq 'xface gnus-article-wash-types)
2085 ;; We have already displayed X-Faces, so we remove them
2087 (gnus-delete-images 'xface)
2089 (let (x-faces from face)
2091 (when (and wash-face-p
2093 (goto-char (point-min))
2094 (not (re-search-forward
2095 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2096 (gnus-buffer-live-p gnus-original-article-buffer))
2097 ;; If type `W f', use gnus-original-article-buffer,
2098 ;; otherwise use the current buffer because displaying
2099 ;; RFC822 parts calls this function too.
2100 (set-buffer gnus-original-article-buffer))
2102 (mail-narrow-to-head)
2103 (while (gnus-article-goto-header "X-Face")
2104 (push (mail-header-field-value) x-faces))
2105 (setq from (message-fetch-field "from"))))
2106 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2107 ;; single external face.
2108 (when (stringp gnus-article-x-face-command)
2109 (setq x-faces (list (car x-faces))))
2110 (while (and (setq face (pop x-faces))
2111 gnus-article-x-face-command
2113 ;; Check whether this face is censored.
2114 (not gnus-article-x-face-too-ugly)
2115 (and gnus-article-x-face-too-ugly from
2116 (not (string-match gnus-article-x-face-too-ugly
2118 ;; We display the face.
2119 (if (symbolp gnus-article-x-face-command)
2120 ;; The command is a lisp function, so we call it.
2121 (if (gnus-functionp gnus-article-x-face-command)
2122 (funcall gnus-article-x-face-command face)
2123 (error "%s is not a function" gnus-article-x-face-command))
2124 ;; The command is a string, so we interpret the command
2125 ;; as a, well, command, and fork it off.
2126 (let ((process-connection-type nil))
2127 (process-kill-without-query
2129 "article-x-face" nil shell-file-name shell-command-switch
2130 gnus-article-x-face-command))
2133 (process-send-region "article-x-face"
2134 (point-min) (point-max)))
2135 (process-send-eof "article-x-face")))))))))
2137 (defun article-decode-mime-words ()
2138 "Decode all MIME-encoded words in the article."
2141 (set-buffer gnus-article-buffer)
2142 (let ((inhibit-point-motion-hooks t)
2144 (mail-parse-charset gnus-newsgroup-charset)
2145 (mail-parse-ignored-charsets
2146 (save-excursion (set-buffer gnus-summary-buffer)
2147 gnus-newsgroup-ignored-charsets)))
2148 (mail-decode-encoded-word-region (point-min) (point-max)))))
2150 (defun article-decode-charset (&optional prompt)
2151 "Decode charset-encoded text in the article.
2152 If PROMPT (the prefix), prompt for a coding system to use."
2154 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2156 (mail-parse-charset gnus-newsgroup-charset)
2157 (mail-parse-ignored-charsets
2158 (save-excursion (condition-case nil
2159 (set-buffer gnus-summary-buffer)
2161 gnus-newsgroup-ignored-charsets))
2162 ct cte ctl charset format)
2165 (article-narrow-to-head)
2166 (setq ct (message-fetch-field "Content-Type" t)
2167 cte (message-fetch-field "Content-Transfer-Encoding" t)
2168 ctl (and ct (ignore-errors
2169 (mail-header-parse-content-type ct)))
2172 (mm-read-coding-system "Charset to decode: "))
2174 (mail-content-type-get ctl 'charset)))
2175 format (and ctl (mail-content-type-get ctl 'format)))
2177 (setq cte (mail-header-strip cte)))
2178 (if (and ctl (not (string-match "/" (car ctl))))
2180 (goto-char (point-max)))
2183 (narrow-to-region (point) (point-max))
2184 (when (and (eq mail-parse-charset 'gnus-decoded)
2185 (eq (mm-body-7-or-8) '8bit))
2186 ;; The text code could have been decoded.
2187 (setq charset mail-parse-charset))
2188 (when (and (or (not ctl)
2189 (equal (car ctl) "text/plain"))
2190 (not format)) ;; article with format will decode later.
2192 charset (and cte (intern (downcase
2193 (gnus-strip-whitespace cte))))
2196 (defun article-decode-encoded-words ()
2197 "Remove encoded-word encoding from headers."
2198 (let (buffer-read-only)
2199 (let ((charset (save-excursion
2200 (set-buffer gnus-summary-buffer)
2201 default-mime-charset)))
2202 (mime-decode-header-in-buffer charset))))
2204 (defun article-decode-group-name ()
2205 "Decode group names in `Newsgroups:'."
2206 (let ((inhibit-point-motion-hooks t)
2208 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2209 (when (and (or gnus-group-name-charset-method-alist
2210 gnus-group-name-charset-group-alist)
2211 (gnus-buffer-live-p gnus-original-article-buffer))
2212 (when (nnmail-fetch-field "Newsgroups")
2213 (nnheader-replace-header "Newsgroups"
2214 (gnus-decode-newsgroups
2215 (with-current-buffer
2216 gnus-original-article-buffer
2217 (nnmail-fetch-field "Newsgroups"))
2218 gnus-newsgroup-name method)))
2219 (when (nnmail-fetch-field "Followup-To")
2220 (nnheader-replace-header "Followup-To"
2221 (gnus-decode-newsgroups
2222 (with-current-buffer
2223 gnus-original-article-buffer
2224 (nnmail-fetch-field "Followup-To"))
2225 gnus-newsgroup-name method))))))
2227 (defun article-de-quoted-unreadable (&optional force read-charset)
2228 "Translate a quoted-printable-encoded article.
2229 If FORCE, decode the article whether it is marked as quoted-printable
2231 If READ-CHARSET, ask for a coding system."
2232 (interactive (list 'force current-prefix-arg))
2234 (let ((buffer-read-only nil) type charset)
2235 (if (gnus-buffer-live-p gnus-original-article-buffer)
2236 (with-current-buffer gnus-original-article-buffer
2238 (gnus-fetch-field "content-transfer-encoding"))
2239 (let* ((ct (gnus-fetch-field "content-type"))
2242 (mail-header-parse-content-type ct)))))
2243 (setq charset (and ctl
2244 (mail-content-type-get ctl 'charset)))
2245 (if (stringp charset)
2246 (setq charset (intern (downcase charset)))))))
2248 (setq charset (mm-read-coding-system "Charset: " charset)))
2250 (setq charset gnus-newsgroup-charset))
2252 (and type (let ((case-fold-search t))
2253 (string-match "quoted-printable" type))))
2255 (quoted-printable-decode-region
2256 (point) (point-max) (mm-charset-to-coding-system charset))))))
2258 (defun article-de-base64-unreadable (&optional force read-charset)
2259 "Translate a base64 article.
2260 If FORCE, decode the article whether it is marked as base64 not.
2261 If READ-CHARSET, ask for a coding system."
2262 (interactive (list 'force current-prefix-arg))
2264 (let ((buffer-read-only nil) type charset)
2265 (if (gnus-buffer-live-p gnus-original-article-buffer)
2266 (with-current-buffer gnus-original-article-buffer
2268 (gnus-fetch-field "content-transfer-encoding"))
2269 (let* ((ct (gnus-fetch-field "content-type"))
2272 (mail-header-parse-content-type ct)))))
2273 (setq charset (and ctl
2274 (mail-content-type-get ctl 'charset)))
2275 (if (stringp charset)
2276 (setq charset (intern (downcase charset)))))))
2278 (setq charset (mm-read-coding-system "Charset: " charset)))
2280 (setq charset gnus-newsgroup-charset))
2282 (and type (let ((case-fold-search t))
2283 (string-match "base64" type))))
2286 (narrow-to-region (point) (point-max))
2287 (base64-decode-region (point-min) (point-max))
2288 (mm-decode-coding-region
2289 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2294 (defun article-decode-HZ ()
2295 "Translate a HZ-encoded article."
2299 (let ((buffer-read-only nil))
2300 (rfc1843-decode-region (point-min) (point-max)))))
2302 (defun article-unsplit-urls ()
2303 "Remove the newlines that some other mailers insert into URLs."
2306 (let ((buffer-read-only nil))
2307 (goto-char (point-min))
2308 (while (re-search-forward
2309 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2310 (replace-match "\\1\\3" t)))
2311 (when (and gnus-display-mime-function (interactive-p))
2312 (funcall gnus-display-mime-function))))
2315 (defun article-wash-html (&optional read-charset)
2316 "Format an HTML article.
2317 If READ-CHARSET, ask for a coding system."
2320 (let ((buffer-read-only nil)
2322 (when (gnus-buffer-live-p gnus-original-article-buffer)
2323 (with-current-buffer gnus-original-article-buffer
2324 (let* ((ct (gnus-fetch-field "content-type"))
2327 (mail-header-parse-content-type ct)))))
2328 (setq charset (and ctl
2329 (mail-content-type-get ctl 'charset)))
2330 (when (stringp charset)
2331 (setq charset (intern (downcase charset)))))))
2333 (setq charset (mm-read-coding-system "Charset: " charset)))
2335 (setq charset gnus-newsgroup-charset))
2337 (save-window-excursion
2339 (narrow-to-region (point) (point-max))
2340 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2341 (entry (assq func mm-text-html-washer-alist)))
2343 (setq func (cdr entry)))
2345 ((gnus-functionp func)
2348 (apply (car func) (cdr func))))))))))
2350 (defun gnus-article-wash-html-with-w3 ()
2351 "Wash the current buffer with w3."
2353 (let ((w3-strict-width (window-width))
2354 (url-standalone-mode t)
2355 (url-gateway-unplugged t)
2356 (w3-honor-stylesheets nil))
2358 (w3-region (point-min) (point-max))
2361 (defun gnus-article-wash-html-with-w3m ()
2362 "Wash the current buffer with emacs-w3m."
2365 (narrow-to-region (point) (point-max))
2366 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2369 (w3m-display-inline-images mm-inline-text-html-with-images)
2370 w3m-force-redisplay)
2371 (w3m-region (point-min) (point-max)))
2372 (when mm-inline-text-html-with-w3m-keymap
2373 (add-text-properties
2374 (point-min) (point-max)
2375 (nconc (mm-w3m-local-map-property)
2376 '(mm-inline-text-html-with-w3m t))))))
2378 (defun article-hide-list-identifiers ()
2379 "Remove list identifies from the Subject header.
2380 The `gnus-list-identifiers' variable specifies what to do."
2382 (let ((inhibit-point-motion-hooks t)
2383 (regexp (if (consp gnus-list-identifiers)
2384 (mapconcat 'identity gnus-list-identifiers " *\\|")
2385 gnus-list-identifiers))
2390 (article-narrow-to-head)
2391 (goto-char (point-min))
2392 (while (re-search-forward
2393 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2395 (delete-region (match-beginning 2) (match-end 0))
2396 (beginning-of-line))
2397 (when (re-search-forward
2398 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2399 (delete-region (match-beginning 1) (match-end 1))))))))
2401 (defun article-hide-pem (&optional arg)
2402 "Toggle hiding of any PEM headers and signatures in the current article.
2403 If given a negative prefix, always show; if given a positive prefix,
2405 (interactive (gnus-article-hidden-arg))
2406 (unless (gnus-article-check-hidden-text 'pem arg)
2408 (let (buffer-read-only end)
2409 (goto-char (point-min))
2410 ;; Hide the horrendously ugly "header".
2411 (when (and (search-forward
2412 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2414 (setq end (1+ (match-beginning 0))))
2415 (gnus-add-wash-type 'pem)
2416 (gnus-article-hide-text-type
2418 (if (search-forward "\n\n" nil t)
2422 ;; Hide the trailer as well
2423 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2425 (gnus-article-hide-text-type
2426 (match-beginning 0) (match-end 0) 'pem)))))))
2428 (defun article-strip-banner ()
2429 "Strip the banners specified by the `banner' group parameter and by
2430 `gnus-article-address-banner-alist'."
2434 (let ((inhibit-point-motion-hooks t))
2435 (when (gnus-parameter-banner gnus-newsgroup-name)
2436 (article-really-strip-banner
2437 (gnus-parameter-banner gnus-newsgroup-name)))
2438 (when gnus-article-address-banner-alist
2439 (article-really-strip-banner
2440 (let ((from (save-restriction
2442 (article-narrow-to-head)
2443 (mail-fetch-field "from"))))
2446 (caar (mail-header-parse-addresses from))))
2448 (dolist (pair gnus-article-address-banner-alist)
2449 (when (string-match (car pair) from)
2450 (throw 'found (cdr pair)))))))))))))
2452 (defun article-really-strip-banner (banner)
2453 "Strip the banner specified by the argument."
2456 (let ((inhibit-point-motion-hooks t)
2457 (gnus-signature-limit nil)
2461 ((eq banner 'signature)
2462 (when (gnus-article-narrow-to-signature)
2465 (delete-region (point) (point-max))))
2467 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2468 (while (re-search-forward banner nil t)
2469 (delete-region (match-beginning 0) (match-end 0)))))
2471 (while (re-search-forward banner nil t)
2472 (delete-region (match-beginning 0) (match-end 0)))))))))
2474 (defun article-babel ()
2475 "Translate article using an online translation service."
2479 (set-buffer gnus-article-buffer)
2480 (when (article-goto-body)
2481 (let* ((buffer-read-only nil)
2484 (orig (buffer-substring start end))
2485 (trans (babel-as-string orig)))
2487 (narrow-to-region start end)
2488 (delete-region start end)
2491 (defun article-hide-signature (&optional arg)
2492 "Hide the signature in the current article.
2493 If given a negative prefix, always show; if given a positive prefix,
2495 (interactive (gnus-article-hidden-arg))
2501 (article-goto-body))
2502 (goto-char (point-min)))
2503 (unless (gnus-article-check-hidden-text 'signature arg)
2504 (let ((buffer-read-only nil)
2506 (while (setq button (text-property-any button (point-max)
2508 'gnus-signature-toggle))
2509 (setq button (text-property-not-all button (point-max)
2511 'gnus-signature-toggle))
2512 (when (and button (not (eobp)))
2513 (gnus-article-hide-text-type
2515 (next-single-property-change (1+ button) 'mime-view-entity
2518 (gnus-set-mode-line 'article))
2520 (defun article-strip-headers-in-body ()
2521 "Strip offensive headers from bodies."
2525 (let ((case-fold-search t))
2526 (when (looking-at "x-no-archive:")
2527 (gnus-delete-line)))))
2529 (defun article-strip-leading-blank-lines ()
2530 "Remove all blank lines from the beginning of the article."
2533 (let ((inhibit-point-motion-hooks t)
2535 (when (article-goto-body)
2536 (while (and (not (eobp))
2537 (looking-at "[ \t]*$"))
2538 (gnus-delete-line))))))
2540 (defun article-narrow-to-head ()
2541 "Narrow the buffer to the head of the message.
2542 Point is left at the beginning of the narrowed-to region."
2544 (goto-char (point-min))
2545 (if (search-forward "\n\n" nil 1)
2548 (goto-char (point-min)))
2550 (defun article-goto-body ()
2551 "Place point at the start of the body."
2552 (goto-char (point-min))
2554 ;; This variable is only bound when dealing with separate
2556 (article-goto-body-goes-to-point-min-p
2558 ((search-forward "\n\n" nil t)
2561 (goto-char (point-max))
2564 (defun article-strip-multiple-blank-lines ()
2565 "Replace consecutive blank lines with one empty line."
2568 (let ((inhibit-point-motion-hooks t)
2570 ;; First make all blank lines empty.
2572 (while (re-search-forward "^[ \t]+$" nil t)
2573 (unless (gnus-annotation-in-region-p
2574 (match-beginning 0) (match-end 0))
2575 (replace-match "" nil t)))
2576 ;; Then replace multiple empty lines with a single empty line.
2578 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2579 (unless (gnus-annotation-in-region-p
2580 (match-beginning 0) (match-end 0))
2581 (delete-region (match-beginning 1) (match-end 1)))))))
2583 (defun article-strip-leading-space ()
2584 "Remove all white space from the beginning of the lines in the article."
2587 (let ((inhibit-point-motion-hooks t)
2590 (while (re-search-forward "^[ \t]+" nil t)
2591 (replace-match "" t t)))))
2593 (defun article-strip-trailing-space ()
2594 "Remove all white space from the end of the lines in the article."
2597 (let ((inhibit-point-motion-hooks t)
2600 (while (re-search-forward "[ \t]+$" nil t)
2601 (replace-match "" t t)))))
2603 (defun article-strip-blank-lines ()
2604 "Strip leading, trailing and multiple blank lines."
2606 (article-strip-leading-blank-lines)
2607 (article-remove-trailing-blank-lines)
2608 (article-strip-multiple-blank-lines))
2610 (defun article-strip-all-blank-lines ()
2611 "Strip all blank lines."
2614 (let ((inhibit-point-motion-hooks t)
2617 (while (re-search-forward "^[ \t]*\n" nil t)
2618 (replace-match "" t t)))))
2620 (defun gnus-article-narrow-to-signature ()
2621 "Narrow to the signature; return t if a signature is found, else nil."
2622 (let ((inhibit-point-motion-hooks t))
2623 (when (gnus-article-search-signature)
2625 ;; Check whether we have some limits to what we consider
2626 ;; to be a signature.
2627 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2628 (list gnus-signature-limit)))
2630 (while (setq limit (pop limits))
2631 (if (or (and (integerp limit)
2632 (< (- (point-max) (point)) limit))
2634 (< (count-lines (point) (point-max)) limit))
2635 (and (gnus-functionp limit)
2637 (and (stringp limit)
2638 (not (re-search-forward limit nil t))))
2639 () ; This limit did not succeed.
2643 (narrow-to-region (point) (point-max))
2646 (defun gnus-article-search-signature ()
2647 "Search the current buffer for the signature separator.
2648 Put point at the beginning of the signature separator."
2649 (let ((cur (point)))
2650 (goto-char (point-max))
2651 (if (if (stringp gnus-signature-separator)
2652 (re-search-backward gnus-signature-separator nil t)
2653 (let ((seps gnus-signature-separator))
2655 (not (re-search-backward (car seps) nil t)))
2662 (defun gnus-article-hidden-arg ()
2663 "Return the current prefix arg as a number, or 0 if no prefix."
2664 (list (if current-prefix-arg
2665 (prefix-numeric-value current-prefix-arg)
2668 (defun gnus-article-check-hidden-text (type arg)
2669 "Return nil if hiding is necessary.
2670 Arg can be nil or a number. nil and positive means hide, negative
2671 means show, 0 means toggle."
2674 (let ((hide (gnus-article-hidden-text-p type)))
2680 (gnus-article-show-hidden-text type)
2683 (if (eq hide 'hidden)
2685 (gnus-article-show-hidden-text type)
2689 (defun gnus-article-hidden-text-p (type)
2690 "Say whether the current buffer contains hidden text of type TYPE."
2691 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2693 (not (get-text-property pos 'invisible))
2694 (not (get-text-property pos 'dummy-invisible)))
2696 (text-property-any (1+ pos) (point-max) 'article-type type)))
2701 (defun gnus-article-show-hidden-text (type &optional dummy)
2702 "Show all hidden text of type TYPE.
2703 Originally it is hide instead of DUMMY."
2704 (let ((buffer-read-only nil)
2705 (inhibit-point-motion-hooks t))
2706 (gnus-remove-text-properties-when
2708 (point-min) (point-max)
2709 (cons 'article-type (cons type
2710 gnus-hidden-properties)))
2711 (gnus-delete-wash-type type)))
2713 (defconst article-time-units
2714 `((year . ,(* 365.25 24 60 60))
2715 (week . ,(* 7 24 60 60))
2716 (day . ,(* 24 60 60))
2720 "Mapping from time units to seconds.")
2722 (defun gnus-article-forward-header ()
2723 "Move point to the start of the next header.
2724 If the current header is a continuation header, this can be several
2729 (if (looking-at "[ \t]+[^ \t]")
2733 (defun article-date-ut (&optional type highlight header)
2734 "Convert DATE date to universal time in the current article.
2735 If TYPE is `local', convert to local time; if it is `lapsed', output
2736 how much time has lapsed since DATE. For `lapsed', the value of
2737 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2738 should replace the \"Date:\" one, or should be added below it."
2739 (interactive (list 'ut t))
2740 (let* ((header (or header
2741 (and (eq 1 (point-min))
2742 (mail-header-date (save-excursion
2743 (set-buffer gnus-summary-buffer)
2744 gnus-current-headers)))
2745 (message-fetch-field "date")
2747 (date (if (vectorp header) (mail-header-date header)
2749 (inhibit-point-motion-hooks t)
2750 bface eface date-pos)
2751 (when (and date (not (string= date "")))
2754 (article-narrow-to-head)
2755 (when (or (and (eq type 'lapsed)
2756 gnus-article-date-lapsed-new-header
2757 ;; Attempt to get the face of X-Sent first.
2758 (re-search-forward "^X-Sent:[ \t]" nil t))
2759 (re-search-forward "^Date:[ \t]" nil t)
2760 ;; If Date is missing, try again for X-Sent.
2761 (re-search-forward "^X-Sent:[ \t]" nil t))
2762 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2763 date (or (get-text-property (gnus-point-at-bol)
2766 eface (get-text-property (1- (gnus-point-at-eol))
2768 (let ((buffer-read-only nil))
2769 ;; Delete any old X-Sent headers.
2770 (when (setq date-pos
2771 (text-property-any (point-min) (point-max)
2772 'article-date-lapsed t))
2773 (goto-char (setq date-pos (set-marker (make-marker) date-pos)))
2774 (delete-region (match-beginning 0)
2775 (progn (forward-line 1) (point))))
2776 (goto-char (point-min))
2777 ;; Delete any old Date headers.
2778 (while (re-search-forward "^Date:[ \t]" nil t)
2780 (setq date-pos (match-beginning 0)))
2781 (unless (and (eq type 'lapsed)
2782 gnus-article-date-lapsed-new-header)
2783 (delete-region (match-beginning 0)
2784 (progn (message-next-header) (point)))))
2787 (goto-char date-pos)
2789 ;; Possibly, Date has been deleted.
2791 (when (and (eq type 'lapsed)
2792 gnus-article-date-lapsed-new-header
2793 (looking-at "Date:"))
2795 (goto-char (point-min)))
2796 (insert (article-make-date-line date type))
2797 (when (eq type 'lapsed)
2798 (put-text-property (gnus-point-at-bol) (point)
2799 'article-date-lapsed t))
2803 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2804 (put-text-property (match-beginning 1) (1+ (match-end 1))
2805 'original-date date)
2806 (put-text-property (match-beginning 1) (1+ (match-end 1))
2808 (put-text-property (match-beginning 2) (match-end 2)
2811 (defun article-make-date-line (date type)
2812 "Return a DATE line of TYPE."
2813 (unless (memq type '(local ut original user iso8601 lapsed english))
2814 (error "Unknown conversion type: %s" type))
2816 (let ((time (date-to-time date)))
2818 ;; Convert to the local timezone.
2820 (let ((tz (car (current-time-zone time))))
2821 (format "Date: %s %s%02d%02d" (current-time-string time)
2822 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2823 (/ (% (abs tz) 3600) 60))))
2824 ;; Convert to Universal Time.
2827 (current-time-string
2828 (let* ((e (parse-time-string date))
2829 (tm (apply 'encode-time e))
2831 (ls (- (cadr tm) (car (current-time-zone time)))))
2832 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2833 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2836 ;; Get the original date from the article.
2837 ((eq type 'original)
2838 (concat "Date: " (if (string-match "\n+$" date)
2839 (substring date 0 (match-beginning 0))
2841 ;; Let the user define the format.
2843 (let ((format (or (condition-case nil
2844 (with-current-buffer gnus-summary-buffer
2845 gnus-article-time-format)
2847 gnus-article-time-format)))
2848 (if (gnus-functionp format)
2849 (funcall format time)
2850 (concat "Date: " (format-time-string format time)))))
2853 (let ((tz (car (current-time-zone time))))
2856 (format-time-string "%Y%m%dT%H%M%S" time)
2857 (format "%s%02d%02d"
2858 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2859 (/ (% (abs tz) 3600) 60)))))
2860 ;; Do an X-Sent lapsed format.
2862 ;; If the date is seriously mangled, the timezone functions are
2863 ;; liable to bug out, so we ignore all errors.
2864 (let* ((now (current-time))
2865 (real-time (subtract-time now time))
2866 (real-sec (and real-time
2867 (+ (* (float (car real-time)) 65536)
2869 (sec (and real-time (abs real-sec)))
2879 ;; This is a bit convoluted, but basically we go
2880 ;; through the time units for years, weeks, etc,
2881 ;; and divide things to see whether that results
2882 ;; in positive answers.
2885 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2886 ;; The (remaining) seconds are too few to
2887 ;; be divided into this time unit.
2889 ;; It's big enough, so we output it.
2890 (setq sec (- sec (* num (cdr unit))))
2892 (concat (if prev ", " "") (int-to-string
2894 " " (symbol-name (car unit))
2895 (if (> num 1) "s" ""))
2897 article-time-units "")
2898 ;; If dates are odd, then it might appear like the
2899 ;; article was sent in the future.
2902 " in the future"))))))
2903 ;; Display the date in proper English
2905 (let ((dtime (decode-time time)))
2908 (number-to-string (nth 3 dtime))
2909 (let ((digit (% (nth 3 dtime) 10)))
2911 ((memq (nth 3 dtime) '(11 12 13)) "th")
2917 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2919 (number-to-string (nth 5 dtime))
2921 (format "%02d" (nth 2 dtime))
2923 (format "%02d" (nth 1 dtime)))))))
2925 (format "Date: %s (from T-gnus)" date))))
2927 (defun article-date-local (&optional highlight)
2928 "Convert the current article date to the local timezone."
2929 (interactive (list t))
2930 (article-date-ut 'local highlight))
2932 (defun article-date-english (&optional highlight)
2933 "Convert the current article date to something that is proper English."
2934 (interactive (list t))
2935 (article-date-ut 'english highlight))
2937 (defun article-date-original (&optional highlight)
2938 "Convert the current article date to what it was originally.
2939 This is only useful if you have used some other date conversion
2940 function and want to see what the date was before converting."
2941 (interactive (list t))
2942 (article-date-ut 'original highlight))
2944 (defun article-date-lapsed (&optional highlight)
2945 "Convert the current article date to time lapsed since it was sent."
2946 (interactive (list t))
2947 (article-date-ut 'lapsed highlight))
2949 (defun article-update-date-lapsed ()
2950 "Function to be run from a timer to update the lapsed time line."
2951 (let (deactivate-mark)
2956 (set-buffer (window-buffer w))
2957 (when (eq major-mode 'gnus-article-mode)
2958 (goto-char (point-min))
2959 (when (re-search-forward "^X-Sent:" nil t)
2960 (article-date-lapsed t))))
2963 (defun gnus-start-date-timer (&optional n)
2964 "Start a timer to update the X-Sent header in the article buffers.
2965 The numerical prefix says how frequently (in seconds) the function
2970 (gnus-stop-date-timer)
2971 (setq article-lapsed-timer
2972 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2974 (defun gnus-stop-date-timer ()
2975 "Stop the X-Sent timer."
2977 (when article-lapsed-timer
2978 (nnheader-cancel-timer article-lapsed-timer)
2979 (setq article-lapsed-timer nil)))
2981 (defun article-date-user (&optional highlight)
2982 "Convert the current article date to the user-defined format.
2983 This format is defined by the `gnus-article-time-format' variable."
2984 (interactive (list t))
2985 (article-date-ut 'user highlight))
2987 (defun article-date-iso8601 (&optional highlight)
2988 "Convert the current article date to ISO8601."
2989 (interactive (list t))
2990 (article-date-ut 'iso8601 highlight))
2992 ;; (defun article-show-all ()
2993 ;; "Show all hidden text in the article buffer."
2997 ;; (let ((buffer-read-only nil))
2998 ;; (gnus-article-unhide-text (point-min) (point-max))
2999 ;; (gnus-remove-text-with-property 'gnus-prev)
3000 ;; (gnus-remove-text-with-property 'gnus-next))))
3002 (defun article-show-all-headers ()
3003 "Show all hidden headers in the article buffer."
3008 (article-narrow-to-head)
3009 (let ((buffer-read-only nil))
3010 (gnus-article-unhide-text (point-min) (point-max))))))
3012 (defun article-remove-leading-whitespace ()
3013 "Remove excessive whitespace from all headers."
3017 (let ((buffer-read-only nil))
3018 (article-narrow-to-head)
3019 (goto-char (point-min))
3020 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3021 (delete-region (match-beginning 1) (match-end 1)))))))
3023 (defun article-emphasize (&optional arg)
3024 "Emphasize text according to `gnus-emphasis-alist'."
3025 (interactive (gnus-article-hidden-arg))
3026 (unless (gnus-article-check-hidden-text 'emphasis arg)
3030 (with-current-buffer gnus-summary-buffer
3031 gnus-article-emphasis-alist)
3033 gnus-emphasis-alist))
3034 (buffer-read-only nil)
3035 (props (append '(article-type emphasis)
3036 gnus-hidden-properties))
3037 regexp elem beg invisible visible face)
3040 (while (setq elem (pop alist))
3042 (setq regexp (car elem)
3043 invisible (nth 1 elem)
3044 visible (nth 2 elem)
3046 (while (re-search-forward regexp nil t)
3047 (when (and (match-beginning visible) (match-beginning invisible))
3048 (gnus-article-hide-text
3049 (match-beginning invisible) (match-end invisible) props)
3050 (gnus-article-unhide-text-type
3051 (match-beginning visible) (match-end visible) 'emphasis)
3052 (gnus-put-overlay-excluding-newlines
3053 (match-beginning visible) (match-end visible) 'face face)
3054 (gnus-add-wash-type 'emphasis)
3055 (goto-char (match-end invisible)))))))))
3057 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3058 "Setup newsgroup emphasis alist."
3059 (unless gnus-article-emphasis-alist
3060 (let ((name (and gnus-newsgroup-name
3061 (gnus-group-real-name gnus-newsgroup-name))))
3062 (make-local-variable 'gnus-article-emphasis-alist)
3063 (setq gnus-article-emphasis-alist
3065 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3066 (while (setq elem (pop alist))
3067 (when (and name (string-match (car elem) name))
3069 highlight (copy-sequence (cdr elem)))))
3071 (copy-sequence highlight-words)
3072 (if gnus-newsgroup-name
3073 (copy-sequence (gnus-group-find-parameter
3074 gnus-newsgroup-name 'highlight-words t)))
3075 gnus-emphasis-alist)))))
3078 (defvar gnus-summary-article-menu)
3079 (defvar gnus-summary-post-menu))
3081 ;;; Saving functions.
3083 (defun gnus-article-save (save-buffer file &optional num)
3084 "Save the currently selected article."
3085 (unless gnus-save-all-headers
3086 ;; Remove headers according to `gnus-saved-headers'.
3087 (let ((gnus-visible-headers
3088 (or gnus-saved-headers gnus-visible-headers))
3089 (gnus-article-buffer save-buffer))
3091 (set-buffer save-buffer)
3092 (article-hide-headers 1 t))))
3093 (save-window-excursion
3094 (if (not gnus-default-article-saver)
3095 (error "No default saver is defined")
3096 ;; !!! Magic! The saving functions all save
3097 ;; `gnus-save-article-buffer' (or so they think), but we
3098 ;; bind that variable to our save-buffer.
3099 (set-buffer gnus-article-buffer)
3100 (let* ((gnus-save-article-buffer save-buffer)
3103 ((not gnus-prompt-before-saving) 'default)
3104 ((eq gnus-prompt-before-saving 'always) nil)
3106 (gnus-number-of-articles-to-be-saved
3107 (when (eq gnus-prompt-before-saving t)
3109 (set-buffer gnus-article-current-summary)
3110 (funcall gnus-default-article-saver filename)))))
3112 (defun gnus-read-save-file-name (prompt &optional filename
3113 function group headers variable)
3115 (funcall function group headers (symbol-value variable)))
3120 ((eq filename 'default)
3126 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3129 (if (and gnus-number-of-articles-to-be-saved
3130 (> gnus-number-of-articles-to-be-saved 1))
3131 (format "these %d articles"
3132 gnus-number-of-articles-to-be-saved)
3135 ;; Let the split methods have their say.
3137 ;; No split name was found.
3140 (concat prompt " (default "
3141 (file-name-nondirectory default-name) ") ")
3142 (file-name-directory default-name)
3144 ;; A single group name is returned.
3145 ((stringp split-name)
3147 (funcall function split-name headers
3148 (symbol-value variable)))
3150 (concat prompt " (default "
3151 (file-name-nondirectory default-name) ") ")
3152 (file-name-directory default-name)
3154 ;; A single split name was found
3155 ((= 1 (length split-name))
3156 (let* ((name (expand-file-name
3158 gnus-article-save-directory))
3159 (dir (cond ((file-directory-p name)
3160 (file-name-as-directory name))
3161 ((file-exists-p name) name)
3162 (t gnus-article-save-directory))))
3164 (concat prompt " (default " name ") ")
3166 ;; A list of splits was found.
3168 (setq split-name (nreverse split-name))
3170 (let ((file-name-history
3171 (nconc split-name file-name-history)))
3175 (concat prompt " (`M-p' for defaults) ")
3176 gnus-article-save-directory
3178 gnus-article-save-directory)))
3179 (car (push result file-name-history)))))))
3180 ;; Create the directory.
3181 (gnus-make-directory (file-name-directory file))
3182 ;; If we have read a directory, we append the default file name.
3183 (when (file-directory-p file)
3184 (setq file (expand-file-name (file-name-nondirectory
3186 (file-name-as-directory file))))
3187 ;; Possibly translate some characters.
3188 (nnheader-translate-file-chars file))))))
3189 (gnus-make-directory (file-name-directory result))
3190 (set variable result)))
3192 (defun gnus-article-archive-name (group)
3193 "Return the first instance of an \"Archive-name\" in the current buffer."
3194 (let ((case-fold-search t))
3195 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3196 (nnheader-concat gnus-article-save-directory
3197 (match-string 1)))))
3199 (defun gnus-article-nndoc-name (group)
3200 "If GROUP is an nndoc group, return the name of the parent group."
3201 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3202 (gnus-group-get-parameter group 'save-article-group)))
3204 (defun gnus-summary-save-in-rmail (&optional filename)
3205 "Append this article to Rmail file.
3206 Optional argument FILENAME specifies file name.
3207 Directory to save to is default to `gnus-article-save-directory'."
3208 (setq filename (gnus-read-save-file-name
3209 "Save %s in rmail file:" filename
3210 gnus-rmail-save-name gnus-newsgroup-name
3211 gnus-current-headers 'gnus-newsgroup-last-rmail))
3212 (gnus-eval-in-buffer-window gnus-save-article-buffer
3216 (gnus-output-to-rmail filename))))
3219 (defun gnus-summary-save-in-mail (&optional filename)
3220 "Append this article to Unix mail file.
3221 Optional argument FILENAME specifies file name.
3222 Directory to save to is default to `gnus-article-save-directory'."
3223 (setq filename (gnus-read-save-file-name
3224 "Save %s in Unix mail file:" filename
3225 gnus-mail-save-name gnus-newsgroup-name
3226 gnus-current-headers 'gnus-newsgroup-last-mail))
3227 (gnus-eval-in-buffer-window gnus-save-article-buffer
3231 (if (and (file-readable-p filename)
3232 (file-regular-p filename)
3233 (mail-file-babyl-p filename))
3234 (rmail-output-to-rmail-file filename t)
3235 (gnus-output-to-mail filename)))))
3238 (defun gnus-summary-save-in-file (&optional filename overwrite)
3239 "Append this article to file.
3240 Optional argument FILENAME specifies file name.
3241 Directory to save to is default to `gnus-article-save-directory'."
3242 (setq filename (gnus-read-save-file-name
3243 "Save %s in file:" filename
3244 gnus-file-save-name gnus-newsgroup-name
3245 gnus-current-headers 'gnus-newsgroup-last-file))
3246 (gnus-eval-in-buffer-window gnus-save-article-buffer
3250 (when (and overwrite
3251 (file-exists-p filename))
3252 (delete-file filename))
3253 (gnus-output-to-file filename))))
3256 (defun gnus-summary-write-to-file (&optional filename)
3257 "Write this article to a file, overwriting it if the file exists.
3258 Optional argument FILENAME specifies file name.
3259 The directory to save in defaults to `gnus-article-save-directory'."
3260 (gnus-summary-save-in-file nil t))
3262 (defun gnus-summary-save-body-in-file (&optional filename)
3263 "Append this article body to a file.
3264 Optional argument FILENAME specifies file name.
3265 The directory to save in defaults to `gnus-article-save-directory'."
3266 (setq filename (gnus-read-save-file-name
3267 "Save %s body in file:" filename
3268 gnus-file-save-name gnus-newsgroup-name
3269 gnus-current-headers 'gnus-newsgroup-last-file))
3270 (gnus-eval-in-buffer-window gnus-save-article-buffer
3274 (when (article-goto-body)
3275 (narrow-to-region (point) (point-max)))
3276 (gnus-output-to-file filename))))
3279 (defun gnus-summary-save-in-pipe (&optional command)
3280 "Pipe this article to subprocess."
3282 (cond ((and (eq command 'default)
3283 gnus-last-shell-command)
3284 gnus-last-shell-command)
3289 "Shell command on %s: "
3290 (if (and gnus-number-of-articles-to-be-saved
3291 (> gnus-number-of-articles-to-be-saved 1))
3292 (format "these %d articles"
3293 gnus-number-of-articles-to-be-saved)
3295 gnus-last-shell-command))))
3296 (when (string-equal command "")
3297 (if gnus-last-shell-command
3298 (setq command gnus-last-shell-command)
3299 (error "A command is required")))
3300 (gnus-eval-in-buffer-window gnus-article-buffer
3303 (shell-command-on-region (point-min) (point-max) command nil)))
3304 (setq gnus-last-shell-command command))
3306 (defun gnus-summary-pipe-to-muttprint (&optional command)
3307 "Pipe this article to muttprint."
3308 (setq command (read-string
3309 "Print using command: " gnus-summary-muttprint-program
3310 nil gnus-summary-muttprint-program))
3311 (gnus-summary-save-in-pipe command))
3313 ;;; Article file names when saving.
3315 (defun gnus-capitalize-newsgroup (newsgroup)
3316 "Capitalize NEWSGROUP name."
3317 (when (not (zerop (length newsgroup)))
3318 (concat (char-to-string (upcase (aref newsgroup 0)))
3319 (substring newsgroup 1))))
3321 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3322 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3323 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3324 Otherwise, it is like ~/News/news/group/num."
3327 (concat (if (gnus-use-long-file-name 'not-save)
3328 (gnus-capitalize-newsgroup newsgroup)
3329 (gnus-newsgroup-directory-form newsgroup))
3330 "/" (int-to-string (mail-header-number headers)))
3331 gnus-article-save-directory)))
3333 (string-equal (file-name-directory default)
3334 (file-name-directory last-file))
3335 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3337 (or last-file default))))
3339 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3340 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3341 If variable `gnus-use-long-file-name' is non-nil, it is
3342 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3345 (concat (if (gnus-use-long-file-name 'not-save)
3347 (gnus-newsgroup-directory-form newsgroup))
3348 "/" (int-to-string (mail-header-number headers)))
3349 gnus-article-save-directory)))
3351 (string-equal (file-name-directory default)
3352 (file-name-directory last-file))
3353 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3355 (or last-file default))))
3357 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3358 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3359 If variable `gnus-use-long-file-name' is non-nil, it is
3360 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3363 (if (gnus-use-long-file-name 'not-save)
3366 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3368 gnus-article-save-directory)))
3370 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3371 "Generate file name from sender."
3372 (let ((from (mail-header-from headers)))
3374 (if (and from (string-match "\\([^ <]+\\)@" from))
3375 (match-string 1 from)
3377 gnus-article-save-directory)))
3379 (defun article-verify-x-pgp-sig ()
3382 (if (gnus-buffer-live-p gnus-original-article-buffer)
3383 (let ((sig (with-current-buffer gnus-original-article-buffer
3384 (gnus-fetch-field "X-PGP-Sig")))
3388 (mml2015-clear-verify-function))
3390 (insert-buffer-substring gnus-original-article-buffer)
3391 (setq items (split-string sig))
3392 (message-narrow-to-head)
3393 (let ((inhibit-point-motion-hooks t)
3394 (case-fold-search t))
3395 ;; Don't verify multiple headers.
3396 (setq headers (mapconcat (lambda (header)
3398 (mail-fetch-field header) "\n"))
3399 (split-string (nth 1 items) ",") "")))
3400 (delete-region (point-min) (point-max))
3401 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3402 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3407 (if (looking-at "^-")
3410 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3411 (insert "Version: " (car items) "\n\n")
3412 (insert (mapconcat 'identity (cddr items) "\n"))
3413 (insert "\n-----END PGP SIGNATURE-----\n")
3414 (let ((mm-security-handle (list (format "multipart/signed"))))
3415 (mml2015-clean-buffer)
3416 (let ((coding-system-for-write (or gnus-newsgroup-charset
3418 (funcall (mml2015-clear-verify-function)))
3420 (or (mm-handle-multipart-ctl-parameter
3421 mm-security-handle 'gnus-details)
3422 (mm-handle-multipart-ctl-parameter
3423 mm-security-handle 'gnus-info)))))
3425 (let (buffer-read-only bface eface)
3427 (message-narrow-to-head)
3428 (goto-char (point-max))
3430 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3431 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3432 (message-remove-header "X-Gnus-PGP-Verify")
3433 (if (re-search-forward "^X-PGP-Sig:" nil t)
3435 (goto-char (point-max)))
3436 (narrow-to-region (point) (point))
3437 (insert "X-Gnus-PGP-Verify: " info "\n")
3438 (goto-char (point-min))
3441 (if (not (looking-at "^[ \t]"))
3445 (goto-char (point-min))
3446 (when (looking-at "\\([^:]+\\): *")
3447 (put-text-property (match-beginning 1) (1+ (match-end 1))
3449 (put-text-property (match-end 0) (point-max)
3450 'face eface)))))))))
3452 (defun article-verify-cancel-lock ()
3453 "Verify Cancel-Lock header."
3455 (if (gnus-buffer-live-p gnus-original-article-buffer)
3456 (canlock-verify gnus-original-article-buffer)))
3458 (defun article-monafy ()
3459 "Display body part with mona font."
3461 (unless (if (featurep 'xemacs)
3462 (find-face 'gnus-mona-face)
3463 (facep 'gnus-mona-face))
3464 (require 'navi2ch-mona)
3465 (set-face-font (make-face 'gnus-mona-face) navi2ch-mona-font))
3467 (let ((buffer-read-only nil))
3470 (gnus-make-overlay (point) (point-max))
3471 'face 'gnus-mona-face))))
3478 (setq afunc (car func)
3481 gfunc (intern (format "gnus-%s" func))))
3483 (when (fboundp afunc)
3484 `(lambda (&optional interactive &rest args)
3485 ,(documentation afunc t)
3486 (interactive (list t))
3488 (set-buffer gnus-article-buffer)
3490 (call-interactively ',afunc)
3491 (apply ',afunc args))))))))
3492 '(article-hide-headers
3493 article-verify-x-pgp-sig
3494 article-verify-cancel-lock
3496 article-hide-boring-headers
3497 article-treat-overstrike
3498 article-fill-long-lines
3499 article-capitalize-sentences
3501 article-remove-leading-whitespace
3502 article-display-x-face
3503 article-display-face
3504 article-de-quoted-unreadable
3505 article-de-base64-unreadable
3508 article-unsplit-urls
3509 article-hide-list-identifiers
3510 article-strip-banner
3513 article-hide-signature
3514 article-strip-headers-in-body
3515 article-remove-trailing-blank-lines
3516 article-strip-leading-blank-lines
3517 article-strip-multiple-blank-lines
3518 article-strip-leading-space
3519 article-strip-trailing-space
3520 article-strip-blank-lines
3521 article-strip-all-blank-lines
3523 article-date-english
3524 article-date-iso8601
3525 article-date-original
3527 article-decode-mime-words
3528 article-decode-charset
3529 article-decode-encoded-words
3533 article-treat-dumbquotes
3534 article-normalize-headers
3535 (article-show-all-headers . gnus-article-show-all-headers)
3536 ;; (article-show-all . gnus-article-show-all)
3540 ;;; Gnus article mode
3543 (put 'gnus-article-mode 'mode-class 'special)
3545 (gnus-define-keys gnus-article-mode-map
3546 " " gnus-article-goto-next-page
3547 "\177" gnus-article-goto-prev-page
3548 [delete] gnus-article-goto-prev-page
3549 [backspace] gnus-article-goto-prev-page
3550 "\C-c^" gnus-article-refer-article
3551 "h" gnus-article-show-summary
3552 "s" gnus-article-show-summary
3553 "\C-c\C-m" gnus-article-mail
3554 "?" gnus-article-describe-briefly
3555 "e" gnus-summary-edit-article
3556 "<" beginning-of-buffer
3558 "\C-c\C-i" gnus-info-find-node
3560 "R" gnus-article-reply-with-original
3561 "F" gnus-article-followup-with-original
3562 "\C-hk" gnus-article-describe-key
3563 "\C-hc" gnus-article-describe-key-briefly
3565 "\C-d" gnus-article-read-summary-keys
3566 "\M-*" gnus-article-read-summary-keys
3567 "\M-#" gnus-article-read-summary-keys
3568 "\M-^" gnus-article-read-summary-keys
3569 "\M-g" gnus-article-read-summary-keys)
3571 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3575 (push (char-to-string key) keys)
3577 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3578 (setq key (car elem))
3579 (when (and (> (length key) 0)
3580 (not (eq 'menu-bar (aref key 0)))
3581 (symbolp (lookup-key gnus-summary-mode-map key)))
3584 (unless (lookup-key gnus-article-mode-map key)
3585 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3587 (defun gnus-article-make-menu-bar ()
3588 (unless (boundp 'gnus-article-commands-menu)
3589 (gnus-summary-make-menu-bar))
3590 (gnus-turn-off-edit-menu 'article)
3591 (unless (boundp 'gnus-article-article-menu)
3593 gnus-article-article-menu gnus-article-mode-map ""
3595 ["Scroll forwards" gnus-article-goto-next-page t]
3596 ["Scroll backwards" gnus-article-goto-prev-page t]
3597 ["Show summary" gnus-article-show-summary t]
3598 ["Fetch Message-ID at point" gnus-article-refer-article t]
3599 ["Mail to address at point" gnus-article-mail t]
3600 ["Send a bug report" gnus-bug t]))
3603 gnus-article-treatment-menu gnus-article-mode-map ""
3604 ;; Fixme: this should use :active (and maybe :visible).
3606 ["Hide headers" gnus-article-hide-headers t]
3607 ["Hide signature" gnus-article-hide-signature t]
3608 ["Hide citation" gnus-article-hide-citation t]
3609 ["Treat overstrike" gnus-article-treat-overstrike t]
3610 ["Remove carriage return" gnus-article-remove-cr t]
3611 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3612 ["Treat html" gnus-article-wash-html t]
3613 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3614 ["Decode HZ" gnus-article-decode-HZ t]))
3616 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3618 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3620 (gnus-run-hooks 'gnus-article-menu-hook)))
3622 (defun gnus-article-mode ()
3623 "Major mode for displaying an article.
3625 All normal editing commands are switched off.
3627 The following commands are available in addition to all summary mode
3629 \\<gnus-article-mode-map>
3630 \\[gnus-article-next-page]\t Scroll the article one page forwards
3631 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3632 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3633 \\[gnus-article-show-summary]\t Display the summary buffer
3634 \\[gnus-article-mail]\t Send a reply to the address near point
3635 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3636 \\[gnus-info-find-node]\t Go to the Gnus info node"
3638 (gnus-simplify-mode-line)
3639 (setq mode-name "Article")
3640 (setq major-mode 'gnus-article-mode)
3641 (make-local-variable 'minor-mode-alist)
3642 (unless (assq 'gnus-show-mime minor-mode-alist)
3643 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3644 (use-local-map gnus-article-mode-map)
3645 (when (gnus-visual-p 'article-menu 'menu)
3646 (gnus-article-make-menu-bar)
3647 (when gnus-summary-tool-bar-map
3648 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3649 (gnus-update-format-specifications nil 'article-mode)
3650 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3651 (make-local-variable 'gnus-page-broken)
3652 (make-local-variable 'gnus-button-marker-list)
3653 (make-local-variable 'gnus-article-current-summary)
3654 (make-local-variable 'gnus-article-mime-handles)
3655 (make-local-variable 'gnus-article-decoded-p)
3656 (make-local-variable 'gnus-article-mime-handle-alist)
3657 (make-local-variable 'gnus-article-wash-types)
3658 (make-local-variable 'gnus-article-image-alist)
3659 (make-local-variable 'gnus-article-charset)
3660 (make-local-variable 'gnus-article-ignored-charsets)
3661 (gnus-set-default-directory)
3662 (buffer-disable-undo)
3663 (setq buffer-read-only t)
3664 (set-syntax-table gnus-article-mode-syntax-table)
3665 (gnus-run-hooks 'gnus-article-mode-hook))
3667 (defun gnus-article-setup-buffer ()
3668 "Initialize the article buffer."
3669 (let* ((name (if gnus-single-article-buffer "*Article*"
3670 (concat "*Article " gnus-newsgroup-name "*")))
3672 (progn (string-match "\\*Article" name)
3673 (concat " *Original Article"
3674 (substring name (match-end 0))))))
3675 (setq gnus-article-buffer name)
3676 (setq gnus-original-article-buffer original)
3677 (setq gnus-article-mime-handle-alist nil)
3678 ;; This might be a variable local to the summary buffer.
3679 (unless gnus-single-article-buffer
3681 (set-buffer gnus-summary-buffer)
3682 (setq gnus-article-buffer name)
3683 (setq gnus-original-article-buffer original)
3684 (gnus-set-global-variables)))
3685 (gnus-article-setup-highlight-words)
3686 ;; Init original article buffer.
3688 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3689 (set-buffer-multibyte t)
3690 (setq major-mode 'gnus-original-article-mode)
3691 (make-local-variable 'gnus-original-article))
3692 (if (get-buffer name)
3695 (when (and gnus-article-edit-mode
3698 (y-or-n-p "Article mode edit in progress; discard? ")))
3699 (error "Action aborted"))
3700 (set (make-local-variable 'gnus-article-edit-mode) nil)
3701 (buffer-disable-undo)
3702 (setq buffer-read-only t)
3703 ;; This list just keeps growing if we don't reset it.
3704 (setq gnus-button-marker-list nil)
3705 (unless (eq major-mode 'gnus-article-mode)
3706 (gnus-article-mode))
3709 (set-buffer (gnus-get-buffer-create name))
3711 (make-local-variable 'gnus-summary-buffer)
3712 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3713 (current-buffer)))))
3715 ;; Set article window start at LINE, where LINE is the number of lines
3716 ;; from the head of the article.
3717 (defun gnus-article-set-window-start (&optional line)
3719 (gnus-get-buffer-window gnus-article-buffer t)
3721 (set-buffer gnus-article-buffer)
3722 (goto-char (point-min))
3725 (gnus-message 6 "Moved to bookmark")
3726 (search-forward "\n\n" nil t)
3730 ;;; @@ article filters
3733 (defun gnus-article-display-mime-message ()
3734 "Article display method for MIME message."
3735 ;; called from `gnus-original-article-buffer'.
3736 (let (charset all-headers)
3737 (with-current-buffer gnus-summary-buffer
3738 (setq charset default-mime-charset
3739 all-headers gnus-have-all-headers))
3740 (make-local-variable 'default-mime-charset)
3741 (setq default-mime-charset charset)
3742 (with-current-buffer (get-buffer-create gnus-article-buffer)
3743 (make-local-variable 'default-mime-charset)
3744 (setq default-mime-charset charset))
3745 (mime-display-message mime-message-structure
3746 gnus-article-buffer nil gnus-article-mode-map)
3748 (gnus-article-hide-headers nil -1)))
3749 (run-hooks 'gnus-mime-article-prepare-hook))
3751 (defun gnus-article-display-traditional-message ()
3752 "Article display method for traditional message."
3753 (set-buffer gnus-article-buffer)
3754 (let (buffer-read-only)
3756 (insert-buffer-substring gnus-original-article-buffer)))
3758 (defun gnus-article-make-full-mail-header (&optional number charset)
3759 "Create a new mail header structure in a raw article buffer."
3760 (unless (and number charset)
3761 (save-current-buffer
3762 (set-buffer gnus-summary-buffer)
3764 (setq number (or (cdr gnus-article-current) 0)))
3766 (setq charset (or default-mime-charset 'x-ctext)))))
3767 (goto-char (point-min))
3768 (let ((header-end (if (search-forward "\n\n" nil t)
3770 (goto-char (point-max))))
3771 (chars (- (point-max) (point)))
3772 (lines (count-lines (point) (point-max)))
3773 (default-mime-charset charset)
3775 (narrow-to-region (point-min) header-end)
3776 (setq xref (std11-fetch-field "xref"))
3778 (make-full-mail-header
3780 (std11-fetch-field "subject")
3781 (std11-fetch-field "from")
3782 (std11-fetch-field "date")
3783 (std11-fetch-field "message-id")
3784 (std11-fetch-field "references")
3787 (when xref (concat "Xref: " xref)))
3790 (defun gnus-article-prepare (article &optional all-headers header)
3791 "Prepare ARTICLE in article mode buffer.
3792 ARTICLE should either be an article number or a Message-ID.
3793 If ARTICLE is an id, HEADER should be the article headers.
3794 If ALL-HEADERS is non-nil, no headers are hidden."
3796 ;; Make sure we start in a summary buffer.
3797 (unless (eq major-mode 'gnus-summary-mode)
3798 (set-buffer gnus-summary-buffer))
3799 (setq gnus-summary-buffer (current-buffer))
3800 (let* ((gnus-article (if header (mail-header-number header) article))
3801 (summary-buffer (current-buffer))
3802 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3803 (group gnus-newsgroup-name)
3806 (gnus-article-setup-buffer)
3807 (set-buffer gnus-article-buffer)
3808 ;; Deactivate active regions.
3809 (when (and (boundp 'transient-mark-mode)
3810 transient-mark-mode)
3811 (setq mark-active nil))
3812 (if (not (setq result (let ((buffer-read-only nil))
3813 (gnus-request-article-this-buffer
3815 ;; There is no such article.
3817 (when (and (numberp article)
3818 (not (memq article gnus-newsgroup-sparse)))
3819 (setq gnus-article-current
3820 (cons gnus-newsgroup-name article))
3821 (set-buffer gnus-summary-buffer)
3822 (setq gnus-current-article article)
3823 (if (and (memq article gnus-newsgroup-undownloaded)
3824 (not (gnus-online (gnus-find-method-for-group
3825 gnus-newsgroup-name))))
3827 (gnus-summary-set-agent-mark article)
3828 (message "Message marked for downloading"))
3829 (gnus-summary-mark-article article gnus-canceled-mark)
3830 (unless (memq article gnus-newsgroup-sparse)
3831 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3832 (if (or (eq result 'pseudo)
3833 (eq result 'nneething))
3836 (set-buffer summary-buffer)
3837 (push article gnus-newsgroup-history)
3838 (setq gnus-last-article gnus-current-article
3839 gnus-current-article 0
3840 gnus-current-headers nil
3841 gnus-article-current nil)
3842 (if (eq result 'nneething)
3843 (gnus-configure-windows 'summary)
3844 (gnus-configure-windows 'article))
3845 (gnus-set-global-variables))
3846 (let ((gnus-article-mime-handle-alist-1
3847 gnus-article-mime-handle-alist))
3848 (gnus-set-mode-line 'article)))
3849 ;; The result from the `request' was an actual article -
3850 ;; or at least some text that is now displayed in the
3852 (when (and (numberp article)
3853 (not (eq article gnus-current-article)))
3854 ;; Seems like a new article has been selected.
3855 ;; `gnus-current-article' must be an article number.
3857 (set-buffer summary-buffer)
3858 (push article gnus-newsgroup-history)
3859 (setq gnus-last-article gnus-current-article
3860 gnus-current-article article
3861 gnus-current-headers
3862 (gnus-summary-article-header gnus-current-article)
3863 gnus-article-current
3864 (cons gnus-newsgroup-name gnus-current-article))
3865 (unless (vectorp gnus-current-headers)
3866 (setq gnus-current-headers nil))
3867 (gnus-summary-goto-subject gnus-current-article)
3868 (when (gnus-summary-show-thread)
3869 ;; If the summary buffer really was folded, the
3870 ;; previous goto may not actually have gone to
3871 ;; the right article, but the thread root instead.
3873 (gnus-summary-goto-subject gnus-current-article))
3874 (gnus-run-hooks 'gnus-mark-article-hook)
3875 (gnus-set-mode-line 'summary)
3876 (when (gnus-visual-p 'article-highlight 'highlight)
3877 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3878 ;; Set the global newsgroup variables here.
3879 (gnus-set-global-variables)
3880 (setq gnus-have-all-headers
3881 (or all-headers gnus-show-all-headers))))
3883 (gnus-configure-windows 'article))
3884 (when (or (numberp article)
3886 (gnus-article-prepare-display)
3888 (goto-char (point-min))
3889 (setq gnus-page-broken
3890 (when gnus-break-pages
3891 (gnus-narrow-to-page)
3893 (let ((gnus-article-mime-handle-alist-1
3894 gnus-article-mime-handle-alist))
3895 (gnus-set-mode-line 'article))
3899 (set-window-point (get-buffer-window (current-buffer)) (point))
3900 (gnus-configure-windows 'article)
3903 (defun gnus-article-prepare-mime-display (&optional number)
3904 (goto-char (point-min))
3905 (when (re-search-forward "^[^\t ]+:" nil t)
3906 (goto-char (match-beginning 0)))
3907 (let ((entity (if (eq 1 (point-min))
3908 (get-text-property 1 'mime-view-entity)
3909 (get-text-property (point) 'mime-view-entity)))
3910 last-entity child-entity next type)
3911 (setq child-entity (mime-entity-children entity))
3913 (setq last-entity (nth (1- (length child-entity))
3915 (setq last-entity entity))
3917 (narrow-to-region (point)
3918 (if (search-forward "\n\n" nil t)
3921 (gnus-treat-article 'head)
3922 (put-text-property (point-min) (point-max) 'article-treated-header t)
3923 (goto-char (point-max)))
3924 (while (and (not (eobp)) entity)
3925 (setq next (set-marker
3927 (next-single-property-change (point) 'mime-view-entity
3929 (let ((types (mime-entity-content-type entity)))
3930 (while (eq 'multipart (mime-content-type-primary-type types))
3931 (setq entity (car (mime-entity-children entity))
3932 types (mime-entity-content-type entity)))
3934 (setq type (format "%s/%s"
3935 (mime-content-type-primary-type types)
3936 (mime-content-type-subtype types)))))
3937 (if (string-equal type "message/rfc822")
3940 (let ((children (mime-entity-children entity))
3943 (setq last-children (nth (1- (length children)) children))
3946 (not (eq last-children
3947 (get-text-property next 'mime-view-entity)))
3949 (next-single-property-change next
3951 nil (point-max)))))))
3952 (setq next (next-single-property-change next 'mime-view-entity
3955 (narrow-to-region (point) next)
3956 (gnus-article-prepare-mime-display)
3957 (goto-char (point-max)))
3958 (setq entity (get-text-property (point) 'mime-view-entity)))
3960 (narrow-to-region (point) next)
3961 ;; Kludge. We have to count true number, but for now,
3962 ;; part number is here only to achieve `last'.
3963 (gnus-treat-article nil 1
3964 (if (eq entity last-entity)
3967 (goto-char (point-max)))
3968 (setq entity (get-text-property next 'mime-view-entity))))))
3971 (defun gnus-article-prepare-display ()
3972 "Make the current buffer look like a nice article."
3973 (let ((gnus-article-buffer (current-buffer))
3975 (unless (eq major-mode 'gnus-article-mode)
3976 (gnus-article-mode))
3977 (setq buffer-read-only nil
3978 gnus-button-marker-list nil
3979 gnus-article-wash-types nil
3980 gnus-article-image-alist nil)
3983 (static-if (featurep 'xemacs)
3984 (map-extents (lambda (extent maparg) (delete-extent extent)))
3985 (let ((lists (overlay-lists)))
3986 (dolist (overlay (nconc (car lists) (cdr lists)))
3987 (delete-overlay overlay)))))
3988 (gnus-run-hooks 'gnus-tmp-internal-hook))
3989 (let ((show-mime (unless (member gnus-newsgroup-name '("nndraft:delayed"
3992 (inhibit-read-only t))
3993 (set-buffer gnus-original-article-buffer)
3995 (setq mime-message-structure gnus-current-headers)
3996 (mime-buffer-entity-set-buffer-internal mime-message-structure
3997 gnus-original-article-buffer)
3998 (mime-entity-set-representation-type-internal mime-message-structure
3999 'mime-buffer-entity)
4000 (luna-send mime-message-structure 'initialize-instance
4001 mime-message-structure)
4003 (let (mime-display-header-hook mime-display-text/plain-hook)
4004 (funcall gnus-article-display-method-for-mime))
4005 (funcall gnus-article-display-method-for-traditional))
4006 ;; Call the treatment functions.
4010 (gnus-article-prepare-mime-display)
4011 (narrow-to-region (goto-char (point-min))
4012 (if (search-forward "\n\n" nil t)
4015 (gnus-treat-article 'head)
4016 (put-text-property (point-min) (point-max) 'article-treated-header t)
4017 (goto-char (point-max))
4019 (narrow-to-region (point) (point-max))
4020 (gnus-treat-article nil))
4021 (put-text-property (point-min) (point-max) 'read-only nil)))
4022 (gnus-run-hooks 'gnus-article-prepare-hook))
4024 (defun gnus-article-decode-article-as-default-mime-charset ()
4025 "Decode an article as `default-mime-charset'. It won't work if the
4026 value of the variable `gnus-show-mime' is non-nil."
4027 (unless (or gnus-show-mime
4028 (member gnus-newsgroup-name '("nndraft:delayed"
4030 (set (make-local-variable 'default-mime-charset)
4031 (with-current-buffer gnus-summary-buffer
4032 default-mime-charset))
4033 (decode-mime-charset-region (point-min) (point-max)
4034 default-mime-charset)))
4037 ;;; Gnus MIME viewing functions
4040 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4041 "Format of the MIME buttons.
4043 Valid specifiers include:
4045 %T MIME type, along with additional info
4046 %n The `name' parameter
4047 %d The description, if any
4048 %l The length of the encoded part
4049 %p The part identifier number
4050 %e Dots if the part isn't displayed
4052 General format specifiers can also be used. See Info node
4053 `(gnus)Formatting Variables'.")
4055 (defvar gnus-mime-button-line-format-alist
4056 '((?t gnus-tmp-type ?s)
4057 (?T gnus-tmp-type-long ?s)
4058 (?n gnus-tmp-name ?s)
4059 (?d gnus-tmp-description ?s)
4061 (?l gnus-tmp-length ?d)
4062 (?e gnus-tmp-dots ?s)))
4064 (defvar gnus-mime-button-commands
4065 '((gnus-article-press-button "\r" "Toggle Display")
4066 (gnus-mime-view-part "v" "View Interactively...")
4067 (gnus-mime-view-part-as-type "t" "View As Type...")
4068 (gnus-mime-view-part-as-charset "C" "View As charset...")
4069 (gnus-mime-save-part "o" "Save...")
4070 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4071 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4072 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4073 (gnus-mime-view-part-internally "E" "View Internally")
4074 (gnus-mime-view-part-externally "e" "View Externally")
4075 (gnus-mime-print-part "p" "Print")
4076 (gnus-mime-pipe-part "|" "Pipe To Command...")
4077 (gnus-mime-action-on-part "." "Take action on the part...")))
4079 (defun gnus-article-mime-part-status ()
4080 (with-current-buffer gnus-article-buffer
4081 (let ((entity (get-text-property (point-min) 'mime-view-entity))
4084 (setq children (mime-entity-children entity))
4085 (setq children (length children)))
4088 (format " (%d parts)" children))
4091 (defvar gnus-mime-button-map
4092 (let ((map (make-sparse-keymap)))
4093 (unless (>= (string-to-number emacs-version) 21)
4094 ;; XEmacs doesn't care.
4095 (set-keymap-parent map gnus-article-mode-map))
4096 (define-key map gnus-mouse-2 'gnus-article-push-button)
4097 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4098 (dolist (c gnus-mime-button-commands)
4099 (define-key map (cadr c) (car c)))
4102 (easy-menu-define gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4104 ,@(mapcar (lambda (c)
4105 (vector (caddr c) (car c) :enable t)) gnus-mime-button-commands)))
4107 (defun gnus-mime-button-menu (event prefix)
4108 "Construct a context-sensitive menu of MIME commands."
4109 (interactive "e\nP")
4110 (save-window-excursion
4111 (let ((pos (event-start event)))
4112 (select-window (posn-window pos))
4113 (goto-char (posn-point pos))
4114 (gnus-article-check-buffer)
4115 (popup-menu gnus-mime-button-menu nil prefix))))
4117 (defun gnus-mime-view-all-parts (&optional handles)
4118 "View all the MIME parts."
4120 (save-current-buffer
4121 (set-buffer gnus-article-buffer)
4122 (let ((handles (or handles gnus-article-mime-handles))
4123 (mail-parse-charset gnus-newsgroup-charset)
4124 (mail-parse-ignored-charsets
4125 (with-current-buffer gnus-summary-buffer
4126 gnus-newsgroup-ignored-charsets)))
4128 (mm-remove-parts handles)
4129 (goto-char (point-min))
4130 (or (search-forward "\n\n") (goto-char (point-max)))
4131 (let (buffer-read-only)
4132 (delete-region (point) (point-max))
4133 (mm-display-parts handles))))))
4135 (defun gnus-mime-save-part-and-strip ()
4136 "Save the MIME part under point then replace it with an external body."
4138 (gnus-article-check-buffer)
4139 (let* ((data (get-text-property (point) 'gnus-data))
4141 (handles gnus-article-mime-handles))
4142 (if (mm-multiple-handles gnus-article-mime-handles)
4143 (error "This function is not implemented"))
4144 (setq file (and data (mm-save-part data)))
4146 (with-current-buffer (mm-handle-buffer data)
4148 (insert "Content-Type: " (mm-handle-media-type data))
4149 (mml-insert-parameter-string (cdr (mm-handle-type data))
4152 (insert "Content-ID: " (message-make-message-id) "\n")
4153 (insert "Content-Transfer-Encoding: binary\n")
4156 (cdr (mm-make-handle nil
4157 `("message/external-body"
4158 (access-type . "LOCAL-FILE")
4160 (set-buffer gnus-summary-buffer)
4161 (gnus-article-edit-article
4164 (let ((mail-parse-charset (or gnus-article-charset
4165 ',gnus-newsgroup-charset))
4166 (mail-parse-ignored-charsets
4167 (or gnus-article-ignored-charsets
4168 ',gnus-newsgroup-ignored-charsets))
4169 (mbl mml-buffer-list))
4170 (setq mml-buffer-list nil)
4171 (insert-buffer gnus-original-article-buffer)
4172 (mime-to-mml ',handles)
4173 (setq gnus-article-mime-handles nil)
4174 (let ((mbl1 mml-buffer-list))
4175 (setq mml-buffer-list mbl)
4176 (set (make-local-variable 'mml-buffer-list) mbl1))
4177 ;; LOCAL argument of add-hook differs between GNU Emacs
4178 ;; and XEmacs. make-local-hook makes sure they are local.
4179 (make-local-hook 'kill-buffer-hook)
4180 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4181 `(lambda (no-highlight)
4182 (let ((mail-parse-charset (or gnus-article-charset
4183 ',gnus-newsgroup-charset))
4184 (message-options message-options)
4185 (message-options-set-recipient)
4186 (mail-parse-ignored-charsets
4187 (or gnus-article-ignored-charsets
4188 ',gnus-newsgroup-ignored-charsets)))
4190 (mml-destroy-buffers)
4191 (remove-hook 'kill-buffer-hook
4192 'mml-destroy-buffers t)
4193 (kill-local-variable 'mml-buffer-list))
4194 (gnus-summary-edit-article-done
4195 ,(or (mail-header-references gnus-current-headers) "")
4196 ,(gnus-group-read-only-p)
4197 ,gnus-summary-buffer no-highlight))))))
4199 (defun gnus-mime-save-part ()
4200 "Save the MIME part under point."
4202 (gnus-article-check-buffer)
4203 (let ((data (get-text-property (point) 'gnus-data)))
4205 (mm-save-part data))))
4207 (defun gnus-mime-pipe-part ()
4208 "Pipe the MIME part under point to a process."
4210 (gnus-article-check-buffer)
4211 (let ((data (get-text-property (point) 'gnus-data)))
4213 (mm-pipe-part data))))
4215 (defun gnus-mime-view-part ()
4216 "Interactively choose a viewing method for the MIME part under point."
4218 (gnus-article-check-buffer)
4219 (let ((data (get-text-property (point) 'gnus-data)))
4221 (setq gnus-article-mime-handles
4223 gnus-article-mime-handles (setq data (copy-sequence data))))
4224 (mm-interactively-view-part data))))
4226 (defun gnus-mime-view-part-as-type-internal ()
4227 (gnus-article-check-buffer)
4228 (let* ((name (mail-content-type-get
4229 (mm-handle-type (get-text-property (point) 'gnus-data))
4231 (def-type (and name (mm-default-file-encoding name))))
4232 (and def-type (cons def-type 0))))
4234 (defun gnus-mime-view-part-as-type (&optional mime-type)
4235 "Choose a MIME media type, and view the part as such."
4238 (setq mime-type (completing-read
4239 "View as MIME type: "
4240 (mapcar #'list (mailcap-mime-types))
4242 (gnus-mime-view-part-as-type-internal))))
4243 (gnus-article-check-buffer)
4244 (let ((handle (get-text-property (point) 'gnus-data)))
4247 (mm-make-handle (mm-handle-buffer handle)
4248 (cons mime-type (cdr (mm-handle-type handle)))
4249 (mm-handle-encoding handle)
4250 (mm-handle-undisplayer handle)
4251 (mm-handle-disposition handle)
4252 (mm-handle-description handle)
4254 (mm-handle-id handle)))
4255 (setq gnus-article-mime-handles
4256 (mm-merge-handles gnus-article-mime-handles handle))
4257 (gnus-mm-display-part handle))))
4260 (require 'jka-compr))
4262 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4263 ;; emacs can do that itself.
4265 (defun gnus-mime-jka-compr-maybe-uncompress ()
4266 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4267 The uncompress method used is derived from `buffer-file-name'."
4268 (when (and (fboundp 'jka-compr-installed-p)
4269 (jka-compr-installed-p))
4270 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4272 (let ((basename (file-name-nondirectory buffer-file-name))
4273 (args (jka-compr-info-uncompress-args info))
4274 (prog (jka-compr-info-uncompress-program info))
4275 (message (jka-compr-info-uncompress-message info))
4276 (err-file (jka-compr-make-temp-name)))
4278 (message "%s %s..." message basename))
4280 (unless (memq (apply 'call-process-region
4281 (point-min) (point-max)
4283 t (list t err-file) nil
4285 jka-compr-acceptable-retval-list)
4286 (jka-compr-error prog args basename message err-file))
4287 (jka-compr-delete-temp-file err-file)))))))
4289 (defun gnus-mime-copy-part (&optional handle)
4290 "Put the MIME part under point into a new buffer.
4291 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4294 (gnus-article-check-buffer)
4295 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4296 (contents (and handle (mm-get-part handle)))
4298 (file-name-nondirectory
4300 (mail-content-type-get (mm-handle-type handle) 'name)
4301 (mail-content-type-get (mm-handle-disposition handle)
4304 (buffer (and base (generate-new-buffer base))))
4306 (switch-to-buffer buffer)
4308 ;; We do it this way to make `normal-mode' set the appropriate mode.
4311 (setq buffer-file-name (expand-file-name base))
4312 (gnus-mime-jka-compr-maybe-uncompress)
4314 (setq buffer-file-name nil))
4315 (goto-char (point-min)))))
4317 (defun gnus-mime-print-part (&optional handle filename)
4318 "Print the MIME part under point."
4319 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4320 (gnus-article-check-buffer)
4321 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4322 (contents (and handle (mm-get-part handle)))
4323 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4324 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4329 (mm-save-part-to-file handle file)
4330 (call-process shell-file-name nil
4331 (generate-new-buffer " *mm*")
4333 shell-command-switch
4335 printer file (mm-handle-type handle))))
4339 (gnus-print-buffer))
4340 (ps-despool filename)))))
4342 (defun gnus-mime-inline-part (&optional handle arg)
4343 "Insert the MIME part under point into the current buffer."
4344 (interactive (list nil current-prefix-arg))
4345 (gnus-article-check-buffer)
4346 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4351 (if (and (not arg) (mm-handle-undisplayer handle))
4352 (mm-remove-part handle)
4353 (setq contents (mm-get-part handle))
4356 (setq charset (or (mail-content-type-get
4357 (mm-handle-type handle) 'charset)
4358 gnus-newsgroup-charset)))
4360 (if (mm-handle-undisplayer handle)
4361 (mm-remove-part handle))
4364 gnus-summary-show-article-charset-alist))
4365 (mm-read-coding-system "Charset: ")))))
4367 (mm-insert-inline handle
4369 (setq charset (mm-charset-to-coding-system
4371 (not (eq charset 'ascii)))
4372 (mm-decode-coding-string contents charset)
4376 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4377 "Insert the MIME part under point into the current buffer using the
4379 (interactive (list nil current-prefix-arg))
4380 (gnus-article-check-buffer)
4381 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4386 (if (mm-handle-undisplayer handle)
4387 (mm-remove-part handle))
4388 (let ((gnus-newsgroup-charset
4390 gnus-summary-show-article-charset-alist))
4391 (mm-read-coding-system "Charset: ")))
4392 (gnus-newsgroup-ignored-charsets 'gnus-all))
4393 (gnus-article-press-button)))))
4395 (defun gnus-mime-view-part-externally (&optional handle)
4396 "View the MIME part under point with an external viewer."
4398 (gnus-article-check-buffer)
4399 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4400 (mm-user-display-methods nil)
4401 (mm-inlined-types nil)
4402 (mail-parse-charset gnus-newsgroup-charset)
4403 (mail-parse-ignored-charsets
4404 (save-excursion (set-buffer gnus-summary-buffer)
4405 gnus-newsgroup-ignored-charsets)))
4407 (if (mm-handle-undisplayer handle)
4408 (mm-remove-part handle)
4409 (mm-display-part handle)))))
4411 (defun gnus-mime-view-part-internally (&optional handle)
4412 "View the MIME part under point with an internal viewer.
4413 If no internal viewer is available, use an external viewer."
4415 (gnus-article-check-buffer)
4416 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4417 (mm-inlined-types '(".*"))
4418 (mm-inline-large-images t)
4419 (mail-parse-charset gnus-newsgroup-charset)
4420 (mail-parse-ignored-charsets
4421 (save-excursion (set-buffer gnus-summary-buffer)
4422 gnus-newsgroup-ignored-charsets))
4425 (if (mm-handle-undisplayer handle)
4426 (mm-remove-part handle)
4427 (mm-display-part handle)))))
4429 (defun gnus-mime-action-on-part (&optional action)
4430 "Do something with the MIME attachment at \(point\)."
4432 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4433 (gnus-article-check-buffer)
4434 (let ((action-pair (assoc action gnus-mime-action-alist)))
4436 (funcall (cdr action-pair)))))
4438 (defun gnus-article-part-wrapper (n function)
4439 (save-current-buffer
4440 (set-buffer gnus-article-buffer)
4441 (when (> n (length gnus-article-mime-handle-alist))
4442 (error "No such part"))
4443 (gnus-article-goto-part n)
4444 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4445 (funcall function handle))))
4447 (defun gnus-article-pipe-part (n)
4448 "Pipe MIME part N, which is the numerical prefix."
4450 (gnus-article-part-wrapper n 'mm-pipe-part))
4452 (defun gnus-article-save-part (n)
4453 "Save MIME part N, which is the numerical prefix."
4455 (gnus-article-part-wrapper n 'mm-save-part))
4457 (defun gnus-article-interactively-view-part (n)
4458 "View MIME part N interactively, which is the numerical prefix."
4460 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4462 (defun gnus-article-copy-part (n)
4463 "Copy MIME part N, which is the numerical prefix."
4465 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4467 (defun gnus-article-view-part-as-charset (n)
4468 "Copy MIME part N, which is the numerical prefix."
4470 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4472 (defun gnus-article-view-part-externally (n)
4473 "View MIME part N externally, which is the numerical prefix."
4475 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4477 (defun gnus-article-inline-part (n)
4478 "Inline MIME part N, which is the numerical prefix."
4480 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4482 (defun gnus-article-mime-match-handle-first (condition)
4484 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4485 (while (setq ihandle (pop alist))
4487 ((functionp condition)
4488 (funcall condition (cdr ihandle)))
4489 ((eq condition 'undisplayed)
4490 (not (or (mm-handle-undisplayer (cdr ihandle))
4491 (equal (mm-handle-media-type (cdr ihandle))
4492 "multipart/alternative"))))
4493 ((eq condition 'undisplayed-alternative)
4494 (not (mm-handle-undisplayer (cdr ihandle))))
4496 (gnus-article-goto-part (car ihandle))
4497 (or (not n) (< (car ihandle) n)))
4498 (setq n (car ihandle))))
4502 (defun gnus-article-view-part (&optional n)
4503 "View MIME part N, which is the numerical prefix."
4505 (save-current-buffer
4506 (set-buffer gnus-article-buffer)
4507 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4508 gnus-article-mime-match-handle-function)))
4509 (when (> n (length gnus-article-mime-handle-alist))
4510 (error "No such part"))
4511 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4512 (when (gnus-article-goto-part n)
4513 (if (equal (car handle) "multipart/alternative")
4514 (gnus-article-press-button)
4515 (when (eq (gnus-mm-display-part handle) 'internal)
4516 (gnus-set-window-start)))))))
4518 (defsubst gnus-article-mime-total-parts ()
4519 (if (bufferp (car gnus-article-mime-handles))
4521 (1- (length gnus-article-mime-handles))))
4523 (defun gnus-mm-display-part (handle)
4524 "Display HANDLE and fix MIME button."
4525 (let ((id (get-text-property (point) 'gnus-part))
4530 (let ((window (selected-window))
4531 (mail-parse-charset gnus-newsgroup-charset)
4532 (mail-parse-ignored-charsets
4533 (if (gnus-buffer-live-p gnus-summary-buffer)
4535 (set-buffer gnus-summary-buffer)
4536 gnus-newsgroup-ignored-charsets)
4540 (let ((win (gnus-get-buffer-window (current-buffer) t))
4543 (select-window win))
4546 (if (mm-handle-displayed-p handle)
4547 ;; This will remove the part.
4548 (mm-display-part handle)
4550 (narrow-to-region (point)
4551 (if (eobp) (point) (1+ (point))))
4552 (mm-display-part handle)
4553 ;; We narrow to the part itself and
4554 ;; then call the treatment functions.
4555 (goto-char (point-min))
4557 (narrow-to-region (point) (point-max))
4560 (gnus-article-mime-total-parts)
4561 (mm-handle-media-type handle)))))
4562 (if (window-live-p window)
4563 (select-window window)))))
4565 (delete-region (gnus-point-at-bol) (progn (forward-line 1) (point)))
4566 (gnus-insert-mime-button
4567 handle id (list (mm-handle-displayed-p handle)))
4568 (goto-char point))))
4570 (defun gnus-article-goto-part (n)
4571 "Go to MIME part N."
4572 (let ((point (text-property-any (point-min) (point-max) 'gnus-part n)))
4574 (goto-char point))))
4576 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4577 (let ((gnus-tmp-name
4578 (or (mail-content-type-get (mm-handle-type handle) 'name)
4579 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4580 (mail-content-type-get (mm-handle-type handle) 'url)
4582 (gnus-tmp-type (mm-handle-media-type handle))
4583 (gnus-tmp-description
4584 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4587 (if (if displayed (car displayed)
4588 (mm-handle-displayed-p handle))
4590 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4592 gnus-tmp-type-long b e)
4593 (when (string-match ".*/" gnus-tmp-name)
4594 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4595 (setq gnus-tmp-type-long (concat gnus-tmp-type
4596 (and (not (equal gnus-tmp-name ""))
4597 (concat "; " gnus-tmp-name))))
4598 (unless (equal gnus-tmp-description "")
4599 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4604 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4605 `(,@(gnus-local-map-property gnus-mime-button-map)
4606 gnus-callback gnus-mm-display-part
4607 gnus-part ,gnus-tmp-id
4608 article-type annotation
4611 (widget-convert-button
4614 :action 'gnus-widget-press-button
4615 :button-keymap gnus-mime-button-map
4617 (lambda (widget/window &optional overlay pos)
4618 ;; Needed to properly clear the message due to a bug in
4619 ;; wid-edit (XEmacs only).
4620 (if (boundp 'help-echo-owns-message)
4621 (setq help-echo-owns-message t))
4623 "%S: %s the MIME part; %S: more options"
4624 (aref gnus-mouse-2 0)
4625 ;; XEmacs will get a single widget arg; Emacs 21 will get
4626 ;; window, overlay, position.
4627 (if (mm-handle-displayed-p
4629 (with-current-buffer (gnus-overlay-buffer overlay)
4630 (widget-get (widget-at (gnus-overlay-start overlay))
4632 (widget-get widget/window :mime-handle)))
4634 (aref gnus-down-mouse-3 0))))))
4636 (defun gnus-widget-press-button (elems el)
4637 (goto-char (widget-get elems :from))
4638 (gnus-article-press-button))
4640 (defvar gnus-displaying-mime nil)
4642 (defun gnus-display-mime (&optional ihandles)
4643 "Display the MIME parts."
4645 (save-selected-window
4646 (let ((window (get-buffer-window gnus-article-buffer))
4649 (select-window window)
4650 ;; We have to do this since selecting the window
4651 ;; may change the point. So we set the window point.
4652 (set-window-point window point)))
4653 (let* ((handles (or ihandles
4654 (mm-dissect-buffer nil gnus-article-loose-mime)
4655 (and gnus-article-emulate-mime
4657 buffer-read-only handle name type b e display)
4658 (when (and (not ihandles)
4659 (not gnus-displaying-mime))
4660 ;; Top-level call; we clean up.
4661 (when gnus-article-mime-handles
4662 (mm-destroy-parts gnus-article-mime-handles)
4663 (setq gnus-article-mime-handle-alist nil));; A trick.
4664 (setq gnus-article-mime-handles handles)
4665 ;; We allow users to glean info from the handles.
4666 (when gnus-article-mime-part-function
4667 (gnus-mime-part-function handles)))
4669 (or (not (stringp (car handles)))
4672 (when (and (not ihandles)
4673 (not gnus-displaying-mime))
4674 ;; Clean up for mime parts.
4676 (delete-region (point) (point-max)))
4677 (let ((gnus-displaying-mime t))
4678 (gnus-mime-display-part handles)))
4681 (narrow-to-region (point) (point-max))
4682 (gnus-treat-article nil 1 1)
4685 ;; Highlight the headers.
4689 (narrow-to-region (point-min) (point))
4690 (gnus-treat-article 'head))))))))
4692 (defvar gnus-mime-display-multipart-as-mixed nil)
4693 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
4694 (defvar gnus-mime-display-multipart-related-as-mixed nil)
4696 (defun gnus-mime-display-part (handle)
4699 ((not (stringp (car handle)))
4700 (gnus-mime-display-single handle))
4701 ;; User-defined multipart
4702 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4703 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4705 ;; multipart/alternative
4706 ((and (equal (car handle) "multipart/alternative")
4707 (not (or gnus-mime-display-multipart-as-mixed
4708 gnus-mime-display-multipart-alternative-as-mixed)))
4709 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4710 (push (cons id handle) gnus-article-mime-handle-alist)
4711 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4712 ;; multipart/related
4713 ((and (equal (car handle) "multipart/related")
4714 (not (or gnus-mime-display-multipart-as-mixed
4715 gnus-mime-display-multipart-related-as-mixed)))
4716 ;;;!!!We should find the start part, but we just default
4717 ;;;!!!to the first part.
4718 ;;(gnus-mime-display-part (cadr handle))
4719 ;;;!!! Most multipart/related is an HTML message plus images.
4720 ;;;!!! Unfortunately we are unable to let W3 display those
4721 ;;;!!! included images, so we just display it as a mixed multipart.
4722 ;;(gnus-mime-display-mixed (cdr handle))
4723 ;;;!!! No, w3 can display everything just fine.
4724 (gnus-mime-display-part (cadr handle)))
4725 ((equal (car handle) "multipart/signed")
4726 (gnus-add-wash-type 'signed)
4727 (gnus-mime-display-security handle))
4728 ((equal (car handle) "multipart/encrypted")
4729 (gnus-add-wash-type 'encrypted)
4730 (gnus-mime-display-security handle))
4731 ;; Other multiparts are handled like multipart/mixed.
4733 (gnus-mime-display-mixed (cdr handle)))))
4735 (defun gnus-mime-part-function (handles)
4736 (if (stringp (car handles))
4737 (mapcar 'gnus-mime-part-function (cdr handles))
4738 (funcall gnus-article-mime-part-function handles)))
4740 (defun gnus-mime-display-mixed (handles)
4741 (mapcar 'gnus-mime-display-part handles))
4743 (defun gnus-mime-display-single (handle)
4744 (let ((type (mm-handle-media-type handle))
4745 (ignored gnus-ignored-mime-types)
4752 (when (string-match (pop ignored) type)
4753 (throw 'ignored nil)))
4754 (if (and (setq not-attachment
4755 (and (not (mm-inline-override-p handle))
4756 (or (not (mm-handle-disposition handle))
4757 (equal (car (mm-handle-disposition handle))
4759 (mm-attachment-override-p handle))))
4760 (mm-automatic-display-p handle)
4762 (mm-inlinable-p handle)
4763 (mm-inlined-p handle))
4764 (mm-automatic-external-display-p type)))
4766 (when (equal (mm-handle-media-supertype handle) "text")
4768 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4770 (push (cons id handle) gnus-article-mime-handle-alist)
4771 (when (or (not display)
4772 (not (gnus-unbuttonized-mime-type-p type)))
4773 ;(gnus-article-insert-newline)
4774 (gnus-insert-mime-button
4775 handle id (list (or display (and not-attachment text))))
4776 (gnus-article-insert-newline)
4777 ;(gnus-article-insert-newline)
4778 ;; Remember modify the number of forward lines.
4786 (let ((mail-parse-charset gnus-newsgroup-charset)
4787 (mail-parse-ignored-charsets
4788 (save-excursion (condition-case ()
4789 (set-buffer gnus-summary-buffer)
4791 gnus-newsgroup-ignored-charsets)))
4792 (mm-display-part handle t))
4793 (goto-char (point-max)))
4794 ((and text not-attachment)
4798 (gnus-article-insert-newline)
4799 (mm-insert-inline handle (mm-get-part handle))
4800 (goto-char (point-max))))
4804 (narrow-to-region beg (point))
4807 (gnus-article-mime-total-parts)
4808 (mm-handle-media-type handle)))))))))
4810 (defun gnus-unbuttonized-mime-type-p (type)
4811 "Say whether TYPE is to be unbuttonized."
4812 (unless gnus-inhibit-mime-unbuttonizing
4814 (let ((types gnus-unbuttonized-mime-types))
4816 (when (string-match (pop types) type)
4817 (throw 'found t)))))
4819 (let ((types gnus-buttonized-mime-types))
4821 (when (string-match (pop types) type)
4822 (throw 'found t)))))))))
4824 (defun gnus-article-insert-newline ()
4825 "Insert a newline, but mark it as undeletable."
4826 (gnus-put-text-property
4827 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4829 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4830 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4833 handle buffer-read-only from props begend not-pref)
4834 (save-window-excursion
4837 (narrow-to-region (car ibegend)
4840 (goto-char (car ibegend))
4843 (delete-region (point-min) (point-max))
4844 (mm-remove-parts handles))
4845 (setq begend (list (point-marker)))
4847 (unless (setq not-pref (cadr (member preferred ihandles)))
4848 (setq not-pref (car ihandles)))
4851 (not (gnus-unbuttonized-mime-type-p
4852 "multipart/alternative")))
4853 (gnus-add-text-properties
4856 (insert (format "%d. " id))
4860 (unless ,(not ibegend)
4861 (setq gnus-article-mime-handle-alist
4862 ',gnus-article-mime-handle-alist))
4863 (gnus-mime-display-alternative
4864 ',ihandles ',not-pref ',begend ,id))
4865 ,@(gnus-local-map-property gnus-mime-button-map)
4866 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4867 face ,gnus-article-button-face
4870 (widget-convert-button 'link from (point)
4871 :action 'gnus-widget-press-button
4872 :button-keymap gnus-widget-button-keymap)
4874 (while (setq handle (pop handles))
4875 (gnus-add-text-properties
4878 (insert (format "(%c) %-18s"
4879 (if (equal handle preferred) ?* ? )
4880 (mm-handle-media-type handle)))
4884 (unless ,(not ibegend)
4885 (setq gnus-article-mime-handle-alist
4886 ',gnus-article-mime-handle-alist))
4887 (gnus-mime-display-alternative
4888 ',ihandles ',handle ',begend ,id))
4889 ,@(gnus-local-map-property gnus-mime-button-map)
4890 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4891 face ,gnus-article-button-face
4894 (widget-convert-button 'link from (point)
4895 :action 'gnus-widget-press-button
4896 :button-keymap gnus-widget-button-keymap)
4900 (if (stringp (car preferred))
4901 (gnus-display-mime preferred)
4902 (let ((mail-parse-charset gnus-newsgroup-charset)
4903 (mail-parse-ignored-charsets
4904 (save-excursion (set-buffer gnus-summary-buffer)
4905 gnus-newsgroup-ignored-charsets)))
4906 (mm-display-part preferred)
4910 (narrow-to-region (car begend) (point-max))
4912 nil (length gnus-article-mime-handle-alist)
4913 (gnus-article-mime-total-parts)
4914 (mm-handle-media-type handle))))))
4915 (goto-char (point-max))
4916 (setcdr begend (point-marker)))))
4918 (goto-char point))))
4920 (defconst gnus-article-wash-status-strings
4921 (let ((alist '((cite "c" "Possible hidden citation text"
4922 " " "All citation text visible")
4923 (headers "h" "Hidden headers"
4924 " " "All headers visible.")
4925 (pgp "p" "Encrypted or signed message status hidden"
4926 " " "No hidden encryption nor digital signature status")
4927 (signature "s" "Signature has been hidden"
4928 " " "Signature is visible")
4929 (overstrike "o" "Overstrike (^H) characters applied"
4930 " " "No overstrike characters applied")
4931 (gnus-show-mime "m" "Mime processing is activated"
4932 " " "Mime processing is not activated")
4933 (emphasis "e" "/*_Emphasis_*/ characters applied"
4934 " " "No /*_emphasis_*/ characters applied")))
4936 (dolist (entry alist result)
4937 (let ((key (nth 0 entry))
4938 (on (copy-sequence (nth 1 entry)))
4939 (on-help (nth 2 entry))
4940 (off (copy-sequence (nth 3 entry)))
4941 (off-help (nth 4 entry)))
4942 (put-text-property 0 1 'help-echo on-help on)
4943 (put-text-property 0 1 'help-echo off-help off)
4944 (push (list key on off) result))))
4945 "Alist of strings describing wash status in the mode line.
4946 Each entry has the form (KEY ON OF), where the KEY is a symbol
4947 representing the particular washing function, ON is the string to use
4948 in the article mode line when the washing function is active, and OFF
4949 is the string to use when it is inactive.")
4951 (defun gnus-article-wash-status-entry (key value)
4952 (let ((entry (assoc key gnus-article-wash-status-strings)))
4953 (if value (nth 1 entry) (nth 2 entry))))
4955 (defun gnus-article-wash-status ()
4956 "Return a string which display status of article washing."
4958 (set-buffer gnus-article-buffer)
4959 (let ((cite (memq 'cite gnus-article-wash-types))
4960 (headers (memq 'headers gnus-article-wash-types))
4961 (boring (memq 'boring-headers gnus-article-wash-types))
4962 (pgp (memq 'pgp gnus-article-wash-types))
4963 (pem (memq 'pem gnus-article-wash-types))
4964 (signed (memq 'signed gnus-article-wash-types))
4965 (encrypted (memq 'encrypted gnus-article-wash-types))
4966 (signature (memq 'signature gnus-article-wash-types))
4967 (overstrike (memq 'overstrike gnus-article-wash-types))
4968 (emphasis (memq 'emphasis gnus-article-wash-types)))
4970 (gnus-article-wash-status-entry 'cite cite)
4971 (gnus-article-wash-status-entry 'headers (or headers boring))
4972 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
4973 (gnus-article-wash-status-entry 'signature signature)
4974 (gnus-article-wash-status-entry 'overstrike overstrike)
4975 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
4976 (gnus-article-wash-status-entry 'emphasis emphasis)))))
4978 (defun gnus-add-wash-type (type)
4979 "Add a washing of TYPE to the current status."
4980 (add-to-list 'gnus-article-wash-types type))
4982 (defun gnus-delete-wash-type (type)
4983 "Add a washing of TYPE to the current status."
4984 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
4986 (defun gnus-add-image (category image)
4987 "Add IMAGE of CATEGORY to the list of displayed images."
4988 (let ((entry (assq category gnus-article-image-alist)))
4990 (setq entry (list category))
4991 (push entry gnus-article-image-alist))
4992 (nconc entry (list image))))
4994 (defun gnus-delete-images (category)
4995 "Delete all images in CATEGORY."
4996 (let ((entry (assq category gnus-article-image-alist)))
4997 (dolist (image (cdr entry))
4998 (gnus-remove-image image))
4999 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5000 (gnus-delete-wash-type category)))
5002 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5004 (defun gnus-article-maybe-hide-headers ()
5005 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5006 Provided for backwards compatibility."
5007 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5008 (not (save-excursion (set-buffer gnus-summary-buffer)
5009 gnus-have-all-headers)))
5010 (not gnus-inhibit-hiding))
5011 (gnus-article-hide-headers)))
5015 (defun gnus-output-to-file (file-name)
5016 "Append the current article to a file named FILE-NAME."
5017 (let ((artbuf (current-buffer)))
5019 (insert-buffer-substring artbuf)
5020 ;; Append newline at end of the buffer as separator, and then
5022 (goto-char (point-max))
5024 (let ((file-name-coding-system nnmail-pathname-coding-system)
5025 (pathname-coding-system nnmail-pathname-coding-system))
5026 (write-region-as-binary (point-min) (point-max) file-name 'append))
5029 (defun gnus-narrow-to-page (&optional arg)
5030 "Narrow the article buffer to a page.
5031 If given a numerical ARG, move forward ARG pages."
5033 (setq arg (if arg (prefix-numeric-value arg) 0))
5035 (set-buffer gnus-article-buffer)
5036 (goto-char (point-min))
5038 ;; Remove any old next/prev buttons.
5039 (when (gnus-visual-p 'page-marker)
5040 (let ((buffer-read-only nil))
5041 (gnus-remove-text-with-property 'gnus-prev)
5042 (gnus-remove-text-with-property 'gnus-next)))
5045 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5047 (re-search-forward page-delimiter nil 'move arg)))
5048 (goto-char (match-end 0)))
5051 (if (re-search-forward page-delimiter nil 'move)
5054 (when (and (gnus-visual-p 'page-marker)
5055 (not (= (point-min) 1)))
5057 (goto-char (point-min))
5058 (gnus-insert-prev-page-button)))
5059 (when (and (gnus-visual-p 'page-marker)
5060 (< (+ (point-max) 2) (buffer-size)))
5062 (goto-char (point-max))
5063 (gnus-insert-next-page-button)))))
5065 ;; Article mode commands
5067 (defun gnus-article-goto-next-page ()
5068 "Show the next page of the article."
5070 (gnus-eval-in-buffer-window gnus-summary-buffer
5071 (gnus-summary-next-page)))
5073 (defun gnus-article-goto-prev-page ()
5074 "Show the next page of the article."
5076 (gnus-eval-in-buffer-window gnus-summary-buffer
5077 (gnus-summary-prev-page)))
5079 (defun gnus-article-next-page (&optional lines)
5080 "Show the next page of the current article.
5081 If end of article, return non-nil. Otherwise return nil.
5082 Argument LINES specifies lines to be scrolled up."
5084 (let ((start (window-start))
5085 end-of-buffer end-of-page)
5087 (move-to-window-line -1)
5088 (if (<= (point) start)
5091 (setq start (point)))
5094 (unless (or (cond ((eq (1+ (buffer-size)) (point))
5095 (and (pos-visible-in-window-p)
5096 (setq end-of-buffer t)))
5098 (setq end-of-page t)))
5100 (move-to-window-line lines)
5101 (unless (search-backward "\n\n" nil t)
5102 (setq start (point)))))
5103 (cond (end-of-buffer t)
5105 (gnus-narrow-to-page 1)
5109 (set-window-start (selected-window) start)
5110 (let (window-pixel-scroll-increment)
5114 (defun gnus-article-prev-page (&optional lines)
5115 "Show previous page of current article.
5116 Argument LINES specifies lines to be scrolled down."
5118 (let (beginning-of-buffer beginning-of-page)
5120 (move-to-window-line 0)
5121 (cond ((eq 1 (point))
5122 (setq beginning-of-buffer t))
5124 (setq beginning-of-page t))))
5125 (cond (beginning-of-buffer)
5127 (gnus-narrow-to-page -1))
5130 (let (window-pixel-scroll-increment)
5131 (scroll-down lines))
5132 (beginning-of-buffer
5133 (goto-char (point-min))))))))
5135 (defun gnus-article-only-boring-p ()
5136 "Decide whether there is only boring text remaining in the article.
5137 Something \"interesting\" is a word of at least two letters that does
5138 not have a face in `gnus-article-boring-faces'."
5139 (when (and gnus-article-skip-boring
5140 (boundp 'gnus-article-boring-faces)
5141 (symbol-value 'gnus-article-boring-faces))
5144 (while (re-search-forward "\\b\\w\\w" nil t)
5146 (when (not (gnus-intersection
5147 (gnus-faces-at (point))
5148 (symbol-value 'gnus-article-boring-faces)))
5149 (throw 'only-boring nil)))
5150 (throw 'only-boring t)))))
5152 (defun gnus-article-refer-article ()
5153 "Read article specified by message-id around point."
5156 (re-search-backward "<?news:\\|<" (point-at-bol) t)
5157 (cond ((re-search-forward
5158 gnus-button-mid-or-mail-regexp (point-at-eol) t)
5159 (let ((msg-id (concat "<" (match-string 0) ">")))
5160 (set-buffer gnus-summary-buffer)
5161 (gnus-summary-refer-article msg-id)))
5163 (error "No references around point")))))
5165 (defun gnus-article-show-summary ()
5166 "Reconfigure windows to show summary buffer."
5168 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5169 (error "There is no summary buffer for this article buffer")
5170 (gnus-article-set-globals)
5171 (gnus-configure-windows 'article)
5172 (gnus-summary-goto-subject gnus-current-article)
5173 (gnus-summary-position-point)))
5175 (defun gnus-article-describe-briefly ()
5176 "Describe article mode commands briefly."
5178 (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")))
5180 (defun gnus-article-summary-command ()
5181 "Execute the last keystroke in the summary buffer."
5183 (let ((obuf (current-buffer))
5184 (owin (current-window-configuration))
5186 (switch-to-buffer gnus-article-current-summary 'norecord)
5187 (setq func (lookup-key (current-local-map) (this-command-keys)))
5188 (call-interactively func)
5190 (set-window-configuration owin)
5191 (set-window-point (get-buffer-window (current-buffer)) (point))))
5193 (defun gnus-article-summary-command-nosave ()
5194 "Execute the last keystroke in the summary buffer."
5197 (pop-to-buffer gnus-article-current-summary 'norecord)
5198 (setq func (lookup-key (current-local-map) (this-command-keys)))
5199 (call-interactively func)))
5201 (defun gnus-article-check-buffer ()
5202 "Beep if not in an article buffer."
5203 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5204 (error "Command invoked outside of a Gnus article buffer")))
5206 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5207 "Read a summary buffer key sequence and execute it from the article buffer."
5209 (gnus-article-check-buffer)
5211 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5212 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5213 "=" "^" "\M-^" "|"))
5219 '("n" "Gn" "p" "Gp"))
5222 (set-buffer gnus-article-current-summary)
5223 (let (gnus-pick-mode)
5224 (push (or key last-command-event) unread-command-events)
5225 (setq keys (static-if (featurep 'xemacs)
5226 (events-to-keys (read-key-sequence nil))
5227 (read-key-sequence nil)))))
5230 (if (or (member keys nosaves)
5231 (member keys nosave-but-article)
5232 (member keys nosave-in-article))
5234 (save-window-excursion
5235 (pop-to-buffer gnus-article-current-summary 'norecord)
5236 ;; We disable the pick minor mode commands.
5237 (let (gnus-pick-mode)
5238 (setq func (lookup-key (current-local-map) keys))))
5242 (unless (member keys nosave-in-article)
5243 (set-buffer gnus-article-current-summary))
5244 (call-interactively func)
5245 (setq new-sum-point (point)))
5246 (when (member keys nosave-but-article)
5247 (pop-to-buffer gnus-article-buffer 'norecord)))
5248 ;; These commands should restore window configuration.
5249 (let ((obuf (current-buffer))
5250 (owin (current-window-configuration))
5252 (summary gnus-article-current-summary)
5253 func in-buffer selected)
5254 (if not-restore-window
5255 (pop-to-buffer summary 'norecord)
5256 (switch-to-buffer summary 'norecord))
5257 (setq in-buffer (current-buffer))
5258 ;; We disable the pick minor mode commands.
5259 (if (and (setq func (let (gnus-pick-mode)
5260 (lookup-key (current-local-map) keys)))
5263 (call-interactively func)
5264 (setq new-sum-point (point))
5265 (when (eq in-buffer (current-buffer))
5266 (setq selected (gnus-summary-select-article))
5268 (unless not-restore-window
5269 (set-window-configuration owin))
5270 (when (eq selected 'old)
5272 (set-window-start (get-buffer-window (current-buffer))
5274 (set-window-point (get-buffer-window (current-buffer))
5276 (let ((win (get-buffer-window gnus-article-current-summary)))
5278 (set-window-point win new-sum-point)))) )
5279 (switch-to-buffer gnus-article-buffer)
5282 (defun gnus-article-describe-key (key)
5283 "Display documentation of the function invoked by KEY. KEY is a string."
5284 (interactive "kDescribe key: ")
5285 (gnus-article-check-buffer)
5286 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5288 (set-buffer gnus-article-current-summary)
5289 (let (gnus-pick-mode)
5290 (if (featurep 'xemacs)
5292 (push (elt key 0) unread-command-events)
5293 (setq key (events-to-keys
5294 (read-key-sequence "Describe key: "))))
5295 (setq unread-command-events
5297 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5299 (setq key (read-key-sequence "Describe key: "))))
5301 (describe-key key)))
5303 (defun gnus-article-describe-key-briefly (key &optional insert)
5304 "Display documentation of the function invoked by KEY. KEY is a string."
5305 (interactive "kDescribe key: \nP")
5306 (gnus-article-check-buffer)
5307 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5309 (set-buffer gnus-article-current-summary)
5310 (let (gnus-pick-mode)
5311 (if (featurep 'xemacs)
5313 (push (elt key 0) unread-command-events)
5314 (setq key (events-to-keys
5315 (read-key-sequence "Describe key: "))))
5316 (setq unread-command-events
5318 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5320 (setq key (read-key-sequence "Describe key: "))))
5321 (describe-key-briefly key insert))
5322 (describe-key-briefly key insert)))
5324 (defun gnus-article-reply-with-original (&optional wide)
5325 "Start composing a reply mail to the current message.
5326 The text in the region will be yanked. If the region isn't active,
5327 the entire article will be yanked."
5329 (let ((article (cdr gnus-article-current))
5331 (if (not (gnus-mark-active-p))
5332 (with-current-buffer gnus-summary-buffer
5333 (gnus-summary-reply (list (list article)) wide))
5334 (setq contents (buffer-substring (point) (mark t)))
5335 ;; Deactivate active regions.
5336 (when (and (boundp 'transient-mark-mode)
5337 transient-mark-mode)
5338 (setq mark-active nil))
5339 (with-current-buffer gnus-summary-buffer
5341 (list (list article contents)) wide)))))
5343 (defun gnus-article-followup-with-original ()
5344 "Compose a followup to the current article.
5345 The text in the region will be yanked. If the region isn't active,
5346 the entire article will be yanked."
5348 (let ((article (cdr gnus-article-current))
5350 (if (not (gnus-mark-active-p))
5351 (with-current-buffer gnus-summary-buffer
5352 (gnus-summary-followup (list (list article))))
5353 (setq contents (buffer-substring (point) (mark t)))
5354 ;; Deactivate active regions.
5355 (when (and (boundp 'transient-mark-mode)
5356 transient-mark-mode)
5357 (setq mark-active nil))
5358 (with-current-buffer gnus-summary-buffer
5359 (gnus-summary-followup
5360 (list (list article contents)))))))
5362 (defun gnus-article-hide (&optional arg force)
5363 "Hide all the gruft in the current article.
5364 This means that signatures, cited text and (some) headers will be
5366 If given a prefix, show the hidden text instead."
5367 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5368 (gnus-article-hide-headers arg)
5369 (gnus-article-hide-list-identifiers arg)
5370 (gnus-article-hide-citation-maybe arg force)
5371 (gnus-article-hide-signature arg))
5373 (defun gnus-article-maybe-highlight ()
5374 "Do some article highlighting if article highlighting is requested."
5375 (when (gnus-visual-p 'article-highlight 'highlight)
5376 (gnus-article-highlight-some)))
5378 (defun gnus-check-group-server ()
5379 ;; Make sure the connection to the server is alive.
5380 (unless (gnus-server-opened
5381 (gnus-find-method-for-group gnus-newsgroup-name))
5382 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5383 (gnus-request-group gnus-newsgroup-name t)))
5386 (autoload 'nneething-get-file-name "nneething"))
5388 (defun gnus-request-article-this-buffer (article group)
5389 "Get an article and insert it into this buffer."
5390 (let (do-update-line sparse-header)
5394 (gnus-kill-all-overlays)
5395 (setq group (or group gnus-newsgroup-name))
5397 ;; Using `gnus-request-article' directly will insert the article into
5398 ;; `nntp-server-buffer' - so we'll save some time by not having to
5399 ;; copy it from the server buffer into the article buffer.
5401 ;; We only request an article by message-id when we do not have the
5402 ;; headers for it, so we'll have to get those.
5403 (when (stringp article)
5404 (gnus-read-header article))
5406 ;; If the article number is negative, that means that this article
5407 ;; doesn't belong in this newsgroup (possibly), so we find its
5408 ;; message-id and request it by id instead of number.
5409 (when (and (numberp article)
5411 (get-buffer gnus-summary-buffer)
5412 (gnus-buffer-exists-p gnus-summary-buffer))
5414 (set-buffer gnus-summary-buffer)
5415 (let ((header (gnus-summary-article-header article)))
5418 ((memq article gnus-newsgroup-sparse)
5419 ;; This is a sparse gap article.
5420 (setq do-update-line article)
5421 (setq article (mail-header-id header))
5422 (setq sparse-header (gnus-read-header article))
5423 (setq gnus-newsgroup-sparse
5424 (delq article gnus-newsgroup-sparse)))
5426 ;; It's a real article.
5427 (setq article (mail-header-id header)))
5429 ;; It is an extracted pseudo-article.
5430 (setq article 'pseudo)
5431 (gnus-request-pseudo-article header))))
5433 (let ((method (gnus-find-method-for-group
5434 gnus-newsgroup-name)))
5435 (when (and (eq (car method) 'nneething)
5437 (let ((dir (nneething-get-file-name
5438 (mail-header-id header))))
5439 (when (and (stringp dir)
5440 (file-directory-p dir))
5441 (setq article 'nneething)
5442 (gnus-group-enter-directory dir))))))))
5445 ;; Refuse to select canceled articles.
5446 ((and (numberp article)
5448 (get-buffer gnus-summary-buffer)
5449 (gnus-buffer-exists-p gnus-summary-buffer)
5450 (eq (cdr (save-excursion
5451 (set-buffer gnus-summary-buffer)
5452 (assq article gnus-newsgroup-reads)))
5453 gnus-canceled-mark))
5455 ;; We first check `gnus-original-article-buffer'.
5456 ((and (get-buffer gnus-original-article-buffer)
5459 (set-buffer gnus-original-article-buffer)
5460 (and (equal (car gnus-original-article) group)
5461 (eq (cdr gnus-original-article) article))))
5462 (insert-buffer-substring gnus-original-article-buffer)
5464 ;; Check the backlog.
5465 ((and gnus-keep-backlog
5466 (gnus-backlog-request-article group article (current-buffer)))
5468 ;; Check asynchronous pre-fetch.
5469 ((gnus-async-request-fetched-article group article (current-buffer))
5470 (gnus-async-prefetch-next group article gnus-summary-buffer)
5471 (when (and (numberp article) gnus-keep-backlog)
5472 (gnus-backlog-enter-article group article (current-buffer)))
5475 ((and gnus-use-cache
5477 (gnus-cache-request-article article group))
5479 ;; Check the agent cache.
5480 ((and gnus-agent gnus-agent-cache gnus-plugged
5482 (gnus-agent-request-article article group))
5484 ;; Get the article and put into the article buffer.
5485 ((or (stringp article)
5487 (let ((gnus-override-method gnus-override-method)
5488 (methods (and (stringp article)
5489 gnus-refer-article-method))
5490 (backend (car (gnus-find-method-for-group
5491 gnus-newsgroup-name)))
5493 (buffer-read-only nil))
5494 (if (or (not (listp methods))
5495 (and (symbolp (car methods))
5496 (assq (car methods) nnoo-definition-alist)))
5497 (setq methods (list methods)))
5498 (when (and (null gnus-override-method)
5500 (setq gnus-override-method (pop methods)))
5502 (when (eq gnus-override-method 'current)
5503 (setq gnus-override-method
5504 (with-current-buffer gnus-summary-buffer
5505 gnus-current-select-method)))
5507 (gnus-kill-all-overlays)
5508 (let ((gnus-newsgroup-name group))
5509 (gnus-check-group-server))
5511 ((gnus-request-article article group (current-buffer))
5512 (when (numberp article)
5513 (gnus-async-prefetch-next group article
5514 gnus-summary-buffer)
5515 (when gnus-keep-backlog
5516 (gnus-backlog-enter-article
5517 group article (current-buffer))))
5518 (setq result 'article))
5520 (setq gnus-override-method (pop methods)))
5521 ((not (string-match "^400 "
5522 (nnheader-get-report backend)))
5523 ;; If we get 400 server disconnect, reconnect and
5524 ;; retry; otherwise, assume the article has expired.
5525 (setq result 'done))))
5526 (and (eq result 'article) 'article)))
5530 ;; Associate this article with the current summary buffer.
5531 (setq gnus-article-current-summary gnus-summary-buffer)
5533 ;; Take the article from the original article buffer
5534 ;; and place it in the buffer it's supposed to be in.
5535 (when (and (get-buffer gnus-article-buffer)
5536 (equal (buffer-name (current-buffer))
5537 (buffer-name (get-buffer gnus-article-buffer))))
5539 (if (get-buffer gnus-original-article-buffer)
5540 (set-buffer gnus-original-article-buffer)
5541 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5542 (buffer-disable-undo)
5543 (setq major-mode 'gnus-original-article-mode)
5544 (setq buffer-read-only t))
5545 (let (buffer-read-only)
5547 (insert-buffer-substring gnus-article-buffer))
5548 (setq gnus-original-article (cons group article)))
5551 (run-hooks 'gnus-article-decode-hook)
5552 ;; Mark article as decoded or not.
5553 (setq gnus-article-decoded-p gnus-article-decode-hook))
5555 ;; Update sparse articles.
5556 (when (and do-update-line
5557 (or (numberp article)
5559 (let ((buf (current-buffer)))
5560 (set-buffer gnus-summary-buffer)
5561 (gnus-summary-update-article do-update-line sparse-header)
5562 (gnus-summary-goto-subject do-update-line nil t)
5563 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5565 (set-buffer buf))))))
5571 (defcustom gnus-article-edit-mode-hook nil
5572 "Hook run in article edit mode buffers."
5573 :group 'gnus-article-various
5576 (defcustom gnus-article-edit-article-setup-function
5577 'gnus-article-mime-edit-article-setup
5578 "Function called to setup an editing article buffer."
5579 :group 'gnus-article-various
5582 (defvar gnus-article-edit-done-function nil)
5584 (defvar gnus-article-edit-mode-map nil)
5585 (defvar gnus-article-edit-mode nil)
5587 ;; Should we be using derived.el for this?
5588 (unless gnus-article-edit-mode-map
5589 (setq gnus-article-edit-mode-map (make-keymap))
5590 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5592 (gnus-define-keys gnus-article-edit-mode-map
5593 "\C-c?" describe-mode
5594 "\C-c\C-c" gnus-article-edit-done
5595 "\C-c\C-k" gnus-article-edit-exit
5596 "\C-c\C-f\C-t" message-goto-to
5597 "\C-c\C-f\C-o" message-goto-from
5598 "\C-c\C-f\C-b" message-goto-bcc
5599 ;;"\C-c\C-f\C-w" message-goto-fcc
5600 "\C-c\C-f\C-c" message-goto-cc
5601 "\C-c\C-f\C-s" message-goto-subject
5602 "\C-c\C-f\C-r" message-goto-reply-to
5603 "\C-c\C-f\C-n" message-goto-newsgroups
5604 "\C-c\C-f\C-d" message-goto-distribution
5605 "\C-c\C-f\C-f" message-goto-followup-to
5606 "\C-c\C-f\C-m" message-goto-mail-followup-to
5607 "\C-c\C-f\C-k" message-goto-keywords
5608 "\C-c\C-f\C-u" message-goto-summary
5609 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5610 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5611 "\C-c\C-b" message-goto-body
5612 "\C-c\C-i" message-goto-signature
5614 "\C-c\C-t" message-insert-to
5615 "\C-c\C-n" message-insert-newsgroups
5616 "\C-c\C-o" message-sort-headers
5617 "\C-c\C-e" message-elide-region
5618 "\C-c\C-v" message-delete-not-region
5619 "\C-c\C-z" message-kill-to-signature
5620 "\M-\r" message-newline-and-reformat
5621 "\C-c\C-a" mml-attach-file
5622 "\C-a" message-beginning-of-line
5624 "\M-;" comment-region)
5626 (gnus-define-keys (gnus-article-edit-wash-map
5627 "\C-c\C-w" gnus-article-edit-mode-map)
5628 "f" gnus-article-edit-full-stops))
5631 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5633 ["Fetch To" message-insert-to t]
5634 ["Fetch Newsgroups" message-insert-newsgroups t]
5636 ["To" message-goto-to t]
5637 ["From" message-goto-from t]
5638 ["Subject" message-goto-subject t]
5639 ["Cc" message-goto-cc t]
5640 ["Reply-To" message-goto-reply-to t]
5641 ["Summary" message-goto-summary t]
5642 ["Keywords" message-goto-keywords t]
5643 ["Newsgroups" message-goto-newsgroups t]
5644 ["Followup-To" message-goto-followup-to t]
5645 ["Mail-Followup-To" message-goto-mail-followup-to t]
5646 ["Distribution" message-goto-distribution t]
5647 ["Body" message-goto-body t]
5648 ["Signature" message-goto-signature t]))
5650 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5651 "Major mode for editing articles.
5652 This is an extended text-mode.
5654 \\{gnus-article-edit-mode-map}"
5655 (make-local-variable 'gnus-article-edit-done-function)
5656 (make-local-variable 'gnus-prev-winconf)
5657 (set (make-local-variable 'font-lock-defaults)
5658 '(message-font-lock-keywords t))
5659 (set (make-local-variable 'mail-header-separator) "")
5660 (set (make-local-variable 'gnus-article-edit-mode) t)
5661 (easy-menu-add message-mode-field-menu message-mode-map)
5662 (setq buffer-read-only nil)
5663 (buffer-enable-undo)
5666 (defun gnus-article-edit (&optional force)
5667 "Edit the current article.
5668 This will have permanent effect only in mail groups.
5669 If FORCE is non-nil, allow editing of articles even in read-only
5672 (when (and (not force)
5673 (gnus-group-read-only-p))
5674 (error "The current newsgroup does not support article editing"))
5675 (gnus-article-date-original)
5676 (gnus-article-edit-article
5678 `(lambda (no-highlight)
5680 (gnus-summary-edit-article-done
5681 ,(or (mail-header-references gnus-current-headers) "")
5682 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5684 (defun gnus-article-edit-article (start-func exit-func)
5685 "Start editing the contents of the current article buffer."
5686 (let ((winconf (current-window-configuration)))
5687 (set-buffer gnus-article-buffer)
5688 (gnus-article-edit-mode)
5689 (funcall start-func)
5690 (set-buffer-modified-p nil)
5691 (gnus-configure-windows 'edit-article)
5692 (setq gnus-article-edit-done-function exit-func)
5693 (setq gnus-prev-winconf winconf)
5694 (when gnus-article-edit-article-setup-function
5695 (funcall gnus-article-edit-article-setup-function))
5696 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit")))
5698 (defun gnus-article-edit-done (&optional arg)
5699 "Update the article edits and exit."
5701 (let ((func gnus-article-edit-done-function)
5702 (buf (current-buffer))
5703 (start (window-start))
5705 (winconf gnus-prev-winconf))
5706 (remove-hook 'gnus-article-mode-hook
5707 'gnus-article-mime-edit-article-unwind)
5708 (widen) ;; Widen it in case that users narrowed the buffer.
5711 ;; The cache and backlog have to be flushed somewhat.
5712 (when gnus-keep-backlog
5713 (gnus-backlog-remove-article
5714 (car gnus-article-current) (cdr gnus-article-current)))
5715 ;; Flush original article as well.
5717 (when (get-buffer gnus-original-article-buffer)
5718 (set-buffer gnus-original-article-buffer)
5719 (setq gnus-original-article nil)))
5720 (when gnus-use-cache
5721 (gnus-cache-update-article
5722 (car gnus-article-current) (cdr gnus-article-current)))
5723 ;; We remove all text props from the article buffer.
5724 (kill-all-local-variables)
5725 (gnus-set-text-properties (point-min) (point-max) nil)
5727 (set-window-configuration winconf)
5729 (set-window-start (get-buffer-window buf) start)
5730 (set-window-point (get-buffer-window buf) (point))))
5732 (defun gnus-article-edit-exit ()
5733 "Exit the article editing without updating."
5735 (when (or (not (buffer-modified-p))
5736 (yes-or-no-p "Article modified; kill anyway? "))
5737 (let ((curbuf (current-buffer))
5739 (window-start (window-start)))
5741 (if (gnus-buffer-live-p gnus-original-article-buffer)
5742 (insert-buffer-substring gnus-original-article-buffer))
5743 (let ((winconf gnus-prev-winconf))
5744 (kill-all-local-variables)
5746 (set-window-configuration winconf)
5747 ;; Tippy-toe some to make sure that point remains where it was.
5748 (save-current-buffer
5750 (set-window-start (get-buffer-window (current-buffer)) window-start)
5753 (defun gnus-article-edit-full-stops ()
5754 "Interactively repair spacing at end of sentences."
5757 (goto-char (point-min))
5758 (search-forward-regexp "^$" nil t)
5759 (let ((case-fold-search nil))
5760 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5763 ;;; Article editing with MIME-Edit
5766 (defcustom gnus-article-mime-edit-article-setup-hook nil
5767 "Hook run after setting up a MIME editing article buffer."
5768 :group 'gnus-article-various
5771 (defun gnus-article-mime-edit-article-unwind ()
5772 "Unwind `gnus-article-buffer' if article editing was given up."
5773 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
5774 (when (featurep 'font-lock)
5775 (setq font-lock-defaults nil)
5776 (font-lock-mode -1))
5777 (when mime-edit-mode-flag
5778 (mime-edit-exit 'nomime 'no-error)
5781 (defun gnus-article-mime-edit-article-setup ()
5782 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
5783 after replacing with the original article."
5784 (setq gnus-show-mime t)
5785 (setq gnus-article-edit-done-function
5786 `(lambda (&rest args)
5787 (when mime-edit-mode-flag
5788 (let (mime-edit-insert-user-agent-field)
5791 (goto-char (point-min))
5792 (let (case-fold-search)
5793 (when (re-search-forward
5794 (format "^%s$" (regexp-quote mail-header-separator))
5796 (replace-match "")))
5797 (apply ,gnus-article-edit-done-function args)
5800 (buffer-substring-no-properties (point-min) (point-max))
5801 (set-buffer (get-buffer-create gnus-original-article-buffer))
5803 (setq gnus-current-headers (gnus-article-make-full-mail-header))
5804 (set-buffer gnus-article-buffer)
5805 (gnus-article-prepare-display)))
5806 (substitute-key-definition 'gnus-article-edit-done
5807 'gnus-article-mime-edit-done
5808 gnus-article-edit-mode-map)
5809 (substitute-key-definition 'gnus-article-edit-exit
5810 'gnus-article-mime-edit-exit
5811 gnus-article-edit-mode-map)
5813 (insert-buffer-substring gnus-original-article-buffer)
5814 (unless (member (with-current-buffer gnus-summary-buffer
5815 gnus-newsgroup-name)
5816 '("nndraft:delayed" "nndraft:drafts"))
5817 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
5818 (fset 'mime-edit-decode-single-part-in-buffer
5819 (lambda (&rest args)
5820 (if (let ((content-type (car args)))
5821 (and (eq 'message (mime-content-type-primary-type
5823 (eq 'rfc822 (mime-content-type-subtype
5825 (setcar (cdr args) 'not-decode-text))
5829 (fset 'mime-edit-decode-single-part-in-buffer ofn))))
5830 (when (featurep 'font-lock)
5831 (set (make-local-variable 'font-lock-defaults)
5832 '(message-font-lock-keywords t))
5833 (font-lock-set-defaults)
5834 (turn-on-font-lock))
5835 (set-buffer-modified-p nil)
5836 (delete-other-windows)
5837 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
5838 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
5840 (defun gnus-article-mime-edit-done (&optional arg)
5841 "Update the article MIME edits and exit."
5843 (when (featurep 'font-lock)
5844 (setq font-lock-defaults nil)
5845 (font-lock-mode -1))
5846 (let ((inhibit-read-only t))
5847 (gnus-article-edit-done arg)))
5849 (defun gnus-article-mime-edit-exit ()
5850 "Exit the article MIME editing without updating."
5852 (when (or (not (buffer-modified-p))
5853 (yes-or-no-p "Article modified; kill anyway? "))
5854 (when (featurep 'font-lock)
5855 (setq font-lock-defaults nil)
5856 (font-lock-mode -1))
5857 (when mime-edit-mode-flag
5858 (let (mime-edit-insert-user-agent-field)
5861 (goto-char (point-min))
5862 (let (case-fold-search)
5863 (when (re-search-forward
5864 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
5865 (replace-match "")))
5866 (let ((winconf gnus-prev-winconf))
5868 (buffer-substring-no-properties (point-min) (point-max))
5869 (set-buffer (get-buffer-create gnus-original-article-buffer))
5871 (setq gnus-current-headers (gnus-article-make-full-mail-header))
5872 (set-buffer gnus-article-buffer)
5873 (gnus-article-prepare-display)
5874 (set-window-configuration winconf))))
5877 ;;; Article highlights
5880 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5882 ;;; Internal Variables:
5884 (defcustom gnus-button-url-regexp
5885 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5886 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-z0-9_.]+:[0-9]*\\)?[-a-z0-9_=!?#$@~%&*+\\/:;.,[:word:]]+[-a-z0-9_=#$@~%&*+\\/[:word:]]\\)"
5887 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-z0-9_.]+:[0-9]*\\)?\\([-a-z0-9_=!?#$@~%&*+\\/:;.,]\\|\\w\\)+\\([-a-z0-9_=#$@~%&*+\\/]\\|\\w\\)\\)")
5888 "Regular expression that matches URLs."
5889 :group 'gnus-article-buttons
5892 (defcustom gnus-button-valid-fqdn-regexp
5893 (concat "[a-z0-9][-.a-z0-9]+\\." ;; [hostname.subdomain.]domain.
5895 "\\([a-z][a-z]" ;; two letter country TDLs
5896 "\\|biz\\|com\\|edu\\|gov\\|int\\|mil\\|net\\|org"
5897 "\\|aero\\|coop\\|info\\|name\\|museum"
5898 "\\|arpa\\|pro\\|uucp\\|bitnet\\|bofh" ;; old style?
5900 "Regular expression that matches a valid FQDN."
5901 :group 'gnus-article-buttons
5904 (defcustom gnus-button-man-handler 'manual-entry
5905 "Function to use for displaying man pages.
5906 The function must take at least one argument with a string naming the
5908 :type '(choice (function-item :tag "Man" manual-entry)
5909 (function-item :tag "Woman" woman)
5910 (function :tag "Other"))
5911 :group 'gnus-article-buttons)
5913 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
5914 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
5915 If the default site is too slow, try to find a CTAN mirror, see
5916 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
5917 the variable `gnus-button-handle-ctan'."
5918 :group 'gnus-article-buttons
5919 :link '(custom-manual "(gnus)Group Parameters")
5920 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
5921 (const "http://tug.ctan.org/tex-archive/")
5922 (const "http://www.dante.de/CTAN/")
5923 (string :tag "Other")))
5925 (defcustom gnus-button-ctan-handler 'browse-url
5926 "Function to use for displaying CTAN links.
5927 The function must take one argument, the string naming the URL."
5928 :type '(choice (function-item :tag "Browse Url" browse-url)
5929 (function :tag "Other"))
5930 :group 'gnus-article-buttons)
5932 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
5933 "Bogus strings removed from CTAN URLs."
5934 :group 'gnus-article-buttons
5935 :type '(choice (const "^/?tex-archive/\\|/")
5936 (regexp :tag "Other")))
5938 (defcustom gnus-button-mid-or-mail-regexp
5939 (concat "\\b\\(<?[a-z0-9][^<>\")!;:,{}\n\t ]*@"
5940 gnus-button-valid-fqdn-regexp
5942 "Regular expression that matches a message ID or a mail address."
5943 :group 'gnus-article-buttons
5946 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
5947 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
5948 Strings like this can be either a message ID or a mail address. If it is one
5949 of the symbols `mid' or `mail', Gnus will always assume that the string is a
5950 message ID or a mail address, respectivly. If this variable is set to the
5951 symbol `ask', always query the user what do do. If it is a function, this
5952 function will be called with the string as it's only argument. The function
5953 must return `mid', `mail', `invalid' or `ask'."
5954 :group 'gnus-article-buttons
5955 :type '(choice (function-item :tag "Heuristic function"
5956 gnus-button-mid-or-mail-heuristic)
5961 (defcustom gnus-button-mid-or-mail-heuristic-alist
5962 '((-10.0 . ".+\\$.+@")
5965 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
5966 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
5967 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
5968 (-1.0 . "^[^a-z]+@")
5970 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
5971 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
5972 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
5973 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
5976 (-1.0 . "^[0-9][0-9]")
5978 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
5979 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5980 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
5981 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5983 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
5984 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
5987 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
5990 (-20.0 . "\\.fsf@") ;; Gnus
5993 (-20.0 . "_-_") ;; Subject change in thread
5995 (-20.0 . "\\.ln@") ;; leafnode
5996 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
5997 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
5999 ;; (5.0 . "") ;; $local_part_len <= 7
6000 (10.0 . "^[^0-9]+@")
6001 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6002 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6005 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6007 (0.5 . "^[A-Z][a-z]")
6008 (0.5 . "^[A-Z][a-z][a-z]")
6009 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6010 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6011 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6013 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6014 address. The REGEXP is processed with `case-fold-search' set to `nil'."
6015 :group 'gnus-article-buttons
6016 :type '(repeat (cons (number :tag "Rate")
6017 (regexp :tag "Regexp"))))
6019 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6020 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6021 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6022 address, `ask' if unsure and `invalid' if the string is invalid."
6023 (let ((case-fold-search nil)
6024 (list gnus-button-mid-or-mail-heuristic-alist)
6025 (result 0) rate regexp lpartlen elem)
6027 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6028 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6029 ;; Certain special cases...
6032 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$" "\\|"
6033 "^[0-9]+\.[0-9]+\@compuserve")
6035 (gnus-message 8 "`%s' is a known mail address.")
6036 (setq result 'mail))
6037 (when (string-match "@.*@\\| " mid-or-mail)
6038 (gnus-message 8 "`%s' is invalid.")
6039 (setq result 'invalid))
6040 ;; Nothing more to do, if result is not a number here...
6041 (when (numberp result)
6043 (setq elem (car list)
6047 (when (string-match regexp mid-or-mail)
6048 (setq result (+ result rate))
6050 9 "`%s' matched `%s', rate `%s', result `%s'."
6051 mid-or-mail regexp rate result)))
6052 (when (<= lpartlen 7)
6053 (setq result (+ result 5.0))
6054 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6055 mid-or-mail result))
6056 (when (>= lpartlen 12)
6057 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6059 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6060 ;; Long local part should contain realname if e-mail address,
6061 ;; too many digits: message-id.
6062 ;; $score -= 5.0 + 0.1 * $local_part_len;
6063 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6064 (setq result (+ result rate))
6066 9 "Many digits in `%s', rate `%s', result `%s'."
6067 mid-or-mail rate result))
6068 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6070 ;; Too few vowels [^aeiouy]{4,}.*\@
6071 (setq result (+ result -5.0))
6073 9 "Few vowels in `%s', rate `%s', result `%s'."
6074 mid-or-mail -5.0 result))
6076 (setq result (+ result 5.0))
6078 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6079 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6081 ;; Maybe we should make this a customizable alist: (condition . 'result)
6082 ((< result -10.0) 'mid)
6083 ((> result 10.0) 'mail)
6086 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6087 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6088 (url-mid (concat "news" ":" mid-or-mail))
6089 (url-mailto (concat "mailto" ":" mid-or-mail)))
6090 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6091 (when (fboundp pref)
6093 ;; get rid of surrounding angles...
6095 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6096 (if (or (eq 'mid guessed) (eq 'mail guessed))
6100 (save-window-excursion
6101 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6104 (cond ((eq pref 'mid)
6105 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6106 (gnus-button-handle-news url-mid))
6108 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6109 (gnus-url-mailto url-mailto))
6110 (t (gnus-message 3 "Invalid string.")))))
6112 (defun gnus-button-handle-custom (url)
6113 "Follow a Custom URL."
6114 (customize-apropos (gnus-url-unhex-string url)))
6116 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6118 (defun gnus-button-handle-describe-function (url)
6119 "Call `describe-function' when pushing the corresponding URL button."
6122 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6124 (defun gnus-button-handle-describe-variable (url)
6125 "Call `describe-variable' when pushing the corresponding URL button."
6128 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6130 (defun gnus-button-handle-describe-key (url)
6131 "Call `describe-key' when pushing the corresponding URL button."
6133 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6134 (keys (ignore-errors (eval `(kbd ,key-string)))))
6137 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6139 (defun gnus-button-handle-apropos (url)
6140 "Call `apropos' when pushing the corresponding URL button."
6141 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6143 (defun gnus-button-handle-apropos-command (url)
6144 "Call `apropos' when pushing the corresponding URL button."
6146 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6148 (defun gnus-button-handle-apropos-variable (url)
6149 "Call `apropos' when pushing the corresponding URL button."
6151 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6152 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6154 (defun gnus-button-handle-apropos-documentation (url)
6155 "Call `apropos' when pushing the corresponding URL button."
6157 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6158 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6160 (defun gnus-button-handle-ctan (url)
6161 "Call `browse-url' when pushing a CTAN URL button."
6163 gnus-button-ctan-handler
6166 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6168 (defcustom gnus-button-tex-level 5
6169 "*Integer that says how many TeX-related buttons Gnus will show.
6170 The higher the number, the more buttons will appear and the more false
6171 positives are possible. Note that you can set this variable local to
6172 specifific groups. Setting it higher in TeX groups is probably a good idea.
6173 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6174 how to set variables in specific groups."
6175 :group 'gnus-article-buttons
6176 :link '(custom-manual "(gnus)Group Parameters")
6179 (defcustom gnus-button-man-level 5
6180 "*Integer that says how many man-related buttons Gnus will show.
6181 The higher the number, the more buttons will appear and the more false
6182 positives are possible. Note that you can set this variable local to
6183 specifific groups. Setting it higher in Unix groups is probably a good idea.
6184 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6185 how to set variables in specific groups."
6186 :group 'gnus-article-buttons
6187 :link '(custom-manual "(gnus)Group Parameters")
6190 (defcustom gnus-button-emacs-level 5
6191 "*Integer that says how many emacs-related buttons Gnus will show.
6192 The higher the number, the more buttons will appear and the more false
6193 positives are possible. Note that you can set this variable local to
6194 specifific groups. Setting it higher in Emacs or Gnus related groups is
6195 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6196 `gnus-parameters' on how to set variables in specific groups."
6197 :group 'gnus-article-buttons
6198 :link '(custom-manual "(gnus)Group Parameters")
6201 (defcustom gnus-button-mail-level 5
6202 "*Integer that says how many buttons for message IDs or mail addresses will appear.
6203 The higher the number, the more buttons will appear and the more false
6204 positives are possible."
6205 :group 'gnus-article-buttons
6208 (defcustom gnus-button-alist
6209 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6210 0 t gnus-button-handle-news 3)
6211 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6212 gnus-button-handle-news 2)
6213 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6215 gnus-button-fetch-group 4)
6216 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
6217 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
6218 t gnus-button-message-id 3)
6219 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
6220 ("mailto:\\([-a-z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
6221 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
6223 ("\\bCTAN:[ \t\n]*\\([^>)!;:,\n\t ]*\\)" 0 (>= gnus-button-tex-level 1)
6224 gnus-button-handle-ctan 1)
6226 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0
6227 (>= gnus-button-emacs-level 1) gnus-button-handle-info 2)
6229 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)" 0
6230 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6231 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6232 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6233 ;; Emacs help commands
6234 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6235 ;; regexp doesn't match arguments containing ` '.
6236 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6237 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6238 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6239 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6240 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6241 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6242 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6243 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6244 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6245 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6246 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6247 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'" 1
6248 ;; Unlike the other regexps we really have to require quoting
6249 ;; here to determine where it ends.
6250 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6251 ;; This is how URLs _should_ be embedded in text...
6252 ("<URL: *\\([^<>]*\\)>" 1 t gnus-button-embedded-url 1)
6254 (gnus-button-url-regexp 0 t browse-url 0)
6256 ("\\b\\([a-z][a-z]+\\)([1-9])\\W" 0
6257 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6258 gnus-button-handle-man 1)
6259 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6260 ("\\b\\([a-z][-_.a-z0-9]+\\)([1-9])\\W" 0
6261 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6262 gnus-button-handle-man 1)
6263 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6264 ;; SoWWWAnchor(3iv), XSelectInput(3X11)
6265 ("\\b\\([a-z][-_.:a-z0-9]+\\)([1-9][X1a-z]*)\\W" 0
6266 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6267 ;; MID or mail: To avoid too many false positives we don't try to catch
6268 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6269 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6270 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6271 ;; so that non-ambiguous entries (see above) match first.
6272 (gnus-button-mid-or-mail-regexp
6273 0 (>= gnus-button-mail-level 5) gnus-button-handle-mid-or-mail 1))
6274 "*Alist of regexps matching buttons in article bodies.
6276 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6277 REGEXP: is the string (case insensitive) matching text around the button (can
6278 also be lisp expression evaluating to a string),
6279 BUTTON: is the number of the regexp grouping actually matching the button,
6280 FORM: is a lisp expression which must eval to true for the button to
6282 CALLBACK: is the function to call when the user push this button, and each
6283 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6285 CALLBACK can also be a variable, in that case the value of that
6286 variable it the real callback function."
6287 :group 'gnus-article-buttons
6288 :type '(repeat (list (choice regexp variable)
6289 (integer :tag "Button")
6291 (function :tag "Callback")
6294 (integer :tag "Regexp group")))))
6296 (defcustom gnus-header-button-alist
6297 '(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
6298 0 t gnus-button-message-id 0)
6299 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
6300 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6301 0 t gnus-button-mailto 0)
6302 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp 0 t browse-url 0)
6303 ("^Subject:" gnus-button-url-regexp 0 t browse-url 0)
6304 ("^[^:]+:" gnus-button-url-regexp 0 t browse-url 0)
6305 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
6306 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
6307 gnus-button-message-id 3))
6308 "*Alist of headers and regexps to match buttons in article heads.
6310 This alist is very similar to `gnus-button-alist', except that each
6311 alist has an additional HEADER element first in each entry:
6313 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6315 HEADER is a regexp to match a header. For a fuller explanation, see
6316 `gnus-button-alist'."
6317 :group 'gnus-article-buttons
6318 :group 'gnus-article-headers
6319 :type '(repeat (list (regexp :tag "Header")
6321 (integer :tag "Button")
6323 (function :tag "Callback")
6326 (integer :tag "Regexp group")))))
6328 (defvar gnus-button-regexp nil)
6329 (defvar gnus-button-marker-list nil)
6330 ;; Regexp matching any of the regexps from `gnus-button-alist'.
6332 (defvar gnus-button-last nil)
6333 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
6337 (defun gnus-article-push-button (event)
6338 "Check text under the mouse pointer for a callback function.
6339 If the text under the mouse pointer has a `gnus-callback' property,
6340 call it with the value of the `gnus-data' text property."
6342 (set-buffer (window-buffer (posn-window (event-start event))))
6343 (let* ((pos (posn-point (event-start event)))
6344 (data (get-text-property pos 'gnus-data))
6345 (fun (get-text-property pos 'gnus-callback)))
6348 (funcall fun data))))
6350 (defun gnus-article-press-button ()
6351 "Check text at point for a callback function.
6352 If the text at point has a `gnus-callback' property,
6353 call it with the value of the `gnus-data' text property."
6355 (let ((data (get-text-property (point) 'gnus-data))
6356 (fun (get-text-property (point) 'gnus-callback)))
6358 (funcall fun data))))
6360 (defun gnus-article-prev-button (n)
6361 "Move point to N buttons backward.
6362 If N is negative, move forward instead."
6364 (gnus-article-next-button (- n)))
6366 (defun gnus-article-next-button (n)
6367 "Move point to N buttons forward.
6368 If N is negative, move backward instead."
6370 (let ((function (if (< n 0) 'previous-single-property-change
6371 'next-single-property-change))
6372 (inhibit-point-motion-hooks t)
6374 (limit (if (< n 0) (point-min) (point-max))))
6376 (while (and (not (= limit (point)))
6378 ;; Skip past the current button.
6379 (when (get-text-property (point) 'gnus-callback)
6380 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6381 ;; Go to the next (or previous) button.
6382 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
6383 ;; Put point at the start of the button.
6384 (when (and backward (not (get-text-property (point) 'gnus-callback)))
6385 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6386 ;; Skip past intangible buttons.
6387 (when (get-text-property (point) 'intangible)
6391 (gnus-message 5 "No more buttons"))
6394 (defun gnus-article-highlight (&optional force)
6395 "Highlight current article.
6396 This function calls `gnus-article-highlight-headers',
6397 `gnus-article-highlight-citation',
6398 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6399 do the highlighting. See the documentation for those functions."
6400 (interactive (list 'force))
6401 (gnus-article-highlight-headers)
6402 (gnus-article-highlight-citation force)
6403 (gnus-article-highlight-signature)
6404 (gnus-article-add-buttons force)
6405 (gnus-article-add-buttons-to-head))
6407 (defun gnus-article-highlight-some (&optional force)
6408 "Highlight current article.
6409 This function calls `gnus-article-highlight-headers',
6410 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6411 do the highlighting. See the documentation for those functions."
6412 (interactive (list 'force))
6413 (gnus-article-highlight-headers)
6414 (gnus-article-highlight-signature)
6415 (gnus-article-add-buttons))
6417 (defun gnus-article-highlight-headers ()
6418 "Highlight article headers as specified by `gnus-header-face-alist'."
6421 (set-buffer gnus-article-buffer)
6423 (let ((alist gnus-header-face-alist)
6424 (buffer-read-only nil)
6425 (case-fold-search t)
6426 (inhibit-point-motion-hooks t)
6427 entry regexp header-face field-face from hpoints fpoints)
6428 (article-narrow-to-head)
6429 (while (setq entry (pop alist))
6430 (goto-char (point-min))
6431 (setq regexp (concat "^\\("
6432 (if (string-equal "" (nth 0 entry))
6436 header-face (nth 1 entry)
6437 field-face (nth 2 entry))
6438 (while (and (re-search-forward regexp nil t)
6442 (unless (search-forward ":" nil t)
6444 (when (and header-face
6445 (not (memq (point) hpoints)))
6446 (push (point) hpoints)
6447 (gnus-put-text-property from (point) 'face header-face))
6448 (when (and field-face
6449 (not (memq (setq from (point)) fpoints)))
6451 (if (re-search-forward "^[^ \t]" nil t)
6453 (goto-char (point-max)))
6454 (gnus-put-text-property from (point) 'face field-face))))))))
6456 (defun gnus-article-highlight-signature ()
6457 "Highlight the signature in an article.
6458 It does this by highlighting everything after
6459 `gnus-signature-separator' using `gnus-signature-face'."
6461 (when gnus-signature-face
6463 (set-buffer gnus-article-buffer)
6464 (let ((buffer-read-only nil)
6465 (inhibit-point-motion-hooks t))
6467 (when (gnus-article-narrow-to-signature)
6468 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6469 'face gnus-signature-face)))))))
6471 (defun gnus-article-buttonize-signature ()
6472 "Add button to the signature."
6475 (set-buffer gnus-article-buffer)
6476 (let ((buffer-read-only nil)
6477 (inhibit-point-motion-hooks t))
6478 (when (gnus-article-search-signature)
6479 (gnus-article-add-button (match-beginning 0) (match-end 0)
6480 'gnus-signature-toggle
6481 (set-marker (make-marker)
6482 (1+ (match-end 0))))))))
6484 (defun gnus-button-in-region-p (b e prop)
6485 "Say whether PROP exists in the region."
6486 (text-property-not-all b e prop nil))
6488 (defun gnus-article-add-buttons (&optional force)
6489 "Find external references in the article and make buttons of them.
6490 \"External references\" are things like Message-IDs and URLs, as
6491 specified by `gnus-button-alist'."
6492 (interactive (list 'force))
6494 (set-buffer gnus-article-buffer)
6495 (let ((buffer-read-only nil)
6496 (inhibit-point-motion-hooks t)
6497 (case-fold-search t)
6498 (alist gnus-button-alist)
6500 ;; Remove all old markers.
6501 (let (marker entry new-list)
6502 (while (setq marker (pop gnus-button-marker-list))
6503 (if (or (< marker (point-min)) (>= marker (point-max)))
6504 (push marker new-list)
6506 (when (setq entry (gnus-button-entry))
6507 (put-text-property (match-beginning (nth 1 entry))
6508 (match-end (nth 1 entry))
6509 'gnus-callback nil))
6510 (set-marker marker nil)))
6511 (setq gnus-button-marker-list new-list))
6512 ;; We skip the headers.
6515 (while (setq entry (pop alist))
6516 (setq regexp (eval (car entry)))
6518 (while (re-search-forward regexp nil t)
6519 (let* ((start (and entry (match-beginning (nth 1 entry))))
6520 (end (and entry (match-end (nth 1 entry))))
6521 (from (match-beginning 0)))
6522 (when (and (or (eq t (nth 2 entry))
6523 (eval (nth 2 entry)))
6524 (not (gnus-button-in-region-p
6525 start end 'gnus-callback)))
6526 ;; That optional form returned non-nil, so we add the
6528 (gnus-article-add-button
6529 start end 'gnus-button-push
6530 (car (push (set-marker (make-marker) from)
6531 gnus-button-marker-list))))))))))
6533 ;; Add buttons to the head of an article.
6534 (defun gnus-article-add-buttons-to-head ()
6535 "Add buttons to the head of the article."
6538 (set-buffer gnus-article-buffer)
6540 (let ((buffer-read-only nil)
6541 (inhibit-point-motion-hooks t)
6542 (case-fold-search t)
6543 (alist gnus-header-button-alist)
6545 (article-narrow-to-head)
6547 ;; Each alist entry.
6548 (setq entry (car alist)
6550 (goto-char (point-min))
6551 (while (re-search-forward (car entry) nil t)
6552 ;; Each header matching the entry.
6553 (setq beg (match-beginning 0))
6554 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6555 (match-beginning 0))
6558 (while (re-search-forward (eval (nth 1 entry)) end t)
6559 ;; Each match within a header.
6560 (let* ((entry (cdr entry))
6561 (start (match-beginning (nth 1 entry)))
6562 (end (match-end (nth 1 entry)))
6563 (form (nth 2 entry)))
6564 (goto-char (match-end 0))
6566 (gnus-article-add-button
6567 start end (nth 3 entry)
6568 (buffer-substring (match-beginning (nth 4 entry))
6569 (match-end (nth 4 entry)))))))
6570 (goto-char end)))))))
6572 ;;; External functions:
6574 (defun gnus-article-add-button (from to fun &optional data)
6575 "Create a button between FROM and TO with callback FUN and data DATA."
6576 (when gnus-article-button-face
6577 (gnus-overlay-put (gnus-make-overlay from to)
6578 'face gnus-article-button-face))
6579 (gnus-add-text-properties
6581 (nconc (and gnus-article-mouse-face
6582 (list gnus-mouse-face-prop gnus-article-mouse-face))
6583 (list 'gnus-callback fun)
6584 (and data (list 'gnus-data data))))
6585 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6586 ;; Quote `:button-keymap' for Mule 2.3
6587 ;; but it won't work.
6588 ':button-keymap gnus-widget-button-keymap))
6590 ;;; Internal functions:
6592 (defun gnus-article-set-globals ()
6594 (set-buffer gnus-summary-buffer)
6595 (gnus-set-global-variables)))
6597 (defun gnus-signature-toggle (end)
6599 (set-buffer gnus-article-buffer)
6600 (let ((buffer-read-only nil)
6601 (inhibit-point-motion-hooks t)
6602 (limit (next-single-property-change end 'mime-view-entity
6604 (if (text-property-any end limit 'article-type 'signature)
6606 (gnus-delete-wash-type 'signature)
6607 (gnus-remove-text-properties-when
6608 'article-type 'signature end limit
6609 (cons 'article-type (cons 'signature
6610 gnus-hidden-properties))))
6611 (gnus-add-wash-type 'signature)
6612 (gnus-add-text-properties-when
6613 'article-type nil end limit
6614 (cons 'article-type (cons 'signature
6615 gnus-hidden-properties)))))
6616 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6617 (gnus-set-mode-line 'article))))
6619 (defun gnus-button-entry ()
6620 ;; Return the first entry in `gnus-button-alist' matching this place.
6621 (let ((alist gnus-button-alist)
6624 (setq entry (pop alist))
6625 (if (looking-at (eval (car entry)))
6630 (defun gnus-button-push (marker)
6631 ;; Push button starting at MARKER.
6634 (let* ((entry (gnus-button-entry))
6635 (inhibit-point-motion-hooks t)
6637 (args (mapcar (lambda (group)
6638 (let ((string (match-string group)))
6639 (gnus-set-text-properties
6640 0 (length string) nil string)
6647 (fboundp (symbol-value fun)))
6648 (apply (symbol-value fun) args))
6650 (gnus-message 1 "You must define `%S' to use this button"
6651 (cons fun args)))))))
6653 (defun gnus-parse-news-url (url)
6654 (let (scheme server group message-id articles)
6657 (goto-char (point-min))
6658 (when (looking-at "\\([A-Za-z]+\\):")
6659 (setq scheme (match-string 1))
6660 (goto-char (match-end 0)))
6661 (when (looking-at "//\\([^/]+\\)/")
6662 (setq server (match-string 1))
6663 (goto-char (match-end 0)))
6666 ((looking-at "\\(.*@.*\\)")
6667 (setq message-id (match-string 1)))
6668 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6669 (setq group (match-string 1)
6670 articles (split-string (match-string 2) "-")))
6671 ((looking-at "\\([^/]+\\)/?")
6672 (setq group (match-string 1)))
6674 (error "Unknown news URL syntax"))))
6675 (list scheme server group message-id articles)))
6677 (defun gnus-button-handle-news (url)
6679 (destructuring-bind (scheme server group message-id articles)
6680 (gnus-parse-news-url url)
6684 (set-buffer gnus-summary-buffer)
6686 (let ((gnus-refer-article-method (list (list 'nntp server))))
6687 (gnus-summary-refer-article message-id))
6688 (gnus-summary-refer-article message-id))))
6690 (gnus-button-fetch-group url)))))
6692 (defun gnus-button-handle-man (url)
6694 (funcall gnus-button-man-handler url))
6696 (defun gnus-button-handle-info (url)
6697 "Fetch an info URL."
6699 "^\\([^:/]+\\)?/\\(.*\\)"
6701 (gnus-info-find-node
6702 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6705 (gnus-url-unhex-string (match-string 2 url))))
6706 (error "Can't parse %s" url)))
6708 (defun gnus-button-message-id (message-id)
6711 (set-buffer gnus-summary-buffer)
6712 (gnus-summary-refer-article message-id)))
6714 (defun gnus-button-fetch-group (address)
6715 "Fetch GROUP specified by ADDRESS."
6716 (if (not (string-match "[:/]" address))
6717 ;; This is just a simple group url.
6718 (gnus-group-read-ephemeral-group address gnus-select-method)
6721 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6723 (error "Can't parse %s" address)
6724 (gnus-group-read-ephemeral-group
6725 (match-string 4 address)
6726 `(nntp ,(match-string 1 address)
6727 (nntp-address ,(match-string 1 address))
6728 (nntp-port-number ,(if (match-end 3)
6729 (match-string 3 address)
6732 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
6734 (defun gnus-url-parse-query-string (query &optional downcase)
6735 (let (retval pairs cur key val)
6736 (setq pairs (split-string query "&"))
6738 (setq cur (car pairs)
6740 (if (not (string-match "=" cur))
6742 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6743 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6745 (setq key (downcase key)))
6746 (setq cur (assoc key retval))
6748 (setcdr cur (cons val (cdr cur)))
6749 (setq retval (cons (list key val) retval)))))
6752 (defun gnus-url-mailto (url)
6753 ;; Send mail to someone
6754 (when (string-match "mailto:/*\\(.*\\)" url)
6755 (setq url (substring url (match-beginning 1) nil)))
6756 (let (to args subject func)
6757 (if (string-match (regexp-quote "?") url)
6758 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
6759 args (gnus-url-parse-query-string
6760 (substring url (match-end 0) nil) t))
6761 (setq to (gnus-url-unhex-string url)))
6762 (setq args (cons (list "to" to) args)
6763 subject (cdr-safe (assoc "subject" args)))
6766 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6769 (message-position-on-field (caar args)))
6770 (insert (mapconcat 'identity (cdar args) ", "))
6771 (setq args (cdr args)))
6774 (message-goto-subject))))
6776 (defun gnus-button-embedded-url (address)
6777 "Activate ADDRESS with `browse-url'."
6778 (browse-url (gnus-strip-whitespace address)))
6780 ;;; Next/prev buttons in the article buffer.
6782 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6783 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6785 (defvar gnus-prev-page-map
6786 (let ((map (make-sparse-keymap)))
6787 (unless (>= emacs-major-version 21)
6788 ;; XEmacs doesn't care.
6789 (set-keymap-parent map gnus-article-mode-map))
6790 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6791 (define-key map "\r" 'gnus-button-prev-page)
6794 (defun gnus-insert-prev-page-button ()
6796 (buffer-read-only nil)
6797 (situation (get-text-property (point-min) 'mime-view-situation)))
6799 gnus-prev-page-line-format nil
6800 `(,@(gnus-local-map-property gnus-prev-page-map)
6802 gnus-callback gnus-article-button-prev-page
6803 article-type annotation
6804 mime-view-situation ,situation))
6805 (widget-convert-button
6807 :action 'gnus-button-prev-page
6808 :button-keymap gnus-prev-page-map)))
6810 (defvar gnus-next-page-map
6811 (let ((map (make-sparse-keymap)))
6812 (unless (>= emacs-major-version 21)
6813 ;; XEmacs doesn't care.
6814 (set-keymap-parent map gnus-article-mode-map))
6815 (define-key map gnus-mouse-2 'gnus-button-next-page)
6816 (define-key map "\r" 'gnus-button-next-page)
6819 (defun gnus-button-next-page (&optional args more-args)
6820 "Go to the next page."
6822 (let ((win (selected-window)))
6823 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6824 (gnus-article-next-page)
6825 (select-window win)))
6827 (defun gnus-button-prev-page (&optional args more-args)
6828 "Go to the prev page."
6830 (let ((win (selected-window)))
6831 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6832 (gnus-article-prev-page)
6833 (select-window win)))
6835 (defun gnus-insert-next-page-button ()
6837 (buffer-read-only nil)
6838 (situation (get-text-property (point-min) 'mime-view-situation)))
6839 (gnus-eval-format gnus-next-page-line-format nil
6840 `(,@(gnus-local-map-property gnus-next-page-map)
6842 gnus-callback gnus-article-button-next-page
6843 article-type annotation
6844 mime-view-situation ,situation))
6845 (widget-convert-button
6847 :action 'gnus-button-next-page
6848 :button-keymap gnus-next-page-map)))
6850 (defun gnus-article-button-next-page (arg)
6851 "Go to the next page."
6853 (let ((win (selected-window)))
6854 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6855 (gnus-article-next-page)
6856 (select-window win)))
6858 (defun gnus-article-button-prev-page (arg)
6859 "Go to the prev page."
6861 (let ((win (selected-window)))
6862 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6863 (gnus-article-prev-page)
6864 (select-window win)))
6866 (defvar gnus-decode-header-methods
6867 '(mail-decode-encoded-word-region)
6868 "List of methods used to decode headers.
6870 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6871 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
6872 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
6873 whose names match REGEXP.
6876 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6877 mail-decode-encoded-word-region
6878 (\"chinese\" . rfc1843-decode-region))
6881 (defvar gnus-decode-header-methods-cache nil)
6883 (defun gnus-multi-decode-header (start end)
6884 "Apply the functions from `gnus-encoded-word-methods' that match."
6885 (unless (and gnus-decode-header-methods-cache
6886 (eq gnus-newsgroup-name
6887 (car gnus-decode-header-methods-cache)))
6888 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6891 (nconc gnus-decode-header-methods-cache (list x))
6892 (if (and gnus-newsgroup-name
6893 (string-match (car x) gnus-newsgroup-name))
6894 (nconc gnus-decode-header-methods-cache
6896 gnus-decode-header-methods))
6897 (let ((xlist gnus-decode-header-methods-cache))
6900 (narrow-to-region start end)
6902 (funcall (pop xlist) (point-min) (point-max))))))
6905 ;;; Treatment top-level handling.
6908 (defun gnus-treat-article (condition &optional part-number total-parts type)
6909 (let ((length (- (point-max) (point-min)))
6910 (alist gnus-treatment-function-alist)
6911 (article-goto-body-goes-to-point-min-p t)
6915 (let ((list gnus-article-treat-types))
6917 (when (string-match (pop list) type)
6918 (throw 'found t)))))))
6919 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6920 (entity (static-unless (featurep 'xemacs)
6921 (when (eq 'head condition)
6922 (get-text-property (point-min) 'mime-view-entity))))
6923 val elem buttonized)
6924 (gnus-run-hooks 'gnus-part-display-hook)
6925 (unless gnus-inhibit-treatment
6926 (dolist (elem alist)
6929 (when (gnus-buffer-live-p gnus-summary-buffer)
6930 (set-buffer gnus-summary-buffer))
6931 (symbol-value (car elem))))
6932 (when (and (or (consp val)
6934 (gnus-treat-predicate val)
6935 (or (not (get (car elem) 'highlight))
6937 (when (and (not buttonized)
6939 '(gnus-treat-hide-signature
6940 gnus-treat-highlight-signature)))
6941 (gnus-article-buttonize-signature)
6942 (setq buttonized t))
6944 (funcall (cadr elem)))))
6945 ;; FSF Emacsen does not inherit the existing text properties
6946 ;; in the new text, so we should do it for `mime-view-entity'.
6947 (static-unless (featurep 'xemacs)
6949 (put-text-property (point-min) (point-max)
6950 'mime-view-entity entity))))))
6952 ;; Dynamic variables.
6954 (defvar part-number)
6955 (defvar total-parts)
6960 (defun gnus-treat-predicate (val)
6965 (stringp (car val)))
6966 (apply 'gnus-or (mapcar `(lambda (s)
6967 (string-match s ,(or gnus-newsgroup-name "")))
6970 (let ((pred (pop val)))
6973 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
6975 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
6977 (not (gnus-treat-predicate (car val))))
6979 (equal (car val) type))
6981 (error "%S is not a valid predicate" pred)))))
6991 (eq part-number total-parts))
6995 (error "%S is not a valid value" val))))
6997 (defun gnus-article-encrypt-body (protocol &optional n)
6998 "Encrypt the article body."
7001 (or gnus-article-encrypt-protocol
7002 (completing-read "Encrypt protocol: "
7003 gnus-article-encrypt-protocol-alist
7005 current-prefix-arg))
7006 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7008 (error (format "Can't find the encrypt protocol %s" protocol)))
7009 (if (member gnus-newsgroup-name '("nndraft:delayed"
7012 (error "Can't encrypt the article in group %s"
7013 gnus-newsgroup-name))
7014 (gnus-summary-iterate n
7016 (set-buffer gnus-summary-buffer)
7017 (let ((mail-parse-charset gnus-newsgroup-charset)
7018 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7019 (summary-buffer gnus-summary-buffer)
7021 (gnus-set-global-variables)
7022 (when (gnus-group-read-only-p)
7023 (error "The current newsgroup does not support article encrypt"))
7024 (gnus-summary-show-article t)
7026 (or (mail-header-references gnus-current-headers) ""))
7027 (set-buffer gnus-article-buffer)
7028 (let* ((buffer-read-only nil)
7030 (mapcar (lambda (field)
7031 (and (save-restriction
7032 (message-narrow-to-head)
7033 (goto-char (point-min))
7034 (search-forward field nil t))
7036 (message-narrow-to-field)
7037 (buffer-substring (point-min) (point-max))
7038 (delete-region (point-min) (point-max))
7040 '("Content-Type:" "Content-Transfer-Encoding:"
7041 "Content-Disposition:"))))
7042 (message-narrow-to-head)
7043 (message-remove-header "MIME-Version")
7044 (goto-char (point-max))
7045 (setq point (point))
7046 (insert (apply 'concat headers))
7048 (narrow-to-region point (point-max))
7049 (let ((message-options message-options))
7050 (message-options-set 'message-sender user-mail-address)
7051 (message-options-set 'message-recipients user-mail-address)
7052 (message-options-set 'message-sign-encrypt 'not)
7054 (goto-char (point-min))
7055 (insert "MIME-Version: 1.0\n")
7057 (gnus-summary-edit-article-done
7058 references nil summary-buffer t))
7059 (when gnus-keep-backlog
7060 (gnus-backlog-remove-article
7061 (car gnus-article-current) (cdr gnus-article-current)))
7063 (when (get-buffer gnus-original-article-buffer)
7064 (set-buffer gnus-original-article-buffer)
7065 (setq gnus-original-article nil)))
7066 (when gnus-use-cache
7067 (gnus-cache-update-article
7068 (car gnus-article-current) (cdr gnus-article-current))))))))
7070 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7071 "The following specs can be used:
7072 %t The security MIME type
7075 %D Details if button is pressed")
7077 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7078 "The following specs can be used:
7079 %t The security MIME type
7082 %D Details if button is pressed")
7084 (defvar gnus-mime-security-button-line-format-alist
7085 '((?t gnus-tmp-type ?s)
7086 (?i gnus-tmp-info ?s)
7087 (?d gnus-tmp-details ?s)
7088 (?D gnus-tmp-pressed-details ?s)))
7090 (defvar gnus-mime-security-button-map
7091 (let ((map (make-sparse-keymap)))
7092 (unless (>= (string-to-number emacs-version) 21)
7093 (set-keymap-parent map gnus-article-mode-map))
7094 (define-key map gnus-mouse-2 'gnus-article-push-button)
7095 (define-key map "\r" 'gnus-article-press-button)
7098 (defvar gnus-mime-security-details-buffer nil)
7100 (defvar gnus-mime-security-button-pressed nil)
7102 (defvar gnus-mime-security-show-details-inline t
7103 "If non-nil, show details in the article buffer.")
7105 (defun gnus-mime-security-verify-or-decrypt (handle)
7106 (mm-remove-parts (cdr handle))
7107 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7108 point buffer-read-only)
7110 (goto-char (car region)))
7112 (narrow-to-region (point) (point))
7113 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7114 (let* ((mm-verify-option 'known)
7115 (mm-decrypt-option 'known)
7116 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7117 (unless (eq nparts (cdr handle))
7118 (mm-destroy-parts (cdr handle))
7119 (setcdr handle nparts))))
7120 (setq point (point))
7121 (gnus-mime-display-security handle)
7122 (goto-char (point-max)))
7124 (delete-region (point) (cdr region))
7125 (set-marker (car region) nil)
7126 (set-marker (cdr region) nil))
7129 (defun gnus-mime-security-show-details (handle)
7130 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7132 (gnus-message 5 "No details.")
7133 (if gnus-mime-security-show-details-inline
7134 (let ((gnus-mime-security-button-pressed
7135 (not (get-text-property (point) 'gnus-mime-details)))
7136 (gnus-mime-security-button-line-format
7137 (get-text-property (point) 'gnus-line-format))
7140 (while (eq (get-text-property (point) 'gnus-line-format)
7141 gnus-mime-security-button-line-format)
7145 (narrow-to-region (point) (point))
7146 (gnus-insert-mime-security-button handle))
7147 (delete-region (point)
7148 (or (text-property-not-all
7151 gnus-mime-security-button-line-format)
7154 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7155 (with-current-buffer gnus-mime-security-details-buffer
7158 (setq gnus-mime-security-details-buffer
7159 (gnus-get-buffer-create "*MIME Security Details*")))
7160 (with-current-buffer gnus-mime-security-details-buffer
7162 (goto-char (point-min)))
7163 (pop-to-buffer gnus-mime-security-details-buffer)))))
7165 (defun gnus-mime-security-press-button (handle)
7167 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7168 (gnus-mime-security-show-details handle)
7169 (gnus-mime-security-verify-or-decrypt handle))))
7171 (defun gnus-insert-mime-security-button (handle &optional displayed)
7172 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7175 (or (nth 2 (assoc protocol mm-verify-function-alist))
7176 (nth 2 (assoc protocol mm-decrypt-function-alist))
7178 (if (equal (car handle) "multipart/signed")
7179 " Signed" " Encrypted")
7182 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7185 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7186 gnus-tmp-pressed-details
7188 (setq gnus-tmp-details
7189 (if gnus-tmp-details
7190 (concat "\n" gnus-tmp-details)
7192 (setq gnus-tmp-pressed-details
7193 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7198 gnus-mime-security-button-line-format
7199 gnus-mime-security-button-line-format-alist
7200 `(,@(gnus-local-map-property gnus-mime-security-button-map)
7201 gnus-callback gnus-mime-security-press-button
7202 gnus-line-format ,gnus-mime-security-button-line-format
7203 gnus-mime-details ,gnus-mime-security-button-pressed
7204 article-type annotation
7207 (widget-convert-button
7210 :action 'gnus-widget-press-button
7211 :button-keymap gnus-mime-security-button-map
7213 (lambda (widget/window &optional overlay pos)
7214 ;; Needed to properly clear the message due to a bug in
7215 ;; wid-edit (XEmacs only).
7216 (when (boundp 'help-echo-owns-message)
7217 (setq help-echo-owns-message t))
7220 (aref gnus-mouse-2 0))))))
7222 (defun gnus-mime-display-security (handle)
7224 (narrow-to-region (point) (point))
7225 (unless (gnus-unbuttonized-mime-type-p (car handle))
7226 (gnus-insert-mime-security-button handle))
7227 (gnus-mime-display-mixed (cdr handle))
7230 (unless (gnus-unbuttonized-mime-type-p (car handle))
7231 (let ((gnus-mime-security-button-line-format
7232 gnus-mime-security-button-end-line-format))
7233 (gnus-insert-mime-security-button handle)))
7234 (mm-set-handle-multipart-parameter
7236 (cons (set-marker (make-marker) (point-min))
7237 (set-marker (make-marker) (point-max))))))
7243 (defun gnus-article-header-presentation-method (entity situation)
7244 (mime-insert-header entity)
7245 (article-decode-group-name))
7247 (set-alist 'mime-header-presentation-method-alist
7248 'gnus-original-article-mode
7249 #'gnus-article-header-presentation-method)
7251 (defun gnus-mime-preview-quitting-method ()
7252 (mime-preview-kill-buffer)
7253 (delete-other-windows)
7254 (gnus-article-show-summary)
7255 (gnus-summary-select-article gnus-show-all-headers t))
7257 (set-alist 'mime-preview-quitting-method-alist
7258 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
7260 (set-alist 'mime-preview-following-method-alist
7261 'gnus-original-article-mode #'gnus-following-method)
7263 (set-alist 'mime-preview-over-to-previous-method-alist
7264 'gnus-original-article-mode
7266 (if (> (point-min) 1)
7267 (gnus-article-prev-page)
7268 (gnus-article-read-summary-keys
7269 nil (gnus-character-to-event ?P)))))
7271 (set-alist 'mime-preview-over-to-next-method-alist
7272 'gnus-original-article-mode'
7274 (if (< (point-max) (buffer-size))
7275 (gnus-article-next-page)
7276 (gnus-article-read-summary-keys
7277 nil (gnus-character-to-event ?N)))))
7287 (run-hooks 'gnus-art-load-hook)
7289 ;;; gnus-art.el ends here