1 ;;; gnus-art.el --- article mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
31 (defvar tool-bar-map))
46 (autoload 'gnus-msg-mail "gnus-msg" nil t)
47 (autoload 'gnus-button-mailto "gnus-msg")
48 (autoload 'gnus-button-reply "gnus-msg" nil t)
49 (autoload 'ansi-color-apply-on-region "ansi-color")
51 (defgroup gnus-article nil
53 :link '(custom-manual "(gnus)Article Buffer")
56 (defgroup gnus-article-treat nil
57 "Treating article parts."
58 :link '(custom-manual "(gnus)Article Hiding")
61 (defgroup gnus-article-hiding nil
62 "Hiding article parts."
63 :link '(custom-manual "(gnus)Article Hiding")
66 (defgroup gnus-article-highlight nil
67 "Article highlighting."
68 :link '(custom-manual "(gnus)Article Highlighting")
72 (defgroup gnus-article-signature nil
74 :link '(custom-manual "(gnus)Article Signature")
77 (defgroup gnus-article-headers nil
79 :link '(custom-manual "(gnus)Hiding Headers")
82 (defgroup gnus-article-washing nil
83 "Special commands on articles."
84 :link '(custom-manual "(gnus)Article Washing")
87 (defgroup gnus-article-emphasis nil
88 "Fontisizing articles."
89 :link '(custom-manual "(gnus)Article Fontisizing")
92 (defgroup gnus-article-saving nil
94 :link '(custom-manual "(gnus)Saving Articles")
97 (defgroup gnus-article-mime nil
98 "Worshiping the MIME wonder."
99 :link '(custom-manual "(gnus)Using MIME")
100 :group 'gnus-article)
102 (defgroup gnus-article-buttons nil
103 "Pushable buttons in the article buffer."
104 :link '(custom-manual "(gnus)Article Buttons")
105 :group 'gnus-article)
107 (defgroup gnus-article-various nil
108 "Other article options."
109 :link '(custom-manual "(gnus)Misc Article")
110 :group 'gnus-article)
112 (defcustom gnus-ignored-headers
115 (concat "^" header ":"))
116 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
117 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
118 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
119 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
120 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
121 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
122 "X-Attribution" "X-Originating-IP" "Delivered-To"
123 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
124 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
125 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
126 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
127 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
128 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
129 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
130 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
131 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
132 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
133 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
134 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
135 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
136 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
137 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
138 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
139 "List-[A-Za-z]+" "X-Listprocessor-Version"
140 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
141 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
142 "X-Received" "Content-length" "X-precedence"
143 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
144 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
145 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
146 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
147 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
148 "X-Content-length" "X-Posting-Agent" "Original-Received"
149 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
150 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
151 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
152 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
153 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"))
154 "*All headers that start with this regexp will be hidden.
155 This variable can also be a list of regexps of headers to be ignored.
156 If `gnus-visible-headers' is non-nil, this variable will be ignored."
157 :type '(choice :custom-show nil
160 :group 'gnus-article-hiding)
162 (defcustom gnus-visible-headers
163 "^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:"
164 "*All headers that do not match this regexp will be hidden.
165 This variable can also be a list of regexp of headers to remain visible.
166 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
167 :type '(repeat :value-to-internal (lambda (widget value)
168 (custom-split-regexp-maybe value))
169 :match (lambda (widget value)
171 (widget-editable-list-match widget value)))
173 :group 'gnus-article-hiding)
175 (defcustom gnus-sorted-header-list
176 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
177 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
178 "*This variable is a list of regular expressions.
179 If it is non-nil, headers that match the regular expressions will
180 be placed first in the article buffer in the sequence specified by
182 :type '(repeat regexp)
183 :group 'gnus-article-hiding)
185 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
186 "Headers that are only to be displayed if they have interesting data.
187 Possible values in this list are:
189 'empty Headers with no content.
190 'newsgroups Newsgroup identical to Gnus group.
191 'to-address To identical to To-address.
192 'to-list To identical to To-list.
193 'cc-list CC identical to To-list.
194 'followup-to Followup-to identical to Newsgroups.
195 'reply-to Reply-to identical to From.
196 'date Date less than four days old.
197 'long-to To and/or Cc longer than 1024 characters.
198 'many-to Multiple To and/or Cc."
199 :type '(set (const :tag "Headers with no content." empty)
200 (const :tag "Newsgroups identical to Gnus group." newsgroups)
201 (const :tag "To identical to To-address." to-address)
202 (const :tag "To identical to To-list." to-list)
203 (const :tag "CC identical to To-list." cc-list)
204 (const :tag "Followup-to identical to Newsgroups." followup-to)
205 (const :tag "Reply-to identical to From." reply-to)
206 (const :tag "Date less than four days old." date)
207 (const :tag "To and/or Cc longer than 1024 characters." long-to)
208 (const :tag "Multiple To and/or Cc headers." many-to))
209 :group 'gnus-article-hiding)
211 (defcustom gnus-article-skip-boring nil
212 "Skip over text that is not worth reading.
213 By default, if you set this t, then Gnus will display citations and
214 signatures, but will never scroll down to show you a page consisting
215 only of boring text. Boring text is controlled by
216 `gnus-article-boring-faces'."
218 :group 'gnus-article-hiding)
220 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
221 "Regexp matching signature separator.
222 This can also be a list of regexps. In that case, it will be checked
223 from head to tail looking for a separator. Searches will be done from
224 the end of the buffer."
225 :type '(repeat string)
226 :group 'gnus-article-signature)
228 (defcustom gnus-signature-limit nil
229 "Provide a limit to what is considered a signature.
230 If it is a number, no signature may not be longer (in characters) than
231 that number. If it is a floating point number, no signature may be
232 longer (in lines) than that number. If it is a function, the function
233 will be called without any parameters, and if it returns nil, there is
234 no signature in the buffer. If it is a string, it will be used as a
235 regexp. If it matches, the text in question is not a signature."
236 :type '(choice (integer :value 200)
238 (function :value fun)
239 (regexp :value ".*"))
240 :group 'gnus-article-signature)
242 (defcustom gnus-hidden-properties '(invisible t intangible t)
243 "Property list to use for hiding text."
245 :group 'gnus-article-hiding)
247 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
248 ;; frames in a session.
249 (defcustom gnus-article-x-face-command
250 (if (featurep 'xemacs)
251 (if (or (gnus-image-type-available-p 'xface)
252 (gnus-image-type-available-p 'pbm))
253 'gnus-display-x-face-in-from
254 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
255 (if (gnus-image-type-available-p 'pbm)
256 'gnus-display-x-face-in-from
257 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
259 "*String or function to be executed to display an X-Face header.
260 If it is a string, the command will be executed in a sub-shell
261 asynchronously. The compressed face will be piped to this command."
262 :type `(choice string
263 (function-item gnus-display-x-face-in-from)
267 :group 'gnus-article-washing)
269 (defcustom gnus-article-x-face-too-ugly nil
270 "Regexp matching posters whose face shouldn't be shown automatically."
271 :type '(choice regexp (const nil))
272 :group 'gnus-article-washing)
274 (defcustom gnus-article-banner-alist nil
275 "Banner alist for stripping.
277 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
279 :type '(repeat (cons symbol regexp))
280 :group 'gnus-article-washing)
282 (gnus-define-group-parameter
285 "Alist of regexps (to match group names) and banner."
286 :variable-group gnus-article-washing
288 '(choice :tag "Banner"
290 (const :tag "Remove signature" signature)
291 (symbol :tag "Item in `gnus-article-banner-alist'" none)
293 (const :tag "None" nil))
295 "If non-nil, specify how to remove `banners' from articles.
297 Symbol `signature' means to remove signatures delimited by
298 `gnus-signature-separator'. Any other symbol is used to look up a
299 regular expression to match the banner in `gnus-article-banner-alist'.
300 A string is used as a regular expression to match the banner
303 (defcustom gnus-article-address-banner-alist nil
304 "Alist of mail addresses and banners.
305 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
306 to match a mail address in the From: header, BANNER is one of a symbol
307 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
308 If ADDRESS matches author's mail address, it will remove things like
309 advertisements. For example:
311 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
315 (regexp :tag "Address")
316 (choice :tag "Banner" :value nil
317 (const :tag "Remove signature" signature)
318 (symbol :tag "Item in `gnus-article-banner-alist'" none)
320 (const :tag "None" nil))))
321 :group 'gnus-article-washing)
323 (defcustom gnus-emphasis-alist
325 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
330 ("_/" "/_" underline-italic)
331 ("_\\*" "\\*_" underline-bold)
332 ("\\*/" "/\\*" bold-italic)
333 ("_\\*/" "/\\*_" underline-bold-italic))))
337 (format format (car spec) (cadr spec))
338 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
340 ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
341 2 3 gnus-emphasis-strikethru)
342 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
343 2 3 gnus-emphasis-underline)))
344 "*Alist that says how to fontify certain phrases.
345 Each item looks like this:
347 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
349 The first element is a regular expression to be matched. The second
350 is a number that says what regular expression grouping used to find
351 the entire emphasized word. The third is a number that says what
352 regexp grouping should be displayed and highlighted. The fourth
353 is the face used for highlighting."
354 :type '(repeat (list :value ("" 0 0 default)
356 (integer :tag "Match group")
357 (integer :tag "Emphasize group")
359 :group 'gnus-article-emphasis)
361 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
362 "A regexp to describe whitespace which should not be emphasized.
363 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
364 The former avoids underlining of leading and trailing whitespace,
365 and the latter avoids underlining any whitespace at all."
367 :group 'gnus-article-emphasis
370 (defface gnus-emphasis-bold '((t (:bold t)))
371 "Face used for displaying strong emphasized text (*word*)."
372 :group 'gnus-article-emphasis)
374 (defface gnus-emphasis-italic '((t (:italic t)))
375 "Face used for displaying italic emphasized text (/word/)."
376 :group 'gnus-article-emphasis)
378 (defface gnus-emphasis-underline '((t (:underline t)))
379 "Face used for displaying underlined emphasized text (_word_)."
380 :group 'gnus-article-emphasis)
382 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
383 "Face used for displaying underlined bold emphasized text (_*word*_)."
384 :group 'gnus-article-emphasis)
386 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
387 "Face used for displaying underlined italic emphasized text (_/word/_)."
388 :group 'gnus-article-emphasis)
390 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
391 "Face used for displaying bold italic emphasized text (/*word*/)."
392 :group 'gnus-article-emphasis)
394 (defface gnus-emphasis-underline-bold-italic
395 '((t (:bold t :italic t :underline t)))
396 "Face used for displaying underlined bold italic emphasized text.
397 Example: (_/*word*/_)."
398 :group 'gnus-article-emphasis)
400 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
401 '((t (:strikethru t)))
402 '((t (:strike-through t))))
403 "Face used for displaying strike-through text (-word-)."
404 :group 'gnus-article-emphasis)
406 (defface gnus-emphasis-highlight-words
407 '((t (:background "black" :foreground "yellow")))
408 "Face used for displaying highlighted words."
409 :group 'gnus-article-emphasis)
411 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
412 "Format for display of Date headers in article bodies.
413 See `format-time-string' for the possible values.
415 The variable can also be function, which should return a complete Date
416 header. The function is called with one argument, the time, which can
417 be fed to `format-time-string'."
418 :type '(choice string symbol)
419 :link '(custom-manual "(gnus)Article Date")
420 :group 'gnus-article-washing)
423 (autoload 'mail-extract-address-components "mail-extr"))
425 (defcustom gnus-save-all-headers t
426 "*If non-nil, don't remove any headers before saving."
427 :group 'gnus-article-saving
430 (defcustom gnus-prompt-before-saving 'always
431 "*This variable says how much prompting is to be done when saving articles.
432 If it is nil, no prompting will be done, and the articles will be
433 saved to the default files. If this variable is `always', each and
434 every article that is saved will be preceded by a prompt, even when
435 saving large batches of articles. If this variable is neither nil not
436 `always', there the user will be prompted once for a file name for
437 each invocation of the saving commands."
438 :group 'gnus-article-saving
439 :type '(choice (item always)
440 (item :tag "never" nil)
441 (sexp :tag "once" :format "%t\n" :value t)))
443 (defcustom gnus-saved-headers gnus-visible-headers
444 "Headers to keep if `gnus-save-all-headers' is nil.
445 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
446 If that variable is nil, however, all headers that match this regexp
447 will be kept while the rest will be deleted before saving."
448 :group 'gnus-article-saving
451 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
452 "A function to save articles in your favourite format.
453 The function must be interactively callable (in other words, it must
454 be an Emacs command).
456 Gnus provides the following functions:
458 * gnus-summary-save-in-rmail (Rmail format)
459 * gnus-summary-save-in-mail (Unix mail format)
460 * gnus-summary-save-in-folder (MH folder)
461 * gnus-summary-save-in-file (article format)
462 * gnus-summary-save-body-in-file (article body)
463 * gnus-summary-save-in-vm (use VM's folder format)
464 * gnus-summary-write-to-file (article format -- overwrite)."
465 :group 'gnus-article-saving
466 :type '(radio (function-item gnus-summary-save-in-rmail)
467 (function-item gnus-summary-save-in-mail)
468 (function-item gnus-summary-save-in-folder)
469 (function-item gnus-summary-save-in-file)
470 (function-item gnus-summary-save-body-in-file)
471 (function-item gnus-summary-save-in-vm)
472 (function-item gnus-summary-write-to-file)))
474 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
475 "A function generating a file name to save articles in Rmail format.
476 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
477 :group 'gnus-article-saving
480 (defcustom gnus-mail-save-name 'gnus-plain-save-name
481 "A function generating a file name to save articles in Unix mail format.
482 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
483 :group 'gnus-article-saving
486 (defcustom gnus-folder-save-name 'gnus-folder-save-name
487 "A function generating a file name to save articles in MH folder.
488 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
489 :group 'gnus-article-saving
492 (defcustom gnus-file-save-name 'gnus-numeric-save-name
493 "A function generating a file name to save articles in article format.
494 The function is called with NEWSGROUP, HEADERS, and optional
496 :group 'gnus-article-saving
499 (defcustom gnus-split-methods
500 '((gnus-article-archive-name)
501 (gnus-article-nndoc-name))
502 "*Variable used to suggest where articles are to be saved.
503 For instance, if you would like to save articles related to Gnus in
504 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
505 you could set this variable to something like:
507 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
508 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
510 This variable is an alist where the where the key is the match and the
511 value is a list of possible files to save in if the match is non-nil.
513 If the match is a string, it is used as a regexp match on the
514 article. If the match is a symbol, that symbol will be funcalled
515 from the buffer of the article to be saved with the newsgroup as the
516 parameter. If it is a list, it will be evaled in the same buffer.
518 If this form or function returns a string, this string will be used as
519 a possible file name; and if it returns a non-nil list, that list will
520 be used as possible file names."
521 :group 'gnus-article-saving
522 :type '(repeat (choice (list :value (fun) function)
523 (cons :value ("" "") regexp (repeat string))
526 (defcustom gnus-page-delimiter "^\^L"
527 "*Regexp describing what to use as article page delimiters.
528 The default value is \"^\^L\", which is a form linefeed at the
529 beginning of a line."
531 :group 'gnus-article-various)
533 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
534 "*The format specification for the article mode line.
535 See `gnus-summary-mode-line-format' for a closer description.
537 The following additional specs are available:
539 %w The article washing status.
540 %m The number of MIME parts in the article."
542 :group 'gnus-article-various)
544 (defcustom gnus-article-mode-hook nil
545 "*A hook for Gnus article mode."
547 :group 'gnus-article-various)
549 (when (featurep 'xemacs)
550 ;; Extracted from gnus-xmas-define in order to preserve user settings
551 (when (fboundp 'turn-off-scroll-in-place)
552 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
553 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
554 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
556 (defcustom gnus-article-menu-hook nil
557 "*Hook run after the creation of the article mode menu."
559 :group 'gnus-article-various)
561 (defcustom gnus-article-prepare-hook nil
562 "*A hook called after an article has been prepared in the article buffer."
564 :group 'gnus-article-various)
566 (make-obsolete-variable 'gnus-article-hide-pgp-hook
567 "This variable is obsolete in Gnus 5.10.")
569 (defcustom gnus-article-button-face 'bold
570 "Face used for highlighting buttons in the article buffer.
572 An article button is a piece of text that you can activate by pressing
573 `RET' or `mouse-2' above it."
575 :group 'gnus-article-buttons)
577 (defcustom gnus-article-mouse-face 'highlight
578 "Face used for mouse highlighting in the article buffer.
580 Article buttons will be displayed in this face when the cursor is
583 :group 'gnus-article-buttons)
585 (defcustom gnus-signature-face 'gnus-signature-face
586 "Face used for highlighting a signature in the article buffer.
587 Obsolete; use the face `gnus-signature-face' for customizations instead."
589 :group 'gnus-article-highlight
590 :group 'gnus-article-signature)
592 (defface gnus-signature-face
595 "Face used for highlighting a signature in the article buffer."
596 :group 'gnus-article-highlight
597 :group 'gnus-article-signature)
599 (defface gnus-header-from-face
602 (:foreground "spring green"))
605 (:foreground "red3"))
608 "Face used for displaying from headers."
609 :group 'gnus-article-headers
610 :group 'gnus-article-highlight)
612 (defface gnus-header-subject-face
615 (:foreground "SeaGreen3"))
618 (:foreground "red4"))
620 (:bold t :italic t)))
621 "Face used for displaying subject headers."
622 :group 'gnus-article-headers
623 :group 'gnus-article-highlight)
625 (defface gnus-header-newsgroups-face
628 (:foreground "yellow" :italic t))
631 (:foreground "MidnightBlue" :italic t))
634 "Face used for displaying newsgroups headers.
635 In the default setup this face is only used for crossposted
637 :group 'gnus-article-headers
638 :group 'gnus-article-highlight)
640 (defface gnus-header-name-face
643 (:foreground "SeaGreen"))
646 (:foreground "maroon"))
649 "Face used for displaying header names."
650 :group 'gnus-article-headers
651 :group 'gnus-article-highlight)
653 (defface gnus-header-content-face
656 (:foreground "forest green" :italic t))
659 (:foreground "indianred4" :italic t))
661 (:italic t))) "Face used for displaying header content."
662 :group 'gnus-article-headers
663 :group 'gnus-article-highlight)
665 (defcustom gnus-header-face-alist
666 '(("From" nil gnus-header-from-face)
667 ("Subject" nil gnus-header-subject-face)
668 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
669 ("" gnus-header-name-face gnus-header-content-face))
670 "*Controls highlighting of article headers.
672 An alist of the form (HEADER NAME CONTENT).
674 HEADER is a regular expression which should match the name of a
675 header and NAME and CONTENT are either face names or nil.
677 The name of each header field will be displayed using the face
678 specified by the first element in the list where HEADER matches
679 the header name and NAME is non-nil. Similarly, the content will
680 be displayed by the first non-nil matching CONTENT face."
681 :group 'gnus-article-headers
682 :group 'gnus-article-highlight
683 :type '(repeat (list (regexp :tag "Header")
685 (item :tag "skip" nil)
686 (face :value default))
687 (choice :tag "Content"
688 (item :tag "skip" nil)
689 (face :value default)))))
691 (defcustom gnus-article-decode-hook
692 '(article-decode-charset article-decode-encoded-words
693 article-decode-group-name article-decode-idna-rhs)
694 "*Hook run to decode charsets in articles."
695 :group 'gnus-article-headers
698 (defcustom gnus-display-mime-function 'gnus-display-mime
699 "Function to display MIME articles."
700 :group 'gnus-article-mime
703 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
704 "Function used to decode headers.")
706 (defvar gnus-article-dumbquotes-map
726 "Table for MS-to-Latin1 translation.")
728 (defcustom gnus-ignored-mime-types nil
729 "List of MIME types that should be ignored by Gnus."
731 :group 'gnus-article-mime
732 :type '(repeat regexp))
734 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
735 "List of MIME types that should not be given buttons when rendered inline.
736 See also `gnus-buttonized-mime-types' which may override this variable.
737 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
739 :group 'gnus-article-mime
740 :type '(repeat regexp))
742 (defcustom gnus-buttonized-mime-types nil
743 "List of MIME types that should be given buttons when rendered inline.
744 If set, this variable overrides `gnus-unbuttonized-mime-types'.
745 To see e.g. security buttons you could set this to
746 `(\"multipart/signed\")'.
747 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
749 :group 'gnus-article-mime
750 :type '(repeat regexp))
752 (defcustom gnus-inhibit-mime-unbuttonizing nil
753 "If non-nil, all MIME parts get buttons.
754 When nil (the default value), then some MIME parts do not get buttons,
755 as described by the variables `gnus-buttonized-mime-types' and
756 `gnus-unbuttonized-mime-types'."
760 (defcustom gnus-body-boundary-delimiter "_"
761 "String used to delimit header and body.
762 This variable is used by `gnus-article-treat-body-boundary' which can
763 be controlled by `gnus-treat-body-boundary'."
764 :group 'gnus-article-various
765 :type '(choice (item :tag "None" :value nil)
768 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
769 "Defines the location of the faces database.
770 For information on obtaining this database of pretty pictures, please
771 see http://www.cs.indiana.edu/picons/ftp/index.html"
772 :type '(repeat directory)
773 :link '(url-link :tag "download"
774 "http://www.cs.indiana.edu/picons/ftp/index.html")
775 :link '(custom-manual "(gnus)Picons")
778 (defun gnus-picons-installed-p ()
779 "Say whether picons are installed on your machine."
780 (let ((installed nil))
781 (dolist (database gnus-picon-databases)
782 (when (file-exists-p database)
786 (defcustom gnus-article-mime-part-function nil
787 "Function called with a MIME handle as the argument.
788 This is meant for people who want to do something automatic based
789 on parts -- for instance, adding Vcard info to a database."
790 :group 'gnus-article-mime
793 (defcustom gnus-mime-multipart-functions nil
794 "An alist of MIME types to functions to display them."
796 :group 'gnus-article-mime
799 (defcustom gnus-article-date-lapsed-new-header nil
800 "Whether the X-Sent and Date headers can coexist.
801 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
802 either replace the old \"Date:\" header (if this variable is nil), or
803 be added below it (otherwise)."
805 :group 'gnus-article-headers
808 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
809 "Function called with a MIME handle as the argument.
810 This is meant for people who want to view first matched part.
811 For `undisplayed-alternative' (default), the first undisplayed
812 part or alternative part is used. For `undisplayed', the first
813 undisplayed part is used. For a function, the first part which
814 the function return t is used. For nil, the first part is
817 :group 'gnus-article-mime
819 (item :tag "first" :value nil)
820 (item :tag "undisplayed" :value undisplayed)
821 (item :tag "undisplayed or alternative"
822 :value undisplayed-alternative)
825 (defcustom gnus-mime-action-alist
826 '(("save to file" . gnus-mime-save-part)
827 ("save and strip" . gnus-mime-save-part-and-strip)
828 ("delete part" . gnus-mime-delete-part)
829 ("display as text" . gnus-mime-inline-part)
830 ("view the part" . gnus-mime-view-part)
831 ("pipe to command" . gnus-mime-pipe-part)
832 ("toggle display" . gnus-article-press-button)
833 ("toggle display" . gnus-article-view-part-as-charset)
834 ("view as type" . gnus-mime-view-part-as-type)
835 ("view internally" . gnus-mime-view-part-internally)
836 ("view externally" . gnus-mime-view-part-externally))
837 "An alist of actions that run on the MIME attachment."
838 :group 'gnus-article-mime
839 :type '(repeat (cons (string :tag "name")
843 ;;; The treatment variables
846 (defvar gnus-part-display-hook nil
847 "Hook called on parts that are to receive treatment.")
849 (defvar gnus-article-treat-custom
850 '(choice (const :tag "Off" nil)
852 (const :tag "Header" head)
853 (const :tag "Last" last)
854 (integer :tag "Less")
855 (repeat :tag "Groups" regexp)
856 (sexp :tag "Predicate")))
858 (defvar gnus-article-treat-head-custom
859 '(choice (const :tag "Off" nil)
860 (const :tag "Header" head)))
862 (defvar gnus-article-treat-types '("text/plain")
865 (defvar gnus-inhibit-treatment nil
866 "Whether to inhibit treatment.")
868 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
869 "Highlight the signature.
870 Valid values are nil, t, `head', `last', an integer or a predicate.
871 See Info node `(gnus)Customizing Articles'."
872 :group 'gnus-article-treat
873 :link '(custom-manual "(gnus)Customizing Articles")
874 :type gnus-article-treat-custom)
875 (put 'gnus-treat-highlight-signature 'highlight t)
877 (defcustom gnus-treat-buttonize 100000
879 Valid values are nil, t, `head', `last', an integer or a predicate.
880 See Info node `(gnus)Customizing Articles'."
881 :group 'gnus-article-treat
882 :link '(custom-manual "(gnus)Customizing Articles")
883 :type gnus-article-treat-custom)
884 (put 'gnus-treat-buttonize 'highlight t)
886 (defcustom gnus-treat-buttonize-head 'head
887 "Add buttons to the head.
888 Valid values are nil, t, `head', `last', an integer or a predicate.
889 See Info node `(gnus)Customizing Articles' for details."
890 :group 'gnus-article-treat
891 :link '(custom-manual "(gnus)Customizing Articles")
892 :type gnus-article-treat-head-custom)
893 (put 'gnus-treat-buttonize-head 'highlight t)
895 (defcustom gnus-treat-emphasize
896 (and (or window-system
900 Valid values are nil, t, `head', `last', an integer or a predicate.
901 See Info node `(gnus)Customizing Articles' for details."
902 :group 'gnus-article-treat
903 :link '(custom-manual "(gnus)Customizing Articles")
904 :type gnus-article-treat-custom)
905 (put 'gnus-treat-emphasize 'highlight t)
907 (defcustom gnus-treat-strip-cr nil
908 "Remove carriage returns.
909 Valid values are nil, t, `head', `last', an integer or a predicate.
910 See Info node `(gnus)Customizing Articles' for details."
911 :group 'gnus-article-treat
912 :link '(custom-manual "(gnus)Customizing Articles")
913 :type gnus-article-treat-custom)
915 (defcustom gnus-treat-unsplit-urls nil
916 "Remove newlines from within URLs.
917 Valid values are nil, t, `head', `last', an integer or a predicate.
918 See Info node `(gnus)Customizing Articles' for details."
919 :group 'gnus-article-treat
920 :link '(custom-manual "(gnus)Customizing Articles")
921 :type gnus-article-treat-custom)
923 (defcustom gnus-treat-leading-whitespace nil
924 "Remove leading whitespace in headers.
925 Valid values are nil, t, `head', `last', an integer or a predicate.
926 See Info node `(gnus)Customizing Articles' for details."
927 :group 'gnus-article-treat
928 :link '(custom-manual "(gnus)Customizing Articles")
929 :type gnus-article-treat-custom)
931 (defcustom gnus-treat-hide-headers 'head
933 Valid values are nil, t, `head', `last', an integer or a predicate.
934 See Info node `(gnus)Customizing Articles' for details."
935 :group 'gnus-article-treat
936 :link '(custom-manual "(gnus)Customizing Articles")
937 :type gnus-article-treat-head-custom)
939 (defcustom gnus-treat-hide-boring-headers nil
940 "Hide boring headers.
941 Valid values are nil, t, `head', `last', an integer or a predicate.
942 See Info node `(gnus)Customizing Articles' for details."
943 :group 'gnus-article-treat
944 :link '(custom-manual "(gnus)Customizing Articles")
945 :type gnus-article-treat-head-custom)
947 (defcustom gnus-treat-hide-signature nil
949 Valid values are nil, t, `head', `last', an integer or a predicate.
950 See Info node `(gnus)Customizing Articles' for details."
951 :group 'gnus-article-treat
952 :link '(custom-manual "(gnus)Customizing Articles")
953 :type gnus-article-treat-custom)
955 (defcustom gnus-treat-fill-article nil
957 Valid values are nil, t, `head', `last', an integer or a predicate.
958 See Info node `(gnus)Customizing Articles' for details."
959 :group 'gnus-article-treat
960 :link '(custom-manual "(gnus)Customizing Articles")
961 :type gnus-article-treat-custom)
963 (defcustom gnus-treat-hide-citation nil
965 Valid values are nil, t, `head', `last', an integer or a predicate.
966 See Info node `(gnus)Customizing Articles' for details."
967 :group 'gnus-article-treat
968 :link '(custom-manual "(gnus)Customizing Articles")
969 :type gnus-article-treat-custom)
971 (defcustom gnus-treat-hide-citation-maybe nil
973 Valid values are nil, t, `head', `last', an integer or a predicate.
974 See Info node `(gnus)Customizing Articles' for details."
975 :group 'gnus-article-treat
976 :link '(custom-manual "(gnus)Customizing Articles")
977 :type gnus-article-treat-custom)
979 (defcustom gnus-treat-strip-list-identifiers 'head
980 "Strip list identifiers from `gnus-list-identifiers`.
981 Valid values are nil, t, `head', `last', an integer or a predicate.
982 See Info node `(gnus)Customizing Articles' for details."
984 :group 'gnus-article-treat
985 :link '(custom-manual "(gnus)Customizing Articles")
986 :type gnus-article-treat-custom)
988 (make-obsolete-variable 'gnus-treat-strip-pgp
989 "This option is obsolete in Gnus 5.10.")
991 (defcustom gnus-treat-strip-pem nil
992 "Strip PEM signatures.
993 Valid values are nil, t, `head', `last', an integer or a predicate.
994 See Info node `(gnus)Customizing Articles' for details."
995 :group 'gnus-article-treat
996 :link '(custom-manual "(gnus)Customizing Articles")
997 :type gnus-article-treat-custom)
999 (defcustom gnus-treat-strip-banner t
1000 "Strip banners from articles.
1001 The banner to be stripped is specified in the `banner' group parameter.
1002 Valid values are nil, t, `head', `last', an integer or a predicate.
1003 See Info node `(gnus)Customizing Articles' for details."
1004 :group 'gnus-article-treat
1005 :link '(custom-manual "(gnus)Customizing Articles")
1006 :type gnus-article-treat-custom)
1008 (defcustom gnus-treat-highlight-headers 'head
1009 "Highlight the headers.
1010 Valid values are nil, t, `head', `last', an integer or a predicate.
1011 See Info node `(gnus)Customizing Articles' for details."
1012 :group 'gnus-article-treat
1013 :link '(custom-manual "(gnus)Customizing Articles")
1014 :type gnus-article-treat-head-custom)
1015 (put 'gnus-treat-highlight-headers 'highlight t)
1017 (defcustom gnus-treat-highlight-citation t
1018 "Highlight cited text.
1019 Valid values are nil, t, `head', `last', an integer or a predicate.
1020 See Info node `(gnus)Customizing Articles' for details."
1021 :group 'gnus-article-treat
1022 :link '(custom-manual "(gnus)Customizing Articles")
1023 :type gnus-article-treat-custom)
1024 (put 'gnus-treat-highlight-citation 'highlight t)
1026 (defcustom gnus-treat-date-ut nil
1027 "Display the Date in UT (GMT).
1028 Valid values are nil, t, `head', `last', an integer or a predicate.
1029 See Info node `(gnus)Customizing Articles' for details."
1030 :group 'gnus-article-treat
1031 :link '(custom-manual "(gnus)Customizing Articles")
1032 :type gnus-article-treat-head-custom)
1034 (defcustom gnus-treat-date-local nil
1035 "Display the Date in the local timezone.
1036 Valid values are nil, t, `head', `last', an integer or a predicate.
1037 See Info node `(gnus)Customizing Articles' for details."
1038 :group 'gnus-article-treat
1039 :link '(custom-manual "(gnus)Customizing Articles")
1040 :type gnus-article-treat-head-custom)
1042 (defcustom gnus-treat-date-english nil
1043 "Display the Date in a format that can be read aloud in English.
1044 Valid values are nil, t, `head', `last', an integer or a predicate.
1045 See Info node `(gnus)Customizing Articles' for details."
1046 :group 'gnus-article-treat
1047 :link '(custom-manual "(gnus)Customizing Articles")
1048 :type gnus-article-treat-head-custom)
1050 (defcustom gnus-treat-date-lapsed nil
1051 "Display the Date header in a way that says how much time has elapsed.
1052 Valid values are nil, t, `head', `last', an integer or a predicate.
1053 See Info node `(gnus)Customizing Articles' for details."
1054 :group 'gnus-article-treat
1055 :link '(custom-manual "(gnus)Customizing Articles")
1056 :type gnus-article-treat-head-custom)
1058 (defcustom gnus-treat-date-original nil
1059 "Display the date in the original timezone.
1060 Valid values are nil, t, `head', `last', an integer or a predicate.
1061 See Info node `(gnus)Customizing Articles' for details."
1062 :group 'gnus-article-treat
1063 :link '(custom-manual "(gnus)Customizing Articles")
1064 :type gnus-article-treat-head-custom)
1066 (defcustom gnus-treat-date-iso8601 nil
1067 "Display the date in the ISO8601 format.
1068 Valid values are nil, t, `head', `last', an integer or a predicate.
1069 See Info node `(gnus)Customizing Articles' for details."
1071 :group 'gnus-article-treat
1072 :link '(custom-manual "(gnus)Customizing Articles")
1073 :type gnus-article-treat-head-custom)
1075 (defcustom gnus-treat-date-user-defined nil
1076 "Display the date in a user-defined format.
1077 The format is defined by the `gnus-article-time-format' variable.
1078 Valid values are nil, t, `head', `last', an integer or a predicate.
1079 See Info node `(gnus)Customizing Articles' for details."
1080 :group 'gnus-article-treat
1081 :link '(custom-manual "(gnus)Customizing Articles")
1082 :type gnus-article-treat-head-custom)
1084 (defcustom gnus-treat-strip-headers-in-body t
1085 "Strip the X-No-Archive header line from the beginning of the body.
1086 Valid values are nil, t, `head', `last', an integer or a predicate.
1087 See Info node `(gnus)Customizing Articles' for details."
1089 :group 'gnus-article-treat
1090 :link '(custom-manual "(gnus)Customizing Articles")
1091 :type gnus-article-treat-custom)
1093 (defcustom gnus-treat-strip-trailing-blank-lines nil
1094 "Strip trailing blank lines.
1095 Valid values are nil, t, `head', `last', an integer or a predicate.
1096 See Info node `(gnus)Customizing Articles' for details."
1097 :group 'gnus-article-treat
1098 :link '(custom-manual "(gnus)Customizing Articles")
1099 :type gnus-article-treat-custom)
1101 (defcustom gnus-treat-strip-leading-blank-lines nil
1102 "Strip leading blank lines.
1103 Valid values are nil, t, `head', `last', an integer or a predicate.
1104 See Info node `(gnus)Customizing Articles' for details."
1105 :group 'gnus-article-treat
1106 :link '(custom-manual "(gnus)Customizing Articles")
1107 :type gnus-article-treat-custom)
1109 (defcustom gnus-treat-strip-multiple-blank-lines nil
1110 "Strip multiple blank lines.
1111 Valid values are nil, t, `head', `last', an integer or a predicate.
1112 See Info node `(gnus)Customizing Articles' for details."
1113 :group 'gnus-article-treat
1114 :link '(custom-manual "(gnus)Customizing Articles")
1115 :type gnus-article-treat-custom)
1117 (defcustom gnus-treat-unfold-headers 'head
1118 "Unfold folded header lines.
1119 Valid values are nil, t, `head', `last', an integer or a predicate.
1120 See Info node `(gnus)Customizing Articles' for details."
1121 :group 'gnus-article-treat
1122 :link '(custom-manual "(gnus)Customizing Articles")
1123 :type gnus-article-treat-custom)
1125 (defcustom gnus-treat-fold-headers nil
1127 Valid values are nil, t, `head', `last', an integer or a predicate.
1128 See Info node `(gnus)Customizing Articles' for details."
1129 :group 'gnus-article-treat
1130 :link '(custom-manual "(gnus)Customizing Articles")
1131 :type gnus-article-treat-custom)
1133 (defcustom gnus-treat-fold-newsgroups 'head
1134 "Fold the Newsgroups and Followup-To headers.
1135 Valid values are nil, t, `head', `last', an integer or a predicate.
1136 See Info node `(gnus)Customizing Articles' for details."
1137 :group 'gnus-article-treat
1138 :link '(custom-manual "(gnus)Customizing Articles")
1139 :type gnus-article-treat-custom)
1141 (defcustom gnus-treat-overstrike t
1142 "Treat overstrike highlighting.
1143 Valid values are nil, t, `head', `last', an integer or a predicate.
1144 See Info node `(gnus)Customizing Articles' for details."
1145 :group 'gnus-article-treat
1146 :link '(custom-manual "(gnus)Customizing Articles")
1147 :type gnus-article-treat-custom)
1148 (put 'gnus-treat-overstrike 'highlight t)
1150 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1151 "Treat ANSI SGR control sequences.
1152 Valid values are nil, t, `head', `last', an integer or a predicate.
1153 See Info node `(gnus)Customizing Articles' for details."
1154 :group 'gnus-article-treat
1155 :link '(custom-manual "(gnus)Customizing Articles")
1156 :type gnus-article-treat-custom)
1158 (make-obsolete-variable 'gnus-treat-display-xface
1159 'gnus-treat-display-x-face)
1161 (defcustom gnus-treat-display-x-face
1162 (and (not noninteractive)
1163 (or (and (fboundp 'image-type-available-p)
1164 (image-type-available-p 'xbm)
1165 (string-match "^0x" (shell-command-to-string "uncompface"))
1166 (executable-find "icontopbm"))
1167 (and (featurep 'xemacs)
1170 "Display X-Face headers.
1171 Valid values are nil, t, `head', `last', an integer or a predicate.
1172 See Info node `(gnus)Customizing Articles' and Info node
1173 `(gnus)X-Face' for details."
1174 :group 'gnus-article-treat
1176 :link '(custom-manual "(gnus)Customizing Articles")
1177 :link '(custom-manual "(gnus)X-Face")
1178 :type gnus-article-treat-head-custom
1179 :set (lambda (symbol value)
1182 (cond ((or (boundp symbol) (get symbol 'saved-value))
1184 ((boundp 'gnus-treat-display-xface)
1186 ** gnus-treat-display-xface is an obsolete variable;\
1187 use gnus-treat-display-x-face instead")
1188 (default-value 'gnus-treat-display-xface))
1189 ((get 'gnus-treat-display-xface 'saved-value)
1191 ** gnus-treat-display-xface is an obsolete variable;\
1192 use gnus-treat-display-x-face instead")
1193 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1196 (put 'gnus-treat-display-x-face 'highlight t)
1198 (defcustom gnus-treat-display-face
1199 (and (not noninteractive)
1200 (or (and (fboundp 'image-type-available-p)
1201 (image-type-available-p 'png))
1202 (and (featurep 'xemacs)
1205 "Display Face headers.
1206 Valid values are nil, t, `head', `last', an integer or a predicate.
1207 See Info node `(gnus)Customizing Articles' and Info node
1208 `(gnus)X-Face' for details."
1209 :group 'gnus-article-treat
1211 :link '(custom-manual "(gnus)Customizing Articles")
1212 :link '(custom-manual "(gnus)X-Face")
1213 :type gnus-article-treat-head-custom)
1214 (put 'gnus-treat-display-face 'highlight t)
1216 (defcustom gnus-treat-display-smileys
1217 (if (or (and (featurep 'xemacs)
1219 (and (fboundp 'image-type-available-p)
1220 (image-type-available-p 'pbm)))
1223 Valid values are nil, t, `head', `last', an integer or a predicate.
1224 See Info node `(gnus)Customizing Articles' and Info node
1225 `(gnus)Smileys' for details."
1226 :group 'gnus-article-treat
1228 :link '(custom-manual "(gnus)Customizing Articles")
1229 :link '(custom-manual "(gnus)Smileys")
1230 :type gnus-article-treat-custom)
1231 (put 'gnus-treat-display-smileys 'highlight t)
1233 (defcustom gnus-treat-from-picon
1234 (if (and (gnus-image-type-available-p 'xpm)
1235 (gnus-picons-installed-p))
1237 "Display picons in the From header.
1238 Valid values are nil, t, `head', `last', an integer or a predicate.
1239 See Info node `(gnus)Customizing Articles' and Info node
1240 `(gnus)Picons' for details."
1241 :group 'gnus-article-treat
1243 :link '(custom-manual "(gnus)Customizing Articles")
1244 :link '(custom-manual "(gnus)Picons")
1245 :type gnus-article-treat-head-custom)
1246 (put 'gnus-treat-from-picon 'highlight t)
1248 (defcustom gnus-treat-mail-picon
1249 (if (and (gnus-image-type-available-p 'xpm)
1250 (gnus-picons-installed-p))
1252 "Display picons in To and Cc headers.
1253 Valid values are nil, t, `head', `last', an integer or a predicate.
1254 See Info node `(gnus)Customizing Articles' and Info node
1255 `(gnus)Picons' for details."
1256 :group 'gnus-article-treat
1258 :link '(custom-manual "(gnus)Customizing Articles")
1259 :link '(custom-manual "(gnus)Picons")
1260 :type gnus-article-treat-head-custom)
1261 (put 'gnus-treat-mail-picon 'highlight t)
1263 (defcustom gnus-treat-newsgroups-picon
1264 (if (and (gnus-image-type-available-p 'xpm)
1265 (gnus-picons-installed-p))
1267 "Display picons in the Newsgroups and Followup-To headers.
1268 Valid values are nil, t, `head', `last', an integer or a predicate.
1269 See Info node `(gnus)Customizing Articles' and Info node
1270 `(gnus)Picons' for details."
1271 :group 'gnus-article-treat
1273 :link '(custom-manual "(gnus)Customizing Articles")
1274 :link '(custom-manual "(gnus)Picons")
1275 :type gnus-article-treat-head-custom)
1276 (put 'gnus-treat-newsgroups-picon 'highlight t)
1278 (defcustom gnus-treat-body-boundary
1279 (if (or gnus-treat-newsgroups-picon
1280 gnus-treat-mail-picon
1281 gnus-treat-from-picon)
1283 "Draw a boundary at the end of the headers.
1284 Valid values are nil and `head'.
1285 See Info node `(gnus)Customizing Articles' for details."
1287 :group 'gnus-article-treat
1288 :link '(custom-manual "(gnus)Customizing Articles")
1289 :type gnus-article-treat-head-custom)
1291 (defcustom gnus-treat-capitalize-sentences nil
1292 "Capitalize sentence-starting words.
1293 Valid values are nil, t, `head', `last', an integer or a predicate.
1294 See Info node `(gnus)Customizing Articles' for details."
1296 :group 'gnus-article-treat
1297 :link '(custom-manual "(gnus)Customizing Articles")
1298 :type gnus-article-treat-custom)
1300 (defcustom gnus-treat-wash-html nil
1302 Valid values are nil, t, `head', `last', an integer or a predicate.
1303 See Info node `(gnus)Customizing Articles' for details."
1304 :group 'gnus-article-treat
1305 :link '(custom-manual "(gnus)Customizing Articles")
1306 :type gnus-article-treat-custom)
1308 (defcustom gnus-treat-fill-long-lines nil
1310 Valid values are nil, t, `head', `last', an integer or a predicate.
1311 See Info node `(gnus)Customizing Articles' for details."
1312 :group 'gnus-article-treat
1313 :link '(custom-manual "(gnus)Customizing Articles")
1314 :type gnus-article-treat-custom)
1316 (defcustom gnus-treat-play-sounds nil
1318 Valid values are nil, t, `head', `last', an integer or a predicate.
1319 See Info node `(gnus)Customizing Articles' for details."
1321 :group 'gnus-article-treat
1322 :link '(custom-manual "(gnus)Customizing Articles")
1323 :type gnus-article-treat-custom)
1325 (defcustom gnus-treat-translate nil
1326 "Translate articles from one language to another.
1327 Valid values are nil, t, `head', `last', an integer or a predicate.
1328 See Info node `(gnus)Customizing Articles' for details."
1330 :group 'gnus-article-treat
1331 :link '(custom-manual "(gnus)Customizing Articles")
1332 :type gnus-article-treat-custom)
1334 (defcustom gnus-treat-x-pgp-sig nil
1336 To automatically treat X-PGP-Sig, set it to head.
1337 Valid values are nil, t, `head', `last', an integer or a predicate.
1338 See Info node `(gnus)Customizing Articles' for details."
1339 :group 'gnus-article-treat
1340 :group 'mime-security
1341 :link '(custom-manual "(gnus)Customizing Articles")
1342 :type gnus-article-treat-custom)
1344 (defvar gnus-article-encrypt-protocol-alist
1345 '(("PGP" . mml2015-self-encrypt)))
1347 ;; Set to nil if more than one protocol added to
1348 ;; gnus-article-encrypt-protocol-alist.
1349 (defcustom gnus-article-encrypt-protocol "PGP"
1350 "The protocol used for encrypt articles.
1351 It is a string, such as \"PGP\". If nil, ask user."
1353 :group 'mime-security)
1355 (defvar gnus-article-wash-function nil
1356 "Function used for converting HTML into text.")
1358 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1359 (mm-coding-system-p 'utf-8)
1360 (executable-find idna-program))
1361 "Whether IDNA decoding of headers is used when viewing messages.
1362 This requires GNU Libidn, and by default only enabled if it is found."
1363 :group 'gnus-article-headers
1366 (defcustom gnus-article-over-scroll nil
1367 "If non-nil, allow scrolling the article buffer even when there no more text."
1368 :group 'gnus-article
1371 ;;; Internal variables
1373 (defvar gnus-english-month-names
1374 '("January" "February" "March" "April" "May" "June" "July" "August"
1375 "September" "October" "November" "December"))
1377 (defvar gnus-button-regexp nil)
1378 (defvar gnus-button-marker-list nil)
1379 ;; Regexp matching any of the regexps from `gnus-button-alist'.
1381 (defvar gnus-button-last nil)
1382 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
1384 (defvar article-goto-body-goes-to-point-min-p nil)
1385 (defvar gnus-article-wash-types nil)
1386 (defvar gnus-article-emphasis-alist nil)
1387 (defvar gnus-article-image-alist nil)
1389 (defvar gnus-article-mime-handle-alist-1 nil)
1390 (defvar gnus-treatment-function-alist
1391 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1392 (gnus-treat-strip-banner gnus-article-strip-banner)
1393 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1394 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1395 (gnus-treat-buttonize gnus-article-add-buttons)
1396 (gnus-treat-fill-article gnus-article-fill-cited-article)
1397 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1398 (gnus-treat-strip-cr gnus-article-remove-cr)
1399 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1400 (gnus-treat-date-ut gnus-article-date-ut)
1401 (gnus-treat-date-local gnus-article-date-local)
1402 (gnus-treat-date-english gnus-article-date-english)
1403 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1404 (gnus-treat-date-original gnus-article-date-original)
1405 (gnus-treat-date-user-defined gnus-article-date-user)
1406 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1407 (gnus-treat-display-x-face gnus-article-display-x-face)
1408 (gnus-treat-display-face gnus-article-display-face)
1409 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1410 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1411 (gnus-treat-hide-signature gnus-article-hide-signature)
1412 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1413 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1414 (gnus-treat-strip-pem gnus-article-hide-pem)
1415 (gnus-treat-from-picon gnus-treat-from-picon)
1416 (gnus-treat-mail-picon gnus-treat-mail-picon)
1417 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1418 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1419 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1420 (gnus-treat-strip-trailing-blank-lines
1421 gnus-article-remove-trailing-blank-lines)
1422 (gnus-treat-strip-leading-blank-lines
1423 gnus-article-strip-leading-blank-lines)
1424 (gnus-treat-strip-multiple-blank-lines
1425 gnus-article-strip-multiple-blank-lines)
1426 (gnus-treat-overstrike gnus-article-treat-overstrike)
1427 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1428 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1429 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1430 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1431 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1432 (gnus-treat-display-smileys gnus-treat-smiley)
1433 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1434 (gnus-treat-wash-html gnus-article-wash-html)
1435 (gnus-treat-emphasize gnus-article-emphasize)
1436 (gnus-treat-hide-citation gnus-article-hide-citation)
1437 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1438 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1439 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1440 (gnus-treat-play-sounds gnus-earcon-display)))
1442 (defvar gnus-article-mime-handle-alist nil)
1443 (defvar article-lapsed-timer nil)
1444 (defvar gnus-article-current-summary nil)
1446 (defvar gnus-article-mode-syntax-table
1447 (let ((table (copy-syntax-table text-mode-syntax-table)))
1448 ;; This causes the citation match run O(2^n).
1449 ;; (modify-syntax-entry ?- "w" table)
1450 (modify-syntax-entry ?> ")<" table)
1451 (modify-syntax-entry ?< "(>" table)
1452 ;; make M-. in article buffers work for `foo' strings
1453 (modify-syntax-entry ?' " " table)
1454 (modify-syntax-entry ?` " " table)
1456 "Syntax table used in article mode buffers.
1457 Initialized from `text-mode-syntax-table.")
1459 (defvar gnus-save-article-buffer nil)
1461 (defvar gnus-article-mode-line-format-alist
1462 (nconc '((?w (gnus-article-wash-status) ?s)
1463 (?m (gnus-article-mime-part-status) ?s))
1464 gnus-summary-mode-line-format-alist))
1466 (defvar gnus-number-of-articles-to-be-saved nil)
1468 (defvar gnus-inhibit-hiding nil)
1470 (defvar gnus-article-edit-mode nil)
1472 ;;; Macros for dealing with the article buffer.
1474 (defmacro gnus-with-article-headers (&rest forms)
1476 (set-buffer gnus-article-buffer)
1478 (let ((buffer-read-only nil)
1479 (inhibit-point-motion-hooks t)
1480 (case-fold-search t))
1481 (article-narrow-to-head)
1484 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1485 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1487 (defmacro gnus-with-article-buffer (&rest forms)
1489 (set-buffer gnus-article-buffer)
1490 (let ((buffer-read-only nil))
1493 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1494 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1496 (defun gnus-article-goto-header (header)
1497 "Go to HEADER, which is a regular expression."
1498 (re-search-forward (concat "^\\(" header "\\):") nil t))
1500 (defsubst gnus-article-hide-text (b e props)
1501 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1502 (gnus-add-text-properties-when 'article-type nil b e props)
1503 (when (memq 'intangible props)
1505 (max (1- b) (point-min))
1506 b 'intangible (cddr (memq 'intangible props)))))
1508 (defsubst gnus-article-unhide-text (b e)
1509 "Remove hidden text properties from region between B and E."
1510 (remove-text-properties b e gnus-hidden-properties)
1511 (when (memq 'intangible gnus-hidden-properties)
1512 (put-text-property (max (1- b) (point-min))
1513 b 'intangible nil)))
1515 (defun gnus-article-hide-text-type (b e type)
1516 "Hide text of TYPE between B and E."
1517 (gnus-add-wash-type type)
1518 (gnus-article-hide-text
1519 b e (cons 'article-type (cons type gnus-hidden-properties))))
1521 (defun gnus-article-unhide-text-type (b e type)
1522 "Unhide text of TYPE between B and E."
1523 (gnus-delete-wash-type type)
1524 (remove-text-properties
1525 b e (cons 'article-type (cons type gnus-hidden-properties)))
1526 (when (memq 'intangible gnus-hidden-properties)
1527 (put-text-property (max (1- b) (point-min))
1528 b 'intangible nil)))
1530 (defun gnus-article-hide-text-of-type (type)
1531 "Hide text of TYPE in the current buffer."
1533 (let ((b (point-min))
1535 (while (setq b (text-property-any b e 'article-type type))
1536 (add-text-properties b (incf b) gnus-hidden-properties)))))
1538 (defun gnus-article-delete-text-of-type (type)
1539 "Delete text of TYPE in the current buffer."
1541 (let ((b (point-min)))
1542 (while (setq b (text-property-any b (point-max) 'article-type type))
1544 b (or (text-property-not-all b (point-max) 'article-type type)
1547 (defun gnus-article-delete-invisible-text ()
1548 "Delete all invisible text in the current buffer."
1550 (let ((b (point-min)))
1551 (while (setq b (text-property-any b (point-max) 'invisible t))
1553 b (or (text-property-not-all b (point-max) 'invisible t)
1556 (defun gnus-article-text-type-exists-p (type)
1557 "Say whether any text of type TYPE exists in the buffer."
1558 (text-property-any (point-min) (point-max) 'article-type type))
1560 (defsubst gnus-article-header-rank ()
1561 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1562 (let ((list gnus-sorted-header-list)
1565 (if (looking-at (car list))
1567 (setq list (cdr list))
1571 (defun article-hide-headers (&optional arg delete)
1572 "Hide unwanted headers and possibly sort them as well."
1574 ;; This function might be inhibited.
1575 (unless gnus-inhibit-hiding
1578 (let ((buffer-read-only nil)
1579 (case-fold-search t)
1580 (max (1+ (length gnus-sorted-header-list)))
1581 (ignored (when (not gnus-visible-headers)
1582 (cond ((stringp gnus-ignored-headers)
1583 gnus-ignored-headers)
1584 ((listp gnus-ignored-headers)
1585 (mapconcat 'identity gnus-ignored-headers
1588 (cond ((stringp gnus-visible-headers)
1589 gnus-visible-headers)
1590 ((and gnus-visible-headers
1591 (listp gnus-visible-headers))
1592 (mapconcat 'identity gnus-visible-headers "\\|"))))
1593 (inhibit-point-motion-hooks t)
1595 ;; First we narrow to just the headers.
1596 (article-narrow-to-head)
1597 ;; Hide any "From " lines at the beginning of (mail) articles.
1598 (while (looking-at "From ")
1601 (delete-region (point-min) (point)))
1602 ;; Then treat the rest of the header lines.
1603 ;; Then we use the two regular expressions
1604 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1605 ;; select which header lines is to remain visible in the
1607 (while (re-search-forward "^[^ \t:]*:" nil t)
1609 ;; Mark the rank of the header.
1611 (point) (1+ (point)) 'message-rank
1612 (if (or (and visible (looking-at visible))
1614 (not (looking-at ignored))))
1615 (gnus-article-header-rank)
1618 (message-sort-headers-1)
1619 (when (setq beg (text-property-any
1620 (point-min) (point-max) 'message-rank (+ 2 max)))
1621 ;; We delete the unwanted headers.
1622 (gnus-add-wash-type 'headers)
1623 (add-text-properties (point-min) (+ 5 (point-min))
1624 '(article-type headers dummy-invisible t))
1625 (delete-region beg (point-max))))))))
1627 (defun article-hide-boring-headers (&optional arg)
1628 "Toggle hiding of headers that aren't very interesting.
1629 If given a negative prefix, always show; if given a positive prefix,
1631 (interactive (gnus-article-hidden-arg))
1632 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1633 (not gnus-show-all-headers))
1636 (let ((buffer-read-only nil)
1637 (list gnus-boring-article-headers)
1638 (inhibit-point-motion-hooks t)
1640 (article-narrow-to-head)
1642 (setq elem (pop list))
1643 (goto-char (point-min))
1645 ;; Hide empty headers.
1647 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1649 (gnus-article-hide-text-type
1653 (if (re-search-forward "^[^ \t]" nil t)
1657 ;; Hide boring Newsgroups header.
1658 ((eq elem 'newsgroups)
1659 (when (gnus-string-equal
1660 (gnus-fetch-field "newsgroups")
1661 (gnus-group-real-name
1662 (if (boundp 'gnus-newsgroup-name)
1665 (gnus-article-hide-header "newsgroups")))
1666 ((eq elem 'to-address)
1667 (let ((to (message-fetch-field "to"))
1669 (gnus-parameter-to-address
1670 (if (boundp 'gnus-newsgroup-name)
1671 gnus-newsgroup-name ""))))
1672 (when (and to to-address
1675 ;; only one address in To
1676 (nth 1 (mail-extract-address-components to))
1678 (gnus-article-hide-header "to"))))
1680 (let ((to (message-fetch-field "to"))
1682 (gnus-parameter-to-list
1683 (if (boundp 'gnus-newsgroup-name)
1684 gnus-newsgroup-name ""))))
1685 (when (and to to-list
1688 ;; only one address in To
1689 (nth 1 (mail-extract-address-components to))
1691 (gnus-article-hide-header "to"))))
1693 (let ((cc (message-fetch-field "cc"))
1695 (gnus-parameter-to-list
1696 (if (boundp 'gnus-newsgroup-name)
1697 gnus-newsgroup-name ""))))
1698 (when (and cc to-list
1701 ;; only one address in CC
1702 (nth 1 (mail-extract-address-components cc))
1704 (gnus-article-hide-header "cc"))))
1705 ((eq elem 'followup-to)
1706 (when (gnus-string-equal
1707 (message-fetch-field "followup-to")
1708 (message-fetch-field "newsgroups"))
1709 (gnus-article-hide-header "followup-to")))
1710 ((eq elem 'reply-to)
1711 (if (gnus-group-find-parameter
1712 gnus-newsgroup-name 'broken-reply-to)
1713 (gnus-article-hide-header "reply-to")
1714 (let ((from (message-fetch-field "from"))
1715 (reply-to (message-fetch-field "reply-to")))
1722 (lambda (x) (downcase (cadr x)))
1723 (mail-extract-address-components from t))
1726 (lambda (x) (downcase (cadr x)))
1727 (mail-extract-address-components reply-to t))
1729 (gnus-article-hide-header "reply-to")))))
1731 (let ((date (message-fetch-field "date")))
1733 (< (days-between (current-time-string) date)
1735 (gnus-article-hide-header "date"))))
1737 (let ((to (message-fetch-field "to"))
1738 (cc (message-fetch-field "cc")))
1739 (when (> (length to) 1024)
1740 (gnus-article-hide-header "to"))
1741 (when (> (length cc) 1024)
1742 (gnus-article-hide-header "cc"))))
1746 (goto-char (point-min))
1747 (while (re-search-forward "^to:" nil t)
1748 (setq to-count (1+ to-count)))
1749 (when (> to-count 1)
1750 (while (> to-count 0)
1751 (goto-char (point-min))
1753 (re-search-forward "^to:" nil nil to-count)
1755 (narrow-to-region (point) (point-max))
1756 (gnus-article-hide-header "to"))
1757 (setq to-count (1- to-count))))
1758 (goto-char (point-min))
1759 (while (re-search-forward "^cc:" nil t)
1760 (setq cc-count (1+ cc-count)))
1761 (when (> cc-count 1)
1762 (while (> cc-count 0)
1763 (goto-char (point-min))
1765 (re-search-forward "^cc:" nil nil cc-count)
1767 (narrow-to-region (point) (point-max))
1768 (gnus-article-hide-header "cc"))
1769 (setq cc-count (1- cc-count)))))))))))))
1771 (defun gnus-article-hide-header (header)
1773 (goto-char (point-min))
1774 (when (re-search-forward (concat "^" header ":") nil t)
1775 (gnus-article-hide-text-type
1779 (if (re-search-forward "^[^ \t]" nil t)
1784 (defvar gnus-article-normalized-header-length 40
1785 "Length of normalized headers.")
1787 (defun article-normalize-headers ()
1788 "Make all header lines 40 characters long."
1790 (let ((buffer-read-only nil)
1794 (article-narrow-to-head)
1797 ((< (setq column (- (point-at-eol) (point)))
1798 gnus-article-normalized-header-length)
1800 (insert (make-string
1801 (- gnus-article-normalized-header-length column)
1803 ((> column gnus-article-normalized-header-length)
1804 (gnus-put-text-property
1806 (forward-char gnus-article-normalized-header-length)
1813 (forward-line 1))))))
1815 (defun article-treat-dumbquotes ()
1816 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
1817 Note that this function guesses whether a character is a sm*rtq**t* or
1818 not, so it should only be used interactively.
1820 Sm*rtq**t*s are M****s***'s unilateral extension to the
1821 iso-8859-1 character map in an attempt to provide more quoting
1822 characters. If you see something like \\222 or \\264 where
1823 you're expecting some kind of apostrophe or quotation mark, then
1826 (article-translate-strings gnus-article-dumbquotes-map))
1828 (defun article-translate-characters (from to)
1829 "Translate all characters in the body of the article according to FROM and TO.
1830 FROM is a string of characters to translate from; to is a string of
1831 characters to translate to."
1833 (when (article-goto-body)
1834 (let ((buffer-read-only nil)
1835 (x (make-string 225 ?x))
1837 (while (< (incf i) (length x))
1840 (while (< i (length from))
1841 (aset x (aref from i) (aref to i))
1843 (translate-region (point) (point-max) x)))))
1845 (defun article-translate-strings (map)
1846 "Translate all string in the body of the article according to MAP.
1847 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1849 (when (article-goto-body)
1850 (let ((buffer-read-only nil)
1852 (while (setq elem (pop map))
1854 (while (search-forward (car elem) nil t)
1855 (replace-match (cadr elem)))))))))
1857 (defun article-treat-overstrike ()
1858 "Translate overstrikes into bold text."
1861 (when (article-goto-body)
1862 (let ((buffer-read-only nil))
1863 (while (search-forward "\b" nil t)
1864 (let ((next (char-after))
1865 (previous (char-after (- (point) 2))))
1866 ;; We do the boldification/underlining by hiding the
1867 ;; overstrikes and putting the proper text property
1871 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1872 (put-text-property (point) (1+ (point)) 'face 'bold))
1874 (gnus-article-hide-text-type
1875 (1- (point)) (1+ (point)) 'overstrike)
1877 (- (point) 2) (1- (point)) 'face 'underline))
1879 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1881 (point) (1+ (point)) 'face 'underline)))))))))
1883 (defun article-treat-ansi-sequences ()
1884 "Translate ANSI SGR control sequences into overlays or extents."
1887 (when (article-goto-body)
1888 (let ((buffer-read-only nil))
1889 (ansi-color-apply-on-region (point) (point-max))))))
1891 (defun gnus-article-treat-unfold-headers ()
1892 "Unfold folded message headers.
1893 Only the headers that fit into the current window width will be
1896 (gnus-with-article-headers
1900 (mail-header-narrow-to-field)
1901 (let ((header (buffer-string)))
1904 (goto-char (point-min))
1905 (while (re-search-forward "\n[\t ]" nil t)
1906 (replace-match " " t t)))
1907 (setq length (- (point-max) (point-min) 1)))
1908 (when (< length (window-width))
1909 (while (re-search-forward "\n[\t ]" nil t)
1910 (replace-match " " t t)))
1911 (goto-char (point-max)))))))
1913 (defun gnus-article-treat-fold-headers ()
1914 "Fold message headers."
1916 (gnus-with-article-headers
1919 (mail-header-narrow-to-field)
1920 (mail-header-fold-field)
1921 (goto-char (point-max))))))
1923 (defun gnus-treat-smiley ()
1924 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1926 (gnus-with-article-buffer
1927 (if (memq 'smiley gnus-article-wash-types)
1928 (gnus-delete-images 'smiley)
1930 (let ((images (smiley-region (point) (point-max))))
1932 (gnus-add-wash-type 'smiley)
1933 (dolist (image images)
1934 (gnus-add-image 'smiley image)))))))
1936 (defun gnus-article-remove-images ()
1937 "Remove all images from the article buffer."
1939 (gnus-with-article-buffer
1940 (dolist (elem gnus-article-image-alist)
1941 (gnus-delete-images (car elem)))))
1943 (defun gnus-article-treat-fold-newsgroups ()
1944 "Unfold folded message headers.
1945 Only the headers that fit into the current window width will be
1948 (gnus-with-article-headers
1949 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1951 (mail-header-narrow-to-field)
1952 (while (re-search-forward ", *" nil t)
1953 (replace-match ", " t t))
1954 (mail-header-fold-field)
1955 (goto-char (point-max))))))
1957 (defun gnus-article-treat-body-boundary ()
1958 "Place a boundary line at the end of the headers."
1960 (when (and gnus-body-boundary-delimiter
1961 (> (length gnus-body-boundary-delimiter) 0))
1962 (gnus-with-article-headers
1963 (goto-char (point-max))
1964 (let ((start (point)))
1965 (insert "X-Boundary: ")
1966 (gnus-add-text-properties start (point) '(invisible t intangible t))
1968 (while (>= (1- (window-width)) (length str))
1969 (setq str (concat str gnus-body-boundary-delimiter)))
1970 (substring str 0 (1- (window-width))))
1972 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
1974 (defun article-fill-long-lines ()
1975 "Fill lines that are wider than the window width."
1978 (let ((buffer-read-only nil)
1979 (width (window-width (get-buffer-window (current-buffer)))))
1982 (let ((adaptive-fill-mode nil)) ;Why? -sm
1985 (when (>= (current-column) (min fill-column width))
1986 (narrow-to-region (min (1+ (point)) (point-max))
1988 (let ((goback (point-marker)))
1989 (fill-paragraph nil)
1990 (goto-char (marker-position goback)))
1992 (forward-line 1)))))))
1994 (defun article-capitalize-sentences ()
1995 "Capitalize the first word in each sentence."
1998 (let ((buffer-read-only nil)
1999 (paragraph-start "^[\n\^L]"))
2003 (forward-sentence)))))
2005 (defun article-remove-cr ()
2006 "Remove trailing CRs and then translate remaining CRs into LFs."
2009 (let ((buffer-read-only nil))
2010 (goto-char (point-min))
2011 (while (re-search-forward "\r+$" nil t)
2012 (replace-match "" t t))
2013 (goto-char (point-min))
2014 (while (search-forward "\r" nil t)
2015 (replace-match "\n" t t)))))
2017 (defun article-remove-trailing-blank-lines ()
2018 "Remove all trailing blank lines from the article."
2021 (let ((buffer-read-only nil))
2022 (goto-char (point-max))
2026 (while (and (not (bobp))
2027 (looking-at "^[ \t]*$")
2028 (not (gnus-annotation-in-region-p
2029 (point) (point-at-eol))))
2035 (defvar gnus-face-properties-alist))
2037 (defun article-display-face ()
2038 "Display any Face headers in the header."
2040 (let ((wash-face-p buffer-read-only))
2041 (gnus-with-article-headers
2042 ;; When displaying parts, this function can be called several times on
2043 ;; the same article, without any intended toggle semantic (as typing `W
2044 ;; D d' would have). So face deletion must occur only when we come from
2045 ;; an interactive command, that is when the *Article* buffer is
2047 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2048 (gnus-delete-images 'face)
2051 (when (and wash-face-p
2053 (goto-char (point-min))
2054 (not (re-search-forward "^Face:[\t ]*" nil t)))
2055 (gnus-buffer-live-p gnus-original-article-buffer))
2056 (set-buffer gnus-original-article-buffer))
2058 (mail-narrow-to-head)
2059 (while (gnus-article-goto-header "Face")
2060 (push (mail-header-field-value) faces))))
2061 (while (setq face (pop faces))
2062 (let ((png (gnus-convert-face-to-png face))
2066 (apply 'gnus-create-image png 'png t
2067 (cdr (assq 'png gnus-face-properties-alist))))
2068 (gnus-article-goto-header "from")
2070 (insert "From: [no `from' set]\n")
2072 (gnus-add-wash-type 'face)
2073 (gnus-add-image 'face image)
2074 (gnus-put-image image nil 'face))))))
2077 (defun article-display-x-face (&optional force)
2078 "Look for an X-Face header and display it if present."
2079 (interactive (list 'force))
2080 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2081 (gnus-with-article-headers
2082 ;; Delete the old process, if any.
2083 (when (process-status "article-x-face")
2084 (delete-process "article-x-face"))
2085 ;; See the comment in `article-display-face'.
2086 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2087 ;; We have already displayed X-Faces, so we remove them
2089 (gnus-delete-images 'xface)
2091 (let (x-faces from face)
2093 (when (and wash-face-p
2095 (goto-char (point-min))
2096 (not (re-search-forward
2097 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2098 (gnus-buffer-live-p gnus-original-article-buffer))
2099 ;; If type `W f', use gnus-original-article-buffer,
2100 ;; otherwise use the current buffer because displaying
2101 ;; RFC822 parts calls this function too.
2102 (set-buffer gnus-original-article-buffer))
2104 (mail-narrow-to-head)
2105 (while (gnus-article-goto-header "X-Face")
2106 (push (mail-header-field-value) x-faces))
2107 (setq from (message-fetch-field "from"))))
2108 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2109 ;; single external face.
2110 (when (stringp gnus-article-x-face-command)
2111 (setq x-faces (list (car x-faces))))
2112 (while (and (setq face (pop x-faces))
2113 gnus-article-x-face-command
2115 ;; Check whether this face is censored.
2116 (not gnus-article-x-face-too-ugly)
2117 (and gnus-article-x-face-too-ugly from
2118 (not (string-match gnus-article-x-face-too-ugly
2120 ;; We display the face.
2121 (cond ((stringp gnus-article-x-face-command)
2122 ;; The command is a string, so we interpret the command
2123 ;; as a, well, command, and fork it off.
2124 (let ((process-connection-type nil))
2125 (process-kill-without-query
2127 "article-x-face" nil shell-file-name
2128 shell-command-switch gnus-article-x-face-command))
2131 (process-send-region "article-x-face"
2132 (point-min) (point-max)))
2133 (process-send-eof "article-x-face")))
2134 ((functionp gnus-article-x-face-command)
2135 ;; The command is a lisp function, so we call it.
2136 (funcall gnus-article-x-face-command face))
2138 (error "%s is not a function"
2139 gnus-article-x-face-command)))))))))
2141 (defun article-decode-mime-words ()
2142 "Decode all MIME-encoded words in the article."
2144 (gnus-with-article-buffer
2145 (let ((inhibit-point-motion-hooks t)
2146 (mail-parse-charset gnus-newsgroup-charset)
2147 (mail-parse-ignored-charsets
2148 (with-current-buffer gnus-summary-buffer
2149 gnus-newsgroup-ignored-charsets)))
2150 (mail-decode-encoded-word-region (point-min) (point-max)))))
2152 (defun article-decode-charset (&optional prompt)
2153 "Decode charset-encoded text in the article.
2154 If PROMPT (the prefix), prompt for a coding system to use."
2156 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2158 (mail-parse-charset gnus-newsgroup-charset)
2159 (mail-parse-ignored-charsets
2160 (save-excursion (condition-case nil
2161 (set-buffer gnus-summary-buffer)
2163 gnus-newsgroup-ignored-charsets))
2164 ct cte ctl charset format)
2167 (article-narrow-to-head)
2168 (setq ct (message-fetch-field "Content-Type" t)
2169 cte (message-fetch-field "Content-Transfer-Encoding" t)
2170 ctl (and ct (ignore-errors
2171 (mail-header-parse-content-type ct)))
2174 (mm-read-coding-system "Charset to decode: "))
2176 (mail-content-type-get ctl 'charset)))
2177 format (and ctl (mail-content-type-get ctl 'format)))
2179 (setq cte (mail-header-strip cte)))
2180 (if (and ctl (not (string-match "/" (car ctl))))
2182 (goto-char (point-max)))
2185 (narrow-to-region (point) (point-max))
2186 (when (and (eq mail-parse-charset 'gnus-decoded)
2187 (eq (mm-body-7-or-8) '8bit))
2188 ;; The text code could have been decoded.
2189 (setq charset mail-parse-charset))
2190 (when (and (or (not ctl)
2191 (equal (car ctl) "text/plain"))
2192 (not format)) ;; article with format will decode later.
2194 charset (and cte (intern (downcase
2195 (gnus-strip-whitespace cte))))
2198 (defun article-decode-encoded-words ()
2199 "Remove encoded-word encoding from headers."
2200 (let ((inhibit-point-motion-hooks t)
2201 (mail-parse-charset gnus-newsgroup-charset)
2202 (mail-parse-ignored-charsets
2203 (save-excursion (condition-case nil
2204 (set-buffer gnus-summary-buffer)
2206 gnus-newsgroup-ignored-charsets))
2209 (article-narrow-to-head)
2210 (funcall gnus-decode-header-function (point-min) (point-max)))))
2212 (defun article-decode-group-name ()
2213 "Decode group names in `Newsgroups:'."
2214 (let ((inhibit-point-motion-hooks t)
2216 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2217 (when (and (or gnus-group-name-charset-method-alist
2218 gnus-group-name-charset-group-alist)
2219 (gnus-buffer-live-p gnus-original-article-buffer))
2221 (article-narrow-to-head)
2222 (with-current-buffer gnus-original-article-buffer
2223 (goto-char (point-min)))
2224 (while (re-search-forward
2225 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2226 (replace-match (save-match-data
2227 (gnus-decode-newsgroups
2228 ;; XXX how to use data in article buffer?
2229 (with-current-buffer gnus-original-article-buffer
2231 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2234 gnus-newsgroup-name method))
2236 (goto-char (point-min))
2237 (with-current-buffer gnus-original-article-buffer
2238 (goto-char (point-min)))
2239 (while (re-search-forward
2240 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2241 (replace-match (save-match-data
2242 (gnus-decode-newsgroups
2243 ;; XXX how to use data in article buffer?
2244 (with-current-buffer gnus-original-article-buffer
2246 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2249 gnus-newsgroup-name method))
2252 (autoload 'idna-to-unicode "idna")
2254 (defun article-decode-idna-rhs ()
2255 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2258 (let ((inhibit-point-motion-hooks t)
2260 (article-narrow-to-head)
2261 (goto-char (point-min))
2262 (while (re-search-forward "\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2264 (when (save-match-data
2265 (and (setq ace (match-string 1))
2267 (and (re-search-backward "^[^ \t]" nil t)
2268 (looking-at "From\\|To\\|Cc")))
2269 (save-excursion (backward-char)
2270 (message-idna-inside-rhs-p))
2271 (setq unicode (idna-to-unicode ace))))
2272 (unless (string= ace unicode)
2273 (replace-match unicode nil nil nil 1)))))))))
2275 (defun article-de-quoted-unreadable (&optional force read-charset)
2276 "Translate a quoted-printable-encoded article.
2277 If FORCE, decode the article whether it is marked as quoted-printable
2279 If READ-CHARSET, ask for a coding system."
2280 (interactive (list 'force current-prefix-arg))
2282 (let ((buffer-read-only nil) type charset)
2283 (if (gnus-buffer-live-p gnus-original-article-buffer)
2284 (with-current-buffer gnus-original-article-buffer
2286 (gnus-fetch-field "content-transfer-encoding"))
2287 (let* ((ct (gnus-fetch-field "content-type"))
2290 (mail-header-parse-content-type ct)))))
2291 (setq charset (and ctl
2292 (mail-content-type-get ctl 'charset)))
2293 (if (stringp charset)
2294 (setq charset (intern (downcase charset)))))))
2296 (setq charset (mm-read-coding-system "Charset: " charset)))
2298 (setq charset gnus-newsgroup-charset))
2300 (and type (let ((case-fold-search t))
2301 (string-match "quoted-printable" type))))
2303 (quoted-printable-decode-region
2304 (point) (point-max) (mm-charset-to-coding-system charset))))))
2306 (defun article-de-base64-unreadable (&optional force read-charset)
2307 "Translate a base64 article.
2308 If FORCE, decode the article whether it is marked as base64 not.
2309 If READ-CHARSET, ask for a coding system."
2310 (interactive (list 'force current-prefix-arg))
2312 (let ((buffer-read-only nil) type charset)
2313 (if (gnus-buffer-live-p gnus-original-article-buffer)
2314 (with-current-buffer gnus-original-article-buffer
2316 (gnus-fetch-field "content-transfer-encoding"))
2317 (let* ((ct (gnus-fetch-field "content-type"))
2320 (mail-header-parse-content-type ct)))))
2321 (setq charset (and ctl
2322 (mail-content-type-get ctl 'charset)))
2323 (if (stringp charset)
2324 (setq charset (intern (downcase charset)))))))
2326 (setq charset (mm-read-coding-system "Charset: " charset)))
2328 (setq charset gnus-newsgroup-charset))
2330 (and type (let ((case-fold-search t))
2331 (string-match "base64" type))))
2334 (narrow-to-region (point) (point-max))
2335 (base64-decode-region (point-min) (point-max))
2336 (mm-decode-coding-region
2337 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2342 (defun article-decode-HZ ()
2343 "Translate a HZ-encoded article."
2347 (let ((buffer-read-only nil))
2348 (rfc1843-decode-region (point-min) (point-max)))))
2350 (defun article-unsplit-urls ()
2351 "Remove the newlines that some other mailers insert into URLs."
2354 (let ((buffer-read-only nil))
2355 (goto-char (point-min))
2356 (while (re-search-forward
2357 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2358 (replace-match "\\1\\3" t)))
2359 (when (interactive-p)
2360 (gnus-treat-article nil))))
2363 (defun article-wash-html (&optional read-charset)
2364 "Format an HTML article.
2365 If READ-CHARSET, ask for a coding system."
2368 (let ((buffer-read-only nil)
2370 (when (gnus-buffer-live-p gnus-original-article-buffer)
2371 (with-current-buffer gnus-original-article-buffer
2372 (let* ((ct (gnus-fetch-field "content-type"))
2375 (mail-header-parse-content-type ct)))))
2376 (setq charset (and ctl
2377 (mail-content-type-get ctl 'charset)))
2378 (when (stringp charset)
2379 (setq charset (intern (downcase charset)))))))
2381 (setq charset (mm-read-coding-system "Charset: " charset)))
2383 (setq charset gnus-newsgroup-charset))
2385 (save-window-excursion
2387 (narrow-to-region (point) (point-max))
2388 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2389 (entry (assq func mm-text-html-washer-alist)))
2391 (setq func (cdr entry)))
2396 (apply (car func) (cdr func))))))))))
2398 (defun gnus-article-wash-html-with-w3 ()
2399 "Wash the current buffer with w3."
2401 (let ((w3-strict-width (window-width))
2402 (url-standalone-mode t)
2403 (url-gateway-unplugged t)
2404 (w3-honor-stylesheets nil))
2406 (w3-region (point-min) (point-max))
2409 (defun gnus-article-wash-html-with-w3m ()
2410 "Wash the current buffer with emacs-w3m."
2413 (narrow-to-region (point) (point-max))
2414 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2417 w3m-force-redisplay)
2418 (w3m-region (point-min) (point-max)))
2419 (when (and mm-inline-text-html-with-w3m-keymap
2420 (boundp 'w3m-minor-mode-map)
2422 (add-text-properties
2423 (point-min) (point-max)
2424 (list 'keymap w3m-minor-mode-map
2425 ;; Put the mark meaning this part was rendered by emacs-w3m.
2426 'mm-inline-text-html-with-w3m t)))))
2428 (defun article-hide-list-identifiers ()
2429 "Remove list identifies from the Subject header.
2430 The `gnus-list-identifiers' variable specifies what to do."
2432 (let ((inhibit-point-motion-hooks t)
2433 (regexp (if (consp gnus-list-identifiers)
2434 (mapconcat 'identity gnus-list-identifiers " *\\|")
2435 gnus-list-identifiers))
2440 (article-narrow-to-head)
2441 (goto-char (point-min))
2442 (while (re-search-forward
2443 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2445 (delete-region (match-beginning 2) (match-end 0))
2446 (beginning-of-line))
2447 (when (re-search-forward
2448 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2449 (delete-region (match-beginning 1) (match-end 1))))))))
2451 (defun article-hide-pem (&optional arg)
2452 "Toggle hiding of any PEM headers and signatures in the current article.
2453 If given a negative prefix, always show; if given a positive prefix,
2455 (interactive (gnus-article-hidden-arg))
2456 (unless (gnus-article-check-hidden-text 'pem arg)
2458 (let (buffer-read-only end)
2459 (goto-char (point-min))
2460 ;; Hide the horrendously ugly "header".
2461 (when (and (search-forward
2462 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2464 (setq end (1+ (match-beginning 0))))
2465 (gnus-add-wash-type 'pem)
2466 (gnus-article-hide-text-type
2468 (if (search-forward "\n\n" nil t)
2472 ;; Hide the trailer as well
2473 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2475 (gnus-article-hide-text-type
2476 (match-beginning 0) (match-end 0) 'pem)))))))
2478 (defun article-strip-banner ()
2479 "Strip the banners specified by the `banner' group parameter and by
2480 `gnus-article-address-banner-alist'."
2484 (let ((inhibit-point-motion-hooks t))
2485 (when (gnus-parameter-banner gnus-newsgroup-name)
2486 (article-really-strip-banner
2487 (gnus-parameter-banner gnus-newsgroup-name)))
2488 (when gnus-article-address-banner-alist
2489 (article-really-strip-banner
2490 (let ((from (save-restriction
2492 (article-narrow-to-head)
2493 (mail-fetch-field "from"))))
2496 (caar (mail-header-parse-addresses from))))
2498 (dolist (pair gnus-article-address-banner-alist)
2499 (when (string-match (car pair) from)
2500 (throw 'found (cdr pair)))))))))))))
2502 (defun article-really-strip-banner (banner)
2503 "Strip the banner specified by the argument."
2506 (let ((inhibit-point-motion-hooks t)
2507 (gnus-signature-limit nil)
2511 ((eq banner 'signature)
2512 (when (gnus-article-narrow-to-signature)
2515 (delete-region (point) (point-max))))
2517 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2518 (while (re-search-forward banner nil t)
2519 (delete-region (match-beginning 0) (match-end 0)))))
2521 (while (re-search-forward banner nil t)
2522 (delete-region (match-beginning 0) (match-end 0)))))))))
2524 (defun article-babel ()
2525 "Translate article using an online translation service."
2528 (gnus-with-article-buffer
2529 (when (article-goto-body)
2530 (let* ((start (point))
2532 (orig (buffer-substring start end))
2533 (trans (babel-as-string orig)))
2535 (narrow-to-region start end)
2536 (delete-region start end)
2539 (defun article-hide-signature (&optional arg)
2540 "Hide the signature in the current article.
2541 If given a negative prefix, always show; if given a positive prefix,
2543 (interactive (gnus-article-hidden-arg))
2544 (unless (gnus-article-check-hidden-text 'signature arg)
2547 (let ((buffer-read-only nil))
2548 (when (gnus-article-narrow-to-signature)
2549 (gnus-article-hide-text-type
2550 (point-min) (point-max) 'signature))))))
2551 (gnus-set-mode-line 'article))
2553 (defun article-strip-headers-in-body ()
2554 "Strip offensive headers from bodies."
2558 (let ((case-fold-search t))
2559 (when (looking-at "x-no-archive:")
2560 (gnus-delete-line)))))
2562 (defun article-strip-leading-blank-lines ()
2563 "Remove all blank lines from the beginning of the article."
2566 (let ((inhibit-point-motion-hooks t)
2568 (when (article-goto-body)
2569 (while (and (not (eobp))
2570 (looking-at "[ \t]*$"))
2571 (gnus-delete-line))))))
2573 (defun article-narrow-to-head ()
2574 "Narrow the buffer to the head of the message.
2575 Point is left at the beginning of the narrowed-to region."
2577 (goto-char (point-min))
2578 (if (search-forward "\n\n" nil 1)
2581 (goto-char (point-min)))
2583 (defun article-goto-body ()
2584 "Place point at the start of the body."
2585 (goto-char (point-min))
2587 ;; This variable is only bound when dealing with separate
2589 (article-goto-body-goes-to-point-min-p
2591 ((search-forward "\n\n" nil t)
2594 (goto-char (point-max))
2597 (defun article-strip-multiple-blank-lines ()
2598 "Replace consecutive blank lines with one empty line."
2601 (let ((inhibit-point-motion-hooks t)
2603 ;; First make all blank lines empty.
2605 (while (re-search-forward "^[ \t]+$" nil t)
2606 (unless (gnus-annotation-in-region-p
2607 (match-beginning 0) (match-end 0))
2608 (replace-match "" nil t)))
2609 ;; Then replace multiple empty lines with a single empty line.
2611 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2612 (unless (gnus-annotation-in-region-p
2613 (match-beginning 0) (match-end 0))
2614 (delete-region (match-beginning 1) (match-end 1)))))))
2616 (defun article-strip-leading-space ()
2617 "Remove all white space from the beginning of the lines in the article."
2620 (let ((inhibit-point-motion-hooks t)
2623 (while (re-search-forward "^[ \t]+" nil t)
2624 (replace-match "" t t)))))
2626 (defun article-strip-trailing-space ()
2627 "Remove all white space from the end of the lines in the article."
2630 (let ((inhibit-point-motion-hooks t)
2633 (while (re-search-forward "[ \t]+$" nil t)
2634 (replace-match "" t t)))))
2636 (defun article-strip-blank-lines ()
2637 "Strip leading, trailing and multiple blank lines."
2639 (article-strip-leading-blank-lines)
2640 (article-remove-trailing-blank-lines)
2641 (article-strip-multiple-blank-lines))
2643 (defun article-strip-all-blank-lines ()
2644 "Strip all blank lines."
2647 (let ((inhibit-point-motion-hooks t)
2650 (while (re-search-forward "^[ \t]*\n" nil t)
2651 (replace-match "" t t)))))
2653 (defun gnus-article-narrow-to-signature ()
2654 "Narrow to the signature; return t if a signature is found, else nil."
2655 (let ((inhibit-point-motion-hooks t))
2656 (when (gnus-article-search-signature)
2658 ;; Check whether we have some limits to what we consider
2659 ;; to be a signature.
2660 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2661 (list gnus-signature-limit)))
2663 (while (setq limit (pop limits))
2664 (if (or (and (integerp limit)
2665 (< (- (point-max) (point)) limit))
2667 (< (count-lines (point) (point-max)) limit))
2668 (and (functionp limit)
2670 (and (stringp limit)
2671 (not (re-search-forward limit nil t))))
2672 () ; This limit did not succeed.
2676 (narrow-to-region (point) (point-max))
2679 (defun gnus-article-search-signature ()
2680 "Search the current buffer for the signature separator.
2681 Put point at the beginning of the signature separator."
2682 (let ((cur (point)))
2683 (goto-char (point-max))
2684 (if (if (stringp gnus-signature-separator)
2685 (re-search-backward gnus-signature-separator nil t)
2686 (let ((seps gnus-signature-separator))
2688 (not (re-search-backward (car seps) nil t)))
2695 (defun gnus-article-hidden-arg ()
2696 "Return the current prefix arg as a number, or 0 if no prefix."
2697 (list (if current-prefix-arg
2698 (prefix-numeric-value current-prefix-arg)
2701 (defun gnus-article-check-hidden-text (type arg)
2702 "Return nil if hiding is necessary.
2703 Arg can be nil or a number. nil and positive means hide, negative
2704 means show, 0 means toggle."
2707 (let ((hide (gnus-article-hidden-text-p type)))
2713 (gnus-article-show-hidden-text type)
2716 (if (eq hide 'hidden)
2718 (gnus-article-show-hidden-text type)
2722 (defun gnus-article-hidden-text-p (type)
2723 "Say whether the current buffer contains hidden text of type TYPE."
2724 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2726 (not (get-text-property pos 'invisible))
2727 (not (get-text-property pos 'dummy-invisible)))
2729 (text-property-any (1+ pos) (point-max) 'article-type type)))
2734 (defun gnus-article-show-hidden-text (type &optional dummy)
2735 "Show all hidden text of type TYPE.
2736 Originally it is hide instead of DUMMY."
2737 (let ((buffer-read-only nil)
2738 (inhibit-point-motion-hooks t))
2739 (gnus-remove-text-properties-when
2741 (point-min) (point-max)
2742 (cons 'article-type (cons type
2743 gnus-hidden-properties)))
2744 (gnus-delete-wash-type type)))
2746 (defconst article-time-units
2747 `((year . ,(* 365.25 24 60 60))
2748 (week . ,(* 7 24 60 60))
2749 (day . ,(* 24 60 60))
2753 "Mapping from time units to seconds.")
2755 (defun gnus-article-forward-header ()
2756 "Move point to the start of the next header.
2757 If the current header is a continuation header, this can be several
2762 (if (looking-at "[ \t]+[^ \t]")
2766 (defun article-date-ut (&optional type highlight header)
2767 "Convert DATE date to universal time in the current article.
2768 If TYPE is `local', convert to local time; if it is `lapsed', output
2769 how much time has lapsed since DATE. For `lapsed', the value of
2770 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2771 should replace the \"Date:\" one, or should be added below it."
2772 (interactive (list 'ut t))
2773 (let* ((header (or header
2774 (message-fetch-field "date")
2776 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2779 ((not gnus-article-date-lapsed-new-header)
2785 (date (if (vectorp header) (mail-header-date header)
2787 (inhibit-point-motion-hooks t)
2792 (article-narrow-to-head)
2793 (when (re-search-forward tdate-regexp nil t)
2794 (setq bface (get-text-property (point-at-bol) 'face)
2795 date (or (get-text-property (point-at-bol)
2798 eface (get-text-property (1- (point-at-eol)) 'face))
2800 (when (and date (not (string= date "")))
2801 (goto-char (point-min))
2802 (let ((buffer-read-only nil))
2803 ;; Delete any old Date headers.
2804 (while (re-search-forward date-regexp nil t)
2806 (delete-region (point-at-bol)
2807 (progn (gnus-article-forward-header)
2809 (delete-region (point-at-bol)
2810 (progn (gnus-article-forward-header)
2813 (setq pos (point))))
2814 (when (and (not pos)
2815 (re-search-forward tdate-regexp nil t))
2817 (gnus-goto-char pos)
2818 (insert (article-make-date-line date (or type 'ut)))
2824 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2825 (put-text-property (match-beginning 1) (1+ (match-end 1))
2826 'original-date date)
2827 (put-text-property (match-beginning 1) (1+ (match-end 1))
2829 (put-text-property (match-beginning 2) (match-end 2)
2832 (defun article-make-date-line (date type)
2833 "Return a DATE line of TYPE."
2834 (unless (memq type '(local ut original user iso8601 lapsed english))
2835 (error "Unknown conversion type: %s" type))
2837 (let ((time (date-to-time date)))
2839 ;; Convert to the local timezone.
2841 (let ((tz (car (current-time-zone time))))
2842 (format "Date: %s %s%02d%02d" (current-time-string time)
2843 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2844 (/ (% (abs tz) 3600) 60))))
2845 ;; Convert to Universal Time.
2848 (current-time-string
2849 (let* ((e (parse-time-string date))
2850 (tm (apply 'encode-time e))
2852 (ls (- (cadr tm) (car (current-time-zone time)))))
2853 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2854 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2857 ;; Get the original date from the article.
2858 ((eq type 'original)
2859 (concat "Date: " (if (string-match "\n+$" date)
2860 (substring date 0 (match-beginning 0))
2862 ;; Let the user define the format.
2864 (let ((format (or (condition-case nil
2865 (with-current-buffer gnus-summary-buffer
2866 gnus-article-time-format)
2868 gnus-article-time-format)))
2869 (if (functionp format)
2870 (funcall format time)
2871 (concat "Date: " (format-time-string format time)))))
2874 (let ((tz (car (current-time-zone time))))
2877 (format-time-string "%Y%m%dT%H%M%S" time)
2878 (format "%s%02d%02d"
2879 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2880 (/ (% (abs tz) 3600) 60)))))
2881 ;; Do an X-Sent lapsed format.
2883 ;; If the date is seriously mangled, the timezone functions are
2884 ;; liable to bug out, so we ignore all errors.
2885 (let* ((now (current-time))
2886 (real-time (subtract-time now time))
2887 (real-sec (and real-time
2888 (+ (* (float (car real-time)) 65536)
2890 (sec (and real-time (abs real-sec)))
2900 ;; This is a bit convoluted, but basically we go
2901 ;; through the time units for years, weeks, etc,
2902 ;; and divide things to see whether that results
2903 ;; in positive answers.
2906 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2907 ;; The (remaining) seconds are too few to
2908 ;; be divided into this time unit.
2910 ;; It's big enough, so we output it.
2911 (setq sec (- sec (* num (cdr unit))))
2913 (concat (if prev ", " "") (int-to-string
2915 " " (symbol-name (car unit))
2916 (if (> num 1) "s" ""))
2918 article-time-units "")
2919 ;; If dates are odd, then it might appear like the
2920 ;; article was sent in the future.
2923 " in the future"))))))
2924 ;; Display the date in proper English
2926 (let ((dtime (decode-time time)))
2929 (number-to-string (nth 3 dtime))
2930 (let ((digit (% (nth 3 dtime) 10)))
2932 ((memq (nth 3 dtime) '(11 12 13)) "th")
2938 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2940 (number-to-string (nth 5 dtime))
2942 (format "%02d" (nth 2 dtime))
2944 (format "%02d" (nth 1 dtime)))))))
2946 (format "Date: %s (from Gnus)" date))))