1 ;;; gnus-art.el --- article mode commands for Gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
31 (defvar tool-bar-map))
46 (autoload 'gnus-msg-mail "gnus-msg" nil t)
47 (autoload 'gnus-button-mailto "gnus-msg")
48 (autoload 'gnus-button-reply "gnus-msg" nil t)
50 (defgroup gnus-article nil
52 :link '(custom-manual "(gnus)The Article Buffer")
55 (defgroup gnus-article-treat nil
56 "Treating article parts."
57 :link '(custom-manual "(gnus)Article Hiding")
60 (defgroup gnus-article-hiding nil
61 "Hiding article parts."
62 :link '(custom-manual "(gnus)Article Hiding")
65 (defgroup gnus-article-highlight nil
66 "Article highlighting."
67 :link '(custom-manual "(gnus)Article Highlighting")
71 (defgroup gnus-article-signature nil
73 :link '(custom-manual "(gnus)Article Signature")
76 (defgroup gnus-article-headers nil
78 :link '(custom-manual "(gnus)Hiding Headers")
81 (defgroup gnus-article-washing nil
82 "Special commands on articles."
83 :link '(custom-manual "(gnus)Article Washing")
86 (defgroup gnus-article-emphasis nil
87 "Fontisizing articles."
88 :link '(custom-manual "(gnus)Article Fontisizing")
91 (defgroup gnus-article-saving nil
93 :link '(custom-manual "(gnus)Saving Articles")
96 (defgroup gnus-article-mime nil
97 "Worshiping the MIME wonder."
98 :link '(custom-manual "(gnus)Using MIME")
101 (defgroup gnus-article-buttons nil
102 "Pushable buttons in the article buffer."
103 :link '(custom-manual "(gnus)Article Buttons")
104 :group 'gnus-article)
106 (defgroup gnus-article-various nil
107 "Other article options."
108 :link '(custom-manual "(gnus)Misc Article")
109 :group 'gnus-article)
111 (defcustom gnus-ignored-headers
114 (concat "^" header ":"))
115 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
116 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
117 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
118 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
119 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
120 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
121 "X-Attribution" "X-Originating-IP" "Delivered-To"
122 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
123 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
124 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
125 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
126 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
127 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
128 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
129 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
130 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
131 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
132 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
133 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
134 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
135 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
136 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
137 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
138 "List-[A-Za-z]+" "X-Listprocessor-Version"
139 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
140 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
141 "X-Received" "Content-length" "X-precedence"
142 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
143 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
144 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
145 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
146 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
147 "X-Content-length" "X-Posting-Agent" "Original-Received"
148 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
149 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
150 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
151 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
152 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"))
153 "*All headers that start with this regexp will be hidden.
154 This variable can also be a list of regexps of headers to be ignored.
155 If `gnus-visible-headers' is non-nil, this variable will be ignored."
156 :type '(choice :custom-show nil
159 :group 'gnus-article-hiding)
161 (defcustom gnus-visible-headers
162 "^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:"
163 "*All headers that do not match this regexp will be hidden.
164 This variable can also be a list of regexp of headers to remain visible.
165 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
166 :type '(repeat :value-to-internal (lambda (widget value)
167 (custom-split-regexp-maybe value))
168 :match (lambda (widget value)
170 (widget-editable-list-match widget value)))
172 :group 'gnus-article-hiding)
174 (defcustom gnus-sorted-header-list
175 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
176 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
177 "*This variable is a list of regular expressions.
178 If it is non-nil, headers that match the regular expressions will
179 be placed first in the article buffer in the sequence specified by
181 :type '(repeat regexp)
182 :group 'gnus-article-hiding)
184 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
185 "Headers that are only to be displayed if they have interesting data.
186 Possible values in this list are:
188 'empty Headers with no content.
189 'newsgroups Newsgroup identical to Gnus group.
190 'to-address To identical to To-address.
191 'to-list To identical to To-list.
192 'cc-list CC identical to To-list.
193 'followup-to Followup-to identical to Newsgroups.
194 'reply-to Reply-to identical to From.
195 'date Date less than four days old.
196 'long-to To and/or Cc longer than 1024 characters.
197 'many-to Multiple To and/or Cc."
198 :type '(set (const :tag "Headers with no content." empty)
199 (const :tag "Newsgroups identical to Gnus group." newsgroups)
200 (const :tag "To identical to To-address." to-address)
201 (const :tag "To identical to To-list." to-list)
202 (const :tag "CC identical to To-list." cc-list)
203 (const :tag "Followup-to identical to Newsgroups." followup-to)
204 (const :tag "Reply-to identical to From." reply-to)
205 (const :tag "Date less than four days old." date)
206 (const :tag "To and/or Cc longer than 1024 characters." long-to)
207 (const :tag "Multiple To and/or Cc headers." many-to))
208 :group 'gnus-article-hiding)
210 (defcustom gnus-article-skip-boring nil
211 "Skip over text that is not worth reading.
212 By default, if you set this t, then Gnus will display citations and
213 signatures, but will never scroll down to show you a page consisting
214 only of boring text. Boring text is controlled by
215 `gnus-article-boring-faces'."
217 :group 'gnus-article-hiding)
219 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
220 "Regexp matching signature separator.
221 This can also be a list of regexps. In that case, it will be checked
222 from head to tail looking for a separator. Searches will be done from
223 the end of the buffer."
224 :type '(repeat string)
225 :group 'gnus-article-signature)
227 (defcustom gnus-signature-limit nil
228 "Provide a limit to what is considered a signature.
229 If it is a number, no signature may not be longer (in characters) than
230 that number. If it is a floating point number, no signature may be
231 longer (in lines) than that number. If it is a function, the function
232 will be called without any parameters, and if it returns nil, there is
233 no signature in the buffer. If it is a string, it will be used as a
234 regexp. If it matches, the text in question is not a signature."
235 :type '(choice (integer :value 200)
237 (function :value fun)
238 (regexp :value ".*"))
239 :group 'gnus-article-signature)
241 (defcustom gnus-hidden-properties '(invisible t intangible t)
242 "Property list to use for hiding text."
244 :group 'gnus-article-hiding)
246 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
247 ;; frames in a session.
248 (defcustom gnus-article-x-face-command
249 (if (featurep 'xemacs)
250 (if (or (gnus-image-type-available-p 'xface)
251 (gnus-image-type-available-p 'pbm))
252 'gnus-display-x-face-in-from
253 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
254 (if (gnus-image-type-available-p 'pbm)
255 'gnus-display-x-face-in-from
256 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
258 "*String or function to be executed to display an X-Face header.
259 If it is a string, the command will be executed in a sub-shell
260 asynchronously. The compressed face will be piped to this command."
261 :type `(choice string
262 (function-item gnus-display-x-face-in-from)
266 :group 'gnus-article-washing)
268 (defcustom gnus-article-x-face-too-ugly nil
269 "Regexp matching posters whose face shouldn't be shown automatically."
270 :type '(choice regexp (const nil))
271 :group 'gnus-article-washing)
273 (defcustom gnus-article-banner-alist nil
274 "Banner alist for stripping.
276 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
278 :type '(repeat (cons symbol regexp))
279 :group 'gnus-article-washing)
281 (gnus-define-group-parameter
284 "Alist of regexps (to match group names) and banner."
285 :variable-group gnus-article-washing
287 '(choice :tag "Banner"
289 (const :tag "Remove signature" signature)
290 (symbol :tag "Item in `gnus-article-banner-alist'" none)
292 (const :tag "None" nil))
294 "If non-nil, specify how to remove `banners' from articles.
296 Symbol `signature' means to remove signatures delimited by
297 `gnus-signature-separator'. Any other symbol is used to look up a
298 regular expression to match the banner in `gnus-article-banner-alist'.
299 A string is used as a regular expression to match the banner
302 (defcustom gnus-article-address-banner-alist nil
303 "Alist of mail addresses and banners.
304 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
305 to match a mail address in the From: header, BANNER is one of a symbol
306 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
307 If ADDRESS matches author's mail address, it will remove things like
308 advertisements. For example:
310 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
314 (regexp :tag "Address")
315 (choice :tag "Banner" :value nil
316 (const :tag "Remove signature" signature)
317 (symbol :tag "Item in `gnus-article-banner-alist'" none)
319 (const :tag "None" nil))))
320 :group 'gnus-article-washing)
322 (defcustom gnus-emphasis-alist
324 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
329 ("_/" "/_" underline-italic)
330 ("_\\*" "\\*_" underline-bold)
331 ("\\*/" "/\\*" bold-italic)
332 ("_\\*/" "/\\*_" underline-bold-italic))))
336 (format format (car spec) (cadr spec))
337 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
339 ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
340 2 3 gnus-emphasis-strikethru)
341 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
342 2 3 gnus-emphasis-underline)))
343 "*Alist that says how to fontify certain phrases.
344 Each item looks like this:
346 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
348 The first element is a regular expression to be matched. The second
349 is a number that says what regular expression grouping used to find
350 the entire emphasized word. The third is a number that says what
351 regexp grouping should be displayed and highlighted. The fourth
352 is the face used for highlighting."
353 :type '(repeat (list :value ("" 0 0 default)
355 (integer :tag "Match group")
356 (integer :tag "Emphasize group")
358 :group 'gnus-article-emphasis)
360 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
361 "A regexp to describe whitespace which should not be emphasized.
362 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
363 The former avoids underlining of leading and trailing whitespace,
364 and the latter avoids underlining any whitespace at all."
366 :group 'gnus-article-emphasis
369 (defface gnus-emphasis-bold '((t (:bold t)))
370 "Face used for displaying strong emphasized text (*word*)."
371 :group 'gnus-article-emphasis)
373 (defface gnus-emphasis-italic '((t (:italic t)))
374 "Face used for displaying italic emphasized text (/word/)."
375 :group 'gnus-article-emphasis)
377 (defface gnus-emphasis-underline '((t (:underline t)))
378 "Face used for displaying underlined emphasized text (_word_)."
379 :group 'gnus-article-emphasis)
381 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
382 "Face used for displaying underlined bold emphasized text (_*word*_)."
383 :group 'gnus-article-emphasis)
385 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
386 "Face used for displaying underlined italic emphasized text (_/word/_)."
387 :group 'gnus-article-emphasis)
389 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
390 "Face used for displaying bold italic emphasized text (/*word*/)."
391 :group 'gnus-article-emphasis)
393 (defface gnus-emphasis-underline-bold-italic
394 '((t (:bold t :italic t :underline t)))
395 "Face used for displaying underlined bold italic emphasized text.
396 Example: (_/*word*/_)."
397 :group 'gnus-article-emphasis)
399 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
400 '((t (:strikethru t)))
401 '((t (:strike-through t))))
402 "Face used for displaying strike-through text (-word-)."
403 :group 'gnus-article-emphasis)
405 (defface gnus-emphasis-highlight-words
406 '((t (:background "black" :foreground "yellow")))
407 "Face used for displaying highlighted words."
408 :group 'gnus-article-emphasis)
410 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
411 "Format for display of Date headers in article bodies.
412 See `format-time-string' for the possible values.
414 The variable can also be function, which should return a complete Date
415 header. The function is called with one argument, the time, which can
416 be fed to `format-time-string'."
417 :type '(choice string symbol)
418 :link '(custom-manual "(gnus)Article Date")
419 :group 'gnus-article-washing)
422 (autoload 'mail-extract-address-components "mail-extr"))
424 (defcustom gnus-save-all-headers t
425 "*If non-nil, don't remove any headers before saving."
426 :group 'gnus-article-saving
429 (defcustom gnus-prompt-before-saving 'always
430 "*This variable says how much prompting is to be done when saving articles.
431 If it is nil, no prompting will be done, and the articles will be
432 saved to the default files. If this variable is `always', each and
433 every article that is saved will be preceded by a prompt, even when
434 saving large batches of articles. If this variable is neither nil not
435 `always', there the user will be prompted once for a file name for
436 each invocation of the saving commands."
437 :group 'gnus-article-saving
438 :type '(choice (item always)
439 (item :tag "never" nil)
440 (sexp :tag "once" :format "%t\n" :value t)))
442 (defcustom gnus-saved-headers gnus-visible-headers
443 "Headers to keep if `gnus-save-all-headers' is nil.
444 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
445 If that variable is nil, however, all headers that match this regexp
446 will be kept while the rest will be deleted before saving."
447 :group 'gnus-article-saving
450 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
451 "A function to save articles in your favourite format.
452 The function must be interactively callable (in other words, it must
453 be an Emacs command).
455 Gnus provides the following functions:
457 * gnus-summary-save-in-rmail (Rmail format)
458 * gnus-summary-save-in-mail (Unix mail format)
459 * gnus-summary-save-in-folder (MH folder)
460 * gnus-summary-save-in-file (article format)
461 * gnus-summary-save-body-in-file (article body)
462 * gnus-summary-save-in-vm (use VM's folder format)
463 * gnus-summary-write-to-file (article format -- overwrite)."
464 :group 'gnus-article-saving
465 :type '(radio (function-item gnus-summary-save-in-rmail)
466 (function-item gnus-summary-save-in-mail)
467 (function-item gnus-summary-save-in-folder)
468 (function-item gnus-summary-save-in-file)
469 (function-item gnus-summary-save-body-in-file)
470 (function-item gnus-summary-save-in-vm)
471 (function-item gnus-summary-write-to-file)))
473 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
474 "A function generating a file name to save articles in Rmail format.
475 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
476 :group 'gnus-article-saving
479 (defcustom gnus-mail-save-name 'gnus-plain-save-name
480 "A function generating a file name to save articles in Unix mail format.
481 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
482 :group 'gnus-article-saving
485 (defcustom gnus-folder-save-name 'gnus-folder-save-name
486 "A function generating a file name to save articles in MH folder.
487 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
488 :group 'gnus-article-saving
491 (defcustom gnus-file-save-name 'gnus-numeric-save-name
492 "A function generating a file name to save articles in article format.
493 The function is called with NEWSGROUP, HEADERS, and optional
495 :group 'gnus-article-saving
498 (defcustom gnus-split-methods
499 '((gnus-article-archive-name)
500 (gnus-article-nndoc-name))
501 "*Variable used to suggest where articles are to be saved.
502 For instance, if you would like to save articles related to Gnus in
503 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
504 you could set this variable to something like:
506 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
507 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
509 This variable is an alist where the where the key is the match and the
510 value is a list of possible files to save in if the match is non-nil.
512 If the match is a string, it is used as a regexp match on the
513 article. If the match is a symbol, that symbol will be funcalled
514 from the buffer of the article to be saved with the newsgroup as the
515 parameter. If it is a list, it will be evaled in the same buffer.
517 If this form or function returns a string, this string will be used as
518 a possible file name; and if it returns a non-nil list, that list will
519 be used as possible file names."
520 :group 'gnus-article-saving
521 :type '(repeat (choice (list :value (fun) function)
522 (cons :value ("" "") regexp (repeat string))
525 (defcustom gnus-page-delimiter "^\^L"
526 "*Regexp describing what to use as article page delimiters.
527 The default value is \"^\^L\", which is a form linefeed at the
528 beginning of a line."
530 :group 'gnus-article-various)
532 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
533 "*The format specification for the article mode line.
534 See `gnus-summary-mode-line-format' for a closer description.
536 The following additional specs are available:
538 %w The article washing status.
539 %m The number of MIME parts in the article."
541 :group 'gnus-article-various)
543 (defcustom gnus-article-mode-hook nil
544 "*A hook for Gnus article mode."
546 :group 'gnus-article-various)
548 (when (featurep 'xemacs)
549 ;; Extracted from gnus-xmas-define in order to preserve user settings
550 (when (fboundp 'turn-off-scroll-in-place)
551 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
552 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
553 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
555 (defcustom gnus-article-menu-hook nil
556 "*Hook run after the creation of the article mode menu."
558 :group 'gnus-article-various)
560 (defcustom gnus-article-prepare-hook nil
561 "*A hook called after an article has been prepared in the article buffer."
563 :group 'gnus-article-various)
565 (make-obsolete-variable 'gnus-article-hide-pgp-hook
566 "This variable is obsolete in Gnus 5.10.")
568 (defcustom gnus-article-button-face 'bold
569 "Face used for highlighting buttons in the article buffer.
571 An article button is a piece of text that you can activate by pressing
572 `RET' or `mouse-2' above it."
574 :group 'gnus-article-buttons)
576 (defcustom gnus-article-mouse-face 'highlight
577 "Face used for mouse highlighting in the article buffer.
579 Article buttons will be displayed in this face when the cursor is
582 :group 'gnus-article-buttons)
584 (defcustom gnus-signature-face 'gnus-signature-face
585 "Face used for highlighting a signature in the article buffer.
586 Obsolete; use the face `gnus-signature-face' for customizations instead."
588 :group 'gnus-article-highlight
589 :group 'gnus-article-signature)
591 (defface gnus-signature-face
594 "Face used for highlighting a signature in the article buffer."
595 :group 'gnus-article-highlight
596 :group 'gnus-article-signature)
598 (defface gnus-header-from-face
601 (:foreground "spring green"))
604 (:foreground "red3"))
607 "Face used for displaying from headers."
608 :group 'gnus-article-headers
609 :group 'gnus-article-highlight)
611 (defface gnus-header-subject-face
614 (:foreground "SeaGreen3"))
617 (:foreground "red4"))
619 (:bold t :italic t)))
620 "Face used for displaying subject headers."
621 :group 'gnus-article-headers
622 :group 'gnus-article-highlight)
624 (defface gnus-header-newsgroups-face
627 (:foreground "yellow" :italic t))
630 (:foreground "MidnightBlue" :italic t))
633 "Face used for displaying newsgroups headers.
634 In the default setup this face is only used for crossposted
636 :group 'gnus-article-headers
637 :group 'gnus-article-highlight)
639 (defface gnus-header-name-face
642 (:foreground "SeaGreen"))
645 (:foreground "maroon"))
648 "Face used for displaying header names."
649 :group 'gnus-article-headers
650 :group 'gnus-article-highlight)
652 (defface gnus-header-content-face
655 (:foreground "forest green" :italic t))
658 (:foreground "indianred4" :italic t))
660 (:italic t))) "Face used for displaying header content."
661 :group 'gnus-article-headers
662 :group 'gnus-article-highlight)
664 (defcustom gnus-header-face-alist
665 '(("From" nil gnus-header-from-face)
666 ("Subject" nil gnus-header-subject-face)
667 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
668 ("" gnus-header-name-face gnus-header-content-face))
669 "*Controls highlighting of article headers.
671 An alist of the form (HEADER NAME CONTENT).
673 HEADER is a regular expression which should match the name of a
674 header and NAME and CONTENT are either face names or nil.
676 The name of each header field will be displayed using the face
677 specified by the first element in the list where HEADER matches
678 the header name and NAME is non-nil. Similarly, the content will
679 be displayed by the first non-nil matching CONTENT face."
680 :group 'gnus-article-headers
681 :group 'gnus-article-highlight
682 :type '(repeat (list (regexp :tag "Header")
684 (item :tag "skip" nil)
685 (face :value default))
686 (choice :tag "Content"
687 (item :tag "skip" nil)
688 (face :value default)))))
690 (defcustom gnus-article-decode-hook
691 '(article-decode-charset article-decode-encoded-words
692 article-decode-group-name article-decode-idna-rhs)
693 "*Hook run to decode charsets in articles."
694 :group 'gnus-article-headers
697 (defcustom gnus-display-mime-function 'gnus-display-mime
698 "Function to display MIME articles."
699 :group 'gnus-article-mime
702 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
703 "Function used to decode headers.")
705 (defvar gnus-article-dumbquotes-map
725 "Table for MS-to-Latin1 translation.")
727 (defcustom gnus-ignored-mime-types nil
728 "List of MIME types that should be ignored by Gnus."
730 :group 'gnus-article-mime
731 :type '(repeat regexp))
733 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
734 "List of MIME types that should not be given buttons when rendered inline.
735 See also `gnus-buttonized-mime-types' which may override this variable.
736 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
738 :group 'gnus-article-mime
739 :type '(repeat regexp))
741 (defcustom gnus-buttonized-mime-types nil
742 "List of MIME types that should be given buttons when rendered inline.
743 If set, this variable overrides `gnus-unbuttonized-mime-types'.
744 To see e.g. security buttons you could set this to
745 `(\"multipart/signed\")'.
746 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
748 :group 'gnus-article-mime
749 :type '(repeat regexp))
751 (defcustom gnus-inhibit-mime-unbuttonizing nil
752 "If non-nil, all MIME parts get buttons.
753 When nil (the default value), then some MIME parts do not get buttons,
754 as described by the variables `gnus-buttonized-mime-types' and
755 `gnus-unbuttonized-mime-types'."
759 (defcustom gnus-body-boundary-delimiter "_"
760 "String used to delimit header and body.
761 This variable is used by `gnus-article-treat-body-boundary' which can
762 be controlled by `gnus-treat-body-boundary'."
763 :group 'gnus-article-various
764 :type '(choice (item :tag "None" :value nil)
767 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
768 "Defines the location of the faces database.
769 For information on obtaining this database of pretty pictures, please
770 see http://www.cs.indiana.edu/picons/ftp/index.html"
771 :type '(repeat directory)
772 :link '(url-link :tag "download"
773 "http://www.cs.indiana.edu/picons/ftp/index.html")
774 :link '(custom-manual "(gnus)Picons")
777 (defun gnus-picons-installed-p ()
778 "Say whether picons are installed on your machine."
779 (let ((installed nil))
780 (dolist (database gnus-picon-databases)
781 (when (file-exists-p database)
785 (defcustom gnus-article-mime-part-function nil
786 "Function called with a MIME handle as the argument.
787 This is meant for people who want to do something automatic based
788 on parts -- for instance, adding Vcard info to a database."
789 :group 'gnus-article-mime
792 (defcustom gnus-mime-multipart-functions nil
793 "An alist of MIME types to functions to display them."
795 :group 'gnus-article-mime
798 (defcustom gnus-article-date-lapsed-new-header nil
799 "Whether the X-Sent and Date headers can coexist.
800 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
801 either replace the old \"Date:\" header (if this variable is nil), or
802 be added below it (otherwise)."
804 :group 'gnus-article-headers
807 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
808 "Function called with a MIME handle as the argument.
809 This is meant for people who want to view first matched part.
810 For `undisplayed-alternative' (default), the first undisplayed
811 part or alternative part is used. For `undisplayed', the first
812 undisplayed part is used. For a function, the first part which
813 the function return t is used. For nil, the first part is
816 :group 'gnus-article-mime
818 (item :tag "first" :value nil)
819 (item :tag "undisplayed" :value undisplayed)
820 (item :tag "undisplayed or alternative"
821 :value undisplayed-alternative)
824 (defcustom gnus-mime-action-alist
825 '(("save to file" . gnus-mime-save-part)
826 ("save and strip" . gnus-mime-save-part-and-strip)
827 ("delete part" . gnus-mime-delete-part)
828 ("display as text" . gnus-mime-inline-part)
829 ("view the part" . gnus-mime-view-part)
830 ("pipe to command" . gnus-mime-pipe-part)
831 ("toggle display" . gnus-article-press-button)
832 ("toggle display" . gnus-article-view-part-as-charset)
833 ("view as type" . gnus-mime-view-part-as-type)
834 ("view internally" . gnus-mime-view-part-internally)
835 ("view externally" . gnus-mime-view-part-externally))
836 "An alist of actions that run on the MIME attachment."
837 :group 'gnus-article-mime
838 :type '(repeat (cons (string :tag "name")
842 ;;; The treatment variables
845 (defvar gnus-part-display-hook nil
846 "Hook called on parts that are to receive treatment.")
848 (defvar gnus-article-treat-custom
849 '(choice (const :tag "Off" nil)
851 (const :tag "Header" head)
852 (const :tag "Last" last)
853 (integer :tag "Less")
854 (repeat :tag "Groups" regexp)
855 (sexp :tag "Predicate")))
857 (defvar gnus-article-treat-head-custom
858 '(choice (const :tag "Off" nil)
859 (const :tag "Header" head)))
861 (defvar gnus-article-treat-types '("text/plain")
864 (defvar gnus-inhibit-treatment nil
865 "Whether to inhibit treatment.")
867 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
868 "Highlight the signature.
869 Valid values are nil, t, `head', `last', an integer or a predicate.
870 See Info node `(gnus)Customizing Articles'."
871 :group 'gnus-article-treat
872 :link '(custom-manual "(gnus)Customizing Articles")
873 :type gnus-article-treat-custom)
874 (put 'gnus-treat-highlight-signature 'highlight t)
876 (defcustom gnus-treat-buttonize 100000
878 Valid values are nil, t, `head', `last', an integer or a predicate.
879 See Info node `(gnus)Customizing Articles'."
880 :group 'gnus-article-treat
881 :link '(custom-manual "(gnus)Customizing Articles")
882 :type gnus-article-treat-custom)
883 (put 'gnus-treat-buttonize 'highlight t)
885 (defcustom gnus-treat-buttonize-head 'head
886 "Add buttons to the head.
887 Valid values are nil, t, `head', `last', an integer or a predicate.
888 See Info node `(gnus)Customizing Articles' for details."
889 :group 'gnus-article-treat
890 :link '(custom-manual "(gnus)Customizing Articles")
891 :type gnus-article-treat-head-custom)
892 (put 'gnus-treat-buttonize-head 'highlight t)
894 (defcustom gnus-treat-emphasize
895 (and (or window-system
897 (>= (string-to-number emacs-version) 21))
900 Valid values are nil, t, `head', `last', an integer or a predicate.
901 See Info node `(gnus)Customizing Articles' for details."
902 :group 'gnus-article-treat
903 :link '(custom-manual "(gnus)Customizing Articles")
904 :type gnus-article-treat-custom)
905 (put 'gnus-treat-emphasize 'highlight t)
907 (defcustom gnus-treat-strip-cr nil
908 "Remove carriage returns.
909 Valid values are nil, t, `head', `last', an integer or a predicate.
910 See Info node `(gnus)Customizing Articles' for details."
911 :group 'gnus-article-treat
912 :link '(custom-manual "(gnus)Customizing Articles")
913 :type gnus-article-treat-custom)
915 (defcustom gnus-treat-unsplit-urls nil
916 "Remove newlines from within URLs.
917 Valid values are nil, t, `head', `last', an integer or a predicate.
918 See Info node `(gnus)Customizing Articles' for details."
919 :group 'gnus-article-treat
920 :link '(custom-manual "(gnus)Customizing Articles")
921 :type gnus-article-treat-custom)
923 (defcustom gnus-treat-leading-whitespace nil
924 "Remove leading whitespace in headers.
925 Valid values are nil, t, `head', `last', an integer or a predicate.
926 See Info node `(gnus)Customizing Articles' for details."
927 :group 'gnus-article-treat
928 :link '(custom-manual "(gnus)Customizing Articles")
929 :type gnus-article-treat-custom)
931 (defcustom gnus-treat-hide-headers 'head
933 Valid values are nil, t, `head', `last', an integer or a predicate.
934 See Info node `(gnus)Customizing Articles' for details."
935 :group 'gnus-article-treat
936 :link '(custom-manual "(gnus)Customizing Articles")
937 :type gnus-article-treat-head-custom)
939 (defcustom gnus-treat-hide-boring-headers nil
940 "Hide boring headers.
941 Valid values are nil, t, `head', `last', an integer or a predicate.
942 See Info node `(gnus)Customizing Articles' for details."
943 :group 'gnus-article-treat
944 :link '(custom-manual "(gnus)Customizing Articles")
945 :type gnus-article-treat-head-custom)
947 (defcustom gnus-treat-hide-signature nil
949 Valid values are nil, t, `head', `last', an integer or a predicate.
950 See Info node `(gnus)Customizing Articles' for details."
951 :group 'gnus-article-treat
952 :link '(custom-manual "(gnus)Customizing Articles")
953 :type gnus-article-treat-custom)
955 (defcustom gnus-treat-fill-article nil
957 Valid values are nil, t, `head', `last', an integer or a predicate.
958 See Info node `(gnus)Customizing Articles' for details."
959 :group 'gnus-article-treat
960 :link '(custom-manual "(gnus)Customizing Articles")
961 :type gnus-article-treat-custom)
963 (defcustom gnus-treat-hide-citation nil
965 Valid values are nil, t, `head', `last', an integer or a predicate.
966 See Info node `(gnus)Customizing Articles' for details."
967 :group 'gnus-article-treat
968 :link '(custom-manual "(gnus)Customizing Articles")
969 :type gnus-article-treat-custom)
971 (defcustom gnus-treat-hide-citation-maybe nil
973 Valid values are nil, t, `head', `last', an integer or a predicate.
974 See Info node `(gnus)Customizing Articles' for details."
975 :group 'gnus-article-treat
976 :link '(custom-manual "(gnus)Customizing Articles")
977 :type gnus-article-treat-custom)
979 (defcustom gnus-treat-strip-list-identifiers 'head
980 "Strip list identifiers from `gnus-list-identifiers`.
981 Valid values are nil, t, `head', `last', an integer or a predicate.
982 See Info node `(gnus)Customizing Articles' for details."
984 :group 'gnus-article-treat
985 :link '(custom-manual "(gnus)Customizing Articles")
986 :type gnus-article-treat-custom)
988 (make-obsolete-variable 'gnus-treat-strip-pgp
989 "This option is obsolete in Gnus 5.10.")
991 (defcustom gnus-treat-strip-pem nil
992 "Strip PEM signatures.
993 Valid values are nil, t, `head', `last', an integer or a predicate.
994 See Info node `(gnus)Customizing Articles' for details."
995 :group 'gnus-article-treat
996 :link '(custom-manual "(gnus)Customizing Articles")
997 :type gnus-article-treat-custom)
999 (defcustom gnus-treat-strip-banner t
1000 "Strip banners from articles.
1001 The banner to be stripped is specified in the `banner' group parameter.
1002 Valid values are nil, t, `head', `last', an integer or a predicate.
1003 See Info node `(gnus)Customizing Articles' for details."
1004 :group 'gnus-article-treat
1005 :link '(custom-manual "(gnus)Customizing Articles")
1006 :type gnus-article-treat-custom)
1008 (defcustom gnus-treat-highlight-headers 'head
1009 "Highlight the headers.
1010 Valid values are nil, t, `head', `last', an integer or a predicate.
1011 See Info node `(gnus)Customizing Articles' for details."
1012 :group 'gnus-article-treat
1013 :link '(custom-manual "(gnus)Customizing Articles")
1014 :type gnus-article-treat-head-custom)
1015 (put 'gnus-treat-highlight-headers 'highlight t)
1017 (defcustom gnus-treat-highlight-citation t
1018 "Highlight cited text.
1019 Valid values are nil, t, `head', `last', an integer or a predicate.
1020 See Info node `(gnus)Customizing Articles' for details."
1021 :group 'gnus-article-treat
1022 :link '(custom-manual "(gnus)Customizing Articles")
1023 :type gnus-article-treat-custom)
1024 (put 'gnus-treat-highlight-citation 'highlight t)
1026 (defcustom gnus-treat-date-ut nil
1027 "Display the Date in UT (GMT).
1028 Valid values are nil, t, `head', `last', an integer or a predicate.
1029 See Info node `(gnus)Customizing Articles' for details."
1030 :group 'gnus-article-treat
1031 :link '(custom-manual "(gnus)Customizing Articles")
1032 :type gnus-article-treat-head-custom)
1034 (defcustom gnus-treat-date-local nil
1035 "Display the Date in the local timezone.
1036 Valid values are nil, t, `head', `last', an integer or a predicate.
1037 See Info node `(gnus)Customizing Articles' for details."
1038 :group 'gnus-article-treat
1039 :link '(custom-manual "(gnus)Customizing Articles")
1040 :type gnus-article-treat-head-custom)
1042 (defcustom gnus-treat-date-english nil
1043 "Display the Date in a format that can be read aloud in English.
1044 Valid values are nil, t, `head', `last', an integer or a predicate.
1045 See Info node `(gnus)Customizing Articles' for details."
1046 :group 'gnus-article-treat
1047 :link '(custom-manual "(gnus)Customizing Articles")
1048 :type gnus-article-treat-head-custom)
1050 (defcustom gnus-treat-date-lapsed nil
1051 "Display the Date header in a way that says how much time has elapsed.
1052 Valid values are nil, t, `head', `last', an integer or a predicate.
1053 See Info node `(gnus)Customizing Articles' for details."
1054 :group 'gnus-article-treat
1055 :link '(custom-manual "(gnus)Customizing Articles")
1056 :type gnus-article-treat-head-custom)
1058 (defcustom gnus-treat-date-original nil
1059 "Display the date in the original timezone.
1060 Valid values are nil, t, `head', `last', an integer or a predicate.
1061 See Info node `(gnus)Customizing Articles' for details."
1062 :group 'gnus-article-treat
1063 :link '(custom-manual "(gnus)Customizing Articles")
1064 :type gnus-article-treat-head-custom)
1066 (defcustom gnus-treat-date-iso8601 nil
1067 "Display the date in the ISO8601 format.
1068 Valid values are nil, t, `head', `last', an integer or a predicate.
1069 See Info node `(gnus)Customizing Articles' for details."
1071 :group 'gnus-article-treat
1072 :link '(custom-manual "(gnus)Customizing Articles")
1073 :type gnus-article-treat-head-custom)
1075 (defcustom gnus-treat-date-user-defined nil
1076 "Display the date in a user-defined format.
1077 The format is defined by the `gnus-article-time-format' variable.
1078 Valid values are nil, t, `head', `last', an integer or a predicate.
1079 See Info node `(gnus)Customizing Articles' for details."
1080 :group 'gnus-article-treat
1081 :link '(custom-manual "(gnus)Customizing Articles")
1082 :type gnus-article-treat-head-custom)
1084 (defcustom gnus-treat-strip-headers-in-body t
1085 "Strip the X-No-Archive header line from the beginning of the body.
1086 Valid values are nil, t, `head', `last', an integer or a predicate.
1087 See Info node `(gnus)Customizing Articles' for details."
1089 :group 'gnus-article-treat
1090 :link '(custom-manual "(gnus)Customizing Articles")
1091 :type gnus-article-treat-custom)
1093 (defcustom gnus-treat-strip-trailing-blank-lines nil
1094 "Strip trailing blank lines.
1095 Valid values are nil, t, `head', `last', an integer or a predicate.
1096 See Info node `(gnus)Customizing Articles' for details."
1097 :group 'gnus-article-treat
1098 :link '(custom-manual "(gnus)Customizing Articles")
1099 :type gnus-article-treat-custom)
1101 (defcustom gnus-treat-strip-leading-blank-lines nil
1102 "Strip leading blank lines.
1103 Valid values are nil, t, `head', `last', an integer or a predicate.
1104 See Info node `(gnus)Customizing Articles' for details."
1105 :group 'gnus-article-treat
1106 :link '(custom-manual "(gnus)Customizing Articles")
1107 :type gnus-article-treat-custom)
1109 (defcustom gnus-treat-strip-multiple-blank-lines nil
1110 "Strip multiple blank lines.
1111 Valid values are nil, t, `head', `last', an integer or a predicate.
1112 See Info node `(gnus)Customizing Articles' for details."
1113 :group 'gnus-article-treat
1114 :link '(custom-manual "(gnus)Customizing Articles")
1115 :type gnus-article-treat-custom)
1117 (defcustom gnus-treat-unfold-headers 'head
1118 "Unfold folded header lines.
1119 Valid values are nil, t, `head', `last', an integer or a predicate.
1120 See Info node `(gnus)Customizing Articles' for details."
1121 :group 'gnus-article-treat
1122 :link '(custom-manual "(gnus)Customizing Articles")
1123 :type gnus-article-treat-custom)
1125 (defcustom gnus-treat-fold-headers nil
1127 Valid values are nil, t, `head', `last', an integer or a predicate.
1128 See Info node `(gnus)Customizing Articles' for details."
1129 :group 'gnus-article-treat
1130 :link '(custom-manual "(gnus)Customizing Articles")
1131 :type gnus-article-treat-custom)
1133 (defcustom gnus-treat-fold-newsgroups 'head
1134 "Fold the Newsgroups and Followup-To headers.
1135 Valid values are nil, t, `head', `last', an integer or a predicate.
1136 See Info node `(gnus)Customizing Articles' for details."
1137 :group 'gnus-article-treat
1138 :link '(custom-manual "(gnus)Customizing Articles")
1139 :type gnus-article-treat-custom)
1141 (defcustom gnus-treat-overstrike t
1142 "Treat overstrike highlighting.
1143 Valid values are nil, t, `head', `last', an integer or a predicate.
1144 See Info node `(gnus)Customizing Articles' for details."
1145 :group 'gnus-article-treat
1146 :link '(custom-manual "(gnus)Customizing Articles")
1147 :type gnus-article-treat-custom)
1148 (put 'gnus-treat-overstrike 'highlight t)
1150 (make-obsolete-variable 'gnus-treat-display-xface
1151 'gnus-treat-display-x-face)
1153 (defcustom gnus-treat-display-x-face
1154 (and (not noninteractive)
1155 (or (and (fboundp 'image-type-available-p)
1156 (image-type-available-p 'xbm)
1157 (string-match "^0x" (shell-command-to-string "uncompface"))
1158 (executable-find "icontopbm"))
1159 (and (featurep 'xemacs)
1162 "Display X-Face headers.
1163 Valid values are nil, t, `head', `last', an integer or a predicate.
1164 See Info node `(gnus)Customizing Articles' and Info node
1165 `(gnus)X-Face' for details."
1166 :group 'gnus-article-treat
1168 :link '(custom-manual "(gnus)Customizing Articles")
1169 :link '(custom-manual "(gnus)X-Face")
1170 :type gnus-article-treat-head-custom
1171 :set (lambda (symbol value)
1174 (cond ((or (boundp symbol) (get symbol 'saved-value))
1176 ((boundp 'gnus-treat-display-xface)
1178 ** gnus-treat-display-xface is an obsolete variable;\
1179 use gnus-treat-display-x-face instead")
1180 (default-value 'gnus-treat-display-xface))
1181 ((get 'gnus-treat-display-xface 'saved-value)
1183 ** gnus-treat-display-xface is an obsolete variable;\
1184 use gnus-treat-display-x-face instead")
1185 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1188 (put 'gnus-treat-display-x-face 'highlight t)
1190 (defcustom gnus-treat-display-face
1191 (and (not noninteractive)
1192 (or (and (fboundp 'image-type-available-p)
1193 (image-type-available-p 'png))
1194 (and (featurep 'xemacs)
1197 "Display Face headers.
1198 Valid values are nil, t, `head', `last', an integer or a predicate.
1199 See Info node `(gnus)Customizing Articles' and Info node
1200 `(gnus)X-Face' for details."
1201 :group 'gnus-article-treat
1203 :link '(custom-manual "(gnus)Customizing Articles")
1204 :link '(custom-manual "(gnus)X-Face")
1205 :type gnus-article-treat-head-custom)
1206 (put 'gnus-treat-display-face 'highlight t)
1208 (defcustom gnus-treat-display-smileys
1209 (if (or (and (featurep 'xemacs)
1211 (and (fboundp 'image-type-available-p)
1212 (image-type-available-p 'pbm)))
1215 Valid values are nil, t, `head', `last', an integer or a predicate.
1216 See Info node `(gnus)Customizing Articles' and Info node
1217 `(gnus)Smileys' for details."
1218 :group 'gnus-article-treat
1220 :link '(custom-manual "(gnus)Customizing Articles")
1221 :link '(custom-manual "(gnus)Smileys")
1222 :type gnus-article-treat-custom)
1223 (put 'gnus-treat-display-smileys 'highlight t)
1225 (defcustom gnus-treat-from-picon
1226 (if (and (gnus-image-type-available-p 'xpm)
1227 (gnus-picons-installed-p))
1229 "Display picons in the From header.
1230 Valid values are nil, t, `head', `last', an integer or a predicate.
1231 See Info node `(gnus)Customizing Articles' and Info node
1232 `(gnus)Picons' for details."
1233 :group 'gnus-article-treat
1235 :link '(custom-manual "(gnus)Customizing Articles")
1236 :link '(custom-manual "(gnus)Picons")
1237 :type gnus-article-treat-head-custom)
1238 (put 'gnus-treat-from-picon 'highlight t)
1240 (defcustom gnus-treat-mail-picon
1241 (if (and (gnus-image-type-available-p 'xpm)
1242 (gnus-picons-installed-p))
1244 "Display picons in To and Cc headers.
1245 Valid values are nil, t, `head', `last', an integer or a predicate.
1246 See Info node `(gnus)Customizing Articles' and Info node
1247 `(gnus)Picons' for details."
1248 :group 'gnus-article-treat
1250 :link '(custom-manual "(gnus)Customizing Articles")
1251 :link '(custom-manual "(gnus)Picons")
1252 :type gnus-article-treat-head-custom)
1253 (put 'gnus-treat-mail-picon 'highlight t)
1255 (defcustom gnus-treat-newsgroups-picon
1256 (if (and (gnus-image-type-available-p 'xpm)
1257 (gnus-picons-installed-p))
1259 "Display picons in the Newsgroups and Followup-To headers.
1260 Valid values are nil, t, `head', `last', an integer or a predicate.
1261 See Info node `(gnus)Customizing Articles' and Info node
1262 `(gnus)Picons' for details."
1263 :group 'gnus-article-treat
1265 :link '(custom-manual "(gnus)Customizing Articles")
1266 :link '(custom-manual "(gnus)Picons")
1267 :type gnus-article-treat-head-custom)
1268 (put 'gnus-treat-newsgroups-picon 'highlight t)
1270 (defcustom gnus-treat-body-boundary
1271 (if (or gnus-treat-newsgroups-picon
1272 gnus-treat-mail-picon
1273 gnus-treat-from-picon)
1275 "Draw a boundary at the end of the headers.
1276 Valid values are nil, t, `head', `last', an integer or a predicate.
1277 See Info node `(gnus)Customizing Articles' for details."
1279 :group 'gnus-article-treat
1280 :link '(custom-manual "(gnus)Customizing Articles")
1281 :type gnus-article-treat-custom)
1283 (defcustom gnus-treat-capitalize-sentences nil
1284 "Capitalize sentence-starting words.
1285 Valid values are nil, t, `head', `last', an integer or a predicate.
1286 See Info node `(gnus)Customizing Articles' for details."
1288 :group 'gnus-article-treat
1289 :link '(custom-manual "(gnus)Customizing Articles")
1290 :type gnus-article-treat-custom)
1292 (defcustom gnus-treat-wash-html nil
1294 Valid values are nil, t, `head', `last', an integer or a predicate.
1295 See Info node `(gnus)Customizing Articles' for details."
1296 :group 'gnus-article-treat
1297 :link '(custom-manual "(gnus)Customizing Articles")
1298 :type gnus-article-treat-custom)
1300 (defcustom gnus-treat-fill-long-lines nil
1302 Valid values are nil, t, `head', `last', an integer or a predicate.
1303 See Info node `(gnus)Customizing Articles' for details."
1304 :group 'gnus-article-treat
1305 :link '(custom-manual "(gnus)Customizing Articles")
1306 :type gnus-article-treat-custom)
1308 (defcustom gnus-treat-play-sounds nil
1310 Valid values are nil, t, `head', `last', an integer or a predicate.
1311 See Info node `(gnus)Customizing Articles' for details."
1313 :group 'gnus-article-treat
1314 :link '(custom-manual "(gnus)Customizing Articles")
1315 :type gnus-article-treat-custom)
1317 (defcustom gnus-treat-translate nil
1318 "Translate articles from one language to another.
1319 Valid values are nil, t, `head', `last', an integer or a predicate.
1320 See Info node `(gnus)Customizing Articles' for details."
1322 :group 'gnus-article-treat
1323 :link '(custom-manual "(gnus)Customizing Articles")
1324 :type gnus-article-treat-custom)
1326 (defcustom gnus-treat-x-pgp-sig nil
1328 To automatically treat X-PGP-Sig, set it to head.
1329 Valid values are nil, t, `head', `last', an integer or a predicate.
1330 See Info node `(gnus)Customizing Articles' for details."
1331 :group 'gnus-article-treat
1332 :group 'mime-security
1333 :link '(custom-manual "(gnus)Customizing Articles")
1334 :type gnus-article-treat-custom)
1336 (defvar gnus-article-encrypt-protocol-alist
1337 '(("PGP" . mml2015-self-encrypt)))
1339 ;; Set to nil if more than one protocol added to
1340 ;; gnus-article-encrypt-protocol-alist.
1341 (defcustom gnus-article-encrypt-protocol "PGP"
1342 "The protocol used for encrypt articles.
1343 It is a string, such as \"PGP\". If nil, ask user."
1345 :group 'mime-security)
1347 (defvar gnus-article-wash-function nil
1348 "Function used for converting HTML into text.")
1350 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1351 (mm-coding-system-p 'utf-8)
1352 (executable-find idna-program))
1353 "Whether IDNA decoding of headers is used when viewing messages.
1354 This requires GNU Libidn, and by default only enabled if it is found."
1355 :group 'gnus-article-headers
1358 (defcustom gnus-article-over-scroll nil
1359 "If non-nil, allow scrolling the article buffer even when there no more text."
1360 :group 'gnus-article
1363 ;;; Internal variables
1365 (defvar gnus-english-month-names
1366 '("January" "February" "March" "April" "May" "June" "July" "August"
1367 "September" "October" "November" "December"))
1369 (defvar article-goto-body-goes-to-point-min-p nil)
1370 (defvar gnus-article-wash-types nil)
1371 (defvar gnus-article-emphasis-alist nil)
1372 (defvar gnus-article-image-alist nil)
1374 (defvar gnus-article-mime-handle-alist-1 nil)
1375 (defvar gnus-treatment-function-alist
1376 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1377 (gnus-treat-strip-banner gnus-article-strip-banner)
1378 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1379 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1380 (gnus-treat-buttonize gnus-article-add-buttons)
1381 (gnus-treat-fill-article gnus-article-fill-cited-article)
1382 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1383 (gnus-treat-strip-cr gnus-article-remove-cr)
1384 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1385 (gnus-treat-date-ut gnus-article-date-ut)
1386 (gnus-treat-date-local gnus-article-date-local)
1387 (gnus-treat-date-english gnus-article-date-english)
1388 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1389 (gnus-treat-date-original gnus-article-date-original)
1390 (gnus-treat-date-user-defined gnus-article-date-user)
1391 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1392 (gnus-treat-display-x-face gnus-article-display-x-face)
1393 (gnus-treat-display-face gnus-article-display-face)
1394 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1395 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1396 (gnus-treat-hide-signature gnus-article-hide-signature)
1397 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1398 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1399 (gnus-treat-strip-pem gnus-article-hide-pem)
1400 (gnus-treat-from-picon gnus-treat-from-picon)
1401 (gnus-treat-mail-picon gnus-treat-mail-picon)
1402 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1403 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1404 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1405 (gnus-treat-strip-trailing-blank-lines
1406 gnus-article-remove-trailing-blank-lines)
1407 (gnus-treat-strip-leading-blank-lines
1408 gnus-article-strip-leading-blank-lines)
1409 (gnus-treat-strip-multiple-blank-lines
1410 gnus-article-strip-multiple-blank-lines)
1411 (gnus-treat-overstrike gnus-article-treat-overstrike)
1412 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1413 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1414 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1415 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1416 (gnus-treat-display-smileys gnus-treat-smiley)
1417 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1418 (gnus-treat-wash-html gnus-article-wash-html)
1419 (gnus-treat-emphasize gnus-article-emphasize)
1420 (gnus-treat-hide-citation gnus-article-hide-citation)
1421 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1422 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1423 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1424 (gnus-treat-play-sounds gnus-earcon-display)))
1426 (defvar gnus-article-mime-handle-alist nil)
1427 (defvar article-lapsed-timer nil)
1428 (defvar gnus-article-current-summary nil)
1430 (defvar gnus-article-mode-syntax-table
1431 (let ((table (copy-syntax-table text-mode-syntax-table)))
1432 ;; This causes the citation match run O(2^n).
1433 ;; (modify-syntax-entry ?- "w" table)
1434 (modify-syntax-entry ?> ")<" table)
1435 (modify-syntax-entry ?< "(>" table)
1436 ;; make M-. in article buffers work for `foo' strings
1437 (modify-syntax-entry ?' " " table)
1438 (modify-syntax-entry ?` " " table)
1440 "Syntax table used in article mode buffers.
1441 Initialized from `text-mode-syntax-table.")
1443 (defvar gnus-save-article-buffer nil)
1445 (defvar gnus-article-mode-line-format-alist
1446 (nconc '((?w (gnus-article-wash-status) ?s)
1447 (?m (gnus-article-mime-part-status) ?s))
1448 gnus-summary-mode-line-format-alist))
1450 (defvar gnus-number-of-articles-to-be-saved nil)
1452 (defvar gnus-inhibit-hiding nil)
1454 ;;; Macros for dealing with the article buffer.
1456 (defmacro gnus-with-article-headers (&rest forms)
1458 (set-buffer gnus-article-buffer)
1460 (let ((buffer-read-only nil)
1461 (inhibit-point-motion-hooks t)
1462 (case-fold-search t))
1463 (article-narrow-to-head)
1466 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1467 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1469 (defmacro gnus-with-article-buffer (&rest forms)
1471 (set-buffer gnus-article-buffer)
1472 (let ((buffer-read-only nil))
1475 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1476 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1478 (defun gnus-article-goto-header (header)
1479 "Go to HEADER, which is a regular expression."
1480 (re-search-forward (concat "^\\(" header "\\):") nil t))
1482 (defsubst gnus-article-hide-text (b e props)
1483 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1484 (gnus-add-text-properties-when 'article-type nil b e props)
1485 (when (memq 'intangible props)
1487 (max (1- b) (point-min))
1488 b 'intangible (cddr (memq 'intangible props)))))
1490 (defsubst gnus-article-unhide-text (b e)
1491 "Remove hidden text properties from region between B and E."
1492 (remove-text-properties b e gnus-hidden-properties)
1493 (when (memq 'intangible gnus-hidden-properties)
1494 (put-text-property (max (1- b) (point-min))
1495 b 'intangible nil)))
1497 (defun gnus-article-hide-text-type (b e type)
1498 "Hide text of TYPE between B and E."
1499 (gnus-add-wash-type type)
1500 (gnus-article-hide-text
1501 b e (cons 'article-type (cons type gnus-hidden-properties))))
1503 (defun gnus-article-unhide-text-type (b e type)
1504 "Unhide text of TYPE between B and E."
1505 (gnus-delete-wash-type type)
1506 (remove-text-properties
1507 b e (cons 'article-type (cons type gnus-hidden-properties)))
1508 (when (memq 'intangible gnus-hidden-properties)
1509 (put-text-property (max (1- b) (point-min))
1510 b 'intangible nil)))
1512 (defun gnus-article-hide-text-of-type (type)
1513 "Hide text of TYPE in the current buffer."
1515 (let ((b (point-min))
1517 (while (setq b (text-property-any b e 'article-type type))
1518 (add-text-properties b (incf b) gnus-hidden-properties)))))
1520 (defun gnus-article-delete-text-of-type (type)
1521 "Delete text of TYPE in the current buffer."
1523 (let ((b (point-min)))
1524 (while (setq b (text-property-any b (point-max) 'article-type type))
1526 b (or (text-property-not-all b (point-max) 'article-type type)
1529 (defun gnus-article-delete-invisible-text ()
1530 "Delete all invisible text in the current buffer."
1532 (let ((b (point-min)))
1533 (while (setq b (text-property-any b (point-max) 'invisible t))
1535 b (or (text-property-not-all b (point-max) 'invisible t)
1538 (defun gnus-article-text-type-exists-p (type)
1539 "Say whether any text of type TYPE exists in the buffer."
1540 (text-property-any (point-min) (point-max) 'article-type type))
1542 (defsubst gnus-article-header-rank ()
1543 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1544 (let ((list gnus-sorted-header-list)
1547 (if (looking-at (car list))
1549 (setq list (cdr list))
1553 (defun article-hide-headers (&optional arg delete)
1554 "Hide unwanted headers and possibly sort them as well."
1556 ;; This function might be inhibited.
1557 (unless gnus-inhibit-hiding
1560 (let ((buffer-read-only nil)
1561 (case-fold-search t)
1562 (max (1+ (length gnus-sorted-header-list)))
1563 (ignored (when (not gnus-visible-headers)
1564 (cond ((stringp gnus-ignored-headers)
1565 gnus-ignored-headers)
1566 ((listp gnus-ignored-headers)
1567 (mapconcat 'identity gnus-ignored-headers
1570 (cond ((stringp gnus-visible-headers)
1571 gnus-visible-headers)
1572 ((and gnus-visible-headers
1573 (listp gnus-visible-headers))
1574 (mapconcat 'identity gnus-visible-headers "\\|"))))
1575 (inhibit-point-motion-hooks t)
1577 ;; First we narrow to just the headers.
1578 (article-narrow-to-head)
1579 ;; Hide any "From " lines at the beginning of (mail) articles.
1580 (while (looking-at "From ")
1583 (delete-region (point-min) (point)))
1584 ;; Then treat the rest of the header lines.
1585 ;; Then we use the two regular expressions
1586 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1587 ;; select which header lines is to remain visible in the
1589 (while (re-search-forward "^[^ \t:]*:" nil t)
1591 ;; Mark the rank of the header.
1593 (point) (1+ (point)) 'message-rank
1594 (if (or (and visible (looking-at visible))
1596 (not (looking-at ignored))))
1597 (gnus-article-header-rank)
1600 (message-sort-headers-1)
1601 (when (setq beg (text-property-any
1602 (point-min) (point-max) 'message-rank (+ 2 max)))
1603 ;; We delete the unwanted headers.
1604 (gnus-add-wash-type 'headers)
1605 (add-text-properties (point-min) (+ 5 (point-min))
1606 '(article-type headers dummy-invisible t))
1607 (delete-region beg (point-max))))))))
1609 (defun article-hide-boring-headers (&optional arg)
1610 "Toggle hiding of headers that aren't very interesting.
1611 If given a negative prefix, always show; if given a positive prefix,
1613 (interactive (gnus-article-hidden-arg))
1614 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1615 (not gnus-show-all-headers))
1618 (let ((buffer-read-only nil)
1619 (list gnus-boring-article-headers)
1620 (inhibit-point-motion-hooks t)
1622 (article-narrow-to-head)
1624 (setq elem (pop list))
1625 (goto-char (point-min))
1627 ;; Hide empty headers.
1629 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1631 (gnus-article-hide-text-type
1635 (if (re-search-forward "^[^ \t]" nil t)
1639 ;; Hide boring Newsgroups header.
1640 ((eq elem 'newsgroups)
1641 (when (gnus-string-equal
1642 (gnus-fetch-field "newsgroups")
1643 (gnus-group-real-name
1644 (if (boundp 'gnus-newsgroup-name)
1647 (gnus-article-hide-header "newsgroups")))
1648 ((eq elem 'to-address)
1649 (let ((to (message-fetch-field "to"))
1651 (gnus-parameter-to-address
1652 (if (boundp 'gnus-newsgroup-name)
1653 gnus-newsgroup-name ""))))
1654 (when (and to to-address
1657 ;; only one address in To
1658 (nth 1 (mail-extract-address-components to))
1660 (gnus-article-hide-header "to"))))
1662 (let ((to (message-fetch-field "to"))
1664 (gnus-parameter-to-list
1665 (if (boundp 'gnus-newsgroup-name)
1666 gnus-newsgroup-name ""))))
1667 (when (and to to-list
1670 ;; only one address in To
1671 (nth 1 (mail-extract-address-components to))
1673 (gnus-article-hide-header "to"))))
1675 (let ((cc (message-fetch-field "cc"))
1677 (gnus-parameter-to-list
1678 (if (boundp 'gnus-newsgroup-name)
1679 gnus-newsgroup-name ""))))
1680 (when (and cc to-list
1683 ;; only one address in CC
1684 (nth 1 (mail-extract-address-components cc))
1686 (gnus-article-hide-header "cc"))))
1687 ((eq elem 'followup-to)
1688 (when (gnus-string-equal
1689 (message-fetch-field "followup-to")
1690 (message-fetch-field "newsgroups"))
1691 (gnus-article-hide-header "followup-to")))
1692 ((eq elem 'reply-to)
1693 (if (gnus-group-find-parameter
1694 gnus-newsgroup-name 'broken-reply-to)
1695 (gnus-article-hide-header "reply-to")
1696 (let ((from (message-fetch-field "from"))
1697 (reply-to (message-fetch-field "reply-to")))
1702 (nth 1 (mail-extract-address-components from))
1703 (nth 1 (mail-extract-address-components reply-to)))))
1704 (gnus-article-hide-header "reply-to")))))
1706 (let ((date (message-fetch-field "date")))
1708 (< (days-between (current-time-string) date)
1710 (gnus-article-hide-header "date"))))
1712 (let ((to (message-fetch-field "to"))
1713 (cc (message-fetch-field "cc")))
1714 (when (> (length to) 1024)
1715 (gnus-article-hide-header "to"))
1716 (when (> (length cc) 1024)
1717 (gnus-article-hide-header "cc"))))
1721 (goto-char (point-min))
1722 (while (re-search-forward "^to:" nil t)
1723 (setq to-count (1+ to-count)))
1724 (when (> to-count 1)
1725 (while (> to-count 0)
1726 (goto-char (point-min))
1728 (re-search-forward "^to:" nil nil to-count)
1730 (narrow-to-region (point) (point-max))
1731 (gnus-article-hide-header "to"))
1732 (setq to-count (1- to-count))))
1733 (goto-char (point-min))
1734 (while (re-search-forward "^cc:" nil t)
1735 (setq cc-count (1+ cc-count)))
1736 (when (> cc-count 1)
1737 (while (> cc-count 0)
1738 (goto-char (point-min))
1740 (re-search-forward "^cc:" nil nil cc-count)
1742 (narrow-to-region (point) (point-max))
1743 (gnus-article-hide-header "cc"))
1744 (setq cc-count (1- cc-count)))))))))))))
1746 (defun gnus-article-hide-header (header)
1748 (goto-char (point-min))
1749 (when (re-search-forward (concat "^" header ":") nil t)
1750 (gnus-article-hide-text-type
1754 (if (re-search-forward "^[^ \t]" nil t)
1759 (defvar gnus-article-normalized-header-length 40
1760 "Length of normalized headers.")
1762 (defun article-normalize-headers ()
1763 "Make all header lines 40 characters long."
1765 (let ((buffer-read-only nil)
1769 (article-narrow-to-head)
1772 ((< (setq column (- (gnus-point-at-eol) (point)))
1773 gnus-article-normalized-header-length)
1775 (insert (make-string
1776 (- gnus-article-normalized-header-length column)
1778 ((> column gnus-article-normalized-header-length)
1779 (gnus-put-text-property
1781 (forward-char gnus-article-normalized-header-length)
1788 (forward-line 1))))))
1790 (defun article-treat-dumbquotes ()
1791 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
1792 Note that this function guesses whether a character is a sm*rtq**t* or
1793 not, so it should only be used interactively.
1795 Sm*rtq**t*s are M****s***'s unilateral extension to the
1796 iso-8859-1 character map in an attempt to provide more quoting
1797 characters. If you see something like \\222 or \\264 where
1798 you're expecting some kind of apostrophe or quotation mark, then
1801 (article-translate-strings gnus-article-dumbquotes-map))
1803 (defun article-translate-characters (from to)
1804 "Translate all characters in the body of the article according to FROM and TO.
1805 FROM is a string of characters to translate from; to is a string of
1806 characters to translate to."
1808 (when (article-goto-body)
1809 (let ((buffer-read-only nil)
1810 (x (make-string 225 ?x))
1812 (while (< (incf i) (length x))
1815 (while (< i (length from))
1816 (aset x (aref from i) (aref to i))
1818 (translate-region (point) (point-max) x)))))
1820 (defun article-translate-strings (map)
1821 "Translate all string in the body of the article according to MAP.
1822 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1824 (when (article-goto-body)
1825 (let ((buffer-read-only nil)
1827 (while (setq elem (pop map))
1829 (while (search-forward (car elem) nil t)
1830 (replace-match (cadr elem)))))))))
1832 (defun article-treat-overstrike ()
1833 "Translate overstrikes into bold text."
1836 (when (article-goto-body)
1837 (let ((buffer-read-only nil))
1838 (while (search-forward "\b" nil t)
1839 (let ((next (char-after))
1840 (previous (char-after (- (point) 2))))
1841 ;; We do the boldification/underlining by hiding the
1842 ;; overstrikes and putting the proper text property
1846 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1847 (put-text-property (point) (1+ (point)) 'face 'bold))
1849 (gnus-article-hide-text-type
1850 (1- (point)) (1+ (point)) 'overstrike)
1852 (- (point) 2) (1- (point)) 'face 'underline))
1854 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
1856 (point) (1+ (point)) 'face 'underline)))))))))
1858 (defun gnus-article-treat-unfold-headers ()
1859 "Unfold folded message headers.
1860 Only the headers that fit into the current window width will be
1863 (gnus-with-article-headers
1867 (mail-header-narrow-to-field)
1868 (let ((header (buffer-string)))
1871 (goto-char (point-min))
1872 (while (re-search-forward "\n[\t ]" nil t)
1873 (replace-match " " t t)))
1874 (setq length (- (point-max) (point-min) 1)))
1875 (when (< length (window-width))
1876 (while (re-search-forward "\n[\t ]" nil t)
1877 (replace-match " " t t)))
1878 (goto-char (point-max)))))))
1880 (defun gnus-article-treat-fold-headers ()
1881 "Fold message headers."
1883 (gnus-with-article-headers
1886 (mail-header-narrow-to-field)
1887 (mail-header-fold-field)
1888 (goto-char (point-max))))))
1890 (defun gnus-treat-smiley ()
1891 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1893 (gnus-with-article-buffer
1894 (if (memq 'smiley gnus-article-wash-types)
1895 (gnus-delete-images 'smiley)
1897 (let ((images (smiley-region (point) (point-max))))
1899 (gnus-add-wash-type 'smiley)
1900 (dolist (image images)
1901 (gnus-add-image 'smiley image)))))))
1903 (defun gnus-article-remove-images ()
1904 "Remove all images from the article buffer."
1906 (gnus-with-article-buffer
1907 (dolist (elem gnus-article-image-alist)
1908 (gnus-delete-images (car elem)))))
1910 (defun gnus-article-treat-fold-newsgroups ()
1911 "Unfold folded message headers.
1912 Only the headers that fit into the current window width will be
1915 (gnus-with-article-headers
1916 (while (gnus-article-goto-header "newsgroups\\|followup-to")
1918 (mail-header-narrow-to-field)
1919 (while (re-search-forward ", *" nil t)
1920 (replace-match ", " t t))
1921 (mail-header-fold-field)
1922 (goto-char (point-max))))))
1924 (defun gnus-article-treat-body-boundary ()
1925 "Place a boundary line at the end of the headers."
1927 (when (and gnus-body-boundary-delimiter
1928 (> (length gnus-body-boundary-delimiter) 0))
1929 (gnus-with-article-headers
1930 (goto-char (point-max))
1931 (let ((start (point)))
1932 (insert "X-Boundary: ")
1933 (gnus-add-text-properties start (point) '(invisible t intangible t))
1935 (while (>= (1- (window-width)) (length str))
1936 (setq str (concat str gnus-body-boundary-delimiter)))
1937 (substring str 0 (1- (window-width))))
1939 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
1941 (defun article-fill-long-lines ()
1942 "Fill lines that are wider than the window width."
1945 (let ((buffer-read-only nil)
1946 (width (window-width (get-buffer-window (current-buffer)))))
1949 (let ((adaptive-fill-mode nil)) ;Why? -sm
1952 (when (>= (current-column) (min fill-column width))
1953 (narrow-to-region (min (1+ (point)) (point-max))
1954 (gnus-point-at-bol))
1955 (let ((goback (point-marker)))
1956 (fill-paragraph nil)
1957 (goto-char (marker-position goback)))
1959 (forward-line 1)))))))
1961 (defun article-capitalize-sentences ()
1962 "Capitalize the first word in each sentence."
1965 (let ((buffer-read-only nil)
1966 (paragraph-start "^[\n\^L]"))
1970 (forward-sentence)))))
1972 (defun article-remove-cr ()
1973 "Remove trailing CRs and then translate remaining CRs into LFs."
1976 (let ((buffer-read-only nil))
1977 (goto-char (point-min))
1978 (while (re-search-forward "\r+$" nil t)
1979 (replace-match "" t t))
1980 (goto-char (point-min))
1981 (while (search-forward "\r" nil t)
1982 (replace-match "\n" t t)))))
1984 (defun article-remove-trailing-blank-lines ()
1985 "Remove all trailing blank lines from the article."
1988 (let ((buffer-read-only nil))
1989 (goto-char (point-max))
1993 (while (and (not (bobp))
1994 (looking-at "^[ \t]*$")
1995 (not (gnus-annotation-in-region-p
1996 (point) (gnus-point-at-eol))))
2001 (defun article-display-face ()
2002 "Display any Face headers in the header."
2004 (let ((wash-face-p buffer-read-only))
2005 (gnus-with-article-headers
2006 ;; When displaying parts, this function can be called several times on
2007 ;; the same article, without any intended toggle semantic (as typing `W
2008 ;; D d' would have). So face deletion must occur only when we come from
2009 ;; an interactive command, that is when the *Article* buffer is
2011 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2012 (gnus-delete-images 'face)
2015 (when (and wash-face-p
2017 (goto-char (point-min))
2018 (not (re-search-forward "^Face:[\t ]*" nil t)))
2019 (gnus-buffer-live-p gnus-original-article-buffer))
2020 (set-buffer gnus-original-article-buffer))
2022 (mail-narrow-to-head)
2023 (while (gnus-article-goto-header "Face")
2024 (push (mail-header-field-value) faces))))
2025 (while (setq face (pop faces))
2026 (let ((png (gnus-convert-face-to-png face))
2029 (setq image (gnus-create-image png 'png t))
2030 (gnus-article-goto-header "from")
2032 (insert "From: [no `from' set]\n")
2034 (gnus-add-wash-type 'face)
2035 (gnus-add-image 'face image)
2036 (gnus-put-image image nil 'face))))))
2039 (defun article-display-x-face (&optional force)
2040 "Look for an X-Face header and display it if present."
2041 (interactive (list 'force))
2042 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2043 (gnus-with-article-headers
2044 ;; Delete the old process, if any.
2045 (when (process-status "article-x-face")
2046 (delete-process "article-x-face"))
2047 ;; See the comment in `article-display-face'.
2048 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2049 ;; We have already displayed X-Faces, so we remove them
2051 (gnus-delete-images 'xface)
2053 (let (x-faces from face)
2055 (when (and wash-face-p
2057 (goto-char (point-min))
2058 (not (re-search-forward
2059 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2060 (gnus-buffer-live-p gnus-original-article-buffer))
2061 ;; If type `W f', use gnus-original-article-buffer,
2062 ;; otherwise use the current buffer because displaying
2063 ;; RFC822 parts calls this function too.
2064 (set-buffer gnus-original-article-buffer))
2066 (mail-narrow-to-head)
2067 (while (gnus-article-goto-header "X-Face")
2068 (push (mail-header-field-value) x-faces))
2069 (setq from (message-fetch-field "from"))))
2070 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2071 ;; single external face.
2072 (when (stringp gnus-article-x-face-command)
2073 (setq x-faces (list (car x-faces))))
2074 (while (and (setq face (pop x-faces))
2075 gnus-article-x-face-command
2077 ;; Check whether this face is censored.
2078 (not gnus-article-x-face-too-ugly)
2079 (and gnus-article-x-face-too-ugly from
2080 (not (string-match gnus-article-x-face-too-ugly
2082 ;; We display the face.
2083 (cond ((stringp gnus-article-x-face-command)
2084 ;; The command is a string, so we interpret the command
2085 ;; as a, well, command, and fork it off.
2086 (let ((process-connection-type nil))
2087 (process-kill-without-query
2089 "article-x-face" nil shell-file-name
2090 shell-command-switch gnus-article-x-face-command))
2093 (process-send-region "article-x-face"
2094 (point-min) (point-max)))
2095 (process-send-eof "article-x-face")))
2096 ((functionp gnus-article-x-face-command)
2097 ;; The command is a lisp function, so we call it.
2098 (funcall gnus-article-x-face-command face))
2100 (error "%s is not a function"
2101 gnus-article-x-face-command)))))))))
2103 (defun article-decode-mime-words ()
2104 "Decode all MIME-encoded words in the article."
2107 (set-buffer gnus-article-buffer)
2108 (let ((inhibit-point-motion-hooks t)
2110 (mail-parse-charset gnus-newsgroup-charset)
2111 (mail-parse-ignored-charsets
2112 (save-excursion (set-buffer gnus-summary-buffer)
2113 gnus-newsgroup-ignored-charsets)))
2114 (mail-decode-encoded-word-region (point-min) (point-max)))))
2116 (defun article-decode-charset (&optional prompt)
2117 "Decode charset-encoded text in the article.
2118 If PROMPT (the prefix), prompt for a coding system to use."
2120 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2122 (mail-parse-charset gnus-newsgroup-charset)
2123 (mail-parse-ignored-charsets
2124 (save-excursion (condition-case nil
2125 (set-buffer gnus-summary-buffer)
2127 gnus-newsgroup-ignored-charsets))
2128 ct cte ctl charset format)
2131 (article-narrow-to-head)
2132 (setq ct (message-fetch-field "Content-Type" t)
2133 cte (message-fetch-field "Content-Transfer-Encoding" t)
2134 ctl (and ct (ignore-errors
2135 (mail-header-parse-content-type ct)))
2138 (mm-read-coding-system "Charset to decode: "))
2140 (mail-content-type-get ctl 'charset)))
2141 format (and ctl (mail-content-type-get ctl 'format)))
2143 (setq cte (mail-header-strip cte)))
2144 (if (and ctl (not (string-match "/" (car ctl))))
2146 (goto-char (point-max)))
2149 (narrow-to-region (point) (point-max))
2150 (when (and (eq mail-parse-charset 'gnus-decoded)
2151 (eq (mm-body-7-or-8) '8bit))
2152 ;; The text code could have been decoded.
2153 (setq charset mail-parse-charset))
2154 (when (and (or (not ctl)
2155 (equal (car ctl) "text/plain"))
2156 (not format)) ;; article with format will decode later.
2158 charset (and cte (intern (downcase
2159 (gnus-strip-whitespace cte))))
2162 (defun article-decode-encoded-words ()
2163 "Remove encoded-word encoding from headers."
2164 (let ((inhibit-point-motion-hooks t)
2165 (mail-parse-charset gnus-newsgroup-charset)
2166 (mail-parse-ignored-charsets
2167 (save-excursion (condition-case nil
2168 (set-buffer gnus-summary-buffer)
2170 gnus-newsgroup-ignored-charsets))
2173 (article-narrow-to-head)
2174 (funcall gnus-decode-header-function (point-min) (point-max)))))
2176 (defun article-decode-group-name ()
2177 "Decode group names in `Newsgroups:'."
2178 (let ((inhibit-point-motion-hooks t)
2180 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2181 (when (and (or gnus-group-name-charset-method-alist
2182 gnus-group-name-charset-group-alist)
2183 (gnus-buffer-live-p gnus-original-article-buffer))
2185 (article-narrow-to-head)
2186 (with-current-buffer gnus-original-article-buffer
2187 (goto-char (point-min)))
2188 (while (re-search-forward
2189 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2190 (replace-match (save-match-data
2191 (gnus-decode-newsgroups
2192 ;; XXX how to use data in article buffer?
2193 (with-current-buffer gnus-original-article-buffer
2195 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2198 gnus-newsgroup-name method))
2200 (goto-char (point-min))
2201 (with-current-buffer gnus-original-article-buffer
2202 (goto-char (point-min)))
2203 (while (re-search-forward
2204 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2205 (replace-match (save-match-data
2206 (gnus-decode-newsgroups
2207 ;; XXX how to use data in article buffer?
2208 (with-current-buffer gnus-original-article-buffer
2210 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2213 gnus-newsgroup-name method))
2216 (autoload 'idna-to-unicode "idna")
2218 (defun article-decode-idna-rhs ()
2219 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2222 (let ((inhibit-point-motion-hooks t)
2224 (article-narrow-to-head)
2225 (goto-char (point-min))
2226 (while (re-search-forward "\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2228 (when (save-match-data
2229 (and (setq ace (match-string 1))
2231 (and (re-search-backward "^[^ \t]" nil t)
2232 (looking-at "From\\|To\\|Cc")))
2233 (save-excursion (backward-char)
2234 (message-idna-inside-rhs-p))
2235 (setq unicode (idna-to-unicode ace))))
2236 (unless (string= ace unicode)
2237 (replace-match unicode nil nil nil 1)))))))))
2239 (defun article-de-quoted-unreadable (&optional force read-charset)
2240 "Translate a quoted-printable-encoded article.
2241 If FORCE, decode the article whether it is marked as quoted-printable
2243 If READ-CHARSET, ask for a coding system."
2244 (interactive (list 'force current-prefix-arg))
2246 (let ((buffer-read-only nil) type charset)
2247 (if (gnus-buffer-live-p gnus-original-article-buffer)
2248 (with-current-buffer gnus-original-article-buffer
2250 (gnus-fetch-field "content-transfer-encoding"))
2251 (let* ((ct (gnus-fetch-field "content-type"))
2254 (mail-header-parse-content-type ct)))))
2255 (setq charset (and ctl
2256 (mail-content-type-get ctl 'charset)))
2257 (if (stringp charset)
2258 (setq charset (intern (downcase charset)))))))
2260 (setq charset (mm-read-coding-system "Charset: " charset)))
2262 (setq charset gnus-newsgroup-charset))
2264 (and type (let ((case-fold-search t))
2265 (string-match "quoted-printable" type))))
2267 (quoted-printable-decode-region
2268 (point) (point-max) (mm-charset-to-coding-system charset))))))
2270 (defun article-de-base64-unreadable (&optional force read-charset)
2271 "Translate a base64 article.
2272 If FORCE, decode the article whether it is marked as base64 not.
2273 If READ-CHARSET, ask for a coding system."
2274 (interactive (list 'force current-prefix-arg))
2276 (let ((buffer-read-only nil) type charset)
2277 (if (gnus-buffer-live-p gnus-original-article-buffer)
2278 (with-current-buffer gnus-original-article-buffer
2280 (gnus-fetch-field "content-transfer-encoding"))
2281 (let* ((ct (gnus-fetch-field "content-type"))
2284 (mail-header-parse-content-type ct)))))
2285 (setq charset (and ctl
2286 (mail-content-type-get ctl 'charset)))
2287 (if (stringp charset)
2288 (setq charset (intern (downcase charset)))))))
2290 (setq charset (mm-read-coding-system "Charset: " charset)))
2292 (setq charset gnus-newsgroup-charset))
2294 (and type (let ((case-fold-search t))
2295 (string-match "base64" type))))
2298 (narrow-to-region (point) (point-max))
2299 (base64-decode-region (point-min) (point-max))
2300 (mm-decode-coding-region
2301 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2306 (defun article-decode-HZ ()
2307 "Translate a HZ-encoded article."
2311 (let ((buffer-read-only nil))
2312 (rfc1843-decode-region (point-min) (point-max)))))
2314 (defun article-unsplit-urls ()
2315 "Remove the newlines that some other mailers insert into URLs."
2318 (let ((buffer-read-only nil))
2319 (goto-char (point-min))
2320 (while (re-search-forward
2321 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2322 (replace-match "\\1\\3" t)))
2323 (when (interactive-p)
2324 (gnus-treat-article nil))))
2327 (defun article-wash-html (&optional read-charset)
2328 "Format an HTML article.
2329 If READ-CHARSET, ask for a coding system."
2332 (let ((buffer-read-only nil)
2334 (when (gnus-buffer-live-p gnus-original-article-buffer)
2335 (with-current-buffer gnus-original-article-buffer
2336 (let* ((ct (gnus-fetch-field "content-type"))
2339 (mail-header-parse-content-type ct)))))
2340 (setq charset (and ctl
2341 (mail-content-type-get ctl 'charset)))
2342 (when (stringp charset)
2343 (setq charset (intern (downcase charset)))))))
2345 (setq charset (mm-read-coding-system "Charset: " charset)))
2347 (setq charset gnus-newsgroup-charset))
2349 (save-window-excursion
2351 (narrow-to-region (point) (point-max))
2352 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2353 (entry (assq func mm-text-html-washer-alist)))
2355 (setq func (cdr entry)))
2360 (apply (car func) (cdr func))))))))))
2362 (defun gnus-article-wash-html-with-w3 ()
2363 "Wash the current buffer with w3."
2365 (let ((w3-strict-width (window-width))
2366 (url-standalone-mode t)
2367 (url-gateway-unplugged t)
2368 (w3-honor-stylesheets nil))
2370 (w3-region (point-min) (point-max))
2373 (defun gnus-article-wash-html-with-w3m ()
2374 "Wash the current buffer with emacs-w3m."
2377 (narrow-to-region (point) (point-max))
2378 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2381 w3m-force-redisplay)
2382 (w3m-region (point-min) (point-max)))
2383 (when mm-inline-text-html-with-w3m-keymap
2384 (add-text-properties
2385 (point-min) (point-max)
2386 (nconc (mm-w3m-local-map-property)
2387 '(mm-inline-text-html-with-w3m t))))))
2389 (defun article-hide-list-identifiers ()
2390 "Remove list identifies from the Subject header.
2391 The `gnus-list-identifiers' variable specifies what to do."
2393 (let ((inhibit-point-motion-hooks t)
2394 (regexp (if (consp gnus-list-identifiers)
2395 (mapconcat 'identity gnus-list-identifiers " *\\|")
2396 gnus-list-identifiers))
2401 (article-narrow-to-head)
2402 (goto-char (point-min))
2403 (while (re-search-forward
2404 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2406 (delete-region (match-beginning 2) (match-end 0))
2407 (beginning-of-line))
2408 (when (re-search-forward
2409 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2410 (delete-region (match-beginning 1) (match-end 1))))))))
2412 (defun article-hide-pem (&optional arg)
2413 "Toggle hiding of any PEM headers and signatures in the current article.
2414 If given a negative prefix, always show; if given a positive prefix,
2416 (interactive (gnus-article-hidden-arg))
2417 (unless (gnus-article-check-hidden-text 'pem arg)
2419 (let (buffer-read-only end)
2420 (goto-char (point-min))
2421 ;; Hide the horrendously ugly "header".
2422 (when (and (search-forward
2423 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2425 (setq end (1+ (match-beginning 0))))
2426 (gnus-add-wash-type 'pem)
2427 (gnus-article-hide-text-type
2429 (if (search-forward "\n\n" nil t)
2433 ;; Hide the trailer as well
2434 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2436 (gnus-article-hide-text-type
2437 (match-beginning 0) (match-end 0) 'pem)))))))
2439 (defun article-strip-banner ()
2440 "Strip the banners specified by the `banner' group parameter and by
2441 `gnus-article-address-banner-alist'."
2445 (let ((inhibit-point-motion-hooks t))
2446 (when (gnus-parameter-banner gnus-newsgroup-name)
2447 (article-really-strip-banner
2448 (gnus-parameter-banner gnus-newsgroup-name)))
2449 (when gnus-article-address-banner-alist
2450 (article-really-strip-banner
2451 (let ((from (save-restriction
2453 (article-narrow-to-head)
2454 (mail-fetch-field "from"))))
2457 (caar (mail-header-parse-addresses from))))
2459 (dolist (pair gnus-article-address-banner-alist)
2460 (when (string-match (car pair) from)
2461 (throw 'found (cdr pair)))))))))))))
2463 (defun article-really-strip-banner (banner)
2464 "Strip the banner specified by the argument."
2467 (let ((inhibit-point-motion-hooks t)
2468 (gnus-signature-limit nil)
2472 ((eq banner 'signature)
2473 (when (gnus-article-narrow-to-signature)
2476 (delete-region (point) (point-max))))
2478 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2479 (while (re-search-forward banner nil t)
2480 (delete-region (match-beginning 0) (match-end 0)))))
2482 (while (re-search-forward banner nil t)
2483 (delete-region (match-beginning 0) (match-end 0)))))))))
2485 (defun article-babel ()
2486 "Translate article using an online translation service."
2490 (set-buffer gnus-article-buffer)
2491 (when (article-goto-body)
2492 (let* ((buffer-read-only nil)
2495 (orig (buffer-substring start end))
2496 (trans (babel-as-string orig)))
2498 (narrow-to-region start end)
2499 (delete-region start end)
2502 (defun article-hide-signature (&optional arg)
2503 "Hide the signature in the current article.
2504 If given a negative prefix, always show; if given a positive prefix,
2506 (interactive (gnus-article-hidden-arg))
2507 (unless (gnus-article-check-hidden-text 'signature arg)
2510 (let ((buffer-read-only nil))
2511 (when (gnus-article-narrow-to-signature)
2512 (gnus-article-hide-text-type
2513 (point-min) (point-max) 'signature))))))
2514 (gnus-set-mode-line 'article))
2516 (defun article-strip-headers-in-body ()
2517 "Strip offensive headers from bodies."
2521 (let ((case-fold-search t))
2522 (when (looking-at "x-no-archive:")
2523 (gnus-delete-line)))))
2525 (defun article-strip-leading-blank-lines ()
2526 "Remove all blank lines from the beginning of the article."
2529 (let ((inhibit-point-motion-hooks t)
2531 (when (article-goto-body)
2532 (while (and (not (eobp))
2533 (looking-at "[ \t]*$"))
2534 (gnus-delete-line))))))
2536 (defun article-narrow-to-head ()
2537 "Narrow the buffer to the head of the message.
2538 Point is left at the beginning of the narrowed-to region."
2540 (goto-char (point-min))
2541 (if (search-forward "\n\n" nil 1)
2544 (goto-char (point-min)))
2546 (defun article-goto-body ()
2547 "Place point at the start of the body."
2548 (goto-char (point-min))
2550 ;; This variable is only bound when dealing with separate
2552 (article-goto-body-goes-to-point-min-p
2554 ((search-forward "\n\n" nil t)
2557 (goto-char (point-max))
2560 (defun article-strip-multiple-blank-lines ()
2561 "Replace consecutive blank lines with one empty line."
2564 (let ((inhibit-point-motion-hooks t)
2566 ;; First make all blank lines empty.
2568 (while (re-search-forward "^[ \t]+$" nil t)
2569 (unless (gnus-annotation-in-region-p
2570 (match-beginning 0) (match-end 0))
2571 (replace-match "" nil t)))
2572 ;; Then replace multiple empty lines with a single empty line.
2574 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2575 (unless (gnus-annotation-in-region-p
2576 (match-beginning 0) (match-end 0))
2577 (delete-region (match-beginning 1) (match-end 1)))))))
2579 (defun article-strip-leading-space ()
2580 "Remove all white space from the beginning of the lines in the article."
2583 (let ((inhibit-point-motion-hooks t)
2586 (while (re-search-forward "^[ \t]+" nil t)
2587 (replace-match "" t t)))))
2589 (defun article-strip-trailing-space ()
2590 "Remove all white space from the end of the lines in the article."
2593 (let ((inhibit-point-motion-hooks t)
2596 (while (re-search-forward "[ \t]+$" nil t)
2597 (replace-match "" t t)))))
2599 (defun article-strip-blank-lines ()
2600 "Strip leading, trailing and multiple blank lines."
2602 (article-strip-leading-blank-lines)
2603 (article-remove-trailing-blank-lines)
2604 (article-strip-multiple-blank-lines))
2606 (defun article-strip-all-blank-lines ()
2607 "Strip all blank lines."
2610 (let ((inhibit-point-motion-hooks t)
2613 (while (re-search-forward "^[ \t]*\n" nil t)
2614 (replace-match "" t t)))))
2616 (defun gnus-article-narrow-to-signature ()
2617 "Narrow to the signature; return t if a signature is found, else nil."
2618 (let ((inhibit-point-motion-hooks t))
2619 (when (gnus-article-search-signature)
2621 ;; Check whether we have some limits to what we consider
2622 ;; to be a signature.
2623 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2624 (list gnus-signature-limit)))
2626 (while (setq limit (pop limits))
2627 (if (or (and (integerp limit)
2628 (< (- (point-max) (point)) limit))
2630 (< (count-lines (point) (point-max)) limit))
2631 (and (functionp limit)
2633 (and (stringp limit)
2634 (not (re-search-forward limit nil t))))
2635 () ; This limit did not succeed.
2639 (narrow-to-region (point) (point-max))
2642 (defun gnus-article-search-signature ()
2643 "Search the current buffer for the signature separator.
2644 Put point at the beginning of the signature separator."
2645 (let ((cur (point)))
2646 (goto-char (point-max))
2647 (if (if (stringp gnus-signature-separator)
2648 (re-search-backward gnus-signature-separator nil t)
2649 (let ((seps gnus-signature-separator))
2651 (not (re-search-backward (car seps) nil t)))
2658 (defun gnus-article-hidden-arg ()
2659 "Return the current prefix arg as a number, or 0 if no prefix."
2660 (list (if current-prefix-arg
2661 (prefix-numeric-value current-prefix-arg)
2664 (defun gnus-article-check-hidden-text (type arg)
2665 "Return nil if hiding is necessary.
2666 Arg can be nil or a number. nil and positive means hide, negative
2667 means show, 0 means toggle."
2670 (let ((hide (gnus-article-hidden-text-p type)))
2676 (gnus-article-show-hidden-text type)
2679 (if (eq hide 'hidden)
2681 (gnus-article-show-hidden-text type)
2685 (defun gnus-article-hidden-text-p (type)
2686 "Say whether the current buffer contains hidden text of type TYPE."
2687 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2689 (not (get-text-property pos 'invisible))
2690 (not (get-text-property pos 'dummy-invisible)))
2692 (text-property-any (1+ pos) (point-max) 'article-type type)))
2697 (defun gnus-article-show-hidden-text (type &optional dummy)
2698 "Show all hidden text of type TYPE.
2699 Originally it is hide instead of DUMMY."
2700 (let ((buffer-read-only nil)
2701 (inhibit-point-motion-hooks t))
2702 (gnus-remove-text-properties-when
2704 (point-min) (point-max)
2705 (cons 'article-type (cons type
2706 gnus-hidden-properties)))
2707 (gnus-delete-wash-type type)))
2709 (defconst article-time-units
2710 `((year . ,(* 365.25 24 60 60))
2711 (week . ,(* 7 24 60 60))
2712 (day . ,(* 24 60 60))
2716 "Mapping from time units to seconds.")
2718 (defun gnus-article-forward-header ()
2719 "Move point to the start of the next header.
2720 If the current header is a continuation header, this can be several
2725 (if (looking-at "[ \t]+[^ \t]")
2729 (defun article-date-ut (&optional type highlight header)
2730 "Convert DATE date to universal time in the current article.
2731 If TYPE is `local', convert to local time; if it is `lapsed', output
2732 how much time has lapsed since DATE. For `lapsed', the value of
2733 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2734 should replace the \"Date:\" one, or should be added below it."
2735 (interactive (list 'ut t))
2736 (let* ((header (or header
2737 (message-fetch-field "date")
2739 (tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
2742 ((not gnus-article-date-lapsed-new-header)
2748 (date (if (vectorp header) (mail-header-date header)
2750 (inhibit-point-motion-hooks t)
2755 (article-narrow-to-head)
2756 (when (re-search-forward tdate-regexp nil t)
2757 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2758 date (or (get-text-property (gnus-point-at-bol)
2761 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
2763 (when (and date (not (string= date "")))
2764 (goto-char (point-min))
2765 (let ((buffer-read-only nil))
2766 ;; Delete any old Date headers.
2767 (while (re-search-forward date-regexp nil t)
2769 (delete-region (progn (beginning-of-line) (point))
2770 (progn (gnus-article-forward-header)
2772 (delete-region (progn (beginning-of-line) (point))
2773 (progn (gnus-article-forward-header)
2776 (setq pos (point))))
2777 (when (and (not pos)
2778 (re-search-forward tdate-regexp nil t))
2782 (insert (article-make-date-line date (or type 'ut)))
2788 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2789 (put-text-property (match-beginning 1) (1+ (match-end 1))
2790 'original-date date)
2791 (put-text-property (match-beginning 1) (1+ (match-end 1))
2793 (put-text-property (match-beginning 2) (match-end 2)
2796 (defun article-make-date-line (date type)
2797 "Return a DATE line of TYPE."
2798 (unless (memq type '(local ut original user iso8601 lapsed english))
2799 (error "Unknown conversion type: %s" type))
2801 (let ((time (date-to-time date)))
2803 ;; Convert to the local timezone.
2805 (let ((tz (car (current-time-zone time))))
2806 (format "Date: %s %s%02d%02d" (current-time-string time)
2807 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2808 (/ (% (abs tz) 3600) 60))))
2809 ;; Convert to Universal Time.
2812 (current-time-string
2813 (let* ((e (parse-time-string date))
2814 (tm (apply 'encode-time e))
2816 (ls (- (cadr tm) (car (current-time-zone time)))))
2817 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2818 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2821 ;; Get the original date from the article.
2822 ((eq type 'original)
2823 (concat "Date: " (if (string-match "\n+$" date)
2824 (substring date 0 (match-beginning 0))
2826 ;; Let the user define the format.
2828 (let ((format (or (condition-case nil
2829 (with-current-buffer gnus-summary-buffer
2830 gnus-article-time-format)
2832 gnus-article-time-format)))
2833 (if (functionp format)
2834 (funcall format time)
2835 (concat "Date: " (format-time-string format time)))))
2838 (let ((tz (car (current-time-zone time))))
2841 (format-time-string "%Y%m%dT%H%M%S" time)
2842 (format "%s%02d%02d"
2843 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2844 (/ (% (abs tz) 3600) 60)))))
2845 ;; Do an X-Sent lapsed format.
2847 ;; If the date is seriously mangled, the timezone functions are
2848 ;; liable to bug out, so we ignore all errors.
2849 (let* ((now (current-time))
2850 (real-time (subtract-time now time))
2851 (real-sec (and real-time
2852 (+ (* (float (car real-time)) 65536)
2854 (sec (and real-time (abs real-sec)))
2864 ;; This is a bit convoluted, but basically we go
2865 ;; through the time units for years, weeks, etc,
2866 ;; and divide things to see whether that results
2867 ;; in positive answers.
2870 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2871 ;; The (remaining) seconds are too few to
2872 ;; be divided into this time unit.
2874 ;; It's big enough, so we output it.
2875 (setq sec (- sec (* num (cdr unit))))
2877 (concat (if prev ", " "") (int-to-string
2879 " " (symbol-name (car unit))
2880 (if (> num 1) "s" ""))
2882 article-time-units "")
2883 ;; If dates are odd, then it might appear like the
2884 ;; article was sent in the future.
2887 " in the future"))))))
2888 ;; Display the date in proper English
2890 (let ((dtime (decode-time time)))
2893 (number-to-string (nth 3 dtime))
2894 (let ((digit (% (nth 3 dtime) 10)))
2896 ((memq (nth 3 dtime) '(11 12 13)) "th")
2902 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2904 (number-to-string (nth 5 dtime))
2906 (format "%02d" (nth 2 dtime))
2908 (format "%02d" (nth 1 dtime)))))))
2910 (format "Date: %s (from Gnus)" date))))
2912 (defun article-date-local (&optional highlight)
2913 "Convert the current article date to the local timezone."
2914 (interactive (list t))
2915 (article-date-ut 'local highlight))
2917 (defun article-date-english (&optional highlight)
2918 "Convert the current article date to something that is proper English."
2919 (interactive (list t))
2920 (article-date-ut 'english highlight))
2922 (defun article-date-original (&optional highlight)
2923 "Convert the current article date to what it was originally.
2924 This is only useful if you have used some other date conversion
2925 function and want to see what the date was before converting."
2926 (interactive (list t))
2927 (article-date-ut 'original highlight))
2929 (defun article-date-lapsed (&optional highlight)
2930 "Convert the current article date to time lapsed since it was sent."
2931 (interactive (list t))
2932 (article-date-ut 'lapsed highlight))
2934 (defun article-update-date-lapsed ()
2935 "Function to be run from a timer to update the lapsed time line."
2936 (let (deactivate-mark)
2941 (set-buffer (window-buffer w))
2942 (when (eq major-mode 'gnus-article-mode)
2943 (let ((mark (point-marker)))
2944 (goto-char (point-min))
2945 (when (re-search-forward "^X-Sent:" nil t)
2946 (article-date-lapsed t))
2947 (goto-char (marker-position mark))
2948 (move-marker mark nil))))
2951 (defun gnus-start-date-timer (&optional n)
2952 "Start a timer to update the X-Sent header in the article buffers.
2953 The numerical prefix says how frequently (in seconds) the function
2958 (gnus-stop-date-timer)
2959 (setq article-lapsed-timer
2960 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
2962 (defun gnus-stop-date-timer ()
2963 "Stop the X-Sent timer."
2965 (when article-lapsed-timer
2966 (nnheader-cancel-timer article-lapsed-timer)
2967 (setq article-lapsed-timer nil)))
2969 (defun article-date-user (&optional highlight)
2970 "Convert the current article date to the user-defined format.
2971 This format is defined by the `gnus-article-time-format' variable."
2972 (interactive (list t))
2973 (article-date-ut 'user highlight))
2975 (defun article-date-iso8601 (&optional highlight)
2976 "Convert the current article date to ISO8601."
2977 (interactive (list t))
2978 (article-date-ut 'iso8601 highlight))
2980 ;; (defun article-show-all ()
2981 ;; "Show all hidden text in the article buffer."
2984 ;; (let ((buffer-read-only nil))
2985 ;; (gnus-article-unhide-text (point-min) (point-max)))))
2987 (defun article-remove-leading-whitespace ()
2988 "Remove excessive whitespace from all headers."
2992 (let ((buffer-read-only nil))
2993 (article-narrow-to-head)
2994 (goto-char (point-min))
2995 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
2996 (delete-region (match-beginning 1) (match-end 1)))))))
2998 (defun article-emphasize (&optional arg)
2999 "Emphasize text according to `gnus-emphasis-alist'."
3000 (interactive (gnus-article-hidden-arg))
3001 (unless (gnus-article-check-hidden-text 'emphasis arg)
3005 (with-current-buffer gnus-summary-buffer
3006 gnus-article-emphasis-alist)
3008 gnus-emphasis-alist))
3009 (buffer-read-only nil)
3010 (props (append '(article-type emphasis)
3011 gnus-hidden-properties))
3012 regexp elem beg invisible visible face)
3015 (while (setq elem (pop alist))
3017 (setq regexp (car elem)
3018 invisible (nth 1 elem)
3019 visible (nth 2 elem)
3021 (while (re-search-forward regexp nil t)
3022 (when (and (match-beginning visible) (match-beginning invisible))
3023 (gnus-article-hide-text
3024 (match-beginning invisible) (match-end invisible) props)
3025 (gnus-article-unhide-text-type
3026 (match-beginning visible) (match-end visible) 'emphasis)
3027 (gnus-put-overlay-excluding-newlines
3028 (match-beginning visible) (match-end visible) 'face face)
3029 (gnus-add-wash-type 'emphasis)
3030 (goto-char (match-end invisible)))))))))
3032 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3033 "Setup newsgroup emphasis alist."
3034 (unless gnus-article-emphasis-alist
3035 (let ((name (and gnus-newsgroup-name
3036 (gnus-group-real-name gnus-newsgroup-name))))
3037 (make-local-variable 'gnus-article-emphasis-alist)
3038 (setq gnus-article-emphasis-alist
3040 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3041 (while (setq elem (pop alist))
3042 (when (and name (string-match (car elem) name))
3044 highlight (copy-sequence (cdr elem)))))
3046 (copy-sequence highlight-words)
3047 (if gnus-newsgroup-name
3048 (copy-sequence (gnus-group-find-parameter
3049 gnus-newsgroup-name 'highlight-words t)))
3050 gnus-emphasis-alist)))))
3053 (defvar gnus-summary-article-menu)
3054 (defvar gnus-summary-post-menu))
3056 ;;; Saving functions.
3058 (defun gnus-article-save (save-buffer file &optional num)
3059 "Save the currently selected article."
3060 (unless gnus-save-all-headers
3061 ;; Remove headers according to `gnus-saved-headers'.
3062 (let ((gnus-visible-headers
3063 (or gnus-saved-headers gnus-visible-headers))
3064 (gnus-article-buffer save-buffer))
3066 (set-buffer save-buffer)
3067 (article-hide-headers 1 t))))
3068 (save-window-excursion
3069 (if (not gnus-default-article-saver)
3070 (error "No default saver is defined")
3071 ;; !!! Magic! The saving functions all save
3072 ;; `gnus-save-article-buffer' (or so they think), but we
3073 ;; bind that variable to our save-buffer.
3074 (set-buffer gnus-article-buffer)
3075 (let* ((gnus-save-article-buffer save-buffer)
3078 ((not gnus-prompt-before-saving) 'default)
3079 ((eq gnus-prompt-before-saving 'always) nil)
3081 (gnus-number-of-articles-to-be-saved
3082 (when (eq gnus-prompt-before-saving t)
3084 (set-buffer gnus-article-current-summary)
3085 (funcall gnus-default-article-saver filename)))))
3087 (defun gnus-read-save-file-name (prompt &optional filename
3088 function group headers variable)
3090 (funcall function group headers (symbol-value variable)))
3095 ((eq filename 'default)
3101 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3104 (if (and gnus-number-of-articles-to-be-saved
3105 (> gnus-number-of-articles-to-be-saved 1))
3106 (format "these %d articles"
3107 gnus-number-of-articles-to-be-saved)
3110 ;; Let the split methods have their say.
3112 ;; No split name was found.
3115 (concat prompt " (default "
3116 (file-name-nondirectory default-name) ") ")
3117 (file-name-directory default-name)
3119 ;; A single group name is returned.
3120 ((stringp split-name)
3122 (funcall function split-name headers
3123 (symbol-value variable)))
3125 (concat prompt " (default "
3126 (file-name-nondirectory default-name) ") ")
3127 (file-name-directory default-name)
3129 ;; A single split name was found
3130 ((= 1 (length split-name))
3131 (let* ((name (expand-file-name
3133 gnus-article-save-directory))
3134 (dir (cond ((file-directory-p name)
3135 (file-name-as-directory name))
3136 ((file-exists-p name) name)
3137 (t gnus-article-save-directory))))
3139 (concat prompt " (default " name ") ")
3141 ;; A list of splits was found.
3143 (setq split-name (nreverse split-name))
3145 (let ((file-name-history
3146 (nconc split-name file-name-history)))
3150 (concat prompt " (`M-p' for defaults) ")
3151 gnus-article-save-directory
3153 gnus-article-save-directory)))
3154 (car (push result file-name-history)))))))
3155 ;; Create the directory.
3156 (gnus-make-directory (file-name-directory file))
3157 ;; If we have read a directory, we append the default file name.
3158 (when (file-directory-p file)
3159 (setq file (expand-file-name (file-name-nondirectory
3161 (file-name-as-directory file))))
3162 ;; Possibly translate some characters.
3163 (nnheader-translate-file-chars file))))))
3164 (gnus-make-directory (file-name-directory result))
3165 (set variable result)))
3167 (defun gnus-article-archive-name (group)
3168 "Return the first instance of an \"Archive-name\" in the current buffer."
3169 (let ((case-fold-search t))
3170 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3171 (nnheader-concat gnus-article-save-directory
3172 (match-string 1)))))
3174 (defun gnus-article-nndoc-name (group)
3175 "If GROUP is an nndoc group, return the name of the parent group."
3176 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3177 (gnus-group-get-parameter group 'save-article-group)))
3179 (defun gnus-summary-save-in-rmail (&optional filename)
3180 "Append this article to Rmail file.
3181 Optional argument FILENAME specifies file name.
3182 Directory to save to is default to `gnus-article-save-directory'."
3183 (setq filename (gnus-read-save-file-name
3184 "Save %s in rmail file:" filename
3185 gnus-rmail-save-name gnus-newsgroup-name
3186 gnus-current-headers 'gnus-newsgroup-last-rmail))
3187 (gnus-eval-in-buffer-window gnus-save-article-buffer
3191 (gnus-output-to-rmail filename))))
3194 (defun gnus-summary-save-in-mail (&optional filename)
3195 "Append this article to Unix mail file.
3196 Optional argument FILENAME specifies file name.
3197 Directory to save to is default to `gnus-article-save-directory'."
3198 (setq filename (gnus-read-save-file-name
3199 "Save %s in Unix mail file:" filename
3200 gnus-mail-save-name gnus-newsgroup-name
3201 gnus-current-headers 'gnus-newsgroup-last-mail))
3202 (gnus-eval-in-buffer-window gnus-save-article-buffer
3206 (if (and (file-readable-p filename)
3207 (file-regular-p filename)
3208 (mail-file-babyl-p filename))
3209 (rmail-output-to-rmail-file filename t)
3210 (gnus-output-to-mail filename)))))
3213 (defun gnus-summary-save-in-file (&optional filename overwrite)
3214 "Append this article to file.
3215 Optional argument FILENAME specifies file name.
3216 Directory to save to is default to `gnus-article-save-directory'."
3217 (setq filename (gnus-read-save-file-name
3218 "Save %s in file:" filename
3219 gnus-file-save-name gnus-newsgroup-name
3220 gnus-current-headers 'gnus-newsgroup-last-file))
3221 (gnus-eval-in-buffer-window gnus-save-article-buffer
3225 (when (and overwrite
3226 (file-exists-p filename))
3227 (delete-file filename))
3228 (gnus-output-to-file filename))))
3231 (defun gnus-summary-write-to-file (&optional filename)
3232 "Write this article to a file, overwriting it if the file exists.
3233 Optional argument FILENAME specifies file name.
3234 The directory to save in defaults to `gnus-article-save-directory'."
3235 (gnus-summary-save-in-file nil t))
3237 (defun gnus-summary-save-body-in-file (&optional filename)
3238 "Append this article body to a file.
3239 Optional argument FILENAME specifies file name.
3240 The directory to save in defaults to `gnus-article-save-directory'."
3241 (setq filename (gnus-read-save-file-name
3242 "Save %s body in file:" filename
3243 gnus-file-save-name gnus-newsgroup-name
3244 gnus-current-headers 'gnus-newsgroup-last-file))
3245 (gnus-eval-in-buffer-window gnus-save-article-buffer
3249 (when (article-goto-body)
3250 (narrow-to-region (point) (point-max)))
3251 (gnus-output-to-file filename))))
3254 (defun gnus-summary-save-in-pipe (&optional command)
3255 "Pipe this article to subprocess."
3257 (cond ((and (eq command 'default)
3258 gnus-last-shell-command)
3259 gnus-last-shell-command)
3264 "Shell command on %s: "
3265 (if (and gnus-number-of-articles-to-be-saved
3266 (> gnus-number-of-articles-to-be-saved 1))
3267 (format "these %d articles"
3268 gnus-number-of-articles-to-be-saved)
3270 gnus-last-shell-command))))
3271 (when (string-equal command "")
3272 (if gnus-last-shell-command
3273 (setq command gnus-last-shell-command)
3274 (error "A command is required")))
3275 (gnus-eval-in-buffer-window gnus-article-buffer
3278 (shell-command-on-region (point-min) (point-max) command nil)))
3279 (setq gnus-last-shell-command command))
3281 (defmacro gnus-read-string (prompt &optional initial-contents history
3283 "Like `read-string' but allow for older XEmacsen that don't have the 5th arg."
3284 (if (and (featurep 'xemacs)
3285 (< emacs-minor-version 2))
3286 `(read-string ,prompt ,initial-contents ,history)
3287 `(read-string ,prompt ,initial-contents ,history ,default-value)))
3289 (defun gnus-summary-pipe-to-muttprint (&optional command)
3290 "Pipe this article to muttprint."
3291 (setq command (gnus-read-string
3292 "Print using command: " gnus-summary-muttprint-program
3293 nil gnus-summary-muttprint-program))
3294 (gnus-summary-save-in-pipe command))
3296 ;;; Article file names when saving.
3298 (defun gnus-capitalize-newsgroup (newsgroup)
3299 "Capitalize NEWSGROUP name."
3300 (when (not (zerop (length newsgroup)))
3301 (concat (char-to-string (upcase (aref newsgroup 0)))
3302 (substring newsgroup 1))))
3304 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3305 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3306 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3307 Otherwise, it is like ~/News/news/group/num."
3310 (concat (if (gnus-use-long-file-name 'not-save)
3311 (gnus-capitalize-newsgroup newsgroup)
3312 (gnus-newsgroup-directory-form newsgroup))
3313 "/" (int-to-string (mail-header-number headers)))
3314 gnus-article-save-directory)))
3316 (string-equal (file-name-directory default)
3317 (file-name-directory last-file))
3318 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3320 (or last-file default))))
3322 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3323 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3324 If variable `gnus-use-long-file-name' is non-nil, it is
3325 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3328 (concat (if (gnus-use-long-file-name 'not-save)
3330 (gnus-newsgroup-directory-form newsgroup))
3331 "/" (int-to-string (mail-header-number headers)))
3332 gnus-article-save-directory)))
3334 (string-equal (file-name-directory default)
3335 (file-name-directory last-file))
3336 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3338 (or last-file default))))
3340 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3341 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3342 If variable `gnus-use-long-file-name' is non-nil, it is
3343 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3346 (if (gnus-use-long-file-name 'not-save)
3349 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3351 gnus-article-save-directory)))
3353 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3354 "Generate file name from sender."
3355 (let ((from (mail-header-from headers)))
3357 (if (and from (string-match "\\([^ <]+\\)@" from))
3358 (match-string 1 from)
3360 gnus-article-save-directory)))
3362 (defun article-verify-x-pgp-sig ()
3365 (if (gnus-buffer-live-p gnus-original-article-buffer)
3366 (let ((sig (with-current-buffer gnus-original-article-buffer
3367 (gnus-fetch-field "X-PGP-Sig")))
3371 (mml2015-clear-verify-function))
3373 (insert-buffer-substring gnus-original-article-buffer)
3374 (setq items (split-string sig))
3375 (message-narrow-to-head)
3376 (let ((inhibit-point-motion-hooks t)
3377 (case-fold-search t))
3378 ;; Don't verify multiple headers.
3379 (setq headers (mapconcat (lambda (header)
3381 (mail-fetch-field header)
3383 (split-string (nth 1 items) ",") "")))
3384 (delete-region (point-min) (point-max))
3385 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3386 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3391 (if (looking-at "^-")
3394 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3395 (insert "Version: " (car items) "\n\n")
3396 (insert (mapconcat 'identity (cddr items) "\n"))
3397 (insert "\n-----END PGP SIGNATURE-----\n")
3398 (let ((mm-security-handle (list (format "multipart/signed"))))
3399 (mml2015-clean-buffer)
3400 (let ((coding-system-for-write (or gnus-newsgroup-charset
3402 (funcall (mml2015-clear-verify-function)))
3404 (or (mm-handle-multipart-ctl-parameter
3405 mm-security-handle 'gnus-details)
3406 (mm-handle-multipart-ctl-parameter
3407 mm-security-handle 'gnus-info)))))
3409 (let (buffer-read-only bface eface)
3411 (message-narrow-to-head)
3412 (goto-char (point-max))
3414 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3415 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3416 (message-remove-header "X-Gnus-PGP-Verify")
3417 (if (re-search-forward "^X-PGP-Sig:" nil t)
3419 (goto-char (point-max)))
3420 (narrow-to-region (point) (point))
3421 (insert "X-Gnus-PGP-Verify: " info "\n")
3422 (goto-char (point-min))
3425 (if (not (looking-at "^[ \t]"))
3429 (goto-char (point-min))
3430 (when (looking-at "\\([^:]+\\): *")
3431 (put-text-property (match-beginning 1) (1+ (match-end 1))
3433 (put-text-property (match-end 0) (point-max)
3434 'face eface)))))))))
3436 (defun article-verify-cancel-lock ()
3437 "Verify Cancel-Lock header."
3439 (if (gnus-buffer-live-p gnus-original-article-buffer)
3440 (canlock-verify gnus-original-article-buffer)))
3447 (setq afunc (car func)
3450 gfunc (intern (format "gnus-%s" func))))
3452 (when (fboundp afunc)
3453 `(lambda (&optional interactive &rest args)
3454 ,(documentation afunc t)
3455 (interactive (list t))
3457 (set-buffer gnus-article-buffer)
3459 (call-interactively ',afunc)
3460 (apply ',afunc args))))))))
3461 '(article-hide-headers
3462 article-verify-x-pgp-sig
3463 article-verify-cancel-lock
3464 article-hide-boring-headers
3465 article-treat-overstrike
3466 article-fill-long-lines
3467 article-capitalize-sentences
3469 article-remove-leading-whitespace
3470 article-display-x-face
3471 article-display-face
3472 article-de-quoted-unreadable
3473 article-de-base64-unreadable
3476 article-unsplit-urls
3477 article-hide-list-identifiers
3478 article-strip-banner
3481 article-hide-signature
3482 article-strip-headers-in-body
3483 article-remove-trailing-blank-lines
3484 article-strip-leading-blank-lines
3485 article-strip-multiple-blank-lines
3486 article-strip-leading-space
3487 article-strip-trailing-space
3488 article-strip-blank-lines
3489 article-strip-all-blank-lines
3491 article-date-english
3492 article-date-iso8601
3493 article-date-original
3495 article-decode-mime-words
3496 article-decode-charset
3497 article-decode-encoded-words
3501 article-treat-dumbquotes
3502 article-normalize-headers
3503 ;; (article-show-all . gnus-article-show-all-headers)
3507 ;;; Gnus article mode
3510 (put 'gnus-article-mode 'mode-class 'special)
3512 (set-keymap-parent gnus-article-mode-map widget-keymap)
3514 (gnus-define-keys gnus-article-mode-map
3515 " " gnus-article-goto-next-page
3516 "\177" gnus-article-goto-prev-page
3517 [delete] gnus-article-goto-prev-page
3518 [backspace] gnus-article-goto-prev-page
3519 "\C-c^" gnus-article-refer-article
3520 "h" gnus-article-show-summary
3521 "s" gnus-article-show-summary
3522 "\C-c\C-m" gnus-article-mail
3523 "?" gnus-article-describe-briefly
3524 "e" gnus-summary-edit-article
3525 "<" beginning-of-buffer
3527 "\C-c\C-i" gnus-info-find-node
3529 "R" gnus-article-reply-with-original
3530 "F" gnus-article-followup-with-original
3531 "\C-hk" gnus-article-describe-key
3532 "\C-hc" gnus-article-describe-key-briefly
3534 "\C-d" gnus-article-read-summary-keys
3535 "\M-*" gnus-article-read-summary-keys
3536 "\M-#" gnus-article-read-summary-keys
3537 "\M-^" gnus-article-read-summary-keys
3538 "\M-g" gnus-article-read-summary-keys)
3540 (substitute-key-definition
3541 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
3543 (defun gnus-article-make-menu-bar ()
3544 (unless (boundp 'gnus-article-commands-menu)
3545 (gnus-summary-make-menu-bar))
3546 (gnus-turn-off-edit-menu 'article)
3547 (unless (boundp 'gnus-article-article-menu)
3549 gnus-article-article-menu gnus-article-mode-map ""
3551 ["Scroll forwards" gnus-article-goto-next-page t]
3552 ["Scroll backwards" gnus-article-goto-prev-page t]
3553 ["Show summary" gnus-article-show-summary t]
3554 ["Fetch Message-ID at point" gnus-article-refer-article t]
3555 ["Mail to address at point" gnus-article-mail t]
3556 ["Send a bug report" gnus-bug t]))
3559 gnus-article-treatment-menu gnus-article-mode-map ""
3560 ;; Fixme: this should use :active (and maybe :visible).
3562 ["Hide headers" gnus-article-hide-headers t]
3563 ["Hide signature" gnus-article-hide-signature t]
3564 ["Hide citation" gnus-article-hide-citation t]
3565 ["Treat overstrike" gnus-article-treat-overstrike t]
3566 ["Remove carriage return" gnus-article-remove-cr t]
3567 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3568 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
3569 ["Remove base64" gnus-article-de-base64-unreadable t]
3570 ["Treat html" gnus-article-wash-html t]
3571 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3572 ["Decode HZ" gnus-article-decode-HZ t]))
3574 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3576 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3578 (gnus-run-hooks 'gnus-article-menu-hook)))
3580 (defun gnus-article-mode ()
3581 "Major mode for displaying an article.
3583 All normal editing commands are switched off.
3585 The following commands are available in addition to all summary mode
3587 \\<gnus-article-mode-map>
3588 \\[gnus-article-next-page]\t Scroll the article one page forwards
3589 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3590 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3591 \\[gnus-article-show-summary]\t Display the summary buffer
3592 \\[gnus-article-mail]\t Send a reply to the address near point
3593 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3594 \\[gnus-info-find-node]\t Go to the Gnus info node"
3596 (gnus-simplify-mode-line)
3597 (setq mode-name "Article")
3598 (setq major-mode 'gnus-article-mode)
3599 (make-local-variable 'minor-mode-alist)
3600 (use-local-map gnus-article-mode-map)
3601 (when (gnus-visual-p 'article-menu 'menu)
3602 (gnus-article-make-menu-bar)
3603 (when gnus-summary-tool-bar-map
3604 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3605 (gnus-update-format-specifications nil 'article-mode)
3606 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3607 (set (make-local-variable 'gnus-page-broken) nil)
3608 (make-local-variable 'gnus-button-marker-list)
3609 (make-local-variable 'gnus-article-current-summary)
3610 (make-local-variable 'gnus-article-mime-handles)
3611 (make-local-variable 'gnus-article-decoded-p)
3612 (make-local-variable 'gnus-article-mime-handle-alist)
3613 (make-local-variable 'gnus-article-wash-types)
3614 (make-local-variable 'gnus-article-image-alist)
3615 (make-local-variable 'gnus-article-charset)
3616 (make-local-variable 'gnus-article-ignored-charsets)
3617 (gnus-set-default-directory)
3618 (buffer-disable-undo)
3619 (setq buffer-read-only t)
3620 (set-syntax-table gnus-article-mode-syntax-table)
3621 (mm-enable-multibyte)
3622 (gnus-run-hooks 'gnus-article-mode-hook))
3624 (defun gnus-article-setup-buffer ()
3625 "Initialize the article buffer."
3626 (let* ((name (if gnus-single-article-buffer "*Article*"
3627 (concat "*Article " gnus-newsgroup-name "*")))
3629 (progn (string-match "\\*Article" name)
3630 (concat " *Original Article"
3631 (substring name (match-end 0))))))
3632 (setq gnus-article-buffer name)
3633 (setq gnus-original-article-buffer original)
3634 (setq gnus-article-mime-handle-alist nil)
3635 ;; This might be a variable local to the summary buffer.
3636 (unless gnus-single-article-buffer
3638 (set-buffer gnus-summary-buffer)
3639 (setq gnus-article-buffer name)
3640 (setq gnus-original-article-buffer original)
3641 (gnus-set-global-variables)))
3642 (gnus-article-setup-highlight-words)
3643 ;; Init original article buffer.
3645 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3646 (mm-enable-multibyte)
3647 (setq major-mode 'gnus-original-article-mode)
3648 (make-local-variable 'gnus-original-article))
3649 (if (get-buffer name)
3652 (when (and gnus-article-edit-mode
3655 (y-or-n-p "Article mode edit in progress; discard? ")))
3656 (error "Action aborted"))
3657 (set (make-local-variable 'gnus-article-edit-mode) nil)
3658 (when gnus-article-mime-handles
3659 (mm-destroy-parts gnus-article-mime-handles)
3660 (setq gnus-article-mime-handles nil))
3661 ;; Set it to nil in article-buffer!
3662 (setq gnus-article-mime-handle-alist nil)
3663 (buffer-disable-undo)
3664 (setq buffer-read-only t)
3665 ;; This list just keeps growing if we don't reset it.
3666 (setq gnus-button-marker-list nil)
3667 (unless (eq major-mode 'gnus-article-mode)
3668 (gnus-article-mode))
3671 (set-buffer (gnus-get-buffer-create name))
3673 (make-local-variable 'gnus-summary-buffer)
3674 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3675 (current-buffer)))))
3677 ;; Set article window start at LINE, where LINE is the number of lines
3678 ;; from the head of the article.
3679 (defun gnus-article-set-window-start (&optional line)
3681 (gnus-get-buffer-window gnus-article-buffer t)
3683 (set-buffer gnus-article-buffer)
3684 (goto-char (point-min))
3687 (gnus-message 6 "Moved to bookmark")
3688 (search-forward "\n\n" nil t)
3692 (defun gnus-article-prepare (article &optional all-headers header)
3693 "Prepare ARTICLE in article mode buffer.
3694 ARTICLE should either be an article number or a Message-ID.
3695 If ARTICLE is an id, HEADER should be the article headers.
3696 If ALL-HEADERS is non-nil, no headers are hidden."
3698 ;; Make sure we start in a summary buffer.
3699 (unless (eq major-mode 'gnus-summary-mode)
3700 (set-buffer gnus-summary-buffer))
3701 (setq gnus-summary-buffer (current-buffer))
3702 (let* ((gnus-article (if header (mail-header-number header) article))
3703 (summary-buffer (current-buffer))
3704 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3705 (group gnus-newsgroup-name)
3708 (gnus-article-setup-buffer)
3709 (set-buffer gnus-article-buffer)
3710 ;; Deactivate active regions.
3711 (when (and (boundp 'transient-mark-mode)
3712 transient-mark-mode)
3713 (setq mark-active nil))
3714 (if (not (setq result (let ((buffer-read-only nil))
3715 (gnus-request-article-this-buffer
3717 ;; There is no such article.
3719 (when (and (numberp article)
3720 (not (memq article gnus-newsgroup-sparse)))
3721 (setq gnus-article-current
3722 (cons gnus-newsgroup-name article))
3723 (set-buffer gnus-summary-buffer)
3724 (setq gnus-current-article article)
3725 (if (and (memq article gnus-newsgroup-undownloaded)
3726 (not (gnus-online (gnus-find-method-for-group
3727 gnus-newsgroup-name))))
3729 (gnus-summary-set-agent-mark article)
3730 (message "Message marked for downloading"))
3731 (gnus-summary-mark-article article gnus-canceled-mark)
3732 (unless (memq article gnus-newsgroup-sparse)
3733 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3734 (if (or (eq result 'pseudo)
3735 (eq result 'nneething))
3738 (set-buffer summary-buffer)
3739 (push article gnus-newsgroup-history)
3740 (setq gnus-last-article gnus-current-article
3741 gnus-current-article 0
3742 gnus-current-headers nil
3743 gnus-article-current nil)
3744 (if (eq result 'nneething)
3745 (gnus-configure-windows 'summary)
3746 (gnus-configure-windows 'article))
3747 (gnus-set-global-variables))
3748 (let ((gnus-article-mime-handle-alist-1
3749 gnus-article-mime-handle-alist))
3750 (gnus-set-mode-line 'article)))
3751 ;; The result from the `request' was an actual article -
3752 ;; or at least some text that is now displayed in the
3754 (when (and (numberp article)
3755 (not (eq article gnus-current-article)))
3756 ;; Seems like a new article has been selected.
3757 ;; `gnus-current-article' must be an article number.
3759 (set-buffer summary-buffer)
3760 (push article gnus-newsgroup-history)
3761 (setq gnus-last-article gnus-current-article
3762 gnus-current-article article
3763 gnus-current-headers
3764 (gnus-summary-article-header gnus-current-article)
3765 gnus-article-current
3766 (cons gnus-newsgroup-name gnus-current-article))
3767 (unless (vectorp gnus-current-headers)
3768 (setq gnus-current-headers nil))
3769 (gnus-summary-goto-subject gnus-current-article)
3770 (when (gnus-summary-show-thread)
3771 ;; If the summary buffer really was folded, the
3772 ;; previous goto may not actually have gone to
3773 ;; the right article, but the thread root instead.
3775 (gnus-summary-goto-subject gnus-current-article))
3776 (gnus-run-hooks 'gnus-mark-article-hook)
3777 (gnus-set-mode-line 'summary)
3778 (when (gnus-visual-p 'article-highlight 'highlight)
3779 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3780 ;; Set the global newsgroup variables here.
3781 (gnus-set-global-variables)
3782 (setq gnus-have-all-headers
3783 (or all-headers gnus-show-all-headers))))
3785 (gnus-configure-windows 'article))
3786 (when (or (numberp article)
3788 (gnus-article-prepare-display)
3790 (goto-char (point-min))
3791 (when gnus-break-pages
3792 (gnus-narrow-to-page)))
3793 (let ((gnus-article-mime-handle-alist-1
3794 gnus-article-mime-handle-alist))
3795 (gnus-set-mode-line 'article))
3799 (set-window-point (get-buffer-window (current-buffer)) (point))
3800 (gnus-configure-windows 'article)
3804 (defun gnus-article-prepare-display ()
3805 "Make the current buffer look like a nice article."
3806 ;; Hooks for getting information from the article.
3807 ;; This hook must be called before being narrowed.
3808 (let ((gnus-article-buffer (current-buffer))
3810 (unless (eq major-mode 'gnus-article-mode)
3811 (gnus-article-mode))
3812 (setq buffer-read-only nil
3813 gnus-article-wash-types nil
3814 gnus-article-image-alist nil)
3815 (gnus-run-hooks 'gnus-tmp-internal-hook)
3816 (when gnus-display-mime-function
3817 (funcall gnus-display-mime-function))
3818 (gnus-run-hooks 'gnus-article-prepare-hook)))
3821 ;;; Gnus MIME viewing functions
3824 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
3825 "Format of the MIME buttons.
3827 Valid specifiers include:
3829 %T MIME type, along with additional info
3830 %n The `name' parameter
3831 %d The description, if any
3832 %l The length of the encoded part
3833 %p The part identifier number
3834 %e Dots if the part isn't displayed
3836 General format specifiers can also be used. See Info node
3837 `(gnus)Formatting Variables'.")
3839 (defvar gnus-mime-button-line-format-alist
3840 '((?t gnus-tmp-type ?s)
3841 (?T gnus-tmp-type-long ?s)
3842 (?n gnus-tmp-name ?s)
3843 (?d gnus-tmp-description ?s)
3845 (?l gnus-tmp-length ?d)
3846 (?e gnus-tmp-dots ?s)))
3848 (defvar gnus-mime-button-commands
3849 '((gnus-article-press-button "\r" "Toggle Display")
3850 (gnus-mime-view-part "v" "View Interactively...")
3851 (gnus-mime-view-part-as-type "t" "View As Type...")
3852 (gnus-mime-view-part-as-charset "C" "View As charset...")
3853 (gnus-mime-save-part "o" "Save...")
3854 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
3855 (gnus-mime-delete-part "d" "Delete part")
3856 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
3857 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
3858 (gnus-mime-view-part-internally "E" "View Internally")
3859 (gnus-mime-view-part-externally "e" "View Externally")
3860 (gnus-mime-print-part "p" "Print")
3861 (gnus-mime-pipe-part "|" "Pipe To Command...")
3862 (gnus-mime-action-on-part "." "Take action on the part...")))
3864 (defun gnus-article-mime-part-status ()
3865 (if gnus-article-mime-handle-alist-1
3866 (if (eq 1 (length gnus-article-mime-handle-alist-1))
3868 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
3871 (defvar gnus-mime-button-map
3872 (let ((map (make-sparse-keymap)))
3873 (unless (>= (string-to-number emacs-version) 21)
3874 ;; XEmacs doesn't care.
3875 (set-keymap-parent map gnus-article-mode-map))
3876 (define-key map gnus-mouse-2 'gnus-article-push-button)
3877 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
3878 (dolist (c gnus-mime-button-commands)
3879 (define-key map (cadr c) (car c)))
3883 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
3885 ,@(mapcar (lambda (c)
3886 (vector (caddr c) (car c) :enable t))
3887 gnus-mime-button-commands)))
3890 (define-compiler-macro popup-menu (&whole form
3891 menu &optional position prefix)
3892 (if (and (fboundp 'popup-menu)
3893 (not (memq 'popup-menu (assoc "lmenu" load-history))))
3895 ;; Gnus is probably running under Emacs 20.
3896 `(let* ((menu (cdr ,menu))
3897 (response (x-popup-menu
3899 (cons "" (mapcar (lambda (c)
3900 (cons (caddr c) (car c)))
3903 (call-interactively (nth 3 (assq response menu))))))))
3905 (defun gnus-mime-button-menu (event prefix)
3906 "Construct a context-sensitive menu of MIME commands."
3907 (interactive "e\nP")
3908 (save-window-excursion
3909 (let ((pos (event-start event)))
3910 (select-window (posn-window pos))
3911 (goto-char (posn-point pos))
3912 (gnus-article-check-buffer)
3913 (popup-menu gnus-mime-button-menu nil prefix))))
3915 (defun gnus-mime-view-all-parts (&optional handles)
3916 "View all the MIME parts."
3918 (save-current-buffer
3919 (set-buffer gnus-article-buffer)
3920 (let ((handles (or handles gnus-article-mime-handles))
3921 (mail-parse-charset gnus-newsgroup-charset)
3922 (mail-parse-ignored-charsets
3923 (with-current-buffer gnus-summary-buffer
3924 gnus-newsgroup-ignored-charsets)))
3926 (mm-remove-parts handles)
3927 (goto-char (point-min))
3928 (or (search-forward "\n\n") (goto-char (point-max)))
3929 (let (buffer-read-only)
3930 (delete-region (point) (point-max))
3931 (mm-display-parts handles))))))
3933 (defun gnus-mime-save-part-and-strip ()
3934 "Save the MIME part under point then replace it with an external body."
3936 (gnus-article-check-buffer)
3937 (let* ((data (get-text-property (point) 'gnus-data))
3939 (handles gnus-article-mime-handles))
3940 (if (mm-multiple-handles gnus-article-mime-handles)
3941 (error "This function is not implemented"))
3942 (setq file (and data (mm-save-part data)))
3944 (with-current-buffer (mm-handle-buffer data)
3946 (insert "Content-Type: " (mm-handle-media-type data))
3947 (mml-insert-parameter-string (cdr (mm-handle-type data))
3950 (insert "Content-ID: " (message-make-message-id) "\n")
3951 (insert "Content-Transfer-Encoding: binary\n")
3954 (cdr (mm-make-handle nil
3955 `("message/external-body"
3956 (access-type . "LOCAL-FILE")
3958 (set-buffer gnus-summary-buffer)
3959 (gnus-article-edit-article
3962 (let ((mail-parse-charset (or gnus-article-charset
3963 ',gnus-newsgroup-charset))
3964 (mail-parse-ignored-charsets
3965 (or gnus-article-ignored-charsets
3966 ',gnus-newsgroup-ignored-charsets))
3967 (mbl mml-buffer-list))
3968 (setq mml-buffer-list nil)
3969 (insert-buffer gnus-original-article-buffer)
3970 (mime-to-mml ',handles)
3971 (setq gnus-article-mime-handles nil)
3972 (let ((mbl1 mml-buffer-list))
3973 (setq mml-buffer-list mbl)
3974 (set (make-local-variable 'mml-buffer-list) mbl1))
3975 (gnus-make-local-hook 'kill-buffer-hook)
3976 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
3977 `(lambda (no-highlight)
3978 (let ((mail-parse-charset (or gnus-article-charset
3979 ',gnus-newsgroup-charset))
3980 (message-options message-options)
3981 (message-options-set-recipient)
3982 (mail-parse-ignored-charsets
3983 (or gnus-article-ignored-charsets
3984 ',gnus-newsgroup-ignored-charsets)))
3986 (mml-destroy-buffers)
3987 (remove-hook 'kill-buffer-hook
3988 'mml-destroy-buffers t)
3989 (kill-local-variable 'mml-buffer-list))
3990 (gnus-summary-edit-article-done
3991 ,(or (mail-header-references gnus-current-headers) "")
3992 ,(gnus-group-read-only-p)
3993 ,gnus-summary-buffer no-highlight))))))
3995 (defun gnus-mime-delete-part ()
3996 "Delete the MIME part under point.
3997 Replace it with some information about the removed part."
3999 (gnus-article-check-buffer)
4000 (unless (and gnus-novice-user
4001 (not (gnus-yes-or-no-p
4002 "Really delete attachment forever? ")))
4003 (let* ((data (get-text-property (point) 'gnus-data))
4004 (handles gnus-article-mime-handles)
4008 (mail-decode-encoded-word-string (or (mm-handle-description data)
4011 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4013 (type (mm-handle-media-type data)))
4014 (if (mm-multiple-handles gnus-article-mime-handles)
4015 (error "This function is not implemented"))
4016 (with-current-buffer (mm-handle-buffer data)
4017 (let ((bsize (format "%s" (buffer-size))))
4022 "| The following attachment has been deleted:\n"
4024 "| Type: " type "\n"
4025 "| Filename: " filename "\n"
4026 "| Size (encoded): " bsize " Byte\n"
4027 "| Description: " description "\n"
4030 (cdr (mm-make-handle
4031 nil `("text/plain") nil nil
4033 (format "Deleted attachment (%s bytes)" bsize))))))
4034 (set-buffer gnus-summary-buffer)
4035 ;; FIXME: maybe some of the following code (borrowed from
4036 ;; `gnus-mime-save-part-and-strip') isn't necessary?
4037 (gnus-article-edit-article
4040 (let ((mail-parse-charset (or gnus-article-charset
4041 ',gnus-newsgroup-charset))
4042 (mail-parse-ignored-charsets
4043 (or gnus-article-ignored-charsets
4044 ',gnus-newsgroup-ignored-charsets))
4045 (mbl mml-buffer-list))
4046 (setq mml-buffer-list nil)
4047 (insert-buffer gnus-original-article-buffer)
4048 (mime-to-mml ',handles)
4049 (setq gnus-article-mime-handles nil)
4050 (let ((mbl1 mml-buffer-list))
4051 (setq mml-buffer-list mbl)
4052 (set (make-local-variable 'mml-buffer-list) mbl1))
4053 (gnus-make-local-hook 'kill-buffer-hook)
4054 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4055 `(lambda (no-highlight)
4056 (let ((mail-parse-charset (or gnus-article-charset
4057 ',gnus-newsgroup-charset))
4058 (message-options message-options)
4059 (message-options-set-recipient)
4060 (mail-parse-ignored-charsets
4061 (or gnus-article-ignored-charsets
4062 ',gnus-newsgroup-ignored-charsets)))
4064 (mml-destroy-buffers)
4065 (remove-hook 'kill-buffer-hook
4066 'mml-destroy-buffers t)
4067 (kill-local-variable 'mml-buffer-list))
4068 (gnus-summary-edit-article-done
4069 ,(or (mail-header-references gnus-current-headers) "")
4070 ,(gnus-group-read-only-p)
4071 ,gnus-summary-buffer no-highlight)))))
4072 ;; Not in `gnus-mime-save-part-and-strip':
4073 (gnus-article-edit-done)
4074 (gnus-summary-expand-window)
4075 (gnus-summary-show-article))
4077 (defun gnus-mime-save-part ()
4078 "Save the MIME part under point."
4080 (gnus-article-check-buffer)
4081 (let ((data (get-text-property (point) 'gnus-data)))
4083 (mm-save-part data))))
4085 (defun gnus-mime-pipe-part ()
4086 "Pipe the MIME part under point to a process."
4088 (gnus-article-check-buffer)
4089 (let ((data (get-text-property (point) 'gnus-data)))
4091 (mm-pipe-part data))))
4093 (defun gnus-mime-view-part ()
4094 "Interactively choose a viewing method for the MIME part under point."
4096 (gnus-article-check-buffer)
4097 (let ((data (get-text-property (point) 'gnus-data)))
4099 (setq gnus-article-mime-handles
4101 gnus-article-mime-handles (setq data (copy-sequence data))))
4102 (mm-interactively-view-part data))))
4104 (defun gnus-mime-view-part-as-type-internal ()
4105 (gnus-article-check-buffer)
4106 (let* ((name (mail-content-type-get
4107 (mm-handle-type (get-text-property (point) 'gnus-data))
4109 (def-type (and name (mm-default-file-encoding name))))
4110 (and def-type (cons def-type 0))))
4112 (defun gnus-mime-view-part-as-type (&optional mime-type)
4113 "Choose a MIME media type, and view the part as such."
4116 (setq mime-type (completing-read
4117 "View as MIME type: "
4118 (mapcar #'list (mailcap-mime-types))
4120 (gnus-mime-view-part-as-type-internal))))
4121 (gnus-article-check-buffer)
4122 (let ((handle (get-text-property (point) 'gnus-data)))
4125 (mm-make-handle (mm-handle-buffer handle)
4126 (cons mime-type (cdr (mm-handle-type handle)))
4127 (mm-handle-encoding handle)
4128 (mm-handle-undisplayer handle)
4129 (mm-handle-disposition handle)
4130 (mm-handle-description handle)
4132 (mm-handle-id handle)))
4133 (setq gnus-article-mime-handles
4134 (mm-merge-handles gnus-article-mime-handles handle))
4135 (gnus-mm-display-part handle))))
4138 (require 'jka-compr))
4140 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4141 ;; emacs can do that itself.
4143 (defun gnus-mime-jka-compr-maybe-uncompress ()
4144 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4145 The uncompress method used is derived from `buffer-file-name'."
4146 (when (and (fboundp 'jka-compr-installed-p)
4147 (jka-compr-installed-p))
4148 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4150 (let ((basename (file-name-nondirectory buffer-file-name))
4151 (args (jka-compr-info-uncompress-args info))
4152 (prog (jka-compr-info-uncompress-program info))
4153 (message (jka-compr-info-uncompress-message info))
4154 (err-file (jka-compr-make-temp-name)))
4156 (message "%s %s..." message basename))
4158 (unless (memq (apply 'call-process-region
4159 (point-min) (point-max)
4161 t (list t err-file) nil
4163 jka-compr-acceptable-retval-list)
4164 (jka-compr-error prog args basename message err-file))
4165 (jka-compr-delete-temp-file err-file)))))))
4167 (defun gnus-mime-copy-part (&optional handle)
4168 "Put the MIME part under point into a new buffer.
4169 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4172 (gnus-article-check-buffer)
4173 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4174 (contents (and handle (mm-get-part handle)))
4176 (file-name-nondirectory
4178 (mail-content-type-get (mm-handle-type handle) 'name)
4179 (mail-content-type-get (mm-handle-disposition handle)
4182 (buffer (and base (generate-new-buffer base))))
4184 (switch-to-buffer buffer)
4186 ;; We do it this way to make `normal-mode' set the appropriate mode.
4189 (setq buffer-file-name (expand-file-name base))
4190 (gnus-mime-jka-compr-maybe-uncompress)
4192 (setq buffer-file-name nil))
4193 (goto-char (point-min)))))
4195 (defun gnus-mime-print-part (&optional handle filename)
4196 "Print the MIME part under point."
4197 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4198 (gnus-article-check-buffer)
4199 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4200 (contents (and handle (mm-get-part handle)))
4201 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4202 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4207 (mm-save-part-to-file handle file)
4208 (call-process shell-file-name nil
4209 (generate-new-buffer " *mm*")
4211 shell-command-switch
4213 printer file (mm-handle-type handle))))
4217 (gnus-print-buffer))
4218 (ps-despool filename)))))
4220 (defun gnus-mime-inline-part (&optional handle arg)
4221 "Insert the MIME part under point into the current buffer."
4222 (interactive (list nil current-prefix-arg))
4223 (gnus-article-check-buffer)
4224 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4229 (if (and (not arg) (mm-handle-undisplayer handle))
4230 (mm-remove-part handle)
4231 (setq contents (mm-get-part handle))
4234 (setq charset (or (mail-content-type-get
4235 (mm-handle-type handle) 'charset)
4236 gnus-newsgroup-charset)))
4238 (if (mm-handle-undisplayer handle)
4239 (mm-remove-part handle))
4242 gnus-summary-show-article-charset-alist))
4243 (mm-read-coding-system "Charset: ")))))
4245 (mm-insert-inline handle
4247 (setq charset (mm-charset-to-coding-system
4249 (not (eq charset 'ascii)))
4250 (mm-decode-coding-string contents charset)
4254 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4255 "Insert the MIME part under point into the current buffer using the
4257 (interactive (list nil current-prefix-arg))
4258 (gnus-article-check-buffer)
4259 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4264 (if (mm-handle-undisplayer handle)
4265 (mm-remove-part handle))
4266 (let ((gnus-newsgroup-charset
4268 gnus-summary-show-article-charset-alist))
4269 (mm-read-coding-system "Charset: ")))
4270 (gnus-newsgroup-ignored-charsets 'gnus-all))
4271 (gnus-article-press-button)))))
4273 (defun gnus-mime-view-part-externally (&optional handle)
4274 "View the MIME part under point with an external viewer."
4276 (gnus-article-check-buffer)
4277 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4278 (mm-user-display-methods nil)
4279 (mm-inlined-types nil)
4280 (mail-parse-charset gnus-newsgroup-charset)
4281 (mail-parse-ignored-charsets
4282 (save-excursion (set-buffer gnus-summary-buffer)
4283 gnus-newsgroup-ignored-charsets)))
4285 (if (mm-handle-undisplayer handle)
4286 (mm-remove-part handle)
4287 (mm-display-part handle)))))
4289 (defun gnus-mime-view-part-internally (&optional handle)
4290 "View the MIME part under point with an internal viewer.
4291 If no internal viewer is available, use an external viewer."
4293 (gnus-article-check-buffer)
4294 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4295 (mm-inlined-types '(".*"))
4296 (mm-inline-large-images t)
4297 (mail-parse-charset gnus-newsgroup-charset)
4298 (mail-parse-ignored-charsets
4299 (save-excursion (set-buffer gnus-summary-buffer)
4300 gnus-newsgroup-ignored-charsets))
4303 (if (mm-handle-undisplayer handle)
4304 (mm-remove-part handle)
4305 (mm-display-part handle)))))
4307 (defun gnus-mime-action-on-part (&optional action)
4308 "Do something with the MIME attachment at \(point\)."
4310 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4311 (gnus-article-check-buffer)
4312 (let ((action-pair (assoc action gnus-mime-action-alist)))
4314 (funcall (cdr action-pair)))))
4316 (defun gnus-article-part-wrapper (n function)
4317 (save-current-buffer
4318 (set-buffer gnus-article-buffer)
4319 (when (> n (length gnus-article-mime-handle-alist))
4320 (error "No such part"))
4321 (gnus-article-goto-part n)
4322 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4323 (funcall function handle))))
4325 (defun gnus-article-pipe-part (n)
4326 "Pipe MIME part N, which is the numerical prefix."
4328 (gnus-article-part-wrapper n 'mm-pipe-part))
4330 (defun gnus-article-save-part (n)
4331 "Save MIME part N, which is the numerical prefix."
4333 (gnus-article-part-wrapper n 'mm-save-part))
4335 (defun gnus-article-interactively-view-part (n)
4336 "View MIME part N interactively, which is the numerical prefix."
4338 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4340 (defun gnus-article-copy-part (n)
4341 "Copy MIME part N, which is the numerical prefix."
4343 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4345 (defun gnus-article-view-part-as-charset (n)
4346 "View MIME part N using a specified charset.
4347 N is the numerical prefix."
4349 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4351 (defun gnus-article-view-part-externally (n)
4352 "View MIME part N externally, which is the numerical prefix."
4354 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4356 (defun gnus-article-inline-part (n)
4357 "Inline MIME part N, which is the numerical prefix."
4359 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4361 (defun gnus-article-mime-match-handle-first (condition)
4363 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4364 (while (setq ihandle (pop alist))
4366 ((functionp condition)
4367 (funcall condition (cdr ihandle)))
4368 ((eq condition 'undisplayed)
4369 (not (or (mm-handle-undisplayer (cdr ihandle))
4370 (equal (mm-handle-media-type (cdr ihandle))
4371 "multipart/alternative"))))
4372 ((eq condition 'undisplayed-alternative)
4373 (not (mm-handle-undisplayer (cdr ihandle))))
4375 (gnus-article-goto-part (car ihandle))
4376 (or (not n) (< (car ihandle) n)))
4377 (setq n (car ihandle))))
4381 (defun gnus-article-view-part (&optional n)
4382 "View MIME part N, which is the numerical prefix."
4384 (save-current-buffer
4385 (set-buffer gnus-article-buffer)
4386 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4387 gnus-article-mime-match-handle-function)))
4388 (when (> n (length gnus-article-mime-handle-alist))
4389 (error "No such part"))
4390 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4391 (when (gnus-article-goto-part n)
4392 (if (equal (car handle) "multipart/alternative")
4393 (gnus-article-press-button)
4394 (when (eq (gnus-mm-display-part handle) 'internal)
4395 (gnus-set-window-start)))))))
4397 (defsubst gnus-article-mime-total-parts ()
4398 (if (bufferp (car gnus-article-mime-handles))
4400 (1- (length gnus-article-mime-handles))))
4402 (defun gnus-mm-display-part (handle)
4403 "Display HANDLE and fix MIME button."
4404 (let ((id (get-text-property (point) 'gnus-part))
4409 (let ((window (selected-window))
4410 (mail-parse-charset gnus-newsgroup-charset)
4411 (mail-parse-ignored-charsets
4412 (if (gnus-buffer-live-p gnus-summary-buffer)
4414 (set-buffer gnus-summary-buffer)
4415 gnus-newsgroup-ignored-charsets)
4419 (let ((win (gnus-get-buffer-window (current-buffer) t))
4422 (select-window win))
4425 (if (mm-handle-displayed-p handle)
4426 ;; This will remove the part.
4427 (mm-display-part handle)
4429 (narrow-to-region (point)
4430 (if (eobp) (point) (1+ (point))))
4431 (mm-display-part handle)
4432 ;; We narrow to the part itself and
4433 ;; then call the treatment functions.
4434 (goto-char (point-min))
4436 (narrow-to-region (point) (point-max))
4439 (gnus-article-mime-total-parts)
4440 (mm-handle-media-type handle)))))
4441 (if (window-live-p window)
4442 (select-window window)))))
4445 (gnus-insert-mime-button
4446 handle id (list (mm-handle-displayed-p handle)))
4447 (goto-char point))))
4449 (defun gnus-article-goto-part (n)
4450 "Go to MIME part N."
4451 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4453 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4454 (let ((gnus-tmp-name
4455 (or (mail-content-type-get (mm-handle-type handle) 'name)
4456 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4457 (mail-content-type-get (mm-handle-type handle) 'url)
4459 (gnus-tmp-type (mm-handle-media-type handle))
4460 (gnus-tmp-description
4461 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4464 (if (if displayed (car displayed)
4465 (mm-handle-displayed-p handle))
4467 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4469 gnus-tmp-type-long b e)
4470 (when (string-match ".*/" gnus-tmp-name)
4471 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4472 (setq gnus-tmp-type-long (concat gnus-tmp-type
4473 (and (not (equal gnus-tmp-name ""))
4474 (concat "; " gnus-tmp-name))))
4475 (unless (equal gnus-tmp-description "")
4476 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4481 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4482 `(,@(gnus-local-map-property gnus-mime-button-map)
4483 gnus-callback gnus-mm-display-part
4484 gnus-part ,gnus-tmp-id
4485 article-type annotation
4488 ;; Exclude a newline.
4491 (widget-convert-button
4494 :action 'gnus-widget-press-button
4495 :button-keymap gnus-mime-button-map
4497 (lambda (widget/window &optional overlay pos)
4498 ;; Needed to properly clear the message due to a bug in
4499 ;; wid-edit (XEmacs only).
4500 (if (boundp 'help-echo-owns-message)
4501 (setq help-echo-owns-message t))
4503 "%S: %s the MIME part; %S: more options"
4504 (aref gnus-mouse-2 0)
4505 ;; XEmacs will get a single widget arg; Emacs 21 will get
4506 ;; window, overlay, position.
4507 (if (mm-handle-displayed-p
4509 (with-current-buffer (gnus-overlay-buffer overlay)
4510 (widget-get (widget-at (gnus-overlay-start overlay))
4512 (widget-get widget/window :mime-handle)))
4514 (aref gnus-down-mouse-3 0))))))
4516 (defun gnus-widget-press-button (elems el)
4517 (goto-char (widget-get elems :from))
4518 (gnus-article-press-button))
4520 (defvar gnus-displaying-mime nil)
4522 (defun gnus-display-mime (&optional ihandles)
4523 "Display the MIME parts."
4525 (save-selected-window
4526 (let ((window (get-buffer-window gnus-article-buffer))
4529 (select-window window)
4530 ;; We have to do this since selecting the window
4531 ;; may change the point. So we set the window point.
4532 (set-window-point window point)))
4533 (let* ((handles (or ihandles
4534 (mm-dissect-buffer nil gnus-article-loose-mime)
4535 (and gnus-article-emulate-mime
4537 buffer-read-only handle name type b e display)
4538 (when (and (not ihandles)
4539 (not gnus-displaying-mime))
4540 ;; Top-level call; we clean up.
4541 (when gnus-article-mime-handles
4542 (mm-destroy-parts gnus-article-mime-handles)
4543 (setq gnus-article-mime-handle-alist nil));; A trick.
4544 (setq gnus-article-mime-handles handles)
4545 ;; We allow users to glean info from the handles.
4546 (when gnus-article-mime-part-function
4547 (gnus-mime-part-function handles)))
4549 (or (not (stringp (car handles)))
4552 (when (and (not ihandles)
4553 (not gnus-displaying-mime))
4554 ;; Clean up for mime parts.
4556 (delete-region (point) (point-max)))
4557 (let ((gnus-displaying-mime t))
4558 (gnus-mime-display-part handles)))
4561 (narrow-to-region (point) (point-max))
4562 (gnus-treat-article nil 1 1)
4565 ;; Highlight the headers.
4569 (narrow-to-region (point-min) (point))
4570 (gnus-treat-article 'head))))))))
4572 (defcustom gnus-mime-display-multipart-as-mixed nil
4573 "Display \"multipart\" parts as \"multipart/mixed\".
4575 If t, it overrides nil values of
4576 `gnus-mime-display-multipart-alternative-as-mixed' and
4577 `gnus-mime-display-multipart-related-as-mixed'."
4578 :group 'gnus-article-mime
4581 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4582 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4583 :group 'gnus-article-mime
4586 (defcustom gnus-mime-display-multipart-related-as-mixed nil