1 ;;; gnus-art.el --- article mode commands for Gnus
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005 Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
33 (defvar w3m-minor-mode-map))
36 ;; Avoid the "Recursive load suspected" error in Emacs 21.1.
38 (let ((recursive-load-depth-limit 100))
51 (autoload 'gnus-msg-mail "gnus-msg" nil t)
52 (autoload 'gnus-button-mailto "gnus-msg")
53 (autoload 'gnus-button-reply "gnus-msg" nil t)
54 (autoload 'parse-time-string "parse-time" nil nil)
55 (autoload 'ansi-color-apply-on-region "ansi-color")
57 (defgroup gnus-article nil
59 :link '(custom-manual "(gnus)Article Buffer")
62 (defgroup gnus-article-treat nil
63 "Treating article parts."
64 :link '(custom-manual "(gnus)Article Hiding")
67 (defgroup gnus-article-hiding nil
68 "Hiding article parts."
69 :link '(custom-manual "(gnus)Article Hiding")
72 (defgroup gnus-article-highlight nil
73 "Article highlighting."
74 :link '(custom-manual "(gnus)Article Highlighting")
78 (defgroup gnus-article-signature nil
80 :link '(custom-manual "(gnus)Article Signature")
83 (defgroup gnus-article-headers nil
85 :link '(custom-manual "(gnus)Hiding Headers")
88 (defgroup gnus-article-washing nil
89 "Special commands on articles."
90 :link '(custom-manual "(gnus)Article Washing")
93 (defgroup gnus-article-emphasis nil
94 "Fontisizing articles."
95 :link '(custom-manual "(gnus)Article Fontisizing")
98 (defgroup gnus-article-saving nil
100 :link '(custom-manual "(gnus)Saving Articles")
101 :group 'gnus-article)
103 (defgroup gnus-article-mime nil
104 "Worshiping the MIME wonder."
105 :link '(custom-manual "(gnus)Using MIME")
106 :group 'gnus-article)
108 (defgroup gnus-article-buttons nil
109 "Pushable buttons in the article buffer."
110 :link '(custom-manual "(gnus)Article Buttons")
111 :group 'gnus-article)
113 (defgroup gnus-article-various nil
114 "Other article options."
115 :link '(custom-manual "(gnus)Misc Article")
116 :group 'gnus-article)
118 (defcustom gnus-ignored-headers
121 (concat "^" header ":"))
122 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
123 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
124 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
125 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
126 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
127 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
128 "X-Attribution" "X-Originating-IP" "Delivered-To"
129 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
130 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
131 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
132 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
133 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
134 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
135 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
136 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
137 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
138 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
139 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
140 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
141 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
142 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
143 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
144 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
145 "List-[A-Za-z]+" "X-Listprocessor-Version"
146 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
147 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
148 "X-Received" "Content-length" "X-precedence"
149 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
150 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
151 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
152 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
153 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
154 "X-Content-length" "X-Posting-Agent" "Original-Received"
155 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
156 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
157 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
158 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
159 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"))
160 "*All headers that start with this regexp will be hidden.
161 This variable can also be a list of regexps of headers to be ignored.
162 If `gnus-visible-headers' is non-nil, this variable will be ignored."
163 :type '(choice :custom-show nil
166 :group 'gnus-article-hiding)
168 (defcustom gnus-visible-headers
169 "^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:"
170 "*All headers that do not match this regexp will be hidden.
171 This variable can also be a list of regexp of headers to remain visible.
172 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
173 :type '(repeat :value-to-internal (lambda (widget value)
174 (custom-split-regexp-maybe value))
175 :match (lambda (widget value)
177 (widget-editable-list-match widget value)))
179 :group 'gnus-article-hiding)
181 (defcustom gnus-sorted-header-list
182 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
183 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
184 "*This variable is a list of regular expressions.
185 If it is non-nil, headers that match the regular expressions will
186 be placed first in the article buffer in the sequence specified by
188 :type '(repeat regexp)
189 :group 'gnus-article-hiding)
191 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
192 "Headers that are only to be displayed if they have interesting data.
193 Possible values in this list are:
195 'empty Headers with no content.
196 'newsgroups Newsgroup identical to Gnus group.
197 'to-address To identical to To-address.
198 'to-list To identical to To-list.
199 'cc-list CC identical to To-list.
200 'followup-to Followup-to identical to Newsgroups.
201 'reply-to Reply-to identical to From.
202 'date Date less than four days old.
203 'long-to To and/or Cc longer than 1024 characters.
204 'many-to Multiple To and/or Cc."
205 :type '(set (const :tag "Headers with no content." empty)
206 (const :tag "Newsgroups identical to Gnus group." newsgroups)
207 (const :tag "To identical to To-address." to-address)
208 (const :tag "To identical to To-list." to-list)
209 (const :tag "CC identical to To-list." cc-list)
210 (const :tag "Followup-to identical to Newsgroups." followup-to)
211 (const :tag "Reply-to identical to From." reply-to)
212 (const :tag "Date less than four days old." date)
213 (const :tag "To and/or Cc longer than 1024 characters." long-to)
214 (const :tag "Multiple To and/or Cc headers." many-to))
215 :group 'gnus-article-hiding)
217 (defcustom gnus-article-skip-boring nil
218 "Skip over text that is not worth reading.
219 By default, if you set this t, then Gnus will display citations and
220 signatures, but will never scroll down to show you a page consisting
221 only of boring text. Boring text is controlled by
222 `gnus-article-boring-faces'."
225 :group 'gnus-article-hiding)
227 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
228 "Regexp matching signature separator.
229 This can also be a list of regexps. In that case, it will be checked
230 from head to tail looking for a separator. Searches will be done from
231 the end of the buffer."
232 :type '(repeat string)
233 :group 'gnus-article-signature)
235 (defcustom gnus-signature-limit nil
236 "Provide a limit to what is considered a signature.
237 If it is a number, no signature may not be longer (in characters) than
238 that number. If it is a floating point number, no signature may be
239 longer (in lines) than that number. If it is a function, the function
240 will be called without any parameters, and if it returns nil, there is
241 no signature in the buffer. If it is a string, it will be used as a
242 regexp. If it matches, the text in question is not a signature.
244 This can also be a list of the above values."
245 :type '(choice (const nil)
248 (function :value fun)
249 (regexp :value ".*"))
250 :group 'gnus-article-signature)
252 (defcustom gnus-hidden-properties '(invisible t intangible t)
253 "Property list to use for hiding text."
255 :group 'gnus-article-hiding)
257 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
258 ;; frames in a session.
259 (defcustom gnus-article-x-face-command
260 (if (featurep 'xemacs)
261 (if (or (gnus-image-type-available-p 'xface)
262 (gnus-image-type-available-p 'pbm))
263 'gnus-display-x-face-in-from
264 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
265 (if (gnus-image-type-available-p 'pbm)
266 'gnus-display-x-face-in-from
267 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
269 "*String or function to be executed to display an X-Face header.
270 If it is a string, the command will be executed in a sub-shell
271 asynchronously. The compressed face will be piped to this command."
272 :type `(choice string
273 (function-item gnus-display-x-face-in-from)
277 :group 'gnus-article-washing)
279 (defcustom gnus-article-x-face-too-ugly nil
280 "Regexp matching posters whose face shouldn't be shown automatically."
281 :type '(choice regexp (const nil))
282 :group 'gnus-article-washing)
284 (defcustom gnus-article-banner-alist nil
285 "Banner alist for stripping.
287 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
289 :type '(repeat (cons symbol regexp))
290 :group 'gnus-article-washing)
292 (gnus-define-group-parameter
295 "Alist of regexps (to match group names) and banner."
296 :variable-group gnus-article-washing
298 '(choice :tag "Banner"
300 (const :tag "Remove signature" signature)
301 (symbol :tag "Item in `gnus-article-banner-alist'" none)
303 (const :tag "None" nil))
305 "If non-nil, specify how to remove `banners' from articles.
307 Symbol `signature' means to remove signatures delimited by
308 `gnus-signature-separator'. Any other symbol is used to look up a
309 regular expression to match the banner in `gnus-article-banner-alist'.
310 A string is used as a regular expression to match the banner
313 (defcustom gnus-article-address-banner-alist nil
314 "Alist of mail addresses and banners.
315 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
316 to match a mail address in the From: header, BANNER is one of a symbol
317 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
318 If ADDRESS matches author's mail address, it will remove things like
319 advertisements. For example:
321 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
325 (regexp :tag "Address")
326 (choice :tag "Banner" :value nil
327 (const :tag "Remove signature" signature)
328 (symbol :tag "Item in `gnus-article-banner-alist'" none)
330 (const :tag "None" nil))))
332 :group 'gnus-article-washing)
334 (defmacro gnus-emphasis-custom-with-format (&rest body)
336 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
337 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
340 (defun gnus-emphasis-custom-value-to-external (value)
341 (gnus-emphasis-custom-with-format
342 (if (consp (car value))
343 (list (format format (car (car value)) (cdr (car value)))
345 (if (nth 1 value) 2 3)
349 (defun gnus-emphasis-custom-value-to-internal (value)
350 (gnus-emphasis-custom-with-format
351 (let ((regexp (concat "\\`"
352 (format (regexp-quote format)
353 "\\([^()]+\\)" "\\([^()]+\\)")
356 (if (string-match regexp (setq pattern (car value)))
357 (list (cons (match-string 1 pattern) (match-string 2 pattern))
362 (defcustom gnus-emphasis-alist
364 '(("\\*" "\\*" bold nil 2)
367 ("_/" "/_" underline-italic)
368 ("_\\*" "\\*_" underline-bold)
369 ("\\*/" "/\\*" bold-italic)
370 ("_\\*/" "/\\*_" underline-bold-italic))))
372 (gnus-emphasis-custom-with-format
373 (mapcar (lambda (spec)
374 (list (format format (car spec) (cadr spec))
377 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
379 '(;; I've never seen anyone use this strikethru convention whereas I've
380 ;; several times seen it triggered by normal text. --Stef
381 ;; Miles suggests that this form is sometimes used but for italics,
382 ;; so maybe we should map it to `italic'.
383 ;; ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
384 ;; 2 3 gnus-emphasis-strikethru)
385 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
386 2 3 gnus-emphasis-underline))))
387 "*Alist that says how to fontify certain phrases.
388 Each item looks like this:
390 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
392 The first element is a regular expression to be matched. The second
393 is a number that says what regular expression grouping used to find
394 the entire emphasized word. The third is a number that says what
395 regexp grouping should be displayed and highlighted. The fourth
396 is the face used for highlighting."
400 :format "%[Customizing Style%]\n%v"
402 (group :tag "Default"
403 :value ("" 0 0 default)
406 (let ((value (widget-get
407 (cadr (widget-get (widget-get widget :parent)
410 (if (not (eq (nth 2 value) 'default))
414 (gnus-emphasis-custom-value-to-external value))))
415 (widget-group-value-create widget))
417 (integer :format "Match group: %v")
418 (integer :format "Emphasize group: %v")
421 :value (("_" . "_") nil default)
423 (regexp :format "Start regexp: %v")
424 (regexp :format "End regexp: %v"))
425 (boolean :format "Show start and end patterns: %[%v%]\n"
426 :on " On " :off " Off ")
428 :get (lambda (symbol)
429 (mapcar 'gnus-emphasis-custom-value-to-internal
430 (default-value symbol)))
431 :set (lambda (symbol value)
432 (set-default symbol (mapcar 'gnus-emphasis-custom-value-to-external
434 :group 'gnus-article-emphasis)
436 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
437 "A regexp to describe whitespace which should not be emphasized.
438 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
439 The former avoids underlining of leading and trailing whitespace,
440 and the latter avoids underlining any whitespace at all."
442 :group 'gnus-article-emphasis
445 (defface gnus-emphasis-bold '((t (:bold t)))
446 "Face used for displaying strong emphasized text (*word*)."
447 :group 'gnus-article-emphasis)
449 (defface gnus-emphasis-italic '((t (:italic t)))
450 "Face used for displaying italic emphasized text (/word/)."
451 :group 'gnus-article-emphasis)
453 (defface gnus-emphasis-underline '((t (:underline t)))
454 "Face used for displaying underlined emphasized text (_word_)."
455 :group 'gnus-article-emphasis)
457 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
458 "Face used for displaying underlined bold emphasized text (_*word*_)."
459 :group 'gnus-article-emphasis)
461 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
462 "Face used for displaying underlined italic emphasized text (_/word/_)."
463 :group 'gnus-article-emphasis)
465 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
466 "Face used for displaying bold italic emphasized text (/*word*/)."
467 :group 'gnus-article-emphasis)
469 (defface gnus-emphasis-underline-bold-italic
470 '((t (:bold t :italic t :underline t)))
471 "Face used for displaying underlined bold italic emphasized text.
472 Example: (_/*word*/_)."
473 :group 'gnus-article-emphasis)
475 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
476 '((t (:strikethru t)))
477 '((t (:strike-through t))))
478 "Face used for displaying strike-through text (-word-)."
479 :group 'gnus-article-emphasis)
481 (defface gnus-emphasis-highlight-words
482 '((t (:background "black" :foreground "yellow")))
483 "Face used for displaying highlighted words."
484 :group 'gnus-article-emphasis)
486 (defcustom gnus-article-time-format "%a, %d %b %Y %T %Z"
487 "Format for display of Date headers in article bodies.
488 See `format-time-string' for the possible values.
490 The variable can also be function, which should return a complete Date
491 header. The function is called with one argument, the time, which can
492 be fed to `format-time-string'."
493 :type '(choice string function)
494 :link '(custom-manual "(gnus)Article Date")
495 :group 'gnus-article-washing)
497 (defcustom gnus-save-all-headers t
498 "*If non-nil, don't remove any headers before saving."
499 :group 'gnus-article-saving
502 (defcustom gnus-prompt-before-saving 'always
503 "*This variable says how much prompting is to be done when saving articles.
504 If it is nil, no prompting will be done, and the articles will be
505 saved to the default files. If this variable is `always', each and
506 every article that is saved will be preceded by a prompt, even when
507 saving large batches of articles. If this variable is neither nil not
508 `always', there the user will be prompted once for a file name for
509 each invocation of the saving commands."
510 :group 'gnus-article-saving
511 :type '(choice (item always)
512 (item :tag "never" nil)
513 (sexp :tag "once" :format "%t\n" :value t)))
515 (defcustom gnus-saved-headers gnus-visible-headers
516 "Headers to keep if `gnus-save-all-headers' is nil.
517 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
518 If that variable is nil, however, all headers that match this regexp
519 will be kept while the rest will be deleted before saving."
520 :group 'gnus-article-saving
523 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
524 "A function to save articles in your favourite format.
525 The function must be interactively callable (in other words, it must
526 be an Emacs command).
528 Gnus provides the following functions:
530 * gnus-summary-save-in-rmail (Rmail format)
531 * gnus-summary-save-in-mail (Unix mail format)
532 * gnus-summary-save-in-folder (MH folder)
533 * gnus-summary-save-in-file (article format)
534 * gnus-summary-save-body-in-file (article body)
535 * gnus-summary-save-in-vm (use VM's folder format)
536 * gnus-summary-write-to-file (article format -- overwrite)."
537 :group 'gnus-article-saving
538 :type '(radio (function-item gnus-summary-save-in-rmail)
539 (function-item gnus-summary-save-in-mail)
540 (function-item gnus-summary-save-in-folder)
541 (function-item gnus-summary-save-in-file)
542 (function-item gnus-summary-save-body-in-file)
543 (function-item gnus-summary-save-in-vm)
544 (function-item gnus-summary-write-to-file)))
546 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
547 "A function generating a file name to save articles in Rmail format.
548 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
549 :group 'gnus-article-saving
552 (defcustom gnus-mail-save-name 'gnus-plain-save-name
553 "A function generating a file name to save articles in Unix mail format.
554 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
555 :group 'gnus-article-saving
558 (defcustom gnus-folder-save-name 'gnus-folder-save-name
559 "A function generating a file name to save articles in MH folder.
560 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
561 :group 'gnus-article-saving
564 (defcustom gnus-file-save-name 'gnus-numeric-save-name
565 "A function generating a file name to save articles in article format.
566 The function is called with NEWSGROUP, HEADERS, and optional
568 :group 'gnus-article-saving
571 (defcustom gnus-split-methods
572 '((gnus-article-archive-name)
573 (gnus-article-nndoc-name))
574 "*Variable used to suggest where articles are to be saved.
575 For instance, if you would like to save articles related to Gnus in
576 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
577 you could set this variable to something like:
579 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
580 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
582 This variable is an alist where the key is the match and the
583 value is a list of possible files to save in if the match is
586 If the match is a string, it is used as a regexp match on the
587 article. If the match is a symbol, that symbol will be funcalled
588 from the buffer of the article to be saved with the newsgroup as
589 the parameter. If it is a list, it will be evaled in the same
592 If this form or function returns a string, this string will be
593 used as a possible file name; and if it returns a non-nil list,
594 that list will be used as possible file names."
595 :group 'gnus-article-saving
596 :type '(repeat (choice (list :value (fun) function)
597 (cons :value ("" "") regexp (repeat string))
600 (defcustom gnus-page-delimiter "^\^L"
601 "*Regexp describing what to use as article page delimiters.
602 The default value is \"^\^L\", which is a form linefeed at the
603 beginning of a line."
605 :group 'gnus-article-various)
607 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
608 "*The format specification for the article mode line.
609 See `gnus-summary-mode-line-format' for a closer description.
611 The following additional specs are available:
613 %w The article washing status.
614 %m The number of MIME parts in the article."
616 :group 'gnus-article-various)
618 (defcustom gnus-article-mode-hook nil
619 "*A hook for Gnus article mode."
621 :group 'gnus-article-various)
623 (when (featurep 'xemacs)
624 ;; Extracted from gnus-xmas-define in order to preserve user settings
625 (when (fboundp 'turn-off-scroll-in-place)
626 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
627 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
628 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
630 (defcustom gnus-article-menu-hook nil
631 "*Hook run after the creation of the article mode menu."
633 :group 'gnus-article-various)
635 (defcustom gnus-article-prepare-hook nil
636 "*A hook called after an article has been prepared in the article buffer."
638 :group 'gnus-article-various)
640 (defcustom gnus-copy-article-ignored-headers nil
641 "List of headers to be removed when copying an article.
642 Each element is a regular expression."
643 :version "23.0" ;; No Gnus
644 :type '(repeat regexp)
645 :group 'gnus-article-various)
647 (make-obsolete-variable 'gnus-article-hide-pgp-hook
648 "This variable is obsolete in Gnus 5.10.")
650 (defcustom gnus-article-button-face 'bold
651 "Face used for highlighting buttons in the article buffer.
653 An article button is a piece of text that you can activate by pressing
654 `RET' or `mouse-2' above it."
656 :group 'gnus-article-buttons)
658 (defcustom gnus-article-mouse-face 'highlight
659 "Face used for mouse highlighting in the article buffer.
661 Article buttons will be displayed in this face when the cursor is
664 :group 'gnus-article-buttons)
666 (defcustom gnus-signature-face 'gnus-signature
667 "Face used for highlighting a signature in the article buffer.
668 Obsolete; use the face `gnus-signature' for customizations instead."
670 :group 'gnus-article-highlight
671 :group 'gnus-article-signature)
673 (defface gnus-signature
676 "Face used for highlighting a signature in the article buffer."
677 :group 'gnus-article-highlight
678 :group 'gnus-article-signature)
679 ;; backward-compatibility alias
680 (put 'gnus-signature-face 'face-alias 'gnus-signature)
682 (defface gnus-header-from
685 (:foreground "spring green"))
688 (:foreground "red3"))
691 "Face used for displaying from headers."
692 :group 'gnus-article-headers
693 :group 'gnus-article-highlight)
694 ;; backward-compatibility alias
695 (put 'gnus-header-from-face 'face-alias 'gnus-header-from)
697 (defface gnus-header-subject
700 (:foreground "SeaGreen3"))
703 (:foreground "red4"))
705 (:bold t :italic t)))
706 "Face used for displaying subject headers."
707 :group 'gnus-article-headers
708 :group 'gnus-article-highlight)
709 ;; backward-compatibility alias
710 (put 'gnus-header-subject-face 'face-alias 'gnus-header-subject)
712 (defface gnus-header-newsgroups
715 (:foreground "yellow" :italic t))
718 (:foreground "MidnightBlue" :italic t))
721 "Face used for displaying newsgroups headers.
722 In the default setup this face is only used for crossposted
724 :group 'gnus-article-headers
725 :group 'gnus-article-highlight)
726 ;; backward-compatibility alias
727 (put 'gnus-header-newsgroups-face 'face-alias 'gnus-header-newsgroups)
729 (defface gnus-header-name
732 (:foreground "SeaGreen"))
735 (:foreground "maroon"))
738 "Face used for displaying header names."
739 :group 'gnus-article-headers
740 :group 'gnus-article-highlight)
741 ;; backward-compatibility alias
742 (put 'gnus-header-name-face 'face-alias 'gnus-header-name)
744 (defface gnus-header-content
747 (:foreground "forest green" :italic t))
750 (:foreground "indianred4" :italic t))
752 (:italic t))) "Face used for displaying header content."
753 :group 'gnus-article-headers
754 :group 'gnus-article-highlight)
755 ;; backward-compatibility alias
756 (put 'gnus-header-content-face 'face-alias 'gnus-header-content)
758 (defcustom gnus-header-face-alist
759 '(("From" nil gnus-header-from)
760 ("Subject" nil gnus-header-subject)
761 ("Newsgroups:.*," nil gnus-header-newsgroups)
762 ("" gnus-header-name gnus-header-content))
763 "*Controls highlighting of article headers.
765 An alist of the form (HEADER NAME CONTENT).
767 HEADER is a regular expression which should match the name of a
768 header and NAME and CONTENT are either face names or nil.
770 The name of each header field will be displayed using the face
771 specified by the first element in the list where HEADER matches
772 the header name and NAME is non-nil. Similarly, the content will
773 be displayed by the first non-nil matching CONTENT face."
774 :group 'gnus-article-headers
775 :group 'gnus-article-highlight
776 :type '(repeat (list (regexp :tag "Header")
778 (item :tag "skip" nil)
779 (face :value default))
780 (choice :tag "Content"
781 (item :tag "skip" nil)
782 (face :value default)))))
784 (defcustom gnus-article-decode-hook
785 '(article-decode-charset article-decode-encoded-words
786 article-decode-group-name article-decode-idna-rhs)
787 "*Hook run to decode charsets in articles."
788 :group 'gnus-article-headers
791 (defcustom gnus-display-mime-function 'gnus-display-mime
792 "Function to display MIME articles."
793 :group 'gnus-article-mime
796 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
797 "Function used to decode headers.")
799 (defvar gnus-article-dumbquotes-map
819 "Table for MS-to-Latin1 translation.")
821 (defcustom gnus-ignored-mime-types nil
822 "List of MIME types that should be ignored by Gnus."
824 :group 'gnus-article-mime
825 :type '(repeat regexp))
827 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
828 "List of MIME types that should not be given buttons when rendered inline.
829 See also `gnus-buttonized-mime-types' which may override this variable.
830 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
832 :group 'gnus-article-mime
833 :type '(repeat regexp))
835 (defcustom gnus-buttonized-mime-types nil
836 "List of MIME types that should be given buttons when rendered inline.
837 If set, this variable overrides `gnus-unbuttonized-mime-types'.
838 To see e.g. security buttons you could set this to
839 `(\"multipart/signed\")'.
840 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
842 :group 'gnus-article-mime
843 :type '(repeat regexp))
845 (defcustom gnus-inhibit-mime-unbuttonizing nil
846 "If non-nil, all MIME parts get buttons.
847 When nil (the default value), then some MIME parts do not get buttons,
848 as described by the variables `gnus-buttonized-mime-types' and
849 `gnus-unbuttonized-mime-types'."
851 :group 'gnus-article-mime
854 (defcustom gnus-body-boundary-delimiter "_"
855 "String used to delimit header and body.
856 This variable is used by `gnus-article-treat-body-boundary' which can
857 be controlled by `gnus-treat-body-boundary'."
859 :group 'gnus-article-various
860 :type '(choice (item :tag "None" :value nil)
863 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
865 "Defines the location of the faces database.
866 For information on obtaining this database of pretty pictures, please
867 see http://www.cs.indiana.edu/picons/ftp/index.html"
869 :type '(repeat directory)
870 :link '(url-link :tag "download"
871 "http://www.cs.indiana.edu/picons/ftp/index.html")
872 :link '(custom-manual "(gnus)Picons")
875 (defun gnus-picons-installed-p ()
876 "Say whether picons are installed on your machine."
877 (let ((installed nil))
878 (dolist (database gnus-picon-databases)
879 (when (file-exists-p database)
883 (defcustom gnus-article-mime-part-function nil
884 "Function called with a MIME handle as the argument.
885 This is meant for people who want to do something automatic based
886 on parts -- for instance, adding Vcard info to a database."
887 :group 'gnus-article-mime
888 :type '(choice (const nil)
891 (defcustom gnus-mime-multipart-functions nil
892 "An alist of MIME types to functions to display them."
894 :group 'gnus-article-mime
895 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
897 (defcustom gnus-article-date-lapsed-new-header nil
898 "Whether the X-Sent and Date headers can coexist.
899 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
900 either replace the old \"Date:\" header (if this variable is nil), or
901 be added below it (otherwise)."
903 :group 'gnus-article-headers
906 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
907 "Function called with a MIME handle as the argument.
908 This is meant for people who want to view first matched part.
909 For `undisplayed-alternative' (default), the first undisplayed
910 part or alternative part is used. For `undisplayed', the first
911 undisplayed part is used. For a function, the first part which
912 the function return t is used. For nil, the first part is
915 :group 'gnus-article-mime
917 (item :tag "first" :value nil)
918 (item :tag "undisplayed" :value undisplayed)
919 (item :tag "undisplayed or alternative"
920 :value undisplayed-alternative)
923 (defcustom gnus-mime-action-alist
924 '(("save to file" . gnus-mime-save-part)
925 ("save and strip" . gnus-mime-save-part-and-strip)
926 ("replace with file" . gnus-mime-replace-part)
927 ("delete part" . gnus-mime-delete-part)
928 ("display as text" . gnus-mime-inline-part)
929 ("view the part" . gnus-mime-view-part)
930 ("pipe to command" . gnus-mime-pipe-part)
931 ("toggle display" . gnus-article-press-button)
932 ("toggle display" . gnus-article-view-part-as-charset)
933 ("view as type" . gnus-mime-view-part-as-type)
934 ("view internally" . gnus-mime-view-part-internally)
935 ("view externally" . gnus-mime-view-part-externally))
936 "An alist of actions that run on the MIME attachment."
937 :group 'gnus-article-mime
938 :type '(repeat (cons (string :tag "name")
941 (defcustom gnus-auto-select-part 1
942 "Advance to next MIME part when deleting or stripping parts.
944 When 0, point will be placed on the same part as before. When
945 positive (negative), move point forward (backwards) this many
946 parts. When nil, redisplay article."
947 :version "23.0" ;; No Gnus
948 :group 'gnus-article-mime
949 :type '(choice (const nil :tag "Redisplay article.")
950 (const 1 :tag "Next part.")
951 (const 0 :tag "Current part.")
955 ;;; The treatment variables
958 (defvar gnus-part-display-hook nil
959 "Hook called on parts that are to receive treatment.")
961 (defvar gnus-article-treat-custom
962 '(choice (const :tag "Off" nil)
964 (const :tag "Header" head)
965 (const :tag "Last" last)
966 (integer :tag "Less")
967 (repeat :tag "Groups" regexp)
968 (sexp :tag "Predicate")))
970 (defvar gnus-article-treat-head-custom
971 '(choice (const :tag "Off" nil)
972 (const :tag "Header" head)))
974 (defvar gnus-article-treat-types '("text/plain")
977 (defvar gnus-inhibit-treatment nil
978 "Whether to inhibit treatment.")
980 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
981 "Highlight the signature.
982 Valid values are nil, t, `head', `last', an integer or a predicate.
983 See Info node `(gnus)Customizing Articles'."
984 :group 'gnus-article-treat
985 :link '(custom-manual "(gnus)Customizing Articles")
986 :type gnus-article-treat-custom)
987 (put 'gnus-treat-highlight-signature 'highlight t)
989 (defcustom gnus-treat-buttonize 100000
991 Valid values are nil, t, `head', `last', an integer or a predicate.
992 See Info node `(gnus)Customizing Articles'."
993 :group 'gnus-article-treat
994 :link '(custom-manual "(gnus)Customizing Articles")
995 :type gnus-article-treat-custom)
996 (put 'gnus-treat-buttonize 'highlight t)
998 (defcustom gnus-treat-buttonize-head 'head
999 "Add buttons to the head.
1000 Valid values are nil, t, `head', `last', an integer or a predicate.
1001 See Info node `(gnus)Customizing Articles' for details."
1002 :group 'gnus-article-treat
1003 :link '(custom-manual "(gnus)Customizing Articles")
1004 :type gnus-article-treat-head-custom)
1005 (put 'gnus-treat-buttonize-head 'highlight t)
1007 (defcustom gnus-treat-emphasize
1008 (and (or window-system
1012 Valid values are nil, t, `head', `last', an integer or a predicate.
1013 See Info node `(gnus)Customizing Articles' for details."
1014 :group 'gnus-article-treat
1015 :link '(custom-manual "(gnus)Customizing Articles")
1016 :type gnus-article-treat-custom)
1017 (put 'gnus-treat-emphasize 'highlight t)
1019 (defcustom gnus-treat-strip-cr nil
1020 "Remove carriage returns.
1021 Valid values are nil, t, `head', `last', an integer or a predicate.
1022 See Info node `(gnus)Customizing Articles' for details."
1024 :group 'gnus-article-treat
1025 :link '(custom-manual "(gnus)Customizing Articles")
1026 :type gnus-article-treat-custom)
1028 (defcustom gnus-treat-unsplit-urls nil
1029 "Remove newlines from within URLs.
1030 Valid values are nil, t, `head', `last', an integer or a predicate.
1031 See Info node `(gnus)Customizing Articles' for details."
1033 :group 'gnus-article-treat
1034 :link '(custom-manual "(gnus)Customizing Articles")
1035 :type gnus-article-treat-custom)
1037 (defcustom gnus-treat-leading-whitespace nil
1038 "Remove leading whitespace in headers.
1039 Valid values are nil, t, `head', `last', an integer or a predicate.
1040 See Info node `(gnus)Customizing Articles' for details."
1042 :group 'gnus-article-treat
1043 :link '(custom-manual "(gnus)Customizing Articles")
1044 :type gnus-article-treat-custom)
1046 (defcustom gnus-treat-hide-headers 'head
1048 Valid values are nil, t, `head', `last', an integer or a predicate.
1049 See Info node `(gnus)Customizing Articles' for details."
1050 :group 'gnus-article-treat
1051 :link '(custom-manual "(gnus)Customizing Articles")
1052 :type gnus-article-treat-head-custom)
1054 (defcustom gnus-treat-hide-boring-headers nil
1055 "Hide boring headers.
1056 Valid values are nil, t, `head', `last', an integer or a predicate.
1057 See Info node `(gnus)Customizing Articles' for details."
1058 :group 'gnus-article-treat
1059 :link '(custom-manual "(gnus)Customizing Articles")
1060 :type gnus-article-treat-head-custom)
1062 (defcustom gnus-treat-hide-signature nil
1063 "Hide the signature.
1064 Valid values are nil, t, `head', `last', an integer or a predicate.
1065 See Info node `(gnus)Customizing Articles' for details."
1066 :group 'gnus-article-treat
1067 :link '(custom-manual "(gnus)Customizing Articles")
1068 :type gnus-article-treat-custom)
1070 (defcustom gnus-treat-fill-article nil
1072 Valid values are nil, t, `head', `last', an integer or a predicate.
1073 See Info node `(gnus)Customizing Articles' for details."
1074 :group 'gnus-article-treat
1075 :link '(custom-manual "(gnus)Customizing Articles")
1076 :type gnus-article-treat-custom)
1078 (defcustom gnus-treat-hide-citation nil
1080 Valid values are nil, t, `head', `last', an integer or a predicate.
1081 See Info node `(gnus)Customizing Articles' for details."
1082 :group 'gnus-article-treat
1083 :link '(custom-manual "(gnus)Customizing Articles")
1084 :type gnus-article-treat-custom)
1086 (defcustom gnus-treat-hide-citation-maybe nil
1088 Valid values are nil, t, `head', `last', an integer or a predicate.
1089 See Info node `(gnus)Customizing Articles' for details."
1090 :group 'gnus-article-treat
1091 :link '(custom-manual "(gnus)Customizing Articles")
1092 :type gnus-article-treat-custom)
1094 (defcustom gnus-treat-strip-list-identifiers 'head
1095 "Strip list identifiers from `gnus-list-identifiers`.
1096 Valid values are nil, t, `head', `last', an integer or a predicate.
1097 See Info node `(gnus)Customizing Articles' for details."
1099 :group 'gnus-article-treat
1100 :link '(custom-manual "(gnus)Customizing Articles")
1101 :type gnus-article-treat-custom)
1103 (make-obsolete-variable 'gnus-treat-strip-pgp
1104 "This option is obsolete in Gnus 5.10.")
1106 (defcustom gnus-treat-strip-pem nil
1107 "Strip PEM signatures.
1108 Valid values are nil, t, `head', `last', an integer or a predicate.
1109 See Info node `(gnus)Customizing Articles' for details."
1110 :group 'gnus-article-treat
1111 :link '(custom-manual "(gnus)Customizing Articles")
1112 :type gnus-article-treat-custom)
1114 (defcustom gnus-treat-strip-banner t
1115 "Strip banners from articles.
1116 The banner to be stripped is specified in the `banner' group parameter.
1117 Valid values are nil, t, `head', `last', an integer or a predicate.
1118 See Info node `(gnus)Customizing Articles' for details."
1119 :group 'gnus-article-treat
1120 :link '(custom-manual "(gnus)Customizing Articles")
1121 :type gnus-article-treat-custom)
1123 (defcustom gnus-treat-highlight-headers 'head
1124 "Highlight the headers.
1125 Valid values are nil, t, `head', `last', an integer or a predicate.
1126 See Info node `(gnus)Customizing Articles' for details."
1127 :group 'gnus-article-treat
1128 :link '(custom-manual "(gnus)Customizing Articles")
1129 :type gnus-article-treat-head-custom)
1130 (put 'gnus-treat-highlight-headers 'highlight t)
1132 (defcustom gnus-treat-highlight-citation t
1133 "Highlight cited text.
1134 Valid values are nil, t, `head', `last', an integer or a predicate.
1135 See Info node `(gnus)Customizing Articles' for details."
1136 :group 'gnus-article-treat
1137 :link '(custom-manual "(gnus)Customizing Articles")
1138 :type gnus-article-treat-custom)
1139 (put 'gnus-treat-highlight-citation 'highlight t)
1141 (defcustom gnus-treat-date-ut nil
1142 "Display the Date in UT (GMT).
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-head-custom)
1149 (defcustom gnus-treat-date-local nil
1150 "Display the Date in the local timezone.
1151 Valid values are nil, t, `head', `last', an integer or a predicate.
1152 See Info node `(gnus)Customizing Articles' for details."
1153 :group 'gnus-article-treat
1154 :link '(custom-manual "(gnus)Customizing Articles")
1155 :type gnus-article-treat-head-custom)
1157 (defcustom gnus-treat-date-english nil
1158 "Display the Date in a format that can be read aloud in English.
1159 Valid values are nil, t, `head', `last', an integer or a predicate.
1160 See Info node `(gnus)Customizing Articles' for details."
1162 :group 'gnus-article-treat
1163 :link '(custom-manual "(gnus)Customizing Articles")
1164 :type gnus-article-treat-head-custom)
1166 (defcustom gnus-treat-date-lapsed nil
1167 "Display the Date header in a way that says how much time has elapsed.
1168 Valid values are nil, t, `head', `last', an integer or a predicate.
1169 See Info node `(gnus)Customizing Articles' for details."
1170 :group 'gnus-article-treat
1171 :link '(custom-manual "(gnus)Customizing Articles")
1172 :type gnus-article-treat-head-custom)
1174 (defcustom gnus-treat-date-original nil
1175 "Display the date in the original timezone.
1176 Valid values are nil, t, `head', `last', an integer or a predicate.
1177 See Info node `(gnus)Customizing Articles' for details."
1178 :group 'gnus-article-treat
1179 :link '(custom-manual "(gnus)Customizing Articles")
1180 :type gnus-article-treat-head-custom)
1182 (defcustom gnus-treat-date-iso8601 nil
1183 "Display the date in the ISO8601 format.
1184 Valid values are nil, t, `head', `last', an integer or a predicate.
1185 See Info node `(gnus)Customizing Articles' for details."
1187 :group 'gnus-article-treat
1188 :link '(custom-manual "(gnus)Customizing Articles")
1189 :type gnus-article-treat-head-custom)
1191 (defcustom gnus-treat-date-user-defined nil
1192 "Display the date in a user-defined format.
1193 The format is defined by the `gnus-article-time-format' variable.
1194 Valid values are nil, t, `head', `last', an integer or a predicate.
1195 See Info node `(gnus)Customizing Articles' for details."
1196 :group 'gnus-article-treat
1197 :link '(custom-manual "(gnus)Customizing Articles")
1198 :type gnus-article-treat-head-custom)
1200 (defcustom gnus-treat-strip-headers-in-body t
1201 "Strip the X-No-Archive header line from the beginning of the body.
1202 Valid values are nil, t, `head', `last', an integer or a predicate.
1203 See Info node `(gnus)Customizing Articles' for details."
1205 :group 'gnus-article-treat
1206 :link '(custom-manual "(gnus)Customizing Articles")
1207 :type gnus-article-treat-custom)
1209 (defcustom gnus-treat-strip-trailing-blank-lines nil
1210 "Strip trailing blank lines.
1211 Valid values are nil, t, `head', `last', an integer or a predicate.
1212 See Info node `(gnus)Customizing Articles' for details."
1213 :group 'gnus-article-treat
1214 :link '(custom-manual "(gnus)Customizing Articles")
1215 :type gnus-article-treat-custom)
1217 (defcustom gnus-treat-strip-leading-blank-lines nil
1218 "Strip leading blank lines.
1219 Valid values are nil, t, `head', `last', an integer or a predicate.
1220 See Info node `(gnus)Customizing Articles' for details."
1221 :group 'gnus-article-treat
1222 :link '(custom-manual "(gnus)Customizing Articles")
1223 :type gnus-article-treat-custom)
1225 (defcustom gnus-treat-strip-multiple-blank-lines nil
1226 "Strip multiple blank lines.
1227 Valid values are nil, t, `head', `last', an integer or a predicate.
1228 See Info node `(gnus)Customizing Articles' for details."
1229 :group 'gnus-article-treat
1230 :link '(custom-manual "(gnus)Customizing Articles")
1231 :type gnus-article-treat-custom)
1233 (defcustom gnus-treat-unfold-headers 'head
1234 "Unfold folded header lines.
1235 Valid values are nil, t, `head', `last', an integer or a predicate.
1236 See Info node `(gnus)Customizing Articles' for details."
1238 :group 'gnus-article-treat
1239 :link '(custom-manual "(gnus)Customizing Articles")
1240 :type gnus-article-treat-custom)
1242 (defcustom gnus-treat-fold-headers nil
1244 Valid values are nil, t, `head', `last', an integer or a predicate.
1245 See Info node `(gnus)Customizing Articles' for details."
1247 :group 'gnus-article-treat
1248 :link '(custom-manual "(gnus)Customizing Articles")
1249 :type gnus-article-treat-custom)
1251 (defcustom gnus-treat-fold-newsgroups 'head
1252 "Fold the Newsgroups and Followup-To headers.
1253 Valid values are nil, t, `head', `last', an integer or a predicate.
1254 See Info node `(gnus)Customizing Articles' for details."
1256 :group 'gnus-article-treat
1257 :link '(custom-manual "(gnus)Customizing Articles")
1258 :type gnus-article-treat-custom)
1260 (defcustom gnus-treat-overstrike t
1261 "Treat overstrike highlighting.
1262 Valid values are nil, t, `head', `last', an integer or a predicate.
1263 See Info node `(gnus)Customizing Articles' for details."
1264 :group 'gnus-article-treat
1265 :link '(custom-manual "(gnus)Customizing Articles")
1266 :type gnus-article-treat-custom)
1267 (put 'gnus-treat-overstrike 'highlight t)
1269 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1270 "Treat ANSI SGR control sequences.
1271 Valid values are nil, t, `head', `last', an integer or a predicate.
1272 See Info node `(gnus)Customizing Articles' for details."
1273 :group 'gnus-article-treat
1274 :link '(custom-manual "(gnus)Customizing Articles")
1275 :type gnus-article-treat-custom)
1277 (make-obsolete-variable 'gnus-treat-display-xface
1278 'gnus-treat-display-x-face)
1280 (defcustom gnus-treat-display-x-face
1281 (and (not noninteractive)
1282 (or (and (fboundp 'image-type-available-p)
1283 (image-type-available-p 'xbm)
1284 (string-match "^0x" (shell-command-to-string "uncompface"))
1285 (executable-find "icontopbm"))
1286 (and (featurep 'xemacs)
1289 "Display X-Face headers.
1290 Valid values are nil, t, `head', `last', an integer or a predicate.
1291 See Info node `(gnus)Customizing Articles' and Info node
1292 `(gnus)X-Face' for details."
1293 :group 'gnus-article-treat
1295 :link '(custom-manual "(gnus)Customizing Articles")
1296 :link '(custom-manual "(gnus)X-Face")
1297 :type gnus-article-treat-head-custom
1298 :set (lambda (symbol value)
1301 (cond ((or (boundp symbol) (get symbol 'saved-value))
1303 ((boundp 'gnus-treat-display-xface)
1305 ** gnus-treat-display-xface is an obsolete variable;\
1306 use gnus-treat-display-x-face instead")
1307 (default-value 'gnus-treat-display-xface))
1308 ((get 'gnus-treat-display-xface 'saved-value)
1310 ** gnus-treat-display-xface is an obsolete variable;\
1311 use gnus-treat-display-x-face instead")
1312 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1315 (put 'gnus-treat-display-x-face 'highlight t)
1317 (defcustom gnus-treat-display-face
1318 (and (not noninteractive)
1319 (or (and (fboundp 'image-type-available-p)
1320 (image-type-available-p 'png))
1321 (and (featurep 'xemacs)
1324 "Display Face headers.
1325 Valid values are nil, t, `head', `last', an integer or a predicate.
1326 See Info node `(gnus)Customizing Articles' and Info node
1327 `(gnus)X-Face' for details."
1328 :group 'gnus-article-treat
1330 :link '(custom-manual "(gnus)Customizing Articles")
1331 :link '(custom-manual "(gnus)X-Face")
1332 :type gnus-article-treat-head-custom)
1333 (put 'gnus-treat-display-face 'highlight t)
1335 (defcustom gnus-treat-display-smileys
1336 (if (or (and (featurep 'xemacs)
1338 (and (fboundp 'image-type-available-p)
1339 (image-type-available-p 'pbm)))
1342 Valid values are nil, t, `head', `last', an integer or a predicate.
1343 See Info node `(gnus)Customizing Articles' and Info node
1344 `(gnus)Smileys' for details."
1345 :group 'gnus-article-treat
1347 :link '(custom-manual "(gnus)Customizing Articles")
1348 :link '(custom-manual "(gnus)Smileys")
1349 :type gnus-article-treat-custom)
1350 (put 'gnus-treat-display-smileys 'highlight t)
1352 (defcustom gnus-treat-from-picon
1353 (if (and (gnus-image-type-available-p 'xpm)
1354 (gnus-picons-installed-p))
1356 "Display picons in the From header.
1357 Valid values are nil, t, `head', `last', an integer or a predicate.
1358 See Info node `(gnus)Customizing Articles' and Info node
1359 `(gnus)Picons' for details."
1361 :group 'gnus-article-treat
1363 :link '(custom-manual "(gnus)Customizing Articles")
1364 :link '(custom-manual "(gnus)Picons")
1365 :type gnus-article-treat-head-custom)
1366 (put 'gnus-treat-from-picon 'highlight t)
1368 (defcustom gnus-treat-mail-picon
1369 (if (and (gnus-image-type-available-p 'xpm)
1370 (gnus-picons-installed-p))
1372 "Display picons in To and Cc headers.
1373 Valid values are nil, t, `head', `last', an integer or a predicate.
1374 See Info node `(gnus)Customizing Articles' and Info node
1375 `(gnus)Picons' for details."
1377 :group 'gnus-article-treat
1379 :link '(custom-manual "(gnus)Customizing Articles")
1380 :link '(custom-manual "(gnus)Picons")
1381 :type gnus-article-treat-head-custom)
1382 (put 'gnus-treat-mail-picon 'highlight t)
1384 (defcustom gnus-treat-newsgroups-picon
1385 (if (and (gnus-image-type-available-p 'xpm)
1386 (gnus-picons-installed-p))
1388 "Display picons in the Newsgroups and Followup-To headers.
1389 Valid values are nil, t, `head', `last', an integer or a predicate.
1390 See Info node `(gnus)Customizing Articles' and Info node
1391 `(gnus)Picons' for details."
1393 :group 'gnus-article-treat
1395 :link '(custom-manual "(gnus)Customizing Articles")
1396 :link '(custom-manual "(gnus)Picons")
1397 :type gnus-article-treat-head-custom)
1398 (put 'gnus-treat-newsgroups-picon 'highlight t)
1400 (defcustom gnus-treat-body-boundary
1401 (if (and (eq window-system 'x)
1402 (or gnus-treat-newsgroups-picon
1403 gnus-treat-mail-picon
1404 gnus-treat-from-picon))
1406 "Draw a boundary at the end of the headers.
1407 Valid values are nil and `head'.
1408 See Info node `(gnus)Customizing Articles' for details."
1410 :group 'gnus-article-treat
1411 :link '(custom-manual "(gnus)Customizing Articles")
1412 :type gnus-article-treat-head-custom)
1414 (defcustom gnus-treat-capitalize-sentences nil
1415 "Capitalize sentence-starting words.
1416 Valid values are nil, t, `head', `last', an integer or a predicate.
1417 See Info node `(gnus)Customizing Articles' for details."
1419 :group 'gnus-article-treat
1420 :link '(custom-manual "(gnus)Customizing Articles")
1421 :type gnus-article-treat-custom)
1423 (defcustom gnus-treat-wash-html nil
1425 Valid values are nil, t, `head', `last', an integer or a predicate.
1426 See Info node `(gnus)Customizing Articles' for details."
1428 :group 'gnus-article-treat
1429 :link '(custom-manual "(gnus)Customizing Articles")
1430 :type gnus-article-treat-custom)
1432 (defcustom gnus-treat-fill-long-lines nil
1434 Valid values are nil, t, `head', `last', an integer or a predicate.
1435 See Info node `(gnus)Customizing Articles' for details."
1436 :group 'gnus-article-treat
1437 :link '(custom-manual "(gnus)Customizing Articles")
1438 :type gnus-article-treat-custom)
1440 (defcustom gnus-treat-play-sounds nil
1442 Valid values are nil, t, `head', `last', an integer or a predicate.
1443 See Info node `(gnus)Customizing Articles' for details."
1445 :group 'gnus-article-treat
1446 :link '(custom-manual "(gnus)Customizing Articles")
1447 :type gnus-article-treat-custom)
1449 (defcustom gnus-treat-translate nil
1450 "Translate articles from one language to another.
1451 Valid values are nil, t, `head', `last', an integer or a predicate.
1452 See Info node `(gnus)Customizing Articles' for details."
1454 :group 'gnus-article-treat
1455 :link '(custom-manual "(gnus)Customizing Articles")
1456 :type gnus-article-treat-custom)
1458 (defcustom gnus-treat-x-pgp-sig nil
1460 To automatically treat X-PGP-Sig, set it to head.
1461 Valid values are nil, t, `head', `last', an integer or a predicate.
1462 See Info node `(gnus)Customizing Articles' for details."
1464 :group 'gnus-article-treat
1465 :group 'mime-security
1466 :link '(custom-manual "(gnus)Customizing Articles")
1467 :type gnus-article-treat-custom)
1469 (defvar gnus-article-encrypt-protocol-alist
1470 '(("PGP" . mml2015-self-encrypt)))
1472 ;; Set to nil if more than one protocol added to
1473 ;; gnus-article-encrypt-protocol-alist.
1474 (defcustom gnus-article-encrypt-protocol "PGP"
1475 "The protocol used for encrypt articles.
1476 It is a string, such as \"PGP\". If nil, ask user."
1479 :group 'mime-security)
1481 (defvar gnus-article-wash-function nil
1482 "Function used for converting HTML into text.")
1484 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1485 (mm-coding-system-p 'utf-8)
1486 (executable-find idna-program))
1487 "Whether IDNA decoding of headers is used when viewing messages.
1488 This requires GNU Libidn, and by default only enabled if it is found."
1490 :group 'gnus-article-headers
1493 (defcustom gnus-article-over-scroll nil
1494 "If non-nil, allow scrolling the article buffer even when there no more text."
1496 :group 'gnus-article
1499 ;;; Internal variables
1501 (defvar gnus-english-month-names
1502 '("January" "February" "March" "April" "May" "June" "July" "August"
1503 "September" "October" "November" "December"))
1505 (defvar gnus-button-regexp nil)
1506 (defvar gnus-button-marker-list nil)
1507 ;; Regexp matching any of the regexps from `gnus-button-alist'.
1509 (defvar gnus-button-last nil)
1510 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
1512 (defvar article-goto-body-goes-to-point-min-p nil)
1513 (defvar gnus-article-wash-types nil)
1514 (defvar gnus-article-emphasis-alist nil)
1515 (defvar gnus-article-image-alist nil)
1517 (defvar gnus-article-mime-handle-alist-1 nil)
1518 (defvar gnus-treatment-function-alist
1519 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1520 (gnus-treat-strip-banner gnus-article-strip-banner)
1521 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1522 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1523 (gnus-treat-buttonize gnus-article-add-buttons)
1524 (gnus-treat-fill-article gnus-article-fill-cited-article)
1525 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1526 (gnus-treat-strip-cr gnus-article-remove-cr)
1527 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1528 (gnus-treat-date-ut gnus-article-date-ut)
1529 (gnus-treat-date-local gnus-article-date-local)
1530 (gnus-treat-date-english gnus-article-date-english)
1531 (gnus-treat-date-original gnus-article-date-original)
1532 (gnus-treat-date-user-defined gnus-article-date-user)
1533 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1534 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1535 (gnus-treat-display-x-face gnus-article-display-x-face)
1536 (gnus-treat-display-face gnus-article-display-face)
1537 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1538 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1539 (gnus-treat-hide-signature gnus-article-hide-signature)
1540 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1541 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1542 (gnus-treat-strip-pem gnus-article-hide-pem)
1543 (gnus-treat-from-picon gnus-treat-from-picon)
1544 (gnus-treat-mail-picon gnus-treat-mail-picon)
1545 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1546 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1547 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1548 (gnus-treat-strip-trailing-blank-lines
1549 gnus-article-remove-trailing-blank-lines)
1550 (gnus-treat-strip-leading-blank-lines
1551 gnus-article-strip-leading-blank-lines)
1552 (gnus-treat-strip-multiple-blank-lines
1553 gnus-article-strip-multiple-blank-lines)
1554 (gnus-treat-overstrike gnus-article-treat-overstrike)
1555 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1556 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1557 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1558 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1559 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1560 (gnus-treat-display-smileys gnus-treat-smiley)
1561 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1562 (gnus-treat-wash-html gnus-article-wash-html)
1563 (gnus-treat-emphasize gnus-article-emphasize)
1564 (gnus-treat-hide-citation gnus-article-hide-citation)
1565 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1566 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1567 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1568 (gnus-treat-play-sounds gnus-earcon-display)))
1570 (defvar gnus-article-mime-handle-alist nil)
1571 (defvar article-lapsed-timer nil)
1572 (defvar gnus-article-current-summary nil)
1574 (defvar gnus-article-mode-syntax-table
1575 (let ((table (copy-syntax-table text-mode-syntax-table)))
1576 ;; This causes the citation match run O(2^n).
1577 ;; (modify-syntax-entry ?- "w" table)
1578 (modify-syntax-entry ?> ")<" table)
1579 (modify-syntax-entry ?< "(>" table)
1580 ;; make M-. in article buffers work for `foo' strings
1581 (modify-syntax-entry ?' " " table)
1582 (modify-syntax-entry ?` " " table)
1584 "Syntax table used in article mode buffers.
1585 Initialized from `text-mode-syntax-table.")
1587 (defvar gnus-save-article-buffer nil)
1589 (defvar gnus-article-mode-line-format-alist
1590 (nconc '((?w (gnus-article-wash-status) ?s)
1591 (?m (gnus-article-mime-part-status) ?s))
1592 gnus-summary-mode-line-format-alist))
1594 (defvar gnus-number-of-articles-to-be-saved nil)
1596 (defvar gnus-inhibit-hiding nil)
1598 (defvar gnus-article-edit-mode nil)
1600 ;;; Macros for dealing with the article buffer.
1602 (defmacro gnus-with-article-headers (&rest forms)
1604 (set-buffer gnus-article-buffer)
1606 (let ((inhibit-read-only t)
1607 (inhibit-point-motion-hooks t)
1608 (case-fold-search t))
1609 (article-narrow-to-head)
1612 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1613 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1615 (defmacro gnus-with-article-buffer (&rest forms)
1617 (set-buffer gnus-article-buffer)
1618 (let ((inhibit-read-only t))
1621 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1622 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1624 (defun gnus-article-goto-header (header)
1625 "Go to HEADER, which is a regular expression."
1626 (re-search-forward (concat "^\\(" header "\\):") nil t))
1628 (defsubst gnus-article-hide-text (b e props)
1629 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1630 (gnus-add-text-properties-when 'article-type nil b e props)
1631 (when (memq 'intangible props)
1633 (max (1- b) (point-min))
1634 b 'intangible (cddr (memq 'intangible props)))))
1636 (defsubst gnus-article-unhide-text (b e)
1637 "Remove hidden text properties from region between B and E."
1638 (remove-text-properties b e gnus-hidden-properties)
1639 (when (memq 'intangible gnus-hidden-properties)
1640 (put-text-property (max (1- b) (point-min))
1641 b 'intangible nil)))
1643 (defun gnus-article-hide-text-type (b e type)
1644 "Hide text of TYPE between B and E."
1645 (gnus-add-wash-type type)
1646 (gnus-article-hide-text
1647 b e (cons 'article-type (cons type gnus-hidden-properties))))
1649 (defun gnus-article-unhide-text-type (b e type)
1650 "Unhide text of TYPE between B and E."
1651 (gnus-delete-wash-type type)
1652 (remove-text-properties
1653 b e (cons 'article-type (cons type gnus-hidden-properties)))
1654 (when (memq 'intangible gnus-hidden-properties)
1655 (put-text-property (max (1- b) (point-min))
1656 b 'intangible nil)))
1658 (defun gnus-article-hide-text-of-type (type)
1659 "Hide text of TYPE in the current buffer."
1661 (let ((b (point-min))
1663 (while (setq b (text-property-any b e 'article-type type))
1664 (add-text-properties b (incf b) gnus-hidden-properties)))))
1666 (defun gnus-article-delete-text-of-type (type)
1667 "Delete text of TYPE in the current buffer."
1669 (let ((b (point-min)))
1670 (while (setq b (text-property-any b (point-max) 'article-type type))
1672 b (or (text-property-not-all b (point-max) 'article-type type)
1675 (defun gnus-article-delete-invisible-text ()
1676 "Delete all invisible text in the current buffer."
1678 (let ((b (point-min)))
1679 (while (setq b (text-property-any b (point-max) 'invisible t))
1681 b (or (text-property-not-all b (point-max) 'invisible t)
1684 (defun gnus-article-text-type-exists-p (type)
1685 "Say whether any text of type TYPE exists in the buffer."
1686 (text-property-any (point-min) (point-max) 'article-type type))
1688 (defsubst gnus-article-header-rank ()
1689 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1690 (let ((list gnus-sorted-header-list)
1693 (if (looking-at (car list))
1695 (setq list (cdr list))
1699 (defun article-hide-headers (&optional arg delete)
1700 "Hide unwanted headers and possibly sort them as well."
1702 ;; This function might be inhibited.
1703 (unless gnus-inhibit-hiding
1704 (let ((inhibit-read-only nil)
1705 (case-fold-search t)
1706 (max (1+ (length gnus-sorted-header-list)))
1707 (inhibit-point-motion-hooks t)
1708 (cur (current-buffer))
1709 ignored visible beg)
1711 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1712 ;; group parameters, so we should go to the summary buffer.
1715 (progn (set-buffer gnus-summary-buffer) t)
1717 (setq ignored (when (not gnus-visible-headers)
1718 (cond ((stringp gnus-ignored-headers)
1719 gnus-ignored-headers)
1720 ((listp gnus-ignored-headers)
1721 (mapconcat 'identity
1722 gnus-ignored-headers
1724 visible (cond ((stringp gnus-visible-headers)
1725 gnus-visible-headers)
1726 ((and gnus-visible-headers
1727 (listp gnus-visible-headers))
1728 (mapconcat 'identity
1729 gnus-visible-headers
1733 ;; First we narrow to just the headers.
1734 (article-narrow-to-head)
1735 ;; Hide any "From " lines at the beginning of (mail) articles.
1736 (while (looking-at "From ")
1739 (delete-region (point-min) (point)))
1740 ;; Then treat the rest of the header lines.
1741 ;; Then we use the two regular expressions
1742 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1743 ;; select which header lines is to remain visible in the
1745 (while (re-search-forward "^[^ \t:]*:" nil t)
1747 ;; Mark the rank of the header.
1749 (point) (1+ (point)) 'message-rank
1750 (if (or (and visible (looking-at visible))
1752 (not (looking-at ignored))))
1753 (gnus-article-header-rank)
1756 (message-sort-headers-1)
1757 (when (setq beg (text-property-any
1758 (point-min) (point-max) 'message-rank (+ 2 max)))
1759 ;; We delete the unwanted headers.
1760 (gnus-add-wash-type 'headers)
1761 (add-text-properties (point-min) (+ 5 (point-min))
1762 '(article-type headers dummy-invisible t))
1763 (delete-region beg (point-max))))))))
1765 (defun article-hide-boring-headers (&optional arg)
1766 "Toggle hiding of headers that aren't very interesting.
1767 If given a negative prefix, always show; if given a positive prefix,
1769 (interactive (gnus-article-hidden-arg))
1770 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1771 (not gnus-show-all-headers))
1774 (let ((inhibit-read-only t)
1775 (inhibit-point-motion-hooks t))
1776 (article-narrow-to-head)
1777 (dolist (elem gnus-boring-article-headers)
1778 (goto-char (point-min))
1780 ;; Hide empty headers.
1782 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1784 (gnus-article-hide-text-type
1788 (if (re-search-forward "^[^ \t]" nil t)
1792 ;; Hide boring Newsgroups header.
1793 ((eq elem 'newsgroups)
1794 (when (gnus-string-equal
1795 (gnus-fetch-field "newsgroups")
1796 (gnus-group-real-name
1797 (if (boundp 'gnus-newsgroup-name)
1800 (gnus-article-hide-header "newsgroups")))
1801 ((eq elem 'to-address)
1802 (let ((to (message-fetch-field "to"))
1804 (gnus-parameter-to-address
1805 (if (boundp 'gnus-newsgroup-name)
1806 gnus-newsgroup-name ""))))
1807 (when (and to to-address
1810 ;; only one address in To
1811 (nth 1 (mail-extract-address-components to))
1813 (gnus-article-hide-header "to"))))
1815 (let ((to (message-fetch-field "to"))
1817 (gnus-parameter-to-list
1818 (if (boundp 'gnus-newsgroup-name)
1819 gnus-newsgroup-name ""))))
1820 (when (and to to-list
1823 ;; only one address in To
1824 (nth 1 (mail-extract-address-components to))
1826 (gnus-article-hide-header "to"))))
1828 (let ((cc (message-fetch-field "cc"))
1830 (gnus-parameter-to-list
1831 (if (boundp 'gnus-newsgroup-name)
1832 gnus-newsgroup-name ""))))
1833 (when (and cc to-list
1836 ;; only one address in CC
1837 (nth 1 (mail-extract-address-components cc))
1839 (gnus-article-hide-header "cc"))))
1840 ((eq elem 'followup-to)
1841 (when (gnus-string-equal
1842 (message-fetch-field "followup-to")
1843 (message-fetch-field "newsgroups"))
1844 (gnus-article-hide-header "followup-to")))
1845 ((eq elem 'reply-to)
1846 (if (gnus-group-find-parameter
1847 gnus-newsgroup-name 'broken-reply-to)
1848 (gnus-article-hide-header "reply-to")
1849 (let ((from (message-fetch-field "from"))
1850 (reply-to (message-fetch-field "reply-to")))
1857 (lambda (x) (downcase (cadr x)))
1858 (mail-extract-address-components from t))
1861 (lambda (x) (downcase (cadr x)))
1862 (mail-extract-address-components reply-to t))
1864 (gnus-article-hide-header "reply-to")))))
1866 (let ((date (message-fetch-field "date")))
1868 (< (days-between (current-time-string) date)
1870 (gnus-article-hide-header "date"))))
1872 (let ((to (message-fetch-field "to"))
1873 (cc (message-fetch-field "cc")))
1874 (when (> (length to) 1024)
1875 (gnus-article-hide-header "to"))
1876 (when (> (length cc) 1024)
1877 (gnus-article-hide-header "cc"))))
1881 (goto-char (point-min))
1882 (while (re-search-forward "^to:" nil t)
1883 (setq to-count (1+ to-count)))
1884 (when (> to-count 1)
1885 (while (> to-count 0)
1886 (goto-char (point-min))
1888 (re-search-forward "^to:" nil nil to-count)
1890 (narrow-to-region (point) (point-max))
1891 (gnus-article-hide-header "to"))
1892 (setq to-count (1- to-count))))
1893 (goto-char (point-min))
1894 (while (re-search-forward "^cc:" nil t)
1895 (setq cc-count (1+ cc-count)))
1896 (when (> cc-count 1)
1897 (while (> cc-count 0)
1898 (goto-char (point-min))
1900 (re-search-forward "^cc:" nil nil cc-count)
1902 (narrow-to-region (point) (point-max))
1903 (gnus-article-hide-header "cc"))
1904 (setq cc-count (1- cc-count)))))))))))))
1906 (defun gnus-article-hide-header (header)
1908 (goto-char (point-min))
1909 (when (re-search-forward (concat "^" header ":") nil t)
1910 (gnus-article-hide-text-type
1914 (if (re-search-forward "^[^ \t]" nil t)
1919 (defvar gnus-article-normalized-header-length 40
1920 "Length of normalized headers.")
1922 (defun article-normalize-headers ()
1923 "Make all header lines 40 characters long."
1925 (let ((inhibit-read-only t)
1929 (article-narrow-to-head)
1932 ((< (setq column (- (point-at-eol) (point)))
1933 gnus-article-normalized-header-length)
1935 (insert (make-string
1936 (- gnus-article-normalized-header-length column)
1938 ((> column gnus-article-normalized-header-length)
1939 (gnus-put-text-property
1941 (forward-char gnus-article-normalized-header-length)
1948 (forward-line 1))))))
1950 (defun article-treat-dumbquotes ()
1951 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
1952 Note that this function guesses whether a character is a sm*rtq**t* or
1953 not, so it should only be used interactively.
1955 Sm*rtq**t*s are M****s***'s unilateral extension to the
1956 iso-8859-1 character map in an attempt to provide more quoting
1957 characters. If you see something like \\222 or \\264 where
1958 you're expecting some kind of apostrophe or quotation mark, then
1961 (article-translate-strings gnus-article-dumbquotes-map))
1963 (defun article-translate-characters (from to)
1964 "Translate all characters in the body of the article according to FROM and TO.
1965 FROM is a string of characters to translate from; to is a string of
1966 characters to translate to."
1968 (when (article-goto-body)
1969 (let ((inhibit-read-only t)
1970 (x (make-string 225 ?x))
1972 (while (< (incf i) (length x))
1975 (while (< i (length from))
1976 (aset x (aref from i) (aref to i))
1978 (translate-region (point) (point-max) x)))))
1980 (defun article-translate-strings (map)
1981 "Translate all string in the body of the article according to MAP.
1982 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1984 (when (article-goto-body)
1985 (let ((inhibit-read-only t))
1988 (while (search-forward (car elem) nil t)
1989 (replace-match (cadr elem)))))))))
1991 (defun article-treat-overstrike ()
1992 "Translate overstrikes into bold text."
1995 (when (article-goto-body)
1996 (let ((inhibit-read-only t))
1997 (while (search-forward "\b" nil t)
1998 (let ((next (char-after))
1999 (previous (char-after (- (point) 2))))
2000 ;; We do the boldification/underlining by hiding the
2001 ;; overstrikes and putting the proper text property
2005 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
2006 (put-text-property (point) (1+ (point)) 'face 'bold))
2008 (gnus-article-hide-text-type
2009 (1- (point)) (1+ (point)) 'overstrike)
2011 (- (point) 2) (1- (point)) 'face 'underline))
2013 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
2015 (point) (1+ (point)) 'face 'underline)))))))))
2017 (defun article-treat-ansi-sequences ()
2018 "Translate ANSI SGR control sequences into overlays or extents."
2021 (when (article-goto-body)
2022 (let ((inhibit-read-only t))
2023 (ansi-color-apply-on-region (point) (point-max))))))
2025 (defun gnus-article-treat-unfold-headers ()
2026 "Unfold folded message headers.
2027 Only the headers that fit into the current window width will be
2030 (gnus-with-article-headers
2034 (mail-header-narrow-to-field)
2035 (let ((header (buffer-string)))
2038 (goto-char (point-min))
2039 (while (re-search-forward "\n[\t ]" nil t)
2040 (replace-match " " t t)))
2041 (setq length (- (point-max) (point-min) 1)))
2042 (when (< length (window-width))
2043 (while (re-search-forward "\n[\t ]" nil t)
2044 (replace-match " " t t)))
2045 (goto-char (point-max)))))))
2047 (defun gnus-article-treat-fold-headers ()
2048 "Fold message headers."
2050 (gnus-with-article-headers
2053 (mail-header-narrow-to-field)
2054 (mail-header-fold-field)
2055 (goto-char (point-max))))))
2057 (defun gnus-treat-smiley ()
2058 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2060 (gnus-with-article-buffer
2061 (if (memq 'smiley gnus-article-wash-types)
2062 (gnus-delete-images 'smiley)
2064 (let ((images (smiley-region (point) (point-max))))
2066 (gnus-add-wash-type 'smiley)
2067 (dolist (image images)
2068 (gnus-add-image 'smiley image)))))))
2070 (defun gnus-article-remove-images ()
2071 "Remove all images from the article buffer."
2073 (gnus-with-article-buffer
2074 (dolist (elem gnus-article-image-alist)
2075 (gnus-delete-images (car elem)))))
2077 (defun gnus-article-treat-fold-newsgroups ()
2078 "Unfold folded message headers.
2079 Only the headers that fit into the current window width will be
2082 (gnus-with-article-headers
2083 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2085 (mail-header-narrow-to-field)
2086 (while (re-search-forward ", *" nil t)
2087 (replace-match ", " t t))
2088 (mail-header-fold-field)
2089 (goto-char (point-max))))))
2091 (defun gnus-article-treat-body-boundary ()
2092 "Place a boundary line at the end of the headers."
2094 (when (and gnus-body-boundary-delimiter
2095 (> (length gnus-body-boundary-delimiter) 0))
2096 (gnus-with-article-headers
2097 (goto-char (point-max))
2098 (let ((start (point)))
2099 (insert "X-Boundary: ")
2100 (gnus-add-text-properties start (point) '(invisible t intangible t))
2102 (while (>= (1- (window-width)) (length str))
2103 (setq str (concat str gnus-body-boundary-delimiter)))
2104 (substring str 0 (1- (window-width))))
2106 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2108 (defun article-fill-long-lines ()
2109 "Fill lines that are wider than the window width."
2112 (let ((inhibit-read-only t)
2113 (width (window-width (get-buffer-window (current-buffer)))))
2116 (let ((adaptive-fill-mode nil)) ;Why? -sm
2119 (when (>= (current-column) (min fill-column width))
2120 (narrow-to-region (min (1+ (point)) (point-max))
2122 (let ((goback (point-marker)))
2123 (fill-paragraph nil)
2124 (goto-char (marker-position goback)))
2126 (forward-line 1)))))))
2128 (defun article-capitalize-sentences ()
2129 "Capitalize the first word in each sentence."
2132 (let ((inhibit-read-only t)
2133 (paragraph-start "^[\n\^L]"))
2137 (forward-sentence)))))
2139 (defun article-remove-cr ()
2140 "Remove trailing CRs and then translate remaining CRs into LFs."
2143 (let ((inhibit-read-only t))
2144 (goto-char (point-min))
2145 (while (re-search-forward "\r+$" nil t)
2146 (replace-match "" t t))
2147 (goto-char (point-min))
2148 (while (search-forward "\r" nil t)
2149 (replace-match "\n" t t)))))
2151 (defun article-remove-trailing-blank-lines ()
2152 "Remove all trailing blank lines from the article."
2155 (let ((inhibit-read-only t))
2156 (goto-char (point-max))
2160 (while (and (not (bobp))
2161 (looking-at "^[ \t]*$")
2162 (not (gnus-annotation-in-region-p
2163 (point) (point-at-eol))))
2169 (defvar gnus-face-properties-alist))
2171 (defun article-display-face ()
2172 "Display any Face headers in the header."
2174 (let ((wash-face-p buffer-read-only))
2175 (gnus-with-article-headers
2176 ;; When displaying parts, this function can be called several times on
2177 ;; the same article, without any intended toggle semantic (as typing `W
2178 ;; D d' would have). So face deletion must occur only when we come from
2179 ;; an interactive command, that is when the *Article* buffer is
2181 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2182 (gnus-delete-images 'face)
2183 (let (face faces from)
2184 (save-current-buffer
2185 (when (and wash-face-p
2186 (gnus-buffer-live-p gnus-original-article-buffer)
2187 (not (re-search-forward "^Face:[\t ]*" nil t)))
2188 (set-buffer gnus-original-article-buffer))
2190 (mail-narrow-to-head)
2191 (while (gnus-article-goto-header "Face")
2192 (push (mail-header-field-value) faces))))
2194 (goto-char (point-min))
2195 (let ((from (gnus-article-goto-header "from"))
2200 (insert "[no `from' set]\n"))
2202 (when (setq png (gnus-convert-face-to-png (pop faces)))
2204 (apply 'gnus-create-image png 'png t
2205 (cdr (assq 'png gnus-face-properties-alist))))
2207 (gnus-add-wash-type 'face)
2208 (gnus-add-image 'face image)
2209 (gnus-put-image image nil 'face))))))))))
2211 (defun article-display-x-face (&optional force)
2212 "Look for an X-Face header and display it if present."
2213 (interactive (list 'force))
2214 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2215 (gnus-with-article-headers
2216 ;; Delete the old process, if any.
2217 (when (process-status "article-x-face")
2218 (delete-process "article-x-face"))
2219 ;; See the comment in `article-display-face'.
2220 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2221 ;; We have already displayed X-Faces, so we remove them
2223 (gnus-delete-images 'xface)
2225 (let (x-faces from face)
2226 (save-current-buffer
2227 (when (and wash-face-p
2228 (gnus-buffer-live-p gnus-original-article-buffer)
2229 (not (re-search-forward "^X-Face:[\t ]*" nil t)))
2230 ;; If type `W f', use gnus-original-article-buffer,
2231 ;; otherwise use the current buffer because displaying
2232 ;; RFC822 parts calls this function too.
2233 (set-buffer gnus-original-article-buffer))
2235 (mail-narrow-to-head)
2236 (while (gnus-article-goto-header "X-Face")
2237 (push (mail-header-field-value) x-faces))
2238 (setq from (message-fetch-field "from"))))
2239 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2240 ;; single external face.
2241 (when (stringp gnus-article-x-face-command)
2242 (setq x-faces (list (car x-faces))))
2244 gnus-article-x-face-command
2246 ;; Check whether this face is censored.
2247 (not gnus-article-x-face-too-ugly)
2249 (not (string-match gnus-article-x-face-too-ugly
2251 (while (setq face (pop x-faces))
2252 ;; We display the face.
2253 (cond ((stringp gnus-article-x-face-command)
2254 ;; The command is a string, so we interpret the command
2255 ;; as a, well, command, and fork it off.
2256 (let ((process-connection-type nil))
2257 (gnus-set-process-query-on-exit-flag
2259 "article-x-face" nil shell-file-name
2260 shell-command-switch gnus-article-x-face-command)
2264 (process-send-region "article-x-face"
2265 (point-min) (point-max)))
2266 (process-send-eof "article-x-face")))
2267 ((functionp gnus-article-x-face-command)
2268 ;; The command is a lisp function, so we call it.
2269 (funcall gnus-article-x-face-command face))
2271 (error "%s is not a function"
2272 gnus-article-x-face-command))))))))))
2274 (defun article-decode-mime-words ()
2275 "Decode all MIME-encoded words in the article."
2277 (gnus-with-article-buffer
2278 (let ((inhibit-point-motion-hooks t)
2279 (mail-parse-charset gnus-newsgroup-charset)
2280 (mail-parse-ignored-charsets
2281 (with-current-buffer gnus-summary-buffer
2282 gnus-newsgroup-ignored-charsets)))
2283 (mail-decode-encoded-word-region (point-min) (point-max)))))
2285 (defun article-decode-charset (&optional prompt)
2286 "Decode charset-encoded text in the article.
2287 If PROMPT (the prefix), prompt for a coding system to use."
2289 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2290 (inhibit-read-only t)
2291 (mail-parse-charset gnus-newsgroup-charset)
2292 (mail-parse-ignored-charsets
2293 (save-excursion (condition-case nil
2294 (set-buffer gnus-summary-buffer)
2296 gnus-newsgroup-ignored-charsets))
2297 ct cte ctl charset format)
2300 (article-narrow-to-head)
2301 (setq ct (message-fetch-field "Content-Type" t)
2302 cte (message-fetch-field "Content-Transfer-Encoding" t)
2303 ctl (and ct (ignore-errors
2304 (mail-header-parse-content-type ct)))
2307 (mm-read-coding-system "Charset to decode: "))
2309 (mail-content-type-get ctl 'charset)))
2310 format (and ctl (mail-content-type-get ctl 'format)))
2312 (setq cte (mail-header-strip cte)))
2313 (if (and ctl (not (string-match "/" (car ctl))))
2315 (goto-char (point-max)))
2318 (narrow-to-region (point) (point-max))
2319 (when (and (eq mail-parse-charset 'gnus-decoded)
2320 (eq (mm-body-7-or-8) '8bit))
2321 ;; The text code could have been decoded.
2322 (setq charset mail-parse-charset))
2323 (when (and (or (not ctl)
2324 (equal (car ctl) "text/plain"))
2325 (not format)) ;; article with format will decode later.
2327 charset (and cte (intern (downcase
2328 (gnus-strip-whitespace cte))))
2331 (defun article-decode-encoded-words ()
2332 "Remove encoded-word encoding from headers."
2333 (let ((inhibit-point-motion-hooks t)
2334 (mail-parse-charset gnus-newsgroup-charset)
2335 (mail-parse-ignored-charsets
2336 (save-excursion (condition-case nil
2337 (set-buffer gnus-summary-buffer)
2339 gnus-newsgroup-ignored-charsets))
2340 (inhibit-read-only t))
2342 (article-narrow-to-head)
2343 (funcall gnus-decode-header-function (point-min) (point-max)))))
2345 (defun article-decode-group-name ()
2346 "Decode group names in `Newsgroups:'."
2347 (let ((inhibit-point-motion-hooks t)
2348 (inhibit-read-only t)
2349 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2350 (when (and (or gnus-group-name-charset-method-alist
2351 gnus-group-name-charset-group-alist)
2352 (gnus-buffer-live-p gnus-original-article-buffer))
2354 (article-narrow-to-head)
2355 (with-current-buffer gnus-original-article-buffer
2356 (goto-char (point-min)))
2357 (while (re-search-forward
2358 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2359 (replace-match (save-match-data
2360 (gnus-decode-newsgroups
2361 ;; XXX how to use data in article buffer?
2362 (with-current-buffer gnus-original-article-buffer
2364 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2367 gnus-newsgroup-name method))
2369 (goto-char (point-min))
2370 (with-current-buffer gnus-original-article-buffer
2371 (goto-char (point-min)))
2372 (while (re-search-forward
2373 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2374 (replace-match (save-match-data
2375 (gnus-decode-newsgroups
2376 ;; XXX how to use data in article buffer?
2377 (with-current-buffer gnus-original-article-buffer
2379 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2382 gnus-newsgroup-name method))
2385 (autoload 'idna-to-unicode "idna")
2387 (defun article-decode-idna-rhs ()
2388 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2391 (let ((inhibit-point-motion-hooks t)
2392 (inhibit-read-only t))
2393 (article-narrow-to-head)
2394 (goto-char (point-min))
2395 (while (re-search-forward "@.*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2397 (when (save-match-data
2398 (and (setq ace (match-string 1))
2400 (and (re-search-backward "^[^ \t]" nil t)
2401 (looking-at "From\\|To\\|Cc")))
2402 (setq unicode (idna-to-unicode ace))))
2403 (unless (string= ace unicode)
2404 (replace-match unicode nil nil nil 1)))))))))
2406 (defun article-de-quoted-unreadable (&optional force read-charset)
2407 "Translate a quoted-printable-encoded article.
2408 If FORCE, decode the article whether it is marked as quoted-printable
2410 If READ-CHARSET, ask for a coding system."
2411 (interactive (list 'force current-prefix-arg))
2413 (let ((inhibit-read-only t) type charset)
2414 (if (gnus-buffer-live-p gnus-original-article-buffer)
2415 (with-current-buffer gnus-original-article-buffer
2417 (gnus-fetch-field "content-transfer-encoding"))
2418 (let* ((ct (gnus-fetch-field "content-type"))
2421 (mail-header-parse-content-type ct)))))
2422 (setq charset (and ctl
2423 (mail-content-type-get ctl 'charset)))
2424 (if (stringp charset)
2425 (setq charset (intern (downcase charset)))))))
2427 (setq charset (mm-read-coding-system "Charset: " charset)))
2429 (setq charset gnus-newsgroup-charset))
2431 (and type (let ((case-fold-search t))
2432 (string-match "quoted-printable" type))))
2434 (quoted-printable-decode-region
2435 (point) (point-max) (mm-charset-to-coding-system charset))))))
2437 (defun article-de-base64-unreadable (&optional force read-charset)
2438 "Translate a base64 article.
2439 If FORCE, decode the article whether it is marked as base64 not.
2440 If READ-CHARSET, ask for a coding system."
2441 (interactive (list 'force current-prefix-arg))
2443 (let ((inhibit-read-only t) type charset)
2444 (if (gnus-buffer-live-p gnus-original-article-buffer)
2445 (with-current-buffer gnus-original-article-buffer
2447 (gnus-fetch-field "content-transfer-encoding"))
2448 (let* ((ct (gnus-fetch-field "content-type"))
2451 (mail-header-parse-content-type ct)))))
2452 (setq charset (and ctl
2453 (mail-content-type-get ctl 'charset)))
2454 (if (stringp charset)
2455 (setq charset (intern (downcase charset)))))))
2457 (setq charset (mm-read-coding-system "Charset: " charset)))
2459 (setq charset gnus-newsgroup-charset))
2461 (and type (let ((case-fold-search t))
2462 (string-match "base64" type))))
2465 (narrow-to-region (point) (point-max))
2466 (base64-decode-region (point-min) (point-max))
2467 (mm-decode-coding-region
2468 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2473 (defun article-decode-HZ ()
2474 "Translate a HZ-encoded article."
2478 (let ((inhibit-read-only t))
2479 (rfc1843-decode-region (point-min) (point-max)))))
2481 (defun article-unsplit-urls ()
2482 "Remove the newlines that some other mailers insert into URLs."
2485 (let ((inhibit-read-only t))
2486 (goto-char (point-min))
2487 (while (re-search-forward
2488 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2489 (replace-match "\\1\\3" t)))
2490 (when (interactive-p)
2491 (gnus-treat-article nil))))
2494 (defun article-wash-html (&optional read-charset)
2495 "Format an HTML article.
2496 If READ-CHARSET, ask for a coding system."
2499 (let ((inhibit-read-only t)
2501 (when (gnus-buffer-live-p gnus-original-article-buffer)
2502 (with-current-buffer gnus-original-article-buffer
2503 (let* ((ct (gnus-fetch-field "content-type"))
2506 (mail-header-parse-content-type ct)))))
2507 (setq charset (and ctl
2508 (mail-content-type-get ctl 'charset)))
2509 (when (stringp charset)
2510 (setq charset (intern (downcase charset)))))))
2512 (setq charset (mm-read-coding-system "Charset: " charset)))
2514 (setq charset gnus-newsgroup-charset))
2516 (save-window-excursion
2518 (narrow-to-region (point) (point-max))
2519 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2520 (entry (assq func mm-text-html-washer-alist)))
2522 (setq func (cdr entry)))
2527 (apply (car func) (cdr func))))))))))
2529 (defun gnus-article-wash-html-with-w3 ()
2530 "Wash the current buffer with w3."
2532 (let ((w3-strict-width (window-width))
2533 (url-standalone-mode t)
2534 (url-gateway-unplugged t)
2535 (w3-honor-stylesheets nil))
2537 (w3-region (point-min) (point-max))
2540 (defun gnus-article-wash-html-with-w3m ()
2541 "Wash the current buffer with emacs-w3m."
2544 (narrow-to-region (point) (point-max))
2545 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2546 w3m-force-redisplay)
2547 (w3m-region (point-min) (point-max)))
2548 (when (and mm-inline-text-html-with-w3m-keymap
2549 (boundp 'w3m-minor-mode-map)
2551 (add-text-properties
2552 (point-min) (point-max)
2553 (list 'keymap w3m-minor-mode-map
2554 ;; Put the mark meaning this part was rendered by emacs-w3m.
2555 'mm-inline-text-html-with-w3m t)))))
2557 (defun article-hide-list-identifiers ()
2558 "Remove list identifies from the Subject header.
2559 The `gnus-list-identifiers' variable specifies what to do."
2561 (let ((inhibit-point-motion-hooks t)
2562 (regexp (if (consp gnus-list-identifiers)
2563 (mapconcat 'identity gnus-list-identifiers " *\\|")
2564 gnus-list-identifiers))
2565 (inhibit-read-only t))
2569 (article-narrow-to-head)
2570 (goto-char (point-min))
2571 (while (re-search-forward
2572 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2574 (delete-region (match-beginning 2) (match-end 0))
2575 (beginning-of-line))
2576 (when (re-search-forward
2577 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2578 (delete-region (match-beginning 1) (match-end 1))))))))
2580 (defun article-hide-pem (&optional arg)
2581 "Toggle hiding of any PEM headers and signatures in the current article.
2582 If given a negative prefix, always show; if given a positive prefix,
2584 (interactive (gnus-article-hidden-arg))
2585 (unless (gnus-article-check-hidden-text 'pem arg)
2587 (let ((inhibit-read-only t) end)
2588 (goto-char (point-min))
2589 ;; Hide the horrendously ugly "header".
2590 (when (and (search-forward
2591 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2593 (setq end (1+ (match-beginning 0))))
2594 (gnus-add-wash-type 'pem)
2595 (gnus-article-hide-text-type
2597 (if (search-forward "\n\n" nil t)
2601 ;; Hide the trailer as well
2602 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2604 (gnus-article-hide-text-type
2605 (match-beginning 0) (match-end 0) 'pem)))))))
2607 (defun article-strip-banner ()
2608 "Strip the banners specified by the `banner' group parameter and by
2609 `gnus-article-address-banner-alist'."
2613 (let ((inhibit-point-motion-hooks t))
2614 (when (gnus-parameter-banner gnus-newsgroup-name)
2615 (article-really-strip-banner
2616 (gnus-parameter-banner gnus-newsgroup-name)))
2617 (when gnus-article-address-banner-alist
2618 ;; It is necessary to encode from fields before checking,
2619 ;; because `mail-header-parse-addresses' does not work
2620 ;; (reliably) on decoded headers. And more, it is
2621 ;; impossible to use `gnus-fetch-original-field' here,
2622 ;; because `article-strip-banner' may be called in draft
2623 ;; buffers to preview them.
2624 (let ((from (save-restriction
2626 (article-narrow-to-head)
2627 (mail-fetch-field "from"))))
2630 (caar (mail-header-parse-addresses
2631 (mail-encode-encoded-word-string from)))))
2633 (dolist (pair gnus-article-address-banner-alist)
2634 (when (string-match (car pair) from)
2636 (article-really-strip-banner (cdr pair)))))))))))))
2638 (defun article-really-strip-banner (banner)
2639 "Strip the banner specified by the argument."
2642 (let ((inhibit-point-motion-hooks t)
2643 (gnus-signature-limit nil)
2644 (inhibit-read-only t))
2647 ((eq banner 'signature)
2648 (when (gnus-article-narrow-to-signature)
2651 (delete-region (point) (point-max))))
2653 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2654 (while (re-search-forward banner nil t)
2655 (delete-region (match-beginning 0) (match-end 0)))))
2657 (while (re-search-forward banner nil t)
2658 (delete-region (match-beginning 0) (match-end 0)))))))))
2660 (defun article-babel ()
2661 "Translate article using an online translation service."
2664 (gnus-with-article-buffer
2665 (when (article-goto-body)
2666 (let* ((start (point))
2668 (orig (buffer-substring start end))
2669 (trans (babel-as-string orig)))
2671 (narrow-to-region start end)
2672 (delete-region start end)
2675 (defun article-hide-signature (&optional arg)
2676 "Hide the signature in the current article.
2677 If given a negative prefix, always show; if given a positive prefix,
2679 (interactive (gnus-article-hidden-arg))
2680 (unless (gnus-article-check-hidden-text 'signature arg)
2683 (let ((inhibit-read-only t))
2684 (when (gnus-article-narrow-to-signature)
2685 (gnus-article-hide-text-type
2686 (point-min) (point-max) 'signature))))))
2687 (gnus-set-mode-line 'article))
2689 (defun article-strip-headers-in-body ()
2690 "Strip offensive headers from bodies."
2694 (let ((case-fold-search t))
2695 (when (looking-at "x-no-archive:")
2696 (gnus-delete-line)))))
2698 (defun article-strip-leading-blank-lines ()
2699 "Remove all blank lines from the beginning of the article."
2702 (let ((inhibit-point-motion-hooks t)
2703 (inhibit-read-only t))
2704 (when (article-goto-body)
2705 (while (and (not (eobp))
2706 (looking-at "[ \t]*$"))
2707 (gnus-delete-line))))))
2709 (defun article-narrow-to-head ()
2710 "Narrow the buffer to the head of the message.
2711 Point is left at the beginning of the narrowed-to region."
2713 (goto-char (point-min))
2714 (if (search-forward "\n\n" nil 1)
2717 (goto-char (point-min)))
2719 (defun article-goto-body ()
2720 "Place point at the start of the body."
2721 (goto-char (point-min))
2723 ;; This variable is only bound when dealing with separate
2725 (article-goto-body-goes-to-point-min-p
2727 ((search-forward "\n\n" nil t)
2730 (goto-char (point-max))
2733 (defun article-strip-multiple-blank-lines ()
2734 "Replace consecutive blank lines with one empty line."
2737 (let ((inhibit-point-motion-hooks t)
2738 (inhibit-read-only t))
2739 ;; First make all blank lines empty.
2741 (while (re-search-forward "^[ \t]+$" nil t)
2742 (unless (gnus-annotation-in-region-p
2743 (match-beginning 0) (match-end 0))
2744 (replace-match "" nil t)))
2745 ;; Then replace multiple empty lines with a single empty line.
2747 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2748 (unless (gnus-annotation-in-region-p
2749 (match-beginning 0) (match-end 0))
2750 (delete-region (match-beginning 1) (match-end 1)))))))
2752 (defun article-strip-leading-space ()
2753 "Remove all white space from the beginning of the lines in the article."
2756 (let ((inhibit-point-motion-hooks t)
2757 (inhibit-read-only t))
2759 (while (re-search-forward "^[ \t]+" nil t)
2760 (replace-match "" t t)))))
2762 (defun article-strip-trailing-space ()
2763 "Remove all white space from the end of the lines in the article."
2766 (let ((inhibit-point-motion-hooks t)
2767 (inhibit-read-only t))
2769 (while (re-search-forward "[ \t]+$" nil t)
2770 (replace-match "" t t)))))
2772 (defun article-strip-blank-lines ()
2773 "Strip leading, trailing and multiple blank lines."
2775 (article-strip-leading-blank-lines)
2776 (article-remove-trailing-blank-lines)
2777 (article-strip-multiple-blank-lines))
2779 (defun article-strip-all-blank-lines ()
2780 "Strip all blank lines."
2783 (let ((inhibit-point-motion-hooks t)
2784 (inhibit-read-only t))
2786 (while (re-search-forward "^[ \t]*\n" nil t)
2787 (replace-match "" t t)))))
2789 (defun gnus-article-narrow-to-signature ()
2790 "Narrow to the signature; return t if a signature is found, else nil."
2791 (let ((inhibit-point-motion-hooks t))
2792 (when (gnus-article-search-signature)
2794 ;; Check whether we have some limits to what we consider
2795 ;; to be a signature.
2796 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2797 (list gnus-signature-limit)))
2799 (while (setq limit (pop limits))
2800 (if (or (and (integerp limit)
2801 (< (- (point-max) (point)) limit))
2803 (< (count-lines (point) (point-max)) limit))
2804 (and (functionp limit)
2806 (and (stringp limit)
2807 (not (re-search-forward limit nil t))))
2808 () ; This limit did not succeed.
2812 (narrow-to-region (point) (point-max))
2815 (defun gnus-article-search-signature ()
2816 "Search the current buffer for the signature separator.
2817 Put point at the beginning of the signature separator."
2818 (let ((cur (point)))
2819 (goto-char (point-max))
2820 (if (if (stringp gnus-signature-separator)
2821 (re-search-backward gnus-signature-separator nil t)
2822 (let ((seps gnus-signature-separator))
2824 (not (re-search-backward (car seps) nil t)))
2831 (defun gnus-article-hidden-arg ()
2832 "Return the current prefix arg as a number, or 0 if no prefix."
2833 (list (if current-prefix-arg
2834 (prefix-numeric-value current-prefix-arg)
2837 (defun gnus-article-check-hidden-text (type arg)
2838 "Return nil if hiding is necessary.
2839 Arg can be nil or a number. nil and positive means hide, negative
2840 means show, 0 means toggle."
2843 (let ((hide (gnus-article-hidden-text-p type)))
2849 (gnus-article-show-hidden-text type)
2852 (if (eq hide 'hidden)
2854 (gnus-article-show-hidden-text type)
2858 (defun gnus-article-hidden-text-p (type)
2859 "Say whether the current buffer contains hidden text of type TYPE."
2860 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2862 (not (get-text-property pos 'invisible))
2863 (not (get-text-property pos 'dummy-invisible)))
2865 (text-property-any (1+ pos) (point-max) 'article-type type)))
2870 (defun gnus-article-show-hidden-text (type &optional dummy)
2871 "Show all hidden text of type TYPE.
2872 Originally it is hide instead of DUMMY."
2873 (let ((inhibit-read-only t)
2874 (inhibit-point-motion-hooks t))
2875 (gnus-remove-text-properties-when
2877 (point-min) (point-max)
2878 (cons 'article-type (cons type
2879 gnus-hidden-properties)))
2880 (gnus-delete-wash-type type)))
2882 (defconst article-time-units
2883 `((year . ,(* 365.25 24 60 60))
2884 (week . ,(* 7 24 60 60))
2885 (day . ,(* 24 60 60))
2889 "Mapping from time units to seconds.")
2891 (defun gnus-article-forward-header ()
2892 "Move point to the start of the next header.
2893 If the current header is a continuation header, this can be several
2898 (if (looking-at "[ \t]+[^ \t]")
2902 (defun article-date-ut (&optional type highlight)
2903 "Convert DATE date to universal time in the current article.
2904 If TYPE is `local', convert to local time; if it is `lapsed', output
2905 how much time has lapsed since DATE. For `lapsed', the value of
2906 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2907 should replace the \"Date:\" one, or should be added below it."
2908 (interactive (list 'ut t))
2909 (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2910 (date-regexp (cond ((not gnus-article-date-lapsed-new-header)
2914 (article-lapsed-timer
2918 (case-fold-search t)
2919 (inhibit-read-only t)
2920 (inhibit-point-motion-hooks t)
2921 pos date bface eface)
2925 (goto-char (point-min))
2926 (while (or (setq date (get-text-property (setq pos (point))
2928 (when (setq pos (next-single-property-change
2929 (point) 'original-date))
2930 (setq date (get-text-property pos 'original-date))
2932 (narrow-to-region pos (or (text-property-any pos (point-max)
2935 (goto-char (point-min))
2936 (when (re-search-forward tdate-regexp nil t)
2937 (setq bface (get-text-property (point-at-bol) 'face)
2938 eface (get-text-property (1- (point-at-eol)) 'face)))
2939 (goto-char (point-min))
2941 ;; Delete any old Date headers.
2942 (while (re-search-forward date-regexp nil t)
2944 (delete-region (point-at-bol) (progn
2945 (gnus-article-forward-header)
2947 (delete-region (point-at-bol) (progn
2948 (gnus-article-forward-header)
2951 (setq pos (point))))
2952 (when (and (not pos)
2953 (re-search-forward tdate-regexp nil t))
2955 (gnus-goto-char pos)
2956 (insert (article-make-date-line date (or type 'ut)))
2962 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2963 (put-text-property (match-beginning 1) (1+ (match-end 1))
2965 (put-text-property (match-beginning 2) (match-end 2)
2967 (put-text-property (point-min) (1- (point-max)) 'original-date date)
2968 (goto-char (point-max))
2971 (defun article-make-date-line (date type)
2972 "Return a DATE line of TYPE."
2973 (unless (memq type '(local ut original user iso8601 lapsed english))
2974 (error "Unknown conversion type: %s" type))
2976 (let ((time (date-to-time date)))
2978 ;; Convert to the local timezone.
2980 (concat "Date: " (message-make-date time)))
2981 ;; Convert to Universal Time.
2986 (let* ((e (parse-time-string date))
2987 (tm (apply 'encode-time e))
2989 (ls (- (cadr tm) (car (current-time-zone time)))))
2990 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2991 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2995 ;; Get the original date from the article.
2996 ((eq type 'original)
2997 (concat "Date: " (if (string-match "\n+$" date)
2998 (substring date 0 (match-beginning 0))
3000 ;; Let the user define the format.
3002 (let ((format (or (condition-case nil
3003 (with-current-buffer gnus-summary-buffer
3004 gnus-article-time-format)
3006 gnus-article-time-format)))
3007 (if (functionp format)
3008 (funcall format time)
3009 (concat "Date: " (format-time-string format time)))))
3012 (let ((tz (car (current-time-zone time))))
3015 (format-time-string "%Y%m%dT%H%M%S" time)
3016 (format "%s%02d%02d"
3017 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3018 (/ (% (abs tz) 3600) 60)))))
3019 ;; Do an X-Sent lapsed format.
3021 ;; If the date is seriously mangled, the timezone functions are
3022 ;; liable to bug out, so we ignore all errors.
3023 (let* ((now (current-time))
3024 (real-time (subtract-time now time))
3025 (real-sec (and real-time
3026 (+ (* (float (car real-time)) 65536)
3028 (sec (and real-time (abs real-sec)))
3038 ;; This is a bit convoluted, but basically we go
3039 ;; through the time units for years, weeks, etc,
3040 ;; and divide things to see whether that results
3041 ;; in positive answers.
3044 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3045 ;; The (remaining) seconds are too few to
3046 ;; be divided into this time unit.
3048 ;; It's big enough, so we output it.
3049 (setq sec (- sec (* num (cdr unit))))
3051 (concat (if prev ", " "") (int-to-string
3053 " " (symbol-name (car unit))
3054 (if (> num 1) "s" ""))
3056 article-time-units "")
3057 ;; If dates are odd, then it might appear like the
3058 ;; article was sent in the future.
3061 " in the future"))))))
3062 ;; Display the date in proper English
3064 (let ((dtime (decode-time time)))
3067 (number-to-string (nth 3 dtime))
3068 (let ((digit (% (nth 3 dtime) 10)))
3070 ((memq (nth 3 dtime) '(11 12 13)) "th")
3076 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3078 (number-to-string (nth 5 dtime))
3080 (format "%02d" (nth 2 dtime))
3082 (format "%02d" (nth 1 dtime)))))))
3084 (format "Date: %s (from Gnus)" date))))
3086 (defun article-date-local (&optional highlight)
3087 "Convert the current article date to the local timezone."
3088 (interactive (list t))
3089 (article-date-ut 'local highlight))
3091 (defun article-date-english (&optional highlight)
3092 "Convert the current article date to something that is proper English."
3093 (interactive (list t))
3094 (article-date-ut 'english highlight))
3096 (defun article-date-original (&optional highlight)
3097 "Convert the current article date to what it was originally.
3098 This is only useful if you have used some other date conversion
3099 function and want to see what the date was before converting."
3100 (interactive (list t))
3101 (article-date-ut 'original highlight))
3103 (defun article-date-lapsed (&optional highlight)
3104 "Convert the current article date to time lapsed since it was sent."
3105 (interactive (list t))
3106 (article-date-ut 'lapsed highlight))
3108 (defun article-update-date-lapsed ()
3109 "Function to be run from a timer to update the lapsed time line."
3111 (let (deactivate-mark)
3116 (set-buffer (window-buffer w))
3117 (when (eq major-mode 'gnus-article-mode)
3118 (let ((mark (point-marker)))
3119 (goto-char (point-min))
3120 (when (re-search-forward "^X-Sent:" nil t)
3121 (article-date-lapsed t))
3122 (goto-char (marker-position mark))
3123 (move-marker mark nil))))
3126 (defun gnus-start-date-timer (&optional n)
3127 "Start a timer to update the X-Sent header in the article buffers.
3128 The numerical prefix says how frequently (in seconds) the function
3133 (gnus-stop-date-timer)
3134 (setq article-lapsed-timer
3135 (run-at-time 1 n 'article-update-date-lapsed)))
3137 (defun gnus-stop-date-timer ()
3138 "Stop the X-Sent timer."
3140 (when article-lapsed-timer
3141 (nnheader-cancel-timer article-lapsed-timer)
3142 (setq article-lapsed-timer nil)))
3144 (defun article-date-user (&optional highlight)
3145 "Convert the current article date to the user-defined format.
3146 This format is defined by the `gnus-article-time-format' variable."
3147 (interactive (list t))
3148 (article-date-ut 'user highlight))
3150 (defun article-date-iso8601 (&optional highlight)
3151 "Convert the current article date to ISO8601."
3152 (interactive (list t))
3153 (article-date-ut 'iso8601 highlight))
3155 (defmacro gnus-article-save-original-date (&rest forms)
3156 "Save the original date as a text property and evaluate FORMS."
3157 `(let* ((case-fold-search t)
3159 (goto-char (point-min))
3160 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3163 (date (when (and start
3164 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3166 (buffer-substring-no-properties start
3167 (match-beginning 0)))))
3168 (goto-char (point-max))
3169 (skip-chars-backward "\n")
3170 (put-text-property (point-min) (point) 'original-date date)
3172 (goto-char (point-max))
3173 (skip-chars-backward "\n")
3174 (put-text-property (point-min) (point) 'original-date date)))
3176 ;; (defun article-show-all ()
3177 ;; "Show all hidden text in the article buffer."
3180 ;; (let ((inhibit-read-only t))
3181 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3183 (defun article-remove-leading-whitespace ()
3184 "Remove excessive whitespace from all headers."
3188 (let ((inhibit-read-only t))
3189 (article-narrow-to-head)
3190 (goto-char (point-min))
3191 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3192 (delete-region (match-beginning 1) (match-end 1)))))))
3194 (defun article-emphasize (&optional arg)
3195 "Emphasize text according to `gnus-emphasis-alist'."
3196 (interactive (gnus-article-hidden-arg))
3197 (unless (gnus-article-check-hidden-text 'emphasis arg)
3201 (with-current-buffer gnus-summary-buffer
3202 gnus-article-emphasis-alist)
3204 gnus-emphasis-alist))
3205 (inhibit-read-only t)
3206 (props (append '(article-type emphasis)
3207 gnus-hidden-properties))
3208 regexp elem beg invisible visible face)
3211 (while (setq elem (pop alist))
3213 (setq regexp (car elem)
3214 invisible (nth 1 elem)
3215 visible (nth 2 elem)
3217 (while (re-search-forward regexp nil t)
3218 (when (and (match-beginning visible) (match-beginning invisible))
3219 (gnus-article-hide-text
3220 (match-beginning invisible) (match-end invisible) props)
3221 (gnus-article-unhide-text-type
3222 (match-beginning visible) (match-end visible) 'emphasis)
3223 (gnus-put-overlay-excluding-newlines
3224 (match-beginning visible) (match-end visible) 'face face)
3225 (gnus-add-wash-type 'emphasis)
3226 (goto-char (match-end invisible)))))))))
3228 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3229 "Setup newsgroup emphasis alist."
3230 (unless gnus-article-emphasis-alist
3231 (let ((name (and gnus-newsgroup-name
3232 (gnus-group-real-name gnus-newsgroup-name))))
3233 (make-local-variable 'gnus-article-emphasis-alist)
3234 (setq gnus-article-emphasis-alist
3236 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3237 (while (setq elem (pop alist))
3238 (when (and name (string-match (car elem) name))
3240 highlight (copy-sequence (cdr elem)))))
3242 (copy-sequence highlight-words)
3243 (if gnus-newsgroup-name
3244 (copy-sequence (gnus-group-find-parameter
3245 gnus-newsgroup-name 'highlight-words t)))
3246 gnus-emphasis-alist)))))
3249 (defvar gnus-summary-article-menu)
3250 (defvar gnus-summary-post-menu))
3252 ;;; Saving functions.
3254 (defun gnus-article-save (save-buffer file &optional num)
3255 "Save the currently selected article."
3256 (unless gnus-save-all-headers
3257 ;; Remove headers according to `gnus-saved-headers'.
3258 (let ((gnus-visible-headers
3259 (or gnus-saved-headers gnus-visible-headers))
3260 (gnus-article-buffer save-buffer))
3262 (set-buffer save-buffer)
3263 (article-hide-headers 1 t))))
3264 (save-window-excursion
3265 (if (not gnus-default-article-saver)
3266 (error "No default saver is defined")
3267 ;; !!! Magic! The saving functions all save
3268 ;; `gnus-save-article-buffer' (or so they think), but we
3269 ;; bind that variable to our save-buffer.
3270 (set-buffer gnus-article-buffer)
3271 (let* ((gnus-save-article-buffer save-buffer)
3274 ((not gnus-prompt-before-saving) 'default)
3275 ((eq gnus-prompt-before-saving 'always) nil)
3277 (gnus-number-of-articles-to-be-saved
3278 (when (eq gnus-prompt-before-saving t)
3280 (set-buffer gnus-article-current-summary)
3281 (funcall gnus-default-article-saver filename)))))
3283 (defun gnus-read-save-file-name (prompt &optional filename
3284 function group headers variable)
3286 (funcall function group headers (symbol-value variable)))
3291 ((eq filename 'default)
3297 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3300 (if (and gnus-number-of-articles-to-be-saved
3301 (> gnus-number-of-articles-to-be-saved 1))
3302 (format "these %d articles"
3303 gnus-number-of-articles-to-be-saved)
3306 ;; Let the split methods have their say.
3308 ;; No split name was found.
3311 (concat prompt " (default "
3312 (file-name-nondirectory default-name) ") ")
3313 (file-name-directory default-name)
3315 ;; A single group name is returned.
3316 ((stringp split-name)
3318 (funcall function split-name headers
3319 (symbol-value variable)))
3321 (concat prompt " (default "
3322 (file-name-nondirectory default-name) ") ")
3323 (file-name-directory default-name)
3325 ;; A single split name was found
3326 ((= 1 (length split-name))
3327 (let* ((name (expand-file-name
3329 gnus-article-save-directory))
3330 (dir (cond ((file-directory-p name)
3331 (file-name-as-directory name))
3332 ((file-exists-p name) name)
3333 (t gnus-article-save-directory))))
3335 (concat prompt " (default " name ") ")
3337 ;; A list of splits was found.<