1 ;;; gnus-art.el --- article mode commands for Semi-gnus
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005 Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
7 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
8 ;; Katsumi Yamaoka <yamaoka@jpl.org>
9 ;; Keywords: mail, news, MIME
11 ;; This file is part of GNU Emacs.
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation; either version 2, or (at your option)
18 ;; GNU Emacs is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;; GNU General Public License for more details.
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
25 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
26 ;; Boston, MA 02110-1301, USA.
35 (defvar tool-bar-map))
39 ;; Avoid the "Recursive load suspected" error in Emacs 21.1.
41 (let ((recursive-load-depth-limit 100))
48 (when (static-if (featurep 'xemacs)
49 (console-on-window-system-p)
51 (require 'mime-image))
54 ;; Avoid byte-compile warnings.
64 (autoload 'gnus-msg-mail "gnus-msg" nil t)
65 (autoload 'gnus-button-mailto "gnus-msg")
66 (autoload 'gnus-button-reply "gnus-msg" nil t)
67 (autoload 'parse-time-string "parse-time" nil nil)
68 (autoload 'ansi-color-apply-on-region "ansi-color")
70 (defgroup gnus-article nil
72 :link '(custom-manual "(gnus)Article Buffer")
75 (defgroup gnus-article-treat nil
76 "Treating article parts."
77 :link '(custom-manual "(gnus)Article Hiding")
80 (defgroup gnus-article-hiding nil
81 "Hiding article parts."
82 :link '(custom-manual "(gnus)Article Hiding")
85 (defgroup gnus-article-highlight nil
86 "Article highlighting."
87 :link '(custom-manual "(gnus)Article Highlighting")
91 (defgroup gnus-article-signature nil
93 :link '(custom-manual "(gnus)Article Signature")
96 (defgroup gnus-article-headers nil
98 :link '(custom-manual "(gnus)Hiding Headers")
101 (defgroup gnus-article-washing nil
102 "Special commands on articles."
103 :link '(custom-manual "(gnus)Article Washing")
104 :group 'gnus-article)
106 (defgroup gnus-article-emphasis nil
107 "Fontisizing articles."
108 :link '(custom-manual "(gnus)Article Fontisizing")
109 :group 'gnus-article)
111 (defgroup gnus-article-saving nil
113 :link '(custom-manual "(gnus)Saving Articles")
114 :group 'gnus-article)
116 (defgroup gnus-article-mime nil
117 "Worshiping the MIME wonder."
118 :link '(custom-manual "(gnus)Using MIME")
119 :group 'gnus-article)
121 (defgroup gnus-article-buttons nil
122 "Pushable buttons in the article buffer."
123 :link '(custom-manual "(gnus)Article Buttons")
124 :group 'gnus-article)
126 (defgroup gnus-article-various nil
127 "Other article options."
128 :link '(custom-manual "(gnus)Misc Article")
129 :group 'gnus-article)
131 (defcustom gnus-ignored-headers
134 (concat "^" header ":"))
135 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
136 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
137 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
138 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
139 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
140 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
141 "X-Attribution" "X-Originating-IP" "Delivered-To"
142 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
143 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
144 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
145 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
146 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
147 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
148 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
149 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
150 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
151 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
152 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
153 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
154 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
155 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
156 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
157 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
158 "List-[A-Za-z]+" "X-Listprocessor-Version"
159 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
160 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
161 "X-Received" "Content-length" "X-precedence"
162 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
163 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
164 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
165 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
166 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
167 "X-Content-length" "X-Posting-Agent" "Original-Received"
168 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
169 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
170 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
171 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
172 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"))
173 "*All headers that start with this regexp will be hidden.
174 This variable can also be a list of regexps of headers to be ignored.
175 If `gnus-visible-headers' is non-nil, this variable will be ignored."
176 :type '(choice :custom-show nil
179 :group 'gnus-article-hiding)
181 (defcustom gnus-visible-headers
182 "^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:"
183 "*All headers that do not match this regexp will be hidden.
184 This variable can also be a list of regexp of headers to remain visible.
185 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
186 :type '(repeat :value-to-internal (lambda (widget value)
187 (custom-split-regexp-maybe value))
188 :match (lambda (widget value)
190 (widget-editable-list-match widget value)))
192 :group 'gnus-article-hiding)
194 (defcustom gnus-sorted-header-list
195 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
196 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
197 "*This variable is a list of regular expressions.
198 If it is non-nil, headers that match the regular expressions will
199 be placed first in the article buffer in the sequence specified by
201 :type '(repeat regexp)
202 :group 'gnus-article-hiding)
204 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
205 "Headers that are only to be displayed if they have interesting data.
206 Possible values in this list are:
208 'empty Headers with no content.
209 'newsgroups Newsgroup identical to Gnus group.
210 'to-address To identical to To-address.
211 'to-list To identical to To-list.
212 'cc-list CC identical to To-list.
213 'followup-to Followup-to identical to Newsgroups.
214 'reply-to Reply-to identical to From.
215 'date Date less than four days old.
216 'long-to To and/or Cc longer than 1024 characters.
217 'many-to Multiple To and/or Cc."
218 :type '(set (const :tag "Headers with no content." empty)
219 (const :tag "Newsgroups identical to Gnus group." newsgroups)
220 (const :tag "To identical to To-address." to-address)
221 (const :tag "To identical to To-list." to-list)
222 (const :tag "CC identical to To-list." cc-list)
223 (const :tag "Followup-to identical to Newsgroups." followup-to)
224 (const :tag "Reply-to identical to From." reply-to)
225 (const :tag "Date less than four days old." date)
226 (const :tag "To and/or Cc longer than 1024 characters." long-to)
227 (const :tag "Multiple To and/or Cc headers." many-to))
228 :group 'gnus-article-hiding)
230 (defcustom gnus-article-skip-boring nil
231 "Skip over text that is not worth reading.
232 By default, if you set this t, then Gnus will display citations and
233 signatures, but will never scroll down to show you a page consisting
234 only of boring text. Boring text is controlled by
235 `gnus-article-boring-faces'."
238 :group 'gnus-article-hiding)
240 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
241 "Regexp matching signature separator.
242 This can also be a list of regexps. In that case, it will be checked
243 from head to tail looking for a separator. Searches will be done from
244 the end of the buffer."
245 :type '(repeat string)
246 :group 'gnus-article-signature)
248 (defcustom gnus-signature-limit nil
249 "Provide a limit to what is considered a signature.
250 If it is a number, no signature may not be longer (in characters) than
251 that number. If it is a floating point number, no signature may be
252 longer (in lines) than that number. If it is a function, the function
253 will be called without any parameters, and if it returns nil, there is
254 no signature in the buffer. If it is a string, it will be used as a
255 regexp. If it matches, the text in question is not a signature.
257 This can also be a list of the above values."
258 :type '(choice (integer :value 200)
260 (function :value fun)
261 (regexp :value ".*"))
262 :group 'gnus-article-signature)
264 (defcustom gnus-hidden-properties '(invisible t intangible t)
265 "Property list to use for hiding text."
267 :group 'gnus-article-hiding)
269 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
270 ;; frames in a session.
271 (defcustom gnus-article-x-face-command
276 (if (or (gnus-image-type-available-p 'xface)
277 (gnus-image-type-available-p 'pbm))
278 'gnus-display-x-face-in-from
279 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -"))
280 ((gnus-image-type-available-p 'pbm)
281 'gnus-display-x-face-in-from)
283 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
285 "*String or function to be executed to display an X-Face header.
286 If it is a string, the command will be executed in a sub-shell
287 asynchronously. The compressed face will be piped to this command."
289 :format "%{%t%}:\n%[Value Menu%] %v"
293 (if (or (gnus-image-type-available-p 'xface)
294 (gnus-image-type-available-p 'pbm))
295 '(function-item gnus-display-x-face-in-from))
299 :group 'gnus-article-washing)
301 (defcustom gnus-article-x-face-too-ugly nil
302 "Regexp matching posters whose face shouldn't be shown automatically."
303 :type '(choice regexp (const nil))
304 :group 'gnus-article-washing)
306 (defcustom gnus-article-banner-alist nil
307 "Banner alist for stripping.
309 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
311 :type '(repeat (cons symbol regexp))
312 :group 'gnus-article-washing)
314 (gnus-define-group-parameter
317 "Alist of regexps (to match group names) and banner."
318 :variable-group gnus-article-washing
320 '(choice :tag "Banner"
322 (const :tag "Remove signature" signature)
323 (symbol :tag "Item in `gnus-article-banner-alist'" none)
325 (const :tag "None" nil))
327 "If non-nil, specify how to remove `banners' from articles.
329 Symbol `signature' means to remove signatures delimited by
330 `gnus-signature-separator'. Any other symbol is used to look up a
331 regular expression to match the banner in `gnus-article-banner-alist'.
332 A string is used as a regular expression to match the banner
335 (defcustom gnus-article-address-banner-alist nil
336 "Alist of mail addresses and banners.
337 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
338 to match a mail address in the From: header, BANNER is one of a symbol
339 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
340 If ADDRESS matches author's mail address, it will remove things like
341 advertisements. For example:
343 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
347 (regexp :tag "Address")
348 (choice :tag "Banner" :value nil
349 (const :tag "Remove signature" signature)
350 (symbol :tag "Item in `gnus-article-banner-alist'" none)
352 (const :tag "None" nil))))
354 :group 'gnus-article-washing)
356 (defmacro gnus-emphasis-custom-with-format (&rest body)
358 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
359 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
362 (defun gnus-emphasis-custom-value-to-external (value)
363 (gnus-emphasis-custom-with-format
364 (if (consp (car value))
365 (list (format format (car (car value)) (cdr (car value)))
367 (if (nth 1 value) 2 3)
371 (defun gnus-emphasis-custom-value-to-internal (value)
372 (gnus-emphasis-custom-with-format
373 (let ((regexp (concat "\\`"
374 (format (regexp-quote format)
375 "\\([^()]+\\)" "\\([^()]+\\)")
378 (if (string-match regexp (setq pattern (car value)))
379 (list (cons (match-string 1 pattern) (match-string 2 pattern))
384 (defcustom gnus-emphasis-alist
386 '(("\\*" "\\*" bold nil 2)
389 ("_/" "/_" underline-italic)
390 ("_\\*" "\\*_" underline-bold)
391 ("\\*/" "/\\*" bold-italic)
392 ("_\\*/" "/\\*_" underline-bold-italic))))
394 (gnus-emphasis-custom-with-format
395 (mapcar (lambda (spec)
396 (list (format format (car spec) (cadr spec))
399 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
401 '(;; I've never seen anyone use this strikethru convention whereas I've
402 ;; several times seen it triggered by normal text. --Stef
403 ;; Miles suggests that this form is sometimes used but for italics,
404 ;; so maybe we should map it to `italic'.
405 ;; ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
406 ;; 2 3 gnus-emphasis-strikethru)
407 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
408 2 3 gnus-emphasis-underline))))
409 "*Alist that says how to fontify certain phrases.
410 Each item looks like this:
412 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
414 The first element is a regular expression to be matched. The second
415 is a number that says what regular expression grouping used to find
416 the entire emphasized word. The third is a number that says what
417 regexp grouping should be displayed and highlighted. The fourth
418 is the face used for highlighting."
422 :format "%[Customizing Style%]\n%v"
424 (group :tag "Default"
425 :value ("" 0 0 default)
428 (let ((value (widget-get
429 (cadr (widget-get (widget-get widget :parent)
432 (if (not (eq (nth 2 value) 'default))
436 (gnus-emphasis-custom-value-to-external value))))
437 (widget-group-value-create widget))
439 (integer :format "Match group: %v")
440 (integer :format "Emphasize group: %v")
443 :value (("_" . "_") nil default)
445 (regexp :format "Start regexp: %v")
446 (regexp :format "End regexp: %v"))
447 (boolean :format "Show start and end patterns: %[%v%]\n"
448 :on " On " :off " Off ")
450 :get (lambda (symbol)
451 (mapcar 'gnus-emphasis-custom-value-to-internal
452 (default-value symbol)))
453 :set (lambda (symbol value)
454 (set-default symbol (mapcar 'gnus-emphasis-custom-value-to-external
456 :group 'gnus-article-emphasis)
458 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
459 "A regexp to describe whitespace which should not be emphasized.
460 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
461 The former avoids underlining of leading and trailing whitespace,
462 and the latter avoids underlining any whitespace at all."
464 :group 'gnus-article-emphasis
467 (defface gnus-emphasis-bold '((t (:bold t)))
468 "Face used for displaying strong emphasized text (*word*)."
469 :group 'gnus-article-emphasis)
471 (defface gnus-emphasis-italic '((t (:italic t)))
472 "Face used for displaying italic emphasized text (/word/)."
473 :group 'gnus-article-emphasis)
475 (defface gnus-emphasis-underline '((t (:underline t)))
476 "Face used for displaying underlined emphasized text (_word_)."
477 :group 'gnus-article-emphasis)
479 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
480 "Face used for displaying underlined bold emphasized text (_*word*_)."
481 :group 'gnus-article-emphasis)
483 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
484 "Face used for displaying underlined italic emphasized text (_/word/_)."
485 :group 'gnus-article-emphasis)
487 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
488 "Face used for displaying bold italic emphasized text (/*word*/)."
489 :group 'gnus-article-emphasis)
491 (defface gnus-emphasis-underline-bold-italic
492 '((t (:bold t :italic t :underline t)))
493 "Face used for displaying underlined bold italic emphasized text.
494 Example: (_/*word*/_)."
495 :group 'gnus-article-emphasis)
497 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
498 '((t (:strikethru t)))
499 '((t (:strike-through t))))
500 "Face used for displaying strike-through text (-word-)."
501 :group 'gnus-article-emphasis)
503 (defface gnus-emphasis-highlight-words
504 '((t (:background "black" :foreground "yellow")))
505 "Face used for displaying highlighted words."
506 :group 'gnus-article-emphasis)
508 (defcustom gnus-article-time-format "%a, %d %b %Y %T %Z"
509 "Format for display of Date headers in article bodies.
510 See `format-time-string' for the possible values.
512 The variable can also be function, which should return a complete Date
513 header. The function is called with one argument, the time, which can
514 be fed to `format-time-string'."
515 :type '(choice string function)
516 :link '(custom-manual "(gnus)Article Date")
517 :group 'gnus-article-washing)
519 (defcustom gnus-save-all-headers t
520 "*If non-nil, don't remove any headers before saving."
521 :group 'gnus-article-saving
524 (defcustom gnus-prompt-before-saving 'always
525 "*This variable says how much prompting is to be done when saving articles.
526 If it is nil, no prompting will be done, and the articles will be
527 saved to the default files. If this variable is `always', each and
528 every article that is saved will be preceded by a prompt, even when
529 saving large batches of articles. If this variable is neither nil not
530 `always', there the user will be prompted once for a file name for
531 each invocation of the saving commands."
532 :group 'gnus-article-saving
533 :type '(choice (item always)
534 (item :tag "never" nil)
535 (sexp :tag "once" :format "%t\n" :value t)))
537 (defcustom gnus-saved-headers gnus-visible-headers
538 "Headers to keep if `gnus-save-all-headers' is nil.
539 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
540 If that variable is nil, however, all headers that match this regexp
541 will be kept while the rest will be deleted before saving."
542 :group 'gnus-article-saving
545 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
546 "A function to save articles in your favourite format.
547 The function must be interactively callable (in other words, it must
548 be an Emacs command).
550 Gnus provides the following functions:
552 * gnus-summary-save-in-rmail (Rmail format)
553 * gnus-summary-save-in-mail (Unix mail format)
554 * gnus-summary-save-in-folder (MH folder)
555 * gnus-summary-save-in-file (article format)
556 * gnus-summary-save-body-in-file (article body)
557 * gnus-summary-save-in-vm (use VM's folder format)
558 * gnus-summary-write-to-file (article format -- overwrite)."
559 :group 'gnus-article-saving
560 :type '(radio (function-item gnus-summary-save-in-rmail)
561 (function-item gnus-summary-save-in-mail)
562 (function-item gnus-summary-save-in-folder)
563 (function-item gnus-summary-save-in-file)
564 (function-item gnus-summary-save-body-in-file)
565 (function-item gnus-summary-save-in-vm)
566 (function-item gnus-summary-write-to-file)))
568 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
569 "A function generating a file name to save articles in Rmail format.
570 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
571 :group 'gnus-article-saving
574 (defcustom gnus-mail-save-name 'gnus-plain-save-name
575 "A function generating a file name to save articles in Unix mail format.
576 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
577 :group 'gnus-article-saving
580 (defcustom gnus-folder-save-name 'gnus-folder-save-name
581 "A function generating a file name to save articles in MH folder.
582 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
583 :group 'gnus-article-saving
586 (defcustom gnus-file-save-name 'gnus-numeric-save-name
587 "A function generating a file name to save articles in article format.
588 The function is called with NEWSGROUP, HEADERS, and optional
590 :group 'gnus-article-saving
593 (defcustom gnus-split-methods
594 '((gnus-article-archive-name)
595 (gnus-article-nndoc-name))
596 "*Variable used to suggest where articles are to be saved.
597 For instance, if you would like to save articles related to Gnus in
598 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
599 you could set this variable to something like:
601 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
602 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
604 This variable is an alist where the key is the match and the
605 value is a list of possible files to save in if the match is
608 If the match is a string, it is used as a regexp match on the
609 article. If the match is a symbol, that symbol will be funcalled
610 from the buffer of the article to be saved with the newsgroup as
611 the parameter. If it is a list, it will be evaled in the same
614 If this form or function returns a string, this string will be
615 used as a possible file name; and if it returns a non-nil list,
616 that list will be used as possible file names."
617 :group 'gnus-article-saving
618 :type '(repeat (choice (list :value (fun) function)
619 (cons :value ("" "") regexp (repeat string))
622 (defcustom gnus-article-display-method-for-mime
623 'gnus-article-display-mime-message
624 "Function to display a MIME message.
625 The function is called from the article buffer."
626 :group 'gnus-article-mime
629 (defcustom gnus-article-display-method-for-traditional
630 'gnus-article-display-traditional-message
631 "*Function to display a traditional message.
632 The function is called from the article buffer."
633 :group 'gnus-article-mime
636 (defcustom gnus-page-delimiter "^\^L"
637 "*Regexp describing what to use as article page delimiters.
638 The default value is \"^\^L\", which is a form linefeed at the
639 beginning of a line."
641 :group 'gnus-article-various)
643 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
644 "*The format specification for the article mode line.
645 See `gnus-summary-mode-line-format' for a closer description.
647 The following additional specs are available:
649 %w The article washing status.
650 %m The number of MIME parts in the article."
652 :group 'gnus-article-various)
654 (defcustom gnus-article-mode-hook nil
655 "*A hook for Gnus article mode."
657 :group 'gnus-article-various)
659 (when (featurep 'xemacs)
660 ;; Extracted from gnus-xmas-define in order to preserve user settings
661 (when (fboundp 'turn-off-scroll-in-place)
662 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
663 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
664 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
666 (defcustom gnus-article-menu-hook nil
667 "*Hook run after the creation of the article mode menu."
669 :group 'gnus-article-various)
671 (defcustom gnus-article-prepare-hook nil
672 "*A hook called after an article has been prepared in the article buffer."
674 :group 'gnus-article-various)
676 (defcustom gnus-copy-article-ignored-headers nil
677 "List of headers to be removed when copying an article.
678 Each element is a regular expression."
679 :version "23.0" ;; No Gnus
680 :type '(repeat regexp)
681 :group 'gnus-article-various)
683 (make-obsolete-variable 'gnus-article-hide-pgp-hook
684 "This variable is obsolete in Gnus 5.10.")
686 (defcustom gnus-article-button-face 'bold
687 "Face used for highlighting buttons in the article buffer.
689 An article button is a piece of text that you can activate by pressing
690 `RET' or `mouse-2' above it."
692 :group 'gnus-article-buttons)
694 (defcustom gnus-article-mouse-face 'highlight
695 "Face used for mouse highlighting in the article buffer.
697 Article buttons will be displayed in this face when the cursor is
700 :group 'gnus-article-buttons)
702 (defcustom gnus-signature-face 'gnus-signature
703 "Face used for highlighting a signature in the article buffer.
704 Obsolete; use the face `gnus-signature' for customizations instead."
706 :group 'gnus-article-highlight
707 :group 'gnus-article-signature)
709 (defface gnus-signature
712 "Face used for highlighting a signature in the article buffer."
713 :group 'gnus-article-highlight
714 :group 'gnus-article-signature)
715 ;; backward-compatibility alias
716 (put 'gnus-signature-face 'face-alias 'gnus-signature)
718 (defface gnus-header-from
721 (:foreground "spring green"))
724 (:foreground "red3"))
727 "Face used for displaying from headers."
728 :group 'gnus-article-headers
729 :group 'gnus-article-highlight)
730 ;; backward-compatibility alias
731 (put 'gnus-header-from-face 'face-alias 'gnus-header-from)
733 (defface gnus-header-subject
736 (:foreground "SeaGreen3"))
739 (:foreground "red4"))
741 (:bold t :italic t)))
742 "Face used for displaying subject headers."
743 :group 'gnus-article-headers
744 :group 'gnus-article-highlight)
745 ;; backward-compatibility alias
746 (put 'gnus-header-subject-face 'face-alias 'gnus-header-subject)
748 (defface gnus-header-newsgroups
751 (:foreground "yellow" :italic t))
754 (:foreground "MidnightBlue" :italic t))
757 "Face used for displaying newsgroups headers.
758 In the default setup this face is only used for crossposted
760 :group 'gnus-article-headers
761 :group 'gnus-article-highlight)
762 ;; backward-compatibility alias
763 (put 'gnus-header-newsgroups-face 'face-alias 'gnus-header-newsgroups)
765 (defface gnus-header-name
768 (:foreground "SeaGreen"))
771 (:foreground "maroon"))
774 "Face used for displaying header names."
775 :group 'gnus-article-headers
776 :group 'gnus-article-highlight)
777 ;; backward-compatibility alias
778 (put 'gnus-header-name-face 'face-alias 'gnus-header-name)
780 (defface gnus-header-content
783 (:foreground "forest green" :italic t))
786 (:foreground "indianred4" :italic t))
789 "Face used for displaying header content."
790 :group 'gnus-article-headers
791 :group 'gnus-article-highlight)
792 ;; backward-compatibility alias
793 (put 'gnus-header-content-face 'face-alias 'gnus-header-content)
795 (defcustom gnus-header-face-alist
796 '(("From" nil gnus-header-from)
797 ("Subject" nil gnus-header-subject)
798 ("Newsgroups:.*," nil gnus-header-newsgroups)
799 ("" gnus-header-name gnus-header-content))
800 "*Controls highlighting of article headers.
802 An alist of the form (HEADER NAME CONTENT).
804 HEADER is a regular expression which should match the name of a
805 header and NAME and CONTENT are either face names or nil.
807 The name of each header field will be displayed using the face
808 specified by the first element in the list where HEADER matches
809 the header name and NAME is non-nil. Similarly, the content will
810 be displayed by the first non-nil matching CONTENT face."
811 :group 'gnus-article-headers
812 :group 'gnus-article-highlight
813 :type '(repeat (list (regexp :tag "Header")
815 (item :tag "skip" nil)
816 (face :value default))
817 (choice :tag "Content"
818 (item :tag "skip" nil)
819 (face :value default)))))
821 (defcustom gnus-article-decode-hook
822 '(article-decode-group-name article-decode-idna-rhs)
823 "*Hook run to decode charsets in articles."
824 :group 'gnus-article-headers
827 (defcustom gnus-display-mime-function 'gnus-display-mime
828 "Function to display MIME articles."
829 :group 'gnus-article-mime
832 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
833 "Function used to decode headers.")
835 (defvar gnus-article-dumbquotes-map
855 "Table for MS-to-Latin1 translation.")
857 (defcustom gnus-ignored-mime-types nil
858 "List of MIME types that should be ignored by Gnus."
860 :group 'gnus-article-mime
861 :type '(repeat regexp))
863 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
864 "List of MIME types that should not be given buttons when rendered inline.
865 See also `gnus-buttonized-mime-types' which may override this variable.
866 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
868 :group 'gnus-article-mime
869 :type '(repeat regexp))
871 (defcustom gnus-buttonized-mime-types nil
872 "List of MIME types that should be given buttons when rendered inline.
873 If set, this variable overrides `gnus-unbuttonized-mime-types'.
874 To see e.g. security buttons you could set this to
875 `(\"multipart/signed\")'.
876 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
878 :group 'gnus-article-mime
879 :type '(repeat regexp))
881 (defcustom gnus-inhibit-mime-unbuttonizing nil
882 "If non-nil, all MIME parts get buttons.
883 When nil (the default value), then some MIME parts do not get buttons,
884 as described by the variables `gnus-buttonized-mime-types' and
885 `gnus-unbuttonized-mime-types'."
887 :group 'gnus-article-mime
890 (defcustom gnus-body-boundary-delimiter "_"
891 "String used to delimit header and body.
892 This variable is used by `gnus-article-treat-body-boundary' which can
893 be controlled by `gnus-treat-body-boundary'."
895 :group 'gnus-article-various
896 :type '(choice (item :tag "None" :value nil)
899 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
901 "Defines the location of the faces database.
902 For information on obtaining this database of pretty pictures, please
903 see http://www.cs.indiana.edu/picons/ftp/index.html"
905 :type '(repeat directory)
906 :link '(url-link :tag "download"
907 "http://www.cs.indiana.edu/picons/ftp/index.html")
908 :link '(custom-manual "(gnus)Picons")
911 (defun gnus-picons-installed-p ()
912 "Say whether picons are installed on your machine."
913 (let ((installed nil))
914 (dolist (database gnus-picon-databases)
915 (when (file-exists-p database)
919 (defcustom gnus-article-mime-part-function nil
920 "Function called with a MIME handle as the argument.
921 This is meant for people who want to do something automatic based
922 on parts -- for instance, adding Vcard info to a database."
923 :group 'gnus-article-mime
926 (defcustom gnus-mime-multipart-functions nil
927 "An alist of MIME types to functions to display them."
929 :group 'gnus-article-mime
930 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
932 (defcustom gnus-article-date-lapsed-new-header nil
933 "Whether the X-Sent and Date headers can coexist.
934 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
935 either replace the old \"Date:\" header (if this variable is nil), or
936 be added below it (otherwise)."
938 :group 'gnus-article-headers
941 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
942 "Function called with a MIME handle as the argument.
943 This is meant for people who want to view first matched part.
944 For `undisplayed-alternative' (default), the first undisplayed
945 part or alternative part is used. For `undisplayed', the first
946 undisplayed part is used. For a function, the first part which
947 the function return t is used. For nil, the first part is
950 :group 'gnus-article-mime
952 (item :tag "first" :value nil)
953 (item :tag "undisplayed" :value undisplayed)
954 (item :tag "undisplayed or alternative"
955 :value undisplayed-alternative)
958 (defcustom gnus-mime-action-alist
959 '(("save to file" . gnus-mime-save-part)
960 ("save and strip" . gnus-mime-save-part-and-strip)
961 ("delete part" . gnus-mime-delete-part)
962 ("display as text" . gnus-mime-inline-part)
963 ("view the part" . gnus-mime-view-part)
964 ("pipe to command" . gnus-mime-pipe-part)
965 ("toggle display" . gnus-article-press-button)
966 ("toggle display" . gnus-article-view-part-as-charset)
967 ("view as type" . gnus-mime-view-part-as-type)
968 ("view internally" . gnus-mime-view-part-internally)
969 ("view externally" . gnus-mime-view-part-externally))
970 "An alist of actions that run on the MIME attachment."
971 :group 'gnus-article-mime
972 :type '(repeat (cons (string :tag "name")
976 ;;; The treatment variables
979 (defvar gnus-part-display-hook nil
980 "Hook called on parts that are to receive treatment.")
982 (defvar gnus-article-treat-custom
983 '(choice (const :tag "Off" nil)
985 (const :tag "Header" head)
986 (const :tag "Last" last)
987 (const :tag "Mime" mime)
988 (integer :tag "Less")
989 (repeat :tag "Groups" regexp)
990 (sexp :tag "Predicate")))
992 (defvar gnus-article-treat-head-custom
993 '(choice (const :tag "Off" nil)
994 (const :tag "Header" head)))
996 (defvar gnus-article-treat-types '("text/plain")
999 (defvar gnus-inhibit-treatment nil
1000 "Whether to inhibit treatment.")
1002 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
1003 "Highlight the signature.
1004 Valid values are nil, t, `head', `last', an integer or a predicate.
1005 See Info node `(gnus)Customizing Articles'."
1006 :group 'gnus-article-treat
1007 :link '(custom-manual "(gnus)Customizing Articles")
1008 :type gnus-article-treat-custom)
1009 (put 'gnus-treat-highlight-signature 'highlight t)
1011 (defcustom gnus-treat-buttonize 100000
1013 Valid values are nil, t, `head', `last', an integer or a predicate.
1014 See Info node `(gnus)Customizing Articles'."
1015 :group 'gnus-article-treat
1016 :link '(custom-manual "(gnus)Customizing Articles")
1017 :type gnus-article-treat-custom)
1018 (put 'gnus-treat-buttonize 'highlight t)
1020 (defcustom gnus-treat-buttonize-head 'head
1021 "Add buttons to the head.
1022 Valid values are nil, t, `head', `last', an integer or a predicate.
1023 See Info node `(gnus)Customizing Articles' for details."
1024 :group 'gnus-article-treat
1025 :link '(custom-manual "(gnus)Customizing Articles")
1026 :type gnus-article-treat-head-custom)
1027 (put 'gnus-treat-buttonize-head 'highlight t)
1029 (defcustom gnus-treat-emphasize
1030 (and (or window-system
1034 Valid values are nil, t, `head', `last', an integer or a predicate.
1035 See Info node `(gnus)Customizing Articles' for details."
1036 :group 'gnus-article-treat
1037 :link '(custom-manual "(gnus)Customizing Articles")
1038 :type gnus-article-treat-custom)
1039 (put 'gnus-treat-emphasize 'highlight t)
1041 (defcustom gnus-treat-strip-cr nil
1042 "Remove carriage returns.
1043 Valid values are nil, t, `head', `last', an integer or a predicate.
1044 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-unsplit-urls nil
1051 "Remove newlines from within URLs.
1052 Valid values are nil, t, `head', `last', an integer or a predicate.
1053 See Info node `(gnus)Customizing Articles' for details."
1055 :group 'gnus-article-treat
1056 :link '(custom-manual "(gnus)Customizing Articles")
1057 :type gnus-article-treat-custom)
1059 (defcustom gnus-treat-leading-whitespace nil
1060 "Remove leading whitespace in headers.
1061 Valid values are nil, t, `head', `last', an integer or a predicate.
1062 See Info node `(gnus)Customizing Articles' for details."
1064 :group 'gnus-article-treat
1065 :link '(custom-manual "(gnus)Customizing Articles")
1066 :type gnus-article-treat-custom)
1068 (defcustom gnus-treat-hide-headers 'head
1070 Valid values are nil, t, `head', `last', an integer or a predicate.
1071 See Info node `(gnus)Customizing Articles' for details."
1072 :group 'gnus-article-treat
1073 :link '(custom-manual "(gnus)Customizing Articles")
1074 :type gnus-article-treat-head-custom)
1076 (defcustom gnus-treat-hide-boring-headers nil
1077 "Hide boring headers.
1078 Valid values are nil, t, `head', `last', an integer or a predicate.
1079 See Info node `(gnus)Customizing Articles' for details."
1080 :group 'gnus-article-treat
1081 :link '(custom-manual "(gnus)Customizing Articles")
1082 :type gnus-article-treat-head-custom)
1084 (defcustom gnus-treat-hide-signature nil
1085 "Hide the signature.
1086 Valid values are nil, t, `head', `last', an integer or a predicate.
1087 See Info node `(gnus)Customizing Articles' for details."
1088 :group 'gnus-article-treat
1089 :link '(custom-manual "(gnus)Customizing Articles")
1090 :type gnus-article-treat-custom)
1092 (defcustom gnus-treat-fill-article nil
1094 Valid values are nil, t, `head', `last', an integer or a predicate.
1095 See Info node `(gnus)Customizing Articles' for details."
1096 :group 'gnus-article-treat
1097 :link '(custom-manual "(gnus)Customizing Articles")
1098 :type gnus-article-treat-custom)
1100 (defcustom gnus-treat-hide-citation nil
1102 Valid values are nil, t, `head', `last', an integer or a predicate.
1103 See Info node `(gnus)Customizing Articles' for details."
1104 :group 'gnus-article-treat
1105 :link '(custom-manual "(gnus)Customizing Articles")
1106 :type gnus-article-treat-custom)
1108 (defcustom gnus-treat-hide-citation-maybe nil
1110 Valid values are nil, t, `head', `last', an integer or a predicate.
1111 See Info node `(gnus)Customizing Articles' for details."
1112 :group 'gnus-article-treat
1113 :link '(custom-manual "(gnus)Customizing Articles")
1114 :type gnus-article-treat-custom)
1116 (defcustom gnus-treat-strip-list-identifiers 'head
1117 "Strip list identifiers from `gnus-list-identifiers`.
1118 Valid values are nil, t, `head', `last', an integer or a predicate.
1119 See Info node `(gnus)Customizing Articles' for details."
1121 :group 'gnus-article-treat
1122 :link '(custom-manual "(gnus)Customizing Articles")
1123 :type gnus-article-treat-custom)
1125 (make-obsolete-variable 'gnus-treat-strip-pgp
1126 "This option is obsolete in Gnus 5.10.")
1128 (defcustom gnus-treat-strip-pem nil
1129 "Strip PEM signatures.
1130 Valid values are nil, t, `head', `last', an integer or a predicate.
1131 See Info node `(gnus)Customizing Articles' for details."
1132 :group 'gnus-article-treat
1133 :link '(custom-manual "(gnus)Customizing Articles")
1134 :type gnus-article-treat-custom)
1136 (defcustom gnus-treat-strip-banner t
1137 "Strip banners from articles.
1138 The banner to be stripped is specified in the `banner' group parameter.
1139 Valid values are nil, t, `head', `last', an integer or a predicate.
1140 See Info node `(gnus)Customizing Articles' for details."
1141 :group 'gnus-article-treat
1142 :link '(custom-manual "(gnus)Customizing Articles")
1143 :type gnus-article-treat-custom)
1145 (defcustom gnus-treat-highlight-headers 'head
1146 "Highlight the headers.
1147 Valid values are nil, t, `head', `last', an integer or a predicate.
1148 See Info node `(gnus)Customizing Articles' for details."
1149 :group 'gnus-article-treat
1150 :link '(custom-manual "(gnus)Customizing Articles")
1151 :type gnus-article-treat-head-custom)
1152 (put 'gnus-treat-highlight-headers 'highlight t)
1154 (defcustom gnus-treat-highlight-citation t
1155 "Highlight cited text.
1156 Valid values are nil, t, `head', `last', an integer or a predicate.
1157 See Info node `(gnus)Customizing Articles' for details."
1158 :group 'gnus-article-treat
1159 :link '(custom-manual "(gnus)Customizing Articles")
1160 :type gnus-article-treat-custom)
1161 (put 'gnus-treat-highlight-citation 'highlight t)
1163 (defcustom gnus-treat-date-ut nil
1164 "Display the Date in UT (GMT).
1165 Valid values are nil, t, `head', `last', an integer or a predicate.
1166 See Info node `(gnus)Customizing Articles' for details."
1167 :group 'gnus-article-treat
1168 :link '(custom-manual "(gnus)Customizing Articles")
1169 :type gnus-article-treat-head-custom)
1171 (defcustom gnus-treat-date-local nil
1172 "Display the Date in the local timezone.
1173 Valid values are nil, t, `head', `last', an integer or a predicate.
1174 See Info node `(gnus)Customizing Articles' for details."
1175 :group 'gnus-article-treat
1176 :link '(custom-manual "(gnus)Customizing Articles")
1177 :type gnus-article-treat-head-custom)
1179 (defcustom gnus-treat-date-english nil
1180 "Display the Date in a format that can be read aloud in English.
1181 Valid values are nil, t, `head', `last', an integer or a predicate.
1182 See Info node `(gnus)Customizing Articles' for details."
1184 :group 'gnus-article-treat
1185 :link '(custom-manual "(gnus)Customizing Articles")
1186 :type gnus-article-treat-head-custom)
1188 (defcustom gnus-treat-date-lapsed nil
1189 "Display the Date header in a way that says how much time has elapsed.
1190 Valid values are nil, t, `head', `last', an integer or a predicate.
1191 See Info node `(gnus)Customizing Articles' for details."
1192 :group 'gnus-article-treat
1193 :link '(custom-manual "(gnus)Customizing Articles")
1194 :type gnus-article-treat-head-custom)
1196 (defcustom gnus-treat-date-original nil
1197 "Display the date in the original timezone.
1198 Valid values are nil, t, `head', `last', an integer or a predicate.
1199 See Info node `(gnus)Customizing Articles' for details."
1200 :group 'gnus-article-treat
1201 :link '(custom-manual "(gnus)Customizing Articles")
1202 :type gnus-article-treat-head-custom)
1204 (defcustom gnus-treat-date-iso8601 nil
1205 "Display the date in the ISO8601 format.
1206 Valid values are nil, t, `head', `last', an integer or a predicate.
1207 See Info node `(gnus)Customizing Articles' for details."
1209 :group 'gnus-article-treat
1210 :link '(custom-manual "(gnus)Customizing Articles")
1211 :type gnus-article-treat-head-custom)
1213 (defcustom gnus-treat-date-user-defined nil
1214 "Display the date in a user-defined format.
1215 The format is defined by the `gnus-article-time-format' variable.
1216 Valid values are nil, t, `head', `last', an integer or a predicate.
1217 See Info node `(gnus)Customizing Articles' for details."
1218 :group 'gnus-article-treat
1219 :link '(custom-manual "(gnus)Customizing Articles")
1220 :type gnus-article-treat-head-custom)
1222 (defcustom gnus-treat-strip-headers-in-body t
1223 "Strip the X-No-Archive header line from the beginning of the body.
1224 Valid values are nil, t, `head', `last', an integer or a predicate.
1225 See Info node `(gnus)Customizing Articles' for details."
1227 :group 'gnus-article-treat
1228 :link '(custom-manual "(gnus)Customizing Articles")
1229 :type gnus-article-treat-custom)
1231 (defcustom gnus-treat-strip-trailing-blank-lines nil
1232 "Strip trailing blank lines.
1233 Valid values are nil, t, `head', `last', an integer or a predicate.
1234 See Info node `(gnus)Customizing Articles' for details."
1235 :group 'gnus-article-treat
1236 :link '(custom-manual "(gnus)Customizing Articles")
1237 :type gnus-article-treat-custom)
1239 (defcustom gnus-treat-strip-leading-blank-lines nil
1240 "Strip leading blank lines.
1241 Valid values are nil, t, `head', `last', an integer or a predicate.
1242 See Info node `(gnus)Customizing Articles' for details."
1243 :group 'gnus-article-treat
1244 :link '(custom-manual "(gnus)Customizing Articles")
1245 :type gnus-article-treat-custom)
1247 (defcustom gnus-treat-strip-multiple-blank-lines nil
1248 "Strip multiple blank lines.
1249 Valid values are nil, t, `head', `last', an integer or a predicate.
1250 See Info node `(gnus)Customizing Articles' for details."
1251 :group 'gnus-article-treat
1252 :link '(custom-manual "(gnus)Customizing Articles")
1253 :type gnus-article-treat-custom)
1255 (defcustom gnus-treat-unfold-headers 'head
1256 "Unfold folded header lines.
1257 Valid values are nil, t, `head', `last', an integer or a predicate.
1258 See Info node `(gnus)Customizing Articles' for details."
1260 :group 'gnus-article-treat
1261 :link '(custom-manual "(gnus)Customizing Articles")
1262 :type gnus-article-treat-custom)
1264 (defcustom gnus-treat-fold-headers nil
1266 Valid values are nil, t, `head', `last', an integer or a predicate.
1267 See Info node `(gnus)Customizing Articles' for details."
1269 :group 'gnus-article-treat
1270 :link '(custom-manual "(gnus)Customizing Articles")
1271 :type gnus-article-treat-custom)
1273 (defcustom gnus-treat-fold-newsgroups 'head
1274 "Fold the Newsgroups and Followup-To headers.
1275 Valid values are nil, t, `head', `last', an integer or a predicate.
1276 See Info node `(gnus)Customizing Articles' for details."
1278 :group 'gnus-article-treat
1279 :link '(custom-manual "(gnus)Customizing Articles")
1280 :type gnus-article-treat-custom)
1282 (defcustom gnus-treat-overstrike t
1283 "Treat overstrike highlighting.
1284 Valid values are nil, t, `head', `last', an integer or a predicate.
1285 See Info node `(gnus)Customizing Articles' for details."
1286 :group 'gnus-article-treat
1287 :link '(custom-manual "(gnus)Customizing Articles")
1288 :type gnus-article-treat-custom)
1289 (put 'gnus-treat-overstrike 'highlight t)
1291 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1292 "Treat ANSI SGR control sequences.
1293 Valid values are nil, t, `head', `last', an integer or a predicate.
1294 See Info node `(gnus)Customizing Articles' for details."
1295 :group 'gnus-article-treat
1296 :link '(custom-manual "(gnus)Customizing Articles")
1297 :type gnus-article-treat-custom)
1299 (make-obsolete-variable 'gnus-treat-display-xface
1300 'gnus-treat-display-x-face)
1302 (defcustom gnus-treat-display-x-face
1303 (and (not noninteractive)
1304 (or (and (fboundp 'image-type-available-p)
1305 (image-type-available-p 'xbm)
1306 (string-match "^0x" (shell-command-to-string "uncompface"))
1307 (executable-find "icontopbm"))
1308 (and (featurep 'xemacs)
1311 "Display X-Face headers.
1312 Valid values are nil, t, `head', `last', an integer or a predicate.
1313 See Info node `(gnus)Customizing Articles' and Info node
1314 `(gnus)X-Face' for details."
1315 :group 'gnus-article-treat
1317 :link '(custom-manual "(gnus)Customizing Articles")
1318 :link '(custom-manual "(gnus)X-Face")
1319 :type gnus-article-treat-head-custom
1320 :set (lambda (symbol value)
1323 (cond ((or (boundp symbol) (get symbol 'saved-value))
1325 ((boundp 'gnus-treat-display-xface)
1327 ** gnus-treat-display-xface is an obsolete variable;\
1328 use gnus-treat-display-x-face instead")
1329 (default-value 'gnus-treat-display-xface))
1330 ((get 'gnus-treat-display-xface 'saved-value)
1332 ** gnus-treat-display-xface is an obsolete variable;\
1333 use gnus-treat-display-x-face instead")
1334 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1337 (put 'gnus-treat-display-x-face 'highlight t)
1339 (defcustom gnus-article-should-use-smiley-mule
1340 (not (or (featurep 'xemacs)
1341 (gnus-image-type-available-p 'xpm)
1342 (gnus-image-type-available-p 'pbm)))
1343 "Non-nil means use `smiley-mule' to show smileys rather than `smiley'.
1344 `smiley-mule' is boundled in BITMAP-MULE package. You can set it to t
1345 even if your Emacs supports images. It has no effect on XEmacs."
1346 :group 'gnus-article-various
1348 :get (lambda (symbol)
1349 (and (not noninteractive)
1350 (default-value symbol)
1351 (not (featurep 'xemacs))
1352 (module-installed-p 'smiley-mule)
1354 :set (lambda (symbol value)
1355 (set-default symbol (and (not noninteractive)
1357 (not (featurep 'xemacs))
1358 (module-installed-p 'smiley-mule)
1361 (defvar gnus-article-smiley-mule-loaded-p nil
1362 "Internal variable used to say whether `smiley-mule' is loaded (whether
1363 smiley functions are not overridden by `smiley').")
1365 (defcustom gnus-treat-display-face
1366 (and (not noninteractive)
1367 (or (and (fboundp 'image-type-available-p)
1368 (image-type-available-p 'png))
1369 (and (featurep 'xemacs)
1372 "Display Face headers.
1373 Valid values are nil, t, `head', `last', an integer or a predicate.
1374 See Info node `(gnus)Customizing Articles' and Info node
1375 `(gnus)X-Face' for details."
1376 :group 'gnus-article-treat
1378 :link '(custom-manual "(gnus)Customizing Articles")
1379 :link '(custom-manual "(gnus)X-Face")
1380 :type gnus-article-treat-head-custom)
1381 (put 'gnus-treat-display-face 'highlight t)
1383 (defcustom gnus-treat-display-smileys
1384 (if (and (not noninteractive)
1385 (or (and (featurep 'xemacs)
1387 (gnus-image-type-available-p 'xpm)
1388 (gnus-image-type-available-p 'pbm)
1389 (and (not (featurep 'xemacs))
1391 (module-installed-p 'smiley-mule))))
1395 Valid values are nil, t, `head', `last', an integer or a predicate.
1396 See Info node `(gnus)Customizing Articles' and Info node
1397 `(gnus)Smileys' for details."
1398 :group 'gnus-article-treat
1400 :link '(custom-manual "(gnus)Customizing Articles")
1401 :link '(custom-manual "(gnus)Smileys")
1402 :type gnus-article-treat-custom)
1403 (put 'gnus-treat-display-smileys 'highlight t)
1405 (defcustom gnus-treat-from-picon
1406 (if (and (gnus-image-type-available-p 'xpm)
1407 (gnus-picons-installed-p))
1409 "Display picons in the From header.
1410 Valid values are nil, t, `head', `last', an integer or a predicate.
1411 See Info node `(gnus)Customizing Articles' and Info node
1412 `(gnus)Picons' for details."
1414 :group 'gnus-article-treat
1416 :link '(custom-manual "(gnus)Customizing Articles")
1417 :link '(custom-manual "(gnus)Picons")
1418 :type gnus-article-treat-head-custom)
1419 (put 'gnus-treat-from-picon 'highlight t)
1421 (defcustom gnus-treat-mail-picon
1422 (if (and (gnus-image-type-available-p 'xpm)
1423 (gnus-picons-installed-p))
1425 "Display picons in To and Cc headers.
1426 Valid values are nil, t, `head', `last', an integer or a predicate.
1427 See Info node `(gnus)Customizing Articles' and Info node
1428 `(gnus)Picons' for details."
1430 :group 'gnus-article-treat
1432 :link '(custom-manual "(gnus)Customizing Articles")
1433 :link '(custom-manual "(gnus)Picons")
1434 :type gnus-article-treat-head-custom)
1435 (put 'gnus-treat-mail-picon 'highlight t)
1437 (defcustom gnus-treat-newsgroups-picon
1438 (if (and (gnus-image-type-available-p 'xpm)
1439 (gnus-picons-installed-p))
1441 "Display picons in the Newsgroups and Followup-To headers.
1442 Valid values are nil, t, `head', `last', an integer or a predicate.
1443 See Info node `(gnus)Customizing Articles' and Info node
1444 `(gnus)Picons' for details."
1446 :group 'gnus-article-treat
1448 :link '(custom-manual "(gnus)Customizing Articles")
1449 :link '(custom-manual "(gnus)Picons")
1450 :type gnus-article-treat-head-custom)
1451 (put 'gnus-treat-newsgroups-picon 'highlight t)
1453 (defcustom gnus-treat-body-boundary
1454 (if (and (eq window-system 'x)
1455 (or gnus-treat-newsgroups-picon
1456 gnus-treat-mail-picon
1457 gnus-treat-from-picon))
1459 "Draw a boundary at the end of the headers.
1460 Valid values are nil and `head'.
1461 See Info node `(gnus)Customizing Articles' for details."
1463 :group 'gnus-article-treat
1464 :link '(custom-manual "(gnus)Customizing Articles")
1465 :type gnus-article-treat-head-custom)
1467 (defcustom gnus-treat-capitalize-sentences nil
1468 "Capitalize sentence-starting words.
1469 Valid values are nil, t, `head', `last', an integer or a predicate.
1470 See Info node `(gnus)Customizing Articles' for details."
1472 :group 'gnus-article-treat
1473 :link '(custom-manual "(gnus)Customizing Articles")
1474 :type gnus-article-treat-custom)
1476 (defcustom gnus-treat-wash-html nil
1478 Valid values are nil, t, `head', `last', an integer or a predicate.
1479 See Info node `(gnus)Customizing Articles' for details."
1481 :group 'gnus-article-treat
1482 :link '(custom-manual "(gnus)Customizing Articles")
1483 :type gnus-article-treat-custom)
1485 (defcustom gnus-treat-fill-long-lines nil
1487 Valid values are nil, t, `head', `last', an integer or a predicate.
1488 See Info node `(gnus)Customizing Articles' for details."
1489 :group 'gnus-article-treat
1490 :link '(custom-manual "(gnus)Customizing Articles")
1491 :type gnus-article-treat-custom)
1493 (defcustom gnus-treat-play-sounds nil
1495 Valid values are nil, t, `head', `last', an integer or a predicate.
1496 See Info node `(gnus)Customizing Articles' for details."
1498 :group 'gnus-article-treat
1499 :link '(custom-manual "(gnus)Customizing Articles")
1500 :type gnus-article-treat-custom)
1502 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
1503 "Decode an article as `default-mime-charset'. For instance, if you want to
1504 attempt to decode an article even if the value of `gnus-show-mime' is nil,
1505 you could set this variable to something like: nil for don't decode, t for
1506 decode the body, '(or header t) for the whole article, etc."
1507 :group 'gnus-article-treat
1508 :type '(radio (const :tag "Off" nil)
1509 (const :tag "Decode body" t)
1510 (const :tag "Decode all" (or head t))))
1512 (defcustom gnus-treat-translate nil
1513 "Translate articles from one language to another.
1514 Valid values are nil, t, `head', `last', an integer or a predicate.
1515 See Info node `(gnus)Customizing Articles' for details."
1517 :group 'gnus-article-treat
1518 :link '(custom-manual "(gnus)Customizing Articles")
1519 :type gnus-article-treat-custom)
1521 (defcustom gnus-treat-x-pgp-sig nil
1523 To automatically treat X-PGP-Sig, set it to head.
1524 Valid values are nil, t, `head', `last', an integer or a predicate.
1525 See Info node `(gnus)Customizing Articles' for details."
1527 :group 'gnus-article-treat
1528 :group 'mime-security
1529 :type gnus-article-treat-custom)
1531 (defcustom gnus-treat-monafy nil
1532 "Display body part with mona font.
1533 Valid values are nil, t, `head', `last', an integer or a predicate.
1534 See Info node `(gnus)Customizing Articles' for details."
1535 :group 'gnus-article-treat
1536 :group 'mime-security
1537 :link '(custom-manual "(gnus)Customizing Articles")
1538 :type gnus-article-treat-custom)
1540 (defvar gnus-article-encrypt-protocol-alist
1541 '(("PGP" . mml2015-self-encrypt)))
1543 ;; Set to nil if more than one protocol added to
1544 ;; gnus-article-encrypt-protocol-alist.
1545 (defcustom gnus-article-encrypt-protocol "PGP"
1546 "The protocol used for encrypt articles.
1547 It is a string, such as \"PGP\". If nil, ask user."
1550 :group 'mime-security)
1552 (defvar gnus-article-wash-function nil
1553 "Function used for converting HTML into text.")
1555 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1556 (mm-coding-system-p 'utf-8)
1557 (executable-find idna-program))
1558 "Whether IDNA decoding of headers is used when viewing messages.
1559 This requires GNU Libidn, and by default only enabled if it is found."
1561 :group 'gnus-article-headers
1564 (defcustom gnus-article-over-scroll nil
1565 "If non-nil, allow scrolling the article buffer even when there no more text."
1567 :group 'gnus-article
1570 ;;; Internal variables
1572 (defvar gnus-english-month-names
1573 '("January" "February" "March" "April" "May" "June" "July" "August"
1574 "September" "October" "November" "December"))
1576 (defvar gnus-button-regexp nil)
1577 (defvar gnus-button-marker-list nil)
1578 ;; Regexp matching any of the regexps from `gnus-button-alist'.
1580 (defvar gnus-button-last nil)
1581 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
1583 (defvar article-goto-body-goes-to-point-min-p nil)
1584 (defvar gnus-article-wash-types nil)
1585 (defvar gnus-article-emphasis-alist nil)
1586 (defvar gnus-article-image-alist nil)
1588 (defvar gnus-article-mime-handle-alist-1 nil)
1589 (defvar gnus-treatment-function-alist
1590 '((gnus-treat-decode-article-as-default-mime-charset
1591 gnus-article-decode-article-as-default-mime-charset)
1592 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1593 (gnus-treat-monafy gnus-article-monafy)
1594 (gnus-treat-strip-banner gnus-article-strip-banner)
1595 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1596 (gnus-treat-buttonize gnus-article-add-buttons)
1597 (gnus-treat-fill-article gnus-article-fill-cited-article)
1598 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1599 (gnus-treat-strip-cr gnus-article-remove-cr)
1600 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1601 (gnus-treat-date-ut gnus-article-date-ut)
1602 (gnus-treat-date-local gnus-article-date-local)
1603 (gnus-treat-date-english gnus-article-date-english)
1604 (gnus-treat-date-original gnus-article-date-original)
1605 (gnus-treat-date-user-defined gnus-article-date-user)
1606 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1607 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1608 (gnus-treat-display-face gnus-article-display-face)
1609 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1610 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1611 (gnus-treat-hide-signature gnus-article-hide-signature)
1612 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1613 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1614 (gnus-treat-strip-pem gnus-article-hide-pem)
1615 (gnus-treat-from-picon gnus-treat-from-picon)
1616 (gnus-treat-mail-picon gnus-treat-mail-picon)
1617 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1618 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1619 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1620 (gnus-treat-strip-trailing-blank-lines
1621 gnus-article-remove-trailing-blank-lines)
1622 (gnus-treat-strip-leading-blank-lines
1623 gnus-article-strip-leading-blank-lines)
1624 (gnus-treat-strip-multiple-blank-lines
1625 gnus-article-strip-multiple-blank-lines)
1626 (gnus-treat-overstrike gnus-article-treat-overstrike)
1627 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1628 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1629 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1630 ;; Displaying X-Face should be done after unfolding headers
1631 ;; to protect bitmap lines.
1632 (gnus-treat-display-x-face gnus-article-display-x-face)
1633 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1634 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1635 (gnus-treat-display-smileys gnus-treat-smiley)
1636 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1637 (gnus-treat-wash-html gnus-article-wash-html)
1638 (gnus-treat-emphasize gnus-article-emphasize)
1639 (gnus-treat-hide-citation gnus-article-hide-citation)
1640 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1641 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1642 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1643 (gnus-treat-play-sounds gnus-earcon-display)))
1645 (defvar gnus-article-mime-handle-alist nil)
1646 (defvar article-lapsed-timer nil)
1647 (defvar gnus-article-current-summary nil)
1649 (defvar gnus-article-mode-syntax-table
1650 (let ((table (copy-syntax-table text-mode-syntax-table)))
1651 ;; This causes the citation match run O(2^n).
1652 ;; (modify-syntax-entry ?- "w" table)
1653 (modify-syntax-entry ?> ")<" table)
1654 (modify-syntax-entry ?< "(>" table)
1655 ;; make M-. in article buffers work for `foo' strings
1656 (modify-syntax-entry ?' " " table)
1657 (modify-syntax-entry ?` " " table)
1659 "Syntax table used in article mode buffers.
1660 Initialized from `text-mode-syntax-table.")
1662 (defvar gnus-save-article-buffer nil)
1664 (defvar gnus-article-mode-line-format-alist
1665 (nconc '((?w (gnus-article-wash-status) ?s)
1666 (?m (gnus-article-mime-part-status) ?s))
1667 gnus-summary-mode-line-format-alist))
1669 (defvar gnus-number-of-articles-to-be-saved nil)
1671 (defvar gnus-inhibit-hiding nil)
1673 (defvar gnus-article-edit-mode nil)
1675 ;;; Macros for dealing with the article buffer.
1677 (defmacro gnus-with-article-headers (&rest forms)
1679 (set-buffer gnus-article-buffer)
1681 (let ((inhibit-read-only t)
1682 (inhibit-point-motion-hooks t)
1683 (case-fold-search t))
1684 (article-narrow-to-head)
1687 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1688 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1690 (defmacro gnus-with-article-buffer (&rest forms)
1692 (set-buffer gnus-article-buffer)
1693 (let ((inhibit-read-only t))
1696 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1697 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1699 (defun gnus-article-goto-header (header)
1700 "Go to HEADER, which is a regular expression."
1701 (re-search-forward (concat "^\\(" header "\\):") nil t))
1703 (defsubst gnus-article-hide-text (b e props)
1704 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1705 (gnus-add-text-properties-when 'article-type nil b e props)
1706 (when (memq 'intangible props)
1708 (max (1- b) (point-min))
1709 b 'intangible (cddr (memq 'intangible props)))))
1711 (defsubst gnus-article-unhide-text (b e)
1712 "Remove hidden text properties from region between B and E."
1713 (remove-text-properties b e gnus-hidden-properties)
1714 (when (memq 'intangible gnus-hidden-properties)
1715 (put-text-property (max (1- b) (point-min))
1716 b 'intangible nil)))
1718 (defun gnus-article-hide-text-type (b e type)
1719 "Hide text of TYPE between B and E."
1720 (gnus-add-wash-type type)
1721 (gnus-article-hide-text
1722 b e (cons 'article-type (cons type gnus-hidden-properties))))
1724 (defun gnus-article-unhide-text-type (b e type)
1725 "Unhide text of TYPE between B and E."
1726 (gnus-delete-wash-type type)
1727 (remove-text-properties
1728 b e (cons 'article-type (cons type gnus-hidden-properties)))
1729 (when (memq 'intangible gnus-hidden-properties)
1730 (put-text-property (max (1- b) (point-min))
1731 b 'intangible nil)))
1733 (defun gnus-article-hide-text-of-type (type)
1734 "Hide text of TYPE in the current buffer."
1736 (let ((b (point-min))
1738 (while (setq b (text-property-any b e 'article-type type))
1739 (add-text-properties b (incf b) gnus-hidden-properties)))))
1741 (defun gnus-article-delete-text-of-type (type)
1742 "Delete text of TYPE in the current buffer."
1744 (let ((b (point-min)))
1745 (while (setq b (text-property-any b (point-max) 'article-type type))
1747 b (or (text-property-not-all b (point-max) 'article-type type)
1750 (defun gnus-article-delete-invisible-text ()
1751 "Delete all invisible text in the current buffer."
1753 (let ((b (point-min)))
1754 (while (setq b (text-property-any b (point-max) 'invisible t))
1756 b (or (text-property-not-all b (point-max) 'invisible t)
1759 (defun gnus-article-text-type-exists-p (type)
1760 "Say whether any text of type TYPE exists in the buffer."
1761 (text-property-any (point-min) (point-max) 'article-type type))
1763 (defsubst gnus-article-header-rank ()
1764 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1765 (let ((list gnus-sorted-header-list)
1768 (if (looking-at (car list))
1770 (setq list (cdr list))
1774 (defun article-hide-headers (&optional arg delete)
1775 "Hide unwanted headers and possibly sort them as well."
1776 (interactive (gnus-article-hidden-arg))
1777 ;; Lars said that this function might be inhibited.
1778 (if (gnus-article-check-hidden-text 'headers arg)
1780 ;; Show boring headers as well.
1781 (gnus-article-show-hidden-text 'boring-headers)
1782 (when (eq 1 (point-min))
1783 (set-window-start (get-buffer-window (current-buffer)) 1)))
1784 (unless gnus-inhibit-hiding
1785 (let ((inhibit-read-only t)
1786 (case-fold-search t)
1787 (max (1+ (length gnus-sorted-header-list)))
1788 (inhibit-point-motion-hooks t)
1789 (cur (current-buffer))
1790 ignored visible beg)
1792 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1793 ;; group parameters, so we should go to the summary buffer.
1796 (progn (set-buffer gnus-summary-buffer) t)
1798 (setq ignored (when (not gnus-visible-headers)
1799 (cond ((stringp gnus-ignored-headers)
1800 gnus-ignored-headers)
1801 ((listp gnus-ignored-headers)
1802 (mapconcat 'identity
1803 gnus-ignored-headers
1805 visible (cond ((stringp gnus-visible-headers)
1806 gnus-visible-headers)
1807 ((and gnus-visible-headers
1808 (listp gnus-visible-headers))
1809 (mapconcat 'identity
1810 gnus-visible-headers
1814 ;; First we narrow to just the headers.
1815 (article-narrow-to-head)
1816 ;; Hide any "From " lines at the beginning of (mail) articles.
1817 (while (looking-at "From ")
1821 (delete-region (point-min) (point))
1822 (gnus-article-hide-text (point-min) (point)
1823 (nconc (list 'article-type 'headers)
1824 gnus-hidden-properties))))
1825 ;; Then treat the rest of the header lines.
1826 ;; Then we use the two regular expressions
1827 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1828 ;; select which header lines is to remain visible in the
1830 (while (re-search-forward "^[^ \t:]*:" nil t)
1832 ;; Mark the rank of the header.
1834 (point) (1+ (point)) 'message-rank
1835 (if (or (and visible (looking-at visible))
1837 (not (looking-at ignored))))
1838 (gnus-article-header-rank)
1841 (message-sort-headers-1)
1842 (when (setq beg (text-property-any
1843 (point-min) (point-max) 'message-rank (+ 2 max)))
1844 ;; We delete or make invisible the unwanted headers.
1845 (gnus-add-wash-type 'headers)
1848 (add-text-properties
1849 (point-min) (+ 5 (point-min))
1850 '(article-type headers dummy-invisible t))
1851 (delete-region beg (point-max)))
1852 (gnus-article-hide-text-type beg (point-max) 'headers)))))))))
1854 (defun article-hide-boring-headers (&optional arg)
1855 "Toggle hiding of headers that aren't very interesting.
1856 If given a negative prefix, always show; if given a positive prefix,
1858 (interactive (gnus-article-hidden-arg))
1859 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1860 (not gnus-show-all-headers))
1863 (let ((inhibit-read-only t)
1864 (inhibit-point-motion-hooks t))
1865 (article-narrow-to-head)
1866 (dolist (elem gnus-boring-article-headers)
1867 (goto-char (point-min))
1869 ;; Hide empty headers.
1871 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1873 (gnus-article-hide-text-type
1877 (if (re-search-forward "^[^ \t]" nil t)
1881 ;; Hide boring Newsgroups header.
1882 ((eq elem 'newsgroups)
1883 (when (gnus-string-equal
1884 (gnus-fetch-field "newsgroups")
1885 (gnus-group-real-name
1886 (if (boundp 'gnus-newsgroup-name)
1889 (gnus-article-hide-header "newsgroups")))
1890 ((eq elem 'to-address)
1891 (let ((to (message-fetch-field "to"))
1893 (gnus-parameter-to-address
1894 (if (boundp 'gnus-newsgroup-name)
1895 gnus-newsgroup-name ""))))
1896 (when (and to to-address
1899 ;; only one address in To
1900 (nth 1 (mail-extract-address-components to))
1902 (gnus-article-hide-header "to"))))
1904 (let ((to (message-fetch-field "to"))
1906 (gnus-parameter-to-list
1907 (if (boundp 'gnus-newsgroup-name)
1908 gnus-newsgroup-name ""))))
1909 (when (and to to-list
1912 ;; only one address in To
1913 (nth 1 (mail-extract-address-components to))
1915 (gnus-article-hide-header "to"))))
1917 (let ((cc (message-fetch-field "cc"))
1919 (gnus-parameter-to-list
1920 (if (boundp 'gnus-newsgroup-name)
1921 gnus-newsgroup-name ""))))
1922 (when (and cc to-list
1925 ;; only one address in CC
1926 (nth 1 (mail-extract-address-components cc))
1928 (gnus-article-hide-header "cc"))))
1929 ((eq elem 'followup-to)
1930 (when (gnus-string-equal
1931 (message-fetch-field "followup-to")
1932 (message-fetch-field "newsgroups"))
1933 (gnus-article-hide-header "followup-to")))
1934 ((eq elem 'reply-to)
1935 (if (gnus-group-find-parameter
1936 gnus-newsgroup-name 'broken-reply-to)
1937 (gnus-article-hide-header "reply-to")
1938 (let ((from (message-fetch-field "from"))
1939 (reply-to (message-fetch-field "reply-to")))
1946 (lambda (x) (downcase (cadr x)))
1947 (mail-extract-address-components from t))
1950 (lambda (x) (downcase (cadr x)))
1951 (mail-extract-address-components reply-to t))
1953 (gnus-article-hide-header "reply-to")))))
1955 (let ((date (message-fetch-field "date")))
1957 (< (days-between (current-time-string) date)
1959 (gnus-article-hide-header "date"))))
1961 (let ((to (message-fetch-field "to"))
1962 (cc (message-fetch-field "cc")))
1963 (when (> (length to) 1024)
1964 (gnus-article-hide-header "to"))
1965 (when (> (length cc) 1024)
1966 (gnus-article-hide-header "cc"))))
1970 (goto-char (point-min))
1971 (while (re-search-forward "^to:" nil t)
1972 (setq to-count (1+ to-count)))
1973 (when (> to-count 1)
1974 (while (> to-count 0)
1975 (goto-char (point-min))
1977 (re-search-forward "^to:" nil nil to-count)
1979 (narrow-to-region (point) (point-max))
1980 (gnus-article-hide-header "to"))
1981 (setq to-count (1- to-count))))
1982 (goto-char (point-min))
1983 (while (re-search-forward "^cc:" nil t)
1984 (setq cc-count (1+ cc-count)))
1985 (when (> cc-count 1)
1986 (while (> cc-count 0)
1987 (goto-char (point-min))
1989 (re-search-forward "^cc:" nil nil cc-count)
1991 (narrow-to-region (point) (point-max))
1992 (gnus-article-hide-header "cc"))
1993 (setq cc-count (1- cc-count)))))))))))))
1995 (defun gnus-article-hide-header (header)
1997 (goto-char (point-min))
1998 (when (re-search-forward (concat "^" header ":") nil t)
1999 (gnus-article-hide-text-type
2003 (if (re-search-forward "^[^ \t]" nil t)
2008 (defvar gnus-article-normalized-header-length 40
2009 "Length of normalized headers.")
2011 (defun article-normalize-headers ()
2012 "Make all header lines 40 characters long."
2014 (let ((inhibit-read-only t)
2018 (article-narrow-to-head)
2021 ((< (setq column (- (point-at-eol) (point)))
2022 gnus-article-normalized-header-length)
2024 (insert (make-string
2025 (- gnus-article-normalized-header-length column)
2027 ((> column gnus-article-normalized-header-length)
2028 (gnus-put-text-property
2030 (forward-char gnus-article-normalized-header-length)
2037 (forward-line 1))))))
2039 (defun article-treat-dumbquotes ()
2040 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
2041 Note that this function guesses whether a character is a sm*rtq**t* or
2042 not, so it should only be used interactively.
2044 Sm*rtq**t*s are M****s***'s unilateral extension to the
2045 iso-8859-1 character map in an attempt to provide more quoting
2046 characters. If you see something like \\222 or \\264 where
2047 you're expecting some kind of apostrophe or quotation mark, then
2050 (article-translate-strings gnus-article-dumbquotes-map))
2052 (defun article-translate-characters (from to)
2053 "Translate all characters in the body of the article according to FROM and TO.
2054 FROM is a string of characters to translate from; to is a string of
2055 characters to translate to."
2057 (when (article-goto-body)
2058 (let ((inhibit-read-only t)
2059 (x (make-string 225 ?x))
2061 (while (< (incf i) (length x))
2064 (while (< i (length from))
2065 (aset x (aref from i) (aref to i))
2067 (translate-region (point) (point-max) x)))))
2069 (defun article-translate-strings (map)
2070 "Translate all string in the body of the article according to MAP.
2071 MAP is an alist where the elements are on the form (\"from\" \"to\")."
2073 (when (article-goto-body)
2074 (let ((inhibit-read-only t))
2077 (while (search-forward (car elem) nil t)
2078 (replace-match (cadr elem)))))))))
2080 (defun article-treat-overstrike ()
2081 "Translate overstrikes into bold text."
2084 (when (article-goto-body)
2085 (let ((inhibit-read-only t))
2086 (while (search-forward "\b" nil t)
2087 (let ((next (char-after))
2091 previous (char-after))
2095 ;; We do the boldification/underlining by hiding the
2096 ;; overstrikes and putting the proper text property
2100 (gnus-article-hide-text-type start (point) 'overstrike)
2101 (put-text-property (point) end 'face 'bold))
2103 (gnus-article-hide-text-type
2104 (1- (point)) (1+ (point)) 'overstrike)
2106 start (1- (point)) 'face 'underline))
2108 (gnus-article-hide-text-type start (point) 'overstrike)
2110 (point) end 'face 'underline)))))))))
2112 (defun article-treat-ansi-sequences ()
2113 "Translate ANSI SGR control sequences into overlays or extents."
2116 (when (article-goto-body)
2117 (let ((inhibit-read-only t))
2118 (ansi-color-apply-on-region (point) (point-max))))))
2120 (defun gnus-article-treat-unfold-headers ()
2121 "Unfold folded message headers.
2122 Only the headers that fit into the current window width will be
2125 (gnus-with-article-headers
2129 (mail-header-narrow-to-field)
2130 (let ((header (buffer-string)))
2133 (goto-char (point-min))
2134 (while (re-search-forward "\n[\t ]" nil t)
2135 (replace-match " " t t)))
2136 (setq length (- (point-max) (point-min) 1)))
2137 (when (< length (window-width))
2138 (while (re-search-forward "\n[\t ]" nil t)
2139 (replace-match " " t t)))
2140 (goto-char (point-max)))))))
2142 (defun gnus-article-treat-fold-headers ()
2143 "Fold message headers."
2145 (gnus-with-article-headers
2148 (mail-header-narrow-to-field)
2149 (mail-header-fold-field)
2150 (goto-char (point-max))))))
2152 (defun gnus-treat-smiley ()
2153 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2155 (unless (featurep 'xemacs)
2156 (when (and (not gnus-article-should-use-smiley-mule)
2157 gnus-article-smiley-mule-loaded-p)
2158 (load "smiley" nil t)
2159 (setq gnus-article-smiley-mule-loaded-p nil))
2160 (when (and gnus-article-should-use-smiley-mule
2161 (not gnus-article-smiley-mule-loaded-p))
2162 (load "smiley-mule" nil t)
2163 (setq gnus-article-smiley-mule-loaded-p t)))
2164 (gnus-with-article-buffer
2165 (if (memq 'smiley gnus-article-wash-types)
2166 (gnus-delete-images 'smiley)
2168 (let ((images (smiley-region (point) (point-max))))
2170 (gnus-add-wash-type 'smiley)
2171 (dolist (image images)
2172 (gnus-add-image 'smiley image)))))))
2174 (defun gnus-article-remove-images ()
2175 "Remove all images from the article buffer."
2177 (gnus-with-article-buffer
2178 (dolist (elem gnus-article-image-alist)
2179 (gnus-delete-images (car elem)))))
2181 (defun gnus-article-treat-fold-newsgroups ()
2182 "Unfold folded message headers.
2183 Only the headers that fit into the current window width will be
2186 (gnus-with-article-headers
2187 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2189 (mail-header-narrow-to-field)
2190 (while (re-search-forward ", *" nil t)
2191 (replace-match ", " t t))
2192 (mail-header-fold-field)
2193 (goto-char (point-max))))))
2195 (defun gnus-article-treat-body-boundary ()
2196 "Place a boundary line at the end of the headers."
2198 (when (and gnus-body-boundary-delimiter
2199 (> (length gnus-body-boundary-delimiter) 0))
2200 (gnus-with-article-headers
2201 (goto-char (point-max))
2202 (let ((start (point)))
2203 (insert "X-Boundary: ")
2204 (gnus-add-text-properties start (point) '(invisible t intangible t))
2206 (while (>= (1- (window-width)) (length str))
2207 (setq str (concat str gnus-body-boundary-delimiter)))
2208 (substring str 0 (1- (window-width))))
2210 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2212 (defun article-fill-long-lines ()
2213 "Fill lines that are wider than the window width."
2216 (let ((inhibit-read-only t)
2217 (width (window-width (get-buffer-window (current-buffer)))))
2220 (let ((adaptive-fill-mode nil)) ;Why? -sm
2223 (when (>= (current-column) (min fill-column width))
2224 (narrow-to-region (min (1+ (point)) (point-max))
2226 (let ((goback (point-marker)))
2227 (fill-paragraph nil)
2228 (goto-char (marker-position goback)))
2230 (forward-line 1)))))))
2232 (defun article-capitalize-sentences ()
2233 "Capitalize the first word in each sentence."
2236 (let ((inhibit-read-only t)
2237 (paragraph-start "^[\n\^L]"))
2241 (forward-sentence)))))
2243 (defun article-remove-cr ()
2244 "Remove trailing CRs and then translate remaining CRs into LFs."
2247 (let ((inhibit-read-only t))
2248 (goto-char (point-min))
2249 (while (re-search-forward "\r+$" nil t)
2250 (replace-match "" t t))
2251 (goto-char (point-min))
2252 (while (search-forward "\r" nil t)
2253 (replace-match "\n" t t)))))
2255 (defun article-remove-trailing-blank-lines ()
2256 "Remove all trailing blank lines from the article."
2259 (let ((inhibit-read-only t))
2260 (goto-char (point-max))
2264 (while (and (not (bobp))
2265 (looking-at "^[ \t]*$")
2266 (not (gnus-annotation-in-region-p
2267 (point) (point-at-eol))))
2273 (defvar gnus-face-properties-alist))
2275 (defun article-display-face ()
2276 "Display any Face headers in the header."
2278 (let ((wash-face-p buffer-read-only))
2279 (gnus-with-article-headers
2280 ;; When displaying parts, this function can be called several times on
2281 ;; the same article, without any intended toggle semantic (as typing `W
2282 ;; D d' would have). So face deletion must occur only when we come from
2283 ;; an interactive command, that is when the *Article* buffer is
2285 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2286 (gnus-delete-images 'face)
2287 (let (face faces from)
2288 (save-current-buffer
2289 (when (and wash-face-p
2290 (gnus-buffer-live-p gnus-original-article-buffer)
2291 (not (re-search-forward "^Face:[\t ]*" nil t)))
2292 (set-buffer gnus-original-article-buffer))
2294 (mail-narrow-to-head)
2295 (while (gnus-article-goto-header "Face")
2296 (push (mail-header-field-value) faces))))
2298 (goto-char (point-min))
2299 (let ((from (gnus-article-goto-header "from"))
2304 (insert "[no `from' set]\n"))
2306 (when (setq png (gnus-convert-face-to-png (pop faces)))
2308 (apply 'gnus-create-image png 'png t
2309 (cdr (assq 'png gnus-face-properties-alist))))
2311 (gnus-add-wash-type 'face)
2312 (gnus-add-image 'face image)
2313 (gnus-put-image image nil 'face))))))))))
2315 (defun article-display-x-face (&optional force)
2316 "Look for an X-Face header and display it if present."
2317 (interactive (list 'force))
2318 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2319 (gnus-with-article-headers
2320 ;; Delete the old process, if any.
2321 (when (process-status "article-x-face")
2322 (delete-process "article-x-face"))
2323 ;; See the comment in `article-display-face'.
2324 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2325 ;; We have already displayed X-Faces, so we remove them
2327 (gnus-delete-images 'xface)
2329 (let (x-faces from face)
2330 (save-current-buffer
2331 (when (and wash-face-p
2332 (gnus-buffer-live-p gnus-original-article-buffer)
2333 (not (re-search-forward "^X-Face:[\t ]*" nil t)))
2334 ;; If type `W f', use gnus-original-article-buffer,
2335 ;; otherwise use the current buffer because displaying
2336 ;; RFC822 parts calls this function too.
2337 (set-buffer gnus-original-article-buffer))
2339 (mail-narrow-to-head)
2340 (while (gnus-article-goto-header "X-Face")
2341 (push (mail-header-field-value) x-faces))
2342 (setq from (message-fetch-field "from"))))
2343 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2344 ;; single external face.
2345 (when (stringp gnus-article-x-face-command)
2346 (setq x-faces (list (car x-faces))))
2348 gnus-article-x-face-command
2350 ;; Check whether this face is censored.
2351 (not gnus-article-x-face-too-ugly)
2353 (not (string-match gnus-article-x-face-too-ugly
2355 (while (setq face (pop x-faces))
2356 ;; We display the face.
2357 (cond ((stringp gnus-article-x-face-command)
2358 ;; The command is a string, so we interpret the command
2359 ;; as a, well, command, and fork it off.
2360 (let ((process-connection-type nil))
2361 (gnus-set-process-query-on-exit-flag
2363 "article-x-face" nil shell-file-name
2364 shell-command-switch gnus-article-x-face-command)
2368 (process-send-region "article-x-face"
2369 (point-min) (point-max)))
2370 (process-send-eof "article-x-face")))
2371 ((functionp gnus-article-x-face-command)
2372 ;; The command is a lisp function, so we call it.
2373 (funcall gnus-article-x-face-command face))
2375 (error "%s is not a function"
2376 gnus-article-x-face-command))))))))))
2378 (defun article-decode-mime-words ()
2379 "Decode all MIME-encoded words in the article."
2381 (gnus-with-article-buffer
2382 (let ((inhibit-point-motion-hooks t)
2383 (mail-parse-charset gnus-newsgroup-charset)
2384 (mail-parse-ignored-charsets
2385 (with-current-buffer gnus-summary-buffer
2386 gnus-newsgroup-ignored-charsets)))
2387 (mail-decode-encoded-word-region (point-min) (point-max)))))
2389 (defun article-decode-charset (&optional prompt)
2390 "Decode charset-encoded text in the article.
2391 If PROMPT (the prefix), prompt for a coding system to use."
2393 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2394 (inhibit-read-only t)
2395 (mail-parse-charset gnus-newsgroup-charset)
2396 (mail-parse-ignored-charsets
2397 (save-excursion (condition-case nil
2398 (set-buffer gnus-summary-buffer)
2400 gnus-newsgroup-ignored-charsets))
2401 ct cte ctl charset format)
2404 (article-narrow-to-head)
2405 (setq ct (message-fetch-field "Content-Type" t)
2406 cte (message-fetch-field "Content-Transfer-Encoding" t)
2407 ctl (and ct (ignore-errors
2408 (mail-header-parse-content-type ct)))
2411 (mm-read-coding-system "Charset to decode: "))
2413 (mail-content-type-get ctl 'charset)))
2414 format (and ctl (mail-content-type-get ctl 'format)))
2416 (setq cte (mail-header-strip cte)))
2417 (if (and ctl (not (string-match "/" (car ctl))))
2419 (goto-char (point-max)))
2422 (narrow-to-region (point) (point-max))
2423 (when (and (eq mail-parse-charset 'gnus-decoded)
2424 (eq (mm-body-7-or-8) '8bit))
2425 ;; The text code could have been decoded.
2426 (setq charset mail-parse-charset))
2427 (when (and (or (not ctl)
2428 (equal (car ctl) "text/plain"))
2429 (not format)) ;; article with format will decode later.
2431 charset (and cte (intern (downcase
2432 (gnus-strip-whitespace cte))))
2435 (defun article-decode-encoded-words ()
2436 "Remove encoded-word encoding from headers."
2437 (let ((charset (save-excursion
2438 (set-buffer gnus-summary-buffer)
2439 default-mime-charset))
2440 (inhibit-read-only t))
2441 (mime-decode-header-in-buffer charset)))
2443 (defun article-decode-group-name ()
2444 "Decode group names in `Newsgroups:'."
2445 (let ((inhibit-point-motion-hooks t)
2446 (inhibit-read-only t)
2447 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2448 (when (and (or gnus-group-name-charset-method-alist
2449 gnus-group-name-charset-group-alist)
2450 (gnus-buffer-live-p gnus-original-article-buffer))
2452 (article-narrow-to-head)
2453 (with-current-buffer gnus-original-article-buffer
2454 (goto-char (point-min)))
2455 (while (re-search-forward
2456 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2457 (replace-match (save-match-data
2458 (gnus-decode-newsgroups
2459 ;; XXX how to use data in article buffer?
2460 (with-current-buffer gnus-original-article-buffer
2462 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2465 gnus-newsgroup-name method))
2467 (goto-char (point-min))
2468 (with-current-buffer gnus-original-article-buffer
2469 (goto-char (point-min)))
2470 (while (re-search-forward
2471 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2472 (replace-match (save-match-data
2473 (gnus-decode-newsgroups
2474 ;; XXX how to use data in article buffer?
2475 (with-current-buffer gnus-original-article-buffer
2477 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2480 gnus-newsgroup-name method))
2483 (autoload 'idna-to-unicode "idna")
2485 (defun article-decode-idna-rhs ()
2486 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2489 (let ((inhibit-point-motion-hooks t)
2490 (inhibit-read-only t))
2491 (article-narrow-to-head)
2492 (goto-char (point-min))
2493 (while (re-search-forward "@.*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2495 (when (save-match-data
2496 (and (setq ace (match-string 1))
2498 (and (re-search-backward "^[^ \t]" nil t)
2499 (looking-at "From\\|To\\|Cc")))
2500 (setq unicode (idna-to-unicode ace))))
2501 (unless (string= ace unicode)
2502 (replace-match unicode nil nil nil 1)))))))))
2504 (defun article-de-quoted-unreadable (&optional force read-charset)
2505 "Translate a quoted-printable-encoded article.
2506 If FORCE, decode the article whether it is marked as quoted-printable
2508 If READ-CHARSET, ask for a coding system."
2509 (interactive (list 'force current-prefix-arg))
2511 (let ((inhibit-read-only t) type charset)
2512 (if (gnus-buffer-live-p gnus-original-article-buffer)
2513 (with-current-buffer gnus-original-article-buffer
2515 (gnus-fetch-field "content-transfer-encoding"))
2516 (let* ((ct (gnus-fetch-field "content-type"))
2519 (mail-header-parse-content-type ct)))))
2520 (setq charset (and ctl
2521 (mail-content-type-get ctl 'charset)))
2522 (if (stringp charset)
2523 (setq charset (intern (downcase charset)))))))
2525 (setq charset (mm-read-coding-system "Charset: " charset)))
2527 (setq charset gnus-newsgroup-charset))
2529 (and type (let ((case-fold-search t))
2530 (string-match "quoted-printable" type))))
2532 (quoted-printable-decode-region
2533 (point) (point-max) (mm-charset-to-coding-system charset))))))
2535 (defun article-de-base64-unreadable (&optional force read-charset)
2536 "Translate a base64 article.
2537 If FORCE, decode the article whether it is marked as base64 not.
2538 If READ-CHARSET, ask for a coding system."
2539 (interactive (list 'force current-prefix-arg))
2541 (let ((inhibit-read-only t) type charset)
2542 (if (gnus-buffer-live-p gnus-original-article-buffer)
2543 (with-current-buffer gnus-original-article-buffer
2545 (gnus-fetch-field "content-transfer-encoding"))
2546 (let* ((ct (gnus-fetch-field "content-type"))
2549 (mail-header-parse-content-type ct)))))
2550 (setq charset (and ctl
2551 (mail-content-type-get ctl 'charset)))
2552 (if (stringp charset)
2553 (setq charset (intern (downcase charset)))))))
2555 (setq charset (mm-read-coding-system "Charset: " charset)))
2557 (setq charset gnus-newsgroup-charset))
2559 (and type (let ((case-fold-search t))
2560 (string-match "base64" type))))
2563 (narrow-to-region (point) (point-max))
2564 (base64-decode-region (point-min) (point-max))
2565 (mm-decode-coding-region
2566 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2571 (defun article-decode-HZ ()
2572 "Translate a HZ-encoded article."
2576 (let ((inhibit-read-only t))
2577 (rfc1843-decode-region (point-min) (point-max)))))
2579 (defun article-unsplit-urls ()
2580 "Remove the newlines that some other mailers insert into URLs."
2583 (let ((inhibit-read-only t))
2584 (goto-char (point-min))
2585 (while (re-search-forward
2586 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2587 (replace-match "\\1\\3" t)))
2588 (when (interactive-p)
2589 (gnus-treat-article nil))))
2592 (defun article-wash-html (&optional read-charset)
2593 "Format an HTML article.
2594 If READ-CHARSET, ask for a coding system."
2597 (let ((inhibit-read-only t)
2599 (when (gnus-buffer-live-p gnus-original-article-buffer)
2600 (with-current-buffer gnus-original-article-buffer
2601 (let* ((ct (gnus-fetch-field "content-type"))
2604 (mail-header-parse-content-type ct)))))
2605 (setq charset (and ctl
2606 (mail-content-type-get ctl 'charset)))
2607 (when (stringp charset)
2608 (setq charset (intern (downcase charset)))))))
2610 (setq charset (mm-read-coding-system "Charset: " charset)))
2612 (setq charset gnus-newsgroup-charset))
2614 (save-window-excursion
2616 (narrow-to-region (point) (point-max))
2617 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2618 (entry (assq func mm-text-html-washer-alist)))
2620 (setq func (cdr entry)))
2625 (apply (car func) (cdr func))))))))))
2627 (defun gnus-article-wash-html-with-w3 ()
2628 "Wash the current buffer with w3."
2630 (let ((w3-strict-width (window-width))
2631 (url-standalone-mode t)
2632 (url-gateway-unplugged t)
2633 (w3-honor-stylesheets nil))
2635 (w3-region (point-min) (point-max))
2638 (defun gnus-article-wash-html-with-w3m ()
2639 "Wash the current buffer with emacs-w3m."
2642 (narrow-to-region (point) (point-max))
2643 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2644 w3m-force-redisplay)
2645 (w3m-region (point-min) (point-max)))
2646 (when (and mm-inline-text-html-with-w3m-keymap
2647 (boundp 'w3m-minor-mode-map)
2649 (add-text-properties
2650 (point-min) (point-max)
2651 (list 'keymap w3m-minor-mode-map
2652 ;; Put the mark meaning this part was rendered by emacs-w3m.
2653 'mm-inline-text-html-with-w3m t)))))
2655 (defun article-hide-list-identifiers ()
2656 "Remove list identifies from the Subject header.
2657 The `gnus-list-identifiers' variable specifies what to do."
2659 (let ((inhibit-point-motion-hooks t)
2660 (regexp (if (consp gnus-list-identifiers)
2661 (mapconcat 'identity gnus-list-identifiers " *\\|")
2662 gnus-list-identifiers))
2663 (inhibit-read-only t))
2667 (article-narrow-to-head)
2668 (goto-char (point-min))
2669 (while (re-search-forward
2670 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2672 (delete-region (match-beginning 2) (match-end 0))
2673 (beginning-of-line))
2674 (when (re-search-forward
2675 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2676 (delete-region (match-beginning 1) (match-end 1))))))))
2678 (defun article-hide-pem (&optional arg)
2679 "Toggle hiding of any PEM headers and signatures in the current article.
2680 If given a negative prefix, always show; if given a positive prefix,
2682 (interactive (gnus-article-hidden-arg))
2683 (unless (gnus-article-check-hidden-text 'pem arg)
2685 (let ((inhibit-read-only t) end)
2686 (goto-char (point-min))
2687 ;; Hide the horrendously ugly "header".
2688 (when (and (search-forward
2689 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2691 (setq end (1+ (match-beginning 0))))
2692 (gnus-add-wash-type 'pem)
2693 (gnus-article-hide-text-type
2695 (if (search-forward "\n\n" nil t)
2699 ;; Hide the trailer as well
2700 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2702 (gnus-article-hide-text-type
2703 (match-beginning 0) (match-end 0) 'pem)))))))
2705 (defun article-strip-banner ()
2706 "Strip the banners specified by the `banner' group parameter and by
2707 `gnus-article-address-banner-alist'."
2711 (let ((inhibit-point-motion-hooks t))
2712 (when (gnus-parameter-banner gnus-newsgroup-name)
2713 (article-really-strip-banner
2714 (gnus-parameter-banner gnus-newsgroup-name)))
2715 (when gnus-article-address-banner-alist
2716 ;; It is necessary to encode from fields before checking,
2717 ;; because `mail-header-parse-addresses' does not work
2718 ;; (reliably) on decoded headers. And more, it is
2719 ;; impossible to use `gnus-fetch-original-field' here,
2720 ;; because `article-strip-banner' may be called in draft
2721 ;; buffers to preview them.
2722 (let ((from (save-restriction
2724 (article-narrow-to-head)
2725 (mail-fetch-field "from"))))
2728 (caar (mail-header-parse-addresses
2729 (mail-encode-encoded-word-string from)))))
2731 (dolist (pair gnus-article-address-banner-alist)
2732 (when (string-match (car pair) from)
2734 (article-really-strip-banner (cdr pair)))))))))))))
2736 (defun article-really-strip-banner (banner)
2737 "Strip the banner specified by the argument."
2740 (let ((inhibit-point-motion-hooks t)
2741 (gnus-signature-limit nil)
2742 (inhibit-read-only t))
2745 ((eq banner 'signature)
2746 (when (gnus-article-narrow-to-signature)
2749 (delete-region (point) (point-max))))
2751 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2752 (while (re-search-forward banner nil t)
2753 (delete-region (match-beginning 0) (match-end 0)))))
2755 (while (re-search-forward banner nil t)
2756 (delete-region (match-beginning 0) (match-end 0)))))))))
2758 (defun article-babel ()
2759 "Translate article using an online translation service."
2762 (gnus-with-article-buffer
2763 (when (article-goto-body)
2764 (let* ((start (point))
2766 (orig (buffer-substring start end))
2767 (trans (babel-as-string orig)))
2769 (narrow-to-region start end)
2770 (delete-region start end)
2773 (defun article-hide-signature (&optional arg)
2774 "Hide the signature in the current article.
2775 If given a negative prefix, always show; if given a positive prefix,
2777 (interactive (gnus-article-hidden-arg))
2783 (article-goto-body))
2784 (goto-char (point-min)))
2785 (unless (gnus-article-check-hidden-text 'signature arg)
2786 (let ((inhibit-read-only t)
2788 (while (setq button (text-property-any button (point-max)
2790 'gnus-signature-toggle))
2791 (setq button (text-property-not-all button (point-max)
2793 'gnus-signature-toggle))
2794 (when (and button (not (eobp)))
2795 (gnus-article-hide-text-type
2797 (next-single-property-change (1+ button) 'mime-view-entity
2800 (gnus-set-mode-line 'article))
2802 (defun article-strip-headers-in-body ()
2803 "Strip offensive headers from bodies."
2807 (let ((case-fold-search t))
2808 (when (looking-at "x-no-archive:")
2809 (gnus-delete-line)))))
2811 (defun article-strip-leading-blank-lines ()
2812 "Remove all blank lines from the beginning of the article."
2815 (let ((inhibit-point-motion-hooks t)
2816 (inhibit-read-only t))
2817 (when (article-goto-body)
2818 (while (and (not (eobp))
2819 (looking-at "[ \t]*$"))
2820 (gnus-delete-line))))))
2822 (defun article-narrow-to-head ()
2823 "Narrow the buffer to the head of the message.
2824 Point is left at the beginning of the narrowed-to region."
2826 (goto-char (point-min))
2827 (if (search-forward "\n\n" nil 1)
2830 (goto-char (point-min)))
2832 (defun article-goto-body ()
2833 "Place point at the start of the body."
2834 (goto-char (point-min))
2836 ;; This variable is only bound when dealing with separate
2838 (article-goto-body-goes-to-point-min-p
2840 ((search-forward "\n\n" nil t)
2843 (goto-char (point-max))
2846 (defun article-strip-multiple-blank-lines ()
2847 "Replace consecutive blank lines with one empty line."
2850 (let ((inhibit-point-motion-hooks t)
2851 (inhibit-read-only t))
2852 ;; First make all blank lines empty.
2854 (while (re-search-forward "^[ \t]+$" nil t)
2855 (unless (gnus-annotation-in-region-p
2856 (match-beginning 0) (match-end 0))
2857 (replace-match "" nil t)))
2858 ;; Then replace multiple empty lines with a single empty line.
2860 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2861 (unless (gnus-annotation-in-region-p
2862 (match-beginning 0) (match-end 0))
2863 (delete-region (match-beginning 1) (match-end 1)))))))
2865 (defun article-strip-leading-space ()
2866 "Remove all white space from the beginning of the lines in the article."
2869 (let ((inhibit-point-motion-hooks t)
2870 (inhibit-read-only t))
2872 (while (re-search-forward "^[ \t]+" nil t)
2873 (replace-match "" t t)))))
2875 (defun article-strip-trailing-space ()
2876 "Remove all white space from the end of the lines in the article."
2879 (let ((inhibit-point-motion-hooks t)
2880 (inhibit-read-only t))
2882 (while (re-search-forward "[ \t]+$" nil t)
2883 (replace-match "" t t)))))
2885 (defun article-strip-blank-lines ()
2886 "Strip leading, trailing and multiple blank lines."
2888 (article-strip-leading-blank-lines)
2889 (article-remove-trailing-blank-lines)
2890 (article-strip-multiple-blank-lines))
2892 (defun article-strip-all-blank-lines ()
2893 "Strip all blank lines."
2896 (let ((inhibit-point-motion-hooks t)
2897 (inhibit-read-only t))
2899 (while (re-search-forward "^[ \t]*\n" nil t)
2900 (replace-match "" t t)))))
2902 (defun gnus-article-narrow-to-signature ()
2903 "Narrow to the signature; return t if a signature is found, else nil."
2904 (let ((inhibit-point-motion-hooks t))
2905 (when (gnus-article-search-signature)
2907 ;; Check whether we have some limits to what we consider
2908 ;; to be a signature.
2909 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2910 (list gnus-signature-limit)))
2912 (while (setq limit (pop limits))
2913 (if (or (and (integerp limit)
2914 (< (- (point-max) (point)) limit))
2916 (< (count-lines (point) (point-max)) limit))
2917 (and (functionp limit)
2919 (and (stringp limit)
2920 (not (re-search-forward limit nil t))))
2921 () ; This limit did not succeed.
2925 (narrow-to-region (point) (point-max))
2928 (defun gnus-article-search-signature ()
2929 "Search the current buffer for the signature separator.
2930 Put point at the beginning of the signature separator."
2931 (let ((cur (point)))
2932 (goto-char (point-max))
2933 (if (if (stringp gnus-signature-separator)
2934 (re-search-backward gnus-signature-separator nil t)
2935 (let ((seps gnus-signature-separator))
2937 (not (re-search-backward (car seps) nil t)))
2944 (defun gnus-article-hidden-arg ()
2945 "Return the current prefix arg as a number, or 0 if no prefix."
2946 (list (if current-prefix-arg
2947 (prefix-numeric-value current-prefix-arg)
2950 (defun gnus-article-check-hidden-text (type arg)
2951 "Return nil if hiding is necessary.
2952 Arg can be nil or a number. nil and positive means hide, negative
2953 means show, 0 means toggle."
2956 (let ((hide (gnus-article-hidden-text-p type)))
2962 (gnus-article-show-hidden-text type)
2965 (if (eq hide 'hidden)
2967 (gnus-article-show-hidden-text type)
2971 (defun gnus-article-hidden-text-p (type)
2972 "Say whether the current buffer contains hidden text of type TYPE."
2973 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2975 (not (get-text-property pos 'invisible))
2976 (not (get-text-property pos 'dummy-invisible)))
2978 (text-property-any (1+ pos) (point-max) 'article-type type)))
2983 (defun gnus-article-show-hidden-text (type &optional dummy)
2984 "Show all hidden text of type TYPE.
2985 Originally it is hide instead of DUMMY."
2986 (let ((inhibit-read-only t)
2987 (inhibit-point-motion-hooks t))
2988 (gnus-remove-text-properties-when
2990 (point-min) (point-max)
2991 (cons 'article-type (cons type
2992 gnus-hidden-properties)))
2993 (gnus-delete-wash-type type)))
2995 (defconst article-time-units
2996 `((year . ,(* 365.25 24 60 60))
2997 (week . ,(* 7 24 60 60))
2998 (day . ,(* 24 60 60))
3002 "Mapping from time units to seconds.")
3004 (defun gnus-article-forward-header ()
3005 "Move point to the start of the next header.
3006 If the current header is a continuation header, this can be several
3011 (if (looking-at "[ \t]+[^ \t]")
3015 (defun article-date-ut (&optional type highlight)
3016 "Convert DATE date to universal time in the current article.
3017 If TYPE is `local', convert to local time; if it is `lapsed', output
3018 how much time has lapsed since DATE. For `lapsed', the value of
3019 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
3020 should replace the \"Date:\" one, or should be added below it."
3021 (interactive (list 'ut t))
3022 (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
3023 (date-regexp (cond ((not gnus-article-date-lapsed-new-header)
3027 (article-lapsed-timer
3031 (case-fold-search t)
3032 (inhibit-read-only t)
3033 (inhibit-point-motion-hooks t)
3034 pos date bface eface)
3038 (goto-char (point-min))
3039 (while (or (setq date (get-text-property (setq pos (point))
3041 (when (setq pos (next-single-property-change
3042 (point) 'original-date))
3043 (setq date (get-text-property pos 'original-date))
3045 (narrow-to-region pos (or (text-property-any pos (point-max)
3048 (goto-char (point-min))
3049 (when (re-search-forward tdate-regexp nil t)
3050 (setq bface (get-text-property (point-at-bol) 'face)
3051 eface (get-text-property (1- (point-at-eol)) 'face)))
3052 (goto-char (point-min))
3054 ;; Delete any old Date headers.
3055 (while (re-search-forward date-regexp nil t)
3057 (delete-region (point-at-bol) (progn
3058 (gnus-article-forward-header)
3060 (delete-region (point-at-bol) (progn
3061 (gnus-article-forward-header)
3064 (setq pos (point))))
3065 (when (and (not pos)
3066 (re-search-forward tdate-regexp nil t))
3068 (gnus-goto-char pos)
3069 (insert (article-make-date-line date (or type 'ut)))
3075 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
3076 (put-text-property (match-beginning 1) (1+ (match-end 1))
3078 (put-text-property (match-beginning 2) (match-end 2)
3080 (put-text-property (point-min) (1- (point-max)) 'original-date date)
3081 (goto-char (point-max))
3084 (defun article-make-date-line (date type)
3085 "Return a DATE line of TYPE."
3086 (unless (memq type '(local ut original user iso8601 lapsed english))
3087 (error "Unknown conversion type: %s" type))
3089 (let ((time (date-to-time date)))
3091 ;; Convert to the local timezone.
3093 (concat "Date: " (message-make-date time)))
3094 ;; Convert to Universal Time.
3099 (let* ((e (parse-time-string date))
3100 (tm (apply 'encode-time e))
3102 (ls (- (cadr tm) (car (current-time-zone time)))))
3103 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
3104 ((> ls 65535) (list (1+ ms) (- ls 65536)))
3108 ;; Get the original date from the article.
3109 ((eq type 'original)
3110 (concat "Date: " (if (string-match "\n+$" date)
3111 (substring date 0 (match-beginning 0))
3113 ;; Let the user define the format.
3115 (let ((format (or (condition-case nil
3116 (with-current-buffer gnus-summary-buffer
3117 gnus-article-time-format)
3119 gnus-article-time-format)))
3120 (if (functionp format)
3121 (funcall format time)
3122 (concat "Date: " (format-time-string format time)))))
3125 (let ((tz (car (current-time-zone time))))
3128 (format-time-string "%Y%m%dT%H%M%S" time)
3129 (format "%s%02d%02d"
3130 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3131 (/ (% (abs tz) 3600) 60)))))
3132 ;; Do an X-Sent lapsed format.
3134 ;; If the date is seriously mangled, the timezone functions are
3135 ;; liable to bug out, so we ignore all errors.
3136 (let* ((now (current-time))
3137 (real-time (subtract-time now time))
3138 (real-sec (and real-time
3139 (+ (* (float (car real-time)) 65536)
3141 (sec (and real-time (abs real-sec)))
3151 ;; This is a bit convoluted, but basically we go
3152 ;; through the time units for years, weeks, etc,
3153 ;; and divide things to see whether that results
3154 ;; in positive answers.
3157 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3158 ;; The (remaining) seconds are too few to
3159 ;; be divided into this time unit.
3161 ;; It's big enough, so we output it.
3162 (setq sec (- sec (* num (cdr unit))))
3164 (concat (if prev ", " "") (int-to-string
3166 " " (symbol-name (car unit))
3167 (if (> num 1) "s" ""))
3169 article-time-units "")
3170 ;; If dates are odd, then it might appear like the
3171 ;; article was sent in the future.
3174 " in the future"))))))
3175 ;; Display the date in proper English
3177 (let ((dtime (decode-time time)))
3180 (number-to-string (nth 3 dtime))
3181 (let ((digit (% (nth 3 dtime) 10)))
3183 ((memq (nth 3 dtime) '(11 12 13)) "th")
3189 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3191 (number-to-string (nth 5 dtime))
3193 (format "%02d" (nth 2 dtime))
3195 (format "%02d" (nth 1 dtime)))))))
3197 (format "Date: %s (from T-gnus)" date))))
3199 (defun article-date-local (&optional highlight)
3200 "Convert the current article date to the local timezone."
3201 (interactive (list t))
3202 (article-date-ut 'local highlight))
3204 (defun article-date-english (&optional highlight)
3205 "Convert the current article date to something that is proper English."
3206 (interactive (list t))
3207 (article-date-ut 'english highlight))
3209 (defun article-date-original (&optional highlight)
3210 "Convert the current article date to what it was originally.
3211 This is only useful if you have used some other date conversion
3212 function and want to see what the date was before converting."
3213 (interactive (list t))
3214 (article-date-ut 'original highlight))
3216 (defun article-date-lapsed (&optional highlight)
3217 "Convert the current article date to time lapsed since it was sent."
3218 (interactive (list t))
3219 (article-date-ut 'lapsed highlight))
3221 (defun article-update-date-lapsed ()
3222 "Function to be run from a timer to update the lapsed time line."
3224 (let (deactivate-mark)
3229 (set-buffer (window-buffer w))
3230 (when (or (and (eq major-mode 'mime-view-mode)
3231 (eq (mime-preview-original-major-mode)
3232 'gnus-original-article-mode))
3233 (eq major-mode 'gnus-article-mode))
3234 (let ((mark (point-marker)))
3235 (goto-char (point-min))
3236 (when (re-search-forward "^X-Sent:" nil t)
3237 (article-date-lapsed t))
3238 (goto-char (marker-position mark))
3239 (move-marker mark nil))))
3242 (defun gnus-start-date-timer (&optional n)
3243 "Start a timer to update the X-Sent header in the article buffers.
3244 The numerical prefix says how frequently (in seconds) the function
3249 (gnus-stop-date-timer)
3250 (setq article-lapsed-timer
3251 (run-at-time 1 n 'article-update-date-lapsed)))
3253 (defun gnus-stop-date-timer ()
3254 "Stop the X-Sent timer."
3256 (when article-lapsed-timer
3257 (nnheader-cancel-timer article-lapsed-timer)
3258 (setq article-lapsed-timer nil)))
3260 (defun article-date-user (&optional highlight)
3261 "Convert the current article date to the user-defined format.
3262 This format is defined by the `gnus-article-time-format' variable."
3263 (interactive (list t))
3264 (article-date-ut 'user highlight))
3266 (defun article-date-iso8601 (&optional highlight)
3267 "Convert the current article date to ISO8601."
3268 (interactive (list t))
3269 (article-date-ut 'iso8601 highlight))
3271 (defmacro gnus-article-save-original-date (&rest forms)
3272 "Save the original date as a text property and evaluate FORMS."
3273 `(let* ((case-fold-search t)
3275 (goto-char (point-min))
3276 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3279 (date (when (and start
3280 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3282 (buffer-substring-no-properties start
3283 (match-beginning 0)))))
3284 (goto-char (point-max))
3285 (skip-chars-backward "\n")
3286 (put-text-property (point-min) (point) 'original-date date)
3288 (goto-char (point-max))
3289 (skip-chars-backward "\n")
3290 (put-text-property (point-min) (point) 'original-date date)))
3292 ;; (defun article-show-all ()
3293 ;; "Show all hidden text in the article buffer."
3297 ;; (let ((inhibit-read-only t))
3298 ;; (gnus-article-unhide-text (point-min) (point-max))
3299 ;; (gnus-remove-text-with-property 'gnus-prev)
3300 ;; (gnus-remove-text-with-property 'gnus-next))))
3302 (defun article-show-all-headers ()
3303 "Show all hidden headers in the article buffer."
3308 (article-narrow-to-head)
3309 (let ((inhibit-read-only t))
3310 (gnus-article-unhide-text (point-min) (point-max))))))
3312 (defun article-remove-leading-whitespace ()
3313 "Remove excessive whitespace from all headers."
3317 (let ((inhibit-read-only t))
3318 (article-narrow-to-head)
3319 (goto-char (point-min))
3320 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3321 (delete-region (match-beginning 1) (match-end 1)))))))
3323 (defun article-emphasize (&optional arg)
3324 "Emphasize text according to `gnus-emphasis-alist'."
3325 (interactive (gnus-article-hidden-arg))
3326 (unless (gnus-article-check-hidden-text 'emphasis arg)
3330 (with-current-buffer gnus-summary-buffer
3331 gnus-article-emphasis-alist)
3333 gnus-emphasis-alist))
3334 (inhibit-read-only t)
3335 (props (append '(article-type emphasis)
3336 gnus-hidden-properties))
3337 regexp elem beg invisible visible face)
3340 (while (setq elem (pop alist))
3342 (setq regexp (car elem)
3343 invisible (nth 1 elem)
3344 visible (nth 2 elem)
3346 (while (re-search-forward regexp nil t)
3347 (when (and (match-beginning visible) (match-beginning invisible))
3348 (gnus-article-hide-text
3349 (match-beginning invisible) (match-end invisible) props)
3350 (gnus-article-unhide-text-type
3351 (match-beginning visible) (match-end visible) 'emphasis)
3352 (gnus-put-overlay-excluding-newlines
3353 (match-beginning visible) (match-end visible) 'face face)
3354 (gnus-add-wash-type 'emphasis)
3355 (goto-char (match-end invisible)))))))))
3357 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3358 "Setup newsgroup emphasis alist."
3359 (unless gnus-article-emphasis-alist
3360 (let ((name (and gnus-newsgroup-name
3361 (gnus-group-real-name gnus-newsgroup-name))))
3362 (make-local-variable 'gnus-article-emphasis-alist)
3363 (setq gnus-article-emphasis-alist
3365 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3366 (while (setq elem (pop alist))
3367 (when (and name (string-match (car elem) name))
3369 highlight (copy-sequence (cdr elem)))))
3371 (copy-sequence highlight-words)
3372 (if gnus-newsgroup-name
3373 (copy-sequence (gnus-group-find-parameter
3374 gnus-newsgroup-name 'highlight-words t)))
3375 gnus-emphasis-alist)))))
3378 (defvar gnus-summary-article-menu)
3379 (defvar gnus-summary-post-menu))
3381 ;;; Saving functions.
3383 (defun gnus-article-save (save-buffer file &optional num)
3384 "Save the currently selected article."
3385 (unless gnus-save-all-headers
3386 ;; Remove headers according to `gnus-saved-headers'.
3387 (let ((gnus-visible-headers
3388 (or gnus-saved-headers gnus-visible-headers))
3389 (gnus-article-buffer save-buffer))
3391 (set-buffer save-buffer)
3392 (article-hide-headers 1 t))))
3393 (save-window-excursion
3394 (if (not gnus-default-article-saver)
3395 (error "No default saver is defined")
3396 ;; !!! Magic! The saving functions all save
3397 ;; `gnus-save-article-buffer' (or so they think), but we
3398 ;; bind that variable to our save-buffer.
3399 (set-buffer gnus-article-buffer)
3400 (let* ((gnus-save-article-buffer save-buffer)
3403 ((not gnus-prompt-before-saving) 'default)
3404 ((eq gnus-prompt-before-saving 'always) nil)
3406 (gnus-number-of-articles-to-be-saved
3407 (when (eq gnus-prompt-before-saving t)
3409 (set-buffer gnus-article-current-summary)
3410 (funcall gnus-default-article-saver filename)))))
3412 (defun gnus-read-save-file-name (prompt &optional filename
3413 function group headers variable)
3415 (funcall function group headers (symbol-value variable)))
3420 ((eq filename 'default)
3426 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3429 (if (and gnus-number-of-articles-to-be-saved
3430 (> gnus-number-of-articles-to-be-saved 1))
3431 (format "these %d articles"
3432 gnus-number-of-articles-to-be-saved)
3435 ;; Let the split methods have their say.
3437 ;; No split name was found.
3440 (concat prompt " (default "
3441 (file-name-nondirectory default-name) ") ")
3442 (file-name-directory default-name)
3444 ;; A single group name is returned.
3445 ((stringp split-name)
3447 (funcall function split-name headers
3448 (symbol-value variable)))
3450 (concat prompt " (default "
3451 (file-name-nondirectory default-name) ") ")
3452 (file-name-directory default-name)
3454 ;; A single split name was found
3455 ((= 1 (length split-name))
3456 (let* ((name (expand-file-name
3458 gnus-article-save-directory))
3459 (dir (cond ((file-directory-p name)
3460 (file-name-as-directory name))
3461 ((file-exists-p name) name)
3462 (t gnus-article-save-directory))))
3464 (concat prompt " (default " name ") ")
3466 ;; A list of splits was found.
3468 (setq split-name (nreverse split-name))
3470 (let ((file-name-history
3471 (nconc split-name file-name-history)))
3475 (concat prompt " (`M-p' for defaults) ")
3476 gnus-article-save-directory
3478 gnus-article-save-directory)))
3479 (car (push result file-name-history)))))))
3480 ;; Create the directory.
3481 (gnus-make-directory (file-name-directory file))
3482 ;; If we have read a directory, we append the default file name.
3483 (when (file-directory-p file)
3484 (setq file (expand-file-name (file-name-nondirectory
3486 (file-name-as-directory file))))
3487 ;; Possibly translate some characters.
3488 (nnheader-translate-file-chars file))))))
3489 (gnus-make-directory (file-name-directory result))
3490 (set variable result)))
3492 (defun gnus-article-archive-name (group)
3493 "Return the first instance of an \"Archive-name\" in the current buffer."
3494 (let ((case-fold-search t))
3495 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3496 (nnheader-concat gnus-article-save-directory
3497 (match-string 1)))))
3499 (defun gnus-article-nndoc-name (group)
3500 "If GROUP is an nndoc group, return the name of the parent group."
3501 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3502 (gnus-group-get-parameter group 'save-article-group)))
3504 (defun gnus-summary-save-in-rmail (&optional filename)
3505 "Append this article to Rmail file.
3506 Optional argument FILENAME specifies file name.
3507 Directory to save to is default to `gnus-article-save-directory'."
3508 (setq filename (gnus-read-save-file-name
3509 "Save %s in rmail file:" filename
3510 gnus-rmail-save-name gnus-newsgroup-name
3511 gnus-current-headers 'gnus-newsgroup-last-rmail))
3512 (gnus-eval-in-buffer-window gnus-save-article-buffer
3516 (gnus-output-to-rmail filename))))
3519 (defun gnus-summary-save-in-mail (&optional filename)
3520 "Append this article to Unix mail file.
3521 Optional argument FILENAME specifies file name.
3522 Directory to save to is default to `gnus-article-save-directory'."
3523 (setq filename (gnus-read-save-file-name
3524 "Save %s in Unix mail file:" filename
3525 gnus-mail-save-name gnus-newsgroup-name
3526 gnus-current-headers 'gnus-newsgroup-last-mail))
3527 (gnus-eval-in-buffer-window gnus-save-article-buffer
3531 (if (and (file-readable-p filename)
3532 (file-regular-p filename)
3533 (mail-file-babyl-p filename))
3534 (rmail-output-to-rmail-file filename t)
3535 (gnus-output-to-mail filename)))))
3538 (defun gnus-summary-save-in-file (&optional filename overwrite)
3539 "Append this article to file.
3540 Optional argument FILENAME specifies file name.
3541 Directory to save to is default to `gnus-article-save-directory'."
3542 (setq filename (gnus-read-save-file-name
3543 "Save %s in file:" filename
3544 gnus-file-save-name gnus-newsgroup-name
3545 gnus-current-headers 'gnus-newsgroup-last-file))
3546 (gnus-eval-in-buffer-window gnus-save-article-buffer
3550 (when (and overwrite
3551 (file-exists-p filename))
3552 (delete-file filename))
3553 (gnus-output-to-file filename))))
3556 (defun gnus-summary-write-to-file (&optional filename)
3557 "Write this article to a file, overwriting it if the file exists.
3558 Optional argument FILENAME specifies file name.
3559 The directory to save in defaults to `gnus-article-save-directory'."
3560 (gnus-summary-save-in-file nil t))
3562 (defun gnus-summary-save-body-in-file (&optional filename)
3563 "Append this article body to a file.
3564 Optional argument FILENAME specifies file name.
3565 The directory to save in defaults to `gnus-article-save-directory'."
3566 (setq filename (gnus-read-save-file-name
3567 "Save %s body in file:" filename
3568 gnus-file-save-name gnus-newsgroup-name
3569 gnus-current-headers 'gnus-newsgroup-last-file))
3570 (gnus-eval-in-buffer-window gnus-save-article-buffer
3574 (when (article-goto-body)
3575 (narrow-to-region (point) (point-max)))
3576 (gnus-output-to-file filename))))
3579 (defun gnus-summary-save-in-pipe (&optional command)
3580 "Pipe this article to subprocess."
3582 (cond ((and (eq command 'default)
3583 gnus-last-shell-command)
3584 gnus-last-shell-command)
3589 "Shell command on %s: "
3590 (if (and gnus-number-of-articles-to-be-saved
3591 (> gnus-number-of-articles-to-be-saved 1))
3592 (format "these %d articles"
3593 gnus-number-of-articles-to-be-saved)
3595 gnus-last-shell-command))))
3596 (when (string-equal command "")
3597 (if gnus-last-shell-command
3598 (setq command gnus-last-shell-command)
3599 (error "A command is required")))
3600 (gnus-eval-in-buffer-window gnus-article-buffer
3603 (shell-command-on-region (point-min) (point-max) command nil)))
3604 (setq gnus-last-shell-command command))
3606 (defun gnus-summary-pipe-to-muttprint (&optional command)
3607 "Pipe this article to muttprint."
3608 (setq command (read-string
3609 "Print using command: " gnus-summary-muttprint-program
3610 nil gnus-summary-muttprint-program))
3611 (gnus-summary-save-in-pipe command))
3613 ;;; Article file names when saving.
3615 (defun gnus-capitalize-newsgroup (newsgroup)
3616 "Capitalize NEWSGROUP name."
3617 (when (not (zerop (length newsgroup)))
3618 (concat (char-to-string (upcase (aref newsgroup 0)))
3619 (substring newsgroup 1))))
3621 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3622 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3623 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3624 Otherwise, it is like ~/News/news/group/num."
3627 (concat (if (gnus-use-long-file-name 'not-save)
3628 (gnus-capitalize-newsgroup newsgroup)
3629 (gnus-newsgroup-directory-form newsgroup))
3630 "/" (int-to-string (mail-header-number headers)))
3631 gnus-article-save-directory)))
3633 (string-equal (file-name-directory default)
3634 (file-name-directory last-file))
3635 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3637 (or last-file default))))
3639 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3640 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3641 If variable `gnus-use-long-file-name' is non-nil, it is
3642 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3645 (concat (if (gnus-use-long-file-name 'not-save)
3647 (gnus-newsgroup-directory-form newsgroup))
3648 "/" (int-to-string (mail-header-number headers)))
3649 gnus-article-save-directory)))
3651 (string-equal (file-name-directory default)
3652 (file-name-directory last-file))
3653 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3655 (or last-file default))))
3657 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3658 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3659 If variable `gnus-use-long-file-name' is non-nil, it is
3660 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3663 (if (gnus-use-long-file-name 'not-save)
3666 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3668 gnus-article-save-directory)))
3670 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3671 "Generate file name from sender."
3672 (let ((from (mail-header-from headers)))
3674 (if (and from (string-match "\\([^ <]+\\)@" from))
3675 (match-string 1 from)
3677 gnus-article-save-directory)))
3679 (defun article-verify-x-pgp-sig ()
3682 (if (gnus-buffer-live-p gnus-original-article-buffer)
3683 (let ((sig (with-current-buffer gnus-original-article-buffer
3684 (gnus-fetch-field "X-PGP-Sig")))
3688 (mml2015-clear-verify-function))
3690 (insert-buffer-substring gnus-original-article-buffer)
3691 (setq items (split-string sig))
3692 (message-narrow-to-head)
3693 (let ((inhibit-point-motion-hooks t)
3694 (case-fold-search t))
3695 ;; Don't verify multiple headers.
3696 (setq headers (mapconcat (lambda (header)
3698 (mail-fetch-field header)
3700 (split-string (nth 1 items) ",") "")))
3701 (delete-region (point-min) (point-max))
3702 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3703 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3708 (if (looking-at "^-")
3711 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3712 (insert "Version: " (car items) "\n\n")
3713 (insert (mapconcat 'identity (cddr items) "\n"))
3714 (insert "\n-----END PGP SIGNATURE-----\n")
3715 (let ((mm-security-handle (list (format "multipart/signed"))))
3716 (mml2015-clean-buffer)
3717 (let ((coding-system-for-write (or gnus-newsgroup-charset
3719 (funcall (mml2015-clear-verify-function)))
3721 (or (mm-handle-multipart-ctl-parameter
3722 mm-security-handle 'gnus-details)
3723 (mm-handle-multipart-ctl-parameter
3724 mm-security-handle 'gnus-info)))))
3726 (let ((inhibit-read-only t) bface eface)
3728 (message-narrow-to-head)
3729 (goto-char (point-max))
3731 (setq bface (get-text-property (point-at-bol) 'face)
3732 eface (get-text-property (1- (point-at-eol)) 'face))
3733 (message-remove-header "X-Gnus-PGP-Verify")
3734 (if (re-search-forward "^X-PGP-Sig:" nil t)
3736 (goto-char (point-max)))
3737 (narrow-to-region (point) (point))
3738 (insert "X-Gnus-PGP-Verify: " info "\n")
3739 (goto-char (point-min))
3742 (if (not (looking-at "^[ \t]"))
3746 (goto-char (point-min))
3747 (when (looking-at "\\([^:]+\\): *")
3748 (put-text-property (match-beginning 1) (1+ (match-end 1))
3750 (put-text-property (match-end 0) (point-max)
3751 'face eface)))))))))
3753 (defun article-verify-cancel-lock ()
3754 "Verify Cancel-Lock header."
3756 (if (gnus-buffer-live-p gnus-original-article-buffer)
3757 (canlock-verify gnus-original-article-buffer)))
3759 (defun article-monafy ()
3760 "Display body part with mona font."
3762 (unless (if (featurep 'xemacs)
3763 (find-face 'gnus-mona-face)
3764 (facep 'gnus-mona-face))
3765 (require 'navi2ch-mona)
3766 (set-face-font (make-face 'gnus-mona-face) navi2ch-mona-font))
3768 (let ((inhibit-read-only t))
3771 (gnus-make-overlay (point) (point-max))
3772 'face 'gnus-mona-face))))
3779 (setq afunc (car func)
3782 gfunc (intern (format "gnus-%s" func))))
3784 (when (fboundp afunc)
3785 `(lambda (&optional interactive &rest args)
3786 ,(documentation afunc t)
3787 (interactive (list t))
3789 (set-buffer gnus-article-buffer)
3791 (call-interactively ',afunc)
3792 (apply ',afunc args))))))))
3793 '(article-hide-headers
3794 article-verify-x-pgp-sig
3795 article-verify-cancel-lock
3797 article-hide-boring-headers
3798 article-treat-overstrike
3799 article-treat-ansi-sequences
3800 article-fill-long-lines
3801 article-capitalize-sentences
3803 article-remove-leading-whitespace
3804 article-display-x-face
3805 article-display-face
3806 article-de-quoted-unreadable
3807 article-de-base64-unreadable
3810 article-unsplit-urls
3811 article-hide-list-identifiers
3812 article-strip-banner
3815 article-hide-signature
3816 article-strip-headers-in-body
3817 article-remove-trailing-blank-lines
3818 article-strip-leading-blank-lines
3819 article-strip-multiple-blank-lines
3820 article-strip-leading-space
3821 article-strip-trailing-space
3822 article-strip-blank-lines
3823 article-strip-all-blank-lines
3825 article-date-english
3826 article-date-iso8601
3827 article-date-original
3829 article-decode-mime-words
3830 article-decode-charset
3831 article-decode-encoded-words
3835 article-treat-dumbquotes
3836 article-normalize-headers
3837 (article-show-all-headers . gnus-article-show-all-headers)
3838 ;; (article-show-all . gnus-article-show-all)
3842 ;;; Gnus article mode
3845 (put 'gnus-article-mode 'mode-class 'special)
3847 (gnus-define-keys gnus-article-mode-map
3848 " " gnus-article-goto-next-page
3849 "\177" gnus-article-goto-prev-page
3850 [delete] gnus-article-goto-prev-page
3851 [backspace] gnus-article-goto-prev-page
3852 "\C-c^" gnus-article-refer-article
3853 "h" gnus-article-show-summary
3854 "s" gnus-article-show-summary
3855 "\C-c\C-m" gnus-article-mail
3856 "?" gnus-article-describe-briefly
3857 "e" gnus-summary-edit-article
3858 "<" beginning-of-buffer
3860 "\C-c\C-i" gnus-info-find-node
3862 "R" gnus-article-reply-with-original
3863 "F" gnus-article-followup-with-original
3864 "\C-hk" gnus-article-describe-key
3865 "\C-hc" gnus-article-describe-key-briefly
3867 "\C-d" gnus-article-read-summary-keys
3868 "\M-*" gnus-article-read-summary-keys
3869 "\M-#" gnus-article-read-summary-keys
3870 "\M-^" gnus-article-read-summary-keys
3871 "\M-g" gnus-article-read-summary-keys)
3873 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3877 (push (char-to-string key) keys)
3879 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3880 (setq key (car elem))
3881 (when (and (> (length key) 0)
3882 (not (eq 'menu-bar (aref key 0)))
3883 (symbolp (lookup-key gnus-summary-mode-map key)))
3886 (unless (lookup-key gnus-article-mode-map key)
3887 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3889 (defun gnus-article-make-menu-bar ()
3890 (unless (boundp 'gnus-article-commands-menu)
3891 (gnus-summary-make-menu-bar))
3892 (gnus-turn-off-edit-menu 'article)
3893 (unless (boundp 'gnus-article-article-menu)
3895 gnus-article-article-menu gnus-article-mode-map ""
3897 ["Scroll forwards" gnus-article-goto-next-page t]
3898 ["Scroll backwards" gnus-article-goto-prev-page t]
3899 ["Show summary" gnus-article-show-summary t]
3900 ["Fetch Message-ID at point" gnus-article-refer-article t]
3901 ["Mail to address at point" gnus-article-mail t]
3902 ["Send a bug report" gnus-bug t]))
3905 gnus-article-treatment-menu gnus-article-mode-map ""
3906 ;; Fixme: this should use :active (and maybe :visible).
3908 ["Hide headers" gnus-article-hide-headers t]
3909 ["Hide signature" gnus-article-hide-signature t]
3910 ["Hide citation" gnus-article-hide-citation t]
3911 ["Treat overstrike" gnus-article-treat-overstrike t]
3912 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
3913 ["Remove carriage return" gnus-article-remove-cr t]
3914 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3915 ["Treat html" gnus-article-wash-html t]
3916 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3917 ["Decode HZ" gnus-article-decode-HZ t]))
3919 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3921 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3923 (gnus-run-hooks 'gnus-article-menu-hook)))
3925 (defun gnus-article-mode ()
3926 "Major mode for displaying an article.
3928 All normal editing commands are switched off.
3930 The following commands are available in addition to all summary mode
3932 \\<gnus-article-mode-map>
3933 \\[gnus-article-next-page]\t Scroll the article one page forwards
3934 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3935 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3936 \\[gnus-article-show-summary]\t Display the summary buffer
3937 \\[gnus-article-mail]\t Send a reply to the address near point
3938 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3939 \\[gnus-info-find-node]\t Go to the Gnus info node"
3941 (kill-all-local-variables)
3942 (gnus-simplify-mode-line)
3943 (setq mode-name "Article")
3944 (setq major-mode 'gnus-article-mode)
3945 (make-local-variable 'minor-mode-alist)
3946 (unless (assq 'gnus-show-mime minor-mode-alist)
3947 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3948 (use-local-map gnus-article-mode-map)
3949 (when (gnus-visual-p 'article-menu 'menu)
3950 (gnus-article-make-menu-bar)
3951 (when gnus-summary-tool-bar-map
3952 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3953 (gnus-update-format-specifications nil 'article-mode)
3954 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3955 (set (make-local-variable 'gnus-page-broken) nil)
3956 (make-local-variable 'gnus-button-marker-list)
3957 (make-local-variable 'gnus-article-current-summary)
3958 (make-local-variable 'gnus-article-mime-handles)
3959 (make-local-variable 'gnus-article-decoded-p)
3960 (make-local-variable 'gnus-article-mime-handle-alist)
3961 (make-local-variable 'gnus-article-wash-types)
3962 (make-local-variable 'gnus-article-image-alist)
3963 (make-local-variable 'gnus-article-charset)
3964 (make-local-variable 'gnus-article-ignored-charsets)
3965 ;; Prevent recent Emacsen from displaying non-break space as "\ ".
3966 (set (make-local-variable 'nobreak-char-display) nil)
3967 (gnus-set-default-directory)
3968 (buffer-disable-undo)
3969 (setq buffer-read-only t
3970 show-trailing-whitespace nil)
3971 (set-syntax-table gnus-article-mode-syntax-table)
3972 (gnus-run-mode-hooks 'gnus-article-mode-hook))
3974 (defun gnus-article-setup-buffer ()
3975 "Initialize the article buffer."
3976 (let* ((name (if gnus-single-article-buffer "*Article*"
3977 (concat "*Article " gnus-newsgroup-name "*")))
3979 (progn (string-match "\\*Article" name)
3980 (concat " *Original Article"
3981 (substring name (match-end 0))))))
3982 (setq gnus-article-buffer name)
3983 (setq gnus-original-article-buffer original)
3984 (setq gnus-article-mime-handle-alist nil)
3985 ;; This might be a variable local to the summary buffer.
3986 (unless gnus-single-article-buffer
3988 (set-buffer gnus-summary-buffer)
3989 (setq gnus-article-buffer name)
3990 (setq gnus-original-article-buffer original)
3991 (gnus-set-global-variables)))
3992 (gnus-article-setup-highlight-words)
3993 ;; Init original article buffer.
3995 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3996 (set-buffer-multibyte t)
3997 (setq major-mode 'gnus-original-article-mode)
3998 (make-local-variable 'gnus-original-article))
3999 (if (and (get-buffer name)
4000 (with-current-buffer name
4001 (if gnus-article-edit-mode
4002 (if (y-or-n-p "Article mode edit in progress; discard? ")
4004 (set-buffer-modified-p nil)
4005 (gnus-kill-buffer name)
4008 (error "Action aborted"))
4012 (set (make-local-variable 'gnus-article-edit-mode) nil)
4013 (buffer-disable-undo)
4014 (setq buffer-read-only t)
4015 ;; This list just keeps growing if we don't reset it.
4016 (setq gnus-button-marker-list nil)
4017 (unless (eq major-mode 'gnus-article-mode)
4018 (gnus-article-mode))
4021 (set-buffer (gnus-get-buffer-create name))
4023 (make-local-variable 'gnus-summary-buffer)
4024 (gnus-summary-set-local-parameters gnus-newsgroup-name)
4025 (current-buffer)))))
4027 ;; Set article window start at LINE, where LINE is the number of lines
4028 ;; from the head of the article.
4029 (defun gnus-article-set-window-start (&optional line)
4031 (gnus-get-buffer-window gnus-article-buffer t)
4033 (set-buffer gnus-article-buffer)
4034 (goto-char (point-min))
4037 (gnus-message 6 "Moved to bookmark")
4038 (search-forward "\n\n" nil t)
4042 ;;; @@ article filters
4045 (defun gnus-article-display-mime-message ()
4046 "Article display method for MIME message."
4047 ;; called from `gnus-original-article-buffer'.
4048 (let (charset all-headers)
4049 (with-current-buffer gnus-summary-buffer
4050 (setq charset default-mime-charset
4051 all-headers gnus-have-all-headers))
4052 (make-local-variable 'default-mime-charset)
4053 (setq default-mime-charset charset)
4054 (with-current-buffer (get-buffer-create gnus-article-buffer)
4055 (make-local-variable 'default-mime-charset)
4056 (setq default-mime-charset charset))
4057 (mime-display-message mime-message-structure
4058 gnus-article-buffer nil gnus-article-mode-map)
4060 (gnus-article-hide-headers nil -1)))
4061 (run-hooks 'gnus-mime-article-prepare-hook))
4063 (defun gnus-article-display-traditional-message ()
4064 "Article display method for traditional message."
4065 (set-buffer gnus-article-buffer)
4066 (let ((inhibit-read-only t))
4068 (insert-buffer-substring gnus-original-article-buffer)))
4070 (defun gnus-article-make-full-mail-header (&optional number charset)
4071 "Create a new mail header structure in a raw article buffer."
4072 (unless (and number charset)
4073 (save-current-buffer
4074 (set-buffer gnus-summary-buffer)
4076 (setq number (or (cdr gnus-article-current) 0)))
4078 (setq charset (or default-mime-charset 'x-ctext)))))
4079 (goto-char (point-min))
4080 (let ((header-end (if (search-forward "\n\n" nil t)
4082 (goto-char (point-max))))
4083 (chars (- (point-max) (point)))
4084 (lines (count-lines (point) (point-max)))
4085 (default-mime-charset charset)
4087 (narrow-to-region (point-min) header-end)
4088 (setq xref (std11-fetch-field "xref"))
4090 (make-full-mail-header
4092 (std11-fetch-field "subject")
4093 (std11-fetch-field "from")
4094 (std11-fetch-field "date")
4095 (std11-fetch-field "message-id")
4096 (std11-fetch-field "references")
4099 (when xref (concat "Xref: " xref)))
4102 (defun gnus-article-prepare (article &optional all-headers header)
4103 "Prepare ARTICLE in article mode buffer.
4104 ARTICLE should either be an article number or a Message-ID.
4105 If ARTICLE is an id, HEADER should be the article headers.
4106 If ALL-HEADERS is non-nil, no headers are hidden."
4108 ;; Make sure we start in a summary buffer.
4109 (unless (eq major-mode 'gnus-summary-mode)
4110 (set-buffer gnus-summary-buffer))
4111 (setq gnus-summary-buffer (current-buffer))
4112 (let* ((gnus-article (if header (mail-header-number header) article))
4113 (summary-buffer (current-buffer))
4114 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4115 (group gnus-newsgroup-name)
4118 (gnus-article-setup-buffer)
4119 (set-buffer gnus-article-buffer)
4120 ;; Deactivate active regions.
4121 (when (and (boundp 'transient-mark-mode)
4122 transient-mark-mode)
4123 (setq mark-active nil))
4124 (if (not (setq result (let ((inhibit-read-only t))
4125 (gnus-request-article-this-buffer
4127 ;; There is no such article.
4129 (when (and (numberp article)
4130 (not (memq article gnus-newsgroup-sparse)))
4131 (setq gnus-article-current
4132 (cons gnus-newsgroup-name article))
4133 (set-buffer gnus-summary-buffer)
4134 (setq gnus-current-article article)
4135 (if (and (memq article gnus-newsgroup-undownloaded)
4136 (not (gnus-online (gnus-find-method-for-group
4137 gnus-newsgroup-name))))
4139 (gnus-summary-set-agent-mark article)
4140 (message "Message marked for downloading"))
4141 (gnus-summary-mark-article article gnus-canceled-mark)
4142 (unless (memq article gnus-newsgroup-sparse)
4143 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4144 (if (or (eq result 'pseudo)
4145 (eq result 'nneething))
4148 (set-buffer summary-buffer)
4149 (push article gnus-newsgroup-history)
4150 (setq gnus-last-article gnus-current-article
4151 gnus-current-article 0
4152 gnus-current-headers nil
4153 gnus-article-current nil)
4154 (if (eq result 'nneething)
4155 (gnus-configure-windows 'summary)
4156 (gnus-configure-windows 'article))
4157 (gnus-set-global-variables))
4158 (let ((gnus-article-mime-handle-alist-1
4159 gnus-article-mime-handle-alist))
4160 (gnus-set-mode-line 'article)))
4161 ;; The result from the `request' was an actual article -
4162 ;; or at least some text that is now displayed in the
4164 (when (and (numberp article)
4165 (not (eq article gnus-current-article)))
4166 ;; Seems like a new article has been selected.
4167 ;; `gnus-current-article' must be an article number.
4169 (set-buffer summary-buffer)
4170 (push article gnus-newsgroup-history)
4171 (setq gnus-last-article gnus-current-article
4172 gnus-current-article article
4173 gnus-current-headers
4174 (gnus-summary-article-header gnus-current-article)
4175 gnus-article-current
4176 (cons gnus-newsgroup-name gnus-current-article))
4177 (unless (vectorp gnus-current-headers)
4178 (setq gnus-current-headers nil))
4179 (gnus-summary-goto-subject gnus-current-article)
4180 (when (gnus-summary-show-thread)
4181 ;; If the summary buffer really was folded, the
4182 ;; previous goto may not actually have gone to
4183 ;; the right article, but the thread root instead.
4185 (gnus-summary-goto-subject gnus-current-article))
4186 (gnus-run-hooks 'gnus-mark-article-hook)
4187 (gnus-set-mode-line 'summary)
4188 (when (gnus-visual-p 'article-highlight 'highlight)
4189 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4190 ;; Set the global newsgroup variables here.
4191 (gnus-set-global-variables)
4192 (setq gnus-have-all-headers
4193 (or all-headers gnus-show-all-headers))))
4195 (gnus-configure-windows 'article))
4196 (when (or (numberp article)
4198 (gnus-article-prepare-display)
4200 (goto-char (point-min))
4201 (when gnus-break-pages
4202 (gnus-narrow-to-page)))
4203 (let ((gnus-article-mime-handle-alist-1
4204 gnus-article-mime-handle-alist))
4205 (gnus-set-mode-line 'article))
4209 (set-window-point (get-buffer-window (current-buffer)) (point))
4210 (gnus-configure-windows 'article)
4213 (defun gnus-article-prepare-mime-display (&optional number)
4214 (goto-char (point-min))
4215 (when (re-search-forward "^[^\t ]+:" nil t)
4216 (goto-char (match-beginning 0)))
4217 (let ((entity (if (eq 1 (point-min))
4218 (get-text-property 1 'mime-view-entity)
4219 (get-text-property (point) 'mime-view-entity)))
4220 last-entity child-entity next type)
4221 (setq child-entity (mime-entity-children entity))
4223 (setq last-entity (nth (1- (length child-entity))
4225 (setq last-entity entity))
4227 (narrow-to-region (point)
4228 (if (search-forward "\n\n" nil t)
4231 (gnus-article-save-original-date (gnus-treat-article 'head))
4232 (put-text-property (point-min) (point-max) 'article-treated-header t)
4233 (goto-char (point-max)))
4234 (while (and (not (eobp)) entity)
4235 (setq next (set-marker
4237 (next-single-property-change (point) 'mime-view-entity
4239 (let ((types (mime-entity-content-type entity)))
4240 (while (eq 'multipart (mime-content-type-primary-type types))
4241 (setq entity (car (mime-entity-children entity))
4242 types (mime-entity-content-type entity)))
4244 (setq type (format "%s/%s"
4245 (mime-content-type-primary-type types)
4246 (mime-content-type-subtype types)))))
4247 (if (string-equal type "message/rfc822")
4250 (let ((children (mime-entity-children entity))
4253 (setq last-children (nth (1- (length children)) children))
4256 (not (eq last-children
4257 (get-text-property next 'mime-view-entity)))
4259 (next-single-property-change next
4261 nil (point-max)))))))
4262 (setq next (next-single-property-change next 'mime-view-entity
4265 (narrow-to-region (point) next)
4266 (gnus-article-prepare-mime-display)
4267 (goto-char (point-max)))
4268 (setq entity (get-text-property (point) 'mime-view-entity)))
4270 (narrow-to-region (point) next)
4271 ;; Kludge. We have to count true number, but for now,
4272 ;; part number is here only to achieve `last'.
4273 (gnus-treat-article nil 1
4274 (if (eq entity last-entity)
4277 (goto-char (point-max)))
4278 (setq entity (get-text-property next 'mime-view-entity))))))
4281 (defun gnus-article-prepare-display ()
4282 "Make the current buffer look like a nice article."
4283 (let ((gnus-article-buffer (current-buffer))
4285 (inhibit-read-only t))
4286 (unless (eq major-mode 'gnus-article-mode)
4287 (gnus-article-mode))
4288 (setq buffer-read-only nil
4289 gnus-button-marker-list nil
4290 gnus-article-wash-types nil
4291 gnus-article-image-alist nil)
4294 (static-if (featurep 'xemacs)
4295 (map-extents (lambda (extent maparg) (delete-extent extent)))
4296 (let ((lists (overlay-lists)))
4297 (dolist (overlay (nconc (car lists) (cdr lists)))
4298 (delete-overlay overlay)))))
4299 (gnus-run-hooks 'gnus-tmp-internal-hook))
4300 (let ((show-mime (unless (member gnus-newsgroup-name '("nndraft:delayed"
4303 (inhibit-read-only t))
4304 (set-buffer gnus-original-article-buffer)
4306 (setq mime-message-structure gnus-current-headers)
4307 (mime-buffer-entity-set-buffer-internal mime-message-structure
4308 gnus-original-article-buffer)
4309 (mime-entity-set-representation-type-internal mime-message-structure
4310 'mime-buffer-entity)
4311 (luna-send mime-message-structure 'initialize-instance
4312 mime-message-structure)
4314 (let (mime-display-header-hook mime-display-text/plain-hook)
4315 (funcall gnus-article-display-method-for-mime))
4316 (funcall gnus-article-display-method-for-traditional))
4317 ;; Call the treatment functions.
4321 (gnus-article-prepare-mime-display)
4322 (narrow-to-region (goto-char (point-min))
4323 (if (search-forward "\n\n" nil t)
4326 (gnus-article-save-original-date (gnus-treat-article 'head))
4327 (put-text-property (point-min) (point-max) 'article-treated-header t)
4328 (goto-char (point-max))
4330 (narrow-to-region (point) (point-max))
4331 (gnus-treat-article nil))
4332 (put-text-property (point-min) (point-max) 'read-only nil)))
4333 (gnus-run-hooks 'gnus-article-prepare-hook))
4335 (defun gnus-article-decode-article-as-default-mime-charset ()
4336 "Decode an article as `default-mime-charset'. It won't work if the
4337 value of the variable `gnus-show-mime' is non-nil."
4338 (unless (or gnus-show-mime
4339 (member gnus-newsgroup-name '("nndraft:delayed"
4341 (set (make-local-variable 'default-mime-charset)
4342 (with-current-buffer gnus-summary-buffer
4343 default-mime-charset))
4344 (decode-mime-charset-region (point-min) (point-max)
4345 default-mime-charset)))
4348 ;;; Gnus MIME viewing functions
4351 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4352 "Format of the MIME buttons.
4354 Valid specifiers include:
4356 %T MIME type, along with additional info
4357 %n The `name' parameter
4358 %d The description, if any
4359 %l The length of the encoded part
4360 %p The part identifier number
4361 %e Dots if the part isn't displayed
4363 General format specifiers can also be used. See Info node
4364 `(gnus)Formatting Variables'.")
4366 (defvar gnus-mime-button-line-format-alist
4367 '((?t gnus-tmp-type ?s)
4368 (?T gnus-tmp-type-long ?s)
4369 (?n gnus-tmp-name ?s)
4370 (?d gnus-tmp-description ?s)
4372 (?l gnus-tmp-length ?d)
4373 (?e gnus-tmp-dots ?s)))
4375 (defvar gnus-mime-button-commands
4376 '((gnus-article-press-button "\r" "Toggle Display")
4377 (gnus-mime-view-part "v" "View Interactively...")
4378 (gnus-mime-view-part-as-type "t" "View As Type...")
4379 (gnus-mime-view-part-as-charset "C" "View As charset...")
4380 (gnus-mime-save-part "o" "Save...")
4381 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4382 (gnus-mime-delete-part "d" "Delete part")
4383 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4384 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4385 (gnus-mime-view-part-internally "E" "View Internally")
4386 (gnus-mime-view-part-externally "e" "View Externally")
4387 (gnus-mime-print-part "p" "Print")
4388 (gnus-mime-pipe-part "|" "Pipe To Command...")
4389 (gnus-mime-action-on-part "." "Take action on the part...")))
4391 (defun gnus-article-mime-part-status ()
4392 (with-current-buffer gnus-article-buffer
4393 (let ((entity (get-text-property (point-min) 'mime-view-entity))
4396 (setq children (mime-entity-children entity))
4397 (setq children (length children)))
4400 (format " (%d parts)" children))
4403 (defvar gnus-mime-button-map
4404 (let ((map (make-sparse-keymap)))
4405 (define-key map gnus-mouse-2 'gnus-article-push-button)
4406 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4407 (dolist (c gnus-mime-button-commands)
4408 (define-key map (cadr c) (car c)))
4412 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4414 ,@(mapcar (lambda (c)
4415 (vector (caddr c) (car c) :enable t))
4416 gnus-mime-button-commands)))
4418 (defun gnus-mime-button-menu (event prefix)
4419 "Construct a context-sensitive menu of MIME commands."
4420 (interactive "e\nP")
4421 (save-window-excursion
4422 (let ((pos (event-start event)))
4423 (select-window (posn-window pos))
4424 (goto-char (posn-point pos))
4425 (gnus-article-check-buffer)
4426 (popup-menu gnus-mime-button-menu nil prefix))))
4428 (defun gnus-mime-view-all-parts (&optional handles)
4429 "View all the MIME parts."
4431 (with-current-buffer gnus-article-buffer
4432 (let ((handles (or handles gnus-article-mime-handles))
4433 (mail-parse-charset gnus-newsgroup-charset)
4434 (mail-parse-ignored-charsets
4435 (with-current-buffer gnus-summary-buffer
4436 gnus-newsgroup-ignored-charsets)))
4438 (mm-remove-parts handles)
4439 (goto-char (point-min))
4440 (or (search-forward "\n\n") (goto-char (point-max)))
4441 (let ((inhibit-read-only t))
4442 (delete-region (point) (point-max))
4443 (mm-display-parts handles))))))
4446 (defsubst gnus-article-edit-part (handles)
4447 "Edit an article in order to delete a mime part.
4448 This function is exclusively used by `gnus-mime-save-part-and-strip'
4449 and `gnus-mime-delete-part', and not provided at run-time normally."
4450 (gnus-article-edit-article
4452 (buffer-disable-undo)
4454 (let ((mail-parse-charset (or gnus-article-charset
4455 ',gnus-newsgroup-charset))
4456 (mail-parse-ignored-charsets
4457 (or gnus-article-ignored-charsets
4458 ',gnus-newsgroup-ignored-charsets))
4459 (mbl mml-buffer-list))
4460 (setq mml-buffer-list nil)
4461 (insert-buffer-substring gnus-original-article-buffer)
4462 (mime-to-mml ',handles)
4463 (setq gnus-article-mime-handles nil)
4464 (let ((mbl1 mml-buffer-list))
4465 (setq mml-buffer-list mbl)
4466 (set (make-local-variable 'mml-buffer-list) mbl1))
4467 (gnus-make-local-hook 'kill-buffer-hook)
4468 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4469 `(lambda (no-highlight)
4470 (let ((mail-parse-charset (or gnus-article-charset
4471 ',gnus-newsgroup-charset))
4472 (message-options message-options)
4473 (message-options-set-recipient)
4474 (mail-parse-ignored-charsets
4475 (or gnus-article-ignored-charsets
4476 ',gnus-newsgroup-ignored-charsets)))
4478 (mml-destroy-buffers)
4479 (remove-hook 'kill-buffer-hook
4480 'mml-destroy-buffers t)
4481 (kill-local-variable 'mml-buffer-list))
4482 (gnus-summary-edit-article-done
4483 ,(or (mail-header-references gnus-current-headers) "")
4484 ,(gnus-group-read-only-p)
4485 ,gnus-summary-buffer no-highlight)))
4486 (gnus-article-edit-done)
4487 (gnus-summary-expand-window)
4488 (gnus-summary-show-article)))
4490 (defun gnus-mime-save-part-and-strip ()
4491 "Save the MIME part under point then replace it with an external body."
4493 (gnus-article-check-buffer)
4494 (when (gnus-group-read-only-p)
4495 (error "The current group does not support deleting of parts"))
4496 (when (mm-complicated-handles gnus-article-mime-handles)
4498 The current article has a complicated MIME structure, giving up..."))
4499 (when (gnus-yes-or-no-p "\
4500 Deleting parts may malfunction or destroy the article; continue? ")
4501 (let* ((data (get-text-property (point) 'gnus-data))
4503 (handles gnus-article-mime-handles))
4504 (setq file (and data (mm-save-part data)))
4506 (with-current-buffer (mm-handle-buffer data)
4508 (insert "Content-Type: " (mm-handle-media-type data))
4509 (mml-insert-parameter-string (cdr (mm-handle-type data))
4512 (insert "Content-ID: " (message-make-message-id) "\n")
4513 (insert "Content-Transfer-Encoding: binary\n")
4516 (cdr (mm-make-handle nil
4517 `("message/external-body"
4518 (access-type . "LOCAL-FILE")
4520 (set-buffer gnus-summary-buffer)
4521 (gnus-article-edit-part handles)))))
4523 (defun gnus-mime-delete-part ()
4524 "Delete the MIME part under point.
4525 Replace it with some information about the removed part."
4527 (gnus-article-check-buffer)
4528 (when (gnus-group-read-only-p)
4529 (error "The current group does not support deleting of parts"))
4530 (when (mm-complicated-handles gnus-article-mime-handles)
4532 The current article has a complicated MIME structure, giving up..."))
4533 (when (gnus-yes-or-no-p "\
4534 Deleting parts may malfunction or destroy the article; continue? ")
4535 (let* ((data (get-text-property (point) 'gnus-data))
4536 (handles gnus-article-mime-handles)
4540 (mail-decode-encoded-word-string (or (mm-handle-description data)
4543 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4545 (type (mm-handle-media-type data)))
4547 (error "No MIME part under point"))
4548 (with-current-buffer (mm-handle-buffer data)
4549 (let ((bsize (format "%s" (buffer-size))))
4554 "| The following attachment has been deleted:\n"
4556 "| Type: " type "\n"
4557 "| Filename: " filename "\n"
4558 "| Size (encoded): " bsize " Byte\n"
4559 "| Description: " description "\n"
4562 (cdr (mm-make-handle
4563 nil `("text/plain") nil nil
4565 (format "Deleted attachment (%s bytes)" bsize))))))
4566 (set-buffer gnus-summary-buffer)
4567 (gnus-article-edit-part handles))))
4569 (defun gnus-mime-save-part ()
4570 "Save the MIME part under point."
4572 (gnus-article-check-buffer)
4573 (let ((data (get-text-property (point) 'gnus-data)))
4575 (mm-save-part data))))
4577 (defun gnus-mime-pipe-part ()
4578 "Pipe the MIME part under point to a process."
4580 (gnus-article-check-buffer)
4581 (let ((data (get-text-property (point) 'gnus-data)))
4583 (mm-pipe-part data))))
4585 (defun gnus-mime-view-part ()
4586 "Interactively choose a viewing method for the MIME part under point."
4588 (gnus-article-check-buffer)
4589 (let ((data (get-text-property (point) 'gnus-data)))
4591 (setq gnus-article-mime-handles
4593 gnus-article-mime-handles (setq data (copy-sequence data))))
4594 (mm-interactively-view-part data))))
4596 (defun gnus-mime-view-part-as-type-internal ()
4597 (gnus-article-check-buffer)
4598 (let* ((name (mail-content-type-get
4599 (mm-handle-type (get-text-property (point) 'gnus-data))
4601 (def-type (and name (mm-default-file-encoding name))))
4602 (and def-type (cons def-type 0))))
4604 (defun gnus-mime-view-part-as-type (&optional mime-type)
4605 "Choose a MIME media type, and view the part as such."
4608 (setq mime-type (completing-read
4609 "View as MIME type: "
4610 (mapcar #'list (mailcap-mime-types))
4612 (gnus-mime-view-part-as-type-internal))))
4613 (gnus-article-check-buffer)
4614 (let ((handle (get-text-property (point) 'gnus-data)))
4617 (mm-make-handle (mm-handle-buffer handle)
4618 (cons mime-type (cdr (mm-handle-type handle)))
4619 (mm-handle-encoding handle)
4620 (mm-handle-undisplayer handle)
4621 (mm-handle-disposition handle)
4622 (mm-handle-description handle)
4624 (mm-handle-id handle)))
4625 (setq gnus-article-mime-handles
4626 (mm-merge-handles gnus-article-mime-handles handle))
4627 (gnus-mm-display-part handle))))
4629 (defun gnus-mime-copy-part (&optional handle arg)
4630 "Put the MIME part under point into a new buffer.
4631 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4633 (interactive (list nil current-prefix-arg))
4634 (gnus-article-check-buffer)
4636 (setq handle (get-text-property (point) 'gnus-data)))
4638 (let ((filename (or (mail-content-type-get (mm-handle-disposition handle)
4640 (mail-content-type-get (mm-handle-disposition handle)
4642 contents dont-decode charset coding-system)
4643 (mm-with-unibyte-buffer
4644 (mm-insert-part handle)
4645 (setq contents (or (condition-case nil
4646 (mm-decompress-buffer filename nil 'sig)
4648 (setq dont-decode t)
4651 (setq filename (cond (filename (file-name-nondirectory filename))
4652 (dont-decode "*raw data*")
4657 (unless (setq charset (mail-content-type-get
4658 (mm-handle-type handle) 'charset))
4659 (unless (setq coding-system (mm-with-unibyte-buffer
4661 (mm-find-buffer-file-coding-system)))
4662 (setq charset gnus-newsgroup-charset))))
4664 (setq charset (or (cdr (assq arg
4665 gnus-summary-show-article-charset-alist))
4666 (mm-read-coding-system "Charset: ")))))
4667 (switch-to-buffer (generate-new-buffer filename))
4668 (if (or coding-system
4670 (setq coding-system (mm-charset-to-coding-system charset))
4671 (not (eq charset 'ascii))))
4673 (mm-enable-multibyte)
4674 (insert (mm-decode-coding-string contents coding-system))
4675 (setq buffer-file-coding-system
4676 (if (boundp 'last-coding-system-used)
4677 (symbol-value 'last-coding-system-used)
4679 (mm-disable-multibyte)
4681 (setq buffer-file-coding-system mm-binary-coding-system))
4682 ;; We do it this way to make `normal-mode' set the appropriate mode.
4685 (setq buffer-file-name (expand-file-name filename))
4687 (setq buffer-file-name nil))
4688 (goto-char (point-min)))))
4690 (defun gnus-mime-print-part (&optional handle filename)
4691 "Print the MIME part under point."
4692 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4693 (gnus-article-check-buffer)
4694 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4695 (contents (and handle (mm-get-part handle)))
4696 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4697 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4702 (mm-save-part-to-file handle file)
4703 (call-process shell-file-name nil
4704 (generate-new-buffer " *mm*")
4706 shell-command-switch
4708 printer file (mm-handle-type handle))))
4712 (gnus-print-buffer))
4713 (ps-despool filename)))))
4715 (defun gnus-mime-inline-part (&optional handle arg)
4716 "Insert the MIME part under point into the current buffer.
4717 Compressed files like .gz and .bz2 are decompressed."
4718 (interactive (list nil current-prefix-arg))
4719 (gnus-article-check-buffer)
4721 (setq handle (get-text-property (point) 'gnus-data)))
4724 (inhibit-read-only t)
4725 contents charset coding-system)
4726 (if (and (not arg) (mm-handle-undisplayer handle))
4727 (mm-remove-part handle)
4728 (mm-with-unibyte-buffer
4729 (mm-insert-part handle)
4731 (or (mm-decompress-buffer
4732 (or (mail-content-type-get (mm-handle-disposition handle)
4734 (mail-content-type-get (mm-handle-disposition handle)
4740 (unless (setq charset (mail-content-type-get
4741 (mm-handle-type handle) 'charset))
4742 (unless (setq coding-system
4743 (mm-with-unibyte-buffer
4745 (mm-find-buffer-file-coding-system)))
4746 (setq charset gnus-newsgroup-charset))))
4748 (if (mm-handle-undisplayer handle)
4749 (mm-remove-part handle))
4752 gnus-summary-show-article-charset-alist))
4753 (mm-read-coding-system "Charset: "))))
4755 (if (mm-handle-undisplayer handle)
4756 (mm-remove-part handle))))
4760 (if (or coding-system
4763 (mm-charset-to-coding-system charset))
4764 (not (eq coding-system 'ascii))))
4765 (mm-decode-coding-string contents coding-system)
4766 (mm-string-to-multibyte contents)))
4769 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4770 "Insert the MIME part under point into the current buffer using the
4772 (interactive (list nil current-prefix-arg))
4773 (gnus-article-check-buffer)
4774 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4777 (inhibit-read-only t))
4779 (if (mm-handle-undisplayer handle)
4780 (mm-remove-part handle))
4781 (let ((gnus-newsgroup-charset
4783 gnus-summary-show-article-charset-alist))
4784 (mm-read-coding-system "Charset: ")))
4785 (gnus-newsgroup-ignored-charsets 'gnus-all))
4786 (gnus-article-press-button)))))
4788 (defun gnus-mime-view-part-externally (&optional handle)
4789 "View the MIME part under point with an external viewer."
4791 (gnus-article-check-buffer)
4792 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4793 (mm-user-display-methods nil)
4794 (mm-inlined-types nil)
4795 (mail-parse-charset gnus-newsgroup-charset)
4796 (mail-parse-ignored-charsets
4797 (with-current-buffer gnus-summary-buffer
4798 gnus-newsgroup-ignored-charsets)))
4800 (if (mm-handle-undisplayer handle)
4801 (mm-remove-part handle)
4802 (mm-display-part handle)))))
4804 (defun gnus-mime-view-part-internally (&optional handle)
4805 "View the MIME part under point with an internal viewer.
4806 If no internal viewer is available, use an external viewer."
4808 (gnus-article-check-buffer)
4809 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4810 (mm-inlined-types '(".*"))
4811 (mm-inline-large-images t)
4812 (mail-parse-charset gnus-newsgroup-charset)
4813 (mail-parse-ignored-charsets
4814 (with-current-buffer gnus-summary-buffer
4815 gnus-newsgroup-ignored-charsets))
4816 (inhibit-read-only t))
4818 (if (mm-handle-undisplayer handle)
4819 (mm-remove-part handle)
4820 (mm-display-part handle)))))
4822 (defun gnus-mime-action-on-part (&optional action)
4823 "Do something with the MIME attachment at \(point\)."
4825 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4826 (gnus-article-check-buffer)
4827 (let ((action-pair (assoc action gnus-mime-action-alist)))
4829 (funcall (cdr action-pair)))))
4831 (defun gnus-article-part-wrapper (n function)
4832 (with-current-buffer gnus-article-buffer
4833 (when (> n (length gnus-article-mime-handle-alist))
4834 (error "No such part"))
4835 (gnus-article-goto-part n)
4836 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4837 (funcall function handle))))
4839 (defun gnus-article-pipe-part (n)
4840 "Pipe MIME part N, which is the numerical prefix."
4842 (gnus-article-part-wrapper n 'mm-pipe-part))
4844 (defun gnus-article-save-part (n)
4845 "Save MIME part N, which is the numerical prefix."
4847 (gnus-article-part-wrapper n 'mm-save-part))
4849 (defun gnus-article-interactively-view-part (n)
4850 "View MIME part N interactively, which is the numerical prefix."
4852 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4854 (defun gnus-article-copy-part (n)
4855 "Copy MIME part N, which is the numerical prefix."
4857 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4859 (defun gnus-article-view-part-as-charset (n)
4860 "View MIME part N using a specified charset.
4861 N is the numerical prefix."
4863 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4865 (defun gnus-article-view-part-externally (n)
4866 "View MIME part N externally, which is the numerical prefix."
4868 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4870 (defun gnus-article-inline-part (n)
4871 "Inline MIME part N, which is the numerical prefix."
4873 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4875 (defun gnus-article-mime-match-handle-first (condition)
4878 (dolist (ihandle gnus-article-mime-handle-alist)
4880 ((functionp condition)
4881 (funcall condition (cdr ihandle)))
4882 ((eq condition 'undisplayed)
4883 (not (or (mm-handle-undisplayer (cdr ihandle))
4884 (equal (mm-handle-media-type (cdr ihandle))
4885 "multipart/alternative"))))
4886 ((eq condition 'undisplayed-alternative)
4887 (not (mm-handle-undisplayer (cdr ihandle))))
4889 (gnus-article-goto-part (car ihandle))
4890 (or (not n) (< (car ihandle) n)))
4891 (setq n (car ihandle))))
4895 (defun gnus-article-view-part (&optional n)
4896 "View MIME part N, which is the numerical prefix."
4898 (with-current-buffer gnus-article-buffer
4899 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4900 gnus-article-mime-match-handle-function)))
4901 (when (> n (length gnus-article-mime-handle-alist))
4902 (error "No such part"))
4903 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4904 (when (gnus-article-goto-part n)
4905 (if (equal (car handle) "multipart/alternative")
4906 (gnus-article-press-button)
4907 (when (eq (gnus-mm-display-part handle) 'internal)
4908 (gnus-set-window-start)))))))
4910 (defsubst gnus-article-mime-total-parts ()
4911 (if (bufferp (car gnus-article-mime-handles))
4913 (1- (length gnus-article-mime-handles))))
4915 (defun gnus-mm-display-part (handle)
4916 "Display HANDLE and fix MIME button."
4917 (let ((id (get-text-property (point) 'gnus-part))
4919 (inhibit-read-only t))
4922 (let ((window (selected-window))
4923 (mail-parse-charset gnus-newsgroup-charset)
4924 (mail-parse-ignored-charsets
4925 (if (gnus-buffer-live-p gnus-summary-buffer)
4926 (with-current-buffer gnus-summary-buffer
4927 gnus-newsgroup-ignored-charsets)
4931 (let ((win (gnus-get-buffer-window (current-buffer) t))
4934 (select-window win))
4937 (if (mm-handle-displayed-p handle)
4938 ;; This will remove the part.
4939 (mm-display-part handle)
4941 (narrow-to-region (point)
4942 (if (eobp) (point) (1+ (point))))
4943 (mm-display-part handle)
4944 ;; We narrow to the part itself and
4945 ;; then call the treatment functions.
4946 (goto-char (point-min))
4948 (narrow-to-region (point) (point-max))
4951 (gnus-article-mime-total-parts)
4952 (mm-handle-media-type handle)))))
4953 (if (window-live-p window)
4954 (select-window window)))))
4957 (gnus-insert-mime-button
4958 handle id (list (mm-handle-displayed-p handle)))
4959 (goto-char point))))
4961 (defun gnus-article-goto-part (n)
4962 "Go to MIME part N."
4963 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4965 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4966 (let ((gnus-tmp-name
4967 (or (mail-content-type-get (mm-handle-type handle) 'name)
4968 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4969 (mail-content-type-get (mm-handle-type handle) 'url)
4971 (gnus-tmp-type (mm-handle-media-type handle))
4972 (gnus-tmp-description
4973 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4976 (if (if displayed (car displayed)
4977 (mm-handle-displayed-p handle))
4979 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4981 gnus-tmp-type-long b e)
4982 (when (string-match ".*/" gnus-tmp-name)
4983 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4984 (setq gnus-tmp-type-long (concat gnus-tmp-type
4985 (and (not (equal gnus-tmp-name ""))
4986 (concat "; " gnus-tmp-name))))
4987 (unless (equal gnus-tmp-description "")
4988 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4993 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4994 `(keymap ,gnus-mime-button-map
4995 gnus-callback gnus-mm-display-part
4996 gnus-part ,gnus-tmp-id
4997 article-type annotation
5000 ;; Exclude a newline.
5003 (widget-convert-button
5006 :action 'gnus-widget-press-button
5007 :button-keymap gnus-mime-button-map
5009 (lambda (widget/window &optional overlay pos)
5010 ;; Needed to properly clear the message due to a bug in
5011 ;; wid-edit (XEmacs only).
5012 (if (boundp 'help-echo-owns-message)
5013 (setq help-echo-owns-message t))
5015 "%S: %s the MIME part; %S: more options"
5016 (aref gnus-mouse-2 0)
5017 ;; XEmacs will get a single widget arg; Emacs 21 will get
5018 ;; window, overlay, position.
5019 (if (mm-handle-displayed-p
5021 (with-current-buffer (gnus-overlay-buffer overlay)
5022 (widget-get (widget-at (gnus-overlay-start overlay))
5024 (widget-get widget/window :mime-handle)))
5026 (aref gnus-down-mouse-3 0))))))
5028 (defun gnus-widget-press-button (elems el)
5029 (goto-char (widget-get elems :from))
5030 (gnus-article-press-button))
5032 (defvar gnus-displaying-mime nil)
5034 (defun gnus-display-mime (&optional ihandles)
5035 "Display the MIME parts."
5037 (save-selected-window
5038 (let ((window (get-buffer-window gnus-article-buffer))
5041 (select-window window)
5042 ;; We have to do this since selecting the window
5043 ;; may change the point. So we set the window point.
5044 (set-window-point window point)))
5045 (let ((handles ihandles)
5046 (inhibit-read-only t)
5049 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
5050 (when gnus-article-emulate-mime
5051 (mm-uu-dissect-text-parts handles)))
5052 (gnus-article-emulate-mime
5053 (setq handles (mm-uu-dissect))))
5054 (when (and (not ihandles)
5055 (not gnus-displaying-mime))
5056 ;; Top-level call; we clean up.
5057 (when gnus-article-mime-handles
5058 (mm-destroy-parts gnus-article-mime-handles)
5059 (setq gnus-article-mime-handle-alist nil));; A trick.
5060 (setq gnus-article-mime-handles handles)
5061 ;; We allow users to glean info from the handles.
5062 (when gnus-article-mime-part-function
5063 (gnus-mime-part-function handles)))
5065 (or (not (stringp (car handles)))
5068 (when (and (not ihandles)
5069 (not gnus-displaying-mime))
5070 ;; Clean up for mime parts.
5072 (delete-region (point) (point-max)))
5073 (let ((gnus-displaying-mime t))
5074 (gnus-mime-display-part handles)))
5077 (narrow-to-region (point) (point-max))
5078 (gnus-treat-article nil 1 1)
5081 ;; Highlight the headers.
5085 (narrow-to-region (point-min) (point))
5086 (gnus-article-save-original-date
5087 (gnus-treat-article 'head)))))))))
5089 (defcustom gnus-mime-display-multipart-as-mixed nil
5090 "Display \"multipart\" parts as \"multipart/mixed\".
5092 If t, it overrides nil values of
5093 `gnus-mime-display-multipart-alternative-as-mixed' and
5094 `gnus-mime-display-multipart-related-as-mixed'."
5095 :group 'gnus-article-mime
5098 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
5099 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
5101 :group 'gnus-article-mime
5104 (defcustom gnus-mime-display-multipart-related-as-mixed nil
5105 "Display \"multipart/related\" parts as \"multipart/mixed\".
5107 If displaying \"text/html\" is discouraged \(see
5108 `mm-discouraged-alternatives'\) images or other material inside a
5109 \"multipart/related\" part might be overlooked when this variable is nil."
5111 :group 'gnus-article-mime
5114 (defun gnus-mime-display-part (handle)
5117 ((not (stringp (car handle)))
5118 (gnus-mime-display-single handle))
5119 ;; User-defined multipart
5120 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
5121 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
5123 ;; multipart/alternative
5124 ((and (equal (car handle) "multipart/alternative")
5125 (not (or gnus-mime-display-multipart-as-mixed
5126 gnus-mime-display-multipart-alternative-as-mixed)))
5127 (let ((id (1+ (length gnus-article-mime-handle-alist))))
5128 (push (cons id handle) gnus-article-mime-handle-alist)
5129 (gnus-mime-display-alternative (cdr handle) nil nil id)))
5130 ;; multipart/related
5131 ((and (equal (car handle) "multipart/related")
5132 (not (or gnus-mime-display-multipart-as-mixed
5133 gnus-mime-display-multipart-related-as-mixed)))
5134 ;;;!!!We should find the start part, but we just default
5135 ;;;!!!to the first part.
5136 ;;(gnus-mime-display-part (cadr handle))
5137 ;;;!!! Most multipart/related is an HTML message plus images.
5138 ;;;!!! Unfortunately we are unable to let W3 display those
5139 ;;;!!! included images, so we just display it as a mixed multipart.
5140 ;;(gnus-mime-display-mixed (cdr handle))
5141 ;;;!!! No, w3 can display everything just fine.
5142 (gnus-mime-display-part (cadr handle)))
5143 ((equal (car handle) "multipart/signed")
5144 (gnus-add-wash-type 'signed)
5145 (gnus-mime-display-security handle))
5146 ((equal (car handle) "multipart/encrypted")
5147 (gnus-add-wash-type 'encrypted)
5148 (gnus-mime-display-security handle))
5149 ;; Other multiparts are handled like multipart/mixed.
5151 (gnus-mime-display-mixed (cdr handle)))))
5153 (defun gnus-mime-part-function (handles)
5154 (if (stringp (car handles))
5155 (mapcar 'gnus-mime-part-function (cdr handles))
5156 (funcall gnus-article-mime-part-function handles)))
5158 (defun gnus-mime-display-mixed (handles)
5159 (mapcar 'gnus-mime-display-part handles))
5161 (defun gnus-mime-display-single (handle)
5162 (let ((type (mm-handle-media-type handle))
5163 (ignored gnus-ignored-mime-types)
5170 (when (string-match (pop ignored) type)
5171 (throw 'ignored nil)))
5172 (if (and (setq not-attachment
5173 (and (not (mm-inline-override-p handle))
5174 (or (not (mm-handle-disposition handle))
5175 (equal (car (mm-handle-disposition handle))
5177 (mm-attachment-override-p handle))))
5178 (mm-automatic-display-p handle)
5180 (mm-inlinable-p handle)
5181 (mm-inlined-p handle))
5182 (mm-automatic-external-display-p type)))
5184 (when (equal (mm-handle-media-supertype handle) "text")
5186 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5188 (push (cons id handle) gnus-article-mime-handle-alist)
5189 (when (or (not display)
5190 (not (gnus-unbuttonized-mime-type-p type)))
5191 (gnus-insert-mime-button
5192 handle id (list (or display (and not-attachment text))))
5193 (gnus-article-insert-newline)
5194 ;; Remember modify the number of forward lines.
5202 (let ((mail-parse-charset gnus-newsgroup-charset)
5203 (mail-parse-ignored-charsets
5204 (save-excursion (condition-case ()
5205 (set-buffer gnus-summary-buffer)
5207 gnus-newsgroup-ignored-charsets)))
5208 (mm-display-part handle t))
5209 (goto-char (point-max)))
5210 ((and text not-attachment)
5214 (gnus-article-insert-newline)
5215 (mm-display-inline handle)
5216 (goto-char (point-max))))
5220 (narrow-to-region beg (point))
5223 (gnus-article-mime-total-parts)
5224 (mm-handle-media-type handle)))))))))
5226 (defun gnus-unbuttonized-mime-type-p (type)
5227 "Say whether TYPE is to be unbuttonized."
5228 (unless gnus-inhibit-mime-unbuttonizing
5230 (let ((types gnus-unbuttonized-mime-types))
5232 (when (string-match (pop types) type)
5233 (throw 'found t)))))
5235 (let ((types gnus-buttonized-mime-types))
5237 (when (string-match (pop types) type)
5238 (throw 'found t)))))))))
5240 (defun gnus-article-insert-newline ()
5241 "Insert a newline, but mark it as undeletable."
5242 (gnus-put-text-property
5243 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5245 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5246 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5249 handle (inhibit-read-only t) from props begend not-pref)
5250 (save-window-excursion
5253 (narrow-to-region (car ibegend)
5256 (goto-char (car ibegend))
5259 (delete-region (point-min) (point-max))
5260 (mm-remove-parts handles))
5261 (setq begend (list (point-marker)))
5263 (unless (setq not-pref (cadr (member preferred ihandles)))
5264 (setq not-pref (car ihandles)))
5267 (not (gnus-unbuttonized-mime-type-p
5268 "multipart/alternative")))
5269 (gnus-add-text-properties
5272 (insert (format "%d. " id))
5276 (unless ,(not ibegend)
5277 (setq gnus-article-mime-handle-alist
5278 ',gnus-article-mime-handle-alist))
5279 (gnus-mime-display-alternative
5280 ',ihandles ',not-pref ',begend ,id))
5281 keymap ,gnus-mime-button-map
5282 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5283 face ,gnus-article-button-face
5286 (widget-convert-button 'link from (point)
5287 :action 'gnus-widget-press-button
5288 :button-keymap gnus-widget-button-keymap)
5290 (while (setq handle (pop handles))
5291 (gnus-add-text-properties
5294 (insert (format "(%c) %-18s"
5295 (if (equal handle preferred) ?* ? )
5296 (mm-handle-media-type handle)))
5300 (unless ,(not ibegend)
5301 (setq gnus-article-mime-handle-alist
5302 ',gnus-article-mime-handle-alist))
5303 (gnus-mime-display-alternative
5304 ',ihandles ',handle ',begend ,id))
5305 keymap ,gnus-mime-button-map
5306 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5307 face ,gnus-article-button-face
5310 (widget-convert-button 'link from (point)
5311 :action 'gnus-widget-press-button
5312 :button-keymap gnus-widget-button-keymap)
5316 (if (stringp (car preferred))
5317 (gnus-display-mime preferred)
5318 (let ((mail-parse-charset gnus-newsgroup-charset)
5319 (mail-parse-ignored-charsets
5320 (with-current-buffer gnus-summary-buffer
5321 gnus-newsgroup-ignored-charsets)))
5322 (mm-display-part preferred)
5326 (narrow-to-region (car begend) (point-max))
5328 nil (length gnus-article-mime-handle-alist)
5329 (gnus-article-mime-total-parts)
5330 (mm-handle-media-type handle))))))
5331 (goto-char (point-max))
5332 (setcdr begend (point-marker)))))
5334 (goto-char point))))
5336 (defconst gnus-article-wash-status-strings
5337 (let ((alist '((cite "c" "Possible hidden citation text"
5338 " " "All citation text visible")
5339 (headers "h" "Hidden headers"
5340 " " "All headers visible.")
5341 (pgp "p" "Encrypted or signed message status hidden"
5342 " " "No hidden encryption nor digital signature status")
5343 (signature "s" "Signature has been hidden"
5344 " " "Signature is visible")
5345 (overstrike "o" "Overstrike (^H) characters applied"
5346 " " "No overstrike characters applied")
5347 (gnus-show-mime "m" "Mime processing is activated"
5348 " " "Mime processing is not activated")
5349 (emphasis "e" "/*_Emphasis_*/ characters applied"
5350 " " "No /*_emphasis_*/ characters applied")))
5352 (dolist (entry alist result)
5353 (let ((key (nth 0 entry))
5354 (on (copy-sequence (nth 1 entry)))
5355 (on-help (nth 2 entry))
5356 (off (copy-sequence (nth 3 entry)))
5357 (off-help (nth 4 entry)))
5358 (put-text-property 0 1 'help-echo on-help on)
5359 (put-text-property 0 1 'help-echo off-help off)
5360 (push (list key on off) result))))
5361 "Alist of strings describing wash status in the mode line.
5362 Each entry has the form (KEY ON OF), where the KEY is a symbol
5363 representing the particular washing function, ON is the string to use
5364 in the article mode line when the washing function is active, and OFF
5365 is the string to use when it is inactive.")
5367 (defun gnus-article-wash-status-entry (key value)
5368 (let ((entry (assoc key gnus-article-wash-status-strings)))
5369 (if value (nth 1 entry) (nth 2 entry))))
5371 (defun gnus-article-wash-status ()
5372 "Return a string which display status of article washing."
5373 (with-current-buffer gnus-article-buffer
5374 (let ((cite (memq 'cite gnus-article-wash-types))
5375 (headers (memq 'headers gnus-article-wash-types))
5376 (boring (memq 'boring-headers gnus-article-wash-types))
5377 (pgp (memq 'pgp gnus-article-wash-types))
5378 (pem (memq 'pem gnus-article-wash-types))
5379 (signed (memq 'signed gnus-article-wash-types))
5380 (encrypted (memq 'encrypted gnus-article-wash-types))
5381 (signature (memq 'signature gnus-article-wash-types))
5382 (overstrike (memq 'overstrike gnus-article-wash-types))
5383 (emphasis (memq 'emphasis gnus-article-wash-types)))
5385 (gnus-article-wash-status-entry 'cite cite)
5386 (gnus-article-wash-status-entry 'headers (or headers boring))
5387 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5388 (gnus-article-wash-status-entry 'signature signature)
5389 (gnus-article-wash-status-entry 'overstrike overstrike)
5390 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
5391 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5393 (defun gnus-add-wash-type (type)
5394 "Add a washing of TYPE to the current status."
5395 (add-to-list 'gnus-article-wash-types type))
5397 (defun gnus-delete-wash-type (type)
5398 "Add a washing of TYPE to the current status."
5399 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5401 (defun gnus-add-image (category image)
5402 "Add IMAGE of CATEGORY to the list of displayed images."
5403 (let ((entry (assq category gnus-article-image-alist)))
5405 (setq entry (list category))
5406 (push entry gnus-article-image-alist))
5407 (nconc entry (list image))))
5409 (defun gnus-delete-images (category)
5410 "Delete all images in CATEGORY."
5411 (let ((entry (assq category gnus-article-image-alist)))
5412 (dolist (image (cdr entry))
5413 (gnus-remove-image image category))
5414 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5415 (gnus-delete-wash-type category)))
5417 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5419 (defun gnus-article-maybe-hide-headers ()
5420 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5421 Provided for backwards compatibility."
5422 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5423 (not (with-current-buffer gnus-summary-buffer
5424 gnus-have-all-headers)))
5425 (not gnus-inhibit-hiding))
5426 (gnus-article-hide-headers)))
5430 (defun gnus-output-to-file (file-name)
5431 "Append the current article to a file named FILE-NAME."
5432 (let ((artbuf (current-buffer)))
5434 (insert-buffer-substring artbuf)
5435 ;; Append newline at end of the buffer as separator, and then
5437 (goto-char (point-max))
5439 (let ((file-name-coding-system nnmail-pathname-coding-system))
5440 (write-region-as-binary (point-min) (point-max) file-name 'append))
5443 (defun gnus-narrow-to-page (&optional arg)
5444 "Narrow the article buffer to a page.
5445 If given a numerical ARG, move forward ARG pages."
5447 (setq arg (if arg (prefix-numeric-value arg) 0))
5449 (set-buffer gnus-article-buffer)
5450 (goto-char (point-min))
5452 ;; Remove any old next/prev buttons.
5453 (when (gnus-visual-p 'page-marker)
5454 (let ((inhibit-read-only t))
5455 (gnus-remove-text-with-property 'gnus-prev)
5456 (gnus-remove-text-with-property 'gnus-next)))
5459 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5461 (re-search-forward page-delimiter nil 'move arg)))
5462 (goto-char (match-end 0))
5464 (goto-char (point-min))
5465 (setq gnus-page-broken
5466 (and (re-search-forward page-delimiter nil t) t))))
5467 (when gnus-page-broken
5470 (if (re-search-forward page-delimiter nil 'move)
5473 (when (and (gnus-visual-p 'page-marker)
5474 (> (point-min) (save-restriction (widen) (point-min))))
5476 (goto-char (point-min))
5477 (gnus-insert-prev-page-button)))
5478 (when (and (gnus-visual-p 'page-marker)
5479 (< (point-max) (save-restriction (widen) (point-max))))
5481 (goto-char (point-max))
5482 (gnus-insert-next-page-button))))))
5484 ;; Article mode commands
5486 (defun gnus-article-goto-next-page ()
5487 "Show the next page of the article."
5489 (when (gnus-article-next-page)
5490 (goto-char (point-min))
5491 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5494 (defun gnus-article-goto-prev-page ()
5495 "Show the previous page of the article."
5498 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5499 (gnus-article-prev-page nil)))
5501 ;; This is cleaner but currently breaks `gnus-pick-mode':
5503 ;; (defun gnus-article-goto-next-page ()
5504 ;; "Show the next page of the article."
5506 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5507 ;; (gnus-summary-next-page)))
5509 ;; (defun gnus-article-goto-prev-page ()
5510 ;; "Show the next page of the article."
5512 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5513 ;; (gnus-summary-prev-page)))
5515 (defun gnus-article-next-page (&optional lines)
5516 "Show the next page of the current article.
5517 If end of article, return non-nil. Otherwise return nil.
5518 Argument LINES specifies lines to be scrolled up."
5520 (move-to-window-line -1)
5523 (and (pos-visible-in-window-p) ;Not continuation line.
5524 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5525 ;; Nothing in this page.
5526 (if (or (not gnus-page-broken)
5531 (eobp)))) ;Real end-of-buffer?
5533 (when gnus-article-over-scroll
5534 (gnus-article-next-page-1 lines))
5536 (gnus-narrow-to-page 1) ;Go to next page.
5538 ;; More in this page.
5539 (gnus-article-next-page-1 lines)
5542 (defmacro gnus-article-beginning-of-window ()
5543 "Move point to the beginning of the window.
5544 In Emacs, the point is placed at the line number which `scroll-margin'
5546 (if (featurep 'xemacs)
5547 '(move-to-window-line 0)
5548 '(move-to-window-line
5549 (min (max 0 scroll-margin)
5550 (max 1 (- (window-height)
5551 (if mode-line-format 1 0)
5552 (if header-line-format 1 0)))))))
5554 (defun gnus-article-next-page-1 (lines)
5555 (when (and (not (featurep 'xemacs))
5558 (numberp (symbol-value 'scroll-margin))
5559 (> (symbol-value 'scroll-margin) 0))
5560 ;; Protect against the bug that Emacs 21.x hangs up when scrolling up for
5561 ;; too many number of lines if `scroll-margin' is set as two or greater.
5562 (setq lines (min lines
5563 (max 0 (- (count-lines (window-start) (point-max))
5564 (symbol-value 'scroll-margin))))))
5566 (let ((scroll-in-place nil))
5569 ;; Long lines may cause an end-of-buffer error.
5570 (goto-char (point-max))))
5571 (gnus-article-beginning-of-window))
5573 (defun gnus-article-prev-page (&optional lines)
5574 "Show previous page of current article.
5575 Argument LINES specifies lines to be scrolled down."
5577 (move-to-window-line 0)
5578 (if (and gnus-page-broken
5580 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5582 (gnus-narrow-to-page -1) ;Go to previous page.
5583 (goto-char (point-max))
5587 (let ((scroll-in-place nil))
5588 (scroll-down lines))
5589 (beginning-of-buffer
5590 (goto-char (point-min))))
5591 (gnus-article-beginning-of-window))))
5593 (defun gnus-article-only-boring-p ()
5594 "Decide whether there is only boring text remaining in the article.
5595 Something \"interesting\" is a word of at least two letters that does
5596 not have a face in `gnus-article-boring-faces'."
5597 (when (and gnus-article-skip-boring
5598 (boundp 'gnus-article-boring-faces)
5599 (symbol-value 'gnus-article-boring-faces))
5602 (while (re-search-forward "\\b\\w\\w" nil t)
5604 (when (not (gnus-intersection
5605 (gnus-faces-at (point))
5606 (symbol-value 'gnus-article-boring-faces)))
5607 (throw 'only-boring nil)))
5608 (throw 'only-boring t)))))
5610 (defun gnus-article-refer-article ()
5611 "Read article specified by message-id around point."
5614 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5615 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5616 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5617 (let ((msg-id (concat "<" (match-string 0) ">")))
5618 (set-buffer gnus-summary-buffer)
5619 (gnus-summary-refer-article msg-id))
5620 (error "No references around point"))))
5622 (defun gnus-article-show-summary ()
5623 "Reconfigure windows to show summary buffer."
5625 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5626 (error "There is no summary buffer for this article buffer")
5627 (gnus-article-set-globals)
5628 (gnus-configure-windows 'article)
5629 (gnus-summary-goto-subject gnus-current-article)
5630 (gnus-summary-position-point)))
5632 (defun gnus-article-describe-briefly ()
5633 "Describe article mode commands briefly."
5635 (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")))
5637 (defun gnus-article-summary-command ()
5638 "Execute the last keystroke in the summary buffer."
5640 (let ((obuf (current-buffer))
5641 (owin (current-window-configuration))
5643 (switch-to-buffer gnus-article-current-summary 'norecord)
5644 (setq func (lookup-key (current-local-map) (this-command-keys)))
5645 (call-interactively func)
5647 (set-window-configuration owin)
5648 (set-window-point (get-buffer-window (current-buffer)) (point))))
5650 (defun gnus-article-summary-command-nosave ()
5651 "Execute the last keystroke in the summary buffer."
5654 (pop-to-buffer gnus-article-current-summary 'norecord)
5655 (setq func (lookup-key (current-local-map) (this-command-keys)))
5656 (call-interactively func)))
5658 (defun gnus-article-check-buffer ()
5659 "Beep if not in an article buffer."
5660 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5661 (error "Command invoked outside of a Gnus article buffer")))
5663 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5664 "Read a summary buffer key sequence and execute it from the article buffer."
5666 (gnus-article-check-buffer)
5668 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5669 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5670 "=" "^" "\M-^" "|"))
5676 '("n" "Gn" "p" "Gp"))
5679 (set-buffer gnus-article-current-summary)
5680 (let (gnus-pick-mode)
5681 (push (or key last-command-event) unread-command-events)
5682 (setq keys (static-if (featurep 'xemacs)
5683 (events-to-keys (read-key-sequence nil))
5684 (read-key-sequence nil)))))
5687 (if (or (member keys nosaves)
5688 (member keys nosave-but-article)
5689 (member keys nosave-in-article))
5691 (save-window-excursion
5692 (pop-to-buffer gnus-article-current-summary 'norecord)
5693 ;; We disable the pick minor mode commands.
5694 (let (gnus-pick-mode)
5695 (setq func (lookup-key (current-local-map) keys))))
5699 (unless (member keys nosave-in-article)
5700 (set-buffer gnus-article-current-summary))
5701 (call-interactively func)
5702 (setq new-sum-point (point)))
5703 (when (member keys nosave-but-article)
5704 (pop-to-buffer gnus-article-buffer 'norecord)))
5705 ;; These commands should restore window configuration.
5706 (let ((obuf (current-buffer))
5707 (owin (current-window-configuration))
5709 win func in-buffer selected new-sum-start new-sum-hscroll)
5710 (cond (not-restore-window
5711 (pop-to-buffer gnus-article-current-summary 'norecord))
5712 ((setq win (get-buffer-window gnus-article-current-summary))
5713 (select-window win))
5715 (switch-to-buffer gnus-article-current-summary 'norecord)))
5716 (setq in-buffer (current-buffer))
5717 ;; We disable the pick minor mode commands.
5718 (if (and (setq func (let (gnus-pick-mode)
5719 (lookup-key (current-local-map) keys)))
5722 (call-interactively func)
5723 (when (eq win (selected-window))
5724 (setq new-sum-point (point)
5725 new-sum-start (window-start win)
5726 new-sum-hscroll (window-hscroll win)))
5727 (when (eq in-buffer (current-buffer))
5728 (setq selected (gnus-summary-select-article))
5730 (unless not-restore-window
5731 (set-window-configuration owin))
5732 (when (eq selected 'old)
5734 (set-window-start (get-buffer-window (current-buffer))
5736 (set-window-point (get-buffer-window (current-buffer))
5738 (when (and (not not-restore-window)
5740 (set-window-point win new-sum-point)
5741 (set-window-start win new-sum-start)
5742 (set-window-hscroll win new-sum-hscroll))))
5743 (set-window-configuration owin)
5746 (defun gnus-article-describe-key (key)
5747 "Display documentation of the function invoked by KEY. KEY is a string."
5748 (interactive "kDescribe key: ")
5749 (gnus-article-check-buffer)
5750 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5752 (set-buffer gnus-article-current-summary)
5753 (let (gnus-pick-mode)
5754 (if (featurep 'xemacs)
5756 (push (elt key 0) unread-command-events)
5757 (setq key (events-to-keys
5758 (read-key-sequence "Describe key: "))))
5759 (setq unread-command-events
5761 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5763 (setq key (read-key-sequence "Describe key: "))))
5765 (describe-key key)))
5767 (defun gnus-article-describe-key-briefly (key &optional insert)
5768 "Display documentation of the function invoked by KEY. KEY is a string."
5769 (interactive "kDescribe key: \nP")
5770 (gnus-article-check-buffer)
5771 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5773 (set-buffer gnus-article-current-summary)
5774 (let (gnus-pick-mode)
5775 (if (featurep 'xemacs)
5777 (push (elt key 0) unread-command-events)
5778 (setq key (events-to-keys
5779 (read-key-sequence "Describe key: "))))
5780 (setq unread-command-events
5782 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5784 (setq key (read-key-sequence "Describe key: "))))
5785 (describe-key-briefly key insert))
5786 (describe-key-briefly key insert)))
5788 (defun gnus-article-reply-with-original (&optional wide)
5789 "Start composing a reply mail to the current message.
5790 The text in the region will be yanked. If the region isn't active,
5791 the entire article will be yanked."
5793 (let ((article (cdr gnus-article-current))
5795 (if (not (gnus-region-active-p))
5796 (with-current-buffer gnus-summary-buffer
5797 (gnus-summary-reply (list (list article)) wide))
5798 (setq contents (buffer-substring (point) (mark t)))
5799 ;; Deactivate active regions.
5800 (when (and (boundp 'transient-mark-mode)
5801 transient-mark-mode)
5802 (setq mark-active nil))
5803 (with-current-buffer gnus-summary-buffer
5805 (list (list article contents)) wide)))))
5807 (defun gnus-article-followup-with-original ()
5808 "Compose a followup to the current article.
5809 The text in the region will be yanked. If the region isn't active,
5810 the entire article will be yanked."
5812 (let ((article (cdr gnus-article-current))
5814 (if (not (gnus-region-active-p))
5815 (with-current-buffer gnus-summary-buffer
5816 (gnus-summary-followup (list (list article))))
5817 (setq contents (buffer-substring (point) (mark t)))
5818 ;; Deactivate active regions.
5819 (when (and (boundp 'transient-mark-mode)
5820 transient-mark-mode)
5821 (setq mark-active nil))
5822 (with-current-buffer gnus-summary-buffer
5823 (gnus-summary-followup
5824 (list (list article contents)))))))
5826 (defun gnus-article-hide (&optional arg force)
5827 "Hide all the gruft in the current article.
5828 This means that signatures, cited text and (some) headers will be
5830 If given a prefix, show the hidden text instead."
5831 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5832 (gnus-article-hide-headers arg)
5833 (gnus-article-hide-list-identifiers arg)
5834 (gnus-article-hide-citation-maybe arg force)
5835 (gnus-article-hide-signature arg))
5837 (defun gnus-article-maybe-highlight ()
5838 "Do some article highlighting if article highlighting is requested."
5839 (when (gnus-visual-p 'article-highlight 'highlight)
5840 (gnus-article-highlight-some)))
5842 (defun gnus-check-group-server ()
5843 ;; Make sure the connection to the server is alive.
5844 (unless (gnus-server-opened
5845 (gnus-find-method-for-group gnus-newsgroup-name))
5846 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5847 (gnus-request-group gnus-newsgroup-name t)))
5850 (autoload 'nneething-get-file-name "nneething"))
5852 (defun gnus-request-article-this-buffer (article group)
5853 "Get an article and insert it into this buffer."
5854 (let (do-update-line sparse-header)
5858 (gnus-kill-all-overlays)
5859 (setq group (or group gnus-newsgroup-name))
5861 ;; Using `gnus-request-article' directly will insert the article into
5862 ;; `nntp-server-buffer' - so we'll save some time by not having to
5863 ;; copy it from the server buffer into the article buffer.
5865 ;; We only request an article by message-id when we do not have the
5866 ;; headers for it, so we'll have to get those.
5867 (when (stringp article)
5868 (gnus-read-header article))
5870 ;; If the article number is negative, that means that this article
5871 ;; doesn't belong in this newsgroup (possibly), so we find its
5872 ;; message-id and request it by id instead of number.
5873 (when (and (numberp article)
5875 (get-buffer gnus-summary-buffer)
5876 (gnus-buffer-exists-p gnus-summary-buffer))
5878 (set-buffer gnus-summary-buffer)
5879 (let ((header (gnus-summary-article-header article)))
5882 ((memq article gnus-newsgroup-sparse)
5883 ;; This is a sparse gap article.
5884 (setq do-update-line article)
5885 (setq article (mail-header-id header))
5886 (setq sparse-header (gnus-read-header article))
5887 (setq gnus-newsgroup-sparse
5888 (delq article gnus-newsgroup-sparse)))
5890 ;; It's a real article.
5891 (setq article (mail-header-id header)))
5893 ;; It is an extracted pseudo-article.
5894 (setq article 'pseudo)
5895 (gnus-request-pseudo-article header))))
5897 (let ((method (gnus-find-method-for-group
5898 gnus-newsgroup-name)))
5899 (when (and (eq (car method) 'nneething)
5901 (let ((dir (nneething-get-file-name
5902 (mail-header-id header))))
5903 (when (and (stringp dir)
5904 (file-directory-p dir))
5905 (setq article 'nneething)
5906 (gnus-group-enter-directory dir))))))))
5909 ;; Refuse to select canceled articles.
5910 ((and (numberp article)
5912 (get-buffer gnus-summary-buffer)
5913 (gnus-buffer-exists-p gnus-summary-buffer)
5914 (eq (cdr (with-current-buffer gnus-summary-buffer
5915 (assq article gnus-newsgroup-reads)))
5916 gnus-canceled-mark))
5918 ;; We first check `gnus-original-article-buffer'.
5919 ((and (get-buffer gnus-original-article-buffer)
5921 (with-current-buffer gnus-original-article-buffer
5922 (and (equal (car gnus-original-article) group)
5923 (eq (cdr gnus-original-article) article))))
5924 (insert-buffer-substring gnus-original-article-buffer)
5926 ;; Check the backlog.
5927 ((and gnus-keep-backlog
5928 (gnus-backlog-request-article group article (current-buffer)))
5930 ;; Check asynchronous pre-fetch.
5931 ((gnus-async-request-fetched-article group article (current-buffer))
5932 (gnus-async-prefetch-next group article gnus-summary-buffer)
5933 (when (and (numberp article) gnus-keep-backlog)
5934 (gnus-backlog-enter-article group article (current-buffer)))
5937 ((and gnus-use-cache
5939 (gnus-cache-request-article article group))
5941 ;; Check the agent cache.
5942 ((gnus-agent-request-article article group)
5944 ;; Get the article and put into the article buffer.
5945 ((or (stringp article)
5947 (let ((gnus-override-method gnus-override-method)
5948 (methods (and (stringp article)
5949 gnus-refer-article-method))
5950 (backend (car (gnus-find-method-for-group
5951 gnus-newsgroup-name)))
5953 (inhibit-read-only t))
5954 (if (or (not (listp methods))
5955 (and (symbolp (car methods))
5956 (assq (car methods) nnoo-definition-alist)))
5957 (setq methods (list methods)))
5958 (when (and (null gnus-override-method)
5960 (setq gnus-override-method (pop methods)))
5962 (when (eq gnus-override-method 'current)
5963 (setq gnus-override-method
5964 (with-current-buffer gnus-summary-buffer
5965 gnus-current-select-method)))
5967 (gnus-kill-all-overlays)
5968 (let ((gnus-newsgroup-name group))
5969 (gnus-check-group-server))
5971 ((gnus-request-article article group (current-buffer))
5972 (when (numberp article)
5973 (gnus-async-prefetch-next group article
5974 gnus-summary-buffer)
5975 (when gnus-keep-backlog
5976 (gnus-backlog-enter-article
5977 group article (current-buffer))))
5978 (setq result 'article))
5980 (setq gnus-override-method (pop methods)))
5981 ((not (string-match "^400 "
5982 (nnheader-get-report backend)))
5983 ;; If we get 400 server disconnect, reconnect and
5984 ;; retry; otherwise, assume the article has expired.
5985 (setq result 'done))))
5986 (and (eq result 'article) 'article)))
5990 ;; Associate this article with the current summary buffer.
5991 (setq gnus-article-current-summary gnus-summary-buffer)
5993 ;; Take the article from the original article buffer
5994 ;; and place it in the buffer it's supposed to be in.
5995 (when (and (get-buffer gnus-article-buffer)
5996 (equal (buffer-name (current-buffer))
5997 (buffer-name (get-buffer gnus-article-buffer))))
5999 (if (get-buffer gnus-original-article-buffer)
6000 (set-buffer gnus-original-article-buffer)
6001 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
6002 (buffer-disable-undo)
6003 (setq major-mode 'gnus-original-article-mode)
6004 (setq buffer-read-only t))
6005 (let ((inhibit-read-only t))
6007 (insert-buffer-substring gnus-article-buffer))
6008 (setq gnus-original-article (cons group article)))
6011 (run-hooks 'gnus-article-decode-hook)
6012 ;; Mark article as decoded or not.
6013 (setq gnus-article-decoded-p gnus-article-decode-hook))
6015 ;; Update sparse articles.
6016 (when (and do-update-line
6017 (or (numberp article)
6019 (let ((buf (current-buffer)))
6020 (set-buffer gnus-summary-buffer)
6021 (gnus-summary-update-article do-update-line sparse-header)
6022 (gnus-summary-goto-subject do-update-line nil t)
6023 (set-window-point (gnus-get-buffer-window (current-buffer) t)
6025 (set-buffer buf))))))
6031 (defcustom gnus-article-edit-mode-hook nil
6032 "Hook run in article edit mode buffers."
6033 :group 'gnus-article-various
6036 (defcustom gnus-article-edit-article-setup-function
6037 'gnus-article-mime-edit-article-setup
6038 "Function called to setup an editing article buffer."
6039 :group 'gnus-article-various
6042 (defvar gnus-article-edit-done-function nil)
6044 (defvar gnus-article-edit-mode-map nil)
6046 ;; Should we be using derived.el for this?
6047 (unless gnus-article-edit-mode-map
6048 (setq gnus-article-edit-mode-map (make-keymap))
6049 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
6051 (gnus-define-keys gnus-article-edit-mode-map
6052 "\C-c?" describe-mode
6053 "\C-c\C-c" gnus-article-edit-done
6054 "\C-c\C-k" gnus-article-edit-exit
6055 "\C-c\C-f\C-t" message-goto-to
6056 "\C-c\C-f\C-o" message-goto-from
6057 "\C-c\C-f\C-b" message-goto-bcc
6058 ;;"\C-c\C-f\C-w" message-goto-fcc
6059 "\C-c\C-f\C-c" message-goto-cc
6060 "\C-c\C-f\C-s" message-goto-subject
6061 "\C-c\C-f\C-r" message-goto-reply-to
6062 "\C-c\C-f\C-n" message-goto-newsgroups
6063 "\C-c\C-f\C-d" message-goto-distribution
6064 "\C-c\C-f\C-f" message-goto-followup-to
6065 "\C-c\C-f\C-m" message-goto-mail-followup-to
6066 "\C-c\C-f\C-k" message-goto-keywords
6067 "\C-c\C-f\C-u" message-goto-summary
6068 "\C-c\C-f\C-i" message-insert-or-toggle-importance
6069 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
6070 "\C-c\C-b" message-goto-body
6071 "\C-c\C-i" message-goto-signature
6073 "\C-c\C-t" message-insert-to
6074 "\C-c\C-n" message-insert-newsgroups
6075 "\C-c\C-o" message-sort-headers
6076 "\C-c\C-e" message-elide-region
6077 "\C-c\C-v" message-delete-not-region
6078 "\C-c\C-z" message-kill-to-signature
6079 "\M-\r" message-newline-and-reformat
6080 "\C-c\C-a" mml-attach-file
6081 "\C-a" message-beginning-of-line
6083 "\M-;" comment-region)
6085 (gnus-define-keys (gnus-article-edit-wash-map
6086 "\C-c\C-w" gnus-article-edit-mode-map)
6087 "f" gnus-article-edit-full-stops))
6090 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
6092 ["Fetch To" message-insert-to t]
6093 ["Fetch Newsgroups" message-insert-newsgroups t]
6095 ["To" message-goto-to t]
6096 ["From" message-goto-from t]
6097 ["Subject" message-goto-subject t]
6098 ["Cc" message-goto-cc t]
6099 ["Reply-To" message-goto-reply-to t]
6100 ["Summary" message-goto-summary t]
6101 ["Keywords" message-goto-keywords t]
6102 ["Newsgroups" message-goto-newsgroups t]
6103 ["Followup-To" message-goto-followup-to t]
6104 ["Mail-Followup-To" message-goto-mail-followup-to t]
6105 ["Distribution" message-goto-distribution t]
6106 ["Body" message-goto-body t]
6107 ["Signature" message-goto-signature t]))
6109 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
6110 "Major mode for editing articles.
6111 This is an extended text-mode.
6113 \\{gnus-article-edit-mode-map}"
6114 (make-local-variable 'gnus-article-edit-done-function)
6115 (make-local-variable 'gnus-prev-winconf)
6116 (set (make-local-variable 'font-lock-defaults)
6117 '(message-font-lock-keywords t))
6118 (set (make-local-variable 'mail-header-separator) "")
6119 (set (make-local-variable 'gnus-article-edit-mode) t)
6120 (easy-menu-add message-mode-field-menu message-mode-map)
6121 (setq buffer-read-only nil)
6122 (buffer-enable-undo)
6125 (defun gnus-article-edit (&optional force)
6126 "Edit the current article.
6127 This will have permanent effect only in mail groups.
6128 If FORCE is non-nil, allow editing of articles even in read-only
6131 (when (and (not force)
6132 (gnus-group-read-only-p))
6133 (error "The current newsgroup does not support article editing"))
6134 (gnus-article-date-original)
6135 (gnus-article-edit-article
6137 `(lambda (no-highlight)
6139 (gnus-summary-edit-article-done
6140 ,(or (mail-header-references gnus-current-headers) "")
6141 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
6143 (defun gnus-article-edit-article (start-func exit-func)
6144 "Start editing the contents of the current article buffer."
6145 (let ((winconf (current-window-configuration)))
6146 (set-buffer gnus-article-buffer)
6147 (let ((message-auto-save-directory
6148 ;; Don't associate the article buffer with a draft file.
6150 (gnus-article-edit-mode))
6151 (funcall start-func)
6152 (set-buffer-modified-p nil)
6153 (gnus-configure-windows 'edit-article)
6154 (setq gnus-article-edit-done-function exit-func)
6155 (setq gnus-prev-winconf winconf)
6156 (when gnus-article-edit-article-setup-function
6157 (funcall gnus-article-edit-article-setup-function))
6158 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit")))
6160 (defun gnus-article-edit-done (&optional arg)
6161 "Update the article edits and exit."
6163 (let ((func gnus-article-edit-done-function)
6164 (buf (current-buffer))
6165 (start (window-start))
6167 (winconf gnus-prev-winconf))
6168 (remove-hook 'gnus-article-mode-hook
6169 'gnus-article-mime-edit-article-unwind)
6170 (widen) ;; Widen it in case that users narrowed the buffer.
6173 ;; The cache and backlog have to be flushed somewhat.
6174 (when gnus-keep-backlog
6175 (gnus-backlog-remove-article
6176 (car gnus-article-current) (cdr gnus-article-current)))
6177 ;; Flush original article as well.
6179 (when (get-buffer gnus-original-article-buffer)
6180 (set-buffer gnus-original-article-buffer)
6181 (setq gnus-original-article nil)))
6182 (when gnus-use-cache
6183 (gnus-cache-update-article
6184 (car gnus-article-current) (cdr gnus-article-current)))
6185 ;; We remove all text props from the article buffer.
6186 (kill-all-local-variables)
6187 (set-text-properties (point-min) (point-max) nil)
6189 (set-window-configuration winconf)
6191 (set-window-start (get-buffer-window buf) start)
6192 (set-window-point (get-buffer-window buf) (point)))
6193 (gnus-summary-show-article))
6195 (defun gnus-article-edit-exit ()
6196 "Exit the article editing without updating."
6198 (when (or (not (buffer-modified-p))
6199 (yes-or-no-p "Article modified; kill anyway? "))
6200 (let ((curbuf (current-buffer))
6202 (window-start (window-start)))
6204 (if (gnus-buffer-live-p gnus-original-article-buffer)
6205 (insert-buffer-substring gnus-original-article-buffer))
6206 (let ((winconf gnus-prev-winconf))
6207 (kill-all-local-variables)
6209 (set-window-configuration winconf)
6210 ;; Tippy-toe some to make sure that point remains where it was.
6211 (save-current-buffer
6213 (set-window-start (get-buffer-window (current-buffer)) window-start)
6215 (gnus-summary-show-article)))
6217 (defun gnus-article-edit-full-stops ()
6218 "Interactively repair spacing at end of sentences."
6221 (goto-char (point-min))
6222 (search-forward-regexp "^$" nil t)
6223 (let ((case-fold-search nil))
6224 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
6227 ;;; Article editing with MIME-Edit
6230 (defcustom gnus-article-mime-edit-article-setup-hook nil
6231 "Hook run after setting up a MIME editing article buffer."
6232 :group 'gnus-article-various
6235 (defun gnus-article-mime-edit-article-unwind ()
6236 "Unwind `gnus-article-buffer' if article editing was given up."
6237 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6238 (when (featurep 'font-lock)
6239 (setq font-lock-defaults nil)
6240 (font-lock-mode -1))
6241 (when mime-edit-mode-flag
6242 (mime-edit-exit 'nomime 'no-error)
6245 (defun gnus-article-mime-edit-article-setup ()
6246 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
6247 after replacing with the original article."
6248 (setq gnus-show-mime t)
6249 (setq gnus-article-edit-done-function
6250 `(lambda (&rest args)
6251 (when mime-edit-mode-flag
6252 (let (mime-edit-insert-user-agent-field)
6255 (goto-char (point-min))
6256 (let (case-fold-search)
6257 (when (re-search-forward
6258 (format "^%s$" (regexp-quote mail-header-separator))
6260 (replace-match "")))
6261 (apply ,gnus-article-edit-done-function args)
6264 (buffer-substring-no-properties (point-min) (point-max))
6265 (set-buffer (get-buffer-create gnus-original-article-buffer))
6267 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6268 (set-buffer gnus-article-buffer)
6269 (gnus-article-prepare-display)))
6270 (substitute-key-definition 'gnus-article-edit-done
6271 'gnus-article-mime-edit-done
6272 gnus-article-edit-mode-map)
6273 (substitute-key-definition 'gnus-article-edit-exit
6274 'gnus-article-mime-edit-exit
6275 gnus-article-edit-mode-map)
6277 (insert-buffer-substring gnus-original-article-buffer)
6278 (unless (member (with-current-buffer gnus-summary-buffer
6279 gnus-newsgroup-name)
6280 '("nndraft:delayed" "nndraft:drafts"))
6281 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
6282 (fset 'mime-edit-decode-single-part-in-buffer
6283 (lambda (&rest args)
6284 (if (let ((content-type (car args)))
6285 (and (eq 'message (mime-content-type-primary-type
6287 (eq 'rfc822 (mime-content-type-subtype
6289 (setcar (cdr args) 'not-decode-text))
6293 (fset 'mime-edit-decode-single-part-in-buffer ofn))))
6294 (when (featurep 'font-lock)
6295 (set (make-local-variable 'font-lock-defaults)
6296 '(message-font-lock-keywords t))
6297 (font-lock-set-defaults)
6298 (turn-on-font-lock))
6299 (set-buffer-modified-p nil)
6300 (delete-other-windows)
6301 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6302 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
6304 (defun gnus-article-mime-edit-done (&optional arg)
6305 "Update the article MIME edits and exit."
6307 (when (featurep 'font-lock)
6308 (setq font-lock-defaults nil)
6309 (font-lock-mode -1))
6310 (let ((inhibit-read-only t))
6311 (gnus-article-edit-done arg)))
6313 (defun gnus-article-mime-edit-exit ()
6314 "Exit the article MIME editing without updating."
6316 (when (or (not (buffer-modified-p))
6317 (yes-or-no-p "Article modified; kill anyway? "))
6318 (when (featurep 'font-lock)
6319 (setq font-lock-defaults nil)
6320 (font-lock-mode -1))
6321 (when mime-edit-mode-flag
6322 (let (mime-edit-insert-user-agent-field)
6325 (goto-char (point-min))
6326 (let (case-fold-search)
6327 (when (re-search-forward
6328 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
6329 (replace-match "")))
6330 (let ((winconf gnus-prev-winconf))
6332 (buffer-substring-no-properties (point-min) (point-max))
6333 (set-buffer (get-buffer-create gnus-original-article-buffer))
6335 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6336 (set-buffer gnus-article-buffer)
6337 (gnus-article-prepare-display)
6338 (set-window-configuration winconf))))
6341 ;;; Article highlights
6344 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6346 ;;; Internal Variables:
6348 (defcustom gnus-button-url-regexp
6349 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
6350 "\\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:]]\\)"
6351 "\\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\\)\\)")
6352 "Regular expression that matches URLs."
6353 :group 'gnus-article-buttons
6356 (defcustom gnus-button-valid-fqdn-regexp
6357 message-valid-fqdn-regexp
6358 "Regular expression that matches a valid FQDN."
6360 :group 'gnus-article-buttons
6363 ;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
6364 (defcustom gnus-button-valid-localpart-regexp
6365 "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*"
6366 "Regular expression that matches a localpart of mail addresses or MIDs."
6368 :group 'gnus-article-buttons
6371 (defcustom gnus-button-man-handler 'manual-entry
6372 "Function to use for displaying man pages.
6373 The function must take at least one argument with a string naming the
6376 :type '(choice (function-item :tag "Man" manual-entry)
6377 (function-item :tag "Woman" woman)
6378 (function :tag "Other"))
6379 :group 'gnus-article-buttons)
6381 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6382 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6383 If the default site is too slow, try to find a CTAN mirror, see
6384 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6385 the variable `gnus-button-handle-ctan'."
6387 :group 'gnus-article-buttons
6388 :link '(custom-manual "(gnus)Group Parameters")
6389 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6390 (const "http://tug.ctan.org/tex-archive/")
6391 (const "http://www.dante.de/CTAN/")
6392 (string :tag "Other")))
6394 (defcustom gnus-button-ctan-handler 'browse-url
6395 "Function to use for displaying CTAN links.
6396 The function must take one argument, the string naming the URL."
6398 :type '(choice (function-item :tag "Browse Url" browse-url)
6399 (function :tag "Other"))
6400 :group 'gnus-article-buttons)
6402 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6403 "Bogus strings removed from CTAN URLs."
6405 :group 'gnus-article-buttons
6406 :type '(choice (const "^/?tex-archive/\\|/")
6407 (regexp :tag "Other")))
6409 (defcustom gnus-button-ctan-directory-regexp
6411 (list "archive-tools" "biblio" "bibliography" "digests" "documentation"
6412 "dviware" "fonts" "graphics" "help" "indexing" "info" "language"
6413 "languages" "macros" "nonfree" "obsolete" "support" "systems"
6414 "tds" "tools" "usergrps" "web") t)
6415 "Regular expression for ctan directories.
6416 It should match all directories in the top level of `gnus-ctan-url'."
6418 :group 'gnus-article-buttons
6421 (defcustom gnus-button-mid-or-mail-regexp
6422 (concat "\\b\\(<?" gnus-button-valid-localpart-regexp "@"
6423 gnus-button-valid-fqdn-regexp
6425 "Regular expression that matches a message ID or a mail address."
6427 :group 'gnus-article-buttons
6430 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6431 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6432 Strings like this can be either a message ID or a mail address. If it is one
6433 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6434 message ID or a mail address, respectively. If this variable is set to the
6435 symbol `ask', always query the user what do do. If it is a function, this
6436 function will be called with the string as it's only argument. The function
6437 must return `mid', `mail', `invalid' or `ask'."
6439 :group 'gnus-article-buttons
6440 :type '(choice (function-item :tag "Heuristic function"
6441 gnus-button-mid-or-mail-heuristic)
6446 (defcustom gnus-button-mid-or-mail-heuristic-alist
6447 '((-10.0 . ".+\\$.+@")
6450 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6451 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6452 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6453 (-1.0 . "^[^a-z]+@")
6455 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6456 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6457 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6458 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6461 (-1.0 . "^[0-9][0-9]")
6463 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6464 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6465 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6466 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6468 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6469 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6472 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6474 ;; compensation for TDMA dated mail addresses:
6475 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6477 (-20.0 . "\\.fsf@") ;; Gnus
6480 (-20.0 . "_-_") ;; Subject change in thread
6482 (-20.0 . "\\.ln@") ;; leafnode
6483 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6484 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6486 ;; (5.0 . "") ;; $local_part_len <= 7
6487 (10.0 . "^[^0-9]+@")
6488 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6489 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6492 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6494 (0.5 . "^[A-Z][a-z]")
6495 (0.5 . "^[A-Z][a-z][a-z]")
6496 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6497 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6498 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6500 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6501 address. The REGEXP is processed with `case-fold-search' set to nil."
6503 :group 'gnus-article-buttons
6504 :type '(repeat (cons (number :tag "Rate")
6505 (regexp :tag "Regexp"))))
6507 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6508 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6509 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6510 address, `ask' if unsure and `invalid' if the string is invalid."
6511 (let ((case-fold-search nil)
6512 (list gnus-button-mid-or-mail-heuristic-alist)
6513 (result 0) rate regexp lpartlen elem)
6515 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6516 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6517 ;; Certain special cases...
6520 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6521 "^[0-9]+\\.[0-9]+@compuserve\\|"
6522 "@public\\.gmane\\.org")
6524 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6525 (setq result 'mail))
6526 (when (string-match "@.*@\\| " mid-or-mail)
6527 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6528 (setq result 'invalid))
6529 ;; Nothing more to do, if result is not a number here...
6530 (when (numberp result)
6532 (setq elem (car list)
6536 (when (string-match regexp mid-or-mail)
6537 (setq result (+ result rate))
6539 9 "`%s' matched `%s', rate `%s', result `%s'."
6540 mid-or-mail regexp rate result)))
6541 (when (<= lpartlen 7)
6542 (setq result (+ result 5.0))
6543 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6544 mid-or-mail result))
6545 (when (>= lpartlen 12)
6546 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6548 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6549 ;; Long local part should contain realname if e-mail address,
6550 ;; too many digits: message-id.
6551 ;; $score -= 5.0 + 0.1 * $local_part_len;
6552 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6553 (setq result (+ result rate))
6555 9 "Many digits in `%s', rate `%s', result `%s'."
6556 mid-or-mail rate result))
6557 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6559 ;; Too few vowels [^aeiouy]{4,}.*\@
6560 (setq result (+ result -5.0))
6562 9 "Few vowels in `%s', rate `%s', result `%s'."
6563 mid-or-mail -5.0 result))
6565 (setq result (+ result 5.0))
6567 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6568 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6569 ;; Maybe we should make this a customizable alist: (condition . 'result)
6571 ((symbolp result) result)
6572 ;; Now convert number into proper results:
6573 ((< result -10.0) 'mid)
6574 ((> result 10.0) 'mail)
6577 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6578 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6579 (url-mid (concat "news" ":" mid-or-mail))
6580 (url-mailto (concat "mailto" ":" mid-or-mail)))
6581 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6582 (when (fboundp pref)
6584 ;; get rid of surrounding angles...
6586 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6587 (if (or (eq 'mid guessed) (eq 'mail guessed))
6591 (save-window-excursion
6592 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6595 (cond ((eq pref 'mid)
6596 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6597 (gnus-button-handle-news url-mid))
6599 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6600 (gnus-url-mailto url-mailto))
6601 (t (gnus-message 3 "Invalid string.")))))
6603 (defun gnus-button-handle-custom (url)
6604 "Follow a Custom URL."
6605 (customize-apropos (gnus-url-unhex-string url)))
6607 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6609 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6612 (defun gnus-button-handle-describe-function (url)
6613 "Call `describe-function' when pushing the corresponding URL button."
6616 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6618 (defun gnus-button-handle-describe-variable (url)
6619 "Call `describe-variable' when pushing the corresponding URL button."
6622 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6624 (defun gnus-button-handle-symbol (url)
6625 "Display help on variable or function.
6626 Calls `describe-variable' or `describe-function'."
6627 (let ((sym (intern url)))
6629 ((fboundp sym) (describe-function sym))
6630 ((boundp sym) (describe-variable sym))
6631 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6633 (defun gnus-button-handle-describe-key (url)
6634 "Call `describe-key' when pushing the corresponding URL button."
6636 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6637 (keys (ignore-errors (eval `(kbd ,key-string)))))
6640 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6642 (defun gnus-button-handle-apropos (url)
6643 "Call `apropos' when pushing the corresponding URL button."
6644 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6646 (defun gnus-button-handle-apropos-command (url)
6647 "Call `apropos' when pushing the corresponding URL button."
6649 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6651 (defun gnus-button-handle-apropos-variable (url)
6652 "Call `apropos' when pushing the corresponding URL button."
6654 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6655 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6657 (defun gnus-button-handle-apropos-documentation (url)
6658 "Call `apropos' when pushing the corresponding URL button."
6660 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6661 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6663 (defun gnus-button-handle-library (url)
6664 "Call `locate-library' when pushing the corresponding URL button."
6665 (gnus-message 9 "url=`%s'" url)
6666 (let* ((lib (locate-library url))
6667 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6669 (gnus-message 1 "Cannot locale library `%s'." url)
6670 (find-file-read-only file))))
6672 (defun gnus-button-handle-ctan (url)
6673 "Call `browse-url' when pushing a CTAN URL button."
6675 gnus-button-ctan-handler
6678 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6680 (defcustom gnus-button-tex-level 5
6681 "*Integer that says how many TeX-related buttons Gnus will show.
6682 The higher the number, the more buttons will appear and the more false
6683 positives are possible. Note that you can set this variable local to
6684 specific groups. Setting it higher in TeX groups is probably a good idea.
6685 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6686 how to set variables in specific groups."
6688 :group 'gnus-article-buttons
6689 :link '(custom-manual "(gnus)Group Parameters")
6692 (defcustom gnus-button-man-level 5
6693 "*Integer that says how many man-related buttons Gnus will show.
6694 The higher the number, the more buttons will appear and the more false
6695 positives are possible. Note that you can set this variable local to
6696 specific groups. Setting it higher in Unix groups is probably a good idea.
6697 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6698 how to set variables in specific groups."
6700 :group 'gnus-article-buttons
6701 :link '(custom-manual "(gnus)Group Parameters")
6704 (defcustom gnus-button-emacs-level 5
6705 "*Integer that says how many emacs-related buttons Gnus will show.
6706 The higher the number, the more buttons will appear and the more false
6707 positives are possible. Note that you can set this variable local to
6708 specific groups. Setting it higher in Emacs or Gnus related groups is
6709 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6710 `gnus-parameters' on how to set variables in specific groups."
6712 :group 'gnus-article-buttons
6713 :link '(custom-manual "(gnus)Group Parameters")
6716 (defcustom gnus-button-message-level 5
6717 "*Integer that says how many buttons for news or mail messages will appear.
6718 The higher the number, the more buttons will appear and the more false
6719 positives are possible."
6720 ;; mail addresses, MIDs, URLs for news, ...
6722 :group 'gnus-article-buttons
6725 (defcustom gnus-button-browse-level 5
6726 "*Integer that says how many buttons for browsing will appear.
6727 The higher the number, the more buttons will appear and the more false
6728 positives are possible."
6729 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6731 :group 'gnus-article-buttons
6734 (defcustom gnus-button-alist
6735 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6736 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6737 ((concat "\\b\\(nntp\\|news\\):\\("
6738 gnus-button-valid-localpart-regexp "@[a-z0-9.-]+[a-z]\\)")
6739 0 t gnus-button-handle-news 2)
6740 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6741 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6742 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6743 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6744 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6745 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6746 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6747 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6748 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6749 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6750 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6751 ;; RFC 2368 (The mailto URL scheme)
6752 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6753 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6754 ("\\bmailto:\\([^ \n\t]+\\)"
6755 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6757 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6758 gnus-button-ctan-directory-regexp
6759 "[^][>)!;:,'\n\t ]+\\)")
6760 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6761 ((concat "\\btex-archive/\\("
6762 gnus-button-ctan-directory-regexp
6763 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6764 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6767 gnus-button-ctan-directory-regexp
6768 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6769 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6770 ;; This is info (home-grown style) <info://foo/bar+baz>
6771 ("\\binfo://\\([^'\">\n\t ]+\\)"
6772 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6773 ;; Info GNOME style <info:foo#bar_baz>
6774 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6775 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6776 ;; Info KDE style <info:(foo)bar baz>
6777 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6778 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6779 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6780 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6781 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6782 ;; Info links like `C-h i d m CC Mode RET'
6783 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6785 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6786 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6787 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6788 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6789 ;; Emacs help commands
6790 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6791 ;; regexp doesn't match arguments containing ` '.
6792 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6793 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6794 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6795 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6796 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6797 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6798 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6799 ;; The following entries may lead to many false positives so don't enable
6800 ;; them by default (use a high button level).
6801 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6802 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6803 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6804 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6805 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6806 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6807 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6808 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6809 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6810 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6811 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6812 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6813 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6814 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6815 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6816 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6817 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6818 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6819 ;; Unlike the other regexps we really have to require quoting
6820 ;; here to determine where it ends.
6821 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6822 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6823 ("<URL: *\\([^<>]*\\)>"
6824 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6825 ;; RFC 2396 (2.4.3., delims) ...
6826 ("\"URL: *\\([^\"]*\\)\""
6827 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6828 ;; RFC 2396 (2.4.3., delims) ...
6829 ("\"URL: *\\([^\"]*\\)\""
6830 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6832 (gnus-button-url-regexp
6833 0 (>= gnus-button-browse-level 0) browse-url 0)
6835 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6836 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6837 gnus-button-handle-man 1)
6838 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6839 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6840 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6841 gnus-button-handle-man 1)
6842 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6843 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6844 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6845 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6846 ;; MID or mail: To avoid too many false positives we don't try to catch
6847 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6848 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6849 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6850 ;; so that non-ambiguous entries (see above) match first.
6851 (gnus-button-mid-or-mail-regexp
6852 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6853 "*Alist of regexps matching buttons in article bodies.
6855 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6856 REGEXP: is the string (case insensitive) matching text around the button (can
6857 also be Lisp expression evaluating to a string),
6858 BUTTON: is the number of the regexp grouping actually matching the button,
6859 FORM: is a Lisp expression which must eval to true for the button to
6861 CALLBACK: is the function to call when the user push this button, and each
6862 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6864 CALLBACK can also be a variable, in that case the value of that
6865 variable it the real callback function."
6866 :group 'gnus-article-buttons
6867 :type '(repeat (list (choice regexp variable sexp)
6868 (integer :tag "Button")
6870 (function :tag "Callback")
6873 (integer :tag "Regexp group")))))
6875 (defcustom gnus-header-button-alist
6876 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6877 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6878 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6879 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6880 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6881 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
6882 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6883 0 (>= gnus-button-browse-level 0) browse-url 0)
6884 ("^Subject:" gnus-button-url-regexp
6885 0 (>= gnus-button-browse-level 0) browse-url 0)
6886 ("^[^:]+:" gnus-button-url-regexp
6887 0 (>= gnus-button-browse-level 0) browse-url 0)
6888 ("^OpenPGP:.*url=" gnus-button-url-regexp
6889 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
6890 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6891 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6892 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6893 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6894 "*Alist of headers and regexps to match buttons in article heads.
6896 This alist is very similar to `gnus-button-alist', except that each
6897 alist has an additional HEADER element first in each entry:
6899 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6901 HEADER is a regexp to match a header. For a fuller explanation, see
6902 `gnus-button-alist'."
6903 :group 'gnus-article-buttons
6904 :group 'gnus-article-headers
6905 :type '(repeat (list (regexp :tag "Header")
6906 (choice regexp variable)
6907 (integer :tag "Button")
6909 (function :tag "Callback")
6912 (integer :tag "Regexp group")))))
6916 (defun gnus-article-push-button (event)
6917 "Check text under the mouse pointer for a callback function.
6918 If the text under the mouse pointer has a `gnus-callback' property,
6919 call it with the value of the `gnus-data' text property."
6921 (set-buffer (window-buffer (posn-window (event-start event))))
6922 (let* ((pos (posn-point (event-start event)))
6923 (data (get-text-property pos 'gnus-data))
6924 (fun (get-text-property pos 'gnus-callback)))
6927 (funcall fun data))))
6929 (defun gnus-article-press-button ()
6930 "Check text at point for a callback function.
6931 If the text at point has a `gnus-callback' property,
6932 call it with the value of the `gnus-data' text property."
6934 (let ((data (get-text-property (point) 'gnus-data))
6935 (fun (get-text-property (point) 'gnus-callback)))
6937 (funcall fun data))))
6939 (defun gnus-article-prev-button (n)
6940 "Move point to N buttons backward.
6941 If N is negative, move forward instead."
6943 (gnus-article-next-button (- n)))
6945 (defun gnus-article-next-button (n)
6946 "Move point to N buttons forward.
6947 If N is negative, move backward instead."
6949 (let ((function (if (< n 0) 'previous-single-property-change
6950 'next-single-property-change))
6951 (inhibit-point-motion-hooks t)
6953 (limit (if (< n 0) (point-min) (point-max))))
6955 (while (and (not (= limit (point)))
6957 ;; Skip past the current button.
6958 (when (get-text-property (point) 'gnus-callback)
6959 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6960 ;; Go to the next (or previous) button.
6961 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
6962 ;; Put point at the start of the button.
6963 (when (and backward (not (get-text-property (point) 'gnus-callback)))
6964 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6965 ;; Skip past intangible buttons.
6966 (when (get-text-property (point) 'intangible)
6970 (gnus-message 5 "No more buttons"))
6973 (defun gnus-article-highlight (&optional force)
6974 "Highlight current article.
6975 This function calls `gnus-article-highlight-headers',
6976 `gnus-article-highlight-citation',
6977 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6978 do the highlighting. See the documentation for those functions."
6979 (interactive (list 'force))
6980 (gnus-article-highlight-headers)
6981 (gnus-article-highlight-citation force)
6982 (gnus-article-highlight-signature)
6983 (gnus-article-add-buttons force)
6984 (gnus-article-add-buttons-to-head))
6986 (defun gnus-article-highlight-some (&optional force)
6987 "Highlight current article.
6988 This function calls `gnus-article-highlight-headers',
6989 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6990 do the highlighting. See the documentation for those functions."
6991 (interactive (list 'force))
6992 (gnus-article-highlight-headers)
6993 (gnus-article-highlight-signature)
6994 (gnus-article-add-buttons))
6996 (defun gnus-article-highlight-headers ()
6997 "Highlight article headers as specified by `gnus-header-face-alist'."
6999 (gnus-with-article-headers
7000 (let (regexp header-face field-face from hpoints fpoints)
7001 (dolist (entry gnus-header-face-alist)
7002 (goto-char (point-min))
7003 (setq regexp (concat "^\\("
7004 (if (string-equal "" (nth 0 entry))
7008 header-face (nth 1 entry)
7009 field-face (nth 2 entry))
7010 (while (and (re-search-forward regexp nil t)
7014 (unless (search-forward ":" nil t)
7016 (when (and header-face
7017 (not (memq (point) hpoints)))
7018 (push (point) hpoints)
7019 (gnus-put-text-property from (point) 'face header-face))
7020 (when (and field-face
7021 (not (memq (setq from (point)) fpoints)))
7023 (if (re-search-forward "^[^ \t]" nil t)
7025 (goto-char (point-max)))
7026 (gnus-put-text-property from (point) 'face field-face)))))))
7028 (defun gnus-article-highlight-signature ()
7029 "Highlight the signature in an article.
7030 It does this by highlighting everything after
7031 `gnus-signature-separator' using the face `gnus-signature'."
7033 (when gnus-signature-face
7034 (gnus-with-article-buffer
7035 (let ((inhibit-point-motion-hooks t))
7037 (when (gnus-article-narrow-to-signature)
7038 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
7039 'face gnus-signature-face)))))))
7041 (defun gnus-article-buttonize-signature ()
7042 "Add button to the signature."
7045 (set-buffer gnus-article-buffer)
7046 (let ((inhibit-read-only t)
7047 (inhibit-point-motion-hooks t))
7048 (when (gnus-article-search-signature)
7049 (gnus-article-add-button (match-beginning 0) (match-end 0)
7050 'gnus-signature-toggle
7051 (set-marker (make-marker)
7052 (1+ (match-end 0))))))))
7054 (defun gnus-button-in-region-p (b e prop)
7055 "Say whether PROP exists in the region."
7056 (text-property-not-all b e prop nil))
7058 (defun gnus-article-add-buttons (&optional force)
7059 "Find external references in the article and make buttons of them.
7060 \"External references\" are things like Message-IDs and URLs, as
7061 specified by `gnus-button-alist'."
7062 (interactive (list 'force))
7063 (gnus-with-article-buffer
7064 (let ((inhibit-point-motion-hooks t)
7065 (case-fold-search t)
7066 (alist gnus-button-alist)
7068 ;; Remove all old markers.
7069 (let (marker entry new-list)
7070 (while (setq marker (pop gnus-button-marker-list))
7071 (if (or (< marker (point-min)) (>= marker (point-max)))
7072 (push marker new-list)
7074 (when (setq entry (gnus-button-entry))
7075 (put-text-property (match-beginning (nth 1 entry))
7076 (match-end (nth 1 entry))
7077 'gnus-callback nil))
7078 (set-marker marker nil)))
7079 (setq gnus-button-marker-list new-list))
7080 ;; We skip the headers.
7083 (while (setq entry (pop alist))
7084 (setq regexp (eval (car entry)))
7086 (while (re-search-forward regexp nil t)
7087 (let* ((start (and entry (match-beginning (nth 1 entry))))
7088 (end (and entry (match-end (nth 1 entry))))
7089 (from (match-beginning 0)))
7090 (when (and (or (eq t (nth 2 entry))
7091 (eval (nth 2 entry)))
7092 (not (gnus-button-in-region-p
7093 start end 'gnus-callback)))
7094 ;; That optional form returned non-nil, so we add the
7096 (gnus-article-add-button
7097 start end 'gnus-button-push
7098 (car (push (set-marker (make-marker) from)
7099 gnus-button-marker-list))))))))))
7101 ;; Add buttons to the head of an article.
7102 (defun gnus-article-add-buttons-to-head ()
7103 "Add buttons to the head of the article."
7105 (gnus-with-article-headers
7107 (dolist (entry gnus-header-button-alist)
7108 ;; Each alist entry.
7109 (goto-char (point-min))
7110 (while (re-search-forward (car entry) nil t)
7111 ;; Each header matching the entry.
7112 (setq beg (match-beginning 0))
7113 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
7114 (match-beginning 0))
7117 (while (re-search-forward (eval (nth 1 entry)) end t)
7118 ;; Each match within a header.
7119 (let* ((entry (cdr entry))
7120 (start (match-beginning (nth 1 entry)))
7121 (end (match-end (nth 1 entry)))
7122 (form (nth 2 entry)))
7123 (goto-char (match-end 0))
7125 (gnus-article-add-button
7126 start end (nth 3 entry)
7127 (buffer-substring (match-beginning (nth 4 entry))
7128 (match-end (nth 4 entry)))))))
7129 (goto-char end))))))
7131 ;;; External functions:
7133 (defun gnus-article-add-button (from to fun &optional data)
7134 "Create a button between FROM and TO with callback FUN and data DATA."
7135 (when gnus-article-button-face
7136 (gnus-overlay-put (gnus-make-overlay from to)
7137 'face gnus-article-button-face))
7138 (gnus-add-text-properties
7140 (nconc (and gnus-article-mouse-face
7141 (list gnus-mouse-face-prop gnus-article-mouse-face))
7142 (list 'gnus-callback fun)
7143 (and data (list 'gnus-data data))))
7144 (widget-convert-button 'link from to :action 'gnus-widget-press-button
7145 :button-keymap gnus-widget-button-keymap))
7147 ;;; Internal functions:
7149 (defun gnus-article-set-globals ()
7150 (with-current-buffer gnus-summary-buffer
7151 (gnus-set-global-variables)))
7153 (defun gnus-signature-toggle (end)
7154 (gnus-with-article-buffer
7155 (let ((inhibit-point-motion-hooks t)
7156 (limit (next-single-property-change end 'mime-view-entity
7158 (if (text-property-any end limit 'article-type 'signature)
7160 (gnus-delete-wash-type 'signature)
7161 (gnus-remove-text-properties-when
7162 'article-type 'signature end limit
7163 (cons 'article-type (cons 'signature
7164 gnus-hidden-properties))))
7165 (gnus-add-wash-type 'signature)
7166 (gnus-add-text-properties-when
7167 'article-type nil end limit
7168 (cons 'article-type (cons 'signature
7169 gnus-hidden-properties)))))
7170 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
7171 (gnus-set-mode-line 'article))))
7173 (defun gnus-button-entry ()
7174 ;; Return the first entry in `gnus-button-alist' matching this place.
7175 (let ((alist gnus-button-alist)
7178 (setq entry (pop alist))
7179 (if (looking-at (eval (car entry)))
7184 (defun gnus-button-push (marker)
7185 ;; Push button starting at MARKER.
7188 (let* ((entry (gnus-button-entry))
7189 (inhibit-point-motion-hooks t)
7191 (args (mapcar (lambda (group)
7192 (let ((string (match-string group)))
7193 (set-text-properties
7194 0 (length string) nil string)
7201 (fboundp (symbol-value fun)))
7202 (apply (symbol-value fun) args))
7204 (gnus-message 1 "You must define `%S' to use this button"
7205 (cons fun args)))))))
7207 (defun gnus-parse-news-url (url)
7208 (let (scheme server port group message-id articles)
7211 (goto-char (point-min))
7212 (when (looking-at "\\([A-Za-z]+\\):")
7213 (setq scheme (match-string 1))
7214 (goto-char (match-end 0)))
7215 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
7216 (setq server (match-string 1))
7217 (setq port (if (stringp (match-string 3))
7218 (string-to-number (match-string 3))
7220 (goto-char (match-end 0)))
7223 ((looking-at "\\(.*@.*\\)")
7224 (setq message-id (match-string 1)))
7225 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7226 (setq group (match-string 1)
7227 articles (split-string (match-string 2) "-")))
7228 ((looking-at "\\([^/]+\\)/?")
7229 (setq group (match-string 1)))
7231 (error "Unknown news URL syntax"))))
7232 (list scheme server port group message-id articles)))
7234 (defun gnus-button-handle-news (url)
7236 (destructuring-bind (scheme server port group message-id articles)
7237 (gnus-parse-news-url url)
7241 (set-buffer gnus-summary-buffer)
7243 (let ((gnus-refer-article-method
7244 (nconc (list (list 'nntp server))
7245 gnus-refer-article-method))
7246 (nntp-port-number (or port "nntp")))
7247 (gnus-message 7 "Fetching %s with %s"
7248 message-id gnus-refer-article-method)
7249 (gnus-summary-refer-article message-id))
7250 (gnus-summary-refer-article message-id))))
7252 (gnus-button-fetch-group url)))))
7254 (defun gnus-button-handle-man (url)
7256 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7257 (when (eq gnus-button-man-handler 'woman)
7258 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
7259 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7260 (funcall gnus-button-man-handler url))
7262 (defun gnus-button-handle-info-url (url)
7263 "Fetch an info URL."
7264 (setq url (mm-subst-char-in-string ?+ ?\ url))
7266 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
7267 (gnus-info-find-node
7268 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
7270 ")" (gnus-url-unhex-string (match-string 2 url)))))
7271 ((string-match "([^)\"]+)[^\"]+" url)
7273 (gnus-replace-in-string
7274 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
7275 (gnus-info-find-node url))
7276 (t (error "Can't parse %s" url))))
7278 (defun gnus-button-handle-info-url-gnome (url)
7279 "Fetch GNOME style info URL."
7280 (setq url (mm-subst-char-in-string ?_ ?\ url))
7281 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
7282 (gnus-info-find-node
7284 (gnus-url-unhex-string
7285 (match-string 1 url))
7287 (or (gnus-url-unhex-string
7288 (match-string 2 url))
7290 (error "Can't parse %s" url)))
7292 (defun gnus-button-handle-info-url-kde (url)
7293 "Fetch KDE style info URL."
7294 (gnus-info-find-node (gnus-url-unhex-string url)))
7296 (defun gnus-button-handle-info-keystrokes (url)
7297 "Call `info' when pushing the corresponding URL button."
7298 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
7303 (defun gnus-button-openpgp (url)
7304 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
7306 (mm-url-insert-file-contents-external url)
7307 (pgg-snarf-keys-region (point-min) (point-max))
7308 (pgg-display-output-buffer nil nil nil)))
7310 (defun gnus-button-message-id (message-id)
7312 (with-current-buffer gnus-summary-buffer
7313 (gnus-summary-refer-article message-id)))
7315 (defun gnus-button-fetch-group (address)
7316 "Fetch GROUP specified by ADDRESS."
7317 (if (not (string-match "[:/]" address))
7318 ;; This is just a simple group url.
7319 (gnus-group-read-ephemeral-group address gnus-select-method)
7322 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
7324 (error "Can't parse %s" address)
7325 (gnus-group-read-ephemeral-group
7326 (match-string 4 address)
7327 `(nntp ,(match-string 1 address)
7328 (nntp-address ,(match-string 1 address))
7329 (nntp-port-number ,(if (match-end 3)
7330 (match-string 3 address)
7333 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
7335 (defun gnus-url-parse-query-string (query &optional downcase)
7336 (let (retval pairs cur key val)
7337 (setq pairs (split-string query "&"))
7339 (setq cur (car pairs)
7341 (if (not (string-match "=" cur))
7343 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
7344 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
7346 (setq key (downcase key)))
7347 (setq cur (assoc key retval))
7349 (setcdr cur (cons val (cdr cur)))
7350 (setq retval (cons (list key val) retval)))))
7353 (defun gnus-url-mailto (url)
7354 ;; Send mail to someone
7355 (when (string-match "mailto:/*\\(.*\\)" url)
7356 (setq url (substring url (match-beginning 1) nil)))
7357 (let (to args subject func)
7358 (setq args (gnus-url-parse-query-string
7359 (if (string-match "^\\?" url)
7361 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
7362 (concat "to=" (match-string 1 url) "&"
7363 (match-string 2 url))
7364 (concat "to=" url)))
7366 subject (cdr-safe (assoc "subject" args)))
7369 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
7372 (message-position-on-field (caar args)))
7373 (insert (gnus-replace-in-string
7374 (mapconcat 'identity (reverse (cdar args)) ", ")
7376 (setq args (cdr args)))
7379 (message-goto-subject))))
7381 (defun gnus-button-embedded-url (address)
7382 "Activate ADDRESS with `browse-url'."
7383 (browse-url (gnus-strip-whitespace address)))
7385 ;;; Next/prev buttons in the article buffer.
7387 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
7388 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
7390 (defvar gnus-prev-page-map
7391 (let ((map (make-sparse-keymap)))
7392 (define-key map gnus-mouse-2 'gnus-button-prev-page)
7393 (define-key map "\r" 'gnus-button-prev-page)
7396 (defvar gnus-next-page-map
7397 (let ((map (make-sparse-keymap)))
7398 (unless (>= emacs-major-version 21)
7399 ;; XEmacs doesn't care.
7400 (set-keymap-parent map gnus-article-mode-map))
7401 (define-key map gnus-mouse-2 'gnus-button-next-page)
7402 (define-key map "\r" 'gnus-button-next-page)
7405 (defun gnus-insert-prev-page-button ()
7407 (inhibit-read-only t)
7408 (situation (get-text-property (point-min) 'mime-view-situation)))
7410 gnus-prev-page-line-format nil
7411 `(keymap ,gnus-prev-page-map
7413 gnus-callback gnus-article-button-prev-page
7414 article-type annotation
7415 mime-view-situation ,situation))
7416 (widget-convert-button
7418 ;; Exclude a newline.
7421 :action 'gnus-button-prev-page
7422 :button-keymap gnus-prev-page-map)))
7424 (defun gnus-button-next-page (&optional args more-args)
7425 "Go to the next page."
7427 (let ((win (selected-window)))
7428 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7429 (gnus-article-next-page)
7430 (select-window win)))
7432 (defun gnus-button-prev-page (&optional args more-args)
7433 "Go to the prev page."
7435 (let ((win (selected-window)))
7436 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7437 (gnus-article-prev-page)
7438 (select-window win)))
7440 (defun gnus-insert-next-page-button ()
7442 (inhibit-read-only t)
7443 (situation (get-text-property (point-min) 'mime-view-situation)))
7444 (gnus-eval-format gnus-next-page-line-format nil
7445 `(keymap ,gnus-next-page-map
7447 gnus-callback gnus-article-button-next-page
7448 article-type annotation
7449 mime-view-situation ,situation))
7450 (widget-convert-button
7452 ;; Exclude a newline.
7455 :action 'gnus-button-next-page
7456 :button-keymap gnus-next-page-map)))
7458 (defun gnus-article-button-next-page (arg)
7459 "Go to the next page."
7461 (let ((win (selected-window)))
7462 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7463 (gnus-article-next-page)
7464 (select-window win)))
7466 (defun gnus-article-button-prev-page (arg)
7467 "Go to the prev page."
7469 (let ((win (selected-window)))
7470 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7471 (gnus-article-prev-page)
7472 (select-window win)))
7474 (defvar gnus-decode-header-methods
7475 '(mail-decode-encoded-word-region)
7476 "List of methods used to decode headers.
7478 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7479 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
7480 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
7481 whose names match REGEXP.
7484 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7485 mail-decode-encoded-word-region
7486 (\"chinese\" . rfc1843-decode-region))
7489 (defvar gnus-decode-header-methods-cache nil)
7491 (defun gnus-multi-decode-header (start end)
7492 "Apply the functions from `gnus-encoded-word-methods' that match."
7493 (unless (and gnus-decode-header-methods-cache
7494 (eq gnus-newsgroup-name
7495 (car gnus-decode-header-methods-cache)))
7496 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7499 (nconc gnus-decode-header-methods-cache (list x))
7500 (if (and gnus-newsgroup-name
7501 (string-match (car x) gnus-newsgroup-name))
7502 (nconc gnus-decode-header-methods-cache
7504 gnus-decode-header-methods))
7505 (let ((xlist gnus-decode-header-methods-cache))
7508 (narrow-to-region start end)
7510 (funcall (pop xlist) (point-min) (point-max))))))
7513 ;;; Treatment top-level handling.
7516 (defun gnus-treat-article (condition &optional part-number total-parts type)
7517 (let ((length (- (point-max) (point-min)))
7518 (alist gnus-treatment-function-alist)
7519 (article-goto-body-goes-to-point-min-p t)
7523 (let ((list gnus-article-treat-types))
7525 (when (string-match (pop list) type)
7526 (throw 'found t)))))))
7527 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7528 (entity (static-unless (featurep 'xemacs)
7529 (when (eq 'head condition)
7530 (get-text-property (point-min) 'mime-view-entity))))
7531 val elem buttonized)
7532 (gnus-run-hooks 'gnus-part-display-hook)
7533 (unless gnus-inhibit-treatment
7534 (dolist (elem alist)
7537 (when (gnus-buffer-live-p gnus-summary-buffer)
7538 (set-buffer gnus-summary-buffer))
7539 (symbol-value (car elem))))
7540 (when (and (or (consp val)
7542 (gnus-treat-predicate val)
7543 (or (not (get (car elem) 'highlight))
7545 (when (and (not buttonized)
7547 '(gnus-treat-hide-signature
7548 gnus-treat-highlight-signature)))
7549 (gnus-article-buttonize-signature)
7550 (setq buttonized t))
7552 (funcall (cadr elem)))))
7553 ;; FSF Emacsen does not inherit the existing text properties
7554 ;; in the new text, so we should do it for `mime-view-entity'.
7555 (static-unless (featurep 'xemacs)
7557 (put-text-property (point-min) (point-max)
7558 'mime-view-entity entity))))))
7560 ;; Dynamic variables.
7562 (defvar part-number)
7563 (defvar total-parts)
7568 (defun gnus-treat-predicate (val)
7573 (stringp (car val)))
7574 (apply 'gnus-or (mapcar `(lambda (s)
7575 (string-match s ,(or gnus-newsgroup-name "")))
7578 (let ((pred (pop val)))
7581 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7583 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7585 (not (gnus-treat-predicate (car val))))
7587 (equal (car val) type))
7589 (error "%S is not a valid predicate" pred)))))
7599 (eq part-number total-parts))
7603 (error "%S is not a valid value" val))))
7605 (defun gnus-article-encrypt-body (protocol &optional n)
7606 "Encrypt the article body."
7609 (or gnus-article-encrypt-protocol
7610 (completing-read "Encrypt protocol: "
7611 gnus-article-encrypt-protocol-alist
7613 current-prefix-arg))
7614 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7616 (error "Can't find the encrypt protocol %s" protocol))
7617 (if (member gnus-newsgroup-name '("nndraft:delayed"
7620 (error "Can't encrypt the article in group %s"
7621 gnus-newsgroup-name))
7622 (gnus-summary-iterate n
7624 (set-buffer gnus-summary-buffer)
7625 (let ((mail-parse-charset gnus-newsgroup-charset)
7626 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7627 (summary-buffer gnus-summary-buffer)
7629 (gnus-set-global-variables)
7630 (when (gnus-group-read-only-p)
7631 (error "The current newsgroup does not support article encrypt"))
7632 (gnus-summary-show-article t)
7634 (or (mail-header-references gnus-current-headers) ""))
7635 (set-buffer gnus-article-buffer)
7636 (let* ((inhibit-read-only t)
7638 (mapcar (lambda (field)
7639 (and (save-restriction
7640 (message-narrow-to-head)
7641 (goto-char (point-min))
7642 (search-forward field nil t))
7644 (message-narrow-to-field)
7646 (delete-region (point-min) (point-max))
7648 '("Content-Type:" "Content-Transfer-Encoding:"
7649 "Content-Disposition:"))))
7650 (message-narrow-to-head)
7651 (message-remove-header "MIME-Version")
7652 (goto-char (point-max))
7653 (setq point (point))
7654 (insert (apply 'concat headers))
7656 (narrow-to-region point (point-max))
7657 (let ((message-options message-options))
7658 (message-options-set 'message-sender user-mail-address)
7659 (message-options-set 'message-recipients user-mail-address)
7660 (message-options-set 'message-sign-encrypt 'not)
7662 (goto-char (point-min))
7663 (insert "MIME-Version: 1.0\n")
7665 (gnus-summary-edit-article-done
7666 references nil summary-buffer t))
7667 (when gnus-keep-backlog
7668 (gnus-backlog-remove-article
7669 (car gnus-article-current) (cdr gnus-article-current)))
7671 (when (get-buffer gnus-original-article-buffer)
7672 (set-buffer gnus-original-article-buffer)
7673 (setq gnus-original-article nil)))
7674 (when gnus-use-cache
7675 (gnus-cache-update-article
7676 (car gnus-article-current) (cdr gnus-article-current))))))))
7678 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7679 "The following specs can be used:
7680 %t The security MIME type
7683 %D Details if button is pressed")
7685 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7686 "The following specs can be used:
7687 %t The security MIME type
7690 %D Details if button is pressed")
7692 (defvar gnus-mime-security-button-line-format-alist
7693 '((?t gnus-tmp-type ?s)
7694 (?i gnus-tmp-info ?s)
7695 (?d gnus-tmp-details ?s)
7696 (?D gnus-tmp-pressed-details ?s)))
7698 (defvar gnus-mime-security-button-map
7699 (let ((map (make-sparse-keymap)))
7700 (define-key map gnus-mouse-2 'gnus-article-push-button)
7701 (define-key map "\r" 'gnus-article-press-button)
7704 (defvar gnus-mime-security-details-buffer nil)
7706 (defvar gnus-mime-security-button-pressed nil)
7708 (defvar gnus-mime-security-show-details-inline t
7709 "If non-nil, show details in the article buffer.")
7711 (defun gnus-mime-security-verify-or-decrypt (handle)
7712 (mm-remove-parts (cdr handle))
7713 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7714 point (inhibit-read-only t))
7716 (goto-char (car region)))
7718 (narrow-to-region (point) (point))
7719 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7720 (let* ((mm-verify-option 'known)
7721 (mm-decrypt-option 'known)
7722 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7723 (unless (eq nparts (cdr handle))
7724 (mm-destroy-parts (cdr handle))
7725 (setcdr handle nparts))))
7726 (setq point (point))
7727 (gnus-mime-display-security handle)
7728 (goto-char (point-max)))
7730 (delete-region (point) (cdr region))
7731 (set-marker (car region) nil)
7732 (set-marker (cdr region) nil))
7735 (defun gnus-mime-security-show-details (handle)
7736 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7738 (gnus-message 5 "No details.")
7739 (if gnus-mime-security-show-details-inline
7740 (let ((gnus-mime-security-button-pressed
7741 (not (get-text-property (point) 'gnus-mime-details)))
7742 (gnus-mime-security-button-line-format
7743 (get-text-property (point) 'gnus-line-format))
7744 (inhibit-read-only t))
7746 (while (eq (get-text-property (point) 'gnus-line-format)
7747 gnus-mime-security-button-line-format)
7751 (narrow-to-region (point) (point))
7752 (gnus-insert-mime-security-button handle))
7753 (delete-region (point)
7754 (or (text-property-not-all
7757 gnus-mime-security-button-line-format)
7760 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7761 (with-current-buffer gnus-mime-security-details-buffer
7764 (setq gnus-mime-security-details-buffer
7765 (gnus-get-buffer-create "*MIME Security Details*")))
7766 (with-current-buffer gnus-mime-security-details-buffer
7768 (goto-char (point-min)))
7769 (pop-to-buffer gnus-mime-security-details-buffer)))))
7771 (defun gnus-mime-security-press-button (handle)
7773 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7774 (gnus-mime-security-show-details handle)
7775 (gnus-mime-security-verify-or-decrypt handle))))
7777 (defun gnus-insert-mime-security-button (handle &optional displayed)
7778 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7781 (or (nth 2 (assoc protocol mm-verify-function-alist))
7782 (nth 2 (assoc protocol mm-decrypt-function-alist))
7784 (if (equal (car handle) "multipart/signed")
7785 " Signed" " Encrypted")
7788 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7791 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7792 gnus-tmp-pressed-details
7794 (setq gnus-tmp-details
7795 (if gnus-tmp-details
7796 (concat "\n" gnus-tmp-details)
7798 (setq gnus-tmp-pressed-details
7799 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7804 gnus-mime-security-button-line-format
7805 gnus-mime-security-button-line-format-alist
7806 `(keymap ,gnus-mime-security-button-map
7807 gnus-callback gnus-mime-security-press-button
7808 gnus-line-format ,gnus-mime-security-button-line-format
7809 gnus-mime-details ,gnus-mime-security-button-pressed
7810 article-type annotation
7813 ;; Exclude a newline.
7816 (widget-convert-button
7819 :action 'gnus-widget-press-button
7820 :button-keymap gnus-mime-security-button-map
7822 (lambda (widget/window &optional overlay pos)
7823 ;; Needed to properly clear the message due to a bug in
7824 ;; wid-edit (XEmacs only).
7825 (when (boundp 'help-echo-owns-message)
7826 (setq help-echo-owns-message t))
7829 (aref gnus-mouse-2 0))))))
7831 (defun gnus-mime-display-security (handle)
7833 (narrow-to-region (point) (point))
7834 (unless (gnus-unbuttonized-mime-type-p (car handle))
7835 (gnus-insert-mime-security-button handle))
7836 (gnus-mime-display-mixed (cdr handle))
7839 (unless (gnus-unbuttonized-mime-type-p (car handle))
7840 (let ((gnus-mime-security-button-line-format
7841 gnus-mime-security-button-end-line-format))
7842 (gnus-insert-mime-security-button handle)))
7843 (mm-set-handle-multipart-parameter
7845 (cons (set-marker (make-marker) (point-min))
7846 (set-marker (make-marker) (point-max))))))
7852 (defun gnus-article-header-presentation-method (entity situation)
7853 (mime-insert-header entity)
7854 (article-decode-group-name))
7856 (set-alist 'mime-header-presentation-method-alist
7857 'gnus-original-article-mode
7858 #'gnus-article-header-presentation-method)
7860 (defun gnus-mime-preview-quitting-method ()
7861 (mime-preview-kill-buffer)
7862 (delete-other-windows)
7863 (gnus-article-show-summary)
7864 (gnus-summary-select-article gnus-show-all-headers t))
7866 (set-alist 'mime-preview-quitting-method-alist
7867 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
7869 (set-alist 'mime-preview-following-method-alist
7870 'gnus-original-article-mode #'gnus-following-method)
7872 (set-alist 'mime-preview-over-to-previous-method-alist
7873 'gnus-original-article-mode
7875 (if (> (point-min) 1)
7876 (gnus-article-prev-page)
7877 (gnus-article-read-summary-keys
7878 nil (gnus-character-to-event ?P)))))
7880 (set-alist 'mime-preview-over-to-next-method-alist
7881 'gnus-original-article-mode'
7883 (if (< (point-max) (buffer-size))
7884 (gnus-article-next-page)
7885 (gnus-article-read-summary-keys
7886 nil (gnus-character-to-event ?N)))))
7896 (run-hooks 'gnus-art-load-hook)
7898 ;;; gnus-art.el ends here