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)
488 (defcustom gnus-save-all-headers t
489 "*If non-nil, don't remove any headers before saving."
490 :group 'gnus-article-saving
493 (defcustom gnus-prompt-before-saving 'always
494 "*This variable says how much prompting is to be done when saving articles.
495 If it is nil, no prompting will be done, and the articles will be
496 saved to the default files. If this variable is `always', each and
497 every article that is saved will be preceded by a prompt, even when
498 saving large batches of articles. If this variable is neither nil not
499 `always', there the user will be prompted once for a file name for
500 each invocation of the saving commands."
501 :group 'gnus-article-saving
502 :type '(choice (item always)
503 (item :tag "never" nil)
504 (sexp :tag "once" :format "%t\n" :value t)))
506 (defcustom gnus-saved-headers gnus-visible-headers
507 "Headers to keep if `gnus-save-all-headers' is nil.
508 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
509 If that variable is nil, however, all headers that match this regexp
510 will be kept while the rest will be deleted before saving."
511 :group 'gnus-article-saving
514 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
515 "A function to save articles in your favourite format.
516 The function must be interactively callable (in other words, it must
517 be an Emacs command).
519 Gnus provides the following functions:
521 * gnus-summary-save-in-rmail (Rmail format)
522 * gnus-summary-save-in-mail (Unix mail format)
523 * gnus-summary-save-in-folder (MH folder)
524 * gnus-summary-save-in-file (article format)
525 * gnus-summary-save-body-in-file (article body)
526 * gnus-summary-save-in-vm (use VM's folder format)
527 * gnus-summary-write-to-file (article format -- overwrite)."
528 :group 'gnus-article-saving
529 :type '(radio (function-item gnus-summary-save-in-rmail)
530 (function-item gnus-summary-save-in-mail)
531 (function-item gnus-summary-save-in-folder)
532 (function-item gnus-summary-save-in-file)
533 (function-item gnus-summary-save-body-in-file)
534 (function-item gnus-summary-save-in-vm)
535 (function-item gnus-summary-write-to-file)))
537 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
538 "A function generating a file name to save articles in Rmail format.
539 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
540 :group 'gnus-article-saving
543 (defcustom gnus-mail-save-name 'gnus-plain-save-name
544 "A function generating a file name to save articles in Unix mail format.
545 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
546 :group 'gnus-article-saving
549 (defcustom gnus-folder-save-name 'gnus-folder-save-name
550 "A function generating a file name to save articles in MH folder.
551 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
552 :group 'gnus-article-saving
555 (defcustom gnus-file-save-name 'gnus-numeric-save-name
556 "A function generating a file name to save articles in article format.
557 The function is called with NEWSGROUP, HEADERS, and optional
559 :group 'gnus-article-saving
562 (defcustom gnus-split-methods
563 '((gnus-article-archive-name)
564 (gnus-article-nndoc-name))
565 "*Variable used to suggest where articles are to be saved.
566 For instance, if you would like to save articles related to Gnus in
567 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
568 you could set this variable to something like:
570 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
571 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
573 This variable is an alist where the key is the match and the
574 value is a list of possible files to save in if the match is
577 If the match is a string, it is used as a regexp match on the
578 article. If the match is a symbol, that symbol will be funcalled
579 from the buffer of the article to be saved with the newsgroup as
580 the parameter. If it is a list, it will be evaled in the same
583 If this form or function returns a string, this string will be
584 used as a possible file name; and if it returns a non-nil list,
585 that list will be used as possible file names."
586 :group 'gnus-article-saving
587 :type '(repeat (choice (list :value (fun) function)
588 (cons :value ("" "") regexp (repeat string))
591 (defcustom gnus-page-delimiter "^\^L"
592 "*Regexp describing what to use as article page delimiters.
593 The default value is \"^\^L\", which is a form linefeed at the
594 beginning of a line."
596 :group 'gnus-article-various)
598 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
599 "*The format specification for the article mode line.
600 See `gnus-summary-mode-line-format' for a closer description.
602 The following additional specs are available:
604 %w The article washing status.
605 %m The number of MIME parts in the article."
607 :group 'gnus-article-various)
609 (defcustom gnus-article-mode-hook nil
610 "*A hook for Gnus article mode."
612 :group 'gnus-article-various)
614 (when (featurep 'xemacs)
615 ;; Extracted from gnus-xmas-define in order to preserve user settings
616 (when (fboundp 'turn-off-scroll-in-place)
617 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
618 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
619 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
621 (defcustom gnus-article-menu-hook nil
622 "*Hook run after the creation of the article mode menu."
624 :group 'gnus-article-various)
626 (defcustom gnus-article-prepare-hook nil
627 "*A hook called after an article has been prepared in the article buffer."
629 :group 'gnus-article-various)
631 (defcustom gnus-copy-article-ignored-headers nil
632 "List of headers to be removed when copying an article.
633 Each element is a regular expression."
634 :version "23.0" ;; No Gnus
635 :type '(repeat regexp)
636 :group 'gnus-article-various)
638 (make-obsolete-variable 'gnus-article-hide-pgp-hook
639 "This variable is obsolete in Gnus 5.10.")
641 (defcustom gnus-article-button-face 'bold
642 "Face used for highlighting buttons in the article buffer.
644 An article button is a piece of text that you can activate by pressing
645 `RET' or `mouse-2' above it."
647 :group 'gnus-article-buttons)
649 (defcustom gnus-article-mouse-face 'highlight
650 "Face used for mouse highlighting in the article buffer.
652 Article buttons will be displayed in this face when the cursor is
655 :group 'gnus-article-buttons)
657 (defcustom gnus-signature-face 'gnus-signature-face
658 "Face used for highlighting a signature in the article buffer.
659 Obsolete; use the face `gnus-signature-face' for customizations instead."
661 :group 'gnus-article-highlight
662 :group 'gnus-article-signature)
664 (defface gnus-signature-face
667 "Face used for highlighting a signature in the article buffer."
668 :group 'gnus-article-highlight
669 :group 'gnus-article-signature)
671 (defface gnus-header-from-face
674 (:foreground "spring green"))
677 (:foreground "red3"))
680 "Face used for displaying from headers."
681 :group 'gnus-article-headers
682 :group 'gnus-article-highlight)
684 (defface gnus-header-subject-face
687 (:foreground "SeaGreen3"))
690 (:foreground "red4"))
692 (:bold t :italic t)))
693 "Face used for displaying subject headers."
694 :group 'gnus-article-headers
695 :group 'gnus-article-highlight)
697 (defface gnus-header-newsgroups-face
700 (:foreground "yellow" :italic t))
703 (:foreground "MidnightBlue" :italic t))
706 "Face used for displaying newsgroups headers.
707 In the default setup this face is only used for crossposted
709 :group 'gnus-article-headers
710 :group 'gnus-article-highlight)
712 (defface gnus-header-name-face
715 (:foreground "SeaGreen"))
718 (:foreground "maroon"))
721 "Face used for displaying header names."
722 :group 'gnus-article-headers
723 :group 'gnus-article-highlight)
725 (defface gnus-header-content-face
728 (:foreground "forest green" :italic t))
731 (:foreground "indianred4" :italic t))
733 (:italic t))) "Face used for displaying header content."
734 :group 'gnus-article-headers
735 :group 'gnus-article-highlight)
737 (defcustom gnus-header-face-alist
738 '(("From" nil gnus-header-from-face)
739 ("Subject" nil gnus-header-subject-face)
740 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
741 ("" gnus-header-name-face gnus-header-content-face))
742 "*Controls highlighting of article headers.
744 An alist of the form (HEADER NAME CONTENT).
746 HEADER is a regular expression which should match the name of a
747 header and NAME and CONTENT are either face names or nil.
749 The name of each header field will be displayed using the face
750 specified by the first element in the list where HEADER matches
751 the header name and NAME is non-nil. Similarly, the content will
752 be displayed by the first non-nil matching CONTENT face."
753 :group 'gnus-article-headers
754 :group 'gnus-article-highlight
755 :type '(repeat (list (regexp :tag "Header")
757 (item :tag "skip" nil)
758 (face :value default))
759 (choice :tag "Content"
760 (item :tag "skip" nil)
761 (face :value default)))))
763 (defcustom gnus-article-decode-hook
764 '(article-decode-charset article-decode-encoded-words
765 article-decode-group-name article-decode-idna-rhs)
766 "*Hook run to decode charsets in articles."
767 :group 'gnus-article-headers
770 (defcustom gnus-display-mime-function 'gnus-display-mime
771 "Function to display MIME articles."
772 :group 'gnus-article-mime
775 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
776 "Function used to decode headers.")
778 (defvar gnus-article-dumbquotes-map
798 "Table for MS-to-Latin1 translation.")
800 (defcustom gnus-ignored-mime-types nil
801 "List of MIME types that should be ignored by Gnus."
803 :group 'gnus-article-mime
804 :type '(repeat regexp))
806 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
807 "List of MIME types that should not be given buttons when rendered inline.
808 See also `gnus-buttonized-mime-types' which may override this variable.
809 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
811 :group 'gnus-article-mime
812 :type '(repeat regexp))
814 (defcustom gnus-buttonized-mime-types nil
815 "List of MIME types that should be given buttons when rendered inline.
816 If set, this variable overrides `gnus-unbuttonized-mime-types'.
817 To see e.g. security buttons you could set this to
818 `(\"multipart/signed\")'.
819 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
821 :group 'gnus-article-mime
822 :type '(repeat regexp))
824 (defcustom gnus-inhibit-mime-unbuttonizing nil
825 "If non-nil, all MIME parts get buttons.
826 When nil (the default value), then some MIME parts do not get buttons,
827 as described by the variables `gnus-buttonized-mime-types' and
828 `gnus-unbuttonized-mime-types'."
830 :group 'gnus-article-mime
833 (defcustom gnus-body-boundary-delimiter "_"
834 "String used to delimit header and body.
835 This variable is used by `gnus-article-treat-body-boundary' which can
836 be controlled by `gnus-treat-body-boundary'."
838 :group 'gnus-article-various
839 :type '(choice (item :tag "None" :value nil)
842 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
844 "Defines the location of the faces database.
845 For information on obtaining this database of pretty pictures, please
846 see http://www.cs.indiana.edu/picons/ftp/index.html"
848 :type '(repeat directory)
849 :link '(url-link :tag "download"
850 "http://www.cs.indiana.edu/picons/ftp/index.html")
851 :link '(custom-manual "(gnus)Picons")
854 (defun gnus-picons-installed-p ()
855 "Say whether picons are installed on your machine."
856 (let ((installed nil))
857 (dolist (database gnus-picon-databases)
858 (when (file-exists-p database)
862 (defcustom gnus-article-mime-part-function nil
863 "Function called with a MIME handle as the argument.
864 This is meant for people who want to do something automatic based
865 on parts -- for instance, adding Vcard info to a database."
866 :group 'gnus-article-mime
869 (defcustom gnus-mime-multipart-functions nil
870 "An alist of MIME types to functions to display them."
872 :group 'gnus-article-mime
873 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
875 (defcustom gnus-article-date-lapsed-new-header nil
876 "Whether the X-Sent and Date headers can coexist.
877 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
878 either replace the old \"Date:\" header (if this variable is nil), or
879 be added below it (otherwise)."
881 :group 'gnus-article-headers
884 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
885 "Function called with a MIME handle as the argument.
886 This is meant for people who want to view first matched part.
887 For `undisplayed-alternative' (default), the first undisplayed
888 part or alternative part is used. For `undisplayed', the first
889 undisplayed part is used. For a function, the first part which
890 the function return t is used. For nil, the first part is
893 :group 'gnus-article-mime
895 (item :tag "first" :value nil)
896 (item :tag "undisplayed" :value undisplayed)
897 (item :tag "undisplayed or alternative"
898 :value undisplayed-alternative)
901 (defcustom gnus-mime-action-alist
902 '(("save to file" . gnus-mime-save-part)
903 ("save and strip" . gnus-mime-save-part-and-strip)
904 ("delete part" . gnus-mime-delete-part)
905 ("display as text" . gnus-mime-inline-part)
906 ("view the part" . gnus-mime-view-part)
907 ("pipe to command" . gnus-mime-pipe-part)
908 ("toggle display" . gnus-article-press-button)
909 ("toggle display" . gnus-article-view-part-as-charset)
910 ("view as type" . gnus-mime-view-part-as-type)
911 ("view internally" . gnus-mime-view-part-internally)
912 ("view externally" . gnus-mime-view-part-externally))
913 "An alist of actions that run on the MIME attachment."
914 :group 'gnus-article-mime
915 :type '(repeat (cons (string :tag "name")
919 ;;; The treatment variables
922 (defvar gnus-part-display-hook nil
923 "Hook called on parts that are to receive treatment.")
925 (defvar gnus-article-treat-custom
926 '(choice (const :tag "Off" nil)
928 (const :tag "Header" head)
929 (const :tag "Last" last)
930 (integer :tag "Less")
931 (repeat :tag "Groups" regexp)
932 (sexp :tag "Predicate")))
934 (defvar gnus-article-treat-head-custom
935 '(choice (const :tag "Off" nil)
936 (const :tag "Header" head)))
938 (defvar gnus-article-treat-types '("text/plain")
941 (defvar gnus-inhibit-treatment nil
942 "Whether to inhibit treatment.")
944 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
945 "Highlight the signature.
946 Valid values are nil, t, `head', `last', an integer or a predicate.
947 See Info node `(gnus)Customizing Articles'."
948 :group 'gnus-article-treat
949 :link '(custom-manual "(gnus)Customizing Articles")
950 :type gnus-article-treat-custom)
951 (put 'gnus-treat-highlight-signature 'highlight t)
953 (defcustom gnus-treat-buttonize 100000
955 Valid values are nil, t, `head', `last', an integer or a predicate.
956 See Info node `(gnus)Customizing Articles'."
957 :group 'gnus-article-treat
958 :link '(custom-manual "(gnus)Customizing Articles")
959 :type gnus-article-treat-custom)
960 (put 'gnus-treat-buttonize 'highlight t)
962 (defcustom gnus-treat-buttonize-head 'head
963 "Add buttons to the head.
964 Valid values are nil, t, `head', `last', an integer or a predicate.
965 See Info node `(gnus)Customizing Articles' for details."
966 :group 'gnus-article-treat
967 :link '(custom-manual "(gnus)Customizing Articles")
968 :type gnus-article-treat-head-custom)
969 (put 'gnus-treat-buttonize-head 'highlight t)
971 (defcustom gnus-treat-emphasize
972 (and (or window-system
976 Valid values are nil, t, `head', `last', an integer or a predicate.
977 See Info node `(gnus)Customizing Articles' for details."
978 :group 'gnus-article-treat
979 :link '(custom-manual "(gnus)Customizing Articles")
980 :type gnus-article-treat-custom)
981 (put 'gnus-treat-emphasize 'highlight t)
983 (defcustom gnus-treat-strip-cr nil
984 "Remove carriage returns.
985 Valid values are nil, t, `head', `last', an integer or a predicate.
986 See Info node `(gnus)Customizing Articles' for details."
988 :group 'gnus-article-treat
989 :link '(custom-manual "(gnus)Customizing Articles")
990 :type gnus-article-treat-custom)
992 (defcustom gnus-treat-unsplit-urls nil
993 "Remove newlines from within URLs.
994 Valid values are nil, t, `head', `last', an integer or a predicate.
995 See Info node `(gnus)Customizing Articles' for details."
997 :group 'gnus-article-treat
998 :link '(custom-manual "(gnus)Customizing Articles")
999 :type gnus-article-treat-custom)
1001 (defcustom gnus-treat-leading-whitespace nil
1002 "Remove leading whitespace in headers.
1003 Valid values are nil, t, `head', `last', an integer or a predicate.
1004 See Info node `(gnus)Customizing Articles' for details."
1006 :group 'gnus-article-treat
1007 :link '(custom-manual "(gnus)Customizing Articles")
1008 :type gnus-article-treat-custom)
1010 (defcustom gnus-treat-hide-headers 'head
1012 Valid values are nil, t, `head', `last', an integer or a predicate.
1013 See Info node `(gnus)Customizing Articles' for details."
1014 :group 'gnus-article-treat
1015 :link '(custom-manual "(gnus)Customizing Articles")
1016 :type gnus-article-treat-head-custom)
1018 (defcustom gnus-treat-hide-boring-headers nil
1019 "Hide boring headers.
1020 Valid values are nil, t, `head', `last', an integer or a predicate.
1021 See Info node `(gnus)Customizing Articles' for details."
1022 :group 'gnus-article-treat
1023 :link '(custom-manual "(gnus)Customizing Articles")
1024 :type gnus-article-treat-head-custom)
1026 (defcustom gnus-treat-hide-signature nil
1027 "Hide the signature.
1028 Valid values are nil, t, `head', `last', an integer or a predicate.
1029 See Info node `(gnus)Customizing Articles' for details."
1030 :group 'gnus-article-treat
1031 :link '(custom-manual "(gnus)Customizing Articles")
1032 :type gnus-article-treat-custom)
1034 (defcustom gnus-treat-fill-article nil
1036 Valid values are nil, t, `head', `last', an integer or a predicate.
1037 See Info node `(gnus)Customizing Articles' for details."
1038 :group 'gnus-article-treat
1039 :link '(custom-manual "(gnus)Customizing Articles")
1040 :type gnus-article-treat-custom)
1042 (defcustom gnus-treat-hide-citation nil
1044 Valid values are nil, t, `head', `last', an integer or a predicate.
1045 See Info node `(gnus)Customizing Articles' for details."
1046 :group 'gnus-article-treat
1047 :link '(custom-manual "(gnus)Customizing Articles")
1048 :type gnus-article-treat-custom)
1050 (defcustom gnus-treat-hide-citation-maybe nil
1052 Valid values are nil, t, `head', `last', an integer or a predicate.
1053 See Info node `(gnus)Customizing Articles' for details."
1054 :group 'gnus-article-treat
1055 :link '(custom-manual "(gnus)Customizing Articles")
1056 :type gnus-article-treat-custom)
1058 (defcustom gnus-treat-strip-list-identifiers 'head
1059 "Strip list identifiers from `gnus-list-identifiers`.
1060 Valid values are nil, t, `head', `last', an integer or a predicate.
1061 See Info node `(gnus)Customizing Articles' for details."
1063 :group 'gnus-article-treat
1064 :link '(custom-manual "(gnus)Customizing Articles")
1065 :type gnus-article-treat-custom)
1067 (make-obsolete-variable 'gnus-treat-strip-pgp
1068 "This option is obsolete in Gnus 5.10.")
1070 (defcustom gnus-treat-strip-pem nil
1071 "Strip PEM signatures.
1072 Valid values are nil, t, `head', `last', an integer or a predicate.
1073 See Info node `(gnus)Customizing Articles' for details."
1074 :group 'gnus-article-treat
1075 :link '(custom-manual "(gnus)Customizing Articles")
1076 :type gnus-article-treat-custom)
1078 (defcustom gnus-treat-strip-banner t
1079 "Strip banners from articles.
1080 The banner to be stripped is specified in the `banner' group parameter.
1081 Valid values are nil, t, `head', `last', an integer or a predicate.
1082 See Info node `(gnus)Customizing Articles' for details."
1083 :group 'gnus-article-treat
1084 :link '(custom-manual "(gnus)Customizing Articles")
1085 :type gnus-article-treat-custom)
1087 (defcustom gnus-treat-highlight-headers 'head
1088 "Highlight the headers.
1089 Valid values are nil, t, `head', `last', an integer or a predicate.
1090 See Info node `(gnus)Customizing Articles' for details."
1091 :group 'gnus-article-treat
1092 :link '(custom-manual "(gnus)Customizing Articles")
1093 :type gnus-article-treat-head-custom)
1094 (put 'gnus-treat-highlight-headers 'highlight t)
1096 (defcustom gnus-treat-highlight-citation t
1097 "Highlight cited text.
1098 Valid values are nil, t, `head', `last', an integer or a predicate.
1099 See Info node `(gnus)Customizing Articles' for details."
1100 :group 'gnus-article-treat
1101 :link '(custom-manual "(gnus)Customizing Articles")
1102 :type gnus-article-treat-custom)
1103 (put 'gnus-treat-highlight-citation 'highlight t)
1105 (defcustom gnus-treat-date-ut nil
1106 "Display the Date in UT (GMT).
1107 Valid values are nil, t, `head', `last', an integer or a predicate.
1108 See Info node `(gnus)Customizing Articles' for details."
1109 :group 'gnus-article-treat
1110 :link '(custom-manual "(gnus)Customizing Articles")
1111 :type gnus-article-treat-head-custom)
1113 (defcustom gnus-treat-date-local nil
1114 "Display the Date in the local timezone.
1115 Valid values are nil, t, `head', `last', an integer or a predicate.
1116 See Info node `(gnus)Customizing Articles' for details."
1117 :group 'gnus-article-treat
1118 :link '(custom-manual "(gnus)Customizing Articles")
1119 :type gnus-article-treat-head-custom)
1121 (defcustom gnus-treat-date-english nil
1122 "Display the Date in a format that can be read aloud in English.
1123 Valid values are nil, t, `head', `last', an integer or a predicate.
1124 See Info node `(gnus)Customizing Articles' for details."
1126 :group 'gnus-article-treat
1127 :link '(custom-manual "(gnus)Customizing Articles")
1128 :type gnus-article-treat-head-custom)
1130 (defcustom gnus-treat-date-lapsed nil
1131 "Display the Date header in a way that says how much time has elapsed.
1132 Valid values are nil, t, `head', `last', an integer or a predicate.
1133 See Info node `(gnus)Customizing Articles' for details."
1134 :group 'gnus-article-treat
1135 :link '(custom-manual "(gnus)Customizing Articles")
1136 :type gnus-article-treat-head-custom)
1138 (defcustom gnus-treat-date-original nil
1139 "Display the date in the original timezone.
1140 Valid values are nil, t, `head', `last', an integer or a predicate.
1141 See Info node `(gnus)Customizing Articles' for details."
1142 :group 'gnus-article-treat
1143 :link '(custom-manual "(gnus)Customizing Articles")
1144 :type gnus-article-treat-head-custom)
1146 (defcustom gnus-treat-date-iso8601 nil
1147 "Display the date in the ISO8601 format.
1148 Valid values are nil, t, `head', `last', an integer or a predicate.
1149 See Info node `(gnus)Customizing Articles' for details."
1151 :group 'gnus-article-treat
1152 :link '(custom-manual "(gnus)Customizing Articles")
1153 :type gnus-article-treat-head-custom)
1155 (defcustom gnus-treat-date-user-defined nil
1156 "Display the date in a user-defined format.
1157 The format is defined by the `gnus-article-time-format' variable.
1158 Valid values are nil, t, `head', `last', an integer or a predicate.
1159 See Info node `(gnus)Customizing Articles' for details."
1160 :group 'gnus-article-treat
1161 :link '(custom-manual "(gnus)Customizing Articles")
1162 :type gnus-article-treat-head-custom)
1164 (defcustom gnus-treat-strip-headers-in-body t
1165 "Strip the X-No-Archive header line from the beginning of the body.
1166 Valid values are nil, t, `head', `last', an integer or a predicate.
1167 See Info node `(gnus)Customizing Articles' for details."
1169 :group 'gnus-article-treat
1170 :link '(custom-manual "(gnus)Customizing Articles")
1171 :type gnus-article-treat-custom)
1173 (defcustom gnus-treat-strip-trailing-blank-lines nil
1174 "Strip trailing blank lines.
1175 Valid values are nil, t, `head', `last', an integer or a predicate.
1176 See Info node `(gnus)Customizing Articles' for details."
1177 :group 'gnus-article-treat
1178 :link '(custom-manual "(gnus)Customizing Articles")
1179 :type gnus-article-treat-custom)
1181 (defcustom gnus-treat-strip-leading-blank-lines nil
1182 "Strip leading blank lines.
1183 Valid values are nil, t, `head', `last', an integer or a predicate.
1184 See Info node `(gnus)Customizing Articles' for details."
1185 :group 'gnus-article-treat
1186 :link '(custom-manual "(gnus)Customizing Articles")
1187 :type gnus-article-treat-custom)
1189 (defcustom gnus-treat-strip-multiple-blank-lines nil
1190 "Strip multiple blank lines.
1191 Valid values are nil, t, `head', `last', an integer or a predicate.
1192 See Info node `(gnus)Customizing Articles' for details."
1193 :group 'gnus-article-treat
1194 :link '(custom-manual "(gnus)Customizing Articles")
1195 :type gnus-article-treat-custom)
1197 (defcustom gnus-treat-unfold-headers 'head
1198 "Unfold folded header lines.
1199 Valid values are nil, t, `head', `last', an integer or a predicate.
1200 See Info node `(gnus)Customizing Articles' for details."
1202 :group 'gnus-article-treat
1203 :link '(custom-manual "(gnus)Customizing Articles")
1204 :type gnus-article-treat-custom)
1206 (defcustom gnus-treat-fold-headers nil
1208 Valid values are nil, t, `head', `last', an integer or a predicate.
1209 See Info node `(gnus)Customizing Articles' for details."
1211 :group 'gnus-article-treat
1212 :link '(custom-manual "(gnus)Customizing Articles")
1213 :type gnus-article-treat-custom)
1215 (defcustom gnus-treat-fold-newsgroups 'head
1216 "Fold the Newsgroups and Followup-To headers.
1217 Valid values are nil, t, `head', `last', an integer or a predicate.
1218 See Info node `(gnus)Customizing Articles' for details."
1220 :group 'gnus-article-treat
1221 :link '(custom-manual "(gnus)Customizing Articles")
1222 :type gnus-article-treat-custom)
1224 (defcustom gnus-treat-overstrike t
1225 "Treat overstrike highlighting.
1226 Valid values are nil, t, `head', `last', an integer or a predicate.
1227 See Info node `(gnus)Customizing Articles' for details."
1228 :group 'gnus-article-treat
1229 :link '(custom-manual "(gnus)Customizing Articles")
1230 :type gnus-article-treat-custom)
1231 (put 'gnus-treat-overstrike 'highlight t)
1233 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1234 "Treat ANSI SGR control sequences.
1235 Valid values are nil, t, `head', `last', an integer or a predicate.
1236 See Info node `(gnus)Customizing Articles' for details."
1237 :group 'gnus-article-treat
1238 :link '(custom-manual "(gnus)Customizing Articles")
1239 :type gnus-article-treat-custom)
1241 (make-obsolete-variable 'gnus-treat-display-xface
1242 'gnus-treat-display-x-face)
1244 (defcustom gnus-treat-display-x-face
1245 (and (not noninteractive)
1246 (or (and (fboundp 'image-type-available-p)
1247 (image-type-available-p 'xbm)
1248 (string-match "^0x" (shell-command-to-string "uncompface"))
1249 (executable-find "icontopbm"))
1250 (and (featurep 'xemacs)
1253 "Display X-Face headers.
1254 Valid values are nil, t, `head', `last', an integer or a predicate.
1255 See Info node `(gnus)Customizing Articles' and Info node
1256 `(gnus)X-Face' for details."
1257 :group 'gnus-article-treat
1259 :link '(custom-manual "(gnus)Customizing Articles")
1260 :link '(custom-manual "(gnus)X-Face")
1261 :type gnus-article-treat-head-custom
1262 :set (lambda (symbol value)
1265 (cond ((or (boundp symbol) (get symbol 'saved-value))
1267 ((boundp 'gnus-treat-display-xface)
1269 ** gnus-treat-display-xface is an obsolete variable;\
1270 use gnus-treat-display-x-face instead")
1271 (default-value 'gnus-treat-display-xface))
1272 ((get 'gnus-treat-display-xface 'saved-value)
1274 ** gnus-treat-display-xface is an obsolete variable;\
1275 use gnus-treat-display-x-face instead")
1276 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1279 (put 'gnus-treat-display-x-face 'highlight t)
1281 (defcustom gnus-treat-display-face
1282 (and (not noninteractive)
1283 (or (and (fboundp 'image-type-available-p)
1284 (image-type-available-p 'png))
1285 (and (featurep 'xemacs)
1288 "Display Face headers.
1289 Valid values are nil, t, `head', `last', an integer or a predicate.
1290 See Info node `(gnus)Customizing Articles' and Info node
1291 `(gnus)X-Face' for details."
1292 :group 'gnus-article-treat
1294 :link '(custom-manual "(gnus)Customizing Articles")
1295 :link '(custom-manual "(gnus)X-Face")
1296 :type gnus-article-treat-head-custom)
1297 (put 'gnus-treat-display-face 'highlight t)
1299 (defcustom gnus-treat-display-smileys
1300 (if (or (and (featurep 'xemacs)
1302 (and (fboundp 'image-type-available-p)
1303 (image-type-available-p 'pbm)))
1306 Valid values are nil, t, `head', `last', an integer or a predicate.
1307 See Info node `(gnus)Customizing Articles' and Info node
1308 `(gnus)Smileys' for details."
1309 :group 'gnus-article-treat
1311 :link '(custom-manual "(gnus)Customizing Articles")
1312 :link '(custom-manual "(gnus)Smileys")
1313 :type gnus-article-treat-custom)
1314 (put 'gnus-treat-display-smileys 'highlight t)
1316 (defcustom gnus-treat-from-picon
1317 (if (and (gnus-image-type-available-p 'xpm)
1318 (gnus-picons-installed-p))
1320 "Display picons in the From header.
1321 Valid values are nil, t, `head', `last', an integer or a predicate.
1322 See Info node `(gnus)Customizing Articles' and Info node
1323 `(gnus)Picons' for details."
1325 :group 'gnus-article-treat
1327 :link '(custom-manual "(gnus)Customizing Articles")
1328 :link '(custom-manual "(gnus)Picons")
1329 :type gnus-article-treat-head-custom)
1330 (put 'gnus-treat-from-picon 'highlight t)
1332 (defcustom gnus-treat-mail-picon
1333 (if (and (gnus-image-type-available-p 'xpm)
1334 (gnus-picons-installed-p))
1336 "Display picons in To and Cc headers.
1337 Valid values are nil, t, `head', `last', an integer or a predicate.
1338 See Info node `(gnus)Customizing Articles' and Info node
1339 `(gnus)Picons' for details."
1341 :group 'gnus-article-treat
1343 :link '(custom-manual "(gnus)Customizing Articles")
1344 :link '(custom-manual "(gnus)Picons")
1345 :type gnus-article-treat-head-custom)
1346 (put 'gnus-treat-mail-picon 'highlight t)
1348 (defcustom gnus-treat-newsgroups-picon
1349 (if (and (gnus-image-type-available-p 'xpm)
1350 (gnus-picons-installed-p))
1352 "Display picons in the Newsgroups and Followup-To headers.
1353 Valid values are nil, t, `head', `last', an integer or a predicate.
1354 See Info node `(gnus)Customizing Articles' and Info node
1355 `(gnus)Picons' for details."
1357 :group 'gnus-article-treat
1359 :link '(custom-manual "(gnus)Customizing Articles")
1360 :link '(custom-manual "(gnus)Picons")
1361 :type gnus-article-treat-head-custom)
1362 (put 'gnus-treat-newsgroups-picon 'highlight t)
1364 (defcustom gnus-treat-body-boundary
1365 (if (and (eq window-system 'x)
1366 (or gnus-treat-newsgroups-picon
1367 gnus-treat-mail-picon
1368 gnus-treat-from-picon))
1370 "Draw a boundary at the end of the headers.
1371 Valid values are nil and `head'.
1372 See Info node `(gnus)Customizing Articles' for details."
1374 :group 'gnus-article-treat
1375 :link '(custom-manual "(gnus)Customizing Articles")
1376 :type gnus-article-treat-head-custom)
1378 (defcustom gnus-treat-capitalize-sentences nil
1379 "Capitalize sentence-starting words.
1380 Valid values are nil, t, `head', `last', an integer or a predicate.
1381 See Info node `(gnus)Customizing Articles' for details."
1383 :group 'gnus-article-treat
1384 :link '(custom-manual "(gnus)Customizing Articles")
1385 :type gnus-article-treat-custom)
1387 (defcustom gnus-treat-wash-html nil
1389 Valid values are nil, t, `head', `last', an integer or a predicate.
1390 See Info node `(gnus)Customizing Articles' for details."
1392 :group 'gnus-article-treat
1393 :link '(custom-manual "(gnus)Customizing Articles")
1394 :type gnus-article-treat-custom)
1396 (defcustom gnus-treat-fill-long-lines nil
1398 Valid values are nil, t, `head', `last', an integer or a predicate.
1399 See Info node `(gnus)Customizing Articles' for details."
1400 :group 'gnus-article-treat
1401 :link '(custom-manual "(gnus)Customizing Articles")
1402 :type gnus-article-treat-custom)
1404 (defcustom gnus-treat-play-sounds nil
1406 Valid values are nil, t, `head', `last', an integer or a predicate.
1407 See Info node `(gnus)Customizing Articles' for details."
1409 :group 'gnus-article-treat
1410 :link '(custom-manual "(gnus)Customizing Articles")
1411 :type gnus-article-treat-custom)
1413 (defcustom gnus-treat-translate nil
1414 "Translate articles from one language to another.
1415 Valid values are nil, t, `head', `last', an integer or a predicate.
1416 See Info node `(gnus)Customizing Articles' for details."
1418 :group 'gnus-article-treat
1419 :link '(custom-manual "(gnus)Customizing Articles")
1420 :type gnus-article-treat-custom)
1422 (defcustom gnus-treat-x-pgp-sig nil
1424 To automatically treat X-PGP-Sig, set it to head.
1425 Valid values are nil, t, `head', `last', an integer or a predicate.
1426 See Info node `(gnus)Customizing Articles' for details."
1428 :group 'gnus-article-treat
1429 :group 'mime-security
1430 :link '(custom-manual "(gnus)Customizing Articles")
1431 :type gnus-article-treat-custom)
1433 (defvar gnus-article-encrypt-protocol-alist
1434 '(("PGP" . mml2015-self-encrypt)))
1436 ;; Set to nil if more than one protocol added to
1437 ;; gnus-article-encrypt-protocol-alist.
1438 (defcustom gnus-article-encrypt-protocol "PGP"
1439 "The protocol used for encrypt articles.
1440 It is a string, such as \"PGP\". If nil, ask user."
1443 :group 'mime-security)
1445 (defvar gnus-article-wash-function nil
1446 "Function used for converting HTML into text.")
1448 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1449 (mm-coding-system-p 'utf-8)
1450 (executable-find idna-program))
1451 "Whether IDNA decoding of headers is used when viewing messages.
1452 This requires GNU Libidn, and by default only enabled if it is found."
1454 :group 'gnus-article-headers
1457 (defcustom gnus-article-over-scroll nil
1458 "If non-nil, allow scrolling the article buffer even when there no more text."
1460 :group 'gnus-article
1463 ;;; Internal variables
1465 (defvar gnus-english-month-names
1466 '("January" "February" "March" "April" "May" "June" "July" "August"
1467 "September" "October" "November" "December"))
1469 (defvar gnus-button-regexp nil)
1470 (defvar gnus-button-marker-list nil)
1471 ;; Regexp matching any of the regexps from `gnus-button-alist'.
1473 (defvar gnus-button-last nil)
1474 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
1476 (defvar article-goto-body-goes-to-point-min-p nil)
1477 (defvar gnus-article-wash-types nil)
1478 (defvar gnus-article-emphasis-alist nil)
1479 (defvar gnus-article-image-alist nil)
1481 (defvar gnus-article-mime-handle-alist-1 nil)
1482 (defvar gnus-treatment-function-alist
1483 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1484 (gnus-treat-strip-banner gnus-article-strip-banner)
1485 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1486 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1487 (gnus-treat-buttonize gnus-article-add-buttons)
1488 (gnus-treat-fill-article gnus-article-fill-cited-article)
1489 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1490 (gnus-treat-strip-cr gnus-article-remove-cr)
1491 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1492 (gnus-treat-date-ut gnus-article-date-ut)
1493 (gnus-treat-date-local gnus-article-date-local)
1494 (gnus-treat-date-english gnus-article-date-english)
1495 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1496 (gnus-treat-date-original gnus-article-date-original)
1497 (gnus-treat-date-user-defined gnus-article-date-user)
1498 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1499 (gnus-treat-display-x-face gnus-article-display-x-face)
1500 (gnus-treat-display-face gnus-article-display-face)
1501 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1502 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1503 (gnus-treat-hide-signature gnus-article-hide-signature)
1504 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1505 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1506 (gnus-treat-strip-pem gnus-article-hide-pem)
1507 (gnus-treat-from-picon gnus-treat-from-picon)
1508 (gnus-treat-mail-picon gnus-treat-mail-picon)
1509 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1510 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1511 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1512 (gnus-treat-strip-trailing-blank-lines
1513 gnus-article-remove-trailing-blank-lines)
1514 (gnus-treat-strip-leading-blank-lines
1515 gnus-article-strip-leading-blank-lines)
1516 (gnus-treat-strip-multiple-blank-lines
1517 gnus-article-strip-multiple-blank-lines)
1518 (gnus-treat-overstrike gnus-article-treat-overstrike)
1519 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1520 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1521 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1522 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1523 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1524 (gnus-treat-display-smileys gnus-treat-smiley)
1525 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1526 (gnus-treat-wash-html gnus-article-wash-html)
1527 (gnus-treat-emphasize gnus-article-emphasize)
1528 (gnus-treat-hide-citation gnus-article-hide-citation)
1529 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1530 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1531 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1532 (gnus-treat-play-sounds gnus-earcon-display)))
1534 (defvar gnus-article-mime-handle-alist nil)
1535 (defvar article-lapsed-timer nil)
1536 (defvar gnus-article-current-summary nil)
1538 (defvar gnus-article-mode-syntax-table
1539 (let ((table (copy-syntax-table text-mode-syntax-table)))
1540 ;; This causes the citation match run O(2^n).
1541 ;; (modify-syntax-entry ?- "w" table)
1542 (modify-syntax-entry ?> ")<" table)
1543 (modify-syntax-entry ?< "(>" table)
1544 ;; make M-. in article buffers work for `foo' strings
1545 (modify-syntax-entry ?' " " table)
1546 (modify-syntax-entry ?` " " table)
1548 "Syntax table used in article mode buffers.
1549 Initialized from `text-mode-syntax-table.")
1551 (defvar gnus-save-article-buffer nil)
1553 (defvar gnus-article-mode-line-format-alist
1554 (nconc '((?w (gnus-article-wash-status) ?s)
1555 (?m (gnus-article-mime-part-status) ?s))
1556 gnus-summary-mode-line-format-alist))
1558 (defvar gnus-number-of-articles-to-be-saved nil)
1560 (defvar gnus-inhibit-hiding nil)
1562 (defvar gnus-article-edit-mode nil)
1564 ;;; Macros for dealing with the article buffer.
1566 (defmacro gnus-with-article-headers (&rest forms)
1568 (set-buffer gnus-article-buffer)
1570 (let ((inhibit-read-only t)
1571 (inhibit-point-motion-hooks t)
1572 (case-fold-search t))
1573 (article-narrow-to-head)
1576 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1577 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1579 (defmacro gnus-with-article-buffer (&rest forms)
1581 (set-buffer gnus-article-buffer)
1582 (let ((inhibit-read-only t))
1585 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1586 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1588 (defun gnus-article-goto-header (header)
1589 "Go to HEADER, which is a regular expression."
1590 (re-search-forward (concat "^\\(" header "\\):") nil t))
1592 (defsubst gnus-article-hide-text (b e props)
1593 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1594 (gnus-add-text-properties-when 'article-type nil b e props)
1595 (when (memq 'intangible props)
1597 (max (1- b) (point-min))
1598 b 'intangible (cddr (memq 'intangible props)))))
1600 (defsubst gnus-article-unhide-text (b e)
1601 "Remove hidden text properties from region between B and E."
1602 (remove-text-properties b e gnus-hidden-properties)
1603 (when (memq 'intangible gnus-hidden-properties)
1604 (put-text-property (max (1- b) (point-min))
1605 b 'intangible nil)))
1607 (defun gnus-article-hide-text-type (b e type)
1608 "Hide text of TYPE between B and E."
1609 (gnus-add-wash-type type)
1610 (gnus-article-hide-text
1611 b e (cons 'article-type (cons type gnus-hidden-properties))))
1613 (defun gnus-article-unhide-text-type (b e type)
1614 "Unhide text of TYPE between B and E."
1615 (gnus-delete-wash-type type)
1616 (remove-text-properties
1617 b e (cons 'article-type (cons type gnus-hidden-properties)))
1618 (when (memq 'intangible gnus-hidden-properties)
1619 (put-text-property (max (1- b) (point-min))
1620 b 'intangible nil)))
1622 (defun gnus-article-hide-text-of-type (type)
1623 "Hide text of TYPE in the current buffer."
1625 (let ((b (point-min))
1627 (while (setq b (text-property-any b e 'article-type type))
1628 (add-text-properties b (incf b) gnus-hidden-properties)))))
1630 (defun gnus-article-delete-text-of-type (type)
1631 "Delete text of TYPE in the current buffer."
1633 (let ((b (point-min)))
1634 (while (setq b (text-property-any b (point-max) 'article-type type))
1636 b (or (text-property-not-all b (point-max) 'article-type type)
1639 (defun gnus-article-delete-invisible-text ()
1640 "Delete all invisible text in the current buffer."
1642 (let ((b (point-min)))
1643 (while (setq b (text-property-any b (point-max) 'invisible t))
1645 b (or (text-property-not-all b (point-max) 'invisible t)
1648 (defun gnus-article-text-type-exists-p (type)
1649 "Say whether any text of type TYPE exists in the buffer."
1650 (text-property-any (point-min) (point-max) 'article-type type))
1652 (defsubst gnus-article-header-rank ()
1653 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1654 (let ((list gnus-sorted-header-list)
1657 (if (looking-at (car list))
1659 (setq list (cdr list))
1663 (defun article-hide-headers (&optional arg delete)
1664 "Hide unwanted headers and possibly sort them as well."
1666 ;; This function might be inhibited.
1667 (unless gnus-inhibit-hiding
1668 (let ((inhibit-read-only nil)
1669 (case-fold-search t)
1670 (max (1+ (length gnus-sorted-header-list)))
1671 (inhibit-point-motion-hooks t)
1672 (cur (current-buffer))
1673 ignored visible beg)
1675 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1676 ;; group parameters, so we should go to the summary buffer.
1679 (progn (set-buffer gnus-summary-buffer) t)
1681 (setq ignored (when (not gnus-visible-headers)
1682 (cond ((stringp gnus-ignored-headers)
1683 gnus-ignored-headers)
1684 ((listp gnus-ignored-headers)
1685 (mapconcat 'identity
1686 gnus-ignored-headers
1688 visible (cond ((stringp gnus-visible-headers)
1689 gnus-visible-headers)
1690 ((and gnus-visible-headers
1691 (listp gnus-visible-headers))
1692 (mapconcat 'identity
1693 gnus-visible-headers
1697 ;; First we narrow to just the headers.
1698 (article-narrow-to-head)
1699 ;; Hide any "From " lines at the beginning of (mail) articles.
1700 (while (looking-at "From ")
1703 (delete-region (point-min) (point)))
1704 ;; Then treat the rest of the header lines.
1705 ;; Then we use the two regular expressions
1706 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1707 ;; select which header lines is to remain visible in the
1709 (while (re-search-forward "^[^ \t:]*:" nil t)
1711 ;; Mark the rank of the header.
1713 (point) (1+ (point)) 'message-rank
1714 (if (or (and visible (looking-at visible))
1716 (not (looking-at ignored))))
1717 (gnus-article-header-rank)
1720 (message-sort-headers-1)
1721 (when (setq beg (text-property-any
1722 (point-min) (point-max) 'message-rank (+ 2 max)))
1723 ;; We delete the unwanted headers.
1724 (gnus-add-wash-type 'headers)
1725 (add-text-properties (point-min) (+ 5 (point-min))
1726 '(article-type headers dummy-invisible t))
1727 (delete-region beg (point-max))))))))
1729 (defun article-hide-boring-headers (&optional arg)
1730 "Toggle hiding of headers that aren't very interesting.
1731 If given a negative prefix, always show; if given a positive prefix,
1733 (interactive (gnus-article-hidden-arg))
1734 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1735 (not gnus-show-all-headers))
1738 (let ((inhibit-read-only t)
1739 (inhibit-point-motion-hooks t))
1740 (article-narrow-to-head)
1741 (dolist (elem gnus-boring-article-headers)
1742 (goto-char (point-min))
1744 ;; Hide empty headers.
1746 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1748 (gnus-article-hide-text-type
1752 (if (re-search-forward "^[^ \t]" nil t)
1756 ;; Hide boring Newsgroups header.
1757 ((eq elem 'newsgroups)
1758 (when (gnus-string-equal
1759 (gnus-fetch-field "newsgroups")
1760 (gnus-group-real-name
1761 (if (boundp 'gnus-newsgroup-name)
1764 (gnus-article-hide-header "newsgroups")))
1765 ((eq elem 'to-address)
1766 (let ((to (message-fetch-field "to"))
1768 (gnus-parameter-to-address
1769 (if (boundp 'gnus-newsgroup-name)
1770 gnus-newsgroup-name ""))))
1771 (when (and to to-address
1774 ;; only one address in To
1775 (nth 1 (mail-extract-address-components to))
1777 (gnus-article-hide-header "to"))))
1779 (let ((to (message-fetch-field "to"))
1781 (gnus-parameter-to-list
1782 (if (boundp 'gnus-newsgroup-name)
1783 gnus-newsgroup-name ""))))
1784 (when (and to to-list
1787 ;; only one address in To
1788 (nth 1 (mail-extract-address-components to))
1790 (gnus-article-hide-header "to"))))
1792 (let ((cc (message-fetch-field "cc"))
1794 (gnus-parameter-to-list
1795 (if (boundp 'gnus-newsgroup-name)
1796 gnus-newsgroup-name ""))))
1797 (when (and cc to-list
1800 ;; only one address in CC
1801 (nth 1 (mail-extract-address-components cc))
1803 (gnus-article-hide-header "cc"))))
1804 ((eq elem 'followup-to)
1805 (when (gnus-string-equal
1806 (message-fetch-field "followup-to")
1807 (message-fetch-field "newsgroups"))
1808 (gnus-article-hide-header "followup-to")))
1809 ((eq elem 'reply-to)
1810 (if (gnus-group-find-parameter
1811 gnus-newsgroup-name 'broken-reply-to)
1812 (gnus-article-hide-header "reply-to")
1813 (let ((from (message-fetch-field "from"))
1814 (reply-to (message-fetch-field "reply-to")))
1821 (lambda (x) (downcase (cadr x)))
1822 (mail-extract-address-components from t))
1825 (lambda (x) (downcase (cadr x)))
1826 (mail-extract-address-components reply-to t))
1828 (gnus-article-hide-header "reply-to")))))
1830 (let ((date (message-fetch-field "date")))
1832 (< (days-between (current-time-string) date)
1834 (gnus-article-hide-header "date"))))
1836 (let ((to (message-fetch-field "to"))
1837 (cc (message-fetch-field "cc")))
1838 (when (> (length to) 1024)
1839 (gnus-article-hide-header "to"))
1840 (when (> (length cc) 1024)
1841 (gnus-article-hide-header "cc"))))
1845 (goto-char (point-min))
1846 (while (re-search-forward "^to:" nil t)
1847 (setq to-count (1+ to-count)))
1848 (when (> to-count 1)
1849 (while (> to-count 0)
1850 (goto-char (point-min))
1852 (re-search-forward "^to:" nil nil to-count)
1854 (narrow-to-region (point) (point-max))
1855 (gnus-article-hide-header "to"))
1856 (setq to-count (1- to-count))))
1857 (goto-char (point-min))
1858 (while (re-search-forward "^cc:" nil t)
1859 (setq cc-count (1+ cc-count)))
1860 (when (> cc-count 1)
1861 (while (> cc-count 0)
1862 (goto-char (point-min))
1864 (re-search-forward "^cc:" nil nil cc-count)
1866 (narrow-to-region (point) (point-max))
1867 (gnus-article-hide-header "cc"))
1868 (setq cc-count (1- cc-count)))))))))))))
1870 (defun gnus-article-hide-header (header)
1872 (goto-char (point-min))
1873 (when (re-search-forward (concat "^" header ":") nil t)
1874 (gnus-article-hide-text-type
1878 (if (re-search-forward "^[^ \t]" nil t)
1883 (defvar gnus-article-normalized-header-length 40
1884 "Length of normalized headers.")
1886 (defun article-normalize-headers ()
1887 "Make all header lines 40 characters long."
1889 (let ((inhibit-read-only t)
1893 (article-narrow-to-head)
1896 ((< (setq column (- (point-at-eol) (point)))
1897 gnus-article-normalized-header-length)
1899 (insert (make-string
1900 (- gnus-article-normalized-header-length column)
1902 ((> column gnus-article-normalized-header-length)
1903 (gnus-put-text-property
1905 (forward-char gnus-article-normalized-header-length)
1912 (forward-line 1))))))
1914 (defun article-treat-dumbquotes ()
1915 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
1916 Note that this function guesses whether a character is a sm*rtq**t* or
1917 not, so it should only be used interactively.
1919 Sm*rtq**t*s are M****s***'s unilateral extension to the
1920 iso-8859-1 character map in an attempt to provide more quoting
1921 characters. If you see something like \\222 or \\264 where
1922 you're expecting some kind of apostrophe or quotation mark, then
1925 (article-translate-strings gnus-article-dumbquotes-map))
1927 (defun article-translate-characters (from to)
1928 "Translate all characters in the body of the article according to FROM and TO.
1929 FROM is a string of characters to translate from; to is a string of
1930 characters to translate to."
1932 (when (article-goto-body)
1933 (let ((inhibit-read-only t)
1934 (x (make-string 225 ?x))
1936 (while (< (incf i) (length x))
1939 (while (< i (length from))
1940 (aset x (aref from i) (aref to i))
1942 (translate-region (point) (point-max) x)))))
1944 (defun article-translate-strings (map)
1945 "Translate all string in the body of the article according to MAP.
1946 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1948 (when (article-goto-body)
1949 (let ((inhibit-read-only t))
1952 (while (search-forward (car elem) nil t)
1953 (replace-match (cadr elem)))))))))
1955 (defun article-treat-overstrike ()
1956 "Translate overstrikes into bold text."
1959 (when (article-goto-body)
1960 (let ((inhibit-read-only t))
1961 (while (search-forward "\b" nil t)
1962 (let ((next (char-after))
1963 (previous (char-after (- (point) 2))))
1964 ;; We do the boldification/underlining by hiding the
1965 ;; overstrikes and putting the proper text property
1969 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1970 (put-text-property (point) (1+ (point)) 'face 'bold))
1972 (gnus-article-hide-text-type
1973 (1- (point)) (1+ (point)) 'overstrike)
1975 (- (point) 2) (1- (point)) 'face 'underline))
1977 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1979 (point) (1+ (point)) 'face 'underline)))))))))
1981 (defun article-treat-ansi-sequences ()
1982 "Translate ANSI SGR control sequences into overlays or extents."
1985 (when (article-goto-body)
1986 (let ((inhibit-read-only t))
1987 (ansi-color-apply-on-region (point) (point-max))))))
1989 (defun gnus-article-treat-unfold-headers ()
1990 "Unfold folded message headers.
1991 Only the headers that fit into the current window width will be
1994 (gnus-with-article-headers
1998 (mail-header-narrow-to-field)
1999 (let ((header (buffer-string)))
2002 (goto-char (point-min))
2003 (while (re-search-forward "\n[\t ]" nil t)
2004 (replace-match " " t t)))
2005 (setq length (- (point-max) (point-min) 1)))
2006 (when (< length (window-width))
2007 (while (re-search-forward "\n[\t ]" nil t)
2008 (replace-match " " t t)))
2009 (goto-char (point-max)))))))
2011 (defun gnus-article-treat-fold-headers ()
2012 "Fold message headers."
2014 (gnus-with-article-headers
2017 (mail-header-narrow-to-field)
2018 (mail-header-fold-field)
2019 (goto-char (point-max))))))
2021 (defun gnus-treat-smiley ()
2022 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2024 (gnus-with-article-buffer
2025 (if (memq 'smiley gnus-article-wash-types)
2026 (gnus-delete-images 'smiley)
2028 (let ((images (smiley-region (point) (point-max))))
2030 (gnus-add-wash-type 'smiley)
2031 (dolist (image images)
2032 (gnus-add-image 'smiley image)))))))
2034 (defun gnus-article-remove-images ()
2035 "Remove all images from the article buffer."
2037 (gnus-with-article-buffer
2038 (dolist (elem gnus-article-image-alist)
2039 (gnus-delete-images (car elem)))))
2041 (defun gnus-article-treat-fold-newsgroups ()
2042 "Unfold folded message headers.
2043 Only the headers that fit into the current window width will be
2046 (gnus-with-article-headers
2047 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2049 (mail-header-narrow-to-field)
2050 (while (re-search-forward ", *" nil t)
2051 (replace-match ", " t t))
2052 (mail-header-fold-field)
2053 (goto-char (point-max))))))
2055 (defun gnus-article-treat-body-boundary ()
2056 "Place a boundary line at the end of the headers."
2058 (when (and gnus-body-boundary-delimiter
2059 (> (length gnus-body-boundary-delimiter) 0))
2060 (gnus-with-article-headers
2061 (goto-char (point-max))
2062 (let ((start (point)))
2063 (insert "X-Boundary: ")
2064 (gnus-add-text-properties start (point) '(invisible t intangible t))
2066 (while (>= (1- (window-width)) (length str))
2067 (setq str (concat str gnus-body-boundary-delimiter)))
2068 (substring str 0 (1- (window-width))))
2070 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2072 (defun article-fill-long-lines ()
2073 "Fill lines that are wider than the window width."
2076 (let ((inhibit-read-only t)
2077 (width (window-width (get-buffer-window (current-buffer)))))
2080 (let ((adaptive-fill-mode nil)) ;Why? -sm
2083 (when (>= (current-column) (min fill-column width))
2084 (narrow-to-region (min (1+ (point)) (point-max))
2086 (let ((goback (point-marker)))
2087 (fill-paragraph nil)
2088 (goto-char (marker-position goback)))
2090 (forward-line 1)))))))
2092 (defun article-capitalize-sentences ()
2093 "Capitalize the first word in each sentence."
2096 (let ((inhibit-read-only t)
2097 (paragraph-start "^[\n\^L]"))
2101 (forward-sentence)))))
2103 (defun article-remove-cr ()
2104 "Remove trailing CRs and then translate remaining CRs into LFs."
2107 (let ((inhibit-read-only t))
2108 (goto-char (point-min))
2109 (while (re-search-forward "\r+$" nil t)
2110 (replace-match "" t t))
2111 (goto-char (point-min))
2112 (while (search-forward "\r" nil t)
2113 (replace-match "\n" t t)))))
2115 (defun article-remove-trailing-blank-lines ()
2116 "Remove all trailing blank lines from the article."
2119 (let ((inhibit-read-only t))
2120 (goto-char (point-max))
2124 (while (and (not (bobp))
2125 (looking-at "^[ \t]*$")
2126 (not (gnus-annotation-in-region-p
2127 (point) (point-at-eol))))
2133 (defvar gnus-face-properties-alist))
2135 (defun article-display-face ()
2136 "Display any Face headers in the header."
2138 (let ((wash-face-p buffer-read-only))
2139 (gnus-with-article-headers
2140 ;; When displaying parts, this function can be called several times on
2141 ;; the same article, without any intended toggle semantic (as typing `W
2142 ;; D d' would have). So face deletion must occur only when we come from
2143 ;; an interactive command, that is when the *Article* buffer is
2145 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2146 (gnus-delete-images 'face)
2149 (when (and wash-face-p
2151 (goto-char (point-min))
2152 (not (re-search-forward "^Face:[\t ]*" nil t)))
2153 (gnus-buffer-live-p gnus-original-article-buffer))
2154 (set-buffer gnus-original-article-buffer))
2156 (mail-narrow-to-head)
2157 (while (gnus-article-goto-header "Face")
2158 (setq faces (nconc faces (list (mail-header-field-value)))))))
2159 (dolist (face faces)
2160 (let ((png (gnus-convert-face-to-png face))
2164 (apply 'gnus-create-image png 'png t
2165 (cdr (assq 'png gnus-face-properties-alist))))
2166 (gnus-article-goto-header "from")
2168 (insert "From: [no `from' set]\n")
2170 (gnus-add-wash-type 'face)
2171 (gnus-add-image 'face image)
2172 (gnus-put-image image nil 'face))))))
2175 (defun article-display-x-face (&optional force)
2176 "Look for an X-Face header and display it if present."
2177 (interactive (list 'force))
2178 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2179 (gnus-with-article-headers
2180 ;; Delete the old process, if any.
2181 (when (process-status "article-x-face")
2182 (delete-process "article-x-face"))
2183 ;; See the comment in `article-display-face'.
2184 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2185 ;; We have already displayed X-Faces, so we remove them
2187 (gnus-delete-images 'xface)
2189 (let (x-faces from face)
2191 (when (and wash-face-p
2193 (goto-char (point-min))
2194 (not (re-search-forward
2195 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2196 (gnus-buffer-live-p gnus-original-article-buffer))
2197 ;; If type `W f', use gnus-original-article-buffer,
2198 ;; otherwise use the current buffer because displaying
2199 ;; RFC822 parts calls this function too.
2200 (set-buffer gnus-original-article-buffer))
2202 (mail-narrow-to-head)
2203 (while (gnus-article-goto-header "X-Face")
2204 (push (mail-header-field-value) x-faces))
2205 (setq from (message-fetch-field "from"))))
2206 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2207 ;; single external face.
2208 (when (stringp gnus-article-x-face-command)
2209 (setq x-faces (list (car x-faces))))
2210 (while (and (setq face (pop x-faces))
2211 gnus-article-x-face-command
2213 ;; Check whether this face is censored.
2214 (not gnus-article-x-face-too-ugly)
2215 (and gnus-article-x-face-too-ugly from
2216 (not (string-match gnus-article-x-face-too-ugly
2218 ;; We display the face.
2219 (cond ((stringp gnus-article-x-face-command)
2220 ;; The command is a string, so we interpret the command
2221 ;; as a, well, command, and fork it off.
2222 (let ((process-connection-type nil))
2223 (gnus-set-process-query-on-exit-flag
2225 "article-x-face" nil shell-file-name
2226 shell-command-switch gnus-article-x-face-command)
2230 (process-send-region "article-x-face"
2231 (point-min) (point-max)))
2232 (process-send-eof "article-x-face")))
2233 ((functionp gnus-article-x-face-command)
2234 ;; The command is a lisp function, so we call it.
2235 (funcall gnus-article-x-face-command face))
2237 (error "%s is not a function"
2238 gnus-article-x-face-command)))))))))
2240 (defun article-decode-mime-words ()
2241 "Decode all MIME-encoded words in the article."
2243 (gnus-with-article-buffer
2244 (let ((inhibit-point-motion-hooks t)
2245 (mail-parse-charset gnus-newsgroup-charset)
2246 (mail-parse-ignored-charsets
2247 (with-current-buffer gnus-summary-buffer
2248 gnus-newsgroup-ignored-charsets)))
2249 (mail-decode-encoded-word-region (point-min) (point-max)))))
2251 (defun article-decode-charset (&optional prompt)
2252 "Decode charset-encoded text in the article.
2253 If PROMPT (the prefix), prompt for a coding system to use."
2255 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2256 (inhibit-read-only t)
2257 (mail-parse-charset gnus-newsgroup-charset)
2258 (mail-parse-ignored-charsets
2259 (save-excursion (condition-case nil
2260 (set-buffer gnus-summary-buffer)
2262 gnus-newsgroup-ignored-charsets))
2263 ct cte ctl charset format)
2266 (article-narrow-to-head)
2267 (setq ct (message-fetch-field "Content-Type" t)
2268 cte (message-fetch-field "Content-Transfer-Encoding" t)
2269 ctl (and ct (ignore-errors
2270 (mail-header-parse-content-type ct)))
2273 (mm-read-coding-system "Charset to decode: "))
2275 (mail-content-type-get ctl 'charset)))
2276 format (and ctl (mail-content-type-get ctl 'format)))
2278 (setq cte (mail-header-strip cte)))
2279 (if (and ctl (not (string-match "/" (car ctl))))
2281 (goto-char (point-max)))
2284 (narrow-to-region (point) (point-max))
2285 (when (and (eq mail-parse-charset 'gnus-decoded)
2286 (eq (mm-body-7-or-8) '8bit))
2287 ;; The text code could have been decoded.
2288 (setq charset mail-parse-charset))
2289 (when (and (or (not ctl)
2290 (equal (car ctl) "text/plain"))
2291 (not format)) ;; article with format will decode later.
2293 charset (and cte (intern (downcase
2294 (gnus-strip-whitespace cte))))
2297 (defun article-decode-encoded-words ()
2298 "Remove encoded-word encoding from headers."
2299 (let ((inhibit-point-motion-hooks t)
2300 (mail-parse-charset gnus-newsgroup-charset)
2301 (mail-parse-ignored-charsets
2302 (save-excursion (condition-case nil
2303 (set-buffer gnus-summary-buffer)
2305 gnus-newsgroup-ignored-charsets))
2306 (inhibit-read-only t))
2308 (article-narrow-to-head)
2309 (funcall gnus-decode-header-function (point-min) (point-max)))))
2311 (defun article-decode-group-name ()
2312 "Decode group names in `Newsgroups:'."
2313 (let ((inhibit-point-motion-hooks t)
2314 (inhibit-read-only t)
2315 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2316 (when (and (or gnus-group-name-charset-method-alist
2317 gnus-group-name-charset-group-alist)
2318 (gnus-buffer-live-p gnus-original-article-buffer))
2320 (article-narrow-to-head)
2321 (with-current-buffer gnus-original-article-buffer
2322 (goto-char (point-min)))
2323 (while (re-search-forward
2324 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2325 (replace-match (save-match-data
2326 (gnus-decode-newsgroups
2327 ;; XXX how to use data in article buffer?
2328 (with-current-buffer gnus-original-article-buffer
2330 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2333 gnus-newsgroup-name method))
2335 (goto-char (point-min))
2336 (with-current-buffer gnus-original-article-buffer
2337 (goto-char (point-min)))
2338 (while (re-search-forward
2339 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2340 (replace-match (save-match-data
2341 (gnus-decode-newsgroups
2342 ;; XXX how to use data in article buffer?
2343 (with-current-buffer gnus-original-article-buffer
2345 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2348 gnus-newsgroup-name method))
2351 (autoload 'idna-to-unicode "idna")
2353 (defun article-decode-idna-rhs ()
2354 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2357 (let ((inhibit-point-motion-hooks t)
2358 (inhibit-read-only t))
2359 (article-narrow-to-head)
2360 (goto-char (point-min))
2361 (while (re-search-forward "@.*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2363 (when (save-match-data
2364 (and (setq ace (match-string 1))
2366 (and (re-search-backward "^[^ \t]" nil t)
2367 (looking-at "From\\|To\\|Cc")))
2368 (setq unicode (idna-to-unicode ace))))
2369 (unless (string= ace unicode)
2370 (replace-match unicode nil nil nil 1)))))))))
2372 (defun article-de-quoted-unreadable (&optional force read-charset)
2373 "Translate a quoted-printable-encoded article.
2374 If FORCE, decode the article whether it is marked as quoted-printable
2376 If READ-CHARSET, ask for a coding system."
2377 (interactive (list 'force current-prefix-arg))
2379 (let ((inhibit-read-only t) type charset)
2380 (if (gnus-buffer-live-p gnus-original-article-buffer)
2381 (with-current-buffer gnus-original-article-buffer
2383 (gnus-fetch-field "content-transfer-encoding"))
2384 (let* ((ct (gnus-fetch-field "content-type"))
2387 (mail-header-parse-content-type ct)))))
2388 (setq charset (and ctl
2389 (mail-content-type-get ctl 'charset)))
2390 (if (stringp charset)
2391 (setq charset (intern (downcase charset)))))))
2393 (setq charset (mm-read-coding-system "Charset: " charset)))
2395 (setq charset gnus-newsgroup-charset))
2397 (and type (let ((case-fold-search t))
2398 (string-match "quoted-printable" type))))
2400 (quoted-printable-decode-region
2401 (point) (point-max) (mm-charset-to-coding-system charset))))))
2403 (defun article-de-base64-unreadable (&optional force read-charset)
2404 "Translate a base64 article.
2405 If FORCE, decode the article whether it is marked as base64 not.
2406 If READ-CHARSET, ask for a coding system."
2407 (interactive (list 'force current-prefix-arg))
2409 (let ((inhibit-read-only t) type charset)
2410 (if (gnus-buffer-live-p gnus-original-article-buffer)
2411 (with-current-buffer gnus-original-article-buffer
2413 (gnus-fetch-field "content-transfer-encoding"))
2414 (let* ((ct (gnus-fetch-field "content-type"))
2417 (mail-header-parse-content-type ct)))))
2418 (setq charset (and ctl
2419 (mail-content-type-get ctl 'charset)))
2420 (if (stringp charset)
2421 (setq charset (intern (downcase charset)))))))
2423 (setq charset (mm-read-coding-system "Charset: " charset)))
2425 (setq charset gnus-newsgroup-charset))
2427 (and type (let ((case-fold-search t))
2428 (string-match "base64" type))))
2431 (narrow-to-region (point) (point-max))
2432 (base64-decode-region (point-min) (point-max))
2433 (mm-decode-coding-region
2434 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2439 (defun article-decode-HZ ()
2440 "Translate a HZ-encoded article."
2444 (let ((inhibit-read-only t))
2445 (rfc1843-decode-region (point-min) (point-max)))))
2447 (defun article-unsplit-urls ()
2448 "Remove the newlines that some other mailers insert into URLs."
2451 (let ((inhibit-read-only t))
2452 (goto-char (point-min))
2453 (while (re-search-forward
2454 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2455 (replace-match "\\1\\3" t)))
2456 (when (interactive-p)
2457 (gnus-treat-article nil))))
2460 (defun article-wash-html (&optional read-charset)
2461 "Format an HTML article.
2462 If READ-CHARSET, ask for a coding system."
2465 (let ((inhibit-read-only t)
2467 (when (gnus-buffer-live-p gnus-original-article-buffer)
2468 (with-current-buffer gnus-original-article-buffer
2469 (let* ((ct (gnus-fetch-field "content-type"))
2472 (mail-header-parse-content-type ct)))))
2473 (setq charset (and ctl
2474 (mail-content-type-get ctl 'charset)))
2475 (when (stringp charset)
2476 (setq charset (intern (downcase charset)))))))
2478 (setq charset (mm-read-coding-system "Charset: " charset)))
2480 (setq charset gnus-newsgroup-charset))
2482 (save-window-excursion
2484 (narrow-to-region (point) (point-max))
2485 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2486 (entry (assq func mm-text-html-washer-alist)))
2488 (setq func (cdr entry)))
2493 (apply (car func) (cdr func))))))))))
2495 (defun gnus-article-wash-html-with-w3 ()
2496 "Wash the current buffer with w3."
2498 (let ((w3-strict-width (window-width))
2499 (url-standalone-mode t)
2500 (url-gateway-unplugged t)
2501 (w3-honor-stylesheets nil))
2503 (w3-region (point-min) (point-max))
2506 (defun gnus-article-wash-html-with-w3m ()
2507 "Wash the current buffer with emacs-w3m."
2510 (narrow-to-region (point) (point-max))
2511 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2512 w3m-force-redisplay)
2513 (w3m-region (point-min) (point-max)))
2514 (when (and mm-inline-text-html-with-w3m-keymap
2515 (boundp 'w3m-minor-mode-map)
2517 (add-text-properties
2518 (point-min) (point-max)
2519 (list 'keymap w3m-minor-mode-map
2520 ;; Put the mark meaning this part was rendered by emacs-w3m.
2521 'mm-inline-text-html-with-w3m t)))))
2523 (defun article-hide-list-identifiers ()
2524 "Remove list identifies from the Subject header.
2525 The `gnus-list-identifiers' variable specifies what to do."
2527 (let ((inhibit-point-motion-hooks t)
2528 (regexp (if (consp gnus-list-identifiers)
2529 (mapconcat 'identity gnus-list-identifiers " *\\|")
2530 gnus-list-identifiers))
2531 (inhibit-read-only t))
2535 (article-narrow-to-head)
2536 (goto-char (point-min))
2537 (while (re-search-forward
2538 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2540 (delete-region (match-beginning 2) (match-end 0))
2541 (beginning-of-line))
2542 (when (re-search-forward
2543 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2544 (delete-region (match-beginning 1) (match-end 1))))))))
2546 (defun article-hide-pem (&optional arg)
2547 "Toggle hiding of any PEM headers and signatures in the current article.
2548 If given a negative prefix, always show; if given a positive prefix,
2550 (interactive (gnus-article-hidden-arg))
2551 (unless (gnus-article-check-hidden-text 'pem arg)
2553 (let ((inhibit-read-only t) end)
2554 (goto-char (point-min))
2555 ;; Hide the horrendously ugly "header".
2556 (when (and (search-forward
2557 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2559 (setq end (1+ (match-beginning 0))))
2560 (gnus-add-wash-type 'pem)
2561 (gnus-article-hide-text-type
2563 (if (search-forward "\n\n" nil t)
2567 ;; Hide the trailer as well
2568 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2570 (gnus-article-hide-text-type
2571 (match-beginning 0) (match-end 0) 'pem)))))))
2573 (defun article-strip-banner ()
2574 "Strip the banners specified by the `banner' group parameter and by
2575 `gnus-article-address-banner-alist'."
2579 (let ((inhibit-point-motion-hooks t))
2580 (when (gnus-parameter-banner gnus-newsgroup-name)
2581 (article-really-strip-banner
2582 (gnus-parameter-banner gnus-newsgroup-name)))
2583 (when gnus-article-address-banner-alist
2584 ;; It is necessary to encode from fields before checking,
2585 ;; because `mail-header-parse-addresses' does not work
2586 ;; (reliably) on decoded headers. And more, it is
2587 ;; impossible to use `gnus-fetch-original-field' here,
2588 ;; because `article-strip-banner' may be called in draft
2589 ;; buffers to preview them.
2590 (let ((from (save-restriction
2592 (article-narrow-to-head)
2593 (mail-fetch-field "from"))))
2596 (caar (mail-header-parse-addresses
2597 (mail-encode-encoded-word-string from)))))
2599 (dolist (pair gnus-article-address-banner-alist)
2600 (when (string-match (car pair) from)
2602 (article-really-strip-banner (cdr pair)))))))))))))
2604 (defun article-really-strip-banner (banner)
2605 "Strip the banner specified by the argument."
2608 (let ((inhibit-point-motion-hooks t)
2609 (gnus-signature-limit nil)
2610 (inhibit-read-only t))
2613 ((eq banner 'signature)
2614 (when (gnus-article-narrow-to-signature)
2617 (delete-region (point) (point-max))))
2619 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2620 (while (re-search-forward banner nil t)
2621 (delete-region (match-beginning 0) (match-end 0)))))
2623 (while (re-search-forward banner nil t)
2624 (delete-region (match-beginning 0) (match-end 0)))))))))
2626 (defun article-babel ()
2627 "Translate article using an online translation service."
2630 (gnus-with-article-buffer
2631 (when (article-goto-body)
2632 (let* ((start (point))
2634 (orig (buffer-substring start end))
2635 (trans (babel-as-string orig)))
2637 (narrow-to-region start end)
2638 (delete-region start end)
2641 (defun article-hide-signature (&optional arg)
2642 "Hide the signature in the current article.
2643 If given a negative prefix, always show; if given a positive prefix,
2645 (interactive (gnus-article-hidden-arg))
2646 (unless (gnus-article-check-hidden-text 'signature arg)
2649 (let ((inhibit-read-only t))
2650 (when (gnus-article-narrow-to-signature)
2651 (gnus-article-hide-text-type
2652 (point-min) (point-max) 'signature))))))
2653 (gnus-set-mode-line 'article))
2655 (defun article-strip-headers-in-body ()
2656 "Strip offensive headers from bodies."
2660 (let ((case-fold-search t))
2661 (when (looking-at "x-no-archive:")
2662 (gnus-delete-line)))))
2664 (defun article-strip-leading-blank-lines ()
2665 "Remove all blank lines from the beginning of the article."
2668 (let ((inhibit-point-motion-hooks t)
2669 (inhibit-read-only t))
2670 (when (article-goto-body)
2671 (while (and (not (eobp))
2672 (looking-at "[ \t]*$"))
2673 (gnus-delete-line))))))
2675 (defun article-narrow-to-head ()
2676 "Narrow the buffer to the head of the message.
2677 Point is left at the beginning of the narrowed-to region."
2679 (goto-char (point-min))
2680 (if (search-forward "\n\n" nil 1)
2683 (goto-char (point-min)))
2685 (defun article-goto-body ()
2686 "Place point at the start of the body."
2687 (goto-char (point-min))
2689 ;; This variable is only bound when dealing with separate
2691 (article-goto-body-goes-to-point-min-p
2693 ((search-forward "\n\n" nil t)
2696 (goto-char (point-max))
2699 (defun article-strip-multiple-blank-lines ()
2700 "Replace consecutive blank lines with one empty line."
2703 (let ((inhibit-point-motion-hooks t)
2704 (inhibit-read-only t))
2705 ;; First make all blank lines empty.
2707 (while (re-search-forward "^[ \t]+$" nil t)
2708 (unless (gnus-annotation-in-region-p
2709 (match-beginning 0) (match-end 0))
2710 (replace-match "" nil t)))
2711 ;; Then replace multiple empty lines with a single empty line.
2713 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2714 (unless (gnus-annotation-in-region-p
2715 (match-beginning 0) (match-end 0))
2716 (delete-region (match-beginning 1) (match-end 1)))))))
2718 (defun article-strip-leading-space ()
2719 "Remove all white space from the beginning of the lines in the article."
2722 (let ((inhibit-point-motion-hooks t)
2723 (inhibit-read-only t))
2725 (while (re-search-forward "^[ \t]+" nil t)
2726 (replace-match "" t t)))))
2728 (defun article-strip-trailing-space ()
2729 "Remove all white space from the end of the lines in the article."
2732 (let ((inhibit-point-motion-hooks t)
2733 (inhibit-read-only t))
2735 (while (re-search-forward "[ \t]+$" nil t)
2736 (replace-match "" t t)))))
2738 (defun article-strip-blank-lines ()
2739 "Strip leading, trailing and multiple blank lines."
2741 (article-strip-leading-blank-lines)
2742 (article-remove-trailing-blank-lines)
2743 (article-strip-multiple-blank-lines))
2745 (defun article-strip-all-blank-lines ()
2746 "Strip all blank lines."
2749 (let ((inhibit-point-motion-hooks t)
2750 (inhibit-read-only t))
2752 (while (re-search-forward "^[ \t]*\n" nil t)
2753 (replace-match "" t t)))))
2755 (defun gnus-article-narrow-to-signature ()
2756 "Narrow to the signature; return t if a signature is found, else nil."
2757 (let ((inhibit-point-motion-hooks t))
2758 (when (gnus-article-search-signature)
2760 ;; Check whether we have some limits to what we consider
2761 ;; to be a signature.
2762 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2763 (list gnus-signature-limit)))
2765 (while (setq limit (pop limits))
2766 (if (or (and (integerp limit)
2767 (< (- (point-max) (point)) limit))
2769 (< (count-lines (point) (point-max)) limit))
2770 (and (functionp limit)
2772 (and (stringp limit)
2773 (not (re-search-forward limit nil t))))
2774 () ; This limit did not succeed.
2778 (narrow-to-region (point) (point-max))
2781 (defun gnus-article-search-signature ()
2782 "Search the current buffer for the signature separator.
2783 Put point at the beginning of the signature separator."
2784 (let ((cur (point)))
2785 (goto-char (point-max))
2786 (if (if (stringp gnus-signature-separator)
2787 (re-search-backward gnus-signature-separator nil t)
2788 (let ((seps gnus-signature-separator))
2790 (not (re-search-backward (car seps) nil t)))
2797 (defun gnus-article-hidden-arg ()
2798 "Return the current prefix arg as a number, or 0 if no prefix."
2799 (list (if current-prefix-arg
2800 (prefix-numeric-value current-prefix-arg)
2803 (defun gnus-article-check-hidden-text (type arg)
2804 "Return nil if hiding is necessary.
2805 Arg can be nil or a number. nil and positive means hide, negative
2806 means show, 0 means toggle."
2809 (let ((hide (gnus-article-hidden-text-p type)))
2815 (gnus-article-show-hidden-text type)
2818 (if (eq hide 'hidden)
2820 (gnus-article-show-hidden-text type)
2824 (defun gnus-article-hidden-text-p (type)
2825 "Say whether the current buffer contains hidden text of type TYPE."
2826 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2828 (not (get-text-property pos 'invisible))
2829 (not (get-text-property pos 'dummy-invisible)))
2831 (text-property-any (1+ pos) (point-max) 'article-type type)))
2836 (defun gnus-article-show-hidden-text (type &optional dummy)
2837 "Show all hidden text of type TYPE.
2838 Originally it is hide instead of DUMMY."
2839 (let ((inhibit-read-only t)
2840 (inhibit-point-motion-hooks t))
2841 (gnus-remove-text-properties-when
2843 (point-min) (point-max)
2844 (cons 'article-type (cons type
2845 gnus-hidden-properties)))
2846 (gnus-delete-wash-type type)))
2848 (defconst article-time-units
2849 `((year . ,(* 365.25 24 60 60))
2850 (week . ,(* 7 24 60 60))
2851 (day . ,(* 24 60 60))
2855 "Mapping from time units to seconds.")
2857 (defun gnus-article-forward-header ()
2858 "Move point to the start of the next header.
2859 If the current header is a continuation header, this can be several
2864 (if (looking-at "[ \t]+[^ \t]")
2868 (defun article-date-ut (&optional type highlight)
2869 "Convert DATE date to universal time in the current article.
2870 If TYPE is `local', convert to local time; if it is `lapsed', output
2871 how much time has lapsed since DATE. For `lapsed', the value of
2872 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2873 should replace the \"Date:\" one, or should be added below it."
2874 (interactive (list 'ut t))
2875 (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2876 (date-regexp (cond ((not gnus-article-date-lapsed-new-header)
2880 (article-lapsed-timer
2884 (case-fold-search t)
2885 (inhibit-read-only t)
2886 (inhibit-point-motion-hooks t)
2887 pos date bface eface)
2891 (goto-char (point-min))
2892 (while (or (setq date (get-text-property (setq pos (point))
2894 (when (setq pos (next-single-property-change
2895 (point) 'original-date))
2896 (setq date (get-text-property pos 'original-date))
2898 (narrow-to-region pos (or (text-property-any pos (point-max)
2901 (goto-char (point-min))
2902 (when (re-search-forward tdate-regexp nil t)
2903 (setq bface (get-text-property (point-at-bol) 'face)
2904 eface (get-text-property (1- (point-at-eol)) 'face)))
2905 (goto-char (point-min))
2907 ;; Delete any old Date headers.
2908 (while (re-search-forward date-regexp nil t)
2910 (delete-region (point-at-bol) (progn
2911 (gnus-article-forward-header)
2913 (delete-region (point-at-bol) (progn
2914 (gnus-article-forward-header)
2917 (setq pos (point))))
2918 (when (and (not pos)
2919 (re-search-forward tdate-regexp nil t))
2921 (gnus-goto-char pos)
2922 (insert (article-make-date-line date (or type 'ut)))
2928 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2929 (put-text-property (match-beginning 1) (1+ (match-end 1))
2931 (put-text-property (match-beginning 2) (match-end 2)
2933 (put-text-property (point-min) (1- (point-max)) 'original-date date)
2934 (goto-char (point-max))
2937 (defun article-make-date-line (date type)
2938 "Return a DATE line of TYPE."
2939 (unless (memq type '(local ut original user iso8601 lapsed english))
2940 (error "Unknown conversion type: %s" type))
2942 (let ((time (date-to-time date)))
2944 ;; Convert to the local timezone.
2946 (concat "Date: " (message-make-date time)))
2947 ;; Convert to Universal Time.
2952 (let* ((e (parse-time-string date))
2953 (tm (apply 'encode-time e))
2955 (ls (- (cadr tm) (car (current-time-zone time)))))
2956 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2957 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2961 ;; Get the original date from the article.
2962 ((eq type 'original)
2963 (concat "Date: " (if (string-match "\n+$" date)
2964 (substring date 0 (match-beginning 0))
2966 ;; Let the user define the format.
2968 (let ((format (or (condition-case nil
2969 (with-current-buffer gnus-summary-buffer
2970 gnus-article-time-format)
2972 gnus-article-time-format)))
2973 (if (functionp format)
2974 (funcall format time)
2975 (concat "Date: " (format-time-string format time)))))
2978 (let ((tz (car (current-time-zone time))))
2981 (format-time-string "%Y%m%dT%H%M%S" time)
2982 (format "%s%02d%02d"
2983 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2984 (/ (% (abs tz) 3600) 60)))))
2985 ;; Do an X-Sent lapsed format.
2987 ;; If the date is seriously mangled, the timezone functions are
2988 ;; liable to bug out, so we ignore all errors.
2989 (let* ((now (current-time))
2990 (real-time (subtract-time now time))
2991 (real-sec (and real-time
2992 (+ (* (float (car real-time)) 65536)
2994 (sec (and real-time (abs real-sec)))
3004 ;; This is a bit convoluted, but basically we go
3005 ;; through the time units for years, weeks, etc,
3006 ;; and divide things to see whether that results
3007 ;; in positive answers.
3010 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3011 ;; The (remaining) seconds are too few to
3012 ;; be divided into this time unit.
3014 ;; It's big enough, so we output it.
3015 (setq sec (- sec (* num (cdr unit))))
3017 (concat (if prev ", " "") (int-to-string
3019 " " (symbol-name (car unit))
3020 (if (> num 1) "s" ""))
3022 article-time-units "")
3023 ;; If dates are odd, then it might appear like the
3024 ;; article was sent in the future.
3027 " in the future"))))))
3028 ;; Display the date in proper English
3030 (let ((dtime (decode-time time)))
3033 (number-to-string (nth 3 dtime))
3034 (let ((digit (% (nth 3 dtime) 10)))
3036 ((memq (nth 3 dtime) '(11 12 13)) "th")
3042 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3044 (number-to-string (nth 5 dtime))
3046 (format "%02d" (nth 2 dtime))
3048 (format "%02d" (nth 1 dtime)))))))
3050 (format "Date: %s (from Gnus)" date))))
3052 (defun article-date-local (&optional highlight)
3053 "Convert the current article date to the local timezone."
3054 (interactive (list t))
3055 (article-date-ut 'local highlight))
3057 (defun article-date-english (&optional highlight)
3058 "Convert the current article date to something that is proper English."
3059 (interactive (list t))
3060 (article-date-ut 'english highlight))
3062 (defun article-date-original (&optional highlight)
3063 "Convert the current article date to what it was originally.
3064 This is only useful if you have used some other date conversion
3065 function and want to see what the date was before converting."
3066 (interactive (list t))
3067 (article-date-ut 'original highlight))
3069 (defun article-date-lapsed (&optional highlight)
3070 "Convert the current article date to time lapsed since it was sent."
3071 (interactive (list t))
3072 (article-date-ut 'lapsed highlight))
3074 (defun article-update-date-lapsed ()
3075 "Function to be run from a timer to update the lapsed time line."
3076 (let (deactivate-mark)
3081 (set-buffer (window-buffer w))
3082 (when (eq major-mode 'gnus-article-mode)
3083 (let ((mark (point-marker)))
3084 (goto-char (point-min))
3085 (when (re-search-forward "^X-Sent:" nil t)
3086 (article-date-lapsed t))
3087 (goto-char (marker-position mark))
3088 (move-marker mark nil))))
3091 (defun gnus-start-date-timer (&optional n)
3092 "Start a timer to update the X-Sent header in the article buffers.
3093 The numerical prefix says how frequently (in seconds) the function
3098 (gnus-stop-date-timer)
3099 (setq article-lapsed-timer
3100 (run-at-time 1 n 'article-update-date-lapsed)))
3102 (defun gnus-stop-date-timer ()
3103 "Stop the X-Sent timer."
3105 (when article-lapsed-timer
3106 (nnheader-cancel-timer article-lapsed-timer)
3107 (setq article-lapsed-timer nil)))
3109 (defun article-date-user (&optional highlight)
3110 "Convert the current article date to the user-defined format.
3111 This format is defined by the `gnus-article-time-format' variable."
3112 (interactive (list t))
3113 (article-date-ut 'user highlight))
3115 (defun article-date-iso8601 (&optional highlight)
3116 "Convert the current article date to ISO8601."
3117 (interactive (list t))
3118 (article-date-ut 'iso8601 highlight))
3120 (defmacro gnus-article-save-original-date (&rest forms)
3121 "Save the original date as a text property and evaluate FORMS."
3122 `(let* ((case-fold-search t)
3124 (goto-char (point-min))
3125 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3128 (date (when (and start
3129 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3131 (buffer-substring-no-properties start
3132 (match-beginning 0)))))
3133 (goto-char (point-max))
3134 (skip-chars-backward "\n")
3135 (put-text-property (point-min) (point) 'original-date date)
3137 (goto-char (point-max))
3138 (skip-chars-backward "\n")
3139 (put-text-property (point-min) (point) 'original-date date)))
3141 ;; (defun article-show-all ()
3142 ;; "Show all hidden text in the article buffer."
3145 ;; (let ((inhibit-read-only t))
3146 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3148 (defun article-remove-leading-whitespace ()
3149 "Remove excessive whitespace from all headers."
3153 (let ((inhibit-read-only t))
3154 (article-narrow-to-head)
3155 (goto-char (point-min))
3156 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3157 (delete-region (match-beginning 1) (match-end 1)))))))
3159 (defun article-emphasize (&optional arg)
3160 "Emphasize text according to `gnus-emphasis-alist'."
3161 (interactive (gnus-article-hidden-arg))
3162 (unless (gnus-article-check-hidden-text 'emphasis arg)
3166 (with-current-buffer gnus-summary-buffer
3167 gnus-article-emphasis-alist)
3169 gnus-emphasis-alist))
3170 (inhibit-read-only t)
3171 (props (append '(article-type emphasis)
3172 gnus-hidden-properties))
3173 regexp elem beg invisible visible face)
3176 (while (setq elem (pop alist))
3178 (setq regexp (car elem)
3179 invisible (nth 1 elem)
3180 visible (nth 2 elem)
3182 (while (re-search-forward regexp nil t)
3183 (when (and (match-beginning visible) (match-beginning invisible))
3184 (gnus-article-hide-text
3185 (match-beginning invisible) (match-end invisible) props)
3186 (gnus-article-unhide-text-type
3187 (match-beginning visible) (match-end visible) 'emphasis)
3188 (gnus-put-overlay-excluding-newlines
3189 (match-beginning visible) (match-end visible) 'face face)
3190 (gnus-add-wash-type 'emphasis)
3191 (goto-char (match-end invisible)))))))))
3193 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3194 "Setup newsgroup emphasis alist."
3195 (unless gnus-article-emphasis-alist
3196 (let ((name (and gnus-newsgroup-name
3197 (gnus-group-real-name gnus-newsgroup-name))))
3198 (make-local-variable 'gnus-article-emphasis-alist)
3199 (setq gnus-article-emphasis-alist
3201 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3202 (while (setq elem (pop alist))
3203 (when (and name (string-match (car elem) name))
3205 highlight (copy-sequence (cdr elem)))))
3207 (copy-sequence highlight-words)
3208 (if gnus-newsgroup-name
3209 (copy-sequence (gnus-group-find-parameter
3210 gnus-newsgroup-name 'highlight-words t)))
3211 gnus-emphasis-alist)))))
3214 (defvar gnus-summary-article-menu)
3215 (defvar gnus-summary-post-menu))
3217 ;;; Saving functions.
3219 (defun gnus-article-save (save-buffer file &optional num)
3220 "Save the currently selected article."
3221 (unless gnus-save-all-headers
3222 ;; Remove headers according to `gnus-saved-headers'.
3223 (let ((gnus-visible-headers
3224 (or gnus-saved-headers gnus-visible-headers))
3225 (gnus-article-buffer save-buffer))
3227 (set-buffer save-buffer)
3228 (article-hide-headers 1 t))))
3229 (save-window-excursion
3230 (if (not gnus-default-article-saver)
3231 (error "No default saver is defined")
3232 ;; !!! Magic! The saving functions all save
3233 ;; `gnus-save-article-buffer' (or so they think), but we
3234 ;; bind that variable to our save-buffer.
3235 (set-buffer gnus-article-buffer)
3236 (let* ((gnus-save-article-buffer save-buffer)
3239 ((not gnus-prompt-before-saving) 'default)
3240 ((eq gnus-prompt-before-saving 'always) nil)
3242 (gnus-number-of-articles-to-be-saved
3243 (when (eq gnus-prompt-before-saving t)
3245 (set-buffer gnus-article-current-summary)
3246 (funcall gnus-default-article-saver filename)))))
3248 (defun gnus-read-save-file-name (prompt &optional filename
3249 function group headers variable)
3251 (funcall function group headers (symbol-value variable)))
3256 ((eq filename 'default)
3262 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3265 (if (and gnus-number-of-articles-to-be-saved
3266 (> gnus-number-of-articles-to-be-saved 1))
3267 (format "these %d articles"
3268 gnus-number-of-articles-to-be-saved)
3271 ;; Let the split methods have their say.
3273 ;; No split name was found.
3276 (concat prompt " (default "
3277 (file-name-nondirectory default-name) ") ")
3278 (file-name-directory default-name)
3280 ;; A single group name is returned.
3281 ((stringp split-name)
3283 (funcall function split-name headers
3284 (symbol-value variable)))
3286 (concat prompt " (default "
3287 (file-name-nondirectory default-name) ") ")
3288 (file-name-directory default-name)
3290 ;; A single split name was found
3291 ((= 1 (length split-name))
3292 (let* ((name (expand-file-name
3294 gnus-article-save-directory))
3295 (dir (cond ((file-directory-p name)
3296 (file-name-as-directory name))
3297 ((file-exists-p name) name)
3298 (t gnus-article-save-directory))))
3300 (concat prompt " (default " name ") ")
3302 ;; A list of splits was found.
3304 (setq split-name (nreverse split-name))
3306 (let ((file-name-history
3307 (nconc split-name file-name-history)))
3311 (concat prompt " (`M-p' for defaults) ")
3312 gnus-article-save-directory
3314 gnus-article-save-directory)))
3315 (car (push result file-name-history)))))))
3316 ;; Create the directory.
3317 (gnus-make-directory (file-name-directory file))
3318 ;; If we have read a directory, we append the default file name.
3319 (when (file-directory-p file)
3320 (setq file (expand-file-name (file-name-nondirectory
3322 (file-name-as-directory file))))
3323 ;; Possibly translate some characters.
3324 (nnheader-translate-file-chars file))))))
3325 (gnus-make-directory (file-name-directory result))
3326 (set variable result)))
3328 (defun gnus-article-archive-name (group)
3329 "Return the first instance of an \"Archive-name\" in the current buffer."
3330 (let ((case-fold-search t))
3331 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3332 (nnheader-concat gnus-article-save-directory
3333 (match-string 1)))))
3335 (defun gnus-article-nndoc-name (group)
3336 "If GROUP is an nndoc group, return the name of the parent group."
3337 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3338 (gnus-group-get-parameter group 'save-article-group)))
3340 (defun gnus-summary-save-in-rmail (&optional filename)
3341 "Append this article to Rmail file.
3342 Optional argument FILENAME specifies file name.
3343 Directory to save to is default to `gnus-article-save-directory'."
3344 (setq filename (gnus-read-save-file-name
3345 "Save %s in rmail file:" filename
3346 gnus-rmail-save-name gnus-newsgroup-name
3347 gnus-current-headers 'gnus-newsgroup-last-rmail))
3348 (gnus-eval-in-buffer-window gnus-save-article-buffer
3352 (gnus-output-to-rmail filename))))
3355 (defun gnus-summary-save-in-mail (&optional filename)
3356 "Append this article to Unix mail file.
3357 Optional argument FILENAME specifies file name.
3358 Directory to save to is default to `gnus-article-save-directory'."
3359 (setq filename (gnus-read-save-file-name
3360 "Save %s in Unix mail file:" filename
3361 gnus-mail-save-name gnus-newsgroup-name
3362 gnus-current-headers 'gnus-newsgroup-last-mail))
3363 (gnus-eval-in-buffer-window gnus-save-article-buffer
3367 (if (and (file-readable-p filename)
3368 (file-regular-p filename)
3369 (mail-file-babyl-p filename))
3370 (rmail-output-to-rmail-file filename t)
3371 (gnus-output-to-mail filename)))))
3374 (defun gnus-summary-save-in-file (&optional filename overwrite)
3375 "Append this article to file.
3376 Optional argument FILENAME specifies file name.
3377 Directory to save to is default to `gnus-article-save-directory'."
3378 (setq filename (gnus-read-save-file-name
3379 "Save %s in file:" filename
3380 gnus-file-save-name gnus-newsgroup-name
3381 gnus-current-headers 'gnus-newsgroup-last-file))
3382 (gnus-eval-in-buffer-window gnus-save-article-buffer
3386 (when (and overwrite
3387 (file-exists-p filename))
3388 (delete-file filename))
3389 (gnus-output-to-file filename))))
3392 (defun gnus-summary-write-to-file (&optional filename)
3393 "Write this article to a file, overwriting it if the file exists.
3394 Optional argument FILENAME specifies file name.
3395 The directory to save in defaults to `gnus-article-save-directory'."
3396 (gnus-summary-save-in-file nil t))
3398 (defun gnus-summary-save-body-in-file (&optional filename)
3399 "Append this article body to a file.
3400 Optional argument FILENAME specifies file name.
3401 The directory to save in defaults to `gnus-article-save-directory'."
3402 (setq filename (gnus-read-save-file-name
3403 "Save %s body in file:" filename
3404 gnus-file-save-name gnus-newsgroup-name
3405 gnus-current-headers 'gnus-newsgroup-last-file))
3406 (gnus-eval-in-buffer-window gnus-save-article-buffer
3410 (when (article-goto-body)
3411 (narrow-to-region (point) (point-max)))
3412 (gnus-output-to-file filename))))
3415 (defun gnus-summary-save-in-pipe (&optional command)
3416 "Pipe this article to subprocess."
3418 (cond ((and (eq command 'default)
3419 gnus-last-shell-command)
3420 gnus-last-shell-command)
3425 "Shell command on %s: "
3426 (if (and gnus-number-of-articles-to-be-saved
3427 (> gnus-number-of-articles-to-be-saved 1))
3428 (format "these %d articles"
3429 gnus-number-of-articles-to-be-saved)
3431 gnus-last-shell-command))))
3432 (when (string-equal command "")
3433 (if gnus-last-shell-command
3434 (setq command gnus-last-shell-command)
3435 (error "A command is required")))
3436 (gnus-eval-in-buffer-window gnus-article-buffer
3439 (shell-command-on-region (point-min) (point-max) command nil)))
3440 (setq gnus-last-shell-command command))
3442 (defun gnus-summary-pipe-to-muttprint (&optional command)
3443 "Pipe this article to muttprint."
3444 (setq command (read-string
3445 "Print using command: " gnus-summary-muttprint-program
3446 nil gnus-summary-muttprint-program))
3447 (gnus-summary-save-in-pipe command))
3449 ;;; Article file names when saving.
3451 (defun gnus-capitalize-newsgroup (newsgroup)
3452 "Capitalize NEWSGROUP name."
3453 (when (not (zerop (length newsgroup)))
3454 (concat (char-to-string (upcase (aref newsgroup 0)))
3455 (substring newsgroup 1))))
3457 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3458 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3459 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3460 Otherwise, it is like ~/News/news/group/num."
3463 (concat (if (gnus-use-long-file-name 'not-save)
3464 (gnus-capitalize-newsgroup newsgroup)
3465 (gnus-newsgroup-directory-form newsgroup))
3466 "/" (int-to-string (mail-header-number headers)))
3467 gnus-article-save-directory)))
3469 (string-equal (file-name-directory default)
3470 (file-name-directory last-file))
3471 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3473 (or last-file default))))
3475 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3476 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3477 If variable `gnus-use-long-file-name' is non-nil, it is
3478 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3481 (concat (if (gnus-use-long-file-name 'not-save)
3483 (gnus-newsgroup-directory-form newsgroup))
3484 "/" (int-to-string (mail-header-number headers)))
3485 gnus-article-save-directory)))
3487 (string-equal (file-name-directory default)
3488 (file-name-directory last-file))
3489 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3491 (or last-file default))))
3493 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3494 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3495 If variable `gnus-use-long-file-name' is non-nil, it is
3496 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3499 (if (gnus-use-long-file-name 'not-save)
3502 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3504 gnus-article-save-directory)))
3506 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3507 "Generate file name from sender."
3508 (let ((from (mail-header-from headers)))
3510 (if (and from (string-match "\\([^ <]+\\)@" from))
3511 (match-string 1 from)
3513 gnus-article-save-directory)))
3515 (defun article-verify-x-pgp-sig ()
3518 (if (gnus-buffer-live-p gnus-original-article-buffer)
3519 (let ((sig (with-current-buffer gnus-original-article-buffer
3520 (gnus-fetch-field "X-PGP-Sig")))
3524 (mml2015-clear-verify-function))
3526 (insert-buffer-substring gnus-original-article-buffer)
3527 (setq items (split-string sig))
3528 (message-narrow-to-head)
3529 (let ((inhibit-point-motion-hooks t)
3530 (case-fold-search t))
3531 ;; Don't verify multiple headers.
3532 (setq headers (mapconcat (lambda (header)
3534 (mail-fetch-field header)
3536 (split-string (nth 1 items) ",") "")))
3537 (delete-region (point-min) (point-max))
3538 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3539 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3544 (if (looking-at "^-")
3547 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3548 (insert "Version: " (car items) "\n\n")
3549 (insert (mapconcat 'identity (cddr items) "\n"))
3550 (insert "\n-----END PGP SIGNATURE-----\n")
3551 (let ((mm-security-handle (list (format "multipart/signed"))))
3552 (mml2015-clean-buffer)
3553 (let ((coding-system-for-write (or gnus-newsgroup-charset
3555 (funcall (mml2015-clear-verify-function)))
3557 (or (mm-handle-multipart-ctl-parameter
3558 mm-security-handle 'gnus-details)
3559 (mm-handle-multipart-ctl-parameter
3560 mm-security-handle 'gnus-info)))))
3562 (let ((inhibit-read-only t) bface eface)
3564 (message-narrow-to-head)
3565 (goto-char (point-max))
3567 (setq bface (get-text-property (point-at-bol) 'face)
3568 eface (get-text-property (1- (point-at-eol)) 'face))
3569 (message-remove-header "X-Gnus-PGP-Verify")
3570 (if (re-search-forward "^X-PGP-Sig:" nil t)
3572 (goto-char (point-max)))
3573 (narrow-to-region (point) (point))
3574 (insert "X-Gnus-PGP-Verify: " info "\n")
3575 (goto-char (point-min))
3578 (if (not (looking-at "^[ \t]"))
3582 (goto-char (point-min))
3583 (when (looking-at "\\([^:]+\\): *")
3584 (put-text-property (match-beginning 1) (1+ (match-end 1))
3586 (put-text-property (match-end 0) (point-max)
3587 'face eface)))))))))
3589 (defun article-verify-cancel-lock ()
3590 "Verify Cancel-Lock header."
3592 (if (gnus-buffer-live-p gnus-original-article-buffer)
3593 (canlock-verify gnus-original-article-buffer)))
3600 (setq afunc (car func)
3603 gfunc (intern (format "gnus-%s" func))))
3605 (when (fboundp afunc)
3606 `(lambda (&optional interactive &rest args)
3607 ,(documentation afunc t)
3608 (interactive (list t))
3610 (set-buffer gnus-article-buffer)
3612 (call-interactively ',afunc)
3613 (apply ',afunc args))))))))
3614 '(article-hide-headers
3615 article-verify-x-pgp-sig
3616 article-verify-cancel-lock
3617 article-hide-boring-headers
3618 article-treat-overstrike
3619 article-treat-ansi-sequences
3620 article-fill-long-lines
3621 article-capitalize-sentences
3623 article-remove-leading-whitespace
3624 article-display-x-face
3625 article-display-face
3626 article-de-quoted-unreadable
3627 article-de-base64-unreadable
3630 article-unsplit-urls
3631 article-hide-list-identifiers
3632 article-strip-banner
3635 article-hide-signature
3636 article-strip-headers-in-body
3637 article-remove-trailing-blank-lines
3638 article-strip-leading-blank-lines
3639 article-strip-multiple-blank-lines
3640 article-strip-leading-space
3641 article-strip-trailing-space
3642 article-strip-blank-lines
3643 article-strip-all-blank-lines
3645 article-date-english
3646 article-date-iso8601
3647 article-date-original
3649 article-decode-mime-words
3650 article-decode-charset
3651 article-decode-encoded-words
3655 article-treat-dumbquotes
3656 article-normalize-headers
3657 ;; (article-show-all . gnus-article-show-all-headers)
3661 ;;; Gnus article mode
3664 (put 'gnus-article-mode 'mode-class 'special)
3666 (set-keymap-parent gnus-article-mode-map widget-keymap)
3668 (gnus-define-keys gnus-article-mode-map
3669 " " gnus-article-goto-next-page
3670 "\177" gnus-article-goto-prev-page
3671 [delete] gnus-article-goto-prev-page
3672 [backspace] gnus-article-goto-prev-page
3673 "\C-c^" gnus-article-refer-article
3674 "h" gnus-article-show-summary
3675 "s" gnus-article-show-summary
3676 "\C-c\C-m" gnus-article-mail
3677 "?" gnus-article-describe-briefly
3678 "e" gnus-summary-edit-article
3679 "<" beginning-of-buffer
3681 "\C-c\C-i" gnus-info-find-node
3683 "R" gnus-article-reply-with-original
3684 "F" gnus-article-followup-with-original
3685 "\C-hk" gnus-article-describe-key
3686 "\C-hc" gnus-article-describe-key-briefly
3688 "\C-d" gnus-article-read-summary-keys
3689 "\M-*" gnus-article-read-summary-keys
3690 "\M-#" gnus-article-read-summary-keys
3691 "\M-^" gnus-article-read-summary-keys
3692 "\M-g" gnus-article-read-summary-keys)
3694 (substitute-key-definition
3695 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3697 (defun gnus-article-make-menu-bar ()
3698 (unless (boundp 'gnus-article-commands-menu)
3699 (gnus-summary-make-menu-bar))
3700 (gnus-turn-off-edit-menu 'article)
3701 (unless (boundp 'gnus-article-article-menu)
3703 gnus-article-article-menu gnus-article-mode-map ""
3705 ["Scroll forwards" gnus-article-goto-next-page t]
3706 ["Scroll backwards" gnus-article-goto-prev-page t]
3707 ["Show summary" gnus-article-show-summary t]
3708 ["Fetch Message-ID at point" gnus-article-refer-article t]
3709 ["Mail to address at point" gnus-article-mail t]
3710 ["Send a bug report" gnus-bug t]))
3713 gnus-article-treatment-menu gnus-article-mode-map ""
3714 ;; Fixme: this should use :active (and maybe :visible).
3716 ["Hide headers" gnus-article-hide-headers t]
3717 ["Hide signature" gnus-article-hide-signature t]
3718 ["Hide citation" gnus-article-hide-citation t]
3719 ["Treat overstrike" gnus-article-treat-overstrike t]
3720 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
3721 ["Remove carriage return" gnus-article-remove-cr t]
3722 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3723 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3724 ["Remove base64" gnus-article-de-base64-unreadable t]
3725 ["Treat html" gnus-article-wash-html t]
3726 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3727 ["Decode HZ" gnus-article-decode-HZ t]))
3729 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3731 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3733 (gnus-run-hooks 'gnus-article-menu-hook)))
3735 (defun gnus-article-mode ()
3736 "Major mode for displaying an article.
3738 All normal editing commands are switched off.
3740 The following commands are available in addition to all summary mode
3742 \\<gnus-article-mode-map>
3743 \\[gnus-article-next-page]\t Scroll the article one page forwards
3744 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3745 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3746 \\[gnus-article-show-summary]\t Display the summary buffer
3747 \\[gnus-article-mail]\t Send a reply to the address near point
3748 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3749 \\[gnus-info-find-node]\t Go to the Gnus info node"
3751 (gnus-simplify-mode-line)
3752 (setq mode-name "Article")
3753 (setq major-mode 'gnus-article-mode)
3754 (make-local-variable 'minor-mode-alist)
3755 (use-local-map gnus-article-mode-map)
3756 (when (gnus-visual-p 'article-menu 'menu)
3757 (gnus-article-make-menu-bar)
3758 (when gnus-summary-tool-bar-map
3759 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3760 (gnus-update-format-specifications nil 'article-mode)
3761 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3762 (set (make-local-variable 'gnus-page-broken) nil)
3763 (make-local-variable 'gnus-button-marker-list)
3764 (make-local-variable 'gnus-article-current-summary)
3765 (make-local-variable 'gnus-article-mime-handles)
3766 (make-local-variable 'gnus-article-decoded-p)
3767 (make-local-variable 'gnus-article-mime-handle-alist)
3768 (make-local-variable 'gnus-article-wash-types)
3769 (make-local-variable 'gnus-article-image-alist)
3770 (make-local-variable 'gnus-article-charset)
3771 (make-local-variable 'gnus-article-ignored-charsets)
3772 ;; Prevent recent Emacsen from displaying non-break space as "\ ".
3773 (set (make-local-variable 'show-nonbreak-escape) nil)
3774 (gnus-set-default-directory)
3775 (buffer-disable-undo)
3776 (setq buffer-read-only t
3777 show-trailing-whitespace nil)
3778 (set-syntax-table gnus-article-mode-syntax-table)
3779 (mm-enable-multibyte)
3780 (gnus-run-mode-hooks 'gnus-article-mode-hook))
3782 (defun gnus-article-setup-buffer ()
3783 "Initialize the article buffer."
3784 (let* ((name (if gnus-single-article-buffer "*Article*"
3785 (concat "*Article " gnus-newsgroup-name "*")))
3787 (progn (string-match "\\*Article" name)
3788 (concat " *Original Article"
3789 (substring name (match-end 0))))))
3790 (setq gnus-article-buffer name)
3791 (setq gnus-original-article-buffer original)
3792 (setq gnus-article-mime-handle-alist nil)
3793 ;; This might be a variable local to the summary buffer.
3794 (unless gnus-single-article-buffer
3796 (set-buffer gnus-summary-buffer)
3797 (setq gnus-article-buffer name)
3798 (setq gnus-original-article-buffer original)
3799 (gnus-set-global-variables)))
3800 (gnus-article-setup-highlight-words)
3801 ;; Init original article buffer.
3803 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3804 (mm-enable-multibyte)
3805 (setq major-mode 'gnus-original-article-mode)
3806 (make-local-variable 'gnus-original-article))
3807 (if (and (get-buffer name)
3808 (with-current-buffer name
3809 (if gnus-article-edit-mode
3810 (if (y-or-n-p "Article mode edit in progress; discard? ")
3812 (set-buffer-modified-p nil)
3813 (gnus-kill-buffer name)
3816 (error "Action aborted"))
3820 (set (make-local-variable 'gnus-article-edit-mode) nil)
3821 (when gnus-article-mime-handles
3822 (mm-destroy-parts gnus-article-mime-handles)
3823 (setq gnus-article-mime-handles nil))
3824 ;; Set it to nil in article-buffer!
3825 (setq gnus-article-mime-handle-alist nil)
3826 (buffer-disable-undo)
3827 (setq buffer-read-only t)
3828 ;; This list just keeps growing if we don't reset it.
3829 (setq gnus-button-marker-list nil)
3830 (unless (eq major-mode 'gnus-article-mode)
3831 (gnus-article-mode))
3834 (set-buffer (gnus-get-buffer-create name))
3836 (make-local-variable 'gnus-summary-buffer)
3837 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3838 (current-buffer)))))
3840 ;; Set article window start at LINE, where LINE is the number of lines
3841 ;; from the head of the article.
3842 (defun gnus-article-set-window-start (&optional line)
3844 (gnus-get-buffer-window gnus-article-buffer t)
3846 (set-buffer gnus-article-buffer)
3847 (goto-char (point-min))
3850 (gnus-message 6 "Moved to bookmark")
3851 (search-forward "\n\n" nil t)
3855 (defun gnus-article-prepare (article &optional all-headers header)
3856 "Prepare ARTICLE in article mode buffer.
3857 ARTICLE should either be an article number or a Message-ID.
3858 If ARTICLE is an id, HEADER should be the article headers.
3859 If ALL-HEADERS is non-nil, no headers are hidden."
3861 ;; Make sure we start in a summary buffer.
3862 (unless (eq major-mode 'gnus-summary-mode)
3863 (set-buffer gnus-summary-buffer))
3864 (setq gnus-summary-buffer (current-buffer))
3865 (let* ((gnus-article (if header (mail-header-number header) article))
3866 (summary-buffer (current-buffer))
3867 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3868 (group gnus-newsgroup-name)
3871 (gnus-article-setup-buffer)
3872 (set-buffer gnus-article-buffer)
3873 ;; Deactivate active regions.
3874 (when (and (boundp 'transient-mark-mode)
3875 transient-mark-mode)
3876 (setq mark-active nil))
3877 (if (not (setq result (let ((inhibit-read-only t))
3878 (gnus-request-article-this-buffer
3880 ;; There is no such article.
3882 (when (and (numberp article)
3883 (not (memq article gnus-newsgroup-sparse)))
3884 (setq gnus-article-current
3885 (cons gnus-newsgroup-name article))
3886 (set-buffer gnus-summary-buffer)
3887 (setq gnus-current-article article)
3888 (if (and (memq article gnus-newsgroup-undownloaded)
3889 (not (gnus-online (gnus-find-method-for-group
3890 gnus-newsgroup-name))))
3892 (gnus-summary-set-agent-mark article)
3893 (message "Message marked for downloading"))
3894 (gnus-summary-mark-article article gnus-canceled-mark)
3895 (unless (memq article gnus-newsgroup-sparse)
3896 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3897 (if (or (eq result 'pseudo)
3898 (eq result 'nneething))
3901 (set-buffer summary-buffer)
3902 (push article gnus-newsgroup-history)
3903 (setq gnus-last-article gnus-current-article
3904 gnus-current-article 0
3905 gnus-current-headers nil
3906 gnus-article-current nil)
3907 (if (eq result 'nneething)
3908 (gnus-configure-windows 'summary)
3909 (gnus-configure-windows 'article))
3910 (gnus-set-global-variables))
3911 (let ((gnus-article-mime-handle-alist-1
3912 gnus-article-mime-handle-alist))
3913 (gnus-set-mode-line 'article)))
3914 ;; The result from the `request' was an actual article -
3915 ;; or at least some text that is now displayed in the
3917 (when (and (numberp article)
3918 (not (eq article gnus-current-article)))
3919 ;; Seems like a new article has been selected.
3920 ;; `gnus-current-article' must be an article number.
3922 (set-buffer summary-buffer)
3923 (push article gnus-newsgroup-history)
3924 (setq gnus-last-article gnus-current-article
3925 gnus-current-article article
3926 gnus-current-headers
3927 (gnus-summary-article-header gnus-current-article)
3928 gnus-article-current
3929 (cons gnus-newsgroup-name gnus-current-article))
3930 (unless (vectorp gnus-current-headers)
3931 (setq gnus-current-headers nil))
3932 (gnus-summary-goto-subject gnus-current-article)
3933 (when (gnus-summary-show-thread)
3934 ;; If the summary buffer really was folded, the
3935 ;; previous goto may not actually have gone to
3936 ;; the right article, but the thread root instead.
3938 (gnus-summary-goto-subject gnus-current-article))
3939 (gnus-run-hooks 'gnus-mark-article-hook)
3940 (gnus-set-mode-line 'summary)
3941 (when (gnus-visual-p 'article-highlight 'highlight)
3942 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3943 ;; Set the global newsgroup variables here.
3944 (gnus-set-global-variables)
3945 (setq gnus-have-all-headers
3946 (or all-headers gnus-show-all-headers))))
3948 (gnus-configure-windows 'article))
3949 (when (or (numberp article)
3951 (gnus-article-prepare-display)
3953 (goto-char (point-min))
3954 (when gnus-break-pages
3955 (gnus-narrow-to-page)))
3956 (let ((gnus-article-mime-handle-alist-1
3957 gnus-article-mime-handle-alist))
3958 (gnus-set-mode-line 'article))
3962 (set-window-point (get-buffer-window (current-buffer)) (point))
3963 (gnus-configure-windows 'article)
3967 (defun gnus-article-prepare-display ()
3968 "Make the current buffer look like a nice article."
3969 ;; Hooks for getting information from the article.
3970 ;; This hook must be called before being narrowed.
3971 (let ((gnus-article-buffer (current-buffer))
3973 (inhibit-read-only t))
3974 (unless (eq major-mode 'gnus-article-mode)
3975 (gnus-article-mode))
3976 (setq buffer-read-only nil
3977 gnus-article-wash-types nil
3978 gnus-article-image-alist nil)
3979 (gnus-run-hooks 'gnus-tmp-internal-hook)
3980 (when gnus-display-mime-function
3981 (funcall gnus-display-mime-function))
3982 (gnus-run-hooks 'gnus-article-prepare-hook)))
3985 ;;; Gnus MIME viewing functions
3988 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3989 "Format of the MIME buttons.
3991 Valid specifiers include:
3993 %T MIME type, along with additional info
3994 %n The `name' parameter
3995 %d The description, if any
3996 %l The length of the encoded part
3997 %p The part identifier number
3998 %e Dots if the part isn't displayed
4000 General format specifiers can also be used. See Info node
4001 `(gnus)Formatting Variables'.")
4003 (defvar gnus-mime-button-line-format-alist
4004 '((?t gnus-tmp-type ?s)
4005 (?T gnus-tmp-type-long ?s)
4006 (?n gnus-tmp-name ?s)
4007 (?d gnus-tmp-description ?s)
4009 (?l gnus-tmp-length ?d)
4010 (?e gnus-tmp-dots ?s)))
4012 (defvar gnus-mime-button-commands
4013 '((gnus-article-press-button "\r" "Toggle Display")
4014 (gnus-mime-view-part "v" "View Interactively...")
4015 (gnus-mime-view-part-as-type "t" "View As Type...")
4016 (gnus-mime-view-part-as-charset "C" "View As charset...")
4017 (gnus-mime-save-part "o" "Save...")
4018 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4019 (gnus-mime-delete-part "d" "Delete part")
4020 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4021 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4022 (gnus-mime-view-part-internally "E" "View Internally")
4023 (gnus-mime-view-part-externally "e" "View Externally")
4024 (gnus-mime-print-part "p" "Print")
4025 (gnus-mime-pipe-part "|" "Pipe To Command...")
4026 (gnus-mime-action-on-part "." "Take action on the part...")))
4028 (defun gnus-article-mime-part-status ()
4029 (if gnus-article-mime-handle-alist-1
4030 (if (eq 1 (length gnus-article-mime-handle-alist-1))
4032 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
4035 (defvar gnus-mime-button-map
4036 (let ((map (make-sparse-keymap)))
4037 (define-key map gnus-mouse-2 'gnus-article-push-button)
4038 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4039 (dolist (c gnus-mime-button-commands)
4040 (define-key map (cadr c) (car c)))
4044 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4046 ,@(mapcar (lambda (c)
4047 (vector (caddr c) (car c) :enable t))
4048 gnus-mime-button-commands)))
4050 (defun gnus-mime-button-menu (event prefix)
4051 "Construct a context-sensitive menu of MIME commands."
4052 (interactive "e\nP")
4053 (save-window-excursion
4054 (let ((pos (event-start event)))
4055 (select-window (posn-window pos))
4056 (goto-char (posn-point pos))
4057 (gnus-article-check-buffer)
4058 (popup-menu gnus-mime-button-menu nil prefix))))
4060 (defun gnus-mime-view-all-parts (&optional handles)
4061 "View all the MIME parts."
4063 (with-current-buffer gnus-article-buffer
4064 (let ((handles (or handles gnus-article-mime-handles))
4065 (mail-parse-charset gnus-newsgroup-charset)
4066 (mail-parse-ignored-charsets
4067 (with-current-buffer gnus-summary-buffer
4068 gnus-newsgroup-ignored-charsets)))
4070 (mm-remove-parts handles)
4071 (goto-char (point-min))
4072 (or (search-forward "\n\n") (goto-char (point-max)))
4073 (let ((inhibit-read-only t))
4074 (delete-region (point) (point-max))
4075 (mm-display-parts handles))))))
4078 (defsubst gnus-article-edit-part (handles)
4079 "Edit an article in order to delete a mime part.
4080 This function is exclusively used by `gnus-mime-save-part-and-strip'
4081 and `gnus-mime-delete-part', and not provided at run-time normally."
4082 (gnus-article-edit-article
4084 (buffer-disable-undo)
4086 (let ((mail-parse-charset (or gnus-article-charset
4087 ',gnus-newsgroup-charset))
4088 (mail-parse-ignored-charsets
4089 (or gnus-article-ignored-charsets
4090 ',gnus-newsgroup-ignored-charsets))
4091 (mbl mml-buffer-list))
4092 (setq mml-buffer-list nil)
4093 (insert-buffer gnus-original-article-buffer)
4094 (mime-to-mml ',handles)
4095 (setq gnus-article-mime-handles nil)
4096 (let ((mbl1 mml-buffer-list))
4097 (setq mml-buffer-list mbl)
4098 (set (make-local-variable 'mml-buffer-list) mbl1))
4099 (gnus-make-local-hook 'kill-buffer-hook)
4100 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4101 `(lambda (no-highlight)
4102 (let ((mail-parse-charset (or gnus-article-charset
4103 ',gnus-newsgroup-charset))
4104 (message-options message-options)
4105 (message-options-set-recipient)
4106 (mail-parse-ignored-charsets
4107 (or gnus-article-ignored-charsets
4108 ',gnus-newsgroup-ignored-charsets)))
4110 (mml-destroy-buffers)
4111 (remove-hook 'kill-buffer-hook
4112 'mml-destroy-buffers t)
4113 (kill-local-variable 'mml-buffer-list))
4114 (gnus-summary-edit-article-done
4115 ,(or (mail-header-references gnus-current-headers) "")
4116 ,(gnus-group-read-only-p)
4117 ,gnus-summary-buffer no-highlight)))
4118 (gnus-article-edit-done)
4119 (gnus-summary-expand-window)
4120 (gnus-summary-show-article)))
4122 (defun gnus-mime-save-part-and-strip ()
4123 "Save the MIME part under point then replace it with an external body."
4125 (gnus-article-check-buffer)
4126 (when (gnus-group-read-only-p)
4127 (error "The current group does not support deleting of parts"))
4128 (when (mm-complicated-handles gnus-article-mime-handles)
4130 The current article has a complicated MIME structure, giving up..."))
4131 (when (gnus-yes-or-no-p "\
4132 Deleting parts may malfunction or destroy the article; continue? ")
4133 (let* ((data (get-text-property (point) 'gnus-data))
4135 (handles gnus-article-mime-handles))
4136 (setq file (and data (mm-save-part data)))
4138 (with-current-buffer (mm-handle-buffer data)
4140 (insert "Content-Type: " (mm-handle-media-type data))
4141 (mml-insert-parameter-string (cdr (mm-handle-type data))
4144 (insert "Content-ID: " (message-make-message-id) "\n")
4145 (insert "Content-Transfer-Encoding: binary\n")
4148 (cdr (mm-make-handle nil
4149 `("message/external-body"
4150 (access-type . "LOCAL-FILE")
4152 (set-buffer gnus-summary-buffer)
4153 (gnus-article-edit-part handles)))))
4155 (defun gnus-mime-delete-part ()
4156 "Delete the MIME part under point.
4157 Replace it with some information about the removed part."
4159 (gnus-article-check-buffer)
4160 (when (gnus-group-read-only-p)
4161 (error "The current group does not support deleting of parts"))
4162 (when (mm-complicated-handles gnus-article-mime-handles)
4164 The current article has a complicated MIME structure, giving up..."))
4165 (when (gnus-yes-or-no-p "\
4166 Deleting parts may malfunction or destroy the article; continue? ")
4167 (let* ((data (get-text-property (point) 'gnus-data))
4168 (handles gnus-article-mime-handles)
4172 (mail-decode-encoded-word-string (or (mm-handle-description data)
4175 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4177 (type (mm-handle-media-type data)))
4179 (error "No MIME part under point"))
4180 (with-current-buffer (mm-handle-buffer data)
4181 (let ((bsize (format "%s" (buffer-size))))
4186 "| The following attachment has been deleted:\n"
4188 "| Type: " type "\n"
4189 "| Filename: " filename "\n"
4190 "| Size (encoded): " bsize " Byte\n"
4191 "| Description: " description "\n"
4194 (cdr (mm-make-handle
4195 nil `("text/plain") nil nil
4197 (format "Deleted attachment (%s bytes)" bsize))))))
4198 (set-buffer gnus-summary-buffer)
4199 (gnus-article-edit-part handles))))
4201 (defun gnus-mime-save-part ()
4202 "Save the MIME part under point."
4204 (gnus-article-check-buffer)
4205 (let ((data (get-text-property (point) 'gnus-data)))
4207 (mm-save-part data))))
4209 (defun gnus-mime-pipe-part ()
4210 "Pipe the MIME part under point to a process."
4212 (gnus-article-check-buffer)
4213 (let ((data (get-text-property (point) 'gnus-data)))
4215 (mm-pipe-part data))))
4217 (defun gnus-mime-view-part ()
4218 "Interactively choose a viewing method for the MIME part under point."
4220 (gnus-article-check-buffer)
4221 (let ((data (get-text-property (point) 'gnus-data)))
4223 (setq gnus-article-mime-handles
4225 gnus-article-mime-handles (setq data (copy-sequence data))))
4226 (mm-interactively-view-part data))))
4228 (defun gnus-mime-view-part-as-type-internal ()
4229 (gnus-article-check-buffer)
4230 (let* ((name (mail-content-type-get
4231 (mm-handle-type (get-text-property (point) 'gnus-data))
4233 (def-type (and name (mm-default-file-encoding name))))
4234 (and def-type (cons def-type 0))))
4236 (defun gnus-mime-view-part-as-type (&optional mime-type)
4237 "Choose a MIME media type, and view the part as such."
4240 (setq mime-type (completing-read
4241 "View as MIME type: "
4242 (mapcar #'list (mailcap-mime-types))
4244 (gnus-mime-view-part-as-type-internal))))
4245 (gnus-article-check-buffer)
4246 (let ((handle (get-text-property (point) 'gnus-data)))
4249 (mm-make-handle (mm-handle-buffer handle)
4250 (cons mime-type (cdr (mm-handle-type handle)))
4251 (mm-handle-encoding handle)
4252 (mm-handle-undisplayer handle)
4253 (mm-handle-disposition handle)
4254 (mm-handle-description handle)
4256 (mm-handle-id handle)))
4257 (setq gnus-article-mime-handles
4258 (mm-merge-handles gnus-article-mime-handles handle))
4259 (gnus-mm-display-part handle))))
4261 (defun gnus-mime-copy-part (&optional handle arg)
4262 "Put the MIME part under point into a new buffer.
4263 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4265 (interactive (list nil current-prefix-arg))
4266 (gnus-article-check-buffer)
4268 (setq handle (get-text-property (point) 'gnus-data)))
4270 (let ((filename (or (mail-content-type-get (mm-handle-disposition handle)
4272 (mail-content-type-get (mm-handle-disposition handle)
4274 contents dont-decode charset coding-system)
4275 (mm-with-unibyte-buffer
4276 (mm-insert-part handle)
4277 (setq contents (or (condition-case nil
4278 (mm-decompress-buffer filename nil 'sig)
4280 (setq dont-decode t)
4283 (setq filename (cond (filename (file-name-nondirectory filename))
4284 (dont-decode "*raw data*")
4289 (unless (setq charset (mail-content-type-get
4290 (mm-handle-type handle) 'charset))
4291 (unless (setq coding-system (mm-with-unibyte-buffer
4293 (mm-find-buffer-file-coding-system)))
4294 (setq charset gnus-newsgroup-charset))))
4296 (setq charset (or (cdr (assq arg
4297 gnus-summary-show-article-charset-alist))
4298 (mm-read-coding-system "Charset: ")))))
4299 (switch-to-buffer (generate-new-buffer filename))
4300 (if (or coding-system
4302 (setq coding-system (mm-charset-to-coding-system charset))
4303 (not (eq charset 'ascii))))
4305 (mm-enable-multibyte)
4306 (insert (mm-decode-coding-string contents coding-system))
4307 (setq buffer-file-coding-system
4308 (if (boundp 'last-coding-system-used)
4309 (symbol-value 'last-coding-system-used)
4311 (mm-disable-multibyte)
4313 (setq buffer-file-coding-system mm-binary-coding-system))
4314 ;; We do it this way to make `normal-mode' set the appropriate mode.
4317 (setq buffer-file-name (expand-file-name filename))
4319 (setq buffer-file-name nil))
4320 (goto-char (point-min)))))
4322 (defun gnus-mime-print-part (&optional handle filename)
4323 "Print the MIME part under point."
4324 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4325 (gnus-article-check-buffer)
4326 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4327 (contents (and handle (mm-get-part handle)))
4328 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4329 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4334 (mm-save-part-to-file handle file)
4335 (call-process shell-file-name nil
4336 (generate-new-buffer " *mm*")
4338 shell-command-switch
4340 printer file (mm-handle-type handle))))
4344 (gnus-print-buffer))
4345 (ps-despool filename)))))
4347 (defun gnus-mime-inline-part (&optional handle arg)
4348 "Insert the MIME part under point into the current buffer.
4349 Compressed files like .gz and .bz2 are decompressed."
4350 (interactive (list nil current-prefix-arg))
4351 (gnus-article-check-buffer)
4353 (setq handle (get-text-property (point) 'gnus-data)))
4356 (inhibit-read-only t)
4357 contents charset coding-system)
4358 (if (and (not arg) (mm-handle-undisplayer handle))
4359 (mm-remove-part handle)
4360 (mm-with-unibyte-buffer
4361 (mm-insert-part handle)
4363 (or (mm-decompress-buffer
4364 (or (mail-content-type-get (mm-handle-disposition handle)
4366 (mail-content-type-get (mm-handle-disposition handle)
4372 (unless (setq charset (mail-content-type-get
4373 (mm-handle-type handle) 'charset))
4374 (unless (setq coding-system
4375 (mm-with-unibyte-buffer
4377 (mm-find-buffer-file-coding-system)))
4378 (setq charset gnus-newsgroup-charset))))
4380 (if (mm-handle-undisplayer handle)
4381 (mm-remove-part handle))
4384 gnus-summary-show-article-charset-alist))
4385 (mm-read-coding-system "Charset: "))))
4387 (if (mm-handle-undisplayer handle)
4388 (mm-remove-part handle))))
4392 (if (or coding-system
4395 (mm-charset-to-coding-system charset))
4396 (not (eq charset 'ascii))))
4397 (mm-decode-coding-string contents coding-system)
4398 (mm-string-to-multibyte contents)))
4401 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4402 "Insert the MIME part under point into the current buffer using the
4404 (interactive (list nil current-prefix-arg))
4405 (gnus-article-check-buffer)
4406 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4409 (inhibit-read-only t))
4411 (if (mm-handle-undisplayer handle)
4412 (mm-remove-part handle))
4413 (let ((gnus-newsgroup-charset
4415 gnus-summary-show-article-charset-alist))
4416 (mm-read-coding-system "Charset: ")))
4417 (gnus-newsgroup-ignored-charsets 'gnus-all))
4418 (gnus-article-press-button)))))
4420 (defun gnus-mime-view-part-externally (&optional handle)
4421 "View the MIME part under point with an external viewer."
4423 (gnus-article-check-buffer)
4424 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4425 (mm-user-display-methods nil)
4426 (mm-inlined-types nil)
4427 (mail-parse-charset gnus-newsgroup-charset)
4428 (mail-parse-ignored-charsets
4429 (with-current-buffer gnus-summary-buffer
4430 gnus-newsgroup-ignored-charsets)))
4432 (if (mm-handle-undisplayer handle)
4433 (mm-remove-part handle)
4434 (mm-display-part handle)))))
4436 (defun gnus-mime-view-part-internally (&optional handle)
4437 "View the MIME part under point with an internal viewer.
4438 If no internal viewer is available, use an external viewer."
4440 (gnus-article-check-buffer)
4441 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4442 (mm-inlined-types '(".*"))
4443 (mm-inline-large-images t)
4444 (mail-parse-charset gnus-newsgroup-charset)
4445 (mail-parse-ignored-charsets
4446 (with-current-buffer gnus-summary-buffer
4447 gnus-newsgroup-ignored-charsets))
4448 (inhibit-read-only t))
4450 (if (mm-handle-undisplayer handle)
4451 (mm-remove-part handle)
4452 (mm-display-part handle)))))
4454 (defun gnus-mime-action-on-part (&optional action)
4455 "Do something with the MIME attachment at \(point\)."
4457 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4458 (gnus-article-check-buffer)
4459 (let ((action-pair (assoc action gnus-mime-action-alist)))
4461 (funcall (cdr action-pair)))))
4463 (defun gnus-article-part-wrapper (n function)
4464 (with-current-buffer gnus-article-buffer
4465 (when (> n (length gnus-article-mime-handle-alist))
4466 (error "No such part"))
4467 (gnus-article-goto-part n)
4468 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4469 (funcall function handle))))
4471 (defun gnus-article-pipe-part (n)
4472 "Pipe MIME part N, which is the numerical prefix."
4474 (gnus-article-part-wrapper n 'mm-pipe-part))
4476 (defun gnus-article-save-part (n)
4477 "Save MIME part N, which is the numerical prefix."
4479 (gnus-article-part-wrapper n 'mm-save-part))
4481 (defun gnus-article-interactively-view-part (n)
4482 "View MIME part N interactively, which is the numerical prefix."
4484 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4486 (defun gnus-article-copy-part (n)
4487 "Copy MIME part N, which is the numerical prefix."
4489 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4491 (defun gnus-article-view-part-as-charset (n)
4492 "View MIME part N using a specified charset.
4493 N is the numerical prefix."
4495 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4497 (defun gnus-article-view-part-externally (n)
4498 "View MIME part N externally, which is the numerical prefix."
4500 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4502 (defun gnus-article-inline-part (n)
4503 "Inline MIME part N, which is the numerical prefix."
4505 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4507 (defun gnus-article-mime-match-handle-first (condition)
4510 (dolist (ihandle gnus-article-mime-handle-alist)
4512 ((functionp condition)
4513 (funcall condition (cdr ihandle)))
4514 ((eq condition 'undisplayed)
4515 (not (or (mm-handle-undisplayer (cdr ihandle))
4516 (equal (mm-handle-media-type (cdr ihandle))
4517 "multipart/alternative"))))
4518 ((eq condition 'undisplayed-alternative)
4519 (not (mm-handle-undisplayer (cdr ihandle))))
4521 (gnus-article-goto-part (car ihandle))
4522 (or (not n) (< (car ihandle) n)))
4523 (setq n (car ihandle))))
4527 (defun gnus-article-view-part (&optional n)
4528 "View MIME part N, which is the numerical prefix."
4530 (with-current-buffer gnus-article-buffer
4531 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4532 gnus-article-mime-match-handle-function)))
4533 (when (> n (length gnus-article-mime-handle-alist))
4534 (error "No such part"))
4535 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4536 (when (gnus-article-goto-part n)
4537 (if (equal (car handle) "multipart/alternative")
4538 (gnus-article-press-button)
4539 (when (eq (gnus-mm-display-part handle) 'internal)
4540 (gnus-set-window-start)))))))
4542 (defsubst gnus-article-mime-total-parts ()
4543 (if (bufferp (car gnus-article-mime-handles))
4545 (1- (length gnus-article-mime-handles))))
4547 (defun gnus-mm-display-part (handle)
4548 "Display HANDLE and fix MIME button."
4549 (let ((id (get-text-property (point) 'gnus-part))
4551 (inhibit-read-only t))
4554 (let ((window (selected-window))
4555 (mail-parse-charset gnus-newsgroup-charset)
4556 (mail-parse-ignored-charsets
4557 (if (gnus-buffer-live-p gnus-summary-buffer)
4558 (with-current-buffer gnus-summary-buffer
4559 gnus-newsgroup-ignored-charsets)
4563 (let ((win (gnus-get-buffer-window (current-buffer) t))
4566 (select-window win))
4569 (if (mm-handle-displayed-p handle)
4570 ;; This will remove the part.
4571 (mm-display-part handle)
4573 (narrow-to-region (point)
4574 (if (eobp) (point) (1+ (point))))
4575 (mm-display-part handle)
4576 ;; We narrow to the part itself and
4577 ;; then call the treatment functions.
4578 (goto-char (point-min))
4580 (narrow-to-region (point) (point-max))
4583 (gnus-article-mime-total-parts)
4584 (mm-handle-media-type handle)))))
4585 (if (window-live-p window)
4586 (select-window window)))))
4589 (gnus-insert-mime-button
4590 handle id (list (mm-handle-displayed-p handle)))
4591 (goto-char point))))
4593 (defun gnus-article-goto-part (n)
4594 "Go to MIME part N."
4595 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4597 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4598 (let ((gnus-tmp-name
4599 (or (mail-content-type-get (mm-handle-type handle) 'name)
4600 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4601 (mail-content-type-get (mm-handle-type handle) 'url)
4603 (gnus-tmp-type (mm-handle-media-type handle))
4604 (gnus-tmp-description
4605 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4608 (if (if displayed (car displayed)
4609 (mm-handle-displayed-p handle))
4611 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4613 gnus-tmp-type-long b e)
4614 (when (string-match ".*/" gnus-tmp-name)
4615 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4616 (setq gnus-tmp-type-long (concat gnus-tmp-type
4617 (and (not (equal gnus-tmp-name ""))
4618 (concat "; " gnus-tmp-name))))
4619 (unless (equal gnus-tmp-description "")
4620 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4625 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4626 `(keymap ,gnus-mime-button-map
4627 gnus-callback gnus-mm-display-part
4628 gnus-part ,gnus-tmp-id
4629 article-type annotation
4632 ;; Exclude a newline.
4635 (widget-convert-button
4638 :action 'gnus-widget-press-button
4639 :button-keymap gnus-mime-button-map
4641 (lambda (widget/window &optional overlay pos)
4642 ;; Needed to properly clear the message due to a bug in
4643 ;; wid-edit (XEmacs only).
4644 (if (boundp 'help-echo-owns-message)
4645 (setq help-echo-owns-message t))
4647 "%S: %s the MIME part; %S: more options"
4648 (aref gnus-mouse-2 0)
4649 ;; XEmacs will get a single widget arg; Emacs 21 will get
4650 ;; window, overlay, position.
4651 (if (mm-handle-displayed-p
4653 (with-current-buffer (gnus-overlay-buffer overlay)
4654 (widget-get (widget-at (gnus-overlay-start overlay))
4656 (widget-get widget/window :mime-handle)))
4658 (aref gnus-down-mouse-3 0))))))
4660 (defun gnus-widget-press-button (elems el)
4661 (goto-char (widget-get elems :from))
4662 (gnus-article-press-button))
4664 (defvar gnus-displaying-mime nil)
4666 (defun gnus-display-mime (&optional ihandles)
4667 "Display the MIME parts."
4669 (save-selected-window
4670 (let ((window (get-buffer-window gnus-article-buffer))
4673 (select-window window)
4674 ;; We have to do this since selecting the window
4675 ;; may change the point. So we set the window point.
4676 (set-window-point window point)))
4677 (let ((handles ihandles)
4678 (inhibit-read-only t)
4681 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
4682 (when gnus-article-emulate-mime
4683 (mm-uu-dissect-text-parts handles)))
4684 (gnus-article-emulate-mime
4685 (setq handles (mm-uu-dissect))))
4686 (when (and (not ihandles)
4687 (not gnus-displaying-mime))
4688 ;; Top-level call; we clean up.
4689 (when gnus-article-mime-handles
4690 (mm-destroy-parts gnus-article-mime-handles)
4691 (setq gnus-article-mime-handle-alist nil));; A trick.
4692 (setq gnus-article-mime-handles handles)
4693 ;; We allow users to glean info from the handles.
4694 (when gnus-article-mime-part-function
4695 (gnus-mime-part-function handles)))
4697 (or (not (stringp (car handles)))
4700 (when (and (not ihandles)
4701 (not gnus-displaying-mime))
4702 ;; Clean up for mime parts.
4704 (delete-region (point) (point-max)))
4705 (let ((gnus-displaying-mime t))
4706 (gnus-mime-display-part handles)))
4709 (narrow-to-region (point) (point-max))
4710 (gnus-treat-article nil 1 1)
4713 ;; Highlight the headers.
4717 (narrow-to-region (point-min) (point))
4718 (gnus-article-save-original-date
4719 (gnus-treat-article 'head)))))))))
4721 (defcustom gnus-mime-display-multipart-as-mixed nil
4722 "Display \"multipart\" parts as \"multipart/mixed\".
4724 If t, it overrides nil values of
4725 `gnus-mime-display-multipart-alternative-as-mixed' and
4726 `gnus-mime-display-multipart-related-as-mixed'."
4727 :group 'gnus-article-mime
4730 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4731 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4733 :group 'gnus-article-mime
4736 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4737 "Display \"multipart/related\" parts as \"multipart/mixed\".
4739 If displaying \"text/html\" is discouraged \(see
4740 `mm-discouraged-alternatives'\) images or other material inside a
4741 \"multipart/related\" part might be overlooked when this variable is nil."
4743 :group 'gnus-article-mime
4746 (defun gnus-mime-display-part (handle)
4749 ((not (stringp (car handle)))
4750 (gnus-mime-display-single handle))
4751 ;; User-defined multipart
4752 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4753 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4755 ;; multipart/alternative
4756 ((and (equal (car handle) "multipart/alternative")
4757 (not (or gnus-mime-display-multipart-as-mixed
4758 gnus-mime-display-multipart-alternative-as-mixed)))
4759 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4760 (push (cons id handle) gnus-article-mime-handle-alist)
4761 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4762 ;; multipart/related
4763 ((and (equal (car handle) "multipart/related")
4764 (not (or gnus-mime-display-multipart-as-mixed
4765 gnus-mime-display-multipart-related-as-mixed)))
4766 ;;;!!!We should find the start part, but we just default
4767 ;;;!!!to the first part.
4768 ;;(gnus-mime-display-part (cadr handle))
4769 ;;;!!! Most multipart/related is an HTML message plus images.
4770 ;;;!!! Unfortunately we are unable to let W3 display those
4771 ;;;!!! included images, so we just display it as a mixed multipart.
4772 ;;(gnus-mime-display-mixed (cdr handle))
4773 ;;;!!! No, w3 can display everything just fine.
4774 (gnus-mime-display-part (cadr handle)))
4775 ((equal (car handle) "multipart/signed")
4776 (gnus-add-wash-type 'signed)
4777 (gnus-mime-display-security handle))
4778 ((equal (car handle) "multipart/encrypted")
4779 (gnus-add-wash-type 'encrypted)
4780 (gnus-mime-display-security handle))
4781 ;; Other multiparts are handled like multipart/mixed.
4783 (gnus-mime-display-mixed (cdr handle)))))
4785 (defun gnus-mime-part-function (handles)
4786 (if (stringp (car handles))
4787 (mapcar 'gnus-mime-part-function (cdr handles))
4788 (funcall gnus-article-mime-part-function handles)))
4790 (defun gnus-mime-display-mixed (handles)
4791 (mapcar 'gnus-mime-display-part handles))
4793 (defun gnus-mime-display-single (handle)
4794 (let ((type (mm-handle-media-type handle))
4795 (ignored gnus-ignored-mime-types)
4802 (when (string-match (pop ignored) type)
4803 (throw 'ignored nil)))
4804 (if (and (setq not-attachment
4805 (and (not (mm-inline-override-p handle))
4806 (or (not (mm-handle-disposition handle))
4807 (equal (car (mm-handle-disposition handle))
4809 (mm-attachment-override-p handle))))
4810 (mm-automatic-display-p handle)
4812 (mm-inlinable-p handle)
4813 (mm-inlined-p handle))
4814 (mm-automatic-external-display-p type)))
4816 (when (equal (mm-handle-media-supertype handle) "text")
4818 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4820 (push (cons id handle) gnus-article-mime-handle-alist)
4821 (when (or (not display)
4822 (not (gnus-unbuttonized-mime-type-p type)))
4823 (gnus-insert-mime-button
4824 handle id (list (or display (and not-attachment text))))
4825 (gnus-article-insert-newline)
4826 ;; Remember modify the number of forward lines.
4834 (let ((mail-parse-charset gnus-newsgroup-charset)
4835 (mail-parse-ignored-charsets
4836 (save-excursion (condition-case ()
4837 (set-buffer gnus-summary-buffer)
4839 gnus-newsgroup-ignored-charsets)))
4840 (mm-display-part handle t))
4841 (goto-char (point-max)))
4842 ((and text not-attachment)
4846 (gnus-article-insert-newline)
4847 (mm-display-inline handle)
4848 (goto-char (point-max))))
4852 (narrow-to-region beg (point))
4855 (gnus-article-mime-total-parts)
4856 (mm-handle-media-type handle)))))))))
4858 (defun gnus-unbuttonized-mime-type-p (type)
4859 "Say whether TYPE is to be unbuttonized."
4860 (unless gnus-inhibit-mime-unbuttonizing
4862 (let ((types gnus-unbuttonized-mime-types))
4864 (when (string-match (pop types) type)
4865 (throw 'found t)))))
4867 (let ((types gnus-buttonized-mime-types))
4869 (when (string-match (pop types) type)
4870 (throw 'found t)))))))))
4872 (defun gnus-article-insert-newline ()
4873 "Insert a newline, but mark it as undeletable."
4874 (gnus-put-text-property
4875 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4877 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4878 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4881 handle (inhibit-read-only t) from props begend not-pref)
4882 (save-window-excursion
4885 (narrow-to-region (car ibegend)
4888 (goto-char (car ibegend))
4891 (delete-region (point-min) (point-max))
4892 (mm-remove-parts handles))
4893 (setq begend (list (point-marker)))
4895 (unless (setq not-pref (cadr (member preferred ihandles)))
4896 (setq not-pref (car ihandles)))
4899 (not (gnus-unbuttonized-mime-type-p
4900 "multipart/alternative")))
4901 (gnus-add-text-properties
4904 (insert (format "%d. " id))
4908 (unless ,(not ibegend)
4909 (setq gnus-article-mime-handle-alist
4910 ',gnus-article-mime-handle-alist))
4911 (gnus-mime-display-alternative
4912 ',ihandles ',not-pref ',begend ,id))
4913 keymap ,gnus-mime-button-map
4914 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4915 face ,gnus-article-button-face
4918 (widget-convert-button 'link from (point)
4919 :action 'gnus-widget-press-button
4920 :button-keymap gnus-widget-button-keymap)
4922 (while (setq handle (pop handles))
4923 (gnus-add-text-properties
4926 (insert (format "(%c) %-18s"
4927 (if (equal handle preferred) ?* ? )
4928 (mm-handle-media-type handle)))
4932 (unless ,(not ibegend)
4933 (setq gnus-article-mime-handle-alist
4934 ',gnus-article-mime-handle-alist))
4935 (gnus-mime-display-alternative
4936 ',ihandles ',handle ',begend ,id))
4937 keymap ,gnus-mime-button-map
4938 ,gnus-mouse-face-prop ,gnus-article-mouse-face
4939 face ,gnus-article-button-face
4942 (widget-convert-button 'link from (point)
4943 :action 'gnus-widget-press-button
4944 :button-keymap gnus-widget-button-keymap)
4948 (if (stringp (car preferred))
4949 (gnus-display-mime preferred)
4950 (let ((mail-parse-charset gnus-newsgroup-charset)
4951 (mail-parse-ignored-charsets
4952 (with-current-buffer gnus-summary-buffer
4953 gnus-newsgroup-ignored-charsets)))
4954 (mm-display-part preferred)
4958 (narrow-to-region (car begend) (point-max))
4960 nil (length gnus-article-mime-handle-alist)
4961 (gnus-article-mime-total-parts)
4962 (mm-handle-media-type handle))))))
4963 (goto-char (point-max))
4964 (setcdr begend (point-marker)))))
4966 (goto-char point))))
4968 (defconst gnus-article-wash-status-strings
4969 (let ((alist '((cite "c" "Possible hidden citation text"
4970 " " "All citation text visible")
4971 (headers "h" "Hidden headers"
4972 " " "All headers visible.")
4973 (pgp "p" "Encrypted or signed message status hidden"
4974 " " "No hidden encryption nor digital signature status")
4975 (signature "s" "Signature has been hidden"
4976 " " "Signature is visible")
4977 (overstrike "o" "Overstrike (^H) characters applied"
4978 " " "No overstrike characters applied")
4979 (emphasis "e" "/*_Emphasis_*/ characters applied"
4980 " " "No /*_emphasis_*/ characters applied")))
4982 (dolist (entry alist result)
4983 (let ((key (nth 0 entry))
4984 (on (copy-sequence (nth 1 entry)))
4985 (on-help (nth 2 entry))
4986 (off (copy-sequence (nth 3 entry)))
4987 (off-help (nth 4 entry)))
4988 (put-text-property 0 1 'help-echo on-help on)
4989 (put-text-property 0 1 'help-echo off-help off)
4990 (push (list key on off) result))))
4991 "Alist of strings describing wash status in the mode line.
4992 Each entry has the form (KEY ON OF), where the KEY is a symbol
4993 representing the particular washing function, ON is the string to use
4994 in the article mode line when the washing function is active, and OFF
4995 is the string to use when it is inactive.")
4997 (defun gnus-article-wash-status-entry (key value)
4998 (let ((entry (assoc key gnus-article-wash-status-strings)))
4999 (if value (nth 1 entry) (nth 2 entry))))
5001 (defun gnus-article-wash-status ()
5002 "Return a string which display status of article washing."
5003 (with-current-buffer gnus-article-buffer
5004 (let ((cite (memq 'cite gnus-article-wash-types))
5005 (headers (memq 'headers gnus-article-wash-types))
5006 (boring (memq 'boring-headers gnus-article-wash-types))
5007 (pgp (memq 'pgp gnus-article-wash-types))
5008 (pem (memq 'pem gnus-article-wash-types))
5009 (signed (memq 'signed gnus-article-wash-types))
5010 (encrypted (memq 'encrypted gnus-article-wash-types))
5011 (signature (memq 'signature gnus-article-wash-types))
5012 (overstrike (memq 'overstrike gnus-article-wash-types))
5013 (emphasis (memq 'emphasis gnus-article-wash-types)))
5015 (gnus-article-wash-status-entry 'cite cite)
5016 (gnus-article-wash-status-entry 'headers (or headers boring))
5017 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5018 (gnus-article-wash-status-entry 'signature signature)
5019 (gnus-article-wash-status-entry 'overstrike overstrike)
5020 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5022 (defun gnus-add-wash-type (type)
5023 "Add a washing of TYPE to the current status."
5024 (add-to-list 'gnus-article-wash-types type))
5026 (defun gnus-delete-wash-type (type)
5027 "Add a washing of TYPE to the current status."
5028 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5030 (defun gnus-add-image (category image)
5031 "Add IMAGE of CATEGORY to the list of displayed images."
5032 (let ((entry (assq category gnus-article-image-alist)))
5034 (setq entry (list category))
5035 (push entry gnus-article-image-alist))
5036 (nconc entry (list image))))
5038 (defun gnus-delete-images (category)
5039 "Delete all images in CATEGORY."
5040 (let ((entry (assq category gnus-article-image-alist)))
5041 (dolist (image (cdr entry))
5042 (gnus-remove-image image category))
5043 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5044 (gnus-delete-wash-type category)))
5046 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5048 (defun gnus-article-maybe-hide-headers ()
5049 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5050 Provided for backwards compatibility."
5051 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5052 (not (with-current-buffer gnus-summary-buffer
5053 gnus-have-all-headers)))
5054 (not gnus-inhibit-hiding))
5055 (gnus-article-hide-headers)))
5059 (defun gnus-output-to-file (file-name)
5060 "Append the current article to a file named FILE-NAME."
5061 (let ((artbuf (current-buffer)))
5063 (insert-buffer-substring artbuf)
5064 ;; Append newline at end of the buffer as separator, and then
5066 (goto-char (point-max))
5068 (let ((file-name-coding-system nnmail-pathname-coding-system))
5069 (mm-append-to-file (point-min) (point-max) file-name))
5072 (defun gnus-narrow-to-page (&optional arg)
5073 "Narrow the article buffer to a page.
5074 If given a numerical ARG, move forward ARG pages."
5076 (setq arg (if arg (prefix-numeric-value arg) 0))
5078 (set-buffer gnus-article-buffer)
5079 (goto-char (point-min))
5081 ;; Remove any old next/prev buttons.
5082 (when (gnus-visual-p 'page-marker)
5083 (let ((inhibit-read-only t))
5084 (gnus-remove-text-with-property 'gnus-prev)
5085 (gnus-remove-text-with-property 'gnus-next)))
5088 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5090 (re-search-forward page-delimiter nil 'move arg)))
5091 (goto-char (match-end 0))
5093 (goto-char (point-min))
5094 (setq gnus-page-broken
5095 (and (re-search-forward page-delimiter nil t) t))))
5096 (when gnus-page-broken
5099 (if (re-search-forward page-delimiter nil 'move)
5102 (when (and (gnus-visual-p 'page-marker)
5103 (> (point-min) (save-restriction (widen) (point-min))))
5105 (goto-char (point-min))
5106 (gnus-insert-prev-page-button)))
5107 (when (and (gnus-visual-p 'page-marker)
5108 (< (point-max) (save-restriction (widen) (point-max))))
5110 (goto-char (point-max))
5111 (gnus-insert-next-page-button))))))
5113 ;; Article mode commands
5115 (defun gnus-article-goto-next-page ()
5116 "Show the next page of the article."
5118 (when (gnus-article-next-page)
5119 (goto-char (point-min))
5120 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5123 (defun gnus-article-goto-prev-page ()
5124 "Show the previous page of the article."
5127 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5128 (gnus-article-prev-page nil)))
5130 ;; This is cleaner but currently breaks `gnus-pick-mode':
5132 ;; (defun gnus-article-goto-next-page ()
5133 ;; "Show the next page of the article."
5135 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5136 ;; (gnus-summary-next-page)))
5138 ;; (defun gnus-article-goto-prev-page ()
5139 ;; "Show the next page of the article."
5141 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5142 ;; (gnus-summary-prev-page)))
5144 (defun gnus-article-next-page (&optional lines)
5145 "Show the next page of the current article.
5146 If end of article, return non-nil. Otherwise return nil.
5147 Argument LINES specifies lines to be scrolled up."
5149 (move-to-window-line -1)
5152 (and (pos-visible-in-window-p) ;Not continuation line.
5153 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5154 ;; Nothing in this page.
5155 (if (or (not gnus-page-broken)
5160 (eobp)))) ;Real end-of-buffer?
5162 (when gnus-article-over-scroll
5163 (gnus-article-next-page-1 lines))
5165 (gnus-narrow-to-page 1) ;Go to next page.
5167 ;; More in this page.
5168 (gnus-article-next-page-1 lines)
5171 (defun gnus-article-next-page-1 (lines)
5172 (let ((scroll-in-place nil))
5176 ;; Long lines may cause an end-of-buffer error.
5177 (goto-char (point-max)))))
5178 (move-to-window-line 0))
5180 (defun gnus-article-prev-page (&optional lines)
5181 "Show previous page of current article.
5182 Argument LINES specifies lines to be scrolled down."
5184 (move-to-window-line 0)
5185 (if (and gnus-page-broken
5187 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5189 (gnus-narrow-to-page -1) ;Go to previous page.
5190 (goto-char (point-max))
5192 (let ((scroll-in-place nil))
5196 (beginning-of-buffer
5197 (goto-char (point-min))))
5198 (move-to-window-line 0)))))
5200 (defun gnus-article-only-boring-p ()
5201 "Decide whether there is only boring text remaining in the article.
5202 Something \"interesting\" is a word of at least two letters that does
5203 not have a face in `gnus-article-boring-faces'."
5204 (when (and gnus-article-skip-boring
5205 (boundp 'gnus-article-boring-faces)
5206 (symbol-value 'gnus-article-boring-faces))
5209 (while (re-search-forward "\\b\\w\\w" nil t)
5211 (when (not (gnus-intersection
5212 (gnus-faces-at (point))
5213 (symbol-value 'gnus-article-boring-faces)))
5214 (throw 'only-boring nil)))
5215 (throw 'only-boring t)))))
5217 (defun gnus-article-refer-article ()
5218 "Read article specified by message-id around point."
5221 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5222 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5223 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5224 (let ((msg-id (concat "<" (match-string 0) ">")))
5225 (set-buffer gnus-summary-buffer)
5226 (gnus-summary-refer-article msg-id))
5227 (error "No references around point"))))
5229 (defun gnus-article-show-summary ()
5230 "Reconfigure windows to show summary buffer."
5232 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5233 (error "There is no summary buffer for this article buffer")
5234 (gnus-article-set-globals)
5235 (gnus-configure-windows 'article)
5236 (gnus-summary-goto-subject gnus-current-article)
5237 (gnus-summary-position-point)))
5239 (defun gnus-article-describe-briefly ()
5240 "Describe article mode commands briefly."
5242 (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")))
5244 (defun gnus-article-summary-command ()
5245 "Execute the last keystroke in the summary buffer."
5247 (let ((obuf (current-buffer))
5248 (owin (current-window-configuration))
5250 (switch-to-buffer gnus-article-current-summary 'norecord)
5251 (setq func (lookup-key (current-local-map) (this-command-keys)))
5252 (call-interactively func)
5254 (set-window-configuration owin)
5255 (set-window-point (get-buffer-window (current-buffer)) (point))))
5257 (defun gnus-article-summary-command-nosave ()
5258 "Execute the last keystroke in the summary buffer."
5261 (pop-to-buffer gnus-article-current-summary 'norecord)
5262 (setq func (lookup-key (current-local-map) (this-command-keys)))
5263 (call-interactively func)))
5265 (defun gnus-article-check-buffer ()
5266 "Beep if not in an article buffer."
5267 (unless (equal major-mode 'gnus-article-mode)
5268 (error "Command invoked outside of a Gnus article buffer")))
5270 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5271 "Read a summary buffer key sequence and execute it from the article buffer."
5273 (gnus-article-check-buffer)
5275 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5276 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5277 "=" "^" "\M-^" "|"))
5283 '("n" "Gn" "p" "Gp"))
5286 (set-buffer gnus-article-current-summary)
5287 (let (gnus-pick-mode)
5288 (push (or key last-command-event) unread-command-events)
5289 (setq keys (if (featurep 'xemacs)
5290 (events-to-keys (read-key-sequence nil))
5291 (read-key-sequence nil)))))
5295 (if (or (member keys nosaves)
5296 (member keys nosave-but-article)
5297 (member keys nosave-in-article))
5299 (save-window-excursion
5300 (pop-to-buffer gnus-article-current-summary 'norecord)
5301 ;; We disable the pick minor mode commands.
5302 (let (gnus-pick-mode)
5303 (setq func (lookup-key (current-local-map) keys))))
5307 (unless (member keys nosave-in-article)
5308 (set-buffer gnus-article-current-summary))
5309 (call-interactively func)
5310 (setq new-sum-point (point)))
5311 (when (member keys nosave-but-article)
5312 (pop-to-buffer gnus-article-buffer 'norecord)))
5313 ;; These commands should restore window configuration.
5314 (let ((obuf (current-buffer))
5315 (owin (current-window-configuration))
5317 win func in-buffer selected new-sum-start new-sum-hscroll)
5318 (cond (not-restore-window
5319 (pop-to-buffer gnus-article-current-summary 'norecord))
5320 ((setq win (get-buffer-window gnus-article-current-summary))
5321 (select-window win))
5323 (switch-to-buffer gnus-article-current-summary 'norecord)))
5324 (setq in-buffer (current-buffer))
5325 ;; We disable the pick minor mode commands.
5326 (if (and (setq func (let (gnus-pick-mode)
5327 (lookup-key (current-local-map) keys)))
5330 (call-interactively func)
5331 (when (eq win (selected-window))
5332 (setq new-sum-point (point)
5333 new-sum-start (window-start win)
5334 new-sum-hscroll (window-hscroll win)))
5335 (when (eq in-buffer (current-buffer))
5336 (setq selected (gnus-summary-select-article))
5338 (unless not-restore-window
5339 (set-window-configuration owin))
5340 (when (eq selected 'old)
5342 (set-window-start (get-buffer-window (current-buffer))
5344 (set-window-point (get-buffer-window (current-buffer))
5346 (when (and (not not-restore-window)
5348 (set-window-point win new-sum-point)
5349 (set-window-start win new-sum-start)
5350 (set-window-hscroll win new-sum-hscroll))))
5351 (set-window-configuration owin)
5354 (defun gnus-article-describe-key (key)
5355 "Display documentation of the function invoked by KEY. KEY is a string."
5356 (interactive "kDescribe key: ")
5357 (gnus-article-check-buffer)
5358 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5360 (set-buffer gnus-article-current-summary)
5361 (let (gnus-pick-mode)
5362 (if (featurep 'xemacs)
5364 (push (elt key 0) unread-command-events)
5365 (setq key (events-to-keys
5366 (read-key-sequence "Describe key: "))))
5367 (setq unread-command-events
5369 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5370 (string-to-list key)))
5371 (setq key (read-key-sequence "Describe key: "))))
5373 (describe-key key)))
5375 (defun gnus-article-describe-key-briefly (key &optional insert)
5376 "Display documentation of the function invoked by KEY. KEY is a string."
5377 (interactive "kDescribe key: \nP")
5378 (gnus-article-check-buffer)
5379 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5381 (set-buffer gnus-article-current-summary)
5382 (let (gnus-pick-mode)
5383 (if (featurep 'xemacs)
5385 (push (elt key 0) unread-command-events)
5386 (setq key (events-to-keys
5387 (read-key-sequence "Describe key: "))))
5388 (setq unread-command-events
5390 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5391 (string-to-list key)))
5392 (setq key (read-key-sequence "Describe key: "))))
5393 (describe-key-briefly key insert))
5394 (describe-key-briefly key insert)))
5396 (defun gnus-article-reply-with-original (&optional wide)
5397 "Start composing a reply mail to the current message.
5398 The text in the region will be yanked. If the region isn't active,
5399 the entire article will be yanked."
5401 (let ((article (cdr gnus-article-current))
5403 (if (not (gnus-region-active-p))
5404 (with-current-buffer gnus-summary-buffer
5405 (gnus-summary-reply (list (list article)) wide))
5406 (setq contents (buffer-substring (point) (mark t)))
5407 ;; Deactivate active regions.
5408 (when (and (boundp 'transient-mark-mode)
5409 transient-mark-mode)
5410 (setq mark-active nil))
5411 (with-current-buffer gnus-summary-buffer
5413 (list (list article contents)) wide)))))
5415 (defun gnus-article-followup-with-original ()
5416 "Compose a followup to the current article.
5417 The text in the region will be yanked. If the region isn't active,
5418 the entire article will be yanked."
5420 (let ((article (cdr gnus-article-current))
5422 (if (not (gnus-region-active-p))
5423 (with-current-buffer gnus-summary-buffer
5424 (gnus-summary-followup (list (list article))))
5425 (setq contents (buffer-substring (point) (mark t)))
5426 ;; Deactivate active regions.
5427 (when (and (boundp 'transient-mark-mode)
5428 transient-mark-mode)
5429 (setq mark-active nil))
5430 (with-current-buffer gnus-summary-buffer
5431 (gnus-summary-followup
5432 (list (list article contents)))))))
5434 (defun gnus-article-hide (&optional arg force)
5435 "Hide all the gruft in the current article.
5436 This means that signatures, cited text and (some) headers will be
5438 If given a prefix, show the hidden text instead."
5439 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5440 (gnus-article-hide-headers arg)
5441 (gnus-article-hide-list-identifiers arg)
5442 (gnus-article-hide-citation-maybe arg force)
5443 (gnus-article-hide-signature arg))
5445 (defun gnus-article-maybe-highlight ()
5446 "Do some article highlighting if article highlighting is requested."
5447 (when (gnus-visual-p 'article-highlight 'highlight)
5448 (gnus-article-highlight-some)))
5450 (defun gnus-check-group-server ()
5451 ;; Make sure the connection to the server is alive.
5452 (unless (gnus-server-opened
5453 (gnus-find-method-for-group gnus-newsgroup-name))
5454 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5455 (gnus-request-group gnus-newsgroup-name t)))
5458 (autoload 'nneething-get-file-name "nneething"))
5460 (defun gnus-request-article-this-buffer (article group)
5461 "Get an article and insert it into this buffer."
5462 (let (do-update-line sparse-header)
5466 (gnus-kill-all-overlays)
5467 (setq group (or group gnus-newsgroup-name))
5469 ;; Using `gnus-request-article' directly will insert the article into
5470 ;; `nntp-server-buffer' - so we'll save some time by not having to
5471 ;; copy it from the server buffer into the article buffer.
5473 ;; We only request an article by message-id when we do not have the
5474 ;; headers for it, so we'll have to get those.
5475 (when (stringp article)
5476 (gnus-read-header article))
5478 ;; If the article number is negative, that means that this article
5479 ;; doesn't belong in this newsgroup (possibly), so we find its
5480 ;; message-id and request it by id instead of number.
5481 (when (and (numberp article)
5483 (get-buffer gnus-summary-buffer)
5484 (gnus-buffer-exists-p gnus-summary-buffer))
5486 (set-buffer gnus-summary-buffer)
5487 (let ((header (gnus-summary-article-header article)))
5490 ((memq article gnus-newsgroup-sparse)
5491 ;; This is a sparse gap article.
5492 (setq do-update-line article)
5493 (setq article (mail-header-id header))
5494 (setq sparse-header (gnus-read-header article))
5495 (setq gnus-newsgroup-sparse
5496 (delq article gnus-newsgroup-sparse)))
5498 ;; It's a real article.
5499 (setq article (mail-header-id header)))
5501 ;; It is an extracted pseudo-article.
5502 (setq article 'pseudo)
5503 (gnus-request-pseudo-article header))))
5505 (let ((method (gnus-find-method-for-group
5506 gnus-newsgroup-name)))
5507 (when (and (eq (car method) 'nneething)
5509 (let ((dir (nneething-get-file-name
5510 (mail-header-id header))))
5511 (when (and (stringp dir)
5512 (file-directory-p dir))
5513 (setq article 'nneething)
5514 (gnus-group-enter-directory dir))))))))
5517 ;; Refuse to select canceled articles.
5518 ((and (numberp article)
5520 (get-buffer gnus-summary-buffer)
5521 (gnus-buffer-exists-p gnus-summary-buffer)
5522 (eq (cdr (with-current-buffer gnus-summary-buffer
5523 (assq article gnus-newsgroup-reads)))
5524 gnus-canceled-mark))
5526 ;; We first check `gnus-original-article-buffer'.
5527 ((and (get-buffer gnus-original-article-buffer)
5529 (with-current-buffer gnus-original-article-buffer
5530 (and (equal (car gnus-original-article) group)
5531 (eq (cdr gnus-original-article) article))))
5532 (insert-buffer-substring gnus-original-article-buffer)
5534 ;; Check the backlog.
5535 ((and gnus-keep-backlog
5536 (gnus-backlog-request-article group article (current-buffer)))
5538 ;; Check asynchronous pre-fetch.
5539 ((gnus-async-request-fetched-article group article (current-buffer))
5540 (gnus-async-prefetch-next group article gnus-summary-buffer)
5541 (when (and (numberp article) gnus-keep-backlog)
5542 (gnus-backlog-enter-article group article (current-buffer)))
5545 ((and gnus-use-cache
5547 (gnus-cache-request-article article group))
5549 ;; Check the agent cache.
5550 ((gnus-agent-request-article article group)
5552 ;; Get the article and put into the article buffer.
5553 ((or (stringp article)
5555 (let ((gnus-override-method gnus-override-method)
5556 (methods (and (stringp article)
5557 gnus-refer-article-method))
5558 (backend (car (gnus-find-method-for-group
5559 gnus-newsgroup-name)))
5561 (inhibit-read-only t))
5562 (if (or (not (listp methods))
5563 (and (symbolp (car methods))
5564 (assq (car methods) nnoo-definition-alist)))
5565 (setq methods (list methods)))
5566 (when (and (null gnus-override-method)
5568 (setq gnus-override-method (pop methods)))
5570 (when (eq gnus-override-method 'current)
5571 (setq gnus-override-method
5572 (with-current-buffer gnus-summary-buffer
5573 gnus-current-select-method)))
5575 (gnus-kill-all-overlays)
5576 (let ((gnus-newsgroup-name group))
5577 (gnus-check-group-server))
5579 ((gnus-request-article article group (current-buffer))
5580 (when (numberp article)
5581 (gnus-async-prefetch-next group article
5582 gnus-summary-buffer)
5583 (when gnus-keep-backlog
5584 (gnus-backlog-enter-article
5585 group article (current-buffer))))
5586 (setq result 'article))
5588 (setq gnus-override-method (pop methods)))
5589 ((not (string-match "^400 "
5590 (nnheader-get-report backend)))
5591 ;; If we get 400 server disconnect, reconnect and
5592 ;; retry; otherwise, assume the article has expired.
5593 (setq result 'done))))
5594 (and (eq result 'article) 'article)))
5598 ;; Associate this article with the current summary buffer.
5599 (setq gnus-article-current-summary gnus-summary-buffer)
5601 ;; Take the article from the original article buffer
5602 ;; and place it in the buffer it's supposed to be in.
5603 (when (and (get-buffer gnus-article-buffer)
5604 (equal (buffer-name (current-buffer))
5605 (buffer-name (get-buffer gnus-article-buffer))))
5607 (if (get-buffer gnus-original-article-buffer)
5608 (set-buffer gnus-original-article-buffer)
5609 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5610 (buffer-disable-undo)
5611 (setq major-mode 'gnus-original-article-mode)
5612 (setq buffer-read-only t))
5613 (let ((inhibit-read-only t))
5615 (insert-buffer-substring gnus-article-buffer))
5616 (setq gnus-original-article (cons group article)))
5619 (run-hooks 'gnus-article-decode-hook)
5620 ;; Mark article as decoded or not.
5621 (setq gnus-article-decoded-p gnus-article-decode-hook))
5623 ;; Update sparse articles.
5624 (when (and do-update-line
5625 (or (numberp article)
5627 (let ((buf (current-buffer)))
5628 (set-buffer gnus-summary-buffer)
5629 (gnus-summary-update-article do-update-line sparse-header)
5630 (gnus-summary-goto-subject do-update-line nil t)
5631 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5633 (set-buffer buf))))))
5639 (defcustom gnus-article-edit-mode-hook nil
5640 "Hook run in article edit mode buffers."
5641 :group 'gnus-article-various
5644 (defvar gnus-article-edit-done-function nil)
5646 (defvar gnus-article-edit-mode-map nil)
5648 ;; Should we be using derived.el for this?
5649 (unless gnus-article-edit-mode-map
5650 (setq gnus-article-edit-mode-map (make-keymap))
5651 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5653 (gnus-define-keys gnus-article-edit-mode-map
5654 "\C-c?" describe-mode
5655 "\C-c\C-c" gnus-article-edit-done
5656 "\C-c\C-k" gnus-article-edit-exit
5657 "\C-c\C-f\C-t" message-goto-to
5658 "\C-c\C-f\C-o" message-goto-from
5659 "\C-c\C-f\C-b" message-goto-bcc
5660 ;;"\C-c\C-f\C-w" message-goto-fcc
5661 "\C-c\C-f\C-c" message-goto-cc
5662 "\C-c\C-f\C-s" message-goto-subject
5663 "\C-c\C-f\C-r" message-goto-reply-to
5664 "\C-c\C-f\C-n" message-goto-newsgroups
5665 "\C-c\C-f\C-d" message-goto-distribution
5666 "\C-c\C-f\C-f" message-goto-followup-to
5667 "\C-c\C-f\C-m" message-goto-mail-followup-to
5668 "\C-c\C-f\C-k" message-goto-keywords
5669 "\C-c\C-f\C-u" message-goto-summary
5670 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5671 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5672 "\C-c\C-b" message-goto-body
5673 "\C-c\C-i" message-goto-signature
5675 "\C-c\C-t" message-insert-to
5676 "\C-c\C-n" message-insert-newsgroups
5677 "\C-c\C-o" message-sort-headers
5678 "\C-c\C-e" message-elide-region
5679 "\C-c\C-v" message-delete-not-region
5680 "\C-c\C-z" message-kill-to-signature
5681 "\M-\r" message-newline-and-reformat
5682 "\C-c\C-a" mml-attach-file
5683 "\C-a" message-beginning-of-line
5685 "\M-;" comment-region)
5687 (gnus-define-keys (gnus-article-edit-wash-map
5688 "\C-c\C-w" gnus-article-edit-mode-map)
5689 "f" gnus-article-edit-full-stops))
5692 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5694 ["Fetch To" message-insert-to t]
5695 ["Fetch Newsgroups" message-insert-newsgroups t]
5697 ["To" message-goto-to t]
5698 ["From" message-goto-from t]
5699 ["Subject" message-goto-subject t]
5700 ["Cc" message-goto-cc t]
5701 ["Reply-To" message-goto-reply-to t]
5702 ["Summary" message-goto-summary t]
5703 ["Keywords" message-goto-keywords t]
5704 ["Newsgroups" message-goto-newsgroups t]
5705 ["Followup-To" message-goto-followup-to t]
5706 ["Mail-Followup-To" message-goto-mail-followup-to t]
5707 ["Distribution" message-goto-distribution t]
5708 ["Body" message-goto-body t]
5709 ["Signature" message-goto-signature t]))
5711 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
5712 "Major mode for editing articles.
5713 This is an extended text-mode.
5715 \\{gnus-article-edit-mode-map}"
5716 (make-local-variable 'gnus-article-edit-done-function)
5717 (make-local-variable 'gnus-prev-winconf)
5718 (set (make-local-variable 'font-lock-defaults)
5719 '(message-font-lock-keywords t))
5720 (set (make-local-variable 'mail-header-separator) "")
5721 (set (make-local-variable 'gnus-article-edit-mode) t)
5722 (easy-menu-add message-mode-field-menu message-mode-map)
5724 (setq buffer-read-only nil)
5725 (buffer-enable-undo)
5728 (defun gnus-article-edit (&optional force)
5729 "Edit the current article.
5730 This will have permanent effect only in mail groups.
5731 If FORCE is non-nil, allow editing of articles even in read-only
5734 (when (and (not force)
5735 (gnus-group-read-only-p))
5736 (error "The current newsgroup does not support article editing"))
5737 (gnus-article-date-original)
5738 (gnus-article-edit-article
5740 `(lambda (no-highlight)
5742 (gnus-summary-edit-article-done
5743 ,(or (mail-header-references gnus-current-headers) "")
5744 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5746 (defun gnus-article-edit-article (start-func exit-func)
5747 "Start editing the contents of the current article buffer."
5748 (let ((winconf (current-window-configuration)))
5749 (set-buffer gnus-article-buffer)
5750 (let ((message-auto-save-directory
5751 ;; Don't associate the article buffer with a draft file.
5753 (gnus-article-edit-mode))
5754 (funcall start-func)
5755 (set-buffer-modified-p nil)
5756 (gnus-configure-windows 'edit-article)
5757 (setq gnus-article-edit-done-function exit-func)
5758 (setq gnus-prev-winconf winconf)
5759 (gnus-message 6 "C-c C-c to end edits")))
5761 (defun gnus-article-edit-done (&optional arg)
5762 "Update the article edits and exit."
5764 (let ((func gnus-article-edit-done-function)
5765 (buf (current-buffer))
5766 (start (window-start))
5768 (winconf gnus-prev-winconf))
5769 (widen) ;; Widen it in case that users narrowed the buffer.
5772 ;; The cache and backlog have to be flushed somewhat.
5773 (when gnus-keep-backlog
5774 (gnus-backlog-remove-article
5775 (car gnus-article-current) (cdr gnus-article-current)))
5776 ;; Flush original article as well.
5778 (when (get-buffer gnus-original-article-buffer)
5779 (set-buffer gnus-original-article-buffer)
5780 (setq gnus-original-article nil)))
5781 (when gnus-use-cache
5782 (gnus-cache-update-article
5783 (car gnus-article-current) (cdr gnus-article-current)))
5784 ;; We remove all text props from the article buffer.
5785 (kill-all-local-variables)
5786 (set-text-properties (point-min) (point-max) nil)
5788 (set-window-configuration winconf)
5790 (set-window-start (get-buffer-window buf) start)
5791 (set-window-point (get-buffer-window buf) (point)))
5792 (gnus-summary-show-article))
5794 (defun gnus-article-edit-exit ()
5795 "Exit the article editing without updating."
5797 (when (or (not (buffer-modified-p))
5798 (yes-or-no-p "Article modified; kill anyway? "))
5799 (let ((curbuf (current-buffer))
5801 (window-start (window-start)))
5803 (if (gnus-buffer-live-p gnus-original-article-buffer)
5804 (insert-buffer gnus-original-article-buffer))
5805 (let ((winconf gnus-prev-winconf))
5806 (kill-all-local-variables)
5808 (set-window-configuration winconf)
5809 ;; Tippy-toe some to make sure that point remains where it was.
5810 (save-current-buffer
5812 (set-window-start (get-buffer-window (current-buffer)) window-start)
5814 (gnus-summary-show-article)))
5816 (defun gnus-article-edit-full-stops ()
5817 "Interactively repair spacing at end of sentences."
5820 (goto-char (point-min))
5821 (search-forward-regexp "^$" nil t)
5822 (let ((case-fold-search nil))
5823 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5826 ;;; Article highlights
5829 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
5831 ;;; Internal Variables:
5833 (defcustom gnus-button-url-regexp
5834 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
5835 "\\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:]]\\)"
5836 "\\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\\)\\)")
5837 "Regular expression that matches URLs."
5838 :group 'gnus-article-buttons
5841 (defcustom gnus-button-valid-fqdn-regexp
5842 message-valid-fqdn-regexp
5843 "Regular expression that matches a valid FQDN."
5845 :group 'gnus-article-buttons
5848 (defcustom gnus-button-man-handler 'manual-entry
5849 "Function to use for displaying man pages.
5850 The function must take at least one argument with a string naming the
5853 :type '(choice (function-item :tag "Man" manual-entry)
5854 (function-item :tag "Woman" woman)
5855 (function :tag "Other"))
5856 :group 'gnus-article-buttons)
5858 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
5859 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
5860 If the default site is too slow, try to find a CTAN mirror, see
5861 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
5862 the variable `gnus-button-handle-ctan'."
5864 :group 'gnus-article-buttons
5865 :link '(custom-manual "(gnus)Group Parameters")
5866 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
5867 (const "http://tug.ctan.org/tex-archive/")
5868 (const "http://www.dante.de/CTAN/")
5869 (string :tag "Other")))
5871 (defcustom gnus-button-ctan-handler 'browse-url
5872 "Function to use for displaying CTAN links.
5873 The function must take one argument, the string naming the URL."
5875 :type '(choice (function-item :tag "Browse Url" browse-url)
5876 (function :tag "Other"))
5877 :group 'gnus-article-buttons)
5879 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
5880 "Bogus strings removed from CTAN URLs."
5882 :group 'gnus-article-buttons
5883 :type '(choice (const "^/?tex-archive/\\|/")
5884 (regexp :tag "Other")))
5886 (defcustom gnus-button-ctan-directory-regexp
5889 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
5890 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
5891 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
5893 "Regular expression for ctan directories.
5894 It should match all directories in the top level of `gnus-ctan-url'."
5896 :group 'gnus-article-buttons
5899 (defcustom gnus-button-mid-or-mail-regexp
5900 (concat "\\b\\(<?[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*@"
5901 ;; Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
5902 gnus-button-valid-fqdn-regexp
5904 "Regular expression that matches a message ID or a mail address."
5906 :group 'gnus-article-buttons
5909 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
5910 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
5911 Strings like this can be either a message ID or a mail address. If it is one
5912 of the symbols `mid' or `mail', Gnus will always assume that the string is a
5913 message ID or a mail address, respectively. If this variable is set to the
5914 symbol `ask', always query the user what do do. If it is a function, this
5915 function will be called with the string as it's only argument. The function
5916 must return `mid', `mail', `invalid' or `ask'."
5918 :group 'gnus-article-buttons
5919 :type '(choice (function-item :tag "Heuristic function"
5920 gnus-button-mid-or-mail-heuristic)
5925 (defcustom gnus-button-mid-or-mail-heuristic-alist
5926 '((-10.0 . ".+\\$.+@")
5929 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
5930 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
5931 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
5932 (-1.0 . "^[^a-z]+@")
5934 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
5935 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
5936 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
5937 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
5940 (-1.0 . "^[0-9][0-9]")
5942 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
5943 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5944 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
5945 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
5947 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
5948 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
5951 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
5953 ;; compensation for TDMA dated mail addresses:
5954 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
5956 (-20.0 . "\\.fsf@") ;; Gnus
5959 (-20.0 . "_-_") ;; Subject change in thread
5961 (-20.0 . "\\.ln@") ;; leafnode
5962 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
5963 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
5965 ;; (5.0 . "") ;; $local_part_len <= 7
5966 (10.0 . "^[^0-9]+@")
5967 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
5968 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
5971 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
5973 (0.5 . "^[A-Z][a-z]")
5974 (0.5 . "^[A-Z][a-z][a-z]")
5975 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
5976 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
5977 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
5979 A negative RATE indicates a message IDs, whereas a positive indicates a mail
5980 address. The REGEXP is processed with `case-fold-search' set to nil."
5982 :group 'gnus-article-buttons
5983 :type '(repeat (cons (number :tag "Rate")
5984 (regexp :tag "Regexp"))))
5986 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
5987 "Guess whether MID-OR-MAIL is a message ID or a mail address.
5988 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
5989 address, `ask' if unsure and `invalid' if the string is invalid."
5990 (let ((case-fold-search nil)
5991 (list gnus-button-mid-or-mail-heuristic-alist)
5992 (result 0) rate regexp lpartlen elem)
5994 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
5995 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
5996 ;; Certain special cases...
5999 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6000 "^[0-9]+\\.[0-9]+@compuserve\\|"
6001 "@public\\.gmane\\.org")
6003 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6004 (setq result 'mail))
6005 (when (string-match "@.*@\\| " mid-or-mail)
6006 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6007 (setq result 'invalid))
6008 ;; Nothing more to do, if result is not a number here...
6009 (when (numberp result)
6011 (setq elem (car list)
6015 (when (string-match regexp mid-or-mail)
6016 (setq result (+ result rate))
6018 9 "`%s' matched `%s', rate `%s', result `%s'."
6019 mid-or-mail regexp rate result)))
6020 (when (<= lpartlen 7)
6021 (setq result (+ result 5.0))
6022 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6023 mid-or-mail result))
6024 (when (>= lpartlen 12)
6025 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6027 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6028 ;; Long local part should contain realname if e-mail address,
6029 ;; too many digits: message-id.
6030 ;; $score -= 5.0 + 0.1 * $local_part_len;
6031 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6032 (setq result (+ result rate))
6034 9 "Many digits in `%s', rate `%s', result `%s'."
6035 mid-or-mail rate result))
6036 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6038 ;; Too few vowels [^aeiouy]{4,}.*\@
6039 (setq result (+ result -5.0))
6041 9 "Few vowels in `%s', rate `%s', result `%s'."
6042 mid-or-mail -5.0 result))
6044 (setq result (+ result 5.0))
6046 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6047 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6048 ;; Maybe we should make this a customizable alist: (condition . 'result)
6050 ((symbolp result) result)
6051 ;; Now convert number into proper results:
6052 ((< result -10.0) 'mid)
6053 ((> result 10.0) 'mail)
6056 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6057 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6058 (url-mid (concat "news" ":" mid-or-mail))
6059 (url-mailto (concat "mailto" ":" mid-or-mail)))
6060 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6061 (when (fboundp pref)
6063 ;; get rid of surrounding angles...
6065 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6066 (if (or (eq 'mid guessed) (eq 'mail guessed))
6070 (save-window-excursion
6071 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6074 (cond ((eq pref 'mid)
6075 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6076 (gnus-button-handle-news url-mid))
6078 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6079 (gnus-url-mailto url-mailto))
6080 (t (gnus-message 3 "Invalid string.")))))
6082 (defun gnus-button-handle-custom (url)
6083 "Follow a Custom URL."
6084 (customize-apropos (gnus-url-unhex-string url)))
6086 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6088 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6091 (defun gnus-button-handle-describe-function (url)
6092 "Call `describe-function' when pushing the corresponding URL button."
6095 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6097 (defun gnus-button-handle-describe-variable (url)
6098 "Call `describe-variable' when pushing the corresponding URL button."
6101 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6103 (defun gnus-button-handle-symbol (url)
6104 "Display help on variable or function.
6105 Calls `describe-variable' or `describe-function'."
6106 (let ((sym (intern url)))
6108 ((fboundp sym) (describe-function sym))
6109 ((boundp sym) (describe-variable sym))
6110 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6112 (defun gnus-button-handle-describe-key (url)
6113 "Call `describe-key' when pushing the corresponding URL button."
6115 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6116 (keys (ignore-errors (eval `(kbd ,key-string)))))
6119 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6121 (defun gnus-button-handle-apropos (url)
6122 "Call `apropos' when pushing the corresponding URL button."
6123 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6125 (defun gnus-button-handle-apropos-command (url)
6126 "Call `apropos' when pushing the corresponding URL button."
6128 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6130 (defun gnus-button-handle-apropos-variable (url)
6131 "Call `apropos' when pushing the corresponding URL button."
6133 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6134 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6136 (defun gnus-button-handle-apropos-documentation (url)
6137 "Call `apropos' when pushing the corresponding URL button."
6139 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6140 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6142 (defun gnus-button-handle-library (url)
6143 "Call `locate-library' when pushing the corresponding URL button."
6144 (gnus-message 9 "url=`%s'" url)
6145 (let* ((lib (locate-library url))
6146 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6148 (gnus-message 1 "Cannot locale library `%s'." url)
6149 (find-file-read-only file))))
6151 (defun gnus-button-handle-ctan (url)
6152 "Call `browse-url' when pushing a CTAN URL button."
6154 gnus-button-ctan-handler
6157 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6159 (defcustom gnus-button-tex-level 5
6160 "*Integer that says how many TeX-related buttons Gnus will show.
6161 The higher the number, the more buttons will appear and the more false
6162 positives are possible. Note that you can set this variable local to
6163 specific groups. Setting it higher in TeX groups is probably a good idea.
6164 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6165 how to set variables in specific groups."
6167 :group 'gnus-article-buttons
6168 :link '(custom-manual "(gnus)Group Parameters")
6171 (defcustom gnus-button-man-level 5
6172 "*Integer that says how many man-related buttons Gnus will show.
6173 The higher the number, the more buttons will appear and the more false
6174 positives are possible. Note that you can set this variable local to
6175 specific groups. Setting it higher in Unix groups is probably a good idea.
6176 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6177 how to set variables in specific groups."
6179 :group 'gnus-article-buttons
6180 :link '(custom-manual "(gnus)Group Parameters")
6183 (defcustom gnus-button-emacs-level 5
6184 "*Integer that says how many emacs-related buttons Gnus will show.
6185 The higher the number, the more buttons will appear and the more false
6186 positives are possible. Note that you can set this variable local to
6187 specific groups. Setting it higher in Emacs or Gnus related groups is
6188 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6189 `gnus-parameters' on how to set variables in specific groups."
6191 :group 'gnus-article-buttons
6192 :link '(custom-manual "(gnus)Group Parameters")
6195 (defcustom gnus-button-message-level 5
6196 "*Integer that says how many buttons for news or mail messages will appear.
6197 The higher the number, the more buttons will appear and the more false
6198 positives are possible."
6199 ;; mail addresses, MIDs, URLs for news, ...
6201 :group 'gnus-article-buttons
6204 (defcustom gnus-button-browse-level 5
6205 "*Integer that says how many buttons for browsing will appear.
6206 The higher the number, the more buttons will appear and the more false
6207 positives are possible."
6208 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6210 :group 'gnus-article-buttons
6213 (defcustom gnus-button-alist
6214 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6215 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6216 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6217 gnus-button-handle-news 2)
6218 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6219 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6220 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6221 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6222 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6223 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6224 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6225 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6226 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6227 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6228 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6229 ;; RFC 2368 (The mailto URL scheme)
6230 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6231 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6232 ("\\bmailto:\\([^ \n\t]+\\)"
6233 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6235 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6236 gnus-button-ctan-directory-regexp
6237 "[^][>)!;:,'\n\t ]+\\)")
6238 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6239 ((concat "\\btex-archive/\\("
6240 gnus-button-ctan-directory-regexp
6241 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6242 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6245 gnus-button-ctan-directory-regexp
6246 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6247 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6248 ;; This is info (home-grown style) <info://foo/bar+baz>
6249 ("\\binfo://\\([^'\">\n\t ]+\\)"
6250 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6251 ;; Info GNOME style <info:foo#bar_baz>
6252 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6253 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6254 ;; Info KDE style <info:(foo)bar baz>
6255 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6256 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6257 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6258 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6259 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6260 ;; Info links like `C-h i d m CC Mode RET'
6261 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6263 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6264 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6265 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6266 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6267 ;; Emacs help commands
6268 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6269 ;; regexp doesn't match arguments containing ` '.
6270 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6271 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6272 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6273 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6274 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6275 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6276 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6277 ;; The following entries may lead to many false positives so don't enable
6278 ;; them by default (use a high button level).
6279 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6280 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6281 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6282 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6283 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6284 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6285 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6286 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6287 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6288 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6289 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6290 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6291 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6292 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6293 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6294 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6295 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6296 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6297 ;; Unlike the other regexps we really have to require quoting
6298 ;; here to determine where it ends.
6299 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6300 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6301 ("<URL: *\\([^<>]*\\)>"
6302 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6303 ;; RFC 2396 (2.4.3., delims) ...
6304 ("\"URL: *\\([^\"]*\\)\""
6305 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6306 ;; RFC 2396 (2.4.3., delims) ...
6307 ("\"URL: *\\([^\"]*\\)\""
6308 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6310 (gnus-button-url-regexp
6311 0 (>= gnus-button-browse-level 0) browse-url 0)
6313 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6314 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6315 gnus-button-handle-man 1)
6316 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6317 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6318 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6319 gnus-button-handle-man 1)
6320 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6321 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6322 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6323 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6324 ;; MID or mail: To avoid too many false positives we don't try to catch
6325 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6326 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6327 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6328 ;; so that non-ambiguous entries (see above) match first.
6329 (gnus-button-mid-or-mail-regexp
6330 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6331 "*Alist of regexps matching buttons in article bodies.
6333 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6334 REGEXP: is the string (case insensitive) matching text around the button (can
6335 also be Lisp expression evaluating to a string),
6336 BUTTON: is the number of the regexp grouping actually matching the button,
6337 FORM: is a Lisp expression which must eval to true for the button to
6339 CALLBACK: is the function to call when the user push this button, and each
6340 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6342 CALLBACK can also be a variable, in that case the value of that
6343 variable it the real callback function."
6344 :group 'gnus-article-buttons
6345 :type '(repeat (list (choice regexp variable sexp)
6346 (integer :tag "Button")
6348 (function :tag "Callback")
6351 (integer :tag "Regexp group")))))
6353 (defcustom gnus-header-button-alist
6354 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6355 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6356 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6357 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6358 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6359 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
6360 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6361 0 (>= gnus-button-browse-level 0) browse-url 0)
6362 ("^Subject:" gnus-button-url-regexp
6363 0 (>= gnus-button-browse-level 0) browse-url 0)
6364 ("^[^:]+:" gnus-button-url-regexp
6365 0 (>= gnus-button-browse-level 0) browse-url 0)
6366 ("^OpenPGP:.*url=" gnus-button-url-regexp
6367 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
6368 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6369 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6370 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6371 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6372 "*Alist of headers and regexps to match buttons in article heads.
6374 This alist is very similar to `gnus-button-alist', except that each
6375 alist has an additional HEADER element first in each entry:
6377 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6379 HEADER is a regexp to match a header. For a fuller explanation, see
6380 `gnus-button-alist'."
6381 :group 'gnus-article-buttons
6382 :group 'gnus-article-headers
6383 :type '(repeat (list (regexp :tag "Header")
6384 (choice regexp variable)
6385 (integer :tag "Button")
6387 (function :tag "Callback")
6390 (integer :tag "Regexp group")))))
6394 (defun gnus-article-push-button (event)
6395 "Check text under the mouse pointer for a callback function.
6396 If the text under the mouse pointer has a `gnus-callback' property,
6397 call it with the value of the `gnus-data' text property."
6399 (set-buffer (window-buffer (posn-window (event-start event))))
6400 (let* ((pos (posn-point (event-start event)))
6401 (data (get-text-property pos 'gnus-data))
6402 (fun (get-text-property pos 'gnus-callback)))
6405 (funcall fun data))))
6407 (defun gnus-article-press-button ()
6408 "Check text at point for a callback function.
6409 If the text at point has a `gnus-callback' property,
6410 call it with the value of the `gnus-data' text property."
6412 (let ((data (get-text-property (point) 'gnus-data))
6413 (fun (get-text-property (point) 'gnus-callback)))
6415 (funcall fun data))))
6417 (defun gnus-article-highlight (&optional force)
6418 "Highlight current article.
6419 This function calls `gnus-article-highlight-headers',
6420 `gnus-article-highlight-citation',
6421 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6422 do the highlighting. See the documentation for those functions."
6423 (interactive (list 'force))
6424 (gnus-article-highlight-headers)
6425 (gnus-article-highlight-citation force)
6426 (gnus-article-highlight-signature)
6427 (gnus-article-add-buttons force)
6428 (gnus-article-add-buttons-to-head))
6430 (defun gnus-article-highlight-some (&optional force)
6431 "Highlight current article.
6432 This function calls `gnus-article-highlight-headers',
6433 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6434 do the highlighting. See the documentation for those functions."
6435 (interactive (list 'force))
6436 (gnus-article-highlight-headers)
6437 (gnus-article-highlight-signature)
6438 (gnus-article-add-buttons))
6440 (defun gnus-article-highlight-headers ()
6441 "Highlight article headers as specified by `gnus-header-face-alist'."
6443 (gnus-with-article-headers
6444 (let (regexp header-face field-face from hpoints fpoints)
6445 (dolist (entry gnus-header-face-alist)
6446 (goto-char (point-min))
6447 (setq regexp (concat "^\\("
6448 (if (string-equal "" (nth 0 entry))
6452 header-face (nth 1 entry)
6453 field-face (nth 2 entry))
6454 (while (and (re-search-forward regexp nil t)
6458 (unless (search-forward ":" nil t)
6460 (when (and header-face
6461 (not (memq (point) hpoints)))
6462 (push (point) hpoints)
6463 (gnus-put-text-property from (point) 'face header-face))
6464 (when (and field-face
6465 (not (memq (setq from (point)) fpoints)))
6467 (if (re-search-forward "^[^ \t]" nil t)
6469 (goto-char (point-max)))
6470 (gnus-put-text-property from (point) 'face field-face)))))))
6472 (defun gnus-article-highlight-signature ()
6473 "Highlight the signature in an article.
6474 It does this by highlighting everything after
6475 `gnus-signature-separator' using `gnus-signature-face'."
6477 (gnus-with-article-buffer
6478 (let ((inhibit-point-motion-hooks t))
6480 (when (and gnus-signature-face
6481 (gnus-article-narrow-to-signature))
6482 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6483 'face gnus-signature-face)
6485 (gnus-article-search-signature)
6486 (let ((start (match-beginning 0))
6487 (end (set-marker (make-marker) (1+ (match-end 0)))))
6488 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
6491 (defun gnus-button-in-region-p (b e prop)
6492 "Say whether PROP exists in the region."
6493 (text-property-not-all b e prop nil))
6495 (defun gnus-article-add-buttons (&optional force)
6496 "Find external references in the article and make buttons of them.
6497 \"External references\" are things like Message-IDs and URLs, as
6498 specified by `gnus-button-alist'."
6499 (interactive (list 'force))
6500 (gnus-with-article-buffer
6501 (let ((inhibit-point-motion-hooks t)
6502 (case-fold-search t)
6503 (alist gnus-button-alist)
6505 ;; Remove all old markers.
6506 (let (marker entry new-list)
6507 (while (setq marker (pop gnus-button-marker-list))
6508 (if (or (< marker (point-min)) (>= marker (point-max)))
6509 (push marker new-list)
6511 (when (setq entry (gnus-button-entry))
6512 (put-text-property (match-beginning (nth 1 entry))
6513 (match-end (nth 1 entry))
6514 'gnus-callback nil))
6515 (set-marker marker nil)))
6516 (setq gnus-button-marker-list new-list))
6517 ;; We skip the headers.
6520 (while (setq entry (pop alist))
6521 (setq regexp (eval (car entry)))
6523 (while (re-search-forward regexp nil t)
6524 (let* ((start (and entry (match-beginning (nth 1 entry))))
6525 (end (and entry (match-end (nth 1 entry))))
6526 (from (match-beginning 0)))
6527 (when (and (or (eq t (nth 2 entry))
6528 (eval (nth 2 entry)))
6529 (not (gnus-button-in-region-p
6530 start end 'gnus-callback)))
6531 ;; That optional form returned non-nil, so we add the
6533 (gnus-article-add-button
6534 start end 'gnus-button-push
6535 (car (push (set-marker (make-marker) from)
6536 gnus-button-marker-list))))))))))
6538 ;; Add buttons to the head of an article.
6539 (defun gnus-article-add-buttons-to-head ()
6540 "Add buttons to the head of the article."
6542 (gnus-with-article-headers
6544 (dolist (entry gnus-header-button-alist)
6545 ;; Each alist entry.
6546 (goto-char (point-min))
6547 (while (re-search-forward (car entry) nil t)
6548 ;; Each header matching the entry.
6549 (setq beg (match-beginning 0))
6550 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6551 (match-beginning 0))
6554 (while (re-search-forward (eval (nth 1 entry)) end t)
6555 ;; Each match within a header.
6556 (let* ((entry (cdr entry))
6557 (start (match-beginning (nth 1 entry)))
6558 (end (match-end (nth 1 entry)))
6559 (form (nth 2 entry)))
6560 (goto-char (match-end 0))
6562 (gnus-article-add-button
6563 start end (nth 3 entry)
6564 (buffer-substring (match-beginning (nth 4 entry))
6565 (match-end (nth 4 entry)))))))
6566 (goto-char end))))))
6568 ;;; External functions:
6570 (defun gnus-article-add-button (from to fun &optional data)
6571 "Create a button between FROM and TO with callback FUN and data DATA."
6572 (when gnus-article-button-face
6573 (gnus-overlay-put (gnus-make-overlay from to)
6574 'face gnus-article-button-face))
6575 (gnus-add-text-properties
6577 (nconc (and gnus-article-mouse-face
6578 (list gnus-mouse-face-prop gnus-article-mouse-face))
6579 (list 'gnus-callback fun)
6580 (and data (list 'gnus-data data))))
6581 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6582 :button-keymap gnus-widget-button-keymap))
6584 ;;; Internal functions:
6586 (defun gnus-article-set-globals ()
6587 (with-current-buffer gnus-summary-buffer
6588 (gnus-set-global-variables)))
6590 (defun gnus-signature-toggle (end)
6591 (gnus-with-article-buffer
6592 (let ((inhibit-point-motion-hooks t))
6593 (if (text-property-any end (point-max) 'article-type 'signature)
6595 (gnus-delete-wash-type 'signature)
6596 (gnus-remove-text-properties-when
6597 'article-type 'signature end (point-max)
6598 (cons 'article-type (cons 'signature
6599 gnus-hidden-properties))))
6600 (gnus-add-wash-type 'signature)
6601 (gnus-add-text-properties-when
6602 'article-type nil end (point-max)
6603 (cons 'article-type (cons 'signature
6604 gnus-hidden-properties)))))
6605 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6606 (gnus-set-mode-line 'article))))
6608 (defun gnus-button-entry ()
6609 ;; Return the first entry in `gnus-button-alist' matching this place.
6610 (let ((alist gnus-button-alist)
6613 (setq entry (pop alist))
6614 (if (looking-at (eval (car entry)))
6619 (defun gnus-button-push (marker)
6620 ;; Push button starting at MARKER.
6623 (let* ((entry (gnus-button-entry))
6624 (inhibit-point-motion-hooks t)
6626 (args (mapcar (lambda (group)
6627 (let ((string (match-string group)))
6628 (set-text-properties
6629 0 (length string) nil string)
6636 (fboundp (symbol-value fun)))
6637 (apply (symbol-value fun) args))
6639 (gnus-message 1 "You must define `%S' to use this button"
6640 (cons fun args)))))))
6642 (defun gnus-parse-news-url (url)
6643 (let (scheme server port group message-id articles)
6646 (goto-char (point-min))
6647 (when (looking-at "\\([A-Za-z]+\\):")
6648 (setq scheme (match-string 1))
6649 (goto-char (match-end 0)))
6650 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
6651 (setq server (match-string 1))
6652 (setq port (if (stringp (match-string 3))
6653 (string-to-number (match-string 3))
6655 (goto-char (match-end 0)))
6658 ((looking-at "\\(.*@.*\\)")
6659 (setq message-id (match-string 1)))
6660 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6661 (setq group (match-string 1)
6662 articles (split-string (match-string 2) "-")))
6663 ((looking-at "\\([^/]+\\)/?")
6664 (setq group (match-string 1)))
6666 (error "Unknown news URL syntax"))))
6667 (list scheme server port group message-id articles)))
6669 (defun gnus-button-handle-news (url)
6671 (destructuring-bind (scheme server port group message-id articles)
6672 (gnus-parse-news-url url)
6676 (set-buffer gnus-summary-buffer)
6678 (let ((gnus-refer-article-method
6679 (nconc (list (list 'nntp server))
6680 gnus-refer-article-method))
6681 (nntp-port-number (or port "nntp")))
6682 (gnus-message 7 "Fetching %s with %s"
6683 message-id gnus-refer-article-method)
6684 (gnus-summary-refer-article message-id))
6685 (gnus-summary-refer-article message-id))))
6687 (gnus-button-fetch-group url)))))
6689 (defun gnus-button-handle-man (url)
6691 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
6692 (when (eq gnus-button-man-handler 'woman)
6693 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
6694 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
6695 (funcall gnus-button-man-handler url))
6697 (defun gnus-button-handle-info-url (url)
6698 "Fetch an info URL."
6699 (setq url (mm-subst-char-in-string ?+ ?\ url))
6701 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
6702 (gnus-info-find-node
6703 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6705 ")" (gnus-url-unhex-string (match-string 2 url)))))
6706 ((string-match "([^)\"]+)[^\"]+" url)
6708 (gnus-replace-in-string
6709 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
6710 (gnus-info-find-node url))
6711 (t (error "Can't parse %s" url))))
6713 (defun gnus-button-handle-info-url-gnome (url)
6714 "Fetch GNOME style info URL."
6715 (setq url (mm-subst-char-in-string ?_ ?\ url))
6716 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
6717 (gnus-info-find-node
6719 (gnus-url-unhex-string
6720 (match-string 1 url))
6722 (or (gnus-url-unhex-string
6723 (match-string 2 url))
6725 (error "Can't parse %s" url)))
6727 (defun gnus-button-handle-info-url-kde (url)
6728 "Fetch KDE style info URL."
6729 (gnus-info-find-node (gnus-url-unhex-string url)))
6731 (defun gnus-button-handle-info-keystrokes (url)
6732 "Call `info' when pushing the corresponding URL button."
6733 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
6738 (defun gnus-button-openpgp (url)
6739 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
6741 (mm-url-insert-file-contents-external url)
6742 (pgg-snarf-keys-region (point-min) (point-max))
6743 (pgg-display-output-buffer nil nil nil)))
6745 (defun gnus-button-message-id (message-id)
6747 (with-current-buffer gnus-summary-buffer
6748 (gnus-summary-refer-article message-id)))
6750 (defun gnus-button-fetch-group (address)
6751 "Fetch GROUP specified by ADDRESS."
6752 (if (not (string-match "[:/]" address))
6753 ;; This is just a simple group url.
6754 (gnus-group-read-ephemeral-group address gnus-select-method)
6757 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6759 (error "Can't parse %s" address)
6760 (gnus-group-read-ephemeral-group
6761 (match-string 4 address)
6762 `(nntp ,(match-string 1 address)
6763 (nntp-address ,(match-string 1 address))
6764 (nntp-port-number ,(if (match-end 3)
6765 (match-string 3 address)
6768 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
6770 (defun gnus-url-parse-query-string (query &optional downcase)
6771 (let (retval pairs cur key val)
6772 (setq pairs (split-string query "&"))
6774 (setq cur (car pairs)
6776 (if (not (string-match "=" cur))
6778 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6779 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6781 (setq key (downcase key)))
6782 (setq cur (assoc key retval))
6784 (setcdr cur (cons val (cdr cur)))
6785 (setq retval (cons (list key val) retval)))))
6788 (defun gnus-url-mailto (url)
6789 ;; Send mail to someone
6790 (when (string-match "mailto:/*\\(.*\\)" url)
6791 (setq url (substring url (match-beginning 1) nil)))
6792 (let (to args subject func)
6793 (setq args (gnus-url-parse-query-string
6794 (if (string-match "^\\?" url)
6796 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
6797 (concat "to=" (match-string 1 url) "&"
6798 (match-string 2 url))
6799 (concat "to=" url)))
6801 subject (cdr-safe (assoc "subject" args)))
6804 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6807 (message-position-on-field (caar args)))
6808 (insert (gnus-replace-in-string
6809 (mapconcat 'identity (reverse (cdar args)) ", ")
6811 (setq args (cdr args)))
6814 (message-goto-subject))))
6816 (defun gnus-button-embedded-url (address)
6817 "Activate ADDRESS with `browse-url'."
6818 (browse-url (gnus-strip-whitespace address)))
6820 ;;; Next/prev buttons in the article buffer.
6822 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6823 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6825 (defvar gnus-prev-page-map
6826 (let ((map (make-sparse-keymap)))
6827 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6828 (define-key map "\r" 'gnus-button-prev-page)
6831 (defvar gnus-next-page-map
6832 (let ((map (make-sparse-keymap)))
6833 (unless (>= emacs-major-version 21)
6834 ;; XEmacs doesn't care.
6835 (set-keymap-parent map gnus-article-mode-map))
6836 (define-key map gnus-mouse-2 'gnus-button-next-page)
6837 (define-key map "\r" 'gnus-button-next-page)
6840 (defun gnus-insert-prev-page-button ()
6842 (inhibit-read-only t))
6844 gnus-prev-page-line-format nil
6845 `(keymap ,gnus-prev-page-map
6847 gnus-callback gnus-article-button-prev-page
6848 article-type annotation))
6849 (widget-convert-button
6851 ;; Exclude a newline.
6854 :action 'gnus-button-prev-page
6855 :button-keymap gnus-prev-page-map)))
6857 (defun gnus-button-next-page (&optional args more-args)
6858 "Go to the next page."
6860 (let ((win (selected-window)))
6861 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6862 (gnus-article-next-page)
6863 (select-window win)))
6865 (defun gnus-button-prev-page (&optional args more-args)
6866 "Go to the prev page."
6868 (let ((win (selected-window)))
6869 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6870 (gnus-article-prev-page)
6871 (select-window win)))
6873 (defun gnus-insert-next-page-button ()
6875 (inhibit-read-only t))
6876 (gnus-eval-format gnus-next-page-line-format nil
6877 `(keymap ,gnus-next-page-map
6879 gnus-callback gnus-article-button-next-page
6880 article-type annotation))
6881 (widget-convert-button
6883 ;; Exclude a newline.
6886 :action 'gnus-button-next-page
6887 :button-keymap gnus-next-page-map)))
6889 (defun gnus-article-button-next-page (arg)
6890 "Go to the next page."
6892 (let ((win (selected-window)))
6893 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6894 (gnus-article-next-page)
6895 (select-window win)))
6897 (defun gnus-article-button-prev-page (arg)
6898 "Go to the prev page."
6900 (let ((win (selected-window)))
6901 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6902 (gnus-article-prev-page)
6903 (select-window win)))
6905 (defvar gnus-decode-header-methods
6906 '(mail-decode-encoded-word-region)
6907 "List of methods used to decode headers.
6909 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
6910 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
6911 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
6912 whose names match REGEXP.
6915 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
6916 mail-decode-encoded-word-region
6917 (\"chinese\" . rfc1843-decode-region))
6920 (defvar gnus-decode-header-methods-cache nil)
6922 (defun gnus-multi-decode-header (start end)
6923 "Apply the functions from `gnus-encoded-word-methods' that match."
6924 (unless (and gnus-decode-header-methods-cache
6925 (eq gnus-newsgroup-name
6926 (car gnus-decode-header-methods-cache)))
6927 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
6930 (nconc gnus-decode-header-methods-cache (list x))
6931 (if (and gnus-newsgroup-name
6932 (string-match (car x) gnus-newsgroup-name))
6933 (nconc gnus-decode-header-methods-cache
6935 gnus-decode-header-methods))
6936 (let ((xlist gnus-decode-header-methods-cache))
6939 (narrow-to-region start end)
6941 (funcall (pop xlist) (point-min) (point-max))))))
6944 ;;; Treatment top-level handling.
6947 (defun gnus-treat-article (condition &optional part-number total-parts type)
6948 (let ((length (- (point-max) (point-min)))
6949 (alist gnus-treatment-function-alist)
6950 (article-goto-body-goes-to-point-min-p t)
6954 (let ((list gnus-article-treat-types))
6956 (when (string-match (pop list) type)
6957 (throw 'found t)))))))
6958 (highlightp (gnus-visual-p 'article-highlight 'highlight))
6960 (gnus-run-hooks 'gnus-part-display-hook)
6961 (dolist (elem alist)
6964 (when (gnus-buffer-live-p gnus-summary-buffer)
6965 (set-buffer gnus-summary-buffer))
6966 (symbol-value (car elem))))
6967 (when (and (or (consp val)
6969 (gnus-treat-predicate val)
6970 (or (not (get (car elem) 'highlight))
6973 (funcall (cadr elem)))))))
6975 ;; Dynamic variables.
6977 (defvar part-number)
6978 (defvar total-parts)
6983 (defun gnus-treat-predicate (val)
6990 (stringp (car val)))
6991 (apply 'gnus-or (mapcar `(lambda (s)
6992 (string-match s ,(or gnus-newsgroup-name "")))
6995 (let ((pred (pop val)))
6998 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7000 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7002 (not (gnus-treat-predicate (car val))))
7004 (equal (car val) type))
7006 (error "%S is not a valid predicate" pred)))))
7012 (eq part-number total-parts))
7016 (error "%S is not a valid value" val))))
7018 (defun gnus-article-encrypt-body (protocol &optional n)
7019 "Encrypt the article body."
7022 (or gnus-article-encrypt-protocol
7023 (completing-read "Encrypt protocol: "
7024 gnus-article-encrypt-protocol-alist
7026 current-prefix-arg))
7027 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7029 (error (format "Can't find the encrypt protocol %s" protocol)))
7030 (if (member gnus-newsgroup-name '("nndraft:delayed"
7033 (error "Can't encrypt the article in group %s"
7034 gnus-newsgroup-name))
7035 (gnus-summary-iterate n
7037 (set-buffer gnus-summary-buffer)
7038 (let ((mail-parse-charset gnus-newsgroup-charset)
7039 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7040 (summary-buffer gnus-summary-buffer)
7042 (gnus-set-global-variables)
7043 (when (gnus-group-read-only-p)
7044 (error "The current newsgroup does not support article encrypt"))
7045 (gnus-summary-show-article t)
7047 (or (mail-header-references gnus-current-headers) ""))
7048 (set-buffer gnus-article-buffer)
7049 (let* ((inhibit-read-only t)
7051 (mapcar (lambda (field)
7052 (and (save-restriction
7053 (message-narrow-to-head)
7054 (goto-char (point-min))
7055 (search-forward field nil t))
7057 (message-narrow-to-field)
7059 (delete-region (point-min) (point-max))
7061 '("Content-Type:" "Content-Transfer-Encoding:"
7062 "Content-Disposition:"))))
7063 (message-narrow-to-head)
7064 (message-remove-header "MIME-Version")
7065 (goto-char (point-max))
7066 (setq point (point))
7067 (insert (apply 'concat headers))
7069 (narrow-to-region point (point-max))
7070 (let ((message-options message-options))
7071 (message-options-set 'message-sender user-mail-address)
7072 (message-options-set 'message-recipients user-mail-address)
7073 (message-options-set 'message-sign-encrypt 'not)
7075 (goto-char (point-min))
7076 (insert "MIME-Version: 1.0\n")
7078 (gnus-summary-edit-article-done
7079 references nil summary-buffer t))
7080 (when gnus-keep-backlog
7081 (gnus-backlog-remove-article
7082 (car gnus-article-current) (cdr gnus-article-current)))
7084 (when (get-buffer gnus-original-article-buffer)
7085 (set-buffer gnus-original-article-buffer)
7086 (setq gnus-original-article nil)))
7087 (when gnus-use-cache
7088 (gnus-cache-update-article
7089 (car gnus-article-current) (cdr gnus-article-current))))))))
7091 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7092 "The following specs can be used:
7093 %t The security MIME type
7096 %D Details if button is pressed")
7098 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7099 "The following specs can be used:
7100 %t The security MIME type
7103 %D Details if button is pressed")
7105 (defvar gnus-mime-security-button-line-format-alist
7106 '((?t gnus-tmp-type ?s)
7107 (?i gnus-tmp-info ?s)
7108 (?d gnus-tmp-details ?s)
7109 (?D gnus-tmp-pressed-details ?s)))
7111 (defvar gnus-mime-security-button-map
7112 (let ((map (make-sparse-keymap)))
7113 (define-key map gnus-mouse-2 'gnus-article-push-button)
7114 (define-key map "\r" 'gnus-article-press-button)
7117 (defvar gnus-mime-security-details-buffer nil)
7119 (defvar gnus-mime-security-button-pressed nil)
7121 (defvar gnus-mime-security-show-details-inline t
7122 "If non-nil, show details in the article buffer.")
7124 (defun gnus-mime-security-verify-or-decrypt (handle)
7125 (mm-remove-parts (cdr handle))
7126 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7127 point (inhibit-read-only t))
7129 (goto-char (car region)))
7131 (narrow-to-region (point) (point))
7132 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7133 (let* ((mm-verify-option 'known)
7134 (mm-decrypt-option 'known)
7135 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7136 (unless (eq nparts (cdr handle))
7137 (mm-destroy-parts (cdr handle))
7138 (setcdr handle nparts))))
7139 (setq point (point))
7140 (gnus-mime-display-security handle)
7141 (goto-char (point-max)))
7143 (delete-region (point) (cdr region))
7144 (set-marker (car region) nil)
7145 (set-marker (cdr region) nil))
7148 (defun gnus-mime-security-show-details (handle)
7149 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7151 (gnus-message 5 "No details.")
7152 (if gnus-mime-security-show-details-inline
7153 (let ((gnus-mime-security-button-pressed
7154 (not (get-text-property (point) 'gnus-mime-details)))
7155 (gnus-mime-security-button-line-format
7156 (get-text-property (point) 'gnus-line-format))
7157 (inhibit-read-only t))
7159 (while (eq (get-text-property (point) 'gnus-line-format)
7160 gnus-mime-security-button-line-format)
7164 (narrow-to-region (point) (point))
7165 (gnus-insert-mime-security-button handle))
7166 (delete-region (point)
7167 (or (text-property-not-all
7170 gnus-mime-security-button-line-format)
7173 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7174 (with-current-buffer gnus-mime-security-details-buffer
7177 (setq gnus-mime-security-details-buffer
7178 (gnus-get-buffer-create "*MIME Security Details*")))
7179 (with-current-buffer gnus-mime-security-details-buffer
7181 (goto-char (point-min)))
7182 (pop-to-buffer gnus-mime-security-details-buffer)))))
7184 (defun gnus-mime-security-press-button (handle)
7186 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7187 (gnus-mime-security-show-details handle)
7188 (gnus-mime-security-verify-or-decrypt handle))))
7190 (defun gnus-insert-mime-security-button (handle &optional displayed)
7191 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7194 (or (nth 2 (assoc protocol mm-verify-function-alist))
7195 (nth 2 (assoc protocol mm-decrypt-function-alist))
7197 (if (equal (car handle) "multipart/signed")
7198 " Signed" " Encrypted")
7201 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7204 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7205 gnus-tmp-pressed-details
7207 (setq gnus-tmp-details
7208 (if gnus-tmp-details
7209 (concat "\n" gnus-tmp-details)
7211 (setq gnus-tmp-pressed-details
7212 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7217 gnus-mime-security-button-line-format
7218 gnus-mime-security-button-line-format-alist
7219 `(keymap ,gnus-mime-security-button-map
7220 gnus-callback gnus-mime-security-press-button
7221 gnus-line-format ,gnus-mime-security-button-line-format
7222 gnus-mime-details ,gnus-mime-security-button-pressed
7223 article-type annotation
7226 ;; Exclude a newline.
7229 (widget-convert-button
7232 :action 'gnus-widget-press-button
7233 :button-keymap gnus-mime-security-button-map
7235 (lambda (widget/window &optional overlay pos)
7236 ;; Needed to properly clear the message due to a bug in
7237 ;; wid-edit (XEmacs only).
7238 (when (boundp 'help-echo-owns-message)
7239 (setq help-echo-owns-message t))
7242 (aref gnus-mouse-2 0))))))
7244 (defun gnus-mime-display-security (handle)
7246 (narrow-to-region (point) (point))
7247 (unless (gnus-unbuttonized-mime-type-p (car handle))
7248 (gnus-insert-mime-security-button handle))
7249 (gnus-mime-display-mixed (cdr handle))
7252 (unless (gnus-unbuttonized-mime-type-p (car handle))
7253 (let ((gnus-mime-security-button-line-format
7254 gnus-mime-security-button-end-line-format))
7255 (gnus-insert-mime-security-button handle)))
7256 (mm-set-handle-multipart-parameter
7258 (cons (set-marker (make-marker) (point-min))
7259 (set-marker (make-marker) (point-max))))))
7265 (run-hooks 'gnus-art-load-hook)
7267 ;;; arch-tag: 2654516f-6279-48f9-a83b-05c1fa450c33
7268 ;;; gnus-art.el ends here