1 ;;; gnus-art.el --- article mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
29 (eval-when-compile (require 'cl))
42 (autoload 'gnus-msg-mail "gnus-msg" nil t)
43 (autoload 'gnus-button-mailto "gnus-msg")
44 (autoload 'gnus-button-reply "gnus-msg" nil t)
46 (defgroup gnus-article nil
48 :link '(custom-manual "(gnus)The Article Buffer")
51 (defgroup gnus-article-treat nil
52 "Treating article parts."
53 :link '(custom-manual "(gnus)Article Hiding")
56 (defgroup gnus-article-hiding nil
57 "Hiding article parts."
58 :link '(custom-manual "(gnus)Article Hiding")
61 (defgroup gnus-article-highlight nil
62 "Article highlighting."
63 :link '(custom-manual "(gnus)Article Highlighting")
67 (defgroup gnus-article-signature nil
69 :link '(custom-manual "(gnus)Article Signature")
72 (defgroup gnus-article-headers nil
74 :link '(custom-manual "(gnus)Hiding Headers")
77 (defgroup gnus-article-washing nil
78 "Special commands on articles."
79 :link '(custom-manual "(gnus)Article Washing")
82 (defgroup gnus-article-emphasis nil
83 "Fontisizing articles."
84 :link '(custom-manual "(gnus)Article Fontisizing")
87 (defgroup gnus-article-saving nil
89 :link '(custom-manual "(gnus)Saving Articles")
92 (defgroup gnus-article-mime nil
93 "Worshiping the MIME wonder."
94 :link '(custom-manual "(gnus)Using MIME")
97 (defgroup gnus-article-buttons nil
98 "Pushable buttons in the article buffer."
99 :link '(custom-manual "(gnus)Article Buttons")
100 :group 'gnus-article)
102 (defgroup gnus-article-various nil
103 "Other article options."
104 :link '(custom-manual "(gnus)Misc Article")
105 :group 'gnus-article)
107 (defcustom gnus-ignored-headers
108 '("^Path:" "^Expires:" "^Date-Received:" "^References:" "^Xref:" "^Lines:"
109 "^Relay-Version:" "^Message-ID:" "^Approved:" "^Sender:" "^Received:"
110 "^X-UIDL:" "^MIME-Version:" "^Return-Path:" "^In-Reply-To:"
111 "^Content-Type:" "^Content-Transfer-Encoding:" "^X-WebTV-Signature:"
112 "^X-MimeOLE:" "^X-MSMail-Priority:" "^X-Priority:" "^X-Loop:"
113 "^X-Authentication-Warning:" "^X-MIME-Autoconverted:" "^X-Face:"
114 "^X-Attribution:" "^X-Originating-IP:" "^Delivered-To:"
115 "^NNTP-[-A-Za-z]+:" "^Distribution:" "^X-no-archive:" "^X-Trace:"
116 "^X-Complaints-To:" "^X-NNTP-Posting-Host:" "^X-Orig.*:"
117 "^Abuse-Reports-To:" "^Cache-Post-Path:" "^X-Article-Creation-Date:"
118 "^X-Poster:" "^X-Mail2News-Path:" "^X-Server-Date:" "^X-Cache:"
119 "^Originator:" "^X-Problems-To:" "^X-Auth-User:" "^X-Post-Time:"
120 "^X-Admin:" "^X-UID:" "^Resent-[-A-Za-z]+:" "^X-Mailing-List:"
121 "^Precedence:" "^Original-[-A-Za-z]+:" "^X-filename:" "^X-Orcpt:"
122 "^Old-Received:" "^X-Pgp" "^X-Auth:" "^X-From-Line:"
123 "^X-Gnus-Article-Number:" "^X-Majordomo:" "^X-Url:" "^X-Sender:"
124 "^MBOX-Line" "^Priority:" "^X400-[-A-Za-z]+:"
125 "^Status:" "^X-Gnus-Mail-Source:" "^Cancel-Lock:"
126 "^X-FTN" "^X-EXP32-SerialNo:" "^Encoding:" "^Importance:"
127 "^Autoforwarded:" "^Original-Encoded-Information-Types:" "^X-Ya-Pop3:"
128 "^X-Face-Version:" "^X-Vms-To:" "^X-ML-NAME:" "^X-ML-COUNT:"
129 "^Mailing-List:" "^X-finfo:" "^X-md5sum:" "^X-md5sum-Origin:"
130 "^X-Sun-Charset:" "^X-Accept-Language:" "^X-Envelope-Sender:"
131 "^List-[A-Za-z]+:" "^X-Listprocessor-Version:"
132 "^X-Received:" "^X-Distribute:" "^X-Sequence:" "^X-Juno-Line-Breaks:"
133 "^X-Notes-Item:" "^X-MS-TNEF-Correlator:" "^x-uunet-gateway:"
134 "^X-Received:" "^Content-length:" "X-precedence:"
135 "^X-Authenticated-User:" "^X-Comment" "^X-Report:" "^X-Abuse-Info:"
136 "^X-HTTP-Proxy:" "^X-Mydeja-Info:" "^X-Copyright" "^X-No-Markup:"
137 "^X-Abuse-Info:" "^X-From_:" "^X-Accept-Language:" "^Errors-To:"
138 "^X-BeenThere:" "^X-Mailman-Version:" "^List-Help:" "^List-Post:"
139 "^List-Subscribe:" "^List-Id:" "^List-Unsubscribe:" "^List-Archive:"
140 "^X-Content-length:" "^X-Posting-Agent:" "^Original-Received:")
141 "*All headers that start with this regexp will be hidden.
142 This variable can also be a list of regexps of headers to be ignored.
143 If `gnus-visible-headers' is non-nil, this variable will be ignored."
144 :type '(choice :custom-show nil
147 :group 'gnus-article-hiding)
149 (defcustom gnus-visible-headers
150 "^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:"
151 "*All headers that do not match this regexp will be hidden.
152 This variable can also be a list of regexp of headers to remain visible.
153 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
154 :type '(repeat :value-to-internal (lambda (widget value)
155 (custom-split-regexp-maybe value))
156 :match (lambda (widget value)
158 (widget-editable-list-match widget value)))
160 :group 'gnus-article-hiding)
162 (defcustom gnus-sorted-header-list
163 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
164 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
165 "*This variable is a list of regular expressions.
166 If it is non-nil, headers that match the regular expressions will
167 be placed first in the article buffer in the sequence specified by
169 :type '(repeat regexp)
170 :group 'gnus-article-hiding)
172 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
173 "Headers that are only to be displayed if they have interesting data.
174 Possible values in this list are:
176 'empty Headers with no content.
177 'newsgroups Newsgroup identical to Gnus group.
178 'to-address To identical to To-address.
179 'followup-to Followup-to identical to Newsgroups.
180 'reply-to Reply-to identical to From.
181 'date Date less than four days old.
182 'long-to To and/or Cc longer than 1024 characters.
183 'many-to Multiple To and/or Cc."
184 :type '(set (const :tag "Headers with no content." empty)
185 (const :tag "Newsgroups identical to Gnus group." newsgroups)
186 (const :tag "To identical to To-address." to-address)
187 (const :tag "Followup-to identical to Newsgroups." followup-to)
188 (const :tag "Reply-to identical to From." reply-to)
189 (const :tag "Date less than four days old." date)
190 (const :tag "To and/or Cc longer than 1024 characters." long-to)
191 (const :tag "Multiple To and/or Cc headers." many-to))
192 :group 'gnus-article-hiding)
194 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
195 "Regexp matching signature separator.
196 This can also be a list of regexps. In that case, it will be checked
197 from head to tail looking for a separator. Searches will be done from
198 the end of the buffer."
199 :type '(repeat string)
200 :group 'gnus-article-signature)
202 (defcustom gnus-signature-limit nil
203 "Provide a limit to what is considered a signature.
204 If it is a number, no signature may not be longer (in characters) than
205 that number. If it is a floating point number, no signature may be
206 longer (in lines) than that number. If it is a function, the function
207 will be called without any parameters, and if it returns nil, there is
208 no signature in the buffer. If it is a string, it will be used as a
209 regexp. If it matches, the text in question is not a signature."
210 :type '(choice (integer :value 200)
212 (function :value fun)
213 (regexp :value ".*"))
214 :group 'gnus-article-signature)
216 (defcustom gnus-hidden-properties '(invisible t intangible t)
217 "Property list to use for hiding text."
219 :group 'gnus-article-hiding)
221 ;; Fixme: This isn't the right thing for mixed graphical and and
222 ;; non-graphical frames in a session.
223 (defcustom gnus-article-x-face-command
224 (if (featurep 'xemacs)
225 (if (or (featurep 'xface)
227 'gnus-xmas-article-display-xface
228 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
229 (if (and (fboundp 'image-type-available-p)
230 (image-type-available-p 'xbm))
231 'gnus-article-display-xface
232 (if gnus-article-compface-xbm
233 "{ echo '/* Width=48, Height=48 */'; uncompface; } | display -"
234 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
236 "*String or function to be executed to display an X-Face header.
237 If it is a string, the command will be executed in a sub-shell
238 asynchronously. The compressed face will be piped to this command."
239 :type `(choice string
241 ,(if (featurep 'xemacs)
242 'gnus-xmas-article-display-xface
243 'gnus-article-display-xface))
246 :group 'gnus-article-washing)
248 (defcustom gnus-article-x-face-too-ugly nil
249 "Regexp matching posters whose face shouldn't be shown automatically."
250 :type '(choice regexp (const nil))
251 :group 'gnus-article-washing)
253 (defcustom gnus-article-banner-alist nil
254 "Banner alist for stripping.
256 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
258 :type '(repeat (cons symbol regexp))
259 :group 'gnus-article-washing)
261 (gnus-define-group-parameter
264 "Alist of regexps (to match group names) and banner."
265 :variable-group gnus-article-washing
267 '(choice :tag "Banner"
269 (const :tag "Remove signature" signature)
270 (symbol :tag "Item in `gnus-article-banner-alist'" none)
272 (const :tag "None" nil))
274 "If non-nil, specify how to remove `banners' from articles.
276 Symbol `signature' means to remove signatures delimited by
277 `gnus-signature-separator'. Any other symbol is used to look up a
278 regular expression to match the banner in `gnus-article-banner-alist'.
279 A string is used as a regular expression to match the banner
282 (defcustom gnus-emphasis-alist
284 "\\(\\s-\\|^\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\s-\\|[-,;:\"]\\s-\\|[?!.]+\\s-\\|\\s)\\)")
286 '(("_" "_" underline)
289 ("_/" "/_" underline-italic)
290 ("_\\*" "\\*_" underline-bold)
291 ("\\*/" "/\\*" bold-italic)
292 ("_\\*/" "/\\*_" underline-bold-italic))))
293 `(("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
294 2 3 gnus-emphasis-underline)
298 (format format (car spec) (cadr spec))
299 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
301 "*Alist that says how to fontify certain phrases.
302 Each item looks like this:
304 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
306 The first element is a regular expression to be matched. The second
307 is a number that says what regular expression grouping used to find
308 the entire emphasized word. The third is a number that says what
309 regexp grouping should be displayed and highlighted. The fourth
310 is the face used for highlighting."
311 :type '(repeat (list :value ("" 0 0 default)
313 (integer :tag "Match group")
314 (integer :tag "Emphasize group")
316 :group 'gnus-article-emphasis)
318 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
319 "A regexp to describe whitespace which should not be emphasized.
320 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
321 The former avoids underlining of leading and trailing whitespace,
322 and the latter avoids underlining any whitespace at all."
324 :group 'gnus-article-emphasis
327 (defface gnus-emphasis-bold '((t (:bold t)))
328 "Face used for displaying strong emphasized text (*word*)."
329 :group 'gnus-article-emphasis)
331 (defface gnus-emphasis-italic '((t (:italic t)))
332 "Face used for displaying italic emphasized text (/word/)."
333 :group 'gnus-article-emphasis)
335 (defface gnus-emphasis-underline '((t (:underline t)))
336 "Face used for displaying underlined emphasized text (_word_)."
337 :group 'gnus-article-emphasis)
339 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
340 "Face used for displaying underlined bold emphasized text (_*word*_)."
341 :group 'gnus-article-emphasis)
343 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
344 "Face used for displaying underlined italic emphasized text (_/word/_)."
345 :group 'gnus-article-emphasis)
347 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
348 "Face used for displaying bold italic emphasized text (/*word*/)."
349 :group 'gnus-article-emphasis)
351 (defface gnus-emphasis-underline-bold-italic
352 '((t (:bold t :italic t :underline t)))
353 "Face used for displaying underlined bold italic emphasized text.
354 Esample: (_/*word*/_)."
355 :group 'gnus-article-emphasis)
357 (defface gnus-emphasis-highlight-words
358 '((t (:background "black" :foreground "yellow")))
359 "Face used for displaying highlighted words."
360 :group 'gnus-article-emphasis)
362 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
363 "Format for display of Date headers in article bodies.
364 See `format-time-string' for the possible values.
366 The variable can also be function, which should return a complete Date
367 header. The function is called with one argument, the time, which can
368 be fed to `format-time-string'."
369 :type '(choice string symbol)
370 :link '(custom-manual "(gnus)Article Date")
371 :group 'gnus-article-washing)
374 (autoload 'mail-extract-address-components "mail-extr"))
376 (defcustom gnus-save-all-headers t
377 "*If non-nil, don't remove any headers before saving."
378 :group 'gnus-article-saving
381 (defcustom gnus-prompt-before-saving 'always
382 "*This variable says how much prompting is to be done when saving articles.
383 If it is nil, no prompting will be done, and the articles will be
384 saved to the default files. If this variable is `always', each and
385 every article that is saved will be preceded by a prompt, even when
386 saving large batches of articles. If this variable is neither nil not
387 `always', there the user will be prompted once for a file name for
388 each invocation of the saving commands."
389 :group 'gnus-article-saving
390 :type '(choice (item always)
391 (item :tag "never" nil)
392 (sexp :tag "once" :format "%t\n" :value t)))
394 (defcustom gnus-saved-headers gnus-visible-headers
395 "Headers to keep if `gnus-save-all-headers' is nil.
396 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
397 If that variable is nil, however, all headers that match this regexp
398 will be kept while the rest will be deleted before saving."
399 :group 'gnus-article-saving
402 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
403 "A function to save articles in your favourite format.
404 The function must be interactively callable (in other words, it must
405 be an Emacs command).
407 Gnus provides the following functions:
409 * gnus-summary-save-in-rmail (Rmail format)
410 * gnus-summary-save-in-mail (Unix mail format)
411 * gnus-summary-save-in-folder (MH folder)
412 * gnus-summary-save-in-file (article format)
413 * gnus-summary-save-in-vm (use VM's folder format)
414 * gnus-summary-write-to-file (article format -- overwrite)."
415 :group 'gnus-article-saving
416 :type '(radio (function-item gnus-summary-save-in-rmail)
417 (function-item gnus-summary-save-in-mail)
418 (function-item gnus-summary-save-in-folder)
419 (function-item gnus-summary-save-in-file)
420 (function-item gnus-summary-save-in-vm)
421 (function-item gnus-summary-write-to-file)))
423 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
424 "A function generating a file name to save articles in Rmail format.
425 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
426 :group 'gnus-article-saving
429 (defcustom gnus-mail-save-name 'gnus-plain-save-name
430 "A function generating a file name to save articles in Unix mail format.
431 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
432 :group 'gnus-article-saving
435 (defcustom gnus-folder-save-name 'gnus-folder-save-name
436 "A function generating a file name to save articles in MH folder.
437 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
438 :group 'gnus-article-saving
441 (defcustom gnus-file-save-name 'gnus-numeric-save-name
442 "A function generating a file name to save articles in article format.
443 The function is called with NEWSGROUP, HEADERS, and optional
445 :group 'gnus-article-saving
448 (defcustom gnus-split-methods
449 '((gnus-article-archive-name)
450 (gnus-article-nndoc-name))
451 "*Variable used to suggest where articles are to be saved.
452 For instance, if you would like to save articles related to Gnus in
453 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
454 you could set this variable to something like:
456 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
457 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
459 This variable is an alist where the where the key is the match and the
460 value is a list of possible files to save in if the match is non-nil.
462 If the match is a string, it is used as a regexp match on the
463 article. If the match is a symbol, that symbol will be funcalled
464 from the buffer of the article to be saved with the newsgroup as the
465 parameter. If it is a list, it will be evaled in the same buffer.
467 If this form or function returns a string, this string will be used as
468 a possible file name; and if it returns a non-nil list, that list will
469 be used as possible file names."
470 :group 'gnus-article-saving
471 :type '(repeat (choice (list :value (fun) function)
472 (cons :value ("" "") regexp (repeat string))
475 (defcustom gnus-page-delimiter "^\^L"
476 "*Regexp describing what to use as article page delimiters.
477 The default value is \"^\^L\", which is a form linefeed at the
478 beginning of a line."
480 :group 'gnus-article-various)
482 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
483 "*The format specification for the article mode line.
484 See `gnus-summary-mode-line-format' for a closer description.
486 The following additional specs are available:
488 %w The article washing status.
489 %m The number of MIME parts in the article."
491 :group 'gnus-article-various)
493 (defcustom gnus-article-mode-hook nil
494 "*A hook for Gnus article mode."
496 :group 'gnus-article-various)
498 (when (featurep 'xemacs)
499 ;; Extracted from gnus-xmas-define in order to preserve user settings
500 (when (fboundp 'turn-off-scroll-in-place)
501 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
502 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
503 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
505 (defcustom gnus-article-menu-hook nil
506 "*Hook run after the creation of the article mode menu."
508 :group 'gnus-article-various)
510 (defcustom gnus-article-prepare-hook nil
511 "*A hook called after an article has been prepared in the article buffer."
513 :group 'gnus-article-various)
515 (defcustom gnus-article-hide-pgp-hook nil
516 "*A hook called after successfully hiding a PGP signature."
518 :group 'gnus-article-various)
520 (defcustom gnus-article-button-face 'bold
521 "Face used for highlighting buttons in the article buffer.
523 An article button is a piece of text that you can activate by pressing
524 `RET' or `mouse-2' above it."
526 :group 'gnus-article-buttons)
528 (defcustom gnus-article-mouse-face 'highlight
529 "Face used for mouse highlighting in the article buffer.
531 Article buttons will be displayed in this face when the cursor is
534 :group 'gnus-article-buttons)
536 (defcustom gnus-signature-face 'gnus-signature-face
537 "Face used for highlighting a signature in the article buffer.
538 Obsolete; use the face `gnus-signature-face' for customizations instead."
540 :group 'gnus-article-highlight
541 :group 'gnus-article-signature)
543 (defface gnus-signature-face
546 "Face used for highlighting a signature in the article buffer."
547 :group 'gnus-article-highlight
548 :group 'gnus-article-signature)
550 (defface gnus-header-from-face
553 (:foreground "spring green"))
556 (:foreground "red3"))
559 "Face used for displaying from headers."
560 :group 'gnus-article-headers
561 :group 'gnus-article-highlight)
563 (defface gnus-header-subject-face
566 (:foreground "SeaGreen3"))
569 (:foreground "red4"))
571 (:bold t :italic t)))
572 "Face used for displaying subject headers."
573 :group 'gnus-article-headers
574 :group 'gnus-article-highlight)
576 (defface gnus-header-newsgroups-face
579 (:foreground "yellow" :italic t))
582 (:foreground "MidnightBlue" :italic t))
585 "Face used for displaying newsgroups headers."
586 :group 'gnus-article-headers
587 :group 'gnus-article-highlight)
589 (defface gnus-header-name-face
592 (:foreground "SeaGreen"))
595 (:foreground "maroon"))
598 "Face used for displaying header names."
599 :group 'gnus-article-headers
600 :group 'gnus-article-highlight)
602 (defface gnus-header-content-face
605 (:foreground "forest green" :italic t))
608 (:foreground "indianred4" :italic t))
610 (:italic t))) "Face used for displaying header content."
611 :group 'gnus-article-headers
612 :group 'gnus-article-highlight)
614 (defcustom gnus-header-face-alist
615 '(("From" nil gnus-header-from-face)
616 ("Subject" nil gnus-header-subject-face)
617 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
618 ("" gnus-header-name-face gnus-header-content-face))
619 "*Controls highlighting of article header.
621 An alist of the form (HEADER NAME CONTENT).
623 HEADER is a regular expression which should match the name of an
624 header header and NAME and CONTENT are either face names or nil.
626 The name of each header field will be displayed using the face
627 specified by the first element in the list where HEADER match the
628 header name and NAME is non-nil. Similarly, the content will be
629 displayed by the first non-nil matching CONTENT face."
630 :group 'gnus-article-headers
631 :group 'gnus-article-highlight
632 :type '(repeat (list (regexp :tag "Header")
634 (item :tag "skip" nil)
635 (face :value default))
636 (choice :tag "Content"
637 (item :tag "skip" nil)
638 (face :value default)))))
640 (defcustom gnus-article-decode-hook
641 '(article-decode-charset article-decode-encoded-words)
642 "*Hook run to decode charsets in articles."
643 :group 'gnus-article-headers
646 (defcustom gnus-display-mime-function 'gnus-display-mime
647 "Function to display MIME articles."
648 :group 'gnus-article-mime
651 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
652 "Function used to decode headers.")
654 (defvar gnus-article-dumbquotes-map
673 "Table for MS-to-Latin1 translation.")
675 (defcustom gnus-ignored-mime-types nil
676 "List of MIME types that should be ignored by Gnus."
678 :group 'gnus-article-mime
679 :type '(repeat regexp))
681 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
682 "List of MIME types that should not be given buttons when rendered inline.
683 See also `gnus-buttonized-mime-types' which may override this variable."
685 :group 'gnus-article-mime
686 :type '(repeat regexp))
688 (defcustom gnus-buttonized-mime-types nil
689 "List of MIME types that should be given buttons when rendered inline.
690 If set, this variable overrides `gnus-unbuttonized-mime-types'.
691 To see e.g. security buttons you could set this to
692 `(\"multipart/signed\")'."
694 :group 'gnus-article-mime
695 :type '(repeat regexp))
697 (defcustom gnus-article-mime-part-function nil
698 "Function called with a MIME handle as the argument.
699 This is meant for people who want to do something automatic based
700 on parts -- for instance, adding Vcard info to a database."
701 :group 'gnus-article-mime
704 (defcustom gnus-mime-multipart-functions nil
705 "An alist of MIME types to functions to display them."
707 :group 'gnus-article-mime
710 (defcustom gnus-article-date-lapsed-new-header nil
711 "Whether the X-Sent and Date headers can coexist.
712 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
713 either replace the old \"Date:\" header (if this variable is nil), or
714 be added below it (otherwise)."
716 :group 'gnus-article-headers
719 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
720 "Function called with a MIME handle as the argument.
721 This is meant for people who want to view first matched part.
722 For `undisplayed-alternative' (default), the first undisplayed
723 part or alternative part is used. For `undisplayed', the first
724 undisplayed part is used. For a function, the first part which
725 the function return `t' is used. For `nil', the first part is
728 :group 'gnus-article-mime
730 (item :tag "first" :value nil)
731 (item :tag "undisplayed" :value undisplayed)
732 (item :tag "undisplayed or alternative"
733 :value undisplayed-alternative)
736 (defcustom gnus-mime-action-alist
737 '(("save to file" . gnus-mime-save-part)
738 ("save and strip" . gnus-mime-save-part-and-strip)
739 ("display as text" . gnus-mime-inline-part)
740 ("view the part" . gnus-mime-view-part)
741 ("pipe to command" . gnus-mime-pipe-part)
742 ("toggle display" . gnus-article-press-button)
743 ("toggle display" . gnus-article-view-part-as-charset)
744 ("view as type" . gnus-mime-view-part-as-type)
745 ("internalize type" . gnus-mime-internalize-part)
746 ("externalize type" . gnus-mime-externalize-part))
747 "An alist of actions that run on the MIME attachment."
748 :group 'gnus-article-mime
749 :type '(repeat (cons (string :tag "name")
752 (defcustom gnus-mime-action-alist
753 '(("save to file" . gnus-mime-save-part)
754 ("display as text" . gnus-mime-inline-part)
755 ("view the part" . gnus-mime-view-part)
756 ("pipe to command" . gnus-mime-pipe-part)
757 ("toggle display" . gnus-article-press-button)
758 ("view as type" . gnus-mime-view-part-as-type)
759 ("internalize type" . gnus-mime-internalize-part)
760 ("externalize type" . gnus-mime-externalize-part))
761 "An alist of actions that run on the MIME attachment."
763 :group 'gnus-article-mime
764 :type '(repeat (cons (string :tag "name")
768 ;;; The treatment variables
771 (defvar gnus-part-display-hook nil
772 "Hook called on parts that are to receive treatment.")
774 (defvar gnus-article-treat-custom
775 '(choice (const :tag "Off" nil)
777 (const :tag "Header" head)
778 (const :tag "Last" last)
779 (integer :tag "Less")
780 (repeat :tag "Groups" regexp)
781 (sexp :tag "Predicate")))
783 (defvar gnus-article-treat-head-custom
784 '(choice (const :tag "Off" nil)
785 (const :tag "Header" head)))
787 (defvar gnus-article-treat-types '("text/plain")
790 (defvar gnus-inhibit-treatment nil
791 "Whether to inhibit treatment.")
793 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
794 "Highlight the signature.
795 Valid values are nil, t, `head', `last', an integer or a predicate.
796 See the manual for details."
797 :group 'gnus-article-treat
798 :type gnus-article-treat-custom)
799 (put 'gnus-treat-highlight-signature 'highlight t)
801 (defcustom gnus-treat-buttonize 100000
803 Valid values are nil, t, `head', `last', an integer or a predicate.
804 See the manual for details."
805 :group 'gnus-article-treat
806 :type gnus-article-treat-custom)
807 (put 'gnus-treat-buttonize 'highlight t)
809 (defcustom gnus-treat-buttonize-head 'head
810 "Add buttons to the head.
811 Valid values are nil, t, `head', `last', an integer or a predicate.
812 See the manual for details."
813 :group 'gnus-article-treat
814 :type gnus-article-treat-head-custom)
815 (put 'gnus-treat-buttonize-head 'highlight t)
817 (defcustom gnus-treat-emphasize
818 (and (or window-system
820 (>= (string-to-number emacs-version) 21))
823 Valid values are nil, t, `head', `last', an integer or a predicate.
824 See the manual for details."
825 :group 'gnus-article-treat
826 :type gnus-article-treat-custom)
827 (put 'gnus-treat-emphasize 'highlight t)
829 (defcustom gnus-treat-strip-cr nil
830 "Remove carriage returns.
831 Valid values are nil, t, `head', `last', an integer or a predicate.
832 See the manual for details."
833 :group 'gnus-article-treat
834 :type gnus-article-treat-custom)
836 (defcustom gnus-treat-leading-whitespace nil
837 "Remove leading whitespace in headers.
838 Valid values are nil, t, `head', `last', an integer or a predicate.
839 See the manual for details."
840 :group 'gnus-article-treat
841 :type gnus-article-treat-custom)
843 (defcustom gnus-treat-hide-headers 'head
845 Valid values are nil, t, `head', `last', an integer or a predicate.
846 See the manual for details."
847 :group 'gnus-article-treat
848 :type gnus-article-treat-head-custom)
850 (defcustom gnus-treat-hide-boring-headers nil
851 "Hide boring headers.
852 Valid values are nil, t, `head', `last', an integer or a predicate.
853 See the manual for details."
854 :group 'gnus-article-treat
855 :type gnus-article-treat-head-custom)
857 (defcustom gnus-treat-hide-signature nil
859 Valid values are nil, t, `head', `last', an integer or a predicate.
860 See the manual for details."
861 :group 'gnus-article-treat
862 :type gnus-article-treat-custom)
864 (defcustom gnus-treat-fill-article nil
866 Valid values are nil, t, `head', `last', an integer or a predicate.
867 See the manual for details."
868 :group 'gnus-article-treat
869 :type gnus-article-treat-custom)
871 (defcustom gnus-treat-hide-citation nil
873 Valid values are nil, t, `head', `last', an integer or a predicate.
874 See the manual for details."
875 :group 'gnus-article-treat
876 :type gnus-article-treat-custom)
878 (defcustom gnus-treat-hide-citation-maybe nil
880 Valid values are nil, t, `head', `last', an integer or a predicate.
881 See the manual for details."
882 :group 'gnus-article-treat
883 :type gnus-article-treat-custom)
885 (defcustom gnus-treat-hide-citation-maybe nil
887 Valid values are nil, t, `head', `last', an integer or a predicate.
888 See the manual for details."
889 :group 'gnus-article-treat
890 :type gnus-article-treat-custom)
892 (defcustom gnus-treat-strip-list-identifiers 'head
893 "Strip list identifiers from `gnus-list-identifiers`.
894 Valid values are nil, t, `head', `last', an integer or a predicate.
895 See the manual for details."
897 :group 'gnus-article-treat
898 :type gnus-article-treat-custom)
900 (defcustom gnus-treat-strip-pgp t
901 "Strip PGP signatures.
902 Valid values are nil, t, `head', `last', an integer or a predicate.
903 See the manual for details."
904 :group 'gnus-article-treat
905 :type gnus-article-treat-custom)
907 (defcustom gnus-treat-strip-pem nil
908 "Strip PEM signatures.
909 Valid values are nil, t, `head', `last', an integer or a predicate.
910 See the manual for details."
911 :group 'gnus-article-treat
912 :type gnus-article-treat-custom)
914 (defcustom gnus-treat-strip-banner t
915 "Strip banners from articles.
916 The banner to be stripped is specified in the `banner' group parameter.
917 Valid values are nil, t, `head', `last', an integer or a predicate.
918 See the manual for details."
919 :group 'gnus-article-treat
920 :type gnus-article-treat-custom)
922 (defcustom gnus-treat-highlight-headers 'head
923 "Highlight the headers.
924 Valid values are nil, t, `head', `last', an integer or a predicate.
925 See the manual for details."
926 :group 'gnus-article-treat
927 :type gnus-article-treat-head-custom)
928 (put 'gnus-treat-highlight-headers 'highlight t)
930 (defcustom gnus-treat-highlight-citation t
931 "Highlight cited text.
932 Valid values are nil, t, `head', `last', an integer or a predicate.
933 See the manual for details."
934 :group 'gnus-article-treat
935 :type gnus-article-treat-custom)
936 (put 'gnus-treat-highlight-citation 'highlight t)
938 (defcustom gnus-treat-date-ut nil
939 "Display the Date in UT (GMT).
940 Valid values are nil, t, `head', `last', an integer or a predicate.
941 See the manual for details."
942 :group 'gnus-article-treat
943 :type gnus-article-treat-head-custom)
945 (defcustom gnus-treat-date-local nil
946 "Display the Date in the local timezone.
947 Valid values are nil, t, `head', `last', an integer or a predicate.
948 See the manual for details."
949 :group 'gnus-article-treat
950 :type gnus-article-treat-head-custom)
952 (defcustom gnus-treat-date-english nil
953 "Display the Date in a format that can be read aloud in English.
954 Valid values are nil, t, `head', `last', an integer or a predicate.
955 See the manual for details."
956 :group 'gnus-article-treat
957 :type gnus-article-treat-head-custom)
959 (defcustom gnus-treat-date-lapsed nil
960 "Display the Date header in a way that says how much time has elapsed.
961 Valid values are nil, t, `head', `last', an integer or a predicate.
962 See the manual for details."
963 :group 'gnus-article-treat
964 :type gnus-article-treat-head-custom)
966 (defcustom gnus-treat-date-original nil
967 "Display the date in the original timezone.
968 Valid values are nil, t, `head', `last', an integer or a predicate.
969 See the manual for details."
970 :group 'gnus-article-treat
971 :type gnus-article-treat-head-custom)
973 (defcustom gnus-treat-date-iso8601 nil
974 "Display the date in the ISO8601 format.
975 Valid values are nil, t, `head', `last', an integer or a predicate.
976 See the manual for details."
978 :group 'gnus-article-treat
979 :type gnus-article-treat-head-custom)
981 (defcustom gnus-treat-date-user-defined nil
982 "Display the date in a user-defined format.
983 The format is defined by the `gnus-article-time-format' variable.
984 Valid values are nil, t, `head', `last', an integer or a predicate.
985 See the manual for details."
986 :group 'gnus-article-treat
987 :type gnus-article-treat-head-custom)
989 (defcustom gnus-treat-strip-headers-in-body t
990 "Strip the X-No-Archive header line from the beginning of the body.
991 Valid values are nil, t, `head', `last', an integer or a predicate.
992 See the manual for details."
994 :group 'gnus-article-treat
995 :type gnus-article-treat-custom)
997 (defcustom gnus-treat-strip-trailing-blank-lines nil
998 "Strip trailing blank lines.
999 Valid values are nil, t, `head', `last', an integer or a predicate.
1000 See the manual for details."
1001 :group 'gnus-article-treat
1002 :type gnus-article-treat-custom)
1004 (defcustom gnus-treat-strip-leading-blank-lines nil
1005 "Strip leading blank lines.
1006 Valid values are nil, t, `head', `last', an integer or a predicate.
1007 See the manual for details."
1008 :group 'gnus-article-treat
1009 :type gnus-article-treat-custom)
1011 (defcustom gnus-treat-strip-multiple-blank-lines nil
1012 "Strip multiple blank lines.
1013 Valid values are nil, t, `head', `last', an integer or a predicate.
1014 See the manual for details."
1015 :group 'gnus-article-treat
1016 :type gnus-article-treat-custom)
1018 (defcustom gnus-treat-overstrike t
1019 "Treat overstrike highlighting.
1020 Valid values are nil, t, `head', `last', an integer or a predicate.
1021 See the manual for details."
1022 :group 'gnus-article-treat
1023 :type gnus-article-treat-custom)
1024 (put 'gnus-treat-overstrike 'highlight t)
1026 (defcustom gnus-treat-display-xface
1027 (and (or (and (fboundp 'image-type-available-p)
1028 (image-type-available-p 'xbm)
1029 (string-match "^0x" (shell-command-to-string "uncompface")))
1030 (and (featurep 'xemacs) (featurep 'xface)))
1032 "Display X-Face headers.
1033 Valid values are nil, t, `head', `last', an integer or a predicate.
1034 See the manual for details."
1035 :group 'gnus-article-treat
1037 :type gnus-article-treat-head-custom)
1038 (put 'gnus-treat-display-xface 'highlight t)
1040 (defcustom gnus-treat-display-smileys
1041 (if (or (and (featurep 'xemacs)
1043 (and (fboundp 'image-type-available-p)
1044 (image-type-available-p 'pbm)))
1047 Valid values are nil, t, `head', `last', an integer or a predicate.
1048 See the manual for details."
1049 :group 'gnus-article-treat
1051 :type gnus-article-treat-custom)
1052 (put 'gnus-treat-display-smileys 'highlight t)
1054 (defcustom gnus-treat-display-picons (if (featurep 'xemacs) 'head nil)
1056 Valid values are nil, t, `head', `last', an integer or a predicate.
1057 See the manual for details."
1058 :group 'gnus-article-treat
1059 :type gnus-article-treat-head-custom)
1060 (put 'gnus-treat-display-picons 'highlight t)
1062 (defcustom gnus-treat-capitalize-sentences nil
1063 "Capitalize sentence-starting words.
1064 Valid values are nil, t, `head', `last', an integer or a predicate.
1065 See the manual for details."
1067 :group 'gnus-article-treat
1068 :type gnus-article-treat-custom)
1070 (defcustom gnus-treat-fill-long-lines nil
1072 Valid values are nil, t, `head', `last', an integer or a predicate.
1073 See the manual for details."
1074 :group 'gnus-article-treat
1075 :type gnus-article-treat-custom)
1077 (defcustom gnus-treat-play-sounds nil
1079 Valid values are nil, t, `head', `last', an integer or a predicate.
1080 See the manual for details."
1082 :group 'gnus-article-treat
1083 :type gnus-article-treat-custom)
1085 (defcustom gnus-treat-translate nil
1086 "Translate articles from one language to another.
1087 Valid values are nil, t, `head', `last', an integer or a predicate.
1088 See the manual for details."
1090 :group 'gnus-article-treat
1091 :type gnus-article-treat-custom)
1093 (defcustom gnus-treat-x-pgp-sig nil
1095 To automatically treat X-PGP-Sig, set it to head.
1096 Valid values are nil, t, `head', `last', an integer or a predicate.
1097 See the manual for details."
1098 :group 'gnus-article-treat
1099 :group 'mime-security
1100 :type gnus-article-treat-custom)
1102 (defvar gnus-article-encrypt-protocol-alist
1103 '(("PGP" . mml2015-self-encrypt)))
1105 ;; Set to nil if more than one protocol added to
1106 ;; gnus-article-encrypt-protocol-alist.
1107 (defcustom gnus-article-encrypt-protocol "PGP"
1108 "The protocol used for encrypt articles.
1109 It is a string, such as \"PGP\". If nil, ask user."
1111 :group 'mime-security)
1113 ;;; Internal variables
1115 (defvar gnus-english-month-names
1116 '("January" "February" "March" "April" "May" "June" "July" "August"
1117 "September" "October" "November" "December"))
1119 (defvar article-goto-body-goes-to-point-min-p nil)
1120 (defvar gnus-article-wash-types nil)
1121 (defvar gnus-article-emphasis-alist nil)
1123 (defvar gnus-article-mime-handle-alist-1 nil)
1124 (defvar gnus-treatment-function-alist
1125 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1126 (gnus-treat-strip-banner gnus-article-strip-banner)
1127 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1128 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1129 (gnus-treat-buttonize gnus-article-add-buttons)
1130 (gnus-treat-fill-article gnus-article-fill-cited-article)
1131 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1132 (gnus-treat-strip-cr gnus-article-remove-cr)
1133 (gnus-treat-emphasize gnus-article-emphasize)
1134 (gnus-treat-display-xface gnus-article-display-x-face)
1135 (gnus-treat-date-ut gnus-article-date-ut)
1136 (gnus-treat-date-local gnus-article-date-local)
1137 (gnus-treat-date-english gnus-article-date-english)
1138 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1139 (gnus-treat-date-original gnus-article-date-original)
1140 (gnus-treat-date-user-defined gnus-article-date-user)
1141 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1142 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1143 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1144 (gnus-treat-hide-signature gnus-article-hide-signature)
1145 (gnus-treat-hide-citation gnus-article-hide-citation)
1146 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1147 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1148 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1149 (gnus-treat-strip-pgp gnus-article-hide-pgp)
1150 (gnus-treat-strip-pem gnus-article-hide-pem)
1151 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1152 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1153 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1154 (gnus-treat-strip-trailing-blank-lines
1155 gnus-article-remove-trailing-blank-lines)
1156 (gnus-treat-strip-leading-blank-lines
1157 gnus-article-strip-leading-blank-lines)
1158 (gnus-treat-strip-multiple-blank-lines
1159 gnus-article-strip-multiple-blank-lines)
1160 (gnus-treat-overstrike gnus-article-treat-overstrike)
1161 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1162 (gnus-treat-display-smileys gnus-smiley-display)
1163 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1164 (gnus-treat-display-picons gnus-article-display-picons)
1165 (gnus-treat-play-sounds gnus-earcon-display)))
1167 (defvar gnus-article-mime-handle-alist nil)
1168 (defvar article-lapsed-timer nil)
1169 (defvar gnus-article-current-summary nil)
1171 (defvar gnus-article-mode-syntax-table
1172 (let ((table (copy-syntax-table text-mode-syntax-table)))
1173 ;; This causes the citation match run O(2^n).
1174 ;; (modify-syntax-entry ?- "w" table)
1175 (modify-syntax-entry ?> ")" table)
1176 (modify-syntax-entry ?< "(" table)
1178 "Syntax table used in article mode buffers.
1179 Initialized from `text-mode-syntax-table.")
1181 (defvar gnus-save-article-buffer nil)
1183 (defvar gnus-article-mode-line-format-alist
1184 (nconc '((?w (gnus-article-wash-status) ?s)
1185 (?m (gnus-article-mime-part-status) ?s))
1186 gnus-summary-mode-line-format-alist))
1188 (defvar gnus-number-of-articles-to-be-saved nil)
1190 (defvar gnus-inhibit-hiding nil)
1192 (defsubst gnus-article-hide-text (b e props)
1193 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1194 (gnus-add-text-properties-when 'article-type nil b e props)
1195 (when (memq 'intangible props)
1197 (max (1- b) (point-min))
1198 b 'intangible (cddr (memq 'intangible props)))))
1200 (defsubst gnus-article-unhide-text (b e)
1201 "Remove hidden text properties from region between B and E."
1202 (remove-text-properties b e gnus-hidden-properties)
1203 (when (memq 'intangible gnus-hidden-properties)
1204 (put-text-property (max (1- b) (point-min))
1205 b 'intangible nil)))
1207 (defun gnus-article-hide-text-type (b e type)
1208 "Hide text of TYPE between B and E."
1209 (push type gnus-article-wash-types)
1210 (gnus-article-hide-text
1211 b e (cons 'article-type (cons type gnus-hidden-properties))))
1213 (defun gnus-article-unhide-text-type (b e type)
1214 "Unhide text of TYPE between B and E."
1215 (setq gnus-article-wash-types
1216 (delq type gnus-article-wash-types))
1217 (remove-text-properties
1218 b e (cons 'article-type (cons type gnus-hidden-properties)))
1219 (when (memq 'intangible gnus-hidden-properties)
1220 (put-text-property (max (1- b) (point-min))
1221 b 'intangible nil)))
1223 (defun gnus-article-hide-text-of-type (type)
1224 "Hide text of TYPE in the current buffer."
1226 (let ((b (point-min))
1228 (while (setq b (text-property-any b e 'article-type type))
1229 (add-text-properties b (incf b) gnus-hidden-properties)))))
1231 (defun gnus-article-delete-text-of-type (type)
1232 "Delete text of TYPE in the current buffer."
1234 (let ((b (point-min)))
1235 (while (setq b (text-property-any b (point-max) 'article-type type))
1237 b (or (text-property-not-all b (point-max) 'article-type type)
1240 (defun gnus-article-delete-invisible-text ()
1241 "Delete all invisible text in the current buffer."
1243 (let ((b (point-min)))
1244 (while (setq b (text-property-any b (point-max) 'invisible t))
1246 b (or (text-property-not-all b (point-max) 'invisible t)
1249 (defun gnus-article-text-type-exists-p (type)
1250 "Say whether any text of type TYPE exists in the buffer."
1251 (text-property-any (point-min) (point-max) 'article-type type))
1253 (defsubst gnus-article-header-rank ()
1254 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1255 (let ((list gnus-sorted-header-list)
1258 (when (looking-at (car list))
1260 (setq list (cdr list))
1264 (defun article-hide-headers (&optional arg delete)
1265 "Hide unwanted headers and possibly sort them as well."
1267 ;; This function might be inhibited.
1268 (unless gnus-inhibit-hiding
1271 (let ((buffer-read-only nil)
1272 (case-fold-search t)
1273 (max (1+ (length gnus-sorted-header-list)))
1274 (ignored (when (not gnus-visible-headers)
1275 (cond ((stringp gnus-ignored-headers)
1276 gnus-ignored-headers)
1277 ((listp gnus-ignored-headers)
1278 (mapconcat 'identity gnus-ignored-headers
1281 (cond ((stringp gnus-visible-headers)
1282 gnus-visible-headers)
1283 ((and gnus-visible-headers
1284 (listp gnus-visible-headers))
1285 (mapconcat 'identity gnus-visible-headers "\\|"))))
1286 (inhibit-point-motion-hooks t)
1288 ;; First we narrow to just the headers.
1289 (article-narrow-to-head)
1290 ;; Hide any "From " lines at the beginning of (mail) articles.
1291 (while (looking-at "From ")
1294 (delete-region (point-min) (point)))
1295 ;; Then treat the rest of the header lines.
1296 ;; Then we use the two regular expressions
1297 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1298 ;; select which header lines is to remain visible in the
1300 (while (re-search-forward "^[^ \t:]*:" nil t)
1302 ;; Mark the rank of the header.
1304 (point) (1+ (point)) 'message-rank
1305 (if (or (and visible (looking-at visible))
1307 (not (looking-at ignored))))
1308 (gnus-article-header-rank)
1311 (message-sort-headers-1)
1312 (when (setq beg (text-property-any
1313 (point-min) (point-max) 'message-rank (+ 2 max)))
1314 ;; We delete the unwanted headers.
1315 (push 'headers gnus-article-wash-types)
1316 (add-text-properties (point-min) (+ 5 (point-min))
1317 '(article-type headers dummy-invisible t))
1318 (delete-region beg (point-max))))))))
1320 (defun article-hide-boring-headers (&optional arg)
1321 "Toggle hiding of headers that aren't very interesting.
1322 If given a negative prefix, always show; if given a positive prefix,
1324 (interactive (gnus-article-hidden-arg))
1325 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1326 (not gnus-show-all-headers))
1329 (let ((buffer-read-only nil)
1330 (list gnus-boring-article-headers)
1331 (inhibit-point-motion-hooks t)
1333 (article-narrow-to-head)
1335 (setq elem (pop list))
1336 (goto-char (point-min))
1338 ;; Hide empty headers.
1340 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1342 (gnus-article-hide-text-type
1343 (progn (beginning-of-line) (point))
1346 (if (re-search-forward "^[^ \t]" nil t)
1350 ;; Hide boring Newsgroups header.
1351 ((eq elem 'newsgroups)
1352 (when (gnus-string-equal
1353 (gnus-fetch-field "newsgroups")
1354 (gnus-group-real-name
1355 (if (boundp 'gnus-newsgroup-name)
1358 (gnus-article-hide-header "newsgroups")))
1359 ((eq elem 'to-address)
1360 (let ((to (message-fetch-field "to"))
1362 (gnus-parameter-to-address
1363 (if (boundp 'gnus-newsgroup-name)
1364 gnus-newsgroup-name ""))))
1365 (when (and to to-address
1368 ;; only one address in To
1369 (nth 1 (mail-extract-address-components to))
1371 (gnus-article-hide-header "to"))))
1372 ((eq elem 'followup-to)
1373 (when (gnus-string-equal
1374 (message-fetch-field "followup-to")
1375 (message-fetch-field "newsgroups"))
1376 (gnus-article-hide-header "followup-to")))
1377 ((eq elem 'reply-to)
1378 (let ((from (message-fetch-field "from"))
1379 (reply-to (message-fetch-field "reply-to")))
1384 (nth 1 (mail-extract-address-components from))
1385 (nth 1 (mail-extract-address-components reply-to)))))
1386 (gnus-article-hide-header "reply-to"))))
1388 (let ((date (message-fetch-field "date")))
1390 (< (days-between (current-time-string) date)
1392 (gnus-article-hide-header "date"))))
1394 (let ((to (message-fetch-field "to"))
1395 (cc (message-fetch-field "cc")))
1396 (when (> (length to) 1024)
1397 (gnus-article-hide-header "to"))
1398 (when (> (length cc) 1024)
1399 (gnus-article-hide-header "cc"))))
1403 (goto-char (point-min))
1404 (while (re-search-forward "^to:" nil t)
1405 (setq to-count (1+ to-count)))
1406 (when (> to-count 1)
1407 (while (> to-count 0)
1408 (goto-char (point-min))
1410 (re-search-forward "^to:" nil nil to-count)
1412 (narrow-to-region (point) (point-max))
1413 (gnus-article-hide-header "to"))
1414 (setq to-count (1- to-count))))
1415 (goto-char (point-min))
1416 (while (re-search-forward "^cc:" nil t)
1417 (setq cc-count (1+ cc-count)))
1418 (when (> cc-count 1)
1419 (while (> cc-count 0)
1420 (goto-char (point-min))
1422 (re-search-forward "^cc:" nil nil cc-count)
1424 (narrow-to-region (point) (point-max))
1425 (gnus-article-hide-header "cc"))
1426 (setq cc-count (1- cc-count)))))))))))))
1428 (defun gnus-article-hide-header (header)
1430 (goto-char (point-min))
1431 (when (re-search-forward (concat "^" header ":") nil t)
1432 (gnus-article-hide-text-type
1433 (progn (beginning-of-line) (point))
1436 (if (re-search-forward "^[^ \t]" nil t)
1441 (defvar gnus-article-normalized-header-length 40
1442 "Length of normalized headers.")
1444 (defun article-normalize-headers ()
1445 "Make all header lines 40 characters long."
1447 (let ((buffer-read-only nil)
1451 (article-narrow-to-head)
1454 ((< (setq column (- (gnus-point-at-eol) (point)))
1455 gnus-article-normalized-header-length)
1457 (insert (make-string
1458 (- gnus-article-normalized-header-length column)
1460 ((> column gnus-article-normalized-header-length)
1461 (gnus-put-text-property
1463 (forward-char gnus-article-normalized-header-length)
1470 (forward-line 1))))))
1472 (defun article-treat-dumbquotes ()
1473 "Translate M****s*** sm*rtq**t*s into proper text.
1474 Note that this function guesses whether a character is a sm*rtq**t* or
1475 not, so it should only be used interactively.
1477 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1478 in an attempt to provide more quoting characters. If you see
1479 something like \\222 or \\264 where you're expecting some kind of
1480 apostrophe or quotation mark, then try this wash."
1482 (article-translate-strings gnus-article-dumbquotes-map))
1484 (defun article-translate-characters (from to)
1485 "Translate all characters in the body of the article according to FROM and TO.
1486 FROM is a string of characters to translate from; to is a string of
1487 characters to translate to."
1489 (when (article-goto-body)
1490 (let ((buffer-read-only nil)
1491 (x (make-string 225 ?x))
1493 (while (< (incf i) (length x))
1496 (while (< i (length from))
1497 (aset x (aref from i) (aref to i))
1499 (translate-region (point) (point-max) x)))))
1501 (defun article-translate-strings (map)
1502 "Translate all string in the body of the article according to MAP.
1503 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1505 (when (article-goto-body)
1506 (let ((buffer-read-only nil)
1508 (while (setq elem (pop map))
1510 (while (search-forward (car elem) nil t)
1511 (replace-match (cadr elem)))))))))
1513 (defun article-treat-overstrike ()
1514 "Translate overstrikes into bold text."
1517 (when (article-goto-body)
1518 (let ((buffer-read-only nil))
1519 (while (search-forward "\b" nil t)
1520 (let ((next (char-after))
1521 (previous (char-after (- (point) 2))))
1522 ;; We do the boldification/underlining by hiding the
1523 ;; overstrikes and putting the proper text property
1527 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1528 (put-text-property (point) (1+ (point)) 'face 'bold))
1530 (gnus-article-hide-text-type
1531 (1- (point)) (1+ (point)) 'overstrike)
1533 (- (point) 2) (1- (point)) 'face 'underline))
1535 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1537 (point) (1+ (point)) 'face 'underline)))))))))
1539 (defun article-fill-long-lines ()
1540 "Fill lines that are wider than the window width."
1543 (let ((buffer-read-only nil)
1544 (width (window-width (get-buffer-window (current-buffer)))))
1547 (let ((adaptive-fill-mode nil)) ;Why? -sm
1550 (when (>= (current-column) (min fill-column width))
1551 (narrow-to-region (point) (gnus-point-at-bol))
1552 (fill-paragraph nil)
1553 (goto-char (point-max))
1555 (forward-line 1)))))))
1557 (defun article-capitalize-sentences ()
1558 "Capitalize the first word in each sentence."
1561 (let ((buffer-read-only nil)
1562 (paragraph-start "^[\n\^L]"))
1566 (forward-sentence)))))
1568 (defun article-remove-cr ()
1569 "Remove trailing CRs and then translate remaining CRs into LFs."
1572 (let ((buffer-read-only nil))
1573 (goto-char (point-min))
1574 (while (re-search-forward "\r+$" nil t)
1575 (replace-match "" t t))
1576 (goto-char (point-min))
1577 (while (search-forward "\r" nil t)
1578 (replace-match "\n" t t)))))
1580 (defun article-remove-trailing-blank-lines ()
1581 "Remove all trailing blank lines from the article."
1584 (let ((buffer-read-only nil))
1585 (goto-char (point-max))
1589 (while (and (not (bobp))
1590 (looking-at "^[ \t]*$")
1591 (not (gnus-annotation-in-region-p
1592 (point) (gnus-point-at-eol))))
1597 (defun article-display-x-face (&optional force)
1598 "Look for an X-Face header and display it if present."
1599 (interactive (list 'force))
1601 ;; Delete the old process, if any.
1602 (when (process-status "article-x-face")
1603 (delete-process "article-x-face"))
1604 (let ((inhibit-point-motion-hooks t)
1606 (case-fold-search t)
1609 (article-narrow-to-head)
1610 (when (and buffer-read-only ;; When type `W f'
1612 (goto-char (point-min))
1613 (not (re-search-forward "^X-Face:[\t ]*" nil t)))
1614 (gnus-buffer-live-p gnus-original-article-buffer))
1615 (with-current-buffer gnus-original-article-buffer
1617 (article-narrow-to-head)
1618 (while (re-search-forward "^X-Face:" nil t)
1624 (1- (re-search-forward
1625 "^\\($\\|[^ \t]\\)" nil t))))))))
1627 (let (point start bface eface buffer-read-only)
1628 (goto-char (point-max))
1630 (setq bface (get-text-property (gnus-point-at-bol) 'face)
1631 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
1632 (goto-char (point-max))
1633 (setq point (point))
1636 (while (looking-at "\\([^:]+\\): *")
1637 (put-text-property (match-beginning 1) (1+ (match-end 1))
1639 (setq start (match-end 0))
1641 (while (looking-at "[\t ]")
1643 (put-text-property start (point)
1645 (goto-char (point-min))
1646 (setq from (message-fetch-field "from"))
1647 (goto-char (point-min))
1648 (while (and gnus-article-x-face-command
1651 ;; Check whether this face is censored.
1652 (not gnus-article-x-face-too-ugly)
1653 (and gnus-article-x-face-too-ugly from
1654 (not (string-match gnus-article-x-face-too-ugly
1656 ;; Has to be present.
1657 (re-search-forward "^X-Face:[\t ]*" nil t))
1658 ;; This used to try to do multiple faces (`while' instead of
1659 ;; `when' above), but (a) sending multiple EOFs to xv doesn't
1660 ;; work (b) it can crash some versions of Emacs (c) are
1661 ;; multiple faces really something to encourage?
1662 (when (stringp gnus-article-x-face-command)
1664 ;; We now have the area of the buffer where the X-Face is stored.
1667 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
1668 ;; We display the face.
1669 (if (symbolp gnus-article-x-face-command)
1670 ;; The command is a lisp function, so we call it.
1671 (if (gnus-functionp gnus-article-x-face-command)
1672 (funcall gnus-article-x-face-command beg end)
1673 (error "%s is not a function" gnus-article-x-face-command))
1674 ;; The command is a string, so we interpret the command
1675 ;; as a, well, command, and fork it off.
1676 (let ((process-connection-type nil))
1677 (process-kill-without-query
1679 "article-x-face" nil shell-file-name shell-command-switch
1680 gnus-article-x-face-command))
1681 (process-send-region "article-x-face" beg end)
1682 (process-send-eof "article-x-face"))))))))))
1684 (defun article-decode-mime-words ()
1685 "Decode all MIME-encoded words in the article."
1688 (set-buffer gnus-article-buffer)
1689 (let ((inhibit-point-motion-hooks t)
1691 (mail-parse-charset gnus-newsgroup-charset)
1692 (mail-parse-ignored-charsets
1693 (save-excursion (set-buffer gnus-summary-buffer)
1694 gnus-newsgroup-ignored-charsets)))
1695 (mail-decode-encoded-word-region (point-min) (point-max)))))
1697 (defun article-decode-charset (&optional prompt)
1698 "Decode charset-encoded text in the article.
1699 If PROMPT (the prefix), prompt for a coding system to use."
1701 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
1703 (mail-parse-charset gnus-newsgroup-charset)
1704 (mail-parse-ignored-charsets
1705 (save-excursion (condition-case nil
1706 (set-buffer gnus-summary-buffer)
1708 gnus-newsgroup-ignored-charsets))
1709 ct cte ctl charset format)
1712 (article-narrow-to-head)
1713 (setq ct (message-fetch-field "Content-Type" t)
1714 cte (message-fetch-field "Content-Transfer-Encoding" t)
1715 ctl (and ct (ignore-errors
1716 (mail-header-parse-content-type ct)))
1719 (mm-read-coding-system "Charset to decode: "))
1721 (mail-content-type-get ctl 'charset)))
1722 format (and ctl (mail-content-type-get ctl 'format)))
1724 (setq cte (mail-header-strip cte)))
1725 (if (and ctl (not (string-match "/" (car ctl))))
1727 (goto-char (point-max)))
1730 (narrow-to-region (point) (point-max))
1731 (when (and (eq mail-parse-charset 'gnus-decoded)
1732 (eq (mm-body-7-or-8) '8bit))
1733 ;; The text code could have been decoded.
1734 (setq charset mail-parse-charset))
1735 (when (and (or (not ctl)
1736 (equal (car ctl) "text/plain"))
1737 (not format)) ;; article with format will decode later.
1739 charset (and cte (intern (downcase
1740 (gnus-strip-whitespace cte))))
1743 (defun article-decode-encoded-words ()
1744 "Remove encoded-word encoding from headers."
1745 (let ((inhibit-point-motion-hooks t)
1746 (mail-parse-charset gnus-newsgroup-charset)
1747 (mail-parse-ignored-charsets
1748 (save-excursion (condition-case nil
1749 (set-buffer gnus-summary-buffer)
1751 gnus-newsgroup-ignored-charsets))
1754 (article-narrow-to-head)
1755 (funcall gnus-decode-header-function (point-min) (point-max)))))
1757 (defun article-de-quoted-unreadable (&optional force read-charset)
1758 "Translate a quoted-printable-encoded article.
1759 If FORCE, decode the article whether it is marked as quoted-printable
1761 If READ-CHARSET, ask for a coding system."
1762 (interactive (list 'force current-prefix-arg))
1764 (let ((buffer-read-only nil) type charset)
1765 (if (gnus-buffer-live-p gnus-original-article-buffer)
1766 (with-current-buffer gnus-original-article-buffer
1768 (gnus-fetch-field "content-transfer-encoding"))
1769 (let* ((ct (gnus-fetch-field "content-type"))
1772 (mail-header-parse-content-type ct)))))
1773 (setq charset (and ctl
1774 (mail-content-type-get ctl 'charset)))
1775 (if (stringp charset)
1776 (setq charset (intern (downcase charset)))))))
1778 (setq charset (mm-read-coding-system "Charset: " charset)))
1780 (setq charset gnus-newsgroup-charset))
1782 (and type (let ((case-fold-search t))
1783 (string-match "quoted-printable" type))))
1785 (quoted-printable-decode-region
1786 (point) (point-max) (mm-charset-to-coding-system charset))))))
1788 (defun article-de-base64-unreadable (&optional force read-charset)
1789 "Translate a base64 article.
1790 If FORCE, decode the article whether it is marked as base64 not.
1791 If READ-CHARSET, ask for a coding system."
1792 (interactive (list 'force current-prefix-arg))
1794 (let ((buffer-read-only nil) type charset)
1795 (if (gnus-buffer-live-p gnus-original-article-buffer)
1796 (with-current-buffer gnus-original-article-buffer
1798 (gnus-fetch-field "content-transfer-encoding"))
1799 (let* ((ct (gnus-fetch-field "content-type"))
1802 (mail-header-parse-content-type ct)))))
1803 (setq charset (and ctl
1804 (mail-content-type-get ctl 'charset)))
1805 (if (stringp charset)
1806 (setq charset (intern (downcase charset)))))))
1808 (setq charset (mm-read-coding-system "Charset: " charset)))
1810 (setq charset gnus-newsgroup-charset))
1812 (and type (let ((case-fold-search t))
1813 (string-match "base64" type))))
1816 (narrow-to-region (point) (point-max))
1817 (base64-decode-region (point-min) (point-max))
1818 (mm-decode-coding-region
1819 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
1824 (defun article-decode-HZ ()
1825 "Translate a HZ-encoded article."
1829 (let ((buffer-read-only nil))
1830 (rfc1843-decode-region (point-min) (point-max)))))
1832 (defun article-wash-html (&optional read-charset)
1833 "Format an html article.
1834 If READ-CHARSET, ask for a coding system."
1837 (let ((buffer-read-only nil)
1839 (if (gnus-buffer-live-p gnus-original-article-buffer)
1840 (with-current-buffer gnus-original-article-buffer
1841 (let* ((ct (gnus-fetch-field "content-type"))
1844 (mail-header-parse-content-type ct)))))
1845 (setq charset (and ctl
1846 (mail-content-type-get ctl 'charset)))
1847 (if (stringp charset)
1848 (setq charset (intern (downcase charset)))))))
1850 (setq charset (mm-read-coding-system "Charset: " charset)))
1852 (setq charset gnus-newsgroup-charset))
1854 (save-window-excursion
1856 (narrow-to-region (point) (point-max))
1858 (let ((w3-strict-width (window-width))
1859 (url-standalone-mode t))
1861 (w3-region (point-min) (point-max))
1864 (defun article-hide-list-identifiers ()
1865 "Remove list identifies from the Subject header.
1866 The `gnus-list-identifiers' variable specifies what to do."
1868 (let ((inhibit-point-motion-hooks t)
1869 (regexp (if (consp gnus-list-identifiers)
1870 (mapconcat 'identity gnus-list-identifiers " *\\|")
1871 gnus-list-identifiers))
1876 (article-narrow-to-head)
1877 (goto-char (point-min))
1878 (while (re-search-forward
1879 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
1881 (delete-region (match-beginning 2) (match-end 0))
1882 (beginning-of-line))
1883 (when (re-search-forward
1884 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
1885 (delete-region (match-beginning 1) (match-end 1))))))))
1887 (defun article-hide-pgp ()
1888 "Remove any PGP headers and signatures in the current article."
1892 (let ((inhibit-point-motion-hooks t)
1893 buffer-read-only beg end)
1895 ;; Hide the "header".
1896 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
1897 (push 'pgp gnus-article-wash-types)
1898 (delete-region (match-beginning 0) (match-end 0))
1899 ;; Remove armor headers (rfc2440 6.2)
1900 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
1903 ;; Hide the actual signature.
1904 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
1905 (setq end (1+ (match-beginning 0)))
1908 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
1910 ;; Perhaps we shouldn't hide to the end of the buffer
1911 ;; if there is no end to the signature?
1913 ;; Hide "- " PGP quotation markers.
1915 (narrow-to-region beg end)
1916 (goto-char (point-min))
1917 (while (re-search-forward "^- " nil t)
1919 (match-beginning 0) (match-end 0)))
1921 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
1923 (defun article-hide-pem (&optional arg)
1924 "Toggle hiding of any PEM headers and signatures in the current article.
1925 If given a negative prefix, always show; if given a positive prefix,
1927 (interactive (gnus-article-hidden-arg))
1928 (unless (gnus-article-check-hidden-text 'pem arg)
1930 (let (buffer-read-only end)
1931 (goto-char (point-min))
1932 ;; Hide the horrendously ugly "header".
1933 (when (and (search-forward
1934 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
1936 (setq end (1+ (match-beginning 0))))
1937 (push 'pem gnus-article-wash-types)
1938 (gnus-article-hide-text-type
1940 (if (search-forward "\n\n" nil t)
1944 ;; Hide the trailer as well
1945 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
1947 (gnus-article-hide-text-type
1948 (match-beginning 0) (match-end 0) 'pem)))))))
1950 (defun article-strip-banner ()
1951 "Strip the banner specified by the `banner' group parameter."
1955 (let ((inhibit-point-motion-hooks t)
1956 (banner (gnus-parameter-banner gnus-newsgroup-name))
1957 (gnus-signature-limit nil)
1958 buffer-read-only beg end)
1962 ((eq banner 'signature)
1963 (when (gnus-article-narrow-to-signature)
1966 (delete-region (point) (point-max))))
1968 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
1969 (while (re-search-forward banner nil t)
1970 (delete-region (match-beginning 0) (match-end 0)))))
1972 (while (re-search-forward banner nil t)
1973 (delete-region (match-beginning 0) (match-end 0))))))))))
1975 (defun article-babel ()
1976 "Translate article using an online translation service."
1980 (set-buffer gnus-article-buffer)
1981 (when (article-goto-body)
1982 (let* ((buffer-read-only nil)
1985 (orig (buffer-substring start end))
1986 (trans (babel-as-string orig)))
1988 (narrow-to-region start end)
1989 (delete-region start end)
1992 (defun article-hide-signature (&optional arg)
1993 "Hide the signature in the current article.
1994 If given a negative prefix, always show; if given a positive prefix,
1996 (interactive (gnus-article-hidden-arg))
1997 (unless (gnus-article-check-hidden-text 'signature arg)
2000 (let ((buffer-read-only nil))
2001 (when (gnus-article-narrow-to-signature)
2002 (gnus-article-hide-text-type
2003 (point-min) (point-max) 'signature)))))))
2005 (defun article-strip-headers-in-body ()
2006 "Strip offensive headers from bodies."
2010 (let ((case-fold-search t))
2011 (when (looking-at "x-no-archive:")
2012 (gnus-delete-line)))))
2014 (defun article-strip-leading-blank-lines ()
2015 "Remove all blank lines from the beginning of the article."
2018 (let ((inhibit-point-motion-hooks t)
2020 (when (article-goto-body)
2021 (while (and (not (eobp))
2022 (looking-at "[ \t]*$"))
2023 (gnus-delete-line))))))
2025 (defun article-narrow-to-head ()
2026 "Narrow the buffer to the head of the message.
2027 Point is left at the beginning of the narrowed-to region."
2029 (goto-char (point-min))
2030 (if (search-forward "\n\n" nil 1)
2033 (goto-char (point-min)))
2035 (defun article-goto-body ()
2036 "Place point at the start of the body."
2037 (goto-char (point-min))
2039 ;; This variable is only bound when dealing with separate
2041 (article-goto-body-goes-to-point-min-p
2043 ((search-forward "\n\n" nil t)
2046 (goto-char (point-max))
2049 (defun article-strip-multiple-blank-lines ()
2050 "Replace consecutive blank lines with one empty line."
2053 (let ((inhibit-point-motion-hooks t)
2055 ;; First make all blank lines empty.
2057 (while (re-search-forward "^[ \t]+$" nil t)
2058 (unless (gnus-annotation-in-region-p
2059 (match-beginning 0) (match-end 0))
2060 (replace-match "" nil t)))
2061 ;; Then replace multiple empty lines with a single empty line.
2063 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2064 (unless (gnus-annotation-in-region-p
2065 (match-beginning 0) (match-end 0))
2066 (delete-region (match-beginning 1) (match-end 1)))))))
2068 (defun article-strip-leading-space ()
2069 "Remove all white space from the beginning of the lines in the article."
2072 (let ((inhibit-point-motion-hooks t)
2075 (while (re-search-forward "^[ \t]+" nil t)
2076 (replace-match "" t t)))))
2078 (defun article-strip-trailing-space ()
2079 "Remove all white space from the end of the lines in the article."
2082 (let ((inhibit-point-motion-hooks t)
2085 (while (re-search-forward "[ \t]+$" nil t)
2086 (replace-match "" t t)))))
2088 (defun article-strip-blank-lines ()
2089 "Strip leading, trailing and multiple blank lines."
2091 (article-strip-leading-blank-lines)
2092 (article-remove-trailing-blank-lines)
2093 (article-strip-multiple-blank-lines))
2095 (defun article-strip-all-blank-lines ()
2096 "Strip all blank lines."
2099 (let ((inhibit-point-motion-hooks t)
2102 (while (re-search-forward "^[ \t]*\n" nil t)
2103 (replace-match "" t t)))))
2105 (defun gnus-article-narrow-to-signature ()
2106 "Narrow to the signature; return t if a signature is found, else nil."
2107 (let ((inhibit-point-motion-hooks t))
2108 (when (gnus-article-search-signature)
2110 ;; Check whether we have some limits to what we consider
2111 ;; to be a signature.
2112 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2113 (list gnus-signature-limit)))
2115 (while (setq limit (pop limits))
2116 (if (or (and (integerp limit)
2117 (< (- (point-max) (point)) limit))
2119 (< (count-lines (point) (point-max)) limit))
2120 (and (gnus-functionp limit)
2122 (and (stringp limit)
2123 (not (re-search-forward limit nil t))))
2124 () ; This limit did not succeed.
2128 (narrow-to-region (point) (point-max))
2131 (defun gnus-article-search-signature ()
2132 "Search the current buffer for the signature separator.
2133 Put point at the beginning of the signature separator."
2134 (let ((cur (point)))
2135 (goto-char (point-max))
2136 (if (if (stringp gnus-signature-separator)
2137 (re-search-backward gnus-signature-separator nil t)
2138 (let ((seps gnus-signature-separator))
2140 (not (re-search-backward (car seps) nil t)))
2147 (defun gnus-article-hidden-arg ()
2148 "Return the current prefix arg as a number, or 0 if no prefix."
2149 (list (if current-prefix-arg
2150 (prefix-numeric-value current-prefix-arg)
2153 (defun gnus-article-check-hidden-text (type arg)
2154 "Return nil if hiding is necessary.
2155 Arg can be nil or a number. Nil and positive means hide, negative
2156 means show, 0 means toggle."
2159 (let ((hide (gnus-article-hidden-text-p type)))
2165 (gnus-article-show-hidden-text type)
2168 (if (eq hide 'hidden)
2170 (gnus-article-show-hidden-text type)
2174 (defun gnus-article-hidden-text-p (type)
2175 "Say whether the current buffer contains hidden text of type TYPE."
2176 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2178 (not (get-text-property pos 'invisible))
2179 (not (get-text-property pos 'dummy-invisible)))
2181 (text-property-any (1+ pos) (point-max) 'article-type type)))
2186 (defun gnus-article-show-hidden-text (type &optional dummy)
2187 "Show all hidden text of type TYPE.
2188 Originally it is hide instead of DUMMY."
2189 (let ((buffer-read-only nil)
2190 (inhibit-point-motion-hooks t))
2191 (gnus-remove-text-properties-when
2193 (point-min) (point-max)
2194 (cons 'article-type (cons type
2195 gnus-hidden-properties)))))
2197 (defconst article-time-units
2198 `((year . ,(* 365.25 24 60 60))
2199 (week . ,(* 7 24 60 60))
2200 (day . ,(* 24 60 60))
2204 "Mapping from time units to seconds.")
2206 (defun article-date-ut (&optional type highlight header)
2207 "Convert DATE date to universal time in the current article.
2208 If TYPE is `local', convert to local time; if it is `lapsed', output
2209 how much time has lapsed since DATE. For `lapsed', the value of
2210 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2211 should replace the \"Date:\" one, or should be added below it."
2212 (interactive (list 'ut t))
2213 (let* ((header (or header
2214 (message-fetch-field "date")
2216 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2219 ((not gnus-article-date-lapsed-new-header)
2225 (date (if (vectorp header) (mail-header-date header)
2227 (inhibit-point-motion-hooks t)
2232 (article-narrow-to-head)
2233 (when (re-search-forward tdate-regexp nil t)
2234 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2235 date (or (get-text-property (gnus-point-at-bol)
2238 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2240 (when (and date (not (string= date "")))
2241 (goto-char (point-min))
2242 (let ((buffer-read-only nil))
2243 ;; Delete any old Date headers.
2244 (while (re-search-forward date-regexp nil t)
2246 (delete-region (progn (beginning-of-line) (point))
2247 (progn (forward-line 1) (point)))
2248 (delete-region (progn (beginning-of-line) (point))
2249 (progn (end-of-line) (point)))
2250 (setq pos (point))))
2251 (when (and (not pos) (re-search-forward tdate-regexp nil t))
2253 (if pos (goto-char pos))
2254 (insert (article-make-date-line date (or type 'ut)))
2260 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2261 (put-text-property (match-beginning 1) (1+ (match-end 1))
2262 'original-date date)
2263 (put-text-property (match-beginning 1) (1+ (match-end 1))
2265 (put-text-property (match-beginning 2) (match-end 2)
2268 (defun article-make-date-line (date type)
2269 "Return a DATE line of TYPE."
2270 (unless (memq type '(local ut original user iso8601 lapsed english))
2271 (error "Unknown conversion type: %s" type))
2273 (let ((time (date-to-time date)))
2275 ;; Convert to the local timezone.
2277 (let ((tz (car (current-time-zone time))))
2278 (format "Date: %s %s%02d%02d" (current-time-string time)
2279 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2280 (/ (% (abs tz) 3600) 60))))
2281 ;; Convert to Universal Time.
2284 (current-time-string
2285 (let* ((e (parse-time-string date))
2286 (tm (apply 'encode-time e))
2288 (ls (- (cadr tm) (car (current-time-zone time)))))
2289 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2290 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2293 ;; Get the original date from the article.
2294 ((eq type 'original)
2295 (concat "Date: " (if (string-match "\n+$" date)
2296 (substring date 0 (match-beginning 0))
2298 ;; Let the user define the format.
2300 (if (gnus-functionp gnus-article-time-format)
2301 (funcall gnus-article-time-format time)
2304 (format-time-string gnus-article-time-format time))))
2307 (let ((tz (car (current-time-zone time))))
2310 (format-time-string "%Y%m%dT%H%M%S" time)
2311 (format "%s%02d%02d"
2312 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2313 (/ (% (abs tz) 3600) 60)))))
2314 ;; Do an X-Sent lapsed format.
2316 ;; If the date is seriously mangled, the timezone functions are
2317 ;; liable to bug out, so we ignore all errors.
2318 (let* ((now (current-time))
2319 (real-time (subtract-time now time))
2320 (real-sec (and real-time
2321 (+ (* (float (car real-time)) 65536)
2323 (sec (and real-time (abs real-sec)))
2333 ;; This is a bit convoluted, but basically we go
2334 ;; through the time units for years, weeks, etc,
2335 ;; and divide things to see whether that results
2336 ;; in positive answers.
2339 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2340 ;; The (remaining) seconds are too few to
2341 ;; be divided into this time unit.
2343 ;; It's big enough, so we output it.
2344 (setq sec (- sec (* num (cdr unit))))
2346 (concat (if prev ", " "") (int-to-string
2348 " " (symbol-name (car unit))
2349 (if (> num 1) "s" ""))
2351 article-time-units "")
2352 ;; If dates are odd, then it might appear like the
2353 ;; article was sent in