1 ;;; gnus-art.el --- article mode commands for Semi-gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;; Katsumi Yamaoka <yamaoka@jpl.org>
8 ;; Keywords: mail, news, MIME
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
34 (defvar tool-bar-map))
38 ;; Avoid the "Recursive load suspected" error in Emacs 21.1.
40 (let ((recursive-load-depth-limit 100))
47 (when (static-if (featurep 'xemacs)
48 (console-on-window-system-p)
50 (require 'mime-image))
53 ;; Avoid byte-compile warnings.
63 (autoload 'gnus-msg-mail "gnus-msg" nil t)
64 (autoload 'gnus-button-mailto "gnus-msg")
65 (autoload 'gnus-button-reply "gnus-msg" nil t)
66 (autoload 'parse-time-string "parse-time" nil nil)
67 (autoload 'ansi-color-apply-on-region "ansi-color")
69 (defgroup gnus-article nil
71 :link '(custom-manual "(gnus)Article Buffer")
74 (defgroup gnus-article-treat nil
75 "Treating article parts."
76 :link '(custom-manual "(gnus)Article Hiding")
79 (defgroup gnus-article-hiding nil
80 "Hiding article parts."
81 :link '(custom-manual "(gnus)Article Hiding")
84 (defgroup gnus-article-highlight nil
85 "Article highlighting."
86 :link '(custom-manual "(gnus)Article Highlighting")
90 (defgroup gnus-article-signature nil
92 :link '(custom-manual "(gnus)Article Signature")
95 (defgroup gnus-article-headers nil
97 :link '(custom-manual "(gnus)Hiding Headers")
100 (defgroup gnus-article-washing nil
101 "Special commands on articles."
102 :link '(custom-manual "(gnus)Article Washing")
103 :group 'gnus-article)
105 (defgroup gnus-article-emphasis nil
106 "Fontisizing articles."
107 :link '(custom-manual "(gnus)Article Fontisizing")
108 :group 'gnus-article)
110 (defgroup gnus-article-saving nil
112 :link '(custom-manual "(gnus)Saving Articles")
113 :group 'gnus-article)
115 (defgroup gnus-article-mime nil
116 "Worshiping the MIME wonder."
117 :link '(custom-manual "(gnus)Using MIME")
118 :group 'gnus-article)
120 (defgroup gnus-article-buttons nil
121 "Pushable buttons in the article buffer."
122 :link '(custom-manual "(gnus)Article Buttons")
123 :group 'gnus-article)
125 (defgroup gnus-article-various nil
126 "Other article options."
127 :link '(custom-manual "(gnus)Misc Article")
128 :group 'gnus-article)
130 (defcustom gnus-ignored-headers
133 (concat "^" header ":"))
134 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
135 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
136 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
137 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
138 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
139 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
140 "X-Attribution" "X-Originating-IP" "Delivered-To"
141 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
142 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
143 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
144 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
145 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
146 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
147 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
148 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
149 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
150 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
151 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
152 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
153 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
154 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
155 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
156 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
157 "List-[A-Za-z]+" "X-Listprocessor-Version"
158 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
159 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
160 "X-Received" "Content-length" "X-precedence"
161 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
162 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
163 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
164 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
165 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
166 "X-Content-length" "X-Posting-Agent" "Original-Received"
167 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
168 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
169 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
170 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
171 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"))
172 "*All headers that start with this regexp will be hidden.
173 This variable can also be a list of regexps of headers to be ignored.
174 If `gnus-visible-headers' is non-nil, this variable will be ignored."
175 :type '(choice :custom-show nil
178 :group 'gnus-article-hiding)
180 (defcustom gnus-visible-headers
181 "^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:"
182 "*All headers that do not match this regexp will be hidden.
183 This variable can also be a list of regexp of headers to remain visible.
184 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
185 :type '(repeat :value-to-internal (lambda (widget value)
186 (custom-split-regexp-maybe value))
187 :match (lambda (widget value)
189 (widget-editable-list-match widget value)))
191 :group 'gnus-article-hiding)
193 (defcustom gnus-sorted-header-list
194 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
195 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
196 "*This variable is a list of regular expressions.
197 If it is non-nil, headers that match the regular expressions will
198 be placed first in the article buffer in the sequence specified by
200 :type '(repeat regexp)
201 :group 'gnus-article-hiding)
203 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
204 "Headers that are only to be displayed if they have interesting data.
205 Possible values in this list are:
207 'empty Headers with no content.
208 'newsgroups Newsgroup identical to Gnus group.
209 'to-address To identical to To-address.
210 'to-list To identical to To-list.
211 'cc-list CC identical to To-list.
212 'followup-to Followup-to identical to Newsgroups.
213 'reply-to Reply-to identical to From.
214 'date Date less than four days old.
215 'long-to To and/or Cc longer than 1024 characters.
216 'many-to Multiple To and/or Cc."
217 :type '(set (const :tag "Headers with no content." empty)
218 (const :tag "Newsgroups identical to Gnus group." newsgroups)
219 (const :tag "To identical to To-address." to-address)
220 (const :tag "To identical to To-list." to-list)
221 (const :tag "CC identical to To-list." cc-list)
222 (const :tag "Followup-to identical to Newsgroups." followup-to)
223 (const :tag "Reply-to identical to From." reply-to)
224 (const :tag "Date less than four days old." date)
225 (const :tag "To and/or Cc longer than 1024 characters." long-to)
226 (const :tag "Multiple To and/or Cc headers." many-to))
227 :group 'gnus-article-hiding)
229 (defcustom gnus-article-skip-boring nil
230 "Skip over text that is not worth reading.
231 By default, if you set this t, then Gnus will display citations and
232 signatures, but will never scroll down to show you a page consisting
233 only of boring text. Boring text is controlled by
234 `gnus-article-boring-faces'."
237 :group 'gnus-article-hiding)
239 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
240 "Regexp matching signature separator.
241 This can also be a list of regexps. In that case, it will be checked
242 from head to tail looking for a separator. Searches will be done from
243 the end of the buffer."
244 :type '(repeat string)
245 :group 'gnus-article-signature)
247 (defcustom gnus-signature-limit nil
248 "Provide a limit to what is considered a signature.
249 If it is a number, no signature may not be longer (in characters) than
250 that number. If it is a floating point number, no signature may be
251 longer (in lines) than that number. If it is a function, the function
252 will be called without any parameters, and if it returns nil, there is
253 no signature in the buffer. If it is a string, it will be used as a
254 regexp. If it matches, the text in question is not a signature.
256 This can also be a list of the above values."
257 :type '(choice (integer :value 200)
259 (function :value fun)
260 (regexp :value ".*"))
261 :group 'gnus-article-signature)
263 (defcustom gnus-hidden-properties '(invisible t intangible t)
264 "Property list to use for hiding text."
266 :group 'gnus-article-hiding)
268 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
269 ;; frames in a session.
270 (defcustom gnus-article-x-face-command
275 (if (or (gnus-image-type-available-p 'xface)
276 (gnus-image-type-available-p 'pbm))
277 'gnus-display-x-face-in-from
278 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -"))
279 ((gnus-image-type-available-p 'pbm)
280 'gnus-display-x-face-in-from)
282 (module-installed-p 'x-face-mule))
283 'x-face-mule-gnus-article-display-x-face)
285 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
287 "*String or function to be executed to display an X-Face header.
288 If it is a string, the command will be executed in a sub-shell
289 asynchronously. The compressed face will be piped to this command."
291 ,@(let ((x-face-mule (if (featurep 'xemacs)
293 (module-installed-p 'x-face-mule))))
297 (if (or (gnus-image-type-available-p 'xface)
298 (gnus-image-type-available-p 'pbm))
299 '(function-item gnus-display-x-face-in-from))
302 x-face-mule-gnus-article-display-x-face))
306 :group 'gnus-article-washing)
308 (defcustom gnus-article-x-face-too-ugly nil
309 "Regexp matching posters whose face shouldn't be shown automatically."
310 :type '(choice regexp (const nil))
311 :group 'gnus-article-washing)
313 (defcustom gnus-article-banner-alist nil
314 "Banner alist for stripping.
316 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
318 :type '(repeat (cons symbol regexp))
319 :group 'gnus-article-washing)
321 (gnus-define-group-parameter
324 "Alist of regexps (to match group names) and banner."
325 :variable-group gnus-article-washing
327 '(choice :tag "Banner"
329 (const :tag "Remove signature" signature)
330 (symbol :tag "Item in `gnus-article-banner-alist'" none)
332 (const :tag "None" nil))
334 "If non-nil, specify how to remove `banners' from articles.
336 Symbol `signature' means to remove signatures delimited by
337 `gnus-signature-separator'. Any other symbol is used to look up a
338 regular expression to match the banner in `gnus-article-banner-alist'.
339 A string is used as a regular expression to match the banner
342 (defcustom gnus-article-address-banner-alist nil
343 "Alist of mail addresses and banners.
344 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
345 to match a mail address in the From: header, BANNER is one of a symbol
346 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
347 If ADDRESS matches author's mail address, it will remove things like
348 advertisements. For example:
350 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
354 (regexp :tag "Address")
355 (choice :tag "Banner" :value nil
356 (const :tag "Remove signature" signature)
357 (symbol :tag "Item in `gnus-article-banner-alist'" none)
359 (const :tag "None" nil))))
361 :group 'gnus-article-washing)
363 (defmacro gnus-emphasis-custom-with-format (&rest body)
365 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
366 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
369 (defun gnus-emphasis-custom-value-to-external (value)
370 (gnus-emphasis-custom-with-format
371 (if (consp (car value))
372 (list (format format (car (car value)) (cdr (car value)))
374 (if (nth 1 value) 2 3)
378 (defun gnus-emphasis-custom-value-to-internal (value)
379 (gnus-emphasis-custom-with-format
380 (let ((regexp (concat "\\`"
381 (format (regexp-quote format)
382 "\\([^()]+\\)" "\\([^()]+\\)")
385 (if (string-match regexp (setq pattern (car value)))
386 (list (cons (match-string 1 pattern) (match-string 2 pattern))
391 (defcustom gnus-emphasis-alist
393 '(("\\*" "\\*" bold nil 2)
396 ("_/" "/_" underline-italic)
397 ("_\\*" "\\*_" underline-bold)
398 ("\\*/" "/\\*" bold-italic)
399 ("_\\*/" "/\\*_" underline-bold-italic))))
401 (gnus-emphasis-custom-with-format
402 (mapcar (lambda (spec)
403 (list (format format (car spec) (cadr spec))
406 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
408 '(;; I've never seen anyone use this strikethru convention whereas I've
409 ;; several times seen it triggered by normal text. --Stef
410 ;; Miles suggests that this form is sometimes used but for italics,
411 ;; so maybe we should map it to `italic'.
412 ;; ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
413 ;; 2 3 gnus-emphasis-strikethru)
414 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
415 2 3 gnus-emphasis-underline))))
416 "*Alist that says how to fontify certain phrases.
417 Each item looks like this:
419 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
421 The first element is a regular expression to be matched. The second
422 is a number that says what regular expression grouping used to find
423 the entire emphasized word. The third is a number that says what
424 regexp grouping should be displayed and highlighted. The fourth
425 is the face used for highlighting."
429 :format "%[Customizing Style%]\n%v"
431 (group :tag "Default"
432 :value ("" 0 0 default)
435 (let ((value (widget-get
436 (cadr (widget-get (widget-get widget :parent)
439 (if (not (eq (nth 2 value) 'default))
443 (gnus-emphasis-custom-value-to-external value))))
444 (widget-group-value-create widget))
446 (integer :format "Match group: %v")
447 (integer :format "Emphasize group: %v")
450 :value (("_" . "_") nil default)
452 (regexp :format "Start regexp: %v")
453 (regexp :format "End regexp: %v"))
454 (boolean :format "Show start and end patterns: %[%v%]\n"
455 :on " On " :off " Off ")
457 :get (lambda (symbol)
458 (mapcar 'gnus-emphasis-custom-value-to-internal
459 (default-value symbol)))
460 :set (lambda (symbol value)
461 (set-default symbol (mapcar 'gnus-emphasis-custom-value-to-external
463 :group 'gnus-article-emphasis)
465 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
466 "A regexp to describe whitespace which should not be emphasized.
467 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
468 The former avoids underlining of leading and trailing whitespace,
469 and the latter avoids underlining any whitespace at all."
471 :group 'gnus-article-emphasis
474 (defface gnus-emphasis-bold '((t (:bold t)))
475 "Face used for displaying strong emphasized text (*word*)."
476 :group 'gnus-article-emphasis)
478 (defface gnus-emphasis-italic '((t (:italic t)))
479 "Face used for displaying italic emphasized text (/word/)."
480 :group 'gnus-article-emphasis)
482 (defface gnus-emphasis-underline '((t (:underline t)))
483 "Face used for displaying underlined emphasized text (_word_)."
484 :group 'gnus-article-emphasis)
486 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
487 "Face used for displaying underlined bold emphasized text (_*word*_)."
488 :group 'gnus-article-emphasis)
490 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
491 "Face used for displaying underlined italic emphasized text (_/word/_)."
492 :group 'gnus-article-emphasis)
494 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
495 "Face used for displaying bold italic emphasized text (/*word*/)."
496 :group 'gnus-article-emphasis)
498 (defface gnus-emphasis-underline-bold-italic
499 '((t (:bold t :italic t :underline t)))
500 "Face used for displaying underlined bold italic emphasized text.
501 Example: (_/*word*/_)."
502 :group 'gnus-article-emphasis)
504 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
505 '((t (:strikethru t)))
506 '((t (:strike-through t))))
507 "Face used for displaying strike-through text (-word-)."
508 :group 'gnus-article-emphasis)
510 (defface gnus-emphasis-highlight-words
511 '((t (:background "black" :foreground "yellow")))
512 "Face used for displaying highlighted words."
513 :group 'gnus-article-emphasis)
515 (defcustom gnus-article-time-format "%a, %d %b %Y %T %Z"
516 "Format for display of Date headers in article bodies.
517 See `format-time-string' for the possible values.
519 The variable can also be function, which should return a complete Date
520 header. The function is called with one argument, the time, which can
521 be fed to `format-time-string'."
522 :type '(choice string function)
523 :link '(custom-manual "(gnus)Article Date")
524 :group 'gnus-article-washing)
526 (defcustom gnus-save-all-headers t
527 "*If non-nil, don't remove any headers before saving."
528 :group 'gnus-article-saving
531 (defcustom gnus-prompt-before-saving 'always
532 "*This variable says how much prompting is to be done when saving articles.
533 If it is nil, no prompting will be done, and the articles will be
534 saved to the default files. If this variable is `always', each and
535 every article that is saved will be preceded by a prompt, even when
536 saving large batches of articles. If this variable is neither nil not
537 `always', there the user will be prompted once for a file name for
538 each invocation of the saving commands."
539 :group 'gnus-article-saving
540 :type '(choice (item always)
541 (item :tag "never" nil)
542 (sexp :tag "once" :format "%t\n" :value t)))
544 (defcustom gnus-saved-headers gnus-visible-headers
545 "Headers to keep if `gnus-save-all-headers' is nil.
546 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
547 If that variable is nil, however, all headers that match this regexp
548 will be kept while the rest will be deleted before saving."
549 :group 'gnus-article-saving
552 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
553 "A function to save articles in your favourite format.
554 The function must be interactively callable (in other words, it must
555 be an Emacs command).
557 Gnus provides the following functions:
559 * gnus-summary-save-in-rmail (Rmail format)
560 * gnus-summary-save-in-mail (Unix mail format)
561 * gnus-summary-save-in-folder (MH folder)
562 * gnus-summary-save-in-file (article format)
563 * gnus-summary-save-body-in-file (article body)
564 * gnus-summary-save-in-vm (use VM's folder format)
565 * gnus-summary-write-to-file (article format -- overwrite)."
566 :group 'gnus-article-saving
567 :type '(radio (function-item gnus-summary-save-in-rmail)
568 (function-item gnus-summary-save-in-mail)
569 (function-item gnus-summary-save-in-folder)
570 (function-item gnus-summary-save-in-file)
571 (function-item gnus-summary-save-body-in-file)
572 (function-item gnus-summary-save-in-vm)
573 (function-item gnus-summary-write-to-file)))
575 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
576 "A function generating a file name to save articles in Rmail format.
577 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
578 :group 'gnus-article-saving
581 (defcustom gnus-mail-save-name 'gnus-plain-save-name
582 "A function generating a file name to save articles in Unix mail format.
583 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
584 :group 'gnus-article-saving
587 (defcustom gnus-folder-save-name 'gnus-folder-save-name
588 "A function generating a file name to save articles in MH folder.
589 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
590 :group 'gnus-article-saving
593 (defcustom gnus-file-save-name 'gnus-numeric-save-name
594 "A function generating a file name to save articles in article format.
595 The function is called with NEWSGROUP, HEADERS, and optional
597 :group 'gnus-article-saving
600 (defcustom gnus-split-methods
601 '((gnus-article-archive-name)
602 (gnus-article-nndoc-name))
603 "*Variable used to suggest where articles are to be saved.
604 For instance, if you would like to save articles related to Gnus in
605 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
606 you could set this variable to something like:
608 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
609 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
611 This variable is an alist where the key is the match and the
612 value is a list of possible files to save in if the match is
615 If the match is a string, it is used as a regexp match on the
616 article. If the match is a symbol, that symbol will be funcalled
617 from the buffer of the article to be saved with the newsgroup as
618 the parameter. If it is a list, it will be evaled in the same
621 If this form or function returns a string, this string will be
622 used as a possible file name; and if it returns a non-nil list,
623 that list will be used as possible file names."
624 :group 'gnus-article-saving
625 :type '(repeat (choice (list :value (fun) function)
626 (cons :value ("" "") regexp (repeat string))
629 (defcustom gnus-article-display-method-for-mime
630 'gnus-article-display-mime-message
631 "Function to display a MIME message.
632 The function is called from the article buffer."
633 :group 'gnus-article-mime
636 (defcustom gnus-article-display-method-for-traditional
637 'gnus-article-display-traditional-message
638 "*Function to display a traditional message.
639 The function is called from the article buffer."
640 :group 'gnus-article-mime
643 (defcustom gnus-page-delimiter "^\^L"
644 "*Regexp describing what to use as article page delimiters.
645 The default value is \"^\^L\", which is a form linefeed at the
646 beginning of a line."
648 :group 'gnus-article-various)
650 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
651 "*The format specification for the article mode line.
652 See `gnus-summary-mode-line-format' for a closer description.
654 The following additional specs are available:
656 %w The article washing status.
657 %m The number of MIME parts in the article."
659 :group 'gnus-article-various)
661 (defcustom gnus-article-mode-hook nil
662 "*A hook for Gnus article mode."
664 :group 'gnus-article-various)
666 (when (featurep 'xemacs)
667 ;; Extracted from gnus-xmas-define in order to preserve user settings
668 (when (fboundp 'turn-off-scroll-in-place)
669 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
670 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
671 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
673 (defcustom gnus-article-menu-hook nil
674 "*Hook run after the creation of the article mode menu."
676 :group 'gnus-article-various)
678 (defcustom gnus-article-prepare-hook nil
679 "*A hook called after an article has been prepared in the article buffer."
681 :group 'gnus-article-various)
683 (defcustom gnus-copy-article-ignored-headers nil
684 "List of headers to be removed when copying an article.
685 Each element is a regular expression."
686 :version "23.0" ;; No Gnus
687 :type '(repeat regexp)
688 :group 'gnus-article-various)
690 (make-obsolete-variable 'gnus-article-hide-pgp-hook
691 "This variable is obsolete in Gnus 5.10.")
693 (defcustom gnus-article-button-face 'bold
694 "Face used for highlighting buttons in the article buffer.
696 An article button is a piece of text that you can activate by pressing
697 `RET' or `mouse-2' above it."
699 :group 'gnus-article-buttons)
701 (defcustom gnus-article-mouse-face 'highlight
702 "Face used for mouse highlighting in the article buffer.
704 Article buttons will be displayed in this face when the cursor is
707 :group 'gnus-article-buttons)
709 (defcustom gnus-signature-face 'gnus-signature-face
710 "Face used for highlighting a signature in the article buffer.
711 Obsolete; use the face `gnus-signature-face' for customizations instead."
713 :group 'gnus-article-highlight
714 :group 'gnus-article-signature)
716 (defface gnus-signature-face
719 "Face used for highlighting a signature in the article buffer."
720 :group 'gnus-article-highlight
721 :group 'gnus-article-signature)
723 (defface gnus-header-from-face
726 (:foreground "spring green"))
729 (:foreground "red3"))
732 "Face used for displaying from headers."
733 :group 'gnus-article-headers
734 :group 'gnus-article-highlight)
736 (defface gnus-header-subject-face
739 (:foreground "SeaGreen3"))
742 (:foreground "red4"))
744 (:bold t :italic t)))
745 "Face used for displaying subject headers."
746 :group 'gnus-article-headers
747 :group 'gnus-article-highlight)
749 (defface gnus-header-newsgroups-face
752 (:foreground "yellow" :italic t))
755 (:foreground "MidnightBlue" :italic t))
758 "Face used for displaying newsgroups headers.
759 In the default setup this face is only used for crossposted
761 :group 'gnus-article-headers
762 :group 'gnus-article-highlight)
764 (defface gnus-header-name-face
767 (:foreground "SeaGreen"))
770 (:foreground "maroon"))
773 "Face used for displaying header names."
774 :group 'gnus-article-headers
775 :group 'gnus-article-highlight)
777 (defface gnus-header-content-face
780 (:foreground "forest green" :italic t))
783 (:foreground "indianred4" :italic t))
786 "Face used for displaying header content."
787 :group 'gnus-article-headers
788 :group 'gnus-article-highlight)
790 (defcustom gnus-header-face-alist
791 '(("From" nil gnus-header-from-face)
792 ("Subject" nil gnus-header-subject-face)
793 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
794 ("" gnus-header-name-face gnus-header-content-face))
795 "*Controls highlighting of article headers.
797 An alist of the form (HEADER NAME CONTENT).
799 HEADER is a regular expression which should match the name of a
800 header and NAME and CONTENT are either face names or nil.
802 The name of each header field will be displayed using the face
803 specified by the first element in the list where HEADER matches
804 the header name and NAME is non-nil. Similarly, the content will
805 be displayed by the first non-nil matching CONTENT face."
806 :group 'gnus-article-headers
807 :group 'gnus-article-highlight
808 :type '(repeat (list (regexp :tag "Header")
810 (item :tag "skip" nil)
811 (face :value default))
812 (choice :tag "Content"
813 (item :tag "skip" nil)
814 (face :value default)))))
816 (defcustom gnus-article-decode-hook
817 '(article-decode-group-name article-decode-idna-rhs)
818 "*Hook run to decode charsets in articles."
819 :group 'gnus-article-headers
822 (defcustom gnus-display-mime-function 'gnus-display-mime
823 "Function to display MIME articles."
824 :group 'gnus-article-mime
827 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
828 "Function used to decode headers.")
830 (defvar gnus-article-dumbquotes-map
850 "Table for MS-to-Latin1 translation.")
852 (defcustom gnus-ignored-mime-types nil
853 "List of MIME types that should be ignored by Gnus."
855 :group 'gnus-article-mime
856 :type '(repeat regexp))
858 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
859 "List of MIME types that should not be given buttons when rendered inline.
860 See also `gnus-buttonized-mime-types' which may override this variable.
861 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
863 :group 'gnus-article-mime
864 :type '(repeat regexp))
866 (defcustom gnus-buttonized-mime-types nil
867 "List of MIME types that should be given buttons when rendered inline.
868 If set, this variable overrides `gnus-unbuttonized-mime-types'.
869 To see e.g. security buttons you could set this to
870 `(\"multipart/signed\")'.
871 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
873 :group 'gnus-article-mime
874 :type '(repeat regexp))
876 (defcustom gnus-inhibit-mime-unbuttonizing nil
877 "If non-nil, all MIME parts get buttons.
878 When nil (the default value), then some MIME parts do not get buttons,
879 as described by the variables `gnus-buttonized-mime-types' and
880 `gnus-unbuttonized-mime-types'."
882 :group 'gnus-article-mime
885 (defcustom gnus-body-boundary-delimiter "_"
886 "String used to delimit header and body.
887 This variable is used by `gnus-article-treat-body-boundary' which can
888 be controlled by `gnus-treat-body-boundary'."
890 :group 'gnus-article-various
891 :type '(choice (item :tag "None" :value nil)
894 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
896 "Defines the location of the faces database.
897 For information on obtaining this database of pretty pictures, please
898 see http://www.cs.indiana.edu/picons/ftp/index.html"
900 :type '(repeat directory)
901 :link '(url-link :tag "download"
902 "http://www.cs.indiana.edu/picons/ftp/index.html")
903 :link '(custom-manual "(gnus)Picons")
906 (defun gnus-picons-installed-p ()
907 "Say whether picons are installed on your machine."
908 (let ((installed nil))
909 (dolist (database gnus-picon-databases)
910 (when (file-exists-p database)
914 (defcustom gnus-article-mime-part-function nil
915 "Function called with a MIME handle as the argument.
916 This is meant for people who want to do something automatic based
917 on parts -- for instance, adding Vcard info to a database."
918 :group 'gnus-article-mime
921 (defcustom gnus-mime-multipart-functions nil
922 "An alist of MIME types to functions to display them."
924 :group 'gnus-article-mime
925 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
927 (defcustom gnus-article-date-lapsed-new-header nil
928 "Whether the X-Sent and Date headers can coexist.
929 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
930 either replace the old \"Date:\" header (if this variable is nil), or
931 be added below it (otherwise)."
933 :group 'gnus-article-headers
936 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
937 "Function called with a MIME handle as the argument.
938 This is meant for people who want to view first matched part.
939 For `undisplayed-alternative' (default), the first undisplayed
940 part or alternative part is used. For `undisplayed', the first
941 undisplayed part is used. For a function, the first part which
942 the function return t is used. For nil, the first part is
945 :group 'gnus-article-mime
947 (item :tag "first" :value nil)
948 (item :tag "undisplayed" :value undisplayed)
949 (item :tag "undisplayed or alternative"
950 :value undisplayed-alternative)
953 (defcustom gnus-mime-action-alist
954 '(("save to file" . gnus-mime-save-part)
955 ("save and strip" . gnus-mime-save-part-and-strip)
956 ("delete part" . gnus-mime-delete-part)
957 ("display as text" . gnus-mime-inline-part)
958 ("view the part" . gnus-mime-view-part)
959 ("pipe to command" . gnus-mime-pipe-part)
960 ("toggle display" . gnus-article-press-button)
961 ("toggle display" . gnus-article-view-part-as-charset)
962 ("view as type" . gnus-mime-view-part-as-type)
963 ("view internally" . gnus-mime-view-part-internally)
964 ("view externally" . gnus-mime-view-part-externally))
965 "An alist of actions that run on the MIME attachment."
966 :group 'gnus-article-mime
967 :type '(repeat (cons (string :tag "name")
971 ;;; The treatment variables
974 (defvar gnus-part-display-hook nil
975 "Hook called on parts that are to receive treatment.")
977 (defvar gnus-article-treat-custom
978 '(choice (const :tag "Off" nil)
980 (const :tag "Header" head)
981 (const :tag "Last" last)
982 (const :tag "Mime" mime)
983 (integer :tag "Less")
984 (repeat :tag "Groups" regexp)
985 (sexp :tag "Predicate")))
987 (defvar gnus-article-treat-head-custom
988 '(choice (const :tag "Off" nil)
989 (const :tag "Header" head)))
991 (defvar gnus-article-treat-types '("text/plain")
994 (defvar gnus-inhibit-treatment nil
995 "Whether to inhibit treatment.")
997 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
998 "Highlight the signature.
999 Valid values are nil, t, `head', `last', an integer or a predicate.
1000 See Info node `(gnus)Customizing Articles'."
1001 :group 'gnus-article-treat
1002 :link '(custom-manual "(gnus)Customizing Articles")
1003 :type gnus-article-treat-custom)
1004 (put 'gnus-treat-highlight-signature 'highlight t)
1006 (defcustom gnus-treat-buttonize 100000
1008 Valid values are nil, t, `head', `last', an integer or a predicate.
1009 See Info node `(gnus)Customizing Articles'."
1010 :group 'gnus-article-treat
1011 :link '(custom-manual "(gnus)Customizing Articles")
1012 :type gnus-article-treat-custom)
1013 (put 'gnus-treat-buttonize 'highlight t)
1015 (defcustom gnus-treat-buttonize-head 'head
1016 "Add buttons to the head.
1017 Valid values are nil, t, `head', `last', an integer or a predicate.
1018 See Info node `(gnus)Customizing Articles' for details."
1019 :group 'gnus-article-treat
1020 :link '(custom-manual "(gnus)Customizing Articles")
1021 :type gnus-article-treat-head-custom)
1022 (put 'gnus-treat-buttonize-head 'highlight t)
1024 (defcustom gnus-treat-emphasize
1025 (and (or window-system
1029 Valid values are nil, t, `head', `last', an integer or a predicate.
1030 See Info node `(gnus)Customizing Articles' for details."
1031 :group 'gnus-article-treat
1032 :link '(custom-manual "(gnus)Customizing Articles")
1033 :type gnus-article-treat-custom)
1034 (put 'gnus-treat-emphasize 'highlight t)
1036 (defcustom gnus-treat-strip-cr nil
1037 "Remove carriage returns.
1038 Valid values are nil, t, `head', `last', an integer or a predicate.
1039 See Info node `(gnus)Customizing Articles' for details."
1041 :group 'gnus-article-treat
1042 :link '(custom-manual "(gnus)Customizing Articles")
1043 :type gnus-article-treat-custom)
1045 (defcustom gnus-treat-unsplit-urls nil
1046 "Remove newlines from within URLs.
1047 Valid values are nil, t, `head', `last', an integer or a predicate.
1048 See Info node `(gnus)Customizing Articles' for details."
1050 :group 'gnus-article-treat
1051 :link '(custom-manual "(gnus)Customizing Articles")
1052 :type gnus-article-treat-custom)
1054 (defcustom gnus-treat-leading-whitespace nil
1055 "Remove leading whitespace in headers.
1056 Valid values are nil, t, `head', `last', an integer or a predicate.
1057 See Info node `(gnus)Customizing Articles' for details."
1059 :group 'gnus-article-treat
1060 :link '(custom-manual "(gnus)Customizing Articles")
1061 :type gnus-article-treat-custom)
1063 (defcustom gnus-treat-hide-headers 'head
1065 Valid values are nil, t, `head', `last', an integer or a predicate.
1066 See Info node `(gnus)Customizing Articles' for details."
1067 :group 'gnus-article-treat
1068 :link '(custom-manual "(gnus)Customizing Articles")
1069 :type gnus-article-treat-head-custom)
1071 (defcustom gnus-treat-hide-boring-headers nil
1072 "Hide boring headers.
1073 Valid values are nil, t, `head', `last', an integer or a predicate.
1074 See Info node `(gnus)Customizing Articles' for details."
1075 :group 'gnus-article-treat
1076 :link '(custom-manual "(gnus)Customizing Articles")
1077 :type gnus-article-treat-head-custom)
1079 (defcustom gnus-treat-hide-signature nil
1080 "Hide the signature.
1081 Valid values are nil, t, `head', `last', an integer or a predicate.
1082 See Info node `(gnus)Customizing Articles' for details."
1083 :group 'gnus-article-treat
1084 :link '(custom-manual "(gnus)Customizing Articles")
1085 :type gnus-article-treat-custom)
1087 (defcustom gnus-treat-fill-article nil
1089 Valid values are nil, t, `head', `last', an integer or a predicate.
1090 See Info node `(gnus)Customizing Articles' for details."
1091 :group 'gnus-article-treat
1092 :link '(custom-manual "(gnus)Customizing Articles")
1093 :type gnus-article-treat-custom)
1095 (defcustom gnus-treat-hide-citation nil
1097 Valid values are nil, t, `head', `last', an integer or a predicate.
1098 See Info node `(gnus)Customizing Articles' for details."
1099 :group 'gnus-article-treat
1100 :link '(custom-manual "(gnus)Customizing Articles")
1101 :type gnus-article-treat-custom)
1103 (defcustom gnus-treat-hide-citation-maybe nil
1105 Valid values are nil, t, `head', `last', an integer or a predicate.
1106 See Info node `(gnus)Customizing Articles' for details."
1107 :group 'gnus-article-treat
1108 :link '(custom-manual "(gnus)Customizing Articles")
1109 :type gnus-article-treat-custom)
1111 (defcustom gnus-treat-strip-list-identifiers 'head
1112 "Strip list identifiers from `gnus-list-identifiers`.
1113 Valid values are nil, t, `head', `last', an integer or a predicate.
1114 See Info node `(gnus)Customizing Articles' for details."
1116 :group 'gnus-article-treat
1117 :link '(custom-manual "(gnus)Customizing Articles")
1118 :type gnus-article-treat-custom)
1120 (make-obsolete-variable 'gnus-treat-strip-pgp
1121 "This option is obsolete in Gnus 5.10.")
1123 (defcustom gnus-treat-strip-pem nil
1124 "Strip PEM signatures.
1125 Valid values are nil, t, `head', `last', an integer or a predicate.
1126 See Info node `(gnus)Customizing Articles' for details."
1127 :group 'gnus-article-treat
1128 :link '(custom-manual "(gnus)Customizing Articles")
1129 :type gnus-article-treat-custom)
1131 (defcustom gnus-treat-strip-banner t
1132 "Strip banners from articles.
1133 The banner to be stripped is specified in the `banner' group parameter.
1134 Valid values are nil, t, `head', `last', an integer or a predicate.
1135 See Info node `(gnus)Customizing Articles' for details."
1136 :group 'gnus-article-treat
1137 :link '(custom-manual "(gnus)Customizing Articles")
1138 :type gnus-article-treat-custom)
1140 (defcustom gnus-treat-highlight-headers 'head
1141 "Highlight the headers.
1142 Valid values are nil, t, `head', `last', an integer or a predicate.
1143 See Info node `(gnus)Customizing Articles' for details."
1144 :group 'gnus-article-treat
1145 :link '(custom-manual "(gnus)Customizing Articles")
1146 :type gnus-article-treat-head-custom)
1147 (put 'gnus-treat-highlight-headers 'highlight t)
1149 (defcustom gnus-treat-highlight-citation t
1150 "Highlight cited text.
1151 Valid values are nil, t, `head', `last', an integer or a predicate.
1152 See Info node `(gnus)Customizing Articles' for details."
1153 :group 'gnus-article-treat
1154 :link '(custom-manual "(gnus)Customizing Articles")
1155 :type gnus-article-treat-custom)
1156 (put 'gnus-treat-highlight-citation 'highlight t)
1158 (defcustom gnus-treat-date-ut nil
1159 "Display the Date in UT (GMT).
1160 Valid values are nil, t, `head', `last', an integer or a predicate.
1161 See Info node `(gnus)Customizing Articles' for details."
1162 :group 'gnus-article-treat
1163 :link '(custom-manual "(gnus)Customizing Articles")
1164 :type gnus-article-treat-head-custom)
1166 (defcustom gnus-treat-date-local nil
1167 "Display the Date in the local timezone.
1168 Valid values are nil, t, `head', `last', an integer or a predicate.
1169 See Info node `(gnus)Customizing Articles' for details."
1170 :group 'gnus-article-treat
1171 :link '(custom-manual "(gnus)Customizing Articles")
1172 :type gnus-article-treat-head-custom)
1174 (defcustom gnus-treat-date-english nil
1175 "Display the Date in a format that can be read aloud in English.
1176 Valid values are nil, t, `head', `last', an integer or a predicate.
1177 See Info node `(gnus)Customizing Articles' for details."
1179 :group 'gnus-article-treat
1180 :link '(custom-manual "(gnus)Customizing Articles")
1181 :type gnus-article-treat-head-custom)
1183 (defcustom gnus-treat-date-lapsed nil
1184 "Display the Date header in a way that says how much time has elapsed.
1185 Valid values are nil, t, `head', `last', an integer or a predicate.
1186 See Info node `(gnus)Customizing Articles' for details."
1187 :group 'gnus-article-treat
1188 :link '(custom-manual "(gnus)Customizing Articles")
1189 :type gnus-article-treat-head-custom)
1191 (defcustom gnus-treat-date-original nil
1192 "Display the date in the original timezone.
1193 Valid values are nil, t, `head', `last', an integer or a predicate.
1194 See Info node `(gnus)Customizing Articles' for details."
1195 :group 'gnus-article-treat
1196 :link '(custom-manual "(gnus)Customizing Articles")
1197 :type gnus-article-treat-head-custom)
1199 (defcustom gnus-treat-date-iso8601 nil
1200 "Display the date in the ISO8601 format.
1201 Valid values are nil, t, `head', `last', an integer or a predicate.
1202 See Info node `(gnus)Customizing Articles' for details."
1204 :group 'gnus-article-treat
1205 :link '(custom-manual "(gnus)Customizing Articles")
1206 :type gnus-article-treat-head-custom)
1208 (defcustom gnus-treat-date-user-defined nil
1209 "Display the date in a user-defined format.
1210 The format is defined by the `gnus-article-time-format' variable.
1211 Valid values are nil, t, `head', `last', an integer or a predicate.
1212 See Info node `(gnus)Customizing Articles' for details."
1213 :group 'gnus-article-treat
1214 :link '(custom-manual "(gnus)Customizing Articles")
1215 :type gnus-article-treat-head-custom)
1217 (defcustom gnus-treat-strip-headers-in-body t
1218 "Strip the X-No-Archive header line from the beginning of the body.
1219 Valid values are nil, t, `head', `last', an integer or a predicate.
1220 See Info node `(gnus)Customizing Articles' for details."
1222 :group 'gnus-article-treat
1223 :link '(custom-manual "(gnus)Customizing Articles")
1224 :type gnus-article-treat-custom)
1226 (defcustom gnus-treat-strip-trailing-blank-lines nil
1227 "Strip trailing blank lines.
1228 Valid values are nil, t, `head', `last', an integer or a predicate.
1229 See Info node `(gnus)Customizing Articles' for details."
1230 :group 'gnus-article-treat
1231 :link '(custom-manual "(gnus)Customizing Articles")
1232 :type gnus-article-treat-custom)
1234 (defcustom gnus-treat-strip-leading-blank-lines nil
1235 "Strip leading blank lines.
1236 Valid values are nil, t, `head', `last', an integer or a predicate.
1237 See Info node `(gnus)Customizing Articles' for details."
1238 :group 'gnus-article-treat
1239 :link '(custom-manual "(gnus)Customizing Articles")
1240 :type gnus-article-treat-custom)
1242 (defcustom gnus-treat-strip-multiple-blank-lines nil
1243 "Strip multiple blank lines.
1244 Valid values are nil, t, `head', `last', an integer or a predicate.
1245 See Info node `(gnus)Customizing Articles' for details."
1246 :group 'gnus-article-treat
1247 :link '(custom-manual "(gnus)Customizing Articles")
1248 :type gnus-article-treat-custom)
1250 (defcustom gnus-treat-unfold-headers 'head
1251 "Unfold folded header lines.
1252 Valid values are nil, t, `head', `last', an integer or a predicate.
1253 See Info node `(gnus)Customizing Articles' for details."
1255 :group 'gnus-article-treat
1256 :link '(custom-manual "(gnus)Customizing Articles")
1257 :type gnus-article-treat-custom)
1259 (defcustom gnus-treat-fold-headers nil
1261 Valid values are nil, t, `head', `last', an integer or a predicate.
1262 See Info node `(gnus)Customizing Articles' for details."
1264 :group 'gnus-article-treat
1265 :link '(custom-manual "(gnus)Customizing Articles")
1266 :type gnus-article-treat-custom)
1268 (defcustom gnus-treat-fold-newsgroups 'head
1269 "Fold the Newsgroups and Followup-To headers.
1270 Valid values are nil, t, `head', `last', an integer or a predicate.
1271 See Info node `(gnus)Customizing Articles' for details."
1273 :group 'gnus-article-treat
1274 :link '(custom-manual "(gnus)Customizing Articles")
1275 :type gnus-article-treat-custom)
1277 (defcustom gnus-treat-overstrike t
1278 "Treat overstrike highlighting.
1279 Valid values are nil, t, `head', `last', an integer or a predicate.
1280 See Info node `(gnus)Customizing Articles' for details."
1281 :group 'gnus-article-treat
1282 :link '(custom-manual "(gnus)Customizing Articles")
1283 :type gnus-article-treat-custom)
1284 (put 'gnus-treat-overstrike 'highlight t)
1286 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1287 "Treat ANSI SGR control sequences.
1288 Valid values are nil, t, `head', `last', an integer or a predicate.
1289 See Info node `(gnus)Customizing Articles' for details."
1290 :group 'gnus-article-treat
1291 :link '(custom-manual "(gnus)Customizing Articles")
1292 :type gnus-article-treat-custom)
1294 (make-obsolete-variable 'gnus-treat-display-xface
1295 'gnus-treat-display-x-face)
1297 (defcustom gnus-treat-display-x-face
1298 (and (not noninteractive)
1299 (or (eq gnus-article-x-face-command
1300 'x-face-mule-gnus-article-display-x-face)
1301 (and (fboundp 'image-type-available-p)
1302 (image-type-available-p 'xbm)
1303 (string-match "^0x" (shell-command-to-string "uncompface"))
1304 (executable-find "icontopbm"))
1305 (and (featurep 'xemacs)
1308 "Display X-Face headers.
1309 Valid values are nil, t, `head', `last', an integer or a predicate.
1310 See Info node `(gnus)Customizing Articles' and Info node
1311 `(gnus)X-Face' for details."
1312 :group 'gnus-article-treat
1314 :link '(custom-manual "(gnus)Customizing Articles")
1315 :link '(custom-manual "(gnus)X-Face")
1316 :type gnus-article-treat-head-custom
1317 :set (lambda (symbol value)
1320 (cond ((or (boundp symbol) (get symbol 'saved-value))
1322 ((boundp 'gnus-treat-display-xface)
1324 ** gnus-treat-display-xface is an obsolete variable;\
1325 use gnus-treat-display-x-face instead")
1326 (default-value 'gnus-treat-display-xface))
1327 ((get 'gnus-treat-display-xface 'saved-value)
1329 ** gnus-treat-display-xface is an obsolete variable;\
1330 use gnus-treat-display-x-face instead")
1331 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1334 (put 'gnus-treat-display-x-face 'highlight t)
1336 (defcustom gnus-article-should-use-smiley-mule
1337 (not (or (featurep 'xemacs)
1338 (gnus-image-type-available-p 'xpm)
1339 (gnus-image-type-available-p 'pbm)))
1340 "Non-nil means use `smiley-mule' to show smileys rather than `smiley'.
1341 `smiley-mule' is boundled in BITMAP-MULE package. You can set it to t
1342 even if your Emacs supports images. It has no effect on XEmacs."
1343 :group 'gnus-article-various
1345 :get (lambda (symbol)
1346 (and (not noninteractive)
1347 (default-value symbol)
1348 (not (featurep 'xemacs))
1349 (module-installed-p 'smiley-mule)
1351 :set (lambda (symbol value)
1352 (set-default symbol (and (not noninteractive)
1354 (not (featurep 'xemacs))
1355 (module-installed-p 'smiley-mule)
1358 (defvar gnus-article-smiley-mule-loaded-p nil
1359 "Internal variable used to say whether `smiley-mule' is loaded (whether
1360 smiley functions are not overridden by `smiley').")
1362 (defcustom gnus-treat-display-face
1363 (and (not noninteractive)
1364 (or (and (fboundp 'image-type-available-p)
1365 (image-type-available-p 'png))
1366 (and (featurep 'xemacs)
1369 "Display Face headers.
1370 Valid values are nil, t, `head', `last', an integer or a predicate.
1371 See Info node `(gnus)Customizing Articles' and Info node
1372 `(gnus)X-Face' for details."
1373 :group 'gnus-article-treat
1375 :link '(custom-manual "(gnus)Customizing Articles")
1376 :link '(custom-manual "(gnus)X-Face")
1377 :type gnus-article-treat-head-custom)
1378 (put 'gnus-treat-display-face 'highlight t)
1380 (defcustom gnus-treat-display-smileys
1381 (if (and (not noninteractive)
1382 (or (and (featurep 'xemacs)
1384 (gnus-image-type-available-p 'xpm)
1385 (gnus-image-type-available-p 'pbm)
1386 (and (not (featurep 'xemacs))
1388 (module-installed-p 'smiley-mule))))
1392 Valid values are nil, t, `head', `last', an integer or a predicate.
1393 See Info node `(gnus)Customizing Articles' and Info node
1394 `(gnus)Smileys' for details."
1395 :group 'gnus-article-treat
1397 :link '(custom-manual "(gnus)Customizing Articles")
1398 :link '(custom-manual "(gnus)Smileys")
1399 :type gnus-article-treat-custom)
1400 (put 'gnus-treat-display-smileys 'highlight t)
1402 (defcustom gnus-treat-from-picon
1403 (if (and (gnus-image-type-available-p 'xpm)
1404 (gnus-picons-installed-p))
1406 "Display picons in the From header.
1407 Valid values are nil, t, `head', `last', an integer or a predicate.
1408 See Info node `(gnus)Customizing Articles' and Info node
1409 `(gnus)Picons' for details."
1411 :group 'gnus-article-treat
1413 :link '(custom-manual "(gnus)Customizing Articles")
1414 :link '(custom-manual "(gnus)Picons")
1415 :type gnus-article-treat-head-custom)
1416 (put 'gnus-treat-from-picon 'highlight t)
1418 (defcustom gnus-treat-mail-picon
1419 (if (and (gnus-image-type-available-p 'xpm)
1420 (gnus-picons-installed-p))
1422 "Display picons in To and Cc headers.
1423 Valid values are nil, t, `head', `last', an integer or a predicate.
1424 See Info node `(gnus)Customizing Articles' and Info node
1425 `(gnus)Picons' for details."
1427 :group 'gnus-article-treat
1429 :link '(custom-manual "(gnus)Customizing Articles")
1430 :link '(custom-manual "(gnus)Picons")
1431 :type gnus-article-treat-head-custom)
1432 (put 'gnus-treat-mail-picon 'highlight t)
1434 (defcustom gnus-treat-newsgroups-picon
1435 (if (and (gnus-image-type-available-p 'xpm)
1436 (gnus-picons-installed-p))
1438 "Display picons in the Newsgroups and Followup-To headers.
1439 Valid values are nil, t, `head', `last', an integer or a predicate.
1440 See Info node `(gnus)Customizing Articles' and Info node
1441 `(gnus)Picons' for details."
1443 :group 'gnus-article-treat
1445 :link '(custom-manual "(gnus)Customizing Articles")
1446 :link '(custom-manual "(gnus)Picons")
1447 :type gnus-article-treat-head-custom)
1448 (put 'gnus-treat-newsgroups-picon 'highlight t)
1450 (defcustom gnus-treat-body-boundary
1451 (if (and (eq window-system 'x)
1452 (or gnus-treat-newsgroups-picon
1453 gnus-treat-mail-picon
1454 gnus-treat-from-picon))
1456 "Draw a boundary at the end of the headers.
1457 Valid values are nil and `head'.
1458 See Info node `(gnus)Customizing Articles' for details."
1460 :group 'gnus-article-treat
1461 :link '(custom-manual "(gnus)Customizing Articles")
1462 :type gnus-article-treat-head-custom)
1464 (defcustom gnus-treat-capitalize-sentences nil
1465 "Capitalize sentence-starting words.
1466 Valid values are nil, t, `head', `last', an integer or a predicate.
1467 See Info node `(gnus)Customizing Articles' for details."
1469 :group 'gnus-article-treat
1470 :link '(custom-manual "(gnus)Customizing Articles")
1471 :type gnus-article-treat-custom)
1473 (defcustom gnus-treat-wash-html nil
1475 Valid values are nil, t, `head', `last', an integer or a predicate.
1476 See Info node `(gnus)Customizing Articles' for details."
1478 :group 'gnus-article-treat
1479 :link '(custom-manual "(gnus)Customizing Articles")
1480 :type gnus-article-treat-custom)
1482 (defcustom gnus-treat-fill-long-lines nil
1484 Valid values are nil, t, `head', `last', an integer or a predicate.
1485 See Info node `(gnus)Customizing Articles' for details."
1486 :group 'gnus-article-treat
1487 :link '(custom-manual "(gnus)Customizing Articles")
1488 :type gnus-article-treat-custom)
1490 (defcustom gnus-treat-play-sounds nil
1492 Valid values are nil, t, `head', `last', an integer or a predicate.
1493 See Info node `(gnus)Customizing Articles' for details."
1495 :group 'gnus-article-treat
1496 :link '(custom-manual "(gnus)Customizing Articles")
1497 :type gnus-article-treat-custom)
1499 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
1500 "Decode an article as `default-mime-charset'. For instance, if you want to
1501 attempt to decode an article even if the value of `gnus-show-mime' is nil,
1502 you could set this variable to something like: nil for don't decode, t for
1503 decode the body, '(or header t) for the whole article, etc."
1504 :group 'gnus-article-treat
1505 :type '(radio (const :tag "Off" nil)
1506 (const :tag "Decode body" t)
1507 (const :tag "Decode all" (or head t))))
1509 (defcustom gnus-treat-translate nil
1510 "Translate articles from one language to another.
1511 Valid values are nil, t, `head', `last', an integer or a predicate.
1512 See Info node `(gnus)Customizing Articles' for details."
1514 :group 'gnus-article-treat
1515 :link '(custom-manual "(gnus)Customizing Articles")
1516 :type gnus-article-treat-custom)
1518 (defcustom gnus-treat-x-pgp-sig nil
1520 To automatically treat X-PGP-Sig, set it to head.
1521 Valid values are nil, t, `head', `last', an integer or a predicate.
1522 See Info node `(gnus)Customizing Articles' for details."
1524 :group 'gnus-article-treat
1525 :group 'mime-security
1526 :type gnus-article-treat-custom)
1528 (defcustom gnus-treat-monafy nil
1529 "Display body part with mona font.
1530 Valid values are nil, t, `head', `last', an integer or a predicate.
1531 See Info node `(gnus)Customizing Articles' for details."
1532 :group 'gnus-article-treat
1533 :group 'mime-security
1534 :link '(custom-manual "(gnus)Customizing Articles")
1535 :type gnus-article-treat-custom)
1537 (defvar gnus-article-encrypt-protocol-alist
1538 '(("PGP" . mml2015-self-encrypt)))
1540 ;; Set to nil if more than one protocol added to
1541 ;; gnus-article-encrypt-protocol-alist.
1542 (defcustom gnus-article-encrypt-protocol "PGP"
1543 "The protocol used for encrypt articles.
1544 It is a string, such as \"PGP\". If nil, ask user."
1547 :group 'mime-security)
1549 (defvar gnus-article-wash-function nil
1550 "Function used for converting HTML into text.")
1552 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1553 (mm-coding-system-p 'utf-8)
1554 (executable-find idna-program))
1555 "Whether IDNA decoding of headers is used when viewing messages.
1556 This requires GNU Libidn, and by default only enabled if it is found."
1558 :group 'gnus-article-headers
1561 (defcustom gnus-article-over-scroll nil
1562 "If non-nil, allow scrolling the article buffer even when there no more text."
1564 :group 'gnus-article
1567 ;;; Internal variables
1569 (defvar gnus-english-month-names
1570 '("January" "February" "March" "April" "May" "June" "July" "August"
1571 "September" "October" "November" "December"))
1573 (defvar gnus-button-regexp nil)
1574 (defvar gnus-button-marker-list nil)
1575 ;; Regexp matching any of the regexps from `gnus-button-alist'.
1577 (defvar gnus-button-last nil)
1578 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
1580 (defvar article-goto-body-goes-to-point-min-p nil)
1581 (defvar gnus-article-wash-types nil)
1582 (defvar gnus-article-emphasis-alist nil)
1583 (defvar gnus-article-image-alist nil)
1585 (defvar gnus-article-mime-handle-alist-1 nil)
1586 (defvar gnus-treatment-function-alist
1587 '((gnus-treat-decode-article-as-default-mime-charset
1588 gnus-article-decode-article-as-default-mime-charset)
1589 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1590 (gnus-treat-monafy gnus-article-monafy)
1591 (gnus-treat-strip-banner gnus-article-strip-banner)
1592 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1593 (gnus-treat-buttonize gnus-article-add-buttons)
1594 (gnus-treat-fill-article gnus-article-fill-cited-article)
1595 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1596 (gnus-treat-strip-cr gnus-article-remove-cr)
1597 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1598 (gnus-treat-date-ut gnus-article-date-ut)
1599 (gnus-treat-date-local gnus-article-date-local)
1600 (gnus-treat-date-english gnus-article-date-english)
1601 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1602 (gnus-treat-date-original gnus-article-date-original)
1603 (gnus-treat-date-user-defined gnus-article-date-user)
1604 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1605 (gnus-treat-display-face gnus-article-display-face)
1606 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1607 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1608 (gnus-treat-hide-signature gnus-article-hide-signature)
1609 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1610 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1611 (gnus-treat-strip-pem gnus-article-hide-pem)
1612 (gnus-treat-from-picon gnus-treat-from-picon)
1613 (gnus-treat-mail-picon gnus-treat-mail-picon)
1614 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1615 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1616 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1617 (gnus-treat-strip-trailing-blank-lines
1618 gnus-article-remove-trailing-blank-lines)
1619 (gnus-treat-strip-leading-blank-lines
1620 gnus-article-strip-leading-blank-lines)
1621 (gnus-treat-strip-multiple-blank-lines
1622 gnus-article-strip-multiple-blank-lines)
1623 (gnus-treat-overstrike gnus-article-treat-overstrike)
1624 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1625 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1626 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1627 ;; Displaying X-Face should be done after unfolding headers
1628 ;; to protect bitmap lines.
1629 (gnus-treat-display-x-face gnus-article-display-x-face)
1630 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1631 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1632 (gnus-treat-display-smileys gnus-treat-smiley)
1633 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1634 (gnus-treat-wash-html gnus-article-wash-html)
1635 (gnus-treat-emphasize gnus-article-emphasize)
1636 (gnus-treat-hide-citation gnus-article-hide-citation)
1637 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1638 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1639 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1640 (gnus-treat-play-sounds gnus-earcon-display)))
1642 (defvar gnus-article-mime-handle-alist nil)
1643 (defvar article-lapsed-timer nil)
1644 (defvar gnus-article-current-summary nil)
1646 (defvar gnus-article-mode-syntax-table
1647 (let ((table (copy-syntax-table text-mode-syntax-table)))
1648 ;; This causes the citation match run O(2^n).
1649 ;; (modify-syntax-entry ?- "w" table)
1650 (modify-syntax-entry ?> ")<" table)
1651 (modify-syntax-entry ?< "(>" table)
1652 ;; make M-. in article buffers work for `foo' strings
1653 (modify-syntax-entry ?' " " table)
1654 (modify-syntax-entry ?` " " table)
1656 "Syntax table used in article mode buffers.
1657 Initialized from `text-mode-syntax-table.")
1659 (defvar gnus-save-article-buffer nil)
1661 (defvar gnus-article-mode-line-format-alist
1662 (nconc '((?w (gnus-article-wash-status) ?s)
1663 (?m (gnus-article-mime-part-status) ?s))
1664 gnus-summary-mode-line-format-alist))
1666 (defvar gnus-number-of-articles-to-be-saved nil)
1668 (defvar gnus-inhibit-hiding nil)
1670 (defvar gnus-article-edit-mode nil)
1672 ;;; Macros for dealing with the article buffer.
1674 (defmacro gnus-with-article-headers (&rest forms)
1676 (set-buffer gnus-article-buffer)
1678 (let ((inhibit-read-only t)
1679 (inhibit-point-motion-hooks t)
1680 (case-fold-search t))
1681 (article-narrow-to-head)
1684 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1685 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1687 (defmacro gnus-with-article-buffer (&rest forms)
1689 (set-buffer gnus-article-buffer)
1690 (let ((inhibit-read-only t))
1693 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1694 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1696 (defun gnus-article-goto-header (header)
1697 "Go to HEADER, which is a regular expression."
1698 (re-search-forward (concat "^\\(" header "\\):") nil t))
1700 (defsubst gnus-article-hide-text (b e props)
1701 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1702 (gnus-add-text-properties-when 'article-type nil b e props)
1703 (when (memq 'intangible props)
1705 (max (1- b) (point-min))
1706 b 'intangible (cddr (memq 'intangible props)))))
1708 (defsubst gnus-article-unhide-text (b e)
1709 "Remove hidden text properties from region between B and E."
1710 (remove-text-properties b e gnus-hidden-properties)
1711 (when (memq 'intangible gnus-hidden-properties)
1712 (put-text-property (max (1- b) (point-min))
1713 b 'intangible nil)))
1715 (defun gnus-article-hide-text-type (b e type)
1716 "Hide text of TYPE between B and E."
1717 (gnus-add-wash-type type)
1718 (gnus-article-hide-text
1719 b e (cons 'article-type (cons type gnus-hidden-properties))))
1721 (defun gnus-article-unhide-text-type (b e type)
1722 "Unhide text of TYPE between B and E."
1723 (gnus-delete-wash-type type)
1724 (remove-text-properties
1725 b e (cons 'article-type (cons type gnus-hidden-properties)))
1726 (when (memq 'intangible gnus-hidden-properties)
1727 (put-text-property (max (1- b) (point-min))
1728 b 'intangible nil)))
1730 (defun gnus-article-hide-text-of-type (type)
1731 "Hide text of TYPE in the current buffer."
1733 (let ((b (point-min))
1735 (while (setq b (text-property-any b e 'article-type type))
1736 (add-text-properties b (incf b) gnus-hidden-properties)))))
1738 (defun gnus-article-delete-text-of-type (type)
1739 "Delete text of TYPE in the current buffer."
1741 (let ((b (point-min)))
1742 (while (setq b (text-property-any b (point-max) 'article-type type))
1744 b (or (text-property-not-all b (point-max) 'article-type type)
1747 (defun gnus-article-delete-invisible-text ()
1748 "Delete all invisible text in the current buffer."
1750 (let ((b (point-min)))
1751 (while (setq b (text-property-any b (point-max) 'invisible t))
1753 b (or (text-property-not-all b (point-max) 'invisible t)
1756 (defun gnus-article-text-type-exists-p (type)
1757 "Say whether any text of type TYPE exists in the buffer."
1758 (text-property-any (point-min) (point-max) 'article-type type))
1760 (defsubst gnus-article-header-rank ()
1761 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1762 (let ((list gnus-sorted-header-list)
1765 (if (looking-at (car list))
1767 (setq list (cdr list))
1771 (defun article-hide-headers (&optional arg delete)
1772 "Hide unwanted headers and possibly sort them as well."
1773 (interactive (gnus-article-hidden-arg))
1774 ;; Lars said that this function might be inhibited.
1775 (if (gnus-article-check-hidden-text 'headers arg)
1777 ;; Show boring headers as well.
1778 (gnus-article-show-hidden-text 'boring-headers)
1779 (when (eq 1 (point-min))
1780 (set-window-start (get-buffer-window (current-buffer)) 1)))
1781 (unless gnus-inhibit-hiding
1782 (let ((inhibit-read-only t)
1783 (case-fold-search t)
1784 (max (1+ (length gnus-sorted-header-list)))
1785 (inhibit-point-motion-hooks t)
1786 (cur (current-buffer))
1787 ignored visible beg)
1789 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1790 ;; group parameters, so we should go to the summary buffer.
1793 (progn (set-buffer gnus-summary-buffer) t)
1795 (setq ignored (when (not gnus-visible-headers)
1796 (cond ((stringp gnus-ignored-headers)
1797 gnus-ignored-headers)
1798 ((listp gnus-ignored-headers)
1799 (mapconcat 'identity
1800 gnus-ignored-headers
1802 visible (cond ((stringp gnus-visible-headers)
1803 gnus-visible-headers)
1804 ((and gnus-visible-headers
1805 (listp gnus-visible-headers))
1806 (mapconcat 'identity
1807 gnus-visible-headers
1811 ;; First we narrow to just the headers.
1812 (article-narrow-to-head)
1813 ;; Hide any "From " lines at the beginning of (mail) articles.
1814 (while (looking-at "From ")
1818 (delete-region (point-min) (point))
1819 (gnus-article-hide-text (point-min) (point)
1820 (nconc (list 'article-type 'headers)
1821 gnus-hidden-properties))))
1822 ;; Then treat the rest of the header lines.
1823 ;; Then we use the two regular expressions
1824 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1825 ;; select which header lines is to remain visible in the
1827 (while (re-search-forward "^[^ \t:]*:" nil t)
1829 ;; Mark the rank of the header.
1831 (point) (1+ (point)) 'message-rank
1832 (if (or (and visible (looking-at visible))
1834 (not (looking-at ignored))))
1835 (gnus-article-header-rank)
1838 (message-sort-headers-1)
1839 (when (setq beg (text-property-any
1840 (point-min) (point-max) 'message-rank (+ 2 max)))
1841 ;; We delete or make invisible the unwanted headers.
1842 (gnus-add-wash-type 'headers)
1845 (add-text-properties
1846 (point-min) (+ 5 (point-min))
1847 '(article-type headers dummy-invisible t))
1848 (delete-region beg (point-max)))
1849 (gnus-article-hide-text-type beg (point-max) 'headers)))))))))
1851 (defun article-hide-boring-headers (&optional arg)
1852 "Toggle hiding of headers that aren't very interesting.
1853 If given a negative prefix, always show; if given a positive prefix,
1855 (interactive (gnus-article-hidden-arg))
1856 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1857 (not gnus-show-all-headers))
1860 (let ((inhibit-read-only t)
1861 (inhibit-point-motion-hooks t))
1862 (article-narrow-to-head)
1863 (dolist (elem gnus-boring-article-headers)
1864 (goto-char (point-min))
1866 ;; Hide empty headers.
1868 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1870 (gnus-article-hide-text-type
1874 (if (re-search-forward "^[^ \t]" nil t)
1878 ;; Hide boring Newsgroups header.
1879 ((eq elem 'newsgroups)
1880 (when (gnus-string-equal
1881 (gnus-fetch-field "newsgroups")
1882 (gnus-group-real-name
1883 (if (boundp 'gnus-newsgroup-name)
1886 (gnus-article-hide-header "newsgroups")))
1887 ((eq elem 'to-address)
1888 (let ((to (message-fetch-field "to"))
1890 (gnus-parameter-to-address
1891 (if (boundp 'gnus-newsgroup-name)
1892 gnus-newsgroup-name ""))))
1893 (when (and to to-address
1896 ;; only one address in To
1897 (nth 1 (mail-extract-address-components to))
1899 (gnus-article-hide-header "to"))))
1901 (let ((to (message-fetch-field "to"))
1903 (gnus-parameter-to-list
1904 (if (boundp 'gnus-newsgroup-name)
1905 gnus-newsgroup-name ""))))
1906 (when (and to to-list
1909 ;; only one address in To
1910 (nth 1 (mail-extract-address-components to))
1912 (gnus-article-hide-header "to"))))
1914 (let ((cc (message-fetch-field "cc"))
1916 (gnus-parameter-to-list
1917 (if (boundp 'gnus-newsgroup-name)
1918 gnus-newsgroup-name ""))))
1919 (when (and cc to-list
1922 ;; only one address in CC
1923 (nth 1 (mail-extract-address-components cc))
1925 (gnus-article-hide-header "cc"))))
1926 ((eq elem 'followup-to)
1927 (when (gnus-string-equal
1928 (message-fetch-field "followup-to")
1929 (message-fetch-field "newsgroups"))
1930 (gnus-article-hide-header "followup-to")))
1931 ((eq elem 'reply-to)
1932 (if (gnus-group-find-parameter
1933 gnus-newsgroup-name 'broken-reply-to)
1934 (gnus-article-hide-header "reply-to")
1935 (let ((from (message-fetch-field "from"))
1936 (reply-to (message-fetch-field "reply-to")))
1943 (lambda (x) (downcase (cadr x)))
1944 (mail-extract-address-components from t))
1947 (lambda (x) (downcase (cadr x)))
1948 (mail-extract-address-components reply-to t))
1950 (gnus-article-hide-header "reply-to")))))
1952 (let ((date (message-fetch-field "date")))
1954 (< (days-between (current-time-string) date)
1956 (gnus-article-hide-header "date"))))
1958 (let ((to (message-fetch-field "to"))
1959 (cc (message-fetch-field "cc")))
1960 (when (> (length to) 1024)
1961 (gnus-article-hide-header "to"))
1962 (when (> (length cc) 1024)
1963 (gnus-article-hide-header "cc"))))
1967 (goto-char (point-min))
1968 (while (re-search-forward "^to:" nil t)
1969 (setq to-count (1+ to-count)))
1970 (when (> to-count 1)
1971 (while (> to-count 0)
1972 (goto-char (point-min))
1974 (re-search-forward "^to:" nil nil to-count)
1976 (narrow-to-region (point) (point-max))
1977 (gnus-article-hide-header "to"))
1978 (setq to-count (1- to-count))))
1979 (goto-char (point-min))
1980 (while (re-search-forward "^cc:" nil t)
1981 (setq cc-count (1+ cc-count)))
1982 (when (> cc-count 1)
1983 (while (> cc-count 0)
1984 (goto-char (point-min))
1986 (re-search-forward "^cc:" nil nil cc-count)
1988 (narrow-to-region (point) (point-max))
1989 (gnus-article-hide-header "cc"))
1990 (setq cc-count (1- cc-count)))))))))))))
1992 (defun gnus-article-hide-header (header)
1994 (goto-char (point-min))
1995 (when (re-search-forward (concat "^" header ":") nil t)
1996 (gnus-article-hide-text-type
2000 (if (re-search-forward "^[^ \t]" nil t)
2005 (defvar gnus-article-normalized-header-length 40
2006 "Length of normalized headers.")
2008 (defun article-normalize-headers ()
2009 "Make all header lines 40 characters long."
2011 (let ((inhibit-read-only t)
2015 (article-narrow-to-head)
2018 ((< (setq column (- (point-at-eol) (point)))
2019 gnus-article-normalized-header-length)
2021 (insert (make-string
2022 (- gnus-article-normalized-header-length column)
2024 ((> column gnus-article-normalized-header-length)
2025 (gnus-put-text-property
2027 (forward-char gnus-article-normalized-header-length)
2034 (forward-line 1))))))
2036 (defun article-treat-dumbquotes ()
2037 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
2038 Note that this function guesses whether a character is a sm*rtq**t* or
2039 not, so it should only be used interactively.
2041 Sm*rtq**t*s are M****s***'s unilateral extension to the
2042 iso-8859-1 character map in an attempt to provide more quoting
2043 characters. If you see something like \\222 or \\264 where
2044 you're expecting some kind of apostrophe or quotation mark, then
2047 (article-translate-strings gnus-article-dumbquotes-map))
2049 (defun article-translate-characters (from to)
2050 "Translate all characters in the body of the article according to FROM and TO.
2051 FROM is a string of characters to translate from; to is a string of
2052 characters to translate to."
2054 (when (article-goto-body)
2055 (let ((inhibit-read-only t)
2056 (x (make-string 225 ?x))
2058 (while (< (incf i) (length x))
2061 (while (< i (length from))
2062 (aset x (aref from i) (aref to i))
2064 (translate-region (point) (point-max) x)))))
2066 (defun article-translate-strings (map)
2067 "Translate all string in the body of the article according to MAP.
2068 MAP is an alist where the elements are on the form (\"from\" \"to\")."
2070 (when (article-goto-body)
2071 (let ((inhibit-read-only t))
2074 (while (search-forward (car elem) nil t)
2075 (replace-match (cadr elem)))))))))
2077 (defun article-treat-overstrike ()
2078 "Translate overstrikes into bold text."
2081 (when (article-goto-body)
2082 (let ((inhibit-read-only t))
2083 (while (search-forward "\b" nil t)
2084 (let ((next (char-after))
2088 previous (char-after))
2092 ;; We do the boldification/underlining by hiding the
2093 ;; overstrikes and putting the proper text property
2097 (gnus-article-hide-text-type start (point) 'overstrike)
2098 (put-text-property (point) end 'face 'bold))
2100 (gnus-article-hide-text-type
2101 (1- (point)) (1+ (point)) 'overstrike)
2103 start (1- (point)) 'face 'underline))
2105 (gnus-article-hide-text-type start (point) 'overstrike)
2107 (point) end 'face 'underline)))))))))
2109 (defun article-treat-ansi-sequences ()
2110 "Translate ANSI SGR control sequences into overlays or extents."
2113 (when (article-goto-body)
2114 (let ((inhibit-read-only t))
2115 (ansi-color-apply-on-region (point) (point-max))))))
2117 (defun gnus-article-treat-unfold-headers ()
2118 "Unfold folded message headers.
2119 Only the headers that fit into the current window width will be
2122 (gnus-with-article-headers
2126 (mail-header-narrow-to-field)
2127 (let ((header (buffer-string)))
2130 (goto-char (point-min))
2131 (while (re-search-forward "\n[\t ]" nil t)
2132 (replace-match " " t t)))
2133 (setq length (- (point-max) (point-min) 1)))
2134 (when (< length (window-width))
2135 (while (re-search-forward "\n[\t ]" nil t)
2136 (replace-match " " t t)))
2137 (goto-char (point-max)))))))
2139 (defun gnus-article-treat-fold-headers ()
2140 "Fold message headers."
2142 (gnus-with-article-headers
2145 (mail-header-narrow-to-field)
2146 (mail-header-fold-field)
2147 (goto-char (point-max))))))
2149 (defun gnus-treat-smiley ()
2150 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2152 (unless (featurep 'xemacs)
2153 (when (and (not gnus-article-should-use-smiley-mule)
2154 gnus-article-smiley-mule-loaded-p)
2155 (load "smiley" nil t)
2156 (setq gnus-article-smiley-mule-loaded-p nil))
2157 (when (and gnus-article-should-use-smiley-mule
2158 (not gnus-article-smiley-mule-loaded-p))
2159 (load "smiley-mule" nil t)
2160 (setq gnus-article-smiley-mule-loaded-p t)))
2161 (gnus-with-article-buffer
2162 (if (memq 'smiley gnus-article-wash-types)
2163 (gnus-delete-images 'smiley)
2165 (let ((images (smiley-region (point) (point-max))))
2167 (gnus-add-wash-type 'smiley)
2168 (dolist (image images)
2169 (gnus-add-image 'smiley image)))))))
2171 (defun gnus-article-remove-images ()
2172 "Remove all images from the article buffer."
2174 (gnus-with-article-buffer
2175 (dolist (elem gnus-article-image-alist)
2176 (gnus-delete-images (car elem)))))
2178 (defun gnus-article-treat-fold-newsgroups ()
2179 "Unfold folded message headers.
2180 Only the headers that fit into the current window width will be
2183 (gnus-with-article-headers
2184 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2186 (mail-header-narrow-to-field)
2187 (while (re-search-forward ", *" nil t)
2188 (replace-match ", " t t))
2189 (mail-header-fold-field)
2190 (goto-char (point-max))))))
2192 (defun gnus-article-treat-body-boundary ()
2193 "Place a boundary line at the end of the headers."
2195 (when (and gnus-body-boundary-delimiter
2196 (> (length gnus-body-boundary-delimiter) 0))
2197 (gnus-with-article-headers
2198 (goto-char (point-max))
2199 (let ((start (point)))
2200 (insert "X-Boundary: ")
2201 (gnus-add-text-properties start (point) '(invisible t intangible t))
2203 (while (>= (1- (window-width)) (length str))
2204 (setq str (concat str gnus-body-boundary-delimiter)))
2205 (substring str 0 (1- (window-width))))
2207 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2209 (defun article-fill-long-lines ()
2210 "Fill lines that are wider than the window width."
2213 (let ((inhibit-read-only t)
2214 (width (window-width (get-buffer-window (current-buffer)))))
2217 (let ((adaptive-fill-mode nil)) ;Why? -sm
2220 (when (>= (current-column) (min fill-column width))
2221 (narrow-to-region (min (1+ (point)) (point-max))
2223 (let ((goback (point-marker)))
2224 (fill-paragraph nil)
2225 (goto-char (marker-position goback)))
2227 (forward-line 1)))))))
2229 (defun article-capitalize-sentences ()
2230 "Capitalize the first word in each sentence."
2233 (let ((inhibit-read-only t)
2234 (paragraph-start "^[\n\^L]"))
2238 (forward-sentence)))))
2240 (defun article-remove-cr ()
2241 "Remove trailing CRs and then translate remaining CRs into LFs."
2244 (let ((inhibit-read-only t))
2245 (goto-char (point-min))
2246 (while (re-search-forward "\r+$" nil t)
2247 (replace-match "" t t))
2248 (goto-char (point-min))
2249 (while (search-forward "\r" nil t)
2250 (replace-match "\n" t t)))))
2252 (defun article-remove-trailing-blank-lines ()
2253 "Remove all trailing blank lines from the article."
2256 (let ((inhibit-read-only t))
2257 (goto-char (point-max))
2261 (while (and (not (bobp))
2262 (looking-at "^[ \t]*$")
2263 (not (gnus-annotation-in-region-p
2264 (point) (point-at-eol))))
2270 (defvar gnus-face-properties-alist))
2272 (defun article-display-face ()
2273 "Display any Face headers in the header."
2275 (let ((wash-face-p buffer-read-only))
2276 (gnus-with-article-headers
2277 ;; When displaying parts, this function can be called several times on
2278 ;; the same article, without any intended toggle semantic (as typing `W
2279 ;; D d' would have). So face deletion must occur only when we come from
2280 ;; an interactive command, that is when the *Article* buffer is
2282 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2283 (gnus-delete-images 'face)
2286 (when (and wash-face-p
2288 (goto-char (point-min))
2289 (not (re-search-forward "^Face:[\t ]*" nil t)))
2290 (gnus-buffer-live-p gnus-original-article-buffer))
2291 (set-buffer gnus-original-article-buffer))
2293 (mail-narrow-to-head)
2294 (while (gnus-article-goto-header "Face")
2295 (setq faces (nconc faces (list (mail-header-field-value)))))))
2296 (dolist (face faces)
2297 (let ((png (gnus-convert-face-to-png face))
2301 (apply 'gnus-create-image png 'png t
2302 (cdr (assq 'png gnus-face-properties-alist))))
2303 (gnus-article-goto-header "from")
2305 (insert "From: [no `from' set]\n")
2307 (gnus-add-wash-type 'face)
2308 (gnus-add-image 'face image)
2309 (gnus-put-image image nil 'face))))))
2312 (defun article-display-x-face (&optional force)
2313 "Look for an X-Face header and display it if present."
2314 (interactive (list 'force))
2315 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2316 (gnus-with-article-headers
2317 ;; Delete the old process, if any.
2318 (when (process-status "article-x-face")
2319 (delete-process "article-x-face"))
2320 ;; See the comment in `article-display-face'.
2321 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2322 ;; We have already displayed X-Faces, so we remove them
2324 (gnus-delete-images 'xface)
2326 (let (x-faces from face)
2328 (when (and wash-face-p
2330 (goto-char (point-min))
2331 (not (re-search-forward
2332 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2333 (gnus-buffer-live-p gnus-original-article-buffer))
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))))
2347 (while (and (setq face (pop x-faces))
2348 gnus-article-x-face-command
2350 ;; Check whether this face is censored.
2351 (not gnus-article-x-face-too-ugly)
2352 (and gnus-article-x-face-too-ugly from
2353 (not (string-match gnus-article-x-face-too-ugly
2355 ;; We display the face.
2356 (cond ((stringp gnus-article-x-face-command)
2357 ;; The command is a string, so we interpret the command
2358 ;; as a, well, command, and fork it off.
2359 (let ((process-connection-type nil))
2360 (gnus-set-process-query-on-exit-flag
2362 "article-x-face" nil shell-file-name
2363 shell-command-switch gnus-article-x-face-command)
2367 (process-send-region "article-x-face"
2368 (point-min) (point-max)))
2369 (process-send-eof "article-x-face")))
2370 ((functionp gnus-article-x-face-command)
2371 ;; The command is a lisp function, so we call it.
2372 (funcall gnus-article-x-face-command face))
2374 (error "%s is not a function"
2375 gnus-article-x-face-command)))))))))
2377 (defun article-decode-mime-words ()
2378 "Decode all MIME-encoded words in the article."
2380 (gnus-with-article-buffer
2381 (let ((inhibit-point-motion-hooks t)
2382 (mail-parse-charset gnus-newsgroup-charset)
2383 (mail-parse-ignored-charsets
2384 (with-current-buffer gnus-summary-buffer
2385 gnus-newsgroup-ignored-charsets)))
2386 (mail-decode-encoded-word-region (point-min) (point-max)))))
2388 (defun article-decode-charset (&optional prompt)
2389 "Decode charset-encoded text in the article.
2390 If PROMPT (the prefix), prompt for a coding system to use."
2392 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2393 (inhibit-read-only t)
2394 (mail-parse-charset gnus-newsgroup-charset)
2395 (mail-parse-ignored-charsets
2396 (save-excursion (condition-case nil
2397 (set-buffer gnus-summary-buffer)
2399 gnus-newsgroup-ignored-charsets))
2400 ct cte ctl charset format)
2403 (article-narrow-to-head)
2404 (setq ct (message-fetch-field "Content-Type" t)
2405 cte (message-fetch-field "Content-Transfer-Encoding" t)
2406 ctl (and ct (ignore-errors
2407 (mail-header-parse-content-type ct)))
2410 (mm-read-coding-system "Charset to decode: "))
2412 (mail-content-type-get ctl 'charset)))
2413 format (and ctl (mail-content-type-get ctl 'format)))
2415 (setq cte (mail-header-strip cte)))
2416 (if (and ctl (not (string-match "/" (car ctl))))
2418 (goto-char (point-max)))
2421 (narrow-to-region (point) (point-max))
2422 (when (and (eq mail-parse-charset 'gnus-decoded)
2423 (eq (mm-body-7-or-8) '8bit))
2424 ;; The text code could have been decoded.
2425 (setq charset mail-parse-charset))
2426 (when (and (or (not ctl)
2427 (equal (car ctl) "text/plain"))
2428 (not format)) ;; article with format will decode later.
2430 charset (and cte (intern (downcase
2431 (gnus-strip-whitespace cte))))
2434 (defun article-decode-encoded-words ()
2435 "Remove encoded-word encoding from headers."
2436 (let ((charset (save-excursion
2437 (set-buffer gnus-summary-buffer)
2438 default-mime-charset))
2439 (inhibit-read-only t))
2440 (mime-decode-header-in-buffer charset)))
2442 (defun article-decode-group-name ()
2443 "Decode group names in `Newsgroups:'."
2444 (let ((inhibit-point-motion-hooks t)
2445 (inhibit-read-only t)
2446 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2447 (when (and (or gnus-group-name-charset-method-alist
2448 gnus-group-name-charset-group-alist)
2449 (gnus-buffer-live-p gnus-original-article-buffer))
2451 (article-narrow-to-head)
2452 (with-current-buffer gnus-original-article-buffer
2453 (goto-char (point-min)))
2454 (while (re-search-forward
2455 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2456 (replace-match (save-match-data
2457 (gnus-decode-newsgroups
2458 ;; XXX how to use data in article buffer?
2459 (with-current-buffer gnus-original-article-buffer
2461 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2464 gnus-newsgroup-name method))
2466 (goto-char (point-min))
2467 (with-current-buffer gnus-original-article-buffer
2468 (goto-char (point-min)))
2469 (while (re-search-forward
2470 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2471 (replace-match (save-match-data
2472 (gnus-decode-newsgroups
2473 ;; XXX how to use data in article buffer?
2474 (with-current-buffer gnus-original-article-buffer
2476 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2479 gnus-newsgroup-name method))
2482 (autoload 'idna-to-unicode "idna")
2484 (defun article-decode-idna-rhs ()
2485 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2488 (let ((inhibit-point-motion-hooks t)
2489 (inhibit-read-only t))
2490 (article-narrow-to-head)
2491 (goto-char (point-min))
2492 (while (re-search-forward "@.*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2494 (when (save-match-data
2495 (and (setq ace (match-string 1))
2497 (and (re-search-backward "^[^ \t]" nil t)
2498 (looking-at "From\\|To\\|Cc")))
2499 (setq unicode (idna-to-unicode ace))))
2500 (unless (string= ace unicode)
2501 (replace-match unicode nil nil nil 1)))))))))
2503 (defun article-de-quoted-unreadable (&optional force read-charset)
2504 "Translate a quoted-printable-encoded article.
2505 If FORCE, decode the article whether it is marked as quoted-printable
2507 If READ-CHARSET, ask for a coding system."
2508 (interactive (list 'force current-prefix-arg))
2510 (let ((inhibit-read-only t) type charset)
2511 (if (gnus-buffer-live-p gnus-original-article-buffer)
2512 (with-current-buffer gnus-original-article-buffer
2514 (gnus-fetch-field "content-transfer-encoding"))
2515 (let* ((ct (gnus-fetch-field "content-type"))
2518 (mail-header-parse-content-type ct)))))
2519 (setq charset (and ctl
2520 (mail-content-type-get ctl 'charset)))
2521 (if (stringp charset)
2522 (setq charset (intern (downcase charset)))))))
2524 (setq charset (mm-read-coding-system "Charset: " charset)))
2526 (setq charset gnus-newsgroup-charset))
2528 (and type (let ((case-fold-search t))
2529 (string-match "quoted-printable" type))))
2531 (quoted-printable-decode-region
2532 (point) (point-max) (mm-charset-to-coding-system charset))))))
2534 (defun article-de-base64-unreadable (&optional force read-charset)
2535 "Translate a base64 article.
2536 If FORCE, decode the article whether it is marked as base64 not.
2537 If READ-CHARSET, ask for a coding system."
2538 (interactive (list 'force current-prefix-arg))
2540 (let ((inhibit-read-only t) type charset)
2541 (if (gnus-buffer-live-p gnus-original-article-buffer)
2542 (with-current-buffer gnus-original-article-buffer
2544 (gnus-fetch-field "content-transfer-encoding"))
2545 (let* ((ct (gnus-fetch-field "content-type"))
2548 (mail-header-parse-content-type ct)))))
2549 (setq charset (and ctl
2550 (mail-content-type-get ctl 'charset)))
2551 (if (stringp charset)
2552 (setq charset (intern (downcase charset)))))))
2554 (setq charset (mm-read-coding-system "Charset: " charset)))
2556 (setq charset gnus-newsgroup-charset))
2558 (and type (let ((case-fold-search t))
2559 (string-match "base64" type))))
2562 (narrow-to-region (point) (point-max))
2563 (base64-decode-region (point-min) (point-max))
2564 (mm-decode-coding-region
2565 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2570 (defun article-decode-HZ ()
2571 "Translate a HZ-encoded article."
2575 (let ((inhibit-read-only t))
2576 (rfc1843-decode-region (point-min) (point-max)))))
2578 (defun article-unsplit-urls ()
2579 "Remove the newlines that some other mailers insert into URLs."
2582 (let ((inhibit-read-only t))
2583 (goto-char (point-min))
2584 (while (re-search-forward
2585 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2586 (replace-match "\\1\\3" t)))
2587 (when (interactive-p)
2588 (gnus-treat-article nil))))
2591 (defun article-wash-html (&optional read-charset)
2592 "Format an HTML article.
2593 If READ-CHARSET, ask for a coding system."
2596 (let ((inhibit-read-only t)
2598 (when (gnus-buffer-live-p gnus-original-article-buffer)
2599 (with-current-buffer gnus-original-article-buffer
2600 (let* ((ct (gnus-fetch-field "content-type"))
2603 (mail-header-parse-content-type ct)))))
2604 (setq charset (and ctl
2605 (mail-content-type-get ctl 'charset)))
2606 (when (stringp charset)
2607 (setq charset (intern (downcase charset)))))))
2609 (setq charset (mm-read-coding-system "Charset: " charset)))
2611 (setq charset gnus-newsgroup-charset))
2613 (save-window-excursion
2615 (narrow-to-region (point) (point-max))
2616 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2617 (entry (assq func mm-text-html-washer-alist)))
2619 (setq func (cdr entry)))
2624 (apply (car func) (cdr func))))))))))
2626 (defun gnus-article-wash-html-with-w3 ()
2627 "Wash the current buffer with w3."
2629 (let ((w3-strict-width (window-width))
2630 (url-standalone-mode t)
2631 (url-gateway-unplugged t)
2632 (w3-honor-stylesheets nil))
2634 (w3-region (point-min) (point-max))
2637 (defun gnus-article-wash-html-with-w3m ()
2638 "Wash the current buffer with emacs-w3m."
2641 (narrow-to-region (point) (point-max))
2642 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2643 w3m-force-redisplay)
2644 (w3m-region (point-min) (point-max)))
2645 (when (and mm-inline-text-html-with-w3m-keymap
2646 (boundp 'w3m-minor-mode-map)
2648 (add-text-properties
2649 (point-min) (point-max)
2650 (list 'keymap w3m-minor-mode-map
2651 ;; Put the mark meaning this part was rendered by emacs-w3m.
2652 'mm-inline-text-html-with-w3m t)))))
2654 (defun article-hide-list-identifiers ()
2655 "Remove list identifies from the Subject header.
2656 The `gnus-list-identifiers' variable specifies what to do."
2658 (let ((inhibit-point-motion-hooks t)
2659 (regexp (if (consp gnus-list-identifiers)
2660 (mapconcat 'identity gnus-list-identifiers " *\\|")
2661 gnus-list-identifiers))
2662 (inhibit-read-only t))
2666 (article-narrow-to-head)
2667 (goto-char (point-min))
2668 (while (re-search-forward
2669 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2671 (delete-region (match-beginning 2) (match-end 0))
2672 (beginning-of-line))
2673 (when (re-search-forward
2674 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2675 (delete-region (match-beginning 1) (match-end 1))))))))
2677 (defun article-hide-pem (&optional arg)
2678 "Toggle hiding of any PEM headers and signatures in the current article.
2679 If given a negative prefix, always show; if given a positive prefix,
2681 (interactive (gnus-article-hidden-arg))
2682 (unless (gnus-article-check-hidden-text 'pem arg)
2684 (let ((inhibit-read-only t) end)
2685 (goto-char (point-min))
2686 ;; Hide the horrendously ugly "header".
2687 (when (and (search-forward
2688 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2690 (setq end (1+ (match-beginning 0))))
2691 (gnus-add-wash-type 'pem)
2692 (gnus-article-hide-text-type
2694 (if (search-forward "\n\n" nil t)
2698 ;; Hide the trailer as well
2699 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2701 (gnus-article-hide-text-type
2702 (match-beginning 0) (match-end 0) 'pem)))))))
2704 (defun article-strip-banner ()
2705 "Strip the banners specified by the `banner' group parameter and by
2706 `gnus-article-address-banner-alist'."
2710 (let ((inhibit-point-motion-hooks t))
2711 (when (gnus-parameter-banner gnus-newsgroup-name)
2712 (article-really-strip-banner
2713 (gnus-parameter-banner gnus-newsgroup-name)))
2714 (when gnus-article-address-banner-alist
2715 ;; It is necessary to encode from fields before checking,
2716 ;; because `mail-header-parse-addresses' does not work
2717 ;; (reliably) on decoded headers. And more, it is
2718 ;; impossible to use `gnus-fetch-original-field' here,
2719 ;; because `article-strip-banner' may be called in draft
2720 ;; buffers to preview them.
2721 (let ((from (save-restriction
2723 (article-narrow-to-head)
2724 (mail-fetch-field "from"))))
2727 (caar (mail-header-parse-addresses
2728 (mail-encode-encoded-word-string from)))))
2730 (dolist (pair gnus-article-address-banner-alist)
2731 (when (string-match (car pair) from)
2733 (article-really-strip-banner (cdr pair)))))))))))))
2735 (defun article-really-strip-banner (banner)
2736 "Strip the banner specified by the argument."
2739 (let ((inhibit-point-motion-hooks t)
2740 (gnus-signature-limit nil)
2741 (inhibit-read-only t))
2744 ((eq banner 'signature)
2745 (when (gnus-article-narrow-to-signature)
2748 (delete-region (point) (point-max))))
2750 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2751 (while (re-search-forward banner nil t)
2752 (delete-region (match-beginning 0) (match-end 0)))))
2754 (while (re-search-forward banner nil t)
2755 (delete-region (match-beginning 0) (match-end 0)))))))))
2757 (defun article-babel ()
2758 "Translate article using an online translation service."
2761 (gnus-with-article-buffer
2762 (when (article-goto-body)
2763 (let* ((start (point))
2765 (orig (buffer-substring start end))
2766 (trans (babel-as-string orig)))
2768 (narrow-to-region start end)
2769 (delete-region start end)
2772 (defun article-hide-signature (&optional arg)
2773 "Hide the signature in the current article.
2774 If given a negative prefix, always show; if given a positive prefix,
2776 (interactive (gnus-article-hidden-arg))
2782 (article-goto-body))
2783 (goto-char (point-min)))
2784 (unless (gnus-article-check-hidden-text 'signature arg)
2785 (let ((inhibit-read-only t)
2787 (while (setq button (text-property-any button (point-max)
2789 'gnus-signature-toggle))
2790 (setq button (text-property-not-all button (point-max)
2792 'gnus-signature-toggle))
2793 (when (and button (not (eobp)))
2794 (gnus-article-hide-text-type
2796 (next-single-property-change (1+ button) 'mime-view-entity
2799 (gnus-set-mode-line 'article))
2801 (defun article-strip-headers-in-body ()
2802 "Strip offensive headers from bodies."
2806 (let ((case-fold-search t))
2807 (when (looking-at "x-no-archive:")
2808 (gnus-delete-line)))))
2810 (defun article-strip-leading-blank-lines ()
2811 "Remove all blank lines from the beginning of the article."
2814 (let ((inhibit-point-motion-hooks t)
2815 (inhibit-read-only t))
2816 (when (article-goto-body)
2817 (while (and (not (eobp))
2818 (looking-at "[ \t]*$"))
2819 (gnus-delete-line))))))
2821 (defun article-narrow-to-head ()
2822 "Narrow the buffer to the head of the message.
2823 Point is left at the beginning of the narrowed-to region."
2825 (goto-char (point-min))
2826 (if (search-forward "\n\n" nil 1)
2829 (goto-char (point-min)))
2831 (defun article-goto-body ()
2832 "Place point at the start of the body."
2833 (goto-char (point-min))
2835 ;; This variable is only bound when dealing with separate
2837 (article-goto-body-goes-to-point-min-p
2839 ((search-forward "\n\n" nil t)
2842 (goto-char (point-max))
2845 (defun article-strip-multiple-blank-lines ()
2846 "Replace consecutive blank lines with one empty line."
2849 (let ((inhibit-point-motion-hooks t)
2850 (inhibit-read-only t))
2851 ;; First make all blank lines empty.
2853 (while (re-search-forward "^[ \t]+$" nil t)
2854 (unless (gnus-annotation-in-region-p
2855 (match-beginning 0) (match-end 0))
2856 (replace-match "" nil t)))
2857 ;; Then replace multiple empty lines with a single empty line.
2859 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2860 (unless (gnus-annotation-in-region-p
2861 (match-beginning 0) (match-end 0))
2862 (delete-region (match-beginning 1) (match-end 1)))))))
2864 (defun article-strip-leading-space ()
2865 "Remove all white space from the beginning of the lines in the article."
2868 (let ((inhibit-point-motion-hooks t)
2869 (inhibit-read-only t))
2871 (while (re-search-forward "^[ \t]+" nil t)
2872 (replace-match "" t t)))))
2874 (defun article-strip-trailing-space ()
2875 "Remove all white space from the end of the lines in the article."
2878 (let ((inhibit-point-motion-hooks t)
2879 (inhibit-read-only t))
2881 (while (re-search-forward "[ \t]+$" nil t)
2882 (replace-match "" t t)))))
2884 (defun article-strip-blank-lines ()
2885 "Strip leading, trailing and multiple blank lines."
2887 (article-strip-leading-blank-lines)
2888 (article-remove-trailing-blank-lines)
2889 (article-strip-multiple-blank-lines))
2891 (defun article-strip-all-blank-lines ()
2892 "Strip all blank lines."
2895 (let ((inhibit-point-motion-hooks t)
2896 (inhibit-read-only t))
2898 (while (re-search-forward "^[ \t]*\n" nil t)
2899 (replace-match "" t t)))))
2901 (defun gnus-article-narrow-to-signature ()
2902 "Narrow to the signature; return t if a signature is found, else nil."
2903 (let ((inhibit-point-motion-hooks t))
2904 (when (gnus-article-search-signature)
2906 ;; Check whether we have some limits to what we consider
2907 ;; to be a signature.
2908 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2909 (list gnus-signature-limit)))
2911 (while (setq limit (pop limits))
2912 (if (or (and (integerp limit)
2913 (< (- (point-max) (point)) limit))
2915 (< (count-lines (point) (point-max)) limit))
2916 (and (functionp limit)
2918 (and (stringp limit)
2919 (not (re-search-forward limit nil t))))
2920 () ; This limit did not succeed.
2924 (narrow-to-region (point) (point-max))
2927 (defun gnus-article-search-signature ()
2928 "Search the current buffer for the signature separator.
2929 Put point at the beginning of the signature separator."
2930 (let ((cur (point)))
2931 (goto-char (point-max))
2932 (if (if (stringp gnus-signature-separator)
2933 (re-search-backward gnus-signature-separator nil t)
2934 (let ((seps gnus-signature-separator))
2936 (not (re-search-backward (car seps) nil t)))
2943 (defun gnus-article-hidden-arg ()
2944 "Return the current prefix arg as a number, or 0 if no prefix."
2945 (list (if current-prefix-arg
2946 (prefix-numeric-value current-prefix-arg)
2949 (defun gnus-article-check-hidden-text (type arg)
2950 "Return nil if hiding is necessary.
2951 Arg can be nil or a number. nil and positive means hide, negative
2952 means show, 0 means toggle."
2955 (let ((hide (gnus-article-hidden-text-p type)))
2961 (gnus-article-show-hidden-text type)
2964 (if (eq hide 'hidden)
2966 (gnus-article-show-hidden-text type)
2970 (defun gnus-article-hidden-text-p (type)
2971 "Say whether the current buffer contains hidden text of type TYPE."
2972 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2974 (not (get-text-property pos 'invisible))
2975 (not (get-text-property pos 'dummy-invisible)))
2977 (text-property-any (1+ pos) (point-max) 'article-type type)))
2982 (defun gnus-article-show-hidden-text (type &optional dummy)
2983 "Show all hidden text of type TYPE.
2984 Originally it is hide instead of DUMMY."
2985 (let ((inhibit-read-only t)
2986 (inhibit-point-motion-hooks t))
2987 (gnus-remove-text-properties-when
2989 (point-min) (point-max)
2990 (cons 'article-type (cons type
2991 gnus-hidden-properties)))
2992 (gnus-delete-wash-type type)))
2994 (defconst article-time-units
2995 `((year . ,(* 365.25 24 60 60))
2996 (week . ,(* 7 24 60 60))
2997 (day . ,(* 24 60 60))
3001 "Mapping from time units to seconds.")
3003 (defun gnus-article-forward-header ()
3004 "Move point to the start of the next header.
3005 If the current header is a continuation header, this can be several
3010 (if (looking-at "[ \t]+[^ \t]")
3014 (defun article-date-ut (&optional type highlight)
3015 "Convert DATE date to universal time in the current article.
3016 If TYPE is `local', convert to local time; if it is `lapsed', output
3017 how much time has lapsed since DATE. For `lapsed', the value of
3018 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
3019 should replace the \"Date:\" one, or should be added below it."
3020 (interactive (list 'ut t))
3021 (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
3022 (date-regexp (cond ((not gnus-article-date-lapsed-new-header)
3026 (article-lapsed-timer
3030 (case-fold-search t)
3031 (inhibit-read-only t)
3032 (inhibit-point-motion-hooks t)
3033 pos date bface eface)
3037 (goto-char (point-min))
3038 (while (or (setq date (get-text-property (setq pos (point))
3040 (when (setq pos (next-single-property-change
3041 (point) 'original-date))
3042 (setq date (get-text-property pos 'original-date))
3044 (narrow-to-region pos (or (text-property-any pos (point-max)
3047 (goto-char (point-min))
3048 (when (re-search-forward tdate-regexp nil t)
3049 (setq bface (get-text-property (point-at-bol) 'face)
3050 eface (get-text-property (1- (point-at-eol)) 'face)))
3051 (goto-char (point-min))
3053 ;; Delete any old Date headers.
3054 (while (re-search-forward date-regexp nil t)
3056 (delete-region (point-at-bol) (progn
3057 (gnus-article-forward-header)
3059 (delete-region (point-at-bol) (progn
3060 (gnus-article-forward-header)
3063 (setq pos (point))))
3064 (when (and (not pos)
3065 (re-search-forward tdate-regexp nil t))
3067 (gnus-goto-char pos)
3068 (insert (article-make-date-line date (or type 'ut)))
3074 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
3075 (put-text-property (match-beginning 1) (1+ (match-end 1))
3077 (put-text-property (match-beginning 2) (match-end 2)
3079 (put-text-property (point-min) (1- (point-max)) 'original-date date)
3080 (goto-char (point-max))
3083 (defun article-make-date-line (date type)
3084 "Return a DATE line of TYPE."
3085 (unless (memq type '(local ut original user iso8601 lapsed english))
3086 (error "Unknown conversion type: %s" type))
3088 (let ((time (date-to-time date)))
3090 ;; Convert to the local timezone.
3092 (concat "Date: " (message-make-date time)))
3093 ;; Convert to Universal Time.
3098 (let* ((e (parse-time-string date))
3099 (tm (apply 'encode-time e))
3101 (ls (- (cadr tm) (car (current-time-zone time)))))
3102 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
3103 ((> ls 65535) (list (1+ ms) (- ls 65536)))
3107 ;; Get the original date from the article.
3108 ((eq type 'original)
3109 (concat "Date: " (if (string-match "\n+$" date)
3110 (substring date 0 (match-beginning 0))
3112 ;; Let the user define the format.
3114 (let ((format (or (condition-case nil
3115 (with-current-buffer gnus-summary-buffer
3116 gnus-article-time-format)
3118 gnus-article-time-format)))
3119 (if (functionp format)
3120 (funcall format time)
3121 (concat "Date: " (format-time-string format time)))))
3124 (let ((tz (car (current-time-zone time))))
3127 (format-time-string "%Y%m%dT%H%M%S" time)
3128 (format "%s%02d%02d"
3129 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3130 (/ (% (abs tz) 3600) 60)))))
3131 ;; Do an X-Sent lapsed format.
3133 ;; If the date is seriously mangled, the timezone functions are
3134 ;; liable to bug out, so we ignore all errors.
3135 (let* ((now (current-time))
3136 (real-time (subtract-time now time))
3137 (real-sec (and real-time
3138 (+ (* (float (car real-time)) 65536)
3140 (sec (and real-time (abs real-sec)))
3150 ;; This is a bit convoluted, but basically we go
3151 ;; through the time units for years, weeks, etc,
3152 ;; and divide things to see whether that results
3153 ;; in positive answers.
3156 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3157 ;; The (remaining) seconds are too few to
3158 ;; be divided into this time unit.
3160 ;; It's big enough, so we output it.
3161 (setq sec (- sec (* num (cdr unit))))
3163 (concat (if prev ", " "") (int-to-string
3165 " " (symbol-name (car unit))
3166 (if (> num 1) "s" ""))
3168 article-time-units "")
3169 ;; If dates are odd, then it might appear like the
3170 ;; article was sent in the future.
3173 " in the future"))))))
3174 ;; Display the date in proper English
3176 (let ((dtime (decode-time time)))
3179 (number-to-string (nth 3 dtime))
3180 (let ((digit (% (nth 3 dtime) 10)))
3182 ((memq (nth 3 dtime) '(11 12 13)) "th")
3188 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3190 (number-to-string (nth 5 dtime))
3192 (format "%02d" (nth 2 dtime))
3194 (format "%02d" (nth 1 dtime)))))))
3196 (format "Date: %s (from T-gnus)" date))))
3198 (defun article-date-local (&optional highlight)
3199 "Convert the current article date to the local timezone."
3200 (interactive (list t))
3201 (article-date-ut 'local highlight))
3203 (defun article-date-english (&optional highlight)
3204 "Convert the current article date to something that is proper English."
3205 (interactive (list t))
3206 (article-date-ut 'english highlight))
3208 (defun article-date-original (&optional highlight)
3209 "Convert the current article date to what it was originally.
3210 This is only useful if you have used some other date conversion
3211 function and want to see what the date was before converting."
3212 (interactive (list t))
3213 (article-date-ut 'original highlight))
3215 (defun article-date-lapsed (&optional highlight)
3216 "Convert the current article date to time lapsed since it was sent."
3217 (interactive (list t))
3218 (article-date-ut 'lapsed highlight))
3220 (defun article-update-date-lapsed ()
3221 "Function to be run from a timer to update the lapsed time line."
3223 (let (deactivate-mark)
3228 (set-buffer (window-buffer w))
3229 (when (or (and (eq major-mode 'mime-view-mode)
3230 (eq (mime-preview-original-major-mode)
3231 'gnus-original-article-mode))
3232 (eq major-mode 'gnus-article-mode))
3233 (let ((mark (point-marker)))
3234 (goto-char (point-min))
3235 (when (re-search-forward "^X-Sent:" nil t)
3236 (article-date-lapsed t))
3237 (goto-char (marker-position mark))
3238 (move-marker mark nil))))
3241 (defun gnus-start-date-timer (&optional n)
3242 "Start a timer to update the X-Sent header in the article buffers.
3243 The numerical prefix says how frequently (in seconds) the function
3248 (gnus-stop-date-timer)
3249 (setq article-lapsed-timer
3250 (run-at-time 1 n 'article-update-date-lapsed)))
3252 (defun gnus-stop-date-timer ()
3253 "Stop the X-Sent timer."
3255 (when article-lapsed-timer
3256 (nnheader-cancel-timer article-lapsed-timer)
3257 (setq article-lapsed-timer nil)))
3259 (defun article-date-user (&optional highlight)
3260 "Convert the current article date to the user-defined format.
3261 This format is defined by the `gnus-article-time-format' variable."
3262 (interactive (list t))
3263 (article-date-ut 'user highlight))
3265 (defun article-date-iso8601 (&optional highlight)
3266 "Convert the current article date to ISO8601."
3267 (interactive (list t))
3268 (article-date-ut 'iso8601 highlight))
3270 (defmacro gnus-article-save-original-date (&rest forms)
3271 "Save the original date as a text property and evaluate FORMS."
3272 `(let* ((case-fold-search t)
3274 (goto-char (point-min))
3275 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3278 (date (when (and start
3279 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3281 (buffer-substring-no-properties start
3282 (match-beginning 0)))))
3283 (goto-char (point-max))
3284 (skip-chars-backward "\n")
3285 (put-text-property (point-min) (point) 'original-date date)
3287 (goto-char (point-max))
3288 (skip-chars-backward "\n")
3289 (put-text-property (point-min) (point) 'original-date date)))
3291 ;; (defun article-show-all ()
3292 ;; "Show all hidden text in the article buffer."
3296 ;; (let ((inhibit-read-only t))
3297 ;; (gnus-article-unhide-text (point-min) (point-max))
3298 ;; (gnus-remove-text-with-property 'gnus-prev)
3299 ;; (gnus-remove-text-with-property 'gnus-next))))
3301 (defun article-show-all-headers ()
3302 "Show all hidden headers in the article buffer."
3307 (article-narrow-to-head)
3308 (let ((inhibit-read-only t))
3309 (gnus-article-unhide-text (point-min) (point-max))))))
3311 (defun article-remove-leading-whitespace ()
3312 "Remove excessive whitespace from all headers."
3316 (let ((inhibit-read-only t))
3317 (article-narrow-to-head)
3318 (goto-char (point-min))
3319 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3320 (delete-region (match-beginning 1) (match-end 1)))))))
3322 (defun article-emphasize (&optional arg)
3323 "Emphasize text according to `gnus-emphasis-alist'."
3324 (interactive (gnus-article-hidden-arg))
3325 (unless (gnus-article-check-hidden-text 'emphasis arg)
3329 (with-current-buffer gnus-summary-buffer
3330 gnus-article-emphasis-alist)
3332 gnus-emphasis-alist))
3333 (inhibit-read-only t)
3334 (props (append '(article-type emphasis)
3335 gnus-hidden-properties))
3336 regexp elem beg invisible visible face)
3339 (while (setq elem (pop alist))
3341 (setq regexp (car elem)
3342 invisible (nth 1 elem)
3343 visible (nth 2 elem)
3345 (while (re-search-forward regexp nil t)
3346 (when (and (match-beginning visible) (match-beginning invisible))
3347 (gnus-article-hide-text
3348 (match-beginning invisible) (match-end invisible) props)
3349 (gnus-article-unhide-text-type
3350 (match-beginning visible) (match-end visible) 'emphasis)
3351 (gnus-put-overlay-excluding-newlines
3352 (match-beginning visible) (match-end visible) 'face face)
3353 (gnus-add-wash-type 'emphasis)
3354 (goto-char (match-end invisible)))))))))
3356 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3357 "Setup newsgroup emphasis alist."
3358 (unless gnus-article-emphasis-alist
3359 (let ((name (and gnus-newsgroup-name
3360 (gnus-group-real-name gnus-newsgroup-name))))
3361 (make-local-variable 'gnus-article-emphasis-alist)
3362 (setq gnus-article-emphasis-alist
3364 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3365 (while (setq elem (pop alist))
3366 (when (and name (string-match (car elem) name))
3368 highlight (copy-sequence (cdr elem)))))
3370 (copy-sequence highlight-words)
3371 (if gnus-newsgroup-name
3372 (copy-sequence (gnus-group-find-parameter
3373 gnus-newsgroup-name 'highlight-words t)))
3374 gnus-emphasis-alist)))))
3377 (defvar gnus-summary-article-menu)
3378 (defvar gnus-summary-post-menu))
3380 ;;; Saving functions.
3382 (defun gnus-article-save (save-buffer file &optional num)
3383 "Save the currently selected article."
3384 (unless gnus-save-all-headers
3385 ;; Remove headers according to `gnus-saved-headers'.
3386 (let ((gnus-visible-headers
3387 (or gnus-saved-headers gnus-visible-headers))
3388 (gnus-article-buffer save-buffer))
3390 (set-buffer save-buffer)
3391 (article-hide-headers 1 t))))
3392 (save-window-excursion
3393 (if (not gnus-default-article-saver)
3394 (error "No default saver is defined")
3395 ;; !!! Magic! The saving functions all save
3396 ;; `gnus-save-article-buffer' (or so they think), but we
3397 ;; bind that variable to our save-buffer.
3398 (set-buffer gnus-article-buffer)
3399 (let* ((gnus-save-article-buffer save-buffer)
3402 ((not gnus-prompt-before-saving) 'default)
3403 ((eq gnus-prompt-before-saving 'always) nil)
3405 (gnus-number-of-articles-to-be-saved
3406 (when (eq gnus-prompt-before-saving t)
3408 (set-buffer gnus-article-current-summary)
3409 (funcall gnus-default-article-saver filename)))))
3411 (defun gnus-read-save-file-name (prompt &optional filename
3412 function group headers variable)
3414 (funcall function group headers (symbol-value variable)))
3419 ((eq filename 'default)
3425 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3428 (if (and gnus-number-of-articles-to-be-saved
3429 (> gnus-number-of-articles-to-be-saved 1))
3430 (format "these %d articles"
3431 gnus-number-of-articles-to-be-saved)
3434 ;; Let the split methods have their say.
3436 ;; No split name was found.
3439 (concat prompt " (default "
3440 (file-name-nondirectory default-name) ") ")
3441 (file-name-directory default-name)
3443 ;; A single group name is returned.
3444 ((stringp split-name)
3446 (funcall function split-name headers
3447 (symbol-value variable)))
3449 (concat prompt " (default "
3450 (file-name-nondirectory default-name) ") ")
3451 (file-name-directory default-name)
3453 ;; A single split name was found
3454 ((= 1 (length split-name))
3455 (let* ((name (expand-file-name
3457 gnus-article-save-directory))
3458 (dir (cond ((file-directory-p name)
3459 (file-name-as-directory name))
3460 ((file-exists-p name) name)
3461 (t gnus-article-save-directory))))
3463 (concat prompt " (default " name ") ")
3465 ;; A list of splits was found.
3467 (setq split-name (nreverse split-name))
3469 (let ((file-name-history
3470 (nconc split-name file-name-history)))
3474 (concat prompt " (`M-p' for defaults) ")
3475 gnus-article-save-directory
3477 gnus-article-save-directory)))
3478 (car (push result file-name-history)))))))
3479 ;; Create the directory.
3480 (gnus-make-directory (file-name-directory file))
3481 ;; If we have read a directory, we append the default file name.
3482 (when (file-directory-p file)
3483 (setq file (expand-file-name (file-name-nondirectory
3485 (file-name-as-directory file))))
3486 ;; Possibly translate some characters.
3487 (nnheader-translate-file-chars file))))))
3488 (gnus-make-directory (file-name-directory result))
3489 (set variable result)))
3491 (defun gnus-article-archive-name (group)
3492 "Return the first instance of an \"Archive-name\" in the current buffer."
3493 (let ((case-fold-search t))
3494 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3495 (nnheader-concat gnus-article-save-directory
3496 (match-string 1)))))
3498 (defun gnus-article-nndoc-name (group)
3499 "If GROUP is an nndoc group, return the name of the parent group."
3500 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3501 (gnus-group-get-parameter group 'save-article-group)))
3503 (defun gnus-summary-save-in-rmail (&optional filename)
3504 "Append this article to Rmail file.
3505 Optional argument FILENAME specifies file name.
3506 Directory to save to is default to `gnus-article-save-directory'."
3507 (setq filename (gnus-read-save-file-name
3508 "Save %s in rmail file:" filename
3509 gnus-rmail-save-name gnus-newsgroup-name
3510 gnus-current-headers 'gnus-newsgroup-last-rmail))
3511 (gnus-eval-in-buffer-window gnus-save-article-buffer
3515 (gnus-output-to-rmail filename))))
3518 (defun gnus-summary-save-in-mail (&optional filename)
3519 "Append this article to Unix mail file.
3520 Optional argument FILENAME specifies file name.
3521 Directory to save to is default to `gnus-article-save-directory'."
3522 (setq filename (gnus-read-save-file-name
3523 "Save %s in Unix mail file:" filename
3524 gnus-mail-save-name gnus-newsgroup-name
3525 gnus-current-headers 'gnus-newsgroup-last-mail))
3526 (gnus-eval-in-buffer-window gnus-save-article-buffer
3530 (if (and (file-readable-p filename)
3531 (file-regular-p filename)
3532 (mail-file-babyl-p filename))
3533 (rmail-output-to-rmail-file filename t)
3534 (gnus-output-to-mail filename)))))
3537 (defun gnus-summary-save-in-file (&optional filename overwrite)
3538 "Append this article to file.
3539 Optional argument FILENAME specifies file name.
3540 Directory to save to is default to `gnus-article-save-directory'."
3541 (setq filename (gnus-read-save-file-name
3542 "Save %s in file:" filename
3543 gnus-file-save-name gnus-newsgroup-name
3544 gnus-current-headers 'gnus-newsgroup-last-file))
3545 (gnus-eval-in-buffer-window gnus-save-article-buffer
3549 (when (and overwrite
3550 (file-exists-p filename))
3551 (delete-file filename))
3552 (gnus-output-to-file filename))))
3555 (defun gnus-summary-write-to-file (&optional filename)
3556 "Write this article to a file, overwriting it if the file exists.
3557 Optional argument FILENAME specifies file name.
3558 The directory to save in defaults to `gnus-article-save-directory'."
3559 (gnus-summary-save-in-file nil t))
3561 (defun gnus-summary-save-body-in-file (&optional filename)
3562 "Append this article body to a file.
3563 Optional argument FILENAME specifies file name.
3564 The directory to save in defaults to `gnus-article-save-directory'."
3565 (setq filename (gnus-read-save-file-name
3566 "Save %s body in file:" filename
3567 gnus-file-save-name gnus-newsgroup-name
3568 gnus-current-headers 'gnus-newsgroup-last-file))
3569 (gnus-eval-in-buffer-window gnus-save-article-buffer
3573 (when (article-goto-body)
3574 (narrow-to-region (point) (point-max)))
3575 (gnus-output-to-file filename))))
3578 (defun gnus-summary-save-in-pipe (&optional command)
3579 "Pipe this article to subprocess."
3581 (cond ((and (eq command 'default)
3582 gnus-last-shell-command)
3583 gnus-last-shell-command)
3588 "Shell command on %s: "
3589 (if (and gnus-number-of-articles-to-be-saved
3590 (> gnus-number-of-articles-to-be-saved 1))
3591 (format "these %d articles"
3592 gnus-number-of-articles-to-be-saved)
3594 gnus-last-shell-command))))
3595 (when (string-equal command "")
3596 (if gnus-last-shell-command
3597 (setq command gnus-last-shell-command)
3598 (error "A command is required")))
3599 (gnus-eval-in-buffer-window gnus-article-buffer
3602 (shell-command-on-region (point-min) (point-max) command nil)))
3603 (setq gnus-last-shell-command command))
3605 (defun gnus-summary-pipe-to-muttprint (&optional command)
3606 "Pipe this article to muttprint."
3607 (setq command (read-string
3608 "Print using command: " gnus-summary-muttprint-program
3609 nil gnus-summary-muttprint-program))
3610 (gnus-summary-save-in-pipe command))
3612 ;;; Article file names when saving.
3614 (defun gnus-capitalize-newsgroup (newsgroup)
3615 "Capitalize NEWSGROUP name."
3616 (when (not (zerop (length newsgroup)))
3617 (concat (char-to-string (upcase (aref newsgroup 0)))
3618 (substring newsgroup 1))))
3620 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3621 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3622 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3623 Otherwise, it is like ~/News/news/group/num."
3626 (concat (if (gnus-use-long-file-name 'not-save)
3627 (gnus-capitalize-newsgroup newsgroup)
3628 (gnus-newsgroup-directory-form newsgroup))
3629 "/" (int-to-string (mail-header-number headers)))
3630 gnus-article-save-directory)))
3632 (string-equal (file-name-directory default)
3633 (file-name-directory last-file))
3634 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3636 (or last-file default))))
3638 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3639 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3640 If variable `gnus-use-long-file-name' is non-nil, it is
3641 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3644 (concat (if (gnus-use-long-file-name 'not-save)
3646 (gnus-newsgroup-directory-form newsgroup))
3647 "/" (int-to-string (mail-header-number headers)))
3648 gnus-article-save-directory)))
3650 (string-equal (file-name-directory default)
3651 (file-name-directory last-file))
3652 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3654 (or last-file default))))
3656 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3657 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3658 If variable `gnus-use-long-file-name' is non-nil, it is
3659 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3662 (if (gnus-use-long-file-name 'not-save)
3665 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3667 gnus-article-save-directory)))
3669 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3670 "Generate file name from sender."
3671 (let ((from (mail-header-from headers)))
3673 (if (and from (string-match "\\([^ <]+\\)@" from))
3674 (match-string 1 from)
3676 gnus-article-save-directory)))
3678 (defun article-verify-x-pgp-sig ()
3681 (if (gnus-buffer-live-p gnus-original-article-buffer)
3682 (let ((sig (with-current-buffer gnus-original-article-buffer
3683 (gnus-fetch-field "X-PGP-Sig")))
3687 (mml2015-clear-verify-function))
3689 (insert-buffer-substring gnus-original-article-buffer)
3690 (setq items (split-string sig))
3691 (message-narrow-to-head)
3692 (let ((inhibit-point-motion-hooks t)
3693 (case-fold-search t))
3694 ;; Don't verify multiple headers.
3695 (setq headers (mapconcat (lambda (header)
3697 (mail-fetch-field header)
3699 (split-string (nth 1 items) ",") "")))
3700 (delete-region (point-min) (point-max))
3701 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3702 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3707 (if (looking-at "^-")
3710 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3711 (insert "Version: " (car items) "\n\n")
3712 (insert (mapconcat 'identity (cddr items) "\n"))
3713 (insert "\n-----END PGP SIGNATURE-----\n")
3714 (let ((mm-security-handle (list (format "multipart/signed"))))
3715 (mml2015-clean-buffer)
3716 (let ((coding-system-for-write (or gnus-newsgroup-charset
3718 (funcall (mml2015-clear-verify-function)))
3720 (or (mm-handle-multipart-ctl-parameter
3721 mm-security-handle 'gnus-details)
3722 (mm-handle-multipart-ctl-parameter
3723 mm-security-handle 'gnus-info)))))
3725 (let ((inhibit-read-only t) bface eface)
3727 (message-narrow-to-head)
3728 (goto-char (point-max))
3730 (setq bface (get-text-property (point-at-bol) 'face)
3731 eface (get-text-property (1- (point-at-eol)) 'face))
3732 (message-remove-header "X-Gnus-PGP-Verify")
3733 (if (re-search-forward "^X-PGP-Sig:" nil t)
3735 (goto-char (point-max)))
3736 (narrow-to-region (point) (point))
3737 (insert "X-Gnus-PGP-Verify: " info "\n")
3738 (goto-char (point-min))
3741 (if (not (looking-at "^[ \t]"))
3745 (goto-char (point-min))
3746 (when (looking-at "\\([^:]+\\): *")
3747 (put-text-property (match-beginning 1) (1+ (match-end 1))
3749 (put-text-property (match-end 0) (point-max)
3750 'face eface)))))))))
3752 (defun article-verify-cancel-lock ()
3753 "Verify Cancel-Lock header."
3755 (if (gnus-buffer-live-p gnus-original-article-buffer)
3756 (canlock-verify gnus-original-article-buffer)))
3758 (defun article-monafy ()
3759 "Display body part with mona font."
3761 (unless (if (featurep 'xemacs)
3762 (find-face 'gnus-mona-face)
3763 (facep 'gnus-mona-face))
3764 (require 'navi2ch-mona)
3765 (set-face-font (make-face 'gnus-mona-face) navi2ch-mona-font))
3767 (let ((inhibit-read-only t))
3770 (gnus-make-overlay (point) (point-max))
3771 'face 'gnus-mona-face))))
3778 (setq afunc (car func)
3781 gfunc (intern (format "gnus-%s" func))))
3783 (when (fboundp afunc)
3784 `(lambda (&optional interactive &rest args)
3785 ,(documentation afunc t)
3786 (interactive (list t))
3788 (set-buffer gnus-article-buffer)
3790 (call-interactively ',afunc)
3791 (apply ',afunc args))))))))
3792 '(article-hide-headers
3793 article-verify-x-pgp-sig
3794 article-verify-cancel-lock
3796 article-hide-boring-headers
3797 article-treat-overstrike
3798 article-treat-ansi-sequences
3799 article-fill-long-lines
3800 article-capitalize-sentences
3802 article-remove-leading-whitespace
3803 article-display-x-face
3804 article-display-face
3805 article-de-quoted-unreadable
3806 article-de-base64-unreadable
3809 article-unsplit-urls
3810 article-hide-list-identifiers
3811 article-strip-banner
3814 article-hide-signature
3815 article-strip-headers-in-body
3816 article-remove-trailing-blank-lines
3817 article-strip-leading-blank-lines
3818 article-strip-multiple-blank-lines
3819 article-strip-leading-space
3820 article-strip-trailing-space
3821 article-strip-blank-lines
3822 article-strip-all-blank-lines
3824 article-date-english
3825 article-date-iso8601
3826 article-date-original
3828 article-decode-mime-words
3829 article-decode-charset
3830 article-decode-encoded-words
3834 article-treat-dumbquotes
3835 article-normalize-headers
3836 (article-show-all-headers . gnus-article-show-all-headers)
3837 ;; (article-show-all . gnus-article-show-all)
3841 ;;; Gnus article mode
3844 (put 'gnus-article-mode 'mode-class 'special)
3846 (gnus-define-keys gnus-article-mode-map
3847 " " gnus-article-goto-next-page
3848 "\177" gnus-article-goto-prev-page
3849 [delete] gnus-article-goto-prev-page
3850 [backspace] gnus-article-goto-prev-page
3851 "\C-c^" gnus-article-refer-article
3852 "h" gnus-article-show-summary
3853 "s" gnus-article-show-summary
3854 "\C-c\C-m" gnus-article-mail
3855 "?" gnus-article-describe-briefly
3856 "e" gnus-summary-edit-article
3857 "<" beginning-of-buffer
3859 "\C-c\C-i" gnus-info-find-node
3861 "R" gnus-article-reply-with-original
3862 "F" gnus-article-followup-with-original
3863 "\C-hk" gnus-article-describe-key
3864 "\C-hc" gnus-article-describe-key-briefly
3866 "\C-d" gnus-article-read-summary-keys
3867 "\M-*" gnus-article-read-summary-keys
3868 "\M-#" gnus-article-read-summary-keys
3869 "\M-^" gnus-article-read-summary-keys
3870 "\M-g" gnus-article-read-summary-keys)
3872 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3876 (push (char-to-string key) keys)
3878 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3879 (setq key (car elem))
3880 (when (and (> (length key) 0)
3881 (not (eq 'menu-bar (aref key 0)))
3882 (symbolp (lookup-key gnus-summary-mode-map key)))
3885 (unless (lookup-key gnus-article-mode-map key)
3886 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3888 (defun gnus-article-make-menu-bar ()
3889 (unless (boundp 'gnus-article-commands-menu)
3890 (gnus-summary-make-menu-bar))
3891 (gnus-turn-off-edit-menu 'article)
3892 (unless (boundp 'gnus-article-article-menu)
3894 gnus-article-article-menu gnus-article-mode-map ""
3896 ["Scroll forwards" gnus-article-goto-next-page t]
3897 ["Scroll backwards" gnus-article-goto-prev-page t]
3898 ["Show summary" gnus-article-show-summary t]
3899 ["Fetch Message-ID at point" gnus-article-refer-article t]
3900 ["Mail to address at point" gnus-article-mail t]
3901 ["Send a bug report" gnus-bug t]))
3904 gnus-article-treatment-menu gnus-article-mode-map ""
3905 ;; Fixme: this should use :active (and maybe :visible).
3907 ["Hide headers" gnus-article-hide-headers t]
3908 ["Hide signature" gnus-article-hide-signature t]
3909 ["Hide citation" gnus-article-hide-citation t]
3910 ["Treat overstrike" gnus-article-treat-overstrike t]
3911 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
3912 ["Remove carriage return" gnus-article-remove-cr t]
3913 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3914 ["Treat html" gnus-article-wash-html t]
3915 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3916 ["Decode HZ" gnus-article-decode-HZ t]))
3918 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3920 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3922 (gnus-run-hooks 'gnus-article-menu-hook)))
3924 (defun gnus-article-mode ()
3925 "Major mode for displaying an article.
3927 All normal editing commands are switched off.
3929 The following commands are available in addition to all summary mode
3931 \\<gnus-article-mode-map>
3932 \\[gnus-article-next-page]\t Scroll the article one page forwards
3933 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3934 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3935 \\[gnus-article-show-summary]\t Display the summary buffer
3936 \\[gnus-article-mail]\t Send a reply to the address near point
3937 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3938 \\[gnus-info-find-node]\t Go to the Gnus info node"
3940 (gnus-simplify-mode-line)
3941 (setq mode-name "Article")
3942 (setq major-mode 'gnus-article-mode)
3943 (make-local-variable 'minor-mode-alist)
3944 (unless (assq 'gnus-show-mime minor-mode-alist)
3945 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3946 (use-local-map gnus-article-mode-map)
3947 (when (gnus-visual-p 'article-menu 'menu)
3948 (gnus-article-make-menu-bar)
3949 (when gnus-summary-tool-bar-map
3950 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3951 (gnus-update-format-specifications nil 'article-mode)
3952 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3953 (set (make-local-variable 'gnus-page-broken) nil)
3954 (make-local-variable 'gnus-button-marker-list)
3955 (make-local-variable 'gnus-article-current-summary)
3956 (make-local-variable 'gnus-article-mime-handles)
3957 (make-local-variable 'gnus-article-decoded-p)
3958 (make-local-variable 'gnus-article-mime-handle-alist)
3959 (make-local-variable 'gnus-article-wash-types)
3960 (make-local-variable 'gnus-article-image-alist)
3961 (make-local-variable 'gnus-article-charset)
3962 (make-local-variable 'gnus-article-ignored-charsets)
3963 ;; Prevent recent Emacsen from displaying non-break space as "\ ".
3964 (set (make-local-variable 'show-nonbreak-escape) nil)
3965 (gnus-set-default-directory)
3966 (buffer-disable-undo)
3967 (setq buffer-read-only t
3968 show-trailing-whitespace nil)
3969 (set-syntax-table gnus-article-mode-syntax-table)
3970 (gnus-run-mode-hooks 'gnus-article-mode-hook))
3972 (defun gnus-article-setup-buffer ()
3973 "Initialize the article buffer."
3974 (let* ((name (if gnus-single-article-buffer "*Article*"
3975 (concat "*Article " gnus-newsgroup-name "*")))
3977 (progn (string-match "\\*Article" name)
3978 (concat " *Original Article"
3979 (substring name (match-end 0))))))
3980 (setq gnus-article-buffer name)
3981 (setq gnus-original-article-buffer original)
3982 (setq gnus-article-mime-handle-alist nil)
3983 ;; This might be a variable local to the summary buffer.
3984 (unless gnus-single-article-buffer
3986 (set-buffer gnus-summary-buffer)
3987 (setq gnus-article-buffer name)
3988 (setq gnus-original-article-buffer original)
3989 (gnus-set-global-variables)))
3990 (gnus-article-setup-highlight-words)
3991 ;; Init original article buffer.
3993 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3994 (set-buffer-multibyte t)
3995 (setq major-mode 'gnus-original-article-mode)
3996 (make-local-variable 'gnus-original-article))
3997 (if (and (get-buffer name)
3998 (with-current-buffer name
3999 (if gnus-article-edit-mode
4000 (if (y-or-n-p "Article mode edit in progress; discard? ")
4002 (set-buffer-modified-p nil)
4003 (gnus-kill-buffer name)
4006 (error "Action aborted"))
4010 (set (make-local-variable 'gnus-article-edit-mode) nil)
4011 (buffer-disable-undo)
4012 (setq buffer-read-only t)
4013 ;; This list just keeps growing if we don't reset it.
4014 (setq gnus-button-marker-list nil)
4015 (unless (eq major-mode 'gnus-article-mode)
4016 (gnus-article-mode))
4019 (set-buffer (gnus-get-buffer-create name))
4021 (make-local-variable 'gnus-summary-buffer)
4022 (gnus-summary-set-local-parameters gnus-newsgroup-name)
4023 (current-buffer)))))
4025 ;; Set article window start at LINE, where LINE is the number of lines
4026 ;; from the head of the article.
4027 (defun gnus-article-set-window-start (&optional line)
4029 (gnus-get-buffer-window gnus-article-buffer t)
4031 (set-buffer gnus-article-buffer)
4032 (goto-char (point-min))
4035 (gnus-message 6 "Moved to bookmark")
4036 (search-forward "\n\n" nil t)
4040 ;;; @@ article filters
4043 (defun gnus-article-display-mime-message ()
4044 "Article display method for MIME message."
4045 ;; called from `gnus-original-article-buffer'.
4046 (let (charset all-headers)
4047 (with-current-buffer gnus-summary-buffer
4048 (setq charset default-mime-charset
4049 all-headers gnus-have-all-headers))
4050 (make-local-variable 'default-mime-charset)
4051 (setq default-mime-charset charset)
4052 (with-current-buffer (get-buffer-create gnus-article-buffer)
4053 (make-local-variable 'default-mime-charset)
4054 (setq default-mime-charset charset))
4055 (mime-display-message mime-message-structure
4056 gnus-article-buffer nil gnus-article-mode-map)
4058 (gnus-article-hide-headers nil -1)))
4059 (run-hooks 'gnus-mime-article-prepare-hook))
4061 (defun gnus-article-display-traditional-message ()
4062 "Article display method for traditional message."
4063 (set-buffer gnus-article-buffer)
4064 (let ((inhibit-read-only t))
4066 (insert-buffer-substring gnus-original-article-buffer)))
4068 (defun gnus-article-make-full-mail-header (&optional number charset)
4069 "Create a new mail header structure in a raw article buffer."
4070 (unless (and number charset)
4071 (save-current-buffer
4072 (set-buffer gnus-summary-buffer)
4074 (setq number (or (cdr gnus-article-current) 0)))
4076 (setq charset (or default-mime-charset 'x-ctext)))))
4077 (goto-char (point-min))
4078 (let ((header-end (if (search-forward "\n\n" nil t)
4080 (goto-char (point-max))))
4081 (chars (- (point-max) (point)))
4082 (lines (count-lines (point) (point-max)))
4083 (default-mime-charset charset)
4085 (narrow-to-region (point-min) header-end)
4086 (setq xref (std11-fetch-field "xref"))
4088 (make-full-mail-header
4090 (std11-fetch-field "subject")
4091 (std11-fetch-field "from")
4092 (std11-fetch-field "date")
4093 (std11-fetch-field "message-id")
4094 (std11-fetch-field "references")
4097 (when xref (concat "Xref: " xref)))
4100 (defun gnus-article-prepare (article &optional all-headers header)
4101 "Prepare ARTICLE in article mode buffer.
4102 ARTICLE should either be an article number or a Message-ID.
4103 If ARTICLE is an id, HEADER should be the article headers.
4104 If ALL-HEADERS is non-nil, no headers are hidden."
4106 ;; Make sure we start in a summary buffer.
4107 (unless (eq major-mode 'gnus-summary-mode)
4108 (set-buffer gnus-summary-buffer))
4109 (setq gnus-summary-buffer (current-buffer))
4110 (let* ((gnus-article (if header (mail-header-number header) article))
4111 (summary-buffer (current-buffer))
4112 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4113 (group gnus-newsgroup-name)
4116 (gnus-article-setup-buffer)
4117 (set-buffer gnus-article-buffer)
4118 ;; Deactivate active regions.
4119 (when (and (boundp 'transient-mark-mode)
4120 transient-mark-mode)
4121 (setq mark-active nil))
4122 (if (not (setq result (let ((inhibit-read-only t))
4123 (gnus-request-article-this-buffer
4125 ;; There is no such article.
4127 (when (and (numberp article)
4128 (not (memq article gnus-newsgroup-sparse)))
4129 (setq gnus-article-current
4130 (cons gnus-newsgroup-name article))
4131 (set-buffer gnus-summary-buffer)
4132 (setq gnus-current-article article)
4133 (if (and (memq article gnus-newsgroup-undownloaded)
4134 (not (gnus-online (gnus-find-method-for-group
4135 gnus-newsgroup-name))))
4137 (gnus-summary-set-agent-mark article)
4138 (message "Message marked for downloading"))
4139 (gnus-summary-mark-article article gnus-canceled-mark)
4140 (unless (memq article gnus-newsgroup-sparse)
4141 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4142 (if (or (eq result 'pseudo)
4143 (eq result 'nneething))
4146 (set-buffer summary-buffer)
4147 (push article gnus-newsgroup-history)
4148 (setq gnus-last-article gnus-current-article
4149 gnus-current-article 0
4150 gnus-current-headers nil
4151 gnus-article-current nil)
4152 (if (eq result 'nneething)
4153 (gnus-configure-windows 'summary)
4154 (gnus-configure-windows 'article))
4155 (gnus-set-global-variables))
4156 (let ((gnus-article-mime-handle-alist-1
4157 gnus-article-mime-handle-alist))
4158 (gnus-set-mode-line 'article)))
4159 ;; The result from the `request' was an actual article -
4160 ;; or at least some text that is now displayed in the
4162 (when (and (numberp article)
4163 (not (eq article gnus-current-article)))
4164 ;; Seems like a new article has been selected.
4165 ;; `gnus-current-article' must be an article number.
4167 (set-buffer summary-buffer)
4168 (push article gnus-newsgroup-history)
4169 (setq gnus-last-article gnus-current-article
4170 gnus-current-article article
4171 gnus-current-headers
4172 (gnus-summary-article-header gnus-current-article)
4173 gnus-article-current
4174 (cons gnus-newsgroup-name gnus-current-article))
4175 (unless (vectorp gnus-current-headers)
4176 (setq gnus-current-headers nil))
4177 (gnus-summary-goto-subject gnus-current-article)
4178 (when (gnus-summary-show-thread)
4179 ;; If the summary buffer really was folded, the
4180 ;; previous goto may not actually have gone to
4181 ;; the right article, but the thread root instead.
4183 (gnus-summary-goto-subject gnus-current-article))
4184 (gnus-run-hooks 'gnus-mark-article-hook)
4185 (gnus-set-mode-line 'summary)
4186 (when (gnus-visual-p 'article-highlight 'highlight)
4187 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4188 ;; Set the global newsgroup variables here.
4189 (gnus-set-global-variables)
4190 (setq gnus-have-all-headers
4191 (or all-headers gnus-show-all-headers))))
4193 (gnus-configure-windows 'article))
4194 (when (or (numberp article)
4196 (gnus-article-prepare-display)
4198 (goto-char (point-min))
4199 (when gnus-break-pages
4200 (gnus-narrow-to-page)))
4201 (let ((gnus-article-mime-handle-alist-1
4202 gnus-article-mime-handle-alist))
4203 (gnus-set-mode-line 'article))
4207 (set-window-point (get-buffer-window (current-buffer)) (point))
4208 (gnus-configure-windows 'article)
4211 (defun gnus-article-prepare-mime-display (&optional number)
4212 (goto-char (point-min))
4213 (when (re-search-forward "^[^\t ]+:" nil t)
4214 (goto-char (match-beginning 0)))
4215 (let ((entity (if (eq 1 (point-min))
4216 (get-text-property 1 'mime-view-entity)
4217 (get-text-property (point) 'mime-view-entity)))
4218 last-entity child-entity next type)
4219 (setq child-entity (mime-entity-children entity))
4221 (setq last-entity (nth (1- (length child-entity))
4223 (setq last-entity entity))
4225 (narrow-to-region (point)
4226 (if (search-forward "\n\n" nil t)
4229 (gnus-article-save-original-date (gnus-treat-article 'head))
4230 (put-text-property (point-min) (point-max) 'article-treated-header t)
4231 (goto-char (point-max)))
4232 (while (and (not (eobp)) entity)
4233 (setq next (set-marker
4235 (next-single-property-change (point) 'mime-view-entity
4237 (let ((types (mime-entity-content-type entity)))
4238 (while (eq 'multipart (mime-content-type-primary-type types))
4239 (setq entity (car (mime-entity-children entity))
4240 types (mime-entity-content-type entity)))
4242 (setq type (format "%s/%s"
4243 (mime-content-type-primary-type types)
4244 (mime-content-type-subtype types)))))
4245 (if (string-equal type "message/rfc822")
4248 (let ((children (mime-entity-children entity))
4251 (setq last-children (nth (1- (length children)) children))
4254 (not (eq last-children
4255 (get-text-property next 'mime-view-entity)))
4257 (next-single-property-change next
4259 nil (point-max)))))))
4260 (setq next (next-single-property-change next 'mime-view-entity
4263 (narrow-to-region (point) next)
4264 (gnus-article-prepare-mime-display)
4265 (goto-char (point-max)))
4266 (setq entity (get-text-property (point) 'mime-view-entity)))
4268 (narrow-to-region (point) next)
4269 ;; Kludge. We have to count true number, but for now,
4270 ;; part number is here only to achieve `last'.
4271 (gnus-treat-article nil 1
4272 (if (eq entity last-entity)
4275 (goto-char (point-max)))
4276 (setq entity (get-text-property next 'mime-view-entity))))))
4279 (defun gnus-article-prepare-display ()
4280 "Make the current buffer look like a nice article."
4281 (let ((gnus-article-buffer (current-buffer))
4283 (inhibit-read-only t))
4284 (unless (eq major-mode 'gnus-article-mode)
4285 (gnus-article-mode))
4286 (setq buffer-read-only nil
4287 gnus-button-marker-list nil
4288 gnus-article-wash-types nil
4289 gnus-article-image-alist nil)
4292 (static-if (featurep 'xemacs)
4293 (map-extents (lambda (extent maparg) (delete-extent extent)))
4294 (let ((lists (overlay-lists)))
4295 (dolist (overlay (nconc (car lists) (cdr lists)))
4296 (delete-overlay overlay)))))
4297 (gnus-run-hooks 'gnus-tmp-internal-hook))
4298 (let ((show-mime (unless (member gnus-newsgroup-name '("nndraft:delayed"
4301 (inhibit-read-only t))
4302 (set-buffer gnus-original-article-buffer)
4304 (setq mime-message-structure gnus-current-headers)
4305 (mime-buffer-entity-set-buffer-internal mime-message-structure
4306 gnus-original-article-buffer)
4307 (mime-entity-set-representation-type-internal mime-message-structure
4308 'mime-buffer-entity)
4309 (luna-send mime-message-structure 'initialize-instance
4310 mime-message-structure)
4312 (let (mime-display-header-hook mime-display-text/plain-hook)
4313 (funcall gnus-article-display-method-for-mime))
4314 (funcall gnus-article-display-method-for-traditional))
4315 ;; Call the treatment functions.
4319 (gnus-article-prepare-mime-display)
4320 (narrow-to-region (goto-char (point-min))
4321 (if (search-forward "\n\n" nil t)
4324 (gnus-article-save-original-date (gnus-treat-article 'head))
4325 (put-text-property (point-min) (point-max) 'article-treated-header t)
4326 (goto-char (point-max))
4328 (narrow-to-region (point) (point-max))
4329 (gnus-treat-article nil))
4330 (put-text-property (point-min) (point-max) 'read-only nil)))
4331 (gnus-run-hooks 'gnus-article-prepare-hook))
4333 (defun gnus-article-decode-article-as-default-mime-charset ()
4334 "Decode an article as `default-mime-charset'. It won't work if the
4335 value of the variable `gnus-show-mime' is non-nil."
4336 (unless (or gnus-show-mime
4337 (member gnus-newsgroup-name '("nndraft:delayed"
4339 (set (make-local-variable 'default-mime-charset)
4340 (with-current-buffer gnus-summary-buffer
4341 default-mime-charset))
4342 (decode-mime-charset-region (point-min) (point-max)
4343 default-mime-charset)))
4346 ;;; Gnus MIME viewing functions
4349 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4350 "Format of the MIME buttons.
4352 Valid specifiers include:
4354 %T MIME type, along with additional info
4355 %n The `name' parameter
4356 %d The description, if any
4357 %l The length of the encoded part
4358 %p The part identifier number
4359 %e Dots if the part isn't displayed
4361 General format specifiers can also be used. See Info node
4362 `(gnus)Formatting Variables'.")
4364 (defvar gnus-mime-button-line-format-alist
4365 '((?t gnus-tmp-type ?s)
4366 (?T gnus-tmp-type-long ?s)
4367 (?n gnus-tmp-name ?s)
4368 (?d gnus-tmp-description ?s)
4370 (?l gnus-tmp-length ?d)
4371 (?e gnus-tmp-dots ?s)))
4373 (defvar gnus-mime-button-commands
4374 '((gnus-article-press-button "\r" "Toggle Display")
4375 (gnus-mime-view-part "v" "View Interactively...")
4376 (gnus-mime-view-part-as-type "t" "View As Type...")
4377 (gnus-mime-view-part-as-charset "C" "View As charset...")
4378 (gnus-mime-save-part "o" "Save...")
4379 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4380 (gnus-mime-delete-part "d" "Delete part")
4381 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4382 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4383 (gnus-mime-view-part-internally "E" "View Internally")
4384 (gnus-mime-view-part-externally "e" "View Externally")
4385 (gnus-mime-print-part "p" "Print")
4386 (gnus-mime-pipe-part "|" "Pipe To Command...")
4387 (gnus-mime-action-on-part "." "Take action on the part...")))
4389 (defun gnus-article-mime-part-status ()
4390 (with-current-buffer gnus-article-buffer
4391 (let ((entity (get-text-property (point-min) 'mime-view-entity))
4394 (setq children (mime-entity-children entity))
4395 (setq children (length children)))
4398 (format " (%d parts)" children))
4401 (defvar gnus-mime-button-map
4402 (let ((map (make-sparse-keymap)))
4403 (define-key map gnus-mouse-2 'gnus-article-push-button)
4404 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4405 (dolist (c gnus-mime-button-commands)
4406 (define-key map (cadr c) (car c)))
4410 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4412 ,@(mapcar (lambda (c)
4413 (vector (caddr c) (car c) :enable t))
4414 gnus-mime-button-commands)))
4416 (defun gnus-mime-button-menu (event prefix)
4417 "Construct a context-sensitive menu of MIME commands."
4418 (interactive "e\nP")
4419 (save-window-excursion
4420 (let ((pos (event-start event)))
4421 (select-window (posn-window pos))
4422 (goto-char (posn-point pos))
4423 (gnus-article-check-buffer)
4424 (popup-menu gnus-mime-button-menu nil prefix))))
4426 (defun gnus-mime-view-all-parts (&optional handles)
4427 "View all the MIME parts."
4429 (with-current-buffer gnus-article-buffer
4430 (let ((handles (or handles gnus-article-mime-handles))
4431 (mail-parse-charset gnus-newsgroup-charset)
4432 (mail-parse-ignored-charsets
4433 (with-current-buffer gnus-summary-buffer
4434 gnus-newsgroup-ignored-charsets)))
4436 (mm-remove-parts handles)
4437 (goto-char (point-min))
4438 (or (search-forward "\n\n") (goto-char (point-max)))
4439 (let ((inhibit-read-only t))
4440 (delete-region (point) (point-max))
4441 (mm-display-parts handles))))))
4444 (defsubst gnus-article-edit-part (handles)
4445 "Edit an article in order to delete a mime part.
4446 This function is exclusively used by `gnus-mime-save-part-and-strip'
4447 and `gnus-mime-delete-part', and not provided at run-time normally."
4448 (gnus-article-edit-article
4450 (buffer-disable-undo)
4452 (let ((mail-parse-charset (or gnus-article-charset
4453 ',gnus-newsgroup-charset))
4454 (mail-parse-ignored-charsets
4455 (or gnus-article-ignored-charsets
4456 ',gnus-newsgroup-ignored-charsets))
4457 (mbl mml-buffer-list))
4458 (setq mml-buffer-list nil)
4459 (insert-buffer gnus-original-article-buffer)
4460 (mime-to-mml ',handles)
4461 (setq gnus-article-mime-handles nil)
4462 (let ((mbl1 mml-buffer-list))
4463 (setq mml-buffer-list mbl)
4464 (set (make-local-variable 'mml-buffer-list) mbl1))
4465 (gnus-make-local-hook 'kill-buffer-hook)
4466 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4467 `(lambda (no-highlight)
4468 (let ((mail-parse-charset (or gnus-article-charset
4469 ',gnus-newsgroup-charset))
4470 (message-options message-options)
4471 (message-options-set-recipient)
4472 (mail-parse-ignored-charsets
4473 (or gnus-article-ignored-charsets
4474 ',gnus-newsgroup-ignored-charsets)))
4476 (mml-destroy-buffers)
4477 (remove-hook 'kill-buffer-hook
4478 'mml-destroy-buffers t)
4479 (kill-local-variable 'mml-buffer-list))
4480 (gnus-summary-edit-article-done
4481 ,(or (mail-header-references gnus-current-headers) "")
4482 ,(gnus-group-read-only-p)
4483 ,gnus-summary-buffer no-highlight)))
4484 (gnus-article-edit-done)
4485 (gnus-summary-expand-window)
4486 (gnus-summary-show-article)))
4488 (defun gnus-mime-save-part-and-strip ()
4489 "Save the MIME part under point then replace it with an external body."
4491 (gnus-article-check-buffer)
4492 (when (gnus-group-read-only-p)
4493 (error "The current group does not support deleting of parts"))
4494 (when (mm-complicated-handles gnus-article-mime-handles)
4496 The current article has a complicated MIME structure, giving up..."))
4497 (when (gnus-yes-or-no-p "\
4498 Deleting parts may malfunction or destroy the article; continue? ")
4499 (let* ((data (get-text-property (point) 'gnus-data))
4501 (handles gnus-article-mime-handles))
4502 (setq file (and data (mm-save-part data)))
4504 (with-current-buffer (mm-handle-buffer data)
4506 (insert "Content-Type: " (mm-handle-media-type data))
4507 (mml-insert-parameter-string (cdr (mm-handle-type data))
4510 (insert "Content-ID: " (message-make-message-id) "\n")
4511 (insert "Content-Transfer-Encoding: binary\n")
4514 (cdr (mm-make-handle nil
4515 `("message/external-body"
4516 (access-type . "LOCAL-FILE")
4518 (set-buffer gnus-summary-buffer)
4519 (gnus-article-edit-part handles)))))
4521 (defun gnus-mime-delete-part ()
4522 "Delete the MIME part under point.
4523 Replace it with some information about the removed part."
4525 (gnus-article-check-buffer)
4526 (when (gnus-group-read-only-p)
4527 (error "The current group does not support deleting of parts"))
4528 (when (mm-complicated-handles gnus-article-mime-handles)
4530 The current article has a complicated MIME structure, giving up..."))
4531 (when (gnus-yes-or-no-p "\
4532 Deleting parts may malfunction or destroy the article; continue? ")
4533 (let* ((data (get-text-property (point) 'gnus-data))
4534 (handles gnus-article-mime-handles)
4538 (mail-decode-encoded-word-string (or (mm-handle-description data)
4541 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4543 (type (mm-handle-media-type data)))
4545 (error "No MIME part under point"))
4546 (with-current-buffer (mm-handle-buffer data)
4547 (let ((bsize (format "%s" (buffer-size))))
4552 "| The following attachment has been deleted:\n"
4554 "| Type: " type "\n"
4555 "| Filename: " filename "\n"
4556 "| Size (encoded): " bsize " Byte\n"
4557 "| Description: " description "\n"
4560 (cdr (mm-make-handle
4561 nil `("text/plain") nil nil
4563 (format "Deleted attachment (%s bytes)" bsize))))))
4564 (set-buffer gnus-summary-buffer)
4565 (gnus-article-edit-part handles))))
4567 (defun gnus-mime-save-part ()
4568 "Save the MIME part under point."
4570 (gnus-article-check-buffer)
4571 (let ((data (get-text-property (point) 'gnus-data)))
4573 (mm-save-part data))))
4575 (defun gnus-mime-pipe-part ()
4576 "Pipe the MIME part under point to a process."
4578 (gnus-article-check-buffer)
4579 (let ((data (get-text-property (point) 'gnus-data)))
4581 (mm-pipe-part data))))
4583 (defun gnus-mime-view-part ()
4584 "Interactively choose a viewing method for the MIME part under point."
4586 (gnus-article-check-buffer)
4587 (let ((data (get-text-property (point) 'gnus-data)))
4589 (setq gnus-article-mime-handles
4591 gnus-article-mime-handles (setq data (copy-sequence data))))
4592 (mm-interactively-view-part data))))
4594 (defun gnus-mime-view-part-as-type-internal ()
4595 (gnus-article-check-buffer)
4596 (let* ((name (mail-content-type-get
4597 (mm-handle-type (get-text-property (point) 'gnus-data))
4599 (def-type (and name (mm-default-file-encoding name))))
4600 (and def-type (cons def-type 0))))
4602 (defun gnus-mime-view-part-as-type (&optional mime-type)
4603 "Choose a MIME media type, and view the part as such."
4606 (setq mime-type (completing-read
4607 "View as MIME type: "
4608 (mapcar #'list (mailcap-mime-types))
4610 (gnus-mime-view-part-as-type-internal))))
4611 (gnus-article-check-buffer)
4612 (let ((handle (get-text-property (point) 'gnus-data)))
4615 (mm-make-handle (mm-handle-buffer handle)
4616 (cons mime-type (cdr (mm-handle-type handle)))
4617 (mm-handle-encoding handle)
4618 (mm-handle-undisplayer handle)
4619 (mm-handle-disposition handle)
4620 (mm-handle-description handle)
4622 (mm-handle-id handle)))
4623 (setq gnus-article-mime-handles
4624 (mm-merge-handles gnus-article-mime-handles handle))
4625 (gnus-mm-display-part handle))))
4627 (defun gnus-mime-copy-part (&optional handle arg)
4628 "Put the MIME part under point into a new buffer.
4629 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4631 (interactive (list nil current-prefix-arg))
4632 (gnus-article-check-buffer)
4634 (setq handle (get-text-property (point) 'gnus-data)))
4636 (let ((filename (or (mail-content-type-get (mm-handle-disposition handle)
4638 (mail-content-type-get (mm-handle-disposition handle)
4640 contents dont-decode charset coding-system)
4641 (mm-with-unibyte-buffer
4642 (mm-insert-part handle)
4643 (setq contents (or (condition-case nil
4644 (mm-decompress-buffer filename nil 'sig)
4646 (setq dont-decode t)
4649 (setq filename (cond (filename (file-name-nondirectory filename))
4650 (dont-decode "*raw data*")
4655 (unless (setq charset (mail-content-type-get
4656 (mm-handle-type handle) 'charset))
4657 (unless (setq coding-system (mm-with-unibyte-buffer
4659 (mm-find-buffer-file-coding-system)))
4660 (setq charset gnus-newsgroup-charset))))
4662 (setq charset (or (cdr (assq arg
4663 gnus-summary-show-article-charset-alist))
4664 (mm-read-coding-system "Charset: ")))))
4665 (switch-to-buffer (generate-new-buffer filename))
4666 (if (or coding-system
4668 (setq coding-system (mm-charset-to-coding-system charset))
4669 (not (eq charset 'ascii))))
4671 (mm-enable-multibyte)
4672 (insert (mm-decode-coding-string contents coding-system))
4673 (setq buffer-file-coding-system
4674 (if (boundp 'last-coding-system-used)
4675 (symbol-value 'last-coding-system-used)
4677 (mm-disable-multibyte)
4679 (setq buffer-file-coding-system mm-binary-coding-system))
4680 ;; We do it this way to make `normal-mode' set the appropriate mode.
4683 (setq buffer-file-name (expand-file-name filename))
4685 (setq buffer-file-name nil))
4686 (goto-char (point-min)))))
4688 (defun gnus-mime-print-part (&optional handle filename)
4689 "Print the MIME part under point."
4690 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4691 (gnus-article-check-buffer)
4692 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4693 (contents (and handle (mm-get-part handle)))
4694 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4695 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4700 (mm-save-part-to-file handle file)
4701 (call-process shell-file-name nil
4702 (generate-new-buffer " *mm*")
4704 shell-command-switch
4706 printer file (mm-handle-type handle))))
4710 (gnus-print-buffer))
4711 (ps-despool filename)))))
4713 (defun gnus-mime-inline-part (&optional handle arg)
4714 "Insert the MIME part under point into the current buffer.
4715 Compressed files like .gz and .bz2 are decompressed."
4716 (interactive (list nil current-prefix-arg))
4717 (gnus-article-check-buffer)
4719 (setq handle (get-text-property (point) 'gnus-data)))
4722 (inhibit-read-only t)
4723 contents charset coding-system)
4724 (if (and (not arg) (mm-handle-undisplayer handle))
4725 (mm-remove-part handle)
4726 (mm-with-unibyte-buffer
4727 (mm-insert-part handle)
4729 (or (mm-decompress-buffer
4730 (or (mail-content-type-get (mm-handle-disposition handle)
4732 (mail-content-type-get (mm-handle-disposition handle)
4738 (unless (setq charset (mail-content-type-get
4739 (mm-handle-type handle) 'charset))
4740 (unless (setq coding-system
4741 (mm-with-unibyte-buffer
4743 (mm-find-buffer-file-coding-system)))
4744 (setq charset gnus-newsgroup-charset))))
4746 (if (mm-handle-undisplayer handle)
4747 (mm-remove-part handle))
4750 gnus-summary-show-article-charset-alist))
4751 (mm-read-coding-system "Charset: "))))
4753 (if (mm-handle-undisplayer handle)
4754 (mm-remove-part handle))))
4758 (if (or coding-system
4761 (mm-charset-to-coding-system charset))
4762 (not (eq charset 'ascii))))
4763 (mm-decode-coding-string contents coding-system)
4764 (mm-string-to-multibyte contents)))
4767 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4768 "Insert the MIME part under point into the current buffer using the
4770 (interactive (list nil current-prefix-arg))
4771 (gnus-article-check-buffer)
4772 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4775 (inhibit-read-only t))
4777 (if (mm-handle-undisplayer handle)
4778 (mm-remove-part handle))
4779 (let ((gnus-newsgroup-charset
4781 gnus-summary-show-article-charset-alist))
4782 (mm-read-coding-system "Charset: ")))
4783 (gnus-newsgroup-ignored-charsets 'gnus-all))
4784 (gnus-article-press-button)))))
4786 (defun gnus-mime-view-part-externally (&optional handle)
4787 "View the MIME part under point with an external viewer."
4789 (gnus-article-check-buffer)
4790 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4791 (mm-user-display-methods nil)
4792 (mm-inlined-types nil)
4793 (mail-parse-charset gnus-newsgroup-charset)
4794 (mail-parse-ignored-charsets
4795 (with-current-buffer gnus-summary-buffer
4796 gnus-newsgroup-ignored-charsets)))
4798 (if (mm-handle-undisplayer handle)
4799 (mm-remove-part handle)
4800 (mm-display-part handle)))))
4802 (defun gnus-mime-view-part-internally (&optional handle)
4803 "View the MIME part under point with an internal viewer.
4804 If no internal viewer is available, use an external viewer."
4806 (gnus-article-check-buffer)
4807 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4808 (mm-inlined-types '(".*"))
4809 (mm-inline-large-images t)
4810 (mail-parse-charset gnus-newsgroup-charset)
4811 (mail-parse-ignored-charsets
4812 (with-current-buffer gnus-summary-buffer
4813 gnus-newsgroup-ignored-charsets))
4814 (inhibit-read-only t))
4816 (if (mm-handle-undisplayer handle)
4817 (mm-remove-part handle)
4818 (mm-display-part handle)))))
4820 (defun gnus-mime-action-on-part (&optional action)
4821 "Do something with the MIME attachment at \(point\)."
4823 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4824 (gnus-article-check-buffer)
4825 (let ((action-pair (assoc action gnus-mime-action-alist)))
4827 (funcall (cdr action-pair)))))
4829 (defun gnus-article-part-wrapper (n function)
4830 (with-current-buffer gnus-article-buffer
4831 (when (> n (length gnus-article-mime-handle-alist))
4832 (error "No such part"))
4833 (gnus-article-goto-part n)
4834 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4835 (funcall function handle))))
4837 (defun gnus-article-pipe-part (n)
4838 "Pipe MIME part N, which is the numerical prefix."
4840 (gnus-article-part-wrapper n 'mm-pipe-part))
4842 (defun gnus-article-save-part (n)
4843 "Save MIME part N, which is the numerical prefix."
4845 (gnus-article-part-wrapper n 'mm-save-part))
4847 (defun gnus-article-interactively-view-part (n)
4848 "View MIME part N interactively, which is the numerical prefix."
4850 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4852 (defun gnus-article-copy-part (n)
4853 "Copy MIME part N, which is the numerical prefix."
4855 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4857 (defun gnus-article-view-part-as-charset (n)
4858 "View MIME part N using a specified charset.
4859 N is the numerical prefix."
4861 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4863 (defun gnus-article-view-part-externally (n)
4864 "View MIME part N externally, which is the numerical prefix."
4866 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4868 (defun gnus-article-inline-part (n)
4869 "Inline MIME part N, which is the numerical prefix."
4871 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4873 (defun gnus-article-mime-match-handle-first (condition)
4876 (dolist (ihandle gnus-article-mime-handle-alist)
4878 ((functionp condition)
4879 (funcall condition (cdr ihandle)))
4880 ((eq condition 'undisplayed)
4881 (not (or (mm-handle-undisplayer (cdr ihandle))
4882 (equal (mm-handle-media-type (cdr ihandle))
4883 "multipart/alternative"))))
4884 ((eq condition 'undisplayed-alternative)
4885 (not (mm-handle-undisplayer (cdr ihandle))))
4887 (gnus-article-goto-part (car ihandle))
4888 (or (not n) (< (car ihandle) n)))
4889 (setq n (car ihandle))))
4893 (defun gnus-article-view-part (&optional n)
4894 "View MIME part N, which is the numerical prefix."
4896 (with-current-buffer gnus-article-buffer
4897 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4898 gnus-article-mime-match-handle-function)))
4899 (when (> n (length gnus-article-mime-handle-alist))
4900 (error "No such part"))
4901 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4902 (when (gnus-article-goto-part n)
4903 (if (equal (car handle) "multipart/alternative")
4904 (gnus-article-press-button)
4905 (when (eq (gnus-mm-display-part handle) 'internal)
4906 (gnus-set-window-start)))))))
4908 (defsubst gnus-article-mime-total-parts ()
4909 (if (bufferp (car gnus-article-mime-handles))
4911 (1- (length gnus-article-mime-handles))))
4913 (defun gnus-mm-display-part (handle)
4914 "Display HANDLE and fix MIME button."
4915 (let ((id (get-text-property (point) 'gnus-part))
4917 (inhibit-read-only t))
4920 (let ((window (selected-window))
4921 (mail-parse-charset gnus-newsgroup-charset)
4922 (mail-parse-ignored-charsets
4923 (if (gnus-buffer-live-p gnus-summary-buffer)
4924 (with-current-buffer gnus-summary-buffer
4925 gnus-newsgroup-ignored-charsets)
4929 (let ((win (gnus-get-buffer-window (current-buffer) t))
4932 (select-window win))
4935 (if (mm-handle-displayed-p handle)
4936 ;; This will remove the part.
4937 (mm-display-part handle)
4939 (narrow-to-region (point)
4940 (if (eobp) (point) (1+ (point))))
4941 (mm-display-part handle)
4942 ;; We narrow to the part itself and
4943 ;; then call the treatment functions.
4944 (goto-char (point-min))
4946 (narrow-to-region (point) (point-max))
4949 (gnus-article-mime-total-parts)
4950 (mm-handle-media-type handle)))))
4951 (if (window-live-p window)
4952 (select-window window)))))
4955 (gnus-insert-mime-button
4956 handle id (list (mm-handle-displayed-p handle)))
4957 (goto-char point))))
4959 (defun gnus-article-goto-part (n)
4960 "Go to MIME part N."
4961 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4963 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4964 (let ((gnus-tmp-name
4965 (or (mail-content-type-get (mm-handle-type handle) 'name)
4966 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4967 (mail-content-type-get (mm-handle-type handle) 'url)
4969 (gnus-tmp-type (mm-handle-media-type handle))
4970 (gnus-tmp-description
4971 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4974 (if (if displayed (car displayed)
4975 (mm-handle-displayed-p handle))
4977 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4979 gnus-tmp-type-long b e)
4980 (when (string-match ".*/" gnus-tmp-name)
4981 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4982 (setq gnus-tmp-type-long (concat gnus-tmp-type
4983 (and (not (equal gnus-tmp-name ""))
4984 (concat "; " gnus-tmp-name))))
4985 (unless (equal gnus-tmp-description "")
4986 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4991 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4992 `(keymap ,gnus-mime-button-map
4993 gnus-callback gnus-mm-display-part
4994 gnus-part ,gnus-tmp-id
4995 article-type annotation
4998 ;; Exclude a newline.
5001 (widget-convert-button
5004 :action 'gnus-widget-press-button
5005 :button-keymap gnus-mime-button-map
5007 (lambda (widget/window &optional overlay pos)
5008 ;; Needed to properly clear the message due to a bug in
5009 ;; wid-edit (XEmacs only).
5010 (if (boundp 'help-echo-owns-message)
5011 (setq help-echo-owns-message t))
5013 "%S: %s the MIME part; %S: more options"
5014 (aref gnus-mouse-2 0)
5015 ;; XEmacs will get a single widget arg; Emacs 21 will get
5016 ;; window, overlay, position.
5017 (if (mm-handle-displayed-p
5019 (with-current-buffer (gnus-overlay-buffer overlay)
5020 (widget-get (widget-at (gnus-overlay-start overlay))
5022 (widget-get widget/window :mime-handle)))
5024 (aref gnus-down-mouse-3 0))))))
5026 (defun gnus-widget-press-button (elems el)
5027 (goto-char (widget-get elems :from))
5028 (gnus-article-press-button))
5030 (defvar gnus-displaying-mime nil)
5032 (defun gnus-display-mime (&optional ihandles)
5033 "Display the MIME parts."
5035 (save-selected-window
5036 (let ((window (get-buffer-window gnus-article-buffer))
5039 (select-window window)
5040 ;; We have to do this since selecting the window
5041 ;; may change the point. So we set the window point.
5042 (set-window-point window point)))
5043 (let ((handles ihandles)
5044 (inhibit-read-only t)
5047 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
5048 (when gnus-article-emulate-mime
5049 (mm-uu-dissect-text-parts handles)))
5050 (gnus-article-emulate-mime
5051 (setq handles (mm-uu-dissect))))
5052 (when (and (not ihandles)
5053 (not gnus-displaying-mime))
5054 ;; Top-level call; we clean up.
5055 (when gnus-article-mime-handles
5056 (mm-destroy-parts gnus-article-mime-handles)
5057 (setq gnus-article-mime-handle-alist nil));; A trick.
5058 (setq gnus-article-mime-handles handles)
5059 ;; We allow users to glean info from the handles.
5060 (when gnus-article-mime-part-function
5061 (gnus-mime-part-function handles)))
5063 (or (not (stringp (car handles)))
5066 (when (and (not ihandles)
5067 (not gnus-displaying-mime))
5068 ;; Clean up for mime parts.
5070 (delete-region (point) (point-max)))
5071 (let ((gnus-displaying-mime t))
5072 (gnus-mime-display-part handles)))
5075 (narrow-to-region (point) (point-max))
5076 (gnus-treat-article nil 1 1)
5079 ;; Highlight the headers.
5083 (narrow-to-region (point-min) (point))
5084 (gnus-article-save-original-date
5085 (gnus-treat-article 'head)))))))))
5087 (defcustom gnus-mime-display-multipart-as-mixed nil
5088 "Display \"multipart\" parts as \"multipart/mixed\".
5090 If t, it overrides nil values of
5091 `gnus-mime-display-multipart-alternative-as-mixed' and
5092 `gnus-mime-display-multipart-related-as-mixed'."
5093 :group 'gnus-article-mime
5096 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
5097 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
5099 :group 'gnus-article-mime
5102 (defcustom gnus-mime-display-multipart-related-as-mixed nil
5103 "Display \"multipart/related\" parts as \"multipart/mixed\".
5105 If displaying \"text/html\" is discouraged \(see
5106 `mm-discouraged-alternatives'\) images or other material inside a
5107 \"multipart/related\" part might be overlooked when this variable is nil."
5109 :group 'gnus-article-mime
5112 (defun gnus-mime-display-part (handle)
5115 ((not (stringp (car handle)))
5116 (gnus-mime-display-single handle))
5117 ;; User-defined multipart
5118 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
5119 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
5121 ;; multipart/alternative
5122 ((and (equal (car handle) "multipart/alternative")
5123 (not (or gnus-mime-display-multipart-as-mixed
5124 gnus-mime-display-multipart-alternative-as-mixed)))
5125 (let ((id (1+ (length gnus-article-mime-handle-alist))))
5126 (push (cons id handle) gnus-article-mime-handle-alist)
5127 (gnus-mime-display-alternative (cdr handle) nil nil id)))
5128 ;; multipart/related
5129 ((and (equal (car handle) "multipart/related")
5130 (not (or gnus-mime-display-multipart-as-mixed
5131 gnus-mime-display-multipart-related-as-mixed)))
5132 ;;;!!!We should find the start part, but we just default
5133 ;;;!!!to the first part.
5134 ;;(gnus-mime-display-part (cadr handle))
5135 ;;;!!! Most multipart/related is an HTML message plus images.
5136 ;;;!!! Unfortunately we are unable to let W3 display those
5137 ;;;!!! included images, so we just display it as a mixed multipart.
5138 ;;(gnus-mime-display-mixed (cdr handle))
5139 ;;;!!! No, w3 can display everything just fine.
5140 (gnus-mime-display-part (cadr handle)))
5141 ((equal (car handle) "multipart/signed")
5142 (gnus-add-wash-type 'signed)
5143 (gnus-mime-display-security handle))
5144 ((equal (car handle) "multipart/encrypted")
5145 (gnus-add-wash-type 'encrypted)
5146 (gnus-mime-display-security handle))
5147 ;; Other multiparts are handled like multipart/mixed.
5149 (gnus-mime-display-mixed (cdr handle)))))
5151 (defun gnus-mime-part-function (handles)
5152 (if (stringp (car handles))
5153 (mapcar 'gnus-mime-part-function (cdr handles))
5154 (funcall gnus-article-mime-part-function handles)))
5156 (defun gnus-mime-display-mixed (handles)
5157 (mapcar 'gnus-mime-display-part handles))
5159 (defun gnus-mime-display-single (handle)
5160 (let ((type (mm-handle-media-type handle))
5161 (ignored gnus-ignored-mime-types)
5168 (when (string-match (pop ignored) type)
5169 (throw 'ignored nil)))
5170 (if (and (setq not-attachment
5171 (and (not (mm-inline-override-p handle))
5172 (or (not (mm-handle-disposition handle))
5173 (equal (car (mm-handle-disposition handle))
5175 (mm-attachment-override-p handle))))
5176 (mm-automatic-display-p handle)
5178 (mm-inlinable-p handle)
5179 (mm-inlined-p handle))
5180 (mm-automatic-external-display-p type)))
5182 (when (equal (mm-handle-media-supertype handle) "text")
5184 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5186 (push (cons id handle) gnus-article-mime-handle-alist)
5187 (when (or (not display)
5188 (not (gnus-unbuttonized-mime-type-p type)))
5189 (gnus-insert-mime-button
5190 handle id (list (or display (and not-attachment text))))
5191 (gnus-article-insert-newline)
5192 ;; Remember modify the number of forward lines.
5200 (let ((mail-parse-charset gnus-newsgroup-charset)
5201 (mail-parse-ignored-charsets
5202 (save-excursion (condition-case ()
5203 (set-buffer gnus-summary-buffer)
5205 gnus-newsgroup-ignored-charsets)))
5206 (mm-display-part handle t))
5207 (goto-char (point-max)))
5208 ((and text not-attachment)
5212 (gnus-article-insert-newline)
5213 (mm-display-inline handle)
5214 (goto-char (point-max))))
5218 (narrow-to-region beg (point))
5221 (gnus-article-mime-total-parts)
5222 (mm-handle-media-type handle)))))))))
5224 (defun gnus-unbuttonized-mime-type-p (type)
5225 "Say whether TYPE is to be unbuttonized."
5226 (unless gnus-inhibit-mime-unbuttonizing
5228 (let ((types gnus-unbuttonized-mime-types))
5230 (when (string-match (pop types) type)
5231 (throw 'found t)))))
5233 (let ((types gnus-buttonized-mime-types))
5235 (when (string-match (pop types) type)
5236 (throw 'found t)))))))))
5238 (defun gnus-article-insert-newline ()
5239 "Insert a newline, but mark it as undeletable."
5240 (gnus-put-text-property
5241 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5243 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5244 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5247 handle (inhibit-read-only t) from props begend not-pref)
5248 (save-window-excursion
5251 (narrow-to-region (car ibegend)
5254 (goto-char (car ibegend))
5257 (delete-region (point-min) (point-max))
5258 (mm-remove-parts handles))
5259 (setq begend (list (point-marker)))
5261 (unless (setq not-pref (cadr (member preferred ihandles)))
5262 (setq not-pref (car ihandles)))
5265 (not (gnus-unbuttonized-mime-type-p
5266 "multipart/alternative")))
5267 (gnus-add-text-properties
5270 (insert (format "%d. " id))
5274 (unless ,(not ibegend)
5275 (setq gnus-article-mime-handle-alist
5276 ',gnus-article-mime-handle-alist))
5277 (gnus-mime-display-alternative
5278 ',ihandles ',not-pref ',begend ,id))
5279 keymap ,gnus-mime-button-map
5280 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5281 face ,gnus-article-button-face
5284 (widget-convert-button 'link from (point)
5285 :action 'gnus-widget-press-button
5286 :button-keymap gnus-widget-button-keymap)
5288 (while (setq handle (pop handles))
5289 (gnus-add-text-properties
5292 (insert (format "(%c) %-18s"
5293 (if (equal handle preferred) ?* ? )
5294 (mm-handle-media-type handle)))
5298 (unless ,(not ibegend)
5299 (setq gnus-article-mime-handle-alist
5300 ',gnus-article-mime-handle-alist))
5301 (gnus-mime-display-alternative
5302 ',ihandles ',handle ',begend ,id))
5303 keymap ,gnus-mime-button-map
5304 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5305 face ,gnus-article-button-face
5308 (widget-convert-button 'link from (point)
5309 :action 'gnus-widget-press-button
5310 :button-keymap gnus-widget-button-keymap)
5314 (if (stringp (car preferred))
5315 (gnus-display-mime preferred)
5316 (let ((mail-parse-charset gnus-newsgroup-charset)
5317 (mail-parse-ignored-charsets
5318 (with-current-buffer gnus-summary-buffer
5319 gnus-newsgroup-ignored-charsets)))
5320 (mm-display-part preferred)
5324 (narrow-to-region (car begend) (point-max))
5326 nil (length gnus-article-mime-handle-alist)
5327 (gnus-article-mime-total-parts)
5328 (mm-handle-media-type handle))))))
5329 (goto-char (point-max))
5330 (setcdr begend (point-marker)))))
5332 (goto-char point))))
5334 (defconst gnus-article-wash-status-strings
5335 (let ((alist '((cite "c" "Possible hidden citation text"
5336 " " "All citation text visible")
5337 (headers "h" "Hidden headers"
5338 " " "All headers visible.")
5339 (pgp "p" "Encrypted or signed message status hidden"
5340 " " "No hidden encryption nor digital signature status")
5341 (signature "s" "Signature has been hidden"
5342 " " "Signature is visible")
5343 (overstrike "o" "Overstrike (^H) characters applied"
5344 " " "No overstrike characters applied")
5345 (gnus-show-mime "m" "Mime processing is activated"
5346 " " "Mime processing is not activated")
5347 (emphasis "e" "/*_Emphasis_*/ characters applied"
5348 " " "No /*_emphasis_*/ characters applied")))
5350 (dolist (entry alist result)
5351 (let ((key (nth 0 entry))
5352 (on (copy-sequence (nth 1 entry)))
5353 (on-help (nth 2 entry))
5354 (off (copy-sequence (nth 3 entry)))
5355 (off-help (nth 4 entry)))
5356 (put-text-property 0 1 'help-echo on-help on)
5357 (put-text-property 0 1 'help-echo off-help off)
5358 (push (list key on off) result))))
5359 "Alist of strings describing wash status in the mode line.
5360 Each entry has the form (KEY ON OF), where the KEY is a symbol
5361 representing the particular washing function, ON is the string to use
5362 in the article mode line when the washing function is active, and OFF
5363 is the string to use when it is inactive.")
5365 (defun gnus-article-wash-status-entry (key value)
5366 (let ((entry (assoc key gnus-article-wash-status-strings)))
5367 (if value (nth 1 entry) (nth 2 entry))))
5369 (defun gnus-article-wash-status ()
5370 "Return a string which display status of article washing."
5371 (with-current-buffer gnus-article-buffer
5372 (let ((cite (memq 'cite gnus-article-wash-types))
5373 (headers (memq 'headers gnus-article-wash-types))
5374 (boring (memq 'boring-headers gnus-article-wash-types))
5375 (pgp (memq 'pgp gnus-article-wash-types))
5376 (pem (memq 'pem gnus-article-wash-types))
5377 (signed (memq 'signed gnus-article-wash-types))
5378 (encrypted (memq 'encrypted gnus-article-wash-types))
5379 (signature (memq 'signature gnus-article-wash-types))
5380 (overstrike (memq 'overstrike gnus-article-wash-types))
5381 (emphasis (memq 'emphasis gnus-article-wash-types)))
5383 (gnus-article-wash-status-entry 'cite cite)
5384 (gnus-article-wash-status-entry 'headers (or headers boring))
5385 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5386 (gnus-article-wash-status-entry 'signature signature)
5387 (gnus-article-wash-status-entry 'overstrike overstrike)
5388 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
5389 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5391 (defun gnus-add-wash-type (type)
5392 "Add a washing of TYPE to the current status."
5393 (add-to-list 'gnus-article-wash-types type))
5395 (defun gnus-delete-wash-type (type)
5396 "Add a washing of TYPE to the current status."
5397 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5399 (defun gnus-add-image (category image)
5400 "Add IMAGE of CATEGORY to the list of displayed images."
5401 (let ((entry (assq category gnus-article-image-alist)))
5403 (setq entry (list category))
5404 (push entry gnus-article-image-alist))
5405 (nconc entry (list image))))
5407 (defun gnus-delete-images (category)
5408 "Delete all images in CATEGORY."
5409 (let ((entry (assq category gnus-article-image-alist)))
5410 (dolist (image (cdr entry))
5411 (gnus-remove-image image category))
5412 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5413 (gnus-delete-wash-type category)))
5415 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5417 (defun gnus-article-maybe-hide-headers ()
5418 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5419 Provided for backwards compatibility."
5420 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5421 (not (with-current-buffer gnus-summary-buffer
5422 gnus-have-all-headers)))
5423 (not gnus-inhibit-hiding))
5424 (gnus-article-hide-headers)))
5428 (defun gnus-output-to-file (file-name)
5429 "Append the current article to a file named FILE-NAME."
5430 (let ((artbuf (current-buffer)))
5432 (insert-buffer-substring artbuf)
5433 ;; Append newline at end of the buffer as separator, and then
5435 (goto-char (point-max))
5437 (let ((file-name-coding-system nnmail-pathname-coding-system))
5438 (write-region-as-binary (point-min) (point-max) file-name 'append))
5441 (defun gnus-narrow-to-page (&optional arg)
5442 "Narrow the article buffer to a page.
5443 If given a numerical ARG, move forward ARG pages."
5445 (setq arg (if arg (prefix-numeric-value arg) 0))
5447 (set-buffer gnus-article-buffer)
5448 (goto-char (point-min))
5450 ;; Remove any old next/prev buttons.
5451 (when (gnus-visual-p 'page-marker)
5452 (let ((inhibit-read-only t))
5453 (gnus-remove-text-with-property 'gnus-prev)
5454 (gnus-remove-text-with-property 'gnus-next)))
5457 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5459 (re-search-forward page-delimiter nil 'move arg)))
5460 (goto-char (match-end 0))
5462 (goto-char (point-min))
5463 (setq gnus-page-broken
5464 (and (re-search-forward page-delimiter nil t) t))))
5465 (when gnus-page-broken
5468 (if (re-search-forward page-delimiter nil 'move)
5471 (when (and (gnus-visual-p 'page-marker)
5472 (> (point-min) (save-restriction (widen) (point-min))))
5474 (goto-char (point-min))
5475 (gnus-insert-prev-page-button)))
5476 (when (and (gnus-visual-p 'page-marker)
5477 (< (point-max) (save-restriction (widen) (point-max))))
5479 (goto-char (point-max))
5480 (gnus-insert-next-page-button))))))
5482 ;; Article mode commands
5484 (defun gnus-article-goto-next-page ()
5485 "Show the next page of the article."
5487 (when (gnus-article-next-page)
5488 (goto-char (point-min))
5489 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5492 (defun gnus-article-goto-prev-page ()
5493 "Show the previous page of the article."
5496 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5497 (gnus-article-prev-page nil)))
5499 ;; This is cleaner but currently breaks `gnus-pick-mode':
5501 ;; (defun gnus-article-goto-next-page ()
5502 ;; "Show the next page of the article."
5504 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5505 ;; (gnus-summary-next-page)))
5507 ;; (defun gnus-article-goto-prev-page ()
5508 ;; "Show the next page of the article."
5510 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5511 ;; (gnus-summary-prev-page)))
5513 (defun gnus-article-next-page (&optional lines)
5514 "Show the next page of the current article.
5515 If end of article, return non-nil. Otherwise return nil.
5516 Argument LINES specifies lines to be scrolled up."
5518 (move-to-window-line -1)
5521 (and (pos-visible-in-window-p) ;Not continuation line.
5522 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5523 ;; Nothing in this page.
5524 (if (or (not gnus-page-broken)
5529 (eobp)))) ;Real end-of-buffer?
5531 (when gnus-article-over-scroll
5532 (gnus-article-next-page-1 lines))
5534 (gnus-narrow-to-page 1) ;Go to next page.
5536 ;; More in this page.
5537 (gnus-article-next-page-1 lines)
5540 (defun gnus-article-next-page-1 (lines)
5541 (let ((scroll-in-place nil))
5545 ;; Long lines may cause an end-of-buffer error.
5546 (goto-char (point-max)))))
5547 (move-to-window-line 0))
5549 (defun gnus-article-prev-page (&optional lines)
5550 "Show previous page of current article.
5551 Argument LINES specifies lines to be scrolled down."
5553 (move-to-window-line 0)
5554 (if (and gnus-page-broken
5556 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5558 (gnus-narrow-to-page -1) ;Go to previous page.
5559 (goto-char (point-max))
5561 (let ((scroll-in-place nil))
5565 (beginning-of-buffer
5566 (goto-char (point-min))))
5567 (move-to-window-line 0)))))
5569 (defun gnus-article-only-boring-p ()
5570 "Decide whether there is only boring text remaining in the article.
5571 Something \"interesting\" is a word of at least two letters that does
5572 not have a face in `gnus-article-boring-faces'."
5573 (when (and gnus-article-skip-boring
5574 (boundp 'gnus-article-boring-faces)
5575 (symbol-value 'gnus-article-boring-faces))
5578 (while (re-search-forward "\\b\\w\\w" nil t)
5580 (when (not (gnus-intersection
5581 (gnus-faces-at (point))
5582 (symbol-value 'gnus-article-boring-faces)))
5583 (throw 'only-boring nil)))
5584 (throw 'only-boring t)))))
5586 (defun gnus-article-refer-article ()
5587 "Read article specified by message-id around point."
5590 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5591 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5592 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5593 (let ((msg-id (concat "<" (match-string 0) ">")))
5594 (set-buffer gnus-summary-buffer)
5595 (gnus-summary-refer-article msg-id))
5596 (error "No references around point"))))
5598 (defun gnus-article-show-summary ()
5599 "Reconfigure windows to show summary buffer."
5601 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5602 (error "There is no summary buffer for this article buffer")
5603 (gnus-article-set-globals)
5604 (gnus-configure-windows 'article)
5605 (gnus-summary-goto-subject gnus-current-article)
5606 (gnus-summary-position-point)))
5608 (defun gnus-article-describe-briefly ()
5609 "Describe article mode commands briefly."
5611 (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")))
5613 (defun gnus-article-summary-command ()
5614 "Execute the last keystroke in the summary buffer."
5616 (let ((obuf (current-buffer))
5617 (owin (current-window-configuration))
5619 (switch-to-buffer gnus-article-current-summary 'norecord)
5620 (setq func (lookup-key (current-local-map) (this-command-keys)))
5621 (call-interactively func)
5623 (set-window-configuration owin)
5624 (set-window-point (get-buffer-window (current-buffer)) (point))))
5626 (defun gnus-article-summary-command-nosave ()
5627 "Execute the last keystroke in the summary buffer."
5630 (pop-to-buffer gnus-article-current-summary 'norecord)
5631 (setq func (lookup-key (current-local-map) (this-command-keys)))
5632 (call-interactively func)))
5634 (defun gnus-article-check-buffer ()
5635 "Beep if not in an article buffer."
5636 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5637 (error "Command invoked outside of a Gnus article buffer")))
5639 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5640 "Read a summary buffer key sequence and execute it from the article buffer."
5642 (gnus-article-check-buffer)
5644 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5645 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5646 "=" "^" "\M-^" "|"))
5652 '("n" "Gn" "p" "Gp"))
5655 (set-buffer gnus-article-current-summary)
5656 (let (gnus-pick-mode)
5657 (push (or key last-command-event) unread-command-events)
5658 (setq keys (static-if (featurep 'xemacs)
5659 (events-to-keys (read-key-sequence nil))
5660 (read-key-sequence nil)))))
5663 (if (or (member keys nosaves)
5664 (member keys nosave-but-article)
5665 (member keys nosave-in-article))
5667 (save-window-excursion
5668 (pop-to-buffer gnus-article-current-summary 'norecord)
5669 ;; We disable the pick minor mode commands.
5670 (let (gnus-pick-mode)
5671 (setq func (lookup-key (current-local-map) keys))))
5675 (unless (member keys nosave-in-article)
5676 (set-buffer gnus-article-current-summary))
5677 (call-interactively func)
5678 (setq new-sum-point (point)))
5679 (when (member keys nosave-but-article)
5680 (pop-to-buffer gnus-article-buffer 'norecord)))
5681 ;; These commands should restore window configuration.
5682 (let ((obuf (current-buffer))
5683 (owin (current-window-configuration))
5685 win func in-buffer selected new-sum-start new-sum-hscroll)
5686 (cond (not-restore-window
5687 (pop-to-buffer gnus-article-current-summary 'norecord))
5688 ((setq win (get-buffer-window gnus-article-current-summary))
5689 (select-window win))
5691 (switch-to-buffer gnus-article-current-summary 'norecord)))
5692 (setq in-buffer (current-buffer))
5693 ;; We disable the pick minor mode commands.
5694 (if (and (setq func (let (gnus-pick-mode)
5695 (lookup-key (current-local-map) keys)))
5698 (call-interactively func)
5699 (when (eq win (selected-window))
5700 (setq new-sum-point (point)
5701 new-sum-start (window-start win)
5702 new-sum-hscroll (window-hscroll win)))
5703 (when (eq in-buffer (current-buffer))
5704 (setq selected (gnus-summary-select-article))
5706 (unless not-restore-window
5707 (set-window-configuration owin))
5708 (when (eq selected 'old)
5710 (set-window-start (get-buffer-window (current-buffer))
5712 (set-window-point (get-buffer-window (current-buffer))
5714 (when (and (not not-restore-window)
5716 (set-window-point win new-sum-point)
5717 (set-window-start win new-sum-start)
5718 (set-window-hscroll win new-sum-hscroll))))
5719 (set-window-configuration owin)
5722 (defun gnus-article-describe-key (key)
5723 "Display documentation of the function invoked by KEY. KEY is a string."
5724 (interactive "kDescribe key: ")
5725 (gnus-article-check-buffer)
5726 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5728 (set-buffer gnus-article-current-summary)
5729 (let (gnus-pick-mode)
5730 (if (featurep 'xemacs)
5732 (push (elt key 0) unread-command-events)
5733 (setq key (events-to-keys
5734 (read-key-sequence "Describe key: "))))
5735 (setq unread-command-events
5737 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5739 (setq key (read-key-sequence "Describe key: "))))
5741 (describe-key key)))
5743 (defun gnus-article-describe-key-briefly (key &optional insert)
5744 "Display documentation of the function invoked by KEY. KEY is a string."
5745 (interactive "kDescribe key: \nP")
5746 (gnus-article-check-buffer)
5747 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5749 (set-buffer gnus-article-current-summary)
5750 (let (gnus-pick-mode)
5751 (if (featurep 'xemacs)
5753 (push (elt key 0) unread-command-events)
5754 (setq key (events-to-keys
5755 (read-key-sequence "Describe key: "))))
5756 (setq unread-command-events
5758 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5760 (setq key (read-key-sequence "Describe key: "))))
5761 (describe-key-briefly key insert))
5762 (describe-key-briefly key insert)))
5764 (defun gnus-article-reply-with-original (&optional wide)
5765 "Start composing a reply mail to the current message.
5766 The text in the region will be yanked. If the region isn't active,
5767 the entire article will be yanked."
5769 (let ((article (cdr gnus-article-current))
5771 (if (not (gnus-region-active-p))
5772 (with-current-buffer gnus-summary-buffer
5773 (gnus-summary-reply (list (list article)) wide))
5774 (setq contents (buffer-substring (point) (mark t)))
5775 ;; Deactivate active regions.
5776 (when (and (boundp 'transient-mark-mode)
5777 transient-mark-mode)
5778 (setq mark-active nil))
5779 (with-current-buffer gnus-summary-buffer
5781 (list (list article contents)) wide)))))
5783 (defun gnus-article-followup-with-original ()
5784 "Compose a followup to the current article.
5785 The text in the region will be yanked. If the region isn't active,
5786 the entire article will be yanked."
5788 (let ((article (cdr gnus-article-current))
5790 (if (not (gnus-region-active-p))
5791 (with-current-buffer gnus-summary-buffer
5792 (gnus-summary-followup (list (list article))))
5793 (setq contents (buffer-substring (point) (mark t)))
5794 ;; Deactivate active regions.
5795 (when (and (boundp 'transient-mark-mode)
5796 transient-mark-mode)
5797 (setq mark-active nil))
5798 (with-current-buffer gnus-summary-buffer
5799 (gnus-summary-followup
5800 (list (list article contents)))))))
5802 (defun gnus-article-hide (&optional arg force)
5803 "Hide all the gruft in the current article.
5804 This means that signatures, cited text and (some) headers will be
5806 If given a prefix, show the hidden text instead."
5807 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5808 (gnus-article-hide-headers arg)
5809 (gnus-article-hide-list-identifiers arg)
5810 (gnus-article-hide-citation-maybe arg force)
5811 (gnus-article-hide-signature arg))
5813 (defun gnus-article-maybe-highlight ()
5814 "Do some article highlighting if article highlighting is requested."
5815 (when (gnus-visual-p 'article-highlight 'highlight)
5816 (gnus-article-highlight-some)))
5818 (defun gnus-check-group-server ()
5819 ;; Make sure the connection to the server is alive.
5820 (unless (gnus-server-opened
5821 (gnus-find-method-for-group gnus-newsgroup-name))
5822 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5823 (gnus-request-group gnus-newsgroup-name t)))
5826 (autoload 'nneething-get-file-name "nneething"))
5828 (defun gnus-request-article-this-buffer (article group)
5829 "Get an article and insert it into this buffer."
5830 (let (do-update-line sparse-header)
5834 (gnus-kill-all-overlays)
5835 (setq group (or group gnus-newsgroup-name))
5837 ;; Using `gnus-request-article' directly will insert the article into
5838 ;; `nntp-server-buffer' - so we'll save some time by not having to
5839 ;; copy it from the server buffer into the article buffer.
5841 ;; We only request an article by message-id when we do not have the
5842 ;; headers for it, so we'll have to get those.
5843 (when (stringp article)
5844 (gnus-read-header article))
5846 ;; If the article number is negative, that means that this article
5847 ;; doesn't belong in this newsgroup (possibly), so we find its
5848 ;; message-id and request it by id instead of number.
5849 (when (and (numberp article)
5851 (get-buffer gnus-summary-buffer)
5852 (gnus-buffer-exists-p gnus-summary-buffer))
5854 (set-buffer gnus-summary-buffer)
5855 (let ((header (gnus-summary-article-header article)))
5858 ((memq article gnus-newsgroup-sparse)
5859 ;; This is a sparse gap article.
5860 (setq do-update-line article)
5861 (setq article (mail-header-id header))
5862 (setq sparse-header (gnus-read-header article))
5863 (setq gnus-newsgroup-sparse
5864 (delq article gnus-newsgroup-sparse)))
5866 ;; It's a real article.
5867 (setq article (mail-header-id header)))
5869 ;; It is an extracted pseudo-article.
5870 (setq article 'pseudo)
5871 (gnus-request-pseudo-article header))))
5873 (let ((method (gnus-find-method-for-group
5874 gnus-newsgroup-name)))
5875 (when (and (eq (car method) 'nneething)
5877 (let ((dir (nneething-get-file-name
5878 (mail-header-id header))))
5879 (when (and (stringp dir)
5880 (file-directory-p dir))
5881 (setq article 'nneething)
5882 (gnus-group-enter-directory dir))))))))
5885 ;; Refuse to select canceled articles.
5886 ((and (numberp article)
5888 (get-buffer gnus-summary-buffer)
5889 (gnus-buffer-exists-p gnus-summary-buffer)
5890 (eq (cdr (with-current-buffer gnus-summary-buffer
5891 (assq article gnus-newsgroup-reads)))
5892 gnus-canceled-mark))
5894 ;; We first check `gnus-original-article-buffer'.
5895 ((and (get-buffer gnus-original-article-buffer)
5897 (with-current-buffer gnus-original-article-buffer
5898 (and (equal (car gnus-original-article) group)
5899 (eq (cdr gnus-original-article) article))))
5900 (insert-buffer-substring gnus-original-article-buffer)
5902 ;; Check the backlog.
5903 ((and gnus-keep-backlog
5904 (gnus-backlog-request-article group article (current-buffer)))
5906 ;; Check asynchronous pre-fetch.
5907 ((gnus-async-request-fetched-article group article (current-buffer))
5908 (gnus-async-prefetch-next group article gnus-summary-buffer)
5909 (when (and (numberp article) gnus-keep-backlog)
5910 (gnus-backlog-enter-article group article (current-buffer)))
5913 ((and gnus-use-cache
5915 (gnus-cache-request-article article group))
5917 ;; Check the agent cache.
5918 ((gnus-agent-request-article article group)
5920 ;; Get the article and put into the article buffer.
5921 ((or (stringp article)
5923 (let ((gnus-override-method gnus-override-method)
5924 (methods (and (stringp article)
5925 gnus-refer-article-method))
5926 (backend (car (gnus-find-method-for-group
5927 gnus-newsgroup-name)))
5929 (inhibit-read-only t))
5930 (if (or (not (listp methods))
5931 (and (symbolp (car methods))
5932 (assq (car methods) nnoo-definition-alist)))
5933 (setq methods (list methods)))
5934 (when (and (null gnus-override-method)
5936 (setq gnus-override-method (pop methods)))
5938 (when (eq gnus-override-method 'current)
5939 (setq gnus-override-method
5940 (with-current-buffer gnus-summary-buffer
5941 gnus-current-select-method)))
5943 (gnus-kill-all-overlays)
5944 (let ((gnus-newsgroup-name group))
5945 (gnus-check-group-server))
5947 ((gnus-request-article article group (current-buffer))
5948 (when (numberp article)
5949 (gnus-async-prefetch-next group article
5950 gnus-summary-buffer)
5951 (when gnus-keep-backlog
5952 (gnus-backlog-enter-article
5953 group article (current-buffer))))
5954 (setq result 'article))
5956 (setq gnus-override-method (pop methods)))
5957 ((not (string-match "^400 "
5958 (nnheader-get-report backend)))
5959 ;; If we get 400 server disconnect, reconnect and
5960 ;; retry; otherwise, assume the article has expired.
5961 (setq result 'done))))
5962 (and (eq result 'article) 'article)))
5966 ;; Associate this article with the current summary buffer.
5967 (setq gnus-article-current-summary gnus-summary-buffer)
5969 ;; Take the article from the original article buffer
5970 ;; and place it in the buffer it's supposed to be in.
5971 (when (and (get-buffer gnus-article-buffer)
5972 (equal (buffer-name (current-buffer))
5973 (buffer-name (get-buffer gnus-article-buffer))))
5975 (if (get-buffer gnus-original-article-buffer)
5976 (set-buffer gnus-original-article-buffer)
5977 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5978 (buffer-disable-undo)
5979 (setq major-mode 'gnus-original-article-mode)
5980 (setq buffer-read-only t))
5981 (let ((inhibit-read-only t))
5983 (insert-buffer-substring gnus-article-buffer))
5984 (setq gnus-original-article (cons group article)))
5987 (run-hooks 'gnus-article-decode-hook)
5988 ;; Mark article as decoded or not.
5989 (setq gnus-article-decoded-p gnus-article-decode-hook))
5991 ;; Update sparse articles.
5992 (when (and do-update-line
5993 (or (numberp article)
5995 (let ((buf (current-buffer)))
5996 (set-buffer gnus-summary-buffer)
5997 (gnus-summary-update-article do-update-line sparse-header)
5998 (gnus-summary-goto-subject do-update-line nil t)
5999 (set-window-point (gnus-get-buffer-window (current-buffer) t)
6001 (set-buffer buf))))))
6007 (defcustom gnus-article-edit-mode-hook nil
6008 "Hook run in article edit mode buffers."
6009 :group 'gnus-article-various
6012 (defcustom gnus-article-edit-article-setup-function
6013 'gnus-article-mime-edit-article-setup
6014 "Function called to setup an editing article buffer."
6015 :group 'gnus-article-various
6018 (defvar gnus-article-edit-done-function nil)
6020 (defvar gnus-article-edit-mode-map nil)
6022 ;; Should we be using derived.el for this?
6023 (unless gnus-article-edit-mode-map
6024 (setq gnus-article-edit-mode-map (make-keymap))
6025 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
6027 (gnus-define-keys gnus-article-edit-mode-map
6028 "\C-c?" describe-mode
6029 "\C-c\C-c" gnus-article-edit-done
6030 "\C-c\C-k" gnus-article-edit-exit
6031 "\C-c\C-f\C-t" message-goto-to
6032 "\C-c\C-f\C-o" message-goto-from
6033 "\C-c\C-f\C-b" message-goto-bcc
6034 ;;"\C-c\C-f\C-w" message-goto-fcc
6035 "\C-c\C-f\C-c" message-goto-cc
6036 "\C-c\C-f\C-s" message-goto-subject
6037 "\C-c\C-f\C-r" message-goto-reply-to
6038 "\C-c\C-f\C-n" message-goto-newsgroups
6039 "\C-c\C-f\C-d" message-goto-distribution
6040 "\C-c\C-f\C-f" message-goto-followup-to
6041 "\C-c\C-f\C-m" message-goto-mail-followup-to
6042 "\C-c\C-f\C-k" message-goto-keywords
6043 "\C-c\C-f\C-u" message-goto-summary
6044 "\C-c\C-f\C-i" message-insert-or-toggle-importance
6045 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
6046 "\C-c\C-b" message-goto-body
6047 "\C-c\C-i" message-goto-signature
6049 "\C-c\C-t" message-insert-to
6050 "\C-c\C-n" message-insert-newsgroups
6051 "\C-c\C-o" message-sort-headers
6052 "\C-c\C-e" message-elide-region
6053 "\C-c\C-v" message-delete-not-region
6054 "\C-c\C-z" message-kill-to-signature
6055 "\M-\r" message-newline-and-reformat
6056 "\C-c\C-a" mml-attach-file
6057 "\C-a" message-beginning-of-line
6059 "\M-;" comment-region)
6061 (gnus-define-keys (gnus-article-edit-wash-map
6062 "\C-c\C-w" gnus-article-edit-mode-map)
6063 "f" gnus-article-edit-full-stops))
6066 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
6068 ["Fetch To" message-insert-to t]
6069 ["Fetch Newsgroups" message-insert-newsgroups t]
6071 ["To" message-goto-to t]
6072 ["From" message-goto-from t]
6073 ["Subject" message-goto-subject t]
6074 ["Cc" message-goto-cc t]
6075 ["Reply-To" message-goto-reply-to t]
6076 ["Summary" message-goto-summary t]
6077 ["Keywords" message-goto-keywords t]
6078 ["Newsgroups" message-goto-newsgroups t]
6079 ["Followup-To" message-goto-followup-to t]
6080 ["Mail-Followup-To" message-goto-mail-followup-to t]
6081 ["Distribution" message-goto-distribution t]
6082 ["Body" message-goto-body t]
6083 ["Signature" message-goto-signature t]))
6085 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
6086 "Major mode for editing articles.
6087 This is an extended text-mode.
6089 \\{gnus-article-edit-mode-map}"
6090 (make-local-variable 'gnus-article-edit-done-function)
6091 (make-local-variable 'gnus-prev-winconf)
6092 (set (make-local-variable 'font-lock-defaults)
6093 '(message-font-lock-keywords t))
6094 (set (make-local-variable 'mail-header-separator) "")
6095 (set (make-local-variable 'gnus-article-edit-mode) t)
6096 (easy-menu-add message-mode-field-menu message-mode-map)
6097 (setq buffer-read-only nil)
6098 (buffer-enable-undo)
6101 (defun gnus-article-edit (&optional force)
6102 "Edit the current article.
6103 This will have permanent effect only in mail groups.
6104 If FORCE is non-nil, allow editing of articles even in read-only
6107 (when (and (not force)
6108 (gnus-group-read-only-p))
6109 (error "The current newsgroup does not support article editing"))
6110 (gnus-article-date-original)
6111 (gnus-article-edit-article
6113 `(lambda (no-highlight)
6115 (gnus-summary-edit-article-done
6116 ,(or (mail-header-references gnus-current-headers) "")
6117 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
6119 (defun gnus-article-edit-article (start-func exit-func)
6120 "Start editing the contents of the current article buffer."
6121 (let ((winconf (current-window-configuration)))
6122 (set-buffer gnus-article-buffer)
6123 (let ((message-auto-save-directory
6124 ;; Don't associate the article buffer with a draft file.
6126 (gnus-article-edit-mode))
6127 (funcall start-func)
6128 (set-buffer-modified-p nil)
6129 (gnus-configure-windows 'edit-article)
6130 (setq gnus-article-edit-done-function exit-func)
6131 (setq gnus-prev-winconf winconf)
6132 (when gnus-article-edit-article-setup-function
6133 (funcall gnus-article-edit-article-setup-function))
6134 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit")))
6136 (defun gnus-article-edit-done (&optional arg)
6137 "Update the article edits and exit."
6139 (let ((func gnus-article-edit-done-function)
6140 (buf (current-buffer))
6141 (start (window-start))
6143 (winconf gnus-prev-winconf))
6144 (remove-hook 'gnus-article-mode-hook
6145 'gnus-article-mime-edit-article-unwind)
6146 (widen) ;; Widen it in case that users narrowed the buffer.
6149 ;; The cache and backlog have to be flushed somewhat.
6150 (when gnus-keep-backlog
6151 (gnus-backlog-remove-article
6152 (car gnus-article-current) (cdr gnus-article-current)))
6153 ;; Flush original article as well.
6155 (when (get-buffer gnus-original-article-buffer)
6156 (set-buffer gnus-original-article-buffer)
6157 (setq gnus-original-article nil)))
6158 (when gnus-use-cache
6159 (gnus-cache-update-article
6160 (car gnus-article-current) (cdr gnus-article-current)))
6161 ;; We remove all text props from the article buffer.
6162 (kill-all-local-variables)
6163 (set-text-properties (point-min) (point-max) nil)
6165 (set-window-configuration winconf)
6167 (set-window-start (get-buffer-window buf) start)
6168 (set-window-point (get-buffer-window buf) (point)))
6169 (gnus-summary-show-article))
6171 (defun gnus-article-edit-exit ()
6172 "Exit the article editing without updating."
6174 (when (or (not (buffer-modified-p))
6175 (yes-or-no-p "Article modified; kill anyway? "))
6176 (let ((curbuf (current-buffer))
6178 (window-start (window-start)))
6180 (if (gnus-buffer-live-p gnus-original-article-buffer)
6181 (insert-buffer-substring gnus-original-article-buffer))
6182 (let ((winconf gnus-prev-winconf))
6183 (kill-all-local-variables)
6185 (set-window-configuration winconf)
6186 ;; Tippy-toe some to make sure that point remains where it was.
6187 (save-current-buffer
6189 (set-window-start (get-buffer-window (current-buffer)) window-start)
6191 (gnus-summary-show-article)))
6193 (defun gnus-article-edit-full-stops ()
6194 "Interactively repair spacing at end of sentences."
6197 (goto-char (point-min))
6198 (search-forward-regexp "^$" nil t)
6199 (let ((case-fold-search nil))
6200 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
6203 ;;; Article editing with MIME-Edit
6206 (defcustom gnus-article-mime-edit-article-setup-hook nil
6207 "Hook run after setting up a MIME editing article buffer."
6208 :group 'gnus-article-various
6211 (defun gnus-article-mime-edit-article-unwind ()
6212 "Unwind `gnus-article-buffer' if article editing was given up."
6213 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6214 (when (featurep 'font-lock)
6215 (setq font-lock-defaults nil)
6216 (font-lock-mode -1))
6217 (when mime-edit-mode-flag
6218 (mime-edit-exit 'nomime 'no-error)
6221 (defun gnus-article-mime-edit-article-setup ()
6222 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
6223 after replacing with the original article."
6224 (setq gnus-show-mime t)
6225 (setq gnus-article-edit-done-function
6226 `(lambda (&rest args)
6227 (when mime-edit-mode-flag
6228 (let (mime-edit-insert-user-agent-field)
6231 (goto-char (point-min))
6232 (let (case-fold-search)
6233 (when (re-search-forward
6234 (format "^%s$" (regexp-quote mail-header-separator))
6236 (replace-match "")))
6237 (apply ,gnus-article-edit-done-function args)
6240 (buffer-substring-no-properties (point-min) (point-max))
6241 (set-buffer (get-buffer-create gnus-original-article-buffer))
6243 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6244 (set-buffer gnus-article-buffer)
6245 (gnus-article-prepare-display)))
6246 (substitute-key-definition 'gnus-article-edit-done
6247 'gnus-article-mime-edit-done
6248 gnus-article-edit-mode-map)
6249 (substitute-key-definition 'gnus-article-edit-exit
6250 'gnus-article-mime-edit-exit
6251 gnus-article-edit-mode-map)
6253 (insert-buffer-substring gnus-original-article-buffer)
6254 (unless (member (with-current-buffer gnus-summary-buffer
6255 gnus-newsgroup-name)
6256 '("nndraft:delayed" "nndraft:drafts"))
6257 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
6258 (fset 'mime-edit-decode-single-part-in-buffer
6259 (lambda (&rest args)
6260 (if (let ((content-type (car args)))
6261 (and (eq 'message (mime-content-type-primary-type
6263 (eq 'rfc822 (mime-content-type-subtype
6265 (setcar (cdr args) 'not-decode-text))
6269 (fset 'mime-edit-decode-single-part-in-buffer ofn))))
6270 (when (featurep 'font-lock)
6271 (set (make-local-variable 'font-lock-defaults)
6272 '(message-font-lock-keywords t))
6273 (font-lock-set-defaults)
6274 (turn-on-font-lock))
6275 (set-buffer-modified-p nil)
6276 (delete-other-windows)
6277 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6278 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
6280 (defun gnus-article-mime-edit-done (&optional arg)
6281 "Update the article MIME edits and exit."
6283 (when (featurep 'font-lock)
6284 (setq font-lock-defaults nil)
6285 (font-lock-mode -1))
6286 (let ((inhibit-read-only t))
6287 (gnus-article-edit-done arg)))
6289 (defun gnus-article-mime-edit-exit ()
6290 "Exit the article MIME editing without updating."
6292 (when (or (not (buffer-modified-p))
6293 (yes-or-no-p "Article modified; kill anyway? "))
6294 (when (featurep 'font-lock)
6295 (setq font-lock-defaults nil)
6296 (font-lock-mode -1))
6297 (when mime-edit-mode-flag
6298 (let (mime-edit-insert-user-agent-field)
6301 (goto-char (point-min))
6302 (let (case-fold-search)
6303 (when (re-search-forward
6304 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
6305 (replace-match "")))
6306 (let ((winconf gnus-prev-winconf))
6308 (buffer-substring-no-properties (point-min) (point-max))
6309 (set-buffer (get-buffer-create gnus-original-article-buffer))
6311 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6312 (set-buffer gnus-article-buffer)
6313 (gnus-article-prepare-display)
6314 (set-window-configuration winconf))))
6317 ;;; Article highlights
6320 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6322 ;;; Internal Variables:
6324 (defcustom gnus-button-url-regexp
6325 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
6326 "\\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:]]\\)"
6327 "\\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\\)\\)")
6328 "Regular expression that matches URLs."
6329 :group 'gnus-article-buttons
6332 (defcustom gnus-button-valid-fqdn-regexp
6333 message-valid-fqdn-regexp
6334 "Regular expression that matches a valid FQDN."
6336 :group 'gnus-article-buttons
6339 (defcustom gnus-button-man-handler 'manual-entry
6340 "Function to use for displaying man pages.
6341 The function must take at least one argument with a string naming the
6344 :type '(choice (function-item :tag "Man" manual-entry)
6345 (function-item :tag "Woman" woman)
6346 (function :tag "Other"))
6347 :group 'gnus-article-buttons)
6349 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6350 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6351 If the default site is too slow, try to find a CTAN mirror, see
6352 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6353 the variable `gnus-button-handle-ctan'."
6355 :group 'gnus-article-buttons
6356 :link '(custom-manual "(gnus)Group Parameters")
6357 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6358 (const "http://tug.ctan.org/tex-archive/")
6359 (const "http://www.dante.de/CTAN/")
6360 (string :tag "Other")))
6362 (defcustom gnus-button-ctan-handler 'browse-url
6363 "Function to use for displaying CTAN links.
6364 The function must take one argument, the string naming the URL."
6366 :type '(choice (function-item :tag "Browse Url" browse-url)
6367 (function :tag "Other"))
6368 :group 'gnus-article-buttons)
6370 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6371 "Bogus strings removed from CTAN URLs."
6373 :group 'gnus-article-buttons
6374 :type '(choice (const "^/?tex-archive/\\|/")
6375 (regexp :tag "Other")))
6377 (defcustom gnus-button-ctan-directory-regexp
6380 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
6381 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
6382 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
6384 "Regular expression for ctan directories.
6385 It should match all directories in the top level of `gnus-ctan-url'."
6387 :group 'gnus-article-buttons
6390 (defcustom gnus-button-mid-or-mail-regexp
6391 (concat "\\b\\(<?[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*@"
6392 ;; Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
6393 gnus-button-valid-fqdn-regexp
6395 "Regular expression that matches a message ID or a mail address."
6397 :group 'gnus-article-buttons
6400 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6401 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6402 Strings like this can be either a message ID or a mail address. If it is one
6403 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6404 message ID or a mail address, respectively. If this variable is set to the
6405 symbol `ask', always query the user what do do. If it is a function, this
6406 function will be called with the string as it's only argument. The function
6407 must return `mid', `mail', `invalid' or `ask'."
6409 :group 'gnus-article-buttons
6410 :type '(choice (function-item :tag "Heuristic function"
6411 gnus-button-mid-or-mail-heuristic)
6416 (defcustom gnus-button-mid-or-mail-heuristic-alist
6417 '((-10.0 . ".+\\$.+@")
6420 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6421 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6422 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6423 (-1.0 . "^[^a-z]+@")
6425 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6426 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6427 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6428 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6431 (-1.0 . "^[0-9][0-9]")
6433 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6434 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6435 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6436 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6438 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6439 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6442 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6444 ;; compensation for TDMA dated mail addresses:
6445 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6447 (-20.0 . "\\.fsf@") ;; Gnus
6450 (-20.0 . "_-_") ;; Subject change in thread
6452 (-20.0 . "\\.ln@") ;; leafnode
6453 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6454 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6456 ;; (5.0 . "") ;; $local_part_len <= 7
6457 (10.0 . "^[^0-9]+@")
6458 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6459 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6462 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6464 (0.5 . "^[A-Z][a-z]")
6465 (0.5 . "^[A-Z][a-z][a-z]")
6466 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6467 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6468 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6470 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6471 address. The REGEXP is processed with `case-fold-search' set to nil."
6473 :group 'gnus-article-buttons
6474 :type '(repeat (cons (number :tag "Rate")
6475 (regexp :tag "Regexp"))))
6477 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6478 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6479 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6480 address, `ask' if unsure and `invalid' if the string is invalid."
6481 (let ((case-fold-search nil)
6482 (list gnus-button-mid-or-mail-heuristic-alist)
6483 (result 0) rate regexp lpartlen elem)
6485 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6486 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6487 ;; Certain special cases...
6490 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6491 "^[0-9]+\\.[0-9]+@compuserve\\|"
6492 "@public\\.gmane\\.org")
6494 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6495 (setq result 'mail))
6496 (when (string-match "@.*@\\| " mid-or-mail)
6497 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6498 (setq result 'invalid))
6499 ;; Nothing more to do, if result is not a number here...
6500 (when (numberp result)
6502 (setq elem (car list)
6506 (when (string-match regexp mid-or-mail)
6507 (setq result (+ result rate))
6509 9 "`%s' matched `%s', rate `%s', result `%s'."
6510 mid-or-mail regexp rate result)))
6511 (when (<= lpartlen 7)
6512 (setq result (+ result 5.0))
6513 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6514 mid-or-mail result))
6515 (when (>= lpartlen 12)
6516 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6518 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6519 ;; Long local part should contain realname if e-mail address,
6520 ;; too many digits: message-id.
6521 ;; $score -= 5.0 + 0.1 * $local_part_len;
6522 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6523 (setq result (+ result rate))
6525 9 "Many digits in `%s', rate `%s', result `%s'."
6526 mid-or-mail rate result))
6527 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6529 ;; Too few vowels [^aeiouy]{4,}.*\@
6530 (setq result (+ result -5.0))
6532 9 "Few vowels in `%s', rate `%s', result `%s'."
6533 mid-or-mail -5.0 result))
6535 (setq result (+ result 5.0))
6537 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6538 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6539 ;; Maybe we should make this a customizable alist: (condition . 'result)
6541 ((symbolp result) result)
6542 ;; Now convert number into proper results:
6543 ((< result -10.0) 'mid)
6544 ((> result 10.0) 'mail)
6547 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6548 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6549 (url-mid (concat "news" ":" mid-or-mail))
6550 (url-mailto (concat "mailto" ":" mid-or-mail)))
6551 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6552 (when (fboundp pref)
6554 ;; get rid of surrounding angles...
6556 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6557 (if (or (eq 'mid guessed) (eq 'mail guessed))
6561 (save-window-excursion
6562 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6565 (cond ((eq pref 'mid)
6566 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6567 (gnus-button-handle-news url-mid))
6569 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6570 (gnus-url-mailto url-mailto))
6571 (t (gnus-message 3 "Invalid string.")))))
6573 (defun gnus-button-handle-custom (url)
6574 "Follow a Custom URL."
6575 (customize-apropos (gnus-url-unhex-string url)))
6577 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6579 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6582 (defun gnus-button-handle-describe-function (url)
6583 "Call `describe-function' when pushing the corresponding URL button."
6586 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6588 (defun gnus-button-handle-describe-variable (url)
6589 "Call `describe-variable' when pushing the corresponding URL button."
6592 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6594 (defun gnus-button-handle-symbol (url)
6595 "Display help on variable or function.
6596 Calls `describe-variable' or `describe-function'."
6597 (let ((sym (intern url)))
6599 ((fboundp sym) (describe-function sym))
6600 ((boundp sym) (describe-variable sym))
6601 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6603 (defun gnus-button-handle-describe-key (url)
6604 "Call `describe-key' when pushing the corresponding URL button."
6606 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6607 (keys (ignore-errors (eval `(kbd ,key-string)))))
6610 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6612 (defun gnus-button-handle-apropos (url)
6613 "Call `apropos' when pushing the corresponding URL button."
6614 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6616 (defun gnus-button-handle-apropos-command (url)
6617 "Call `apropos' when pushing the corresponding URL button."
6619 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6621 (defun gnus-button-handle-apropos-variable (url)
6622 "Call `apropos' when pushing the corresponding URL button."
6624 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6625 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6627 (defun gnus-button-handle-apropos-documentation (url)
6628 "Call `apropos' when pushing the corresponding URL button."
6630 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6631 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6633 (defun gnus-button-handle-library (url)
6634 "Call `locate-library' when pushing the corresponding URL button."
6635 (gnus-message 9 "url=`%s'" url)
6636 (let* ((lib (locate-library url))
6637 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6639 (gnus-message 1 "Cannot locale library `%s'." url)
6640 (find-file-read-only file))))
6642 (defun gnus-button-handle-ctan (url)
6643 "Call `browse-url' when pushing a CTAN URL button."
6645 gnus-button-ctan-handler
6648 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6650 (defcustom gnus-button-tex-level 5
6651 "*Integer that says how many TeX-related buttons Gnus will show.
6652 The higher the number, the more buttons will appear and the more false
6653 positives are possible. Note that you can set this variable local to
6654 specific groups. Setting it higher in TeX groups is probably a good idea.
6655 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6656 how to set variables in specific groups."
6658 :group 'gnus-article-buttons
6659 :link '(custom-manual "(gnus)Group Parameters")
6662 (defcustom gnus-button-man-level 5
6663 "*Integer that says how many man-related buttons Gnus will show.
6664 The higher the number, the more buttons will appear and the more false
6665 positives are possible. Note that you can set this variable local to
6666 specific groups. Setting it higher in Unix groups is probably a good idea.
6667 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6668 how to set variables in specific groups."
6670 :group 'gnus-article-buttons
6671 :link '(custom-manual "(gnus)Group Parameters")
6674 (defcustom gnus-button-emacs-level 5
6675 "*Integer that says how many emacs-related buttons Gnus will show.
6676 The higher the number, the more buttons will appear and the more false
6677 positives are possible. Note that you can set this variable local to
6678 specific groups. Setting it higher in Emacs or Gnus related groups is
6679 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6680 `gnus-parameters' on how to set variables in specific groups."
6682 :group 'gnus-article-buttons
6683 :link '(custom-manual "(gnus)Group Parameters")
6686 (defcustom gnus-button-message-level 5
6687 "*Integer that says how many buttons for news or mail messages will appear.
6688 The higher the number, the more buttons will appear and the more false
6689 positives are possible."
6690 ;; mail addresses, MIDs, URLs for news, ...
6692 :group 'gnus-article-buttons
6695 (defcustom gnus-button-browse-level 5
6696 "*Integer that says how many buttons for browsing will appear.
6697 The higher the number, the more buttons will appear and the more false
6698 positives are possible."
6699 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6701 :group 'gnus-article-buttons
6704 (defcustom gnus-button-alist
6705 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6706 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6707 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6708 gnus-button-handle-news 2)
6709 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6710 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6711 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6712 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6713 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6714 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6715 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6716 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6717 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6718 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6719 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6720 ;; RFC 2368 (The mailto URL scheme)
6721 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6722 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6723 ("\\bmailto:\\([^ \n\t]+\\)"
6724 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6726 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6727 gnus-button-ctan-directory-regexp
6728 "[^][>)!;:,'\n\t ]+\\)")
6729 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6730 ((concat "\\btex-archive/\\("
6731 gnus-button-ctan-directory-regexp
6732 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6733 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6736 gnus-button-ctan-directory-regexp
6737 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6738 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6739 ;; This is info (home-grown style) <info://foo/bar+baz>
6740 ("\\binfo://\\([^'\">\n\t ]+\\)"
6741 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6742 ;; Info GNOME style <info:foo#bar_baz>
6743 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6744 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6745 ;; Info KDE style <info:(foo)bar baz>
6746 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6747 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6748 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6749 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6750 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6751 ;; Info links like `C-h i d m CC Mode RET'
6752 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6754 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6755 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6756 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6757 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6758 ;; Emacs help commands
6759 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6760 ;; regexp doesn't match arguments containing ` '.
6761 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6762 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6763 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6764 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6765 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6766 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6767 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6768 ;; The following entries may lead to many false positives so don't enable
6769 ;; them by default (use a high button level).
6770 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6771 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6772 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6773 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6774 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6775 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6776 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6777 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6778 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6779 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6780 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6781 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6782 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6783 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6784 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6785 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6786 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6787 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6788 ;; Unlike the other regexps we really have to require quoting
6789 ;; here to determine where it ends.
6790 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6791 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6792 ("<URL: *\\([^<>]*\\)>"
6793 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6794 ;; RFC 2396 (2.4.3., delims) ...
6795 ("\"URL: *\\([^\"]*\\)\""
6796 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6797 ;; RFC 2396 (2.4.3., delims) ...
6798 ("\"URL: *\\([^\"]*\\)\""
6799 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6801 (gnus-button-url-regexp
6802 0 (>= gnus-button-browse-level 0) browse-url 0)
6804 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6805 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6806 gnus-button-handle-man 1)
6807 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6808 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6809 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6810 gnus-button-handle-man 1)
6811 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6812 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6813 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6814 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6815 ;; MID or mail: To avoid too many false positives we don't try to catch
6816 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6817 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6818 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6819 ;; so that non-ambiguous entries (see above) match first.
6820 (gnus-button-mid-or-mail-regexp
6821 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6822 "*Alist of regexps matching buttons in article bodies.
6824 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6825 REGEXP: is the string (case insensitive) matching text around the button (can
6826 also be Lisp expression evaluating to a string),
6827 BUTTON: is the number of the regexp grouping actually matching the button,
6828 FORM: is a Lisp expression which must eval to true for the button to
6830 CALLBACK: is the function to call when the user push this button, and each
6831 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6833 CALLBACK can also be a variable, in that case the value of that
6834 variable it the real callback function."
6835 :group 'gnus-article-buttons
6836 :type '(repeat (list (choice regexp variable sexp)
6837 (integer :tag "Button")
6839 (function :tag "Callback")
6842 (integer :tag "Regexp group")))))
6844 (defcustom gnus-header-button-alist
6845 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6846 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6847 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6848 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6849 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6850 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
6851 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6852 0 (>= gnus-button-browse-level 0) browse-url 0)
6853 ("^Subject:" gnus-button-url-regexp
6854 0 (>= gnus-button-browse-level 0) browse-url 0)
6855 ("^[^:]+:" gnus-button-url-regexp
6856 0 (>= gnus-button-browse-level 0) browse-url 0)
6857 ("^OpenPGP:.*url=" gnus-button-url-regexp
6858 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
6859 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6860 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6861 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6862 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6863 "*Alist of headers and regexps to match buttons in article heads.
6865 This alist is very similar to `gnus-button-alist', except that each
6866 alist has an additional HEADER element first in each entry:
6868 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6870 HEADER is a regexp to match a header. For a fuller explanation, see
6871 `gnus-button-alist'."
6872 :group 'gnus-article-buttons
6873 :group 'gnus-article-headers
6874 :type '(repeat (list (regexp :tag "Header")
6875 (choice regexp variable)
6876 (integer :tag "Button")
6878 (function :tag "Callback")
6881 (integer :tag "Regexp group")))))
6885 (defun gnus-article-push-button (event)
6886 "Check text under the mouse pointer for a callback function.
6887 If the text under the mouse pointer has a `gnus-callback' property,
6888 call it with the value of the `gnus-data' text property."
6890 (set-buffer (window-buffer (posn-window (event-start event))))
6891 (let* ((pos (posn-point (event-start event)))
6892 (data (get-text-property pos 'gnus-data))
6893 (fun (get-text-property pos 'gnus-callback)))
6896 (funcall fun data))))
6898 (defun gnus-article-press-button ()
6899 "Check text at point for a callback function.
6900 If the text at point has a `gnus-callback' property,
6901 call it with the value of the `gnus-data' text property."
6903 (let ((data (get-text-property (point) 'gnus-data))
6904 (fun (get-text-property (point) 'gnus-callback)))
6906 (funcall fun data))))
6908 (defun gnus-article-prev-button (n)
6909 "Move point to N buttons backward.
6910 If N is negative, move forward instead."
6912 (gnus-article-next-button (- n)))
6914 (defun gnus-article-next-button (n)
6915 "Move point to N buttons forward.
6916 If N is negative, move backward instead."
6918 (let ((function (if (< n 0) 'previous-single-property-change
6919 'next-single-property-change))
6920 (inhibit-point-motion-hooks t)
6922 (limit (if (< n 0) (point-min) (point-max))))
6924 (while (and (not (= limit (point)))
6926 ;; Skip past the current button.
6927 (when (get-text-property (point) 'gnus-callback)
6928 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6929 ;; Go to the next (or previous) button.
6930 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
6931 ;; Put point at the start of the button.
6932 (when (and backward (not (get-text-property (point) 'gnus-callback)))
6933 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6934 ;; Skip past intangible buttons.
6935 (when (get-text-property (point) 'intangible)
6939 (gnus-message 5 "No more buttons"))
6942 (defun gnus-article-highlight (&optional force)
6943 "Highlight current article.
6944 This function calls `gnus-article-highlight-headers',
6945 `gnus-article-highlight-citation',
6946 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6947 do the highlighting. See the documentation for those functions."
6948 (interactive (list 'force))
6949 (gnus-article-highlight-headers)
6950 (gnus-article-highlight-citation force)
6951 (gnus-article-highlight-signature)
6952 (gnus-article-add-buttons force)
6953 (gnus-article-add-buttons-to-head))
6955 (defun gnus-article-highlight-some (&optional force)
6956 "Highlight current article.
6957 This function calls `gnus-article-highlight-headers',
6958 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6959 do the highlighting. See the documentation for those functions."
6960 (interactive (list 'force))
6961 (gnus-article-highlight-headers)
6962 (gnus-article-highlight-signature)
6963 (gnus-article-add-buttons))
6965 (defun gnus-article-highlight-headers ()
6966 "Highlight article headers as specified by `gnus-header-face-alist'."
6968 (gnus-with-article-headers
6969 (let (regexp header-face field-face from hpoints fpoints)
6970 (dolist (entry gnus-header-face-alist)
6971 (goto-char (point-min))
6972 (setq regexp (concat "^\\("
6973 (if (string-equal "" (nth 0 entry))
6977 header-face (nth 1 entry)
6978 field-face (nth 2 entry))
6979 (while (and (re-search-forward regexp nil t)
6983 (unless (search-forward ":" nil t)
6985 (when (and header-face
6986 (not (memq (point) hpoints)))
6987 (push (point) hpoints)
6988 (gnus-put-text-property from (point) 'face header-face))
6989 (when (and field-face
6990 (not (memq (setq from (point)) fpoints)))
6992 (if (re-search-forward "^[^ \t]" nil t)
6994 (goto-char (point-max)))
6995 (gnus-put-text-property from (point) 'face field-face)))))))
6997 (defun gnus-article-highlight-signature ()
6998 "Highlight the signature in an article.
6999 It does this by highlighting everything after
7000 `gnus-signature-separator' using `gnus-signature-face'."
7002 (when gnus-signature-face
7003 (gnus-with-article-buffer
7004 (let ((inhibit-point-motion-hooks t))
7006 (when (gnus-article-narrow-to-signature)
7007 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
7008 'face gnus-signature-face)))))))
7010 (defun gnus-article-buttonize-signature ()
7011 "Add button to the signature."
7014 (set-buffer gnus-article-buffer)
7015 (let ((inhibit-read-only t)
7016 (inhibit-point-motion-hooks t))
7017 (when (gnus-article-search-signature)
7018 (gnus-article-add-button (match-beginning 0) (match-end 0)
7019 'gnus-signature-toggle
7020 (set-marker (make-marker)
7021 (1+ (match-end 0))))))))
7023 (defun gnus-button-in-region-p (b e prop)
7024 "Say whether PROP exists in the region."
7025 (text-property-not-all b e prop nil))
7027 (defun gnus-article-add-buttons (&optional force)
7028 "Find external references in the article and make buttons of them.
7029 \"External references\" are things like Message-IDs and URLs, as
7030 specified by `gnus-button-alist'."
7031 (interactive (list 'force))
7032 (gnus-with-article-buffer
7033 (let ((inhibit-point-motion-hooks t)
7034 (case-fold-search t)
7035 (alist gnus-button-alist)
7037 ;; Remove all old markers.
7038 (let (marker entry new-list)
7039 (while (setq marker (pop gnus-button-marker-list))
7040 (if (or (< marker (point-min)) (>= marker (point-max)))
7041 (push marker new-list)
7043 (when (setq entry (gnus-button-entry))
7044 (put-text-property (match-beginning (nth 1 entry))
7045 (match-end (nth 1 entry))
7046 'gnus-callback nil))
7047 (set-marker marker nil)))
7048 (setq gnus-button-marker-list new-list))
7049 ;; We skip the headers.
7052 (while (setq entry (pop alist))
7053 (setq regexp (eval (car entry)))
7055 (while (re-search-forward regexp nil t)
7056 (let* ((start (and entry (match-beginning (nth 1 entry))))
7057 (end (and entry (match-end (nth 1 entry))))
7058 (from (match-beginning 0)))
7059 (when (and (or (eq t (nth 2 entry))
7060 (eval (nth 2 entry)))
7061 (not (gnus-button-in-region-p
7062 start end 'gnus-callback)))
7063 ;; That optional form returned non-nil, so we add the
7065 (gnus-article-add-button
7066 start end 'gnus-button-push
7067 (car (push (set-marker (make-marker) from)
7068 gnus-button-marker-list))))))))))
7070 ;; Add buttons to the head of an article.
7071 (defun gnus-article-add-buttons-to-head ()
7072 "Add buttons to the head of the article."
7074 (gnus-with-article-headers
7076 (dolist (entry gnus-header-button-alist)
7077 ;; Each alist entry.
7078 (goto-char (point-min))
7079 (while (re-search-forward (car entry) nil t)
7080 ;; Each header matching the entry.
7081 (setq beg (match-beginning 0))
7082 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
7083 (match-beginning 0))
7086 (while (re-search-forward (eval (nth 1 entry)) end t)
7087 ;; Each match within a header.
7088 (let* ((entry (cdr entry))
7089 (start (match-beginning (nth 1 entry)))
7090 (end (match-end (nth 1 entry)))
7091 (form (nth 2 entry)))
7092 (goto-char (match-end 0))
7094 (gnus-article-add-button
7095 start end (nth 3 entry)
7096 (buffer-substring (match-beginning (nth 4 entry))
7097 (match-end (nth 4 entry)))))))
7098 (goto-char end))))))
7100 ;;; External functions:
7102 (defun gnus-article-add-button (from to fun &optional data)
7103 "Create a button between FROM and TO with callback FUN and data DATA."
7104 (when gnus-article-button-face
7105 (gnus-overlay-put (gnus-make-overlay from to)
7106 'face gnus-article-button-face))
7107 (gnus-add-text-properties
7109 (nconc (and gnus-article-mouse-face
7110 (list gnus-mouse-face-prop gnus-article-mouse-face))
7111 (list 'gnus-callback fun)
7112 (and data (list 'gnus-data data))))
7113 (widget-convert-button 'link from to :action 'gnus-widget-press-button
7114 :button-keymap gnus-widget-button-keymap))
7116 ;;; Internal functions:
7118 (defun gnus-article-set-globals ()
7119 (with-current-buffer gnus-summary-buffer
7120 (gnus-set-global-variables)))
7122 (defun gnus-signature-toggle (end)
7123 (gnus-with-article-buffer
7124 (let ((inhibit-point-motion-hooks t)
7125 (limit (next-single-property-change end 'mime-view-entity
7127 (if (text-property-any end limit 'article-type 'signature)
7129 (gnus-delete-wash-type 'signature)
7130 (gnus-remove-text-properties-when
7131 'article-type 'signature end limit
7132 (cons 'article-type (cons 'signature
7133 gnus-hidden-properties))))
7134 (gnus-add-wash-type 'signature)
7135 (gnus-add-text-properties-when
7136 'article-type nil end limit
7137 (cons 'article-type (cons 'signature
7138 gnus-hidden-properties)))))
7139 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
7140 (gnus-set-mode-line 'article))))
7142 (defun gnus-button-entry ()
7143 ;; Return the first entry in `gnus-button-alist' matching this place.
7144 (let ((alist gnus-button-alist)
7147 (setq entry (pop alist))
7148 (if (looking-at (eval (car entry)))
7153 (defun gnus-button-push (marker)
7154 ;; Push button starting at MARKER.
7157 (let* ((entry (gnus-button-entry))
7158 (inhibit-point-motion-hooks t)
7160 (args (mapcar (lambda (group)
7161 (let ((string (match-string group)))
7162 (set-text-properties
7163 0 (length string) nil string)
7170 (fboundp (symbol-value fun)))
7171 (apply (symbol-value fun) args))
7173 (gnus-message 1 "You must define `%S' to use this button"
7174 (cons fun args)))))))
7176 (defun gnus-parse-news-url (url)
7177 (let (scheme server port group message-id articles)
7180 (goto-char (point-min))
7181 (when (looking-at "\\([A-Za-z]+\\):")
7182 (setq scheme (match-string 1))
7183 (goto-char (match-end 0)))
7184 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
7185 (setq server (match-string 1))
7186 (setq port (if (stringp (match-string 3))
7187 (string-to-number (match-string 3))
7189 (goto-char (match-end 0)))
7192 ((looking-at "\\(.*@.*\\)")
7193 (setq message-id (match-string 1)))
7194 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7195 (setq group (match-string 1)
7196 articles (split-string (match-string 2) "-")))
7197 ((looking-at "\\([^/]+\\)/?")
7198 (setq group (match-string 1)))
7200 (error "Unknown news URL syntax"))))
7201 (list scheme server port group message-id articles)))
7203 (defun gnus-button-handle-news (url)
7205 (destructuring-bind (scheme server port group message-id articles)
7206 (gnus-parse-news-url url)
7210 (set-buffer gnus-summary-buffer)
7212 (let ((gnus-refer-article-method
7213 (nconc (list (list 'nntp server))
7214 gnus-refer-article-method))
7215 (nntp-port-number (or port "nntp")))
7216 (gnus-message 7 "Fetching %s with %s"
7217 message-id gnus-refer-article-method)
7218 (gnus-summary-refer-article message-id))
7219 (gnus-summary-refer-article message-id))))
7221 (gnus-button-fetch-group url)))))
7223 (defun gnus-button-handle-man (url)
7225 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7226 (when (eq gnus-button-man-handler 'woman)
7227 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
7228 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7229 (funcall gnus-button-man-handler url))
7231 (defun gnus-button-handle-info-url (url)
7232 "Fetch an info URL."
7233 (setq url (mm-subst-char-in-string ?+ ?\ url))
7235 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
7236 (gnus-info-find-node
7237 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
7239 ")" (gnus-url-unhex-string (match-string 2 url)))))
7240 ((string-match "([^)\"]+)[^\"]+" url)
7242 (gnus-replace-in-string
7243 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
7244 (gnus-info-find-node url))
7245 (t (error "Can't parse %s" url))))
7247 (defun gnus-button-handle-info-url-gnome (url)
7248 "Fetch GNOME style info URL."
7249 (setq url (mm-subst-char-in-string ?_ ?\ url))
7250 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
7251 (gnus-info-find-node
7253 (gnus-url-unhex-string
7254 (match-string 1 url))
7256 (or (gnus-url-unhex-string
7257 (match-string 2 url))
7259 (error "Can't parse %s" url)))
7261 (defun gnus-button-handle-info-url-kde (url)
7262 "Fetch KDE style info URL."
7263 (gnus-info-find-node (gnus-url-unhex-string url)))
7265 (defun gnus-button-handle-info-keystrokes (url)
7266 "Call `info' when pushing the corresponding URL button."
7267 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
7272 (defun gnus-button-openpgp (url)
7273 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
7275 (mm-url-insert-file-contents-external url)
7276 (pgg-snarf-keys-region (point-min) (point-max))
7277 (pgg-display-output-buffer nil nil nil)))
7279 (defun gnus-button-message-id (message-id)
7281 (with-current-buffer gnus-summary-buffer
7282 (gnus-summary-refer-article message-id)))
7284 (defun gnus-button-fetch-group (address)
7285 "Fetch GROUP specified by ADDRESS."
7286 (if (not (string-match "[:/]" address))
7287 ;; This is just a simple group url.
7288 (gnus-group-read-ephemeral-group address gnus-select-method)
7291 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
7293 (error "Can't parse %s" address)
7294 (gnus-group-read-ephemeral-group
7295 (match-string 4 address)
7296 `(nntp ,(match-string 1 address)
7297 (nntp-address ,(match-string 1 address))
7298 (nntp-port-number ,(if (match-end 3)
7299 (match-string 3 address)
7302 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
7304 (defun gnus-url-parse-query-string (query &optional downcase)
7305 (let (retval pairs cur key val)
7306 (setq pairs (split-string query "&"))
7308 (setq cur (car pairs)
7310 (if (not (string-match "=" cur))
7312 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
7313 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
7315 (setq key (downcase key)))
7316 (setq cur (assoc key retval))
7318 (setcdr cur (cons val (cdr cur)))
7319 (setq retval (cons (list key val) retval)))))
7322 (defun gnus-url-mailto (url)
7323 ;; Send mail to someone
7324 (when (string-match "mailto:/*\\(.*\\)" url)
7325 (setq url (substring url (match-beginning 1) nil)))
7326 (let (to args subject func)
7327 (setq args (gnus-url-parse-query-string
7328 (if (string-match "^\\?" url)
7330 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
7331 (concat "to=" (match-string 1 url) "&"
7332 (match-string 2 url))
7333 (concat "to=" url)))
7335 subject (cdr-safe (assoc "subject" args)))
7338 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
7341 (message-position-on-field (caar args)))
7342 (insert (gnus-replace-in-string
7343 (mapconcat 'identity (reverse (cdar args)) ", ")
7345 (setq args (cdr args)))
7348 (message-goto-subject))))
7350 (defun gnus-button-embedded-url (address)
7351 "Activate ADDRESS with `browse-url'."
7352 (browse-url (gnus-strip-whitespace address)))
7354 ;;; Next/prev buttons in the article buffer.
7356 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
7357 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
7359 (defvar gnus-prev-page-map
7360 (let ((map (make-sparse-keymap)))
7361 (define-key map gnus-mouse-2 'gnus-button-prev-page)
7362 (define-key map "\r" 'gnus-button-prev-page)
7365 (defvar gnus-next-page-map
7366 (let ((map (make-sparse-keymap)))
7367 (unless (>= emacs-major-version 21)
7368 ;; XEmacs doesn't care.
7369 (set-keymap-parent map gnus-article-mode-map))
7370 (define-key map gnus-mouse-2 'gnus-button-next-page)
7371 (define-key map "\r" 'gnus-button-next-page)
7374 (defun gnus-insert-prev-page-button ()
7376 (inhibit-read-only t)
7377 (situation (get-text-property (point-min) 'mime-view-situation)))
7379 gnus-prev-page-line-format nil
7380 `(keymap ,gnus-prev-page-map
7382 gnus-callback gnus-article-button-prev-page
7383 article-type annotation
7384 mime-view-situation ,situation))
7385 (widget-convert-button
7387 ;; Exclude a newline.
7390 :action 'gnus-button-prev-page
7391 :button-keymap gnus-prev-page-map)))
7393 (defun gnus-button-next-page (&optional args more-args)
7394 "Go to the next page."
7396 (let ((win (selected-window)))
7397 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7398 (gnus-article-next-page)
7399 (select-window win)))
7401 (defun gnus-button-prev-page (&optional args more-args)
7402 "Go to the prev page."
7404 (let ((win (selected-window)))
7405 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7406 (gnus-article-prev-page)
7407 (select-window win)))
7409 (defun gnus-insert-next-page-button ()
7411 (inhibit-read-only t)
7412 (situation (get-text-property (point-min) 'mime-view-situation)))
7413 (gnus-eval-format gnus-next-page-line-format nil
7414 `(keymap ,gnus-next-page-map
7416 gnus-callback gnus-article-button-next-page
7417 article-type annotation
7418 mime-view-situation ,situation))
7419 (widget-convert-button
7421 ;; Exclude a newline.
7424 :action 'gnus-button-next-page
7425 :button-keymap gnus-next-page-map)))
7427 (defun gnus-article-button-next-page (arg)
7428 "Go to the next page."
7430 (let ((win (selected-window)))
7431 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7432 (gnus-article-next-page)
7433 (select-window win)))
7435 (defun gnus-article-button-prev-page (arg)
7436 "Go to the prev page."
7438 (let ((win (selected-window)))
7439 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7440 (gnus-article-prev-page)
7441 (select-window win)))
7443 (defvar gnus-decode-header-methods
7444 '(mail-decode-encoded-word-region)
7445 "List of methods used to decode headers.
7447 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7448 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
7449 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
7450 whose names match REGEXP.
7453 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7454 mail-decode-encoded-word-region
7455 (\"chinese\" . rfc1843-decode-region))
7458 (defvar gnus-decode-header-methods-cache nil)
7460 (defun gnus-multi-decode-header (start end)
7461 "Apply the functions from `gnus-encoded-word-methods' that match."
7462 (unless (and gnus-decode-header-methods-cache
7463 (eq gnus-newsgroup-name
7464 (car gnus-decode-header-methods-cache)))
7465 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7468 (nconc gnus-decode-header-methods-cache (list x))
7469 (if (and gnus-newsgroup-name
7470 (string-match (car x) gnus-newsgroup-name))
7471 (nconc gnus-decode-header-methods-cache
7473 gnus-decode-header-methods))
7474 (let ((xlist gnus-decode-header-methods-cache))
7477 (narrow-to-region start end)
7479 (funcall (pop xlist) (point-min) (point-max))))))
7482 ;;; Treatment top-level handling.
7485 (defun gnus-treat-article (condition &optional part-number total-parts type)
7486 (let ((length (- (point-max) (point-min)))
7487 (alist gnus-treatment-function-alist)
7488 (article-goto-body-goes-to-point-min-p t)
7492 (let ((list gnus-article-treat-types))
7494 (when (string-match (pop list) type)
7495 (throw 'found t)))))))
7496 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7497 (entity (static-unless (featurep 'xemacs)
7498 (when (eq 'head condition)
7499 (get-text-property (point-min) 'mime-view-entity))))
7500 val elem buttonized)
7501 (gnus-run-hooks 'gnus-part-display-hook)
7502 (unless gnus-inhibit-treatment
7503 (dolist (elem alist)
7506 (when (gnus-buffer-live-p gnus-summary-buffer)
7507 (set-buffer gnus-summary-buffer))
7508 (symbol-value (car elem))))
7509 (when (and (or (consp val)
7511 (gnus-treat-predicate val)
7512 (or (not (get (car elem) 'highlight))
7514 (when (and (not buttonized)
7516 '(gnus-treat-hide-signature
7517 gnus-treat-highlight-signature)))
7518 (gnus-article-buttonize-signature)
7519 (setq buttonized t))
7521 (funcall (cadr elem)))))
7522 ;; FSF Emacsen does not inherit the existing text properties
7523 ;; in the new text, so we should do it for `mime-view-entity'.
7524 (static-unless (featurep 'xemacs)
7526 (put-text-property (point-min) (point-max)
7527 'mime-view-entity entity))))))
7529 ;; Dynamic variables.
7531 (defvar part-number)
7532 (defvar total-parts)
7537 (defun gnus-treat-predicate (val)
7542 (stringp (car val)))
7543 (apply 'gnus-or (mapcar `(lambda (s)
7544 (string-match s ,(or gnus-newsgroup-name "")))
7547 (let ((pred (pop val)))
7550 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7552 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7554 (not (gnus-treat-predicate (car val))))
7556 (equal (car val) type))
7558 (error "%S is not a valid predicate" pred)))))
7568 (eq part-number total-parts))
7572 (error "%S is not a valid value" val))))
7574 (defun gnus-article-encrypt-body (protocol &optional n)
7575 "Encrypt the article body."
7578 (or gnus-article-encrypt-protocol
7579 (completing-read "Encrypt protocol: "
7580 gnus-article-encrypt-protocol-alist
7582 current-prefix-arg))
7583 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7585 (error (format "Can't find the encrypt protocol %s" protocol)))
7586 (if (member gnus-newsgroup-name '("nndraft:delayed"
7589 (error "Can't encrypt the article in group %s"
7590 gnus-newsgroup-name))
7591 (gnus-summary-iterate n
7593 (set-buffer gnus-summary-buffer)
7594 (let ((mail-parse-charset gnus-newsgroup-charset)
7595 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7596 (summary-buffer gnus-summary-buffer)
7598 (gnus-set-global-variables)
7599 (when (gnus-group-read-only-p)
7600 (error "The current newsgroup does not support article encrypt"))
7601 (gnus-summary-show-article t)
7603 (or (mail-header-references gnus-current-headers) ""))
7604 (set-buffer gnus-article-buffer)
7605 (let* ((inhibit-read-only t)
7607 (mapcar (lambda (field)
7608 (and (save-restriction
7609 (message-narrow-to-head)
7610 (goto-char (point-min))
7611 (search-forward field nil t))
7613 (message-narrow-to-field)
7615 (delete-region (point-min) (point-max))
7617 '("Content-Type:" "Content-Transfer-Encoding:"
7618 "Content-Disposition:"))))
7619 (message-narrow-to-head)
7620 (message-remove-header "MIME-Version")
7621 (goto-char (point-max))
7622 (setq point (point))
7623 (insert (apply 'concat headers))
7625 (narrow-to-region point (point-max))
7626 (let ((message-options message-options))
7627 (message-options-set 'message-sender user-mail-address)
7628 (message-options-set 'message-recipients user-mail-address)
7629 (message-options-set 'message-sign-encrypt 'not)
7631 (goto-char (point-min))
7632 (insert "MIME-Version: 1.0\n")
7634 (gnus-summary-edit-article-done
7635 references nil summary-buffer t))
7636 (when gnus-keep-backlog
7637 (gnus-backlog-remove-article
7638 (car gnus-article-current) (cdr gnus-article-current)))
7640 (when (get-buffer gnus-original-article-buffer)
7641 (set-buffer gnus-original-article-buffer)
7642 (setq gnus-original-article nil)))
7643 (when gnus-use-cache
7644 (gnus-cache-update-article
7645 (car gnus-article-current) (cdr gnus-article-current))))))))
7647 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7648 "The following specs can be used:
7649 %t The security MIME type
7652 %D Details if button is pressed")
7654 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7655 "The following specs can be used:
7656 %t The security MIME type
7659 %D Details if button is pressed")
7661 (defvar gnus-mime-security-button-line-format-alist
7662 '((?t gnus-tmp-type ?s)
7663 (?i gnus-tmp-info ?s)
7664 (?d gnus-tmp-details ?s)
7665 (?D gnus-tmp-pressed-details ?s)))
7667 (defvar gnus-mime-security-button-map
7668 (let ((map (make-sparse-keymap)))
7669 (define-key map gnus-mouse-2 'gnus-article-push-button)
7670 (define-key map "\r" 'gnus-article-press-button)
7673 (defvar gnus-mime-security-details-buffer nil)
7675 (defvar gnus-mime-security-button-pressed nil)
7677 (defvar gnus-mime-security-show-details-inline t
7678 "If non-nil, show details in the article buffer.")
7680 (defun gnus-mime-security-verify-or-decrypt (handle)
7681 (mm-remove-parts (cdr handle))
7682 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7683 point (inhibit-read-only t))
7685 (goto-char (car region)))
7687 (narrow-to-region (point) (point))
7688 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7689 (let* ((mm-verify-option 'known)
7690 (mm-decrypt-option 'known)
7691 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7692 (unless (eq nparts (cdr handle))
7693 (mm-destroy-parts (cdr handle))
7694 (setcdr handle nparts))))
7695 (setq point (point))
7696 (gnus-mime-display-security handle)
7697 (goto-char (point-max)))
7699 (delete-region (point) (cdr region))
7700 (set-marker (car region) nil)
7701 (set-marker (cdr region) nil))
7704 (defun gnus-mime-security-show-details (handle)
7705 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7707 (gnus-message 5 "No details.")
7708 (if gnus-mime-security-show-details-inline
7709 (let ((gnus-mime-security-button-pressed
7710 (not (get-text-property (point) 'gnus-mime-details)))
7711 (gnus-mime-security-button-line-format
7712 (get-text-property (point) 'gnus-line-format))
7713 (inhibit-read-only t))
7715 (while (eq (get-text-property (point) 'gnus-line-format)
7716 gnus-mime-security-button-line-format)
7720 (narrow-to-region (point) (point))
7721 (gnus-insert-mime-security-button handle))
7722 (delete-region (point)
7723 (or (text-property-not-all
7726 gnus-mime-security-button-line-format)
7729 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7730 (with-current-buffer gnus-mime-security-details-buffer
7733 (setq gnus-mime-security-details-buffer
7734 (gnus-get-buffer-create "*MIME Security Details*")))
7735 (with-current-buffer gnus-mime-security-details-buffer
7737 (goto-char (point-min)))
7738 (pop-to-buffer gnus-mime-security-details-buffer)))))
7740 (defun gnus-mime-security-press-button (handle)
7742 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7743 (gnus-mime-security-show-details handle)
7744 (gnus-mime-security-verify-or-decrypt handle))))
7746 (defun gnus-insert-mime-security-button (handle &optional displayed)
7747 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7750 (or (nth 2 (assoc protocol mm-verify-function-alist))
7751 (nth 2 (assoc protocol mm-decrypt-function-alist))
7753 (if (equal (car handle) "multipart/signed")
7754 " Signed" " Encrypted")
7757 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7760 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7761 gnus-tmp-pressed-details
7763 (setq gnus-tmp-details
7764 (if gnus-tmp-details
7765 (concat "\n" gnus-tmp-details)
7767 (setq gnus-tmp-pressed-details
7768 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7773 gnus-mime-security-button-line-format
7774 gnus-mime-security-button-line-format-alist
7775 `(keymap ,gnus-mime-security-button-map
7776 gnus-callback gnus-mime-security-press-button
7777 gnus-line-format ,gnus-mime-security-button-line-format
7778 gnus-mime-details ,gnus-mime-security-button-pressed
7779 article-type annotation
7782 ;; Exclude a newline.
7785 (widget-convert-button
7788 :action 'gnus-widget-press-button
7789 :button-keymap gnus-mime-security-button-map
7791 (lambda (widget/window &optional overlay pos)
7792 ;; Needed to properly clear the message due to a bug in
7793 ;; wid-edit (XEmacs only).
7794 (when (boundp 'help-echo-owns-message)
7795 (setq help-echo-owns-message t))
7798 (aref gnus-mouse-2 0))))))
7800 (defun gnus-mime-display-security (handle)
7802 (narrow-to-region (point) (point))
7803 (unless (gnus-unbuttonized-mime-type-p (car handle))
7804 (gnus-insert-mime-security-button handle))
7805 (gnus-mime-display-mixed (cdr handle))
7808 (unless (gnus-unbuttonized-mime-type-p (car handle))
7809 (let ((gnus-mime-security-button-line-format
7810 gnus-mime-security-button-end-line-format))
7811 (gnus-insert-mime-security-button handle)))
7812 (mm-set-handle-multipart-parameter
7814 (cons (set-marker (make-marker) (point-min))
7815 (set-marker (make-marker) (point-max))))))
7821 (defun gnus-article-header-presentation-method (entity situation)
7822 (mime-insert-header entity)
7823 (article-decode-group-name))
7825 (set-alist 'mime-header-presentation-method-alist
7826 'gnus-original-article-mode
7827 #'gnus-article-header-presentation-method)
7829 (defun gnus-mime-preview-quitting-method ()
7830 (mime-preview-kill-buffer)
7831 (delete-other-windows)
7832 (gnus-article-show-summary)
7833 (gnus-summary-select-article gnus-show-all-headers t))
7835 (set-alist 'mime-preview-quitting-method-alist
7836 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
7838 (set-alist 'mime-preview-following-method-alist
7839 'gnus-original-article-mode #'gnus-following-method)
7841 (set-alist 'mime-preview-over-to-previous-method-alist
7842 'gnus-original-article-mode
7844 (if (> (point-min) 1)
7845 (gnus-article-prev-page)
7846 (gnus-article-read-summary-keys
7847 nil (gnus-character-to-event ?P)))))
7849 (set-alist 'mime-preview-over-to-next-method-alist
7850 'gnus-original-article-mode'
7852 (if (< (point-max) (buffer-size))
7853 (gnus-article-next-page)
7854 (gnus-article-read-summary-keys
7855 nil (gnus-character-to-event ?N)))))
7865 (run-hooks 'gnus-art-load-hook)
7867 ;;; gnus-art.el ends here