1 ;;; gnus-art.el --- article mode commands for Gnus
3 ;; Copyright (C) 1996-2012 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 3 of the License, or
13 ;; (at your option) any later version.
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. If not, see <http://www.gnu.org/licenses/>.
27 ;; For Emacs <22.2 and XEmacs.
29 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
33 (defvar w3m-minor-mode-map)
50 (autoload 'gnus-msg-mail "gnus-msg" nil t)
51 (autoload 'gnus-button-mailto "gnus-msg")
52 (autoload 'gnus-button-reply "gnus-msg" nil t)
53 (autoload 'parse-time-string "parse-time" nil nil)
54 (autoload 'ansi-color-apply-on-region "ansi-color")
55 (autoload 'mm-url-insert-file-contents-external "mm-url")
56 (autoload 'mm-extern-cache-contents "mm-extern")
58 (defgroup gnus-article nil
60 :link '(custom-manual "(gnus)Article Buffer")
63 (defgroup gnus-article-treat nil
64 "Treating article parts."
65 :link '(custom-manual "(gnus)Article Hiding")
68 (defgroup gnus-article-hiding nil
69 "Hiding article parts."
70 :link '(custom-manual "(gnus)Article Hiding")
73 (defgroup gnus-article-highlight nil
74 "Article highlighting."
75 :link '(custom-manual "(gnus)Article Highlighting")
79 (defgroup gnus-article-signature nil
81 :link '(custom-manual "(gnus)Article Signature")
84 (defgroup gnus-article-headers nil
86 :link '(custom-manual "(gnus)Hiding Headers")
89 (defgroup gnus-article-washing nil
90 "Special commands on articles."
91 :link '(custom-manual "(gnus)Article Washing")
94 (defgroup gnus-article-emphasis nil
95 "Fontisizing articles."
96 :link '(custom-manual "(gnus)Article Fontisizing")
99 (defgroup gnus-article-saving nil
101 :link '(custom-manual "(gnus)Saving Articles")
102 :group 'gnus-article)
104 (defgroup gnus-article-mime nil
105 "Worshiping the MIME wonder."
106 :link '(custom-manual "(gnus)Using MIME")
107 :group 'gnus-article)
109 (defgroup gnus-article-buttons nil
110 "Pushable buttons in the article buffer."
111 :link '(custom-manual "(gnus)Article Buttons")
112 :group 'gnus-article)
114 (defgroup gnus-article-various nil
115 "Other article options."
116 :link '(custom-manual "(gnus)Misc Article")
117 :group 'gnus-article)
119 (defcustom gnus-ignored-headers
122 (concat "^" header ":"))
123 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
124 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
125 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
126 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
127 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
128 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
129 "X-Attribution" "X-Originating-IP" "Delivered-To"
130 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
131 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
132 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
133 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
134 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
135 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
136 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
137 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
138 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
139 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
140 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
141 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
142 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
143 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
144 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
145 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
146 "List-[A-Za-z]+" "X-Listprocessor-Version"
147 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
148 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
149 "X-Received" "Content-length" "X-precedence"
150 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
151 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
152 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
153 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
154 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
155 "X-Content-length" "X-Posting-Agent" "Original-Received"
156 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
157 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
158 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
159 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
160 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"
161 "Envelope-To" "X-Spam-Score" "System-Type" "X-Injected-Via-Gmane"
162 "X-Gmane-NNTP-Posting-Host" "Jabber-ID" "Archived-At"
163 "Envelope-Sender" "Envelope-Recipients"))
164 "*All headers that start with this regexp will be hidden.
165 This variable can also be a list of regexps of headers to be ignored.
166 If `gnus-visible-headers' is non-nil, this variable will be ignored."
167 :type '(choice regexp
169 :group 'gnus-article-hiding)
171 (defcustom gnus-visible-headers
172 "^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:"
173 "*All headers that do not match this regexp will be hidden.
174 This variable can also be a list of regexp of headers to remain visible.
175 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
177 (repeat :value-to-internal (lambda (widget value)
178 (custom-split-regexp-maybe value))
179 :match (lambda (widget value)
181 (widget-editable-list-match widget value)))
183 (const :tag "Use gnus-ignored-headers" nil)
185 :group 'gnus-article-hiding)
187 (defcustom gnus-sorted-header-list
188 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
189 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
190 "*This variable is a list of regular expressions.
191 If it is non-nil, headers that match the regular expressions will
192 be placed first in the article buffer in the sequence specified by
194 :type '(repeat regexp)
195 :group 'gnus-article-hiding)
197 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
198 "Headers that are only to be displayed if they have interesting data.
199 Possible values in this list are:
201 'empty Headers with no content.
202 'newsgroups Newsgroup identical to Gnus group.
203 'to-address To identical to To-address.
204 'to-list To identical to To-list.
205 'cc-list CC identical to To-list.
206 'followup-to Followup-to identical to Newsgroups.
207 'reply-to Reply-to identical to From.
208 'date Date less than four days old.
209 'long-to To and/or Cc longer than 1024 characters.
210 'many-to Multiple To and/or Cc."
211 :type '(set (const :tag "Headers with no content." empty)
212 (const :tag "Newsgroups identical to Gnus group." newsgroups)
213 (const :tag "To identical to To-address." to-address)
214 (const :tag "To identical to To-list." to-list)
215 (const :tag "CC identical to To-list." cc-list)
216 (const :tag "Followup-to identical to Newsgroups." followup-to)
217 (const :tag "Reply-to identical to From." reply-to)
218 (const :tag "Date less than four days old." date)
219 (const :tag "To and/or Cc longer than 1024 characters." long-to)
220 (const :tag "Multiple To and/or Cc headers." many-to))
221 :group 'gnus-article-hiding)
223 (defcustom gnus-article-skip-boring nil
224 "Skip over text that is not worth reading.
225 By default, if you set this t, then Gnus will display citations and
226 signatures, but will never scroll down to show you a page consisting
227 only of boring text. Boring text is controlled by
228 `gnus-article-boring-faces'."
231 :group 'gnus-article-hiding)
233 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
234 "Regexp matching signature separator.
235 This can also be a list of regexps. In that case, it will be checked
236 from head to tail looking for a separator. Searches will be done from
237 the end of the buffer."
238 :type '(choice :format "%{%t%}: %[Value Menu%]\n%v"
240 (repeat :tag "List of regexp" regexp))
241 :group 'gnus-article-signature)
243 (defcustom gnus-signature-limit nil
244 "Provide a limit to what is considered a signature.
245 If it is a number, no signature may not be longer (in characters) than
246 that number. If it is a floating point number, no signature may be
247 longer (in lines) than that number. If it is a function, the function
248 will be called without any parameters, and if it returns nil, there is
249 no signature in the buffer. If it is a string, it will be used as a
250 regexp. If it matches, the text in question is not a signature.
252 This can also be a list of the above values."
253 :type '(choice (const nil)
257 (regexp :value ".*"))
258 :group 'gnus-article-signature)
260 (defcustom gnus-hidden-properties '(invisible t intangible t)
261 "Property list to use for hiding text."
263 :group 'gnus-article-hiding)
265 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
266 ;; frames in a session.
267 (defcustom gnus-article-x-face-command
268 (if (featurep 'xemacs)
269 (if (or (gnus-image-type-available-p 'xface)
270 (gnus-image-type-available-p 'pbm))
271 'gnus-display-x-face-in-from
273 '/* Format_version=1, Width=48, Height=48, Depth=1, Valid_bits_per_item=16 */'\
274 ; uncompface; } | icontopbm | ee -")
275 (if (gnus-image-type-available-p 'pbm)
276 'gnus-display-x-face-in-from
278 '/* Format_version=1, Width=48, Height=48, Depth=1, Valid_bits_per_item=16 */'\
279 ; uncompface; } | icontopbm | display -"))
280 "*String or function to be executed to display an X-Face header.
281 If it is a string, the command will be executed in a sub-shell
282 asynchronously. The compressed face will be piped to this command."
283 :type `(choice string
284 (function-item gnus-display-x-face-in-from)
288 :group 'gnus-article-washing)
290 (defcustom gnus-article-x-face-too-ugly nil
291 "Regexp matching posters whose face shouldn't be shown automatically."
292 :type '(choice regexp (const nil))
293 :group 'gnus-article-washing)
295 (defcustom gnus-article-banner-alist nil
296 "Banner alist for stripping.
298 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
300 :type '(repeat (cons symbol regexp))
301 :group 'gnus-article-washing)
303 (gnus-define-group-parameter
306 "Alist of regexps (to match group names) and banner."
307 :variable-group gnus-article-washing
309 '(choice :tag "Banner"
311 (const :tag "Remove signature" signature)
312 (symbol :tag "Item in `gnus-article-banner-alist'" none)
314 (const :tag "None" nil))
316 "If non-nil, specify how to remove `banners' from articles.
318 Symbol `signature' means to remove signatures delimited by
319 `gnus-signature-separator'. Any other symbol is used to look up a
320 regular expression to match the banner in `gnus-article-banner-alist'.
321 A string is used as a regular expression to match the banner
324 (defcustom gnus-article-address-banner-alist nil
325 "Alist of mail addresses and banners.
326 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
327 to match a mail address in the From: header, BANNER is one of a symbol
328 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
329 If ADDRESS matches author's mail address, it will remove things like
330 advertisements. For example:
332 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
336 (regexp :tag "Address")
337 (choice :tag "Banner" :value nil
338 (const :tag "Remove signature" signature)
339 (symbol :tag "Item in `gnus-article-banner-alist'" none)
341 (const :tag "None" nil))))
343 :group 'gnus-article-washing)
345 (defmacro gnus-emphasis-custom-with-format (&rest body)
347 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
348 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
351 (defun gnus-emphasis-custom-value-to-external (value)
352 (gnus-emphasis-custom-with-format
353 (if (consp (car value))
354 (list (format format (car (car value)) (cdr (car value)))
356 (if (nth 1 value) 2 3)
360 (defun gnus-emphasis-custom-value-to-internal (value)
361 (gnus-emphasis-custom-with-format
362 (let ((regexp (concat "\\`"
363 (format (regexp-quote format)
364 "\\([^()]+\\)" "\\([^()]+\\)")
367 (if (string-match regexp (setq pattern (car value)))
368 (list (cons (match-string 1 pattern) (match-string 2 pattern))
373 (defcustom gnus-emphasis-alist
375 '(("\\*" "\\*" bold nil 2)
378 ("_/" "/_" underline-italic)
379 ("_\\*" "\\*_" underline-bold)
380 ("\\*/" "/\\*" bold-italic)
381 ("_\\*/" "/\\*_" underline-bold-italic))))
383 (gnus-emphasis-custom-with-format
384 (mapcar (lambda (spec)
385 (list (format format (car spec) (cadr spec))
388 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
390 '(;; I've never seen anyone use this strikethru convention whereas I've
391 ;; several times seen it triggered by normal text. --Stef
392 ;; Miles suggests that this form is sometimes used but for italics,
393 ;; so maybe we should map it to `italic'.
394 ;; ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
395 ;; 2 3 gnus-emphasis-strikethru)
396 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
397 2 3 gnus-emphasis-underline))))
398 "*Alist that says how to fontify certain phrases.
399 Each item looks like this:
401 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
403 The first element is a regular expression to be matched. The second
404 is a number that says what regular expression grouping used to find
405 the entire emphasized word. The third is a number that says what
406 regexp grouping should be displayed and highlighted. The fourth
407 is the face used for highlighting."
411 :format "%[Customizing Style%]\n%v"
413 (group :tag "Default"
414 :value ("" 0 0 default)
417 (let ((value (widget-get
418 (cadr (widget-get (widget-get widget :parent)
421 (if (not (eq (nth 2 value) 'default))
425 (gnus-emphasis-custom-value-to-external value))))
426 (widget-group-value-create widget))
428 (integer :format "Match group: %v")
429 (integer :format "Emphasize group: %v")
432 :value (("_" . "_") nil default)
434 (regexp :format "Start regexp: %v")
435 (regexp :format "End regexp: %v"))
436 (boolean :format "Show start and end patterns: %[%v%]\n"
437 :on " On " :off " Off ")
439 :get (lambda (symbol)
440 (mapcar 'gnus-emphasis-custom-value-to-internal
441 (default-value symbol)))
442 :set (lambda (symbol value)
443 (set-default symbol (mapcar 'gnus-emphasis-custom-value-to-external
445 :group 'gnus-article-emphasis)
447 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
448 "A regexp to describe whitespace which should not be emphasized.
449 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
450 The former avoids underlining of leading and trailing whitespace,
451 and the latter avoids underlining any whitespace at all."
453 :group 'gnus-article-emphasis
456 (defface gnus-emphasis-bold '((t (:bold t)))
457 "Face used for displaying strong emphasized text (*word*)."
458 :group 'gnus-article-emphasis)
460 (defface gnus-emphasis-italic '((t (:italic t)))
461 "Face used for displaying italic emphasized text (/word/)."
462 :group 'gnus-article-emphasis)
464 (defface gnus-emphasis-underline '((t (:underline t)))
465 "Face used for displaying underlined emphasized text (_word_)."
466 :group 'gnus-article-emphasis)
468 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
469 "Face used for displaying underlined bold emphasized text (_*word*_)."
470 :group 'gnus-article-emphasis)
472 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
473 "Face used for displaying underlined italic emphasized text (_/word/_)."
474 :group 'gnus-article-emphasis)
476 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
477 "Face used for displaying bold italic emphasized text (/*word*/)."
478 :group 'gnus-article-emphasis)
480 (defface gnus-emphasis-underline-bold-italic
481 '((t (:bold t :italic t :underline t)))
482 "Face used for displaying underlined bold italic emphasized text.
483 Example: (_/*word*/_)."
484 :group 'gnus-article-emphasis)
486 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
487 '((t (:strikethru t)))
488 '((t (:strike-through t))))
489 "Face used for displaying strike-through text (-word-)."
490 :group 'gnus-article-emphasis)
492 (defface gnus-emphasis-highlight-words
493 '((t (:background "black" :foreground "yellow")))
494 "Face used for displaying highlighted words."
495 :group 'gnus-article-emphasis)
497 (defcustom gnus-article-time-format "%a, %d %b %Y %T %Z"
498 "Format for display of Date headers in article bodies.
499 See `format-time-string' for the possible values.
501 The variable can also be function, which should return a complete Date
502 header. The function is called with one argument, the time, which can
503 be fed to `format-time-string'."
504 :type '(choice string function)
505 :link '(custom-manual "(gnus)Article Date")
506 :group 'gnus-article-washing)
508 (defcustom gnus-save-all-headers t
509 "*If non-nil, don't remove any headers before saving.
510 This will be overridden by the `:headers' property that the symbol of
511 the saver function, which is specified by `gnus-default-article-saver',
513 :group 'gnus-article-saving
516 (defcustom gnus-prompt-before-saving 'always
517 "*This variable says how much prompting is to be done when saving articles.
518 If it is nil, no prompting will be done, and the articles will be
519 saved to the default files. If this variable is `always', each and
520 every article that is saved will be preceded by a prompt, even when
521 saving large batches of articles. If this variable is neither nil not
522 `always', there the user will be prompted once for a file name for
523 each invocation of the saving commands."
524 :group 'gnus-article-saving
525 :type '(choice (item always)
526 (item :tag "never" nil)
527 (sexp :tag "once" :format "%t\n" :value t)))
529 (defcustom gnus-saved-headers gnus-visible-headers
530 "Headers to keep if `gnus-save-all-headers' is nil.
531 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
532 If that variable is nil, however, all headers that match this regexp
533 will be kept while the rest will be deleted before saving. This and
534 `gnus-save-all-headers' will be overridden by the `:headers' property
535 that the symbol of the saver function, which is specified by
536 `gnus-default-article-saver', might have."
537 :group 'gnus-article-saving
540 ;; Note that "Rmail format" is mbox since Emacs 23, but Babyl before.
541 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
542 "A function to save articles in your favorite format.
543 The function will be called by way of the `gnus-summary-save-article'
544 command, and friends such as `gnus-summary-save-article-rmail'.
546 Gnus provides the following functions:
548 * gnus-summary-save-in-rmail (Rmail format)
549 * gnus-summary-save-in-mail (Unix mail format)
550 * gnus-summary-save-in-folder (MH folder)
551 * gnus-summary-save-in-file (article format)
552 * gnus-summary-save-body-in-file (article body)
553 * gnus-summary-save-in-vm (use VM's folder format)
554 * gnus-summary-write-to-file (article format -- overwrite)
555 * gnus-summary-write-body-to-file (article body -- overwrite)
556 * gnus-summary-save-in-pipe (article format)
558 The symbol of each function may have the following properties:
561 The value non-nil means save decoded articles. This is meaningful
562 only with `gnus-summary-save-in-file', `gnus-summary-save-body-in-file',
563 `gnus-summary-write-to-file', `gnus-summary-write-body-to-file', and
564 `gnus-summary-save-in-pipe'.
567 The value specifies an alternative function which appends, not
568 overwrites, articles to a file. This implies that when saving many
569 articles at a time, `gnus-prompt-before-saving' is bound to t and all
570 articles are saved in a single file. This is meaningful only with
571 `gnus-summary-write-to-file' and `gnus-summary-write-body-to-file'.
574 The value specifies the symbol of a variable of which the value
575 specifies headers to be saved. If it is omitted,
576 `gnus-save-all-headers' and `gnus-saved-headers' control what
577 headers should be saved."
578 :group 'gnus-article-saving
579 :type '(radio (function-item gnus-summary-save-in-rmail)
580 (function-item gnus-summary-save-in-mail)
581 (function-item gnus-summary-save-in-folder)
582 (function-item gnus-summary-save-in-file)
583 (function-item gnus-summary-save-body-in-file)
584 (function-item gnus-summary-save-in-vm)
585 (function-item gnus-summary-write-to-file)
586 (function-item gnus-summary-write-body-to-file)
587 (function-item gnus-summary-save-in-pipe)
590 (defcustom gnus-article-save-coding-system
591 (or (and (mm-coding-system-p 'utf-8) 'utf-8)
592 (and (mm-coding-system-p 'iso-2022-7bit) 'iso-2022-7bit)
593 (and (mm-coding-system-p 'emacs-mule) 'emacs-mule)
594 (and (mm-coding-system-p 'escape-quoted) 'escape-quoted))
595 "Coding system used to save decoded articles to a file.
597 The recommended coding systems are `utf-8', `iso-2022-7bit' and so on,
598 which can safely encode any characters in text. This is used by the
601 * gnus-summary-save-article-file
602 * gnus-summary-save-article-body-file
603 * gnus-summary-write-article-file
604 * gnus-summary-write-article-body-file
606 and the functions to which you may set `gnus-default-article-saver':
608 * gnus-summary-save-in-file
609 * gnus-summary-save-body-in-file
610 * gnus-summary-write-to-file
611 * gnus-summary-write-body-to-file
613 Those commands and functions save just text displayed in the article
614 buffer to a file if the value of this variable is non-nil. Note that
615 buttonized MIME parts will be lost in a saved file in that case.
616 Otherwise, raw articles will be saved."
617 :group 'gnus-article-saving
619 :format "%{%t%}:\n %[Value Menu%] %v"
620 (const :tag "Save raw articles" nil)
623 (lambda (arg) (if (mm-coding-system-p (nth 3 arg)) arg))
624 '((const :tag "UTF-8" utf-8)
625 (const :tag "iso-2022-7bit" iso-2022-7bit)
626 (const :tag "Emacs internal" emacs-mule)
627 (const :tag "escape-quoted" escape-quoted))))
628 (symbol :tag "Coding system")))
630 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
631 "A function generating a file name to save articles in Rmail format.
632 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
633 :group 'gnus-article-saving
636 (defcustom gnus-mail-save-name 'gnus-plain-save-name
637 "A function generating a file name to save articles in Unix mail format.
638 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
639 :group 'gnus-article-saving
642 (defcustom gnus-folder-save-name 'gnus-folder-save-name
643 "A function generating a file name to save articles in MH folder.
644 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
645 :group 'gnus-article-saving
648 (defcustom gnus-file-save-name 'gnus-numeric-save-name
649 "A function generating a file name to save articles in article format.
650 The function is called with NEWSGROUP, HEADERS, and optional
652 :group 'gnus-article-saving
655 (defcustom gnus-split-methods
656 '((gnus-article-archive-name)
657 (gnus-article-nndoc-name))
658 "*Variable used to suggest where articles are to be saved.
659 For instance, if you would like to save articles related to Gnus in
660 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
661 you could set this variable to something like:
663 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
664 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
666 This variable is an alist where the key is the match and the
667 value is a list of possible files to save in if the match is
670 If the match is a string, it is used as a regexp match on the
671 article. If the match is a symbol, that symbol will be funcalled
672 from the buffer of the article to be saved with the newsgroup as the
673 parameter. If it is a list, it will be evalled in the same buffer.
675 If this form or function returns a string, this string will be used as a
676 possible file name; and if it returns a non-nil list, that list will be
677 used as possible file names."
678 :group 'gnus-article-saving
679 :type '(repeat (choice (list :value (fun) function)
680 (cons :value ("" "") regexp (repeat string))
683 (defcustom gnus-page-delimiter "^\^L"
684 "*Regexp describing what to use as article page delimiters.
685 The default value is \"^\^L\", which is a form linefeed at the
686 beginning of a line."
688 :group 'gnus-article-various)
690 (defcustom gnus-article-mode-line-format "Gnus: %g %S%m"
691 "*The format specification for the article mode line.
692 See `gnus-summary-mode-line-format' for a closer description.
694 The following additional specs are available:
696 %w The article washing status.
697 %m The number of MIME parts in the article."
700 :group 'gnus-article-various)
702 (defcustom gnus-article-mode-hook nil
703 "*A hook for Gnus article mode."
705 :group 'gnus-article-various)
707 (when (featurep 'xemacs)
708 ;; Extracted from gnus-xmas-define in order to preserve user settings
709 (when (fboundp 'turn-off-scroll-in-place)
710 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
711 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
712 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
714 (defcustom gnus-article-menu-hook nil
715 "*Hook run after the creation of the article mode menu."
717 :group 'gnus-article-various)
719 (defcustom gnus-article-prepare-hook nil
720 "*A hook called after an article has been prepared in the article buffer."
722 :group 'gnus-article-various)
724 (defcustom gnus-copy-article-ignored-headers nil
725 "List of headers to be removed when copying an article.
726 Each element is a regular expression."
727 :version "23.1" ;; No Gnus
728 :type '(repeat regexp)
729 :group 'gnus-article-various)
731 (make-obsolete-variable 'gnus-article-hide-pgp-hook nil
732 "Gnus 5.10 (Emacs 22.1)")
735 '((t (:weight bold)))
736 "Face used for highlighting a button in the article buffer."
737 :group 'gnus-article-buttons)
739 (defcustom gnus-article-button-face 'gnus-button
740 "Face used for highlighting buttons in the article buffer.
742 An article button is a piece of text that you can activate by pressing
743 `RET' or `mouse-2' above it."
745 :group 'gnus-article-buttons)
747 (defcustom gnus-article-mouse-face 'highlight
748 "Face used for mouse highlighting in the article buffer.
750 Article buttons will be displayed in this face when the cursor is
753 :group 'gnus-article-buttons)
755 (defcustom gnus-signature-face 'gnus-signature
756 "Face used for highlighting a signature in the article buffer.
757 Obsolete; use the face `gnus-signature' for customizations instead."
759 :group 'gnus-article-highlight
760 :group 'gnus-article-signature)
762 (defface gnus-signature
765 "Face used for highlighting a signature in the article buffer."
766 :group 'gnus-article-highlight
767 :group 'gnus-article-signature)
768 ;; backward-compatibility alias
769 (put 'gnus-signature-face 'face-alias 'gnus-signature)
770 (put 'gnus-signature-face 'obsolete-face "22.1")
772 (defface gnus-header-from
775 (:foreground "PaleGreen1"))
778 (:foreground "red3"))
781 "Face used for displaying from headers."
782 :group 'gnus-article-headers
783 :group 'gnus-article-highlight)
784 ;; backward-compatibility alias
785 (put 'gnus-header-from-face 'face-alias 'gnus-header-from)
786 (put 'gnus-header-from-face 'obsolete-face "22.1")
788 (defface gnus-header-subject
791 (:foreground "SeaGreen1"))
794 (:foreground "red4"))
796 (:bold t :italic t)))
797 "Face used for displaying subject headers."
798 :group 'gnus-article-headers
799 :group 'gnus-article-highlight)
800 ;; backward-compatibility alias
801 (put 'gnus-header-subject-face 'face-alias 'gnus-header-subject)
802 (put 'gnus-header-subject-face 'obsolete-face "22.1")
804 (defface gnus-header-newsgroups
807 (:foreground "yellow" :italic t))
810 (:foreground "MidnightBlue" :italic t))
813 "Face used for displaying newsgroups headers.
814 In the default setup this face is only used for crossposted
816 :group 'gnus-article-headers
817 :group 'gnus-article-highlight)
818 ;; backward-compatibility alias
819 (put 'gnus-header-newsgroups-face 'face-alias 'gnus-header-newsgroups)
820 (put 'gnus-header-newsgroups-face 'obsolete-face "22.1")
822 (defface gnus-header-name
825 (:foreground "SpringGreen2"))
828 (:foreground "maroon"))
831 "Face used for displaying header names."
832 :group 'gnus-article-headers
833 :group 'gnus-article-highlight)
834 ;; backward-compatibility alias
835 (put 'gnus-header-name-face 'face-alias 'gnus-header-name)
836 (put 'gnus-header-name-face 'obsolete-face "22.1")
838 (defface gnus-header-content
841 (:foreground "SpringGreen1" :italic t))
844 (:foreground "indianred4" :italic t))
846 (:italic t))) "Face used for displaying header content."
847 :group 'gnus-article-headers
848 :group 'gnus-article-highlight)
849 ;; backward-compatibility alias
850 (put 'gnus-header-content-face 'face-alias 'gnus-header-content)
851 (put 'gnus-header-content-face 'obsolete-face "22.1")
853 (defcustom gnus-header-face-alist
854 '(("From" nil gnus-header-from)
855 ("Subject" nil gnus-header-subject)
856 ("Newsgroups:.*," nil gnus-header-newsgroups)
857 ("" gnus-header-name gnus-header-content))
858 "*Controls highlighting of article headers.
860 An alist of the form (HEADER NAME CONTENT).
862 HEADER is a regular expression which should match the name of a
863 header and NAME and CONTENT are either face names or nil.
865 The name of each header field will be displayed using the face
866 specified by the first element in the list where HEADER matches
867 the header name and NAME is non-nil. Similarly, the content will
868 be displayed by the first non-nil matching CONTENT face."
869 :group 'gnus-article-headers
870 :group 'gnus-article-highlight
871 :type '(repeat (list (regexp :tag "Header")
873 (item :tag "skip" nil)
874 (face :value default))
875 (choice :tag "Content"
876 (item :tag "skip" nil)
877 (face :value default)))))
879 (defcustom gnus-face-properties-alist (if (featurep 'xemacs)
880 '((xface . (:face gnus-x-face)))
881 '((pbm . (:face gnus-x-face))
883 "Alist of image types and properties applied to Face and X-Face images.
886 ;; Specify the altitude of Face images in the From header.
887 \(setq gnus-face-properties-alist
888 '((pbm . (:face gnus-x-face :ascent 80))
889 (png . (:ascent 80))))
891 ;; Show Face images as pressed buttons.
892 \(setq gnus-face-properties-alist
893 '((pbm . (:face gnus-x-face :relief -2))
894 (png . (:relief -2))))
896 See the manual for the valid properties for various image types.
897 Currently, `pbm' is used for X-Face images and `png' is used for Face
898 images in Emacs. Only the `:face' property is effective on the `xface'
899 image type in XEmacs if it is built with the libcompface library."
900 :version "23.1" ;; No Gnus
901 :group 'gnus-article-headers
902 :type '(repeat (cons :format "%v" (symbol :tag "Image type") plist)))
904 (defcustom gnus-article-decode-hook
905 '(article-decode-charset article-decode-encoded-words
906 article-decode-group-name article-decode-idna-rhs)
907 "*Hook run to decode charsets in articles."
908 :group 'gnus-article-headers
911 (defcustom gnus-display-mime-function 'gnus-display-mime
912 "Function to display MIME articles."
913 :group 'gnus-article-mime
916 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
917 "Function used to decode headers.")
919 (defvar gnus-decode-address-function 'mail-decode-encoded-address-region
920 "Function used to decode addresses.")
922 (defvar gnus-article-dumbquotes-map
942 "Table for MS-to-Latin1 translation.")
944 (defcustom gnus-ignored-mime-types nil
945 "List of MIME types that should be ignored by Gnus."
947 :group 'gnus-article-mime
948 :type '(repeat regexp))
950 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
951 "List of MIME types that should not be given buttons when rendered inline.
952 See also `gnus-buttonized-mime-types' which may override this variable.
953 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
955 :group 'gnus-article-mime
956 :type '(repeat regexp))
958 (defcustom gnus-buttonized-mime-types nil
959 "List of MIME types that should be given buttons when rendered inline.
960 If set, this variable overrides `gnus-unbuttonized-mime-types'.
961 To see e.g. security buttons you could set this to
962 `(\"multipart/signed\")'. You could also add \"multipart/alternative\" to
963 this list to display radio buttons that allow you to choose one of two
964 media types those mails include. See also `mm-discouraged-alternatives'.
965 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
967 :group 'gnus-article-mime
968 :type '(repeat regexp))
970 (defcustom gnus-inhibit-mime-unbuttonizing nil
971 "If non-nil, all MIME parts get buttons.
972 When nil (the default value), then some MIME parts do not get buttons,
973 as described by the variables `gnus-buttonized-mime-types' and
974 `gnus-unbuttonized-mime-types'."
976 :group 'gnus-article-mime
979 (defcustom gnus-body-boundary-delimiter "_"
980 "String used to delimit header and body.
981 This variable is used by `gnus-article-treat-body-boundary' which can
982 be controlled by `gnus-treat-body-boundary'."
984 :group 'gnus-article-various
985 :type '(choice (item :tag "None" :value nil)
988 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
990 "Defines the location of the faces database.
991 For information on obtaining this database of pretty pictures, please
992 see http://www.cs.indiana.edu/picons/ftp/index.html"
994 :type '(repeat directory)
995 :link '(url-link :tag "download"
996 "http://www.cs.indiana.edu/picons/ftp/index.html")
997 :link '(custom-manual "(gnus)Picons")
1000 (defun gnus-picons-installed-p ()
1001 "Say whether picons are installed on your machine."
1002 (let ((installed nil))
1003 (dolist (database gnus-picon-databases)
1004 (when (file-exists-p database)
1005 (setq installed t)))
1008 (defcustom gnus-article-mime-part-function nil
1009 "Function called with a MIME handle as the argument.
1010 This is meant for people who want to do something automatic based
1011 on parts -- for instance, adding Vcard info to a database."
1012 :group 'gnus-article-mime
1013 :type '(choice (const nil)
1016 (defcustom gnus-mime-multipart-functions nil
1017 "An alist of MIME types to functions to display them."
1019 :group 'gnus-article-mime
1020 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
1022 (defcustom gnus-article-date-headers '(combined-lapsed)
1023 "A list of Date header formats to display.
1024 Valid formats are `ut' (universal time), `local' (local time
1025 zone), `english' (readable English), `lapsed' (elapsed time),
1026 `combined-lapsed' (both the original date and the elapsed time),
1027 `original' (the original date header), `iso8601' (ISO8601
1028 format), and `user-defined' (a user-defined format defined by the
1029 `gnus-article-time-format' variable).
1031 You have as many date headers as you want in the article buffer.
1032 Some of these headers are updated automatically. See
1033 `gnus-article-update-date-headers' for details."
1035 :group 'gnus-article-headers
1037 (item :tag "Universal time (UT)" :value 'ut)
1038 (item :tag "Local time zone" :value 'local)
1039 (item :tag "Readable English" :value 'english)
1040 (item :tag "Elapsed time" :value 'lapsed)
1041 (item :tag "Original and elapsed time" :value 'combined-lapsed)
1042 (item :tag "Original date header" :value 'original)
1043 (item :tag "ISO8601 format" :value 'iso8601)
1044 (item :tag "User-defined" :value 'user-defined)))
1046 (defcustom gnus-article-update-date-headers nil
1047 "A number that says how often to update the date header (in seconds).
1048 If nil, don't update it at all."
1050 :group 'gnus-article-headers
1052 (item :tag "Don't update" :value nil)
1055 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
1056 "Function called with a MIME handle as the argument.
1057 This is meant for people who want to view first matched part.
1058 For `undisplayed-alternative' (default), the first undisplayed
1059 part or alternative part is used. For `undisplayed', the first
1060 undisplayed part is used. For a function, the first part which
1061 the function return t is used. For nil, the first part is
1064 :group 'gnus-article-mime
1066 (item :tag "first" :value nil)
1067 (item :tag "undisplayed" :value undisplayed)
1068 (item :tag "undisplayed or alternative"
1069 :value undisplayed-alternative)
1072 (defcustom gnus-mime-action-alist
1073 '(("save to file" . gnus-mime-save-part)
1074 ("save and strip" . gnus-mime-save-part-and-strip)
1075 ("replace with file" . gnus-mime-replace-part)
1076 ("delete part" . gnus-mime-delete-part)
1077 ("display as text" . gnus-mime-inline-part)
1078 ("view the part" . gnus-mime-view-part)
1079 ("pipe to command" . gnus-mime-pipe-part)
1080 ("toggle display" . gnus-article-press-button)
1081 ("toggle display" . gnus-article-view-part-as-charset)
1082 ("view as type" . gnus-mime-view-part-as-type)
1083 ("view internally" . gnus-mime-view-part-internally)
1084 ("view externally" . gnus-mime-view-part-externally))
1085 "An alist of actions that run on the MIME attachment."
1086 :group 'gnus-article-mime
1087 :type '(repeat (cons (string :tag "name")
1090 (defcustom gnus-auto-select-part 1
1091 "Advance to next MIME part when deleting or stripping parts.
1093 When 0, point will be placed on the same part as before. When
1094 positive (negative), move point forward (backwards) this many
1095 parts. When nil, redisplay article."
1096 :version "23.1" ;; No Gnus
1097 :group 'gnus-article-mime
1098 :type '(choice (const nil :tag "Redisplay article.")
1099 (const 1 :tag "Next part.")
1100 (const 0 :tag "Current part.")
1104 ;;; The treatment variables
1107 (defvar gnus-part-display-hook nil
1108 "Hook called on parts that are to receive treatment.")
1110 (defvar gnus-article-treat-custom
1111 '(choice (const :tag "Off" nil)
1113 (const :tag "Header" head)
1114 (const :tag "First" first)
1115 (const :tag "Last" last)
1116 (integer :tag "Less")
1117 (repeat :tag "Groups" regexp)
1118 (sexp :tag "Predicate")))
1120 (defvar gnus-article-treat-head-custom
1121 '(choice (const :tag "Off" nil)
1122 (const :tag "Header" head)))
1124 (defvar gnus-article-treat-types '("text/plain" "text/x-verbatim"
1125 "text/x-patch" "text/html")
1126 "Part types eligible for treatment.")
1128 (defvar gnus-inhibit-treatment nil
1129 "Whether to inhibit treatment.")
1131 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
1132 "Highlight the signature.
1133 Valid values are nil, t, `head', `first', `last', an integer or a
1134 predicate. See Info node `(gnus)Customizing Articles'."
1135 :group 'gnus-article-treat
1136 :link '(custom-manual "(gnus)Customizing Articles")
1137 :type gnus-article-treat-custom)
1138 (put 'gnus-treat-highlight-signature 'highlight t)
1140 (defcustom gnus-treat-buttonize 100000
1142 Valid values are nil, t, `head', `first', `last', an integer or a
1143 predicate. See Info node `(gnus)Customizing Articles'."
1144 :group 'gnus-article-treat
1145 :link '(custom-manual "(gnus)Customizing Articles")
1146 :type gnus-article-treat-custom)
1147 (put 'gnus-treat-buttonize 'highlight t)
1149 (defcustom gnus-treat-buttonize-head 'head
1150 "Add buttons to the head.
1151 Valid values are nil, t, `head', `first', `last', an integer or a
1152 predicate. See Info node `(gnus)Customizing Articles'."
1153 :group 'gnus-article-treat
1154 :link '(custom-manual "(gnus)Customizing Articles")
1155 :type gnus-article-treat-head-custom)
1156 (put 'gnus-treat-buttonize-head 'highlight t)
1158 (defcustom gnus-treat-date 'head
1159 "Display dates according to the `gnus-article-date-headers' variable.
1160 Valid values are nil, t, `head', `first', `last', an integer or a
1161 predicate. See Info node `(gnus)Customizing Articles'."
1163 :group 'gnus-article-treat
1164 :link '(custom-manual "(gnus)Customizing Articles")
1165 :type gnus-article-treat-head-custom)
1167 (defcustom gnus-treat-emphasize 50000
1169 Valid values are nil, t, `head', `first', `last', an integer or a
1170 predicate. See Info node `(gnus)Customizing Articles'."
1171 :group 'gnus-article-treat
1172 :link '(custom-manual "(gnus)Customizing Articles")
1173 :type gnus-article-treat-custom)
1174 (put 'gnus-treat-emphasize 'highlight t)
1176 (defcustom gnus-treat-strip-cr nil
1177 "Remove carriage returns.
1178 Valid values are nil, t, `head', `first', `last', an integer or a
1179 predicate. See Info node `(gnus)Customizing Articles'."
1181 :group 'gnus-article-treat
1182 :link '(custom-manual "(gnus)Customizing Articles")
1183 :type gnus-article-treat-custom)
1185 (defcustom gnus-treat-unsplit-urls nil
1186 "Remove newlines from within URLs.
1187 Valid values are nil, t, `head', `first', `last', an integer or a
1188 predicate. See Info node `(gnus)Customizing Articles'."
1190 :group 'gnus-article-treat
1191 :link '(custom-manual "(gnus)Customizing Articles")
1192 :type gnus-article-treat-custom)
1194 (defcustom gnus-treat-leading-whitespace nil
1195 "Remove leading whitespace in headers.
1196 Valid values are nil, t, `head', `first', `last', an integer or a
1197 predicate. See Info node `(gnus)Customizing Articles'."
1199 :group 'gnus-article-treat
1200 :link '(custom-manual "(gnus)Customizing Articles")
1201 :type gnus-article-treat-custom)
1203 (defcustom gnus-treat-hide-headers 'head
1205 Valid values are nil, t, `head', `first', `last', an integer or a
1206 predicate. See Info node `(gnus)Customizing Articles'."
1207 :group 'gnus-article-treat
1208 :link '(custom-manual "(gnus)Customizing Articles")
1209 :type gnus-article-treat-head-custom)
1211 (defcustom gnus-treat-hide-boring-headers nil
1212 "Hide boring headers.
1213 Valid values are nil, t, `head', `first', `last', an integer or a
1214 predicate. See Info node `(gnus)Customizing Articles'."
1215 :group 'gnus-article-treat
1216 :link '(custom-manual "(gnus)Customizing Articles")
1217 :type gnus-article-treat-head-custom)
1219 (defcustom gnus-treat-hide-signature nil
1220 "Hide the signature.
1221 Valid values are nil, t, `head', `first', `last', an integer or a
1222 predicate. See Info node `(gnus)Customizing Articles'."
1223 :group 'gnus-article-treat
1224 :link '(custom-manual "(gnus)Customizing Articles")
1225 :type gnus-article-treat-custom)
1227 (defcustom gnus-treat-fill-article nil
1229 Valid values are nil, t, `head', `first', `last', an integer or a
1230 predicate. See Info node `(gnus)Customizing Articles'."
1231 :group 'gnus-article-treat
1232 :link '(custom-manual "(gnus)Customizing Articles")
1233 :type gnus-article-treat-custom)
1235 (defcustom gnus-treat-hide-citation nil
1237 Valid values are nil, t, `head', `first', `last', an integer or a
1238 predicate. See Info node `(gnus)Customizing Articles'.
1240 See `gnus-article-highlight-citation' for variables used to
1241 control what it hides."
1242 :group 'gnus-article-treat
1243 :link '(custom-manual "(gnus)Customizing Articles")
1244 :type gnus-article-treat-custom)
1246 (defcustom gnus-treat-hide-citation-maybe nil
1247 "Hide cited text according to certain conditions.
1248 Valid values are nil, t, `head', `first', `last', an integer or a
1249 predicate. See Info node `(gnus)Customizing Articles'.
1251 See `gnus-cite-hide-percentage' and `gnus-cite-hide-absolute' for
1252 how to control what it hides."
1253 :group 'gnus-article-treat
1254 :link '(custom-manual "(gnus)Customizing Articles")
1255 :type gnus-article-treat-custom)
1257 (defcustom gnus-treat-strip-list-identifiers 'head
1258 "Strip list identifiers from `gnus-list-identifiers`.
1259 Valid values are nil, t, `head', `first', `last', an integer or a
1260 predicate. See Info node `(gnus)Customizing Articles'."
1262 :group 'gnus-article-treat
1263 :link '(custom-manual "(gnus)Customizing Articles")
1264 :type gnus-article-treat-custom)
1266 (gnus-define-group-parameter
1269 "Alist of regexps and correspondent identifiers."
1270 :variable-group gnus-article-washing
1272 '(choice :tag "Identifier"
1274 (symbol :tag "Item in `gnus-list-identifiers'" none)
1276 (const :tag "None" nil))
1278 "If non-nil, specify how to remove `identifiers' from articles' subject.
1280 Any symbol is used to look up a regular expression to match the
1281 banner in `gnus-list-identifiers'. A string is used as a regular
1282 expression to match the identifier directly.")
1284 (make-obsolete-variable 'gnus-treat-strip-pgp nil
1285 "Gnus 5.10 (Emacs 22.1)")
1287 (defcustom gnus-treat-strip-pem nil
1288 "Strip PEM signatures.
1289 Valid values are nil, t, `head', `first', `last', an integer or a
1290 predicate. See Info node `(gnus)Customizing Articles'."
1291 :group 'gnus-article-treat
1292 :link '(custom-manual "(gnus)Customizing Articles")
1293 :type gnus-article-treat-custom)
1295 (defcustom gnus-treat-strip-banner t
1296 "Strip banners from articles.
1297 The banner to be stripped is specified in the `banner' group parameter.
1298 Valid values are nil, t, `head', `first', `last', an integer or a
1299 predicate. See Info node `(gnus)Customizing Articles'."
1300 :group 'gnus-article-treat
1301 :link '(custom-manual "(gnus)Customizing Articles")
1302 :type gnus-article-treat-custom)
1304 (defcustom gnus-treat-highlight-headers 'head
1305 "Highlight the headers.
1306 Valid values are nil, t, `head', `first', `last', an integer or a
1307 predicate. See Info node `(gnus)Customizing Articles'."
1308 :group 'gnus-article-treat
1309 :link '(custom-manual "(gnus)Customizing Articles")
1310 :type gnus-article-treat-head-custom)
1311 (put 'gnus-treat-highlight-headers 'highlight t)
1313 (defcustom gnus-treat-highlight-citation t
1314 "Highlight cited text.
1315 Valid values are nil, t, `head', `first', `last', an integer or a
1316 predicate. See Info node `(gnus)Customizing Articles'."
1317 :group 'gnus-article-treat
1318 :link '(custom-manual "(gnus)Customizing Articles")
1319 :type gnus-article-treat-custom)
1320 (put 'gnus-treat-highlight-citation 'highlight t)
1322 (defcustom gnus-treat-strip-headers-in-body t
1323 "Strip the X-No-Archive header line from the beginning of the body.
1324 Valid values are nil, t, `head', `first', `last', an integer or a
1325 predicate. See Info node `(gnus)Customizing Articles'."
1327 :group 'gnus-article-treat
1328 :link '(custom-manual "(gnus)Customizing Articles")
1329 :type gnus-article-treat-custom)
1331 (defcustom gnus-treat-strip-trailing-blank-lines nil
1332 "Strip trailing blank lines.
1333 Valid values are nil, t, `head', `first', `last', an integer or a
1334 predicate. See Info node `(gnus)Customizing Articles'.
1336 When set to t, it also strips trailing blanks in all MIME parts.
1337 Consider to use `last' instead."
1338 :group 'gnus-article-treat
1339 :link '(custom-manual "(gnus)Customizing Articles")
1340 :type gnus-article-treat-custom)
1342 (defcustom gnus-treat-strip-leading-blank-lines nil
1343 "Strip leading blank lines.
1344 Valid values are nil, t, `head', `first', `last', an integer or a
1345 predicate. See Info node `(gnus)Customizing Articles'.
1347 When set to t, it also strips trailing blanks in all MIME parts."
1348 :group 'gnus-article-treat
1349 :link '(custom-manual "(gnus)Customizing Articles")
1350 :type gnus-article-treat-custom)
1352 (defcustom gnus-treat-strip-multiple-blank-lines nil
1353 "Strip multiple blank lines.
1354 Valid values are nil, t, `head', `first', `last', an integer or a
1355 predicate. See Info node `(gnus)Customizing Articles'."
1356 :group 'gnus-article-treat
1357 :link '(custom-manual "(gnus)Customizing Articles")
1358 :type gnus-article-treat-custom)
1360 (defcustom gnus-treat-unfold-headers 'head
1361 "Unfold folded header lines.
1362 Valid values are nil, t, `head', `first', `last', an integer or a
1363 predicate. See Info node `(gnus)Customizing Articles'."
1365 :group 'gnus-article-treat
1366 :link '(custom-manual "(gnus)Customizing Articles")
1367 :type gnus-article-treat-custom)
1369 (defcustom gnus-article-unfold-long-headers nil
1370 "If non-nil, allow unfolding headers even if the header is long.
1371 If it is a regexp, only long headers matching this regexp are unfolded.
1372 If it is t, all long headers are unfolded.
1374 This variable has no effect if `gnus-treat-unfold-headers' is nil."
1375 :version "23.1" ;; No Gnus
1376 :group 'gnus-article-treat
1377 :type '(choice (const nil)
1378 (const :tag "all" t)
1381 (defcustom gnus-treat-fold-headers nil
1383 Valid values are nil, t, `head', `first', `last', an integer or a
1384 predicate. See Info node `(gnus)Customizing Articles'."
1386 :group 'gnus-article-treat
1387 :link '(custom-manual "(gnus)Customizing Articles")
1388 :type gnus-article-treat-custom)
1390 (defcustom gnus-treat-fold-newsgroups 'head
1391 "Fold the Newsgroups and Followup-To headers.
1392 Valid values are nil, t, `head', `first', `last', an integer or a
1393 predicate. See Info node `(gnus)Customizing Articles'."
1395 :group 'gnus-article-treat
1396 :link '(custom-manual "(gnus)Customizing Articles")
1397 :type gnus-article-treat-custom)
1399 (defcustom gnus-treat-overstrike t
1400 "Treat overstrike highlighting.
1401 Valid values are nil, t, `head', `first', `last', an integer or a
1402 predicate. See Info node `(gnus)Customizing Articles'."
1403 :group 'gnus-article-treat
1404 :link '(custom-manual "(gnus)Customizing Articles")
1405 :type gnus-article-treat-custom)
1406 (put 'gnus-treat-overstrike 'highlight t)
1408 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1409 "Treat ANSI SGR control sequences.
1410 Valid values are nil, t, `head', `first', `last', an integer or a
1411 predicate. See Info node `(gnus)Customizing Articles'."
1412 :group 'gnus-article-treat
1413 :link '(custom-manual "(gnus)Customizing Articles")
1414 :type gnus-article-treat-custom)
1416 (make-obsolete-variable 'gnus-treat-display-xface
1417 'gnus-treat-display-x-face "Emacs 22.1")
1419 (defcustom gnus-treat-display-x-face
1420 (and (not noninteractive)
1421 (gnus-image-type-available-p 'xbm)
1422 (if (featurep 'xemacs)
1425 (and (string-match "^0x" (shell-command-to-string "uncompface"))
1426 (executable-find "icontopbm"))
1427 ;; shell-command-to-string may signal an error, e.g. if
1428 ;; shell-file-name is not found.
1431 "Display X-Face headers.
1432 Valid values are nil and `head'.
1433 See Info node `(gnus)Customizing Articles' and Info node
1434 `(gnus)X-Face' for details."
1435 :group 'gnus-article-treat
1437 :link '(custom-manual "(gnus)Customizing Articles")
1438 :link '(custom-manual "(gnus)X-Face")
1439 :type gnus-article-treat-head-custom
1440 :set (lambda (symbol value)
1443 (cond ((or (boundp symbol) (get symbol 'saved-value))
1445 ((boundp 'gnus-treat-display-xface)
1447 ** gnus-treat-display-xface is an obsolete variable;\
1448 use gnus-treat-display-x-face instead")
1449 (default-value 'gnus-treat-display-xface))
1450 ((get 'gnus-treat-display-xface 'saved-value)
1452 ** gnus-treat-display-xface is an obsolete variable;\
1453 use gnus-treat-display-x-face instead")
1454 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1457 (put 'gnus-treat-display-x-face 'highlight t)
1459 (defcustom gnus-treat-display-face
1460 (and (not noninteractive)
1461 (gnus-image-type-available-p 'png)
1463 "Display Face headers.
1464 Valid values are nil, t, `head', `first', `last', an integer or a
1465 predicate. See Info node `(gnus)Customizing Articles' and Info
1466 node `(gnus)Face' for details."
1467 :group 'gnus-article-treat
1469 :link '(custom-manual "(gnus)Customizing Articles")
1470 :link '(custom-manual "(gnus)X-Face")
1471 :type gnus-article-treat-head-custom)
1472 (put 'gnus-treat-display-face 'highlight t)
1474 (defcustom gnus-treat-display-smileys (gnus-image-type-available-p 'xpm)
1476 Valid values are nil, t, `head', `first', `last', an integer or a
1477 predicate. See Info node `(gnus)Customizing Articles' and Info
1478 node `(gnus)Smileys' for details."
1479 :group 'gnus-article-treat
1481 :link '(custom-manual "(gnus)Customizing Articles")
1482 :link '(custom-manual "(gnus)Smileys")
1483 :type gnus-article-treat-custom)
1484 (put 'gnus-treat-display-smileys 'highlight t)
1486 (defcustom gnus-treat-from-picon
1487 (if (and (gnus-image-type-available-p 'xpm)
1488 (gnus-picons-installed-p))
1490 "Display picons in the From header.
1491 Valid values are nil, t, `head', `first', `last', an integer or a
1492 predicate. See Info node `(gnus)Customizing Articles' and Info
1493 node `(gnus)Picons' for details."
1495 :group 'gnus-article-treat
1497 :link '(custom-manual "(gnus)Customizing Articles")
1498 :link '(custom-manual "(gnus)Picons")
1499 :type gnus-article-treat-head-custom)
1500 (put 'gnus-treat-from-picon 'highlight t)
1502 (defcustom gnus-treat-mail-picon
1503 (if (and (gnus-image-type-available-p 'xpm)
1504 (gnus-picons-installed-p))
1506 "Display picons in To and Cc headers.
1507 Valid values are nil, t, `head', `first', `last', an integer or a
1508 predicate. See Info node `(gnus)Customizing Articles' and Info
1509 node `(gnus)Picons' for details."
1511 :group 'gnus-article-treat
1513 :link '(custom-manual "(gnus)Customizing Articles")
1514 :link '(custom-manual "(gnus)Picons")
1515 :type gnus-article-treat-head-custom)
1516 (put 'gnus-treat-mail-picon 'highlight t)
1518 (defcustom gnus-treat-newsgroups-picon
1519 (if (and (gnus-image-type-available-p 'xpm)
1520 (gnus-picons-installed-p))
1522 "Display picons in the Newsgroups and Followup-To headers.
1523 Valid values are nil, t, `head', `first', `last', an integer or a
1524 predicate. See Info node `(gnus)Customizing Articles' and Info
1525 node `(gnus)Picons' for details."
1527 :group 'gnus-article-treat
1529 :link '(custom-manual "(gnus)Customizing Articles")
1530 :link '(custom-manual "(gnus)Picons")
1531 :type gnus-article-treat-head-custom)
1532 (put 'gnus-treat-newsgroups-picon 'highlight t)
1534 (defcustom gnus-treat-from-gravatar nil
1535 "Display gravatars in the From header.
1536 Valid values are nil, t, `head', `first', `last', an integer or a
1537 predicate. See Info node `(gnus)Customizing Articles' and Info
1538 node `(gnus)Gravatars' for details."
1540 :group 'gnus-article-treat
1541 :group 'gnus-gravatar
1542 :link '(custom-manual "(gnus)Customizing Articles")
1543 :link '(custom-manual "(gnus)Gravatars")
1544 :type gnus-article-treat-head-custom)
1545 (put 'gnus-treat-from-gravatar 'highlight t)
1547 (defcustom gnus-treat-mail-gravatar nil
1548 "Display gravatars in To and Cc headers.
1549 Valid values are nil, t, `head', `first', `last', an integer or a
1550 predicate. See Info node `(gnus)Customizing Articles' and Info
1551 node `(gnus)Gravatars' for details."
1553 :group 'gnus-article-treat
1554 :group 'gnus-gravatar
1555 :link '(custom-manual "(gnus)Customizing Articles")
1556 :link '(custom-manual "(gnus)Gravatars")
1557 :type gnus-article-treat-head-custom)
1558 (put 'gnus-treat-mail-gravatar 'highlight t)
1560 (defcustom gnus-treat-body-boundary
1561 (if (or gnus-treat-newsgroups-picon
1562 gnus-treat-mail-picon
1563 gnus-treat-from-picon
1564 gnus-treat-from-gravatar
1565 gnus-treat-mail-gravatar)
1566 ;; If there's much decoration, the user might prefer a boundary.
1569 "Draw a boundary at the end of the headers.
1570 Valid values are nil and `head'.
1571 See Info node `(gnus)Customizing Articles' for details."
1573 :group 'gnus-article-treat
1574 :link '(custom-manual "(gnus)Customizing Articles")
1575 :type gnus-article-treat-head-custom)
1577 (defcustom gnus-treat-capitalize-sentences nil
1578 "Capitalize sentence-starting words.
1579 Valid values are nil, t, `head', `first', `last', an integer or a
1580 predicate. See Info node `(gnus)Customizing Articles'."
1582 :group 'gnus-article-treat
1583 :link '(custom-manual "(gnus)Customizing Articles")
1584 :type gnus-article-treat-custom)
1586 (defcustom gnus-treat-wash-html nil
1588 Valid values are nil, t, `head', `first', `last', an integer or a
1589 predicate. See Info node `(gnus)Customizing Articles'."
1591 :group 'gnus-article-treat
1592 :link '(custom-manual "(gnus)Customizing Articles")
1593 :type gnus-article-treat-custom)
1595 (defcustom gnus-treat-fill-long-lines '(typep "text/plain")
1597 Valid values are nil, t, `head', `first', `last', an integer or a
1598 predicate. See Info node `(gnus)Customizing Articles'."
1600 :group 'gnus-article-treat
1601 :link '(custom-manual "(gnus)Customizing Articles")
1602 :type gnus-article-treat-custom)
1604 (defcustom gnus-treat-x-pgp-sig nil
1606 To automatically treat X-PGP-Sig, set it to head.
1607 Valid values are nil, t, `head', `first', `last', an integer or a
1608 predicate. See Info node `(gnus)Customizing Articles'."
1610 :group 'gnus-article-treat
1611 :group 'mime-security
1612 :link '(custom-manual "(gnus)Customizing Articles")
1613 :type gnus-article-treat-custom)
1615 (defvar gnus-article-encrypt-protocol-alist
1616 '(("PGP" . mml2015-self-encrypt)))
1618 ;; Set to nil if more than one protocol added to
1619 ;; gnus-article-encrypt-protocol-alist.
1620 (defcustom gnus-article-encrypt-protocol "PGP"
1621 "The protocol used for encrypt articles.
1622 It is a string, such as \"PGP\". If nil, ask user."
1625 :group 'mime-security)
1627 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1628 (mm-coding-system-p 'utf-8)
1629 (executable-find idna-program))
1630 "Whether IDNA decoding of headers is used when viewing messages.
1631 This requires GNU Libidn, and by default only enabled if it is found."
1633 :group 'gnus-article-headers
1636 (defcustom gnus-article-over-scroll nil
1637 "If non-nil, allow scrolling the article buffer even when there no more text."
1639 :group 'gnus-article
1642 (defcustom gnus-inhibit-images nil
1643 "Non-nil means inhibit displaying of images inline in the article body."
1645 :group 'gnus-article
1648 (defcustom gnus-blocked-images 'gnus-block-private-groups
1649 "Images that have URLs matching this regexp will be blocked.
1650 This can also be a function to be evaluated. If so, it will be
1651 called with the group name as the parameter, and should return a
1657 ;;; Internal variables
1659 (defvar gnus-english-month-names
1660 '("January" "February" "March" "April" "May" "June" "July" "August"
1661 "September" "October" "November" "December"))
1663 (defvar article-goto-body-goes-to-point-min-p nil)
1664 (defvar gnus-article-wash-types nil)
1665 (defvar gnus-article-emphasis-alist nil)
1666 (defvar gnus-article-image-alist nil)
1668 (defvar gnus-article-mime-handle-alist-1 nil)
1669 (defvar gnus-treatment-function-alist
1670 '((gnus-treat-strip-cr gnus-article-remove-cr)
1671 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1672 (gnus-treat-strip-banner gnus-article-strip-banner)
1673 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1674 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1675 (gnus-treat-buttonize gnus-article-add-buttons)
1676 (gnus-treat-fill-article gnus-article-fill-cited-article)
1677 (gnus-treat-fill-long-lines gnus-article-fill-cited-long-lines)
1678 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1679 (gnus-treat-display-x-face gnus-article-display-x-face)
1680 (gnus-treat-display-face gnus-article-display-face)
1681 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1682 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1683 (gnus-treat-hide-signature gnus-article-hide-signature)
1684 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1685 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1686 (gnus-treat-from-picon gnus-treat-from-picon)
1687 (gnus-treat-mail-picon gnus-treat-mail-picon)
1688 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1689 (gnus-treat-strip-pem gnus-article-hide-pem)
1690 (gnus-treat-date gnus-article-treat-date)
1691 (gnus-treat-from-gravatar gnus-treat-from-gravatar)
1692 (gnus-treat-mail-gravatar gnus-treat-mail-gravatar)
1693 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1694 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1695 (gnus-treat-strip-trailing-blank-lines
1696 gnus-article-remove-trailing-blank-lines)
1697 (gnus-treat-strip-leading-blank-lines
1698 gnus-article-strip-leading-blank-lines)
1699 (gnus-treat-strip-multiple-blank-lines
1700 gnus-article-strip-multiple-blank-lines)
1701 (gnus-treat-overstrike gnus-article-treat-overstrike)
1702 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1703 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1704 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1705 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1706 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1707 (gnus-treat-display-smileys gnus-treat-smiley)
1708 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1709 (gnus-treat-wash-html gnus-article-wash-html)
1710 (gnus-treat-emphasize gnus-article-emphasize)
1711 (gnus-treat-hide-citation gnus-article-hide-citation)
1712 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1713 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1714 (gnus-treat-body-boundary gnus-article-treat-body-boundary)))
1716 (defvar gnus-article-mime-handle-alist nil)
1717 (defvar article-lapsed-timer nil)
1718 (defvar gnus-article-current-summary nil)
1720 (defvar gnus-article-mode-syntax-table
1721 (let ((table (copy-syntax-table text-mode-syntax-table)))
1722 ;; This causes the citation match run O(2^n).
1723 ;; (modify-syntax-entry ?- "w" table)
1724 (modify-syntax-entry ?> ")<" table)
1725 (modify-syntax-entry ?< "(>" table)
1726 ;; make M-. in article buffers work for `foo' strings
1727 (modify-syntax-entry ?' " " table)
1728 (modify-syntax-entry ?` " " table)
1730 "Syntax table used in article mode buffers.
1731 Initialized from `text-mode-syntax-table.")
1733 (defvar gnus-save-article-buffer nil)
1735 (defvar gnus-number-of-articles-to-be-saved nil)
1737 (defvar gnus-inhibit-hiding nil)
1739 (defvar gnus-article-edit-mode nil)
1741 ;;; Macros for dealing with the article buffer.
1743 (defmacro gnus-with-article-headers (&rest forms)
1744 `(with-current-buffer gnus-article-buffer
1746 (let ((inhibit-read-only t)
1747 (inhibit-point-motion-hooks t)
1748 (case-fold-search t))
1749 (article-narrow-to-head)
1752 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1753 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1755 (defmacro gnus-with-article-buffer (&rest forms)
1756 `(when (buffer-live-p (get-buffer gnus-article-buffer))
1757 (with-current-buffer gnus-article-buffer
1758 (let ((inhibit-read-only t))
1761 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1762 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1764 (defun gnus-article-goto-header (header)
1765 "Go to HEADER, which is a regular expression."
1766 (re-search-forward (concat "^\\(" header "\\):") nil t))
1768 (defsubst gnus-article-hide-text (b e props)
1769 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1770 (gnus-add-text-properties-when 'article-type nil b e props)
1771 (when (memq 'intangible props)
1773 (max (1- b) (point-min))
1774 b 'intangible (cddr (memq 'intangible props)))))
1776 (defsubst gnus-article-unhide-text (b e)
1777 "Remove hidden text properties from region between B and E."
1778 (remove-text-properties b e gnus-hidden-properties)
1779 (when (memq 'intangible gnus-hidden-properties)
1780 (put-text-property (max (1- b) (point-min))
1781 b 'intangible nil)))
1783 (defun gnus-article-hide-text-type (b e type)
1784 "Hide text of TYPE between B and E."
1785 (gnus-add-wash-type type)
1786 (gnus-article-hide-text
1787 b e (cons 'article-type (cons type gnus-hidden-properties))))
1789 (defun gnus-article-unhide-text-type (b e type)
1790 "Unhide text of TYPE between B and E."
1791 (gnus-delete-wash-type type)
1792 (remove-text-properties
1793 b e (cons 'article-type (cons type gnus-hidden-properties)))
1794 (when (memq 'intangible gnus-hidden-properties)
1795 (put-text-property (max (1- b) (point-min))
1796 b 'intangible nil)))
1798 (defun gnus-article-delete-text-of-type (type)
1799 "Delete text of TYPE in the current buffer."
1801 (let ((b (point-min)))
1802 (if (eq type 'multipart)
1803 ;; Remove MIME buttons associated with multipart/alternative parts.
1806 (while (if (get-text-property (point) 'gnus-part)
1808 (when (setq b (next-single-property-change (point)
1813 (skip-chars-forward "\n")
1814 (when (eq (get-text-property b 'article-type) 'multipart)
1815 (delete-region b (point)))))
1816 (while (setq b (text-property-any b (point-max) 'article-type type))
1818 b (or (text-property-not-all b (point-max) 'article-type type)
1821 (defun gnus-article-delete-invisible-text ()
1822 "Delete all invisible text in the current buffer."
1824 (let ((b (point-min)))
1825 (while (setq b (text-property-any b (point-max) 'invisible t))
1827 b (or (text-property-not-all b (point-max) 'invisible t)
1830 (defsubst gnus-article-header-rank ()
1831 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1832 (let ((list gnus-sorted-header-list)
1835 (if (looking-at (car list))
1837 (setq list (cdr list))
1841 (defun article-hide-headers (&optional arg delete)
1842 "Hide unwanted headers and possibly sort them as well."
1844 ;; This function might be inhibited.
1845 (unless gnus-inhibit-hiding
1846 (let ((inhibit-read-only t)
1847 (case-fold-search t)
1848 (max (1+ (length gnus-sorted-header-list)))
1849 (inhibit-point-motion-hooks t)
1850 (cur (current-buffer))
1851 ignored visible beg)
1853 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1854 ;; group parameters, so we should go to the summary buffer.
1857 (progn (set-buffer gnus-summary-buffer) t)
1859 (setq ignored (when (not gnus-visible-headers)
1860 (cond ((stringp gnus-ignored-headers)
1861 gnus-ignored-headers)
1862 ((listp gnus-ignored-headers)
1863 (mapconcat 'identity
1864 gnus-ignored-headers
1866 visible (cond ((stringp gnus-visible-headers)
1867 gnus-visible-headers)
1868 ((and gnus-visible-headers
1869 (listp gnus-visible-headers))
1870 (mapconcat 'identity
1871 gnus-visible-headers
1875 ;; First we narrow to just the headers.
1876 (article-narrow-to-head)
1877 ;; Hide any "From " lines at the beginning of (mail) articles.
1878 (while (looking-at "From ")
1881 (delete-region (point-min) (point)))
1882 ;; Then treat the rest of the header lines.
1883 ;; Then we use the two regular expressions
1884 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1885 ;; select which header lines is to remain visible in the
1887 (while (re-search-forward "^[^ \t:]*:" nil t)
1889 ;; Mark the rank of the header.
1891 (point) (1+ (point)) 'message-rank
1892 (if (or (and visible (looking-at visible))
1894 (not (looking-at ignored))))
1895 (gnus-article-header-rank)
1898 (message-sort-headers-1)
1899 (when (setq beg (text-property-any
1900 (point-min) (point-max) 'message-rank (+ 2 max)))
1901 ;; We delete the unwanted headers.
1902 (gnus-add-wash-type 'headers)
1903 (add-text-properties (point-min) (+ 5 (point-min))
1904 '(article-type headers dummy-invisible t))
1905 (delete-region beg (point-max))))))))
1907 (defun article-hide-boring-headers (&optional arg)
1908 "Toggle hiding of headers that aren't very interesting.
1909 If given a negative prefix, always show; if given a positive prefix,
1911 (interactive (gnus-article-hidden-arg))
1912 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1913 (not gnus-show-all-headers))
1916 (let ((inhibit-read-only t)
1917 (inhibit-point-motion-hooks t))
1918 (article-narrow-to-head)
1919 (dolist (elem gnus-boring-article-headers)
1920 (goto-char (point-min))
1922 ;; Hide empty headers.
1924 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1926 (gnus-article-hide-text-type
1930 (if (re-search-forward "^[^ \t]" nil t)
1934 ;; Hide boring Newsgroups header.
1935 ((eq elem 'newsgroups)
1936 (when (gnus-string-equal
1937 (gnus-fetch-field "newsgroups")
1938 (gnus-group-real-name
1939 (if (boundp 'gnus-newsgroup-name)
1942 (gnus-article-hide-header "newsgroups")))
1943 ((eq elem 'to-address)
1944 (let ((to (message-fetch-field "to"))
1946 (gnus-parameter-to-address
1947 (if (boundp 'gnus-newsgroup-name)
1948 gnus-newsgroup-name ""))))
1949 (when (and to to-address
1952 ;; only one address in To
1953 (nth 1 (mail-extract-address-components to))
1955 (gnus-article-hide-header "to"))))
1957 (let ((to (message-fetch-field "to"))
1959 (gnus-parameter-to-list
1960 (if (boundp 'gnus-newsgroup-name)
1961 gnus-newsgroup-name ""))))
1962 (when (and to to-list
1965 ;; only one address in To
1966 (nth 1 (mail-extract-address-components to))
1968 (gnus-article-hide-header "to"))))
1970 (let ((cc (message-fetch-field "cc"))
1972 (gnus-parameter-to-list
1973 (if (boundp 'gnus-newsgroup-name)
1974 gnus-newsgroup-name ""))))
1975 (when (and cc to-list
1978 ;; only one address in CC
1979 (nth 1 (mail-extract-address-components cc))
1981 (gnus-article-hide-header "cc"))))
1982 ((eq elem 'followup-to)
1983 (when (gnus-string-equal
1984 (message-fetch-field "followup-to")
1985 (message-fetch-field "newsgroups"))
1986 (gnus-article-hide-header "followup-to")))
1987 ((eq elem 'reply-to)
1988 (if (gnus-group-find-parameter
1989 gnus-newsgroup-name 'broken-reply-to)
1990 (gnus-article-hide-header "reply-to")
1991 (let ((from (message-fetch-field "from"))
1992 (reply-to (message-fetch-field "reply-to")))
1999 (lambda (x) (downcase (cadr x)))
2000 (mail-extract-address-components from t))
2003 (lambda (x) (downcase (cadr x)))
2004 (mail-extract-address-components reply-to t))
2006 (gnus-article-hide-header "reply-to")))))
2008 (let ((date (with-current-buffer gnus-original-article-buffer
2009 ;; If date in `gnus-article-buffer' is localized
2010 ;; (`gnus-treat-date-user-defined'),
2011 ;; `days-between' might fail.
2012 (message-fetch-field "date"))))
2014 (< (days-between (current-time-string) date)
2016 (gnus-article-hide-header "date"))))
2018 (let ((to (message-fetch-field "to"))
2019 (cc (message-fetch-field "cc")))
2020 (when (> (length to) 1024)
2021 (gnus-article-hide-header "to"))
2022 (when (> (length cc) 1024)
2023 (gnus-article-hide-header "cc"))))
2027 (goto-char (point-min))
2028 (while (re-search-forward "^to:" nil t)
2029 (setq to-count (1+ to-count)))
2030 (when (> to-count 1)
2031 (while (> to-count 0)
2032 (goto-char (point-min))
2034 (re-search-forward "^to:" nil nil to-count)
2036 (narrow-to-region (point) (point-max))
2037 (gnus-article-hide-header "to"))
2038 (setq to-count (1- to-count))))
2039 (goto-char (point-min))
2040 (while (re-search-forward "^cc:" nil t)
2041 (setq cc-count (1+ cc-count)))
2042 (when (> cc-count 1)
2043 (while (> cc-count 0)
2044 (goto-char (point-min))
2046 (re-search-forward "^cc:" nil nil cc-count)
2048 (narrow-to-region (point) (point-max))
2049 (gnus-article-hide-header "cc"))
2050 (setq cc-count (1- cc-count)))))))))))))
2052 (defun gnus-article-hide-header (header)
2054 (goto-char (point-min))
2055 (when (re-search-forward (concat "^" header ":") nil t)
2056 (gnus-article-hide-text-type
2060 (if (re-search-forward "^[^ \t]" nil t)
2065 (defvar gnus-article-normalized-header-length 40
2066 "Length of normalized headers.")
2068 (defun article-normalize-headers ()
2069 "Make all header lines 40 characters long."
2071 (let ((inhibit-read-only t)
2075 (article-narrow-to-head)
2078 ((< (setq column (- (point-at-eol) (point)))
2079 gnus-article-normalized-header-length)
2081 (insert (make-string
2082 (- gnus-article-normalized-header-length column)
2084 ((> column gnus-article-normalized-header-length)
2085 (gnus-put-text-property
2087 (forward-char gnus-article-normalized-header-length)
2094 (forward-line 1))))))
2096 (defun article-treat-dumbquotes ()
2097 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
2098 Note that this function guesses whether a character is a sm*rtq**t* or
2099 not, so it should only be used interactively.
2101 Sm*rtq**t*s are M****s***'s unilateral extension to the
2102 iso-8859-1 character map in an attempt to provide more quoting
2103 characters. If you see something like \\222 or \\264 where
2104 you're expecting some kind of apostrophe or quotation mark, then
2107 (article-translate-strings gnus-article-dumbquotes-map))
2109 (defvar org-entities)
2111 (defun article-treat-non-ascii ()
2112 "Translate many Unicode characters into their ASCII equivalents."
2114 (require 'org-entities)
2115 (let ((table (make-char-table (if (featurep 'xemacs) 'generic))))
2116 (dolist (elem org-entities)
2117 (when (and (listp elem)
2118 (= (length (nth 6 elem)) 1))
2119 (if (featurep 'xemacs)
2120 (put-char-table (aref (nth 6 elem) 0) (nth 4 elem) table)
2121 (set-char-table-range table (aref (nth 6 elem) 0) (nth 4 elem)))))
2123 (when (article-goto-body)
2124 (let ((inhibit-read-only t)
2127 (if (not (setq replace (if (featurep 'xemacs)
2128 (get-char-table (following-char) table)
2129 (aref table (following-char)))))
2132 (setq props (text-properties-at (point)))
2134 (add-text-properties (point) (progn (insert replace) (point))
2136 (insert replace)))))))))
2138 (defun article-translate-strings (map)
2139 "Translate all string in the body of the article according to MAP.
2140 MAP is an alist where the elements are on the form (\"from\" \"to\")."
2142 (when (article-goto-body)
2143 (let ((inhibit-read-only t))
2145 (let ((from (car elem))
2149 (while (search-forward from nil t)
2152 (if (eq (following-char) from)
2156 (forward-char 1)))))))))))
2158 (defun article-treat-overstrike ()
2159 "Translate overstrikes into bold text."
2162 (when (article-goto-body)
2163 (let ((inhibit-read-only t))
2164 (while (search-forward "\b" nil t)
2165 (let ((next (char-after))
2166 (previous (char-after (- (point) 2))))
2167 ;; We do the boldification/underlining by hiding the
2168 ;; overstrikes and putting the proper text property
2172 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
2173 (put-text-property (point) (1+ (point)) 'face 'bold))
2175 (gnus-article-hide-text-type
2176 (1- (point)) (1+ (point)) 'overstrike)
2178 (- (point) 2) (1- (point)) 'face 'underline))
2180 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
2182 (point) (1+ (point)) 'face 'underline)))))))))
2184 (defun article-treat-ansi-sequences ()
2185 "Translate ANSI SGR control sequences into overlays or extents."
2188 (when (article-goto-body)
2189 (let ((inhibit-read-only t))
2190 (ansi-color-apply-on-region (point) (point-max))))))
2192 (defun gnus-article-treat-unfold-headers ()
2193 "Unfold folded message headers.
2194 Only the headers that fit into the current window width will be
2197 (gnus-with-article-headers
2201 (mail-header-narrow-to-field)
2202 (let* ((header (buffer-string))
2204 (or (equal gnus-article-unfold-long-headers t)
2205 (and (stringp gnus-article-unfold-long-headers)
2206 (string-match gnus-article-unfold-long-headers
2210 (goto-char (point-min))
2211 (while (re-search-forward "\n[\t ]" nil t)
2212 (replace-match " " t t)))
2213 (setq length (- (point-max) (point-min) 1))
2214 (when (or unfoldable
2215 (< length (window-width)))
2216 (while (re-search-forward "\n[\t ]" nil t)
2217 (replace-match " " t t))))
2218 (goto-char (point-max)))))))
2220 (defun gnus-article-treat-fold-headers ()
2221 "Fold message headers."
2223 (gnus-with-article-headers
2226 (mail-header-narrow-to-field)
2227 (mail-header-fold-field)
2228 (goto-char (point-max))))))
2230 (defun gnus-treat-smiley ()
2231 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2233 (gnus-with-article-buffer
2234 (if (memq 'smiley gnus-article-wash-types)
2235 (gnus-delete-images 'smiley)
2237 (let ((images (smiley-region (point) (point-max))))
2239 (gnus-add-wash-type 'smiley)
2240 (dolist (image images)
2241 (gnus-add-image 'smiley image)))))))
2243 (defun gnus-article-remove-images ()
2244 "Remove all images from the article buffer."
2246 (gnus-with-article-buffer
2249 (dolist (elem gnus-article-image-alist)
2250 (gnus-delete-images (car elem))))))
2252 (autoload 'w3m-toggle-inline-images "w3m")
2254 (defun gnus-article-show-images ()
2255 "Show any images that are in the HTML-rendered article buffer.
2256 This only works if the article in question is HTML."
2258 (gnus-with-article-buffer
2261 (if (eq mm-text-html-renderer 'w3m)
2262 (let ((mm-inline-text-html-with-images nil))
2263 (w3m-toggle-inline-images))
2264 (dolist (region (gnus-find-text-property-region (point-min) (point-max)
2266 (destructuring-bind (start end function) region
2267 (funcall function (get-text-property start 'image-url)
2270 (defun gnus-article-treat-fold-newsgroups ()
2271 "Unfold folded message headers.
2272 Only the headers that fit into the current window width will be
2275 (gnus-with-article-headers
2276 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2278 (mail-header-narrow-to-field)
2279 (while (re-search-forward ", *" nil t)
2280 (replace-match ", " t t))
2281 (mail-header-fold-field)
2282 (goto-char (point-max))))))
2284 (defcustom gnus-article-truncate-lines (default-value 'truncate-lines)
2285 "Value of `truncate-lines' in Gnus Article buffer.
2286 Valid values are nil, t, `head', `first', `last', an integer or a
2287 predicate. See Info node `(gnus)Customizing Articles'."
2288 :version "23.1" ;; No Gnus
2289 :group 'gnus-article
2290 ;; :link '(custom-manual "(gnus)Customizing Articles")
2293 (defun gnus-article-toggle-truncate-lines (&optional arg)
2294 "Toggle whether to fold or truncate long lines in article the buffer.
2295 If ARG is non-nil and not a number, toggle
2296 `gnus-article-truncate-lines' too. If ARG is a number, truncate
2297 long lines if and only if arg is positive."
2300 ((and (numberp arg) (> arg 0))
2301 (setq gnus-article-truncate-lines t))
2303 (setq gnus-article-truncate-lines nil))
2305 (setq gnus-article-truncate-lines
2306 (not gnus-article-truncate-lines))))
2307 (gnus-with-article-buffer
2309 ((and (numberp arg) (> arg 0))
2310 (setq truncate-lines nil))
2312 (setq truncate-lines t)))
2313 ;; In versions of Emacs 22 (CVS) before 2006-05-26,
2314 ;; `toggle-truncate-lines' needs an argument.
2315 (toggle-truncate-lines)))
2317 (defun gnus-article-treat-body-boundary ()
2318 "Place a boundary line at the end of the headers."
2320 (when (and gnus-body-boundary-delimiter
2321 (> (length gnus-body-boundary-delimiter) 0))
2322 (gnus-with-article-headers
2323 (goto-char (point-max))
2324 (let ((start (point)))
2325 (insert "X-Boundary: ")
2326 (gnus-add-text-properties start (point) '(invisible t intangible t))
2327 (insert (let (str (max (window-width)))
2328 (if (featurep 'xemacs)
2329 (setq max (1- max)))
2330 (while (>= max (length str))
2331 (setq str (concat str gnus-body-boundary-delimiter)))
2332 (substring str 0 max))
2334 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2336 (defun article-fill-long-lines ()
2337 "Fill lines that are wider than the window width."
2340 (let ((inhibit-read-only t)
2341 (width (window-width (get-buffer-window (current-buffer)))))
2344 (let ((adaptive-fill-mode nil)) ;Why? -sm
2347 (when (>= (current-column) (min fill-column width))
2348 (narrow-to-region (min (1+ (point)) (point-max))
2350 (let ((goback (point-marker)))
2351 (fill-paragraph nil)
2352 (goto-char (marker-position goback)))
2354 (forward-line 1)))))))
2356 (defun article-capitalize-sentences ()
2357 "Capitalize the first word in each sentence."
2360 (let ((inhibit-read-only t)
2361 (paragraph-start "^[\n\^L]"))
2365 (forward-sentence)))))
2367 (defun article-remove-cr ()
2368 "Remove trailing CRs and then translate remaining CRs into LFs."
2371 (let ((inhibit-read-only t))
2372 (goto-char (point-min))
2373 (while (re-search-forward "\r+$" nil t)
2374 (replace-match "" t t))
2375 (goto-char (point-min))
2376 (while (search-forward "\r" nil t)
2377 (replace-match "\n" t t)))))
2379 (defun article-remove-trailing-blank-lines ()
2380 "Remove all trailing blank lines from the article."
2383 (let ((inhibit-read-only t))
2384 (goto-char (point-max))
2388 (while (and (not (bobp))
2389 (looking-at "^[ \t]*$")
2390 (not (gnus-annotation-in-region-p
2391 (point) (point-at-eol))))
2396 (defvar gnus-face-properties-alist)
2398 (defun article-display-face (&optional force)
2399 "Display any Face headers in the header."
2400 (interactive (list 'force))
2401 (let ((wash-face-p buffer-read-only))
2402 (gnus-with-article-headers
2403 ;; When displaying parts, this function can be called several times on
2404 ;; the same article, without any intended toggle semantic (as typing `W
2405 ;; D d' would have). So face deletion must occur only when we come from
2406 ;; an interactive command, that is when the *Article* buffer is
2408 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2409 (gnus-delete-images 'face)
2410 (let ((from (message-fetch-field "from"))
2412 (save-current-buffer
2413 (when (and wash-face-p
2414 (gnus-buffer-live-p gnus-original-article-buffer)
2415 (not (re-search-forward "^Face:[\t ]*" nil t)))
2416 (set-buffer gnus-original-article-buffer))
2418 (mail-narrow-to-head)
2420 ;; Check whether this face is censored.
2421 (not (and gnus-article-x-face-too-ugly
2423 (setq from (message-fetch-field "from")))
2424 (string-match gnus-article-x-face-too-ugly
2426 (while (gnus-article-goto-header "Face")
2427 (push (mail-header-field-value) faces)))))
2429 (goto-char (point-min))
2431 (unless (setq from (gnus-article-goto-header "from"))
2434 (insert " [no `from' set]\n"))
2436 (when (setq png (gnus-convert-face-to-png (pop faces)))
2438 (apply 'gnus-create-image png 'png t
2439 (cdr (assq 'png gnus-face-properties-alist))))
2442 (gnus-add-wash-type 'face)
2443 (gnus-add-image 'face image)
2444 (gnus-put-image image nil 'face)))))))))))
2446 (defun article-display-x-face (&optional force)
2447 "Look for an X-Face header and display it if present."
2448 (interactive (list 'force))
2449 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2450 (gnus-with-article-headers
2451 ;; Delete the old process, if any.
2452 (when (process-status "article-x-face")
2453 (delete-process "article-x-face"))
2454 ;; See the comment in `article-display-face'.
2455 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2456 ;; We have already displayed X-Faces, so we remove them
2458 (gnus-delete-images 'xface)
2460 (let ((from (message-fetch-field "from"))
2462 (save-current-buffer
2463 (when (and wash-face-p
2464 (gnus-buffer-live-p gnus-original-article-buffer)
2465 (not (re-search-forward "^X-Face:[\t ]*" nil t)))
2466 ;; If type `W f', use gnus-original-article-buffer,
2467 ;; otherwise use the current buffer because displaying
2468 ;; RFC822 parts calls this function too.
2469 (set-buffer gnus-original-article-buffer))
2471 (mail-narrow-to-head)
2472 (and gnus-article-x-face-command
2474 ;; Check whether this face is censored.
2475 (not (and gnus-article-x-face-too-ugly
2477 (setq from (message-fetch-field "from")))
2478 (string-match gnus-article-x-face-too-ugly
2480 (while (gnus-article-goto-header "X-Face")
2481 (push (mail-header-field-value) x-faces)))))
2483 ;; We display the face.
2484 (cond ((functionp gnus-article-x-face-command)
2485 ;; The command is a lisp function, so we call it.
2486 (mapc gnus-article-x-face-command x-faces))
2487 ((stringp gnus-article-x-face-command)
2488 ;; The command is a string, so we interpret the command
2489 ;; as a, well, command, and fork it off.
2490 (let ((process-connection-type nil))
2491 (gnus-set-process-query-on-exit-flag
2493 "article-x-face" nil shell-file-name
2494 shell-command-switch gnus-article-x-face-command)
2496 ;; Sending multiple EOFs to xv doesn't work,
2497 ;; so we only do a single external face.
2499 (insert (car x-faces))
2500 (process-send-region "article-x-face"
2501 (point-min) (point-max)))
2502 (process-send-eof "article-x-face")))
2504 (error "`%s' set to `%s' is not a function"
2505 gnus-article-x-face-command
2506 'gnus-article-x-face-command)))))))))
2508 (defun article-decode-mime-words ()
2509 "Decode all MIME-encoded words in the article."
2511 (gnus-with-article-buffer
2512 (let ((inhibit-point-motion-hooks t)
2513 (mail-parse-charset gnus-newsgroup-charset)
2514 (mail-parse-ignored-charsets
2515 (with-current-buffer gnus-summary-buffer
2516 gnus-newsgroup-ignored-charsets)))
2517 (mail-decode-encoded-word-region (point-min) (point-max)))))
2519 (defun article-decode-charset (&optional prompt)
2520 "Decode charset-encoded text in the article.
2521 If PROMPT (the prefix), prompt for a coding system to use."
2523 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2524 (inhibit-read-only t)
2525 (mail-parse-charset gnus-newsgroup-charset)
2526 (mail-parse-ignored-charsets
2527 (save-excursion (condition-case nil
2528 (set-buffer gnus-summary-buffer)
2530 gnus-newsgroup-ignored-charsets))
2531 ct cte ctl charset format)
2534 (article-narrow-to-head)
2535 (setq ct (message-fetch-field "Content-Type" t)
2536 cte (message-fetch-field "Content-Transfer-Encoding" t)
2537 ctl (and ct (mail-header-parse-content-type ct))
2540 (mm-read-coding-system "Charset to decode: "))
2542 (mail-content-type-get ctl 'charset)))
2543 format (and ctl (mail-content-type-get ctl 'format)))
2545 (setq cte (mail-header-strip cte)))
2546 (if (and ctl (not (string-match "/" (car ctl))))
2548 (goto-char (point-max)))
2551 (narrow-to-region (point) (point-max))
2552 (when (and (eq mail-parse-charset 'gnus-decoded)
2553 (eq (mm-body-7-or-8) '8bit))
2554 ;; The text code could have been decoded.
2555 (setq charset mail-parse-charset))
2556 (when (and (or (not ctl)
2557 (equal (car ctl) "text/plain"))
2558 (not format)) ;; article with format will decode later.
2560 charset (and cte (intern (downcase
2561 (gnus-strip-whitespace cte))))
2564 (defun article-decode-encoded-words ()
2565 "Remove encoded-word encoding from headers."
2566 (let ((inhibit-point-motion-hooks t)
2567 (mail-parse-charset gnus-newsgroup-charset)
2568 (mail-parse-ignored-charsets
2569 (save-excursion (condition-case nil
2570 (set-buffer gnus-summary-buffer)
2572 gnus-newsgroup-ignored-charsets))
2573 (inhibit-read-only t)
2575 (goto-char (point-min))
2576 (when (search-forward "\n\n" nil 'move)
2583 (memq (char-after) '(?\t ? )))))
2584 (setq start (point))
2586 \\(?:Resent-\\)?\\(?:From\\|Cc\\|To\\|Bcc\\|\\(?:In-\\)?Reply-To\\|Sender\
2587 \\|Mail-Followup-To\\|Mail-Copies-To\\|Approved\\):")
2588 (funcall gnus-decode-address-function start end)
2589 (funcall gnus-decode-header-function start end))
2590 (goto-char (setq end start)))))
2592 (defun article-decode-group-name ()
2593 "Decode group names in Newsgroups, Followup-To and Xref headers."
2594 (let ((inhibit-point-motion-hooks t)
2595 (inhibit-read-only t)
2596 (method (gnus-find-method-for-group gnus-newsgroup-name))
2598 (when (and (or gnus-group-name-charset-method-alist
2599 gnus-group-name-charset-group-alist)
2600 (gnus-buffer-live-p gnus-original-article-buffer))
2602 (article-narrow-to-head)
2603 (dolist (header '("Newsgroups" "Followup-To" "Xref"))
2604 (with-current-buffer gnus-original-article-buffer
2605 (goto-char (point-min)))
2606 (setq regexp (concat "^" header
2607 ":\\([^\n]*\\(?:\n[\t ]+[^\n]+\\)*\\)\n"))
2608 (while (re-search-forward regexp nil t)
2609 (replace-match (save-match-data
2610 (gnus-decode-newsgroups
2611 ;; XXX how to use data in article buffer?
2612 (with-current-buffer gnus-original-article-buffer
2613 (re-search-forward regexp nil t)
2615 gnus-newsgroup-name method))
2617 (goto-char (point-min)))))))
2619 (autoload 'idna-to-unicode "idna")
2621 (defun article-decode-idna-rhs ()
2622 "Decode IDNA strings in RHS in various headers in current buffer.
2623 The following headers are decoded: From:, To:, Cc:, Reply-To:,
2624 Mail-Reply-To: and Mail-Followup-To:."
2627 (let ((inhibit-point-motion-hooks t)
2628 (inhibit-read-only t))
2629 (article-narrow-to-head)
2630 (goto-char (point-min))
2631 (while (re-search-forward "@[^ \t\n\r,>]*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2633 (when (save-match-data
2634 (and (setq ace (match-string 1))
2636 (and (re-search-backward "^[^ \t]" nil t)
2637 (looking-at "From\\|To\\|Cc\\|Reply-To\\|Mail-Reply-To\\|Mail-Followup-To")))
2638 (setq unicode (idna-to-unicode ace))))
2639 (unless (string= ace unicode)
2640 (replace-match unicode nil nil nil 1)))))))))
2642 (defun article-de-quoted-unreadable (&optional force read-charset)
2643 "Translate a quoted-printable-encoded article.
2644 If FORCE, decode the article whether it is marked as quoted-printable
2646 If READ-CHARSET, ask for a coding system."
2647 (interactive (list 'force current-prefix-arg))
2649 (let ((inhibit-read-only t) type charset)
2650 (if (gnus-buffer-live-p gnus-original-article-buffer)
2651 (with-current-buffer gnus-original-article-buffer
2653 (gnus-fetch-field "content-transfer-encoding"))
2654 (let* ((ct (gnus-fetch-field "content-type"))
2655 (ctl (and ct (mail-header-parse-content-type ct))))
2656 (setq charset (and ctl
2657 (mail-content-type-get ctl 'charset)))
2658 (if (stringp charset)
2659 (setq charset (intern (downcase charset)))))))
2661 (setq charset (mm-read-coding-system "Charset: " charset)))
2663 (setq charset gnus-newsgroup-charset))
2665 (and type (let ((case-fold-search t))
2666 (string-match "quoted-printable" type))))
2668 (quoted-printable-decode-region
2669 (point) (point-max) (mm-charset-to-coding-system charset))))))
2671 (defun article-de-base64-unreadable (&optional force read-charset)
2672 "Translate a base64 article.
2673 If FORCE, decode the article whether it is marked as base64 not.
2674 If READ-CHARSET, ask for a coding system."
2675 (interactive (list 'force current-prefix-arg))
2677 (let ((inhibit-read-only t) type charset)
2678 (if (gnus-buffer-live-p gnus-original-article-buffer)
2679 (with-current-buffer gnus-original-article-buffer
2681 (gnus-fetch-field "content-transfer-encoding"))
2682 (let* ((ct (gnus-fetch-field "content-type"))
2683 (ctl (and ct (mail-header-parse-content-type ct))))
2684 (setq charset (and ctl
2685 (mail-content-type-get ctl 'charset)))
2686 (if (stringp charset)
2687 (setq charset (intern (downcase charset)))))))
2689 (setq charset (mm-read-coding-system "Charset: " charset)))
2691 (setq charset gnus-newsgroup-charset))
2693 (and type (let ((case-fold-search t))
2694 (string-match "base64" type))))
2697 (narrow-to-region (point) (point-max))
2698 (base64-decode-region (point-min) (point-max))
2699 (mm-decode-coding-region
2700 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2705 (defun article-decode-HZ ()
2706 "Translate a HZ-encoded article."
2710 (let ((inhibit-read-only t))
2711 (rfc1843-decode-region (point-min) (point-max)))))
2713 (defun article-unsplit-urls ()
2714 "Remove the newlines that some other mailers insert into URLs."
2717 (let ((inhibit-read-only t))
2718 (goto-char (point-min))
2719 (while (re-search-forward
2720 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2721 (replace-match "\\1\\3" t)))
2722 (when (gmm-called-interactively-p 'any)
2723 (gnus-treat-article nil))))
2725 (defun article-wash-html ()
2726 "Format an HTML article."
2729 (buffer-read-only nil))
2730 (when (gnus-buffer-live-p gnus-original-article-buffer)
2731 (with-current-buffer gnus-original-article-buffer
2732 (setq handles (mm-dissect-buffer t t))))
2734 (delete-region (point) (point-max))
2735 (mm-enable-multibyte)
2736 (mm-inline-text-html handles)))
2738 (defvar gnus-article-browse-html-temp-list nil
2739 "List of temporary files created by `gnus-article-browse-html-parts'.
2740 Internal variable.")
2742 (defcustom gnus-article-browse-delete-temp 'ask
2743 "What to do with temporary files from `gnus-article-browse-html-parts'.
2744 If nil, don't delete temporary files. If it is t, delete them on
2745 exit from the summary buffer. If it is the symbol `file', query
2746 on each file, if it is `ask' ask once when exiting from the
2748 :group 'gnus-article
2749 :version "23.1" ;; No Gnus
2750 :type '(choice (const :tag "Don't delete" nil)
2751 (const :tag "Don't ask" t)
2752 (const :tag "Ask" ask)
2753 (const :tag "Ask for each file" file)))
2755 ;; Cf. mm-postponed-undisplay-list / mm-destroy-postponed-undisplay-list.
2757 (defun gnus-article-browse-delete-temp-files (&optional how)
2758 "Delete temp-files created by `gnus-article-browse-html-parts'."
2759 (when (and gnus-article-browse-html-temp-list
2761 (or how (setq how gnus-article-browse-delete-temp))
2763 (let ((files (length gnus-article-browse-html-temp-list)))
2766 "Delete the temporary HTML file? "
2767 (format "Delete all %s temporary HTML files? "
2769 (setq gnus-article-browse-html-temp-list nil)))
2771 (dolist (file gnus-article-browse-html-temp-list)
2772 (cond ((file-directory-p file)
2773 (when (or (not (eq how 'file))
2776 "Delete temporary HTML file(s) in directory `%s'? "
2777 (file-name-as-directory file))))
2778 (gnus-delete-directory file)))
2779 ((file-exists-p file)
2780 (when (or (not (eq how 'file))
2782 (format "Delete temporary HTML file `%s'? " file)))
2783 (delete-file file)))))
2784 ;; Also remove file from the list when not deleted or if file doesn't
2786 (setq gnus-article-browse-html-temp-list nil))
2787 gnus-article-browse-html-temp-list)
2789 (defun gnus-article-browse-html-save-cid-content (cid handles directory)
2790 "Find CID content in HANDLES and save it in a file in DIRECTORY.
2795 (dolist (handle handles)
2797 ((not (listp handle)))
2798 ((equal (mm-handle-media-supertype handle) "multipart")
2799 (when (setq file (gnus-article-browse-html-save-cid-content
2800 cid handle directory))
2801 (throw 'found file)))
2802 ((equal (concat "<" cid ">") (mm-handle-id handle))
2805 (or (mm-handle-filename handle)
2807 (make-temp-name "cid")
2808 (car (rassoc (car (mm-handle-type handle)) mailcap-mime-extensions))))
2810 (mm-save-part-to-file handle file)
2811 (throw 'found file))))))))
2813 (defun gnus-article-browse-html-parts (list &optional header)
2814 "View all \"text/html\" parts from LIST.
2815 Recurse into multiparts. The optional HEADER that should be a decoded
2816 message header will be added to the bodies of the \"text/html\" parts."
2817 ;; Internal function used by `gnus-article-browse-html-article'.
2818 (let (type file charset content cid-dir tmp-file showed)
2819 ;; Find and show the html-parts.
2820 (dolist (handle list)
2821 ;; If HTML, show it:
2822 (cond ((not (listp handle)))
2823 ((or (equal (car (setq type (mm-handle-type handle))) "text/html")
2824 (and (equal (car type) "message/external-body")
2826 (setq file (mm-handle-filename handle)))
2827 (or (mm-handle-cache handle)
2828 (condition-case code
2829 (progn (mm-extern-cache-contents handle) t)
2831 (gnus-message 3 "%s" (error-message-string code))
2832 (when (>= gnus-verbose 3) (sit-for 2))
2835 (setq handle (mm-handle-cache handle)
2836 type (mm-handle-type handle))
2837 (equal (car type) "text/html"))))
2838 (setq charset (mail-content-type-get type 'charset)
2839 content (mm-get-part handle))
2841 (if (eq charset 'gnus-decoded)
2842 (mm-enable-multibyte)
2843 (mm-disable-multibyte))
2845 ;; resolve cid contents
2846 (let ((case-fold-search t)
2848 (goto-char (point-min))
2849 (while (re-search-forward "\
2850 <img[\t\n ]+\\(?:[^\t\n >]+[\t\n ]+\\)*src=\"\\(cid:\\([^\"]+\\)\\)\""
2853 (setq cid-dir (mm-make-temp-file "cid" t))
2854 (add-to-list 'gnus-article-browse-html-temp-list cid-dir))
2857 (when (setq cid-file
2858 (gnus-article-browse-html-save-cid-content
2860 (with-current-buffer gnus-article-buffer
2861 gnus-article-mime-handles)
2863 (when (eq system-type 'cygwin)
2865 (concat "/" (substring
2866 (with-output-to-string
2867 (call-process "cygpath" nil
2871 (replace-match (concat "file://" cid-file)
2873 (unless content (setq content (buffer-string))))
2874 (when (or charset header (not file))
2875 (setq tmp-file (mm-make-temp-file
2876 ;; Do we need to care for 8.3 filenames?
2877 "mm-" nil ".html")))
2878 ;; Add a meta html tag to specify charset and a header.
2881 (let (title eheader body hcharset coding)
2883 (mm-enable-multibyte)
2884 (setq case-fold-search t)
2885 (insert header "\n")
2886 (setq title (message-fetch-field "subject"))
2887 (goto-char (point-min))
2888 (while (re-search-forward "\\(<\\)\\|\\(>\\)\\|\\(&\\)\\|\n"
2890 (replace-match (cond ((match-beginning 1) "<")
2891 ((match-beginning 2) ">")
2892 ((match-beginning 3) "&")
2894 (goto-char (point-min))
2895 (insert "<div align=\"left\">\n")
2896 (goto-char (point-max))
2897 (insert "</div>\n<hr>\n")
2898 ;; We have to examine charset one by one since
2899 ;; charset specified in parts might be different.
2900 (if (eq charset 'gnus-decoded)
2901 (setq charset 'utf-8
2902 eheader (mm-encode-coding-string (buffer-string)
2905 (mm-encode-coding-string title charset))
2906 body (mm-encode-coding-string content charset))
2907 (setq hcharset (mm-find-mime-charset-region (point-min)
2909 (cond ((= (length hcharset) 1)
2910 (setq hcharset (car hcharset)
2911 coding (mm-charset-to-coding-system
2913 ((> (length hcharset) 1)
2914 (setq hcharset 'utf-8
2920 (mm-charset-to-coding-system charset))
2921 (if (eq coding body)
2922 (setq eheader (mm-encode-coding-string
2923 (buffer-string) coding)
2925 (mm-encode-coding-string
2928 (setq charset 'utf-8
2929 eheader (mm-encode-coding-string
2930 (buffer-string) charset)
2932 (mm-encode-coding-string
2934 body (mm-encode-coding-string
2935 (mm-decode-coding-string
2938 (setq charset hcharset
2939 eheader (mm-encode-coding-string
2940 (buffer-string) coding)
2942 (mm-encode-coding-string
2945 (setq eheader (mm-string-as-unibyte (buffer-string))
2948 (mm-disable-multibyte)
2951 (mm-add-meta-html-tag handle charset t))
2953 (goto-char (point-min))
2954 (unless (search-forward "<title>" nil t)
2955 (re-search-forward "<head>\\s-*" nil t)
2956 (insert "<title>" title "</title>\n")))
2957 (goto-char (point-min))
2958 (or (re-search-forward
2959 "<body\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t)
2961 "</head\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t))
2963 (mm-write-region (point-min) (point-max)
2964 tmp-file nil nil nil 'binary t))))
2966 (mm-with-unibyte-buffer
2967 (insert (if (eq charset 'gnus-decoded)
2968 (mm-encode-coding-string content
2969 (setq charset 'utf-8))
2971 (if (or (mm-add-meta-html-tag handle charset)
2973 (mm-write-region (point-min) (point-max)
2974 tmp-file nil nil nil 'binary t)
2975 (setq tmp-file nil))))
2977 (mm-save-part-to-file handle tmp-file)))
2979 (add-to-list 'gnus-article-browse-html-temp-list tmp-file))
2980 (add-hook 'gnus-summary-prepare-exit-hook
2981 'gnus-article-browse-delete-temp-files)
2982 (add-hook 'gnus-exit-gnus-hook
2984 (gnus-article-browse-delete-temp-files t)))
2985 ;; FIXME: Warn if there's an <img> tag?
2986 (browse-url-of-file (or tmp-file (expand-file-name file)))
2988 ;; If multipart, recurse
2989 ((equal (mm-handle-media-supertype handle) "multipart")
2990 (when (gnus-article-browse-html-parts handle header)
2992 ((equal (mm-handle-media-type handle) "message/rfc822")
2993 (mm-with-multibyte-buffer
2994 (mm-insert-part handle)
2995 (setq handle (mm-dissect-buffer t t))
2996 (when (and (bufferp (car handle))
2997 (stringp (car (mm-handle-type handle))))
2998 (setq handle (list handle)))
3000 (article-decode-encoded-words)
3001 (let ((gnus-visible-headers
3002 (or (get 'gnus-visible-headers 'standard-value)
3003 gnus-visible-headers)))
3004 (article-hide-headers))
3005 (goto-char (point-min))
3006 (search-forward "\n\n" nil 'move)
3007 (skip-chars-backward "\t\n ")
3008 (setq header (buffer-substring (point-min) (point)))))
3010 (gnus-article-browse-html-parts handle header)
3011 (mm-destroy-parts handle))
3015 (defun gnus-article-browse-html-article (&optional arg)
3016 "View \"text/html\" parts of the current article with a WWW browser.
3017 Inline images embedded in a message using the cid scheme, as they are
3018 generally considered to be safe, will be processed properly.
3019 The message header is added to the beginning of every html part unless
3020 the prefix argument ARG is given.
3022 Warning: Spammers use links to images (using the http scheme) in HTML
3023 articles to verify whether you have read the message. As
3024 `gnus-article-browse-html-article' passes the HTML content to the
3025 browser without eliminating these \"web bugs\" you should only
3026 use it for mails from trusted senders.
3028 If you always want to display HTML parts in the browser, set
3029 `mm-text-html-renderer' to nil.
3031 This command creates temporary files to pass HTML contents including
3032 images if any to the browser, and deletes them when exiting the group
3034 ;; Cf. `mm-w3m-safe-url-regexp'
3037 (gnus-summary-show-article)
3038 (let ((gnus-visible-headers (or (get 'gnus-visible-headers 'standard-value)
3039 gnus-visible-headers))
3040 ;; As we insert a <hr>, there's no need for the body boundary.
3041 (gnus-treat-body-boundary nil))
3042 (gnus-summary-show-article)))
3043 (with-current-buffer gnus-article-buffer
3044 (let ((header (unless arg
3047 (buffer-substring-no-properties
3048 (goto-char (point-min))
3049 (if (search-forward "\n\n" nil t)
3051 (goto-char (point-max))
3052 (skip-chars-backward "\t\n ")
3055 (set-buffer gnus-original-article-buffer)
3056 (setq parts (mm-dissect-buffer t t))
3057 ;; If singlepart, enforce a list.
3058 (when (and (bufferp (car parts))
3059 (stringp (car (mm-handle-type parts))))
3060 (setq parts (list parts)))
3062 (unless (gnus-article-browse-html-parts parts header)
3063 (gnus-error 3 "Mail doesn't contain a \"text/html\" part!"))
3064 (mm-destroy-parts parts)
3066 (gnus-summary-show-article)))))
3068 (defun article-hide-list-identifiers ()
3069 "Remove list identifies from the Subject header.
3070 The `gnus-list-identifiers' variable specifies what to do."
3072 (let ((inhibit-point-motion-hooks t)
3073 (regexp (gnus-group-get-list-identifiers gnus-newsgroup-name))
3074 (inhibit-read-only t))
3078 (article-narrow-to-head)
3079 (goto-char (point-min))
3080 (while (re-search-forward
3081 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
3083 (delete-region (match-beginning 2) (match-end 0))
3084 (beginning-of-line))
3085 (when (re-search-forward
3086 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
3087 (delete-region (match-beginning 1) (match-end 1))))))))
3089 (defun article-hide-pem (&optional arg)
3090 "Toggle hiding of any PEM headers and signatures in the current article.
3091 If given a negative prefix, always show; if given a positive prefix,
3093 (interactive (gnus-article-hidden-arg))
3094 (unless (gnus-article-check-hidden-text 'pem arg)
3096 (let ((inhibit-read-only t) end)
3097 (goto-char (point-min))
3098 ;; Hide the horrendously ugly "header".
3099 (when (and (search-forward
3100 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
3102 (setq end (1+ (match-beginning 0))))
3103 (gnus-add-wash-type 'pem)
3104 (gnus-article-hide-text-type
3106 (if (search-forward "\n\n" nil t)
3110 ;; Hide the trailer as well
3111 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
3113 (gnus-article-hide-text-type
3114 (match-beginning 0) (match-end 0) 'pem)))))))
3116 (defun article-strip-banner ()
3117 "Strip the banners specified by the `banner' group parameter and by
3118 `gnus-article-address-banner-alist'."
3122 (let ((inhibit-point-motion-hooks t))
3123 (when (gnus-parameter-banner gnus-newsgroup-name)
3124 (article-really-strip-banner
3125 (gnus-parameter-banner gnus-newsgroup-name)))
3126 (when gnus-article-address-banner-alist
3127 ;; Note that the From header is decoded here, so it is
3128 ;; required that the *-extract-address-components function
3129 ;; supports non-ASCII text.
3130 (let ((from (save-restriction
3132 (article-narrow-to-head)
3133 (mail-fetch-field "from"))))
3136 (cadr (funcall gnus-extract-address-components
3139 (dolist (pair gnus-article-address-banner-alist)
3140 (when (string-match (car pair) from)
3142 (article-really-strip-banner (cdr pair)))))))))))))
3144 (defun article-really-strip-banner (banner)
3145 "Strip the banner specified by the argument."
3148 (let ((inhibit-point-motion-hooks t)
3149 (gnus-signature-limit nil)
3150 (inhibit-read-only t))
3153 ((eq banner 'signature)
3154 (when (gnus-article-narrow-to-signature)
3157 (delete-region (point) (point-max))))
3159 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
3160 (while (re-search-forward banner nil t)
3161 (delete-region (match-beginning 0) (match-end 0)))))
3163 (while (re-search-forward banner nil t)
3164 (delete-region (match-beginning 0) (match-end 0)))))))))
3166 (defun article-babel ()
3167 "Translate article using an online translation service."
3170 (gnus-with-article-buffer
3171 (when (article-goto-body)
3172 (let* ((start (point))
3174 (orig (buffer-substring start end))
3175 (trans (babel-as-string orig)))
3177 (narrow-to-region start end)
3178 (delete-region start end)
3181 (defun article-hide-signature (&optional arg)
3182 "Hide the signature in the current article.
3183 If given a negative prefix, always show; if given a positive prefix,
3185 (interactive (gnus-article-hidden-arg))
3186 (unless (gnus-article-check-hidden-text 'signature arg)
3189 (let ((inhibit-read-only t))
3190 (when (gnus-article-narrow-to-signature)
3191 (gnus-article-hide-text-type
3192 (point-min) (point-max) 'signature))))))
3193 (gnus-set-mode-line 'article))
3195 (defun article-strip-headers-in-body ()
3196 "Strip offensive headers from bodies."
3200 (let ((case-fold-search t))
3201 (when (looking-at "x-no-archive:")
3202 (gnus-delete-line)))))
3204 (defun article-strip-leading-blank-lines ()
3205 "Remove all blank lines from the beginning of the article."
3208 (let ((inhibit-point-motion-hooks t)
3209 (inhibit-read-only t))
3210 (when (article-goto-body)
3211 (while (and (not (eobp))
3212 (looking-at "[ \t]*$"))
3213 (gnus-delete-line))))))
3215 (defun article-narrow-to-head ()
3216 "Narrow the buffer to the head of the message.
3217 Point is left at the beginning of the narrowed-to region."
3219 (goto-char (point-min))
3221 ;; Absolutely no headers displayed.
3225 ((search-forward "\n\n" nil 1)
3227 ;; Nothing but headers.
3230 (goto-char (point-min)))
3232 (defun article-goto-body ()
3233 "Place point at the start of the body."
3234 (goto-char (point-min))
3236 ;; This variable is only bound when dealing with separate
3238 (article-goto-body-goes-to-point-min-p
3240 ((search-forward "\n\n" nil t)
3243 (goto-char (point-max))
3246 (defun article-strip-multiple-blank-lines ()
3247 "Replace consecutive blank lines with one empty line."
3250 (let ((inhibit-point-motion-hooks t)
3251 (inhibit-read-only t))
3252 ;; First make all blank lines empty.
3254 (while (re-search-forward "^[ \t]+$" nil t)
3255 (unless (gnus-annotation-in-region-p
3256 (match-beginning 0) (match-end 0))
3257 (replace-match "" nil t)))
3258 ;; Then replace multiple empty lines with a single empty line.
3260 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
3261 (unless (gnus-annotation-in-region-p
3262 (match-beginning 0) (match-end 0))
3263 (delete-region (match-beginning 1) (match-end 1)))))))
3265 (defun article-strip-leading-space ()
3266 "Remove all white space from the beginning of the lines in the article."
3269 (let ((inhibit-point-motion-hooks t)
3270 (inhibit-read-only t))
3272 (while (re-search-forward "^[ \t]+" nil t)
3273 (replace-match "" t t)))))
3275 (defun article-strip-trailing-space ()
3276 "Remove all white space from the end of the lines in the article."
3279 (let ((inhibit-point-motion-hooks t)
3280 (inhibit-read-only t))
3282 (while (re-search-forward "[ \t]+$" nil t)
3283 (replace-match "" t t)))))
3285 (defun article-strip-blank-lines ()
3286 "Strip leading, trailing and multiple blank lines."
3288 (article-strip-leading-blank-lines)
3289 (article-remove-trailing-blank-lines)
3290 (article-strip-multiple-blank-lines))
3292 (defun article-strip-all-blank-lines ()
3293 "Strip all blank lines."
3296 (let ((inhibit-point-motion-hooks t)
3297 (inhibit-read-only t))
3299 (while (re-search-forward "^[ \t]*\n" nil t)
3300 (replace-match "" t t)))))
3302 (defun gnus-article-narrow-to-signature ()
3303 "Narrow to the signature; return t if a signature is found, else nil."
3304 (let ((inhibit-point-motion-hooks t))
3305 (when (gnus-article-search-signature)
3307 ;; Check whether we have some limits to what we consider
3308 ;; to be a signature.
3309 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
3310 (list gnus-signature-limit)))
3312 (while (setq limit (pop limits))
3313 (if (or (and (integerp limit)
3314 (< (- (point-max) (point)) limit))
3316 (< (count-lines (point) (point-max)) limit))
3317 (and (functionp limit)
3319 (and (stringp limit)
3320 (not (re-search-forward limit nil t))))
3321 () ; This limit did not succeed.
3325 (narrow-to-region (point) (point-max))
3328 (defun gnus-article-search-signature ()
3329 "Search the current buffer for the signature separator.
3330 Put point at the beginning of the signature separator."
3331 (let ((cur (point)))
3332 (goto-char (point-max))
3333 (if (if (stringp gnus-signature-separator)
3334 (re-search-backward gnus-signature-separator nil t)
3335 (let ((seps gnus-signature-separator))
3337 (not (re-search-backward (car seps) nil t)))
3344 (defun gnus-article-hidden-arg ()
3345 "Return the current prefix arg as a number, or 0 if no prefix."
3346 (list (if current-prefix-arg
3347 (prefix-numeric-value current-prefix-arg)
3350 (defun gnus-article-check-hidden-text (type arg)
3351 "Return nil if hiding is necessary.
3352 Arg can be nil or a number. nil and positive means hide, negative
3353 means show, 0 means toggle."
3356 (let ((hide (gnus-article-hidden-text-p type)))
3362 (gnus-article-show-hidden-text type)
3365 (if (eq hide 'hidden)
3367 (gnus-article-show-hidden-text type)
3371 (defun gnus-article-hidden-text-p (type)
3372 "Say whether the current buffer contains hidden text of type TYPE."
3373 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
3375 (not (get-text-property pos 'invisible))
3376 (not (get-text-property pos 'dummy-invisible)))
3378 (text-property-any (1+ pos) (point-max) 'article-type type)))
3383 (defun gnus-article-show-hidden-text (type &optional dummy)
3384 "Show all hidden text of type TYPE.
3385 Originally it is hide instead of DUMMY."
3386 (let ((inhibit-read-only t)
3387 (inhibit-point-motion-hooks t))
3388 (gnus-remove-text-properties-when
3390 (point-min) (point-max)
3391 (cons 'article-type (cons type
3392 gnus-hidden-properties)))
3393 (gnus-delete-wash-type type)))
3395 (defconst article-time-units
3396 `((year . ,(* 365.25 24 60 60))
3397 (week . ,(* 7 24 60 60))
3398 (day . ,(* 24 60 60))
3402 "Mapping from time units to seconds.")
3404 (defun gnus-article-forward-header ()
3405 "Move point to the start of the next header.
3406 If the current header is a continuation header, this can be several
3411 (if (looking-at "[ \t]+[^ \t]")
3415 (defun article-treat-date ()
3416 (article-date-ut (if (gnus-buffer-live-p gnus-summary-buffer)
3417 (with-current-buffer gnus-summary-buffer
3418 gnus-article-date-headers)
3419 gnus-article-date-headers)
3422 (defun article-date-ut (&optional type highlight date-position)
3423 "Convert DATE date to TYPE in the current article.
3424 The default type is `ut'. See `gnus-article-date-headers' for
3426 (interactive (list 'ut t))
3427 (let* ((case-fold-search t)
3428 (inhibit-read-only t)
3429 (inhibit-point-motion-hooks t)
3431 (visible-date (mail-fetch-field "Date"))
3432 pos date bface eface)
3434 (goto-char (point-min))
3435 (when (re-search-forward "^Date:" nil t)
3436 (setq bface (get-text-property (point-at-bol) 'face)
3437 eface (get-text-property (1- (point-at-eol)) 'face)))
3438 ;; Delete any old Date headers.
3441 (goto-char date-position)
3442 (setq date (get-text-property (point) 'original-date))
3443 (delete-region (point)
3445 (gnus-article-forward-header)
3447 (article-transform-date date type bface eface))
3450 (goto-char (point-min))
3451 (while (or (get-text-property (setq pos (point)) 'original-date)
3452 (and (setq pos (next-single-property-change
3453 (point) 'original-date))
3455 (narrow-to-region pos (if (search-forward "\n\n" nil t)
3456 (1+ (match-beginning 0))
3458 (goto-char (point-min))
3459 (while (re-search-forward "^Date:" nil t)
3460 (setq date (get-text-property (match-beginning 0) 'original-date))
3461 (delete-region (point-at-bol) (progn
3462 (gnus-article-forward-header)
3464 (when (and (not date)
3466 (setq date visible-date))
3468 (article-transform-date date type bface eface))
3469 (goto-char (point-max))
3472 (defun article-transform-date (date type bface eface)
3473 (dolist (this-type (cond
3480 (insert (article-make-date-line date (or this-type 'ut)) "\n")
3483 (put-text-property (point) (1+ (point))
3484 'original-date date)
3485 (put-text-property (point) (1+ (point))
3486 'gnus-date-type this-type)
3488 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
3489 (put-text-property (match-beginning 1) (1+ (match-end 1))
3491 (put-text-property (match-beginning 2) (match-end 2)
3495 (defun article-make-date-line (date type)
3496 "Return a DATE line of TYPE."
3497 (unless (memq type '(local ut original user-defined iso8601 lapsed english
3499 (error "Unknown conversion type: %s" type))
3501 (let ((time (ignore-errors (date-to-time date))))
3503 ;; Convert to the local timezone.
3505 (concat "Date: " (message-make-date time)))
3506 ;; Convert to Universal Time.
3511 (let* ((e (parse-time-string date))
3512 (tm (apply 'encode-time e))
3514 (ls (- (cadr tm) (car (current-time-zone time)))))
3515 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
3516 ((> ls 65535) (list (1+ ms) (- ls 65536)))
3520 ;; Get the original date from the article.
3521 ((eq type 'original)
3522 (concat "Date: " (if (string-match "\n+$" date)
3523 (substring date 0 (match-beginning 0))
3525 ;; Let the user define the format.
3526 ((eq type 'user-defined)
3527 (let ((format (or (condition-case nil
3528 (with-current-buffer gnus-summary-buffer
3529 gnus-article-time-format)
3531 gnus-article-time-format)))
3532 (if (functionp format)
3533 (funcall format time)
3534 (concat "Date: " (format-time-string format time)))))
3537 (let ((tz (car (current-time-zone time))))
3540 (format-time-string "%Y%m%dT%H%M%S" time)
3541 (format "%s%02d%02d"
3542 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3543 (/ (% (abs tz) 3600) 60)))))
3544 ;; Do a lapsed format.
3546 (concat "Date: " (article-lapsed-string time)))
3547 ;; A combined date/lapsed format.
3548 ((eq type 'combined-lapsed)
3549 (let ((date-string (article-make-date-line date 'original))
3555 (concat " (" (article-lapsed-string time segments) ")"))
3556 (> (+ (length date-string)
3557 (length lapsed-string))
3560 (setq segments (1- segments)))
3562 (concat date-string lapsed-string)
3564 ;; Display the date in proper English
3566 (let ((dtime (decode-time time)))
3569 (number-to-string (nth 3 dtime))
3570 (let ((digit (% (nth 3 dtime) 10)))
3572 ((memq (nth 3 dtime) '(11 12 13)) "th")
3578 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3580 (number-to-string (nth 5 dtime))
3582 (format "%02d" (nth 2 dtime))
3584 (format "%02d" (nth 1 dtime)))))))
3586 (format "Date: %s (from Gnus)" date))))
3588 (defun article-lapsed-string (time &optional max-segments)
3589 ;; If the date is seriously mangled, the timezone functions are
3590 ;; liable to bug out, so we ignore all errors.
3591 (let* ((now (current-time))
3592 (real-time (subtract-time now time))
3593 (real-sec (and real-time
3594 (+ (* (float (car real-time)) 65536)
3596 (sec (and real-time (abs real-sec)))
3599 (unless max-segments
3600 (setq max-segments (length article-time-units)))
3608 ;; This is a bit convoluted, but basically we go
3609 ;; through the time units for years, weeks, etc,
3610 ;; and divide things to see whether that results
3611 ;; in positive answers.
3614 (if (or (zerop (setq num (ffloor (/ sec (cdr unit)))))
3615 (>= segments max-segments))
3616 ;; The (remaining) seconds are too few to
3617 ;; be divided into this time unit.
3619 ;; It's big enough, so we output it.
3620 (setq sec (- sec (* num (cdr unit))))
3622 (concat (if prev ", " "") (int-to-string
3624 " " (symbol-name (car unit))
3625 (if (> num 1) "s" ""))
3627 segments (1+ segments)))))
3628 article-time-units "")
3629 ;; If dates are odd, then it might appear like the
3630 ;; article was sent in the future.
3633 " in the future"))))))
3635 (defun article-date-local (&optional highlight)
3636 "Convert the current article date to the local timezone."
3637 (interactive (list t))
3638 (article-date-ut 'local highlight))
3640 (defun article-date-english (&optional highlight)
3641 "Convert the current article date to something that is proper English."
3642 (interactive (list t))
3643 (article-date-ut 'english highlight))
3645 (defun article-date-original (&optional highlight)
3646 "Convert the current article date to what it was originally.
3647 This is only useful if you have used some other date conversion
3648 function and want to see what the date was before converting."
3649 (interactive (list t))
3650 (article-date-ut 'original highlight))
3652 (defun article-date-lapsed (&optional highlight)
3653 "Convert the current article date to time lapsed since it was sent."
3654 (interactive (list t))
3655 (article-date-ut 'lapsed highlight))
3657 (defun article-date-combined-lapsed (&optional highlight)
3658 "Convert the current article date to time lapsed since it was sent."
3659 (interactive (list t))
3660 (article-date-ut 'combined-lapsed highlight))
3662 (defun article-update-date-lapsed ()
3663 "Function to be run from a timer to update the lapsed time line."
3665 (let ((buffer (current-buffer)))
3669 (set-buffer (window-buffer w))
3670 (when (eq major-mode 'gnus-article-mode)
3671 (let ((old-line (count-lines (point-min) (point)))
3672 (old-column (- (point) (line-beginning-position)))
3674 (window-start (get-buffer-window (current-buffer)))))
3675 (goto-char (point-min))
3676 (while (re-search-forward "^Date:" nil t)
3677 (let ((type (get-text-property (match-beginning 0)
3679 (when (memq type '(lapsed combined-lapsed user-format))
3680 (when (and window-start
3681 (not (= window-start
3685 (setq window-start nil))
3687 (article-date-ut type t (match-beginning 0)))
3690 (set-window-start (get-buffer-window (current-buffer))
3692 (goto-char (point-min))
3693 (when (> old-column 0)
3694 (setq old-line (1- old-line)))
3695 (forward-line old-line)
3697 (when (> (current-column) old-column)
3699 (forward-char old-column)))))
3701 (set-buffer buffer))))
3703 (defun gnus-start-date-timer (&optional n)
3704 "Start a timer to update the Date headers in the article buffers.
3705 The numerical prefix says how frequently (in seconds) the function
3710 (gnus-stop-date-timer)
3711 (setq article-lapsed-timer
3712 (run-at-time 1 n 'article-update-date-lapsed)))
3714 (defun gnus-stop-date-timer ()
3715 "Stop the Date timer."
3717 (when article-lapsed-timer
3718 (nnheader-cancel-timer article-lapsed-timer)
3719 (setq article-lapsed-timer nil)))
3721 (defun article-date-user (&optional highlight)
3722 "Convert the current article date to the user-defined format.
3723 This format is defined by the `gnus-article-time-format' variable."
3724 (interactive (list t))
3725 (article-date-ut 'user highlight))
3727 (defun article-date-iso8601 (&optional highlight)
3728 "Convert the current article date to ISO8601."
3729 (interactive (list t))
3730 (article-date-ut 'iso8601 highlight))
3732 (defmacro gnus-article-save-original-date (&rest forms)
3733 "Save the original date as a text property and evaluate FORMS."
3734 `(let* ((case-fold-search t)
3736 (goto-char (point-min))
3737 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3740 (date (when (and start
3741 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3743 (buffer-substring-no-properties start
3744 (match-beginning 0)))))
3745 (goto-char (point-max))
3746 (skip-chars-backward "\n")
3747 (put-text-property (point-min) (point) 'original-date date)
3749 (goto-char (point-max))
3750 (skip-chars-backward "\n")
3751 (put-text-property (point-min) (point) 'original-date date)))
3753 ;; (defun article-show-all ()
3754 ;; "Show all hidden text in the article buffer."
3757 ;; (let ((inhibit-read-only t))
3758 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3760 (defun article-remove-leading-whitespace ()
3761 "Remove excessive whitespace from all headers."
3765 (let ((inhibit-read-only t))
3766 (article-narrow-to-head)
3767 (goto-char (point-min))
3768 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3769 (delete-region (match-beginning 1) (match-end 1)))))))
3771 (defun article-emphasize (&optional arg)
3772 "Emphasize text according to `gnus-emphasis-alist'."
3773 (interactive (gnus-article-hidden-arg))
3774 (unless (gnus-article-check-hidden-text 'emphasis arg)
3778 (with-current-buffer gnus-summary-buffer
3779 gnus-article-emphasis-alist)
3781 gnus-emphasis-alist))
3782 (inhibit-read-only t)
3783 (props (append '(article-type emphasis)
3784 gnus-hidden-properties))
3785 regexp elem beg invisible visible face)
3788 (while (setq elem (pop alist))
3790 (setq regexp (car elem)
3791 invisible (nth 1 elem)
3792 visible (nth 2 elem)
3794 (while (re-search-forward regexp nil t)
3795 (when (and (match-beginning visible) (match-beginning invisible))
3796 (gnus-article-hide-text
3797 (match-beginning invisible) (match-end invisible) props)
3798 (gnus-article-unhide-text-type
3799 (match-beginning visible) (match-end visible) 'emphasis)
3800 (gnus-put-overlay-excluding-newlines
3801 (match-beginning visible) (match-end visible) 'face face)
3802 (gnus-add-wash-type 'emphasis)
3803 (goto-char (match-end invisible)))))))))
3805 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3806 "Setup newsgroup emphasis alist."
3807 (unless gnus-article-emphasis-alist
3808 (let ((name (and gnus-newsgroup-name
3809 (gnus-group-real-name gnus-newsgroup-name))))
3810 (make-local-variable 'gnus-article-emphasis-alist)
3811 (setq gnus-article-emphasis-alist
3813 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3814 (while (setq elem (pop alist))
3815 (when (and name (string-match (car elem) name))
3817 highlight (copy-sequence (cdr elem)))))
3819 (copy-sequence highlight-words)
3820 (if gnus-newsgroup-name
3821 (copy-sequence (gnus-group-find-parameter
3822 gnus-newsgroup-name 'highlight-words t)))
3823 gnus-emphasis-alist)))))
3825 (defvar gnus-summary-article-menu)
3826 (defvar gnus-summary-post-menu)
3828 ;;; Saving functions.
3830 (defun gnus-article-save (save-buffer file &optional num)
3831 "Save the currently selected article."
3832 (when (or (get gnus-default-article-saver :headers)
3833 (not gnus-save-all-headers))
3834 ;; Remove headers according to `gnus-saved-headers' or the value
3835 ;; of the `:headers' property that the saver function might have.
3836 (let ((gnus-visible-headers
3837 (or (symbol-value (get gnus-default-article-saver :headers))
3838 gnus-saved-headers gnus-visible-headers))
3839 ;; Ignore group parameter. See `article-hide-headers'.
3840 (gnus-summary-buffer nil))
3841 (with-current-buffer save-buffer
3842 (article-hide-headers 1 t))))
3843 (save-window-excursion
3844 (if (not gnus-default-article-saver)
3845 (error "No default saver is defined")
3846 ;; !!! Magic! The saving functions all save
3847 ;; `gnus-save-article-buffer' (or so they think), but we
3848 ;; bind that variable to our save-buffer.
3849 (set-buffer gnus-article-buffer)
3850 (let* ((gnus-save-article-buffer save-buffer)
3853 ((not gnus-prompt-before-saving) 'default)
3854 ((eq gnus-prompt-before-saving 'always) nil)
3856 (gnus-number-of-articles-to-be-saved
3857 (when (eq gnus-prompt-before-saving t)
3859 (set-buffer gnus-article-current-summary)
3860 (funcall gnus-default-article-saver filename)))))
3862 (defun gnus-read-save-file-name (prompt &optional filename
3863 function group headers variable
3866 (funcall function group headers (symbol-value variable)))
3871 ((eq filename 'default)
3877 (when (symbol-value dir-var)
3878 (setq default-name (expand-file-name
3879 (file-name-nondirectory default-name)
3880 (symbol-value dir-var))))
3881 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3884 (if (and gnus-number-of-articles-to-be-saved
3885 (> gnus-number-of-articles-to-be-saved 1))
3886 (format "these %d articles"
3887 gnus-number-of-articles-to-be-saved)
3890 ;; Let the split methods have their say.
3892 ;; No split name was found.
3895 (concat prompt " (default "
3896 (file-name-nondirectory default-name) "): ")
3897 (file-name-directory default-name)
3899 ;; A single group name is returned.
3900 ((stringp split-name)
3902 (funcall function split-name headers
3903 (symbol-value variable)))
3905 (concat prompt " (default "
3906 (file-name-nondirectory default-name) "): ")
3907 (file-name-directory default-name)
3909 ;; A single split name was found
3910 ((= 1 (length split-name))
3911 (let* ((name (expand-file-name
3913 gnus-article-save-directory))
3914 (dir (cond ((file-directory-p name)
3915 (file-name-as-directory name))
3916 ((file-exists-p name) name)
3917 (t gnus-article-save-directory))))
3919 (concat prompt " (default " name "): ")
3921 ;; A list of splits was found.
3923 (setq split-name (nreverse split-name))
3925 (let ((file-name-history
3926 (nconc split-name file-name-history)))
3930 (concat prompt " (`M-p' for defaults): ")
3931 gnus-article-save-directory
3933 gnus-article-save-directory)))
3934 (car (push result file-name-history)))))))
3935 ;; Create the directory.
3936 (gnus-make-directory (file-name-directory file))
3937 ;; If we have read a directory, we append the default file name.
3938 (when (file-directory-p file)
3939 (setq file (expand-file-name (file-name-nondirectory
3941 (file-name-as-directory file))))
3942 ;; Possibly translate some characters.
3943 (nnheader-translate-file-chars file))))))
3944 (gnus-make-directory (file-name-directory result))
3946 (set variable result))
3948 (set dir-var (file-name-directory result)))
3951 (defun gnus-article-archive-name (group)
3952 "Return the first instance of an \"Archive-name\" in the current buffer."
3953 (let ((case-fold-search t))
3954 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3955 (nnheader-concat gnus-article-save-directory
3956 (match-string 1)))))
3958 (defun gnus-article-nndoc-name (group)
3959 "If GROUP is an nndoc group, return the name of the parent group."
3960 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3961 (gnus-group-get-parameter group 'save-article-group)))
3963 (defun gnus-summary-save-in-rmail (&optional filename)
3964 "Append this article to Rmail file.
3965 Optional argument FILENAME specifies file name.
3966 Directory to save to is default to `gnus-article-save-directory'."
3967 (setq filename (gnus-read-save-file-name
3968 "Save %s in rmail file" filename
3969 gnus-rmail-save-name gnus-newsgroup-name
3970 gnus-current-headers 'gnus-newsgroup-last-rmail))
3971 (with-current-buffer gnus-save-article-buffer
3975 ;; Note that unlike gnus-summary-save-in-mail, there is no
3976 ;; check to see if filename is Babyl. Rmail in Emacs 23 does
3978 (gnus-output-to-rmail filename))))
3981 (defun gnus-summary-save-in-mail (&optional filename)
3982 "Append this article to Unix mail file.
3983 Optional argument FILENAME specifies file name.
3984 Directory to save to is default to `gnus-article-save-directory'."
3985 (setq filename (gnus-read-save-file-name
3986 "Save %s in Unix mail file" filename
3987 gnus-mail-save-name gnus-newsgroup-name
3988 gnus-current-headers 'gnus-newsgroup-last-mail))
3989 (with-current-buffer gnus-save-article-buffer
3993 (if (and (file-readable-p filename)
3994 (file-regular-p filename)
3995 (mail-file-babyl-p filename))
3996 (gnus-output-to-rmail filename)
3997 (gnus-output-to-mail filename)))))
4000 (put 'gnus-summary-save-in-file :decode t)
4001 (put 'gnus-summary-save-in-file :headers 'gnus-saved-headers)
4002 (defun gnus-summary-save-in-file (&optional filename overwrite)
4003 "Append this article to file.
4004 Optional argument FILENAME specifies file name.
4005 Directory to save to is default to `gnus-article-save-directory'."
4006 (setq filename (gnus-read-save-file-name
4007 "Save %s in file" filename
4008 gnus-file-save-name gnus-newsgroup-name
4009 gnus-current-headers 'gnus-newsgroup-last-file))
4010 (with-current-buffer gnus-save-article-buffer
4014 (when (and overwrite
4015 (file-exists-p filename))
4016 (delete-file filename))
4017 (gnus-output-to-file filename))))
4020 (put 'gnus-summary-write-to-file :decode t)
4021 (put 'gnus-summary-write-to-file :function 'gnus-summary-save-in-file)
4022 (put 'gnus-summary-write-to-file :headers 'gnus-saved-headers)
4023 (defun gnus-summary-write-to-file (&optional filename)
4024 "Write this article to a file, overwriting it if the file exists.
4025 Optional argument FILENAME specifies file name.
4026 The directory to save in defaults to `gnus-article-save-directory'."
4027 (setq filename (gnus-read-save-file-name
4028 "Save %s in file" filename
4029 gnus-file-save-name gnus-newsgroup-name
4030 gnus-current-headers nil 'gnus-newsgroup-last-directory))
4031 (gnus-summary-save-in-file filename t))
4033 (put 'gnus-summary-save-body-in-file :decode t)
4034 (defun gnus-summary-save-body-in-file (&optional filename overwrite)
4035 "Append this article body to a file.
4036 Optional argument FILENAME specifies file name.
4037 The directory to save in defaults to `gnus-article-save-directory'."
4038 (setq filename (gnus-read-save-file-name
4039 "Save %s body in file" filename
4040 gnus-file-save-name gnus-newsgroup-name
4041 gnus-current-headers 'gnus-newsgroup-last-file))
4042 (with-current-buffer gnus-save-article-buffer
4046 (when (article-goto-body)
4047 (narrow-to-region (point) (point-max)))
4048 (when (and overwrite
4049 (file-exists-p filename))
4050 (delete-file filename))
4051 (gnus-output-to-file filename))))
4054 (put 'gnus-summary-write-body-to-file :decode t)
4055 (put 'gnus-summary-write-body-to-file
4056 :function 'gnus-summary-save-body-in-file)
4057 (defun gnus-summary-write-body-to-file (&optional filename)
4058 "Write this article body to a file, overwriting it if the file exists.
4059 Optional argument FILENAME specifies file name.
4060 The directory to save in defaults to `gnus-article-save-directory'."
4061 (setq filename (gnus-read-save-file-name
4062 "Save %s body in file" filename
4063 gnus-file-save-name gnus-newsgroup-name
4064 gnus-current-headers nil 'gnus-newsgroup-last-directory))
4065 (gnus-summary-save-body-in-file filename t))
4067 (put 'gnus-summary-save-in-pipe :decode t)
4068 (put 'gnus-summary-save-in-pipe :headers 'gnus-saved-headers)
4069 (defun gnus-summary-save-in-pipe (&optional command raw)
4070 "Pipe this article to subprocess COMMAND.
4071 Valid values for COMMAND include:
4073 The executable command name and possibly arguments.
4075 You will be prompted for the command in the minibuffer.
4076 the symbol `default'
4077 It will be replaced with the command which the variable
4078 `gnus-summary-pipe-output-default-command' holds or the command
4079 last used for saving.
4080 Non-nil value for RAW overrides `:decode' and `:headers' properties
4081 and the raw article including all headers will be piped."
4082 (let ((article (gnus-summary-article-number))
4084 (get 'gnus-summary-save-in-pipe :decode)))
4085 save-buffer default)
4087 (if (vectorp (gnus-summary-article-header article))
4088 (save-current-buffer
4089 (gnus-summary-select-article decode decode nil article)
4090 (insert-buffer-substring
4094 gnus-original-article-buffer)
4096 (nnheader-set-temp-buffer " *Gnus Save*"))))
4097 ;; Remove unwanted headers.
4098 (when (and (not raw)
4099 (or (get 'gnus-summary-save-in-pipe :headers)
4100 (not gnus-save-all-headers)))
4101 (let ((gnus-visible-headers
4102 (or (symbol-value (get 'gnus-summary-save-in-pipe
4104 gnus-saved-headers gnus-visible-headers))
4105 (gnus-summary-buffer nil))
4106 (article-hide-headers 1 t))))
4107 (error "%d is not a real article" article))
4108 (error "No article to pipe"))
4109 (setq default (or gnus-summary-pipe-output-default-command
4110 gnus-last-shell-command))
4111 (unless (stringp command)
4113 (if (and (eq command 'default) default)
4115 (gnus-read-shell-command "Shell command on this article: "
4117 (when (string-equal command "")
4119 (setq command default)
4120 (error "A command is required")))
4121 (with-current-buffer save-buffer
4124 (shell-command-on-region (point-min) (point-max) command nil)))
4125 (gnus-kill-buffer save-buffer))
4126 (setq gnus-summary-pipe-output-default-command command))
4128 (defun gnus-summary-pipe-to-muttprint (&optional command)
4129 "Pipe this article to muttprint."
4130 (unless (stringp command)
4131 (setq command (read-string
4132 "Print using command: " gnus-summary-muttprint-program
4133 nil gnus-summary-muttprint-program)))
4134 (let ((gnus-summary-pipe-output-default-command
4135 gnus-summary-pipe-output-default-command))
4136 (gnus-summary-save-in-pipe command))
4137 (setq gnus-summary-muttprint-program command))
4139 ;;; Article file names when saving.
4141 (defun gnus-capitalize-newsgroup (newsgroup)
4142 "Capitalize NEWSGROUP name."
4143 (when (not (zerop (length newsgroup)))
4144 (concat (char-to-string (upcase (aref newsgroup 0)))
4145 (substring newsgroup 1))))
4147 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
4148 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4149 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
4150 Otherwise, it is like ~/News/news/group/num."
4153 (concat (if (gnus-use-long-file-name 'not-save)
4154 (gnus-capitalize-newsgroup newsgroup)
4155 (gnus-newsgroup-directory-form newsgroup))
4156 "/" (int-to-string (mail-header-number headers)))
4157 gnus-article-save-directory)))
4159 (string-equal (file-name-directory default)
4160 (file-name-directory last-file))
4161 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
4163 (or last-file default))))
4165 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
4166 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4167 If variable `gnus-use-long-file-name' is non-nil, it is
4168 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
4171 (concat (if (gnus-use-long-file-name 'not-save)
4173 (gnus-newsgroup-directory-form newsgroup))
4174 "/" (int-to-string (mail-header-number headers)))
4175 gnus-article-save-directory)))
4177 (string-equal (file-name-directory default)
4178 (file-name-directory last-file))
4179 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
4181 (or last-file default))))
4183 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
4184 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4185 If variable `gnus-use-long-file-name' is non-nil, it is
4186 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
4189 (if (gnus-use-long-file-name 'not-save)
4192 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
4194 gnus-article-save-directory)))
4196 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
4197 "Generate file name from sender."
4198 (let ((from (mail-header-from headers)))
4200 (if (and from (string-match "\\([^ <]+\\)@" from))
4201 (match-string 1 from)
4203 gnus-article-save-directory)))
4205 (defun article-verify-x-pgp-sig ()
4207 ;; <ftp://ftp.isc.org/pub/pgpcontrol/FORMAT>
4209 (if (gnus-buffer-live-p gnus-original-article-buffer)
4210 (let ((sig (with-current-buffer gnus-original-article-buffer
4211 (gnus-fetch-field "X-PGP-Sig")))
4215 (mml2015-clear-verify-function))
4217 (insert-buffer-substring gnus-original-article-buffer)
4218 (setq items (split-string sig))
4219 (message-narrow-to-head)
4220 (let ((inhibit-point-motion-hooks t)
4221 (case-fold-search t))
4222 ;; Don't verify multiple headers.
4223 (setq headers (mapconcat (lambda (header)
4225 (mail-fetch-field header)
4227 (split-string (nth 1 items) ",") "")))
4228 (delete-region (point-min) (point-max))
4229 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
4230 (insert "X-Signed-Headers: " (nth 1 items) "\n")
4235 (if (looking-at "^-")
4238 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
4239 (insert "Version: " (car items) "\n\n")
4240 (insert (mapconcat 'identity (cddr items) "\n"))
4241 (insert "\n-----END PGP SIGNATURE-----\n")
4242 (let ((mm-security-handle (list (format "multipart/signed"))))
4243 (mml2015-clean-buffer)
4244 (let ((coding-system-for-write (or gnus-newsgroup-charset
4246 (funcall (mml2015-clear-verify-function)))
4248 (or (mm-handle-multipart-ctl-parameter
4249 mm-security-handle 'gnus-details)
4250 (mm-handle-multipart-ctl-parameter
4251 mm-security-handle 'gnus-info)))))
4253 (let ((inhibit-read-only t) bface eface)
4255 (message-narrow-to-head)
4256 (goto-char (point-max))
4258 (setq bface (get-text-property (point-at-bol) 'face)
4259 eface (get-text-property (1- (point-at-eol)) 'face))
4260 (message-remove-header "X-Gnus-PGP-Verify")
4261 (if (re-search-forward "^X-PGP-Sig:" nil t)
4263 (goto-char (point-max)))
4264 (narrow-to-region (point) (point))
4265 (insert "X-Gnus-PGP-Verify: " info "\n")
4266 (goto-char (point-min))
4269 (if (not (looking-at "^[ \t]"))
4273 (goto-char (point-min))
4274 (when (looking-at "\\([^:]+\\): *")
4275 (put-text-property (match-beginning 1) (1+ (match-end 1))
4277 (put-text-property (match-end 0) (point-max)
4278 'face eface)))))))))
4280 (autoload 'canlock-verify "canlock" nil t) ;; for XEmacs.
4282 (defun article-verify-cancel-lock ()
4283 "Verify Cancel-Lock header."
4285 (if (gnus-buffer-live-p gnus-original-article-buffer)
4286 (canlock-verify gnus-original-article-buffer)))
4293 (setq afunc (car func)
4296 gfunc (intern (format "gnus-%s" func))))
4298 (when (fboundp afunc)
4299 `(lambda (&optional interactive &rest args)
4300 ,(documentation afunc t)
4301 (interactive (list t))
4302 (with-current-buffer gnus-article-buffer
4304 (call-interactively ',afunc)
4305 (apply ',afunc args))))))))
4306 '(article-hide-headers
4307 article-verify-x-pgp-sig
4308 article-verify-cancel-lock
4309 article-hide-boring-headers
4310 article-treat-overstrike
4311 article-treat-ansi-sequences
4312 article-fill-long-lines
4313 article-capitalize-sentences
4315 article-remove-leading-whitespace
4316 article-display-x-face
4317 article-display-face
4318 article-de-quoted-unreadable
4319 article-de-base64-unreadable
4322 article-unsplit-urls
4323 article-hide-list-identifiers
4324 article-strip-banner
4327 article-hide-signature
4328 article-strip-headers-in-body
4329 article-remove-trailing-blank-lines
4330 article-strip-leading-blank-lines
4331 article-strip-multiple-blank-lines
4332 article-strip-leading-space
4333 article-strip-trailing-space
4334 article-strip-blank-lines
4335 article-strip-all-blank-lines
4337 article-date-english
4338 article-date-iso8601
4339 article-date-original
4342 article-decode-mime-words
4343 article-decode-charset
4344 article-decode-encoded-words
4347 article-date-combined-lapsed
4349 article-treat-dumbquotes
4350 article-treat-non-ascii
4351 article-normalize-headers
4352 ;;(article-show-all . gnus-article-show-all-headers)
4356 ;;; Gnus article mode
4359 (put 'gnus-article-mode 'mode-class 'special)
4361 (set-keymap-parent gnus-article-mode-map widget-keymap)
4363 (gnus-define-keys gnus-article-mode-map
4364 " " gnus-article-goto-next-page
4365 "\177" gnus-article-goto-prev-page
4366 [delete] gnus-article-goto-prev-page
4367 [backspace] gnus-article-goto-prev-page
4368 "\C-c^" gnus-article-refer-article
4369 "h" gnus-article-show-summary
4370 "s" gnus-article-show-summary
4371 "\C-c\C-m" gnus-article-mail
4372 "?" gnus-article-describe-briefly
4373 "<" beginning-of-buffer
4375 "\C-c\C-i" gnus-info-find-node
4377 "R" gnus-article-reply-with-original
4378 "F" gnus-article-followup-with-original
4379 "\C-hk" gnus-article-describe-key
4380 "\C-hc" gnus-article-describe-key-briefly
4381 "\C-hb" gnus-article-describe-bindings
4383 "e" gnus-article-read-summary-keys
4384 "\C-d" gnus-article-read-summary-keys
4385 "\M-*" gnus-article-read-summary-keys
4386 "\M-#" gnus-article-read-summary-keys
4387 "\M-^" gnus-article-read-summary-keys
4388 "\M-g" gnus-article-read-summary-keys)
4390 (substitute-key-definition
4391 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
4393 (gnus-define-keys (gnus-article-send-map "S" gnus-article-mode-map)
4394 "W" gnus-article-wide-reply-with-original)
4395 (if (featurep 'xemacs)
4396 (set-keymap-default-binding gnus-article-send-map
4397 'gnus-article-read-summary-send-keys)
4398 (define-key gnus-article-send-map [t] 'gnus-article-read-summary-send-keys))
4400 (defun gnus-article-make-menu-bar ()
4401 (unless (boundp 'gnus-article-commands-menu)
4402 (gnus-summary-make-menu-bar))
4403 (unless (boundp 'gnus-article-article-menu)
4405 gnus-article-article-menu gnus-article-mode-map ""
4407 ["Scroll forwards" gnus-article-goto-next-page t]
4408 ["Scroll backwards" gnus-article-goto-prev-page t]
4409 ["Show summary" gnus-article-show-summary t]
4410 ["Fetch Message-ID at point" gnus-article-refer-article t]
4411 ["Mail to address at point" gnus-article-mail t]
4412 ["Send a bug report" gnus-bug t]))
4415 gnus-article-treatment-menu gnus-article-mode-map ""
4416 ;; Fixme: this should use :active (and maybe :visible).
4418 ["Hide headers" gnus-article-hide-headers t]
4419 ["Hide signature" gnus-article-hide-signature t]
4420 ["Hide citation" gnus-article-hide-citation t]
4421 ["Treat overstrike" gnus-article-treat-overstrike t]
4422 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
4423 ["Remove carriage return" gnus-article-remove-cr t]
4424 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
4425 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
4426 ["Remove base64" gnus-article-de-base64-unreadable t]
4427 ["Treat html" gnus-article-wash-html t]
4428 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
4429 ["Decode HZ" gnus-article-decode-HZ t]))
4431 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
4433 ;; Note "Post" menu is defined in gnus-sum.el for consistency
4435 (gnus-run-hooks 'gnus-article-menu-hook)))
4437 (defvar bookmark-make-record-function)
4438 (defvar shr-put-image-function)
4440 (defun gnus-article-mode ()
4441 "Major mode for displaying an article.
4443 All normal editing commands are switched off.
4445 The following commands are available in addition to all summary mode
4447 \\<gnus-article-mode-map>
4448 \\[gnus-article-next-page]\t Scroll the article one page forwards
4449 \\[gnus-article-prev-page]\t Scroll the article one page backwards
4450 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
4451 \\[gnus-article-show-summary]\t Display the summary buffer
4452 \\[gnus-article-mail]\t Send a reply to the address near point
4453 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
4454 \\[gnus-info-find-node]\t Go to the Gnus info node"
4456 (kill-all-local-variables)
4457 (gnus-simplify-mode-line)
4458 (setq mode-name "Article")
4459 (setq major-mode 'gnus-article-mode)
4460 (make-local-variable 'minor-mode-alist)
4461 (use-local-map gnus-article-mode-map)
4462 (when (gnus-visual-p 'article-menu 'menu)
4463 (gnus-article-make-menu-bar)
4464 (when gnus-summary-tool-bar-map
4465 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
4466 (gnus-update-format-specifications nil 'article-mode)
4467 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
4468 (set (make-local-variable 'gnus-page-broken) nil)
4469 (make-local-variable 'gnus-article-current-summary)
4470 (make-local-variable 'gnus-article-mime-handles)
4471 (make-local-variable 'gnus-article-decoded-p)
4472 (make-local-variable 'gnus-article-mime-handle-alist)
4473 (make-local-variable 'gnus-article-wash-types)
4474 (make-local-variable 'gnus-article-image-alist)
4475 (make-local-variable 'gnus-article-charset)
4476 (make-local-variable 'gnus-article-ignored-charsets)
4477 (set (make-local-variable 'bookmark-make-record-function)
4478 'gnus-summary-bookmark-make-record)
4479 ;; Prevent Emacs 22 from displaying non-break space with `nobreak-space'
4481 (set (make-local-variable 'nobreak-char-display) nil)
4482 ;; Enable `gnus-article-remove-images' to delete images shr.el renders.
4483 (set (make-local-variable 'shr-put-image-function) 'gnus-shr-put-image)
4484 (setq cursor-in-non-selected-windows nil)
4485 (gnus-set-default-directory)
4486 (buffer-disable-undo)
4487 (setq buffer-read-only t
4488 show-trailing-whitespace nil)
4489 (set-syntax-table gnus-article-mode-syntax-table)
4490 (mm-enable-multibyte)
4491 (gnus-run-mode-hooks 'gnus-article-mode-hook))
4493 (defun gnus-article-setup-buffer ()
4494 "Initialize the article buffer."
4495 (let* ((name (if gnus-single-article-buffer "*Article*"
4497 (gnus-group-decoded-name gnus-newsgroup-name)
4500 (progn (string-match "\\*Article" name)
4501 (concat " *Original Article"
4502 (substring name (match-end 0))))))
4503 (setq gnus-article-buffer name)
4504 (setq gnus-original-article-buffer original)
4505 (setq gnus-article-mime-handle-alist nil)
4506 (with-current-buffer gnus-summary-buffer
4507 ;; This might be a variable local to the summary buffer.
4508 (unless gnus-single-article-buffer
4509 (setq gnus-article-buffer name)
4510 (setq gnus-original-article-buffer original)
4511 (gnus-set-global-variables)))
4512 (gnus-article-setup-highlight-words)
4513 ;; Init original article buffer.
4514 (with-current-buffer (gnus-get-buffer-create gnus-original-article-buffer)
4515 (mm-enable-multibyte)
4516 (setq major-mode 'gnus-original-article-mode)
4517 (make-local-variable 'gnus-original-article))
4518 (if (and (get-buffer name)
4519 (with-current-buffer name
4520 (if gnus-article-edit-mode
4521 (if (y-or-n-p "Article mode edit in progress; discard? ")
4523 (set-buffer-modified-p nil)
4524 (gnus-kill-buffer name)
4527 (error "Action aborted"))
4529 (with-current-buffer name
4530 (set (make-local-variable 'gnus-article-edit-mode) nil)
4531 (gnus-article-stop-animations)
4532 (when gnus-article-mime-handles
4533 (mm-destroy-parts gnus-article-mime-handles)
4534 (setq gnus-article-mime-handles nil))
4535 ;; Set it to nil in article-buffer!
4536 (setq gnus-article-mime-handle-alist nil)
4537 (buffer-disable-undo)
4538 (setq buffer-read-only t)
4539 (unless (eq major-mode 'gnus-article-mode)
4540 (gnus-article-mode))
4541 (setq truncate-lines gnus-article-truncate-lines)
4543 (let ((summary gnus-summary-buffer))
4544 (with-current-buffer (gnus-get-buffer-create name)
4546 (setq truncate-lines gnus-article-truncate-lines)
4547 (set (make-local-variable 'gnus-summary-buffer) summary)
4548 (gnus-summary-set-local-parameters gnus-newsgroup-name)
4549 (when article-lapsed-timer
4550 (gnus-stop-date-timer))
4551 (when gnus-article-update-date-headers
4552 (gnus-start-date-timer gnus-article-update-date-headers))
4553 (current-buffer))))))
4555 (defun gnus-article-stop-animations ()
4556 (dolist (timer (and (boundp 'timer-list)
4558 (when (eq (gnus-timer--function timer) 'image-animate-timeout)
4559 (cancel-timer timer))))
4561 (defun gnus-stop-downloads ()
4562 (when (boundp 'url-queue)
4563 (set (intern "url-queue" obarray) nil)))
4565 ;; Set article window start at LINE, where LINE is the number of lines
4566 ;; from the head of the article.
4567 (defun gnus-article-set-window-start (&optional line)
4568 (let ((article-window (gnus-get-buffer-window gnus-article-buffer t)))
4569 (when article-window
4572 (with-current-buffer gnus-article-buffer
4573 (goto-char (point-min))
4576 (gnus-message 6 "Moved to bookmark")
4577 (search-forward "\n\n" nil t)
4581 (defun gnus-article-prepare (article &optional all-headers header)
4582 "Prepare ARTICLE in article mode buffer.
4583 ARTICLE should either be an article number or a Mess