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:"
138 "*All headers that start with this regexp will be hidden.
139 This variable can also be a list of regexps of headers to be ignored.
140 If `gnus-visible-headers' is non-nil, this variable will be ignored."
141 :type '(choice :custom-show nil
144 :group 'gnus-article-hiding)
146 (defcustom gnus-visible-headers
147 "^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:"
148 "*All headers that do not match this regexp will be hidden.
149 This variable can also be a list of regexp of headers to remain visible.
150 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
151 :type '(repeat :value-to-internal (lambda (widget value)
152 (custom-split-regexp-maybe value))
153 :match (lambda (widget value)
155 (widget-editable-list-match widget value)))
157 :group 'gnus-article-hiding)
159 (defcustom gnus-sorted-header-list
160 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
161 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
162 "*This variable is a list of regular expressions.
163 If it is non-nil, headers that match the regular expressions will
164 be placed first in the article buffer in the sequence specified by
166 :type '(repeat regexp)
167 :group 'gnus-article-hiding)
169 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
170 "Headers that are only to be displayed if they have interesting data.
171 Possible values in this list are `empty', `newsgroups', `followup-to',
172 `to-address', `reply-to', `date', `long-to', and `many-to'."
173 :type '(set (const :tag "Headers with no content." empty)
174 (const :tag "Newsgroups with only one group." newsgroups)
175 (const :tag "To identical to to-address." to-address)
176 (const :tag "Followup-to identical to newsgroups." followup-to)
177 (const :tag "Reply-to identical to from." reply-to)
178 (const :tag "Date less than four days old." date)
179 (const :tag "Very long To and/or Cc header." long-to)
180 (const :tag "Multiple To and/or Cc headers." many-to))
181 :group 'gnus-article-hiding)
183 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
184 "Regexp matching signature separator.
185 This can also be a list of regexps. In that case, it will be checked
186 from head to tail looking for a separator. Searches will be done from
187 the end of the buffer."
188 :type '(repeat string)
189 :group 'gnus-article-signature)
191 (defcustom gnus-signature-limit nil
192 "Provide a limit to what is considered a signature.
193 If it is a number, no signature may not be longer (in characters) than
194 that number. If it is a floating point number, no signature may be
195 longer (in lines) than that number. If it is a function, the function
196 will be called without any parameters, and if it returns nil, there is
197 no signature in the buffer. If it is a string, it will be used as a
198 regexp. If it matches, the text in question is not a signature."
199 :type '(choice (integer :value 200)
201 (function :value fun)
202 (regexp :value ".*"))
203 :group 'gnus-article-signature)
205 (defcustom gnus-hidden-properties '(invisible t intangible t)
206 "Property list to use for hiding text."
208 :group 'gnus-article-hiding)
210 ;; Fixme: This isn't the right thing for mixed graphical and and
211 ;; non-graphical frames in a session.
212 ;; gnus-xmas.el overrides this for XEmacs.
213 (defcustom gnus-article-x-face-command
214 (if (and (fboundp 'image-type-available-p)
215 (image-type-available-p 'xbm))
216 'gnus-article-display-xface
217 (if gnus-article-compface-xbm
218 "{ echo '/* Width=48, Height=48 */'; uncompface; } | display -"
219 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
221 "*String or function to be executed to display an X-Face header.
222 If it is a string, the command will be executed in a sub-shell
223 asynchronously. The compressed face will be piped to this command."
224 :type '(choice string
225 (function-item gnus-article-display-xface)
228 :group 'gnus-article-washing)
230 (defcustom gnus-article-x-face-too-ugly nil
231 "Regexp matching posters whose face shouldn't be shown automatically."
232 :type '(choice regexp (const nil))
233 :group 'gnus-article-washing)
235 (defcustom gnus-article-banner-alist nil
236 "Banner alist for stripping.
238 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
240 :type '(repeat (cons symbol regexp))
241 :group 'gnus-article-washing)
243 (gnus-define-group-parameter
246 "Alist of regexps (to match group names) and banner."
247 :variable-group gnus-article-washing
249 '(choice :tag "Banner"
251 (const :tag "Remove signature" signature)
252 (symbol :tag "Item in `gnus-article-banner-alist'" none)
254 (const :tag "None" nil))
256 "If non-nil, specify how to remove `banners' from articles.
258 Symbol `signature' means to remove signatures delimited by
259 `gnus-signature-separator'. Any other symbol is used to look up a
260 regular expression to match the banner in `gnus-article-banner-alist'.
261 A string is used as a regular expression to match the banner
264 (defcustom gnus-emphasis-alist
266 "\\(\\s-\\|^\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\s-\\|[-,;:\"]\\s-\\|[?!.]+\\s-\\|\\s)\\)")
268 '(("_" "_" underline)
271 ("_/" "/_" underline-italic)
272 ("_\\*" "\\*_" underline-bold)
273 ("\\*/" "/\\*" bold-italic)
274 ("_\\*/" "/\\*_" underline-bold-italic))))
275 `(("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
276 2 3 gnus-emphasis-underline)
280 (format format (car spec) (cadr spec))
281 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
283 "*Alist that says how to fontify certain phrases.
284 Each item looks like this:
286 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
288 The first element is a regular expression to be matched. The second
289 is a number that says what regular expression grouping used to find
290 the entire emphasized word. The third is a number that says what
291 regexp grouping should be displayed and highlighted. The fourth
292 is the face used for highlighting."
293 :type '(repeat (list :value ("" 0 0 default)
295 (integer :tag "Match group")
296 (integer :tag "Emphasize group")
298 :group 'gnus-article-emphasis)
300 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
301 "A regexp to describe whitespace which should not be emphasized.
302 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
303 The former avoids underlining of leading and trailing whitespace,
304 and the latter avoids underlining any whitespace at all."
306 :group 'gnus-article-emphasis
309 (defface gnus-emphasis-bold '((t (:bold t)))
310 "Face used for displaying strong emphasized text (*word*)."
311 :group 'gnus-article-emphasis)
313 (defface gnus-emphasis-italic '((t (:italic t)))
314 "Face used for displaying italic emphasized text (/word/)."
315 :group 'gnus-article-emphasis)
317 (defface gnus-emphasis-underline '((t (:underline t)))
318 "Face used for displaying underlined emphasized text (_word_)."
319 :group 'gnus-article-emphasis)
321 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
322 "Face used for displaying underlined bold emphasized text (_*word*_)."
323 :group 'gnus-article-emphasis)
325 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
326 "Face used for displaying underlined italic emphasized text (_/word/_)."
327 :group 'gnus-article-emphasis)
329 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
330 "Face used for displaying bold italic emphasized text (/*word*/)."
331 :group 'gnus-article-emphasis)
333 (defface gnus-emphasis-underline-bold-italic
334 '((t (:bold t :italic t :underline t)))
335 "Face used for displaying underlined bold italic emphasized text.
336 Esample: (_/*word*/_)."
337 :group 'gnus-article-emphasis)
339 (defface gnus-emphasis-highlight-words
340 '((t (:background "black" :foreground "yellow")))
341 "Face used for displaying highlighted words."
342 :group 'gnus-article-emphasis)
344 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
345 "Format for display of Date headers in article bodies.
346 See `format-time-string' for the possible values.
348 The variable can also be function, which should return a complete Date
349 header. The function is called with one argument, the time, which can
350 be fed to `format-time-string'."
351 :type '(choice string symbol)
352 :link '(custom-manual "(gnus)Article Date")
353 :group 'gnus-article-washing)
356 (autoload 'mail-extract-address-components "mail-extr"))
358 (defcustom gnus-save-all-headers t
359 "*If non-nil, don't remove any headers before saving."
360 :group 'gnus-article-saving
363 (defcustom gnus-prompt-before-saving 'always
364 "*This variable says how much prompting is to be done when saving articles.
365 If it is nil, no prompting will be done, and the articles will be
366 saved to the default files. If this variable is `always', each and
367 every article that is saved will be preceded by a prompt, even when
368 saving large batches of articles. If this variable is neither nil not
369 `always', there the user will be prompted once for a file name for
370 each invocation of the saving commands."
371 :group 'gnus-article-saving
372 :type '(choice (item always)
373 (item :tag "never" nil)
374 (sexp :tag "once" :format "%t\n" :value t)))
376 (defcustom gnus-saved-headers gnus-visible-headers
377 "Headers to keep if `gnus-save-all-headers' is nil.
378 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
379 If that variable is nil, however, all headers that match this regexp
380 will be kept while the rest will be deleted before saving."
381 :group 'gnus-article-saving
384 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
385 "A function to save articles in your favourite format.
386 The function must be interactively callable (in other words, it must
387 be an Emacs command).
389 Gnus provides the following functions:
391 * gnus-summary-save-in-rmail (Rmail format)
392 * gnus-summary-save-in-mail (Unix mail format)
393 * gnus-summary-save-in-folder (MH folder)
394 * gnus-summary-save-in-file (article format)
395 * gnus-summary-save-in-vm (use VM's folder format)
396 * gnus-summary-write-to-file (article format -- overwrite)."
397 :group 'gnus-article-saving
398 :type '(radio (function-item gnus-summary-save-in-rmail)
399 (function-item gnus-summary-save-in-mail)
400 (function-item gnus-summary-save-in-folder)
401 (function-item gnus-summary-save-in-file)
402 (function-item gnus-summary-save-in-vm)
403 (function-item gnus-summary-write-to-file)))
405 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
406 "A function generating a file name to save articles in Rmail format.
407 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
408 :group 'gnus-article-saving
411 (defcustom gnus-mail-save-name 'gnus-plain-save-name
412 "A function generating a file name to save articles in Unix mail format.
413 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
414 :group 'gnus-article-saving
417 (defcustom gnus-folder-save-name 'gnus-folder-save-name
418 "A function generating a file name to save articles in MH folder.
419 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
420 :group 'gnus-article-saving
423 (defcustom gnus-file-save-name 'gnus-numeric-save-name
424 "A function generating a file name to save articles in article format.
425 The function is called with NEWSGROUP, HEADERS, and optional
427 :group 'gnus-article-saving
430 (defcustom gnus-split-methods
431 '((gnus-article-archive-name)
432 (gnus-article-nndoc-name))
433 "*Variable used to suggest where articles are to be saved.
434 For instance, if you would like to save articles related to Gnus in
435 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
436 you could set this variable to something like:
438 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
439 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
441 This variable is an alist where the where the key is the match and the
442 value is a list of possible files to save in if the match is non-nil.
444 If the match is a string, it is used as a regexp match on the
445 article. If the match is a symbol, that symbol will be funcalled
446 from the buffer of the article to be saved with the newsgroup as the
447 parameter. If it is a list, it will be evaled in the same buffer.
449 If this form or function returns a string, this string will be used as
450 a possible file name; and if it returns a non-nil list, that list will
451 be used as possible file names."
452 :group 'gnus-article-saving
453 :type '(repeat (choice (list :value (fun) function)
454 (cons :value ("" "") regexp (repeat string))
457 (defcustom gnus-page-delimiter "^\^L"
458 "*Regexp describing what to use as article page delimiters.
459 The default value is \"^\^L\", which is a form linefeed at the
460 beginning of a line."
462 :group 'gnus-article-various)
464 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
465 "*The format specification for the article mode line.
466 See `gnus-summary-mode-line-format' for a closer description.
468 The following additional specs are available:
470 %w The article washing status.
471 %m The number of MIME parts in the article."
473 :group 'gnus-article-various)
475 (defcustom gnus-article-mode-hook nil
476 "*A hook for Gnus article mode."
478 :group 'gnus-article-various)
480 (when (featurep 'xemacs)
481 ;; Extracted from gnus-xmas-define in order to preserve user settings
482 (when (fboundp 'turn-off-scroll-in-place)
483 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
484 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
485 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
487 (defcustom gnus-article-menu-hook nil
488 "*Hook run after the creation of the article mode menu."
490 :group 'gnus-article-various)
492 (defcustom gnus-article-prepare-hook nil
493 "*A hook called after an article has been prepared in the article buffer."
495 :group 'gnus-article-various)
497 (defcustom gnus-article-hide-pgp-hook nil
498 "*A hook called after successfully hiding a PGP signature."
500 :group 'gnus-article-various)
502 (defcustom gnus-article-button-face 'bold
503 "Face used for highlighting buttons in the article buffer.
505 An article button is a piece of text that you can activate by pressing
506 `RET' or `mouse-2' above it."
508 :group 'gnus-article-buttons)
510 (defcustom gnus-article-mouse-face 'highlight
511 "Face used for mouse highlighting in the article buffer.
513 Article buttons will be displayed in this face when the cursor is
516 :group 'gnus-article-buttons)
518 (defcustom gnus-signature-face 'gnus-signature-face
519 "Face used for highlighting a signature in the article buffer.
520 Obsolete; use the face `gnus-signature-face' for customizations instead."
522 :group 'gnus-article-highlight
523 :group 'gnus-article-signature)
525 (defface gnus-signature-face
528 "Face used for highlighting a signature in the article buffer."
529 :group 'gnus-article-highlight
530 :group 'gnus-article-signature)
532 (defface gnus-header-from-face
535 (:foreground "spring green"))
538 (:foreground "red3"))
541 "Face used for displaying from headers."
542 :group 'gnus-article-headers
543 :group 'gnus-article-highlight)
545 (defface gnus-header-subject-face
548 (:foreground "SeaGreen3"))
551 (:foreground "red4"))
553 (:bold t :italic t)))
554 "Face used for displaying subject headers."
555 :group 'gnus-article-headers
556 :group 'gnus-article-highlight)
558 (defface gnus-header-newsgroups-face
561 (:foreground "yellow" :italic t))
564 (:foreground "MidnightBlue" :italic t))
567 "Face used for displaying newsgroups headers."
568 :group 'gnus-article-headers
569 :group 'gnus-article-highlight)
571 (defface gnus-header-name-face
574 (:foreground "SeaGreen"))
577 (:foreground "maroon"))
580 "Face used for displaying header names."
581 :group 'gnus-article-headers
582 :group 'gnus-article-highlight)
584 (defface gnus-header-content-face
587 (:foreground "forest green" :italic t))
590 (:foreground "indianred4" :italic t))
592 (:italic t))) "Face used for displaying header content."
593 :group 'gnus-article-headers
594 :group 'gnus-article-highlight)
596 (defcustom gnus-header-face-alist
597 '(("From" nil gnus-header-from-face)
598 ("Subject" nil gnus-header-subject-face)
599 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
600 ("" gnus-header-name-face gnus-header-content-face))
601 "*Controls highlighting of article header.
603 An alist of the form (HEADER NAME CONTENT).
605 HEADER is a regular expression which should match the name of an
606 header header and NAME and CONTENT are either face names or nil.
608 The name of each header field will be displayed using the face
609 specified by the first element in the list where HEADER match the
610 header name and NAME is non-nil. Similarly, the content will be
611 displayed by the first non-nil matching CONTENT face."
612 :group 'gnus-article-headers
613 :group 'gnus-article-highlight
614 :type '(repeat (list (regexp :tag "Header")
616 (item :tag "skip" nil)
617 (face :value default))
618 (choice :tag "Content"
619 (item :tag "skip" nil)
620 (face :value default)))))
622 (defcustom gnus-article-decode-hook
623 '(article-decode-charset article-decode-encoded-words)
624 "*Hook run to decode charsets in articles."
625 :group 'gnus-article-headers
628 (defcustom gnus-display-mime-function 'gnus-display-mime
629 "Function to display MIME articles."
630 :group 'gnus-article-mime
633 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
634 "Function used to decode headers.")
636 (defvar gnus-article-dumbquotes-map
655 "Table for MS-to-Latin1 translation.")
657 (defcustom gnus-ignored-mime-types nil
658 "List of MIME types that should be ignored by Gnus."
660 :group 'gnus-article-mime
661 :type '(repeat regexp))
663 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
664 "List of MIME types that should not be given buttons when rendered inline."
666 :group 'gnus-article-mime
667 :type '(repeat regexp))
669 (defcustom gnus-article-mime-part-function nil
670 "Function called with a MIME handle as the argument.
671 This is meant for people who want to do something automatic based
672 on parts -- for instance, adding Vcard info to a database."
673 :group 'gnus-article-mime
676 (defcustom gnus-mime-multipart-functions nil
677 "An alist of MIME types to functions to display them."
679 :group 'gnus-article-mime
682 (defcustom gnus-article-date-lapsed-new-header nil
683 "Whether the X-Sent and Date headers can coexist.
684 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
685 either replace the old \"Date:\" header (if this variable is nil), or
686 be added below it (otherwise)."
688 :group 'gnus-article-headers
691 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
692 "Function called with a MIME handle as the argument.
693 This is meant for people who want to view first matched part.
694 For `undisplayed-alternative' (default), the first undisplayed
695 part or alternative part is used. For `undisplayed', the first
696 undisplayed part is used. For a function, the first part which
697 the function return `t' is used. For `nil', the first part is
700 :group 'gnus-article-mime
702 (item :tag "first" :value nil)
703 (item :tag "undisplayed" :value undisplayed)
704 (item :tag "undisplayed or alternative"
705 :value undisplayed-alternative)
708 (defcustom gnus-mime-action-alist
709 '(("save to file" . gnus-mime-save-part)
710 ("save and strip" . gnus-mime-save-part-and-strip)
711 ("display as text" . gnus-mime-inline-part)
712 ("view the part" . gnus-mime-view-part)
713 ("pipe to command" . gnus-mime-pipe-part)
714 ("toggle display" . gnus-article-press-button)
715 ("toggle display" . gnus-article-view-part-as-charset)
716 ("view as type" . gnus-mime-view-part-as-type)
717 ("internalize type" . gnus-mime-internalize-part)
718 ("externalize type" . gnus-mime-externalize-part))
719 "An alist of actions that run on the MIME attachment."
720 :group 'gnus-article-mime
721 :type '(repeat (cons (string :tag "name")
724 (defcustom gnus-mime-action-alist
725 '(("save to file" . gnus-mime-save-part)
726 ("display as text" . gnus-mime-inline-part)
727 ("view the part" . gnus-mime-view-part)
728 ("pipe to command" . gnus-mime-pipe-part)
729 ("toggle display" . gnus-article-press-button)
730 ("view as type" . gnus-mime-view-part-as-type)
731 ("internalize type" . gnus-mime-internalize-part)
732 ("externalize type" . gnus-mime-externalize-part))
733 "An alist of actions that run on the MIME attachment."
735 :group 'gnus-article-mime
736 :type '(repeat (cons (string :tag "name")
740 ;;; The treatment variables
743 (defvar gnus-part-display-hook nil
744 "Hook called on parts that are to receive treatment.")
746 (defvar gnus-article-treat-custom
747 '(choice (const :tag "Off" nil)
749 (const :tag "Header" head)
750 (const :tag "Last" last)
751 (integer :tag "Less")
752 (repeat :tag "Groups" regexp)
753 (sexp :tag "Predicate")))
755 (defvar gnus-article-treat-head-custom
756 '(choice (const :tag "Off" nil)
757 (const :tag "Header" head)))
759 (defvar gnus-article-treat-types '("text/plain")
762 (defvar gnus-inhibit-treatment nil
763 "Whether to inhibit treatment.")
765 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
766 "Highlight the signature.
767 Valid values are nil, t, `head', `last', an integer or a predicate.
768 See the manual for details."
769 :group 'gnus-article-treat
770 :type gnus-article-treat-custom)
771 (put 'gnus-treat-highlight-signature 'highlight t)
773 (defcustom gnus-treat-buttonize 100000
775 Valid values are nil, t, `head', `last', an integer or a predicate.
776 See the manual for details."
777 :group 'gnus-article-treat
778 :type gnus-article-treat-custom)
779 (put 'gnus-treat-buttonize 'highlight t)
781 (defcustom gnus-treat-buttonize-head 'head
782 "Add buttons to the head.
783 Valid values are nil, t, `head', `last', an integer or a predicate.
784 See the manual for details."
785 :group 'gnus-article-treat
786 :type gnus-article-treat-head-custom)
787 (put 'gnus-treat-buttonize-head 'highlight t)
789 (defcustom gnus-treat-emphasize
790 (and (or window-system
792 (>= (string-to-number emacs-version) 21))
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-emphasize 'highlight t)
801 (defcustom gnus-treat-strip-cr nil
802 "Remove carriage returns.
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)
808 (defcustom gnus-treat-leading-whitespace nil
809 "Remove leading whitespace in headers.
810 Valid values are nil, t, `head', `last', an integer or a predicate.
811 See the manual for details."
812 :group 'gnus-article-treat
813 :type gnus-article-treat-custom)
815 (defcustom gnus-treat-hide-headers 'head
817 Valid values are nil, t, `head', `last', an integer or a predicate.
818 See the manual for details."
819 :group 'gnus-article-treat
820 :type gnus-article-treat-head-custom)
822 (defcustom gnus-treat-hide-boring-headers nil
823 "Hide boring headers.
824 Valid values are nil, t, `head', `last', an integer or a predicate.
825 See the manual for details."
826 :group 'gnus-article-treat
827 :type gnus-article-treat-head-custom)
829 (defcustom gnus-treat-hide-signature nil
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-fill-article nil
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-citation nil
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-custom)
850 (defcustom gnus-treat-hide-citation-maybe nil
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-custom)
857 (defcustom gnus-treat-hide-citation-maybe 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-strip-list-identifiers 'head
865 "Strip list identifiers from `gnus-list-identifiers`.
866 Valid values are nil, t, `head', `last', an integer or a predicate.
867 See the manual for details."
869 :group 'gnus-article-treat
870 :type gnus-article-treat-custom)
872 (defcustom gnus-treat-strip-pgp t
873 "Strip PGP signatures.
874 Valid values are nil, t, `head', `last', an integer or a predicate.
875 See the manual for details."
876 :group 'gnus-article-treat
877 :type gnus-article-treat-custom)
879 (defcustom gnus-treat-strip-pem nil
880 "Strip PEM signatures.
881 Valid values are nil, t, `head', `last', an integer or a predicate.
882 See the manual for details."
883 :group 'gnus-article-treat
884 :type gnus-article-treat-custom)
886 (defcustom gnus-treat-strip-banner t
887 "Strip banners from articles.
888 The banner to be stripped is specified in the `banner' group parameter.
889 Valid values are nil, t, `head', `last', an integer or a predicate.
890 See the manual for details."
891 :group 'gnus-article-treat
892 :type gnus-article-treat-custom)
894 (defcustom gnus-treat-highlight-headers 'head
895 "Highlight the headers.
896 Valid values are nil, t, `head', `last', an integer or a predicate.
897 See the manual for details."
898 :group 'gnus-article-treat
899 :type gnus-article-treat-head-custom)
900 (put 'gnus-treat-highlight-headers 'highlight t)
902 (defcustom gnus-treat-highlight-citation t
903 "Highlight cited text.
904 Valid values are nil, t, `head', `last', an integer or a predicate.
905 See the manual for details."
906 :group 'gnus-article-treat
907 :type gnus-article-treat-custom)
908 (put 'gnus-treat-highlight-citation 'highlight t)
910 (defcustom gnus-treat-date-ut nil
911 "Display the Date in UT (GMT).
912 Valid values are nil, t, `head', `last', an integer or a predicate.
913 See the manual for details."
914 :group 'gnus-article-treat
915 :type gnus-article-treat-head-custom)
917 (defcustom gnus-treat-date-local nil
918 "Display the Date in the local timezone.
919 Valid values are nil, t, `head', `last', an integer or a predicate.
920 See the manual for details."
921 :group 'gnus-article-treat
922 :type gnus-article-treat-head-custom)
924 (defcustom gnus-treat-date-english nil
925 "Display the Date in a format that can be read aloud in English.
926 Valid values are nil, t, `head', `last', an integer or a predicate.
927 See the manual for details."
928 :group 'gnus-article-treat
929 :type gnus-article-treat-head-custom)
931 (defcustom gnus-treat-date-lapsed nil
932 "Display the Date header in a way that says how much time has elapsed.
933 Valid values are nil, t, `head', `last', an integer or a predicate.
934 See the manual for details."
935 :group 'gnus-article-treat
936 :type gnus-article-treat-head-custom)
938 (defcustom gnus-treat-date-original nil
939 "Display the date in the original timezone.
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-iso8601 nil
946 "Display the date in the ISO8601 format.
947 Valid values are nil, t, `head', `last', an integer or a predicate.
948 See the manual for details."
950 :group 'gnus-article-treat
951 :type gnus-article-treat-head-custom)
953 (defcustom gnus-treat-date-user-defined nil
954 "Display the date in a user-defined format.
955 The format is defined by the `gnus-article-time-format' variable.
956 Valid values are nil, t, `head', `last', an integer or a predicate.
957 See the manual for details."
958 :group 'gnus-article-treat
959 :type gnus-article-treat-head-custom)
961 (defcustom gnus-treat-strip-headers-in-body t
962 "Strip the X-No-Archive header line from the beginning of the body.
963 Valid values are nil, t, `head', `last', an integer or a predicate.
964 See the manual for details."
966 :group 'gnus-article-treat
967 :type gnus-article-treat-custom)
969 (defcustom gnus-treat-strip-trailing-blank-lines nil
970 "Strip trailing blank lines.
971 Valid values are nil, t, `head', `last', an integer or a predicate.
972 See the manual for details."
973 :group 'gnus-article-treat
974 :type gnus-article-treat-custom)
976 (defcustom gnus-treat-strip-leading-blank-lines nil
977 "Strip leading blank lines.
978 Valid values are nil, t, `head', `last', an integer or a predicate.
979 See the manual for details."
980 :group 'gnus-article-treat
981 :type gnus-article-treat-custom)
983 (defcustom gnus-treat-strip-multiple-blank-lines nil
984 "Strip multiple blank lines.
985 Valid values are nil, t, `head', `last', an integer or a predicate.
986 See the manual for details."
987 :group 'gnus-article-treat
988 :type gnus-article-treat-custom)
990 (defcustom gnus-treat-overstrike t
991 "Treat overstrike highlighting.
992 Valid values are nil, t, `head', `last', an integer or a predicate.
993 See the manual for details."
994 :group 'gnus-article-treat
995 :type gnus-article-treat-custom)
996 (put 'gnus-treat-overstrike 'highlight t)
998 (defcustom gnus-treat-display-xface
999 (and (or (and (fboundp 'image-type-available-p)
1000 (image-type-available-p 'xbm)
1001 (string-match "^0x" (shell-command-to-string "uncompface")))
1002 (and (featurep 'xemacs) (featurep 'xface)))
1004 "Display X-Face headers.
1005 Valid values are nil, t, `head', `last', an integer or a predicate.
1006 See the manual for details."
1007 :group 'gnus-article-treat
1009 :type gnus-article-treat-head-custom)
1010 (put 'gnus-treat-display-xface 'highlight t)
1012 (defcustom gnus-treat-display-smileys
1013 (if (or (and (featurep 'xemacs)
1015 (and (fboundp 'image-type-available-p)
1016 (image-type-available-p 'pbm)))
1019 Valid values are nil, t, `head', `last', an integer or a predicate.
1020 See the manual for details."
1021 :group 'gnus-article-treat
1023 :type gnus-article-treat-custom)
1024 (put 'gnus-treat-display-smileys 'highlight t)
1026 (defcustom gnus-treat-display-picons (if (featurep 'xemacs) 'head nil)
1028 Valid values are nil, t, `head', `last', an integer or a predicate.
1029 See the manual for details."
1030 :group 'gnus-article-treat
1031 :type gnus-article-treat-head-custom)
1032 (put 'gnus-treat-display-picons 'highlight t)
1034 (defcustom gnus-treat-capitalize-sentences nil
1035 "Capitalize sentence-starting words.
1036 Valid values are nil, t, `head', `last', an integer or a predicate.
1037 See the manual for details."
1039 :group 'gnus-article-treat
1040 :type gnus-article-treat-custom)
1042 (defcustom gnus-treat-fill-long-lines nil
1044 Valid values are nil, t, `head', `last', an integer or a predicate.
1045 See the manual for details."
1046 :group 'gnus-article-treat
1047 :type gnus-article-treat-custom)
1049 (defcustom gnus-treat-play-sounds nil
1051 Valid values are nil, t, `head', `last', an integer or a predicate.
1052 See the manual for details."
1054 :group 'gnus-article-treat
1055 :type gnus-article-treat-custom)
1057 (defcustom gnus-treat-translate nil
1058 "Translate articles from one language to another.
1059 Valid values are nil, t, `head', `last', an integer or a predicate.
1060 See the manual for details."
1062 :group 'gnus-article-treat
1063 :type gnus-article-treat-custom)
1065 (defcustom gnus-treat-x-pgp-sig nil
1067 To automatically treat X-PGP-Sig, set it to head.
1068 Valid values are nil, t, `head', `last', an integer or a predicate.
1069 See the manual for details."
1070 :group 'gnus-article-treat
1071 :group 'mime-security
1072 :type gnus-article-treat-custom)
1074 (defvar gnus-article-encrypt-protocol-alist
1075 '(("PGP" . mml2015-self-encrypt)))
1077 ;; Set to nil if more than one protocol added to
1078 ;; gnus-article-encrypt-protocol-alist.
1079 (defcustom gnus-article-encrypt-protocol "PGP"
1080 "The protocol used for encrypt articles.
1081 It is a string, such as \"PGP\". If nil, ask user."
1083 :group 'mime-security)
1085 ;;; Internal variables
1087 (defvar gnus-english-month-names
1088 '("January" "February" "March" "April" "May" "June" "July" "August"
1089 "September" "October" "November" "December"))
1091 (defvar article-goto-body-goes-to-point-min-p nil)
1092 (defvar gnus-article-wash-types nil)
1093 (defvar gnus-article-emphasis-alist nil)
1095 (defvar gnus-article-mime-handle-alist-1 nil)
1096 (defvar gnus-treatment-function-alist
1097 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1098 (gnus-treat-strip-banner gnus-article-strip-banner)
1099 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1100 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1101 (gnus-treat-buttonize gnus-article-add-buttons)
1102 (gnus-treat-fill-article gnus-article-fill-cited-article)
1103 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1104 (gnus-treat-strip-cr gnus-article-remove-cr)
1105 (gnus-treat-emphasize gnus-article-emphasize)
1106 (gnus-treat-display-xface gnus-article-display-x-face)
1107 (gnus-treat-date-ut gnus-article-date-ut)
1108 (gnus-treat-date-local gnus-article-date-local)
1109 (gnus-treat-date-english gnus-article-date-english)
1110 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1111 (gnus-treat-date-original gnus-article-date-original)
1112 (gnus-treat-date-user-defined gnus-article-date-user)
1113 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1114 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1115 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1116 (gnus-treat-hide-signature gnus-article-hide-signature)
1117 (gnus-treat-hide-citation gnus-article-hide-citation)
1118 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1119 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1120 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1121 (gnus-treat-strip-pgp gnus-article-hide-pgp)
1122 (gnus-treat-strip-pem gnus-article-hide-pem)
1123 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1124 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1125 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1126 (gnus-treat-strip-trailing-blank-lines
1127 gnus-article-remove-trailing-blank-lines)
1128 (gnus-treat-strip-leading-blank-lines
1129 gnus-article-strip-leading-blank-lines)
1130 (gnus-treat-strip-multiple-blank-lines
1131 gnus-article-strip-multiple-blank-lines)
1132 (gnus-treat-overstrike gnus-article-treat-overstrike)
1133 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1134 (gnus-treat-display-smileys gnus-smiley-display)
1135 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1136 (gnus-treat-display-picons gnus-article-display-picons)
1137 (gnus-treat-play-sounds gnus-earcon-display)))
1139 (defvar gnus-article-mime-handle-alist nil)
1140 (defvar article-lapsed-timer nil)
1141 (defvar gnus-article-current-summary nil)
1143 (defvar gnus-article-mode-syntax-table
1144 (let ((table (copy-syntax-table text-mode-syntax-table)))
1145 ;; This causes the citation match run O(2^n).
1146 ;; (modify-syntax-entry ?- "w" table)
1147 (modify-syntax-entry ?> ")" table)
1148 (modify-syntax-entry ?< "(" table)
1150 "Syntax table used in article mode buffers.
1151 Initialized from `text-mode-syntax-table.")
1153 (defvar gnus-save-article-buffer nil)
1155 (defvar gnus-article-mode-line-format-alist
1156 (nconc '((?w (gnus-article-wash-status) ?s)
1157 (?m (gnus-article-mime-part-status) ?s))
1158 gnus-summary-mode-line-format-alist))
1160 (defvar gnus-number-of-articles-to-be-saved nil)
1162 (defvar gnus-inhibit-hiding nil)
1164 (defsubst gnus-article-hide-text (b e props)
1165 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1166 (gnus-add-text-properties-when 'article-type nil b e props)
1167 (when (memq 'intangible props)
1169 (max (1- b) (point-min))
1170 b 'intangible (cddr (memq 'intangible props)))))
1172 (defsubst gnus-article-unhide-text (b e)
1173 "Remove hidden text properties from region between B and E."
1174 (remove-text-properties b e gnus-hidden-properties)
1175 (when (memq 'intangible gnus-hidden-properties)
1176 (put-text-property (max (1- b) (point-min))
1177 b 'intangible nil)))
1179 (defun gnus-article-hide-text-type (b e type)
1180 "Hide text of TYPE between B and E."
1181 (push type gnus-article-wash-types)
1182 (gnus-article-hide-text
1183 b e (cons 'article-type (cons type gnus-hidden-properties))))
1185 (defun gnus-article-unhide-text-type (b e type)
1186 "Unhide text of TYPE between B and E."
1187 (setq gnus-article-wash-types
1188 (delq type gnus-article-wash-types))
1189 (remove-text-properties
1190 b e (cons 'article-type (cons type gnus-hidden-properties)))
1191 (when (memq 'intangible gnus-hidden-properties)
1192 (put-text-property (max (1- b) (point-min))
1193 b 'intangible nil)))
1195 (defun gnus-article-hide-text-of-type (type)
1196 "Hide text of TYPE in the current buffer."
1198 (let ((b (point-min))
1200 (while (setq b (text-property-any b e 'article-type type))
1201 (add-text-properties b (incf b) gnus-hidden-properties)))))
1203 (defun gnus-article-delete-text-of-type (type)
1204 "Delete text of TYPE in the current buffer."
1206 (let ((b (point-min)))
1207 (while (setq b (text-property-any b (point-max) 'article-type type))
1209 b (or (text-property-not-all b (point-max) 'article-type type)
1212 (defun gnus-article-delete-invisible-text ()
1213 "Delete all invisible text in the current buffer."
1215 (let ((b (point-min)))
1216 (while (setq b (text-property-any b (point-max) 'invisible t))
1218 b (or (text-property-not-all b (point-max) 'invisible t)
1221 (defun gnus-article-text-type-exists-p (type)
1222 "Say whether any text of type TYPE exists in the buffer."
1223 (text-property-any (point-min) (point-max) 'article-type type))
1225 (defsubst gnus-article-header-rank ()
1226 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1227 (let ((list gnus-sorted-header-list)
1230 (when (looking-at (car list))
1232 (setq list (cdr list))
1236 (defun article-hide-headers (&optional arg delete)
1237 "Hide unwanted headers and possibly sort them as well."
1239 ;; This function might be inhibited.
1240 (unless gnus-inhibit-hiding
1243 (let ((buffer-read-only nil)
1244 (case-fold-search t)
1245 (max (1+ (length gnus-sorted-header-list)))
1246 (ignored (when (not gnus-visible-headers)
1247 (cond ((stringp gnus-ignored-headers)
1248 gnus-ignored-headers)
1249 ((listp gnus-ignored-headers)
1250 (mapconcat 'identity gnus-ignored-headers
1253 (cond ((stringp gnus-visible-headers)
1254 gnus-visible-headers)
1255 ((and gnus-visible-headers
1256 (listp gnus-visible-headers))
1257 (mapconcat 'identity gnus-visible-headers "\\|"))))
1258 (inhibit-point-motion-hooks t)
1260 ;; First we narrow to just the headers.
1261 (article-narrow-to-head)
1262 ;; Hide any "From " lines at the beginning of (mail) articles.
1263 (while (looking-at "From ")
1266 (delete-region (point-min) (point)))
1267 ;; Then treat the rest of the header lines.
1268 ;; Then we use the two regular expressions
1269 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1270 ;; select which header lines is to remain visible in the
1272 (while (re-search-forward "^[^ \t]*:" nil t)
1274 ;; Mark the rank of the header.
1276 (point) (1+ (point)) 'message-rank
1277 (if (or (and visible (looking-at visible))
1279 (not (looking-at ignored))))
1280 (gnus-article-header-rank)
1283 (message-sort-headers-1)
1284 (when (setq beg (text-property-any
1285 (point-min) (point-max) 'message-rank (+ 2 max)))
1286 ;; We delete the unwanted headers.
1287 (push 'headers gnus-article-wash-types)
1288 (add-text-properties (point-min) (+ 5 (point-min))
1289 '(article-type headers dummy-invisible t))
1290 (delete-region beg (point-max))))))))
1292 (defun article-hide-boring-headers (&optional arg)
1293 "Toggle hiding of headers that aren't very interesting.
1294 If given a negative prefix, always show; if given a positive prefix,
1296 (interactive (gnus-article-hidden-arg))
1297 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1298 (not gnus-show-all-headers))
1301 (let ((buffer-read-only nil)
1302 (list gnus-boring-article-headers)
1303 (inhibit-point-motion-hooks t)
1305 (article-narrow-to-head)
1307 (setq elem (pop list))
1308 (goto-char (point-min))
1310 ;; Hide empty headers.
1312 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1314 (gnus-article-hide-text-type
1315 (progn (beginning-of-line) (point))
1318 (if (re-search-forward "^[^ \t]" nil t)
1322 ;; Hide boring Newsgroups header.
1323 ((eq elem 'newsgroups)
1324 (when (gnus-string-equal
1325 (gnus-fetch-field "newsgroups")
1326 (gnus-group-real-name
1327 (if (boundp 'gnus-newsgroup-name)
1330 (gnus-article-hide-header "newsgroups")))
1331 ((eq elem 'to-address)
1332 (let ((to (message-fetch-field "to"))
1334 (gnus-parameter-to-address
1335 (if (boundp 'gnus-newsgroup-name)
1336 gnus-newsgroup-name ""))))
1337 (when (and to to-address
1340 ;; only one address in To
1341 (nth 1 (mail-extract-address-components to))
1343 (gnus-article-hide-header "to"))))
1344 ((eq elem 'followup-to)
1345 (when (gnus-string-equal
1346 (message-fetch-field "followup-to")
1347 (message-fetch-field "newsgroups"))
1348 (gnus-article-hide-header "followup-to")))
1349 ((eq elem 'reply-to)
1350 (let ((from (message-fetch-field "from"))
1351 (reply-to (message-fetch-field "reply-to")))
1356 (nth 1 (mail-extract-address-components from))
1357 (nth 1 (mail-extract-address-components reply-to)))))
1358 (gnus-article-hide-header "reply-to"))))
1360 (let ((date (message-fetch-field "date")))
1362 (< (days-between (current-time-string) date)
1364 (gnus-article-hide-header "date"))))
1366 (let ((to (message-fetch-field "to"))
1367 (cc (message-fetch-field "cc")))
1368 (when (> (length to) 1024)
1369 (gnus-article-hide-header "to"))
1370 (when (> (length cc) 1024)
1371 (gnus-article-hide-header "cc"))))
1375 (goto-char (point-min))
1376 (while (re-search-forward "^to:" nil t)
1377 (setq to-count (1+ to-count)))
1378 (when (> to-count 1)
1379 (while (> to-count 0)
1380 (goto-char (point-min))
1382 (re-search-forward "^to:" nil nil to-count)
1384 (narrow-to-region (point) (point-max))
1385 (gnus-article-hide-header "to"))
1386 (setq to-count (1- to-count))))
1387 (goto-char (point-min))
1388 (while (re-search-forward "^cc:" nil t)
1389 (setq cc-count (1+ cc-count)))
1390 (when (> cc-count 1)
1391 (while (> cc-count 0)
1392 (goto-char (point-min))
1394 (re-search-forward "^cc:" nil nil cc-count)
1396 (narrow-to-region (point) (point-max))
1397 (gnus-article-hide-header "cc"))
1398 (setq cc-count (1- cc-count)))))))))))))
1400 (defun gnus-article-hide-header (header)
1402 (goto-char (point-min))
1403 (when (re-search-forward (concat "^" header ":") nil t)
1404 (gnus-article-hide-text-type
1405 (progn (beginning-of-line) (point))
1408 (if (re-search-forward "^[^ \t]" nil t)
1413 (defvar gnus-article-normalized-header-length 40
1414 "Length of normalized headers.")
1416 (defun article-normalize-headers ()
1417 "Make all header lines 40 characters long."
1419 (let ((buffer-read-only nil)
1423 (article-narrow-to-head)
1426 ((< (setq column (- (gnus-point-at-eol) (point)))
1427 gnus-article-normalized-header-length)
1429 (insert (make-string
1430 (- gnus-article-normalized-header-length column)
1432 ((> column gnus-article-normalized-header-length)
1433 (gnus-put-text-property
1435 (forward-char gnus-article-normalized-header-length)
1442 (forward-line 1))))))
1444 (defun article-treat-dumbquotes ()
1445 "Translate M****s*** sm*rtq**t*s into proper text.
1446 Note that this function guesses whether a character is a sm*rtq**t* or
1447 not, so it should only be used interactively.
1449 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1450 in an attempt to provide more quoting characters. If you see
1451 something like \\222 or \\264 where you're expecting some kind of
1452 apostrophe or quotation mark, then try this wash."
1454 (article-translate-strings gnus-article-dumbquotes-map))
1456 (defun article-translate-characters (from to)
1457 "Translate all characters in the body of the article according to FROM and TO.
1458 FROM is a string of characters to translate from; to is a string of
1459 characters to translate to."
1461 (when (article-goto-body)
1462 (let ((buffer-read-only nil)
1463 (x (make-string 225 ?x))
1465 (while (< (incf i) (length x))
1468 (while (< i (length from))
1469 (aset x (aref from i) (aref to i))
1471 (translate-region (point) (point-max) x)))))
1473 (defun article-translate-strings (map)
1474 "Translate all string in the body of the article according to MAP.
1475 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1477 (when (article-goto-body)
1478 (let ((buffer-read-only nil)
1480 (while (setq elem (pop map))
1482 (while (search-forward (car elem) nil t)
1483 (replace-match (cadr elem)))))))))
1485 (defun article-treat-overstrike ()
1486 "Translate overstrikes into bold text."
1489 (when (article-goto-body)
1490 (let ((buffer-read-only nil))
1491 (while (search-forward "\b" nil t)
1492 (let ((next (char-after))
1493 (previous (char-after (- (point) 2))))
1494 ;; We do the boldification/underlining by hiding the
1495 ;; overstrikes and putting the proper text property
1499 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1500 (put-text-property (point) (1+ (point)) 'face 'bold))
1502 (gnus-article-hide-text-type
1503 (1- (point)) (1+ (point)) 'overstrike)
1505 (- (point) 2) (1- (point)) 'face 'underline))
1507 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1509 (point) (1+ (point)) 'face 'underline)))))))))
1511 (defun article-fill-long-lines ()
1512 "Fill lines that are wider than the window width."
1515 (let ((buffer-read-only nil)
1516 (width (window-width (get-buffer-window (current-buffer)))))
1519 (let ((adaptive-fill-mode nil))
1522 (when (>= (current-column) (min fill-column width))
1523 (narrow-to-region (point) (gnus-point-at-bol))
1524 (fill-paragraph nil)
1525 (goto-char (point-max))
1527 (forward-line 1)))))))
1529 (defun article-capitalize-sentences ()
1530 "Capitalize the first word in each sentence."
1533 (let ((buffer-read-only nil)
1534 (paragraph-start "^[\n\^L]"))
1538 (forward-sentence)))))
1540 (defun article-remove-cr ()
1541 "Remove trailing CRs and then translate remaining CRs into LFs."
1544 (let ((buffer-read-only nil))
1545 (goto-char (point-min))
1546 (while (re-search-forward "\r+$" nil t)
1547 (replace-match "" t t))
1548 (goto-char (point-min))
1549 (while (search-forward "\r" nil t)
1550 (replace-match "\n" t t)))))
1552 (defun article-remove-trailing-blank-lines ()
1553 "Remove all trailing blank lines from the article."
1556 (let ((buffer-read-only nil))
1557 (goto-char (point-max))
1561 (while (and (not (bobp))
1562 (looking-at "^[ \t]*$")
1563 (not (gnus-annotation-in-region-p
1564 (point) (gnus-point-at-eol))))
1569 (defun article-display-x-face (&optional force)
1570 "Look for an X-Face header and display it if present."
1571 (interactive (list 'force))
1573 ;; Delete the old process, if any.
1574 (when (process-status "article-x-face")
1575 (delete-process "article-x-face"))
1576 (let ((inhibit-point-motion-hooks t)
1578 (case-fold-search t)
1581 (article-narrow-to-head)
1582 (when (and buffer-read-only ;; When type `W f'
1584 (goto-char (point-min))
1585 (not (re-search-forward "^X-Face:[\t ]*" nil t)))
1586 (gnus-buffer-live-p gnus-original-article-buffer))
1587 (with-current-buffer gnus-original-article-buffer
1589 (article-narrow-to-head)
1590 (while (re-search-forward "^X-Face:" nil t)
1596 (1- (re-search-forward
1597 "^\\($\\|[^ \t]\\)" nil t))))))))
1599 (let (point start bface eface buffer-read-only)
1600 (goto-char (point-max))
1602 (setq bface (get-text-property (gnus-point-at-bol) 'face)
1603 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
1604 (goto-char (point-max))
1605 (setq point (point))
1608 (while (looking-at "\\([^:]+\\): *")
1609 (put-text-property (match-beginning 1) (1+ (match-end 1))
1611 (setq start (match-end 0))
1613 (while (looking-at "[\t ]")
1615 (put-text-property start (point)
1617 (goto-char (point-min))
1618 (setq from (message-fetch-field "from"))
1619 (goto-char (point-min))
1620 (while (and gnus-article-x-face-command
1623 ;; Check whether this face is censored.
1624 (not gnus-article-x-face-too-ugly)
1625 (and gnus-article-x-face-too-ugly from
1626 (not (string-match gnus-article-x-face-too-ugly
1628 ;; Has to be present.
1629 (re-search-forward "^X-Face:[\t ]*" nil t))
1630 ;; This used to try to do multiple faces (`while' instead of
1631 ;; `when' above), but (a) sending multiple EOFs to xv doesn't
1632 ;; work (b) it can crash some versions of Emacs (c) are
1633 ;; multiple faces really something to encourage?
1634 (when (stringp gnus-article-x-face-command)
1636 ;; We now have the area of the buffer where the X-Face is stored.
1639 (end (1- (re-search-forward "^\\($\\|[^ \t]\\)" nil t))))
1640 ;; We display the face.
1641 (if (symbolp gnus-article-x-face-command)
1642 ;; The command is a lisp function, so we call it.
1643 (if (gnus-functionp gnus-article-x-face-command)
1644 (funcall gnus-article-x-face-command beg end)
1645 (error "%s is not a function" gnus-article-x-face-command))
1646 ;; The command is a string, so we interpret the command
1647 ;; as a, well, command, and fork it off.
1648 (let ((process-connection-type nil))
1649 (process-kill-without-query
1651 "article-x-face" nil shell-file-name shell-command-switch
1652 gnus-article-x-face-command))
1653 (process-send-region "article-x-face" beg end)
1654 (process-send-eof "article-x-face"))))))))))
1656 (defun article-decode-mime-words ()
1657 "Decode all MIME-encoded words in the article."
1660 (set-buffer gnus-article-buffer)
1661 (let ((inhibit-point-motion-hooks t)
1663 (mail-parse-charset gnus-newsgroup-charset)
1664 (mail-parse-ignored-charsets
1665 (save-excursion (set-buffer gnus-summary-buffer)
1666 gnus-newsgroup-ignored-charsets)))
1667 (mail-decode-encoded-word-region (point-min) (point-max)))))
1669 (defun article-decode-charset (&optional prompt)
1670 "Decode charset-encoded text in the article.
1671 If PROMPT (the prefix), prompt for a coding system to use."
1673 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
1675 (mail-parse-charset gnus-newsgroup-charset)
1676 (mail-parse-ignored-charsets
1677 (save-excursion (condition-case nil
1678 (set-buffer gnus-summary-buffer)
1680 gnus-newsgroup-ignored-charsets))
1681 ct cte ctl charset format)
1684 (article-narrow-to-head)
1685 (setq ct (message-fetch-field "Content-Type" t)
1686 cte (message-fetch-field "Content-Transfer-Encoding" t)
1687 ctl (and ct (ignore-errors
1688 (mail-header-parse-content-type ct)))
1691 (mm-read-coding-system "Charset to decode: "))
1693 (mail-content-type-get ctl 'charset)))
1694 format (and ctl (mail-content-type-get ctl 'format)))
1696 (setq cte (mail-header-strip cte)))
1697 (if (and ctl (not (string-match "/" (car ctl))))
1699 (goto-char (point-max)))
1702 (narrow-to-region (point) (point-max))
1703 (when (and (eq mail-parse-charset 'gnus-decoded)
1704 (eq (mm-body-7-or-8) '8bit))
1705 ;; The text code could have been decoded.
1706 (setq charset mail-parse-charset))
1707 (when (and (or (not ctl)
1708 (equal (car ctl) "text/plain"))
1709 (not format)) ;; article with format will decode later.
1711 charset (and cte (intern (downcase
1712 (gnus-strip-whitespace cte))))
1715 (defun article-decode-encoded-words ()
1716 "Remove encoded-word encoding from headers."
1717 (let ((inhibit-point-motion-hooks t)
1718 (mail-parse-charset gnus-newsgroup-charset)
1719 (mail-parse-ignored-charsets
1720 (save-excursion (condition-case nil
1721 (set-buffer gnus-summary-buffer)
1723 gnus-newsgroup-ignored-charsets))
1726 (article-narrow-to-head)
1727 (funcall gnus-decode-header-function (point-min) (point-max)))))
1729 (defun article-de-quoted-unreadable (&optional force read-charset)
1730 "Translate a quoted-printable-encoded article.
1731 If FORCE, decode the article whether it is marked as quoted-printable
1733 If READ-CHARSET, ask for a coding system."
1734 (interactive (list 'force current-prefix-arg))
1736 (let ((buffer-read-only nil) type charset)
1737 (if (gnus-buffer-live-p gnus-original-article-buffer)
1738 (with-current-buffer gnus-original-article-buffer
1740 (gnus-fetch-field "content-transfer-encoding"))
1741 (let* ((ct (gnus-fetch-field "content-type"))
1744 (mail-header-parse-content-type ct)))))
1745 (setq charset (and ctl
1746 (mail-content-type-get ctl 'charset)))
1747 (if (stringp charset)
1748 (setq charset (intern (downcase charset)))))))
1750 (setq charset (read-coding-system "Charset: " charset)))
1752 (setq charset gnus-newsgroup-charset))
1754 (and type (let ((case-fold-search t))
1755 (string-match "quoted-printable" type))))
1757 (quoted-printable-decode-region
1758 (point) (point-max) (mm-charset-to-coding-system charset))))))
1760 (defun article-de-base64-unreadable (&optional force read-charset)
1761 "Translate a base64 article.
1762 If FORCE, decode the article whether it is marked as base64 not.
1763 If READ-CHARSET, ask for a coding system."
1764 (interactive (list 'force current-prefix-arg))
1766 (let ((buffer-read-only nil) type charset)
1767 (if (gnus-buffer-live-p gnus-original-article-buffer)
1768 (with-current-buffer gnus-original-article-buffer
1770 (gnus-fetch-field "content-transfer-encoding"))
1771 (let* ((ct (gnus-fetch-field "content-type"))
1774 (mail-header-parse-content-type ct)))))
1775 (setq charset (and ctl
1776 (mail-content-type-get ctl 'charset)))
1777 (if (stringp charset)
1778 (setq charset (intern (downcase charset)))))))
1780 (setq charset (read-coding-system "Charset: " charset)))
1782 (setq charset gnus-newsgroup-charset))
1784 (and type (let ((case-fold-search t))
1785 (string-match "base64" type))))
1788 (narrow-to-region (point) (point-max))
1789 (base64-decode-region (point-min) (point-max))
1790 (mm-decode-coding-region
1791 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
1796 (defun article-decode-HZ ()
1797 "Translate a HZ-encoded article."
1801 (let ((buffer-read-only nil))
1802 (rfc1843-decode-region (point-min) (point-max)))))
1804 (defun article-wash-html (&optional read-charset)
1805 "Format an html article.
1806 If READ-CHARSET, ask for a coding system."
1809 (let ((buffer-read-only nil)
1811 (if (gnus-buffer-live-p gnus-original-article-buffer)
1812 (with-current-buffer gnus-original-article-buffer
1813 (let* ((ct (gnus-fetch-field "content-type"))
1816 (mail-header-parse-content-type ct)))))
1817 (setq charset (and ctl
1818 (mail-content-type-get ctl 'charset)))
1819 (if (stringp charset)
1820 (setq charset (intern (downcase charset)))))))
1822 (setq charset (read-coding-system "Charset: " charset)))
1824 (setq charset gnus-newsgroup-charset))
1826 (save-window-excursion
1828 (narrow-to-region (point) (point-max))
1830 (let ((w3-strict-width (window-width))
1831 (url-standalone-mode t))
1833 (w3-region (point-min) (point-max))
1836 (defun article-hide-list-identifiers ()
1837 "Remove list identifies from the Subject header.
1838 The `gnus-list-identifiers' variable specifies what to do."
1840 (let ((inhibit-point-motion-hooks t)
1841 (regexp (if (consp gnus-list-identifiers)
1842 (mapconcat 'identity gnus-list-identifiers " *\\|")
1843 gnus-list-identifiers))
1848 (article-narrow-to-head)
1849 (goto-char (point-min))
1850 (while (re-search-forward
1851 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
1853 (delete-region (match-beginning 2) (match-end 0))
1854 (beginning-of-line))
1855 (when (re-search-forward
1856 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
1857 (delete-region (match-beginning 1) (match-end 1))))))))
1859 (defun article-hide-pgp ()
1860 "Remove any PGP headers and signatures in the current article."
1864 (let ((inhibit-point-motion-hooks t)
1865 buffer-read-only beg end)
1867 ;; Hide the "header".
1868 (when (re-search-forward "^-----BEGIN PGP SIGNED MESSAGE-----\n" nil t)
1869 (push 'pgp gnus-article-wash-types)
1870 (delete-region (match-beginning 0) (match-end 0))
1871 ;; Remove armor headers (rfc2440 6.2)
1872 (delete-region (point) (or (re-search-forward "^[ \t]*\n" nil t)
1875 ;; Hide the actual signature.
1876 (and (search-forward "\n-----BEGIN PGP SIGNATURE-----\n" nil t)
1877 (setq end (1+ (match-beginning 0)))
1880 (if (search-forward "\n-----END PGP SIGNATURE-----\n" nil t)
1882 ;; Perhaps we shouldn't hide to the end of the buffer
1883 ;; if there is no end to the signature?
1885 ;; Hide "- " PGP quotation markers.
1887 (narrow-to-region beg end)
1888 (goto-char (point-min))
1889 (while (re-search-forward "^- " nil t)
1891 (match-beginning 0) (match-end 0)))
1893 (gnus-run-hooks 'gnus-article-hide-pgp-hook))))))
1895 (defun article-hide-pem (&optional arg)
1896 "Toggle hiding of any PEM headers and signatures in the current article.
1897 If given a negative prefix, always show; if given a positive prefix,
1899 (interactive (gnus-article-hidden-arg))
1900 (unless (gnus-article-check-hidden-text 'pem arg)
1902 (let (buffer-read-only end)
1903 (goto-char (point-min))
1904 ;; Hide the horrendously ugly "header".
1905 (when (and (search-forward
1906 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
1908 (setq end (1+ (match-beginning 0))))
1909 (push 'pem gnus-article-wash-types)
1910 (gnus-article-hide-text-type
1912 (if (search-forward "\n\n" nil t)
1916 ;; Hide the trailer as well
1917 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
1919 (gnus-article-hide-text-type
1920 (match-beginning 0) (match-end 0) 'pem)))))))
1922 (defun article-strip-banner ()
1923 "Strip the banner specified by the `banner' group parameter."
1927 (let ((inhibit-point-motion-hooks t)
1928 (banner (gnus-parameter-banner gnus-newsgroup-name))
1929 (gnus-signature-limit nil)
1930 buffer-read-only beg end)
1934 ((eq banner 'signature)
1935 (when (gnus-article-narrow-to-signature)
1938 (delete-region (point) (point-max))))
1940 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
1941 (while (re-search-forward banner nil t)
1942 (delete-region (match-beginning 0) (match-end 0)))))
1944 (while (re-search-forward banner nil t)
1945 (delete-region (match-beginning 0) (match-end 0))))))))))
1947 (defun article-babel ()
1948 "Translate article using an online translation service."
1952 (set-buffer gnus-article-buffer)
1953 (when (article-goto-body)
1954 (let* ((buffer-read-only nil)
1957 (orig (buffer-substring start end))
1958 (trans (babel-as-string orig)))
1960 (narrow-to-region start end)
1961 (delete-region start end)
1964 (defun article-hide-signature (&optional arg)
1965 "Hide the signature in the current article.
1966 If given a negative prefix, always show; if given a positive prefix,
1968 (interactive (gnus-article-hidden-arg))
1969 (unless (gnus-article-check-hidden-text 'signature arg)
1972 (let ((buffer-read-only nil))
1973 (when (gnus-article-narrow-to-signature)
1974 (gnus-article-hide-text-type
1975 (point-min) (point-max) 'signature)))))))
1977 (defun article-strip-headers-in-body ()
1978 "Strip offensive headers from bodies."
1982 (let ((case-fold-search t))
1983 (when (looking-at "x-no-archive:")
1984 (gnus-delete-line)))))
1986 (defun article-strip-leading-blank-lines ()
1987 "Remove all blank lines from the beginning of the article."
1990 (let ((inhibit-point-motion-hooks t)
1992 (when (article-goto-body)
1993 (while (and (not (eobp))
1994 (looking-at "[ \t]*$"))
1995 (gnus-delete-line))))))
1997 (defun article-narrow-to-head ()
1998 "Narrow the buffer to the head of the message.
1999 Point is left at the beginning of the narrowed-to region."
2001 (goto-char (point-min))
2002 (if (search-forward "\n\n" nil 1)
2005 (goto-char (point-min)))
2007 (defun article-goto-body ()
2008 "Place point at the start of the body."
2009 (goto-char (point-min))
2011 ;; This variable is only bound when dealing with separate
2013 (article-goto-body-goes-to-point-min-p
2015 ((search-forward "\n\n" nil t)
2018 (goto-char (point-max))
2021 (defun article-strip-multiple-blank-lines ()
2022 "Replace consecutive blank lines with one empty line."
2025 (let ((inhibit-point-motion-hooks t)
2027 ;; First make all blank lines empty.
2029 (while (re-search-forward "^[ \t]+$" nil t)
2030 (unless (gnus-annotation-in-region-p
2031 (match-beginning 0) (match-end 0))
2032 (replace-match "" nil t)))
2033 ;; Then replace multiple empty lines with a single empty line.
2035 (while (re-search-forward "\n\n\n+" nil t)
2036 (unless (gnus-annotation-in-region-p
2037 (match-beginning 0) (match-end 0))
2038 (replace-match "\n\n" t t))))))
2040 (defun article-strip-leading-space ()
2041 "Remove all white space from the beginning of the lines in the article."
2044 (let ((inhibit-point-motion-hooks t)
2047 (while (re-search-forward "^[ \t]+" nil t)
2048 (replace-match "" t t)))))
2050 (defun article-strip-trailing-space ()
2051 "Remove all white space from the end of the lines in the article."
2054 (let ((inhibit-point-motion-hooks t)
2057 (while (re-search-forward "[ \t]+$" nil t)
2058 (replace-match "" t t)))))
2060 (defun article-strip-blank-lines ()
2061 "Strip leading, trailing and multiple blank lines."
2063 (article-strip-leading-blank-lines)
2064 (article-remove-trailing-blank-lines)
2065 (article-strip-multiple-blank-lines))
2067 (defun article-strip-all-blank-lines ()
2068 "Strip all blank lines."
2071 (let ((inhibit-point-motion-hooks t)
2074 (while (re-search-forward "^[ \t]*\n" nil t)
2075 (replace-match "" t t)))))
2077 (defun gnus-article-narrow-to-signature ()
2078 "Narrow to the signature; return t if a signature is found, else nil."
2079 (let ((inhibit-point-motion-hooks t))
2080 (when (gnus-article-search-signature)
2082 ;; Check whether we have some limits to what we consider
2083 ;; to be a signature.
2084 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2085 (list gnus-signature-limit)))
2087 (while (setq limit (pop limits))
2088 (if (or (and (integerp limit)
2089 (< (- (point-max) (point)) limit))
2091 (< (count-lines (point) (point-max)) limit))
2092 (and (gnus-functionp limit)
2094 (and (stringp limit)
2095 (not (re-search-forward limit nil t))))
2096 () ; This limit did not succeed.
2100 (narrow-to-region (point) (point-max))
2103 (defun gnus-article-search-signature ()
2104 "Search the current buffer for the signature separator.
2105 Put point at the beginning of the signature separator."
2106 (let ((cur (point)))
2107 (goto-char (point-max))
2108 (if (if (stringp gnus-signature-separator)
2109 (re-search-backward gnus-signature-separator nil t)
2110 (let ((seps gnus-signature-separator))
2112 (not (re-search-backward (car seps) nil t)))
2119 (defun gnus-article-hidden-arg ()
2120 "Return the current prefix arg as a number, or 0 if no prefix."
2121 (list (if current-prefix-arg
2122 (prefix-numeric-value current-prefix-arg)
2125 (defun gnus-article-check-hidden-text (type arg)
2126 "Return nil if hiding is necessary.
2127 Arg can be nil or a number. Nil and positive means hide, negative
2128 means show, 0 means toggle."
2131 (let ((hide (gnus-article-hidden-text-p type)))
2137 (gnus-article-show-hidden-text type)
2140 (if (eq hide 'hidden)
2142 (gnus-article-show-hidden-text type)
2146 (defun gnus-article-hidden-text-p (type)
2147 "Say whether the current buffer contains hidden text of type TYPE."
2148 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2150 (not (get-text-property pos 'invisible))
2151 (not (get-text-property pos 'dummy-invisible)))
2153 (text-property-any (1+ pos) (point-max) 'article-type type)))
2158 (defun gnus-article-show-hidden-text (type &optional dummy)
2159 "Show all hidden text of type TYPE.
2160 Originally it is hide instead of DUMMY."
2161 (let ((buffer-read-only nil)
2162 (inhibit-point-motion-hooks t))
2163 (gnus-remove-text-properties-when
2165 (point-min) (point-max)
2166 (cons 'article-type (cons type
2167 gnus-hidden-properties)))))
2169 (defconst article-time-units
2170 `((year . ,(* 365.25 24 60 60))
2171 (week . ,(* 7 24 60 60))
2172 (day . ,(* 24 60 60))
2176 "Mapping from time units to seconds.")
2178 (defun article-date-ut (&optional type highlight header)
2179 "Convert DATE date to universal time in the current article.
2180 If TYPE is `local', convert to local time; if it is `lapsed', output
2181 how much time has lapsed since DATE. For `lapsed', the value of
2182 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2183 should replace the \"Date:\" one, or should be added below it."
2184 (interactive (list 'ut t))
2185 (let* ((header (or header
2186 (message-fetch-field "date")
2188 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2191 ((not gnus-article-date-lapsed-new-header)
2197 (date (if (vectorp header) (mail-header-date header)
2199 (inhibit-point-motion-hooks t)
2204 (article-narrow-to-head)
2205 (when (re-search-forward tdate-regexp nil t)
2206 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2207 date (or (get-text-property (gnus-point-at-bol)
2210 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2212 (when (and date (not (string= date "")))
2213 (goto-char (point-min))
2214 (let ((buffer-read-only nil))
2215 ;; Delete any old Date headers.
2216 (while (re-search-forward date-regexp nil t)
2218 (delete-region (progn (beginning-of-line) (point))
2219 (progn (forward-line 1) (point)))
2220 (delete-region (progn (beginning-of-line) (point))
2221 (progn (end-of-line) (point)))
2222 (setq pos (point))))
2223 (when (and (not pos) (re-search-forward tdate-regexp nil t))
2225 (if pos (goto-char pos))
2226 (insert (article-make-date-line date (or type 'ut)))
2232 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2233 (put-text-property (match-beginning 1) (1+ (match-end 1))
2234 'original-date date)
2235 (put-text-property (match-beginning 1) (1+ (match-end 1))
2237 (put-text-property (match-beginning 2) (match-end 2)
2240 (defun article-make-date-line (date type)
2241 "Return a DATE line of TYPE."
2242 (unless (memq type '(local ut original user iso8601 lapsed english))
2243 (error "Unknown conversion type: %s" type))
2245 (let ((time (date-to-time date)))
2247 ;; Convert to the local timezone.
2249 (let ((tz (car (current-time-zone time))))
2250 (format "Date: %s %s%02d%02d" (current-time-string time)
2251 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2252 (/ (% (abs tz) 3600) 60))))
2253 ;; Convert to Universal Time.
2256 (current-time-string
2257 (let* ((e (parse-time-string date))
2258 (tm (apply 'encode-time e))
2260 (ls (- (cadr tm) (car (current-time-zone time)))))
2261 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2262 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2265 ;; Get the original date from the article.
2266 ((eq type 'original)
2267 (concat "Date: " (if (string-match "\n+$" date)
2268 (substring date 0 (match-beginning 0))
2270 ;; Let the user define the format.
2272 (if (gnus-functionp gnus-article-time-format)
2273 (funcall gnus-article-time-format time)
2276 (format-time-string gnus-article-time-format time))))
2279 (let ((tz (car (current-time-zone time))))
2282 (format-time-string "%Y%m%dT%H%M%S" time)
2283 (format "%s%02d%02d"
2284 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2285 (/ (% (abs tz) 3600) 60)))))
2286 ;; Do an X-Sent lapsed format.
2288 ;; If the date is seriously mangled, the timezone functions are
2289 ;; liable to bug out, so we ignore all errors.
2290 (let* ((now (current-time))
2291 (real-time (subtract-time now time))
2292 (real-sec (and real-time
2293 (+ (* (float (car real-time)) 65536)
2295 (sec (and real-time (abs real-sec)))
2305 ;; This is a bit convoluted, but basically we go
2306 ;; through the time units for years, weeks, etc,
2307 ;; and divide things to see whether that results
2308 ;; in positive answers.
2311 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2312 ;; The (remaining) seconds are too few to
2313 ;; be divided into this time unit.
2315 ;; It's big enough, so we output it.
2316 (setq sec (- sec (* num (cdr unit))))
2318 (concat (if prev ", " "") (int-to-string
2320 " " (symbol-name (car unit))
2321 (if (> num 1) "s" ""))
2323 article-time-units "")
2324 ;; If dates are odd, then it might appear like the
2325 ;; article was sent in the future.
2328 " in the future"))))))
2329 ;; Display the date in proper English
2331 (let ((dtime (decode-time time)))
2334 (number-to-string (nth 3 dtime))
2335 (let ((digit (% (nth 3 dtime) 10)))
2337 ((memq (nth 3 dtime) '(11 12 13)) "th")
2343 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2345 (number-to-string (nth 5 dtime))
2347 (format "%02d" (nth 2 dtime))
2349 (format "%02d" (nth 1 dtime)))))))
2351 (format "Date: %s (from Oort)" date))))
2353 (defun article-date-local (&optional highlight)
2354 "Convert the current article date to the local timezone."
2355 (interactive (list t))
2356 (article-date-ut 'local highlight))
2358 (defun article-date-english (&optional highlight)
2359 "Convert the current article date to something that is proper English."
2360 (interactive (list t))
2361 (article-date-ut 'english highlight))
2363 (defun article-date-original (&optional highlight)
2364 "Convert the current article date to what it was originally.
2365 This is only useful if you have used some other date conversion
2366 function and want to see what the date was before converting."
2367 (interactive (list t))
2368 (article-date-ut 'original highlight))
2370 (defun article-date-lapsed (&optional highlight)
2371 "Convert the current article date to time lapsed since it was sent."
2372 (interactive (list t))
2373 (article-date-ut 'lapsed highlight))
2375 (defun article-update-date-lapsed ()
2376 "Function to be run from a timer to update the lapsed time line."
2377 (let (deactivate-mark)
2382 (set-buffer (window-buffer w))
2383 (when (eq major-mode 'gnus-article-mode)
2384 (goto-char (point-min))
2385 (when (re-search-forward "^X-Sent:" nil t)
2386 (article-date-lapsed t))))
2389 (defun gnus-start-date-timer (&optional n)
2390 "Start a timer to update the X-Sent header in the article buffers.
2391 The numerical prefix says how frequently (in seconds) the function
2396 (gnus-stop-date-timer)
2397 (setq article-lapsed-timer
2398 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2400 (defun gnus-stop-date-timer ()
2401 "Stop the X-Sent timer."
2403 (when article-lapsed-timer
2404 (nnheader-cancel-timer article-lapsed-timer)
2405 (setq article-lapsed-timer nil)))
2407 (defun article-date-user (&optional highlight)
2408 "Convert the current article date to the user-defined format.
2409 This format is defined by the `gnus-article-time-format' variable."
2410 (interactive (list t))
2411 (article-date-ut 'user highlight))
2413 (defun article-date-iso8601 (&optional highlight)
2414 "Convert the current article date to ISO8601."
2415 (interactive (list t))
2416 (article-date-ut 'iso8601 highlight))
2418 (defun article-show-all ()
2419 "Show all hidden text in the article buffer."
2422 (let ((buffer-read-only nil))
2423 (gnus-article-unhide-text (point-min) (point-max)))))
2425 (defun article-remove-leading-whitespace ()
2426 "Remove excessive whitespace from all headers."
2430 (let ((buffer-read-only nil))
2431 (article-narrow-to-head)
2432 (goto-char (point-min))
2433 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2434 (delete-region (match-beginning 1) (match-end 1)))))))
2436 (defun article-emphasize (&optional arg)
2437 "Emphasize text according to `gnus-emphasis-alist'."
2438 (interactive (gnus-article-hidden-arg))
2439 (unless (gnus-article-check-hidden-text 'emphasis arg)
2443 (with-current-buffer gnus-summary-buffer
2444 gnus-article-emphasis-alist)
2446 gnus-emphasis-alist))
2447 (buffer-read-only nil)
2448 (props (append '(article-type emphasis)
2449 gnus-hidden-properties))
2450 regexp elem beg invisible visible face)
2453 (while (setq elem (pop alist))
2455 (setq regexp (car elem)
2456 invisible (nth 1 elem)
2457 visible (nth 2 elem)
2459 (while (re-search-forward regexp nil t)
2460 (when (and (match-beginning visible) (match-beginning invisible))
2461 (push 'emphasis gnus-article-wash-types)
2462 (gnus-article-hide-text
2463 (match-beginning invisible) (match-end invisible) props)
2464 (gnus-article-unhide-text-type
2465 (match-beginning visible) (match-end visible) 'emphasis)
2466 (gnus-put-text-property-excluding-newlines
2467 (match-beginning visible) (match-end visible) 'face face)
2468 (goto-char (match-end invisible)))))))))
2470 (defun gnus-article-setup-highlight-words (&optional highlight-words)
2471 "Setup newsgroup emphasis alist."
2472 (unless gnus-article-emphasis-alist
2473 (let ((name (and gnus-newsgroup-name
2474 (gnus-group-real-name gnus-newsgroup-name))))
2475 (make-local-variable 'gnus-article-emphasis-alist)
2476 (setq gnus-article-emphasis-alist
2478 (let ((alist gnus-group-highlight-words-alist) elem highlight)
2479 (while (setq elem (pop alist))
2480 (when (and name (string-match (car elem) name))
2482 highlight (copy-sequence (cdr elem)))))
2484 (copy-sequence highlight-words)
2485 (if gnus-newsgroup-name
2486 (copy-sequence (gnus-group-find-parameter
2487 gnus-newsgroup-name 'highlight-words t)))
2488 gnus-emphasis-alist)))))
2491 (defvar gnus-summary-article-menu)
2492 (defvar gnus-summary-post-menu))
2494 ;;; Saving functions.
2496 (defun gnus-article-save (save-buffer file &optional num)
2497 "Save the currently selected article."
2498 (unless gnus-save-all-headers
2499 ;; Remove headers according to `gnus-saved-headers'.
2500 (let ((gnus-visible-headers
2501 (or gnus-saved-headers gnus-visible-headers))
2502 (gnus-article-buffer save-buffer))
2504 (set-buffer save-buffer)
2505 (article-hide-headers 1 t))))
2506 (save-window-excursion
2507 (if (not gnus-default-article-saver)
2508 (error "No default saver is defined")
2509 ;; !!! Magic! The saving functions all save
2510 ;; `gnus-save-article-buffer' (or so they think), but we
2511 ;; bind that variable to our save-buffer.
2512 (set-buffer gnus-article-buffer)
2513 (let* ((gnus-save-article-buffer save-buffer)
2516 ((not gnus-prompt-before-saving) 'default)
2517 ((eq gnus-prompt-before-saving 'always) nil)
2519 (gnus-number-of-articles-to-be-saved
2520 (when (eq gnus-prompt-before-saving t)
2522 (set-buffer gnus-article-current-summary)
2523 (funcall gnus-default-article-saver filename)))))
2525 (defun gnus-read-save-file-name (prompt &optional filename
2526 function group headers variable)
2528 (funcall function group headers (symbol-value variable)))
2533 ((eq filename 'default)
2539 (let* ((split-name (gnus-get-split-value gnus-split-methods))
2542 (if (and gnus-number-of-articles-to-be-saved
2543 (> gnus-number-of-articles-to-be-saved 1))
2544 (format "these %d articles"
2545 gnus-number-of-articles-to-be-saved)
2548 ;; Let the split methods have their say.
2550 ;; No split name was found.
2553 (concat prompt " (default "
2554 (file-name-nondirectory default-name) ") ")
2555 (file-name-directory default-name)
2557 ;; A single group name is returned.
2558 ((stringp split-name)
2560 (funcall function split-name headers
2561 (symbol-value variable)))
2563 (concat prompt " (default "
2564 (file-name-nondirectory default-name) ") ")
2565 (file-name-directory default-name)
2567 ;; A single split name was found
2568 ((= 1 (length split-name))
2569 (let* ((name (expand-file-name
2571 gnus-article-save-directory))
2572 (dir (cond ((file-directory-p name)
2573 (file-name-as-directory name))
2574 ((file-exists-p name) name)
2575 (t gnus-article-save-directory))))
2577 (concat prompt " (default " name ") ")
2579 ;; A list of splits was found.
2581 (setq split-name (nreverse split-name))
2583 (let ((file-name-history
2584 (nconc split-name file-name-history)))
2588 (concat prompt " (`M-p' for defaults) ")
2589 gnus-article-save-directory
2591 gnus-article-save-directory)))
2592 (car (push result file-name-history)))))))
2593 ;; Create the directory.
2594 (gnus-make-directory (file-name-directory file))
2595 ;; If we have read a directory, we append the default file name.
2596 (when (file-directory-p file)
2597 (setq file (expand-file-name (file-name-nondirectory
2599 (file-name-as-directory file))))
2600 ;; Possibly translate some characters.
2601 (nnheader-translate-file-chars file))))))
2602 (gnus-make-directory (file-name-directory result))
2603 (set variable result)))
2605 (defun gnus-article-archive-name (group)
2606 "Return the first instance of an \"Archive-name\" in the current buffer."
2607 (let ((case-fold-search t))
2608 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
2609 (nnheader-concat gnus-article-save-directory
2610 (match-string 1)))))
2612 (defun gnus-article-nndoc-name (group)
2613 "If GROUP is an nndoc group, return the name of the parent group."
2614 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
2615 (gnus-group-get-parameter group 'save-article-group)))
2617 (defun gnus-summary-save-in-rmail (&optional filename)
2618 "Append this article to Rmail file.
2619 Optional argument FILENAME specifies file name.
2620 Directory to save to is default to `gnus-article-save-directory'."
2621 (setq filename (gnus-read-save-file-name
2622 "Save %s in rmail file:" filename
2623 gnus-rmail-save-name gnus-newsgroup-name
2624 gnus-current-headers 'gnus-newsgroup-last-rmail))
2625 (gnus-eval-in-buffer-window gnus-save-article-buffer
2629 (gnus-output-to-rmail filename))))
2632 (defun gnus-summary-save-in-mail (&optional filename)
2633 "Append this article to Unix mail file.
2634 Optional argument FILENAME specifies file name.
2635 Directory to save to is default to `gnus-article-save-directory'."
2636 (setq filename (gnus-read-save-file-name
2637 "Save %s in Unix mail file:" filename
2638 gnus-mail-save-name gnus-newsgroup-name
2639 gnus-current-headers 'gnus-newsgroup-last-mail))
2640 (gnus-eval-in-buffer-window gnus-save-article-buffer
2644 (if (and (file-readable-p filename)
2645 (mail-file-babyl-p filename))
2646 (rmail-output-to-rmail-file filename t)
2647 (gnus-output-to-mail filename)))))
2650 (defun gnus-summary-save-in-file (&optional filename overwrite)
2651 "Append this article to file.
2652 Optional argument FILENAME specifies file name.
2653 Directory to save to is default to `gnus-article-save-directory'."
2654 (setq filename (gnus-read-save-file-name
2655 "Save %s in file:" filename
2656 gnus-file-save-name gnus-newsgroup-name
2657 gnus-current-headers 'gnus-newsgroup-last-file))
2658 (gnus-eval-in-buffer-window gnus-save-article-buffer
2662 (when (and overwrite
2663 (file-exists-p filename))
2664 (delete-file filename))
2665 (gnus-output-to-file filename))))
2668 (defun gnus-summary-write-to-file (&optional filename)
2669 "Write this article to a file.
2670 Optional argument FILENAME specifies file name.
2671 The directory to save in defaults to `gnus-article-save-directory'."
2672 (gnus-summary-save-in-file nil t))
2674 (defun gnus-summary-save-body-in-file (&optional filename)
2675 "Append this article body to a file.
2676 Optional argument FILENAME specifies file name.
2677 The directory to save in defaults to `gnus-article-save-directory'."
2678 (setq filename (gnus-read-save-file-name
2679 "Save %s body in file:" filename
2680 gnus-file-save-name gnus-newsgroup-name
2681 gnus-current-headers 'gnus-newsgroup-last-file))
2682 (gnus-eval-in-buffer-window gnus-save-article-buffer
2686 (when (article-goto-body)
2687 (narrow-to-region (point) (point-max)))
2688 (gnus-output-to-file filename))))
2691 (defun gnus-summary-save-in-pipe (&optional command)
2692 "Pipe this article to subprocess."
2694 (cond ((and (eq command 'default)
2695 gnus-last-shell-command)
2696 gnus-last-shell-command)
2701 "Shell command on %s: "
2702 (if (and gnus-number-of-articles-to-be-saved
2703 (> gnus-number-of-articles-to-be-saved 1))
2704 (format "these %d articles"
2705 gnus-number-of-articles-to-be-saved)
2707 gnus-last-shell-command))))
2708 (when (string-equal command "")
2709 (if gnus-last-shell-command
2710 (setq command gnus-last-shell-command)
2711 (error "A command is required.")))
2712 (gnus-eval-in-buffer-window gnus-article-buffer
2715 (shell-command-on-region (point-min) (point-max) command nil)))
2716 (setq gnus-last-shell-command command))
2718 ;;; Article file names when saving.
2720 (defun gnus-capitalize-newsgroup (newsgroup)
2721 "Capitalize NEWSGROUP name."
2722 (when (not (zerop (length newsgroup)))
2723 (concat (char-to-string (upcase (aref newsgroup 0)))
2724 (substring newsgroup 1))))
2726 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
2727 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2728 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
2729 Otherwise, it is like ~/News/news/group/num."
2732 (concat (if (gnus-use-long-file-name 'not-save)
2733 (gnus-capitalize-newsgroup newsgroup)
2734 (gnus-newsgroup-directory-form newsgroup))
2735 "/" (int-to-string (mail-header-number headers)))
2736 gnus-article-save-directory)))
2738 (string-equal (file-name-directory default)
2739 (file-name-directory last-file))
2740 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2742 (or last-file default))))
2744 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
2745 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
2746 If variable `gnus-use-long-file-name' is non-nil, it is
2747 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
2750 (concat (if (gnus-use-long-file-name 'not-save)
2752 (gnus-newsgroup-directory-form newsgroup))
2753 "/" (int-to-string (mail-header-number headers)))
2754 gnus-article-save-directory)))
2756 (string-equal (file-name-directory default)
2757 (file-name-directory last-file))
2758 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
2760 (or last-file default))))
2762 (defun gnus-plain-save-name (newsgroup headers &optional last-file)