1 ;;; gnus-art.el --- article mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
31 (defvar tool-bar-map))
34 ;; Avoid the "Recursive load suspected" error in Emacs 21.1.
36 (let ((recursive-load-depth-limit 100))
49 (autoload 'gnus-msg-mail "gnus-msg" nil t)
50 (autoload 'gnus-button-mailto "gnus-msg")
51 (autoload 'gnus-button-reply "gnus-msg" nil t)
52 (autoload 'parse-time-string "parse-time" nil nil)
53 (autoload 'ansi-color-apply-on-region "ansi-color")
55 (defgroup gnus-article nil
57 :link '(custom-manual "(gnus)Article Buffer")
60 (defgroup gnus-article-treat nil
61 "Treating article parts."
62 :link '(custom-manual "(gnus)Article Hiding")
65 (defgroup gnus-article-hiding nil
66 "Hiding article parts."
67 :link '(custom-manual "(gnus)Article Hiding")
70 (defgroup gnus-article-highlight nil
71 "Article highlighting."
72 :link '(custom-manual "(gnus)Article Highlighting")
76 (defgroup gnus-article-signature nil
78 :link '(custom-manual "(gnus)Article Signature")
81 (defgroup gnus-article-headers nil
83 :link '(custom-manual "(gnus)Hiding Headers")
86 (defgroup gnus-article-washing nil
87 "Special commands on articles."
88 :link '(custom-manual "(gnus)Article Washing")
91 (defgroup gnus-article-emphasis nil
92 "Fontisizing articles."
93 :link '(custom-manual "(gnus)Article Fontisizing")
96 (defgroup gnus-article-saving nil
98 :link '(custom-manual "(gnus)Saving Articles")
101 (defgroup gnus-article-mime nil
102 "Worshiping the MIME wonder."
103 :link '(custom-manual "(gnus)Using MIME")
104 :group 'gnus-article)
106 (defgroup gnus-article-buttons nil
107 "Pushable buttons in the article buffer."
108 :link '(custom-manual "(gnus)Article Buttons")
109 :group 'gnus-article)
111 (defgroup gnus-article-various nil
112 "Other article options."
113 :link '(custom-manual "(gnus)Misc Article")
114 :group 'gnus-article)
116 (defcustom gnus-ignored-headers
119 (concat "^" header ":"))
120 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
121 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
122 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
123 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
124 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
125 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
126 "X-Attribution" "X-Originating-IP" "Delivered-To"
127 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
128 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
129 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
130 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
131 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
132 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
133 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
134 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
135 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
136 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
137 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
138 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
139 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
140 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
141 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
142 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
143 "List-[A-Za-z]+" "X-Listprocessor-Version"
144 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
145 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
146 "X-Received" "Content-length" "X-precedence"
147 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
148 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
149 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
150 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
151 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
152 "X-Content-length" "X-Posting-Agent" "Original-Received"
153 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
154 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
155 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
156 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
157 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"))
158 "*All headers that start with this regexp will be hidden.
159 This variable can also be a list of regexps of headers to be ignored.
160 If `gnus-visible-headers' is non-nil, this variable will be ignored."
161 :type '(choice :custom-show nil
164 :group 'gnus-article-hiding)
166 (defcustom gnus-visible-headers
167 "^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:"
168 "*All headers that do not match this regexp will be hidden.
169 This variable can also be a list of regexp of headers to remain visible.
170 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
171 :type '(repeat :value-to-internal (lambda (widget value)
172 (custom-split-regexp-maybe value))
173 :match (lambda (widget value)
175 (widget-editable-list-match widget value)))
177 :group 'gnus-article-hiding)
179 (defcustom gnus-sorted-header-list
180 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
181 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
182 "*This variable is a list of regular expressions.
183 If it is non-nil, headers that match the regular expressions will
184 be placed first in the article buffer in the sequence specified by
186 :type '(repeat regexp)
187 :group 'gnus-article-hiding)
189 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
190 "Headers that are only to be displayed if they have interesting data.
191 Possible values in this list are:
193 'empty Headers with no content.
194 'newsgroups Newsgroup identical to Gnus group.
195 'to-address To identical to To-address.
196 'to-list To identical to To-list.
197 'cc-list CC identical to To-list.
198 'followup-to Followup-to identical to Newsgroups.
199 'reply-to Reply-to identical to From.
200 'date Date less than four days old.
201 'long-to To and/or Cc longer than 1024 characters.
202 'many-to Multiple To and/or Cc."
203 :type '(set (const :tag "Headers with no content." empty)
204 (const :tag "Newsgroups identical to Gnus group." newsgroups)
205 (const :tag "To identical to To-address." to-address)
206 (const :tag "To identical to To-list." to-list)
207 (const :tag "CC identical to To-list." cc-list)
208 (const :tag "Followup-to identical to Newsgroups." followup-to)
209 (const :tag "Reply-to identical to From." reply-to)
210 (const :tag "Date less than four days old." date)
211 (const :tag "To and/or Cc longer than 1024 characters." long-to)
212 (const :tag "Multiple To and/or Cc headers." many-to))
213 :group 'gnus-article-hiding)
215 (defcustom gnus-article-skip-boring nil
216 "Skip over text that is not worth reading.
217 By default, if you set this t, then Gnus will display citations and
218 signatures, but will never scroll down to show you a page consisting
219 only of boring text. Boring text is controlled by
220 `gnus-article-boring-faces'."
223 :group 'gnus-article-hiding)
225 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
226 "Regexp matching signature separator.
227 This can also be a list of regexps. In that case, it will be checked
228 from head to tail looking for a separator. Searches will be done from
229 the end of the buffer."
230 :type '(repeat string)
231 :group 'gnus-article-signature)
233 (defcustom gnus-signature-limit nil
234 "Provide a limit to what is considered a signature.
235 If it is a number, no signature may not be longer (in characters) than
236 that number. If it is a floating point number, no signature may be
237 longer (in lines) than that number. If it is a function, the function
238 will be called without any parameters, and if it returns nil, there is
239 no signature in the buffer. If it is a string, it will be used as a
240 regexp. If it matches, the text in question is not a signature.
242 This can also be a list of the above values."
243 :type '(choice (integer :value 200)
245 (function :value fun)
246 (regexp :value ".*"))
247 :group 'gnus-article-signature)
249 (defcustom gnus-hidden-properties '(invisible t intangible t)
250 "Property list to use for hiding text."
252 :group 'gnus-article-hiding)
254 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
255 ;; frames in a session.
256 (defcustom gnus-article-x-face-command
257 (if (featurep 'xemacs)
258 (if (or (gnus-image-type-available-p 'xface)
259 (gnus-image-type-available-p 'pbm))
260 'gnus-display-x-face-in-from
261 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
262 (if (gnus-image-type-available-p 'pbm)
263 'gnus-display-x-face-in-from
264 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
266 "*String or function to be executed to display an X-Face header.
267 If it is a string, the command will be executed in a sub-shell
268 asynchronously. The compressed face will be piped to this command."
269 :type `(choice string
270 (function-item gnus-display-x-face-in-from)
274 :group 'gnus-article-washing)
276 (defcustom gnus-article-x-face-too-ugly nil
277 "Regexp matching posters whose face shouldn't be shown automatically."
278 :type '(choice regexp (const nil))
279 :group 'gnus-article-washing)
281 (defcustom gnus-article-banner-alist nil
282 "Banner alist for stripping.
284 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
286 :type '(repeat (cons symbol regexp))
287 :group 'gnus-article-washing)
289 (gnus-define-group-parameter
292 "Alist of regexps (to match group names) and banner."
293 :variable-group gnus-article-washing
295 '(choice :tag "Banner"
297 (const :tag "Remove signature" signature)
298 (symbol :tag "Item in `gnus-article-banner-alist'" none)
300 (const :tag "None" nil))
302 "If non-nil, specify how to remove `banners' from articles.
304 Symbol `signature' means to remove signatures delimited by
305 `gnus-signature-separator'. Any other symbol is used to look up a
306 regular expression to match the banner in `gnus-article-banner-alist'.
307 A string is used as a regular expression to match the banner
310 (defcustom gnus-article-address-banner-alist nil
311 "Alist of mail addresses and banners.
312 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
313 to match a mail address in the From: header, BANNER is one of a symbol
314 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
315 If ADDRESS matches author's mail address, it will remove things like
316 advertisements. For example:
318 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
322 (regexp :tag "Address")
323 (choice :tag "Banner" :value nil
324 (const :tag "Remove signature" signature)
325 (symbol :tag "Item in `gnus-article-banner-alist'" none)
327 (const :tag "None" nil))))
329 :group 'gnus-article-washing)
331 (defmacro gnus-emphasis-custom-with-format (&rest body)
333 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
334 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
337 (defun gnus-emphasis-custom-value-to-external (value)
338 (gnus-emphasis-custom-with-format
339 (if (consp (car value))
340 (list (format format (car (car value)) (cdr (car value)))
342 (if (nth 1 value) 2 3)
346 (defun gnus-emphasis-custom-value-to-internal (value)
347 (gnus-emphasis-custom-with-format
348 (let ((regexp (concat "\\`"
349 (format (regexp-quote format)
350 "\\([^()]+\\)" "\\([^()]+\\)")
353 (if (string-match regexp (setq pattern (car value)))
354 (list (cons (match-string 1 pattern) (match-string 2 pattern))
359 (defcustom gnus-emphasis-alist
361 '(("\\*" "\\*" bold nil 2)
364 ("_/" "/_" underline-italic)
365 ("_\\*" "\\*_" underline-bold)
366 ("\\*/" "/\\*" bold-italic)
367 ("_\\*/" "/\\*_" underline-bold-italic))))
369 (gnus-emphasis-custom-with-format
370 (mapcar (lambda (spec)
371 (list (format format (car spec) (cadr spec))
374 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
376 '(("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
377 2 3 gnus-emphasis-underline))))
378 "*Alist that says how to fontify certain phrases.
379 Each item looks like this:
381 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
383 The first element is a regular expression to be matched. The second
384 is a number that says what regular expression grouping used to find
385 the entire emphasized word. The third is a number that says what
386 regexp grouping should be displayed and highlighted. The fourth
387 is the face used for highlighting."
391 :format "%[Customizing Style%]\n%v"
393 (group :tag "Default"
394 :value ("" 0 0 default)
397 (let ((value (widget-get
398 (cadr (widget-get (widget-get widget :parent)
401 (if (not (eq (nth 2 value) 'default))
405 (gnus-emphasis-custom-value-to-external value))))
406 (widget-group-value-create widget))
408 (integer :format "Match group: %v")
409 (integer :format "Emphasize group: %v")
412 :value (("_" . "_") nil default)
414 (regexp :format "Start regexp: %v")
415 (regexp :format "End regexp: %v"))
416 (boolean :format "Show start and end patterns: %[%v%]\n"
417 :on " On " :off " Off ")
419 :get (lambda (symbol)
420 (mapcar 'gnus-emphasis-custom-value-to-internal
421 (default-value symbol)))
422 :set (lambda (symbol value)
423 (set-default symbol (mapcar 'gnus-emphasis-custom-value-to-external
425 :group 'gnus-article-emphasis)
427 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
428 "A regexp to describe whitespace which should not be emphasized.
429 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
430 The former avoids underlining of leading and trailing whitespace,
431 and the latter avoids underlining any whitespace at all."
433 :group 'gnus-article-emphasis
436 (defface gnus-emphasis-bold '((t (:bold t)))
437 "Face used for displaying strong emphasized text (*word*)."
438 :group 'gnus-article-emphasis)
440 (defface gnus-emphasis-italic '((t (:italic t)))
441 "Face used for displaying italic emphasized text (/word/)."
442 :group 'gnus-article-emphasis)
444 (defface gnus-emphasis-underline '((t (:underline t)))
445 "Face used for displaying underlined emphasized text (_word_)."
446 :group 'gnus-article-emphasis)
448 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
449 "Face used for displaying underlined bold emphasized text (_*word*_)."
450 :group 'gnus-article-emphasis)
452 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
453 "Face used for displaying underlined italic emphasized text (_/word/_)."
454 :group 'gnus-article-emphasis)
456 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
457 "Face used for displaying bold italic emphasized text (/*word*/)."
458 :group 'gnus-article-emphasis)
460 (defface gnus-emphasis-underline-bold-italic
461 '((t (:bold t :italic t :underline t)))
462 "Face used for displaying underlined bold italic emphasized text.
463 Example: (_/*word*/_)."
464 :group 'gnus-article-emphasis)
466 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
467 '((t (:strikethru t)))
468 '((t (:strike-through t))))
469 "Face used for displaying strike-through text (-word-)."
470 :group 'gnus-article-emphasis)
472 (defface gnus-emphasis-highlight-words
473 '((t (:background "black" :foreground "yellow")))
474 "Face used for displaying highlighted words."
475 :group 'gnus-article-emphasis)
477 (defcustom gnus-article-time-format "%a, %d %b %Y %T %Z"
478 "Format for display of Date headers in article bodies.
479 See `format-time-string' for the possible values.
481 The variable can also be function, which should return a complete Date
482 header. The function is called with one argument, the time, which can
483 be fed to `format-time-string'."
484 :type '(choice string function)
485 :link '(custom-manual "(gnus)Article Date")
486 :group 'gnus-article-washing)
489 (autoload 'mail-extract-address-components "mail-extr"))
491 (defcustom gnus-save-all-headers t
492 "*If non-nil, don't remove any headers before saving."
493 :group 'gnus-article-saving
496 (defcustom gnus-prompt-before-saving 'always
497 "*This variable says how much prompting is to be done when saving articles.
498 If it is nil, no prompting will be done, and the articles will be
499 saved to the default files. If this variable is `always', each and
500 every article that is saved will be preceded by a prompt, even when
501 saving large batches of articles. If this variable is neither nil not
502 `always', there the user will be prompted once for a file name for
503 each invocation of the saving commands."
504 :group 'gnus-article-saving
505 :type '(choice (item always)
506 (item :tag "never" nil)
507 (sexp :tag "once" :format "%t\n" :value t)))
509 (defcustom gnus-saved-headers gnus-visible-headers
510 "Headers to keep if `gnus-save-all-headers' is nil.
511 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
512 If that variable is nil, however, all headers that match this regexp
513 will be kept while the rest will be deleted before saving."
514 :group 'gnus-article-saving
517 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
518 "A function to save articles in your favourite format.
519 The function must be interactively callable (in other words, it must
520 be an Emacs command).
522 Gnus provides the following functions:
524 * gnus-summary-save-in-rmail (Rmail format)
525 * gnus-summary-save-in-mail (Unix mail format)
526 * gnus-summary-save-in-folder (MH folder)
527 * gnus-summary-save-in-file (article format)
528 * gnus-summary-save-body-in-file (article body)
529 * gnus-summary-save-in-vm (use VM's folder format)
530 * gnus-summary-write-to-file (article format -- overwrite)."
531 :group 'gnus-article-saving
532 :type '(radio (function-item gnus-summary-save-in-rmail)
533 (function-item gnus-summary-save-in-mail)
534 (function-item gnus-summary-save-in-folder)
535 (function-item gnus-summary-save-in-file)
536 (function-item gnus-summary-save-body-in-file)
537 (function-item gnus-summary-save-in-vm)
538 (function-item gnus-summary-write-to-file)))
540 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
541 "A function generating a file name to save articles in Rmail format.
542 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
543 :group 'gnus-article-saving
546 (defcustom gnus-mail-save-name 'gnus-plain-save-name
547 "A function generating a file name to save articles in Unix mail format.
548 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
549 :group 'gnus-article-saving
552 (defcustom gnus-folder-save-name 'gnus-folder-save-name
553 "A function generating a file name to save articles in MH folder.
554 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
555 :group 'gnus-article-saving
558 (defcustom gnus-file-save-name 'gnus-numeric-save-name
559 "A function generating a file name to save articles in article format.
560 The function is called with NEWSGROUP, HEADERS, and optional
562 :group 'gnus-article-saving
565 (defcustom gnus-split-methods
566 '((gnus-article-archive-name)
567 (gnus-article-nndoc-name))
568 "*Variable used to suggest where articles are to be saved.
569 For instance, if you would like to save articles related to Gnus in
570 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
571 you could set this variable to something like:
573 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
574 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
576 This variable is an alist where the key is the match and the
577 value is a list of possible files to save in if the match is
580 If the match is a string, it is used as a regexp match on the
581 article. If the match is a symbol, that symbol will be funcalled
582 from the buffer of the article to be saved with the newsgroup as
583 the parameter. If it is a list, it will be evaled in the same
586 If this form or function returns a string, this string will be
587 used as a possible file name; and if it returns a non-nil list,
588 that list will be used as possible file names."
589 :group 'gnus-article-saving
590 :type '(repeat (choice (list :value (fun) function)
591 (cons :value ("" "") regexp (repeat string))
594 (defcustom gnus-page-delimiter "^\^L"
595 "*Regexp describing what to use as article page delimiters.
596 The default value is \"^\^L\", which is a form linefeed at the
597 beginning of a line."
599 :group 'gnus-article-various)
601 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
602 "*The format specification for the article mode line.
603 See `gnus-summary-mode-line-format' for a closer description.
605 The following additional specs are available:
607 %w The article washing status.
608 %m The number of MIME parts in the article."
610 :group 'gnus-article-various)
612 (defcustom gnus-article-mode-hook nil
613 "*A hook for Gnus article mode."
615 :group 'gnus-article-various)
617 (when (featurep 'xemacs)
618 ;; Extracted from gnus-xmas-define in order to preserve user settings
619 (when (fboundp 'turn-off-scroll-in-place)
620 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
621 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
622 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
624 (defcustom gnus-article-menu-hook nil
625 "*Hook run after the creation of the article mode menu."
627 :group 'gnus-article-various)
629 (defcustom gnus-article-prepare-hook nil
630 "*A hook called after an article has been prepared in the article buffer."
632 :group 'gnus-article-various)
634 (defcustom gnus-copy-article-ignored-headers nil
635 "List of headers to be removed when copying an article.
636 Each element is a regular expression."
637 :version "23.0" ;; No Gnus
638 :type '(repeat regexp)
639 :group 'gnus-article-various)
641 (make-obsolete-variable 'gnus-article-hide-pgp-hook
642 "This variable is obsolete in Gnus 5.10.")
644 (defcustom gnus-article-button-face 'bold
645 "Face used for highlighting buttons in the article buffer.
647 An article button is a piece of text that you can activate by pressing
648 `RET' or `mouse-2' above it."
650 :group 'gnus-article-buttons)
652 (defcustom gnus-article-mouse-face 'highlight
653 "Face used for mouse highlighting in the article buffer.
655 Article buttons will be displayed in this face when the cursor is
658 :group 'gnus-article-buttons)
660 (defcustom gnus-signature-face 'gnus-signature-face
661 "Face used for highlighting a signature in the article buffer.
662 Obsolete; use the face `gnus-signature-face' for customizations instead."
664 :group 'gnus-article-highlight
665 :group 'gnus-article-signature)
667 (defface gnus-signature-face
670 "Face used for highlighting a signature in the article buffer."
671 :group 'gnus-article-highlight
672 :group 'gnus-article-signature)
674 (defface gnus-header-from-face
677 (:foreground "spring green"))
680 (:foreground "red3"))
683 "Face used for displaying from headers."
684 :group 'gnus-article-headers
685 :group 'gnus-article-highlight)
687 (defface gnus-header-subject-face
690 (:foreground "SeaGreen3"))
693 (:foreground "red4"))
695 (:bold t :italic t)))
696 "Face used for displaying subject headers."
697 :group 'gnus-article-headers
698 :group 'gnus-article-highlight)
700 (defface gnus-header-newsgroups-face
703 (:foreground "yellow" :italic t))
706 (:foreground "MidnightBlue" :italic t))
709 "Face used for displaying newsgroups headers.
710 In the default setup this face is only used for crossposted
712 :group 'gnus-article-headers
713 :group 'gnus-article-highlight)
715 (defface gnus-header-name-face
718 (:foreground "SeaGreen"))
721 (:foreground "maroon"))
724 "Face used for displaying header names."
725 :group 'gnus-article-headers
726 :group 'gnus-article-highlight)
728 (defface gnus-header-content-face
731 (:foreground "forest green" :italic t))
734 (:foreground "indianred4" :italic t))
736 (:italic t))) "Face used for displaying header content."
737 :group 'gnus-article-headers
738 :group 'gnus-article-highlight)
740 (defcustom gnus-header-face-alist
741 '(("From" nil gnus-header-from-face)
742 ("Subject" nil gnus-header-subject-face)
743 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
744 ("" gnus-header-name-face gnus-header-content-face))
745 "*Controls highlighting of article headers.
747 An alist of the form (HEADER NAME CONTENT).
749 HEADER is a regular expression which should match the name of a
750 header and NAME and CONTENT are either face names or nil.
752 The name of each header field will be displayed using the face
753 specified by the first element in the list where HEADER matches
754 the header name and NAME is non-nil. Similarly, the content will
755 be displayed by the first non-nil matching CONTENT face."
756 :group 'gnus-article-headers
757 :group 'gnus-article-highlight
758 :type '(repeat (list (regexp :tag "Header")
760 (item :tag "skip" nil)
761 (face :value default))
762 (choice :tag "Content"
763 (item :tag "skip" nil)
764 (face :value default)))))
766 (defcustom gnus-article-decode-hook
767 '(article-decode-charset article-decode-encoded-words
768 article-decode-group-name article-decode-idna-rhs)
769 "*Hook run to decode charsets in articles."
770 :group 'gnus-article-headers
773 (defcustom gnus-display-mime-function 'gnus-display-mime
774 "Function to display MIME articles."
775 :group 'gnus-article-mime
778 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
779 "Function used to decode headers.")
781 (defvar gnus-article-dumbquotes-map
801 "Table for MS-to-Latin1 translation.")
803 (defcustom gnus-ignored-mime-types nil
804 "List of MIME types that should be ignored by Gnus."
806 :group 'gnus-article-mime
807 :type '(repeat regexp))
809 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
810 "List of MIME types that should not be given buttons when rendered inline.
811 See also `gnus-buttonized-mime-types' which may override this variable.
812 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
814 :group 'gnus-article-mime
815 :type '(repeat regexp))
817 (defcustom gnus-buttonized-mime-types nil
818 "List of MIME types that should be given buttons when rendered inline.
819 If set, this variable overrides `gnus-unbuttonized-mime-types'.
820 To see e.g. security buttons you could set this to
821 `(\"multipart/signed\")'.
822 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
824 :group 'gnus-article-mime
825 :type '(repeat regexp))
827 (defcustom gnus-inhibit-mime-unbuttonizing nil
828 "If non-nil, all MIME parts get buttons.
829 When nil (the default value), then some MIME parts do not get buttons,
830 as described by the variables `gnus-buttonized-mime-types' and
831 `gnus-unbuttonized-mime-types'."
833 :group 'gnus-article-mime
836 (defcustom gnus-body-boundary-delimiter "_"
837 "String used to delimit header and body.
838 This variable is used by `gnus-article-treat-body-boundary' which can
839 be controlled by `gnus-treat-body-boundary'."
841 :group 'gnus-article-various
842 :type '(choice (item :tag "None" :value nil)
845 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
847 "Defines the location of the faces database.
848 For information on obtaining this database of pretty pictures, please
849 see http://www.cs.indiana.edu/picons/ftp/index.html"
851 :type '(repeat directory)
852 :link '(url-link :tag "download"
853 "http://www.cs.indiana.edu/picons/ftp/index.html")
854 :link '(custom-manual "(gnus)Picons")
857 (defun gnus-picons-installed-p ()
858 "Say whether picons are installed on your machine."
859 (let ((installed nil))
860 (dolist (database gnus-picon-databases)
861 (when (file-exists-p database)
865 (defcustom gnus-article-mime-part-function nil
866 "Function called with a MIME handle as the argument.
867 This is meant for people who want to do something automatic based
868 on parts -- for instance, adding Vcard info to a database."
869 :group 'gnus-article-mime
872 (defcustom gnus-mime-multipart-functions nil
873 "An alist of MIME types to functions to display them."
875 :group 'gnus-article-mime
876 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
878 (defcustom gnus-article-date-lapsed-new-header nil
879 "Whether the X-Sent and Date headers can coexist.
880 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
881 either replace the old \"Date:\" header (if this variable is nil), or
882 be added below it (otherwise)."
884 :group 'gnus-article-headers
887 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
888 "Function called with a MIME handle as the argument.
889 This is meant for people who want to view first matched part.
890 For `undisplayed-alternative' (default), the first undisplayed
891 part or alternative part is used. For `undisplayed', the first
892 undisplayed part is used. For a function, the first part which
893 the function return t is used. For nil, the first part is
896 :group 'gnus-article-mime
898 (item :tag "first" :value nil)
899 (item :tag "undisplayed" :value undisplayed)
900 (item :tag "undisplayed or alternative"
901 :value undisplayed-alternative)
904 (defcustom gnus-mime-action-alist
905 '(("save to file" . gnus-mime-save-part)
906 ("save and strip" . gnus-mime-save-part-and-strip)
907 ("delete part" . gnus-mime-delete-part)
908 ("display as text" . gnus-mime-inline-part)
909 ("view the part" . gnus-mime-view-part)
910 ("pipe to command" . gnus-mime-pipe-part)
911 ("toggle display" . gnus-article-press-button)
912 ("toggle display" . gnus-article-view-part-as-charset)
913 ("view as type" . gnus-mime-view-part-as-type)
914 ("view internally" . gnus-mime-view-part-internally)
915 ("view externally" . gnus-mime-view-part-externally))
916 "An alist of actions that run on the MIME attachment."
917 :group 'gnus-article-mime
918 :type '(repeat (cons (string :tag "name")
922 ;;; The treatment variables
925 (defvar gnus-part-display-hook nil
926 "Hook called on parts that are to receive treatment.")
928 (defvar gnus-article-treat-custom
929 '(choice (const :tag "Off" nil)
931 (const :tag "Header" head)
932 (const :tag "Last" last)
933 (integer :tag "Less")
934 (repeat :tag "Groups" regexp)
935 (sexp :tag "Predicate")))
937 (defvar gnus-article-treat-head-custom
938 '(choice (const :tag "Off" nil)
939 (const :tag "Header" head)))
941 (defvar gnus-article-treat-types '("text/plain")
944 (defvar gnus-inhibit-treatment nil
945 "Whether to inhibit treatment.")
947 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
948 "Highlight the signature.
949 Valid values are nil, t, `head', `last', an integer or a predicate.
950 See Info node `(gnus)Customizing Articles'."
951 :group 'gnus-article-treat
952 :link '(custom-manual "(gnus)Customizing Articles")
953 :type gnus-article-treat-custom)
954 (put 'gnus-treat-highlight-signature 'highlight t)
956 (defcustom gnus-treat-buttonize 100000
958 Valid values are nil, t, `head', `last', an integer or a predicate.
959 See Info node `(gnus)Customizing Articles'."
960 :group 'gnus-article-treat
961 :link '(custom-manual "(gnus)Customizing Articles")
962 :type gnus-article-treat-custom)
963 (put 'gnus-treat-buttonize 'highlight t)
965 (defcustom gnus-treat-buttonize-head 'head
966 "Add buttons to the head.
967 Valid values are nil, t, `head', `last', an integer or a predicate.
968 See Info node `(gnus)Customizing Articles' for details."
969 :group 'gnus-article-treat
970 :link '(custom-manual "(gnus)Customizing Articles")
971 :type gnus-article-treat-head-custom)
972 (put 'gnus-treat-buttonize-head 'highlight t)
974 (defcustom gnus-treat-emphasize
975 (and (or window-system
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-custom)
984 (put 'gnus-treat-emphasize 'highlight t)
986 (defcustom gnus-treat-strip-cr nil
987 "Remove carriage returns.
988 Valid values are nil, t, `head', `last', an integer or a predicate.
989 See Info node `(gnus)Customizing Articles' for details."
991 :group 'gnus-article-treat
992 :link '(custom-manual "(gnus)Customizing Articles")
993 :type gnus-article-treat-custom)
995 (defcustom gnus-treat-unsplit-urls nil
996 "Remove newlines from within URLs.
997 Valid values are nil, t, `head', `last', an integer or a predicate.
998 See Info node `(gnus)Customizing Articles' for details."
1000 :group 'gnus-article-treat
1001 :link '(custom-manual "(gnus)Customizing Articles")
1002 :type gnus-article-treat-custom)
1004 (defcustom gnus-treat-leading-whitespace nil
1005 "Remove leading whitespace in headers.
1006 Valid values are nil, t, `head', `last', an integer or a predicate.
1007 See Info node `(gnus)Customizing Articles' for details."
1009 :group 'gnus-article-treat
1010 :link '(custom-manual "(gnus)Customizing Articles")
1011 :type gnus-article-treat-custom)
1013 (defcustom gnus-treat-hide-headers 'head
1015 Valid values are nil, t, `head', `last', an integer or a predicate.
1016 See Info node `(gnus)Customizing Articles' for details."
1017 :group 'gnus-article-treat
1018 :link '(custom-manual "(gnus)Customizing Articles")
1019 :type gnus-article-treat-head-custom)
1021 (defcustom gnus-treat-hide-boring-headers nil
1022 "Hide boring headers.
1023 Valid values are nil, t, `head', `last', an integer or a predicate.
1024 See Info node `(gnus)Customizing Articles' for details."
1025 :group 'gnus-article-treat
1026 :link '(custom-manual "(gnus)Customizing Articles")
1027 :type gnus-article-treat-head-custom)
1029 (defcustom gnus-treat-hide-signature nil
1030 "Hide the signature.
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-fill-article nil
1039 Valid values are nil, t, `head', `last', an integer or a predicate.
1040 See Info node `(gnus)Customizing Articles' for details."
1041 :group 'gnus-article-treat
1042 :link '(custom-manual "(gnus)Customizing Articles")
1043 :type gnus-article-treat-custom)
1045 (defcustom gnus-treat-hide-citation nil
1047 Valid values are nil, t, `head', `last', an integer or a predicate.
1048 See Info node `(gnus)Customizing Articles' for details."
1049 :group 'gnus-article-treat
1050 :link '(custom-manual "(gnus)Customizing Articles")
1051 :type gnus-article-treat-custom)
1053 (defcustom gnus-treat-hide-citation-maybe nil
1055 Valid values are nil, t, `head', `last', an integer or a predicate.
1056 See Info node `(gnus)Customizing Articles' for details."
1057 :group 'gnus-article-treat
1058 :link '(custom-manual "(gnus)Customizing Articles")
1059 :type gnus-article-treat-custom)
1061 (defcustom gnus-treat-strip-list-identifiers 'head
1062 "Strip list identifiers from `gnus-list-identifiers`.
1063 Valid values are nil, t, `head', `last', an integer or a predicate.
1064 See Info node `(gnus)Customizing Articles' for details."
1066 :group 'gnus-article-treat
1067 :link '(custom-manual "(gnus)Customizing Articles")
1068 :type gnus-article-treat-custom)
1070 (make-obsolete-variable 'gnus-treat-strip-pgp
1071 "This option is obsolete in Gnus 5.10.")
1073 (defcustom gnus-treat-strip-pem nil
1074 "Strip PEM signatures.
1075 Valid values are nil, t, `head', `last', an integer or a predicate.
1076 See Info node `(gnus)Customizing Articles' for details."
1077 :group 'gnus-article-treat
1078 :link '(custom-manual "(gnus)Customizing Articles")
1079 :type gnus-article-treat-custom)
1081 (defcustom gnus-treat-strip-banner t
1082 "Strip banners from articles.
1083 The banner to be stripped is specified in the `banner' group parameter.
1084 Valid values are nil, t, `head', `last', an integer or a predicate.
1085 See Info node `(gnus)Customizing Articles' for details."
1086 :group 'gnus-article-treat
1087 :link '(custom-manual "(gnus)Customizing Articles")
1088 :type gnus-article-treat-custom)
1090 (defcustom gnus-treat-highlight-headers 'head
1091 "Highlight the headers.
1092 Valid values are nil, t, `head', `last', an integer or a predicate.
1093 See Info node `(gnus)Customizing Articles' for details."
1094 :group 'gnus-article-treat
1095 :link '(custom-manual "(gnus)Customizing Articles")
1096 :type gnus-article-treat-head-custom)
1097 (put 'gnus-treat-highlight-headers 'highlight t)
1099 (defcustom gnus-treat-highlight-citation t
1100 "Highlight cited text.
1101 Valid values are nil, t, `head', `last', an integer or a predicate.
1102 See Info node `(gnus)Customizing Articles' for details."
1103 :group 'gnus-article-treat
1104 :link '(custom-manual "(gnus)Customizing Articles")
1105 :type gnus-article-treat-custom)
1106 (put 'gnus-treat-highlight-citation 'highlight t)
1108 (defcustom gnus-treat-date-ut nil
1109 "Display the Date in UT (GMT).
1110 Valid values are nil, t, `head', `last', an integer or a predicate.
1111 See Info node `(gnus)Customizing Articles' for details."
1112 :group 'gnus-article-treat
1113 :link '(custom-manual "(gnus)Customizing Articles")
1114 :type gnus-article-treat-head-custom)
1116 (defcustom gnus-treat-date-local nil
1117 "Display the Date in the local timezone.
1118 Valid values are nil, t, `head', `last', an integer or a predicate.
1119 See Info node `(gnus)Customizing Articles' for details."
1120 :group 'gnus-article-treat
1121 :link '(custom-manual "(gnus)Customizing Articles")
1122 :type gnus-article-treat-head-custom)
1124 (defcustom gnus-treat-date-english nil
1125 "Display the Date in a format that can be read aloud in English.
1126 Valid values are nil, t, `head', `last', an integer or a predicate.
1127 See Info node `(gnus)Customizing Articles' for details."
1129 :group 'gnus-article-treat
1130 :link '(custom-manual "(gnus)Customizing Articles")
1131 :type gnus-article-treat-head-custom)
1133 (defcustom gnus-treat-date-lapsed nil
1134 "Display the Date header in a way that says how much time has elapsed.
1135 Valid values are nil, t, `head', `last', an integer or a predicate.
1136 See Info node `(gnus)Customizing Articles' for details."
1137 :group 'gnus-article-treat
1138 :link '(custom-manual "(gnus)Customizing Articles")
1139 :type gnus-article-treat-head-custom)
1141 (defcustom gnus-treat-date-original nil
1142 "Display the date in the original timezone.
1143 Valid values are nil, t, `head', `last', an integer or a predicate.
1144 See Info node `(gnus)Customizing Articles' for details."
1145 :group 'gnus-article-treat
1146 :link '(custom-manual "(gnus)Customizing Articles")
1147 :type gnus-article-treat-head-custom)
1149 (defcustom gnus-treat-date-iso8601 nil
1150 "Display the date in the ISO8601 format.
1151 Valid values are nil, t, `head', `last', an integer or a predicate.
1152 See Info node `(gnus)Customizing Articles' for details."
1154 :group 'gnus-article-treat
1155 :link '(custom-manual "(gnus)Customizing Articles")
1156 :type gnus-article-treat-head-custom)
1158 (defcustom gnus-treat-date-user-defined nil
1159 "Display the date in a user-defined format.
1160 The format is defined by the `gnus-article-time-format' variable.
1161 Valid values are nil, t, `head', `last', an integer or a predicate.
1162 See Info node `(gnus)Customizing Articles' for details."
1163 :group 'gnus-article-treat
1164 :link '(custom-manual "(gnus)Customizing Articles")
1165 :type gnus-article-treat-head-custom)
1167 (defcustom gnus-treat-strip-headers-in-body t
1168 "Strip the X-No-Archive header line from the beginning of the body.
1169 Valid values are nil, t, `head', `last', an integer or a predicate.
1170 See Info node `(gnus)Customizing Articles' for details."
1172 :group 'gnus-article-treat
1173 :link '(custom-manual "(gnus)Customizing Articles")
1174 :type gnus-article-treat-custom)
1176 (defcustom gnus-treat-strip-trailing-blank-lines nil
1177 "Strip trailing blank lines.
1178 Valid values are nil, t, `head', `last', an integer or a predicate.
1179 See Info node `(gnus)Customizing Articles' for details."
1180 :group 'gnus-article-treat
1181 :link '(custom-manual "(gnus)Customizing Articles")
1182 :type gnus-article-treat-custom)
1184 (defcustom gnus-treat-strip-leading-blank-lines nil
1185 "Strip leading blank lines.
1186 Valid values are nil, t, `head', `last', an integer or a predicate.
1187 See Info node `(gnus)Customizing Articles' for details."
1188 :group 'gnus-article-treat
1189 :link '(custom-manual "(gnus)Customizing Articles")
1190 :type gnus-article-treat-custom)
1192 (defcustom gnus-treat-strip-multiple-blank-lines nil
1193 "Strip multiple blank lines.
1194 Valid values are nil, t, `head', `last', an integer or a predicate.
1195 See Info node `(gnus)Customizing Articles' for details."
1196 :group 'gnus-article-treat
1197 :link '(custom-manual "(gnus)Customizing Articles")
1198 :type gnus-article-treat-custom)
1200 (defcustom gnus-treat-unfold-headers 'head
1201 "Unfold folded header lines.
1202 Valid values are nil, t, `head', `last', an integer or a predicate.
1203 See Info node `(gnus)Customizing Articles' for details."
1205 :group 'gnus-article-treat
1206 :link '(custom-manual "(gnus)Customizing Articles")
1207 :type gnus-article-treat-custom)
1209 (defcustom gnus-treat-fold-headers nil
1211 Valid values are nil, t, `head', `last', an integer or a predicate.
1212 See Info node `(gnus)Customizing Articles' for details."
1214 :group 'gnus-article-treat
1215 :link '(custom-manual "(gnus)Customizing Articles")
1216 :type gnus-article-treat-custom)
1218 (defcustom gnus-treat-fold-newsgroups 'head
1219 "Fold the Newsgroups and Followup-To headers.
1220 Valid values are nil, t, `head', `last', an integer or a predicate.
1221 See Info node `(gnus)Customizing Articles' for details."
1223 :group 'gnus-article-treat
1224 :link '(custom-manual "(gnus)Customizing Articles")
1225 :type gnus-article-treat-custom)
1227 (defcustom gnus-treat-overstrike t
1228 "Treat overstrike highlighting.
1229 Valid values are nil, t, `head', `last', an integer or a predicate.
1230 See Info node `(gnus)Customizing Articles' for details."
1231 :group 'gnus-article-treat
1232 :link '(custom-manual "(gnus)Customizing Articles")
1233 :type gnus-article-treat-custom)
1234 (put 'gnus-treat-overstrike 'highlight t)
1236 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1237 "Treat ANSI SGR control sequences.
1238 Valid values are nil, t, `head', `last', an integer or a predicate.
1239 See Info node `(gnus)Customizing Articles' for details."
1240 :group 'gnus-article-treat
1241 :link '(custom-manual "(gnus)Customizing Articles")
1242 :type gnus-article-treat-custom)
1244 (make-obsolete-variable 'gnus-treat-display-xface
1245 'gnus-treat-display-x-face)
1247 (defcustom gnus-treat-display-x-face
1248 (and (not noninteractive)
1249 (or (and (fboundp 'image-type-available-p)
1250 (image-type-available-p 'xbm)
1251 (string-match "^0x" (shell-command-to-string "uncompface"))
1252 (executable-find "icontopbm"))
1253 (and (featurep 'xemacs)
1256 "Display X-Face headers.
1257 Valid values are nil, t, `head', `last', an integer or a predicate.
1258 See Info node `(gnus)Customizing Articles' and Info node
1259 `(gnus)X-Face' for details."
1260 :group 'gnus-article-treat
1262 :link '(custom-manual "(gnus)Customizing Articles")
1263 :link '(custom-manual "(gnus)X-Face")
1264 :type gnus-article-treat-head-custom
1265 :set (lambda (symbol value)
1268 (cond ((or (boundp symbol) (get symbol 'saved-value))
1270 ((boundp 'gnus-treat-display-xface)
1272 ** gnus-treat-display-xface is an obsolete variable;\
1273 use gnus-treat-display-x-face instead")
1274 (default-value 'gnus-treat-display-xface))
1275 ((get 'gnus-treat-display-xface 'saved-value)
1277 ** gnus-treat-display-xface is an obsolete variable;\
1278 use gnus-treat-display-x-face instead")
1279 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1282 (put 'gnus-treat-display-x-face 'highlight t)
1284 (defcustom gnus-treat-display-face
1285 (and (not noninteractive)
1286 (or (and (fboundp 'image-type-available-p)
1287 (image-type-available-p 'png))
1288 (and (featurep 'xemacs)
1291 "Display Face headers.
1292 Valid values are nil, t, `head', `last', an integer or a predicate.
1293 See Info node `(gnus)Customizing Articles' and Info node
1294 `(gnus)X-Face' for details."
1295 :group 'gnus-article-treat
1297 :link '(custom-manual "(gnus)Customizing Articles")
1298 :link '(custom-manual "(gnus)X-Face")
1299 :type gnus-article-treat-head-custom)
1300 (put 'gnus-treat-display-face 'highlight t)
1302 (defcustom gnus-treat-display-smileys
1303 (if (or (and (featurep 'xemacs)
1305 (and (fboundp 'image-type-available-p)
1306 (image-type-available-p 'pbm)))
1309 Valid values are nil, t, `head', `last', an integer or a predicate.
1310 See Info node `(gnus)Customizing Articles' and Info node
1311 `(gnus)Smileys' for details."
1312 :group 'gnus-article-treat
1314 :link '(custom-manual "(gnus)Customizing Articles")
1315 :link '(custom-manual "(gnus)Smileys")
1316 :type gnus-article-treat-custom)
1317 (put 'gnus-treat-display-smileys 'highlight t)
1319 (defcustom gnus-treat-from-picon
1320 (if (and (gnus-image-type-available-p 'xpm)
1321 (gnus-picons-installed-p))
1323 "Display picons in the From header.
1324 Valid values are nil, t, `head', `last', an integer or a predicate.
1325 See Info node `(gnus)Customizing Articles' and Info node
1326 `(gnus)Picons' for details."
1328 :group 'gnus-article-treat
1330 :link '(custom-manual "(gnus)Customizing Articles")
1331 :link '(custom-manual "(gnus)Picons")
1332 :type gnus-article-treat-head-custom)
1333 (put 'gnus-treat-from-picon 'highlight t)
1335 (defcustom gnus-treat-mail-picon
1336 (if (and (gnus-image-type-available-p 'xpm)
1337 (gnus-picons-installed-p))
1339 "Display picons in To and Cc headers.
1340 Valid values are nil, t, `head', `last', an integer or a predicate.
1341 See Info node `(gnus)Customizing Articles' and Info node
1342 `(gnus)Picons' for details."
1344 :group 'gnus-article-treat
1346 :link '(custom-manual "(gnus)Customizing Articles")
1347 :link '(custom-manual "(gnus)Picons")
1348 :type gnus-article-treat-head-custom)
1349 (put 'gnus-treat-mail-picon 'highlight t)
1351 (defcustom gnus-treat-newsgroups-picon
1352 (if (and (gnus-image-type-available-p 'xpm)
1353 (gnus-picons-installed-p))
1355 "Display picons in the Newsgroups and Followup-To headers.
1356 Valid values are nil, t, `head', `last', an integer or a predicate.
1357 See Info node `(gnus)Customizing Articles' and Info node
1358 `(gnus)Picons' for details."
1360 :group 'gnus-article-treat
1362 :link '(custom-manual "(gnus)Customizing Articles")
1363 :link '(custom-manual "(gnus)Picons")
1364 :type gnus-article-treat-head-custom)
1365 (put 'gnus-treat-newsgroups-picon 'highlight t)
1367 (defcustom gnus-treat-body-boundary
1368 (if (and (eq window-system 'x)
1369 (or gnus-treat-newsgroups-picon
1370 gnus-treat-mail-picon
1371 gnus-treat-from-picon))
1373 "Draw a boundary at the end of the headers.
1374 Valid values are nil and `head'.
1375 See Info node `(gnus)Customizing Articles' for details."
1377 :group 'gnus-article-treat
1378 :link '(custom-manual "(gnus)Customizing Articles")
1379 :type gnus-article-treat-head-custom)
1381 (defcustom gnus-treat-capitalize-sentences nil
1382 "Capitalize sentence-starting words.
1383 Valid values are nil, t, `head', `last', an integer or a predicate.
1384 See Info node `(gnus)Customizing Articles' for details."
1386 :group 'gnus-article-treat
1387 :link '(custom-manual "(gnus)Customizing Articles")
1388 :type gnus-article-treat-custom)
1390 (defcustom gnus-treat-wash-html nil
1392 Valid values are nil, t, `head', `last', an integer or a predicate.
1393 See Info node `(gnus)Customizing Articles' for details."
1395 :group 'gnus-article-treat
1396 :link '(custom-manual "(gnus)Customizing Articles")
1397 :type gnus-article-treat-custom)
1399 (defcustom gnus-treat-fill-long-lines nil
1401 Valid values are nil, t, `head', `last', an integer or a predicate.
1402 See Info node `(gnus)Customizing Articles' for details."
1403 :group 'gnus-article-treat
1404 :link '(custom-manual "(gnus)Customizing Articles")
1405 :type gnus-article-treat-custom)
1407 (defcustom gnus-treat-play-sounds nil
1409 Valid values are nil, t, `head', `last', an integer or a predicate.
1410 See Info node `(gnus)Customizing Articles' for details."
1412 :group 'gnus-article-treat
1413 :link '(custom-manual "(gnus)Customizing Articles")
1414 :type gnus-article-treat-custom)
1416 (defcustom gnus-treat-translate nil
1417 "Translate articles from one language to another.
1418 Valid values are nil, t, `head', `last', an integer or a predicate.
1419 See Info node `(gnus)Customizing Articles' for details."
1421 :group 'gnus-article-treat
1422 :link '(custom-manual "(gnus)Customizing Articles")
1423 :type gnus-article-treat-custom)
1425 (defcustom gnus-treat-x-pgp-sig nil
1427 To automatically treat X-PGP-Sig, set it to head.
1428 Valid values are nil, t, `head', `last', an integer or a predicate.
1429 See Info node `(gnus)Customizing Articles' for details."
1431 :group 'gnus-article-treat
1432 :group 'mime-security
1433 :link '(custom-manual "(gnus)Customizing Articles")
1434 :type gnus-article-treat-custom)
1436 (defvar gnus-article-encrypt-protocol-alist
1437 '(("PGP" . mml2015-self-encrypt)))
1439 ;; Set to nil if more than one protocol added to
1440 ;; gnus-article-encrypt-protocol-alist.
1441 (defcustom gnus-article-encrypt-protocol "PGP"
1442 "The protocol used for encrypt articles.
1443 It is a string, such as \"PGP\". If nil, ask user."
1446 :group 'mime-security)
1448 (defvar gnus-article-wash-function nil
1449 "Function used for converting HTML into text.")
1451 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1452 (mm-coding-system-p 'utf-8)
1453 (executable-find idna-program))
1454 "Whether IDNA decoding of headers is used when viewing messages.
1455 This requires GNU Libidn, and by default only enabled if it is found."
1457 :group 'gnus-article-headers
1460 (defcustom gnus-article-over-scroll nil
1461 "If non-nil, allow scrolling the article buffer even when there no more text."
1463 :group 'gnus-article
1466 ;;; Internal variables
1468 (defvar gnus-english-month-names
1469 '("January" "February" "March" "April" "May" "June" "July" "August"
1470 "September" "October" "November" "December"))
1472 (defvar gnus-button-regexp nil)
1473 (defvar gnus-button-marker-list nil)
1474 ;; Regexp matching any of the regexps from `gnus-button-alist'.
1476 (defvar gnus-button-last nil)
1477 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
1479 (defvar article-goto-body-goes-to-point-min-p nil)
1480 (defvar gnus-article-wash-types nil)
1481 (defvar gnus-article-emphasis-alist nil)
1482 (defvar gnus-article-image-alist nil)
1484 (defvar gnus-article-mime-handle-alist-1 nil)
1485 (defvar gnus-treatment-function-alist
1486 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1487 (gnus-treat-strip-banner gnus-article-strip-banner)
1488 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1489 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1490 (gnus-treat-buttonize gnus-article-add-buttons)
1491 (gnus-treat-fill-article gnus-article-fill-cited-article)
1492 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1493 (gnus-treat-strip-cr gnus-article-remove-cr)
1494 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1495 (gnus-treat-date-ut gnus-article-date-ut)
1496 (gnus-treat-date-local gnus-article-date-local)
1497 (gnus-treat-date-english gnus-article-date-english)
1498 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1499 (gnus-treat-date-original gnus-article-date-original)
1500 (gnus-treat-date-user-defined gnus-article-date-user)
1501 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1502 (gnus-treat-display-x-face gnus-article-display-x-face)
1503 (gnus-treat-display-face gnus-article-display-face)
1504 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1505 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1506 (gnus-treat-hide-signature gnus-article-hide-signature)
1507 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1508 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1509 (gnus-treat-strip-pem gnus-article-hide-pem)
1510 (gnus-treat-from-picon gnus-treat-from-picon)
1511 (gnus-treat-mail-picon gnus-treat-mail-picon)
1512 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1513 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1514 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1515 (gnus-treat-strip-trailing-blank-lines
1516 gnus-article-remove-trailing-blank-lines)
1517 (gnus-treat-strip-leading-blank-lines
1518 gnus-article-strip-leading-blank-lines)
1519 (gnus-treat-strip-multiple-blank-lines
1520 gnus-article-strip-multiple-blank-lines)
1521 (gnus-treat-overstrike gnus-article-treat-overstrike)
1522 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1523 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1524 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1525 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1526 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1527 (gnus-treat-display-smileys gnus-treat-smiley)
1528 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1529 (gnus-treat-wash-html gnus-article-wash-html)
1530 (gnus-treat-emphasize gnus-article-emphasize)
1531 (gnus-treat-hide-citation gnus-article-hide-citation)
1532 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1533 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1534 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1535 (gnus-treat-play-sounds gnus-earcon-display)))
1537 (defvar gnus-article-mime-handle-alist nil)
1538 (defvar article-lapsed-timer nil)
1539 (defvar gnus-article-current-summary nil)
1541 (defvar gnus-article-mode-syntax-table
1542 (let ((table (copy-syntax-table text-mode-syntax-table)))
1543 ;; This causes the citation match run O(2^n).
1544 ;; (modify-syntax-entry ?- "w" table)
1545 (modify-syntax-entry ?> ")<" table)
1546 (modify-syntax-entry ?< "(>" table)
1547 ;; make M-. in article buffers work for `foo' strings
1548 (modify-syntax-entry ?' " " table)
1549 (modify-syntax-entry ?` " " table)
1551 "Syntax table used in article mode buffers.
1552 Initialized from `text-mode-syntax-table.")
1554 (defvar gnus-save-article-buffer nil)
1556 (defvar gnus-article-mode-line-format-alist
1557 (nconc '((?w (gnus-article-wash-status) ?s)
1558 (?m (gnus-article-mime-part-status) ?s))
1559 gnus-summary-mode-line-format-alist))
1561 (defvar gnus-number-of-articles-to-be-saved nil)
1563 (defvar gnus-inhibit-hiding nil)
1565 (defvar gnus-article-edit-mode nil)
1567 ;;; Macros for dealing with the article buffer.
1569 (defmacro gnus-with-article-headers (&rest forms)
1571 (set-buffer gnus-article-buffer)
1573 (let ((inhibit-read-only t)
1574 (inhibit-point-motion-hooks t)
1575 (case-fold-search t))
1576 (article-narrow-to-head)
1579 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1580 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1582 (defmacro gnus-with-article-buffer (&rest forms)
1584 (set-buffer gnus-article-buffer)
1585 (let ((inhibit-read-only t))
1588 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1589 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1591 (defun gnus-article-goto-header (header)
1592 "Go to HEADER, which is a regular expression."
1593 (re-search-forward (concat "^\\(" header "\\):") nil t))
1595 (defsubst gnus-article-hide-text (b e props)
1596 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1597 (gnus-add-text-properties-when 'article-type nil b e props)
1598 (when (memq 'intangible props)
1600 (max (1- b) (point-min))
1601 b 'intangible (cddr (memq 'intangible props)))))
1603 (defsubst gnus-article-unhide-text (b e)
1604 "Remove hidden text properties from region between B and E."
1605 (remove-text-properties b e gnus-hidden-properties)
1606 (when (memq 'intangible gnus-hidden-properties)
1607 (put-text-property (max (1- b) (point-min))
1608 b 'intangible nil)))
1610 (defun gnus-article-hide-text-type (b e type)
1611 "Hide text of TYPE between B and E."
1612 (gnus-add-wash-type type)
1613 (gnus-article-hide-text
1614 b e (cons 'article-type (cons type gnus-hidden-properties))))
1616 (defun gnus-article-unhide-text-type (b e type)
1617 "Unhide text of TYPE between B and E."
1618 (gnus-delete-wash-type type)
1619 (remove-text-properties
1620 b e (cons 'article-type (cons type gnus-hidden-properties)))
1621 (when (memq 'intangible gnus-hidden-properties)
1622 (put-text-property (max (1- b) (point-min))
1623 b 'intangible nil)))
1625 (defun gnus-article-hide-text-of-type (type)
1626 "Hide text of TYPE in the current buffer."
1628 (let ((b (point-min))
1630 (while (setq b (text-property-any b e 'article-type type))
1631 (add-text-properties b (incf b) gnus-hidden-properties)))))
1633 (defun gnus-article-delete-text-of-type (type)
1634 "Delete text of TYPE in the current buffer."
1636 (let ((b (point-min)))
1637 (while (setq b (text-property-any b (point-max) 'article-type type))
1639 b (or (text-property-not-all b (point-max) 'article-type type)
1642 (defun gnus-article-delete-invisible-text ()
1643 "Delete all invisible text in the current buffer."
1645 (let ((b (point-min)))
1646 (while (setq b (text-property-any b (point-max) 'invisible t))
1648 b (or (text-property-not-all b (point-max) 'invisible t)
1651 (defun gnus-article-text-type-exists-p (type)
1652 "Say whether any text of type TYPE exists in the buffer."
1653 (text-property-any (point-min) (point-max) 'article-type type))
1655 (defsubst gnus-article-header-rank ()
1656 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1657 (let ((list gnus-sorted-header-list)
1660 (if (looking-at (car list))
1662 (setq list (cdr list))
1666 (defun article-hide-headers (&optional arg delete)
1667 "Hide unwanted headers and possibly sort them as well."
1669 ;; This function might be inhibited.
1670 (unless gnus-inhibit-hiding
1671 (let ((inhibit-read-only nil)
1672 (case-fold-search t)
1673 (max (1+ (length gnus-sorted-header-list)))
1674 (inhibit-point-motion-hooks t)
1675 (cur (current-buffer))
1676 ignored visible beg)
1678 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1679 ;; group parameters, so we should go to the summary buffer.
1682 (progn (set-buffer gnus-summary-buffer) t)
1684 (setq ignored (when (not gnus-visible-headers)
1685 (cond ((stringp gnus-ignored-headers)
1686 gnus-ignored-headers)
1687 ((listp gnus-ignored-headers)
1688 (mapconcat 'identity
1689 gnus-ignored-headers
1691 visible (cond ((stringp gnus-visible-headers)
1692 gnus-visible-headers)
1693 ((and gnus-visible-headers
1694 (listp gnus-visible-headers))
1695 (mapconcat 'identity
1696 gnus-visible-headers
1700 ;; First we narrow to just the headers.
1701 (article-narrow-to-head)
1702 ;; Hide any "From " lines at the beginning of (mail) articles.
1703 (while (looking-at "From ")
1706 (delete-region (point-min) (point)))
1707 ;; Then treat the rest of the header lines.
1708 ;; Then we use the two regular expressions
1709 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1710 ;; select which header lines is to remain visible in the
1712 (while (re-search-forward "^[^ \t:]*:" nil t)
1714 ;; Mark the rank of the header.
1716 (point) (1+ (point)) 'message-rank
1717 (if (or (and visible (looking-at visible))
1719 (not (looking-at ignored))))
1720 (gnus-article-header-rank)
1723 (message-sort-headers-1)
1724 (when (setq beg (text-property-any
1725 (point-min) (point-max) 'message-rank (+ 2 max)))
1726 ;; We delete the unwanted headers.
1727 (gnus-add-wash-type 'headers)
1728 (add-text-properties (point-min) (+ 5 (point-min))
1729 '(article-type headers dummy-invisible t))
1730 (delete-region beg (point-max))))))))
1732 (defun article-hide-boring-headers (&optional arg)
1733 "Toggle hiding of headers that aren't very interesting.
1734 If given a negative prefix, always show; if given a positive prefix,
1736 (interactive (gnus-article-hidden-arg))
1737 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1738 (not gnus-show-all-headers))
1741 (let ((inhibit-read-only t)
1742 (inhibit-point-motion-hooks t))
1743 (article-narrow-to-head)
1744 (dolist (elem gnus-boring-article-headers)
1745 (goto-char (point-min))
1747 ;; Hide empty headers.
1749 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1751 (gnus-article-hide-text-type
1755 (if (re-search-forward "^[^ \t]" nil t)
1759 ;; Hide boring Newsgroups header.
1760 ((eq elem 'newsgroups)
1761 (when (gnus-string-equal
1762 (gnus-fetch-field "newsgroups")
1763 (gnus-group-real-name
1764 (if (boundp 'gnus-newsgroup-name)
1767 (gnus-article-hide-header "newsgroups")))
1768 ((eq elem 'to-address)
1769 (let ((to (message-fetch-field "to"))
1771 (gnus-parameter-to-address
1772 (if (boundp 'gnus-newsgroup-name)
1773 gnus-newsgroup-name ""))))
1774 (when (and to to-address
1777 ;; only one address in To
1778 (nth 1 (mail-extract-address-components to))
1780 (gnus-article-hide-header "to"))))
1782 (let ((to (message-fetch-field "to"))
1784 (gnus-parameter-to-list
1785 (if (boundp 'gnus-newsgroup-name)
1786 gnus-newsgroup-name ""))))
1787 (when (and to to-list
1790 ;; only one address in To
1791 (nth 1 (mail-extract-address-components to))
1793 (gnus-article-hide-header "to"))))
1795 (let ((cc (message-fetch-field "cc"))
1797 (gnus-parameter-to-list
1798 (if (boundp 'gnus-newsgroup-name)
1799 gnus-newsgroup-name ""))))
1800 (when (and cc to-list
1803 ;; only one address in CC
1804 (nth 1 (mail-extract-address-components cc))
1806 (gnus-article-hide-header "cc"))))
1807 ((eq elem 'followup-to)
1808 (when (gnus-string-equal
1809 (message-fetch-field "followup-to")
1810 (message-fetch-field "newsgroups"))
1811 (gnus-article-hide-header "followup-to")))
1812 ((eq elem 'reply-to)
1813 (if (gnus-group-find-parameter
1814 gnus-newsgroup-name 'broken-reply-to)
1815 (gnus-article-hide-header "reply-to")
1816 (let ((from (message-fetch-field "from"))
1817 (reply-to (message-fetch-field "reply-to")))
1824 (lambda (x) (downcase (cadr x)))
1825 (mail-extract-address-components from t))
1828 (lambda (x) (downcase (cadr x)))
1829 (mail-extract-address-components reply-to t))
1831 (gnus-article-hide-header "reply-to")))))
1833 (let ((date (message-fetch-field "date")))
1835 (< (days-between (current-time-string) date)
1837 (gnus-article-hide-header "date"))))
1839 (let ((to (message-fetch-field "to"))
1840 (cc (message-fetch-field "cc")))
1841 (when (> (length to) 1024)
1842 (gnus-article-hide-header "to"))
1843 (when (> (length cc) 1024)
1844 (gnus-article-hide-header "cc"))))
1848 (goto-char (point-min))
1849 (while (re-search-forward "^to:" nil t)
1850 (setq to-count (1+ to-count)))
1851 (when (> to-count 1)
1852 (while (> to-count 0)
1853 (goto-char (point-min))
1855 (re-search-forward "^to:" nil nil to-count)
1857 (narrow-to-region (point) (point-max))
1858 (gnus-article-hide-header "to"))
1859 (setq to-count (1- to-count))))
1860 (goto-char (point-min))
1861 (while (re-search-forward "^cc:" nil t)
1862 (setq cc-count (1+ cc-count)))
1863 (when (> cc-count 1)
1864 (while (> cc-count 0)
1865 (goto-char (point-min))
1867 (re-search-forward "^cc:" nil nil cc-count)
1869 (narrow-to-region (point) (point-max))
1870 (gnus-article-hide-header "cc"))
1871 (setq cc-count (1- cc-count)))))))))))))
1873 (defun gnus-article-hide-header (header)
1875 (goto-char (point-min))
1876 (when (re-search-forward (concat "^" header ":") nil t)
1877 (gnus-article-hide-text-type
1881 (if (re-search-forward "^[^ \t]" nil t)
1886 (defvar gnus-article-normalized-header-length 40
1887 "Length of normalized headers.")
1889 (defun article-normalize-headers ()
1890 "Make all header lines 40 characters long."
1892 (let ((inhibit-read-only t)
1896 (article-narrow-to-head)
1899 ((< (setq column (- (point-at-eol) (point)))
1900 gnus-article-normalized-header-length)
1902 (insert (make-string
1903 (- gnus-article-normalized-header-length column)
1905 ((> column gnus-article-normalized-header-length)
1906 (gnus-put-text-property
1908 (forward-char gnus-article-normalized-header-length)
1915 (forward-line 1))))))
1917 (defun article-treat-dumbquotes ()
1918 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
1919 Note that this function guesses whether a character is a sm*rtq**t* or
1920 not, so it should only be used interactively.
1922 Sm*rtq**t*s are M****s***'s unilateral extension to the
1923 iso-8859-1 character map in an attempt to provide more quoting
1924 characters. If you see something like \\222 or \\264 where
1925 you're expecting some kind of apostrophe or quotation mark, then
1928 (article-translate-strings gnus-article-dumbquotes-map))
1930 (defun article-translate-characters (from to)
1931 "Translate all characters in the body of the article according to FROM and TO.
1932 FROM is a string of characters to translate from; to is a string of
1933 characters to translate to."
1935 (when (article-goto-body)
1936 (let ((inhibit-read-only t)
1937 (x (make-string 225 ?x))
1939 (while (< (incf i) (length x))
1942 (while (< i (length from))
1943 (aset x (aref from i) (aref to i))
1945 (translate-region (point) (point-max) x)))))
1947 (defun article-translate-strings (map)
1948 "Translate all string in the body of the article according to MAP.
1949 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1951 (when (article-goto-body)
1952 (let ((inhibit-read-only t))
1955 (while (search-forward (car elem) nil t)
1956 (replace-match (cadr elem)))))))))
1958 (defun article-treat-overstrike ()
1959 "Translate overstrikes into bold text."
1962 (when (article-goto-body)
1963 (let ((inhibit-read-only t))
1964 (while (search-forward "\b" nil t)
1965 (let ((next (char-after))
1966 (previous (char-after (- (point) 2))))
1967 ;; We do the boldification/underlining by hiding the
1968 ;; overstrikes and putting the proper text property
1972 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1973 (put-text-property (point) (1+ (point)) 'face 'bold))
1975 (gnus-article-hide-text-type
1976 (1- (point)) (1+ (point)) 'overstrike)
1978 (- (point) 2) (1- (point)) 'face 'underline))
1980 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1982 (point) (1+ (point)) 'face 'underline)))))))))
1984 (defun article-treat-ansi-sequences ()
1985 "Translate ANSI SGR control sequences into overlays or extents."
1988 (when (article-goto-body)
1989 (let ((inhibit-read-only t))
1990 (ansi-color-apply-on-region (point) (point-max))))))
1992 (defun gnus-article-treat-unfold-headers ()
1993 "Unfold folded message headers.
1994 Only the headers that fit into the current window width will be
1997 (gnus-with-article-headers
2001 (mail-header-narrow-to-field)
2002 (let ((header (buffer-string)))
2005 (goto-char (point-min))
2006 (while (re-search-forward "\n[\t ]" nil t)
2007 (replace-match " " t t)))
2008 (setq length (- (point-max) (point-min) 1)))
2009 (when (< length (window-width))
2010 (while (re-search-forward "\n[\t ]" nil t)
2011 (replace-match " " t t)))
2012 (goto-char (point-max)))))))
2014 (defun gnus-article-treat-fold-headers ()
2015 "Fold message headers."
2017 (gnus-with-article-headers
2020 (mail-header-narrow-to-field)
2021 (mail-header-fold-field)
2022 (goto-char (point-max))))))
2024 (defun gnus-treat-smiley ()
2025 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2027 (gnus-with-article-buffer
2028 (if (memq 'smiley gnus-article-wash-types)
2029 (gnus-delete-images 'smiley)
2031 (let ((images (smiley-region (point) (point-max))))
2033 (gnus-add-wash-type 'smiley)
2034 (dolist (image images)
2035 (gnus-add-image 'smiley image)))))))
2037 (defun gnus-article-remove-images ()
2038 "Remove all images from the article buffer."
2040 (gnus-with-article-buffer
2041 (dolist (elem gnus-article-image-alist)
2042 (gnus-delete-images (car elem)))))
2044 (defun gnus-article-treat-fold-newsgroups ()
2045 "Unfold folded message headers.
2046 Only the headers that fit into the current window width will be
2049 (gnus-with-article-headers
2050 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2052 (mail-header-narrow-to-field)
2053 (while (re-search-forward ", *" nil t)
2054 (replace-match ", " t t))
2055 (mail-header-fold-field)
2056 (goto-char (point-max))))))
2058 (defun gnus-article-treat-body-boundary ()
2059 "Place a boundary line at the end of the headers."
2061 (when (and gnus-body-boundary-delimiter
2062 (> (length gnus-body-boundary-delimiter) 0))
2063 (gnus-with-article-headers
2064 (goto-char (point-max))
2065 (let ((start (point)))
2066 (insert "X-Boundary: ")
2067 (gnus-add-text-properties start (point) '(invisible t intangible t))
2069 (while (>= (1- (window-width)) (length str))
2070 (setq str (concat str gnus-body-boundary-delimiter)))
2071 (substring str 0 (1- (window-width))))
2073 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2075 (defun article-fill-long-lines ()
2076 "Fill lines that are wider than the window width."
2079 (let ((inhibit-read-only t)
2080 (width (window-width (get-buffer-window (current-buffer)))))
2083 (let ((adaptive-fill-mode nil)) ;Why? -sm
2086 (when (>= (current-column) (min fill-column width))
2087 (narrow-to-region (min (1+ (point)) (point-max))
2089 (let ((goback (point-marker)))
2090 (fill-paragraph nil)
2091 (goto-char (marker-position goback)))
2093 (forward-line 1)))))))
2095 (defun article-capitalize-sentences ()
2096 "Capitalize the first word in each sentence."
2099 (let ((inhibit-read-only t)
2100 (paragraph-start "^[\n\^L]"))
2104 (forward-sentence)))))
2106 (defun article-remove-cr ()
2107 "Remove trailing CRs and then translate remaining CRs into LFs."
2110 (let ((inhibit-read-only t))
2111 (goto-char (point-min))
2112 (while (re-search-forward "\r+$" nil t)
2113 (replace-match "" t t))
2114 (goto-char (point-min))
2115 (while (search-forward "\r" nil t)
2116 (replace-match "\n" t t)))))
2118 (defun article-remove-trailing-blank-lines ()
2119 "Remove all trailing blank lines from the article."
2122 (let ((inhibit-read-only t))
2123 (goto-char (point-max))
2127 (while (and (not (bobp))
2128 (looking-at "^[ \t]*$")
2129 (not (gnus-annotation-in-region-p
2130 (point) (point-at-eol))))
2136 (defvar gnus-face-properties-alist))
2138 (defun article-display-face ()
2139 "Display any Face headers in the header."
2141 (let ((wash-face-p buffer-read-only))
2142 (gnus-with-article-headers
2143 ;; When displaying parts, this function can be called several times on
2144 ;; the same article, without any intended toggle semantic (as typing `W
2145 ;; D d' would have). So face deletion must occur only when we come from
2146 ;; an interactive command, that is when the *Article* buffer is
2148 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2149 (gnus-delete-images 'face)
2152 (when (and wash-face-p
2154 (goto-char (point-min))
2155 (not (re-search-forward "^Face:[\t ]*" nil t)))
2156 (gnus-buffer-live-p gnus-original-article-buffer))
2157 (set-buffer gnus-original-article-buffer))
2159 (mail-narrow-to-head)
2160 (while (gnus-article-goto-header "Face")
2161 (setq faces (nconc faces (list (mail-header-field-value)))))))
2162 (dolist (face faces)
2163 (let ((png (gnus-convert-face-to-png face))
2167 (apply 'gnus-create-image png 'png t
2168 (cdr (assq 'png gnus-face-properties-alist))))
2169 (gnus-article-goto-header "from")
2171 (insert "From: [no `from' set]\n")
2173 (gnus-add-wash-type 'face)
2174 (gnus-add-image 'face image)
2175 (gnus-put-image image nil 'face))))))
2178 (defun article-display-x-face (&optional force)
2179 "Look for an X-Face header and display it if present."
2180 (interactive (list 'force))
2181 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2182 (gnus-with-article-headers
2183 ;; Delete the old process, if any.
2184 (when (process-status "article-x-face")
2185 (delete-process "article-x-face"))
2186 ;; See the comment in `article-display-face'.
2187 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2188 ;; We have already displayed X-Faces, so we remove them
2190 (gnus-delete-images 'xface)
2192 (let (x-faces from face)
2194 (when (and wash-face-p
2196 (goto-char (point-min))
2197 (not (re-search-forward
2198 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2199 (gnus-buffer-live-p gnus-original-article-buffer))
2200 ;; If type `W f', use gnus-original-article-buffer,
2201 ;; otherwise use the current buffer because displaying
2202 ;; RFC822 parts calls this function too.
2203 (set-buffer gnus-original-article-buffer))
2205 (mail-narrow-to-head)
2206 (while (gnus-article-goto-header "X-Face")
2207 (push (mail-header-field-value) x-faces))
2208 (setq from (message-fetch-field "from"))))
2209 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2210 ;; single external face.
2211 (when (stringp gnus-article-x-face-command)
2212 (setq x-faces (list (car x-faces))))
2213 (while (and (setq face (pop x-faces))
2214 gnus-article-x-face-command
2216 ;; Check whether this face is censored.
2217 (not gnus-article-x-face-too-ugly)
2218 (and gnus-article-x-face-too-ugly from
2219 (not (string-match gnus-article-x-face-too-ugly
2221 ;; We display the face.
2222 (cond ((stringp gnus-article-x-face-command)
2223 ;; The command is a string, so we interpret the command
2224 ;; as a, well, command, and fork it off.
2225 (let ((process-connection-type nil))
2226 (process-kill-without-query
2228 "article-x-face" nil shell-file-name
2229 shell-command-switch gnus-article-x-face-command))
2232 (process-send-region "article-x-face"
2233 (point-min) (point-max)))
2234 (process-send-eof "article-x-face")))
2235 ((functionp gnus-article-x-face-command)
2236 ;; The command is a lisp function, so we call it.
2237 (funcall gnus-article-x-face-command face))
2239 (error "%s is not a function"
2240 gnus-article-x-face-command)))))))))
2242 (defun article-decode-mime-words ()
2243 "Decode all MIME-encoded words in the article."
2245 (gnus-with-article-buffer
2246 (let ((inhibit-point-motion-hooks t)
2247 (mail-parse-charset gnus-newsgroup-charset)
2248 (mail-parse-ignored-charsets
2249 (with-current-buffer gnus-summary-buffer
2250 gnus-newsgroup-ignored-charsets)))
2251 (mail-decode-encoded-word-region (point-min) (point-max)))))
2253 (defun article-decode-charset (&optional prompt)
2254 "Decode charset-encoded text in the article.
2255 If PROMPT (the prefix), prompt for a coding system to use."
2257 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2258 (inhibit-read-only t)
2259 (mail-parse-charset gnus-newsgroup-charset)
2260 (mail-parse-ignored-charsets
2261 (save-excursion (condition-case nil
2262 (set-buffer gnus-summary-buffer)
2264 gnus-newsgroup-ignored-charsets))
2265 ct cte ctl charset format)
2268 (article-narrow-to-head)
2269 (setq ct (message-fetch-field "Content-Type" t)
2270 cte (message-fetch-field "Content-Transfer-Encoding" t)
2271 ctl (and ct (ignore-errors
2272 (mail-header-parse-content-type ct)))
2275 (mm-read-coding-system "Charset to decode: "))
2277 (mail-content-type-get ctl 'charset)))
2278 format (and ctl (mail-content-type-get ctl 'format)))
2280 (setq cte (mail-header-strip cte)))
2281 (if (and ctl (not (string-match "/" (car ctl))))
2283 (goto-char (point-max)))
2286 (narrow-to-region (point) (point-max))
2287 (when (and (eq mail-parse-charset 'gnus-decoded)
2288 (eq (mm-body-7-or-8) '8bit))
2289 ;; The text code could have been decoded.
2290 (setq charset mail-parse-charset))
2291 (when (and (or (not ctl)
2292 (equal (car ctl) "text/plain"))
2293 (not format)) ;; article with format will decode later.
2295 charset (and cte (intern (downcase
2296 (gnus-strip-whitespace cte))))
2299 (defun article-decode-encoded-words ()
2300 "Remove encoded-word encoding from headers."
2301 (let ((inhibit-point-motion-hooks t)
2302 (mail-parse-charset gnus-newsgroup-charset)
2303 (mail-parse-ignored-charsets
2304 (save-excursion (condition-case nil
2305 (set-buffer gnus-summary-buffer)
2307 gnus-newsgroup-ignored-charsets))
2308 (inhibit-read-only t))
2310 (article-narrow-to-head)
2311 (funcall gnus-decode-header-function (point-min) (point-max)))))
2313 (defun article-decode-group-name ()
2314 "Decode group names in `Newsgroups:'."
2315 (let ((inhibit-point-motion-hooks t)
2316 (inhibit-read-only t)
2317 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2318 (when (and (or gnus-group-name-charset-method-alist
2319 gnus-group-name-charset-group-alist)
2320 (gnus-buffer-live-p gnus-original-article-buffer))
2322 (article-narrow-to-head)
2323 (with-current-buffer gnus-original-article-buffer
2324 (goto-char (point-min)))
2325 (while (re-search-forward
2326 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2327 (replace-match (save-match-data
2328 (gnus-decode-newsgroups
2329 ;; XXX how to use data in article buffer?
2330 (with-current-buffer gnus-original-article-buffer
2332 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2335 gnus-newsgroup-name method))
2337 (goto-char (point-min))
2338 (with-current-buffer gnus-original-article-buffer
2339 (goto-char (point-min)))
2340 (while (re-search-forward
2341 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2342 (replace-match (save-match-data
2343 (gnus-decode-newsgroups
2344 ;; XXX how to use data in article buffer?
2345 (with-current-buffer gnus-original-article-buffer
2347 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2350 gnus-newsgroup-name method))
2353 (autoload 'idna-to-unicode "idna")
2355 (defun article-decode-idna-rhs ()
2356 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2359 (let ((inhibit-point-motion-hooks t)
2360 (inhibit-read-only t))
2361 (article-narrow-to-head)
2362 (goto-char (point-min))
2363 (while (re-search-forward "@.*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2365 (when (save-match-data
2366 (and (setq ace (match-string 1))
2368 (and (re-search-backward "^[^ \t]" nil t)
2369 (looking-at "From\\|To\\|Cc")))
2370 (setq unicode (idna-to-unicode ace))))
2371 (unless (string= ace unicode)
2372 (replace-match unicode nil nil nil 1)))))))))
2374 (defun article-de-quoted-unreadable (&optional force read-charset)
2375 "Translate a quoted-printable-encoded article.
2376 If FORCE, decode the article whether it is marked as quoted-printable
2378 If READ-CHARSET, ask for a coding system."
2379 (interactive (list 'force current-prefix-arg))
2381 (let ((inhibit-read-only t) type charset)
2382 (if (gnus-buffer-live-p gnus-original-article-buffer)
2383 (with-current-buffer gnus-original-article-buffer
2385 (gnus-fetch-field "content-transfer-encoding"))
2386 (let* ((ct (gnus-fetch-field "content-type"))
2389 (mail-header-parse-content-type ct)))))
2390 (setq charset (and ctl
2391 (mail-content-type-get ctl 'charset)))
2392 (if (stringp charset)
2393 (setq charset (intern (downcase charset)))))))
2395 (setq charset (mm-read-coding-system "Charset: " charset)))
2397 (setq charset gnus-newsgroup-charset))
2399 (and type (let ((case-fold-search t))
2400 (string-match "quoted-printable" type))))
2402 (quoted-printable-decode-region
2403 (point) (point-max) (mm-charset-to-coding-system charset))))))
2405 (defun article-de-base64-unreadable (&optional force read-charset)
2406 "Translate a base64 article.
2407 If FORCE, decode the article whether it is marked as base64 not.
2408 If READ-CHARSET, ask for a coding system."
2409 (interactive (list 'force current-prefix-arg))
2411 (let ((inhibit-read-only t) type charset)
2412 (if (gnus-buffer-live-p gnus-original-article-buffer)
2413 (with-current-buffer gnus-original-article-buffer
2415 (gnus-fetch-field "content-transfer-encoding"))
2416 (let* ((ct (gnus-fetch-field "content-type"))
2419 (mail-header-parse-content-type ct)))))
2420 (setq charset (and ctl
2421 (mail-content-type-get ctl 'charset)))
2422 (if (stringp charset)
2423 (setq charset (intern (downcase charset)))))))
2425 (setq charset (mm-read-coding-system "Charset: " charset)))
2427 (setq charset gnus-newsgroup-charset))
2429 (and type (let ((case-fold-search t))
2430 (string-match "base64" type))))
2433 (narrow-to-region (point) (point-max))
2434 (base64-decode-region (point-min) (point-max))
2435 (mm-decode-coding-region
2436 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2441 (defun article-decode-HZ ()
2442 "Translate a HZ-encoded article."
2446 (let ((inhibit-read-only t))
2447 (rfc1843-decode-region (point-min) (point-max)))))
2449 (defun article-unsplit-urls ()
2450 "Remove the newlines that some other mailers insert into URLs."
2453 (let ((inhibit-read-only t))
2454 (goto-char (point-min))
2455 (while (re-search-forward
2456 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2457 (replace-match "\\1\\3" t)))
2458 (when (interactive-p)
2459 (gnus-treat-article nil))))
2462 (defun article-wash-html (&optional read-charset)
2463 "Format an HTML article.
2464 If READ-CHARSET, ask for a coding system."
2467 (let ((inhibit-read-only t)
2469 (when (gnus-buffer-live-p gnus-original-article-buffer)
2470 (with-current-buffer gnus-original-article-buffer
2471 (let* ((ct (gnus-fetch-field "content-type"))
2474 (mail-header-parse-content-type ct)))))
2475 (setq charset (and ctl
2476 (mail-content-type-get ctl 'charset)))
2477 (when (stringp charset)
2478 (setq charset (intern (downcase charset)))))))
2480 (setq charset (mm-read-coding-system "Charset: " charset)))
2482 (setq charset gnus-newsgroup-charset))
2484 (save-window-excursion
2486 (narrow-to-region (point) (point-max))
2487 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2488 (entry (assq func mm-text-html-washer-alist)))
2490 (setq func (cdr entry)))
2495 (apply (car func) (cdr func))))))))))
2497 (defun gnus-article-wash-html-with-w3 ()
2498 "Wash the current buffer with w3."
2500 (let ((w3-strict-width (window-width))
2501 (url-standalone-mode t)
2502 (url-gateway-unplugged t)
2503 (w3-honor-stylesheets nil))
2505 (w3-region (point-min) (point-max))
2508 (defun gnus-article-wash-html-with-w3m ()
2509 "Wash the current buffer with emacs-w3m."
2512 (narrow-to-region (point) (point-max))
2513 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2514 w3m-force-redisplay)
2515 (w3m-region (point-min) (point-max)))
2516 (when (and mm-inline-text-html-with-w3m-keymap
2517 (boundp 'w3m-minor-mode-map)
2519 (add-text-properties
2520 (point-min) (point-max)
2521 (list 'keymap w3m-minor-mode-map
2522 ;; Put the mark meaning this part was rendered by emacs-w3m.
2523 'mm-inline-text-html-with-w3m t)))))
2525 (defun article-hide-list-identifiers ()
2526 "Remove list identifies from the Subject header.
2527 The `gnus-list-identifiers' variable specifies what to do."
2529 (let ((inhibit-point-motion-hooks t)
2530 (regexp (if (consp gnus-list-identifiers)
2531 (mapconcat 'identity gnus-list-identifiers " *\\|")
2532 gnus-list-identifiers))
2533 (inhibit-read-only t))
2537 (article-narrow-to-head)
2538 (goto-char (point-min))
2539 (while (re-search-forward
2540 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2542 (delete-region (match-beginning 2) (match-end 0))
2543 (beginning-of-line))
2544 (when (re-search-forward
2545 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2546 (delete-region (match-beginning 1) (match-end 1))))))))
2548 (defun article-hide-pem (&optional arg)
2549 "Toggle hiding of any PEM headers and signatures in the current article.
2550 If given a negative prefix, always show; if given a positive prefix,
2552 (interactive (gnus-article-hidden-arg))
2553 (unless (gnus-article-check-hidden-text 'pem arg)
2555 (let ((inhibit-read-only t) end)
2556 (goto-char (point-min))
2557 ;; Hide the horrendously ugly "header".
2558 (when (and (search-forward
2559 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2561 (setq end (1+ (match-beginning 0))))
2562 (gnus-add-wash-type 'pem)
2563 (gnus-article-hide-text-type
2565 (if (search-forward "\n\n" nil t)
2569 ;; Hide the trailer as well
2570 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2572 (gnus-article-hide-text-type
2573 (match-beginning 0) (match-end 0) 'pem)))))))
2575 (defun article-strip-banner ()
2576 "Strip the banners specified by the `banner' group parameter and by
2577 `gnus-article-address-banner-alist'."
2581 (let ((inhibit-point-motion-hooks t))
2582 (when (gnus-parameter-banner gnus-newsgroup-name)
2583 (article-really-strip-banner
2584 (gnus-parameter-banner gnus-newsgroup-name)))
2585 (when gnus-article-address-banner-alist
2586 ;; It is necessary to encode from fields before checking,
2587 ;; because `mail-header-parse-addresses' does not work
2588 ;; (reliably) on decoded headers. And more, it is
2589 ;; impossible to use `gnus-fetch-original-field' here,
2590 ;; because `article-strip-banner' may be called in draft
2591 ;; buffers to preview them.
2592 (let ((from (save-restriction
2594 (article-narrow-to-head)
2595 (mail-fetch-field "from"))))
2598 (caar (mail-header-parse-addresses
2599 (mail-encode-encoded-word-string from)))))
2601 (dolist (pair gnus-article-address-banner-alist)
2602 (when (string-match (car pair) from)
2604 (article-really-strip-banner (cdr pair)))))))))))))
2606 (defun article-really-strip-banner (banner)
2607 "Strip the banner specified by the argument."
2610 (let ((inhibit-point-motion-hooks t)
2611 (gnus-signature-limit nil)
2612 (inhibit-read-only t))
2615 ((eq banner 'signature)
2616 (when (gnus-article-narrow-to-signature)
2619 (delete-region (point) (point-max))))
2621 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2622 (while (re-search-forward banner nil t)
2623 (delete-region (match-beginning 0) (match-end 0)))))
2625 (while (re-search-forward banner nil t)
2626 (delete-region (match-beginning 0) (match-end 0)))))))))
2628 (defun article-babel ()
2629 "Translate article using an online translation service."
2632 (gnus-with-article-buffer
2633 (when (article-goto-body)
2634 (let* ((start (point))
2636 (orig (buffer-substring start end))
2637 (trans (babel-as-string orig)))
2639 (narrow-to-region start end)
2640 (delete-region start end)
2643 (defun article-hide-signature (&optional arg)
2644 "Hide the signature in the current article.
2645 If given a negative prefix, always show; if given a positive prefix,
2647 (interactive (gnus-article-hidden-arg))
2648 (unless (gnus-article-check-hidden-text 'signature arg)
2651 (let ((inhibit-read-only t))
2652 (when (gnus-article-narrow-to-signature)
2653 (gnus-article-hide-text-type
2654 (point-min) (point-max) 'signature))))))
2655 (gnus-set-mode-line 'article))
2657 (defun article-strip-headers-in-body ()
2658 "Strip offensive headers from bodies."
2662 (let ((case-fold-search t))
2663 (when (looking-at "x-no-archive:")
2664 (gnus-delete-line)))))
2666 (defun article-strip-leading-blank-lines ()
2667 "Remove all blank lines from the beginning of the article."
2670 (let ((inhibit-point-motion-hooks t)
2671 (inhibit-read-only t))
2672 (when (article-goto-body)
2673 (while (and (not (eobp))
2674 (looking-at "[ \t]*$"))
2675 (gnus-delete-line))))))
2677 (defun article-narrow-to-head ()
2678 "Narrow the buffer to the head of the message.
2679 Point is left at the beginning of the narrowed-to region."
2681 (goto-char (point-min))
2682 (if (search-forward "\n\n" nil 1)
2685 (goto-char (point-min)))
2687 (defun article-goto-body ()
2688 "Place point at the start of the body."
2689 (goto-char (point-min))
2691 ;; This variable is only bound when dealing with separate
2693 (article-goto-body-goes-to-point-min-p
2695 ((search-forward "\n\n" nil t)
2698 (goto-char (point-max))
2701 (defun article-strip-multiple-blank-lines ()
2702 "Replace consecutive blank lines with one empty line."
2705 (let ((inhibit-point-motion-hooks t)
2706 (inhibit-read-only t))
2707 ;; First make all blank lines empty.
2709 (while (re-search-forward "^[ \t]+$" nil t)
2710 (unless (gnus-annotation-in-region-p
2711 (match-beginning 0) (match-end 0))
2712 (replace-match "" nil t)))
2713 ;; Then replace multiple empty lines with a single empty line.
2715 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2716 (unless (gnus-annotation-in-region-p
2717 (match-beginning 0) (match-end 0))
2718 (delete-region (match-beginning 1) (match-end 1)))))))
2720 (defun article-strip-leading-space ()
2721 "Remove all white space from the beginning of the lines in the article."
2724 (let ((inhibit-point-motion-hooks t)
2725 (inhibit-read-only t))
2727 (while (re-search-forward "^[ \t]+" nil t)
2728 (replace-match "" t t)))))
2730 (defun article-strip-trailing-space ()
2731 "Remove all white space from the end of the lines in the article."
2734 (let ((inhibit-point-motion-hooks t)
2735 (inhibit-read-only t))
2737 (while (re-search-forward "[ \t]+$" nil t)
2738 (replace-match "" t t)))))
2740 (defun article-strip-blank-lines ()
2741 "Strip leading, trailing and multiple blank lines."
2743 (article-strip-leading-blank-lines)
2744 (article-remove-trailing-blank-lines)
2745 (article-strip-multiple-blank-lines))
2747 (defun article-strip-all-blank-lines ()
2748 "Strip all blank lines."
2751 (let ((inhibit-point-motion-hooks t)
2752 (inhibit-read-only t))
2754 (while (re-search-forward "^[ \t]*\n" nil t)
2755 (replace-match "" t t)))))
2757 (defun gnus-article-narrow-to-signature ()
2758 "Narrow to the signature; return t if a signature is found, else nil."
2759 (let ((inhibit-point-motion-hooks t))
2760 (when (gnus-article-search-signature)
2762 ;; Check whether we have some limits to what we consider
2763 ;; to be a signature.
2764 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2765 (list gnus-signature-limit)))
2767 (while (setq limit (pop limits))
2768 (if (or (and (integerp limit)
2769 (< (- (point-max) (point)) limit))
2771 (< (count-lines (point) (point-max)) limit))
2772 (and (functionp limit)
2774 (and (stringp limit)
2775 (not (re-search-forward limit nil t))))
2776 () ; This limit did not succeed.
2780 (narrow-to-region (point) (point-max))
2783 (defun gnus-article-search-signature ()
2784 "Search the current buffer for the signature separator.
2785 Put point at the beginning of the signature separator."
2786 (let ((cur (point)))
2787 (goto-char (point-max))
2788 (if (if (stringp gnus-signature-separator)
2789 (re-search-backward gnus-signature-separator nil t)
2790 (let ((seps gnus-signature-separator))
2792 (not (re-search-backward (car seps) nil t)))
2799 (defun gnus-article-hidden-arg ()
2800 "Return the current prefix arg as a number, or 0 if no prefix."
2801 (list (if current-prefix-arg
2802 (prefix-numeric-value current-prefix-arg)
2805 (defun gnus-article-check-hidden-text (type arg)
2806 "Return nil if hiding is necessary.
2807 Arg can be nil or a number. nil and positive means hide, negative
2808 means show, 0 means toggle."
2811 (let ((hide (gnus-article-hidden-text-p type)))
2817 (gnus-article-show-hidden-text type)
2820 (if (eq hide 'hidden)
2822 (gnus-article-show-hidden-text type)
2826 (defun gnus-article-hidden-text-p (type)
2827 "Say whether the current buffer contains hidden text of type TYPE."
2828 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2830 (not (get-text-property pos 'invisible))
2831 (not (get-text-property pos 'dummy-invisible)))
2833 (text-property-any (1+ pos) (point-max) 'article-type type)))
2838 (defun gnus-article-show-hidden-text (type &optional dummy)
2839 "Show all hidden text of type TYPE.
2840 Originally it is hide instead of DUMMY."
2841 (let ((inhibit-read-only t)
2842 (inhibit-point-motion-hooks t))
2843 (gnus-remove-text-properties-when
2845 (point-min) (point-max)
2846 (cons 'article-type (cons type
2847 gnus-hidden-properties)))
2848 (gnus-delete-wash-type type)))
2850 (defconst article-time-units
2851 `((year . ,(* 365.25 24 60 60))
2852 (week . ,(* 7 24 60 60))
2853 (day . ,(* 24 60 60))
2857 "Mapping from time units to seconds.")
2859 (defun gnus-article-forward-header ()
2860 "Move point to the start of the next header.
2861 If the current header is a continuation header, this can be several
2866 (if (looking-at "[ \t]+[^ \t]")
2870 (defun article-date-ut (&optional type highlight)
2871 "Convert DATE date to universal time in the current article.
2872 If TYPE is `local', convert to local time; if it is `lapsed', output
2873 how much time has lapsed since DATE. For `lapsed', the value of
2874 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2875 should replace the \"Date:\" one, or should be added below it."
2876 (interactive (list 'ut t))
2877 (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2878 (date-regexp (cond ((not gnus-article-date-lapsed-new-header)
2882 (article-lapsed-timer
2886 (case-fold-search t)
2887 (inhibit-read-only t)
2888 (inhibit-point-motion-hooks t)
2889 pos date bface eface)
2893 (goto-char (point-min))
2894 (while (or (setq date (get-text-property (setq pos (point))
2896 (when (setq pos (next-single-property-change
2897 (point) 'original-date))
2898 (setq date (get-text-property pos 'original-date))
2900 (narrow-to-region pos (or (text-property-any pos (point-max)
2903 (goto-char (point-min))
2904 (when (re-search-forward tdate-regexp nil t)
2905 (setq bface (get-text-property (point-at-bol) 'face)
2906 eface (get-text-property (1- (point-at-eol)) 'face)))
2907 (goto-char (point-min))
2909 ;; Delete any old Date headers.
2910 (while (re-search-forward date-regexp nil t)
2912 (delete-region (point-at-bol) (progn
2913 (gnus-article-forward-header)
2915 (delete-region (point-at-bol) (progn
2916 (gnus-article-forward-header)
2919 (setq pos (point))))
2920 (when (and (not pos)
2921 (re-search-forward tdate-regexp nil t))
2923 (gnus-goto-char pos)
2924 (insert (article-make-date-line date (or type 'ut)))
2930 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2931 (put-text-property (match-beginning 1) (1+ (match-end 1))
2933 (put-text-property (match-beginning 2) (match-end 2)
2935 (put-text-property (point-min) (1- (point-max)) 'original-date date)
2936 (goto-char (point-max))
2939 (defun article-make-date-line (date type)
2940 "Return a DATE line of TYPE."
2941 (unless (memq type '(local ut original user iso8601 lapsed english))
2942 (error "Unknown conversion type: %s" type))
2944 (let ((time (date-to-time date)))
2946 ;; Convert to the local timezone.
2948 (concat "Date: " (message-make-date time)))
2949 ;; Convert to Universal Time.
2954 (let* ((e (parse-time-string date))
2955 (tm (apply 'encode-time e))
2957 (ls (- (cadr tm) (car (current-time-zone time)))))
2958 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2959 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2963 ;; Get the original date from the article.
2964 ((eq type 'original)
2965 (concat "Date: " (if (string-match "\n+$" date)
2966 (substring date 0 (match-beginning 0))
2968 ;; Let the user define the format.
2970 (let ((format (or (condition-case nil
2971 (with-current-buffer gnus-summary-buffer
2972 gnus-article-time-format)
2974 gnus-article-time-format)))
2975 (if (functionp format)
2976 (funcall format time)
2977 (concat "Date: " (format-time-string format time)))))
2980 (let ((tz (car (current-time-zone time))))
2983 (format-time-string "%Y%m%dT%H%M%S" time)
2984 (format "%s%02d%02d"
2985 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2986 (/ (% (abs tz) 3600) 60)))))
2987 ;; Do an X-Sent lapsed format.
2989 ;; If the date is seriously mangled, the timezone functions are
2990 ;; liable to bug out, so we ignore all errors.
2991 (let* ((now (current-time))
2992 (real-time (subtract-time now time))
2993 (real-sec (and real-time
2994 (+ (* (float (car real-time)) 65536)
2996 (sec (and real-time (abs real-sec)))
3006 ;; This is a bit convoluted, but basically we go
3007 ;; through the time units for years, weeks, etc,
3008 ;; and divide things to see whether that results
3009 ;; in positive answers.
3012 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3013 ;; The (remaining) seconds are too few to
3014 ;; be divided into this time unit.
3016 ;; It's big enough, so we output it.
3017 (setq sec (- sec (* num (cdr unit))))
3019 (concat (if prev ", " "") (int-to-string
3021 " " (symbol-name (car unit))
3022 (if (> num 1) "s" ""))
3024 article-time-units "")
3025 ;; If dates are odd, then it might appear like the
3026 ;; article was sent in the future.
3029 " in the future"))))))
3030 ;; Display the date in proper English
3032 (let ((dtime (decode-time time)))
3035 (number-to-string (nth 3 dtime))
3036 (let ((digit (% (nth 3 dtime) 10)))
3038 ((memq (nth 3 dtime) '(11 12 13)) "th")
3044 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3046 (number-to-string (nth 5 dtime))
3048 (format "%02d" (nth 2 dtime))
3050 (format "%02d" (nth 1 dtime)))))))
3052 (format "Date: %s (from Gnus)" date))))
3054 (defun article-date-local (&optional highlight)
3055 "Convert the current article date to the local timezone."
3056 (interactive (list t))
3057 (article-date-ut 'local highlight))
3059 (defun article-date-english (&optional highlight)
3060 "Convert the current article date to something that is proper English."
3061 (interactive (list t))
3062 (article-date-ut 'english highlight))
3064 (defun article-date-original (&optional highlight)
3065 "Convert the current article date to what it was originally.
3066 This is only useful if you have used some other date conversion
3067 function and want to see what the date was before converting."
3068 (interactive (list t))
3069 (article-date-ut 'original highlight))
3071 (defun article-date-lapsed (&optional highlight)
3072 "Convert the current article date to time lapsed since it was sent."
3073 (interactive (list t))
3074 (article-date-ut 'lapsed highlight))
3076 (defun article-update-date-lapsed ()
3077 "Function to be run from a timer to update the lapsed time line."
3078 (let (deactivate-mark)
3083 (set-buffer (window-buffer w))
3084 (when (eq major-mode 'gnus-article-mode)
3085 (let ((mark (point-marker)))
3086 (goto-char (point-min))
3087 (when (re-search-forward "^X-Sent:" nil t)
3088 (article-date-lapsed t))
3089 (goto-char (marker-position mark))
3090 (move-marker mark nil))))
3093 (defun gnus-start-date-timer (&optional n)
3094 "Start a timer to update the X-Sent header in the article buffers.
3095 The numerical prefix says how frequently (in seconds) the function
3100 (gnus-stop-date-timer)
3101 (setq article-lapsed-timer
3102 (run-at-time 1 n 'article-update-date-lapsed)))
3104 (defun gnus-stop-date-timer ()
3105 "Stop the X-Sent timer."
3107 (when article-lapsed-timer
3108 (nnheader-cancel-timer article-lapsed-timer)
3109 (setq article-lapsed-timer nil)))
3111 (defun article-date-user (&optional highlight)
3112 "Convert the current article date to the user-defined format.
3113 This format is defined by the `gnus-article-time-format' variable."
3114 (interactive (list t))
3115 (article-date-ut 'user highlight))
3117 (defun article-date-iso8601 (&optional highlight)
3118 "Convert the current article date to ISO8601."
3119 (interactive (list t))
3120 (article-date-ut 'iso8601 highlight))
3122 (defmacro gnus-article-save-original-date (&rest forms)
3123 "Save the original date as a text property and evaluate FORMS."
3124 `(let* ((case-fold-search t)
3126 (goto-char (point-min))
3127 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3130 (date (when (and start
3131 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3133 (buffer-substring-no-properties start
3134 (match-beginning 0)))))
3135 (goto-char (point-max))
3136 (skip-chars-backward "\n")
3137 (put-text-property (point-min) (point) 'original-date date)
3139 (goto-char (point-max))
3140 (skip-chars-backward "\n")
3141 (put-text-property (point-min) (point) 'original-date date)))
3143 ;; (defun article-show-all ()
3144 ;; "Show all hidden text in the article buffer."
3147 ;; (let ((inhibit-read-only t))
3148 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3150 (defun article-remove-leading-whitespace ()
3151 "Remove excessive whitespace from all headers."
3155 (let ((inhibit-read-only t))
3156 (article-narrow-to-head)
3157 (goto-char (point-min))
3158 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3159 (delete-region (match-beginning 1) (match-end 1)))))))
3161 (defun article-emphasize (&optional arg)
3162 "Emphasize text according to `gnus-emphasis-alist'."
3163 (interactive (gnus-article-hidden-arg))
3164 (unless (gnus-article-check-hidden-text 'emphasis arg)
3168 (with-current-buffer gnus-summary-buffer
3169 gnus-article-emphasis-alist)
3171 gnus-emphasis-alist))
3172 (inhibit-read-only t)
3173 (props (append '(article-type emphasis)
3174 gnus-hidden-properties))
3175 regexp elem beg invisible visible face)
3178 (while (setq elem (pop alist))
3180 (setq regexp (car elem)
3181 invisible (nth 1 elem)
3182 visible (nth 2 elem)
3184 (while (re-search-forward regexp nil t)
3185 (when (and (match-beginning visible) (match-beginning invisible))
3186 (gnus-article-hide-text
3187 (match-beginning invisible) (match-end invisible) props)
3188 (gnus-article-unhide-text-type
3189 (match-beginning visible) (match-end visible) 'emphasis)
3190 (gnus-put-overlay-excluding-newlines
3191 (match-beginning visible) (match-end visible) 'face face)
3192 (gnus-add-wash-type 'emphasis)
3193 (goto-char (match-end invisible)))))))))
3195 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3196 "Setup newsgroup emphasis alist."
3197 (unless gnus-article-emphasis-alist
3198 (let ((name (and gnus-newsgroup-name
3199 (gnus-group-real-name gnus-newsgroup-name))))
3200 (make-local-variable 'gnus-article-emphasis-alist)
3201 (setq gnus-article-emphasis-alist
3203 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3204 (while (setq elem (pop alist))
3205 (when (and name (string-match (car elem) name))
3207 highlight (copy-sequence (cdr elem)))))
3209 (copy-sequence highlight-words)
3210 (if gnus-newsgroup-name
3211 (copy-sequence (gnus-group-find-parameter
3212 gnus-newsgroup-name 'highlight-words t)))
3213 gnus-emphasis-alist)))))
3216 (defvar gnus-summary-article-menu)
3217 (defvar gnus-summary-post-menu))
3219 ;;; Saving functions.
3221 (defun gnus-article-save (save-buffer file &optional num)
3222 "Save the currently selected article."
3223 (unless gnus-save-all-headers
3224 ;; Remove headers according to `gnus-saved-headers'.
3225 (let ((gnus-visible-headers
3226 (or gnus-saved-headers gnus-visible-headers))
3227 (gnus-article-buffer save-buffer))
3229 (set-buffer save-buffer)
3230 (article-hide-headers 1 t))))
3231 (save-window-excursion
3232 (if (not gnus-default-article-saver)
3233 (error "No default saver is defined")
3234 ;; !!! Magic! The saving functions all save
3235 ;; `gnus-save-article-buffer' (or so they think), but we
3236 ;; bind that variable to our save-buffer.
3237 (set-buffer gnus-article-buffer)
3238 (let* ((gnus-save-article-buffer save-buffer)
3241 ((not gnus-prompt-before-saving) 'default)
3242 ((eq gnus-prompt-before-saving 'always) nil)
3244 (gnus-number-of-articles-to-be-saved
3245 (when (eq gnus-prompt-before-saving t)
3247 (set-buffer gnus-article-current-summary)
3248 (funcall gnus-default-article-saver filename)))))
3250 (defun gnus-read-save-file-name (prompt &optional filename
3251 function group headers variable)
3253 (funcall function group headers (symbol-value variable)))
3258 ((eq filename 'default)
3264 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3267 (if (and gnus-number-of-articles-to-be-saved
3268 (> gnus-number-of-articles-to-be-saved 1))
3269 (format "these %d articles"
3270 gnus-number-of-articles-to-be-saved)
3273 ;; Let the split methods have their say.
3275 ;; No split name was found.
3278 (concat prompt " (default "
3279 (file-name-nondirectory default-name) ") ")
3280 (file-name-directory default-name)
3282 ;; A single group name is returned.
3283 ((stringp split-name)
3285 (funcall function split-name headers
3286 (symbol-value variable)))
3288 (concat prompt " (default "
3289 (file-name-nondirectory default-name) ") ")
3290 (file-name-directory default-name)
3292 ;; A single split name was found
3293 ((= 1 (length split-name))
3294 (let* ((name (expand-file-name
3296 gnus-article-save-directory))
3297 (dir (cond ((file-directory-p name)
3298 (file-name-as-directory name))
3299 ((file-exists-p name) name)
3300 (t gnus-article-save-directory))))
3302 (concat prompt " (default " name ") ")
3304 ;; A list of splits was found.
3306 (setq split-name (nreverse split-name))
3308 (let ((file-name-history
3309 (nconc split-name file-name-history)))
3313 (concat prompt " (`M-p' for defaults) ")
3314 gnus-article-save-directory
3316 gnus-article-save-directory)))
3317 (car (push result file-name-history)))))))
3318 ;; Create the directory.
3319 (gnus-make-directory (file-name-directory file))
3320 ;; If we have read a directory, we append the default file name.
3321 (when (file-directory-p file)
3322 (setq file (expand-file-name (file-name-nondirectory
3324 (file-name-as-directory file))))
3325 ;; Possibly translate some characters.
3326 (nnheader-translate-file-chars file))))))
3327 (gnus-make-directory (file-name-directory result))
3328 (set variable result)))
3330 (defun gnus-article-archive-name (group)
3331 "Return the first instance of an \"Archive-name\" in the current buffer."
3332 (let ((case-fold-search t))
3333 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3334 (nnheader-concat gnus-article-save-directory
3335 (match-string 1)))))
3337 (defun gnus-article-nndoc-name (group)
3338 "If GROUP is an nndoc group, return the name of the parent group."
3339 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3340 (gnus-group-get-parameter group 'save-article-group)))
3342 (defun gnus-summary-save-in-rmail (&optional filename)
3343 "Append this article to Rmail file.
3344 Optional argument FILENAME specifies file name.
3345 Directory to save to is default to `gnus-article-save-directory'."
3346 (setq filename (gnus-read-save-file-name
3347 "Save %s in rmail file:" filename
3348 gnus-rmail-save-name gnus-newsgroup-name
3349 gnus-current-headers 'gnus-newsgroup-last-rmail))
3350 (gnus-eval-in-buffer-window gnus-save-article-buffer
3354 (gnus-output-to-rmail filename))))
3357 (defun gnus-summary-save-in-mail (&optional filename)
3358 "Append this article to Unix mail file.
3359 Optional argument FILENAME specifies file name.
3360 Directory to save to is default to `gnus-article-save-directory'."
3361 (setq filename (gnus-read-save-file-name
3362 "Save %s in Unix mail file:" filename
3363 gnus-mail-save-name gnus-newsgroup-name
3364 gnus-current-headers 'gnus-newsgroup-last-mail))
3365 (gnus-eval-in-buffer-window gnus-save-article-buffer
3369 (if (and (file-readable-p filename)
3370 (file-regular-p filename)
3371 (mail-file-babyl-p filename))
3372 (rmail-output-to-rmail-file filename t)
3373 (gnus-output-to-mail filename)))))
3376 (defun gnus-summary-save-in-file (&optional filename overwrite)
3377 "Append this article to file.
3378 Optional argument FILENAME specifies file name.
3379 Directory to save to is default to `gnus-article-save-directory'."
3380 (setq filename (gnus-read-save-file-name
3381 "Save %s in file:" filename
3382 gnus-file-save-name gnus-newsgroup-name
3383 gnus-current-headers 'gnus-newsgroup-last-file))
3384 (gnus-eval-in-buffer-window gnus-save-article-buffer
3388 (when (and overwrite
3389 (file-exists-p filename))
3390 (delete-file filename))
3391 (gnus-output-to-file filename))))
3394 (defun gnus-summary-write-to-file (&optional filename)
3395 "Write this article to a file, overwriting it if the file exists.
3396 Optional argument FILENAME specifies file name.
3397 The directory to save in defaults to `gnus-article-save-directory'."
3398 (gnus-summary-save-in-file nil t))
3400 (defun gnus-summary-save-body-in-file (&optional filename)
3401 "Append this article body to a file.
3402 Optional argument FILENAME specifies file name.
3403 The directory to save in defaults to `gnus-article-save-directory'."
3404 (setq filename (gnus-read-save-file-name
3405 "Save %s body in file:" filename
3406 gnus-file-save-name gnus-newsgroup-name
3407 gnus-current-headers 'gnus-newsgroup-last-file))
3408 (gnus-eval-in-buffer-window gnus-save-article-buffer
3412 (when (article-goto-body)
3413 (narrow-to-region (point) (point-max)))
3414 (gnus-output-to-file filename))))
3417 (defun gnus-summary-save-in-pipe (&optional command)
3418 "Pipe this article to subprocess."
3420 (cond ((and (eq command 'default)
3421 gnus-last-shell-command)
3422 gnus-last-shell-command)
3427 "Shell command on %s: "
3428 (if (and gnus-number-of-articles-to-be-saved
3429 (> gnus-number-of-articles-to-be-saved 1))
3430 (format "these %d articles"
3431 gnus-number-of-articles-to-be-saved)
3433 gnus-last-shell-command))))
3434 (when (string-equal command "")
3435 (if gnus-last-shell-command
3436 (setq command gnus-last-shell-command)
3437 (error "A command is required")))
3438 (gnus-eval-in-buffer-window gnus-article-buffer
3441 (shell-command-on-region (point-min) (point-max) command nil)))
3442 (setq gnus-last-shell-command command))
3444 (defun gnus-summary-pipe-to-muttprint (&optional command)
3445 "Pipe this article to muttprint."
3446 (setq command (read-string
3447 "Print using command: " gnus-summary-muttprint-program
3448 nil gnus-summary-muttprint-program))
3449 (gnus-summary-save-in-pipe command))
3451 ;;; Article file names when saving.
3453 (defun gnus-capitalize-newsgroup (newsgroup)
3454 "Capitalize NEWSGROUP name."
3455 (when (not (zerop (length newsgroup)))
3456 (concat (char-to-string (upcase (aref newsgroup 0)))
3457 (substring newsgroup 1))))
3459 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3460 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3461 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3462 Otherwise, it is like ~/News/news/group/num."
3465 (concat (if (gnus-use-long-file-name 'not-save)
3466 (gnus-capitalize-newsgroup newsgroup)
3467 (gnus-newsgroup-directory-form newsgroup))
3468 "/" (int-to-string (mail-header-number headers)))
3469 gnus-article-save-directory)))
3471 (string-equal (file-name-directory default)
3472 (file-name-directory last-file))
3473 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3475 (or last-file default))))
3477 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3478 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3479 If variable `gnus-use-long-file-name' is non-nil, it is
3480 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3483 (concat (if (gnus-use-long-file-name 'not-save)
3485 (gnus-newsgroup-directory-form newsgroup))
3486 "/" (int-to-string (mail-header-number headers)))
3487 gnus-article-save-directory)))
3489 (string-equal (file-name-directory default)
3490 (file-name-directory last-file))
3491 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3493 (or last-file default))))
3495 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3496 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3497 If variable `gnus-use-long-file-name' is non-nil, it is
3498 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3501 (if (gnus-use-long-file-name 'not-save)
3504 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3506 gnus-article-save-directory)))
3508 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3509 "Generate file name from sender."
3510 (let ((from (mail-header-from headers)))
3512 (if (and from (string-match "\\([^ <]+\\)@" from))
3513 (match-string 1 from)
3515 gnus-article-save-directory)))
3517 (defun article-verify-x-pgp-sig ()
3520 (if (gnus-buffer-live-p gnus-original-article-buffer)
3521 (let ((sig (with-current-buffer gnus-original-article-buffer
3522 (gnus-fetch-field "X-PGP-Sig")))
3526 (mml2015-clear-verify-function))
3528 (insert-buffer-substring gnus-original-article-buffer)
3529 (setq items (split-string sig))
3530 (message-narrow-to-head)
3531 (let ((inhibit-point-motion-hooks t)
3532 (case-fold-search t))
3533 ;; Don't verify multiple headers.
3534 (setq headers (mapconcat (lambda (header)
3536 (mail-fetch-field header)
3538 (split-string (nth 1 items) ",") "")))
3539 (delete-region (point-min) (point-max))
3540 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3541 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3546 (if (looking-at "^-")
3549 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3550 (insert "Version: " (car items) "\n\n")
3551 (insert (mapconcat 'identity (cddr items) "\n"))
3552 (insert "\n-----END PGP SIGNATURE-----\n")
3553 (let ((mm-security-handle (list (format "multipart/signed"))))
3554 (mml2015-clean-buffer)
3555 (let ((coding-system-for-write (or gnus-newsgroup-charset
3557 (funcall (mml2015-clear-verify-function)))
3559 (or (mm-handle-multipart-ctl-parameter
3560 mm-security-handle 'gnus-details)
3561 (mm-handle-multipart-ctl-parameter
3562 mm-security-handle 'gnus-info)))))
3564 (let ((inhibit-read-only t) bface eface)
3566 (message-narrow-to-head)
3567 (goto-char (point-max))
3569 (setq bface (get-text-property (point-at-bol) 'face)
3570 eface (get-text-property (1- (point-at-eol)) 'face))
3571 (message-remove-header "X-Gnus-PGP-Verify")
3572 (if (re-search-forward "^X-PGP-Sig:" nil t)
3574 (goto-char (point-max)))
3575 (narrow-to-region (point) (point))
3576 (insert "X-Gnus-PGP-Verify: " info "\n")
3577 (goto-char (point-min))
3580 (if (not (looking-at "^[ \t]"))
3584 (goto-char (point-min))
3585 (when (looking-at "\\([^:]+\\): *")
3586 (put-text-property (match-beginning 1) (1+ (match-end 1))
3588 (put-text-property (match-end 0) (point-max)
3589 'face eface)))))))))
3591 (defun article-verify-cancel-lock ()
3592 "Verify Cancel-Lock header."
3594 (if (gnus-buffer-live-p gnus-original-article-buffer)
3595 (canlock-verify gnus-original-article-buffer)))
3602 (setq afunc (car func)
3605 gfunc (intern (format "gnus-%s" func))))
3607 (when (fboundp afunc)
3608 `(lambda (&optional interactive &rest args)
3609 ,(documentation afunc t)
3610 (interactive (list t))
3612 (set-buffer gnus-article-buffer)
3614 (call-interactively ',afunc)
3615 (apply ',afunc args))))))))
3616 '(article-hide-headers
3617 article-verify-x-pgp-sig
3618 article-verify-cancel-lock
3619 article-hide-boring-headers
3620 article-treat-overstrike
3621 article-treat-ansi-sequences
3622 article-fill-long-lines
3623 article-capitalize-sentences
3625 article-remove-leading-whitespace
3626 article-display-x-face
3627 article-display-face
3628 article-de-quoted-unreadable
3629 article-de-base64-unreadable
3632 article-unsplit-urls
3633 article-hide-list-identifiers
3634 article-strip-banner
3637 article-hide-signature
3638 article-strip-headers-in-body
3639 article-remove-trailing-blank-lines
3640 article-strip-leading-blank-lines
3641 article-strip-multiple-blank-lines
3642 article-strip-leading-space
3643 article-strip-trailing-space
3644 article-strip-blank-lines
3645 article-strip-all-blank-lines
3647 article-date-english
3648 article-date-iso8601
3649 article-date-original
3651 article-decode-mime-words
3652 article-decode-charset
3653 article-decode-encoded-words
3657 article-treat-dumbquotes
3658 article-normalize-headers
3659 ;; (article-show-all . gnus-article-show-all-headers)
3663 ;;; Gnus article mode
3666 (put 'gnus-article-mode 'mode-class 'special)
3668 (set-keymap-parent gnus-article-mode-map widget-keymap)
3670 (gnus-define-keys gnus-article-mode-map
3671 " " gnus-article-goto-next-page
3672 "\177" gnus-article-goto-prev-page
3673 [delete] gnus-article-goto-prev-page
3674 [backspace] gnus-article-goto-prev-page
3675 "\C-c^" gnus-article-refer-article
3676 "h" gnus-article-show-summary
3677 "s" gnus-article-show-summary
3678 "\C-c\C-m" gnus-article-mail
3679 "?" gnus-article-describe-briefly
3680 "e" gnus-summary-edit-article
3681 "<" beginning-of-buffer
3683 "\C-c\C-i" gnus-info-find-node
3685 "R" gnus-article-reply-with-original
3686 "F" gnus-article-followup-with-original
3687 "\C-hk" gnus-article-describe-key
3688 "\C-hc" gnus-article-describe-key-briefly
3690 "\C-d" gnus-article-read-summary-keys
3691 "\M-*" gnus-article-read-summary-keys
3692 "\M-#" gnus-article-read-summary-keys
3693 "\M-^" gnus-article-read-summary-keys
3694 "\M-g" gnus-article-read-summary-keys)
3696 (substitute-key-definition
3697 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3699 (defun gnus-article-make-menu-bar ()
3700 (unless (boundp 'gnus-article-commands-menu)
3701 (gnus-summary-make-menu-bar))
3702 (gnus-turn-off-edit-menu 'article)
3703 (unless (boundp 'gnus-article-article-menu)
3705 gnus-article-article-menu gnus-article-mode-map ""
3707 ["Scroll forwards" gnus-article-goto-next-page t]
3708 ["Scroll backwards" gnus-article-goto-prev-page t]
3709 ["Show summary" gnus-article-show-summary t]
3710 ["Fetch Message-ID at point" gnus-article-refer-article t]
3711 ["Mail to address at point" gnus-article-mail t]
3712 ["Send a bug report" gnus-bug t]))
3715 gnus-article-treatment-menu gnus-article-mode-map ""
3716 ;; Fixme: this should use :active (and maybe :visible).
3718 ["Hide headers" gnus-article-hide-headers t]
3719 ["Hide signature" gnus-article-hide-signature t]
3720 ["Hide citation" gnus-article-hide-citation t]
3721 ["Treat overstrike" gnus-article-treat-overstrike t]
3722 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
3723 ["Remove carriage return" gnus-article-remove-cr t]
3724 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3725 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3726 ["Remove base64" gnus-article-de-base64-unreadable t]
3727 ["Treat html" gnus-article-wash-html t]
3728 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3729 ["Decode HZ" gnus-article-decode-HZ t]))
3731 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3733 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3735 (gnus-run-hooks 'gnus-article-menu-hook)))
3737 (defun gnus-article-mode ()
3738 "Major mode for displaying an article.
3740 All normal editing commands are switched off.
3742 The following commands are available in addition to all summary mode
3744 \\<gnus-article-mode-map>
3745 \\[gnus-article-next-page]\t Scroll the article one page forwards
3746 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3747 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3748 \\[gnus-article-show-summary]\t Display the summary buffer
3749 \\[gnus-article-mail]\t Send a reply to the address near point
3750 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3751 \\[gnus-info-find-node]\t Go to the Gnus info node"
3753 (gnus-simplify-mode-line)
3754 (setq mode-name "Article")
3755 (setq major-mode 'gnus-article-mode)
3756 (make-local-variable 'minor-mode-alist)
3757 (use-local-map gnus-article-mode-map)
3758 (when (gnus-visual-p 'article-menu 'menu)
3759 (gnus-article-make-menu-bar)
3760 (when gnus-summary-tool-bar-map
3761 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3762 (gnus-update-format-specifications nil 'article-mode)
3763 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3764 (set (make-local-variable 'gnus-page-broken) nil)
3765 (make-local-variable 'gnus-button-marker-list)
3766 (make-local-variable 'gnus-article-current-summary)
3767 (make-local-variable 'gnus-article-mime-handles)
3768 (make-local-variable 'gnus-article-decoded-p)
3769 (make-local-variable 'gnus-article-mime-handle-alist)
3770 (make-local-variable 'gnus-article-wash-types)
3771 (make-local-variable 'gnus-article-image-alist)
3772 (make-local-variable 'gnus-article-charset)
3773 (make-local-variable 'gnus-article-ignored-charsets)
3774 ;; Prevent recent Emacsen from displaying non-break space as "\ ".
3775 (set (make-local-variable 'show-nonbreak-escape) nil)
3776 (gnus-set-default-directory)
3777 (buffer-disable-undo)
3778 (setq buffer-read-only t
3779 show-trailing-whitespace nil)
3780 (set-syntax-table gnus-article-mode-syntax-table)
3781 (mm-enable-multibyte)
3782 (gnus-run-hooks 'gnus-article-mode-hook))
3784 (defun gnus-article-setup-buffer ()
3785 "Initialize the article buffer."
3786 (let* ((name (if gnus-single-article-buffer "*Article*"
3787 (concat "*Article " gnus-newsgroup-name "*")))
3789 (progn (string-match "\\*Article" name)
3790 (concat " *Original Article"
3791 (substring name (match-end 0))))))
3792 (setq gnus-article-buffer name)
3793 (setq gnus-original-article-buffer original)
3794 (setq gnus-article-mime-handle-alist nil)
3795 ;; This might be a variable local to the summary buffer.
3796 (unless gnus-single-article-buffer
3798 (set-buffer gnus-summary-buffer)
3799 (setq gnus-article-buffer name)
3800 (setq gnus-original-article-buffer original)
3801 (gnus-set-global-variables)))
3802 (gnus-article-setup-highlight-words)
3803 ;; Init original article buffer.
3805 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3806 (mm-enable-multibyte)
3807 (setq major-mode 'gnus-original-article-mode)
3808 (make-local-variable 'gnus-original-article))
3809 (if (and (get-buffer name)
3810 (with-current-buffer name
3811 (if gnus-article-edit-mode
3812 (if (y-or-n-p "Article mode edit in progress; discard? ")
3814 (set-buffer-modified-p nil)
3815 (gnus-kill-buffer name)
3818 (error "Action aborted"))
3822 (set (make-local-variable 'gnus-article-edit-mode) nil)
3823 (when gnus-article-mime-handles
3824 (mm-destroy-parts gnus-article-mime-handles)
3825 (setq gnus-article-mime-handles nil))
3826 ;; Set it to nil in article-buffer!
3827 (setq gnus-article-mime-handle-alist nil)
3828 (buffer-disable-undo)
3829 (setq buffer-read-only t)
3830 ;; This list just keeps growing if we don't reset it.
3831 (setq gnus-button-marker-list nil)
3832 (unless (eq major-mode 'gnus-article-mode)
3833 (gnus-article-mode))
3836 (set-buffer (gnus-get-buffer-create name))
3838 (make-local-variable 'gnus-summary-buffer)
3839 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3840 (current-buffer)))))
3842 ;; Set article window start at LINE, where LINE is the number of lines
3843 ;; from the head of the article.
3844 (defun gnus-article-set-window-start (&optional line)
3846 (gnus-get-buffer-window gnus-article-buffer t)
3848 (set-buffer gnus-article-buffer)
3849 (goto-char (point-min))
3852 (gnus-message 6 "Moved to bookmark")
3853 (search-forward "\n\n" nil t)
3857 (defun gnus-article-prepare (article &optional all-headers header)
3858 "Prepare ARTICLE in article mode buffer.
3859 ARTICLE should either be an article number or a Message-ID.
3860 If ARTICLE is an id, HEADER should be the article headers.
3861 If ALL-HEADERS is non-nil, no headers are hidden."
3863 ;; Make sure we start in a summary buffer.
3864 (unless (eq major-mode 'gnus-summary-mode)
3865 (set-buffer gnus-summary-buffer))
3866 (setq gnus-summary-buffer (current-buffer))
3867 (let* ((gnus-article (if header (mail-header-number header) article))
3868 (summary-buffer (current-buffer))
3869 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3870 (group gnus-newsgroup-name)
3873 (gnus-article-setup-buffer)
3874 (set-buffer gnus-article-buffer)
3875 ;; Deactivate active regions.
3876 (when (and (boundp 'transient-mark-mode)
3877 transient-mark-mode)
3878 (setq mark-active nil))
3879 (if (not (setq result (let ((inhibit-read-only t))
3880 (gnus-request-article-this-buffer
3882 ;; There is no such article.
3884 (when (and (numberp article)
3885 (not (memq article gnus-newsgroup-sparse)))
3886 (setq gnus-article-current
3887 (cons gnus-newsgroup-name article))
3888 (set-buffer gnus-summary-buffer)
3889 (setq gnus-current-article article)
3890 (if (and (memq article gnus-newsgroup-undownloaded)
3891 (not (gnus-online (gnus-find-method-for-group
3892 gnus-newsgroup-name))))
3894 (gnus-summary-set-agent-mark article)
3895 (message "Message marked for downloading"))
3896 (gnus-summary-mark-article article gnus-canceled-mark)
3897 (unless (memq article gnus-newsgroup-sparse)
3898 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3899 (if (or (eq result 'pseudo)
3900 (eq result 'nneething))
3903 (set-buffer summary-buffer)
3904 (push article gnus-newsgroup-history)
3905 (setq gnus-last-article gnus-current-article
3906 gnus-current-article 0
3907 gnus-current-headers nil
3908 gnus-article-current nil)
3909 (if (eq result 'nneething)
3910 (gnus-configure-windows 'summary)
3911 (gnus-configure-windows 'article))
3912 (gnus-set-global-variables))
3913 (let ((gnus-article-mime-handle-alist-1
3914 gnus-article-mime-handle-alist))
3915 (gnus-set-mode-line 'article)))
3916 ;; The result from the `request' was an actual article -
3917 ;; or at least some text that is now displayed in the
3919 (when (and (numberp article)
3920 (not (eq article gnus-current-article)))
3921 ;; Seems like a new article has been selected.
3922 ;; `gnus-current-article' must be an article number.
3924 (set-buffer summary-buffer)
3925 (push article gnus-newsgroup-history)
3926 (setq gnus-last-article gnus-current-article
3927 gnus-current-article article
3928 gnus-current-headers
3929 (gnus-summary-article-header gnus-current-article)
3930 gnus-article-current
3931 (cons gnus-newsgroup-name gnus-current-article))
3932 (unless (vectorp gnus-current-headers)
3933 (setq gnus-current-headers nil))
3934 (gnus-summary-goto-subject gnus-current-article)
3935 (when (gnus-summary-show-thread)
3936 ;; If the summary buffer really was folded, the
3937 ;; previous goto may not actually have gone to
3938 ;; the right article, but the thread root instead.
3940 (gnus-summary-goto-subject gnus-current-article))
3941 (gnus-run-hooks 'gnus-mark-article-hook)
3942 (gnus-set-mode-line 'summary)
3943 (when (gnus-visual-p 'article-highlight 'highlight)
3944 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3945 ;; Set the global newsgroup variables here.
3946 (gnus-set-global-variables)
3947 (setq gnus-have-all-headers
3948 (or all-headers gnus-show-all-headers))))
3950 (gnus-configure-windows 'article))
3951 (when (or (numberp article)
3953 (gnus-article-prepare-display)
3955 (goto-char (point-min))
3956 (when gnus-break-pages
3957 (gnus-narrow-to-page)))
3958 (let ((gnus-article-mime-handle-alist-1
3959 gnus-article-mime-handle-alist))
3960 (gnus-set-mode-line 'article))
3964 (set-window-point (get-buffer-window (current-buffer)) (point))
3965 (gnus-configure-windows 'article)
3969 (defun gnus-article-prepare-display ()
3970 "Make the current buffer look like a nice article."
3971 ;; Hooks for getting information from the article.
3972 ;; This hook must be called before being narrowed.
3973 (let ((gnus-article-buffer (current-buffer))
3975 (inhibit-read-only t))
3976 (unless (eq major-mode 'gnus-article-mode)
3977 (gnus-article-mode))
3978 (setq buffer-read-only nil
3979 gnus-article-wash-types nil
3980 gnus-article-image-alist nil)
3981 (gnus-run-hooks 'gnus-tmp-internal-hook)
3982 (when gnus-display-mime-function
3983 (funcall gnus-display-mime-function))
3984 (gnus-run-hooks 'gnus-article-prepare-hook)))
3987 ;;; Gnus MIME viewing functions
3990 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3991 "Format of the MIME buttons.
3993 Valid specifiers include:
3995 %T MIME type, along with additional info
3996 %n The `name' parameter
3997 %d The description, if any
3998 %l The length of the encoded part
3999 %p The part identifier number
4000 %e Dots if the part isn't displayed
4002 General format specifiers can also be used. See Info node
4003 `(gnus)Formatting Variables'.")
4005 (defvar gnus-mime-button-line-format-alist
4006 '((?t gnus-tmp-type ?s)
4007 (?T gnus-tmp-type-long ?s)
4008 (?n gnus-tmp-name ?s)
4009 (?d gnus-tmp-description ?s)
4011 (?l gnus-tmp-length ?d)
4012 (?e gnus-tmp-dots ?s)))
4014 (defvar gnus-mime-button-commands
4015 '((gnus-article-press-button "\r" "Toggle Display")
4016 (gnus-mime-view-part "v" "View Interactively...")
4017 (gnus-mime-view-part-as-type "t" "View As Type...")
4018 (gnus-mime-view-part-as-charset "C" "View As charset...")
4019 (gnus-mime-save-part "o" "Save...")
4020 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4021 (gnus-mime-delete-part "d" "Delete part")
4022 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4023 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4024 (gnus-mime-view-part-internally "E" "View Internally")
4025 (gnus-mime-view-part-externally "e" "View Externally")
4026 (gnus-mime-print-part "p" "Print")
4027 (gnus-mime-pipe-part "|" "Pipe To Command...")
4028 (gnus-mime-action-on-part "." "Take action on the part...")))
4030 (defun gnus-article-mime-part-status ()
4031 (if gnus-article-mime-handle-alist-1
4032 (if (eq 1 (length gnus-article-mime-handle-alist-1))
4034 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
4037 (defvar gnus-mime-button-map
4038 (let ((map (make-sparse-keymap)))
4039 (define-key map gnus-mouse-2 'gnus-article-push-button)
4040 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4041 (dolist (c gnus-mime-button-commands)
4042 (define-key map (cadr c) (car c)))
4046 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4048 ,@(mapcar (lambda (c)
4049 (vector (caddr c) (car c) :enable t))
4050 gnus-mime-button-commands)))
4052 (defun gnus-mime-button-menu (event prefix)
4053 "Construct a context-sensitive menu of MIME commands."
4054 (interactive "e\nP")
4055 (save-window-excursion
4056 (let ((pos (event-start event)))
4057 (select-window (posn-window pos))
4058 (goto-char (posn-point pos))
4059 (gnus-article-check-buffer)
4060 (popup-menu gnus-mime-button-menu nil prefix))))
4062 (defun gnus-mime-view-all-parts (&optional handles)
4063 "View all the MIME parts."
4065 (with-current-buffer gnus-article-buffer
4066 (let ((handles (or handles gnus-article-mime-handles))
4067 (mail-parse-charset gnus-newsgroup-charset)
4068 (mail-parse-ignored-charsets
4069 (with-current-buffer gnus-summary-buffer
4070 gnus-newsgroup-ignored-charsets)))
4072 (mm-remove-parts handles)
4073 (goto-char (point-min))
4074 (or (search-forward "\n\n") (goto-char (point-max)))
4075 (let ((inhibit-read-only t))
4076 (delete-region (point) (point-max))
4077 (mm-display-parts handles))))))
4080 (defsubst gnus-article-edit-part (handles)
4081 "Edit an article in order to delete a mime part.
4082 This function is exclusively used by `gnus-mime-save-part-and-strip'
4083 and `gnus-mime-delete-part', and not provided at run-time normally."
4084 (gnus-article-edit-article
4086 (buffer-disable-undo)
4088 (let ((mail-parse-charset (or gnus-article-charset
4089 ',gnus-newsgroup-charset))
4090 (mail-parse-ignored-charsets
4091 (or gnus-article-ignored-charsets
4092 ',gnus-newsgroup-ignored-charsets))
4093 (mbl mml-buffer-list))
4094 (setq mml-buffer-list nil)
4095 (insert-buffer gnus-original-article-buffer)
4096 (mime-to-mml ',handles)
4097 (setq gnus-article-mime-handles nil)
4098 (let ((mbl1 mml-buffer-list))
4099 (setq mml-buffer-list mbl)
4100 (set (make-local-variable 'mml-buffer-list) mbl1))
4101 (gnus-make-local-hook 'kill-buffer-hook)
4102 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4103 `(lambda (no-highlight)
4104 (let ((mail-parse-charset (or gnus-article-charset
4105 ',gnus-newsgroup-charset))
4106 (message-options message-options)
4107 (message-options-set-recipient)
4108 (mail-parse-ignored-charsets
4109 (or gnus-article-ignored-charsets
4110 ',gnus-newsgroup-ignored-charsets)))
4112 (mml-destroy-buffers)
4113 (remove-hook 'kill-buffer-hook
4114 'mml-destroy-buffers t)
4115 (kill-local-variable 'mml-buffer-list))
4116 (gnus-summary-edit-article-done
4117 ,(or (mail-header-references gnus-current-headers) "")
4118 ,(gnus-group-read-only-p)
4119 ,gnus-summary-buffer no-highlight)))
4120 (gnus-article-edit-done)
4121 (gnus-summary-expand-window)
4122 (gnus-summary-show-article)))
4124 (defun gnus-mime-save-part-and-strip ()
4125 "Save the MIME part under point then replace it with an external body."
4127 (gnus-article-check-buffer)
4128 (when (gnus-group-read-only-p)
4129 (error "The current group does not support deleting of parts"))
4130 (when (mm-complicated-handles gnus-article-mime-handles)
4132 The current article has a complicated MIME structure, giving up..."))
4133 (when (gnus-yes-or-no-p "\
4134 Deleting parts may malfunction or destroy the article; continue? ")
4135 (let* ((data (get-text-property (point) 'gnus-data))
4137 (handles gnus-article-mime-handles))
4138 (setq file (and data (mm-save-part data)))
4140 (with-current-buffer (mm-handle-buffer data)
4142 (insert "Content-Type: " (mm-handle-media-type data))
4143 (mml-insert-parameter-string (cdr (mm-handle-type data))
4146 (insert "Content-ID: " (message-make-message-id) "\n")
4147 (insert "Content-Transfer-Encoding: binary\n")
4150 (cdr (mm-make-handle nil
4151 `("message/external-body"
4152 (access-type . "LOCAL-FILE")
4154 (set-buffer gnus-summary-buffer)
4155 (gnus-article-edit-part handles)))))
4157 (defun gnus-mime-delete-part ()
4158 "Delete the MIME part under point.
4159 Replace it with some information about the removed part."
4161 (gnus-article-check-buffer)
4162 (when (gnus-group-read-only-p)
4163 (error "The current group does not support deleting of parts"))
4164 (when (mm-complicated-handles gnus-article-mime-handles)
4166 The current article has a complicated MIME structure, giving up..."))
4167 (when (gnus-yes-or-no-p "\
4168 Deleting parts may malfunction or destroy the article; continue? ")
4169 (let* ((data (get-text-property (point) 'gnus-data))
4170 (handles gnus-article-mime-handles)
4174 (mail-decode-encoded-word-string (or (mm-handle-description data)
4177 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4179 (type (mm-handle-media-type data)))
4181 (error "No MIME part under point"))
4182 (with-current-buffer (mm-handle-buffer data)
4183 (let ((bsize (format "%s" (buffer-size))))
4188 "| The following attachment has been deleted:\n"
4190 "| Type: " type "\n"
4191 "| Filename: " filename "\n"
4192 "| Size (encoded): " bsize " Byte\n"
4193 "| Description: " description "\n"
4196 (cdr (mm-make-handle
4197 nil `("text/plain") nil nil
4199 (format "Deleted attachment (%s bytes)" bsize))))))
4200 (set-buffer gnus-summary-buffer)
4201 (gnus-article-edit-part handles))))
4203 (defun gnus-mime-save-part ()
4204 "Save the MIME part under point."
4206 (gnus-article-check-buffer)
4207 (let ((data (get-text-property (point) 'gnus-data)))
4209 (mm-save-part data))))
4211 (defun gnus-mime-pipe-part ()
4212 "Pipe the MIME part under point to a process."
4214 (gnus-article-check-buffer)
4215 (let ((data (get-text-property (point) 'gnus-data)))
4217 (mm-pipe-part data))))
4219 (defun gnus-mime-view-part ()
4220 "Interactively choose a viewing method for the MIME part under point."
4222 (gnus-article-check-buffer)
4223 (let ((data (get-text-property (point) 'gnus-data)))
4225 (setq gnus-article-mime-handles
4227 gnus-article-mime-handles (setq data (copy-sequence data))))
4228 (mm-interactively-view-part data))))
4230 (defun gnus-mime-view-part-as-type-internal ()
4231 (gnus-article-check-buffer)
4232 (let* ((name (mail-content-type-get
4233 (mm-handle-type (get-text-property (point) 'gnus-data))
4235 (def-type (and name (mm-default-file-encoding name))))
4236 (and def-type (cons def-type 0))))
4238 (defun gnus-mime-view-part-as-type (&optional mime-type)
4239 "Choose a MIME media type, and view the part as such."
4242 (setq mime-type (completing-read
4243 "View as MIME type: "
4244 (mapcar #'list (mailcap-mime-types))
4246 (gnus-mime-view-part-as-type-internal))))
4247 (gnus-article-check-buffer)
4248 (let ((handle (get-text-property (point) 'gnus-data)))
4251 (mm-make-handle (mm-handle-buffer handle)
4252 (cons mime-type (cdr (mm-handle-type handle)))
4253 (mm-handle-encoding handle)
4254 (mm-handle-undisplayer handle)
4255 (mm-handle-disposition handle)
4256 (mm-handle-description handle)
4258 (mm-handle-id handle)))
4259 (setq gnus-article-mime-handles
4260 (mm-merge-handles gnus-article-mime-handles handle))
4261 (gnus-mm-display-part handle))))
4263 (defun gnus-mime-copy-part (&optional handle arg)
4264 "Put the MIME part under point into a new buffer.
4265 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4267 (interactive (list nil current-prefix-arg))
4268 (gnus-article-check-buffer)
4270 (setq handle (get-text-property (point) 'gnus-data)))
4272 (let ((filename (or (mail-content-type-get (mm-handle-disposition handle)
4274 (mail-content-type-get (mm-handle-disposition handle)
4276 contents dont-decode charset coding-system)
4277 (mm-with-unibyte-buffer
4278 (mm-insert-part handle)
4279 (setq contents (or (condition-case nil
4280 (mm-decompress-buffer filename nil 'sig)
4282 (setq dont-decode t)
4285 (setq filename (cond (filename (file-name-nondirectory filename))
4286 (dont-decode "*raw data*")
4291 (unless (setq charset (mail-content-type-get
4292 (mm-handle-type handle) 'charset))
4293 (unless (setq coding-system (mm-with-unibyte-buffer
4295 (mm-find-buffer-file-coding-system)))
4296 (setq charset gnus-newsgroup-charset))))
4298 (setq charset (or (cdr (assq arg
4299 gnus-summary-show-article-charset-alist))
4300 (mm-read-coding-system "Charset: ")))))
4301 (switch-to-buffer (generate-new-buffer filename))
4302 (if (or coding-system
4304 (setq coding-system (mm-charset-to-coding-system charset))
4305 (not (eq charset 'ascii))))
4307 (mm-enable-multibyte)
4308 (insert (mm-decode-coding-string contents coding-system))
4309 (setq buffer-file-coding-system
4310 (if (boundp 'last-coding-system-used)
4311 (symbol-value 'last-coding-system-used)
4313 (mm-disable-multibyte)
4315 (setq buffer-file-coding-system mm-binary-coding-system))
4316 ;; We do it this way to make `normal-mode' set the appropriate mode.
4319 (setq buffer-file-name (expand-file-name filename))
4321 (setq buffer-file-name nil))
4322 (goto-char (point-min)))))
4324 (defun gnus-mime-print-part (&optional handle filename)
4325 "Print the MIME part under point."
4326 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4327 (gnus-article-check-buffer)
4328 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4329 (contents (and handle (mm-get-part handle)))
4330 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4331 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4336 (mm-save-part-to-file handle file)
4337 (call-process shell-file-name nil
4338 (generate-new-buffer " *mm*")
4340 shell-command-switch
4342 printer file (mm-handle-type handle))))
4346 (gnus-print-buffer))
4347 (ps-despool filename)))))
4349 (defun gnus-mime-inline-part (&optional handle arg)
4350 "Insert the MIME part under point into the current buffer.
4351 Compressed files like .gz and .bz2 are decompressed."
4352 (interactive (list nil current-prefix-arg))
4353 (gnus-article-check-buffer)
4355 (setq handle (get-text-property (point) 'gnus-data)))
4358 (inhibit-read-only t)
4359 contents charset coding-system)
4360 (if (and (not arg) (mm-handle-undisplayer handle))
4361 (mm-remove-part handle)
4362 (mm-with-unibyte-buffer
4363 (mm-insert-part handle)
4365 (or (mm-decompress-buffer
4366 (or (mail-content-type-get (mm-handle-disposition handle)
4368 (mail-content-type-get (mm-handle-disposition handle)
4374 (unless (setq charset (mail-content-type-get
4375 (mm-handle-type handle) 'charset))
4376 (unless (setq coding-system
4377 (mm-with-unibyte-buffer
4379 (mm-find-buffer-file-coding-system)))
4380 (setq charset gnus-newsgroup-charset))))
4382 (if (mm-handle-undisplayer handle)
4383 (mm-remove-part handle))
4386 gnus-summary-show-article-charset-alist))
4387 (mm-read-coding-system "Charset: "))))
4389 (if (mm-handle-undisplayer handle)
4390 (mm-remove-part handle))))
4394 (if (or coding-system
4397 (mm-charset-to-coding-system charset))
4398 (not (eq charset 'ascii))))
4399 (mm-decode-coding-string contents coding-system)
4400 (mm-string-to-multibyte contents)))
4403 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4404 "Insert the MIME part under point into the current buffer using the
4406 (interactive (list nil current-prefix-arg))
4407 (gnus-article-check-buffer)
4408 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4411 (inhibit-read-only t))
4413 (if (mm-handle-undisplayer handle)
4414 (mm-remove-part handle))
4415 (let ((gnus-newsgroup-charset
4417 gnus-summary-show-article-charset-alist))
4418 (mm-read-coding-system "Charset: ")))
4419 (gnus-newsgroup-ignored-charsets 'gnus-all))
4420 (gnus-article-press-button)))))
4422 (defun gnus-mime-view-part-externally (&optional handle)
4423 "View the MIME part under point with an external viewer."
4425 (gnus-article-check-buffer)
4426 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4427 (mm-user-display-methods nil)
4428 (mm-inlined-types nil)
4429 (mail-parse-charset gnus-newsgroup-charset)
4430 (mail-parse-ignored-charsets
4431 (with-current-buffer gnus-summary-buffer
4432 gnus-newsgroup-ignored-charsets)))
4434 (if (mm-handle-undisplayer handle)
4435 (mm-remove-part handle)
4436 (mm-display-part handle)))))
4438 (defun gnus-mime-view-part-internally (&optional handle)
4439 "View the MIME part under point with an internal viewer.
4440 If no internal viewer is available, use an external viewer."
4442 (gnus-article-check-buffer)
4443 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4444 (mm-inlined-types '(".*"))
4445 (mm-inline-large-images t)
4446 (mail-parse-charset gnus-newsgroup-charset)
4447 (mail-parse-ignored-charsets
4448 (with-current-buffer gnus-summary-buffer
4449 gnus-newsgroup-ignored-charsets))
4450 (inhibit-read-only t))
4452 (if (mm-handle-undisplayer handle)
4453 (mm-remove-part handle)
4454 (mm-display-part handle)))))
4456 (defun gnus-mime-action-on-part (&optional action)
4457 "Do something with the MIME attachment at \(point\)."
4459 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4460 (gnus-article-check-buffer)
4461 (let ((action-pair (assoc action gnus-mime-action-alist)))
4463 (funcall (cdr action-pair)))))
4465 (defun gnus-article-part-wrapper (n function)
4466 (with-current-buffer gnus-article-buffer
4467 (when (> n (length gnus-article-mime-handle-alist))
4468 (error "No such part"))
4469 (gnus-article-goto-part n)
4470 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4471 (funcall function handle))))
4473 (defun gnus-article-pipe-part (n)
4474 "Pipe MIME part N, which is the numerical prefix."
4476 (gnus-article-part-wrapper n 'mm-pipe-part))
4478 (defun gnus-article-save-part (n)
4479 "Save MIME part N, which is the numerical prefix."
4481 (gnus-article-part-wrapper n 'mm-save-part))
4483 (defun gnus-article-interactively-view-part (n)
4484 "View MIME part N interactively, which is the numerical prefix."
4486 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4488 (defun gnus-article-copy-part (n)
4489 "Copy MIME part N, which is the numerical prefix."
4491 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4493 (defun gnus-article-view-part-as-charset (n)
4494 "View MIME part N using a specified charset.
4495 N is the numerical prefix."
4497 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4499 (defun gnus-article-view-part-externally (n)
4500 "View MIME part N externally, which is the numerical prefix."
4502 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4504 (defun gnus-article-inline-part (n)
4505 "Inline MIME part N, which is the numerical prefix."
4507 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4509 (defun gnus-article-mime-match-handle-first (condition)
4512 (dolist (ihandle gnus-article-mime-handle-alist)
4514 ((functionp condition)
4515 (funcall condition (cdr ihandle)))
4516 ((eq condition 'undisplayed)
4517 (not (or (mm-handle-undisplayer (cdr ihandle))
4518 (equal (mm-handle-media-type (cdr ihandle))
4519 "multipart/alternative"))))
4520 ((eq condition 'undisplayed-alternative)
4521 (not (mm-handle-undisplayer (cdr ihandle))))
4523 (gnus-article-goto-part (car ihandle))
4524 (or (not n) (< (car ihandle) n)))
4525 (setq n (car ihandle))))
4529 (defun gnus-article-view-part (&optional n)
4530 "View MIME part N, which is the numerical prefix."
4532 (with-current-buffer gnus-article-buffer
4533 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4534 gnus-article-mime-match-handle-function)))
4535 (when (> n (length gnus-article-mime-handle-alist))
4536 (error "No such part"))
4537 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4538 (when (gnus-article-goto-part n)
4539 (if (equal (car handle) "multipart/alternative")
4540 (gnus-article-press-button)
4541 (when (eq (gnus-mm-display-part handle) 'internal)
4542 (gnus-set-window-start)))))))
4544 (defsubst gnus-article-mime-total-parts ()
4545 (if (bufferp (car gnus-article-mime-handles))
4547 (1- (length gnus-article-mime-handles))))
4549 (defun gnus-mm-display-part (handle)
4550 "Display HANDLE and fix MIME button."
4551 (let ((id (get-text-property (point) 'gnus-part))
4553 (inhibit-read-only t))
4556 (let ((window (selected-window))
4557 (mail-parse-charset gnus-newsgroup-charset)
4558 (mail-parse-ignored-charsets
4559 (if (gnus-buffer-live-p gnus-summary-buffer)
4560 (with-current-buffer gnus-summary-buffer
4561 gnus-newsgroup-ignored-charsets)
4565 (let ((win (gnus-get-buffer-window (current-buffer) t))
4568 (select-window win))
4571 (if (mm-handle-displayed-p handle)
4572 ;; This will remove the part.
4573 (mm-display-part handle)
4575 (narrow-to-region (point)
4576 (if (eobp) (point) (1+ (point))))
4577 (mm-display-part handle)
4578 ;; We narrow to the part itself and
4579 ;; then call the treatment functions.
4580 (goto-char (point-min))
4582 (narrow-to-region (point) (point-max))
4585 (gnus-article-mime-total-parts)
4586 (mm-handle-media-type handle)))))
4587 (if (window-live-p window)
4588 (select-window window)))))
4591 (gnus-insert-mime-button
4592 handle id (list (mm-handle-displayed-p handle)))
4593 (goto-char point))))
4595 (defun gnus-article-goto-part (n)
4596 "Go to MIME part N."
4597 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4599 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4600 (let ((gnus-tmp-name
4601 (or (mail-content-type-get (mm-handle-type handle) 'name)
4602 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4603 (mail-content-type-get (mm-handle-type handle) 'url)
4605 (gnus-tmp-type (mm-handle-media-type handle))
4606 (gnus-tmp-description
4607 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4610 (if (if displayed (car displayed)
4611 (mm-handle-displayed-p handle))
4613 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4615 gnus-tmp-type-long b e)
4616 (when (string-match ".*/" gnus-tmp-name)
4617 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4618 (setq gnus-tmp-type-long (concat gnus-tmp-type
4619 (and (not (equal gnus-tmp-name ""))
4620 (concat "; " gnus-tmp-name))))
4621 (unless (equal gnus-tmp-description "")
4622 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4627 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4628 `(keymap ,gnus-mime-button-map
4629 gnus-callback gnus-mm-display-part
4630 gnus-part ,gnus-tmp-id
4631 article-type annotation
4634 ;; Exclude a newline.
4637 (widget-convert-button
4640 :action 'gnus-widget-press-button
4641 :button-keymap gnus-mime-button-map
4643 (lambda (widget/window &optional overlay pos)
4644 ;; Needed to properly clear the message due to a bug in
4645 ;; wid-edit (XEmacs only).
4646 (if (boundp 'help-echo-owns-message)
4647 (setq help-echo-owns-message t))
4649 "%S: %s the MIME part; %S: more options"
4650 (aref gnus-mouse-2 0)
4651 ;; XEmacs will get a single widget arg; Emacs 21 will get
4652 ;; window, overlay, position.
4653 (if (mm-handle-displayed-p
4655 (with-current-buffer (gnus-overlay-buffer overlay)
4656 (widget-get (widget-at (gnus-overlay-start overlay))
4658 (widget-get widget/window :mime-handle)))
4660 (aref gnus-down-mouse-3 0))))))
4662 (defun gnus-widget-press-button (elems el)
4663 (goto-char (widget-get elems :from))
4664 (gnus-article-press-button))
4666 (defvar gnus-displaying-mime nil)
4668 (defun gnus-display-mime (&optional ihandles)
4669 "Display the MIME parts."
4671 (save-selected-window
4672 (let ((window (get-buffer-window gnus-article-buffer))
4675 (select-window window)
4676 ;; We have to do this since selecting the window
4677 ;; may change the point. So we set the window point.
4678 (set-window-point window point)))
4679 (let ((handles ihandles)
4680 (inhibit-read-only t)
4683 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
4684 (when gnus-article-emulate-mime
4685 (mm-uu-dissect-text-parts handles)))
4686 (gnus-article-emulate-mime
4687 (setq handles (mm-uu-dissect))))
4688 (when (and (not ihandles)
4689 (not gnus-displaying-mime))
4690 ;; Top-level call; we clean up.
4691 (when gnus-article-mime-handles
4692 (mm-destroy-parts gnus-article-mime-handles)
4693 (setq gnus-article-mime-handle-alist nil));; A trick.
4694 (setq gnus-article-mime-handles handles)
4695 ;; We allow users to glean info from the handles.
4696 (when gnus-article-mime-part-function
4697 (gnus-mime-part-function handles)))
4699 (or (not (stringp (car handles)))
4702 (when (and (not ihandles)
4703 (not gnus-displaying-mime))
4704 ;; Clean up for mime parts.
4706 (delete-region (point) (point-max)))
4707 (let ((gnus-displaying-mime t))
4708 (gnus-mime-display-part handles)))
4711 (narrow-to-region (point) (point-max))
4712 (gnus-treat-article nil 1 1)
4715 ;; Highlight the headers.
4719 (narrow-to-region (point-min) (point))
4720 (gnus-article-save-original-date
4721 (gnus-treat-article 'head)))))))))
4723 (defcustom gnus-mime-display-multipart-as-mixed nil
4724 "Display \"multipart\" parts as \"multipart/mixed\".
4726 If t, it overrides nil values of
4727 `gnus-mime-display-multipart-alternative-as-mixed' and
4728 `gnus-mime-display-multipart-related-as-mixed'."
4729 :group 'gnus-article-mime
4732 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4733 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4735 :group 'gnus-article-mime
4738 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4739 "Display \"multipart/related\" parts as \"multipart/mixed\".
4741 If displaying \"text/html\" is discouraged \(see
4742 `mm-discouraged-alternatives'\) images or other material inside a
4743 \"multipart/related\" part might be overlooked when this variable is nil."
4745 :group 'gnus-article-mime
4748 (defun gnus-mime-display-part (handle)
4751 ((not (stringp (car handle)))
4752 (gnus-mime-display-single handle))
4753 ;; User-defined multipart
4754 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4755 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4757 ;; multipart/alternative
4758 ((and (equal (car handle) "multipart/alternative")
4759 (not (or gnus-mime-display-multipart-as-mixed
4760 gnus-mime-display-multipart-alternative-as-mixed)))
4761 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4762 (push (cons id handle) gnus-article-mime-handle-alist)
4763 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4764 ;; multipart/related
4765 ((and (equal (car handle) "multipart/related")
4766 (not (or gnus-mime-display-multipart-as-mixed
4767 gnus-mime-display-multipart-related-as-mixed)))
4768 ;;;!!!We should find the start part, but we just default
4769 ;;;!!!to the first part.
4770 ;;(gnus-mime-display-part (cadr handle))
4771 ;;;!!! Most multipart/related is an HTML message plus images.
4772 ;;;!!! Unfortunately we are unable to let W3 display those
4773 ;;;!!! included images, so we just display it as a mixed multipart.
4774 ;;(gnus-mime-display-mixed (cdr handle))
4775 ;;;!!! No, w3 can display everything just fine.
4776 (gnus-mime-display-part (cadr handle)))
4777 ((equal (car handle) "multipart/signed")
4778 (gnus-add-wash-type 'signed)
4779 (gnus-mime-display-security handle))
4780 ((equal (car handle) "multipart/encrypted")
4781 (gnus-add-wash-type 'encrypted)
4782 (gnus-mime-display-security handle))
4783 ;; Other multiparts are handled like multipart/mixed.
4785 (gnus-mime-display-mixed (cdr handle)))))
4787 (defun gnus-mime-part-function (handles)
4788 (if (stringp (car handles))
4789 (mapcar 'gnus-mime-part-function (cdr handles))
4790 (funcall gnus-article-mime-part-function handles)))
4792 (defun gnus-mime-display-mixed (handles)
4793 (mapcar 'gnus-mime-display-part handles))
4795 (defun gnus-mime-display-single (handle)
4796 (let ((type (mm-handle-media-type handle))
4797 (ignored gnus-ignored-mime-types)
4804 (when (string-match (pop ignored) type)
4805 (throw 'ignored nil)))
4806 (if (and (setq not-attachment
4807 (and (not (mm-inline-override-p handle))
4808 (or (not (mm-handle-disposition handle))
4809 (equal (car (mm-handle-disposition handle))
4811 (mm-attachment-override-p handle))))
4812 (mm-automatic-display-p handle)
4814 (mm-inlinable-p handle)
4815 (mm-inlined-p handle))
4816 (mm-automatic-external-display-p type)))
4818 (when (equal (mm-handle-media-supertype handle) "text")
4820 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4822 (push (cons id handle) gnus-article-mime-handle-alist)
4823 (when (or (not display)
4824 (not (gnus-unbuttonized-mime-type-p type)))
4825 (gnus-insert-mime-button
4826 handle id (list (or display (and not-attachment text))))
4827 (gnus-article-insert-newline)
4828 ;; Remember modify the number of forward lines.
4836 (let ((mail-parse-charset gnus-newsgroup-charset)
4837 (mail-parse-ignored-charsets
4838 (save-excursion (condition-case ()
4839 (set-buffer gnus-summary-buffer)
4841 gnus-newsgroup-ignored-charsets)))
4842 (mm-display-part handle t))
4843 (goto-char (point-max)))
4844 ((and text not-attachment)
4848 (gnus-article-insert-newline)
4849 (mm-display-inline handle)
4850 (goto-char (point-max))))
4854 (narrow-to-region beg (point))
4857 (gnus-article-mime-total-parts)
4858 (mm-handle-media-type handle)))))))))
4860 (defun gnus-unbuttonized-mime-type-p (type)
4861 "Say whether TYPE is to be unbuttonized."
4862 (unless gnus-inhibit-mime-unbuttonizing
4864 (let ((types gnus-unbuttonized-mime-types))
4866 (when (string-match (pop types) type)
4867 (throw 'found t)))))
4869 (let ((types gnus-buttonized-mime-types))
4871 (when (string-match (pop types) type)
4872 (throw 'found t)))))))))
4874 (defun gnus-article-insert-newline ()
4875 "Insert a newline, but mark it as undeletable."
4876 (gnus-put-text-property
4877 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4879 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4880 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4883 handle (inhibit-read-only t) from props begend not-pref)
4884 (save-window-excursion
4887 (narrow-to-region (car ibegend)
4890 (goto-char (car ibegend))
4893 (delete-region (point-min) (point-max))
4894 (mm-remove-parts handles))
4895 (setq begend (list (point-marker)))
4897 (unless (setq not-pref (cadr (member preferred ihandles)))
4898 (setq not-pref (car ihandles)))
4901 (not (gnus-unbuttonized-mime-type-p
4902 "multipart/alternative")))
4903 (gnus-add-text-properties
4906 (insert (format "%d. " id))
4910 (unless ,(not ibegend)
4911 (setq gnus-article-mime-handle-alist
4912 ',gnus-article-mime-handle-alist))
4913 (gnus-mime-display-alternative
4914 ',ihandles ',not-pref ',begend ,id))
4915 keymap ,gnus-mime-button-map
4916 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4917 face ,gnus-article-button-face
4920 (widget-convert-button 'link from (point)
4921 :action 'gnus-widget-press-button
4922 :button-keymap gnus-widget-button-keymap)
4924 (while (setq handle (pop handles))
4925 (gnus-add-text-properties
4928 (insert (format "(%c) %-18s"
4929 (if (equal handle preferred) ?* ? )
4930 (mm-handle-media-type handle)))
4934 (unless ,(not ibegend)
4935 (setq gnus-article-mime-handle-alist
4936 ',gnus-article-mime-handle-alist))
4937 (gnus-mime-display-alternative
4938 ',ihandles ',handle ',begend ,id))
4939 keymap ,gnus-mime-button-map
4940 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4941 face ,gnus-article-button-face
4944 (widget-convert-button 'link from (point)
4945 :action 'gnus-widget-press-button
4946 :button-keymap gnus-widget-button-keymap)
4950 (if (stringp (car preferred))
4951 (gnus-display-mime preferred)
4952 (let ((mail-parse-charset gnus-newsgroup-charset)
4953 (mail-parse-ignored-charsets
4954 (with-current-buffer gnus-summary-buffer
4955 gnus-newsgroup-ignored-charsets)))
4956 (mm-display-part preferred)
4960 (narrow-to-region (car begend) (point-max))
4962 nil (length gnus-article-mime-handle-alist)
4963 (gnus-article-mime-total-parts)
4964 (mm-handle-media-type handle))))))
4965 (goto-char (point-max))
4966 (setcdr begend (point-marker)))))
4968 (goto-char point))))
4970 (defconst gnus-article-wash-status-strings
4971 (let ((alist '((cite "c" "Possible hidden citation text"
4972 " " "All citation text visible")
4973 (headers "h" "Hidden headers"
4974 " " "All headers visible.")
4975 (pgp "p" "Encrypted or signed message status hidden"
4976 " " "No hidden encryption nor digital signature status")
4977 (signature "s" "Signature has been hidden"
4978 " " "Signature is visible")
4979 (overstrike "o" "Overstrike (^H) characters applied"
4980 " " "No overstrike characters applied")
4981 (emphasis "e" "/*_Emphasis_*/ characters applied"
4982 " " "No /*_emphasis_*/ characters applied")))
4984 (dolist (entry alist result)
4985 (let ((key (nth 0 entry))
4986 (on (copy-sequence (nth 1 entry)))
4987 (on-help (nth 2 entry))
4988 (off (copy-sequence (nth 3 entry)))
4989 (off-help (nth 4 entry)))
4990 (put-text-property 0 1 'help-echo on-help on)
4991 (put-text-property 0 1 'help-echo off-help off)
4992 (push (list key on off) result))))
4993 "Alist of strings describing wash status in the mode line.
4994 Each entry has the form (KEY ON OF), where the KEY is a symbol
4995 representing the particular washing function, ON is the string to use
4996 in the article mode line when the washing function is active, and OFF
4997 is the string to use when it is inactive.")
4999 (defun gnus-article-wash-status-entry (key value)
5000 (let ((entry (assoc key gnus-article-wash-status-strings)))
5001 (if value (nth 1 entry) (nth 2 entry))))
5003 (defun gnus-article-wash-status ()
5004 "Return a string which display status of article washing."
5005 (with-current-buffer gnus-article-buffer
5006 (let ((cite (memq 'cite gnus-article-wash-types))
5007 (headers (memq 'headers gnus-article-wash-types))
5008 (boring (memq 'boring-headers gnus-article-wash-types))
5009 (pgp (memq 'pgp gnus-article-wash-types))
5010 (pem (memq 'pem gnus-article-wash-types))
5011 (signed (memq 'signed gnus-article-wash-types))
5012 (encrypted (memq 'encrypted gnus-article-wash-types))
5013 (signature (memq 'signature gnus-article-wash-types))
5014 (overstrike (memq 'overstrike gnus-article-wash-types))
5015 (emphasis (memq 'emphasis gnus-article-wash-types)))
5017 (gnus-article-wash-status-entry 'cite cite)
5018 (gnus-article-wash-status-entry 'headers (or headers boring))
5019 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5020 (gnus-article-wash-status-entry 'signature signature)
5021 (gnus-article-wash-status-entry 'overstrike overstrike)
5022 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5024 (defun gnus-add-wash-type (type)
5025 "Add a washing of TYPE to the current status."
5026 (add-to-list 'gnus-article-wash-types type))
5028 (defun gnus-delete-wash-type (type)
5029 "Add a washing of TYPE to the current status."
5030 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5032 (defun gnus-add-image (category image)
5033 "Add IMAGE of CATEGORY to the list of displayed images."
5034 (let ((entry (assq category gnus-article-image-alist)))
5036 (setq entry (list category))
5037 (push entry gnus-article-image-alist))
5038 (nconc entry (list image))))
5040 (defun gnus-delete-images (category)
5041 "Delete all images in CATEGORY."
5042 (let ((entry (assq category gnus-article-image-alist)))
5043 (dolist (image (cdr entry))
5044 (gnus-remove-image image category))
5045 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5046 (gnus-delete-wash-type category)))
5048 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5050 (defun gnus-article-maybe-hide-headers ()
5051 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5052 Provided for backwards compatibility."
5053 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5054 (not (with-current-buffer gnus-summary-buffer
5055 gnus-have-all-headers)))
5056 (not gnus-inhibit-hiding))
5057 (gnus-article-hide-headers)))
5061 (defun gnus-output-to-file (file-name)
5062 "Append the current article to a file named FILE-NAME."
5063 (let ((artbuf (current-buffer)))
5065 (insert-buffer-substring artbuf)
5066 ;; Append newline at end of the buffer as separator, and then
5068 (goto-char (point-max))
5070 (let ((file-name-coding-system nnmail-pathname-coding-system))
5071 (mm-append-to-file (point-min) (point-max) file-name))
5074 (defun gnus-narrow-to-page (&optional arg)
5075 "Narrow the article buffer to a page.
5076 If given a numerical ARG, move forward ARG pages."
5078 (setq arg (if arg (prefix-numeric-value arg) 0))
5080 (set-buffer gnus-article-buffer)
5081 (goto-char (point-min))
5083 ;; Remove any old next/prev buttons.
5084 (when (gnus-visual-p 'page-marker)
5085 (let ((inhibit-read-only t))
5086 (gnus-remove-text-with-property 'gnus-prev)
5087 (gnus-remove-text-with-property 'gnus-next)))
5090 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5092 (re-search-forward page-delimiter nil 'move arg)))
5093 (goto-char (match-end 0))
5095 (goto-char (point-min))
5096 (setq gnus-page-broken
5097 (and (re-search-forward page-delimiter nil t) t))))
5098 (when gnus-page-broken
5101 (if (re-search-forward page-delimiter nil 'move)
5104 (when (and (gnus-visual-p 'page-marker)
5105 (> (point-min) (save-restriction (widen) (point-min))))
5107 (goto-char (point-min))
5108 (gnus-insert-prev-page-button)))
5109 (when (and (gnus-visual-p 'page-marker)
5110 (< (point-max) (save-restriction (widen) (point-max))))
5112 (goto-char (point-max))
5113 (gnus-insert-next-page-button))))))
5115 ;; Article mode commands
5117 (defun gnus-article-goto-next-page ()
5118 "Show the next page of the article."
5120 (when (gnus-article-next-page)
5121 (goto-char (point-min))
5122 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5125 (defun gnus-article-goto-prev-page ()
5126 "Show the previous page of the article."
5129 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5130 (gnus-article-prev-page nil)))
5132 ;; This is cleaner but currently breaks `gnus-pick-mode':
5134 ;; (defun gnus-article-goto-next-page ()
5135 ;; "Show the next page of the article."
5137 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5138 ;; (gnus-summary-next-page)))
5140 ;; (defun gnus-article-goto-prev-page ()
5141 ;; "Show the next page of the article."
5143 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5144 ;; (gnus-summary-prev-page)))
5146 (defun gnus-article-next-page (&optional lines)
5147 "Show the next page of the current article.
5148 If end of article, return non-nil. Otherwise return nil.
5149 Argument LINES specifies lines to be scrolled up."
5151 (move-to-window-line -1)
5154 (and (pos-visible-in-window-p) ;Not continuation line.
5155 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5156 ;; Nothing in this page.
5157 (if (or (not gnus-page-broken)
5162 (eobp)))) ;Real end-of-buffer?
5164 (when gnus-article-over-scroll
5165 (gnus-article-next-page-1 lines))
5167 (gnus-narrow-to-page 1) ;Go to next page.
5169 ;; More in this page.
5170 (gnus-article-next-page-1 lines)
5173 (defun gnus-article-next-page-1 (lines)
5174 (let ((scroll-in-place nil))
5178 ;; Long lines may cause an end-of-buffer error.
5179 (goto-char (point-max)))))
5180 (move-to-window-line 0))
5182 (defun gnus-article-prev-page (&optional lines)
5183 "Show previous page of current article.
5184 Argument LINES specifies lines to be scrolled down."
5186 (move-to-window-line 0)
5187 (if (and gnus-page-broken
5189 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5191 (gnus-narrow-to-page -1) ;Go to previous page.
5192 (goto-char (point-max))
5194 (let ((scroll-in-place nil))
5198 (beginning-of-buffer
5199 (goto-char (point-min))))
5200 (move-to-window-line 0)))))
5202 (defun gnus-article-only-boring-p ()
5203 "Decide whether there is only boring text remaining in the article.
5204 Something \"interesting\" is a word of at least two letters that does
5205 not have a face in `gnus-article-boring-faces'."
5206 (when (and gnus-article-skip-boring
5207 (boundp 'gnus-article-boring-faces)
5208 (symbol-value 'gnus-article-boring-faces))
5211 (while (re-search-forward "\\b\\w\\w" nil t)
5213 (when (not (gnus-intersection
5214 (gnus-faces-at (point))
5215 (symbol-value 'gnus-article-boring-faces)))
5216 (throw 'only-boring nil)))
5217 (throw 'only-boring t)))))
5219 (defun gnus-article-refer-article ()
5220 "Read article specified by message-id around point."
5223 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5224 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5225 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5226 (let ((msg-id (concat "<" (match-string 0) ">")))
5227 (set-buffer gnus-summary-buffer)
5228 (gnus-summary-refer-article msg-id))
5229 (error "No references around point"))))
5231 (defun gnus-article-show-summary ()
5232 "Reconfigure windows to show summary buffer."
5234 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5235 (error "There is no summary buffer for this article buffer")
5236 (gnus-article-set-globals)
5237 (gnus-configure-windows 'article)
5238 (gnus-summary-goto-subject gnus-current-article)
5239 (gnus-summary-position-point)))
5241 (defun gnus-article-describe-briefly ()
5242 "Describe article mode commands briefly."
5244 (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")))
5246 (defun gnus-article-summary-command ()
5247 "Execute the last keystroke in the summary buffer."
5249 (let ((obuf (current-buffer))
5250 (owin (current-window-configuration))
5252 (switch-to-buffer gnus-article-current-summary 'norecord)
5253 (setq func (lookup-key (current-local-map) (this-command-keys)))
5254 (call-interactively func)
5256 (set-window-configuration owin)
5257 (set-window-point (get-buffer-window (current-buffer)) (point))))
5259 (defun gnus-article-summary-command-nosave ()
5260 "Execute the last keystroke in the summary buffer."
5263 (pop-to-buffer gnus-article-current-summary 'norecord)
5264 (setq func (lookup-key (current-local-map) (this-command-keys)))
5265 (call-interactively func)))
5267 (defun gnus-article-check-buffer ()
5268 "Beep if not in an article buffer."
5269 (unless (equal major-mode 'gnus-article-mode)
5270 (error "Command invoked outside of a Gnus article buffer")))
5272 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5273 "Read a summary buffer key sequence and execute it from the article buffer."
5275 (gnus-article-check-buffer)
5277 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5278 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5279 "=" "^" "\M-^" "|"))
5285 '("n" "Gn" "p" "Gp"))
5288 (set-buffer gnus-article-current-summary)
5289 (let (gnus-pick-mode)
5290 (push (or key last-command-event) unread-command-events)
5291 (setq keys (if (featurep 'xemacs)
5292 (events-to-keys (read-key-sequence nil))
5293 (read-key-sequence nil)))))
5297 (if (or (member keys nosaves)
5298 (member keys nosave-but-article)
5299 (member keys nosave-in-article))
5301 (save-window-excursion
5302 (pop-to-buffer gnus-article-current-summary 'norecord)
5303 ;; We disable the pick minor mode commands.
5304 (let (gnus-pick-mode)
5305 (setq func (lookup-key (current-local-map) keys))))
5309 (unless (member keys nosave-in-article)
5310 (set-buffer gnus-article-current-summary))
5311 (call-interactively func)
5312 (setq new-sum-point (point)))
5313 (when (member keys nosave-but-article)
5314 (pop-to-buffer gnus-article-buffer 'norecord)))
5315 ;; These commands should restore window configuration.
5316 (let ((obuf (current-buffer))
5317 (owin (current-window-configuration))
5319 win func in-buffer selected new-sum-start new-sum-hscroll)
5320 (cond (not-restore-window
5321 (pop-to-buffer gnus-article-current-summary 'norecord))
5322 ((setq win (get-buffer-window gnus-article-current-summary))
5323 (select-window win))
5325 (switch-to-buffer gnus-article-current-summary 'norecord)))
5326 (setq in-buffer (current-buffer))
5327 ;; We disable the pick minor mode commands.
5328 (if (and (setq func (let (gnus-pick-mode)
5329 (lookup-key (current-local-map) keys)))
5332 (call-interactively func)
5333 (when (eq win (selected-window))
5334 (setq new-sum-point (point)
5335 new-sum-start (window-start win)
5336 new-sum-hscroll (window-hscroll win)))
5337 (when (eq in-buffer (current-buffer))
5338 (setq selected (gnus-summary-select-article))
5340 (unless not-restore-window
5341 (set-window-configuration owin))
5342 (when (eq selected 'old)
5344 (set-window-start (get-buffer-window (current-buffer))
5346 (set-window-point (get-buffer-window (current-buffer))
5348 (when (and (not not-restore-window)
5350 (set-window-point win new-sum-point)
5351 (set-window-start win new-sum-start)
5352 (set-window-hscroll win new-sum-hscroll))))
5353 (set-window-configuration owin)
5356 (defun gnus-article-describe-key (key)
5357 "Display documentation of the function invoked by KEY. KEY is a string."
5358 (interactive "kDescribe key: ")
5359 (gnus-article-check-buffer)
5360 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5362 (set-buffer gnus-article-current-summary)
5363 (let (gnus-pick-mode)
5364 (if (featurep 'xemacs)
5366 (push (elt key 0) unread-command-events)
5367 (setq key (events-to-keys
5368 (read-key-sequence "Describe key: "))))
5369 (setq unread-command-events
5371 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5372 (string-to-list key)))
5373 (setq key (read-key-sequence "Describe key: "))))
5375 (describe-key key)))
5377 (defun gnus-article-describe-key-briefly (key &optional insert)
5378 "Display documentation of the function invoked by KEY. KEY is a string."
5379 (interactive "kDescribe key: \nP")
5380 (gnus-article-check-buffer)
5381 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5383 (set-buffer gnus-article-current-summary)
5384 (let (gnus-pick-mode)
5385 (if (featurep 'xemacs)
5387 (push (elt key 0) unread-command-events)
5388 (setq key (events-to-keys
5389 (read-key-sequence "Describe key: "))))
5390 (setq unread-command-events
5392 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5393 (string-to-list key)))
5394 (setq key (read-key-sequence "Describe key: "))))
5395 (describe-key-briefly key insert))
5396 (describe-key-briefly key insert)))
5398 (defun gnus-article-reply-with-original (&optional wide)
5399 "Start composing a reply mail to the current message.
5400 The text in the region will be yanked. If the region isn't active,
5401 the entire article will be yanked."
5403 (let ((article (cdr gnus-article-current))
5405 (if (not (gnus-region-active-p))
5406 (with-current-buffer gnus-summary-buffer
5407 (gnus-summary-reply (list (list article)) wide))
5408 (setq contents (buffer-substring (point) (mark t)))
5409 ;; Deactivate active regions.
5410 (when (and (boundp 'transient-mark-mode)
5411 transient-mark-mode)
5412 (setq mark-active nil))
5413 (with-current-buffer gnus-summary-buffer
5415 (list (list article contents)) wide)))))
5417 (defun gnus-article-followup-with-original ()
5418 "Compose a followup to the current article.
5419 The text in the region will be yanked. If the region isn't active,
5420 the entire article will be yanked."
5422 (let ((article (cdr gnus-article-current))
5424 (if (not (gnus-region-active-p))
5425 (with-current-buffer gnus-summary-buffer
5426 (gnus-summary-followup (list (list article))))
5427 (setq contents (buffer-substring (point) (mark t)))
5428 ;; Deactivate active regions.
5429 (when (and (boundp 'transient-mark-mode)
5430 transient-mark-mode)
5431 (setq mark-active nil))
5432 (with-current-buffer gnus-summary-buffer
5433 (gnus-summary-followup
5434 (list (list article contents)))))))
5436 (defun gnus-article-hide (&optional arg force)
5437 "Hide all the gruft in the current article.
5438 This means that signatures, cited text and (some) headers will be
5440 If given a prefix, show the hidden text instead."
5441 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5442 (gnus-article-hide-headers arg)
5443 (gnus-article-hide-list-identifiers arg)
5444 (gnus-article-hide-citation-maybe arg force)
5445 (gnus-article-hide-signature arg))
5447 (defun gnus-article-maybe-highlight ()
5448 "Do some article highlighting if article highlighting is requested."
5449 (when (gnus-visual-p 'article-highlight 'highlight)
5450 (gnus-article-highlight-some)))
5452 (defun gnus-check-group-server ()
5453 ;; Make sure the connection to the server is alive.
5454 (unless (gnus-server-opened
5455 (gnus-find-method-for-group gnus-newsgroup-name))
5456 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5457 (gnus-request-group gnus-newsgroup-name t)))
5460 (autoload 'nneething-get-file-name "nneething"))
5462 (defun gnus-request-article-this-buffer (article group)
5463 "Get an article and insert it into this buffer."
5464 (let (do-update-line sparse-header)
5468 (gnus-kill-all-overlays)
5469 (setq group (or group gnus-newsgroup-name))
5471 ;; Using `gnus-request-article' directly will insert the article into
5472 ;; `nntp-server-buffer' - so we'll save some time by not having to
5473 ;; copy it from the server buffer into the article buffer.
5475 ;; We only request an article by message-id when we do not have the
5476 ;; headers for it, so we'll have to get those.
5477 (when (stringp article)
5478 (gnus-read-header article))
5480 ;; If the article number is negative, that means that this article
5481 ;; doesn't belong in this newsgroup (possibly), so we find its
5482 ;; message-id and request it by id instead of number.
5483 (when (and (numberp article)
5485 (get-buffer gnus-summary-buffer)
5486 (gnus-buffer-exists-p gnus-summary-buffer))
5488 (set-buffer gnus-summary-buffer)
5489 (let ((header (gnus-summary-article-header article)))
5492 ((memq article gnus-newsgroup-sparse)
5493 ;; This is a sparse gap article.
5494 (setq do-update-line article)
5495 (setq article (mail-header-id header))
5496 (setq sparse-header (gnus-read-header article))
5497 (setq gnus-newsgroup-sparse
5498 (delq article gnus-newsgroup-sparse)))
5500 ;; It's a real article.
5501 (setq article (mail-header-id header)))
5503 ;; It is an extracted pseudo-article.
5504 (setq article 'pseudo)
5505 (gnus-request-pseudo-article header))))
5507 (let ((method (gnus-find-method-for-group
5508 gnus-newsgroup-name)))
5509 (when (and (eq (car method) 'nneething)
5511 (let ((dir (nneething-get-file-name
5512 (mail-header-id header))))
5513 (when (and (stringp dir)
5514 (file-directory-p dir))
5515 (setq article 'nneething)
5516 (gnus-group-enter-directory dir))))))))
5519 ;; Refuse to select canceled articles.
5520 ((and (numberp article)
5522 (get-buffer gnus-summary-buffer)
5523 (gnus-buffer-exists-p gnus-summary-buffer)
5524 (eq (cdr (with-current-buffer gnus-summary-buffer
5525 (assq article gnus-newsgroup-reads)))
5526 gnus-canceled-mark))
5528 ;; We first check `gnus-original-article-buffer'.
5529 ((and (get-buffer gnus-original-article-buffer)
5531 (with-current-buffer gnus-original-article-buffer
5532 (and (equal (car gnus-original-article) group)
5533 (eq (cdr gnus-original-article) article))))
5534 (insert-buffer-substring gnus-original-article-buffer)
5536 ;; Check the backlog.
5537 ((and gnus-keep-backlog
5538 (gnus-backlog-request-article group article (current-buffer)))
5540 ;; Check asynchronous pre-fetch.
5541 ((gnus-async-request-fetched-article group article (current-buffer))
5542 (gnus-async-prefetch-next group article gnus-summary-buffer)
5543 (when (and (numberp article) gnus-keep-backlog)
5544 (gnus-backlog-enter-article group article (current-buffer)))
5547 ((and gnus-use-cache
5549 (gnus-cache-request-article article group))
5551 ;; Check the agent cache.
5552 ((gnus-agent-request-article article group)
5554 ;; Get the article and put into the article buffer.
5555 ((or (stringp article)
5557 (let ((gnus-override-method gnus-override-method)
5558 (methods (and (stringp article)
5559 gnus-refer-article-method))
5560 (backend (car (gnus-find-method-for-group
5561 gnus-newsgroup-name)))
5563 (inhibit-read-only t))
5564 (if (or (not (listp methods))
5565 (and (symbolp (car methods))
5566 (assq (car methods) nnoo-definition-alist)))
5567 (setq methods (list methods)))
5568 (when (and (null gnus-override-method)
5570 (setq gnus-override-method (pop methods)))
5572 (when (eq gnus-override-method 'current)
5573 (setq gnus-override-method
5574 (with-current-buffer gnus-summary-buffer
5575 gnus-current-select-method)))
5577 (gnus-kill-all-overlays)
5578 (let ((gnus-newsgroup-name group))
5579 (gnus-check-group-server))
5581 ((gnus-request-article article group (current-buffer))
5582 (when (numberp article)
5583 (gnus-async-prefetch-next group article
5584 gnus-summary-buffer)
5585 (when gnus-keep-backlog
5586 (gnus-backlog-enter-article
5587 group article (current-buffer))))
5588 (setq result 'article))
5590 (setq gnus-override-method (pop methods)))
5591 ((not (string-match "^400 "
5592 (nnheader-get-report backend)))
5593 ;; If we get 400 server disconnect, reconnect and
5594 ;; retry; otherwise, assume the article has expired.
5595 (setq result 'done))))
5596 (and (eq result 'article) 'article)))
5600 ;; Associate this article with the current summary buffer.
5601 (setq gnus-article-current-summary gnus-summary-buffer)
5603 ;; Take the article from the original article buffer
5604 ;; and place it in the buffer it's supposed to be in.
5605 (when (and (get-buffer gnus-article-buffer)
5606 (equal (buffer-name (current-buffer))
5607 (buffer-name (get-buffer gnus-article-buffer))))
5609 (if (get-buffer gnus-original-article-buffer)
5610 (set-buffer gnus-original-article-buffer)
5611 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5612 (buffer-disable-undo)
5613 (setq major-mode 'gnus-original-article-mode)
5614 (setq buffer-read-only t))
5615 (let ((inhibit-read-only t))
5617 (insert-buffer-substring gnus-article-buffer))
5618 (setq gnus-original-article (cons group article)))
5621 (run-hooks 'gnus-article-decode-hook)
5622 ;; Mark article as decoded or not.
5623 (setq gnus-article-decoded-p gnus-article-decode-hook))
5625 ;; Update sparse articles.
5626 (when (and do-update-line
5627 (or (numberp article)
5629 (let ((buf (current-buffer)))
5630 (set-buffer gnus-summary-buffer)
5631 (gnus-summary-update-article do-update-line sparse-header)
5632 (gnus-summary-goto-subject do-update-line nil t)
5633 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5635 (set-buffer buf))))))
5641 (defcustom gnus-article-edit-mode-hook nil
5642 "Hook run in article edit mode buffers."
5643 :group 'gnus-article-various
5646 (defvar gnus-article-edit-done-function nil)
5648 (defvar gnus-article-edit-mode-map nil)
5650 ;; Should we be using derived.el for this?
5651 (unless gnus-article-edit-mode-map
5652 (setq gnus-article-edit-mode-map (make-keymap))
5653 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5655 (gnus-define-keys gnus-article-edit-mode-map
5656 "\C-c?" describe-mode
5657 "\C-c\C-c" gnus-article-edit-done
5658 "\C-c\C-k" gnus-article-edit-exit
5659 "\C-c\C-f\C-t" message-goto-to
5660 "\C-c\C-f\C-o" message-goto-from
5661 "\C-c\C-f\C-b" message-goto-bcc
5662 ;;"\C-c\C-f\C-w" message-goto-fcc
5663 "\C-c\C-f\C-c" message-goto-cc
5664 "\C-c\C-f\C-s" message-goto-subject
5665 "\C-c\C-f\C-r" message-goto-reply-to
5666 "\C-c\C-f\C-n" message-goto-newsgroups
5667 "\C-c\C-f\C-d" message-goto-distribution
5668 "\C-c\C-f\C-f" message-goto-followup-to
5669 "\C-c\C-f\C-m" message-goto-mail-followup-to
5670 "\C-c\C-f\C-k" message-goto-keywords
5671 "\C-c\C-f\C-u" message-goto-summary
5672 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5673 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5674 "\C-c\C-b" message-goto-body
5675 "\C-c\C-i" message-goto-signature
5677 "\C-c\C-t" message-insert-to
5678 "\C-c\C-n" message-insert-newsgroups
5679 "\C-c\C-o" message-sort-headers
5680 "\C-c\C-e" message-elide-region
5681 "\C-c\C-v" message-delete-not-region
5682 "\C-c\C-z" message-kill-to-signature
5683 "\M-\r" message-newline-and-reformat
5684 "\C-c\C-a" mml-attach-file
5685 "\C-a" message-beginning-of-line
5687 "\M-;" comment-region)
5689 (gnus-define-keys (gnus-article-edit-wash-map
5690 "\C-c\C-w" gnus-article-edit-mode-map)
5691 "f" gnus-article-edit-full-stops))
5694 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5696 ["Fetch To" message-insert-to t]
5697 ["Fetch Newsgroups" message-insert-newsgroups t]
5699 ["To" message-goto-to t]
5700 ["From" message-goto-from t]
5701 ["Subject" message-goto-subject t]
5702 ["Cc" message-goto-cc t]
5703 ["Reply-To" message-goto-reply-to t]
5704 ["Summary" message-goto-summary t]
5705 ["Keywords" message-goto-keywords t]
5706 ["Newsgroups" message-goto-newsgroups t]
5707 ["Followup-To" message-goto-followup-to t]
5708 ["Mail-Followup-To" message-goto-mail-followup-to t]
5709 ["Distribution" message-goto-distribution t]
5710 ["Body" message-goto-body t]
5711 ["Signature" message-goto-signature t]))
5713 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
5714 "Major mode for editing articles.
5715 This is an extended text-mode.
5717 \\{gnus-article-edit-mode-map}"
5718 (make-local-variable 'gnus-article-edit-done-function)
5719 (make-local-variable 'gnus-prev-winconf)
5720 (set (make-local-variable 'font-lock-defaults)
5721 '(message-font-lock-keywords t))
5722 (set (make-local-variable 'mail-header-separator) "")
5723 (set (make-local-variable 'gnus-article-edit-mode) t)
5724 (easy-menu-add message-mode-field-menu message-mode-map)
5726 (setq buffer-read-only nil)
5727 (buffer-enable-undo)
5730 (defun gnus-article-edit (&optional force)
5731 "Edit the current article.
5732 This will have permanent effect only in mail groups.
5733 If FORCE is non-nil, allow editing of articles even in read-only
5736 (when (and (not force)
5737 (gnus-group-read-only-p))
5738 (error "The current newsgroup does not support article editing"))
5739 (gnus-article-date-original)
5740 (gnus-article-edit-article
5742 `(lambda (no-highlight)
5744 (gnus-summary-edit-article-done
5745 ,(or (mail-header-references gnus-current-headers) "")
5746 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5748 (defun gnus-article-edit-article (start-func exit-func)
5749 "Start editing the contents of the current article buffer."
5750 (let ((winconf (current-window-configuration)))
5751 (set-buffer gnus-article-buffer)
5752 (let ((message-auto-save-directory
5753 ;; Don't associate the article buffer with a draft file.
5755 (gnus-article-edit-mode))
5756 (funcall start-func)
5757 (set-buffer-modified-p nil)
5758 (gnus-configure-windows 'edit-article)
5759 (setq gnus-article-edit-done-function exit-func)
5760 (setq gnus-prev-winconf winconf)
5761 (gnus-message 6 "C-c C-c to end edits")))
5763 (defun gnus-article-edit-done (&optional arg)
5764 "Update the article edits and exit."
5766 (let ((func gnus-article-edit-done-function)
5767 (buf (current-buffer))
5768 (start (window-start))
5770 (winconf gnus-prev-winconf))
5771 (widen) ;; Widen it in case that users narrowed the buffer.
5774 ;; The cache and backlog have to be flushed somewhat.
5775 (when gnus-keep-backlog
5776 (gnus-backlog-remove-article
5777 (car gnus-article-current) (cdr gnus-article-current)))
5778 ;; Flush original article as well.
5780 (when (get-buffer gnus-original-article-buffer)
5781 (set-buffer gnus-original-article-buffer)
5782 (setq gnus-original-article nil)))
5783 (when gnus-use-cache
5784 (gnus-cache-update-article
5785 (car gnus-article-current) (cdr gnus-article-current)))
5786 ;; We remove all text props from the article buffer.
5787 (kill-all-local-variables)
5788 (set-text-properties (point-min) (point-max) nil)
5790 (set-window-configuration winconf)
5792 (set-window-start (get-buffer-window buf) start)
5793 (set-window-point (get-buffer-window buf) (point)))
5794 (gnus-summary-show-article))
5796 (defun gnus-article-edit-exit ()
5797 "Exit the article editing without updating."
5799 (when (or (not (buffer-modified-p))
5800 (yes-or-no-p "Article modified; kill anyway? "))
5801 (let ((curbuf (current-buffer))
5803 (window-start (window-start)))
5805 (if (gnus-buffer-live-p gnus-original-article-buffer)
5806 (insert-buffer gnus-original-article-buffer))
5807 (let ((winconf gnus-prev-winconf))
5808 (kill-all-local-variables)
5810 (set-window-configuration winconf)
5811 ;; Tippy-toe some to make sure that point remains where it was.
5812 (save-current-buffer
5814 (set-window-start (get-buffer-window (current-buffer)) window-start)
5816 (gnus-summary-show-article)))
5818 (defun gnus-article-edit-full-stops ()
5819 "Interactively repair spacing at end of sentences."
5822 (goto-char (point-min))
5823 (search-forward-regexp "^$" nil t)
5824 (let ((case-fold-search nil))
5825 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5828 ;;; Article highlights
5831 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5833 ;;; Internal Variables:
5835 (defcustom gnus-button-url-regexp
5836 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5837 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-z0-9_.]+:[0-9]*\\)?[-a-z0-9_=!?#$@~%&*+\\/:;.,[:word:]]+[-a-z0-9_=#$@~%&*+\\/[:word:]]\\)"
5838 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-z0-9_.]+:[0-9]*\\)?\\([-a-z0-9_=!?#$@~%&*+\\/:;.,]\\|\\w\\)+\\([-a-z0-9_=#$@~%&*+\\/]\\|\\w\\)\\)")
5839 "Regular expression that matches URLs."
5840 :group 'gnus-article-buttons
5843 (defcustom gnus-button-valid-fqdn-regexp
5844 message-valid-fqdn-regexp
5845 "Regular expression that matches a valid FQDN."
5847 :group 'gnus-article-buttons
5850 (defcustom gnus-button-man-handler 'manual-entry
5851 "Function to use for displaying man pages.
5852 The function must take at least one argument with a string naming the
5855 :type '(choice (function-item :tag "Man" manual-entry)
5856 (function-item :tag "Woman" woman)
5857 (function :tag "Other"))
5858 :group 'gnus-article-buttons)
5860 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
5861 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
5862 If the default site is too slow, try to find a CTAN mirror, see
5863 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
5864 the variable `gnus-button-handle-ctan'."
5866 :group 'gnus-article-buttons
5867 :link '(custom-manual "(gnus)Group Parameters")
5868 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
5869 (const "http://tug.ctan.org/tex-archive/")
5870 (const "http://www.dante.de/CTAN/")
5871 (string :tag "Other")))
5873 (defcustom gnus-button-ctan-handler 'browse-url
5874 "Function to use for displaying CTAN links.
5875 The function must take one argument, the string naming the URL."
5877 :type '(choice (function-item :tag "Browse Url" browse-url)
5878 (function :tag "Other"))
5879 :group 'gnus-article-buttons)
5881 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
5882 "Bogus strings removed from CTAN URLs."
5884 :group 'gnus-article-buttons
5885 :type '(choice (const "^/?tex-archive/\\|/")
5886 (regexp :tag "Other")))
5888 (defcustom gnus-button-ctan-directory-regexp
5891 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
5892 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
5893 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
5895 "Regular expression for ctan directories.
5896 It should match all directories in the top level of `gnus-ctan-url'."
5898 :group 'gnus-article-buttons
5901 (defcustom gnus-button-mid-or-mail-regexp
5902 (concat "\\b\\(<?[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*@"
5903 ;; Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
5904 gnus-button-valid-fqdn-regexp
5906 "Regular expression that matches a message ID or a mail address."
5908 :group 'gnus-article-buttons
5911 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
5912 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
5913 Strings like this can be either a message ID or a mail address. If it is one
5914 of the symbols `mid' or `mail', Gnus will always assume that the string is a
5915 message ID or a mail address, respectively. If this variable is set to the
5916 symbol `ask', always query the user what do do. If it is a function, this
5917 function will be called with the string as it's only argument. The function
5918 must return `mid', `mail', `invalid' or `ask'."
5920 :group 'gnus-article-buttons
5921 :type '(choice (function-item :tag "Heuristic function"
5922 gnus-button-mid-or-mail-heuristic)
5927 (defcustom gnus-button-mid-or-mail-heuristic-alist
5928 '((-10.0 . ".+\\$.+@")
5931 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
5932 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
5933 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
5934 (-1.0 . "^[^a-z]+@")
5936 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
5937 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
5938 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
5939 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
5942 (-1.0 . "^[0-9][0-9]")
5944 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
5945 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5946 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
5947 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5949 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
5950 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
5953 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
5955 ;; compensation for TDMA dated mail addresses:
5956 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
5958 (-20.0 . "\\.fsf@") ;; Gnus
5961 (-20.0 . "_-_") ;; Subject change in thread
5963 (-20.0 . "\\.ln@") ;; leafnode
5964 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
5965 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
5967 ;; (5.0 . "") ;; $local_part_len <= 7
5968 (10.0 . "^[^0-9]+@")
5969 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
5970 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
5973 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
5975 (0.5 . "^[A-Z][a-z]")
5976 (0.5 . "^[A-Z][a-z][a-z]")
5977 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
5978 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
5979 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
5981 A negative RATE indicates a message IDs, whereas a positive indicates a mail
5982 address. The REGEXP is processed with `case-fold-search' set to nil."
5984 :group 'gnus-article-buttons
5985 :type '(repeat (cons (number :tag "Rate")
5986 (regexp :tag "Regexp"))))
5988 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
5989 "Guess whether MID-OR-MAIL is a message ID or a mail address.
5990 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
5991 address, `ask' if unsure and `invalid' if the string is invalid."
5992 (let ((case-fold-search nil)
5993 (list gnus-button-mid-or-mail-heuristic-alist)
5994 (result 0) rate regexp lpartlen elem)
5996 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
5997 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
5998 ;; Certain special cases...
6001 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6002 "^[0-9]+\\.[0-9]+@compuserve\\|"
6003 "@public\\.gmane\\.org")
6005 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6006 (setq result 'mail))
6007 (when (string-match "@.*@\\| " mid-or-mail)
6008 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6009 (setq result 'invalid))
6010 ;; Nothing more to do, if result is not a number here...
6011 (when (numberp result)
6013 (setq elem (car list)
6017 (when (string-match regexp mid-or-mail)
6018 (setq result (+ result rate))
6020 9 "`%s' matched `%s', rate `%s', result `%s'."
6021 mid-or-mail regexp rate result)))
6022 (when (<= lpartlen 7)
6023 (setq result (+ result 5.0))
6024 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6025 mid-or-mail result))
6026 (when (>= lpartlen 12)
6027 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6029 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6030 ;; Long local part should contain realname if e-mail address,
6031 ;; too many digits: message-id.
6032 ;; $score -= 5.0 + 0.1 * $local_part_len;
6033 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6034 (setq result (+ result rate))
6036 9 "Many digits in `%s', rate `%s', result `%s'."
6037 mid-or-mail rate result))
6038 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6040 ;; Too few vowels [^aeiouy]{4,}.*\@
6041 (setq result (+ result -5.0))
6043 9 "Few vowels in `%s', rate `%s', result `%s'."
6044 mid-or-mail -5.0 result))
6046 (setq result (+ result 5.0))
6048 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6049 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6050 ;; Maybe we should make this a customizable alist: (condition . 'result)
6052 ((symbolp result) result)
6053 ;; Now convert number into proper results:
6054 ((< result -10.0) 'mid)
6055 ((> result 10.0) 'mail)
6058 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6059 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6060 (url-mid (concat "news" ":" mid-or-mail))
6061 (url-mailto (concat "mailto" ":" mid-or-mail)))
6062 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6063 (when (fboundp pref)
6065 ;; get rid of surrounding angles...
6067 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6068 (if (or (eq 'mid guessed) (eq 'mail guessed))
6072 (save-window-excursion
6073 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6076 (cond ((eq pref 'mid)
6077 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6078 (gnus-button-handle-news url-mid))
6080 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6081 (gnus-url-mailto url-mailto))
6082 (t (gnus-message 3 "Invalid string.")))))
6084 (defun gnus-button-handle-custom (url)
6085 "Follow a Custom URL."
6086 (customize-apropos (gnus-url-unhex-string url)))
6088 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6090 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6093 (defun gnus-button-handle-describe-function (url)
6094 "Call `describe-function' when pushing the corresponding URL button."
6097 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6099 (defun gnus-button-handle-describe-variable (url)
6100 "Call `describe-variable' when pushing the corresponding URL button."
6103 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6105 (defun gnus-button-handle-symbol (url)
6106 "Display help on variable or function.
6107 Calls `describe-variable' or `describe-function'."
6108 (let ((sym (intern url)))
6110 ((fboundp sym) (describe-function sym))
6111 ((boundp sym) (describe-variable sym))
6112 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6114 (defun gnus-button-handle-describe-key (url)
6115 "Call `describe-key' when pushing the corresponding URL button."
6117 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6118 (keys (ignore-errors (eval `(kbd ,key-string)))))
6121 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6123 (defun gnus-button-handle-apropos (url)
6124 "Call `apropos' when pushing the corresponding URL button."
6125 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6127 (defun gnus-button-handle-apropos-command (url)
6128 "Call `apropos' when pushing the corresponding URL button."
6130 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6132 (defun gnus-button-handle-apropos-variable (url)
6133 "Call `apropos' when pushing the corresponding URL button."
6135 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6136 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6138 (defun gnus-button-handle-apropos-documentation (url)
6139 "Call `apropos' when pushing the corresponding URL button."
6141 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6142 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6144 (defun gnus-button-handle-library (url)
6145 "Call `locate-library' when pushing the corresponding URL button."
6146 (gnus-message 9 "url=`%s'" url)
6147 (let* ((lib (locate-library url))
6148 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6150 (gnus-message 1 "Cannot locale library `%s'." url)
6151 (find-file-read-only file))))
6153 (defun gnus-button-handle-ctan (url)
6154 "Call `browse-url' when pushing a CTAN URL button."
6156 gnus-button-ctan-handler
6159 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6161 (defcustom gnus-button-tex-level 5
6162 "*Integer that says how many TeX-related buttons Gnus will show.
6163 The higher the number, the more buttons will appear and the more false
6164 positives are possible. Note that you can set this variable local to
6165 specific groups. Setting it higher in TeX groups is probably a good idea.
6166 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6167 how to set variables in specific groups."
6169 :group 'gnus-article-buttons
6170 :link '(custom-manual "(gnus)Group Parameters")
6173 (defcustom gnus-button-man-level 5
6174 "*Integer that says how many man-related buttons Gnus will show.
6175 The higher the number, the more buttons will appear and the more false
6176 positives are possible. Note that you can set this variable local to
6177 specific groups. Setting it higher in Unix groups is probably a good idea.
6178 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6179 how to set variables in specific groups."
6181 :group 'gnus-article-buttons
6182 :link '(custom-manual "(gnus)Group Parameters")
6185 (defcustom gnus-button-emacs-level 5
6186 "*Integer that says how many emacs-related buttons Gnus will show.
6187 The higher the number, the more buttons will appear and the more false
6188 positives are possible. Note that you can set this variable local to
6189 specific groups. Setting it higher in Emacs or Gnus related groups is
6190 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6191 `gnus-parameters' on how to set variables in specific groups."
6193 :group 'gnus-article-buttons
6194 :link '(custom-manual "(gnus)Group Parameters")
6197 (defcustom gnus-button-message-level 5
6198 "*Integer that says how many buttons for news or mail messages will appear.
6199 The higher the number, the more buttons will appear and the more false
6200 positives are possible."
6201 ;; mail addresses, MIDs, URLs for news, ...
6203 :group 'gnus-article-buttons
6206 (defcustom gnus-button-browse-level 5
6207 "*Integer that says how many buttons for browsing will appear.
6208 The higher the number, the more buttons will appear and the more false
6209 positives are possible."
6210 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6212 :group 'gnus-article-buttons
6215 (defcustom gnus-button-alist
6216 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6217 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6218 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6219 gnus-button-handle-news 2)
6220 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6221 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6222 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6223 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6224 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6225 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6226 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6227 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6228 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6229 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6230 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6231 ;; RFC 2368 (The mailto URL scheme)
6232 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6233 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6234 ("\\bmailto:\\([^ \n\t]+\\)"
6235 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6237 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6238 gnus-button-ctan-directory-regexp
6239 "[^][>)!;:,'\n\t ]+\\)")
6240 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6241 ((concat "\\btex-archive/\\("
6242 gnus-button-ctan-directory-regexp
6243 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6244 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6247 gnus-button-ctan-directory-regexp
6248 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6249 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6250 ;; This is info (home-grown style) <info://foo/bar+baz>
6251 ("\\binfo://\\([^'\">\n\t ]+\\)"
6252 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6253 ;; Info GNOME style <info:foo#bar_baz>
6254 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6255 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6256 ;; Info KDE style <info:(foo)bar baz>
6257 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6258 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6259 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6260 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6261 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6262 ;; Info links like `C-h i d m CC Mode RET'
6263 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6265 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6266 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6267 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6268 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6269 ;; Emacs help commands
6270 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6271 ;; regexp doesn't match arguments containing ` '.
6272 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6273 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6274 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6275 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6276 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6277 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6278 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6279 ;; The following entries may lead to many false positives so don't enable
6280 ;; them by default (use a high button level).
6281 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6282 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6283 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6284 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6285 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6286 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6287 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6288 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6289 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6290 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6291 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6292 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6293 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6294 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6295 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6296 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6297 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6298 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6299 ;; Unlike the other regexps we really have to require quoting
6300 ;; here to determine where it ends.
6301 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6302 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6303 ("<URL: *\\([^<>]*\\)>"
6304 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6305 ;; RFC 2396 (2.4.3., delims) ...
6306 ("\"URL: *\\([^\"]*\\)\""
6307 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6308 ;; RFC 2396 (2.4.3., delims) ...
6309 ("\"URL: *\\([^\"]*\\)\""
6310 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6312 (gnus-button-url-regexp
6313 0 (>= gnus-button-browse-level 0) browse-url 0)
6315 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6316 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6317 gnus-button-handle-man 1)
6318 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6319 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6320 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6321 gnus-button-handle-man 1)
6322 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6323 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6324 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6325 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6326 ;; MID or mail: To avoid too many false positives we don't try to catch
6327 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6328 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6329 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6330 ;; so that non-ambiguous entries (see above) match first.
6331 (gnus-button-mid-or-mail-regexp
6332 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6333 "*Alist of regexps matching buttons in article bodies.
6335 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6336 REGEXP: is the string (case insensitive) matching text around the button (can
6337 also be Lisp expression evaluating to a string),
6338 BUTTON: is the number of the regexp grouping actually matching the button,
6339 FORM: is a Lisp expression which must eval to true for the button to
6341 CALLBACK: is the function to call when the user push this button, and each
6342 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6344 CALLBACK can also be a variable, in that case the value of that
6345 variable it the real callback function."
6346 :group 'gnus-article-buttons
6347 :type '(repeat (list (choice regexp variable sexp)
6348 (integer :tag "Button")
6350 (function :tag "Callback")
6353 (integer :tag "Regexp group")))))
6355 (defcustom gnus-header-button-alist
6356 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6357 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6358 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6359 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6360 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6361 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
6362 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6363 0 (>= gnus-button-browse-level 0) browse-url 0)
6364 ("^Subject:" gnus-button-url-regexp
6365 0 (>= gnus-button-browse-level 0) browse-url 0)
6366 ("^[^:]+:" gnus-button-url-regexp
6367 0 (>= gnus-button-browse-level 0) browse-url 0)
6368 ("^OpenPGP:.*url=" gnus-button-url-regexp
6369 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
6370 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6371 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6372 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6373 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6374 "*Alist of headers and regexps to match buttons in article heads.
6376 This alist is very similar to `gnus-button-alist', except that each
6377 alist has an additional HEADER element first in each entry:
6379 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6381 HEADER is a regexp to match a header. For a fuller explanation, see
6382 `gnus-button-alist'."
6383 :group 'gnus-article-buttons
6384 :group 'gnus-article-headers
6385 :type '(repeat (list (regexp :tag "Header")
6386 (choice regexp variable)
6387 (integer :tag "Button")
6389 (function :tag "Callback")
6392 (integer :tag "Regexp group")))))
6396 (defun gnus-article-push-button (event)
6397 "Check text under the mouse pointer for a callback function.
6398 If the text under the mouse pointer has a `gnus-callback' property,
6399 call it with the value of the `gnus-data' text property."
6401 (set-buffer (window-buffer (posn-window (event-start event))))
6402 (let* ((pos (posn-point (event-start event)))
6403 (data (get-text-property pos 'gnus-data))
6404 (fun (get-text-property pos 'gnus-callback)))
6407 (funcall fun data))))
6409 (defun gnus-article-press-button ()
6410 "Check text at point for a callback function.
6411 If the text at point has a `gnus-callback' property,
6412 call it with the value of the `gnus-data' text property."
6414 (let ((data (get-text-property (point) 'gnus-data))
6415 (fun (get-text-property (point) 'gnus-callback)))
6417 (funcall fun data))))
6419 (defun gnus-article-highlight (&optional force)
6420 "Highlight current article.
6421 This function calls `gnus-article-highlight-headers',
6422 `gnus-article-highlight-citation',
6423 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6424 do the highlighting. See the documentation for those functions."
6425 (interactive (list 'force))
6426 (gnus-article-highlight-headers)
6427 (gnus-article-highlight-citation force)
6428 (gnus-article-highlight-signature)
6429 (gnus-article-add-buttons force)
6430 (gnus-article-add-buttons-to-head))
6432 (defun gnus-article-highlight-some (&optional force)
6433 "Highlight current article.
6434 This function calls `gnus-article-highlight-headers',
6435 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6436 do the highlighting. See the documentation for those functions."
6437 (interactive (list 'force))
6438 (gnus-article-highlight-headers)
6439 (gnus-article-highlight-signature)
6440 (gnus-article-add-buttons))
6442 (defun gnus-article-highlight-headers ()
6443 "Highlight article headers as specified by `gnus-header-face-alist'."
6445 (gnus-with-article-headers
6446 (let (regexp header-face field-face from hpoints fpoints)
6447 (dolist (entry gnus-header-face-alist)
6448 (goto-char (point-min))
6449 (setq regexp (concat "^\\("
6450 (if (string-equal "" (nth 0 entry))
6454 header-face (nth 1 entry)
6455 field-face (nth 2 entry))
6456 (while (and (re-search-forward regexp nil t)
6460 (unless (search-forward ":" nil t)
6462 (when (and header-face
6463 (not (memq (point) hpoints)))
6464 (push (point) hpoints)
6465 (gnus-put-text-property from (point) 'face header-face))
6466 (when (and field-face
6467 (not (memq (setq from (point)) fpoints)))
6469 (if (re-search-forward "^[^ \t]" nil t)
6471 (goto-char (point-max)))
6472 (gnus-put-text-property from (point) 'face field-face)))))))
6474 (defun gnus-article-highlight-signature ()
6475 "Highlight the signature in an article.
6476 It does this by highlighting everything after
6477 `gnus-signature-separator' using `gnus-signature-face'."
6479 (gnus-with-article-buffer
6480 (let ((inhibit-point-motion-hooks t))
6482 (when (and gnus-signature-face
6483 (gnus-article-narrow-to-signature))
6484 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6485 'face gnus-signature-face)
6487 (gnus-article-search-signature)
6488 (let ((start (match-beginning 0))
6489 (end (set-marker (make-marker) (1+ (match-end 0)))))
6490 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
6493 (defun gnus-button-in-region-p (b e prop)
6494 "Say whether PROP exists in the region."
6495 (text-property-not-all b e prop nil))
6497 (defun gnus-article-add-buttons (&optional force)
6498 "Find external references in the article and make buttons of them.
6499 \"External references\" are things like Message-IDs and URLs, as
6500 specified by `gnus-button-alist'."
6501 (interactive (list 'force))
6502 (gnus-with-article-buffer
6503 (let ((inhibit-point-motion-hooks t)
6504 (case-fold-search t)
6505 (alist gnus-button-alist)
6507 ;; Remove all old markers.
6508 (let (marker entry new-list)
6509 (while (setq marker (pop gnus-button-marker-list))
6510 (if (or (< marker (point-min)) (>= marker (point-max)))
6511 (push marker new-list)
6513 (when (setq entry (gnus-button-entry))
6514 (put-text-property (match-beginning (nth 1 entry))
6515 (match-end (nth 1 entry))
6516 'gnus-callback nil))
6517 (set-marker marker nil)))
6518 (setq gnus-button-marker-list new-list))
6519 ;; We skip the headers.
6522 (while (setq entry (pop alist))
6523 (setq regexp (eval (car entry)))
6525 (while (re-search-forward regexp nil t)
6526 (let* ((start (and entry (match-beginning (nth 1 entry))))
6527 (end (and entry (match-end (nth 1 entry))))
6528 (from (match-beginning 0)))
6529 (when (and (or (eq t (nth 2 entry))
6530 (eval (nth 2 entry)))
6531 (not (gnus-button-in-region-p
6532 start end 'gnus-callback)))
6533 ;; That optional form returned non-nil, so we add the
6535 (gnus-article-add-button
6536 start end 'gnus-button-push
6537 (car (push (set-marker (make-marker) from)
6538 gnus-button-marker-list))))))))))
6540 ;; Add buttons to the head of an article.
6541 (defun gnus-article-add-buttons-to-head ()
6542 "Add buttons to the head of the article."
6544 (gnus-with-article-headers
6546 (dolist (entry gnus-header-button-alist)
6547 ;; Each alist entry.
6548 (goto-char (point-min))
6549 (while (re-search-forward (car entry) nil t)
6550 ;; Each header matching the entry.
6551 (setq beg (match-beginning 0))
6552 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6553 (match-beginning 0))
6556 (while (re-search-forward (eval (nth 1 entry)) end t)
6557 ;; Each match within a header.
6558 (let* ((entry (cdr entry))
6559 (start (match-beginning (nth 1 entry)))
6560 (end (match-end (nth 1 entry)))
6561 (form (nth 2 entry)))
6562 (goto-char (match-end 0))
6564 (gnus-article-add-button
6565 start end (nth 3 entry)
6566 (buffer-substring (match-beginning (nth 4 entry))
6567 (match-end (nth 4 entry)))))))
6568 (goto-char end))))))
6570 ;;; External functions:
6572 (defun gnus-article-add-button (from to fun &optional data)
6573 "Create a button between FROM and TO with callback FUN and data DATA."
6574 (when gnus-article-button-face
6575 (gnus-overlay-put (gnus-make-overlay from to)
6576 'face gnus-article-button-face))
6577 (gnus-add-text-properties
6579 (nconc (and gnus-article-mouse-face
6580 (list gnus-mouse-face-prop gnus-article-mouse-face))
6581 (list 'gnus-callback fun)
6582 (and data (list 'gnus-data data))))
6583 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6584 :button-keymap gnus-widget-button-keymap))
6586 ;;; Internal functions:
6588 (defun gnus-article-set-globals ()
6589 (with-current-buffer gnus-summary-buffer
6590 (gnus-set-global-variables)))
6592 (defun gnus-signature-toggle (end)
6593 (gnus-with-article-buffer
6594 (let ((inhibit-point-motion-hooks t))
6595 (if (text-property-any end (point-max) 'article-type 'signature)
6597 (gnus-delete-wash-type 'signature)
6598 (gnus-remove-text-properties-when
6599 'article-type 'signature end (point-max)
6600 (cons 'article-type (cons 'signature
6601 gnus-hidden-properties))))
6602 (gnus-add-wash-type 'signature)
6603 (gnus-add-text-properties-when
6604 'article-type nil end (point-max)
6605 (cons 'article-type (cons 'signature
6606 gnus-hidden-properties)))))
6607 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6608 (gnus-set-mode-line 'article))))
6610 (defun gnus-button-entry ()
6611 ;; Return the first entry in `gnus-button-alist' matching this place.
6612 (let ((alist gnus-button-alist)
6615 (setq entry (pop alist))
6616 (if (looking-at (eval (car entry)))
6621 (defun gnus-button-push (marker)
6622 ;; Push button starting at MARKER.
6625 (let* ((entry (gnus-button-entry))
6626 (inhibit-point-motion-hooks t)
6628 (args (mapcar (lambda (group)
6629 (let ((string (match-string group)))
6630 (set-text-properties
6631 0 (length string) nil string)
6638 (fboundp (symbol-value fun)))
6639 (apply (symbol-value fun) args))
6641 (gnus-message 1 "You must define `%S' to use this button"
6642 (cons fun args)))))))
6644 (defun gnus-parse-news-url (url)
6645 (let (scheme server port group message-id articles)
6648 (goto-char (point-min))
6649 (when (looking-at "\\([A-Za-z]+\\):")
6650 (setq scheme (match-string 1))
6651 (goto-char (match-end 0)))
6652 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
6653 (setq server (match-string 1))
6654 (setq port (if (stringp (match-string 3))
6655 (string-to-number (match-string 3))
6657 (goto-char (match-end 0)))
6660 ((looking-at "\\(.*@.*\\)")
6661 (setq message-id (match-string 1)))
6662 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6663 (setq group (match-string 1)
6664 articles (split-string (match-string 2) "-")))
6665 ((looking-at "\\([^/]+\\)/?")
6666 (setq group (match-string 1)))
6668 (error "Unknown news URL syntax"))))
6669 (list scheme server port group message-id articles)))
6671 (defun gnus-button-handle-news (url)
6673 (destructuring-bind (scheme server port group message-id articles)
6674 (gnus-parse-news-url url)
6678 (set-buffer gnus-summary-buffer)
6680 (let ((gnus-refer-article-method
6681 (nconc (list (list 'nntp server))
6682 gnus-refer-article-method))
6683 (nntp-port-number (or port "nntp")))
6684 (gnus-message 7 "Fetching %s with %s"
6685 message-id gnus-refer-article-method)
6686 (gnus-summary-refer-article message-id))
6687 (gnus-summary-refer-article message-id))))
6689 (gnus-button-fetch-group url)))))
6691 (defun gnus-button-handle-man (url)
6693 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
6694 (when (eq gnus-button-man-handler 'woman)
6695 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
6696 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
6697 (funcall gnus-button-man-handler url))
6699 (defun gnus-button-handle-info-url (url)
6700 "Fetch an info URL."
6701 (setq url (mm-subst-char-in-string ?+ ?\ url))
6703 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
6704 (gnus-info-find-node
6705 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6707 ")" (gnus-url-unhex-string (match-string 2 url)))))
6708 ((string-match "([^)\"]+)[^\"]+" url)
6710 (gnus-replace-in-string
6711 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
6712 (gnus-info-find-node url))
6713 (t (error "Can't parse %s" url))))
6715 (defun gnus-button-handle-info-url-gnome (url)
6716 "Fetch GNOME style info URL."
6717 (setq url (mm-subst-char-in-string ?_ ?\ url))
6718 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
6719 (gnus-info-find-node
6721 (gnus-url-unhex-string
6722 (match-string 1 url))
6724 (or (gnus-url-unhex-string
6725 (match-string 2 url))
6727 (error "Can't parse %s" url)))
6729 (defun gnus-button-handle-info-url-kde (url)
6730 "Fetch KDE style info URL."
6731 (gnus-info-find-node (gnus-url-unhex-string url)))
6733 (defun gnus-button-handle-info-keystrokes (url)
6734 "Call `info' when pushing the corresponding URL button."
6735 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
6740 (defun gnus-button-openpgp (url)
6741 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
6743 (mm-url-insert-file-contents-external url)
6744 (pgg-snarf-keys-region (point-min) (point-max))
6745 (pgg-display-output-buffer nil nil nil)))
6747 (defun gnus-button-message-id (message-id)
6749 (with-current-buffer gnus-summary-buffer
6750 (gnus-summary-refer-article message-id)))
6752 (defun gnus-button-fetch-group (address)
6753 "Fetch GROUP specified by ADDRESS."
6754 (if (not (string-match "[:/]" address))
6755 ;; This is just a simple group url.
6756 (gnus-group-read-ephemeral-group address gnus-select-method)
6759 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6761 (error "Can't parse %s" address)
6762 (gnus-group-read-ephemeral-group
6763 (match-string 4 address)
6764 `(nntp ,(match-string 1 address)
6765 (nntp-address ,(match-string 1 address))
6766 (nntp-port-number ,(if (match-end 3)
6767 (match-string 3 address)
6770 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
6772 (defun gnus-url-parse-query-string (query &optional downcase)
6773 (let (retval pairs cur key val)
6774 (setq pairs (split-string query "&"))
6776 (setq cur (car pairs)
6778 (if (not (string-match "=" cur))
6780 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6781 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6783 (setq key (downcase key)))
6784 (setq cur (assoc key retval))
6786 (setcdr cur (cons val (cdr cur)))
6787 (setq retval (cons (list key val) retval)))))
6790 (defun gnus-url-mailto (url)
6791 ;; Send mail to someone
6792 (when (string-match "mailto:/*\\(.*\\)" url)
6793 (setq url (substring url (match-beginning 1) nil)))
6794 (let (to args subject func)
6795 (setq args (gnus-url-parse-query-string
6796 (if (string-match "^\\?" url)
6798 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
6799 (concat "to=" (match-string 1 url) "&"
6800 (match-string 2 url))
6801 (concat "to=" url)))
6803 subject (cdr-safe (assoc "subject" args)))
6806 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6809 (message-position-on-field (caar args)))
6810 (insert (gnus-replace-in-string
6811 (mapconcat 'identity (reverse (cdar args)) ", ")
6813 (setq args (cdr args)))
6816 (message-goto-subject))))
6818 (defun gnus-button-embedded-url (address)
6819 "Activate ADDRESS with `browse-url'."
6820 (browse-url (gnus-strip-whitespace address)))
6822 ;;; Next/prev buttons in the article buffer.
6824 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6825 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6827 (defvar gnus-prev-page-map
6828 (let ((map (make-sparse-keymap)))
6829 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6830 (define-key map "\r" 'gnus-button-prev-page)
6833 (defvar gnus-next-page-map
6834 (let ((map (make-sparse-keymap)))
6835 (unless (>= emacs-major-version 21)
6836 ;; XEmacs doesn't care.
6837 (set-keymap-parent map gnus-article-mode-map))
6838 (define-key map gnus-mouse-2 'gnus-button-next-page)
6839 (define-key map "\r" 'gnus-button-next-page)
6842 (defun gnus-insert-prev-page-button ()
6844 (inhibit-read-only t))
6846 gnus-prev-page-line-format nil
6847 `(keymap ,gnus-prev-page-map
6849 gnus-callback gnus-article-button-prev-page
6850 article-type annotation))
6851 (widget-convert-button
6853 ;; Exclude a newline.
6856 :action 'gnus-button-prev-page
6857 :button-keymap gnus-prev-page-map)))
6859 (defun gnus-button-next-page (&optional args more-args)
6860 "Go to the next page."
6862 (let ((win (selected-window)))
6863 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6864 (gnus-article-next-page)
6865 (select-window win)))
6867 (defun gnus-button-prev-page (&optional args more-args)
6868 "Go to the prev page."
6870 (let ((win (selected-window)))
6871 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6872 (gnus-article-prev-page)
6873 (select-window win)))
6875 (defun gnus-insert-next-page-button ()
6877 (inhibit-read-only t))
6878 (gnus-eval-format gnus-next-page-line-format nil
6879 `(keymap ,gnus-next-page-map
6881 gnus-callback gnus-article-button-next-page
6882 article-type annotation))
6883 (widget-convert-button
6885 ;; Exclude a newline.
6888 :action 'gnus-button-next-page
6889 :button-keymap gnus-next-page-map)))
6891 (defun gnus-article-button-next-page (arg)
6892 "Go to the next page."
6894 (let ((win (selected-window)))
6895 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6896 (gnus-article-next-page)
6897 (select-window win)))
6899 (defun gnus-article-button-prev-page (arg)
6900 "Go to the prev page."
6902 (let ((win (selected-window)))
6903 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6904 (gnus-article-prev-page)
6905 (select-window win)))
6907 (defvar gnus-decode-header-methods
6908 '(mail-decode-encoded-word-region)
6909 "List of methods used to decode headers.
6911 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6912 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
6913 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
6914 whose names match REGEXP.
6917 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6918 mail-decode-encoded-word-region
6919 (\"chinese\" . rfc1843-decode-region))
6922 (defvar gnus-decode-header-methods-cache nil)
6924 (defun gnus-multi-decode-header (start end)
6925 "Apply the functions from `gnus-encoded-word-methods' that match."
6926 (unless (and gnus-decode-header-methods-cache
6927 (eq gnus-newsgroup-name
6928 (car gnus-decode-header-methods-cache)))
6929 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6932 (nconc gnus-decode-header-methods-cache (list x))
6933 (if (and gnus-newsgroup-name
6934 (string-match (car x) gnus-newsgroup-name))
6935 (nconc gnus-decode-header-methods-cache
6937 gnus-decode-header-methods))
6938 (let ((xlist gnus-decode-header-methods-cache))
6941 (narrow-to-region start end)
6943 (funcall (pop xlist) (point-min) (point-max))))))
6946 ;;; Treatment top-level handling.
6949 (defun gnus-treat-article (condition &optional part-number total-parts type)
6950 (let ((length (- (point-max) (point-min)))
6951 (alist gnus-treatment-function-alist)
6952 (article-goto-body-goes-to-point-min-p t)
6956 (let ((list gnus-article-treat-types))
6958 (when (string-match (pop list) type)
6959 (throw 'found t)))))))
6960 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6962 (gnus-run-hooks 'gnus-part-display-hook)
6963 (dolist (elem alist)
6966 (when (gnus-buffer-live-p gnus-summary-buffer)
6967 (set-buffer gnus-summary-buffer))
6968 (symbol-value (car elem))))
6969 (when (and (or (consp val)
6971 (gnus-treat-predicate val)
6972 (or (not (get (car elem) 'highlight))
6975 (funcall (cadr elem)))))))
6977 ;; Dynamic variables.
6979 (defvar part-number)
6980 (defvar total-parts)
6985 (defun gnus-treat-predicate (val)
6992 (stringp (car val)))
6993 (apply 'gnus-or (mapcar `(lambda (s)
6994 (string-match s ,(or gnus-newsgroup-name "")))
6997 (let ((pred (pop val)))
7000 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7002 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7004 (not (gnus-treat-predicate (car val))))
7006 (equal (car val) type))
7008 (error "%S is not a valid predicate" pred)))))
7014 (eq part-number total-parts))
7018 (error "%S is not a valid value" val))))
7020 (defun gnus-article-encrypt-body (protocol &optional n)
7021 "Encrypt the article body."
7024 (or gnus-article-encrypt-protocol
7025 (completing-read "Encrypt protocol: "
7026 gnus-article-encrypt-protocol-alist
7028 current-prefix-arg))
7029 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7031 (error (format "Can't find the encrypt protocol %s" protocol)))
7032 (if (member gnus-newsgroup-name '("nndraft:delayed"
7035 (error "Can't encrypt the article in group %s"
7036 gnus-newsgroup-name))
7037 (gnus-summary-iterate n
7039 (set-buffer gnus-summary-buffer)
7040 (let ((mail-parse-charset gnus-newsgroup-charset)
7041 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7042 (summary-buffer gnus-summary-buffer)
7044 (gnus-set-global-variables)
7045 (when (gnus-group-read-only-p)
7046 (error "The current newsgroup does not support article encrypt"))
7047 (gnus-summary-show-article t)
7049 (or (mail-header-references gnus-current-headers) ""))
7050 (set-buffer gnus-article-buffer)
7051 (let* ((inhibit-read-only t)
7053 (mapcar (lambda (field)
7054 (and (save-restriction
7055 (message-narrow-to-head)
7056 (goto-char (point-min))
7057 (search-forward field nil t))
7059 (message-narrow-to-field)
7061 (delete-region (point-min) (point-max))
7063 '("Content-Type:" "Content-Transfer-Encoding:"
7064 "Content-Disposition:"))))
7065 (message-narrow-to-head)
7066 (message-remove-header "MIME-Version")
7067 (goto-char (point-max))
7068 (setq point (point))
7069 (insert (apply 'concat headers))
7071 (narrow-to-region point (point-max))
7072 (let ((message-options message-options))
7073 (message-options-set 'message-sender user-mail-address)
7074 (message-options-set 'message-recipients user-mail-address)
7075 (message-options-set 'message-sign-encrypt 'not)
7077 (goto-char (point-min))
7078 (insert "MIME-Version: 1.0\n")
7080 (gnus-summary-edit-article-done
7081 references nil summary-buffer t))
7082 (when gnus-keep-backlog
7083 (gnus-backlog-remove-article
7084 (car gnus-article-current) (cdr gnus-article-current)))
7086 (when (get-buffer gnus-original-article-buffer)
7087 (set-buffer gnus-original-article-buffer)
7088 (setq gnus-original-article nil)))
7089 (when gnus-use-cache
7090 (gnus-cache-update-article
7091 (car gnus-article-current) (cdr gnus-article-current))))))))
7093 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7094 "The following specs can be used:
7095 %t The security MIME type
7098 %D Details if button is pressed")
7100 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7101 "The following specs can be used:
7102 %t The security MIME type
7105 %D Details if button is pressed")
7107 (defvar gnus-mime-security-button-line-format-alist
7108 '((?t gnus-tmp-type ?s)
7109 (?i gnus-tmp-info ?s)
7110 (?d gnus-tmp-details ?s)
7111 (?D gnus-tmp-pressed-details ?s)))
7113 (defvar gnus-mime-security-button-map
7114 (let ((map (make-sparse-keymap)))
7115 (define-key map gnus-mouse-2 'gnus-article-push-button)
7116 (define-key map "\r" 'gnus-article-press-button)
7119 (defvar gnus-mime-security-details-buffer nil)
7121 (defvar gnus-mime-security-button-pressed nil)
7123 (defvar gnus-mime-security-show-details-inline t
7124 "If non-nil, show details in the article buffer.")
7126 (defun gnus-mime-security-verify-or-decrypt (handle)
7127 (mm-remove-parts (cdr handle))
7128 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7129 point (inhibit-read-only t))
7131 (goto-char (car region)))
7133 (narrow-to-region (point) (point))
7134 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7135 (let* ((mm-verify-option 'known)
7136 (mm-decrypt-option 'known)
7137 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7138 (unless (eq nparts (cdr handle))
7139 (mm-destroy-parts (cdr handle))
7140 (setcdr handle nparts))))
7141 (setq point (point))
7142 (gnus-mime-display-security handle)
7143 (goto-char (point-max)))
7145 (delete-region (point) (cdr region))
7146 (set-marker (car region) nil)
7147 (set-marker (cdr region) nil))
7150 (defun gnus-mime-security-show-details (handle)
7151 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7153 (gnus-message 5 "No details.")
7154 (if gnus-mime-security-show-details-inline
7155 (let ((gnus-mime-security-button-pressed
7156 (not (get-text-property (point) 'gnus-mime-details)))
7157 (gnus-mime-security-button-line-format
7158 (get-text-property (point) 'gnus-line-format))
7159 (inhibit-read-only t))
7161 (while (eq (get-text-property (point) 'gnus-line-format)
7162 gnus-mime-security-button-line-format)
7166 (narrow-to-region (point) (point))
7167 (gnus-insert-mime-security-button handle))
7168 (delete-region (point)
7169 (or (text-property-not-all
7172 gnus-mime-security-button-line-format)
7175 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7176 (with-current-buffer gnus-mime-security-details-buffer
7179 (setq gnus-mime-security-details-buffer
7180 (gnus-get-buffer-create "*MIME Security Details*")))
7181 (with-current-buffer gnus-mime-security-details-buffer
7183 (goto-char (point-min)))
7184 (pop-to-buffer gnus-mime-security-details-buffer)))))
7186 (defun gnus-mime-security-press-button (handle)
7188 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7189 (gnus-mime-security-show-details handle)
7190 (gnus-mime-security-verify-or-decrypt handle))))
7192 (defun gnus-insert-mime-security-button (handle &optional displayed)
7193 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7196 (or (nth 2 (assoc protocol mm-verify-function-alist))
7197 (nth 2 (assoc protocol mm-decrypt-function-alist))
7199 (if (equal (car handle) "multipart/signed")
7200 " Signed" " Encrypted")
7203 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7206 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7207 gnus-tmp-pressed-details
7209 (setq gnus-tmp-details
7210 (if gnus-tmp-details
7211 (concat "\n" gnus-tmp-details)
7213 (setq gnus-tmp-pressed-details
7214 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7219 gnus-mime-security-button-line-format
7220 gnus-mime-security-button-line-format-alist
7221 `(keymap ,gnus-mime-security-button-map
7222 gnus-callback gnus-mime-security-press-button
7223 gnus-line-format ,gnus-mime-security-button-line-format
7224 gnus-mime-details ,gnus-mime-security-button-pressed
7225 article-type annotation
7228 ;; Exclude a newline.
7231 (widget-convert-button
7234 :action 'gnus-widget-press-button
7235 :button-keymap gnus-mime-security-button-map
7237 (lambda (widget/window &optional overlay pos)
7238 ;; Needed to properly clear the message due to a bug in
7239 ;; wid-edit (XEmacs only).
7240 (when (boundp 'help-echo-owns-message)
7241 (setq help-echo-owns-message t))
7244 (aref gnus-mouse-2 0))))))
7246 (defun gnus-mime-display-security (handle)
7248 (narrow-to-region (point) (point))
7249 (unless (gnus-unbuttonized-mime-type-p (car handle))
7250 (gnus-insert-mime-security-button handle))
7251 (gnus-mime-display-mixed (cdr handle))
7254 (unless (gnus-unbuttonized-mime-type-p (car handle))
7255 (let ((gnus-mime-security-button-line-format
7256 gnus-mime-security-button-end-line-format))
7257 (gnus-insert-mime-security-button handle)))
7258 (mm-set-handle-multipart-parameter
7260 (cons (set-marker (make-marker) (point-min))
7261 (set-marker (make-marker) (point-max))))))
7267 (run-hooks 'gnus-art-load-hook)
7269 ;;; arch-tag: 2654516f-6279-48f9-a83b-05c1fa450c33
7270 ;;; gnus-art.el ends here