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 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
284 "*String or function to be executed to display an X-Face header.
285 If it is a string, the command will be executed in a sub-shell
286 asynchronously. The compressed face will be piped to this command."
288 :format "%{%t%}:\n%[Value Menu%] %v"
292 (if (or (gnus-image-type-available-p 'xface)
293 (gnus-image-type-available-p 'pbm))
294 '(function-item gnus-display-x-face-in-from))
298 :group 'gnus-article-washing)
300 (defcustom gnus-article-x-face-too-ugly nil
301 "Regexp matching posters whose face shouldn't be shown automatically."
302 :type '(choice regexp (const nil))
303 :group 'gnus-article-washing)
305 (defcustom gnus-article-banner-alist nil
306 "Banner alist for stripping.
308 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
310 :type '(repeat (cons symbol regexp))
311 :group 'gnus-article-washing)
313 (gnus-define-group-parameter
316 "Alist of regexps (to match group names) and banner."
317 :variable-group gnus-article-washing
319 '(choice :tag "Banner"
321 (const :tag "Remove signature" signature)
322 (symbol :tag "Item in `gnus-article-banner-alist'" none)
324 (const :tag "None" nil))
326 "If non-nil, specify how to remove `banners' from articles.
328 Symbol `signature' means to remove signatures delimited by
329 `gnus-signature-separator'. Any other symbol is used to look up a
330 regular expression to match the banner in `gnus-article-banner-alist'.
331 A string is used as a regular expression to match the banner
334 (defcustom gnus-article-address-banner-alist nil
335 "Alist of mail addresses and banners.
336 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
337 to match a mail address in the From: header, BANNER is one of a symbol
338 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
339 If ADDRESS matches author's mail address, it will remove things like
340 advertisements. For example:
342 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
346 (regexp :tag "Address")
347 (choice :tag "Banner" :value nil
348 (const :tag "Remove signature" signature)
349 (symbol :tag "Item in `gnus-article-banner-alist'" none)
351 (const :tag "None" nil))))
353 :group 'gnus-article-washing)
355 (defmacro gnus-emphasis-custom-with-format (&rest body)
357 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
358 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
361 (defun gnus-emphasis-custom-value-to-external (value)
362 (gnus-emphasis-custom-with-format
363 (if (consp (car value))
364 (list (format format (car (car value)) (cdr (car value)))
366 (if (nth 1 value) 2 3)
370 (defun gnus-emphasis-custom-value-to-internal (value)
371 (gnus-emphasis-custom-with-format
372 (let ((regexp (concat "\\`"
373 (format (regexp-quote format)
374 "\\([^()]+\\)" "\\([^()]+\\)")
377 (if (string-match regexp (setq pattern (car value)))
378 (list (cons (match-string 1 pattern) (match-string 2 pattern))
383 (defcustom gnus-emphasis-alist
385 '(("\\*" "\\*" bold nil 2)
388 ("_/" "/_" underline-italic)
389 ("_\\*" "\\*_" underline-bold)
390 ("\\*/" "/\\*" bold-italic)
391 ("_\\*/" "/\\*_" underline-bold-italic))))
393 (gnus-emphasis-custom-with-format
394 (mapcar (lambda (spec)
395 (list (format format (car spec) (cadr spec))
398 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
400 '(;; I've never seen anyone use this strikethru convention whereas I've
401 ;; several times seen it triggered by normal text. --Stef
402 ;; Miles suggests that this form is sometimes used but for italics,
403 ;; so maybe we should map it to `italic'.
404 ;; ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
405 ;; 2 3 gnus-emphasis-strikethru)
406 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
407 2 3 gnus-emphasis-underline))))
408 "*Alist that says how to fontify certain phrases.
409 Each item looks like this:
411 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
413 The first element is a regular expression to be matched. The second
414 is a number that says what regular expression grouping used to find
415 the entire emphasized word. The third is a number that says what
416 regexp grouping should be displayed and highlighted. The fourth
417 is the face used for highlighting."
421 :format "%[Customizing Style%]\n%v"
423 (group :tag "Default"
424 :value ("" 0 0 default)
427 (let ((value (widget-get
428 (cadr (widget-get (widget-get widget :parent)
431 (if (not (eq (nth 2 value) 'default))
435 (gnus-emphasis-custom-value-to-external value))))
436 (widget-group-value-create widget))
438 (integer :format "Match group: %v")
439 (integer :format "Emphasize group: %v")
442 :value (("_" . "_") nil default)
444 (regexp :format "Start regexp: %v")
445 (regexp :format "End regexp: %v"))
446 (boolean :format "Show start and end patterns: %[%v%]\n"
447 :on " On " :off " Off ")
449 :get (lambda (symbol)
450 (mapcar 'gnus-emphasis-custom-value-to-internal
451 (default-value symbol)))
452 :set (lambda (symbol value)
453 (set-default symbol (mapcar 'gnus-emphasis-custom-value-to-external
455 :group 'gnus-article-emphasis)
457 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
458 "A regexp to describe whitespace which should not be emphasized.
459 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
460 The former avoids underlining of leading and trailing whitespace,
461 and the latter avoids underlining any whitespace at all."
463 :group 'gnus-article-emphasis
466 (defface gnus-emphasis-bold '((t (:bold t)))
467 "Face used for displaying strong emphasized text (*word*)."
468 :group 'gnus-article-emphasis)
470 (defface gnus-emphasis-italic '((t (:italic t)))
471 "Face used for displaying italic emphasized text (/word/)."
472 :group 'gnus-article-emphasis)
474 (defface gnus-emphasis-underline '((t (:underline t)))
475 "Face used for displaying underlined emphasized text (_word_)."
476 :group 'gnus-article-emphasis)
478 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
479 "Face used for displaying underlined bold emphasized text (_*word*_)."
480 :group 'gnus-article-emphasis)
482 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
483 "Face used for displaying underlined italic emphasized text (_/word/_)."
484 :group 'gnus-article-emphasis)
486 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
487 "Face used for displaying bold italic emphasized text (/*word*/)."
488 :group 'gnus-article-emphasis)
490 (defface gnus-emphasis-underline-bold-italic
491 '((t (:bold t :italic t :underline t)))
492 "Face used for displaying underlined bold italic emphasized text.
493 Example: (_/*word*/_)."
494 :group 'gnus-article-emphasis)
496 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
497 '((t (:strikethru t)))
498 '((t (:strike-through t))))
499 "Face used for displaying strike-through text (-word-)."
500 :group 'gnus-article-emphasis)
502 (defface gnus-emphasis-highlight-words
503 '((t (:background "black" :foreground "yellow")))
504 "Face used for displaying highlighted words."
505 :group 'gnus-article-emphasis)
507 (defcustom gnus-article-time-format "%a, %d %b %Y %T %Z"
508 "Format for display of Date headers in article bodies.
509 See `format-time-string' for the possible values.
511 The variable can also be function, which should return a complete Date
512 header. The function is called with one argument, the time, which can
513 be fed to `format-time-string'."
514 :type '(choice string function)
515 :link '(custom-manual "(gnus)Article Date")
516 :group 'gnus-article-washing)
518 (defcustom gnus-save-all-headers t
519 "*If non-nil, don't remove any headers before saving."
520 :group 'gnus-article-saving
523 (defcustom gnus-prompt-before-saving 'always
524 "*This variable says how much prompting is to be done when saving articles.
525 If it is nil, no prompting will be done, and the articles will be
526 saved to the default files. If this variable is `always', each and
527 every article that is saved will be preceded by a prompt, even when
528 saving large batches of articles. If this variable is neither nil not
529 `always', there the user will be prompted once for a file name for
530 each invocation of the saving commands."
531 :group 'gnus-article-saving
532 :type '(choice (item always)
533 (item :tag "never" nil)
534 (sexp :tag "once" :format "%t\n" :value t)))
536 (defcustom gnus-saved-headers gnus-visible-headers
537 "Headers to keep if `gnus-save-all-headers' is nil.
538 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
539 If that variable is nil, however, all headers that match this regexp
540 will be kept while the rest will be deleted before saving."
541 :group 'gnus-article-saving
544 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
545 "A function to save articles in your favourite format.
546 The function must be interactively callable (in other words, it must
547 be an Emacs command).
549 Gnus provides the following functions:
551 * gnus-summary-save-in-rmail (Rmail format)
552 * gnus-summary-save-in-mail (Unix mail format)
553 * gnus-summary-save-in-folder (MH folder)
554 * gnus-summary-save-in-file (article format)
555 * gnus-summary-save-body-in-file (article body)
556 * gnus-summary-save-in-vm (use VM's folder format)
557 * gnus-summary-write-to-file (article format -- overwrite)."
558 :group 'gnus-article-saving
559 :type '(radio (function-item gnus-summary-save-in-rmail)
560 (function-item gnus-summary-save-in-mail)
561 (function-item gnus-summary-save-in-folder)
562 (function-item gnus-summary-save-in-file)
563 (function-item gnus-summary-save-body-in-file)
564 (function-item gnus-summary-save-in-vm)
565 (function-item gnus-summary-write-to-file)))
567 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
568 "A function generating a file name to save articles in Rmail format.
569 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
570 :group 'gnus-article-saving
573 (defcustom gnus-mail-save-name 'gnus-plain-save-name
574 "A function generating a file name to save articles in Unix mail format.
575 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
576 :group 'gnus-article-saving
579 (defcustom gnus-folder-save-name 'gnus-folder-save-name
580 "A function generating a file name to save articles in MH folder.
581 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
582 :group 'gnus-article-saving
585 (defcustom gnus-file-save-name 'gnus-numeric-save-name
586 "A function generating a file name to save articles in article format.
587 The function is called with NEWSGROUP, HEADERS, and optional
589 :group 'gnus-article-saving
592 (defcustom gnus-split-methods
593 '((gnus-article-archive-name)
594 (gnus-article-nndoc-name))
595 "*Variable used to suggest where articles are to be saved.
596 For instance, if you would like to save articles related to Gnus in
597 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
598 you could set this variable to something like:
600 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
601 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
603 This variable is an alist where the key is the match and the
604 value is a list of possible files to save in if the match is
607 If the match is a string, it is used as a regexp match on the
608 article. If the match is a symbol, that symbol will be funcalled
609 from the buffer of the article to be saved with the newsgroup as
610 the parameter. If it is a list, it will be evaled in the same
613 If this form or function returns a string, this string will be
614 used as a possible file name; and if it returns a non-nil list,
615 that list will be used as possible file names."
616 :group 'gnus-article-saving
617 :type '(repeat (choice (list :value (fun) function)
618 (cons :value ("" "") regexp (repeat string))
621 (defcustom gnus-article-display-method-for-mime
622 'gnus-article-display-mime-message
623 "Function to display a MIME message.
624 The function is called from the article buffer."
625 :group 'gnus-article-mime
628 (defcustom gnus-article-display-method-for-traditional
629 'gnus-article-display-traditional-message
630 "*Function to display a traditional message.
631 The function is called from the article buffer."
632 :group 'gnus-article-mime
635 (defcustom gnus-page-delimiter "^\^L"
636 "*Regexp describing what to use as article page delimiters.
637 The default value is \"^\^L\", which is a form linefeed at the
638 beginning of a line."
640 :group 'gnus-article-various)
642 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
643 "*The format specification for the article mode line.
644 See `gnus-summary-mode-line-format' for a closer description.
646 The following additional specs are available:
648 %w The article washing status.
649 %m The number of MIME parts in the article."
651 :group 'gnus-article-various)
653 (defcustom gnus-article-mode-hook nil
654 "*A hook for Gnus article mode."
656 :group 'gnus-article-various)
658 (when (featurep 'xemacs)
659 ;; Extracted from gnus-xmas-define in order to preserve user settings
660 (when (fboundp 'turn-off-scroll-in-place)
661 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
662 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
663 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
665 (defcustom gnus-article-menu-hook nil
666 "*Hook run after the creation of the article mode menu."
668 :group 'gnus-article-various)
670 (defcustom gnus-article-prepare-hook nil
671 "*A hook called after an article has been prepared in the article buffer."
673 :group 'gnus-article-various)
675 (defcustom gnus-copy-article-ignored-headers nil
676 "List of headers to be removed when copying an article.
677 Each element is a regular expression."
678 :version "23.0" ;; No Gnus
679 :type '(repeat regexp)
680 :group 'gnus-article-various)
682 (make-obsolete-variable 'gnus-article-hide-pgp-hook
683 "This variable is obsolete in Gnus 5.10.")
685 (defcustom gnus-article-button-face 'bold
686 "Face used for highlighting buttons in the article buffer.
688 An article button is a piece of text that you can activate by pressing
689 `RET' or `mouse-2' above it."
691 :group 'gnus-article-buttons)
693 (defcustom gnus-article-mouse-face 'highlight
694 "Face used for mouse highlighting in the article buffer.
696 Article buttons will be displayed in this face when the cursor is
699 :group 'gnus-article-buttons)
701 (defcustom gnus-signature-face 'gnus-signature
702 "Face used for highlighting a signature in the article buffer.
703 Obsolete; use the face `gnus-signature' for customizations instead."
705 :group 'gnus-article-highlight
706 :group 'gnus-article-signature)
708 (defface gnus-signature
711 "Face used for highlighting a signature in the article buffer."
712 :group 'gnus-article-highlight
713 :group 'gnus-article-signature)
714 ;; backward-compatibility alias
715 (put 'gnus-signature-face 'face-alias 'gnus-signature)
717 (defface gnus-header-from
720 (:foreground "spring green"))
723 (:foreground "red3"))
726 "Face used for displaying from headers."
727 :group 'gnus-article-headers
728 :group 'gnus-article-highlight)
729 ;; backward-compatibility alias
730 (put 'gnus-header-from-face 'face-alias 'gnus-header-from)
732 (defface gnus-header-subject
735 (:foreground "SeaGreen3"))
738 (:foreground "red4"))
740 (:bold t :italic t)))
741 "Face used for displaying subject headers."
742 :group 'gnus-article-headers
743 :group 'gnus-article-highlight)
744 ;; backward-compatibility alias
745 (put 'gnus-header-subject-face 'face-alias 'gnus-header-subject)
747 (defface gnus-header-newsgroups
750 (:foreground "yellow" :italic t))
753 (:foreground "MidnightBlue" :italic t))
756 "Face used for displaying newsgroups headers.
757 In the default setup this face is only used for crossposted
759 :group 'gnus-article-headers
760 :group 'gnus-article-highlight)
761 ;; backward-compatibility alias
762 (put 'gnus-header-newsgroups-face 'face-alias 'gnus-header-newsgroups)
764 (defface gnus-header-name
767 (:foreground "SeaGreen"))
770 (:foreground "maroon"))
773 "Face used for displaying header names."
774 :group 'gnus-article-headers
775 :group 'gnus-article-highlight)
776 ;; backward-compatibility alias
777 (put 'gnus-header-name-face 'face-alias 'gnus-header-name)
779 (defface gnus-header-content
782 (:foreground "forest green" :italic t))
785 (:foreground "indianred4" :italic t))
788 "Face used for displaying header content."
789 :group 'gnus-article-headers
790 :group 'gnus-article-highlight)
791 ;; backward-compatibility alias
792 (put 'gnus-header-content-face 'face-alias 'gnus-header-content)
794 (defcustom gnus-header-face-alist
795 '(("From" nil gnus-header-from)
796 ("Subject" nil gnus-header-subject)
797 ("Newsgroups:.*," nil gnus-header-newsgroups)
798 ("" gnus-header-name gnus-header-content))
799 "*Controls highlighting of article headers.
801 An alist of the form (HEADER NAME CONTENT).
803 HEADER is a regular expression which should match the name of a
804 header and NAME and CONTENT are either face names or nil.
806 The name of each header field will be displayed using the face
807 specified by the first element in the list where HEADER matches
808 the header name and NAME is non-nil. Similarly, the content will
809 be displayed by the first non-nil matching CONTENT face."
810 :group 'gnus-article-headers
811 :group 'gnus-article-highlight
812 :type '(repeat (list (regexp :tag "Header")
814 (item :tag "skip" nil)
815 (face :value default))
816 (choice :tag "Content"
817 (item :tag "skip" nil)
818 (face :value default)))))
820 (defcustom gnus-article-decode-hook
821 '(article-decode-group-name article-decode-idna-rhs)
822 "*Hook run to decode charsets in articles."
823 :group 'gnus-article-headers
826 (defcustom gnus-display-mime-function 'gnus-display-mime
827 "Function to display MIME articles."
828 :group 'gnus-article-mime
831 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
832 "Function used to decode headers.")
834 (defvar gnus-article-dumbquotes-map
854 "Table for MS-to-Latin1 translation.")
856 (defcustom gnus-ignored-mime-types nil
857 "List of MIME types that should be ignored by Gnus."
859 :group 'gnus-article-mime
860 :type '(repeat regexp))
862 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
863 "List of MIME types that should not be given buttons when rendered inline.
864 See also `gnus-buttonized-mime-types' which may override this variable.
865 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
867 :group 'gnus-article-mime
868 :type '(repeat regexp))
870 (defcustom gnus-buttonized-mime-types nil
871 "List of MIME types that should be given buttons when rendered inline.
872 If set, this variable overrides `gnus-unbuttonized-mime-types'.
873 To see e.g. security buttons you could set this to
874 `(\"multipart/signed\")'.
875 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
877 :group 'gnus-article-mime
878 :type '(repeat regexp))
880 (defcustom gnus-inhibit-mime-unbuttonizing nil
881 "If non-nil, all MIME parts get buttons.
882 When nil (the default value), then some MIME parts do not get buttons,
883 as described by the variables `gnus-buttonized-mime-types' and
884 `gnus-unbuttonized-mime-types'."
886 :group 'gnus-article-mime
889 (defcustom gnus-body-boundary-delimiter "_"
890 "String used to delimit header and body.
891 This variable is used by `gnus-article-treat-body-boundary' which can
892 be controlled by `gnus-treat-body-boundary'."
894 :group 'gnus-article-various
895 :type '(choice (item :tag "None" :value nil)
898 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
900 "Defines the location of the faces database.
901 For information on obtaining this database of pretty pictures, please
902 see http://www.cs.indiana.edu/picons/ftp/index.html"
904 :type '(repeat directory)
905 :link '(url-link :tag "download"
906 "http://www.cs.indiana.edu/picons/ftp/index.html")
907 :link '(custom-manual "(gnus)Picons")
910 (defun gnus-picons-installed-p ()
911 "Say whether picons are installed on your machine."
912 (let ((installed nil))
913 (dolist (database gnus-picon-databases)
914 (when (file-exists-p database)
918 (defcustom gnus-article-mime-part-function nil
919 "Function called with a MIME handle as the argument.
920 This is meant for people who want to do something automatic based
921 on parts -- for instance, adding Vcard info to a database."
922 :group 'gnus-article-mime
925 (defcustom gnus-mime-multipart-functions nil
926 "An alist of MIME types to functions to display them."
928 :group 'gnus-article-mime
929 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
931 (defcustom gnus-article-date-lapsed-new-header nil
932 "Whether the X-Sent and Date headers can coexist.
933 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
934 either replace the old \"Date:\" header (if this variable is nil), or
935 be added below it (otherwise)."
937 :group 'gnus-article-headers
940 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
941 "Function called with a MIME handle as the argument.
942 This is meant for people who want to view first matched part.
943 For `undisplayed-alternative' (default), the first undisplayed
944 part or alternative part is used. For `undisplayed', the first
945 undisplayed part is used. For a function, the first part which
946 the function return t is used. For nil, the first part is
949 :group 'gnus-article-mime
951 (item :tag "first" :value nil)
952 (item :tag "undisplayed" :value undisplayed)
953 (item :tag "undisplayed or alternative"
954 :value undisplayed-alternative)
957 (defcustom gnus-mime-action-alist
958 '(("save to file" . gnus-mime-save-part)
959 ("save and strip" . gnus-mime-save-part-and-strip)
960 ("delete part" . gnus-mime-delete-part)
961 ("display as text" . gnus-mime-inline-part)
962 ("view the part" . gnus-mime-view-part)
963 ("pipe to command" . gnus-mime-pipe-part)
964 ("toggle display" . gnus-article-press-button)
965 ("toggle display" . gnus-article-view-part-as-charset)
966 ("view as type" . gnus-mime-view-part-as-type)
967 ("view internally" . gnus-mime-view-part-internally)
968 ("view externally" . gnus-mime-view-part-externally))
969 "An alist of actions that run on the MIME attachment."
970 :group 'gnus-article-mime
971 :type '(repeat (cons (string :tag "name")
975 ;;; The treatment variables
978 (defvar gnus-part-display-hook nil
979 "Hook called on parts that are to receive treatment.")
981 (defvar gnus-article-treat-custom
982 '(choice (const :tag "Off" nil)
984 (const :tag "Header" head)
985 (const :tag "Last" last)
986 (const :tag "Mime" mime)
987 (integer :tag "Less")
988 (repeat :tag "Groups" regexp)
989 (sexp :tag "Predicate")))
991 (defvar gnus-article-treat-head-custom
992 '(choice (const :tag "Off" nil)
993 (const :tag "Header" head)))
995 (defvar gnus-article-treat-types '("text/plain")
998 (defvar gnus-inhibit-treatment nil
999 "Whether to inhibit treatment.")
1001 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
1002 "Highlight the signature.
1003 Valid values are nil, t, `head', `last', an integer or a predicate.
1004 See Info node `(gnus)Customizing Articles'."
1005 :group 'gnus-article-treat
1006 :link '(custom-manual "(gnus)Customizing Articles")
1007 :type gnus-article-treat-custom)
1008 (put 'gnus-treat-highlight-signature 'highlight t)
1010 (defcustom gnus-treat-buttonize 100000
1012 Valid values are nil, t, `head', `last', an integer or a predicate.
1013 See Info node `(gnus)Customizing Articles'."
1014 :group 'gnus-article-treat
1015 :link '(custom-manual "(gnus)Customizing Articles")
1016 :type gnus-article-treat-custom)
1017 (put 'gnus-treat-buttonize 'highlight t)
1019 (defcustom gnus-treat-buttonize-head 'head
1020 "Add buttons to the head.
1021 Valid values are nil, t, `head', `last', an integer or a predicate.
1022 See Info node `(gnus)Customizing Articles' for details."
1023 :group 'gnus-article-treat
1024 :link '(custom-manual "(gnus)Customizing Articles")
1025 :type gnus-article-treat-head-custom)
1026 (put 'gnus-treat-buttonize-head 'highlight t)
1028 (defcustom gnus-treat-emphasize
1029 (and (or window-system
1033 Valid values are nil, t, `head', `last', an integer or a predicate.
1034 See Info node `(gnus)Customizing Articles' for details."
1035 :group 'gnus-article-treat
1036 :link '(custom-manual "(gnus)Customizing Articles")
1037 :type gnus-article-treat-custom)
1038 (put 'gnus-treat-emphasize 'highlight t)
1040 (defcustom gnus-treat-strip-cr nil
1041 "Remove carriage returns.
1042 Valid values are nil, t, `head', `last', an integer or a predicate.
1043 See Info node `(gnus)Customizing Articles' for details."
1045 :group 'gnus-article-treat
1046 :link '(custom-manual "(gnus)Customizing Articles")
1047 :type gnus-article-treat-custom)
1049 (defcustom gnus-treat-unsplit-urls nil
1050 "Remove newlines from within URLs.
1051 Valid values are nil, t, `head', `last', an integer or a predicate.
1052 See Info node `(gnus)Customizing Articles' for details."
1054 :group 'gnus-article-treat
1055 :link '(custom-manual "(gnus)Customizing Articles")
1056 :type gnus-article-treat-custom)
1058 (defcustom gnus-treat-leading-whitespace nil
1059 "Remove leading whitespace in headers.
1060 Valid values are nil, t, `head', `last', an integer or a predicate.
1061 See Info node `(gnus)Customizing Articles' for details."
1063 :group 'gnus-article-treat
1064 :link '(custom-manual "(gnus)Customizing Articles")
1065 :type gnus-article-treat-custom)
1067 (defcustom gnus-treat-hide-headers 'head
1069 Valid values are nil, t, `head', `last', an integer or a predicate.
1070 See Info node `(gnus)Customizing Articles' for details."
1071 :group 'gnus-article-treat
1072 :link '(custom-manual "(gnus)Customizing Articles")
1073 :type gnus-article-treat-head-custom)
1075 (defcustom gnus-treat-hide-boring-headers nil
1076 "Hide boring headers.
1077 Valid values are nil, t, `head', `last', an integer or a predicate.
1078 See Info node `(gnus)Customizing Articles' for details."
1079 :group 'gnus-article-treat
1080 :link '(custom-manual "(gnus)Customizing Articles")
1081 :type gnus-article-treat-head-custom)
1083 (defcustom gnus-treat-hide-signature nil
1084 "Hide the signature.
1085 Valid values are nil, t, `head', `last', an integer or a predicate.
1086 See Info node `(gnus)Customizing Articles' for details."
1087 :group 'gnus-article-treat
1088 :link '(custom-manual "(gnus)Customizing Articles")
1089 :type gnus-article-treat-custom)
1091 (defcustom gnus-treat-fill-article nil
1093 Valid values are nil, t, `head', `last', an integer or a predicate.
1094 See Info node `(gnus)Customizing Articles' for details."
1095 :group 'gnus-article-treat
1096 :link '(custom-manual "(gnus)Customizing Articles")
1097 :type gnus-article-treat-custom)
1099 (defcustom gnus-treat-hide-citation nil
1101 Valid values are nil, t, `head', `last', an integer or a predicate.
1102 See Info node `(gnus)Customizing Articles' for details."
1103 :group 'gnus-article-treat
1104 :link '(custom-manual "(gnus)Customizing Articles")
1105 :type gnus-article-treat-custom)
1107 (defcustom gnus-treat-hide-citation-maybe nil
1109 Valid values are nil, t, `head', `last', an integer or a predicate.
1110 See Info node `(gnus)Customizing Articles' for details."
1111 :group 'gnus-article-treat
1112 :link '(custom-manual "(gnus)Customizing Articles")
1113 :type gnus-article-treat-custom)
1115 (defcustom gnus-treat-strip-list-identifiers 'head
1116 "Strip list identifiers from `gnus-list-identifiers`.
1117 Valid values are nil, t, `head', `last', an integer or a predicate.
1118 See Info node `(gnus)Customizing Articles' for details."
1120 :group 'gnus-article-treat
1121 :link '(custom-manual "(gnus)Customizing Articles")
1122 :type gnus-article-treat-custom)
1124 (make-obsolete-variable 'gnus-treat-strip-pgp
1125 "This option is obsolete in Gnus 5.10.")
1127 (defcustom gnus-treat-strip-pem nil
1128 "Strip PEM signatures.
1129 Valid values are nil, t, `head', `last', an integer or a predicate.
1130 See Info node `(gnus)Customizing Articles' for details."
1131 :group 'gnus-article-treat
1132 :link '(custom-manual "(gnus)Customizing Articles")
1133 :type gnus-article-treat-custom)
1135 (defcustom gnus-treat-strip-banner t
1136 "Strip banners from articles.
1137 The banner to be stripped is specified in the `banner' group parameter.
1138 Valid values are nil, t, `head', `last', an integer or a predicate.
1139 See Info node `(gnus)Customizing Articles' for details."
1140 :group 'gnus-article-treat
1141 :link '(custom-manual "(gnus)Customizing Articles")
1142 :type gnus-article-treat-custom)
1144 (defcustom gnus-treat-highlight-headers 'head
1145 "Highlight the headers.
1146 Valid values are nil, t, `head', `last', an integer or a predicate.
1147 See Info node `(gnus)Customizing Articles' for details."
1148 :group 'gnus-article-treat
1149 :link '(custom-manual "(gnus)Customizing Articles")
1150 :type gnus-article-treat-head-custom)
1151 (put 'gnus-treat-highlight-headers 'highlight t)
1153 (defcustom gnus-treat-highlight-citation t
1154 "Highlight cited text.
1155 Valid values are nil, t, `head', `last', an integer or a predicate.
1156 See Info node `(gnus)Customizing Articles' for details."
1157 :group 'gnus-article-treat
1158 :link '(custom-manual "(gnus)Customizing Articles")
1159 :type gnus-article-treat-custom)
1160 (put 'gnus-treat-highlight-citation 'highlight t)
1162 (defcustom gnus-treat-date-ut nil
1163 "Display the Date in UT (GMT).
1164 Valid values are nil, t, `head', `last', an integer or a predicate.
1165 See Info node `(gnus)Customizing Articles' for details."
1166 :group 'gnus-article-treat
1167 :link '(custom-manual "(gnus)Customizing Articles")
1168 :type gnus-article-treat-head-custom)
1170 (defcustom gnus-treat-date-local nil
1171 "Display the Date in the local timezone.
1172 Valid values are nil, t, `head', `last', an integer or a predicate.
1173 See Info node `(gnus)Customizing Articles' for details."
1174 :group 'gnus-article-treat
1175 :link '(custom-manual "(gnus)Customizing Articles")
1176 :type gnus-article-treat-head-custom)
1178 (defcustom gnus-treat-date-english nil
1179 "Display the Date in a format that can be read aloud in English.
1180 Valid values are nil, t, `head', `last', an integer or a predicate.
1181 See Info node `(gnus)Customizing Articles' for details."
1183 :group 'gnus-article-treat
1184 :link '(custom-manual "(gnus)Customizing Articles")
1185 :type gnus-article-treat-head-custom)
1187 (defcustom gnus-treat-date-lapsed nil
1188 "Display the Date header in a way that says how much time has elapsed.
1189 Valid values are nil, t, `head', `last', an integer or a predicate.
1190 See Info node `(gnus)Customizing Articles' for details."
1191 :group 'gnus-article-treat
1192 :link '(custom-manual "(gnus)Customizing Articles")
1193 :type gnus-article-treat-head-custom)
1195 (defcustom gnus-treat-date-original nil
1196 "Display the date in the original timezone.
1197 Valid values are nil, t, `head', `last', an integer or a predicate.
1198 See Info node `(gnus)Customizing Articles' for details."
1199 :group 'gnus-article-treat
1200 :link '(custom-manual "(gnus)Customizing Articles")
1201 :type gnus-article-treat-head-custom)
1203 (defcustom gnus-treat-date-iso8601 nil
1204 "Display the date in the ISO8601 format.
1205 Valid values are nil, t, `head', `last', an integer or a predicate.
1206 See Info node `(gnus)Customizing Articles' for details."
1208 :group 'gnus-article-treat
1209 :link '(custom-manual "(gnus)Customizing Articles")
1210 :type gnus-article-treat-head-custom)
1212 (defcustom gnus-treat-date-user-defined nil
1213 "Display the date in a user-defined format.
1214 The format is defined by the `gnus-article-time-format' variable.
1215 Valid values are nil, t, `head', `last', an integer or a predicate.
1216 See Info node `(gnus)Customizing Articles' for details."
1217 :group 'gnus-article-treat
1218 :link '(custom-manual "(gnus)Customizing Articles")
1219 :type gnus-article-treat-head-custom)
1221 (defcustom gnus-treat-strip-headers-in-body t
1222 "Strip the X-No-Archive header line from the beginning of the body.
1223 Valid values are nil, t, `head', `last', an integer or a predicate.
1224 See Info node `(gnus)Customizing Articles' for details."
1226 :group 'gnus-article-treat
1227 :link '(custom-manual "(gnus)Customizing Articles")
1228 :type gnus-article-treat-custom)
1230 (defcustom gnus-treat-strip-trailing-blank-lines nil
1231 "Strip trailing blank lines.
1232 Valid values are nil, t, `head', `last', an integer or a predicate.
1233 See Info node `(gnus)Customizing Articles' for details."
1234 :group 'gnus-article-treat
1235 :link '(custom-manual "(gnus)Customizing Articles")
1236 :type gnus-article-treat-custom)
1238 (defcustom gnus-treat-strip-leading-blank-lines nil
1239 "Strip leading blank lines.
1240 Valid values are nil, t, `head', `last', an integer or a predicate.
1241 See Info node `(gnus)Customizing Articles' for details."
1242 :group 'gnus-article-treat
1243 :link '(custom-manual "(gnus)Customizing Articles")
1244 :type gnus-article-treat-custom)
1246 (defcustom gnus-treat-strip-multiple-blank-lines nil
1247 "Strip multiple blank lines.
1248 Valid values are nil, t, `head', `last', an integer or a predicate.
1249 See Info node `(gnus)Customizing Articles' for details."
1250 :group 'gnus-article-treat
1251 :link '(custom-manual "(gnus)Customizing Articles")
1252 :type gnus-article-treat-custom)
1254 (defcustom gnus-treat-unfold-headers 'head
1255 "Unfold folded header lines.
1256 Valid values are nil, t, `head', `last', an integer or a predicate.
1257 See Info node `(gnus)Customizing Articles' for details."
1259 :group 'gnus-article-treat
1260 :link '(custom-manual "(gnus)Customizing Articles")
1261 :type gnus-article-treat-custom)
1263 (defcustom gnus-treat-fold-headers nil
1265 Valid values are nil, t, `head', `last', an integer or a predicate.
1266 See Info node `(gnus)Customizing Articles' for details."
1268 :group 'gnus-article-treat
1269 :link '(custom-manual "(gnus)Customizing Articles")
1270 :type gnus-article-treat-custom)
1272 (defcustom gnus-treat-fold-newsgroups 'head
1273 "Fold the Newsgroups and Followup-To headers.
1274 Valid values are nil, t, `head', `last', an integer or a predicate.
1275 See Info node `(gnus)Customizing Articles' for details."
1277 :group 'gnus-article-treat
1278 :link '(custom-manual "(gnus)Customizing Articles")
1279 :type gnus-article-treat-custom)
1281 (defcustom gnus-treat-overstrike t
1282 "Treat overstrike highlighting.
1283 Valid values are nil, t, `head', `last', an integer or a predicate.
1284 See Info node `(gnus)Customizing Articles' for details."
1285 :group 'gnus-article-treat
1286 :link '(custom-manual "(gnus)Customizing Articles")
1287 :type gnus-article-treat-custom)
1288 (put 'gnus-treat-overstrike 'highlight t)
1290 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1291 "Treat ANSI SGR control sequences.
1292 Valid values are nil, t, `head', `last', an integer or a predicate.
1293 See Info node `(gnus)Customizing Articles' for details."
1294 :group 'gnus-article-treat
1295 :link '(custom-manual "(gnus)Customizing Articles")
1296 :type gnus-article-treat-custom)
1298 (make-obsolete-variable 'gnus-treat-display-xface
1299 'gnus-treat-display-x-face)
1301 (defcustom gnus-treat-display-x-face
1302 (and (not noninteractive)
1303 (or (and (fboundp 'image-type-available-p)
1304 (image-type-available-p 'xbm)
1305 (string-match "^0x" (shell-command-to-string "uncompface"))
1306 (executable-find "icontopbm"))
1307 (and (featurep 'xemacs)
1310 "Display X-Face headers.
1311 Valid values are nil, t, `head', `last', an integer or a predicate.
1312 See Info node `(gnus)Customizing Articles' and Info node
1313 `(gnus)X-Face' for details."
1314 :group 'gnus-article-treat
1316 :link '(custom-manual "(gnus)Customizing Articles")
1317 :link '(custom-manual "(gnus)X-Face")
1318 :type gnus-article-treat-head-custom
1319 :set (lambda (symbol value)
1322 (cond ((or (boundp symbol) (get symbol 'saved-value))
1324 ((boundp 'gnus-treat-display-xface)
1326 ** gnus-treat-display-xface is an obsolete variable;\
1327 use gnus-treat-display-x-face instead")
1328 (default-value 'gnus-treat-display-xface))
1329 ((get 'gnus-treat-display-xface 'saved-value)
1331 ** gnus-treat-display-xface is an obsolete variable;\
1332 use gnus-treat-display-x-face instead")
1333 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1336 (put 'gnus-treat-display-x-face 'highlight t)
1338 (defcustom gnus-article-should-use-smiley-mule
1339 (not (or (featurep 'xemacs)
1340 (gnus-image-type-available-p 'xpm)
1341 (gnus-image-type-available-p 'pbm)))
1342 "Non-nil means use `smiley-mule' to show smileys rather than `smiley'.
1343 `smiley-mule' is boundled in BITMAP-MULE package. You can set it to t
1344 even if your Emacs supports images. It has no effect on XEmacs."
1345 :group 'gnus-article-various
1347 :get (lambda (symbol)
1348 (and (not noninteractive)
1349 (default-value symbol)
1350 (not (featurep 'xemacs))
1351 (module-installed-p 'smiley-mule)
1353 :set (lambda (symbol value)
1354 (set-default symbol (and (not noninteractive)
1356 (not (featurep 'xemacs))
1357 (module-installed-p 'smiley-mule)
1360 (defvar gnus-article-smiley-mule-loaded-p nil
1361 "Internal variable used to say whether `smiley-mule' is loaded (whether
1362 smiley functions are not overridden by `smiley').")
1364 (defcustom gnus-treat-display-face
1365 (and (not noninteractive)
1366 (or (and (fboundp 'image-type-available-p)
1367 (image-type-available-p 'png))
1368 (and (featurep 'xemacs)
1371 "Display Face headers.
1372 Valid values are nil, t, `head', `last', an integer or a predicate.
1373 See Info node `(gnus)Customizing Articles' and Info node
1374 `(gnus)X-Face' for details."
1375 :group 'gnus-article-treat
1377 :link '(custom-manual "(gnus)Customizing Articles")
1378 :link '(custom-manual "(gnus)X-Face")
1379 :type gnus-article-treat-head-custom)
1380 (put 'gnus-treat-display-face 'highlight t)
1382 (defcustom gnus-treat-display-smileys
1383 (if (and (not noninteractive)
1384 (or (and (featurep 'xemacs)
1386 (gnus-image-type-available-p 'xpm)
1387 (gnus-image-type-available-p 'pbm)
1388 (and (not (featurep 'xemacs))
1390 (module-installed-p 'smiley-mule))))
1394 Valid values are nil, t, `head', `last', an integer or a predicate.
1395 See Info node `(gnus)Customizing Articles' and Info node
1396 `(gnus)Smileys' for details."
1397 :group 'gnus-article-treat
1399 :link '(custom-manual "(gnus)Customizing Articles")
1400 :link '(custom-manual "(gnus)Smileys")
1401 :type gnus-article-treat-custom)
1402 (put 'gnus-treat-display-smileys 'highlight t)
1404 (defcustom gnus-treat-from-picon
1405 (if (and (gnus-image-type-available-p 'xpm)
1406 (gnus-picons-installed-p))
1408 "Display picons in the From header.
1409 Valid values are nil, t, `head', `last', an integer or a predicate.
1410 See Info node `(gnus)Customizing Articles' and Info node
1411 `(gnus)Picons' for details."
1413 :group 'gnus-article-treat
1415 :link '(custom-manual "(gnus)Customizing Articles")
1416 :link '(custom-manual "(gnus)Picons")
1417 :type gnus-article-treat-head-custom)
1418 (put 'gnus-treat-from-picon 'highlight t)
1420 (defcustom gnus-treat-mail-picon
1421 (if (and (gnus-image-type-available-p 'xpm)
1422 (gnus-picons-installed-p))
1424 "Display picons in To and Cc headers.
1425 Valid values are nil, t, `head', `last', an integer or a predicate.
1426 See Info node `(gnus)Customizing Articles' and Info node
1427 `(gnus)Picons' for details."
1429 :group 'gnus-article-treat
1431 :link '(custom-manual "(gnus)Customizing Articles")
1432 :link '(custom-manual "(gnus)Picons")
1433 :type gnus-article-treat-head-custom)
1434 (put 'gnus-treat-mail-picon 'highlight t)
1436 (defcustom gnus-treat-newsgroups-picon
1437 (if (and (gnus-image-type-available-p 'xpm)
1438 (gnus-picons-installed-p))
1440 "Display picons in the Newsgroups and Followup-To headers.
1441 Valid values are nil, t, `head', `last', an integer or a predicate.
1442 See Info node `(gnus)Customizing Articles' and Info node
1443 `(gnus)Picons' for details."
1445 :group 'gnus-article-treat
1447 :link '(custom-manual "(gnus)Customizing Articles")
1448 :link '(custom-manual "(gnus)Picons")
1449 :type gnus-article-treat-head-custom)
1450 (put 'gnus-treat-newsgroups-picon 'highlight t)
1452 (defcustom gnus-treat-body-boundary
1453 (if (and (eq window-system 'x)
1454 (or gnus-treat-newsgroups-picon
1455 gnus-treat-mail-picon
1456 gnus-treat-from-picon))
1458 "Draw a boundary at the end of the headers.
1459 Valid values are nil and `head'.
1460 See Info node `(gnus)Customizing Articles' for details."
1462 :group 'gnus-article-treat
1463 :link '(custom-manual "(gnus)Customizing Articles")
1464 :type gnus-article-treat-head-custom)
1466 (defcustom gnus-treat-capitalize-sentences nil
1467 "Capitalize sentence-starting words.
1468 Valid values are nil, t, `head', `last', an integer or a predicate.
1469 See Info node `(gnus)Customizing Articles' for details."
1471 :group 'gnus-article-treat
1472 :link '(custom-manual "(gnus)Customizing Articles")
1473 :type gnus-article-treat-custom)
1475 (defcustom gnus-treat-wash-html nil
1477 Valid values are nil, t, `head', `last', an integer or a predicate.
1478 See Info node `(gnus)Customizing Articles' for details."
1480 :group 'gnus-article-treat
1481 :link '(custom-manual "(gnus)Customizing Articles")
1482 :type gnus-article-treat-custom)
1484 (defcustom gnus-treat-fill-long-lines nil
1486 Valid values are nil, t, `head', `last', an integer or a predicate.
1487 See Info node `(gnus)Customizing Articles' for details."
1488 :group 'gnus-article-treat
1489 :link '(custom-manual "(gnus)Customizing Articles")
1490 :type gnus-article-treat-custom)
1492 (defcustom gnus-treat-play-sounds nil
1494 Valid values are nil, t, `head', `last', an integer or a predicate.
1495 See Info node `(gnus)Customizing Articles' for details."
1497 :group 'gnus-article-treat
1498 :link '(custom-manual "(gnus)Customizing Articles")
1499 :type gnus-article-treat-custom)
1501 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
1502 "Decode an article as `default-mime-charset'. For instance, if you want to
1503 attempt to decode an article even if the value of `gnus-show-mime' is nil,
1504 you could set this variable to something like: nil for don't decode, t for
1505 decode the body, '(or header t) for the whole article, etc."
1506 :group 'gnus-article-treat
1507 :type '(radio (const :tag "Off" nil)
1508 (const :tag "Decode body" t)
1509 (const :tag "Decode all" (or head t))))
1511 (defcustom gnus-treat-translate nil
1512 "Translate articles from one language to another.
1513 Valid values are nil, t, `head', `last', an integer or a predicate.
1514 See Info node `(gnus)Customizing Articles' for details."
1516 :group 'gnus-article-treat
1517 :link '(custom-manual "(gnus)Customizing Articles")
1518 :type gnus-article-treat-custom)
1520 (defcustom gnus-treat-x-pgp-sig nil
1522 To automatically treat X-PGP-Sig, set it to head.
1523 Valid values are nil, t, `head', `last', an integer or a predicate.
1524 See Info node `(gnus)Customizing Articles' for details."
1526 :group 'gnus-article-treat
1527 :group 'mime-security
1528 :type gnus-article-treat-custom)
1530 (defcustom gnus-treat-monafy nil
1531 "Display body part with mona font.
1532 Valid values are nil, t, `head', `last', an integer or a predicate.
1533 See Info node `(gnus)Customizing Articles' for details."
1534 :group 'gnus-article-treat
1535 :group 'mime-security
1536 :link '(custom-manual "(gnus)Customizing Articles")
1537 :type gnus-article-treat-custom)
1539 (defvar gnus-article-encrypt-protocol-alist
1540 '(("PGP" . mml2015-self-encrypt)))
1542 ;; Set to nil if more than one protocol added to
1543 ;; gnus-article-encrypt-protocol-alist.
1544 (defcustom gnus-article-encrypt-protocol "PGP"
1545 "The protocol used for encrypt articles.
1546 It is a string, such as \"PGP\". If nil, ask user."
1549 :group 'mime-security)
1551 (defvar gnus-article-wash-function nil
1552 "Function used for converting HTML into text.")
1554 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1555 (mm-coding-system-p 'utf-8)
1556 (executable-find idna-program))
1557 "Whether IDNA decoding of headers is used when viewing messages.
1558 This requires GNU Libidn, and by default only enabled if it is found."
1560 :group 'gnus-article-headers
1563 (defcustom gnus-article-over-scroll nil
1564 "If non-nil, allow scrolling the article buffer even when there no more text."
1566 :group 'gnus-article
1569 ;;; Internal variables
1571 (defvar gnus-english-month-names
1572 '("January" "February" "March" "April" "May" "June" "July" "August"
1573 "September" "October" "November" "December"))
1575 (defvar gnus-button-regexp nil)
1576 (defvar gnus-button-marker-list nil)
1577 ;; Regexp matching any of the regexps from `gnus-button-alist'.
1579 (defvar gnus-button-last nil)
1580 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
1582 (defvar article-goto-body-goes-to-point-min-p nil)
1583 (defvar gnus-article-wash-types nil)
1584 (defvar gnus-article-emphasis-alist nil)
1585 (defvar gnus-article-image-alist nil)
1587 (defvar gnus-article-mime-handle-alist-1 nil)
1588 (defvar gnus-treatment-function-alist
1589 '((gnus-treat-decode-article-as-default-mime-charset
1590 gnus-article-decode-article-as-default-mime-charset)
1591 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1592 (gnus-treat-monafy gnus-article-monafy)
1593 (gnus-treat-strip-banner gnus-article-strip-banner)
1594 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1595 (gnus-treat-buttonize gnus-article-add-buttons)
1596 (gnus-treat-fill-article gnus-article-fill-cited-article)
1597 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1598 (gnus-treat-strip-cr gnus-article-remove-cr)
1599 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1600 (gnus-treat-date-ut gnus-article-date-ut)
1601 (gnus-treat-date-local gnus-article-date-local)
1602 (gnus-treat-date-english gnus-article-date-english)
1603 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1604 (gnus-treat-date-original gnus-article-date-original)
1605 (gnus-treat-date-user-defined gnus-article-date-user)
1606 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1607 (gnus-treat-display-face gnus-article-display-face)
1608 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1609 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1610 (gnus-treat-hide-signature gnus-article-hide-signature)
1611 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1612 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1613 (gnus-treat-strip-pem gnus-article-hide-pem)
1614 (gnus-treat-from-picon gnus-treat-from-picon)
1615 (gnus-treat-mail-picon gnus-treat-mail-picon)
1616 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1617 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1618 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1619 (gnus-treat-strip-trailing-blank-lines
1620 gnus-article-remove-trailing-blank-lines)
1621 (gnus-treat-strip-leading-blank-lines
1622 gnus-article-strip-leading-blank-lines)
1623 (gnus-treat-strip-multiple-blank-lines
1624 gnus-article-strip-multiple-blank-lines)
1625 (gnus-treat-overstrike gnus-article-treat-overstrike)
1626 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1627 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1628 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1629 ;; Displaying X-Face should be done after unfolding headers
1630 ;; to protect bitmap lines.
1631 (gnus-treat-display-x-face gnus-article-display-x-face)
1632 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1633 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1634 (gnus-treat-display-smileys gnus-treat-smiley)
1635 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1636 (gnus-treat-wash-html gnus-article-wash-html)
1637 (gnus-treat-emphasize gnus-article-emphasize)
1638 (gnus-treat-hide-citation gnus-article-hide-citation)
1639 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1640 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1641 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1642 (gnus-treat-play-sounds gnus-earcon-display)))
1644 (defvar gnus-article-mime-handle-alist nil)
1645 (defvar article-lapsed-timer nil)
1646 (defvar gnus-article-current-summary nil)
1648 (defvar gnus-article-mode-syntax-table
1649 (let ((table (copy-syntax-table text-mode-syntax-table)))
1650 ;; This causes the citation match run O(2^n).
1651 ;; (modify-syntax-entry ?- "w" table)
1652 (modify-syntax-entry ?> ")<" table)
1653 (modify-syntax-entry ?< "(>" table)
1654 ;; make M-. in article buffers work for `foo' strings
1655 (modify-syntax-entry ?' " " table)
1656 (modify-syntax-entry ?` " " table)
1658 "Syntax table used in article mode buffers.
1659 Initialized from `text-mode-syntax-table.")
1661 (defvar gnus-save-article-buffer nil)
1663 (defvar gnus-article-mode-line-format-alist
1664 (nconc '((?w (gnus-article-wash-status) ?s)
1665 (?m (gnus-article-mime-part-status) ?s))
1666 gnus-summary-mode-line-format-alist))
1668 (defvar gnus-number-of-articles-to-be-saved nil)
1670 (defvar gnus-inhibit-hiding nil)
1672 (defvar gnus-article-edit-mode nil)
1674 ;;; Macros for dealing with the article buffer.
1676 (defmacro gnus-with-article-headers (&rest forms)
1678 (set-buffer gnus-article-buffer)
1680 (let ((inhibit-read-only t)
1681 (inhibit-point-motion-hooks t)
1682 (case-fold-search t))
1683 (article-narrow-to-head)
1686 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1687 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1689 (defmacro gnus-with-article-buffer (&rest forms)
1691 (set-buffer gnus-article-buffer)
1692 (let ((inhibit-read-only t))
1695 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1696 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1698 (defun gnus-article-goto-header (header)
1699 "Go to HEADER, which is a regular expression."
1700 (re-search-forward (concat "^\\(" header "\\):") nil t))
1702 (defsubst gnus-article-hide-text (b e props)
1703 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1704 (gnus-add-text-properties-when 'article-type nil b e props)
1705 (when (memq 'intangible props)
1707 (max (1- b) (point-min))
1708 b 'intangible (cddr (memq 'intangible props)))))
1710 (defsubst gnus-article-unhide-text (b e)
1711 "Remove hidden text properties from region between B and E."
1712 (remove-text-properties b e gnus-hidden-properties)
1713 (when (memq 'intangible gnus-hidden-properties)
1714 (put-text-property (max (1- b) (point-min))
1715 b 'intangible nil)))
1717 (defun gnus-article-hide-text-type (b e type)
1718 "Hide text of TYPE between B and E."
1719 (gnus-add-wash-type type)
1720 (gnus-article-hide-text
1721 b e (cons 'article-type (cons type gnus-hidden-properties))))
1723 (defun gnus-article-unhide-text-type (b e type)
1724 "Unhide text of TYPE between B and E."
1725 (gnus-delete-wash-type type)
1726 (remove-text-properties
1727 b e (cons 'article-type (cons type gnus-hidden-properties)))
1728 (when (memq 'intangible gnus-hidden-properties)
1729 (put-text-property (max (1- b) (point-min))
1730 b 'intangible nil)))
1732 (defun gnus-article-hide-text-of-type (type)
1733 "Hide text of TYPE in the current buffer."
1735 (let ((b (point-min))
1737 (while (setq b (text-property-any b e 'article-type type))
1738 (add-text-properties b (incf b) gnus-hidden-properties)))))
1740 (defun gnus-article-delete-text-of-type (type)
1741 "Delete text of TYPE in the current buffer."
1743 (let ((b (point-min)))
1744 (while (setq b (text-property-any b (point-max) 'article-type type))
1746 b (or (text-property-not-all b (point-max) 'article-type type)
1749 (defun gnus-article-delete-invisible-text ()
1750 "Delete all invisible text in the current buffer."
1752 (let ((b (point-min)))
1753 (while (setq b (text-property-any b (point-max) 'invisible t))
1755 b (or (text-property-not-all b (point-max) 'invisible t)
1758 (defun gnus-article-text-type-exists-p (type)
1759 "Say whether any text of type TYPE exists in the buffer."
1760 (text-property-any (point-min) (point-max) 'article-type type))
1762 (defsubst gnus-article-header-rank ()
1763 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1764 (let ((list gnus-sorted-header-list)
1767 (if (looking-at (car list))
1769 (setq list (cdr list))
1773 (defun article-hide-headers (&optional arg delete)
1774 "Hide unwanted headers and possibly sort them as well."
1775 (interactive (gnus-article-hidden-arg))
1776 ;; Lars said that this function might be inhibited.
1777 (if (gnus-article-check-hidden-text 'headers arg)
1779 ;; Show boring headers as well.
1780 (gnus-article-show-hidden-text 'boring-headers)
1781 (when (eq 1 (point-min))
1782 (set-window-start (get-buffer-window (current-buffer)) 1)))
1783 (unless gnus-inhibit-hiding
1784 (let ((inhibit-read-only t)
1785 (case-fold-search t)
1786 (max (1+ (length gnus-sorted-header-list)))
1787 (inhibit-point-motion-hooks t)
1788 (cur (current-buffer))
1789 ignored visible beg)
1791 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1792 ;; group parameters, so we should go to the summary buffer.
1795 (progn (set-buffer gnus-summary-buffer) t)
1797 (setq ignored (when (not gnus-visible-headers)
1798 (cond ((stringp gnus-ignored-headers)
1799 gnus-ignored-headers)
1800 ((listp gnus-ignored-headers)
1801 (mapconcat 'identity
1802 gnus-ignored-headers
1804 visible (cond ((stringp gnus-visible-headers)
1805 gnus-visible-headers)
1806 ((and gnus-visible-headers
1807 (listp gnus-visible-headers))
1808 (mapconcat 'identity
1809 gnus-visible-headers
1813 ;; First we narrow to just the headers.
1814 (article-narrow-to-head)
1815 ;; Hide any "From " lines at the beginning of (mail) articles.
1816 (while (looking-at "From ")
1820 (delete-region (point-min) (point))
1821 (gnus-article-hide-text (point-min) (point)
1822 (nconc (list 'article-type 'headers)
1823 gnus-hidden-properties))))
1824 ;; Then treat the rest of the header lines.
1825 ;; Then we use the two regular expressions
1826 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1827 ;; select which header lines is to remain visible in the
1829 (while (re-search-forward "^[^ \t:]*:" nil t)
1831 ;; Mark the rank of the header.
1833 (point) (1+ (point)) 'message-rank
1834 (if (or (and visible (looking-at visible))
1836 (not (looking-at ignored))))
1837 (gnus-article-header-rank)
1840 (message-sort-headers-1)
1841 (when (setq beg (text-property-any
1842 (point-min) (point-max) 'message-rank (+ 2 max)))
1843 ;; We delete or make invisible the unwanted headers.
1844 (gnus-add-wash-type 'headers)
1847 (add-text-properties
1848 (point-min) (+ 5 (point-min))
1849 '(article-type headers dummy-invisible t))
1850 (delete-region beg (point-max)))
1851 (gnus-article-hide-text-type beg (point-max) 'headers)))))))))
1853 (defun article-hide-boring-headers (&optional arg)
1854 "Toggle hiding of headers that aren't very interesting.
1855 If given a negative prefix, always show; if given a positive prefix,
1857 (interactive (gnus-article-hidden-arg))
1858 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1859 (not gnus-show-all-headers))
1862 (let ((inhibit-read-only t)
1863 (inhibit-point-motion-hooks t))
1864 (article-narrow-to-head)
1865 (dolist (elem gnus-boring-article-headers)
1866 (goto-char (point-min))
1868 ;; Hide empty headers.
1870 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1872 (gnus-article-hide-text-type
1876 (if (re-search-forward "^[^ \t]" nil t)
1880 ;; Hide boring Newsgroups header.
1881 ((eq elem 'newsgroups)
1882 (when (gnus-string-equal
1883 (gnus-fetch-field "newsgroups")
1884 (gnus-group-real-name
1885 (if (boundp 'gnus-newsgroup-name)
1888 (gnus-article-hide-header "newsgroups")))
1889 ((eq elem 'to-address)
1890 (let ((to (message-fetch-field "to"))
1892 (gnus-parameter-to-address
1893 (if (boundp 'gnus-newsgroup-name)
1894 gnus-newsgroup-name ""))))
1895 (when (and to to-address
1898 ;; only one address in To
1899 (nth 1 (mail-extract-address-components to))
1901 (gnus-article-hide-header "to"))))
1903 (let ((to (message-fetch-field "to"))
1905 (gnus-parameter-to-list
1906 (if (boundp 'gnus-newsgroup-name)
1907 gnus-newsgroup-name ""))))
1908 (when (and to to-list
1911 ;; only one address in To
1912 (nth 1 (mail-extract-address-components to))
1914 (gnus-article-hide-header "to"))))
1916 (let ((cc (message-fetch-field "cc"))
1918 (gnus-parameter-to-list
1919 (if (boundp 'gnus-newsgroup-name)
1920 gnus-newsgroup-name ""))))
1921 (when (and cc to-list
1924 ;; only one address in CC
1925 (nth 1 (mail-extract-address-components cc))
1927 (gnus-article-hide-header "cc"))))
1928 ((eq elem 'followup-to)
1929 (when (gnus-string-equal
1930 (message-fetch-field "followup-to")
1931 (message-fetch-field "newsgroups"))
1932 (gnus-article-hide-header "followup-to")))
1933 ((eq elem 'reply-to)
1934 (if (gnus-group-find-parameter
1935 gnus-newsgroup-name 'broken-reply-to)
1936 (gnus-article-hide-header "reply-to")
1937 (let ((from (message-fetch-field "from"))
1938 (reply-to (message-fetch-field "reply-to")))
1945 (lambda (x) (downcase (cadr x)))
1946 (mail-extract-address-components from t))
1949 (lambda (x) (downcase (cadr x)))
1950 (mail-extract-address-components reply-to t))
1952 (gnus-article-hide-header "reply-to")))))
1954 (let ((date (message-fetch-field "date")))
1956 (< (days-between (current-time-string) date)
1958 (gnus-article-hide-header "date"))))
1960 (let ((to (message-fetch-field "to"))
1961 (cc (message-fetch-field "cc")))
1962 (when (> (length to) 1024)
1963 (gnus-article-hide-header "to"))
1964 (when (> (length cc) 1024)
1965 (gnus-article-hide-header "cc"))))
1969 (goto-char (point-min))
1970 (while (re-search-forward "^to:" nil t)
1971 (setq to-count (1+ to-count)))
1972 (when (> to-count 1)
1973 (while (> to-count 0)
1974 (goto-char (point-min))
1976 (re-search-forward "^to:" nil nil to-count)
1978 (narrow-to-region (point) (point-max))
1979 (gnus-article-hide-header "to"))
1980 (setq to-count (1- to-count))))
1981 (goto-char (point-min))
1982 (while (re-search-forward "^cc:" nil t)
1983 (setq cc-count (1+ cc-count)))
1984 (when (> cc-count 1)
1985 (while (> cc-count 0)
1986 (goto-char (point-min))
1988 (re-search-forward "^cc:" nil nil cc-count)
1990 (narrow-to-region (point) (point-max))
1991 (gnus-article-hide-header "cc"))
1992 (setq cc-count (1- cc-count)))))))))))))
1994 (defun gnus-article-hide-header (header)
1996 (goto-char (point-min))
1997 (when (re-search-forward (concat "^" header ":") nil t)
1998 (gnus-article-hide-text-type
2002 (if (re-search-forward "^[^ \t]" nil t)
2007 (defvar gnus-article-normalized-header-length 40
2008 "Length of normalized headers.")
2010 (defun article-normalize-headers ()
2011 "Make all header lines 40 characters long."
2013 (let ((inhibit-read-only t)
2017 (article-narrow-to-head)
2020 ((< (setq column (- (point-at-eol) (point)))
2021 gnus-article-normalized-header-length)
2023 (insert (make-string
2024 (- gnus-article-normalized-header-length column)
2026 ((> column gnus-article-normalized-header-length)
2027 (gnus-put-text-property
2029 (forward-char gnus-article-normalized-header-length)
2036 (forward-line 1))))))
2038 (defun article-treat-dumbquotes ()
2039 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
2040 Note that this function guesses whether a character is a sm*rtq**t* or
2041 not, so it should only be used interactively.
2043 Sm*rtq**t*s are M****s***'s unilateral extension to the
2044 iso-8859-1 character map in an attempt to provide more quoting
2045 characters. If you see something like \\222 or \\264 where
2046 you're expecting some kind of apostrophe or quotation mark, then
2049 (article-translate-strings gnus-article-dumbquotes-map))
2051 (defun article-translate-characters (from to)
2052 "Translate all characters in the body of the article according to FROM and TO.
2053 FROM is a string of characters to translate from; to is a string of
2054 characters to translate to."
2056 (when (article-goto-body)
2057 (let ((inhibit-read-only t)
2058 (x (make-string 225 ?x))
2060 (while (< (incf i) (length x))
2063 (while (< i (length from))
2064 (aset x (aref from i) (aref to i))
2066 (translate-region (point) (point-max) x)))))
2068 (defun article-translate-strings (map)
2069 "Translate all string in the body of the article according to MAP.
2070 MAP is an alist where the elements are on the form (\"from\" \"to\")."
2072 (when (article-goto-body)
2073 (let ((inhibit-read-only t))
2076 (while (search-forward (car elem) nil t)
2077 (replace-match (cadr elem)))))))))
2079 (defun article-treat-overstrike ()
2080 "Translate overstrikes into bold text."
2083 (when (article-goto-body)
2084 (let ((inhibit-read-only t))
2085 (while (search-forward "\b" nil t)
2086 (let ((next (char-after))
2090 previous (char-after))
2094 ;; We do the boldification/underlining by hiding the
2095 ;; overstrikes and putting the proper text property
2099 (gnus-article-hide-text-type start (point) 'overstrike)
2100 (put-text-property (point) end 'face 'bold))
2102 (gnus-article-hide-text-type
2103 (1- (point)) (1+ (point)) 'overstrike)
2105 start (1- (point)) 'face 'underline))
2107 (gnus-article-hide-text-type start (point) 'overstrike)
2109 (point) end 'face 'underline)))))))))
2111 (defun article-treat-ansi-sequences ()
2112 "Translate ANSI SGR control sequences into overlays or extents."
2115 (when (article-goto-body)
2116 (let ((inhibit-read-only t))
2117 (ansi-color-apply-on-region (point) (point-max))))))
2119 (defun gnus-article-treat-unfold-headers ()
2120 "Unfold folded message headers.
2121 Only the headers that fit into the current window width will be
2124 (gnus-with-article-headers
2128 (mail-header-narrow-to-field)
2129 (let ((header (buffer-string)))
2132 (goto-char (point-min))
2133 (while (re-search-forward "\n[\t ]" nil t)
2134 (replace-match " " t t)))
2135 (setq length (- (point-max) (point-min) 1)))
2136 (when (< length (window-width))
2137 (while (re-search-forward "\n[\t ]" nil t)
2138 (replace-match " " t t)))
2139 (goto-char (point-max)))))))
2141 (defun gnus-article-treat-fold-headers ()
2142 "Fold message headers."
2144 (gnus-with-article-headers
2147 (mail-header-narrow-to-field)
2148 (mail-header-fold-field)
2149 (goto-char (point-max))))))
2151 (defun gnus-treat-smiley ()
2152 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2154 (unless (featurep 'xemacs)
2155 (when (and (not gnus-article-should-use-smiley-mule)
2156 gnus-article-smiley-mule-loaded-p)
2157 (load "smiley" nil t)
2158 (setq gnus-article-smiley-mule-loaded-p nil))
2159 (when (and gnus-article-should-use-smiley-mule
2160 (not gnus-article-smiley-mule-loaded-p))
2161 (load "smiley-mule" nil t)
2162 (setq gnus-article-smiley-mule-loaded-p t)))
2163 (gnus-with-article-buffer
2164 (if (memq 'smiley gnus-article-wash-types)
2165 (gnus-delete-images 'smiley)
2167 (let ((images (smiley-region (point) (point-max))))
2169 (gnus-add-wash-type 'smiley)
2170 (dolist (image images)
2171 (gnus-add-image 'smiley image)))))))
2173 (defun gnus-article-remove-images ()
2174 "Remove all images from the article buffer."
2176 (gnus-with-article-buffer
2177 (dolist (elem gnus-article-image-alist)
2178 (gnus-delete-images (car elem)))))
2180 (defun gnus-article-treat-fold-newsgroups ()
2181 "Unfold folded message headers.
2182 Only the headers that fit into the current window width will be
2185 (gnus-with-article-headers
2186 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2188 (mail-header-narrow-to-field)
2189 (while (re-search-forward ", *" nil t)
2190 (replace-match ", " t t))
2191 (mail-header-fold-field)
2192 (goto-char (point-max))))))
2194 (defun gnus-article-treat-body-boundary ()
2195 "Place a boundary line at the end of the headers."
2197 (when (and gnus-body-boundary-delimiter
2198 (> (length gnus-body-boundary-delimiter) 0))
2199 (gnus-with-article-headers
2200 (goto-char (point-max))
2201 (let ((start (point)))
2202 (insert "X-Boundary: ")
2203 (gnus-add-text-properties start (point) '(invisible t intangible t))
2205 (while (>= (1- (window-width)) (length str))
2206 (setq str (concat str gnus-body-boundary-delimiter)))
2207 (substring str 0 (1- (window-width))))
2209 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2211 (defun article-fill-long-lines ()
2212 "Fill lines that are wider than the window width."
2215 (let ((inhibit-read-only t)
2216 (width (window-width (get-buffer-window (current-buffer)))))
2219 (let ((adaptive-fill-mode nil)) ;Why? -sm
2222 (when (>= (current-column) (min fill-column width))
2223 (narrow-to-region (min (1+ (point)) (point-max))
2225 (let ((goback (point-marker)))
2226 (fill-paragraph nil)
2227 (goto-char (marker-position goback)))
2229 (forward-line 1)))))))
2231 (defun article-capitalize-sentences ()
2232 "Capitalize the first word in each sentence."
2235 (let ((inhibit-read-only t)
2236 (paragraph-start "^[\n\^L]"))
2240 (forward-sentence)))))
2242 (defun article-remove-cr ()
2243 "Remove trailing CRs and then translate remaining CRs into LFs."
2246 (let ((inhibit-read-only t))
2247 (goto-char (point-min))
2248 (while (re-search-forward "\r+$" nil t)
2249 (replace-match "" t t))
2250 (goto-char (point-min))
2251 (while (search-forward "\r" nil t)
2252 (replace-match "\n" t t)))))
2254 (defun article-remove-trailing-blank-lines ()
2255 "Remove all trailing blank lines from the article."
2258 (let ((inhibit-read-only t))
2259 (goto-char (point-max))
2263 (while (and (not (bobp))
2264 (looking-at "^[ \t]*$")
2265 (not (gnus-annotation-in-region-p
2266 (point) (point-at-eol))))
2272 (defvar gnus-face-properties-alist))
2274 (defun article-display-face ()
2275 "Display any Face headers in the header."
2277 (let ((wash-face-p buffer-read-only))
2278 (gnus-with-article-headers
2279 ;; When displaying parts, this function can be called several times on
2280 ;; the same article, without any intended toggle semantic (as typing `W
2281 ;; D d' would have). So face deletion must occur only when we come from
2282 ;; an interactive command, that is when the *Article* buffer is
2284 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2285 (gnus-delete-images 'face)
2286 (let ((from (gnus-article-goto-header "from"))
2289 (when (and wash-face-p
2291 (goto-char (point-min))
2292 (not (re-search-forward "^Face:[\t ]*" nil t)))
2293 (gnus-buffer-live-p gnus-original-article-buffer))
2294 (set-buffer gnus-original-article-buffer))
2296 (mail-narrow-to-head)
2297 (while (gnus-article-goto-header "Face")
2298 (push (mail-header-field-value) faces))))
2303 (insert "[no `from' set]\n"))
2304 (dolist (face faces)
2305 (let ((png (gnus-convert-face-to-png face))
2309 (apply 'gnus-create-image png 'png t
2310 (cdr (assq 'png gnus-face-properties-alist))))
2312 (gnus-add-wash-type 'face)
2313 (gnus-add-image 'face image)
2314 (gnus-put-image image nil 'face))))))))))
2316 (defun article-display-x-face (&optional force)
2317 "Look for an X-Face header and display it if present."
2318 (interactive (list 'force))
2319 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2320 (gnus-with-article-headers
2321 ;; Delete the old process, if any.
2322 (when (process-status "article-x-face")
2323 (delete-process "article-x-face"))
2324 ;; See the comment in `article-display-face'.
2325 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2326 ;; We have already displayed X-Faces, so we remove them
2328 (gnus-delete-images 'xface)
2330 (let (x-faces from face)
2332 (when (and wash-face-p
2334 (goto-char (point-min))
2335 (not (re-search-forward
2336 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2337 (gnus-buffer-live-p gnus-original-article-buffer))
2338 ;; If type `W f', use gnus-original-article-buffer,
2339 ;; otherwise use the current buffer because displaying
2340 ;; RFC822 parts calls this function too.
2341 (set-buffer gnus-original-article-buffer))
2343 (mail-narrow-to-head)
2344 (while (gnus-article-goto-header "X-Face")
2345 (push (mail-header-field-value) x-faces))
2346 (setq from (message-fetch-field "from"))))
2347 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2348 ;; single external face.
2349 (when (stringp gnus-article-x-face-command)
2350 (setq x-faces (list (car x-faces))))
2351 (while (and (setq face (pop x-faces))
2352 gnus-article-x-face-command
2354 ;; Check whether this face is censored.
2355 (not gnus-article-x-face-too-ugly)
2356 (and gnus-article-x-face-too-ugly from
2357 (not (string-match gnus-article-x-face-too-ugly
2359 ;; We display the face.
2360 (cond ((stringp gnus-article-x-face-command)
2361 ;; The command is a string, so we interpret the command
2362 ;; as a, well, command, and fork it off.
2363 (let ((process-connection-type nil))
2364 (gnus-set-process-query-on-exit-flag
2366 "article-x-face" nil shell-file-name
2367 shell-command-switch gnus-article-x-face-command)
2371 (process-send-region "article-x-face"
2372 (point-min) (point-max)))
2373 (process-send-eof "article-x-face")))
2374 ((functionp gnus-article-x-face-command)
2375 ;; The command is a lisp function, so we call it.
2376 (funcall gnus-article-x-face-command face))
2378 (error "%s is not a function"
2379 gnus-article-x-face-command)))))))))
2381 (defun article-decode-mime-words ()
2382 "Decode all MIME-encoded words in the article."
2384 (gnus-with-article-buffer
2385 (let ((inhibit-point-motion-hooks t)
2386 (mail-parse-charset gnus-newsgroup-charset)
2387 (mail-parse-ignored-charsets
2388 (with-current-buffer gnus-summary-buffer
2389 gnus-newsgroup-ignored-charsets)))
2390 (mail-decode-encoded-word-region (point-min) (point-max)))))
2392 (defun article-decode-charset (&optional prompt)
2393 "Decode charset-encoded text in the article.
2394 If PROMPT (the prefix), prompt for a coding system to use."
2396 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2397 (inhibit-read-only t)
2398 (mail-parse-charset gnus-newsgroup-charset)
2399 (mail-parse-ignored-charsets
2400 (save-excursion (condition-case nil
2401 (set-buffer gnus-summary-buffer)
2403 gnus-newsgroup-ignored-charsets))
2404 ct cte ctl charset format)
2407 (article-narrow-to-head)
2408 (setq ct (message-fetch-field "Content-Type" t)
2409 cte (message-fetch-field "Content-Transfer-Encoding" t)
2410 ctl (and ct (ignore-errors
2411 (mail-header-parse-content-type ct)))
2414 (mm-read-coding-system "Charset to decode: "))
2416 (mail-content-type-get ctl 'charset)))
2417 format (and ctl (mail-content-type-get ctl 'format)))
2419 (setq cte (mail-header-strip cte)))
2420 (if (and ctl (not (string-match "/" (car ctl))))
2422 (goto-char (point-max)))
2425 (narrow-to-region (point) (point-max))
2426 (when (and (eq mail-parse-charset 'gnus-decoded)
2427 (eq (mm-body-7-or-8) '8bit))
2428 ;; The text code could have been decoded.
2429 (setq charset mail-parse-charset))
2430 (when (and (or (not ctl)
2431 (equal (car ctl) "text/plain"))
2432 (not format)) ;; article with format will decode later.
2434 charset (and cte (intern (downcase
2435 (gnus-strip-whitespace cte))))
2438 (defun article-decode-encoded-words ()
2439 "Remove encoded-word encoding from headers."
2440 (let ((charset (save-excursion
2441 (set-buffer gnus-summary-buffer)
2442 default-mime-charset))
2443 (inhibit-read-only t))
2444 (mime-decode-header-in-buffer charset)))
2446 (defun article-decode-group-name ()
2447 "Decode group names in `Newsgroups:'."
2448 (let ((inhibit-point-motion-hooks t)
2449 (inhibit-read-only t)
2450 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2451 (when (and (or gnus-group-name-charset-method-alist
2452 gnus-group-name-charset-group-alist)
2453 (gnus-buffer-live-p gnus-original-article-buffer))
2455 (article-narrow-to-head)
2456 (with-current-buffer gnus-original-article-buffer
2457 (goto-char (point-min)))
2458 (while (re-search-forward
2459 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2460 (replace-match (save-match-data
2461 (gnus-decode-newsgroups
2462 ;; XXX how to use data in article buffer?
2463 (with-current-buffer gnus-original-article-buffer
2465 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2468 gnus-newsgroup-name method))
2470 (goto-char (point-min))
2471 (with-current-buffer gnus-original-article-buffer
2472 (goto-char (point-min)))
2473 (while (re-search-forward
2474 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2475 (replace-match (save-match-data
2476 (gnus-decode-newsgroups
2477 ;; XXX how to use data in article buffer?
2478 (with-current-buffer gnus-original-article-buffer
2480 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2483 gnus-newsgroup-name method))
2486 (autoload 'idna-to-unicode "idna")
2488 (defun article-decode-idna-rhs ()
2489 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2492 (let ((inhibit-point-motion-hooks t)
2493 (inhibit-read-only t))
2494 (article-narrow-to-head)
2495 (goto-char (point-min))
2496 (while (re-search-forward "@.*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2498 (when (save-match-data
2499 (and (setq ace (match-string 1))
2501 (and (re-search-backward "^[^ \t]" nil t)
2502 (looking-at "From\\|To\\|Cc")))
2503 (setq unicode (idna-to-unicode ace))))
2504 (unless (string= ace unicode)
2505 (replace-match unicode nil nil nil 1)))))))))
2507 (defun article-de-quoted-unreadable (&optional force read-charset)
2508 "Translate a quoted-printable-encoded article.
2509 If FORCE, decode the article whether it is marked as quoted-printable
2511 If READ-CHARSET, ask for a coding system."
2512 (interactive (list 'force current-prefix-arg))
2514 (let ((inhibit-read-only t) type charset)
2515 (if (gnus-buffer-live-p gnus-original-article-buffer)
2516 (with-current-buffer gnus-original-article-buffer
2518 (gnus-fetch-field "content-transfer-encoding"))
2519 (let* ((ct (gnus-fetch-field "content-type"))
2522 (mail-header-parse-content-type ct)))))
2523 (setq charset (and ctl
2524 (mail-content-type-get ctl 'charset)))
2525 (if (stringp charset)
2526 (setq charset (intern (downcase charset)))))))
2528 (setq charset (mm-read-coding-system "Charset: " charset)))
2530 (setq charset gnus-newsgroup-charset))
2532 (and type (let ((case-fold-search t))
2533 (string-match "quoted-printable" type))))
2535 (quoted-printable-decode-region
2536 (point) (point-max) (mm-charset-to-coding-system charset))))))
2538 (defun article-de-base64-unreadable (&optional force read-charset)
2539 "Translate a base64 article.
2540 If FORCE, decode the article whether it is marked as base64 not.
2541 If READ-CHARSET, ask for a coding system."
2542 (interactive (list 'force current-prefix-arg))
2544 (let ((inhibit-read-only t) type charset)
2545 (if (gnus-buffer-live-p gnus-original-article-buffer)
2546 (with-current-buffer gnus-original-article-buffer
2548 (gnus-fetch-field "content-transfer-encoding"))
2549 (let* ((ct (gnus-fetch-field "content-type"))
2552 (mail-header-parse-content-type ct)))))
2553 (setq charset (and ctl
2554 (mail-content-type-get ctl 'charset)))
2555 (if (stringp charset)
2556 (setq charset (intern (downcase charset)))))))
2558 (setq charset (mm-read-coding-system "Charset: " charset)))
2560 (setq charset gnus-newsgroup-charset))
2562 (and type (let ((case-fold-search t))
2563 (string-match "base64" type))))
2566 (narrow-to-region (point) (point-max))
2567 (base64-decode-region (point-min) (point-max))
2568 (mm-decode-coding-region
2569 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2574 (defun article-decode-HZ ()
2575 "Translate a HZ-encoded article."
2579 (let ((inhibit-read-only t))
2580 (rfc1843-decode-region (point-min) (point-max)))))
2582 (defun article-unsplit-urls ()
2583 "Remove the newlines that some other mailers insert into URLs."
2586 (let ((inhibit-read-only t))
2587 (goto-char (point-min))
2588 (while (re-search-forward
2589 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2590 (replace-match "\\1\\3" t)))
2591 (when (interactive-p)
2592 (gnus-treat-article nil))))
2595 (defun article-wash-html (&optional read-charset)
2596 "Format an HTML article.
2597 If READ-CHARSET, ask for a coding system."
2600 (let ((inhibit-read-only t)
2602 (when (gnus-buffer-live-p gnus-original-article-buffer)
2603 (with-current-buffer gnus-original-article-buffer
2604 (let* ((ct (gnus-fetch-field "content-type"))
2607 (mail-header-parse-content-type ct)))))
2608 (setq charset (and ctl
2609 (mail-content-type-get ctl 'charset)))
2610 (when (stringp charset)
2611 (setq charset (intern (downcase charset)))))))
2613 (setq charset (mm-read-coding-system "Charset: " charset)))
2615 (setq charset gnus-newsgroup-charset))
2617 (save-window-excursion
2619 (narrow-to-region (point) (point-max))
2620 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2621 (entry (assq func mm-text-html-washer-alist)))
2623 (setq func (cdr entry)))
2628 (apply (car func) (cdr func))))))))))
2630 (defun gnus-article-wash-html-with-w3 ()
2631 "Wash the current buffer with w3."
2633 (let ((w3-strict-width (window-width))
2634 (url-standalone-mode t)
2635 (url-gateway-unplugged t)
2636 (w3-honor-stylesheets nil))
2638 (w3-region (point-min) (point-max))
2641 (defun gnus-article-wash-html-with-w3m ()
2642 "Wash the current buffer with emacs-w3m."
2645 (narrow-to-region (point) (point-max))
2646 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2647 w3m-force-redisplay)
2648 (w3m-region (point-min) (point-max)))
2649 (when (and mm-inline-text-html-with-w3m-keymap
2650 (boundp 'w3m-minor-mode-map)
2652 (add-text-properties
2653 (point-min) (point-max)
2654 (list 'keymap w3m-minor-mode-map
2655 ;; Put the mark meaning this part was rendered by emacs-w3m.
2656 'mm-inline-text-html-with-w3m t)))))
2658 (defun article-hide-list-identifiers ()
2659 "Remove list identifies from the Subject header.
2660 The `gnus-list-identifiers' variable specifies what to do."
2662 (let ((inhibit-point-motion-hooks t)
2663 (regexp (if (consp gnus-list-identifiers)
2664 (mapconcat 'identity gnus-list-identifiers " *\\|")
2665 gnus-list-identifiers))
2666 (inhibit-read-only t))
2670 (article-narrow-to-head)
2671 (goto-char (point-min))
2672 (while (re-search-forward
2673 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2675 (delete-region (match-beginning 2) (match-end 0))
2676 (beginning-of-line))
2677 (when (re-search-forward
2678 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2679 (delete-region (match-beginning 1) (match-end 1))))))))
2681 (defun article-hide-pem (&optional arg)
2682 "Toggle hiding of any PEM headers and signatures in the current article.
2683 If given a negative prefix, always show; if given a positive prefix,
2685 (interactive (gnus-article-hidden-arg))
2686 (unless (gnus-article-check-hidden-text 'pem arg)
2688 (let ((inhibit-read-only t) end)
2689 (goto-char (point-min))
2690 ;; Hide the horrendously ugly "header".
2691 (when (and (search-forward
2692 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2694 (setq end (1+ (match-beginning 0))))
2695 (gnus-add-wash-type 'pem)
2696 (gnus-article-hide-text-type
2698 (if (search-forward "\n\n" nil t)
2702 ;; Hide the trailer as well
2703 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2705 (gnus-article-hide-text-type
2706 (match-beginning 0) (match-end 0) 'pem)))))))
2708 (defun article-strip-banner ()
2709 "Strip the banners specified by the `banner' group parameter and by
2710 `gnus-article-address-banner-alist'."
2714 (let ((inhibit-point-motion-hooks t))
2715 (when (gnus-parameter-banner gnus-newsgroup-name)
2716 (article-really-strip-banner
2717 (gnus-parameter-banner gnus-newsgroup-name)))
2718 (when gnus-article-address-banner-alist
2719 ;; It is necessary to encode from fields before checking,
2720 ;; because `mail-header-parse-addresses' does not work
2721 ;; (reliably) on decoded headers. And more, it is
2722 ;; impossible to use `gnus-fetch-original-field' here,
2723 ;; because `article-strip-banner' may be called in draft
2724 ;; buffers to preview them.
2725 (let ((from (save-restriction
2727 (article-narrow-to-head)
2728 (mail-fetch-field "from"))))
2731 (caar (mail-header-parse-addresses
2732 (mail-encode-encoded-word-string from)))))
2734 (dolist (pair gnus-article-address-banner-alist)
2735 (when (string-match (car pair) from)
2737 (article-really-strip-banner (cdr pair)))))))))))))
2739 (defun article-really-strip-banner (banner)
2740 "Strip the banner specified by the argument."
2743 (let ((inhibit-point-motion-hooks t)
2744 (gnus-signature-limit nil)
2745 (inhibit-read-only t))
2748 ((eq banner 'signature)
2749 (when (gnus-article-narrow-to-signature)
2752 (delete-region (point) (point-max))))
2754 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2755 (while (re-search-forward banner nil t)
2756 (delete-region (match-beginning 0) (match-end 0)))))
2758 (while (re-search-forward banner nil t)
2759 (delete-region (match-beginning 0) (match-end 0)))))))))
2761 (defun article-babel ()
2762 "Translate article using an online translation service."
2765 (gnus-with-article-buffer
2766 (when (article-goto-body)
2767 (let* ((start (point))
2769 (orig (buffer-substring start end))
2770 (trans (babel-as-string orig)))
2772 (narrow-to-region start end)
2773 (delete-region start end)
2776 (defun article-hide-signature (&optional arg)
2777 "Hide the signature in the current article.
2778 If given a negative prefix, always show; if given a positive prefix,
2780 (interactive (gnus-article-hidden-arg))
2786 (article-goto-body))
2787 (goto-char (point-min)))
2788 (unless (gnus-article-check-hidden-text 'signature arg)
2789 (let ((inhibit-read-only t)
2791 (while (setq button (text-property-any button (point-max)
2793 'gnus-signature-toggle))
2794 (setq button (text-property-not-all button (point-max)
2796 'gnus-signature-toggle))
2797 (when (and button (not (eobp)))
2798 (gnus-article-hide-text-type
2800 (next-single-property-change (1+ button) 'mime-view-entity
2803 (gnus-set-mode-line 'article))
2805 (defun article-strip-headers-in-body ()
2806 "Strip offensive headers from bodies."
2810 (let ((case-fold-search t))
2811 (when (looking-at "x-no-archive:")
2812 (gnus-delete-line)))))
2814 (defun article-strip-leading-blank-lines ()
2815 "Remove all blank lines from the beginning of the article."
2818 (let ((inhibit-point-motion-hooks t)
2819 (inhibit-read-only t))
2820 (when (article-goto-body)
2821 (while (and (not (eobp))
2822 (looking-at "[ \t]*$"))
2823 (gnus-delete-line))))))
2825 (defun article-narrow-to-head ()
2826 "Narrow the buffer to the head of the message.
2827 Point is left at the beginning of the narrowed-to region."
2829 (goto-char (point-min))
2830 (if (search-forward "\n\n" nil 1)
2833 (goto-char (point-min)))
2835 (defun article-goto-body ()
2836 "Place point at the start of the body."
2837 (goto-char (point-min))
2839 ;; This variable is only bound when dealing with separate
2841 (article-goto-body-goes-to-point-min-p
2843 ((search-forward "\n\n" nil t)
2846 (goto-char (point-max))
2849 (defun article-strip-multiple-blank-lines ()
2850 "Replace consecutive blank lines with one empty line."
2853 (let ((inhibit-point-motion-hooks t)
2854 (inhibit-read-only t))
2855 ;; First make all blank lines empty.
2857 (while (re-search-forward "^[ \t]+$" nil t)
2858 (unless (gnus-annotation-in-region-p
2859 (match-beginning 0) (match-end 0))
2860 (replace-match "" nil t)))
2861 ;; Then replace multiple empty lines with a single empty line.
2863 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2864 (unless (gnus-annotation-in-region-p
2865 (match-beginning 0) (match-end 0))
2866 (delete-region (match-beginning 1) (match-end 1)))))))
2868 (defun article-strip-leading-space ()
2869 "Remove all white space from the beginning of the lines in the article."
2872 (let ((inhibit-point-motion-hooks t)
2873 (inhibit-read-only t))
2875 (while (re-search-forward "^[ \t]+" nil t)
2876 (replace-match "" t t)))))
2878 (defun article-strip-trailing-space ()
2879 "Remove all white space from the end of the lines in the article."
2882 (let ((inhibit-point-motion-hooks t)
2883 (inhibit-read-only t))
2885 (while (re-search-forward "[ \t]+$" nil t)
2886 (replace-match "" t t)))))
2888 (defun article-strip-blank-lines ()
2889 "Strip leading, trailing and multiple blank lines."
2891 (article-strip-leading-blank-lines)
2892 (article-remove-trailing-blank-lines)
2893 (article-strip-multiple-blank-lines))
2895 (defun article-strip-all-blank-lines ()
2896 "Strip all blank lines."
2899 (let ((inhibit-point-motion-hooks t)
2900 (inhibit-read-only t))
2902 (while (re-search-forward "^[ \t]*\n" nil t)
2903 (replace-match "" t t)))))
2905 (defun gnus-article-narrow-to-signature ()
2906 "Narrow to the signature; return t if a signature is found, else nil."
2907 (let ((inhibit-point-motion-hooks t))
2908 (when (gnus-article-search-signature)
2910 ;; Check whether we have some limits to what we consider
2911 ;; to be a signature.
2912 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2913 (list gnus-signature-limit)))
2915 (while (setq limit (pop limits))
2916 (if (or (and (integerp limit)
2917 (< (- (point-max) (point)) limit))
2919 (< (count-lines (point) (point-max)) limit))
2920 (and (functionp limit)
2922 (and (stringp limit)
2923 (not (re-search-forward limit nil t))))
2924 () ; This limit did not succeed.
2928 (narrow-to-region (point) (point-max))
2931 (defun gnus-article-search-signature ()
2932 "Search the current buffer for the signature separator.
2933 Put point at the beginning of the signature separator."
2934 (let ((cur (point)))
2935 (goto-char (point-max))
2936 (if (if (stringp gnus-signature-separator)
2937 (re-search-backward gnus-signature-separator nil t)
2938 (let ((seps gnus-signature-separator))
2940 (not (re-search-backward (car seps) nil t)))
2947 (defun gnus-article-hidden-arg ()
2948 "Return the current prefix arg as a number, or 0 if no prefix."
2949 (list (if current-prefix-arg
2950 (prefix-numeric-value current-prefix-arg)
2953 (defun gnus-article-check-hidden-text (type arg)
2954 "Return nil if hiding is necessary.
2955 Arg can be nil or a number. nil and positive means hide, negative
2956 means show, 0 means toggle."
2959 (let ((hide (gnus-article-hidden-text-p type)))
2965 (gnus-article-show-hidden-text type)
2968 (if (eq hide 'hidden)
2970 (gnus-article-show-hidden-text type)
2974 (defun gnus-article-hidden-text-p (type)
2975 "Say whether the current buffer contains hidden text of type TYPE."
2976 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2978 (not (get-text-property pos 'invisible))
2979 (not (get-text-property pos 'dummy-invisible)))
2981 (text-property-any (1+ pos) (point-max) 'article-type type)))
2986 (defun gnus-article-show-hidden-text (type &optional dummy)
2987 "Show all hidden text of type TYPE.
2988 Originally it is hide instead of DUMMY."
2989 (let ((inhibit-read-only t)
2990 (inhibit-point-motion-hooks t))
2991 (gnus-remove-text-properties-when
2993 (point-min) (point-max)
2994 (cons 'article-type (cons type
2995 gnus-hidden-properties)))
2996 (gnus-delete-wash-type type)))
2998 (defconst article-time-units
2999 `((year . ,(* 365.25 24 60 60))
3000 (week . ,(* 7 24 60 60))
3001 (day . ,(* 24 60 60))
3005 "Mapping from time units to seconds.")
3007 (defun gnus-article-forward-header ()
3008 "Move point to the start of the next header.
3009 If the current header is a continuation header, this can be several
3014 (if (looking-at "[ \t]+[^ \t]")
3018 (defun article-date-ut (&optional type highlight)
3019 "Convert DATE date to universal time in the current article.
3020 If TYPE is `local', convert to local time; if it is `lapsed', output
3021 how much time has lapsed since DATE. For `lapsed', the value of
3022 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
3023 should replace the \"Date:\" one, or should be added below it."
3024 (interactive (list 'ut t))
3025 (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
3026 (date-regexp (cond ((not gnus-article-date-lapsed-new-header)
3030 (article-lapsed-timer
3034 (case-fold-search t)
3035 (inhibit-read-only t)
3036 (inhibit-point-motion-hooks t)
3037 pos date bface eface)
3041 (goto-char (point-min))
3042 (while (or (setq date (get-text-property (setq pos (point))
3044 (when (setq pos (next-single-property-change
3045 (point) 'original-date))
3046 (setq date (get-text-property pos 'original-date))
3048 (narrow-to-region pos (or (text-property-any pos (point-max)
3051 (goto-char (point-min))
3052 (when (re-search-forward tdate-regexp nil t)
3053 (setq bface (get-text-property (point-at-bol) 'face)
3054 eface (get-text-property (1- (point-at-eol)) 'face)))
3055 (goto-char (point-min))
3057 ;; Delete any old Date headers.
3058 (while (re-search-forward date-regexp nil t)
3060 (delete-region (point-at-bol) (progn
3061 (gnus-article-forward-header)
3063 (delete-region (point-at-bol) (progn
3064 (gnus-article-forward-header)
3067 (setq pos (point))))
3068 (when (and (not pos)
3069 (re-search-forward tdate-regexp nil t))
3071 (gnus-goto-char pos)
3072 (insert (article-make-date-line date (or type 'ut)))
3078 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
3079 (put-text-property (match-beginning 1) (1+ (match-end 1))
3081 (put-text-property (match-beginning 2) (match-end 2)
3083 (put-text-property (point-min) (1- (point-max)) 'original-date date)
3084 (goto-char (point-max))
3087 (defun article-make-date-line (date type)
3088 "Return a DATE line of TYPE."
3089 (unless (memq type '(local ut original user iso8601 lapsed english))
3090 (error "Unknown conversion type: %s" type))
3092 (let ((time (date-to-time date)))
3094 ;; Convert to the local timezone.
3096 (concat "Date: " (message-make-date time)))
3097 ;; Convert to Universal Time.
3102 (let* ((e (parse-time-string date))
3103 (tm (apply 'encode-time e))
3105 (ls (- (cadr tm) (car (current-time-zone time)))))
3106 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
3107 ((> ls 65535) (list (1+ ms) (- ls 65536)))
3111 ;; Get the original date from the article.
3112 ((eq type 'original)
3113 (concat "Date: " (if (string-match "\n+$" date)
3114 (substring date 0 (match-beginning 0))
3116 ;; Let the user define the format.
3118 (let ((format (or (condition-case nil
3119 (with-current-buffer gnus-summary-buffer
3120 gnus-article-time-format)
3122 gnus-article-time-format)))
3123 (if (functionp format)
3124 (funcall format time)
3125 (concat "Date: " (format-time-string format time)))))
3128 (let ((tz (car (current-time-zone time))))
3131 (format-time-string "%Y%m%dT%H%M%S" time)
3132 (format "%s%02d%02d"
3133 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3134 (/ (% (abs tz) 3600) 60)))))
3135 ;; Do an X-Sent lapsed format.
3137 ;; If the date is seriously mangled, the timezone functions are
3138 ;; liable to bug out, so we ignore all errors.
3139 (let* ((now (current-time))
3140 (real-time (subtract-time now time))
3141 (real-sec (and real-time
3142 (+ (* (float (car real-time)) 65536)
3144 (sec (and real-time (abs real-sec)))
3154 ;; This is a bit convoluted, but basically we go
3155 ;; through the time units for years, weeks, etc,
3156 ;; and divide things to see whether that results
3157 ;; in positive answers.
3160 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3161 ;; The (remaining) seconds are too few to
3162 ;; be divided into this time unit.
3164 ;; It's big enough, so we output it.
3165 (setq sec (- sec (* num (cdr unit))))
3167 (concat (if prev ", " "") (int-to-string
3169 " " (symbol-name (car unit))
3170 (if (> num 1) "s" ""))
3172 article-time-units "")
3173 ;; If dates are odd, then it might appear like the
3174 ;; article was sent in the future.
3177 " in the future"))))))
3178 ;; Display the date in proper English
3180 (let ((dtime (decode-time time)))
3183 (number-to-string (nth 3 dtime))
3184 (let ((digit (% (nth 3 dtime) 10)))
3186 ((memq (nth 3 dtime) '(11 12 13)) "th")
3192 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3194 (number-to-string (nth 5 dtime))
3196 (format "%02d" (nth 2 dtime))
3198 (format "%02d" (nth 1 dtime)))))))
3200 (format "Date: %s (from T-gnus)" date))))
3202 (defun article-date-local (&optional highlight)
3203 "Convert the current article date to the local timezone."
3204 (interactive (list t))
3205 (article-date-ut 'local highlight))
3207 (defun article-date-english (&optional highlight)
3208 "Convert the current article date to something that is proper English."
3209 (interactive (list t))
3210 (article-date-ut 'english highlight))
3212 (defun article-date-original (&optional highlight)
3213 "Convert the current article date to what it was originally.
3214 This is only useful if you have used some other date conversion
3215 function and want to see what the date was before converting."
3216 (interactive (list t))
3217 (article-date-ut 'original highlight))
3219 (defun article-date-lapsed (&optional highlight)
3220 "Convert the current article date to time lapsed since it was sent."
3221 (interactive (list t))
3222 (article-date-ut 'lapsed highlight))
3224 (defun article-update-date-lapsed ()
3225 "Function to be run from a timer to update the lapsed time line."
3227 (let (deactivate-mark)
3232 (set-buffer (window-buffer w))
3233 (when (or (and (eq major-mode 'mime-view-mode)
3234 (eq (mime-preview-original-major-mode)
3235 'gnus-original-article-mode))
3236 (eq major-mode 'gnus-article-mode))
3237 (let ((mark (point-marker)))
3238 (goto-char (point-min))
3239 (when (re-search-forward "^X-Sent:" nil t)
3240 (article-date-lapsed t))
3241 (goto-char (marker-position mark))
3242 (move-marker mark nil))))
3245 (defun gnus-start-date-timer (&optional n)
3246 "Start a timer to update the X-Sent header in the article buffers.
3247 The numerical prefix says how frequently (in seconds) the function
3252 (gnus-stop-date-timer)
3253 (setq article-lapsed-timer
3254 (run-at-time 1 n 'article-update-date-lapsed)))
3256 (defun gnus-stop-date-timer ()
3257 "Stop the X-Sent timer."
3259 (when article-lapsed-timer
3260 (nnheader-cancel-timer article-lapsed-timer)
3261 (setq article-lapsed-timer nil)))
3263 (defun article-date-user (&optional highlight)
3264 "Convert the current article date to the user-defined format.
3265 This format is defined by the `gnus-article-time-format' variable."
3266 (interactive (list t))
3267 (article-date-ut 'user highlight))
3269 (defun article-date-iso8601 (&optional highlight)
3270 "Convert the current article date to ISO8601."
3271 (interactive (list t))
3272 (article-date-ut 'iso8601 highlight))
3274 (defmacro gnus-article-save-original-date (&rest forms)
3275 "Save the original date as a text property and evaluate FORMS."
3276 `(let* ((case-fold-search t)
3278 (goto-char (point-min))
3279 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3282 (date (when (and start
3283 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3285 (buffer-substring-no-properties start
3286 (match-beginning 0)))))
3287 (goto-char (point-max))
3288 (skip-chars-backward "\n")
3289 (put-text-property (point-min) (point) 'original-date date)
3291 (goto-char (point-max))
3292 (skip-chars-backward "\n")
3293 (put-text-property (point-min) (point) 'original-date date)))
3295 ;; (defun article-show-all ()
3296 ;; "Show all hidden text in the article buffer."
3300 ;; (let ((inhibit-read-only t))
3301 ;; (gnus-article-unhide-text (point-min) (point-max))
3302 ;; (gnus-remove-text-with-property 'gnus-prev)
3303 ;; (gnus-remove-text-with-property 'gnus-next))))
3305 (defun article-show-all-headers ()
3306 "Show all hidden headers in the article buffer."
3311 (article-narrow-to-head)
3312 (let ((inhibit-read-only t))
3313 (gnus-article-unhide-text (point-min) (point-max))))))
3315 (defun article-remove-leading-whitespace ()
3316 "Remove excessive whitespace from all headers."
3320 (let ((inhibit-read-only t))
3321 (article-narrow-to-head)
3322 (goto-char (point-min))
3323 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3324 (delete-region (match-beginning 1) (match-end 1)))))))
3326 (defun article-emphasize (&optional arg)
3327 "Emphasize text according to `gnus-emphasis-alist'."
3328 (interactive (gnus-article-hidden-arg))
3329 (unless (gnus-article-check-hidden-text 'emphasis arg)
3333 (with-current-buffer gnus-summary-buffer
3334 gnus-article-emphasis-alist)
3336 gnus-emphasis-alist))
3337 (inhibit-read-only t)
3338 (props (append '(article-type emphasis)
3339 gnus-hidden-properties))
3340 regexp elem beg invisible visible face)
3343 (while (setq elem (pop alist))
3345 (setq regexp (car elem)
3346 invisible (nth 1 elem)
3347 visible (nth 2 elem)
3349 (while (re-search-forward regexp nil t)
3350 (when (and (match-beginning visible) (match-beginning invisible))
3351 (gnus-article-hide-text
3352 (match-beginning invisible) (match-end invisible) props)
3353 (gnus-article-unhide-text-type
3354 (match-beginning visible) (match-end visible) 'emphasis)
3355 (gnus-put-overlay-excluding-newlines
3356 (match-beginning visible) (match-end visible) 'face face)
3357 (gnus-add-wash-type 'emphasis)
3358 (goto-char (match-end invisible)))))))))
3360 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3361 "Setup newsgroup emphasis alist."
3362 (unless gnus-article-emphasis-alist
3363 (let ((name (and gnus-newsgroup-name
3364 (gnus-group-real-name gnus-newsgroup-name))))
3365 (make-local-variable 'gnus-article-emphasis-alist)
3366 (setq gnus-article-emphasis-alist
3368 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3369 (while (setq elem (pop alist))
3370 (when (and name (string-match (car elem) name))
3372 highlight (copy-sequence (cdr elem)))))
3374 (copy-sequence highlight-words)
3375 (if gnus-newsgroup-name
3376 (copy-sequence (gnus-group-find-parameter
3377 gnus-newsgroup-name 'highlight-words t)))
3378 gnus-emphasis-alist)))))
3381 (defvar gnus-summary-article-menu)
3382 (defvar gnus-summary-post-menu))
3384 ;;; Saving functions.
3386 (defun gnus-article-save (save-buffer file &optional num)
3387 "Save the currently selected article."
3388 (unless gnus-save-all-headers
3389 ;; Remove headers according to `gnus-saved-headers'.
3390 (let ((gnus-visible-headers
3391 (or gnus-saved-headers gnus-visible-headers))
3392 (gnus-article-buffer save-buffer))
3394 (set-buffer save-buffer)
3395 (article-hide-headers 1 t))))
3396 (save-window-excursion
3397 (if (not gnus-default-article-saver)
3398 (error "No default saver is defined")
3399 ;; !!! Magic! The saving functions all save
3400 ;; `gnus-save-article-buffer' (or so they think), but we
3401 ;; bind that variable to our save-buffer.
3402 (set-buffer gnus-article-buffer)
3403 (let* ((gnus-save-article-buffer save-buffer)
3406 ((not gnus-prompt-before-saving) 'default)
3407 ((eq gnus-prompt-before-saving 'always) nil)
3409 (gnus-number-of-articles-to-be-saved
3410 (when (eq gnus-prompt-before-saving t)
3412 (set-buffer gnus-article-current-summary)
3413 (funcall gnus-default-article-saver filename)))))
3415 (defun gnus-read-save-file-name (prompt &optional filename
3416 function group headers variable)
3418 (funcall function group headers (symbol-value variable)))
3423 ((eq filename 'default)
3429 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3432 (if (and gnus-number-of-articles-to-be-saved
3433 (> gnus-number-of-articles-to-be-saved 1))
3434 (format "these %d articles"
3435 gnus-number-of-articles-to-be-saved)
3438 ;; Let the split methods have their say.
3440 ;; No split name was found.
3443 (concat prompt " (default "
3444 (file-name-nondirectory default-name) ") ")
3445 (file-name-directory default-name)
3447 ;; A single group name is returned.
3448 ((stringp split-name)
3450 (funcall function split-name headers
3451 (symbol-value variable)))
3453 (concat prompt " (default "
3454 (file-name-nondirectory default-name) ") ")
3455 (file-name-directory default-name)
3457 ;; A single split name was found
3458 ((= 1 (length split-name))
3459 (let* ((name (expand-file-name
3461 gnus-article-save-directory))
3462 (dir (cond ((file-directory-p name)
3463 (file-name-as-directory name))
3464 ((file-exists-p name) name)
3465 (t gnus-article-save-directory))))
3467 (concat prompt " (default " name ") ")
3469 ;; A list of splits was found.
3471 (setq split-name (nreverse split-name))
3473 (let ((file-name-history
3474 (nconc split-name file-name-history)))
3478 (concat prompt " (`M-p' for defaults) ")
3479 gnus-article-save-directory
3481 gnus-article-save-directory)))
3482 (car (push result file-name-history)))))))
3483 ;; Create the directory.
3484 (gnus-make-directory (file-name-directory file))
3485 ;; If we have read a directory, we append the default file name.
3486 (when (file-directory-p file)
3487 (setq file (expand-file-name (file-name-nondirectory
3489 (file-name-as-directory file))))
3490 ;; Possibly translate some characters.
3491 (nnheader-translate-file-chars file))))))
3492 (gnus-make-directory (file-name-directory result))
3493 (set variable result)))
3495 (defun gnus-article-archive-name (group)
3496 "Return the first instance of an \"Archive-name\" in the current buffer."
3497 (let ((case-fold-search t))
3498 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3499 (nnheader-concat gnus-article-save-directory
3500 (match-string 1)))))
3502 (defun gnus-article-nndoc-name (group)
3503 "If GROUP is an nndoc group, return the name of the parent group."
3504 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3505 (gnus-group-get-parameter group 'save-article-group)))
3507 (defun gnus-summary-save-in-rmail (&optional filename)
3508 "Append this article to Rmail file.
3509 Optional argument FILENAME specifies file name.
3510 Directory to save to is default to `gnus-article-save-directory'."
3511 (setq filename (gnus-read-save-file-name
3512 "Save %s in rmail file:" filename
3513 gnus-rmail-save-name gnus-newsgroup-name
3514 gnus-current-headers 'gnus-newsgroup-last-rmail))
3515 (gnus-eval-in-buffer-window gnus-save-article-buffer
3519 (gnus-output-to-rmail filename))))
3522 (defun gnus-summary-save-in-mail (&optional filename)
3523 "Append this article to Unix mail file.
3524 Optional argument FILENAME specifies file name.
3525 Directory to save to is default to `gnus-article-save-directory'."
3526 (setq filename (gnus-read-save-file-name
3527 "Save %s in Unix mail file:" filename
3528 gnus-mail-save-name gnus-newsgroup-name
3529 gnus-current-headers 'gnus-newsgroup-last-mail))
3530 (gnus-eval-in-buffer-window gnus-save-article-buffer
3534 (if (and (file-readable-p filename)
3535 (file-regular-p filename)
3536 (mail-file-babyl-p filename))
3537 (rmail-output-to-rmail-file filename t)
3538 (gnus-output-to-mail filename)))))
3541 (defun gnus-summary-save-in-file (&optional filename overwrite)
3542 "Append this article to file.
3543 Optional argument FILENAME specifies file name.
3544 Directory to save to is default to `gnus-article-save-directory'."
3545 (setq filename (gnus-read-save-file-name
3546 "Save %s in file:" filename
3547 gnus-file-save-name gnus-newsgroup-name
3548 gnus-current-headers 'gnus-newsgroup-last-file))
3549 (gnus-eval-in-buffer-window gnus-save-article-buffer
3553 (when (and overwrite
3554 (file-exists-p filename))
3555 (delete-file filename))
3556 (gnus-output-to-file filename))))
3559 (defun gnus-summary-write-to-file (&optional filename)
3560 "Write this article to a file, overwriting it if the file exists.
3561 Optional argument FILENAME specifies file name.
3562 The directory to save in defaults to `gnus-article-save-directory'."
3563 (gnus-summary-save-in-file nil t))
3565 (defun gnus-summary-save-body-in-file (&optional filename)
3566 "Append this article body to a file.
3567 Optional argument FILENAME specifies file name.
3568 The directory to save in defaults to `gnus-article-save-directory'."
3569 (setq filename (gnus-read-save-file-name
3570 "Save %s body in file:" filename
3571 gnus-file-save-name gnus-newsgroup-name
3572 gnus-current-headers 'gnus-newsgroup-last-file))
3573 (gnus-eval-in-buffer-window gnus-save-article-buffer
3577 (when (article-goto-body)
3578 (narrow-to-region (point) (point-max)))
3579 (gnus-output-to-file filename))))
3582 (defun gnus-summary-save-in-pipe (&optional command)
3583 "Pipe this article to subprocess."
3585 (cond ((and (eq command 'default)
3586 gnus-last-shell-command)
3587 gnus-last-shell-command)
3592 "Shell command on %s: "
3593 (if (and gnus-number-of-articles-to-be-saved
3594 (> gnus-number-of-articles-to-be-saved 1))
3595 (format "these %d articles"
3596 gnus-number-of-articles-to-be-saved)
3598 gnus-last-shell-command))))
3599 (when (string-equal command "")
3600 (if gnus-last-shell-command
3601 (setq command gnus-last-shell-command)
3602 (error "A command is required")))
3603 (gnus-eval-in-buffer-window gnus-article-buffer
3606 (shell-command-on-region (point-min) (point-max) command nil)))
3607 (setq gnus-last-shell-command command))
3609 (defun gnus-summary-pipe-to-muttprint (&optional command)
3610 "Pipe this article to muttprint."
3611 (setq command (read-string
3612 "Print using command: " gnus-summary-muttprint-program
3613 nil gnus-summary-muttprint-program))
3614 (gnus-summary-save-in-pipe command))
3616 ;;; Article file names when saving.
3618 (defun gnus-capitalize-newsgroup (newsgroup)
3619 "Capitalize NEWSGROUP name."
3620 (when (not (zerop (length newsgroup)))
3621 (concat (char-to-string (upcase (aref newsgroup 0)))
3622 (substring newsgroup 1))))
3624 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3625 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3626 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3627 Otherwise, it is like ~/News/news/group/num."
3630 (concat (if (gnus-use-long-file-name 'not-save)
3631 (gnus-capitalize-newsgroup newsgroup)
3632 (gnus-newsgroup-directory-form newsgroup))
3633 "/" (int-to-string (mail-header-number headers)))
3634 gnus-article-save-directory)))
3636 (string-equal (file-name-directory default)
3637 (file-name-directory last-file))
3638 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3640 (or last-file default))))
3642 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3643 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3644 If variable `gnus-use-long-file-name' is non-nil, it is
3645 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3648 (concat (if (gnus-use-long-file-name 'not-save)
3650 (gnus-newsgroup-directory-form newsgroup))
3651 "/" (int-to-string (mail-header-number headers)))
3652 gnus-article-save-directory)))
3654 (string-equal (file-name-directory default)
3655 (file-name-directory last-file))
3656 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3658 (or last-file default))))
3660 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3661 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3662 If variable `gnus-use-long-file-name' is non-nil, it is
3663 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3666 (if (gnus-use-long-file-name 'not-save)
3669 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3671 gnus-article-save-directory)))
3673 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3674 "Generate file name from sender."
3675 (let ((from (mail-header-from headers)))
3677 (if (and from (string-match "\\([^ <]+\\)@" from))
3678 (match-string 1 from)
3680 gnus-article-save-directory)))
3682 (defun article-verify-x-pgp-sig ()
3685 (if (gnus-buffer-live-p gnus-original-article-buffer)
3686 (let ((sig (with-current-buffer gnus-original-article-buffer
3687 (gnus-fetch-field "X-PGP-Sig")))
3691 (mml2015-clear-verify-function))
3693 (insert-buffer-substring gnus-original-article-buffer)
3694 (setq items (split-string sig))
3695 (message-narrow-to-head)
3696 (let ((inhibit-point-motion-hooks t)
3697 (case-fold-search t))
3698 ;; Don't verify multiple headers.
3699 (setq headers (mapconcat (lambda (header)
3701 (mail-fetch-field header)
3703 (split-string (nth 1 items) ",") "")))
3704 (delete-region (point-min) (point-max))
3705 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3706 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3711 (if (looking-at "^-")
3714 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3715 (insert "Version: " (car items) "\n\n")
3716 (insert (mapconcat 'identity (cddr items) "\n"))
3717 (insert "\n-----END PGP SIGNATURE-----\n")
3718 (let ((mm-security-handle (list (format "multipart/signed"))))
3719 (mml2015-clean-buffer)
3720 (let ((coding-system-for-write (or gnus-newsgroup-charset
3722 (funcall (mml2015-clear-verify-function)))
3724 (or (mm-handle-multipart-ctl-parameter
3725 mm-security-handle 'gnus-details)
3726 (mm-handle-multipart-ctl-parameter
3727 mm-security-handle 'gnus-info)))))
3729 (let ((inhibit-read-only t) bface eface)
3731 (message-narrow-to-head)
3732 (goto-char (point-max))
3734 (setq bface (get-text-property (point-at-bol) 'face)
3735 eface (get-text-property (1- (point-at-eol)) 'face))
3736 (message-remove-header "X-Gnus-PGP-Verify")
3737 (if (re-search-forward "^X-PGP-Sig:" nil t)
3739 (goto-char (point-max)))
3740 (narrow-to-region (point) (point))
3741 (insert "X-Gnus-PGP-Verify: " info "\n")
3742 (goto-char (point-min))
3745 (if (not (looking-at "^[ \t]"))
3749 (goto-char (point-min))
3750 (when (looking-at "\\([^:]+\\): *")
3751 (put-text-property (match-beginning 1) (1+ (match-end 1))
3753 (put-text-property (match-end 0) (point-max)
3754 'face eface)))))))))
3756 (defun article-verify-cancel-lock ()
3757 "Verify Cancel-Lock header."
3759 (if (gnus-buffer-live-p gnus-original-article-buffer)
3760 (canlock-verify gnus-original-article-buffer)))
3762 (defun article-monafy ()
3763 "Display body part with mona font."
3765 (unless (if (featurep 'xemacs)
3766 (find-face 'gnus-mona-face)
3767 (facep 'gnus-mona-face))
3768 (require 'navi2ch-mona)
3769 (set-face-font (make-face 'gnus-mona-face) navi2ch-mona-font))
3771 (let ((inhibit-read-only t))
3774 (gnus-make-overlay (point) (point-max))
3775 'face 'gnus-mona-face))))
3782 (setq afunc (car func)
3785 gfunc (intern (format "gnus-%s" func))))
3787 (when (fboundp afunc)
3788 `(lambda (&optional interactive &rest args)
3789 ,(documentation afunc t)
3790 (interactive (list t))
3792 (set-buffer gnus-article-buffer)
3794 (call-interactively ',afunc)
3795 (apply ',afunc args))))))))
3796 '(article-hide-headers
3797 article-verify-x-pgp-sig
3798 article-verify-cancel-lock
3800 article-hide-boring-headers
3801 article-treat-overstrike
3802 article-treat-ansi-sequences
3803 article-fill-long-lines
3804 article-capitalize-sentences
3806 article-remove-leading-whitespace
3807 article-display-x-face
3808 article-display-face
3809 article-de-quoted-unreadable
3810 article-de-base64-unreadable
3813 article-unsplit-urls
3814 article-hide-list-identifiers
3815 article-strip-banner
3818 article-hide-signature
3819 article-strip-headers-in-body
3820 article-remove-trailing-blank-lines
3821 article-strip-leading-blank-lines
3822 article-strip-multiple-blank-lines
3823 article-strip-leading-space
3824 article-strip-trailing-space
3825 article-strip-blank-lines
3826 article-strip-all-blank-lines
3828 article-date-english
3829 article-date-iso8601
3830 article-date-original
3832 article-decode-mime-words
3833 article-decode-charset
3834 article-decode-encoded-words
3838 article-treat-dumbquotes
3839 article-normalize-headers
3840 (article-show-all-headers . gnus-article-show-all-headers)
3841 ;; (article-show-all . gnus-article-show-all)
3845 ;;; Gnus article mode
3848 (put 'gnus-article-mode 'mode-class 'special)
3850 (gnus-define-keys gnus-article-mode-map
3851 " " gnus-article-goto-next-page
3852 "\177" gnus-article-goto-prev-page
3853 [delete] gnus-article-goto-prev-page
3854 [backspace] gnus-article-goto-prev-page
3855 "\C-c^" gnus-article-refer-article
3856 "h" gnus-article-show-summary
3857 "s" gnus-article-show-summary
3858 "\C-c\C-m" gnus-article-mail
3859 "?" gnus-article-describe-briefly
3860 "e" gnus-summary-edit-article
3861 "<" beginning-of-buffer
3863 "\C-c\C-i" gnus-info-find-node
3865 "R" gnus-article-reply-with-original
3866 "F" gnus-article-followup-with-original
3867 "\C-hk" gnus-article-describe-key
3868 "\C-hc" gnus-article-describe-key-briefly
3870 "\C-d" gnus-article-read-summary-keys
3871 "\M-*" gnus-article-read-summary-keys
3872 "\M-#" gnus-article-read-summary-keys
3873 "\M-^" gnus-article-read-summary-keys
3874 "\M-g" gnus-article-read-summary-keys)
3876 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3880 (push (char-to-string key) keys)
3882 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3883 (setq key (car elem))
3884 (when (and (> (length key) 0)
3885 (not (eq 'menu-bar (aref key 0)))
3886 (symbolp (lookup-key gnus-summary-mode-map key)))
3889 (unless (lookup-key gnus-article-mode-map key)
3890 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3892 (defun gnus-article-make-menu-bar ()
3893 (unless (boundp 'gnus-article-commands-menu)
3894 (gnus-summary-make-menu-bar))
3895 (gnus-turn-off-edit-menu 'article)
3896 (unless (boundp 'gnus-article-article-menu)
3898 gnus-article-article-menu gnus-article-mode-map ""
3900 ["Scroll forwards" gnus-article-goto-next-page t]
3901 ["Scroll backwards" gnus-article-goto-prev-page t]
3902 ["Show summary" gnus-article-show-summary t]
3903 ["Fetch Message-ID at point" gnus-article-refer-article t]
3904 ["Mail to address at point" gnus-article-mail t]
3905 ["Send a bug report" gnus-bug t]))
3908 gnus-article-treatment-menu gnus-article-mode-map ""
3909 ;; Fixme: this should use :active (and maybe :visible).
3911 ["Hide headers" gnus-article-hide-headers t]
3912 ["Hide signature" gnus-article-hide-signature t]
3913 ["Hide citation" gnus-article-hide-citation t]
3914 ["Treat overstrike" gnus-article-treat-overstrike t]
3915 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
3916 ["Remove carriage return" gnus-article-remove-cr t]
3917 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3918 ["Treat html" gnus-article-wash-html t]
3919 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3920 ["Decode HZ" gnus-article-decode-HZ t]))
3922 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3924 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3926 (gnus-run-hooks 'gnus-article-menu-hook)))
3928 (defun gnus-article-mode ()
3929 "Major mode for displaying an article.
3931 All normal editing commands are switched off.
3933 The following commands are available in addition to all summary mode
3935 \\<gnus-article-mode-map>
3936 \\[gnus-article-next-page]\t Scroll the article one page forwards
3937 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3938 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3939 \\[gnus-article-show-summary]\t Display the summary buffer
3940 \\[gnus-article-mail]\t Send a reply to the address near point
3941 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3942 \\[gnus-info-find-node]\t Go to the Gnus info node"
3944 (kill-all-local-variables)
3945 (gnus-simplify-mode-line)
3946 (setq mode-name "Article")
3947 (setq major-mode 'gnus-article-mode)
3948 (make-local-variable 'minor-mode-alist)
3949 (unless (assq 'gnus-show-mime minor-mode-alist)
3950 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3951 (use-local-map gnus-article-mode-map)
3952 (when (gnus-visual-p 'article-menu 'menu)
3953 (gnus-article-make-menu-bar)
3954 (when gnus-summary-tool-bar-map
3955 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3956 (gnus-update-format-specifications nil 'article-mode)
3957 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3958 (set (make-local-variable 'gnus-page-broken) nil)
3959 (make-local-variable 'gnus-button-marker-list)
3960 (make-local-variable 'gnus-article-current-summary)
3961 (make-local-variable 'gnus-article-mime-handles)
3962 (make-local-variable 'gnus-article-decoded-p)
3963 (make-local-variable 'gnus-article-mime-handle-alist)
3964 (make-local-variable 'gnus-article-wash-types)
3965 (make-local-variable 'gnus-article-image-alist)
3966 (make-local-variable 'gnus-article-charset)
3967 (make-local-variable 'gnus-article-ignored-charsets)
3968 ;; Prevent recent Emacsen from displaying non-break space as "\ ".
3969 (set (make-local-variable 'nobreak-char-display) nil)
3970 (gnus-set-default-directory)
3971 (buffer-disable-undo)
3972 (setq buffer-read-only t
3973 show-trailing-whitespace nil)
3974 (set-syntax-table gnus-article-mode-syntax-table)
3975 (gnus-run-mode-hooks 'gnus-article-mode-hook))
3977 (defun gnus-article-setup-buffer ()
3978 "Initialize the article buffer."
3979 (let* ((name (if gnus-single-article-buffer "*Article*"
3980 (concat "*Article " gnus-newsgroup-name "*")))
3982 (progn (string-match "\\*Article" name)
3983 (concat " *Original Article"
3984 (substring name (match-end 0))))))
3985 (setq gnus-article-buffer name)
3986 (setq gnus-original-article-buffer original)
3987 (setq gnus-article-mime-handle-alist nil)
3988 ;; This might be a variable local to the summary buffer.
3989 (unless gnus-single-article-buffer
3991 (set-buffer gnus-summary-buffer)
3992 (setq gnus-article-buffer name)
3993 (setq gnus-original-article-buffer original)
3994 (gnus-set-global-variables)))
3995 (gnus-article-setup-highlight-words)
3996 ;; Init original article buffer.
3998 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3999 (set-buffer-multibyte t)
4000 (setq major-mode 'gnus-original-article-mode)
4001 (make-local-variable 'gnus-original-article))
4002 (if (and (get-buffer name)
4003 (with-current-buffer name
4004 (if gnus-article-edit-mode
4005 (if (y-or-n-p "Article mode edit in progress; discard? ")
4007 (set-buffer-modified-p nil)
4008 (gnus-kill-buffer name)
4011 (error "Action aborted"))
4015 (set (make-local-variable 'gnus-article-edit-mode) nil)
4016 (buffer-disable-undo)
4017 (setq buffer-read-only t)
4018 ;; This list just keeps growing if we don't reset it.
4019 (setq gnus-button-marker-list nil)
4020 (unless (eq major-mode 'gnus-article-mode)
4021 (gnus-article-mode))
4024 (set-buffer (gnus-get-buffer-create name))
4026 (make-local-variable 'gnus-summary-buffer)
4027 (gnus-summary-set-local-parameters gnus-newsgroup-name)
4028 (current-buffer)))))
4030 ;; Set article window start at LINE, where LINE is the number of lines
4031 ;; from the head of the article.
4032 (defun gnus-article-set-window-start (&optional line)
4034 (gnus-get-buffer-window gnus-article-buffer t)
4036 (set-buffer gnus-article-buffer)
4037 (goto-char (point-min))
4040 (gnus-message 6 "Moved to bookmark")
4041 (search-forward "\n\n" nil t)
4045 ;;; @@ article filters
4048 (defun gnus-article-display-mime-message ()
4049 "Article display method for MIME message."
4050 ;; called from `gnus-original-article-buffer'.
4051 (let (charset all-headers)
4052 (with-current-buffer gnus-summary-buffer
4053 (setq charset default-mime-charset
4054 all-headers gnus-have-all-headers))
4055 (make-local-variable 'default-mime-charset)
4056 (setq default-mime-charset charset)
4057 (with-current-buffer (get-buffer-create gnus-article-buffer)
4058 (make-local-variable 'default-mime-charset)
4059 (setq default-mime-charset charset))
4060 (mime-display-message mime-message-structure
4061 gnus-article-buffer nil gnus-article-mode-map)
4063 (gnus-article-hide-headers nil -1)))
4064 (run-hooks 'gnus-mime-article-prepare-hook))
4066 (defun gnus-article-display-traditional-message ()
4067 "Article display method for traditional message."
4068 (set-buffer gnus-article-buffer)
4069 (let ((inhibit-read-only t))
4071 (insert-buffer-substring gnus-original-article-buffer)))
4073 (defun gnus-article-make-full-mail-header (&optional number charset)
4074 "Create a new mail header structure in a raw article buffer."
4075 (unless (and number charset)
4076 (save-current-buffer
4077 (set-buffer gnus-summary-buffer)
4079 (setq number (or (cdr gnus-article-current) 0)))
4081 (setq charset (or default-mime-charset 'x-ctext)))))
4082 (goto-char (point-min))
4083 (let ((header-end (if (search-forward "\n\n" nil t)
4085 (goto-char (point-max))))
4086 (chars (- (point-max) (point)))
4087 (lines (count-lines (point) (point-max)))
4088 (default-mime-charset charset)
4090 (narrow-to-region (point-min) header-end)
4091 (setq xref (std11-fetch-field "xref"))
4093 (make-full-mail-header
4095 (std11-fetch-field "subject")
4096 (std11-fetch-field "from")
4097 (std11-fetch-field "date")
4098 (std11-fetch-field "message-id")
4099 (std11-fetch-field "references")
4102 (when xref (concat "Xref: " xref)))
4105 (defun gnus-article-prepare (article &optional all-headers header)
4106 "Prepare ARTICLE in article mode buffer.
4107 ARTICLE should either be an article number or a Message-ID.
4108 If ARTICLE is an id, HEADER should be the article headers.
4109 If ALL-HEADERS is non-nil, no headers are hidden."
4111 ;; Make sure we start in a summary buffer.
4112 (unless (eq major-mode 'gnus-summary-mode)
4113 (set-buffer gnus-summary-buffer))
4114 (setq gnus-summary-buffer (current-buffer))
4115 (let* ((gnus-article (if header (mail-header-number header) article))
4116 (summary-buffer (current-buffer))
4117 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4118 (group gnus-newsgroup-name)
4121 (gnus-article-setup-buffer)
4122 (set-buffer gnus-article-buffer)
4123 ;; Deactivate active regions.
4124 (when (and (boundp 'transient-mark-mode)
4125 transient-mark-mode)
4126 (setq mark-active nil))
4127 (if (not (setq result (let ((inhibit-read-only t))
4128 (gnus-request-article-this-buffer
4130 ;; There is no such article.
4132 (when (and (numberp article)
4133 (not (memq article gnus-newsgroup-sparse)))
4134 (setq gnus-article-current
4135 (cons gnus-newsgroup-name article))
4136 (set-buffer gnus-summary-buffer)
4137 (setq gnus-current-article article)
4138 (if (and (memq article gnus-newsgroup-undownloaded)
4139 (not (gnus-online (gnus-find-method-for-group
4140 gnus-newsgroup-name))))
4142 (gnus-summary-set-agent-mark article)
4143 (message "Message marked for downloading"))
4144 (gnus-summary-mark-article article gnus-canceled-mark)
4145 (unless (memq article gnus-newsgroup-sparse)
4146 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4147 (if (or (eq result 'pseudo)
4148 (eq result 'nneething))
4151 (set-buffer summary-buffer)
4152 (push article gnus-newsgroup-history)
4153 (setq gnus-last-article gnus-current-article
4154 gnus-current-article 0
4155 gnus-current-headers nil
4156 gnus-article-current nil)
4157 (if (eq result 'nneething)
4158 (gnus-configure-windows 'summary)
4159 (gnus-configure-windows 'article))
4160 (gnus-set-global-variables))
4161 (let ((gnus-article-mime-handle-alist-1
4162 gnus-article-mime-handle-alist))
4163 (gnus-set-mode-line 'article)))
4164 ;; The result from the `request' was an actual article -
4165 ;; or at least some text that is now displayed in the
4167 (when (and (numberp article)
4168 (not (eq article gnus-current-article)))
4169 ;; Seems like a new article has been selected.
4170 ;; `gnus-current-article' must be an article number.
4172 (set-buffer summary-buffer)
4173 (push article gnus-newsgroup-history)
4174 (setq gnus-last-article gnus-current-article
4175 gnus-current-article article
4176 gnus-current-headers
4177 (gnus-summary-article-header gnus-current-article)
4178 gnus-article-current
4179 (cons gnus-newsgroup-name gnus-current-article))
4180 (unless (vectorp gnus-current-headers)
4181 (setq gnus-current-headers nil))
4182 (gnus-summary-goto-subject gnus-current-article)
4183 (when (gnus-summary-show-thread)
4184 ;; If the summary buffer really was folded, the
4185 ;; previous goto may not actually have gone to
4186 ;; the right article, but the thread root instead.
4188 (gnus-summary-goto-subject gnus-current-article))
4189 (gnus-run-hooks 'gnus-mark-article-hook)
4190 (gnus-set-mode-line 'summary)
4191 (when (gnus-visual-p 'article-highlight 'highlight)
4192 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4193 ;; Set the global newsgroup variables here.
4194 (gnus-set-global-variables)
4195 (setq gnus-have-all-headers
4196 (or all-headers gnus-show-all-headers))))
4198 (gnus-configure-windows 'article))
4199 (when (or (numberp article)
4201 (gnus-article-prepare-display)
4203 (goto-char (point-min))
4204 (when gnus-break-pages
4205 (gnus-narrow-to-page)))
4206 (let ((gnus-article-mime-handle-alist-1
4207 gnus-article-mime-handle-alist))
4208 (gnus-set-mode-line 'article))
4212 (set-window-point (get-buffer-window (current-buffer)) (point))
4213 (gnus-configure-windows 'article)
4216 (defun gnus-article-prepare-mime-display (&optional number)
4217 (goto-char (point-min))
4218 (when (re-search-forward "^[^\t ]+:" nil t)
4219 (goto-char (match-beginning 0)))
4220 (let ((entity (if (eq 1 (point-min))
4221 (get-text-property 1 'mime-view-entity)
4222 (get-text-property (point) 'mime-view-entity)))
4223 last-entity child-entity next type)
4224 (setq child-entity (mime-entity-children entity))
4226 (setq last-entity (nth (1- (length child-entity))
4228 (setq last-entity entity))
4230 (narrow-to-region (point)
4231 (if (search-forward "\n\n" nil t)
4234 (gnus-article-save-original-date (gnus-treat-article 'head))
4235 (put-text-property (point-min) (point-max) 'article-treated-header t)
4236 (goto-char (point-max)))
4237 (while (and (not (eobp)) entity)
4238 (setq next (set-marker
4240 (next-single-property-change (point) 'mime-view-entity
4242 (let ((types (mime-entity-content-type entity)))
4243 (while (eq 'multipart (mime-content-type-primary-type types))
4244 (setq entity (car (mime-entity-children entity))
4245 types (mime-entity-content-type entity)))
4247 (setq type (format "%s/%s"
4248 (mime-content-type-primary-type types)
4249 (mime-content-type-subtype types)))))
4250 (if (string-equal type "message/rfc822")
4253 (let ((children (mime-entity-children entity))
4256 (setq last-children (nth (1- (length children)) children))
4259 (not (eq last-children
4260 (get-text-property next 'mime-view-entity)))
4262 (next-single-property-change next
4264 nil (point-max)))))))
4265 (setq next (next-single-property-change next 'mime-view-entity
4268 (narrow-to-region (point) next)
4269 (gnus-article-prepare-mime-display)
4270 (goto-char (point-max)))
4271 (setq entity (get-text-property (point) 'mime-view-entity)))
4273 (narrow-to-region (point) next)
4274 ;; Kludge. We have to count true number, but for now,
4275 ;; part number is here only to achieve `last'.
4276 (gnus-treat-article nil 1
4277 (if (eq entity last-entity)
4280 (goto-char (point-max)))
4281 (setq entity (get-text-property next 'mime-view-entity))))))
4284 (defun gnus-article-prepare-display ()
4285 "Make the current buffer look like a nice article."
4286 (let ((gnus-article-buffer (current-buffer))
4288 (inhibit-read-only t))
4289 (unless (eq major-mode 'gnus-article-mode)
4290 (gnus-article-mode))
4291 (setq buffer-read-only nil
4292 gnus-button-marker-list nil
4293 gnus-article-wash-types nil
4294 gnus-article-image-alist nil)
4297 (static-if (featurep 'xemacs)
4298 (map-extents (lambda (extent maparg) (delete-extent extent)))
4299 (let ((lists (overlay-lists)))
4300 (dolist (overlay (nconc (car lists) (cdr lists)))
4301 (delete-overlay overlay)))))
4302 (gnus-run-hooks 'gnus-tmp-internal-hook))
4303 (let ((show-mime (unless (member gnus-newsgroup-name '("nndraft:delayed"
4306 (inhibit-read-only t))
4307 (set-buffer gnus-original-article-buffer)
4309 (setq mime-message-structure gnus-current-headers)
4310 (mime-buffer-entity-set-buffer-internal mime-message-structure
4311 gnus-original-article-buffer)
4312 (mime-entity-set-representation-type-internal mime-message-structure
4313 'mime-buffer-entity)
4314 (luna-send mime-message-structure 'initialize-instance
4315 mime-message-structure)
4317 (let (mime-display-header-hook mime-display-text/plain-hook)
4318 (funcall gnus-article-display-method-for-mime))
4319 (funcall gnus-article-display-method-for-traditional))
4320 ;; Call the treatment functions.
4324 (gnus-article-prepare-mime-display)
4325 (narrow-to-region (goto-char (point-min))
4326 (if (search-forward "\n\n" nil t)
4329 (gnus-article-save-original-date (gnus-treat-article 'head))
4330 (put-text-property (point-min) (point-max) 'article-treated-header t)
4331 (goto-char (point-max))
4333 (narrow-to-region (point) (point-max))
4334 (gnus-treat-article nil))
4335 (put-text-property (point-min) (point-max) 'read-only nil)))
4336 (gnus-run-hooks 'gnus-article-prepare-hook))
4338 (defun gnus-article-decode-article-as-default-mime-charset ()
4339 "Decode an article as `default-mime-charset'. It won't work if the
4340 value of the variable `gnus-show-mime' is non-nil."
4341 (unless (or gnus-show-mime
4342 (member gnus-newsgroup-name '("nndraft:delayed"
4344 (set (make-local-variable 'default-mime-charset)
4345 (with-current-buffer gnus-summary-buffer
4346 default-mime-charset))
4347 (decode-mime-charset-region (point-min) (point-max)
4348 default-mime-charset)))
4351 ;;; Gnus MIME viewing functions
4354 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4355 "Format of the MIME buttons.
4357 Valid specifiers include:
4359 %T MIME type, along with additional info
4360 %n The `name' parameter
4361 %d The description, if any
4362 %l The length of the encoded part
4363 %p The part identifier number
4364 %e Dots if the part isn't displayed
4366 General format specifiers can also be used. See Info node
4367 `(gnus)Formatting Variables'.")
4369 (defvar gnus-mime-button-line-format-alist
4370 '((?t gnus-tmp-type ?s)
4371 (?T gnus-tmp-type-long ?s)
4372 (?n gnus-tmp-name ?s)
4373 (?d gnus-tmp-description ?s)
4375 (?l gnus-tmp-length ?d)
4376 (?e gnus-tmp-dots ?s)))
4378 (defvar gnus-mime-button-commands
4379 '((gnus-article-press-button "\r" "Toggle Display")
4380 (gnus-mime-view-part "v" "View Interactively...")
4381 (gnus-mime-view-part-as-type "t" "View As Type...")
4382 (gnus-mime-view-part-as-charset "C" "View As charset...")
4383 (gnus-mime-save-part "o" "Save...")
4384 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4385 (gnus-mime-delete-part "d" "Delete part")
4386 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4387 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4388 (gnus-mime-view-part-internally "E" "View Internally")
4389 (gnus-mime-view-part-externally "e" "View Externally")
4390 (gnus-mime-print-part "p" "Print")
4391 (gnus-mime-pipe-part "|" "Pipe To Command...")
4392 (gnus-mime-action-on-part "." "Take action on the part...")))
4394 (defun gnus-article-mime-part-status ()
4395 (with-current-buffer gnus-article-buffer
4396 (let ((entity (get-text-property (point-min) 'mime-view-entity))
4399 (setq children (mime-entity-children entity))
4400 (setq children (length children)))
4403 (format " (%d parts)" children))
4406 (defvar gnus-mime-button-map
4407 (let ((map (make-sparse-keymap)))
4408 (define-key map gnus-mouse-2 'gnus-article-push-button)
4409 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4410 (dolist (c gnus-mime-button-commands)
4411 (define-key map (cadr c) (car c)))
4415 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4417 ,@(mapcar (lambda (c)
4418 (vector (caddr c) (car c) :enable t))
4419 gnus-mime-button-commands)))
4421 (defun gnus-mime-button-menu (event prefix)
4422 "Construct a context-sensitive menu of MIME commands."
4423 (interactive "e\nP")
4424 (save-window-excursion
4425 (let ((pos (event-start event)))
4426 (select-window (posn-window pos))
4427 (goto-char (posn-point pos))
4428 (gnus-article-check-buffer)
4429 (popup-menu gnus-mime-button-menu nil prefix))))
4431 (defun gnus-mime-view-all-parts (&optional handles)
4432 "View all the MIME parts."
4434 (with-current-buffer gnus-article-buffer
4435 (let ((handles (or handles gnus-article-mime-handles))
4436 (mail-parse-charset gnus-newsgroup-charset)
4437 (mail-parse-ignored-charsets
4438 (with-current-buffer gnus-summary-buffer
4439 gnus-newsgroup-ignored-charsets)))
4441 (mm-remove-parts handles)
4442 (goto-char (point-min))
4443 (or (search-forward "\n\n") (goto-char (point-max)))
4444 (let ((inhibit-read-only t))
4445 (delete-region (point) (point-max))
4446 (mm-display-parts handles))))))
4449 (defsubst gnus-article-edit-part (handles)
4450 "Edit an article in order to delete a mime part.
4451 This function is exclusively used by `gnus-mime-save-part-and-strip'
4452 and `gnus-mime-delete-part', and not provided at run-time normally."
4453 (gnus-article-edit-article
4455 (buffer-disable-undo)
4457 (let ((mail-parse-charset (or gnus-article-charset
4458 ',gnus-newsgroup-charset))
4459 (mail-parse-ignored-charsets
4460 (or gnus-article-ignored-charsets
4461 ',gnus-newsgroup-ignored-charsets))
4462 (mbl mml-buffer-list))
4463 (setq mml-buffer-list nil)
4464 (insert-buffer gnus-original-article-buffer)
4465 (mime-to-mml ',handles)
4466 (setq gnus-article-mime-handles nil)
4467 (let ((mbl1 mml-buffer-list))
4468 (setq mml-buffer-list mbl)
4469 (set (make-local-variable 'mml-buffer-list) mbl1))
4470 (gnus-make-local-hook 'kill-buffer-hook)
4471 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4472 `(lambda (no-highlight)
4473 (let ((mail-parse-charset (or gnus-article-charset
4474 ',gnus-newsgroup-charset))
4475 (message-options message-options)
4476 (message-options-set-recipient)
4477 (mail-parse-ignored-charsets
4478 (or gnus-article-ignored-charsets
4479 ',gnus-newsgroup-ignored-charsets)))
4481 (mml-destroy-buffers)
4482 (remove-hook 'kill-buffer-hook
4483 'mml-destroy-buffers t)
4484 (kill-local-variable 'mml-buffer-list))
4485 (gnus-summary-edit-article-done
4486 ,(or (mail-header-references gnus-current-headers) "")
4487 ,(gnus-group-read-only-p)
4488 ,gnus-summary-buffer no-highlight)))
4489 (gnus-article-edit-done)
4490 (gnus-summary-expand-window)
4491 (gnus-summary-show-article)))
4493 (defun gnus-mime-save-part-and-strip ()
4494 "Save the MIME part under point then replace it with an external body."
4496 (gnus-article-check-buffer)
4497 (when (gnus-group-read-only-p)
4498 (error "The current group does not support deleting of parts"))
4499 (when (mm-complicated-handles gnus-article-mime-handles)
4501 The current article has a complicated MIME structure, giving up..."))
4502 (when (gnus-yes-or-no-p "\
4503 Deleting parts may malfunction or destroy the article; continue? ")
4504 (let* ((data (get-text-property (point) 'gnus-data))
4506 (handles gnus-article-mime-handles))
4507 (setq file (and data (mm-save-part data)))
4509 (with-current-buffer (mm-handle-buffer data)
4511 (insert "Content-Type: " (mm-handle-media-type data))
4512 (mml-insert-parameter-string (cdr (mm-handle-type data))
4515 (insert "Content-ID: " (message-make-message-id) "\n")
4516 (insert "Content-Transfer-Encoding: binary\n")
4519 (cdr (mm-make-handle nil
4520 `("message/external-body"
4521 (access-type . "LOCAL-FILE")
4523 (set-buffer gnus-summary-buffer)
4524 (gnus-article-edit-part handles)))))
4526 (defun gnus-mime-delete-part ()
4527 "Delete the MIME part under point.
4528 Replace it with some information about the removed part."
4530 (gnus-article-check-buffer)
4531 (when (gnus-group-read-only-p)
4532 (error "The current group does not support deleting of parts"))
4533 (when (mm-complicated-handles gnus-article-mime-handles)
4535 The current article has a complicated MIME structure, giving up..."))
4536 (when (gnus-yes-or-no-p "\
4537 Deleting parts may malfunction or destroy the article; continue? ")
4538 (let* ((data (get-text-property (point) 'gnus-data))
4539 (handles gnus-article-mime-handles)
4543 (mail-decode-encoded-word-string (or (mm-handle-description data)
4546 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4548 (type (mm-handle-media-type data)))
4550 (error "No MIME part under point"))
4551 (with-current-buffer (mm-handle-buffer data)
4552 (let ((bsize (format "%s" (buffer-size))))
4557 "| The following attachment has been deleted:\n"
4559 "| Type: " type "\n"
4560 "| Filename: " filename "\n"
4561 "| Size (encoded): " bsize " Byte\n"
4562 "| Description: " description "\n"
4565 (cdr (mm-make-handle
4566 nil `("text/plain") nil nil
4568 (format "Deleted attachment (%s bytes)" bsize))))))
4569 (set-buffer gnus-summary-buffer)
4570 (gnus-article-edit-part handles))))
4572 (defun gnus-mime-save-part ()
4573 "Save the MIME part under point."
4575 (gnus-article-check-buffer)
4576 (let ((data (get-text-property (point) 'gnus-data)))
4578 (mm-save-part data))))
4580 (defun gnus-mime-pipe-part ()
4581 "Pipe the MIME part under point to a process."
4583 (gnus-article-check-buffer)
4584 (let ((data (get-text-property (point) 'gnus-data)))
4586 (mm-pipe-part data))))
4588 (defun gnus-mime-view-part ()
4589 "Interactively choose a viewing method for the MIME part under point."
4591 (gnus-article-check-buffer)
4592 (let ((data (get-text-property (point) 'gnus-data)))
4594 (setq gnus-article-mime-handles
4596 gnus-article-mime-handles (setq data (copy-sequence data))))
4597 (mm-interactively-view-part data))))
4599 (defun gnus-mime-view-part-as-type-internal ()
4600 (gnus-article-check-buffer)
4601 (let* ((name (mail-content-type-get
4602 (mm-handle-type (get-text-property (point) 'gnus-data))
4604 (def-type (and name (mm-default-file-encoding name))))
4605 (and def-type (cons def-type 0))))
4607 (defun gnus-mime-view-part-as-type (&optional mime-type)
4608 "Choose a MIME media type, and view the part as such."
4611 (setq mime-type (completing-read
4612 "View as MIME type: "
4613 (mapcar #'list (mailcap-mime-types))
4615 (gnus-mime-view-part-as-type-internal))))
4616 (gnus-article-check-buffer)
4617 (let ((handle (get-text-property (point) 'gnus-data)))
4620 (mm-make-handle (mm-handle-buffer handle)
4621 (cons mime-type (cdr (mm-handle-type handle)))
4622 (mm-handle-encoding handle)
4623 (mm-handle-undisplayer handle)
4624 (mm-handle-disposition handle)
4625 (mm-handle-description handle)
4627 (mm-handle-id handle)))
4628 (setq gnus-article-mime-handles
4629 (mm-merge-handles gnus-article-mime-handles handle))
4630 (gnus-mm-display-part handle))))
4632 (defun gnus-mime-copy-part (&optional handle arg)
4633 "Put the MIME part under point into a new buffer.
4634 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4636 (interactive (list nil current-prefix-arg))
4637 (gnus-article-check-buffer)
4639 (setq handle (get-text-property (point) 'gnus-data)))
4641 (let ((filename (or (mail-content-type-get (mm-handle-disposition handle)
4643 (mail-content-type-get (mm-handle-disposition handle)
4645 contents dont-decode charset coding-system)
4646 (mm-with-unibyte-buffer
4647 (mm-insert-part handle)
4648 (setq contents (or (condition-case nil
4649 (mm-decompress-buffer filename nil 'sig)
4651 (setq dont-decode t)
4654 (setq filename (cond (filename (file-name-nondirectory filename))
4655 (dont-decode "*raw data*")
4660 (unless (setq charset (mail-content-type-get
4661 (mm-handle-type handle) 'charset))
4662 (unless (setq coding-system (mm-with-unibyte-buffer
4664 (mm-find-buffer-file-coding-system)))
4665 (setq charset gnus-newsgroup-charset))))
4667 (setq charset (or (cdr (assq arg
4668 gnus-summary-show-article-charset-alist))
4669 (mm-read-coding-system "Charset: ")))))
4670 (switch-to-buffer (generate-new-buffer filename))
4671 (if (or coding-system
4673 (setq coding-system (mm-charset-to-coding-system charset))
4674 (not (eq charset 'ascii))))
4676 (mm-enable-multibyte)
4677 (insert (mm-decode-coding-string contents coding-system))
4678 (setq buffer-file-coding-system
4679 (if (boundp 'last-coding-system-used)
4680 (symbol-value 'last-coding-system-used)
4682 (mm-disable-multibyte)
4684 (setq buffer-file-coding-system mm-binary-coding-system))
4685 ;; We do it this way to make `normal-mode' set the appropriate mode.
4688 (setq buffer-file-name (expand-file-name filename))
4690 (setq buffer-file-name nil))
4691 (goto-char (point-min)))))
4693 (defun gnus-mime-print-part (&optional handle filename)
4694 "Print the MIME part under point."
4695 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4696 (gnus-article-check-buffer)
4697 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4698 (contents (and handle (mm-get-part handle)))
4699 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4700 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4705 (mm-save-part-to-file handle file)
4706 (call-process shell-file-name nil
4707 (generate-new-buffer " *mm*")
4709 shell-command-switch
4711 printer file (mm-handle-type handle))))
4715 (gnus-print-buffer))
4716 (ps-despool filename)))))
4718 (defun gnus-mime-inline-part (&optional handle arg)
4719 "Insert the MIME part under point into the current buffer.
4720 Compressed files like .gz and .bz2 are decompressed."
4721 (interactive (list nil current-prefix-arg))
4722 (gnus-article-check-buffer)
4724 (setq handle (get-text-property (point) 'gnus-data)))
4727 (inhibit-read-only t)
4728 contents charset coding-system)
4729 (if (and (not arg) (mm-handle-undisplayer handle))
4730 (mm-remove-part handle)
4731 (mm-with-unibyte-buffer
4732 (mm-insert-part handle)
4734 (or (mm-decompress-buffer
4735 (or (mail-content-type-get (mm-handle-disposition handle)
4737 (mail-content-type-get (mm-handle-disposition handle)
4743 (unless (setq charset (mail-content-type-get
4744 (mm-handle-type handle) 'charset))
4745 (unless (setq coding-system
4746 (mm-with-unibyte-buffer
4748 (mm-find-buffer-file-coding-system)))
4749 (setq charset gnus-newsgroup-charset))))
4751 (if (mm-handle-undisplayer handle)
4752 (mm-remove-part handle))
4755 gnus-summary-show-article-charset-alist))
4756 (mm-read-coding-system "Charset: "))))
4758 (if (mm-handle-undisplayer handle)
4759 (mm-remove-part handle))))
4763 (if (or coding-system
4766 (mm-charset-to-coding-system charset))
4767 (not (eq coding-system 'ascii))))
4768 (mm-decode-coding-string contents coding-system)
4769 (mm-string-to-multibyte contents)))
4772 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4773 "Insert the MIME part under point into the current buffer using the
4775 (interactive (list nil current-prefix-arg))
4776 (gnus-article-check-buffer)
4777 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4780 (inhibit-read-only t))
4782 (if (mm-handle-undisplayer handle)
4783 (mm-remove-part handle))
4784 (let ((gnus-newsgroup-charset
4786 gnus-summary-show-article-charset-alist))
4787 (mm-read-coding-system "Charset: ")))
4788 (gnus-newsgroup-ignored-charsets 'gnus-all))
4789 (gnus-article-press-button)))))
4791 (defun gnus-mime-view-part-externally (&optional handle)
4792 "View the MIME part under point with an external viewer."
4794 (gnus-article-check-buffer)
4795 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4796 (mm-user-display-methods nil)
4797 (mm-inlined-types nil)
4798 (mail-parse-charset gnus-newsgroup-charset)
4799 (mail-parse-ignored-charsets
4800 (with-current-buffer gnus-summary-buffer
4801 gnus-newsgroup-ignored-charsets)))
4803 (if (mm-handle-undisplayer handle)
4804 (mm-remove-part handle)
4805 (mm-display-part handle)))))
4807 (defun gnus-mime-view-part-internally (&optional handle)
4808 "View the MIME part under point with an internal viewer.
4809 If no internal viewer is available, use an external viewer."
4811 (gnus-article-check-buffer)
4812 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4813 (mm-inlined-types '(".*"))
4814 (mm-inline-large-images t)
4815 (mail-parse-charset gnus-newsgroup-charset)
4816 (mail-parse-ignored-charsets
4817 (with-current-buffer gnus-summary-buffer
4818 gnus-newsgroup-ignored-charsets))
4819 (inhibit-read-only t))
4821 (if (mm-handle-undisplayer handle)
4822 (mm-remove-part handle)
4823 (mm-display-part handle)))))
4825 (defun gnus-mime-action-on-part (&optional action)
4826 "Do something with the MIME attachment at \(point\)."
4828 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4829 (gnus-article-check-buffer)
4830 (let ((action-pair (assoc action gnus-mime-action-alist)))
4832 (funcall (cdr action-pair)))))
4834 (defun gnus-article-part-wrapper (n function)
4835 (with-current-buffer gnus-article-buffer
4836 (when (> n (length gnus-article-mime-handle-alist))
4837 (error "No such part"))
4838 (gnus-article-goto-part n)
4839 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4840 (funcall function handle))))
4842 (defun gnus-article-pipe-part (n)
4843 "Pipe MIME part N, which is the numerical prefix."
4845 (gnus-article-part-wrapper n 'mm-pipe-part))
4847 (defun gnus-article-save-part (n)
4848 "Save MIME part N, which is the numerical prefix."
4850 (gnus-article-part-wrapper n 'mm-save-part))
4852 (defun gnus-article-interactively-view-part (n)
4853 "View MIME part N interactively, which is the numerical prefix."
4855 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4857 (defun gnus-article-copy-part (n)
4858 "Copy MIME part N, which is the numerical prefix."
4860 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4862 (defun gnus-article-view-part-as-charset (n)
4863 "View MIME part N using a specified charset.
4864 N is the numerical prefix."
4866 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4868 (defun gnus-article-view-part-externally (n)
4869 "View MIME part N externally, which is the numerical prefix."
4871 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4873 (defun gnus-article-inline-part (n)
4874 "Inline MIME part N, which is the numerical prefix."
4876 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4878 (defun gnus-article-mime-match-handle-first (condition)
4881 (dolist (ihandle gnus-article-mime-handle-alist)
4883 ((functionp condition)
4884 (funcall condition (cdr ihandle)))
4885 ((eq condition 'undisplayed)
4886 (not (or (mm-handle-undisplayer (cdr ihandle))
4887 (equal (mm-handle-media-type (cdr ihandle))
4888 "multipart/alternative"))))
4889 ((eq condition 'undisplayed-alternative)
4890 (not (mm-handle-undisplayer (cdr ihandle))))
4892 (gnus-article-goto-part (car ihandle))
4893 (or (not n) (< (car ihandle) n)))
4894 (setq n (car ihandle))))
4898 (defun gnus-article-view-part (&optional n)
4899 "View MIME part N, which is the numerical prefix."
4901 (with-current-buffer gnus-article-buffer
4902 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4903 gnus-article-mime-match-handle-function)))
4904 (when (> n (length gnus-article-mime-handle-alist))
4905 (error "No such part"))
4906 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4907 (when (gnus-article-goto-part n)
4908 (if (equal (car handle) "multipart/alternative")
4909 (gnus-article-press-button)
4910 (when (eq (gnus-mm-display-part handle) 'internal)
4911 (gnus-set-window-start)))))))
4913 (defsubst gnus-article-mime-total-parts ()
4914 (if (bufferp (car gnus-article-mime-handles))
4916 (1- (length gnus-article-mime-handles))))
4918 (defun gnus-mm-display-part (handle)
4919 "Display HANDLE and fix MIME button."
4920 (let ((id (get-text-property (point) 'gnus-part))
4922 (inhibit-read-only t))
4925 (let ((window (selected-window))
4926 (mail-parse-charset gnus-newsgroup-charset)
4927 (mail-parse-ignored-charsets
4928 (if (gnus-buffer-live-p gnus-summary-buffer)
4929 (with-current-buffer gnus-summary-buffer
4930 gnus-newsgroup-ignored-charsets)
4934 (let ((win (gnus-get-buffer-window (current-buffer) t))
4937 (select-window win))
4940 (if (mm-handle-displayed-p handle)
4941 ;; This will remove the part.
4942 (mm-display-part handle)
4944 (narrow-to-region (point)
4945 (if (eobp) (point) (1+ (point))))
4946 (mm-display-part handle)
4947 ;; We narrow to the part itself and
4948 ;; then call the treatment functions.
4949 (goto-char (point-min))
4951 (narrow-to-region (point) (point-max))
4954 (gnus-article-mime-total-parts)
4955 (mm-handle-media-type handle)))))
4956 (if (window-live-p window)
4957 (select-window window)))))
4960 (gnus-insert-mime-button
4961 handle id (list (mm-handle-displayed-p handle)))
4962 (goto-char point))))
4964 (defun gnus-article-goto-part (n)
4965 "Go to MIME part N."
4966 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4968 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4969 (let ((gnus-tmp-name
4970 (or (mail-content-type-get (mm-handle-type handle) 'name)
4971 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4972 (mail-content-type-get (mm-handle-type handle) 'url)
4974 (gnus-tmp-type (mm-handle-media-type handle))
4975 (gnus-tmp-description
4976 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4979 (if (if displayed (car displayed)
4980 (mm-handle-displayed-p handle))
4982 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4984 gnus-tmp-type-long b e)
4985 (when (string-match ".*/" gnus-tmp-name)
4986 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4987 (setq gnus-tmp-type-long (concat gnus-tmp-type
4988 (and (not (equal gnus-tmp-name ""))
4989 (concat "; " gnus-tmp-name))))
4990 (unless (equal gnus-tmp-description "")
4991 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4996 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4997 `(keymap ,gnus-mime-button-map
4998 gnus-callback gnus-mm-display-part
4999 gnus-part ,gnus-tmp-id
5000 article-type annotation
5003 ;; Exclude a newline.
5006 (widget-convert-button
5009 :action 'gnus-widget-press-button
5010 :button-keymap gnus-mime-button-map
5012 (lambda (widget/window &optional overlay pos)
5013 ;; Needed to properly clear the message due to a bug in
5014 ;; wid-edit (XEmacs only).
5015 (if (boundp 'help-echo-owns-message)
5016 (setq help-echo-owns-message t))
5018 "%S: %s the MIME part; %S: more options"
5019 (aref gnus-mouse-2 0)
5020 ;; XEmacs will get a single widget arg; Emacs 21 will get
5021 ;; window, overlay, position.
5022 (if (mm-handle-displayed-p
5024 (with-current-buffer (gnus-overlay-buffer overlay)
5025 (widget-get (widget-at (gnus-overlay-start overlay))
5027 (widget-get widget/window :mime-handle)))
5029 (aref gnus-down-mouse-3 0))))))
5031 (defun gnus-widget-press-button (elems el)
5032 (goto-char (widget-get elems :from))
5033 (gnus-article-press-button))
5035 (defvar gnus-displaying-mime nil)
5037 (defun gnus-display-mime (&optional ihandles)
5038 "Display the MIME parts."
5040 (save-selected-window
5041 (let ((window (get-buffer-window gnus-article-buffer))
5044 (select-window window)
5045 ;; We have to do this since selecting the window
5046 ;; may change the point. So we set the window point.
5047 (set-window-point window point)))
5048 (let ((handles ihandles)
5049 (inhibit-read-only t)
5052 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
5053 (when gnus-article-emulate-mime
5054 (mm-uu-dissect-text-parts handles)))
5055 (gnus-article-emulate-mime
5056 (setq handles (mm-uu-dissect))))
5057 (when (and (not ihandles)
5058 (not gnus-displaying-mime))
5059 ;; Top-level call; we clean up.
5060 (when gnus-article-mime-handles
5061 (mm-destroy-parts gnus-article-mime-handles)
5062 (setq gnus-article-mime-handle-alist nil));; A trick.
5063 (setq gnus-article-mime-handles handles)
5064 ;; We allow users to glean info from the handles.
5065 (when gnus-article-mime-part-function
5066 (gnus-mime-part-function handles)))
5068 (or (not (stringp (car handles)))
5071 (when (and (not ihandles)
5072 (not gnus-displaying-mime))
5073 ;; Clean up for mime parts.
5075 (delete-region (point) (point-max)))
5076 (let ((gnus-displaying-mime t))
5077 (gnus-mime-display-part handles)))
5080 (narrow-to-region (point) (point-max))
5081 (gnus-treat-article nil 1 1)
5084 ;; Highlight the headers.
5088 (narrow-to-region (point-min) (point))
5089 (gnus-article-save-original-date
5090 (gnus-treat-article 'head)))))))))
5092 (defcustom gnus-mime-display-multipart-as-mixed nil
5093 "Display \"multipart\" parts as \"multipart/mixed\".
5095 If t, it overrides nil values of
5096 `gnus-mime-display-multipart-alternative-as-mixed' and
5097 `gnus-mime-display-multipart-related-as-mixed'."
5098 :group 'gnus-article-mime
5101 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
5102 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
5104 :group 'gnus-article-mime
5107 (defcustom gnus-mime-display-multipart-related-as-mixed nil
5108 "Display \"multipart/related\" parts as \"multipart/mixed\".
5110 If displaying \"text/html\" is discouraged \(see
5111 `mm-discouraged-alternatives'\) images or other material inside a
5112 \"multipart/related\" part might be overlooked when this variable is nil."
5114 :group 'gnus-article-mime
5117 (defun gnus-mime-display-part (handle)
5120 ((not (stringp (car handle)))
5121 (gnus-mime-display-single handle))
5122 ;; User-defined multipart
5123 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
5124 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
5126 ;; multipart/alternative
5127 ((and (equal (car handle) "multipart/alternative")
5128 (not (or gnus-mime-display-multipart-as-mixed
5129 gnus-mime-display-multipart-alternative-as-mixed)))
5130 (let ((id (1+ (length gnus-article-mime-handle-alist))))
5131 (push (cons id handle) gnus-article-mime-handle-alist)
5132 (gnus-mime-display-alternative (cdr handle) nil nil id)))
5133 ;; multipart/related
5134 ((and (equal (car handle) "multipart/related")
5135 (not (or gnus-mime-display-multipart-as-mixed
5136 gnus-mime-display-multipart-related-as-mixed)))
5137 ;;;!!!We should find the start part, but we just default
5138 ;;;!!!to the first part.
5139 ;;(gnus-mime-display-part (cadr handle))
5140 ;;;!!! Most multipart/related is an HTML message plus images.
5141 ;;;!!! Unfortunately we are unable to let W3 display those
5142 ;;;!!! included images, so we just display it as a mixed multipart.
5143 ;;(gnus-mime-display-mixed (cdr handle))
5144 ;;;!!! No, w3 can display everything just fine.
5145 (gnus-mime-display-part (cadr handle)))
5146 ((equal (car handle) "multipart/signed")
5147 (gnus-add-wash-type 'signed)
5148 (gnus-mime-display-security handle))
5149 ((equal (car handle) "multipart/encrypted")
5150 (gnus-add-wash-type 'encrypted)
5151 (gnus-mime-display-security handle))
5152 ;; Other multiparts are handled like multipart/mixed.
5154 (gnus-mime-display-mixed (cdr handle)))))
5156 (defun gnus-mime-part-function (handles)
5157 (if (stringp (car handles))
5158 (mapcar 'gnus-mime-part-function (cdr handles))
5159 (funcall gnus-article-mime-part-function handles)))
5161 (defun gnus-mime-display-mixed (handles)
5162 (mapcar 'gnus-mime-display-part handles))
5164 (defun gnus-mime-display-single (handle)
5165 (let ((type (mm-handle-media-type handle))
5166 (ignored gnus-ignored-mime-types)
5173 (when (string-match (pop ignored) type)
5174 (throw 'ignored nil)))
5175 (if (and (setq not-attachment
5176 (and (not (mm-inline-override-p handle))
5177 (or (not (mm-handle-disposition handle))
5178 (equal (car (mm-handle-disposition handle))
5180 (mm-attachment-override-p handle))))
5181 (mm-automatic-display-p handle)
5183 (mm-inlinable-p handle)
5184 (mm-inlined-p handle))
5185 (mm-automatic-external-display-p type)))
5187 (when (equal (mm-handle-media-supertype handle) "text")
5189 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5191 (push (cons id handle) gnus-article-mime-handle-alist)
5192 (when (or (not display)
5193 (not (gnus-unbuttonized-mime-type-p type)))
5194 (gnus-insert-mime-button
5195 handle id (list (or display (and not-attachment text))))
5196 (gnus-article-insert-newline)
5197 ;; Remember modify the number of forward lines.
5205 (let ((mail-parse-charset gnus-newsgroup-charset)
5206 (mail-parse-ignored-charsets
5207 (save-excursion (condition-case ()
5208 (set-buffer gnus-summary-buffer)
5210 gnus-newsgroup-ignored-charsets)))
5211 (mm-display-part handle t))
5212 (goto-char (point-max)))
5213 ((and text not-attachment)
5217 (gnus-article-insert-newline)
5218 (mm-display-inline handle)
5219 (goto-char (point-max))))
5223 (narrow-to-region beg (point))
5226 (gnus-article-mime-total-parts)
5227 (mm-handle-media-type handle)))))))))
5229 (defun gnus-unbuttonized-mime-type-p (type)
5230 "Say whether TYPE is to be unbuttonized."
5231 (unless gnus-inhibit-mime-unbuttonizing
5233 (let ((types gnus-unbuttonized-mime-types))
5235 (when (string-match (pop types) type)
5236 (throw 'found t)))))
5238 (let ((types gnus-buttonized-mime-types))
5240 (when (string-match (pop types) type)
5241 (throw 'found t)))))))))
5243 (defun gnus-article-insert-newline ()
5244 "Insert a newline, but mark it as undeletable."
5245 (gnus-put-text-property
5246 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5248 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5249 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5252 handle (inhibit-read-only t) from props begend not-pref)
5253 (save-window-excursion
5256 (narrow-to-region (car ibegend)
5259 (goto-char (car ibegend))
5262 (delete-region (point-min) (point-max))
5263 (mm-remove-parts handles))
5264 (setq begend (list (point-marker)))
5266 (unless (setq not-pref (cadr (member preferred ihandles)))
5267 (setq not-pref (car ihandles)))
5270 (not (gnus-unbuttonized-mime-type-p
5271 "multipart/alternative")))
5272 (gnus-add-text-properties
5275 (insert (format "%d. " id))
5279 (unless ,(not ibegend)
5280 (setq gnus-article-mime-handle-alist
5281 ',gnus-article-mime-handle-alist))
5282 (gnus-mime-display-alternative
5283 ',ihandles ',not-pref ',begend ,id))
5284 keymap ,gnus-mime-button-map
5285 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5286 face ,gnus-article-button-face
5289 (widget-convert-button 'link from (point)
5290 :action 'gnus-widget-press-button
5291 :button-keymap gnus-widget-button-keymap)
5293 (while (setq handle (pop handles))
5294 (gnus-add-text-properties
5297 (insert (format "(%c) %-18s"
5298 (if (equal handle preferred) ?* ? )
5299 (mm-handle-media-type handle)))
5303 (unless ,(not ibegend)
5304 (setq gnus-article-mime-handle-alist
5305 ',gnus-article-mime-handle-alist))
5306 (gnus-mime-display-alternative
5307 ',ihandles ',handle ',begend ,id))
5308 keymap ,gnus-mime-button-map
5309 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5310 face ,gnus-article-button-face
5313 (widget-convert-button 'link from (point)
5314 :action 'gnus-widget-press-button
5315 :button-keymap gnus-widget-button-keymap)
5319 (if (stringp (car preferred))
5320 (gnus-display-mime preferred)
5321 (let ((mail-parse-charset gnus-newsgroup-charset)
5322 (mail-parse-ignored-charsets
5323 (with-current-buffer gnus-summary-buffer
5324 gnus-newsgroup-ignored-charsets)))
5325 (mm-display-part preferred)
5329 (narrow-to-region (car begend) (point-max))
5331 nil (length gnus-article-mime-handle-alist)
5332 (gnus-article-mime-total-parts)
5333 (mm-handle-media-type handle))))))
5334 (goto-char (point-max))
5335 (setcdr begend (point-marker)))))
5337 (goto-char point))))
5339 (defconst gnus-article-wash-status-strings
5340 (let ((alist '((cite "c" "Possible hidden citation text"
5341 " " "All citation text visible")
5342 (headers "h" "Hidden headers"
5343 " " "All headers visible.")
5344 (pgp "p" "Encrypted or signed message status hidden"
5345 " " "No hidden encryption nor digital signature status")
5346 (signature "s" "Signature has been hidden"
5347 " " "Signature is visible")
5348 (overstrike "o" "Overstrike (^H) characters applied"
5349 " " "No overstrike characters applied")
5350 (gnus-show-mime "m" "Mime processing is activated"
5351 " " "Mime processing is not activated")
5352 (emphasis "e" "/*_Emphasis_*/ characters applied"
5353 " " "No /*_emphasis_*/ characters applied")))
5355 (dolist (entry alist result)
5356 (let ((key (nth 0 entry))
5357 (on (copy-sequence (nth 1 entry)))
5358 (on-help (nth 2 entry))
5359 (off (copy-sequence (nth 3 entry)))
5360 (off-help (nth 4 entry)))
5361 (put-text-property 0 1 'help-echo on-help on)
5362 (put-text-property 0 1 'help-echo off-help off)
5363 (push (list key on off) result))))
5364 "Alist of strings describing wash status in the mode line.
5365 Each entry has the form (KEY ON OF), where the KEY is a symbol
5366 representing the particular washing function, ON is the string to use
5367 in the article mode line when the washing function is active, and OFF
5368 is the string to use when it is inactive.")
5370 (defun gnus-article-wash-status-entry (key value)
5371 (let ((entry (assoc key gnus-article-wash-status-strings)))
5372 (if value (nth 1 entry) (nth 2 entry))))
5374 (defun gnus-article-wash-status ()
5375 "Return a string which display status of article washing."
5376 (with-current-buffer gnus-article-buffer
5377 (let ((cite (memq 'cite gnus-article-wash-types))
5378 (headers (memq 'headers gnus-article-wash-types))
5379 (boring (memq 'boring-headers gnus-article-wash-types))
5380 (pgp (memq 'pgp gnus-article-wash-types))
5381 (pem (memq 'pem gnus-article-wash-types))
5382 (signed (memq 'signed gnus-article-wash-types))
5383 (encrypted (memq 'encrypted gnus-article-wash-types))
5384 (signature (memq 'signature gnus-article-wash-types))
5385 (overstrike (memq 'overstrike gnus-article-wash-types))
5386 (emphasis (memq 'emphasis gnus-article-wash-types)))
5388 (gnus-article-wash-status-entry 'cite cite)
5389 (gnus-article-wash-status-entry 'headers (or headers boring))
5390 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5391 (gnus-article-wash-status-entry 'signature signature)
5392 (gnus-article-wash-status-entry 'overstrike overstrike)
5393 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
5394 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5396 (defun gnus-add-wash-type (type)
5397 "Add a washing of TYPE to the current status."
5398 (add-to-list 'gnus-article-wash-types type))
5400 (defun gnus-delete-wash-type (type)
5401 "Add a washing of TYPE to the current status."
5402 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5404 (defun gnus-add-image (category image)
5405 "Add IMAGE of CATEGORY to the list of displayed images."
5406 (let ((entry (assq category gnus-article-image-alist)))
5408 (setq entry (list category))
5409 (push entry gnus-article-image-alist))
5410 (nconc entry (list image))))
5412 (defun gnus-delete-images (category)
5413 "Delete all images in CATEGORY."
5414 (let ((entry (assq category gnus-article-image-alist)))
5415 (dolist (image (cdr entry))
5416 (gnus-remove-image image category))
5417 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5418 (gnus-delete-wash-type category)))
5420 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5422 (defun gnus-article-maybe-hide-headers ()
5423 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5424 Provided for backwards compatibility."
5425 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5426 (not (with-current-buffer gnus-summary-buffer
5427 gnus-have-all-headers)))
5428 (not gnus-inhibit-hiding))
5429 (gnus-article-hide-headers)))
5433 (defun gnus-output-to-file (file-name)
5434 "Append the current article to a file named FILE-NAME."
5435 (let ((artbuf (current-buffer)))
5437 (insert-buffer-substring artbuf)
5438 ;; Append newline at end of the buffer as separator, and then
5440 (goto-char (point-max))
5442 (let ((file-name-coding-system nnmail-pathname-coding-system))
5443 (write-region-as-binary (point-min) (point-max) file-name 'append))
5446 (defun gnus-narrow-to-page (&optional arg)
5447 "Narrow the article buffer to a page.
5448 If given a numerical ARG, move forward ARG pages."
5450 (setq arg (if arg (prefix-numeric-value arg) 0))
5452 (set-buffer gnus-article-buffer)
5453 (goto-char (point-min))
5455 ;; Remove any old next/prev buttons.
5456 (when (gnus-visual-p 'page-marker)
5457 (let ((inhibit-read-only t))
5458 (gnus-remove-text-with-property 'gnus-prev)
5459 (gnus-remove-text-with-property 'gnus-next)))
5462 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5464 (re-search-forward page-delimiter nil 'move arg)))
5465 (goto-char (match-end 0))
5467 (goto-char (point-min))
5468 (setq gnus-page-broken
5469 (and (re-search-forward page-delimiter nil t) t))))
5470 (when gnus-page-broken
5473 (if (re-search-forward page-delimiter nil 'move)
5476 (when (and (gnus-visual-p 'page-marker)
5477 (> (point-min) (save-restriction (widen) (point-min))))
5479 (goto-char (point-min))
5480 (gnus-insert-prev-page-button)))
5481 (when (and (gnus-visual-p 'page-marker)
5482 (< (point-max) (save-restriction (widen) (point-max))))
5484 (goto-char (point-max))
5485 (gnus-insert-next-page-button))))))
5487 ;; Article mode commands
5489 (defun gnus-article-goto-next-page ()
5490 "Show the next page of the article."
5492 (when (gnus-article-next-page)
5493 (goto-char (point-min))
5494 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5497 (defun gnus-article-goto-prev-page ()
5498 "Show the previous page of the article."
5501 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5502 (gnus-article-prev-page nil)))
5504 ;; This is cleaner but currently breaks `gnus-pick-mode':
5506 ;; (defun gnus-article-goto-next-page ()
5507 ;; "Show the next page of the article."
5509 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5510 ;; (gnus-summary-next-page)))
5512 ;; (defun gnus-article-goto-prev-page ()
5513 ;; "Show the next page of the article."
5515 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5516 ;; (gnus-summary-prev-page)))
5518 (defun gnus-article-next-page (&optional lines)
5519 "Show the next page of the current article.
5520 If end of article, return non-nil. Otherwise return nil.
5521 Argument LINES specifies lines to be scrolled up."
5523 (move-to-window-line -1)
5526 (and (pos-visible-in-window-p) ;Not continuation line.
5527 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5528 ;; Nothing in this page.
5529 (if (or (not gnus-page-broken)
5534 (eobp)))) ;Real end-of-buffer?
5536 (when gnus-article-over-scroll
5537 (gnus-article-next-page-1 lines))
5539 (gnus-narrow-to-page 1) ;Go to next page.
5541 ;; More in this page.
5542 (gnus-article-next-page-1 lines)
5545 (defun gnus-article-next-page-1 (lines)
5546 (let ((scroll-in-place nil))
5550 ;; Long lines may cause an end-of-buffer error.
5551 (goto-char (point-max)))))
5552 (move-to-window-line 0))
5554 (defun gnus-article-prev-page (&optional lines)
5555 "Show previous page of current article.
5556 Argument LINES specifies lines to be scrolled down."
5558 (move-to-window-line 0)
5559 (if (and gnus-page-broken
5561 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5563 (gnus-narrow-to-page -1) ;Go to previous page.
5564 (goto-char (point-max))
5566 (let ((scroll-in-place nil))
5570 (beginning-of-buffer
5571 (goto-char (point-min))))
5572 (move-to-window-line 0)))))
5574 (defun gnus-article-only-boring-p ()
5575 "Decide whether there is only boring text remaining in the article.
5576 Something \"interesting\" is a word of at least two letters that does
5577 not have a face in `gnus-article-boring-faces'."
5578 (when (and gnus-article-skip-boring
5579 (boundp 'gnus-article-boring-faces)
5580 (symbol-value 'gnus-article-boring-faces))
5583 (while (re-search-forward "\\b\\w\\w" nil t)
5585 (when (not (gnus-intersection
5586 (gnus-faces-at (point))
5587 (symbol-value 'gnus-article-boring-faces)))
5588 (throw 'only-boring nil)))
5589 (throw 'only-boring t)))))
5591 (defun gnus-article-refer-article ()
5592 "Read article specified by message-id around point."
5595 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5596 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5597 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5598 (let ((msg-id (concat "<" (match-string 0) ">")))
5599 (set-buffer gnus-summary-buffer)
5600 (gnus-summary-refer-article msg-id))
5601 (error "No references around point"))))
5603 (defun gnus-article-show-summary ()
5604 "Reconfigure windows to show summary buffer."
5606 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5607 (error "There is no summary buffer for this article buffer")
5608 (gnus-article-set-globals)
5609 (gnus-configure-windows 'article)
5610 (gnus-summary-goto-subject gnus-current-article)
5611 (gnus-summary-position-point)))
5613 (defun gnus-article-describe-briefly ()
5614 "Describe article mode commands briefly."
5616 (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")))
5618 (defun gnus-article-summary-command ()
5619 "Execute the last keystroke in the summary buffer."
5621 (let ((obuf (current-buffer))
5622 (owin (current-window-configuration))
5624 (switch-to-buffer gnus-article-current-summary 'norecord)
5625 (setq func (lookup-key (current-local-map) (this-command-keys)))
5626 (call-interactively func)
5628 (set-window-configuration owin)
5629 (set-window-point (get-buffer-window (current-buffer)) (point))))
5631 (defun gnus-article-summary-command-nosave ()
5632 "Execute the last keystroke in the summary buffer."
5635 (pop-to-buffer gnus-article-current-summary 'norecord)
5636 (setq func (lookup-key (current-local-map) (this-command-keys)))
5637 (call-interactively func)))
5639 (defun gnus-article-check-buffer ()
5640 "Beep if not in an article buffer."
5641 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5642 (error "Command invoked outside of a Gnus article buffer")))
5644 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5645 "Read a summary buffer key sequence and execute it from the article buffer."
5647 (gnus-article-check-buffer)
5649 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5650 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5651 "=" "^" "\M-^" "|"))
5657 '("n" "Gn" "p" "Gp"))
5660 (set-buffer gnus-article-current-summary)
5661 (let (gnus-pick-mode)
5662 (push (or key last-command-event) unread-command-events)
5663 (setq keys (static-if (featurep 'xemacs)
5664 (events-to-keys (read-key-sequence nil))
5665 (read-key-sequence nil)))))
5668 (if (or (member keys nosaves)
5669 (member keys nosave-but-article)
5670 (member keys nosave-in-article))
5672 (save-window-excursion
5673 (pop-to-buffer gnus-article-current-summary 'norecord)
5674 ;; We disable the pick minor mode commands.
5675 (let (gnus-pick-mode)
5676 (setq func (lookup-key (current-local-map) keys))))
5680 (unless (member keys nosave-in-article)
5681 (set-buffer gnus-article-current-summary))
5682 (call-interactively func)
5683 (setq new-sum-point (point)))
5684 (when (member keys nosave-but-article)
5685 (pop-to-buffer gnus-article-buffer 'norecord)))
5686 ;; These commands should restore window configuration.
5687 (let ((obuf (current-buffer))
5688 (owin (current-window-configuration))
5690 win func in-buffer selected new-sum-start new-sum-hscroll)
5691 (cond (not-restore-window
5692 (pop-to-buffer gnus-article-current-summary 'norecord))
5693 ((setq win (get-buffer-window gnus-article-current-summary))
5694 (select-window win))
5696 (switch-to-buffer gnus-article-current-summary 'norecord)))
5697 (setq in-buffer (current-buffer))
5698 ;; We disable the pick minor mode commands.
5699 (if (and (setq func (let (gnus-pick-mode)
5700 (lookup-key (current-local-map) keys)))
5703 (call-interactively func)
5704 (when (eq win (selected-window))
5705 (setq new-sum-point (point)
5706 new-sum-start (window-start win)
5707 new-sum-hscroll (window-hscroll win)))
5708 (when (eq in-buffer (current-buffer))
5709 (setq selected (gnus-summary-select-article))
5711 (unless not-restore-window
5712 (set-window-configuration owin))
5713 (when (eq selected 'old)
5715 (set-window-start (get-buffer-window (current-buffer))
5717 (set-window-point (get-buffer-window (current-buffer))
5719 (when (and (not not-restore-window)
5721 (set-window-point win new-sum-point)
5722 (set-window-start win new-sum-start)
5723 (set-window-hscroll win new-sum-hscroll))))
5724 (set-window-configuration owin)
5727 (defun gnus-article-describe-key (key)
5728 "Display documentation of the function invoked by KEY. KEY is a string."
5729 (interactive "kDescribe key: ")
5730 (gnus-article-check-buffer)
5731 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5733 (set-buffer gnus-article-current-summary)
5734 (let (gnus-pick-mode)
5735 (if (featurep 'xemacs)
5737 (push (elt key 0) unread-command-events)
5738 (setq key (events-to-keys
5739 (read-key-sequence "Describe key: "))))
5740 (setq unread-command-events
5742 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5744 (setq key (read-key-sequence "Describe key: "))))
5746 (describe-key key)))
5748 (defun gnus-article-describe-key-briefly (key &optional insert)
5749 "Display documentation of the function invoked by KEY. KEY is a string."
5750 (interactive "kDescribe key: \nP")
5751 (gnus-article-check-buffer)
5752 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5754 (set-buffer gnus-article-current-summary)
5755 (let (gnus-pick-mode)
5756 (if (featurep 'xemacs)
5758 (push (elt key 0) unread-command-events)
5759 (setq key (events-to-keys
5760 (read-key-sequence "Describe key: "))))
5761 (setq unread-command-events
5763 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5765 (setq key (read-key-sequence "Describe key: "))))
5766 (describe-key-briefly key insert))
5767 (describe-key-briefly key insert)))
5769 (defun gnus-article-reply-with-original (&optional wide)
5770 "Start composing a reply mail to the current message.
5771 The text in the region will be yanked. If the region isn't active,
5772 the entire article will be yanked."
5774 (let ((article (cdr gnus-article-current))
5776 (if (not (gnus-region-active-p))
5777 (with-current-buffer gnus-summary-buffer
5778 (gnus-summary-reply (list (list article)) wide))
5779 (setq contents (buffer-substring (point) (mark t)))
5780 ;; Deactivate active regions.
5781 (when (and (boundp 'transient-mark-mode)
5782 transient-mark-mode)
5783 (setq mark-active nil))
5784 (with-current-buffer gnus-summary-buffer
5786 (list (list article contents)) wide)))))
5788 (defun gnus-article-followup-with-original ()
5789 "Compose a followup to the current article.
5790 The text in the region will be yanked. If the region isn't active,
5791 the entire article will be yanked."
5793 (let ((article (cdr gnus-article-current))
5795 (if (not (gnus-region-active-p))
5796 (with-current-buffer gnus-summary-buffer
5797 (gnus-summary-followup (list (list article))))
5798 (setq contents (buffer-substring (point) (mark t)))
5799 ;; Deactivate active regions.
5800 (when (and (boundp 'transient-mark-mode)
5801 transient-mark-mode)
5802 (setq mark-active nil))
5803 (with-current-buffer gnus-summary-buffer
5804 (gnus-summary-followup
5805 (list (list article contents)))))))
5807 (defun gnus-article-hide (&optional arg force)
5808 "Hide all the gruft in the current article.
5809 This means that signatures, cited text and (some) headers will be
5811 If given a prefix, show the hidden text instead."
5812 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5813 (gnus-article-hide-headers arg)
5814 (gnus-article-hide-list-identifiers arg)
5815 (gnus-article-hide-citation-maybe arg force)
5816 (gnus-article-hide-signature arg))
5818 (defun gnus-article-maybe-highlight ()
5819 "Do some article highlighting if article highlighting is requested."
5820 (when (gnus-visual-p 'article-highlight 'highlight)
5821 (gnus-article-highlight-some)))
5823 (defun gnus-check-group-server ()
5824 ;; Make sure the connection to the server is alive.
5825 (unless (gnus-server-opened
5826 (gnus-find-method-for-group gnus-newsgroup-name))
5827 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5828 (gnus-request-group gnus-newsgroup-name t)))
5831 (autoload 'nneething-get-file-name "nneething"))
5833 (defun gnus-request-article-this-buffer (article group)
5834 "Get an article and insert it into this buffer."
5835 (let (do-update-line sparse-header)
5839 (gnus-kill-all-overlays)
5840 (setq group (or group gnus-newsgroup-name))
5842 ;; Using `gnus-request-article' directly will insert the article into
5843 ;; `nntp-server-buffer' - so we'll save some time by not having to
5844 ;; copy it from the server buffer into the article buffer.
5846 ;; We only request an article by message-id when we do not have the
5847 ;; headers for it, so we'll have to get those.
5848 (when (stringp article)
5849 (gnus-read-header article))
5851 ;; If the article number is negative, that means that this article
5852 ;; doesn't belong in this newsgroup (possibly), so we find its
5853 ;; message-id and request it by id instead of number.
5854 (when (and (numberp article)
5856 (get-buffer gnus-summary-buffer)
5857 (gnus-buffer-exists-p gnus-summary-buffer))
5859 (set-buffer gnus-summary-buffer)
5860 (let ((header (gnus-summary-article-header article)))
5863 ((memq article gnus-newsgroup-sparse)
5864 ;; This is a sparse gap article.
5865 (setq do-update-line article)
5866 (setq article (mail-header-id header))
5867 (setq sparse-header (gnus-read-header article))
5868 (setq gnus-newsgroup-sparse
5869 (delq article gnus-newsgroup-sparse)))
5871 ;; It's a real article.
5872 (setq article (mail-header-id header)))
5874 ;; It is an extracted pseudo-article.
5875 (setq article 'pseudo)
5876 (gnus-request-pseudo-article header))))
5878 (let ((method (gnus-find-method-for-group
5879 gnus-newsgroup-name)))
5880 (when (and (eq (car method) 'nneething)
5882 (let ((dir (nneething-get-file-name
5883 (mail-header-id header))))
5884 (when (and (stringp dir)
5885 (file-directory-p dir))
5886 (setq article 'nneething)
5887 (gnus-group-enter-directory dir))))))))
5890 ;; Refuse to select canceled articles.
5891 ((and (numberp article)
5893 (get-buffer gnus-summary-buffer)
5894 (gnus-buffer-exists-p gnus-summary-buffer)
5895 (eq (cdr (with-current-buffer gnus-summary-buffer
5896 (assq article gnus-newsgroup-reads)))
5897 gnus-canceled-mark))
5899 ;; We first check `gnus-original-article-buffer'.
5900 ((and (get-buffer gnus-original-article-buffer)
5902 (with-current-buffer gnus-original-article-buffer
5903 (and (equal (car gnus-original-article) group)
5904 (eq (cdr gnus-original-article) article))))
5905 (insert-buffer-substring gnus-original-article-buffer)
5907 ;; Check the backlog.
5908 ((and gnus-keep-backlog
5909 (gnus-backlog-request-article group article (current-buffer)))
5911 ;; Check asynchronous pre-fetch.
5912 ((gnus-async-request-fetched-article group article (current-buffer))
5913 (gnus-async-prefetch-next group article gnus-summary-buffer)
5914 (when (and (numberp article) gnus-keep-backlog)
5915 (gnus-backlog-enter-article group article (current-buffer)))
5918 ((and gnus-use-cache
5920 (gnus-cache-request-article article group))
5922 ;; Check the agent cache.
5923 ((gnus-agent-request-article article group)
5925 ;; Get the article and put into the article buffer.
5926 ((or (stringp article)
5928 (let ((gnus-override-method gnus-override-method)
5929 (methods (and (stringp article)
5930 gnus-refer-article-method))
5931 (backend (car (gnus-find-method-for-group
5932 gnus-newsgroup-name)))
5934 (inhibit-read-only t))
5935 (if (or (not (listp methods))
5936 (and (symbolp (car methods))
5937 (assq (car methods) nnoo-definition-alist)))
5938 (setq methods (list methods)))
5939 (when (and (null gnus-override-method)
5941 (setq gnus-override-method (pop methods)))
5943 (when (eq gnus-override-method 'current)
5944 (setq gnus-override-method
5945 (with-current-buffer gnus-summary-buffer
5946 gnus-current-select-method)))
5948 (gnus-kill-all-overlays)
5949 (let ((gnus-newsgroup-name group))
5950 (gnus-check-group-server))
5952 ((gnus-request-article article group (current-buffer))
5953 (when (numberp article)
5954 (gnus-async-prefetch-next group article
5955 gnus-summary-buffer)
5956 (when gnus-keep-backlog
5957 (gnus-backlog-enter-article
5958 group article (current-buffer))))
5959 (setq result 'article))
5961 (setq gnus-override-method (pop methods)))
5962 ((not (string-match "^400 "
5963 (nnheader-get-report backend)))
5964 ;; If we get 400 server disconnect, reconnect and
5965 ;; retry; otherwise, assume the article has expired.
5966 (setq result 'done))))
5967 (and (eq result 'article) 'article)))
5971 ;; Associate this article with the current summary buffer.
5972 (setq gnus-article-current-summary gnus-summary-buffer)
5974 ;; Take the article from the original article buffer
5975 ;; and place it in the buffer it's supposed to be in.
5976 (when (and (get-buffer gnus-article-buffer)
5977 (equal (buffer-name (current-buffer))
5978 (buffer-name (get-buffer gnus-article-buffer))))
5980 (if (get-buffer gnus-original-article-buffer)
5981 (set-buffer gnus-original-article-buffer)
5982 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5983 (buffer-disable-undo)
5984 (setq major-mode 'gnus-original-article-mode)
5985 (setq buffer-read-only t))
5986 (let ((inhibit-read-only t))
5988 (insert-buffer-substring gnus-article-buffer))
5989 (setq gnus-original-article (cons group article)))
5992 (run-hooks 'gnus-article-decode-hook)
5993 ;; Mark article as decoded or not.
5994 (setq gnus-article-decoded-p gnus-article-decode-hook))
5996 ;; Update sparse articles.
5997 (when (and do-update-line
5998 (or (numberp article)
6000 (let ((buf (current-buffer)))
6001 (set-buffer gnus-summary-buffer)
6002 (gnus-summary-update-article do-update-line sparse-header)
6003 (gnus-summary-goto-subject do-update-line nil t)
6004 (set-window-point (gnus-get-buffer-window (current-buffer) t)
6006 (set-buffer buf))))))
6012 (defcustom gnus-article-edit-mode-hook nil
6013 "Hook run in article edit mode buffers."
6014 :group 'gnus-article-various
6017 (defcustom gnus-article-edit-article-setup-function
6018 'gnus-article-mime-edit-article-setup
6019 "Function called to setup an editing article buffer."
6020 :group 'gnus-article-various
6023 (defvar gnus-article-edit-done-function nil)
6025 (defvar gnus-article-edit-mode-map nil)
6027 ;; Should we be using derived.el for this?
6028 (unless gnus-article-edit-mode-map
6029 (setq gnus-article-edit-mode-map (make-keymap))
6030 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
6032 (gnus-define-keys gnus-article-edit-mode-map
6033 "\C-c?" describe-mode
6034 "\C-c\C-c" gnus-article-edit-done
6035 "\C-c\C-k" gnus-article-edit-exit
6036 "\C-c\C-f\C-t" message-goto-to
6037 "\C-c\C-f\C-o" message-goto-from
6038 "\C-c\C-f\C-b" message-goto-bcc
6039 ;;"\C-c\C-f\C-w" message-goto-fcc
6040 "\C-c\C-f\C-c" message-goto-cc
6041 "\C-c\C-f\C-s" message-goto-subject
6042 "\C-c\C-f\C-r" message-goto-reply-to
6043 "\C-c\C-f\C-n" message-goto-newsgroups
6044 "\C-c\C-f\C-d" message-goto-distribution
6045 "\C-c\C-f\C-f" message-goto-followup-to
6046 "\C-c\C-f\C-m" message-goto-mail-followup-to
6047 "\C-c\C-f\C-k" message-goto-keywords
6048 "\C-c\C-f\C-u" message-goto-summary
6049 "\C-c\C-f\C-i" message-insert-or-toggle-importance
6050 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
6051 "\C-c\C-b" message-goto-body
6052 "\C-c\C-i" message-goto-signature
6054 "\C-c\C-t" message-insert-to
6055 "\C-c\C-n" message-insert-newsgroups
6056 "\C-c\C-o" message-sort-headers
6057 "\C-c\C-e" message-elide-region
6058 "\C-c\C-v" message-delete-not-region
6059 "\C-c\C-z" message-kill-to-signature
6060 "\M-\r" message-newline-and-reformat
6061 "\C-c\C-a" mml-attach-file
6062 "\C-a" message-beginning-of-line
6064 "\M-;" comment-region)
6066 (gnus-define-keys (gnus-article-edit-wash-map
6067 "\C-c\C-w" gnus-article-edit-mode-map)
6068 "f" gnus-article-edit-full-stops))
6071 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
6073 ["Fetch To" message-insert-to t]
6074 ["Fetch Newsgroups" message-insert-newsgroups t]
6076 ["To" message-goto-to t]
6077 ["From" message-goto-from t]
6078 ["Subject" message-goto-subject t]
6079 ["Cc" message-goto-cc t]
6080 ["Reply-To" message-goto-reply-to t]
6081 ["Summary" message-goto-summary t]
6082 ["Keywords" message-goto-keywords t]
6083 ["Newsgroups" message-goto-newsgroups t]
6084 ["Followup-To" message-goto-followup-to t]
6085 ["Mail-Followup-To" message-goto-mail-followup-to t]
6086 ["Distribution" message-goto-distribution t]
6087 ["Body" message-goto-body t]
6088 ["Signature" message-goto-signature t]))
6090 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
6091 "Major mode for editing articles.
6092 This is an extended text-mode.
6094 \\{gnus-article-edit-mode-map}"
6095 (make-local-variable 'gnus-article-edit-done-function)
6096 (make-local-variable 'gnus-prev-winconf)
6097 (set (make-local-variable 'font-lock-defaults)
6098 '(message-font-lock-keywords t))
6099 (set (make-local-variable 'mail-header-separator) "")
6100 (set (make-local-variable 'gnus-article-edit-mode) t)
6101 (easy-menu-add message-mode-field-menu message-mode-map)
6102 (setq buffer-read-only nil)
6103 (buffer-enable-undo)
6106 (defun gnus-article-edit (&optional force)
6107 "Edit the current article.
6108 This will have permanent effect only in mail groups.
6109 If FORCE is non-nil, allow editing of articles even in read-only
6112 (when (and (not force)
6113 (gnus-group-read-only-p))
6114 (error "The current newsgroup does not support article editing"))
6115 (gnus-article-date-original)
6116 (gnus-article-edit-article
6118 `(lambda (no-highlight)
6120 (gnus-summary-edit-article-done
6121 ,(or (mail-header-references gnus-current-headers) "")
6122 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
6124 (defun gnus-article-edit-article (start-func exit-func)
6125 "Start editing the contents of the current article buffer."
6126 (let ((winconf (current-window-configuration)))
6127 (set-buffer gnus-article-buffer)
6128 (let ((message-auto-save-directory
6129 ;; Don't associate the article buffer with a draft file.
6131 (gnus-article-edit-mode))
6132 (funcall start-func)
6133 (set-buffer-modified-p nil)
6134 (gnus-configure-windows 'edit-article)
6135 (setq gnus-article-edit-done-function exit-func)
6136 (setq gnus-prev-winconf winconf)
6137 (when gnus-article-edit-article-setup-function
6138 (funcall gnus-article-edit-article-setup-function))
6139 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit")))
6141 (defun gnus-article-edit-done (&optional arg)
6142 "Update the article edits and exit."
6144 (let ((func gnus-article-edit-done-function)
6145 (buf (current-buffer))
6146 (start (window-start))
6148 (winconf gnus-prev-winconf))
6149 (remove-hook 'gnus-article-mode-hook
6150 'gnus-article-mime-edit-article-unwind)
6151 (widen) ;; Widen it in case that users narrowed the buffer.
6154 ;; The cache and backlog have to be flushed somewhat.
6155 (when gnus-keep-backlog
6156 (gnus-backlog-remove-article
6157 (car gnus-article-current) (cdr gnus-article-current)))
6158 ;; Flush original article as well.
6160 (when (get-buffer gnus-original-article-buffer)
6161 (set-buffer gnus-original-article-buffer)
6162 (setq gnus-original-article nil)))
6163 (when gnus-use-cache
6164 (gnus-cache-update-article
6165 (car gnus-article-current) (cdr gnus-article-current)))
6166 ;; We remove all text props from the article buffer.
6167 (kill-all-local-variables)
6168 (set-text-properties (point-min) (point-max) nil)
6170 (set-window-configuration winconf)
6172 (set-window-start (get-buffer-window buf) start)
6173 (set-window-point (get-buffer-window buf) (point)))
6174 (gnus-summary-show-article))
6176 (defun gnus-article-edit-exit ()
6177 "Exit the article editing without updating."
6179 (when (or (not (buffer-modified-p))
6180 (yes-or-no-p "Article modified; kill anyway? "))
6181 (let ((curbuf (current-buffer))
6183 (window-start (window-start)))
6185 (if (gnus-buffer-live-p gnus-original-article-buffer)
6186 (insert-buffer-substring gnus-original-article-buffer))
6187 (let ((winconf gnus-prev-winconf))
6188 (kill-all-local-variables)
6190 (set-window-configuration winconf)
6191 ;; Tippy-toe some to make sure that point remains where it was.
6192 (save-current-buffer
6194 (set-window-start (get-buffer-window (current-buffer)) window-start)
6196 (gnus-summary-show-article)))
6198 (defun gnus-article-edit-full-stops ()
6199 "Interactively repair spacing at end of sentences."
6202 (goto-char (point-min))
6203 (search-forward-regexp "^$" nil t)
6204 (let ((case-fold-search nil))
6205 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
6208 ;;; Article editing with MIME-Edit
6211 (defcustom gnus-article-mime-edit-article-setup-hook nil
6212 "Hook run after setting up a MIME editing article buffer."
6213 :group 'gnus-article-various
6216 (defun gnus-article-mime-edit-article-unwind ()
6217 "Unwind `gnus-article-buffer' if article editing was given up."
6218 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6219 (when (featurep 'font-lock)
6220 (setq font-lock-defaults nil)
6221 (font-lock-mode -1))
6222 (when mime-edit-mode-flag
6223 (mime-edit-exit 'nomime 'no-error)
6226 (defun gnus-article-mime-edit-article-setup ()
6227 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
6228 after replacing with the original article."
6229 (setq gnus-show-mime t)
6230 (setq gnus-article-edit-done-function
6231 `(lambda (&rest args)
6232 (when mime-edit-mode-flag
6233 (let (mime-edit-insert-user-agent-field)
6236 (goto-char (point-min))
6237 (let (case-fold-search)
6238 (when (re-search-forward
6239 (format "^%s$" (regexp-quote mail-header-separator))
6241 (replace-match "")))
6242 (apply ,gnus-article-edit-done-function args)
6245 (buffer-substring-no-properties (point-min) (point-max))
6246 (set-buffer (get-buffer-create gnus-original-article-buffer))
6248 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6249 (set-buffer gnus-article-buffer)
6250 (gnus-article-prepare-display)))
6251 (substitute-key-definition 'gnus-article-edit-done
6252 'gnus-article-mime-edit-done
6253 gnus-article-edit-mode-map)
6254 (substitute-key-definition 'gnus-article-edit-exit
6255 'gnus-article-mime-edit-exit
6256 gnus-article-edit-mode-map)
6258 (insert-buffer-substring gnus-original-article-buffer)
6259 (unless (member (with-current-buffer gnus-summary-buffer
6260 gnus-newsgroup-name)
6261 '("nndraft:delayed" "nndraft:drafts"))
6262 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
6263 (fset 'mime-edit-decode-single-part-in-buffer
6264 (lambda (&rest args)
6265 (if (let ((content-type (car args)))
6266 (and (eq 'message (mime-content-type-primary-type
6268 (eq 'rfc822 (mime-content-type-subtype
6270 (setcar (cdr args) 'not-decode-text))
6274 (fset 'mime-edit-decode-single-part-in-buffer ofn))))
6275 (when (featurep 'font-lock)
6276 (set (make-local-variable 'font-lock-defaults)
6277 '(message-font-lock-keywords t))
6278 (font-lock-set-defaults)
6279 (turn-on-font-lock))
6280 (set-buffer-modified-p nil)
6281 (delete-other-windows)
6282 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6283 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
6285 (defun gnus-article-mime-edit-done (&optional arg)
6286 "Update the article MIME edits and exit."
6288 (when (featurep 'font-lock)
6289 (setq font-lock-defaults nil)
6290 (font-lock-mode -1))
6291 (let ((inhibit-read-only t))
6292 (gnus-article-edit-done arg)))
6294 (defun gnus-article-mime-edit-exit ()
6295 "Exit the article MIME editing without updating."
6297 (when (or (not (buffer-modified-p))
6298 (yes-or-no-p "Article modified; kill anyway? "))
6299 (when (featurep 'font-lock)
6300 (setq font-lock-defaults nil)
6301 (font-lock-mode -1))
6302 (when mime-edit-mode-flag
6303 (let (mime-edit-insert-user-agent-field)
6306 (goto-char (point-min))
6307 (let (case-fold-search)
6308 (when (re-search-forward
6309 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
6310 (replace-match "")))
6311 (let ((winconf gnus-prev-winconf))
6313 (buffer-substring-no-properties (point-min) (point-max))
6314 (set-buffer (get-buffer-create gnus-original-article-buffer))
6316 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6317 (set-buffer gnus-article-buffer)
6318 (gnus-article-prepare-display)
6319 (set-window-configuration winconf))))
6322 ;;; Article highlights
6325 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6327 ;;; Internal Variables:
6329 (defcustom gnus-button-url-regexp
6330 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
6331 "\\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:]]\\)"
6332 "\\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\\)\\)")
6333 "Regular expression that matches URLs."
6334 :group 'gnus-article-buttons
6337 (defcustom gnus-button-valid-fqdn-regexp
6338 message-valid-fqdn-regexp
6339 "Regular expression that matches a valid FQDN."
6341 :group 'gnus-article-buttons
6344 (defcustom gnus-button-man-handler 'manual-entry
6345 "Function to use for displaying man pages.
6346 The function must take at least one argument with a string naming the
6349 :type '(choice (function-item :tag "Man" manual-entry)
6350 (function-item :tag "Woman" woman)
6351 (function :tag "Other"))
6352 :group 'gnus-article-buttons)
6354 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6355 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6356 If the default site is too slow, try to find a CTAN mirror, see
6357 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6358 the variable `gnus-button-handle-ctan'."
6360 :group 'gnus-article-buttons
6361 :link '(custom-manual "(gnus)Group Parameters")
6362 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6363 (const "http://tug.ctan.org/tex-archive/")
6364 (const "http://www.dante.de/CTAN/")
6365 (string :tag "Other")))
6367 (defcustom gnus-button-ctan-handler 'browse-url
6368 "Function to use for displaying CTAN links.
6369 The function must take one argument, the string naming the URL."
6371 :type '(choice (function-item :tag "Browse Url" browse-url)
6372 (function :tag "Other"))
6373 :group 'gnus-article-buttons)
6375 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6376 "Bogus strings removed from CTAN URLs."
6378 :group 'gnus-article-buttons
6379 :type '(choice (const "^/?tex-archive/\\|/")
6380 (regexp :tag "Other")))
6382 (defcustom gnus-button-ctan-directory-regexp
6385 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
6386 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
6387 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
6389 "Regular expression for ctan directories.
6390 It should match all directories in the top level of `gnus-ctan-url'."
6392 :group 'gnus-article-buttons
6395 (defcustom gnus-button-mid-or-mail-regexp
6396 (concat "\\b\\(<?[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*@"
6397 ;; Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
6398 gnus-button-valid-fqdn-regexp
6400 "Regular expression that matches a message ID or a mail address."
6402 :group 'gnus-article-buttons
6405 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6406 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6407 Strings like this can be either a message ID or a mail address. If it is one
6408 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6409 message ID or a mail address, respectively. If this variable is set to the
6410 symbol `ask', always query the user what do do. If it is a function, this
6411 function will be called with the string as it's only argument. The function
6412 must return `mid', `mail', `invalid' or `ask'."
6414 :group 'gnus-article-buttons
6415 :type '(choice (function-item :tag "Heuristic function"
6416 gnus-button-mid-or-mail-heuristic)
6421 (defcustom gnus-button-mid-or-mail-heuristic-alist
6422 '((-10.0 . ".+\\$.+@")
6425 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6426 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6427 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6428 (-1.0 . "^[^a-z]+@")
6430 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6431 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6432 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6433 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6436 (-1.0 . "^[0-9][0-9]")
6438 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6439 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6440 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6441 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6443 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6444 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6447 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6449 ;; compensation for TDMA dated mail addresses:
6450 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6452 (-20.0 . "\\.fsf@") ;; Gnus
6455 (-20.0 . "_-_") ;; Subject change in thread
6457 (-20.0 . "\\.ln@") ;; leafnode
6458 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6459 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6461 ;; (5.0 . "") ;; $local_part_len <= 7
6462 (10.0 . "^[^0-9]+@")
6463 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6464 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6467 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6469 (0.5 . "^[A-Z][a-z]")
6470 (0.5 . "^[A-Z][a-z][a-z]")
6471 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6472 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6473 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6475 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6476 address. The REGEXP is processed with `case-fold-search' set to nil."
6478 :group 'gnus-article-buttons
6479 :type '(repeat (cons (number :tag "Rate")
6480 (regexp :tag "Regexp"))))
6482 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6483 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6484 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6485 address, `ask' if unsure and `invalid' if the string is invalid."
6486 (let ((case-fold-search nil)
6487 (list gnus-button-mid-or-mail-heuristic-alist)
6488 (result 0) rate regexp lpartlen elem)
6490 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6491 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6492 ;; Certain special cases...
6495 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6496 "^[0-9]+\\.[0-9]+@compuserve\\|"
6497 "@public\\.gmane\\.org")
6499 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6500 (setq result 'mail))
6501 (when (string-match "@.*@\\| " mid-or-mail)
6502 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6503 (setq result 'invalid))
6504 ;; Nothing more to do, if result is not a number here...
6505 (when (numberp result)
6507 (setq elem (car list)
6511 (when (string-match regexp mid-or-mail)
6512 (setq result (+ result rate))
6514 9 "`%s' matched `%s', rate `%s', result `%s'."
6515 mid-or-mail regexp rate result)))
6516 (when (<= lpartlen 7)
6517 (setq result (+ result 5.0))
6518 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6519 mid-or-mail result))
6520 (when (>= lpartlen 12)
6521 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6523 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6524 ;; Long local part should contain realname if e-mail address,
6525 ;; too many digits: message-id.
6526 ;; $score -= 5.0 + 0.1 * $local_part_len;
6527 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6528 (setq result (+ result rate))
6530 9 "Many digits in `%s', rate `%s', result `%s'."
6531 mid-or-mail rate result))
6532 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6534 ;; Too few vowels [^aeiouy]{4,}.*\@
6535 (setq result (+ result -5.0))
6537 9 "Few vowels in `%s', rate `%s', result `%s'."
6538 mid-or-mail -5.0 result))
6540 (setq result (+ result 5.0))
6542 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6543 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6544 ;; Maybe we should make this a customizable alist: (condition . 'result)
6546 ((symbolp result) result)
6547 ;; Now convert number into proper results:
6548 ((< result -10.0) 'mid)
6549 ((> result 10.0) 'mail)
6552 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6553 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6554 (url-mid (concat "news" ":" mid-or-mail))
6555 (url-mailto (concat "mailto" ":" mid-or-mail)))
6556 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6557 (when (fboundp pref)
6559 ;; get rid of surrounding angles...
6561 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6562 (if (or (eq 'mid guessed) (eq 'mail guessed))
6566 (save-window-excursion
6567 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6570 (cond ((eq pref 'mid)
6571 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6572 (gnus-button-handle-news url-mid))
6574 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6575 (gnus-url-mailto url-mailto))
6576 (t (gnus-message 3 "Invalid string.")))))
6578 (defun gnus-button-handle-custom (url)
6579 "Follow a Custom URL."
6580 (customize-apropos (gnus-url-unhex-string url)))
6582 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6584 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6587 (defun gnus-button-handle-describe-function (url)
6588 "Call `describe-function' when pushing the corresponding URL button."
6591 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6593 (defun gnus-button-handle-describe-variable (url)
6594 "Call `describe-variable' when pushing the corresponding URL button."
6597 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6599 (defun gnus-button-handle-symbol (url)
6600 "Display help on variable or function.
6601 Calls `describe-variable' or `describe-function'."
6602 (let ((sym (intern url)))
6604 ((fboundp sym) (describe-function sym))
6605 ((boundp sym) (describe-variable sym))
6606 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6608 (defun gnus-button-handle-describe-key (url)
6609 "Call `describe-key' when pushing the corresponding URL button."
6611 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6612 (keys (ignore-errors (eval `(kbd ,key-string)))))
6615 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6617 (defun gnus-button-handle-apropos (url)
6618 "Call `apropos' when pushing the corresponding URL button."
6619 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6621 (defun gnus-button-handle-apropos-command (url)
6622 "Call `apropos' when pushing the corresponding URL button."
6624 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6626 (defun gnus-button-handle-apropos-variable (url)
6627 "Call `apropos' when pushing the corresponding URL button."
6629 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6630 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6632 (defun gnus-button-handle-apropos-documentation (url)
6633 "Call `apropos' when pushing the corresponding URL button."
6635 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6636 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6638 (defun gnus-button-handle-library (url)
6639 "Call `locate-library' when pushing the corresponding URL button."
6640 (gnus-message 9 "url=`%s'" url)
6641 (let* ((lib (locate-library url))
6642 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6644 (gnus-message 1 "Cannot locale library `%s'." url)
6645 (find-file-read-only file))))
6647 (defun gnus-button-handle-ctan (url)
6648 "Call `browse-url' when pushing a CTAN URL button."
6650 gnus-button-ctan-handler
6653 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6655 (defcustom gnus-button-tex-level 5
6656 "*Integer that says how many TeX-related buttons Gnus will show.
6657 The higher the number, the more buttons will appear and the more false
6658 positives are possible. Note that you can set this variable local to
6659 specific groups. Setting it higher in TeX groups is probably a good idea.
6660 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6661 how to set variables in specific groups."
6663 :group 'gnus-article-buttons
6664 :link '(custom-manual "(gnus)Group Parameters")
6667 (defcustom gnus-button-man-level 5
6668 "*Integer that says how many man-related buttons Gnus will show.
6669 The higher the number, the more buttons will appear and the more false
6670 positives are possible. Note that you can set this variable local to
6671 specific groups. Setting it higher in Unix groups is probably a good idea.
6672 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6673 how to set variables in specific groups."
6675 :group 'gnus-article-buttons
6676 :link '(custom-manual "(gnus)Group Parameters")
6679 (defcustom gnus-button-emacs-level 5
6680 "*Integer that says how many emacs-related buttons Gnus will show.
6681 The higher the number, the more buttons will appear and the more false
6682 positives are possible. Note that you can set this variable local to
6683 specific groups. Setting it higher in Emacs or Gnus related groups is
6684 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6685 `gnus-parameters' on how to set variables in specific groups."
6687 :group 'gnus-article-buttons
6688 :link '(custom-manual "(gnus)Group Parameters")
6691 (defcustom gnus-button-message-level 5
6692 "*Integer that says how many buttons for news or mail messages will appear.
6693 The higher the number, the more buttons will appear and the more false
6694 positives are possible."
6695 ;; mail addresses, MIDs, URLs for news, ...
6697 :group 'gnus-article-buttons
6700 (defcustom gnus-button-browse-level 5
6701 "*Integer that says how many buttons for browsing will appear.
6702 The higher the number, the more buttons will appear and the more false
6703 positives are possible."
6704 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6706 :group 'gnus-article-buttons
6709 (defcustom gnus-button-alist
6710 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6711 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6712 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6713 gnus-button-handle-news 2)
6714 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6715 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6716 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6717 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6718 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6719 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6720 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6721 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6722 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6723 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6724 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6725 ;; RFC 2368 (The mailto URL scheme)
6726 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6727 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6728 ("\\bmailto:\\([^ \n\t]+\\)"
6729 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6731 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6732 gnus-button-ctan-directory-regexp
6733 "[^][>)!;:,'\n\t ]+\\)")
6734 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6735 ((concat "\\btex-archive/\\("
6736 gnus-button-ctan-directory-regexp
6737 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6738 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6741 gnus-button-ctan-directory-regexp
6742 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6743 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6744 ;; This is info (home-grown style) <info://foo/bar+baz>
6745 ("\\binfo://\\([^'\">\n\t ]+\\)"
6746 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6747 ;; Info GNOME style <info:foo#bar_baz>
6748 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6749 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6750 ;; Info KDE style <info:(foo)bar baz>
6751 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6752 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6753 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6754 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6755 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6756 ;; Info links like `C-h i d m CC Mode RET'
6757 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6759 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6760 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6761 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6762 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6763 ;; Emacs help commands
6764 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6765 ;; regexp doesn't match arguments containing ` '.
6766 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6767 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6768 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6769 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6770 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6771 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6772 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6773 ;; The following entries may lead to many false positives so don't enable
6774 ;; them by default (use a high button level).
6775 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6776 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6777 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6778 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6779 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6780 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6781 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6782 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6783 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6784 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6785 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6786 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6787 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6788 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6789 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6790 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6791 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6792 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6793 ;; Unlike the other regexps we really have to require quoting
6794 ;; here to determine where it ends.
6795 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6796 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6797 ("<URL: *\\([^<>]*\\)>"
6798 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6799 ;; RFC 2396 (2.4.3., delims) ...
6800 ("\"URL: *\\([^\"]*\\)\""
6801 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6802 ;; RFC 2396 (2.4.3., delims) ...
6803 ("\"URL: *\\([^\"]*\\)\""
6804 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6806 (gnus-button-url-regexp
6807 0 (>= gnus-button-browse-level 0) browse-url 0)
6809 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6810 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6811 gnus-button-handle-man 1)
6812 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6813 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6814 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6815 gnus-button-handle-man 1)
6816 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6817 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6818 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6819 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6820 ;; MID or mail: To avoid too many false positives we don't try to catch
6821 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6822 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6823 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6824 ;; so that non-ambiguous entries (see above) match first.
6825 (gnus-button-mid-or-mail-regexp
6826 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6827 "*Alist of regexps matching buttons in article bodies.
6829 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6830 REGEXP: is the string (case insensitive) matching text around the button (can
6831 also be Lisp expression evaluating to a string),
6832 BUTTON: is the number of the regexp grouping actually matching the button,
6833 FORM: is a Lisp expression which must eval to true for the button to
6835 CALLBACK: is the function to call when the user push this button, and each
6836 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6838 CALLBACK can also be a variable, in that case the value of that
6839 variable it the real callback function."
6840 :group 'gnus-article-buttons
6841 :type '(repeat (list (choice regexp variable sexp)
6842 (integer :tag "Button")
6844 (function :tag "Callback")
6847 (integer :tag "Regexp group")))))
6849 (defcustom gnus-header-button-alist
6850 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6851 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6852 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6853 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6854 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6855 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
6856 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6857 0 (>= gnus-button-browse-level 0) browse-url 0)
6858 ("^Subject:" gnus-button-url-regexp
6859 0 (>= gnus-button-browse-level 0) browse-url 0)
6860 ("^[^:]+:" gnus-button-url-regexp
6861 0 (>= gnus-button-browse-level 0) browse-url 0)
6862 ("^OpenPGP:.*url=" gnus-button-url-regexp
6863 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
6864 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6865 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6866 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6867 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6868 "*Alist of headers and regexps to match buttons in article heads.
6870 This alist is very similar to `gnus-button-alist', except that each
6871 alist has an additional HEADER element first in each entry:
6873 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6875 HEADER is a regexp to match a header. For a fuller explanation, see
6876 `gnus-button-alist'."
6877 :group 'gnus-article-buttons
6878 :group 'gnus-article-headers
6879 :type '(repeat (list (regexp :tag "Header")
6880 (choice regexp variable)
6881 (integer :tag "Button")
6883 (function :tag "Callback")
6886 (integer :tag "Regexp group")))))
6890 (defun gnus-article-push-button (event)
6891 "Check text under the mouse pointer for a callback function.
6892 If the text under the mouse pointer has a `gnus-callback' property,
6893 call it with the value of the `gnus-data' text property."
6895 (set-buffer (window-buffer (posn-window (event-start event))))
6896 (let* ((pos (posn-point (event-start event)))
6897 (data (get-text-property pos 'gnus-data))
6898 (fun (get-text-property pos 'gnus-callback)))
6901 (funcall fun data))))
6903 (defun gnus-article-press-button ()
6904 "Check text at point for a callback function.
6905 If the text at point has a `gnus-callback' property,
6906 call it with the value of the `gnus-data' text property."
6908 (let ((data (get-text-property (point) 'gnus-data))
6909 (fun (get-text-property (point) 'gnus-callback)))
6911 (funcall fun data))))
6913 (defun gnus-article-prev-button (n)
6914 "Move point to N buttons backward.
6915 If N is negative, move forward instead."
6917 (gnus-article-next-button (- n)))
6919 (defun gnus-article-next-button (n)
6920 "Move point to N buttons forward.
6921 If N is negative, move backward instead."
6923 (let ((function (if (< n 0) 'previous-single-property-change
6924 'next-single-property-change))
6925 (inhibit-point-motion-hooks t)
6927 (limit (if (< n 0) (point-min) (point-max))))
6929 (while (and (not (= limit (point)))
6931 ;; Skip past the current button.
6932 (when (get-text-property (point) 'gnus-callback)
6933 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6934 ;; Go to the next (or previous) button.
6935 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
6936 ;; Put point at the start of the button.
6937 (when (and backward (not (get-text-property (point) 'gnus-callback)))
6938 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6939 ;; Skip past intangible buttons.
6940 (when (get-text-property (point) 'intangible)
6944 (gnus-message 5 "No more buttons"))
6947 (defun gnus-article-highlight (&optional force)
6948 "Highlight current article.
6949 This function calls `gnus-article-highlight-headers',
6950 `gnus-article-highlight-citation',
6951 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6952 do the highlighting. See the documentation for those functions."
6953 (interactive (list 'force))
6954 (gnus-article-highlight-headers)
6955 (gnus-article-highlight-citation force)
6956 (gnus-article-highlight-signature)
6957 (gnus-article-add-buttons force)
6958 (gnus-article-add-buttons-to-head))
6960 (defun gnus-article-highlight-some (&optional force)
6961 "Highlight current article.
6962 This function calls `gnus-article-highlight-headers',
6963 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6964 do the highlighting. See the documentation for those functions."
6965 (interactive (list 'force))
6966 (gnus-article-highlight-headers)
6967 (gnus-article-highlight-signature)
6968 (gnus-article-add-buttons))
6970 (defun gnus-article-highlight-headers ()
6971 "Highlight article headers as specified by `gnus-header-face-alist'."
6973 (gnus-with-article-headers
6974 (let (regexp header-face field-face from hpoints fpoints)
6975 (dolist (entry gnus-header-face-alist)
6976 (goto-char (point-min))
6977 (setq regexp (concat "^\\("
6978 (if (string-equal "" (nth 0 entry))
6982 header-face (nth 1 entry)
6983 field-face (nth 2 entry))
6984 (while (and (re-search-forward regexp nil t)
6988 (unless (search-forward ":" nil t)
6990 (when (and header-face
6991 (not (memq (point) hpoints)))
6992 (push (point) hpoints)
6993 (gnus-put-text-property from (point) 'face header-face))
6994 (when (and field-face
6995 (not (memq (setq from (point)) fpoints)))
6997 (if (re-search-forward "^[^ \t]" nil t)
6999 (goto-char (point-max)))
7000 (gnus-put-text-property from (point) 'face field-face)))))))
7002 (defun gnus-article-highlight-signature ()
7003 "Highlight the signature in an article.
7004 It does this by highlighting everything after
7005 `gnus-signature-separator' using the face `gnus-signature'."
7007 (when gnus-signature-face
7008 (gnus-with-article-buffer
7009 (let ((inhibit-point-motion-hooks t))
7011 (when (gnus-article-narrow-to-signature)
7012 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
7013 'face gnus-signature-face)))))))
7015 (defun gnus-article-buttonize-signature ()
7016 "Add button to the signature."
7019 (set-buffer gnus-article-buffer)
7020 (let ((inhibit-read-only t)
7021 (inhibit-point-motion-hooks t))
7022 (when (gnus-article-search-signature)
7023 (gnus-article-add-button (match-beginning 0) (match-end 0)
7024 'gnus-signature-toggle
7025 (set-marker (make-marker)
7026 (1+ (match-end 0))))))))
7028 (defun gnus-button-in-region-p (b e prop)
7029 "Say whether PROP exists in the region."
7030 (text-property-not-all b e prop nil))
7032 (defun gnus-article-add-buttons (&optional force)
7033 "Find external references in the article and make buttons of them.
7034 \"External references\" are things like Message-IDs and URLs, as
7035 specified by `gnus-button-alist'."
7036 (interactive (list 'force))
7037 (gnus-with-article-buffer
7038 (let ((inhibit-point-motion-hooks t)
7039 (case-fold-search t)
7040 (alist gnus-button-alist)
7042 ;; Remove all old markers.
7043 (let (marker entry new-list)
7044 (while (setq marker (pop gnus-button-marker-list))
7045 (if (or (< marker (point-min)) (>= marker (point-max)))
7046 (push marker new-list)
7048 (when (setq entry (gnus-button-entry))
7049 (put-text-property (match-beginning (nth 1 entry))
7050 (match-end (nth 1 entry))
7051 'gnus-callback nil))
7052 (set-marker marker nil)))
7053 (setq gnus-button-marker-list new-list))
7054 ;; We skip the headers.
7057 (while (setq entry (pop alist))
7058 (setq regexp (eval (car entry)))
7060 (while (re-search-forward regexp nil t)
7061 (let* ((start (and entry (match-beginning (nth 1 entry))))
7062 (end (and entry (match-end (nth 1 entry))))
7063 (from (match-beginning 0)))
7064 (when (and (or (eq t (nth 2 entry))
7065 (eval (nth 2 entry)))
7066 (not (gnus-button-in-region-p
7067 start end 'gnus-callback)))
7068 ;; That optional form returned non-nil, so we add the
7070 (gnus-article-add-button
7071 start end 'gnus-button-push
7072 (car (push (set-marker (make-marker) from)
7073 gnus-button-marker-list))))))))))
7075 ;; Add buttons to the head of an article.
7076 (defun gnus-article-add-buttons-to-head ()
7077 "Add buttons to the head of the article."
7079 (gnus-with-article-headers
7081 (dolist (entry gnus-header-button-alist)
7082 ;; Each alist entry.
7083 (goto-char (point-min))
7084 (while (re-search-forward (car entry) nil t)
7085 ;; Each header matching the entry.
7086 (setq beg (match-beginning 0))
7087 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
7088 (match-beginning 0))
7091 (while (re-search-forward (eval (nth 1 entry)) end t)
7092 ;; Each match within a header.
7093 (let* ((entry (cdr entry))
7094 (start (match-beginning (nth 1 entry)))
7095 (end (match-end (nth 1 entry)))
7096 (form (nth 2 entry)))
7097 (goto-char (match-end 0))
7099 (gnus-article-add-button
7100 start end (nth 3 entry)
7101 (buffer-substring (match-beginning (nth 4 entry))
7102 (match-end (nth 4 entry)))))))
7103 (goto-char end))))))
7105 ;;; External functions:
7107 (defun gnus-article-add-button (from to fun &optional data)
7108 "Create a button between FROM and TO with callback FUN and data DATA."
7109 (when gnus-article-button-face
7110 (gnus-overlay-put (gnus-make-overlay from to)
7111 'face gnus-article-button-face))
7112 (gnus-add-text-properties
7114 (nconc (and gnus-article-mouse-face
7115 (list gnus-mouse-face-prop gnus-article-mouse-face))
7116 (list 'gnus-callback fun)
7117 (and data (list 'gnus-data data))))
7118 (widget-convert-button 'link from to :action 'gnus-widget-press-button
7119 :button-keymap gnus-widget-button-keymap))
7121 ;;; Internal functions:
7123 (defun gnus-article-set-globals ()
7124 (with-current-buffer gnus-summary-buffer
7125 (gnus-set-global-variables)))
7127 (defun gnus-signature-toggle (end)
7128 (gnus-with-article-buffer
7129 (let ((inhibit-point-motion-hooks t)
7130 (limit (next-single-property-change end 'mime-view-entity
7132 (if (text-property-any end limit 'article-type 'signature)
7134 (gnus-delete-wash-type 'signature)
7135 (gnus-remove-text-properties-when
7136 'article-type 'signature end limit
7137 (cons 'article-type (cons 'signature
7138 gnus-hidden-properties))))
7139 (gnus-add-wash-type 'signature)
7140 (gnus-add-text-properties-when
7141 'article-type nil end limit
7142 (cons 'article-type (cons 'signature
7143 gnus-hidden-properties)))))
7144 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
7145 (gnus-set-mode-line 'article))))
7147 (defun gnus-button-entry ()
7148 ;; Return the first entry in `gnus-button-alist' matching this place.
7149 (let ((alist gnus-button-alist)
7152 (setq entry (pop alist))
7153 (if (looking-at (eval (car entry)))
7158 (defun gnus-button-push (marker)
7159 ;; Push button starting at MARKER.
7162 (let* ((entry (gnus-button-entry))
7163 (inhibit-point-motion-hooks t)
7165 (args (mapcar (lambda (group)
7166 (let ((string (match-string group)))
7167 (set-text-properties
7168 0 (length string) nil string)
7175 (fboundp (symbol-value fun)))
7176 (apply (symbol-value fun) args))
7178 (gnus-message 1 "You must define `%S' to use this button"
7179 (cons fun args)))))))
7181 (defun gnus-parse-news-url (url)
7182 (let (scheme server port group message-id articles)
7185 (goto-char (point-min))
7186 (when (looking-at "\\([A-Za-z]+\\):")
7187 (setq scheme (match-string 1))
7188 (goto-char (match-end 0)))
7189 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
7190 (setq server (match-string 1))
7191 (setq port (if (stringp (match-string 3))
7192 (string-to-number (match-string 3))
7194 (goto-char (match-end 0)))
7197 ((looking-at "\\(.*@.*\\)")
7198 (setq message-id (match-string 1)))
7199 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7200 (setq group (match-string 1)
7201 articles (split-string (match-string 2) "-")))
7202 ((looking-at "\\([^/]+\\)/?")
7203 (setq group (match-string 1)))
7205 (error "Unknown news URL syntax"))))
7206 (list scheme server port group message-id articles)))
7208 (defun gnus-button-handle-news (url)
7210 (destructuring-bind (scheme server port group message-id articles)
7211 (gnus-parse-news-url url)
7215 (set-buffer gnus-summary-buffer)
7217 (let ((gnus-refer-article-method
7218 (nconc (list (list 'nntp server))
7219 gnus-refer-article-method))
7220 (nntp-port-number (or port "nntp")))
7221 (gnus-message 7 "Fetching %s with %s"
7222 message-id gnus-refer-article-method)
7223 (gnus-summary-refer-article message-id))
7224 (gnus-summary-refer-article message-id))))
7226 (gnus-button-fetch-group url)))))
7228 (defun gnus-button-handle-man (url)
7230 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7231 (when (eq gnus-button-man-handler 'woman)
7232 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
7233 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7234 (funcall gnus-button-man-handler url))
7236 (defun gnus-button-handle-info-url (url)
7237 "Fetch an info URL."
7238 (setq url (mm-subst-char-in-string ?+ ?\ url))
7240 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
7241 (gnus-info-find-node
7242 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
7244 ")" (gnus-url-unhex-string (match-string 2 url)))))
7245 ((string-match "([^)\"]+)[^\"]+" url)
7247 (gnus-replace-in-string
7248 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
7249 (gnus-info-find-node url))
7250 (t (error "Can't parse %s" url))))
7252 (defun gnus-button-handle-info-url-gnome (url)
7253 "Fetch GNOME style info URL."
7254 (setq url (mm-subst-char-in-string ?_ ?\ url))
7255 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
7256 (gnus-info-find-node
7258 (gnus-url-unhex-string
7259 (match-string 1 url))
7261 (or (gnus-url-unhex-string
7262 (match-string 2 url))
7264 (error "Can't parse %s" url)))
7266 (defun gnus-button-handle-info-url-kde (url)
7267 "Fetch KDE style info URL."
7268 (gnus-info-find-node (gnus-url-unhex-string url)))
7270 (defun gnus-button-handle-info-keystrokes (url)
7271 "Call `info' when pushing the corresponding URL button."
7272 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
7277 (defun gnus-button-openpgp (url)
7278 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
7280 (mm-url-insert-file-contents-external url)
7281 (pgg-snarf-keys-region (point-min) (point-max))
7282 (pgg-display-output-buffer nil nil nil)))
7284 (defun gnus-button-message-id (message-id)
7286 (with-current-buffer gnus-summary-buffer
7287 (gnus-summary-refer-article message-id)))
7289 (defun gnus-button-fetch-group (address)
7290 "Fetch GROUP specified by ADDRESS."
7291 (if (not (string-match "[:/]" address))
7292 ;; This is just a simple group url.
7293 (gnus-group-read-ephemeral-group address gnus-select-method)
7296 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
7298 (error "Can't parse %s" address)
7299 (gnus-group-read-ephemeral-group
7300 (match-string 4 address)
7301 `(nntp ,(match-string 1 address)
7302 (nntp-address ,(match-string 1 address))
7303 (nntp-port-number ,(if (match-end 3)
7304 (match-string 3 address)
7307 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
7309 (defun gnus-url-parse-query-string (query &optional downcase)
7310 (let (retval pairs cur key val)
7311 (setq pairs (split-string query "&"))
7313 (setq cur (car pairs)
7315 (if (not (string-match "=" cur))
7317 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
7318 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
7320 (setq key (downcase key)))
7321 (setq cur (assoc key retval))
7323 (setcdr cur (cons val (cdr cur)))
7324 (setq retval (cons (list key val) retval)))))
7327 (defun gnus-url-mailto (url)
7328 ;; Send mail to someone
7329 (when (string-match "mailto:/*\\(.*\\)" url)
7330 (setq url (substring url (match-beginning 1) nil)))
7331 (let (to args subject func)
7332 (setq args (gnus-url-parse-query-string
7333 (if (string-match "^\\?" url)
7335 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
7336 (concat "to=" (match-string 1 url) "&"
7337 (match-string 2 url))
7338 (concat "to=" url)))
7340 subject (cdr-safe (assoc "subject" args)))
7343 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
7346 (message-position-on-field (caar args)))
7347 (insert (gnus-replace-in-string
7348 (mapconcat 'identity (reverse (cdar args)) ", ")
7350 (setq args (cdr args)))
7353 (message-goto-subject))))
7355 (defun gnus-button-embedded-url (address)
7356 "Activate ADDRESS with `browse-url'."
7357 (browse-url (gnus-strip-whitespace address)))
7359 ;;; Next/prev buttons in the article buffer.
7361 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
7362 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
7364 (defvar gnus-prev-page-map
7365 (let ((map (make-sparse-keymap)))
7366 (define-key map gnus-mouse-2 'gnus-button-prev-page)
7367 (define-key map "\r" 'gnus-button-prev-page)
7370 (defvar gnus-next-page-map
7371 (let ((map (make-sparse-keymap)))
7372 (unless (>= emacs-major-version 21)
7373 ;; XEmacs doesn't care.
7374 (set-keymap-parent map gnus-article-mode-map))
7375 (define-key map gnus-mouse-2 'gnus-button-next-page)
7376 (define-key map "\r" 'gnus-button-next-page)
7379 (defun gnus-insert-prev-page-button ()
7381 (inhibit-read-only t)
7382 (situation (get-text-property (point-min) 'mime-view-situation)))
7384 gnus-prev-page-line-format nil
7385 `(keymap ,gnus-prev-page-map
7387 gnus-callback gnus-article-button-prev-page
7388 article-type annotation
7389 mime-view-situation ,situation))
7390 (widget-convert-button
7392 ;; Exclude a newline.
7395 :action 'gnus-button-prev-page
7396 :button-keymap gnus-prev-page-map)))
7398 (defun gnus-button-next-page (&optional args more-args)
7399 "Go to the next page."
7401 (let ((win (selected-window)))
7402 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7403 (gnus-article-next-page)
7404 (select-window win)))
7406 (defun gnus-button-prev-page (&optional args more-args)
7407 "Go to the prev page."
7409 (let ((win (selected-window)))
7410 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7411 (gnus-article-prev-page)
7412 (select-window win)))
7414 (defun gnus-insert-next-page-button ()
7416 (inhibit-read-only t)
7417 (situation (get-text-property (point-min) 'mime-view-situation)))
7418 (gnus-eval-format gnus-next-page-line-format nil
7419 `(keymap ,gnus-next-page-map
7421 gnus-callback gnus-article-button-next-page
7422 article-type annotation
7423 mime-view-situation ,situation))
7424 (widget-convert-button
7426 ;; Exclude a newline.
7429 :action 'gnus-button-next-page
7430 :button-keymap gnus-next-page-map)))
7432 (defun gnus-article-button-next-page (arg)
7433 "Go to the next page."
7435 (let ((win (selected-window)))
7436 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7437 (gnus-article-next-page)
7438 (select-window win)))
7440 (defun gnus-article-button-prev-page (arg)
7441 "Go to the prev page."
7443 (let ((win (selected-window)))
7444 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7445 (gnus-article-prev-page)
7446 (select-window win)))
7448 (defvar gnus-decode-header-methods
7449 '(mail-decode-encoded-word-region)
7450 "List of methods used to decode headers.
7452 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7453 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
7454 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
7455 whose names match REGEXP.
7458 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7459 mail-decode-encoded-word-region
7460 (\"chinese\" . rfc1843-decode-region))
7463 (defvar gnus-decode-header-methods-cache nil)
7465 (defun gnus-multi-decode-header (start end)
7466 "Apply the functions from `gnus-encoded-word-methods' that match."
7467 (unless (and gnus-decode-header-methods-cache
7468 (eq gnus-newsgroup-name
7469 (car gnus-decode-header-methods-cache)))
7470 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7473 (nconc gnus-decode-header-methods-cache (list x))
7474 (if (and gnus-newsgroup-name
7475 (string-match (car x) gnus-newsgroup-name))
7476 (nconc gnus-decode-header-methods-cache
7478 gnus-decode-header-methods))
7479 (let ((xlist gnus-decode-header-methods-cache))
7482 (narrow-to-region start end)
7484 (funcall (pop xlist) (point-min) (point-max))))))
7487 ;;; Treatment top-level handling.
7490 (defun gnus-treat-article (condition &optional part-number total-parts type)
7491 (let ((length (- (point-max) (point-min)))
7492 (alist gnus-treatment-function-alist)
7493 (article-goto-body-goes-to-point-min-p t)
7497 (let ((list gnus-article-treat-types))
7499 (when (string-match (pop list) type)
7500 (throw 'found t)))))))
7501 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7502 (entity (static-unless (featurep 'xemacs)
7503 (when (eq 'head condition)
7504 (get-text-property (point-min) 'mime-view-entity))))
7505 val elem buttonized)
7506 (gnus-run-hooks 'gnus-part-display-hook)
7507 (unless gnus-inhibit-treatment
7508 (dolist (elem alist)
7511 (when (gnus-buffer-live-p gnus-summary-buffer)
7512 (set-buffer gnus-summary-buffer))
7513 (symbol-value (car elem))))
7514 (when (and (or (consp val)
7516 (gnus-treat-predicate val)
7517 (or (not (get (car elem) 'highlight))
7519 (when (and (not buttonized)
7521 '(gnus-treat-hide-signature
7522 gnus-treat-highlight-signature)))
7523 (gnus-article-buttonize-signature)
7524 (setq buttonized t))
7526 (funcall (cadr elem)))))
7527 ;; FSF Emacsen does not inherit the existing text properties
7528 ;; in the new text, so we should do it for `mime-view-entity'.
7529 (static-unless (featurep 'xemacs)
7531 (put-text-property (point-min) (point-max)
7532 'mime-view-entity entity))))))
7534 ;; Dynamic variables.
7536 (defvar part-number)
7537 (defvar total-parts)
7542 (defun gnus-treat-predicate (val)
7547 (stringp (car val)))
7548 (apply 'gnus-or (mapcar `(lambda (s)
7549 (string-match s ,(or gnus-newsgroup-name "")))
7552 (let ((pred (pop val)))
7555 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7557 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7559 (not (gnus-treat-predicate (car val))))
7561 (equal (car val) type))
7563 (error "%S is not a valid predicate" pred)))))
7573 (eq part-number total-parts))
7577 (error "%S is not a valid value" val))))
7579 (defun gnus-article-encrypt-body (protocol &optional n)
7580 "Encrypt the article body."
7583 (or gnus-article-encrypt-protocol
7584 (completing-read "Encrypt protocol: "
7585 gnus-article-encrypt-protocol-alist
7587 current-prefix-arg))
7588 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7590 (error "Can't find the encrypt protocol %s" protocol))
7591 (if (member gnus-newsgroup-name '("nndraft:delayed"
7594 (error "Can't encrypt the article in group %s"
7595 gnus-newsgroup-name))
7596 (gnus-summary-iterate n
7598 (set-buffer gnus-summary-buffer)
7599 (let ((mail-parse-charset gnus-newsgroup-charset)
7600 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7601 (summary-buffer gnus-summary-buffer)
7603 (gnus-set-global-variables)
7604 (when (gnus-group-read-only-p)
7605 (error "The current newsgroup does not support article encrypt"))
7606 (gnus-summary-show-article t)
7608 (or (mail-header-references gnus-current-headers) ""))
7609 (set-buffer gnus-article-buffer)
7610 (let* ((inhibit-read-only t)
7612 (mapcar (lambda (field)
7613 (and (save-restriction
7614 (message-narrow-to-head)
7615 (goto-char (point-min))
7616 (search-forward field nil t))
7618 (message-narrow-to-field)
7620 (delete-region (point-min) (point-max))
7622 '("Content-Type:" "Content-Transfer-Encoding:"
7623 "Content-Disposition:"))))
7624 (message-narrow-to-head)
7625 (message-remove-header "MIME-Version")
7626 (goto-char (point-max))
7627 (setq point (point))
7628 (insert (apply 'concat headers))
7630 (narrow-to-region point (point-max))
7631 (let ((message-options message-options))
7632 (message-options-set 'message-sender user-mail-address)
7633 (message-options-set 'message-recipients user-mail-address)
7634 (message-options-set 'message-sign-encrypt 'not)
7636 (goto-char (point-min))
7637 (insert "MIME-Version: 1.0\n")
7639 (gnus-summary-edit-article-done
7640 references nil summary-buffer t))
7641 (when gnus-keep-backlog
7642 (gnus-backlog-remove-article
7643 (car gnus-article-current) (cdr gnus-article-current)))
7645 (when (get-buffer gnus-original-article-buffer)
7646 (set-buffer gnus-original-article-buffer)
7647 (setq gnus-original-article nil)))
7648 (when gnus-use-cache
7649 (gnus-cache-update-article
7650 (car gnus-article-current) (cdr gnus-article-current))))))))
7652 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7653 "The following specs can be used:
7654 %t The security MIME type
7657 %D Details if button is pressed")
7659 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7660 "The following specs can be used:
7661 %t The security MIME type
7664 %D Details if button is pressed")
7666 (defvar gnus-mime-security-button-line-format-alist
7667 '((?t gnus-tmp-type ?s)
7668 (?i gnus-tmp-info ?s)
7669 (?d gnus-tmp-details ?s)
7670 (?D gnus-tmp-pressed-details ?s)))
7672 (defvar gnus-mime-security-button-map
7673 (let ((map (make-sparse-keymap)))
7674 (define-key map gnus-mouse-2 'gnus-article-push-button)
7675 (define-key map "\r" 'gnus-article-press-button)
7678 (defvar gnus-mime-security-details-buffer nil)
7680 (defvar gnus-mime-security-button-pressed nil)
7682 (defvar gnus-mime-security-show-details-inline t
7683 "If non-nil, show details in the article buffer.")
7685 (defun gnus-mime-security-verify-or-decrypt (handle)
7686 (mm-remove-parts (cdr handle))
7687 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7688 point (inhibit-read-only t))
7690 (goto-char (car region)))
7692 (narrow-to-region (point) (point))
7693 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7694 (let* ((mm-verify-option 'known)
7695 (mm-decrypt-option 'known)
7696 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7697 (unless (eq nparts (cdr handle))
7698 (mm-destroy-parts (cdr handle))
7699 (setcdr handle nparts))))
7700 (setq point (point))
7701 (gnus-mime-display-security handle)
7702 (goto-char (point-max)))
7704 (delete-region (point) (cdr region))
7705 (set-marker (car region) nil)
7706 (set-marker (cdr region) nil))
7709 (defun gnus-mime-security-show-details (handle)
7710 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7712 (gnus-message 5 "No details.")
7713 (if gnus-mime-security-show-details-inline
7714 (let ((gnus-mime-security-button-pressed
7715 (not (get-text-property (point) 'gnus-mime-details)))
7716 (gnus-mime-security-button-line-format
7717 (get-text-property (point) 'gnus-line-format))
7718 (inhibit-read-only t))
7720 (while (eq (get-text-property (point) 'gnus-line-format)
7721 gnus-mime-security-button-line-format)
7725 (narrow-to-region (point) (point))
7726 (gnus-insert-mime-security-button handle))
7727 (delete-region (point)
7728 (or (text-property-not-all
7731 gnus-mime-security-button-line-format)
7734 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7735 (with-current-buffer gnus-mime-security-details-buffer
7738 (setq gnus-mime-security-details-buffer
7739 (gnus-get-buffer-create "*MIME Security Details*")))
7740 (with-current-buffer gnus-mime-security-details-buffer
7742 (goto-char (point-min)))
7743 (pop-to-buffer gnus-mime-security-details-buffer)))))
7745 (defun gnus-mime-security-press-button (handle)
7747 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7748 (gnus-mime-security-show-details handle)
7749 (gnus-mime-security-verify-or-decrypt handle))))
7751 (defun gnus-insert-mime-security-button (handle &optional displayed)
7752 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7755 (or (nth 2 (assoc protocol mm-verify-function-alist))
7756 (nth 2 (assoc protocol mm-decrypt-function-alist))
7758 (if (equal (car handle) "multipart/signed")
7759 " Signed" " Encrypted")
7762 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7765 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7766 gnus-tmp-pressed-details
7768 (setq gnus-tmp-details
7769 (if gnus-tmp-details
7770 (concat "\n" gnus-tmp-details)
7772 (setq gnus-tmp-pressed-details
7773 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7778 gnus-mime-security-button-line-format
7779 gnus-mime-security-button-line-format-alist
7780 `(keymap ,gnus-mime-security-button-map
7781 gnus-callback gnus-mime-security-press-button
7782 gnus-line-format ,gnus-mime-security-button-line-format
7783 gnus-mime-details ,gnus-mime-security-button-pressed
7784 article-type annotation
7787 ;; Exclude a newline.
7790 (widget-convert-button
7793 :action 'gnus-widget-press-button
7794 :button-keymap gnus-mime-security-button-map
7796 (lambda (widget/window &optional overlay pos)
7797 ;; Needed to properly clear the message due to a bug in
7798 ;; wid-edit (XEmacs only).
7799 (when (boundp 'help-echo-owns-message)
7800 (setq help-echo-owns-message t))
7803 (aref gnus-mouse-2 0))))))
7805 (defun gnus-mime-display-security (handle)
7807 (narrow-to-region (point) (point))
7808 (unless (gnus-unbuttonized-mime-type-p (car handle))
7809 (gnus-insert-mime-security-button handle))
7810 (gnus-mime-display-mixed (cdr handle))
7813 (unless (gnus-unbuttonized-mime-type-p (car handle))
7814 (let ((gnus-mime-security-button-line-format
7815 gnus-mime-security-button-end-line-format))
7816 (gnus-insert-mime-security-button handle)))
7817 (mm-set-handle-multipart-parameter
7819 (cons (set-marker (make-marker) (point-min))
7820 (set-marker (make-marker) (point-max))))))
7826 (defun gnus-article-header-presentation-method (entity situation)
7827 (mime-insert-header entity)
7828 (article-decode-group-name))
7830 (set-alist 'mime-header-presentation-method-alist
7831 'gnus-original-article-mode
7832 #'gnus-article-header-presentation-method)
7834 (defun gnus-mime-preview-quitting-method ()
7835 (mime-preview-kill-buffer)
7836 (delete-other-windows)
7837 (gnus-article-show-summary)
7838 (gnus-summary-select-article gnus-show-all-headers t))
7840 (set-alist 'mime-preview-quitting-method-alist
7841 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
7843 (set-alist 'mime-preview-following-method-alist
7844 'gnus-original-article-mode #'gnus-following-method)
7846 (set-alist 'mime-preview-over-to-previous-method-alist
7847 'gnus-original-article-mode
7849 (if (> (point-min) 1)
7850 (gnus-article-prev-page)
7851 (gnus-article-read-summary-keys
7852 nil (gnus-character-to-event ?P)))))
7854 (set-alist 'mime-preview-over-to-next-method-alist
7855 'gnus-original-article-mode'
7857 (if (< (point-max) (buffer-size))
7858 (gnus-article-next-page)
7859 (gnus-article-read-summary-keys
7860 nil (gnus-character-to-event ?N)))))
7870 (run-hooks 'gnus-art-load-hook)
7872 ;;; gnus-art.el ends here