* gnus-art.el (gnus-copy-article-ignored-headers): Update :version.
[gnus] / lisp / gnus-art.el
1 ;;; gnus-art.el --- article mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
3 ;;        Free Software Foundation, Inc.
4
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; Keywords: news
7
8 ;; This file is part of GNU Emacs.
9
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
14
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 ;; GNU General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
24
25 ;;; Commentary:
26
27 ;;; Code:
28
29 (eval-when-compile
30   (require 'cl)
31   (defvar tool-bar-map))
32
33 (require 'gnus)
34 ;; Avoid the "Recursive load suspected" error in Emacs 21.1.
35 (eval-and-compile
36   (let ((recursive-load-depth-limit 100))
37     (require 'gnus-sum)))
38 (require 'gnus-spec)
39 (require 'gnus-int)
40 (require 'gnus-win)
41 (require 'mm-bodies)
42 (require 'mail-parse)
43 (require 'mm-decode)
44 (require 'mm-view)
45 (require 'wid-edit)
46 (require 'mm-uu)
47 (require 'message)
48
49 (autoload 'gnus-msg-mail "gnus-msg" nil t)
50 (autoload 'gnus-button-mailto "gnus-msg")
51 (autoload 'gnus-button-reply "gnus-msg" nil t)
52 (autoload 'ansi-color-apply-on-region "ansi-color")
53
54 (defgroup gnus-article nil
55   "Article display."
56   :link '(custom-manual "(gnus)Article Buffer")
57   :group 'gnus)
58
59 (defgroup gnus-article-treat nil
60   "Treating article parts."
61   :link '(custom-manual "(gnus)Article Hiding")
62   :group 'gnus-article)
63
64 (defgroup gnus-article-hiding nil
65   "Hiding article parts."
66   :link '(custom-manual "(gnus)Article Hiding")
67   :group 'gnus-article)
68
69 (defgroup gnus-article-highlight nil
70   "Article highlighting."
71   :link '(custom-manual "(gnus)Article Highlighting")
72   :group 'gnus-article
73   :group 'gnus-visual)
74
75 (defgroup gnus-article-signature nil
76   "Article signatures."
77   :link '(custom-manual "(gnus)Article Signature")
78   :group 'gnus-article)
79
80 (defgroup gnus-article-headers nil
81   "Article headers."
82   :link '(custom-manual "(gnus)Hiding Headers")
83   :group 'gnus-article)
84
85 (defgroup gnus-article-washing nil
86   "Special commands on articles."
87   :link '(custom-manual "(gnus)Article Washing")
88   :group 'gnus-article)
89
90 (defgroup gnus-article-emphasis nil
91   "Fontisizing articles."
92   :link '(custom-manual "(gnus)Article Fontisizing")
93   :group 'gnus-article)
94
95 (defgroup gnus-article-saving nil
96   "Saving articles."
97   :link '(custom-manual "(gnus)Saving Articles")
98   :group 'gnus-article)
99
100 (defgroup gnus-article-mime nil
101   "Worshiping the MIME wonder."
102   :link '(custom-manual "(gnus)Using MIME")
103   :group 'gnus-article)
104
105 (defgroup gnus-article-buttons nil
106   "Pushable buttons in the article buffer."
107   :link '(custom-manual "(gnus)Article Buttons")
108   :group 'gnus-article)
109
110 (defgroup gnus-article-various nil
111   "Other article options."
112   :link '(custom-manual "(gnus)Misc Article")
113   :group 'gnus-article)
114
115 (defcustom gnus-ignored-headers
116   (mapcar
117    (lambda (header)
118      (concat "^" header ":"))
119    '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
120      "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
121      "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
122      "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
123      "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
124      "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
125      "X-Attribution" "X-Originating-IP" "Delivered-To"
126      "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
127      "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
128      "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
129      "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
130      "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
131      "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
132      "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
133      "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
134      "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
135      "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
136      "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
137      "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
138      "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
139      "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
140      "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
141      "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
142      "List-[A-Za-z]+" "X-Listprocessor-Version"
143      "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
144      "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
145      "X-Received" "Content-length" "X-precedence"
146      "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
147      "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
148      "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
149      "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
150      "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
151      "X-Content-length" "X-Posting-Agent" "Original-Received"
152      "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
153      "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
154      "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
155      "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
156      "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"))
157   "*All headers that start with this regexp will be hidden.
158 This variable can also be a list of regexps of headers to be ignored.
159 If `gnus-visible-headers' is non-nil, this variable will be ignored."
160   :type '(choice :custom-show nil
161                  regexp
162                  (repeat regexp))
163   :group 'gnus-article-hiding)
164
165 (defcustom gnus-visible-headers
166   "^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:"
167   "*All headers that do not match this regexp will be hidden.
168 This variable can also be a list of regexp of headers to remain visible.
169 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
170   :type '(repeat :value-to-internal (lambda (widget value)
171                                       (custom-split-regexp-maybe value))
172                  :match (lambda (widget value)
173                           (or (stringp value)
174                               (widget-editable-list-match widget value)))
175                  regexp)
176   :group 'gnus-article-hiding)
177
178 (defcustom gnus-sorted-header-list
179   '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
180     "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
181   "*This variable is a list of regular expressions.
182 If it is non-nil, headers that match the regular expressions will
183 be placed first in the article buffer in the sequence specified by
184 this list."
185   :type '(repeat regexp)
186   :group 'gnus-article-hiding)
187
188 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
189   "Headers that are only to be displayed if they have interesting data.
190 Possible values in this list are:
191
192   'empty       Headers with no content.
193   'newsgroups  Newsgroup identical to Gnus group.
194   'to-address  To identical to To-address.
195   'to-list     To identical to To-list.
196   'cc-list     CC identical to To-list.
197   'followup-to Followup-to identical to Newsgroups.
198   'reply-to    Reply-to identical to From.
199   'date        Date less than four days old.
200   'long-to     To and/or Cc longer than 1024 characters.
201   'many-to     Multiple To and/or Cc."
202   :type '(set (const :tag "Headers with no content." empty)
203               (const :tag "Newsgroups identical to Gnus group." newsgroups)
204               (const :tag "To identical to To-address." to-address)
205               (const :tag "To identical to To-list." to-list)
206               (const :tag "CC identical to To-list." cc-list)
207               (const :tag "Followup-to identical to Newsgroups." followup-to)
208               (const :tag "Reply-to identical to From." reply-to)
209               (const :tag "Date less than four days old." date)
210               (const :tag "To and/or Cc longer than 1024 characters." long-to)
211               (const :tag "Multiple To and/or Cc headers." many-to))
212   :group 'gnus-article-hiding)
213
214 (defcustom gnus-article-skip-boring nil
215   "Skip over text that is not worth reading.
216 By default, if you set this t, then Gnus will display citations and
217 signatures, but will never scroll down to show you a page consisting
218 only of boring text.  Boring text is controlled by
219 `gnus-article-boring-faces'."
220   :version "22.1"
221   :type 'boolean
222   :group 'gnus-article-hiding)
223
224 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
225   "Regexp matching signature separator.
226 This can also be a list of regexps.  In that case, it will be checked
227 from head to tail looking for a separator.  Searches will be done from
228 the end of the buffer."
229   :type '(repeat string)
230   :group 'gnus-article-signature)
231
232 (defcustom gnus-signature-limit nil
233   "Provide a limit to what is considered a signature.
234 If it is a number, no signature may not be longer (in characters) than
235 that number.  If it is a floating point number, no signature may be
236 longer (in lines) than that number.  If it is a function, the function
237 will be called without any parameters, and if it returns nil, there is
238 no signature in the buffer.  If it is a string, it will be used as a
239 regexp.  If it matches, the text in question is not a signature.
240
241 This can also be a list of the above values."
242   :type '(choice (integer :value 200)
243                  (number :value 4.0)
244                  (function :value fun)
245                  (regexp :value ".*"))
246   :group 'gnus-article-signature)
247
248 (defcustom gnus-hidden-properties '(invisible t intangible t)
249   "Property list to use for hiding text."
250   :type 'sexp
251   :group 'gnus-article-hiding)
252
253 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
254 ;; frames in a session.
255 (defcustom gnus-article-x-face-command
256   (if (featurep 'xemacs)
257       (if (or (gnus-image-type-available-p 'xface)
258               (gnus-image-type-available-p 'pbm))
259           'gnus-display-x-face-in-from
260         "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
261     (if (gnus-image-type-available-p 'pbm)
262         'gnus-display-x-face-in-from
263       "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
264 display -"))
265   "*String or function to be executed to display an X-Face header.
266 If it is a string, the command will be executed in a sub-shell
267 asynchronously.  The compressed face will be piped to this command."
268   :type `(choice string
269                  (function-item gnus-display-x-face-in-from)
270                  function)
271   :version "21.1"
272   :group 'gnus-picon
273   :group 'gnus-article-washing)
274
275 (defcustom gnus-article-x-face-too-ugly nil
276   "Regexp matching posters whose face shouldn't be shown automatically."
277   :type '(choice regexp (const nil))
278   :group 'gnus-article-washing)
279
280 (defcustom gnus-article-banner-alist nil
281   "Banner alist for stripping.
282 For example,
283      ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
284   :version "21.1"
285   :type '(repeat (cons symbol regexp))
286   :group 'gnus-article-washing)
287
288 (gnus-define-group-parameter
289  banner
290  :variable-document
291  "Alist of regexps (to match group names) and banner."
292  :variable-group gnus-article-washing
293  :parameter-type
294  '(choice :tag "Banner"
295           :value nil
296           (const :tag "Remove signature" signature)
297           (symbol :tag "Item in `gnus-article-banner-alist'" none)
298           regexp
299           (const :tag "None" nil))
300  :parameter-document
301  "If non-nil, specify how to remove `banners' from articles.
302
303 Symbol `signature' means to remove signatures delimited by
304 `gnus-signature-separator'.  Any other symbol is used to look up a
305 regular expression to match the banner in `gnus-article-banner-alist'.
306 A string is used as a regular expression to match the banner
307 directly.")
308
309 (defcustom gnus-article-address-banner-alist nil
310   "Alist of mail addresses and banners.
311 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
312 to match a mail address in the From: header, BANNER is one of a symbol
313 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
314 If ADDRESS matches author's mail address, it will remove things like
315 advertisements.  For example:
316
317 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
318 "
319   :type '(repeat
320           (cons
321            (regexp :tag "Address")
322            (choice :tag "Banner" :value nil
323                    (const :tag "Remove signature" signature)
324                    (symbol :tag "Item in `gnus-article-banner-alist'" none)
325                    regexp
326                    (const :tag "None" nil))))
327   :version "22.1"
328   :group 'gnus-article-washing)
329
330 (defmacro gnus-emphasis-custom-with-format (&rest body)
331   `(let ((format "\
332 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
333 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
334      ,@body))
335
336 (defun gnus-emphasis-custom-value-to-external (value)
337   (gnus-emphasis-custom-with-format
338    (if (consp (car value))
339        (list (format format (car (car value)) (cdr (car value)))
340              2
341              (if (nth 1 value) 2 3)
342              (nth 2 value))
343      value)))
344
345 (defun gnus-emphasis-custom-value-to-internal (value)
346   (gnus-emphasis-custom-with-format
347    (let ((regexp (concat "\\`"
348                          (format (regexp-quote format)
349                                  "\\([^()]+\\)" "\\([^()]+\\)")
350                          "\\'"))
351          pattern)
352      (if (string-match regexp (setq pattern (car value)))
353          (list (cons (match-string 1 pattern) (match-string 2 pattern))
354                (= (nth 2 value) 2)
355                (nth 3 value))
356        value))))
357
358 (defcustom gnus-emphasis-alist
359   (let ((types
360          '(("\\*" "\\*" bold nil 2)
361            ("_" "_" underline)
362            ("/" "/" italic)
363            ("_/" "/_" underline-italic)
364            ("_\\*" "\\*_" underline-bold)
365            ("\\*/" "/\\*" bold-italic)
366            ("_\\*/" "/\\*_" underline-bold-italic))))
367     (nconc
368      (gnus-emphasis-custom-with-format
369       (mapcar (lambda (spec)
370                 (list (format format (car spec) (cadr spec))
371                       (or (nth 3 spec) 2)
372                       (or (nth 4 spec) 3)
373                       (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
374               types))
375      '(("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
376         2 3 gnus-emphasis-underline))))
377   "*Alist that says how to fontify certain phrases.
378 Each item looks like this:
379
380   (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
381
382 The first element is a regular expression to be matched.  The second
383 is a number that says what regular expression grouping used to find
384 the entire emphasized word.  The third is a number that says what
385 regexp grouping should be displayed and highlighted.  The fourth
386 is the face used for highlighting."
387   :type
388   '(repeat
389     (menu-choice
390      :format "%[Customizing Style%]\n%v"
391      :indent 2
392      (group :tag "Default"
393             :value ("" 0 0 default)
394             :value-create
395             (lambda (widget)
396               (let ((value (widget-get
397                             (cadr (widget-get (widget-get widget :parent)
398                                               :args))
399                             :value)))
400                 (if (not (eq (nth 2 value) 'default))
401                     (widget-put
402                      widget
403                      :value
404                      (gnus-emphasis-custom-value-to-external value))))
405               (widget-group-value-create widget))
406             regexp
407             (integer :format "Match group: %v")
408             (integer :format "Emphasize group: %v")
409             face)
410      (group :tag "Simple"
411             :value (("_" . "_") nil default)
412             (cons :format "%v"
413                   (regexp :format "Start regexp: %v")
414                   (regexp :format "End regexp: %v"))
415             (boolean :format "Show start and end patterns: %[%v%]\n"
416                      :on " On " :off " Off ")
417             face)))
418   :get (lambda (symbol)
419          (mapcar 'gnus-emphasis-custom-value-to-internal
420                  (default-value symbol)))
421   :set (lambda (symbol value)
422          (set-default symbol (mapcar 'gnus-emphasis-custom-value-to-external
423                                      value)))
424   :group 'gnus-article-emphasis)
425
426 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
427   "A regexp to describe whitespace which should not be emphasized.
428 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
429 The former avoids underlining of leading and trailing whitespace,
430 and the latter avoids underlining any whitespace at all."
431   :version "21.1"
432   :group 'gnus-article-emphasis
433   :type 'regexp)
434
435 (defface gnus-emphasis-bold '((t (:bold t)))
436   "Face used for displaying strong emphasized text (*word*)."
437   :group 'gnus-article-emphasis)
438
439 (defface gnus-emphasis-italic '((t (:italic t)))
440   "Face used for displaying italic emphasized text (/word/)."
441   :group 'gnus-article-emphasis)
442
443 (defface gnus-emphasis-underline '((t (:underline t)))
444   "Face used for displaying underlined emphasized text (_word_)."
445   :group 'gnus-article-emphasis)
446
447 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
448   "Face used for displaying underlined bold emphasized text (_*word*_)."
449   :group 'gnus-article-emphasis)
450
451 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
452   "Face used for displaying underlined italic emphasized text (_/word/_)."
453   :group 'gnus-article-emphasis)
454
455 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
456   "Face used for displaying bold italic emphasized text (/*word*/)."
457   :group 'gnus-article-emphasis)
458
459 (defface gnus-emphasis-underline-bold-italic
460   '((t (:bold t :italic t :underline t)))
461   "Face used for displaying underlined bold italic emphasized text.
462 Example: (_/*word*/_)."
463   :group 'gnus-article-emphasis)
464
465 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
466                                       '((t (:strikethru t)))
467                                     '((t (:strike-through t))))
468   "Face used for displaying strike-through text (-word-)."
469   :group 'gnus-article-emphasis)
470
471 (defface gnus-emphasis-highlight-words
472   '((t (:background "black" :foreground "yellow")))
473   "Face used for displaying highlighted words."
474   :group 'gnus-article-emphasis)
475
476 (defcustom gnus-article-time-format "%a, %d %b %Y %T %Z"
477   "Format for display of Date headers in article bodies.
478 See `format-time-string' for the possible values.
479
480 The variable can also be function, which should return a complete Date
481 header.  The function is called with one argument, the time, which can
482 be fed to `format-time-string'."
483   :type '(choice string function)
484   :link '(custom-manual "(gnus)Article Date")
485   :group 'gnus-article-washing)
486
487 (eval-and-compile
488   (autoload 'mail-extract-address-components "mail-extr"))
489
490 (defcustom gnus-save-all-headers t
491   "*If non-nil, don't remove any headers before saving."
492   :group 'gnus-article-saving
493   :type 'boolean)
494
495 (defcustom gnus-prompt-before-saving 'always
496   "*This variable says how much prompting is to be done when saving articles.
497 If it is nil, no prompting will be done, and the articles will be
498 saved to the default files.  If this variable is `always', each and
499 every article that is saved will be preceded by a prompt, even when
500 saving large batches of articles.  If this variable is neither nil not
501 `always', there the user will be prompted once for a file name for
502 each invocation of the saving commands."
503   :group 'gnus-article-saving
504   :type '(choice (item always)
505                  (item :tag "never" nil)
506                  (sexp :tag "once" :format "%t\n" :value t)))
507
508 (defcustom gnus-saved-headers gnus-visible-headers
509   "Headers to keep if `gnus-save-all-headers' is nil.
510 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
511 If that variable is nil, however, all headers that match this regexp
512 will be kept while the rest will be deleted before saving."
513   :group 'gnus-article-saving
514   :type 'regexp)
515
516 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
517   "A function to save articles in your favourite format.
518 The function must be interactively callable (in other words, it must
519 be an Emacs command).
520
521 Gnus provides the following functions:
522
523 * gnus-summary-save-in-rmail (Rmail format)
524 * gnus-summary-save-in-mail (Unix mail format)
525 * gnus-summary-save-in-folder (MH folder)
526 * gnus-summary-save-in-file (article format)
527 * gnus-summary-save-body-in-file (article body)
528 * gnus-summary-save-in-vm (use VM's folder format)
529 * gnus-summary-write-to-file (article format -- overwrite)."
530   :group 'gnus-article-saving
531   :type '(radio (function-item gnus-summary-save-in-rmail)
532                 (function-item gnus-summary-save-in-mail)
533                 (function-item gnus-summary-save-in-folder)
534                 (function-item gnus-summary-save-in-file)
535                 (function-item gnus-summary-save-body-in-file)
536                 (function-item gnus-summary-save-in-vm)
537                 (function-item gnus-summary-write-to-file)))
538
539 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
540   "A function generating a file name to save articles in Rmail format.
541 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
542   :group 'gnus-article-saving
543   :type 'function)
544
545 (defcustom gnus-mail-save-name 'gnus-plain-save-name
546   "A function generating a file name to save articles in Unix mail format.
547 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
548   :group 'gnus-article-saving
549   :type 'function)
550
551 (defcustom gnus-folder-save-name 'gnus-folder-save-name
552   "A function generating a file name to save articles in MH folder.
553 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
554   :group 'gnus-article-saving
555   :type 'function)
556
557 (defcustom gnus-file-save-name 'gnus-numeric-save-name
558   "A function generating a file name to save articles in article format.
559 The function is called with NEWSGROUP, HEADERS, and optional
560 LAST-FILE."
561   :group 'gnus-article-saving
562   :type 'function)
563
564 (defcustom gnus-split-methods
565   '((gnus-article-archive-name)
566     (gnus-article-nndoc-name))
567   "*Variable used to suggest where articles are to be saved.
568 For instance, if you would like to save articles related to Gnus in
569 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
570 you could set this variable to something like:
571
572  '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
573    (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
574
575 This variable is an alist where the key is the match and the
576 value is a list of possible files to save in if the match is
577 non-nil.
578
579 If the match is a string, it is used as a regexp match on the
580 article.  If the match is a symbol, that symbol will be funcalled
581 from the buffer of the article to be saved with the newsgroup as
582 the parameter.  If it is a list, it will be evaled in the same
583 buffer.
584
585 If this form or function returns a string, this string will be
586 used as a possible file name; and if it returns a non-nil list,
587 that list will be used as possible file names."
588   :group 'gnus-article-saving
589   :type '(repeat (choice (list :value (fun) function)
590                          (cons :value ("" "") regexp (repeat string))
591                          (sexp :value nil))))
592
593 (defcustom gnus-page-delimiter "^\^L"
594   "*Regexp describing what to use as article page delimiters.
595 The default value is \"^\^L\", which is a form linefeed at the
596 beginning of a line."
597   :type 'regexp
598   :group 'gnus-article-various)
599
600 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
601   "*The format specification for the article mode line.
602 See `gnus-summary-mode-line-format' for a closer description.
603
604 The following additional specs are available:
605
606 %w  The article washing status.
607 %m  The number of MIME parts in the article."
608   :type 'string
609   :group 'gnus-article-various)
610
611 (defcustom gnus-article-mode-hook nil
612   "*A hook for Gnus article mode."
613   :type 'hook
614   :group 'gnus-article-various)
615
616 (when (featurep 'xemacs)
617   ;; Extracted from gnus-xmas-define in order to preserve user settings
618   (when (fboundp 'turn-off-scroll-in-place)
619     (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
620   ;; Extracted from gnus-xmas-redefine in order to preserve user settings
621   (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
622
623 (defcustom gnus-article-menu-hook nil
624   "*Hook run after the creation of the article mode menu."
625   :type 'hook
626   :group 'gnus-article-various)
627
628 (defcustom gnus-article-prepare-hook nil
629   "*A hook called after an article has been prepared in the article buffer."
630   :type 'hook
631   :group 'gnus-article-various)
632
633 (defcustom gnus-copy-article-ignored-headers nil
634   "List of headers to be removed when copying an article.
635 Each element is a regular expression."
636   :version "23.0" ;; No Gnus
637   :type '(repeat regexp)
638   :group 'gnus-article-various)
639
640 (make-obsolete-variable 'gnus-article-hide-pgp-hook
641                         "This variable is obsolete in Gnus 5.10.")
642
643 (defcustom gnus-article-button-face 'bold
644   "Face used for highlighting buttons in the article buffer.
645
646 An article button is a piece of text that you can activate by pressing
647 `RET' or `mouse-2' above it."
648   :type 'face
649   :group 'gnus-article-buttons)
650
651 (defcustom gnus-article-mouse-face 'highlight
652   "Face used for mouse highlighting in the article buffer.
653
654 Article buttons will be displayed in this face when the cursor is
655 above them."
656   :type 'face
657   :group 'gnus-article-buttons)
658
659 (defcustom gnus-signature-face 'gnus-signature-face
660   "Face used for highlighting a signature in the article buffer.
661 Obsolete; use the face `gnus-signature-face' for customizations instead."
662   :type 'face
663   :group 'gnus-article-highlight
664   :group 'gnus-article-signature)
665
666 (defface gnus-signature-face
667   '((t
668      (:italic t)))
669   "Face used for highlighting a signature in the article buffer."
670   :group 'gnus-article-highlight
671   :group 'gnus-article-signature)
672
673 (defface gnus-header-from-face
674   '((((class color)
675       (background dark))
676      (:foreground "spring green"))
677     (((class color)
678       (background light))
679      (:foreground "red3"))
680     (t
681      (:italic t)))
682   "Face used for displaying from headers."
683   :group 'gnus-article-headers
684   :group 'gnus-article-highlight)
685
686 (defface gnus-header-subject-face
687   '((((class color)
688       (background dark))
689      (:foreground "SeaGreen3"))
690     (((class color)
691       (background light))
692      (:foreground "red4"))
693     (t
694      (:bold t :italic t)))
695   "Face used for displaying subject headers."
696   :group 'gnus-article-headers
697   :group 'gnus-article-highlight)
698
699 (defface gnus-header-newsgroups-face
700   '((((class color)
701       (background dark))
702      (:foreground "yellow" :italic t))
703     (((class color)
704       (background light))
705      (:foreground "MidnightBlue" :italic t))
706     (t
707      (:italic t)))
708   "Face used for displaying newsgroups headers.
709 In the default setup this face is only used for crossposted
710 articles."
711   :group 'gnus-article-headers
712   :group 'gnus-article-highlight)
713
714 (defface gnus-header-name-face
715   '((((class color)
716       (background dark))
717      (:foreground "SeaGreen"))
718     (((class color)
719       (background light))
720      (:foreground "maroon"))
721     (t
722      (:bold t)))
723   "Face used for displaying header names."
724   :group 'gnus-article-headers
725   :group 'gnus-article-highlight)
726
727 (defface gnus-header-content-face
728   '((((class color)
729       (background dark))
730      (:foreground "forest green" :italic t))
731     (((class color)
732       (background light))
733      (:foreground "indianred4" :italic t))
734     (t
735      (:italic t)))  "Face used for displaying header content."
736   :group 'gnus-article-headers
737   :group 'gnus-article-highlight)
738
739 (defcustom gnus-header-face-alist
740   '(("From" nil gnus-header-from-face)
741     ("Subject" nil gnus-header-subject-face)
742     ("Newsgroups:.*," nil gnus-header-newsgroups-face)
743     ("" gnus-header-name-face gnus-header-content-face))
744   "*Controls highlighting of article headers.
745
746 An alist of the form (HEADER NAME CONTENT).
747
748 HEADER is a regular expression which should match the name of a
749 header and NAME and CONTENT are either face names or nil.
750
751 The name of each header field will be displayed using the face
752 specified by the first element in the list where HEADER matches
753 the header name and NAME is non-nil.  Similarly, the content will
754 be displayed by the first non-nil matching CONTENT face."
755   :group 'gnus-article-headers
756   :group 'gnus-article-highlight
757   :type '(repeat (list (regexp :tag "Header")
758                        (choice :tag "Name"
759                                (item :tag "skip" nil)
760                                (face :value default))
761                        (choice :tag "Content"
762                                (item :tag "skip" nil)
763                                (face :value default)))))
764
765 (defcustom gnus-article-decode-hook
766   '(article-decode-charset article-decode-encoded-words
767                            article-decode-group-name article-decode-idna-rhs)
768   "*Hook run to decode charsets in articles."
769   :group 'gnus-article-headers
770   :type 'hook)
771
772 (defcustom gnus-display-mime-function 'gnus-display-mime
773   "Function to display MIME articles."
774   :group 'gnus-article-mime
775   :type 'function)
776
777 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
778   "Function used to decode headers.")
779
780 (defvar gnus-article-dumbquotes-map
781   '(("\200" "EUR")
782     ("\202" ",")
783     ("\203" "f")
784     ("\204" ",,")
785     ("\205" "...")
786     ("\213" "<")
787     ("\214" "OE")
788     ("\221" "`")
789     ("\222" "'")
790     ("\223" "``")
791     ("\224" "\"")
792     ("\225" "*")
793     ("\226" "-")
794     ("\227" "--")
795     ("\230" "~")
796     ("\231" "(TM)")
797     ("\233" ">")
798     ("\234" "oe")
799     ("\264" "'"))
800   "Table for MS-to-Latin1 translation.")
801
802 (defcustom gnus-ignored-mime-types nil
803   "List of MIME types that should be ignored by Gnus."
804   :version "21.1"
805   :group 'gnus-article-mime
806   :type '(repeat regexp))
807
808 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
809   "List of MIME types that should not be given buttons when rendered inline.
810 See also `gnus-buttonized-mime-types' which may override this variable.
811 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
812   :version "21.1"
813   :group 'gnus-article-mime
814   :type '(repeat regexp))
815
816 (defcustom gnus-buttonized-mime-types nil
817   "List of MIME types that should be given buttons when rendered inline.
818 If set, this variable overrides `gnus-unbuttonized-mime-types'.
819 To see e.g. security buttons you could set this to
820 `(\"multipart/signed\")'.
821 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
822   :version "22.1"
823   :group 'gnus-article-mime
824   :type '(repeat regexp))
825
826 (defcustom gnus-inhibit-mime-unbuttonizing nil
827   "If non-nil, all MIME parts get buttons.
828 When nil (the default value), then some MIME parts do not get buttons,
829 as described by the variables `gnus-buttonized-mime-types' and
830 `gnus-unbuttonized-mime-types'."
831   :version "22.1"
832   :group 'gnus-article-mime
833   :type 'boolean)
834
835 (defcustom gnus-body-boundary-delimiter "_"
836   "String used to delimit header and body.
837 This variable is used by `gnus-article-treat-body-boundary' which can
838 be controlled by `gnus-treat-body-boundary'."
839   :version "22.1"
840   :group 'gnus-article-various
841   :type '(choice (item :tag "None" :value nil)
842                  string))
843
844 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
845                                   "/usr/share/picons")
846   "Defines the location of the faces database.
847 For information on obtaining this database of pretty pictures, please
848 see http://www.cs.indiana.edu/picons/ftp/index.html"
849   :version "22.1"
850   :type '(repeat directory)
851   :link '(url-link :tag "download"
852                    "http://www.cs.indiana.edu/picons/ftp/index.html")
853   :link '(custom-manual "(gnus)Picons")
854   :group 'gnus-picon)
855
856 (defun gnus-picons-installed-p ()
857   "Say whether picons are installed on your machine."
858   (let ((installed nil))
859     (dolist (database gnus-picon-databases)
860       (when (file-exists-p database)
861         (setq installed t)))
862     installed))
863
864 (defcustom gnus-article-mime-part-function nil
865   "Function called with a MIME handle as the argument.
866 This is meant for people who want to do something automatic based
867 on parts -- for instance, adding Vcard info to a database."
868   :group 'gnus-article-mime
869   :type 'function)
870
871 (defcustom gnus-mime-multipart-functions nil
872   "An alist of MIME types to functions to display them."
873   :version "21.1"
874   :group 'gnus-article-mime
875   :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
876
877 (defcustom gnus-article-date-lapsed-new-header nil
878   "Whether the X-Sent and Date headers can coexist.
879 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
880 either replace the old \"Date:\" header (if this variable is nil), or
881 be added below it (otherwise)."
882   :version "21.1"
883   :group 'gnus-article-headers
884   :type 'boolean)
885
886 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
887   "Function called with a MIME handle as the argument.
888 This is meant for people who want to view first matched part.
889 For `undisplayed-alternative' (default), the first undisplayed
890 part or alternative part is used.  For `undisplayed', the first
891 undisplayed part is used.  For a function, the first part which
892 the function return t is used.  For nil, the first part is
893 used."
894   :version "21.1"
895   :group 'gnus-article-mime
896   :type '(choice
897           (item :tag "first" :value nil)
898           (item :tag "undisplayed" :value undisplayed)
899           (item :tag "undisplayed or alternative"
900                 :value undisplayed-alternative)
901           (function)))
902
903 (defcustom gnus-mime-action-alist
904   '(("save to file" . gnus-mime-save-part)
905     ("save and strip" . gnus-mime-save-part-and-strip)
906     ("delete part" . gnus-mime-delete-part)
907     ("display as text" . gnus-mime-inline-part)
908     ("view the part" . gnus-mime-view-part)
909     ("pipe to command" . gnus-mime-pipe-part)
910     ("toggle display" . gnus-article-press-button)
911     ("toggle display" . gnus-article-view-part-as-charset)
912     ("view as type" . gnus-mime-view-part-as-type)
913     ("view internally" . gnus-mime-view-part-internally)
914     ("view externally" . gnus-mime-view-part-externally))
915   "An alist of actions that run on the MIME attachment."
916   :group 'gnus-article-mime
917   :type '(repeat (cons (string :tag "name")
918                        (function))))
919
920 ;;;
921 ;;; The treatment variables
922 ;;;
923
924 (defvar gnus-part-display-hook nil
925   "Hook called on parts that are to receive treatment.")
926
927 (defvar gnus-article-treat-custom
928   '(choice (const :tag "Off" nil)
929            (const :tag "On" t)
930            (const :tag "Header" head)
931            (const :tag "Last" last)
932            (integer :tag "Less")
933            (repeat :tag "Groups" regexp)
934            (sexp :tag "Predicate")))
935
936 (defvar gnus-article-treat-head-custom
937   '(choice (const :tag "Off" nil)
938            (const :tag "Header" head)))
939
940 (defvar gnus-article-treat-types '("text/plain")
941   "Parts to treat.")
942
943 (defvar gnus-inhibit-treatment nil
944   "Whether to inhibit treatment.")
945
946 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
947   "Highlight the signature.
948 Valid values are nil, t, `head', `last', an integer or a predicate.
949 See Info node `(gnus)Customizing Articles'."
950   :group 'gnus-article-treat
951   :link '(custom-manual "(gnus)Customizing Articles")
952   :type gnus-article-treat-custom)
953 (put 'gnus-treat-highlight-signature 'highlight t)
954
955 (defcustom gnus-treat-buttonize 100000
956   "Add buttons.
957 Valid values are nil, t, `head', `last', an integer or a predicate.
958 See Info node `(gnus)Customizing Articles'."
959   :group 'gnus-article-treat
960   :link '(custom-manual "(gnus)Customizing Articles")
961   :type gnus-article-treat-custom)
962 (put 'gnus-treat-buttonize 'highlight t)
963
964 (defcustom gnus-treat-buttonize-head 'head
965   "Add buttons to the head.
966 Valid values are nil, t, `head', `last', an integer or a predicate.
967 See Info node `(gnus)Customizing Articles' for details."
968   :group 'gnus-article-treat
969   :link '(custom-manual "(gnus)Customizing Articles")
970   :type gnus-article-treat-head-custom)
971 (put 'gnus-treat-buttonize-head 'highlight t)
972
973 (defcustom gnus-treat-emphasize
974   (and (or window-system
975            (featurep 'xemacs))
976        50000)
977   "Emphasize text.
978 Valid values are nil, t, `head', `last', an integer or a predicate.
979 See Info node `(gnus)Customizing Articles' for details."
980   :group 'gnus-article-treat
981   :link '(custom-manual "(gnus)Customizing Articles")
982   :type gnus-article-treat-custom)
983 (put 'gnus-treat-emphasize 'highlight t)
984
985 (defcustom gnus-treat-strip-cr nil
986   "Remove carriage returns.
987 Valid values are nil, t, `head', `last', an integer or a predicate.
988 See Info node `(gnus)Customizing Articles' for details."
989   :version "22.1"
990   :group 'gnus-article-treat
991   :link '(custom-manual "(gnus)Customizing Articles")
992   :type gnus-article-treat-custom)
993
994 (defcustom gnus-treat-unsplit-urls nil
995   "Remove newlines from within URLs.
996 Valid values are nil, t, `head', `last', an integer or a predicate.
997 See Info node `(gnus)Customizing Articles' for details."
998   :version "22.1"
999   :group 'gnus-article-treat
1000   :link '(custom-manual "(gnus)Customizing Articles")
1001   :type gnus-article-treat-custom)
1002
1003 (defcustom gnus-treat-leading-whitespace nil
1004   "Remove leading whitespace in headers.
1005 Valid values are nil, t, `head', `last', an integer or a predicate.
1006 See Info node `(gnus)Customizing Articles' for details."
1007   :version "22.1"
1008   :group 'gnus-article-treat
1009   :link '(custom-manual "(gnus)Customizing Articles")
1010   :type gnus-article-treat-custom)
1011
1012 (defcustom gnus-treat-hide-headers 'head
1013   "Hide headers.
1014 Valid values are nil, t, `head', `last', an integer or a predicate.
1015 See Info node `(gnus)Customizing Articles' for details."
1016   :group 'gnus-article-treat
1017   :link '(custom-manual "(gnus)Customizing Articles")
1018   :type gnus-article-treat-head-custom)
1019
1020 (defcustom gnus-treat-hide-boring-headers nil
1021   "Hide boring headers.
1022 Valid values are nil, t, `head', `last', an integer or a predicate.
1023 See Info node `(gnus)Customizing Articles' for details."
1024   :group 'gnus-article-treat
1025   :link '(custom-manual "(gnus)Customizing Articles")
1026   :type gnus-article-treat-head-custom)
1027
1028 (defcustom gnus-treat-hide-signature nil
1029   "Hide the signature.
1030 Valid values are nil, t, `head', `last', an integer or a predicate.
1031 See Info node `(gnus)Customizing Articles' for details."
1032   :group 'gnus-article-treat
1033   :link '(custom-manual "(gnus)Customizing Articles")
1034   :type gnus-article-treat-custom)
1035
1036 (defcustom gnus-treat-fill-article nil
1037   "Fill the article.
1038 Valid values are nil, t, `head', `last', an integer or a predicate.
1039 See Info node `(gnus)Customizing Articles' for details."
1040   :group 'gnus-article-treat
1041   :link '(custom-manual "(gnus)Customizing Articles")
1042   :type gnus-article-treat-custom)
1043
1044 (defcustom gnus-treat-hide-citation nil
1045   "Hide cited text.
1046 Valid values are nil, t, `head', `last', an integer or a predicate.
1047 See Info node `(gnus)Customizing Articles' for details."
1048   :group 'gnus-article-treat
1049   :link '(custom-manual "(gnus)Customizing Articles")
1050   :type gnus-article-treat-custom)
1051
1052 (defcustom gnus-treat-hide-citation-maybe nil
1053   "Hide cited text.
1054 Valid values are nil, t, `head', `last', an integer or a predicate.
1055 See Info node `(gnus)Customizing Articles' for details."
1056   :group 'gnus-article-treat
1057   :link '(custom-manual "(gnus)Customizing Articles")
1058   :type gnus-article-treat-custom)
1059
1060 (defcustom gnus-treat-strip-list-identifiers 'head
1061   "Strip list identifiers from `gnus-list-identifiers`.
1062 Valid values are nil, t, `head', `last', an integer or a predicate.
1063 See Info node `(gnus)Customizing Articles' for details."
1064   :version "21.1"
1065   :group 'gnus-article-treat
1066   :link '(custom-manual "(gnus)Customizing Articles")
1067   :type gnus-article-treat-custom)
1068
1069 (make-obsolete-variable 'gnus-treat-strip-pgp
1070                         "This option is obsolete in Gnus 5.10.")
1071
1072 (defcustom gnus-treat-strip-pem nil
1073   "Strip PEM signatures.
1074 Valid values are nil, t, `head', `last', an integer or a predicate.
1075 See Info node `(gnus)Customizing Articles' for details."
1076   :group 'gnus-article-treat
1077   :link '(custom-manual "(gnus)Customizing Articles")
1078   :type gnus-article-treat-custom)
1079
1080 (defcustom gnus-treat-strip-banner t
1081   "Strip banners from articles.
1082 The banner to be stripped is specified in the `banner' group parameter.
1083 Valid values are nil, t, `head', `last', an integer or a predicate.
1084 See Info node `(gnus)Customizing Articles' for details."
1085   :group 'gnus-article-treat
1086   :link '(custom-manual "(gnus)Customizing Articles")
1087   :type gnus-article-treat-custom)
1088
1089 (defcustom gnus-treat-highlight-headers 'head
1090   "Highlight the headers.
1091 Valid values are nil, t, `head', `last', an integer or a predicate.
1092 See Info node `(gnus)Customizing Articles' for details."
1093   :group 'gnus-article-treat
1094   :link '(custom-manual "(gnus)Customizing Articles")
1095   :type gnus-article-treat-head-custom)
1096 (put 'gnus-treat-highlight-headers 'highlight t)
1097
1098 (defcustom gnus-treat-highlight-citation t
1099   "Highlight cited text.
1100 Valid values are nil, t, `head', `last', an integer or a predicate.
1101 See Info node `(gnus)Customizing Articles' for details."
1102   :group 'gnus-article-treat
1103   :link '(custom-manual "(gnus)Customizing Articles")
1104   :type gnus-article-treat-custom)
1105 (put 'gnus-treat-highlight-citation 'highlight t)
1106
1107 (defcustom gnus-treat-date-ut nil
1108   "Display the Date in UT (GMT).
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-head-custom)
1114
1115 (defcustom gnus-treat-date-local nil
1116   "Display the Date in the local timezone.
1117 Valid values are nil, t, `head', `last', an integer or a predicate.
1118 See Info node `(gnus)Customizing Articles' for details."
1119   :group 'gnus-article-treat
1120   :link '(custom-manual "(gnus)Customizing Articles")
1121   :type gnus-article-treat-head-custom)
1122
1123 (defcustom gnus-treat-date-english nil
1124   "Display the Date in a format that can be read aloud in English.
1125 Valid values are nil, t, `head', `last', an integer or a predicate.
1126 See Info node `(gnus)Customizing Articles' for details."
1127   :version "22.1"
1128   :group 'gnus-article-treat
1129   :link '(custom-manual "(gnus)Customizing Articles")
1130   :type gnus-article-treat-head-custom)
1131
1132 (defcustom gnus-treat-date-lapsed nil
1133   "Display the Date header in a way that says how much time has elapsed.
1134 Valid values are nil, t, `head', `last', an integer or a predicate.
1135 See Info node `(gnus)Customizing Articles' for details."
1136   :group 'gnus-article-treat
1137   :link '(custom-manual "(gnus)Customizing Articles")
1138   :type gnus-article-treat-head-custom)
1139
1140 (defcustom gnus-treat-date-original nil
1141   "Display the date in the original timezone.
1142 Valid values are nil, t, `head', `last', an integer or a predicate.
1143 See Info node `(gnus)Customizing Articles' for details."
1144   :group 'gnus-article-treat
1145   :link '(custom-manual "(gnus)Customizing Articles")
1146   :type gnus-article-treat-head-custom)
1147
1148 (defcustom gnus-treat-date-iso8601 nil
1149   "Display the date in the ISO8601 format.
1150 Valid values are nil, t, `head', `last', an integer or a predicate.
1151 See Info node `(gnus)Customizing Articles' for details."
1152   :version "21.1"
1153   :group 'gnus-article-treat
1154   :link '(custom-manual "(gnus)Customizing Articles")
1155   :type gnus-article-treat-head-custom)
1156
1157 (defcustom gnus-treat-date-user-defined nil
1158   "Display the date in a user-defined format.
1159 The format is defined by the `gnus-article-time-format' variable.
1160 Valid values are nil, t, `head', `last', an integer or a predicate.
1161 See Info node `(gnus)Customizing Articles' for details."
1162   :group 'gnus-article-treat
1163   :link '(custom-manual "(gnus)Customizing Articles")
1164   :type gnus-article-treat-head-custom)
1165
1166 (defcustom gnus-treat-strip-headers-in-body t
1167   "Strip the X-No-Archive header line from the beginning of the body.
1168 Valid values are nil, t, `head', `last', an integer or a predicate.
1169 See Info node `(gnus)Customizing Articles' for details."
1170   :version "21.1"
1171   :group 'gnus-article-treat
1172   :link '(custom-manual "(gnus)Customizing Articles")
1173   :type gnus-article-treat-custom)
1174
1175 (defcustom gnus-treat-strip-trailing-blank-lines nil
1176   "Strip trailing blank lines.
1177 Valid values are nil, t, `head', `last', an integer or a predicate.
1178 See Info node `(gnus)Customizing Articles' for details."
1179   :group 'gnus-article-treat
1180   :link '(custom-manual "(gnus)Customizing Articles")
1181   :type gnus-article-treat-custom)
1182
1183 (defcustom gnus-treat-strip-leading-blank-lines nil
1184   "Strip leading blank lines.
1185 Valid values are nil, t, `head', `last', an integer or a predicate.
1186 See Info node `(gnus)Customizing Articles' for details."
1187   :group 'gnus-article-treat
1188   :link '(custom-manual "(gnus)Customizing Articles")
1189   :type gnus-article-treat-custom)
1190
1191 (defcustom gnus-treat-strip-multiple-blank-lines nil
1192   "Strip multiple blank lines.
1193 Valid values are nil, t, `head', `last', an integer or a predicate.
1194 See Info node `(gnus)Customizing Articles' for details."
1195   :group 'gnus-article-treat
1196   :link '(custom-manual "(gnus)Customizing Articles")
1197   :type gnus-article-treat-custom)
1198
1199 (defcustom gnus-treat-unfold-headers 'head
1200   "Unfold folded header lines.
1201 Valid values are nil, t, `head', `last', an integer or a predicate.
1202 See Info node `(gnus)Customizing Articles' for details."
1203   :version "22.1"
1204   :group 'gnus-article-treat
1205   :link '(custom-manual "(gnus)Customizing Articles")
1206   :type gnus-article-treat-custom)
1207
1208 (defcustom gnus-treat-fold-headers nil
1209   "Fold headers.
1210 Valid values are nil, t, `head', `last', an integer or a predicate.
1211 See Info node `(gnus)Customizing Articles' for details."
1212   :version "22.1"
1213   :group 'gnus-article-treat
1214   :link '(custom-manual "(gnus)Customizing Articles")
1215   :type gnus-article-treat-custom)
1216
1217 (defcustom gnus-treat-fold-newsgroups 'head
1218   "Fold the Newsgroups and Followup-To headers.
1219 Valid values are nil, t, `head', `last', an integer or a predicate.
1220 See Info node `(gnus)Customizing Articles' for details."
1221   :version "22.1"
1222   :group 'gnus-article-treat
1223   :link '(custom-manual "(gnus)Customizing Articles")
1224   :type gnus-article-treat-custom)
1225
1226 (defcustom gnus-treat-overstrike t
1227   "Treat overstrike highlighting.
1228 Valid values are nil, t, `head', `last', an integer or a predicate.
1229 See Info node `(gnus)Customizing Articles' for details."
1230   :group 'gnus-article-treat
1231   :link '(custom-manual "(gnus)Customizing Articles")
1232   :type gnus-article-treat-custom)
1233 (put 'gnus-treat-overstrike 'highlight t)
1234
1235 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1236   "Treat ANSI SGR control sequences.
1237 Valid values are nil, t, `head', `last', an integer or a predicate.
1238 See Info node `(gnus)Customizing Articles' for details."
1239   :group 'gnus-article-treat
1240   :link '(custom-manual "(gnus)Customizing Articles")
1241   :type gnus-article-treat-custom)
1242
1243 (make-obsolete-variable 'gnus-treat-display-xface
1244                         'gnus-treat-display-x-face)
1245
1246 (defcustom gnus-treat-display-x-face
1247   (and (not noninteractive)
1248        (or (and (fboundp 'image-type-available-p)
1249                 (image-type-available-p 'xbm)
1250                 (string-match "^0x" (shell-command-to-string "uncompface"))
1251                 (executable-find "icontopbm"))
1252            (and (featurep 'xemacs)
1253                 (featurep 'xface)))
1254        'head)
1255   "Display X-Face headers.
1256 Valid values are nil, t, `head', `last', an integer or a predicate.
1257 See Info node `(gnus)Customizing Articles' and Info node
1258 `(gnus)X-Face' for details."
1259   :group 'gnus-article-treat
1260   :version "21.1"
1261   :link '(custom-manual "(gnus)Customizing Articles")
1262   :link '(custom-manual "(gnus)X-Face")
1263   :type gnus-article-treat-head-custom
1264   :set (lambda (symbol value)
1265          (set-default
1266           symbol
1267           (cond ((or (boundp symbol) (get symbol 'saved-value))
1268                  value)
1269                 ((boundp 'gnus-treat-display-xface)
1270                  (message "\
1271 ** gnus-treat-display-xface is an obsolete variable;\
1272  use gnus-treat-display-x-face instead")
1273                  (default-value 'gnus-treat-display-xface))
1274                 ((get 'gnus-treat-display-xface 'saved-value)
1275                  (message "\
1276 ** gnus-treat-display-xface is an obsolete variable;\
1277  use gnus-treat-display-x-face instead")
1278                  (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1279                 (t
1280                  value)))))
1281 (put 'gnus-treat-display-x-face 'highlight t)
1282
1283 (defcustom gnus-treat-display-face
1284   (and (not noninteractive)
1285        (or (and (fboundp 'image-type-available-p)
1286                 (image-type-available-p 'png))
1287            (and (featurep 'xemacs)
1288                 (featurep 'png)))
1289        'head)
1290   "Display Face headers.
1291 Valid values are nil, t, `head', `last', an integer or a predicate.
1292 See Info node `(gnus)Customizing Articles' and Info node
1293 `(gnus)X-Face' for details."
1294   :group 'gnus-article-treat
1295   :version "22.1"
1296   :link '(custom-manual "(gnus)Customizing Articles")
1297   :link '(custom-manual "(gnus)X-Face")
1298   :type gnus-article-treat-head-custom)
1299 (put 'gnus-treat-display-face 'highlight t)
1300
1301 (defcustom gnus-treat-display-smileys
1302   (if (or (and (featurep 'xemacs)
1303                (featurep 'xpm))
1304           (and (fboundp 'image-type-available-p)
1305                (image-type-available-p 'pbm)))
1306       t nil)
1307   "Display smileys.
1308 Valid values are nil, t, `head', `last', an integer or a predicate.
1309 See Info node `(gnus)Customizing Articles' and Info node
1310 `(gnus)Smileys' for details."
1311   :group 'gnus-article-treat
1312   :version "21.1"
1313   :link '(custom-manual "(gnus)Customizing Articles")
1314   :link '(custom-manual "(gnus)Smileys")
1315   :type gnus-article-treat-custom)
1316 (put 'gnus-treat-display-smileys 'highlight t)
1317
1318 (defcustom gnus-treat-from-picon
1319   (if (and (gnus-image-type-available-p 'xpm)
1320            (gnus-picons-installed-p))
1321       'head nil)
1322   "Display picons in the From header.
1323 Valid values are nil, t, `head', `last', an integer or a predicate.
1324 See Info node `(gnus)Customizing Articles' and Info node
1325 `(gnus)Picons' for details."
1326   :version "22.1"
1327   :group 'gnus-article-treat
1328   :group 'gnus-picon
1329   :link '(custom-manual "(gnus)Customizing Articles")
1330   :link '(custom-manual "(gnus)Picons")
1331   :type gnus-article-treat-head-custom)
1332 (put 'gnus-treat-from-picon 'highlight t)
1333
1334 (defcustom gnus-treat-mail-picon
1335   (if (and (gnus-image-type-available-p 'xpm)
1336            (gnus-picons-installed-p))
1337       'head nil)
1338   "Display picons in To and Cc headers.
1339 Valid values are nil, t, `head', `last', an integer or a predicate.
1340 See Info node `(gnus)Customizing Articles' and Info node
1341 `(gnus)Picons' for details."
1342   :version "22.1"
1343   :group 'gnus-article-treat
1344   :group 'gnus-picon
1345   :link '(custom-manual "(gnus)Customizing Articles")
1346   :link '(custom-manual "(gnus)Picons")
1347   :type gnus-article-treat-head-custom)
1348 (put 'gnus-treat-mail-picon 'highlight t)
1349
1350 (defcustom gnus-treat-newsgroups-picon
1351   (if (and (gnus-image-type-available-p 'xpm)
1352            (gnus-picons-installed-p))
1353       'head nil)
1354   "Display picons in the Newsgroups and Followup-To headers.
1355 Valid values are nil, t, `head', `last', an integer or a predicate.
1356 See Info node `(gnus)Customizing Articles' and Info node
1357 `(gnus)Picons' for details."
1358   :version "22.1"
1359   :group 'gnus-article-treat
1360   :group 'gnus-picon
1361   :link '(custom-manual "(gnus)Customizing Articles")
1362   :link '(custom-manual "(gnus)Picons")
1363   :type gnus-article-treat-head-custom)
1364 (put 'gnus-treat-newsgroups-picon 'highlight t)
1365
1366 (defcustom gnus-treat-body-boundary
1367   (if (and (eq window-system 'x)
1368            (or gnus-treat-newsgroups-picon
1369                gnus-treat-mail-picon
1370                gnus-treat-from-picon))
1371       'head nil)
1372   "Draw a boundary at the end of the headers.
1373 Valid values are nil and `head'.
1374 See Info node `(gnus)Customizing Articles' for details."
1375   :version "22.1"
1376   :group 'gnus-article-treat
1377   :link '(custom-manual "(gnus)Customizing Articles")
1378   :type gnus-article-treat-head-custom)
1379
1380 (defcustom gnus-treat-capitalize-sentences nil
1381   "Capitalize sentence-starting words.
1382 Valid values are nil, t, `head', `last', an integer or a predicate.
1383 See Info node `(gnus)Customizing Articles' for details."
1384   :version "21.1"
1385   :group 'gnus-article-treat
1386   :link '(custom-manual "(gnus)Customizing Articles")
1387   :type gnus-article-treat-custom)
1388
1389 (defcustom gnus-treat-wash-html nil
1390   "Format as HTML.
1391 Valid values are nil, t, `head', `last', an integer or a predicate.
1392 See Info node `(gnus)Customizing Articles' for details."
1393   :version "22.1"
1394   :group 'gnus-article-treat
1395   :link '(custom-manual "(gnus)Customizing Articles")
1396   :type gnus-article-treat-custom)
1397
1398 (defcustom gnus-treat-fill-long-lines nil
1399   "Fill long lines.
1400 Valid values are nil, t, `head', `last', an integer or a predicate.
1401 See Info node `(gnus)Customizing Articles' for details."
1402   :group 'gnus-article-treat
1403   :link '(custom-manual "(gnus)Customizing Articles")
1404   :type gnus-article-treat-custom)
1405
1406 (defcustom gnus-treat-play-sounds nil
1407   "Play sounds.
1408 Valid values are nil, t, `head', `last', an integer or a predicate.
1409 See Info node `(gnus)Customizing Articles' for details."
1410   :version "21.1"
1411   :group 'gnus-article-treat
1412   :link '(custom-manual "(gnus)Customizing Articles")
1413   :type gnus-article-treat-custom)
1414
1415 (defcustom gnus-treat-translate nil
1416   "Translate articles from one language to another.
1417 Valid values are nil, t, `head', `last', an integer or a predicate.
1418 See Info node `(gnus)Customizing Articles' for details."
1419   :version "21.1"
1420   :group 'gnus-article-treat
1421   :link '(custom-manual "(gnus)Customizing Articles")
1422   :type gnus-article-treat-custom)
1423
1424 (defcustom gnus-treat-x-pgp-sig nil
1425   "Verify X-PGP-Sig.
1426 To automatically treat X-PGP-Sig, set it to head.
1427 Valid values are nil, t, `head', `last', an integer or a predicate.
1428 See Info node `(gnus)Customizing Articles' for details."
1429   :version "22.1"
1430   :group 'gnus-article-treat
1431   :group 'mime-security
1432   :link '(custom-manual "(gnus)Customizing Articles")
1433   :type gnus-article-treat-custom)
1434
1435 (defvar gnus-article-encrypt-protocol-alist
1436   '(("PGP" . mml2015-self-encrypt)))
1437
1438 ;; Set to nil if more than one protocol added to
1439 ;; gnus-article-encrypt-protocol-alist.
1440 (defcustom gnus-article-encrypt-protocol "PGP"
1441   "The protocol used for encrypt articles.
1442 It is a string, such as \"PGP\". If nil, ask user."
1443   :version "22.1"
1444   :type 'string
1445   :group 'mime-security)
1446
1447 (defvar gnus-article-wash-function nil
1448   "Function used for converting HTML into text.")
1449
1450 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1451                               (mm-coding-system-p 'utf-8)
1452                               (executable-find idna-program))
1453   "Whether IDNA decoding of headers is used when viewing messages.
1454 This requires GNU Libidn, and by default only enabled if it is found."
1455   :version "22.1"
1456   :group 'gnus-article-headers
1457   :type 'boolean)
1458
1459 (defcustom gnus-article-over-scroll nil
1460   "If non-nil, allow scrolling the article buffer even when there no more text."
1461   :version "22.1"
1462   :group 'gnus-article
1463   :type 'boolean)
1464
1465 ;;; Internal variables
1466
1467 (defvar gnus-english-month-names
1468   '("January" "February" "March" "April" "May" "June" "July" "August"
1469     "September" "October" "November" "December"))
1470
1471 (defvar gnus-button-regexp nil)
1472 (defvar gnus-button-marker-list nil)
1473 ;; Regexp matching any of the regexps from `gnus-button-alist'.
1474
1475 (defvar gnus-button-last nil)
1476 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
1477
1478 (defvar article-goto-body-goes-to-point-min-p nil)
1479 (defvar gnus-article-wash-types nil)
1480 (defvar gnus-article-emphasis-alist nil)
1481 (defvar gnus-article-image-alist nil)
1482
1483 (defvar gnus-article-mime-handle-alist-1 nil)
1484 (defvar gnus-treatment-function-alist
1485   '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1486     (gnus-treat-strip-banner gnus-article-strip-banner)
1487     (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1488     (gnus-treat-highlight-signature gnus-article-highlight-signature)
1489     (gnus-treat-buttonize gnus-article-add-buttons)
1490     (gnus-treat-fill-article gnus-article-fill-cited-article)
1491     (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1492     (gnus-treat-strip-cr gnus-article-remove-cr)
1493     (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1494     (gnus-treat-date-ut gnus-article-date-ut)
1495     (gnus-treat-date-local gnus-article-date-local)
1496     (gnus-treat-date-english gnus-article-date-english)
1497     (gnus-treat-date-lapsed gnus-article-date-lapsed)
1498     (gnus-treat-date-original gnus-article-date-original)
1499     (gnus-treat-date-user-defined gnus-article-date-user)
1500     (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1501     (gnus-treat-display-x-face gnus-article-display-x-face)
1502     (gnus-treat-display-face gnus-article-display-face)
1503     (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1504     (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1505     (gnus-treat-hide-signature gnus-article-hide-signature)
1506     (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1507     (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1508     (gnus-treat-strip-pem gnus-article-hide-pem)
1509     (gnus-treat-from-picon gnus-treat-from-picon)
1510     (gnus-treat-mail-picon gnus-treat-mail-picon)
1511     (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1512     (gnus-treat-highlight-headers gnus-article-highlight-headers)
1513     (gnus-treat-highlight-signature gnus-article-highlight-signature)
1514     (gnus-treat-strip-trailing-blank-lines
1515      gnus-article-remove-trailing-blank-lines)
1516     (gnus-treat-strip-leading-blank-lines
1517      gnus-article-strip-leading-blank-lines)
1518     (gnus-treat-strip-multiple-blank-lines
1519      gnus-article-strip-multiple-blank-lines)
1520     (gnus-treat-overstrike gnus-article-treat-overstrike)
1521     (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1522     (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1523     (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1524     (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1525     (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1526     (gnus-treat-display-smileys gnus-treat-smiley)
1527     (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1528     (gnus-treat-wash-html gnus-article-wash-html)
1529     (gnus-treat-emphasize gnus-article-emphasize)
1530     (gnus-treat-hide-citation gnus-article-hide-citation)
1531     (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1532     (gnus-treat-highlight-citation gnus-article-highlight-citation)
1533     (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1534     (gnus-treat-play-sounds gnus-earcon-display)))
1535
1536 (defvar gnus-article-mime-handle-alist nil)
1537 (defvar article-lapsed-timer nil)
1538 (defvar gnus-article-current-summary nil)
1539
1540 (defvar gnus-article-mode-syntax-table
1541   (let ((table (copy-syntax-table text-mode-syntax-table)))
1542     ;; This causes the citation match run O(2^n).
1543     ;; (modify-syntax-entry ?- "w" table)
1544     (modify-syntax-entry ?> ")<" table)
1545     (modify-syntax-entry ?< "(>" table)
1546     ;; make M-. in article buffers work for `foo' strings
1547     (modify-syntax-entry ?' " " table)
1548     (modify-syntax-entry ?` " " table)
1549     table)
1550   "Syntax table used in article mode buffers.
1551 Initialized from `text-mode-syntax-table.")
1552
1553 (defvar gnus-save-article-buffer nil)
1554
1555 (defvar gnus-article-mode-line-format-alist
1556   (nconc '((?w (gnus-article-wash-status) ?s)
1557            (?m (gnus-article-mime-part-status) ?s))
1558          gnus-summary-mode-line-format-alist))
1559
1560 (defvar gnus-number-of-articles-to-be-saved nil)
1561
1562 (defvar gnus-inhibit-hiding nil)
1563
1564 (defvar gnus-article-edit-mode nil)
1565
1566 ;;; Macros for dealing with the article buffer.
1567
1568 (defmacro gnus-with-article-headers (&rest forms)
1569   `(save-excursion
1570      (set-buffer gnus-article-buffer)
1571      (save-restriction
1572        (let ((inhibit-read-only t)
1573              (inhibit-point-motion-hooks t)
1574              (case-fold-search t))
1575          (article-narrow-to-head)
1576          ,@forms))))
1577
1578 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1579 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1580
1581 (defmacro gnus-with-article-buffer (&rest forms)
1582   `(save-excursion
1583      (set-buffer gnus-article-buffer)
1584      (let ((inhibit-read-only t))
1585        ,@forms)))
1586
1587 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1588 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1589
1590 (defun gnus-article-goto-header (header)
1591   "Go to HEADER, which is a regular expression."
1592   (re-search-forward (concat "^\\(" header "\\):") nil t))
1593
1594 (defsubst gnus-article-hide-text (b e props)
1595   "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1596   (gnus-add-text-properties-when 'article-type nil b e props)
1597   (when (memq 'intangible props)
1598     (put-text-property
1599      (max (1- b) (point-min))
1600      b 'intangible (cddr (memq 'intangible props)))))
1601
1602 (defsubst gnus-article-unhide-text (b e)
1603   "Remove hidden text properties from region between B and E."
1604   (remove-text-properties b e gnus-hidden-properties)
1605   (when (memq 'intangible gnus-hidden-properties)
1606     (put-text-property (max (1- b) (point-min))
1607                        b 'intangible nil)))
1608
1609 (defun gnus-article-hide-text-type (b e type)
1610   "Hide text of TYPE between B and E."
1611   (gnus-add-wash-type type)
1612   (gnus-article-hide-text
1613    b e (cons 'article-type (cons type gnus-hidden-properties))))
1614
1615 (defun gnus-article-unhide-text-type (b e type)
1616   "Unhide text of TYPE between B and E."
1617   (gnus-delete-wash-type type)
1618   (remove-text-properties
1619    b e (cons 'article-type (cons type gnus-hidden-properties)))
1620   (when (memq 'intangible gnus-hidden-properties)
1621     (put-text-property (max (1- b) (point-min))
1622                        b 'intangible nil)))
1623
1624 (defun gnus-article-hide-text-of-type (type)
1625   "Hide text of TYPE in the current buffer."
1626   (save-excursion
1627     (let ((b (point-min))
1628           (e (point-max)))
1629       (while (setq b (text-property-any b e 'article-type type))
1630         (add-text-properties b (incf b) gnus-hidden-properties)))))
1631
1632 (defun gnus-article-delete-text-of-type (type)
1633   "Delete text of TYPE in the current buffer."
1634   (save-excursion
1635     (let ((b (point-min)))
1636       (while (setq b (text-property-any b (point-max) 'article-type type))
1637         (delete-region
1638          b (or (text-property-not-all b (point-max) 'article-type type)
1639                (point-max)))))))
1640
1641 (defun gnus-article-delete-invisible-text ()
1642   "Delete all invisible text in the current buffer."
1643   (save-excursion
1644     (let ((b (point-min)))
1645       (while (setq b (text-property-any b (point-max) 'invisible t))
1646         (delete-region
1647          b (or (text-property-not-all b (point-max) 'invisible t)
1648                (point-max)))))))
1649
1650 (defun gnus-article-text-type-exists-p (type)
1651   "Say whether any text of type TYPE exists in the buffer."
1652   (text-property-any (point-min) (point-max) 'article-type type))
1653
1654 (defsubst gnus-article-header-rank ()
1655   "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1656   (let ((list gnus-sorted-header-list)
1657         (i 1))
1658     (while list
1659       (if (looking-at (car list))
1660           (setq list nil)
1661         (setq list (cdr list))
1662         (incf i)))
1663       i))
1664
1665 (defun article-hide-headers (&optional arg delete)
1666   "Hide unwanted headers and possibly sort them as well."
1667   (interactive)
1668   ;; This function might be inhibited.
1669   (unless gnus-inhibit-hiding
1670     (let ((inhibit-read-only nil)
1671           (case-fold-search t)
1672           (max (1+ (length gnus-sorted-header-list)))
1673           (inhibit-point-motion-hooks t)
1674           (cur (current-buffer))
1675           ignored visible beg)
1676       (save-excursion
1677         ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1678         ;; group parameters, so we should go to the summary buffer.
1679         (when (prog1
1680                   (condition-case nil
1681                       (progn (set-buffer gnus-summary-buffer) t)
1682                     (error nil))
1683                 (setq ignored (when (not gnus-visible-headers)
1684                                 (cond ((stringp gnus-ignored-headers)
1685                                        gnus-ignored-headers)
1686                                       ((listp gnus-ignored-headers)
1687                                        (mapconcat 'identity
1688                                                   gnus-ignored-headers
1689                                                   "\\|"))))
1690                       visible (cond ((stringp gnus-visible-headers)
1691                                      gnus-visible-headers)
1692                                     ((and gnus-visible-headers
1693                                           (listp gnus-visible-headers))
1694                                      (mapconcat 'identity
1695                                                 gnus-visible-headers
1696                                                 "\\|")))))
1697           (set-buffer cur))
1698         (save-restriction
1699           ;; First we narrow to just the headers.
1700           (article-narrow-to-head)
1701           ;; Hide any "From " lines at the beginning of (mail) articles.
1702           (while (looking-at "From ")
1703             (forward-line 1))
1704           (unless (bobp)
1705             (delete-region (point-min) (point)))
1706           ;; Then treat the rest of the header lines.
1707           ;; Then we use the two regular expressions
1708           ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1709           ;; select which header lines is to remain visible in the
1710           ;; article buffer.
1711           (while (re-search-forward "^[^ \t:]*:" nil t)
1712             (beginning-of-line)
1713             ;; Mark the rank of the header.
1714             (put-text-property
1715              (point) (1+ (point)) 'message-rank
1716              (if (or (and visible (looking-at visible))
1717                      (and ignored
1718                           (not (looking-at ignored))))
1719                  (gnus-article-header-rank)
1720                (+ 2 max)))
1721             (forward-line 1))
1722           (message-sort-headers-1)
1723           (when (setq beg (text-property-any
1724                            (point-min) (point-max) 'message-rank (+ 2 max)))
1725             ;; We delete the unwanted headers.
1726             (gnus-add-wash-type 'headers)
1727             (add-text-properties (point-min) (+ 5 (point-min))
1728                                  '(article-type headers dummy-invisible t))
1729             (delete-region beg (point-max))))))))
1730
1731 (defun article-hide-boring-headers (&optional arg)
1732   "Toggle hiding of headers that aren't very interesting.
1733 If given a negative prefix, always show; if given a positive prefix,
1734 always hide."
1735   (interactive (gnus-article-hidden-arg))
1736   (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1737              (not gnus-show-all-headers))
1738     (save-excursion
1739       (save-restriction
1740         (let ((inhibit-read-only t)
1741               (inhibit-point-motion-hooks t))
1742           (article-narrow-to-head)
1743           (dolist (elem gnus-boring-article-headers)
1744             (goto-char (point-min))
1745             (cond
1746              ;; Hide empty headers.
1747              ((eq elem 'empty)
1748               (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1749                 (forward-line -1)
1750                 (gnus-article-hide-text-type
1751                  (point-at-bol)
1752                  (progn
1753                    (end-of-line)
1754                    (if (re-search-forward "^[^ \t]" nil t)
1755                        (match-beginning 0)
1756                      (point-max)))
1757                  'boring-headers)))
1758              ;; Hide boring Newsgroups header.
1759              ((eq elem 'newsgroups)
1760               (when (gnus-string-equal
1761                      (gnus-fetch-field "newsgroups")
1762                      (gnus-group-real-name
1763                       (if (boundp 'gnus-newsgroup-name)
1764                           gnus-newsgroup-name
1765                         "")))
1766                 (gnus-article-hide-header "newsgroups")))
1767              ((eq elem 'to-address)
1768               (let ((to (message-fetch-field "to"))
1769                     (to-address
1770                      (gnus-parameter-to-address
1771                       (if (boundp 'gnus-newsgroup-name)
1772                           gnus-newsgroup-name ""))))
1773                 (when (and to to-address
1774                            (ignore-errors
1775                              (gnus-string-equal
1776                               ;; only one address in To
1777                               (nth 1 (mail-extract-address-components to))
1778                               to-address)))
1779                   (gnus-article-hide-header "to"))))
1780              ((eq elem 'to-list)
1781               (let ((to (message-fetch-field "to"))
1782                     (to-list
1783                      (gnus-parameter-to-list
1784                       (if (boundp 'gnus-newsgroup-name)
1785                           gnus-newsgroup-name ""))))
1786                 (when (and to to-list
1787                            (ignore-errors
1788                              (gnus-string-equal
1789                               ;; only one address in To
1790                               (nth 1 (mail-extract-address-components to))
1791                               to-list)))
1792                   (gnus-article-hide-header "to"))))
1793              ((eq elem 'cc-list)
1794               (let ((cc (message-fetch-field "cc"))
1795                     (to-list
1796                      (gnus-parameter-to-list
1797                       (if (boundp 'gnus-newsgroup-name)
1798                           gnus-newsgroup-name ""))))
1799                 (when (and cc to-list
1800                            (ignore-errors
1801                              (gnus-string-equal
1802                               ;; only one address in CC
1803                               (nth 1 (mail-extract-address-components cc))
1804                               to-list)))
1805                   (gnus-article-hide-header "cc"))))
1806              ((eq elem 'followup-to)
1807               (when (gnus-string-equal
1808                      (message-fetch-field "followup-to")
1809                      (message-fetch-field "newsgroups"))
1810                 (gnus-article-hide-header "followup-to")))
1811              ((eq elem 'reply-to)
1812               (if (gnus-group-find-parameter
1813                    gnus-newsgroup-name 'broken-reply-to)
1814                   (gnus-article-hide-header "reply-to")
1815                 (let ((from (message-fetch-field "from"))
1816                       (reply-to (message-fetch-field "reply-to")))
1817                   (when
1818                       (and
1819                        from reply-to
1820                        (ignore-errors
1821                          (equal
1822                           (sort (mapcar
1823                                  (lambda (x) (downcase (cadr x)))
1824                                  (mail-extract-address-components from t))
1825                                 'string<)
1826                           (sort (mapcar
1827                                  (lambda (x) (downcase (cadr x)))
1828                                  (mail-extract-address-components reply-to t))
1829                                 'string<))))
1830                     (gnus-article-hide-header "reply-to")))))
1831              ((eq elem 'date)
1832               (let ((date (message-fetch-field "date")))
1833                 (when (and date
1834                            (< (days-between (current-time-string) date)
1835                               4))
1836                   (gnus-article-hide-header "date"))))
1837              ((eq elem 'long-to)
1838               (let ((to (message-fetch-field "to"))
1839                     (cc (message-fetch-field "cc")))
1840                 (when (> (length to) 1024)
1841                   (gnus-article-hide-header "to"))
1842                 (when (> (length cc) 1024)
1843                   (gnus-article-hide-header "cc"))))
1844              ((eq elem 'many-to)
1845               (let ((to-count 0)
1846                     (cc-count 0))
1847                 (goto-char (point-min))
1848                 (while (re-search-forward "^to:" nil t)
1849                   (setq to-count (1+ to-count)))
1850                 (when (> to-count 1)
1851                   (while (> to-count 0)
1852                     (goto-char (point-min))
1853                     (save-restriction
1854                       (re-search-forward "^to:" nil nil to-count)
1855                       (forward-line -1)
1856                       (narrow-to-region (point) (point-max))
1857                       (gnus-article-hide-header "to"))
1858                     (setq to-count (1- to-count))))
1859                 (goto-char (point-min))
1860                 (while (re-search-forward "^cc:" nil t)
1861                   (setq cc-count (1+ cc-count)))
1862                 (when (> cc-count 1)
1863                   (while (> cc-count 0)
1864                     (goto-char (point-min))
1865                     (save-restriction
1866                       (re-search-forward "^cc:" nil nil cc-count)
1867                       (forward-line -1)
1868                       (narrow-to-region (point) (point-max))
1869                       (gnus-article-hide-header "cc"))
1870                     (setq cc-count (1- cc-count)))))))))))))
1871
1872 (defun gnus-article-hide-header (header)
1873   (save-excursion
1874     (goto-char (point-min))
1875     (when (re-search-forward (concat "^" header ":") nil t)
1876       (gnus-article-hide-text-type
1877        (point-at-bol)
1878        (progn
1879          (end-of-line)
1880          (if (re-search-forward "^[^ \t]" nil t)
1881              (match-beginning 0)
1882            (point-max)))
1883        'boring-headers))))
1884
1885 (defvar gnus-article-normalized-header-length 40
1886   "Length of normalized headers.")
1887
1888 (defun article-normalize-headers ()
1889   "Make all header lines 40 characters long."
1890   (interactive)
1891   (let ((inhibit-read-only t)
1892         column)
1893     (save-excursion
1894       (save-restriction
1895         (article-narrow-to-head)
1896         (while (not (eobp))
1897           (cond
1898            ((< (setq column (- (point-at-eol) (point)))
1899                gnus-article-normalized-header-length)
1900             (end-of-line)
1901             (insert (make-string
1902                      (- gnus-article-normalized-header-length column)
1903                      ? )))
1904            ((> column gnus-article-normalized-header-length)
1905             (gnus-put-text-property
1906              (progn
1907                (forward-char gnus-article-normalized-header-length)
1908                (point))
1909              (point-at-eol)
1910              'invisible t))
1911            (t
1912             ;; Do nothing.
1913             ))
1914           (forward-line 1))))))
1915
1916 (defun article-treat-dumbquotes ()
1917   "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
1918 Note that this function guesses whether a character is a sm*rtq**t* or
1919 not, so it should only be used interactively.
1920
1921 Sm*rtq**t*s are M****s***'s unilateral extension to the
1922 iso-8859-1 character map in an attempt to provide more quoting
1923 characters.  If you see something like \\222 or \\264 where
1924 you're expecting some kind of apostrophe or quotation mark, then
1925 try this wash."
1926   (interactive)
1927   (article-translate-strings gnus-article-dumbquotes-map))
1928
1929 (defun article-translate-characters (from to)
1930   "Translate all characters in the body of the article according to FROM and TO.
1931 FROM is a string of characters to translate from; to is a string of
1932 characters to translate to."
1933   (save-excursion
1934     (when (article-goto-body)
1935       (let ((inhibit-read-only t)
1936             (x (make-string 225 ?x))
1937             (i -1))
1938         (while (< (incf i) (length x))
1939           (aset x i i))
1940         (setq i 0)
1941         (while (< i (length from))
1942           (aset x (aref from i) (aref to i))
1943           (incf i))
1944         (translate-region (point) (point-max) x)))))
1945
1946 (defun article-translate-strings (map)
1947   "Translate all string in the body of the article according to MAP.
1948 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1949   (save-excursion
1950     (when (article-goto-body)
1951       (let ((inhibit-read-only t))
1952         (dolist (elem map)
1953           (save-excursion
1954             (while (search-forward (car elem) nil t)
1955               (replace-match (cadr elem)))))))))
1956
1957 (defun article-treat-overstrike ()
1958   "Translate overstrikes into bold text."
1959   (interactive)
1960   (save-excursion
1961     (when (article-goto-body)
1962       (let ((inhibit-read-only t))
1963         (while (search-forward "\b" nil t)
1964           (let ((next (char-after))
1965                 (previous (char-after (- (point) 2))))
1966             ;; We do the boldification/underlining by hiding the
1967             ;; overstrikes and putting the proper text property
1968             ;; on the letters.
1969             (cond
1970              ((eq next previous)
1971               (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1972               (put-text-property (point) (1+ (point)) 'face 'bold))
1973              ((eq next ?_)
1974               (gnus-article-hide-text-type
1975                (1- (point)) (1+ (point)) 'overstrike)
1976               (put-text-property
1977                (- (point) 2) (1- (point)) 'face 'underline))
1978              ((eq previous ?_)
1979               (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1980               (put-text-property
1981                (point) (1+ (point)) 'face 'underline)))))))))
1982
1983 (defun article-treat-ansi-sequences ()
1984   "Translate ANSI SGR control sequences into overlays or extents."
1985   (interactive)
1986   (save-excursion
1987     (when (article-goto-body)
1988       (let ((inhibit-read-only t))
1989         (ansi-color-apply-on-region (point) (point-max))))))
1990
1991 (defun gnus-article-treat-unfold-headers ()
1992   "Unfold folded message headers.
1993 Only the headers that fit into the current window width will be
1994 unfolded."
1995   (interactive)
1996   (gnus-with-article-headers
1997     (let (length)
1998       (while (not (eobp))
1999         (save-restriction
2000           (mail-header-narrow-to-field)
2001           (let ((header (buffer-string)))
2002             (with-temp-buffer
2003               (insert header)
2004               (goto-char (point-min))
2005               (while (re-search-forward "\n[\t ]" nil t)
2006                 (replace-match " " t t)))
2007             (setq length (- (point-max) (point-min) 1)))
2008           (when (< length (window-width))
2009             (while (re-search-forward "\n[\t ]" nil t)
2010               (replace-match " " t t)))
2011           (goto-char (point-max)))))))
2012
2013 (defun gnus-article-treat-fold-headers ()
2014   "Fold message headers."
2015   (interactive)
2016   (gnus-with-article-headers
2017     (while (not (eobp))
2018       (save-restriction
2019         (mail-header-narrow-to-field)
2020         (mail-header-fold-field)
2021         (goto-char (point-max))))))
2022
2023 (defun gnus-treat-smiley ()
2024   "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2025   (interactive)
2026   (gnus-with-article-buffer
2027     (if (memq 'smiley gnus-article-wash-types)
2028         (gnus-delete-images 'smiley)
2029       (article-goto-body)
2030       (let ((images (smiley-region (point) (point-max))))
2031         (when images
2032           (gnus-add-wash-type 'smiley)
2033           (dolist (image images)
2034             (gnus-add-image 'smiley image)))))))
2035
2036 (defun gnus-article-remove-images ()
2037   "Remove all images from the article buffer."
2038   (interactive)
2039   (gnus-with-article-buffer
2040     (dolist (elem gnus-article-image-alist)
2041       (gnus-delete-images (car elem)))))
2042
2043 (defun gnus-article-treat-fold-newsgroups ()
2044   "Unfold folded message headers.
2045 Only the headers that fit into the current window width will be
2046 unfolded."
2047   (interactive)
2048   (gnus-with-article-headers
2049     (while (gnus-article-goto-header "newsgroups\\|followup-to")
2050       (save-restriction
2051         (mail-header-narrow-to-field)
2052         (while (re-search-forward ", *" nil t)
2053           (replace-match ", " t t))
2054         (mail-header-fold-field)
2055         (goto-char (point-max))))))
2056
2057 (defun gnus-article-treat-body-boundary ()
2058   "Place a boundary line at the end of the headers."
2059   (interactive)
2060   (when (and gnus-body-boundary-delimiter
2061              (> (length gnus-body-boundary-delimiter) 0))
2062     (gnus-with-article-headers
2063       (goto-char (point-max))
2064       (let ((start (point)))
2065         (insert "X-Boundary: ")
2066         (gnus-add-text-properties start (point) '(invisible t intangible t))
2067         (insert (let (str)
2068                   (while (>= (1- (window-width)) (length str))
2069                     (setq str (concat str gnus-body-boundary-delimiter)))
2070                   (substring str 0 (1- (window-width))))
2071                 "\n")
2072         (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2073
2074 (defun article-fill-long-lines ()
2075   "Fill lines that are wider than the window width."
2076   (interactive)
2077   (save-excursion
2078     (let ((inhibit-read-only t)
2079           (width (window-width (get-buffer-window (current-buffer)))))
2080       (save-restriction
2081         (article-goto-body)
2082         (let ((adaptive-fill-mode nil)) ;Why?  -sm
2083           (while (not (eobp))
2084             (end-of-line)
2085             (when (>= (current-column) (min fill-column width))
2086               (narrow-to-region (min (1+ (point)) (point-max))
2087                                 (point-at-bol))
2088               (let ((goback (point-marker)))
2089                 (fill-paragraph nil)
2090                 (goto-char (marker-position goback)))
2091               (widen))
2092             (forward-line 1)))))))
2093
2094 (defun article-capitalize-sentences ()
2095   "Capitalize the first word in each sentence."
2096   (interactive)
2097   (save-excursion
2098     (let ((inhibit-read-only t)
2099           (paragraph-start "^[\n\^L]"))
2100       (article-goto-body)
2101       (while (not (eobp))
2102         (capitalize-word 1)
2103         (forward-sentence)))))
2104
2105 (defun article-remove-cr ()
2106   "Remove trailing CRs and then translate remaining CRs into LFs."
2107   (interactive)
2108   (save-excursion
2109     (let ((inhibit-read-only t))
2110       (goto-char (point-min))
2111       (while (re-search-forward "\r+$" nil t)
2112         (replace-match "" t t))
2113       (goto-char (point-min))
2114       (while (search-forward "\r" nil t)
2115         (replace-match "\n" t t)))))
2116
2117 (defun article-remove-trailing-blank-lines ()
2118   "Remove all trailing blank lines from the article."
2119   (interactive)
2120   (save-excursion
2121     (let ((inhibit-read-only t))
2122       (goto-char (point-max))
2123       (delete-region
2124        (point)
2125        (progn
2126          (while (and (not (bobp))
2127                      (looking-at "^[ \t]*$")
2128                      (not (gnus-annotation-in-region-p
2129                            (point) (point-at-eol))))
2130            (forward-line -1))
2131          (forward-line 1)
2132          (point))))))
2133
2134 (eval-when-compile
2135   (defvar gnus-face-properties-alist))
2136
2137 (defun article-display-face ()
2138   "Display any Face headers in the header."
2139   (interactive)
2140   (let ((wash-face-p buffer-read-only))
2141     (gnus-with-article-headers
2142       ;; When displaying parts, this function can be called several times on
2143       ;; the same article, without any intended toggle semantic (as typing `W
2144       ;; D d' would have). So face deletion must occur only when we come from
2145       ;; an interactive command, that is when the *Article* buffer is
2146       ;; read-only.
2147       (if (and wash-face-p (memq 'face gnus-article-wash-types))
2148           (gnus-delete-images 'face)
2149         (let (face faces)
2150           (save-excursion
2151             (when (and wash-face-p
2152                        (progn
2153                          (goto-char (point-min))
2154                          (not (re-search-forward "^Face:[\t ]*" nil t)))
2155                        (gnus-buffer-live-p gnus-original-article-buffer))
2156               (set-buffer gnus-original-article-buffer))
2157             (save-restriction
2158               (mail-narrow-to-head)
2159               (while (gnus-article-goto-header "Face")
2160                 (setq faces (nconc faces (list (mail-header-field-value)))))))
2161           (dolist (face faces)
2162             (let ((png (gnus-convert-face-to-png face))
2163                   image)
2164               (when png
2165                 (setq image
2166                       (apply 'gnus-create-image png 'png t
2167                              (cdr (assq 'png gnus-face-properties-alist))))
2168                 (gnus-article-goto-header "from")
2169                 (when (bobp)
2170                   (insert "From: [no `from' set]\n")
2171                   (forward-char -17))
2172                 (gnus-add-wash-type 'face)
2173                 (gnus-add-image 'face image)
2174                 (gnus-put-image image nil 'face))))))
2175       )))
2176
2177 (defun article-display-x-face (&optional force)
2178   "Look for an X-Face header and display it if present."
2179   (interactive (list 'force))
2180   (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2181     (gnus-with-article-headers
2182       ;; Delete the old process, if any.
2183       (when (process-status "article-x-face")
2184         (delete-process "article-x-face"))
2185       ;; See the comment in `article-display-face'.
2186       (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2187           ;; We have already displayed X-Faces, so we remove them
2188           ;; instead.
2189           (gnus-delete-images 'xface)
2190         ;; Display X-Faces.
2191         (let (x-faces from face)</