1 ;;; gnus-art.el --- article mode commands for Gnus
3 ;; Copyright (C) 1996-2015 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/>.
30 (defvar w3m-minor-mode-map)
47 (autoload 'gnus-msg-mail "gnus-msg" nil t)
48 (autoload 'gnus-button-mailto "gnus-msg")
49 (autoload 'gnus-button-reply "gnus-msg" nil t)
50 (autoload 'parse-time-string "parse-time" nil nil)
51 (autoload 'ansi-color-apply-on-region "ansi-color")
52 (autoload 'mm-url-insert-file-contents-external "mm-url")
53 (autoload 'mm-extern-cache-contents "mm-extern")
55 (defgroup gnus-article nil
57 :link '(custom-manual "(gnus)Article Buffer")
60 (defgroup gnus-article-treat nil
61 "Treating article parts."
62 :link '(custom-manual "(gnus)Article Hiding")
65 (defgroup gnus-article-hiding nil
66 "Hiding article parts."
67 :link '(custom-manual "(gnus)Article Hiding")
70 (defgroup gnus-article-highlight nil
71 "Article highlighting."
72 :link '(custom-manual "(gnus)Article Highlighting")
76 (defgroup gnus-article-signature nil
78 :link '(custom-manual "(gnus)Article Signature")
81 (defgroup gnus-article-headers nil
83 :link '(custom-manual "(gnus)Hiding Headers")
86 (defgroup gnus-article-washing nil
87 "Special commands on articles."
88 :link '(custom-manual "(gnus)Article Washing")
91 (defgroup gnus-article-emphasis nil
92 "Fontisizing articles."
93 :link '(custom-manual "(gnus)Article Fontisizing")
96 (defgroup gnus-article-saving nil
98 :link '(custom-manual "(gnus)Saving Articles")
101 (defgroup gnus-article-mime nil
102 "Worshiping the MIME wonder."
103 :link '(custom-manual "(gnus)Using MIME")
104 :group 'gnus-article)
106 (defgroup gnus-article-buttons nil
107 "Pushable buttons in the article buffer."
108 :link '(custom-manual "(gnus)Article Buttons")
109 :group 'gnus-article)
111 (defgroup gnus-article-various nil
112 "Other article options."
113 :link '(custom-manual "(gnus)Misc Article")
114 :group 'gnus-article)
116 (defcustom gnus-ignored-headers
119 (concat "^" header ":"))
120 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
121 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
122 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
123 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
124 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
125 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
126 "X-Attribution" "X-Originating-IP" "Delivered-To"
127 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
128 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
129 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
130 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
131 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
132 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
133 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
134 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
135 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
136 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
137 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
138 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
139 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
140 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
141 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
142 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
143 "List-[A-Za-z]+" "X-Listprocessor-Version"
144 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
145 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
146 "X-Received" "Content-length" "X-precedence"
147 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
148 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
149 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
150 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
151 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
152 "X-Content-length" "X-Posting-Agent" "Original-Received"
153 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
154 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
155 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
156 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
157 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"
158 "Envelope-To" "X-Spam-Score" "System-Type" "X-Injected-Via-Gmane"
159 "X-Gmane-NNTP-Posting-Host" "Jabber-ID" "Archived-At"
160 "Envelope-Sender" "Envelope-Recipients"))
161 "*All headers that start with this regexp will be hidden.
162 This variable can also be a list of regexps of headers to be ignored.
163 If `gnus-visible-headers' is non-nil, this variable will be ignored."
164 :type '(choice regexp
166 :group 'gnus-article-hiding)
168 (defcustom gnus-visible-headers
169 "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^[BGF]?Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Mail-Followup-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:"
170 "*All headers that do not match this regexp will be hidden.
171 This variable can also be a list of regexp of headers to remain visible.
172 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
174 (repeat :value-to-internal (lambda (widget value)
175 (custom-split-regexp-maybe value))
176 :match (lambda (widget value)
178 (widget-editable-list-match widget value)))
180 (const :tag "Use gnus-ignored-headers" nil)
182 :group 'gnus-article-hiding)
184 (defcustom gnus-sorted-header-list
185 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
186 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
187 "*This variable is a list of regular expressions.
188 If it is non-nil, headers that match the regular expressions will
189 be placed first in the article buffer in the sequence specified by
191 :type '(repeat regexp)
192 :group 'gnus-article-hiding)
194 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
195 "Headers that are only to be displayed if they have interesting data.
196 Possible values in this list are:
198 'empty Headers with no content.
199 'newsgroups Newsgroup identical to Gnus group.
200 'to-address To identical to To-address.
201 'to-list To identical to To-list.
202 'cc-list CC identical to To-list.
203 'followup-to Followup-to identical to Newsgroups.
204 'reply-to Reply-to identical to From.
205 'date Date less than four days old.
206 'long-to To and/or Cc longer than 1024 characters.
207 'many-to Multiple To and/or Cc."
208 :type '(set (const :tag "Headers with no content." empty)
209 (const :tag "Newsgroups identical to Gnus group." newsgroups)
210 (const :tag "To identical to To-address." to-address)
211 (const :tag "To identical to To-list." to-list)
212 (const :tag "CC identical to To-list." cc-list)
213 (const :tag "Followup-to identical to Newsgroups." followup-to)
214 (const :tag "Reply-to identical to From." reply-to)
215 (const :tag "Date less than four days old." date)
216 (const :tag "To and/or Cc longer than 1024 characters." long-to)
217 (const :tag "Multiple To and/or Cc headers." many-to))
218 :group 'gnus-article-hiding)
220 (defcustom gnus-article-skip-boring nil
221 "Skip over text that is not worth reading.
222 By default, if you set this t, then Gnus will display citations and
223 signatures, but will never scroll down to show you a page consisting
224 only of boring text. Boring text is controlled by
225 `gnus-article-boring-faces'."
228 :group 'gnus-article-hiding)
230 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
231 "Regexp matching signature separator.
232 This can also be a list of regexps. In that case, it will be checked
233 from head to tail looking for a separator. Searches will be done from
234 the end of the buffer."
235 :type '(choice :format "%{%t%}: %[Value Menu%]\n%v"
237 (repeat :tag "List of regexp" regexp))
238 :group 'gnus-article-signature)
240 (defcustom gnus-signature-limit nil
241 "Provide a limit to what is considered a signature.
242 If it is a number, no signature may not be longer (in characters) than
243 that number. If it is a floating point number, no signature may be
244 longer (in lines) than that number. If it is a function, the function
245 will be called without any parameters, and if it returns nil, there is
246 no signature in the buffer. If it is a string, it will be used as a
247 regexp. If it matches, the text in question is not a signature.
249 This can also be a list of the above values."
250 :type '(choice (const nil)
254 (regexp :value ".*"))
255 :group 'gnus-article-signature)
257 (defcustom gnus-hidden-properties
258 (if (featurep 'xemacs)
259 ;; `intangible' is evil, but I keep it here in case it's useful.
260 '(invisible t intangible t)
261 ;; Emacs's command loop moves point out of invisible text anyway, so
262 ;; `intangible' is clearly not needed there.
264 "Property list to use for hiding text."
266 :group 'gnus-article-hiding)
268 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
269 ;; frames in a session.
270 (defcustom gnus-article-x-face-command
271 (if (featurep 'xemacs)
272 (if (or (gnus-image-type-available-p 'xface)
273 (gnus-image-type-available-p 'pbm))
274 'gnus-display-x-face-in-from
276 '/* Format_version=1, Width=48, Height=48, Depth=1, Valid_bits_per_item=16 */'\
277 ; uncompface; } | icontopbm | ee -")
278 (if (gnus-image-type-available-p 'pbm)
279 'gnus-display-x-face-in-from
281 '/* Format_version=1, Width=48, Height=48, Depth=1, Valid_bits_per_item=16 */'\
282 ; uncompface; } | icontopbm | display -"))
283 "*String or function to be executed to display an X-Face header.
284 If it is a string, the command will be executed in a sub-shell
285 asynchronously. The compressed face will be piped to this command."
286 :type `(choice string
287 (function-item gnus-display-x-face-in-from)
291 :group 'gnus-article-washing)
293 (defcustom gnus-article-x-face-too-ugly nil
294 "Regexp matching posters whose face shouldn't be shown automatically."
295 :type '(choice regexp (const nil))
296 :group 'gnus-article-washing)
298 (defcustom gnus-article-banner-alist nil
299 "Banner alist for stripping.
301 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
303 :type '(repeat (cons symbol regexp))
304 :group 'gnus-article-washing)
306 (gnus-define-group-parameter
309 "Alist of regexps (to match group names) and banner."
310 :variable-group gnus-article-washing
312 '(choice :tag "Banner"
314 (const :tag "Remove signature" signature)
315 (symbol :tag "Item in `gnus-article-banner-alist'" none)
317 (const :tag "None" nil))
319 "If non-nil, specify how to remove `banners' from articles.
321 Symbol `signature' means to remove signatures delimited by
322 `gnus-signature-separator'. Any other symbol is used to look up a
323 regular expression to match the banner in `gnus-article-banner-alist'.
324 A string is used as a regular expression to match the banner
327 (defcustom gnus-article-address-banner-alist nil
328 "Alist of mail addresses and banners.
329 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
330 to match a mail address in the From: header, BANNER is one of a symbol
331 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
332 If ADDRESS matches author's mail address, it will remove things like
333 advertisements. For example:
335 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
339 (regexp :tag "Address")
340 (choice :tag "Banner" :value nil
341 (const :tag "Remove signature" signature)
342 (symbol :tag "Item in `gnus-article-banner-alist'" none)
344 (const :tag "None" nil))))
346 :group 'gnus-article-washing)
348 (defmacro gnus-emphasis-custom-with-format (&rest body)
350 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
351 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
354 (defun gnus-emphasis-custom-value-to-external (value)
355 (gnus-emphasis-custom-with-format
356 (if (consp (car value))
357 (list (format format (car (car value)) (cdr (car value)))
359 (if (nth 1 value) 2 3)
363 (defun gnus-emphasis-custom-value-to-internal (value)
364 (gnus-emphasis-custom-with-format
365 (let ((regexp (concat "\\`"
366 (format (regexp-quote format)
367 "\\([^()]+\\)" "\\([^()]+\\)")
370 (if (string-match regexp (setq pattern (car value)))
371 (list (cons (match-string 1 pattern) (match-string 2 pattern))
376 (defcustom gnus-emphasis-alist
378 '(("\\*" "\\*" bold nil 2)
381 ("_/" "/_" underline-italic)
382 ("_\\*" "\\*_" underline-bold)
383 ("\\*/" "/\\*" bold-italic)
384 ("_\\*/" "/\\*_" underline-bold-italic))))
386 (gnus-emphasis-custom-with-format
387 (mapcar (lambda (spec)
388 (list (format format (car spec) (cadr spec))
391 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
393 '(;; I've never seen anyone use this strikethru convention whereas I've
394 ;; several times seen it triggered by normal text. --Stef
395 ;; Miles suggests that this form is sometimes used but for italics,
396 ;; so maybe we should map it to `italic'.
397 ;; ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
398 ;; 2 3 gnus-emphasis-strikethru)
399 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
400 2 3 gnus-emphasis-underline))))
401 "*Alist that says how to fontify certain phrases.
402 Each item looks like this:
404 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
406 The first element is a regular expression to be matched. The second
407 is a number that says what regular expression grouping used to find
408 the entire emphasized word. The third is a number that says what
409 regexp grouping should be displayed and highlighted. The fourth
410 is the face used for highlighting."
414 :format "%[Customizing Style%]\n%v"
416 (group :tag "Default"
417 :value ("" 0 0 default)
420 (let ((value (widget-get
421 (cadr (widget-get (widget-get widget :parent)
424 (if (not (eq (nth 2 value) 'default))
428 (gnus-emphasis-custom-value-to-external value))))
429 (widget-group-value-create widget))
431 (integer :format "Match group: %v")
432 (integer :format "Emphasize group: %v")
435 :value (("_" . "_") nil default)
437 (regexp :format "Start regexp: %v")
438 (regexp :format "End regexp: %v"))
439 (boolean :format "Show start and end patterns: %[%v%]\n"
440 :on " On " :off " Off ")
442 :get (lambda (symbol)
443 (mapcar 'gnus-emphasis-custom-value-to-internal
444 (default-value symbol)))
445 :set (lambda (symbol value)
446 (set-default symbol (mapcar 'gnus-emphasis-custom-value-to-external
448 :group 'gnus-article-emphasis)
450 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
451 "A regexp to describe whitespace which should not be emphasized.
452 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
453 The former avoids underlining of leading and trailing whitespace,
454 and the latter avoids underlining any whitespace at all."
456 :group 'gnus-article-emphasis
459 (defface gnus-emphasis-bold '((t (:bold t)))
460 "Face used for displaying strong emphasized text (*word*)."
461 :group 'gnus-article-emphasis)
463 (defface gnus-emphasis-italic '((t (:italic t)))
464 "Face used for displaying italic emphasized text (/word/)."
465 :group 'gnus-article-emphasis)
467 (defface gnus-emphasis-underline '((t (:underline t)))
468 "Face used for displaying underlined emphasized text (_word_)."
469 :group 'gnus-article-emphasis)
471 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
472 "Face used for displaying underlined bold emphasized text (_*word*_)."
473 :group 'gnus-article-emphasis)
475 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
476 "Face used for displaying underlined italic emphasized text (_/word/_)."
477 :group 'gnus-article-emphasis)
479 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
480 "Face used for displaying bold italic emphasized text (/*word*/)."
481 :group 'gnus-article-emphasis)
483 (defface gnus-emphasis-underline-bold-italic
484 '((t (:bold t :italic t :underline t)))
485 "Face used for displaying underlined bold italic emphasized text.
486 Example: (_/*word*/_)."
487 :group 'gnus-article-emphasis)
489 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
490 '((t (:strikethru t)))
491 '((t (:strike-through t))))
492 "Face used for displaying strike-through text (-word-)."
493 :group 'gnus-article-emphasis)
495 (defface gnus-emphasis-highlight-words
496 '((t (:background "black" :foreground "yellow")))
497 "Face used for displaying highlighted words."
498 :group 'gnus-article-emphasis)
500 (defcustom gnus-article-time-format "%a, %d %b %Y %T %Z"
501 "Format for display of Date headers in article bodies.
502 See `format-time-string' for the possible values.
504 The variable can also be function, which should return a complete Date
505 header. The function is called with one argument, the time, which can
506 be fed to `format-time-string'."
507 :type '(choice string function)
508 :link '(custom-manual "(gnus)Article Date")
509 :group 'gnus-article-washing)
511 (defcustom gnus-save-all-headers t
512 "*If non-nil, don't remove any headers before saving.
513 This will be overridden by the `:headers' property that the symbol of
514 the saver function, which is specified by `gnus-default-article-saver',
516 :group 'gnus-article-saving
519 (defcustom gnus-prompt-before-saving 'always
520 "*This variable says how much prompting is to be done when saving articles.
521 If it is nil, no prompting will be done, and the articles will be
522 saved to the default files. If this variable is `always', each and
523 every article that is saved will be preceded by a prompt, even when
524 saving large batches of articles. If this variable is neither nil not
525 `always', there the user will be prompted once for a file name for
526 each invocation of the saving commands."
527 :group 'gnus-article-saving
528 :type '(choice (item always)
529 (item :tag "never" nil)
530 (sexp :tag "once" :format "%t\n" :value t)))
532 (defcustom gnus-saved-headers gnus-visible-headers
533 "Headers to keep if `gnus-save-all-headers' is nil.
534 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
535 If that variable is nil, however, all headers that match this regexp
536 will be kept while the rest will be deleted before saving. This and
537 `gnus-save-all-headers' will be overridden by the `:headers' property
538 that the symbol of the saver function, which is specified by
539 `gnus-default-article-saver', might have."
540 :group 'gnus-article-saving
543 ;; Note that "Rmail format" is mbox since Emacs 23, but Babyl before.
544 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
545 "A function to save articles in your favorite format.
546 The function will be called by way of the `gnus-summary-save-article'
547 command, and friends such as `gnus-summary-save-article-rmail'.
549 Gnus provides the following functions:
551 * gnus-summary-save-in-rmail (Rmail format)
552 * gnus-summary-save-in-mail (Unix mail format)
553 * gnus-summary-save-in-folder (MH folder)
554 * gnus-summary-save-in-file (article format)
555 * gnus-summary-save-body-in-file (article body)
556 * gnus-summary-save-in-vm (use VM's folder format)
557 * gnus-summary-write-to-file (article format -- overwrite)
558 * gnus-summary-write-body-to-file (article body -- overwrite)
559 * gnus-summary-save-in-pipe (article format)
561 The symbol of each function may have the following properties:
564 The value non-nil means save decoded articles. This is meaningful
565 only with `gnus-summary-save-in-file', `gnus-summary-save-body-in-file',
566 `gnus-summary-write-to-file', `gnus-summary-write-body-to-file', and
567 `gnus-summary-save-in-pipe'.
570 The value specifies an alternative function which appends, not
571 overwrites, articles to a file. This implies that when saving many
572 articles at a time, `gnus-prompt-before-saving' is bound to t and all
573 articles are saved in a single file. This is meaningful only with
574 `gnus-summary-write-to-file' and `gnus-summary-write-body-to-file'.
577 The value specifies the symbol of a variable of which the value
578 specifies headers to be saved. If it is omitted,
579 `gnus-save-all-headers' and `gnus-saved-headers' control what
580 headers should be saved."
581 :group 'gnus-article-saving
582 :type '(radio (function-item gnus-summary-save-in-rmail)
583 (function-item gnus-summary-save-in-mail)
584 (function-item gnus-summary-save-in-folder)
585 (function-item gnus-summary-save-in-file)
586 (function-item gnus-summary-save-body-in-file)
587 (function-item gnus-summary-save-in-vm)
588 (function-item gnus-summary-write-to-file)
589 (function-item gnus-summary-write-body-to-file)
590 (function-item gnus-summary-save-in-pipe)
593 (defcustom gnus-article-save-coding-system
594 (or (and (mm-coding-system-p 'utf-8) 'utf-8)
595 (and (mm-coding-system-p 'iso-2022-7bit) 'iso-2022-7bit)
596 (and (mm-coding-system-p 'emacs-mule) 'emacs-mule)
597 (and (mm-coding-system-p 'escape-quoted) 'escape-quoted))
598 "Coding system used to save decoded articles to a file.
600 The recommended coding systems are `utf-8', `iso-2022-7bit' and so on,
601 which can safely encode any characters in text. This is used by the
604 * gnus-summary-save-article-file
605 * gnus-summary-save-article-body-file
606 * gnus-summary-write-article-file
607 * gnus-summary-write-article-body-file
609 and the functions to which you may set `gnus-default-article-saver':
611 * gnus-summary-save-in-file
612 * gnus-summary-save-body-in-file
613 * gnus-summary-write-to-file
614 * gnus-summary-write-body-to-file
616 Those commands and functions save just text displayed in the article
617 buffer to a file if the value of this variable is non-nil. Note that
618 buttonized MIME parts will be lost in a saved file in that case.
619 Otherwise, raw articles will be saved."
620 :group 'gnus-article-saving
622 :format "%{%t%}:\n %[Value Menu%] %v"
623 (const :tag "Save raw articles" nil)
626 (lambda (arg) (if (mm-coding-system-p (nth 3 arg)) arg))
627 '((const :tag "UTF-8" utf-8)
628 (const :tag "iso-2022-7bit" iso-2022-7bit)
629 (const :tag "Emacs internal" emacs-mule)
630 (const :tag "escape-quoted" escape-quoted))))
631 (symbol :tag "Coding system")))
633 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
634 "A function generating a file name to save articles in Rmail format.
635 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
636 :group 'gnus-article-saving
639 (defcustom gnus-mail-save-name 'gnus-plain-save-name
640 "A function generating a file name to save articles in Unix mail format.
641 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
642 :group 'gnus-article-saving
645 (defcustom gnus-folder-save-name 'gnus-folder-save-name
646 "A function generating a file name to save articles in MH folder.
647 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
648 :group 'gnus-article-saving
651 (defcustom gnus-file-save-name 'gnus-numeric-save-name
652 "A function generating a file name to save articles in article format.
653 The function is called with NEWSGROUP, HEADERS, and optional
655 :group 'gnus-article-saving
658 (defcustom gnus-split-methods
659 '((gnus-article-archive-name)
660 (gnus-article-nndoc-name))
661 "*Variable used to suggest where articles are to be saved.
662 For instance, if you would like to save articles related to Gnus in
663 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
664 you could set this variable to something like:
666 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
667 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
669 This variable is an alist where the key is the match and the
670 value is a list of possible files to save in if the match is
673 If the match is a string, it is used as a regexp match on the
674 article. If the match is a symbol, that symbol will be funcalled
675 from the buffer of the article to be saved with the newsgroup as the
676 parameter. If it is a list, it will be evalled in the same buffer.
678 If this form or function returns a string, this string will be used as a
679 possible file name; and if it returns a non-nil list, that list will be
680 used as possible file names."
681 :group 'gnus-article-saving
682 :type '(repeat (choice (list :value (fun) function)
683 (cons :value ("" "") regexp (repeat string))
686 (defcustom gnus-page-delimiter "^\^L"
687 "*Regexp describing what to use as article page delimiters.
688 The default value is \"^\^L\", which is a form linefeed at the
689 beginning of a line."
691 :group 'gnus-article-various)
693 (defcustom gnus-article-mode-line-format "Gnus: %g %S%m"
694 "*The format specification for the article mode line.
695 See `gnus-summary-mode-line-format' for a closer description.
697 The following additional specs are available:
699 %w The article washing status.
700 %m The number of MIME parts in the article."
703 :group 'gnus-article-various)
705 (defcustom gnus-article-mode-hook nil
706 "*A hook for Gnus article mode."
708 :group 'gnus-article-various)
710 (when (featurep 'xemacs)
711 ;; Extracted from gnus-xmas-define in order to preserve user settings
712 (when (fboundp 'turn-off-scroll-in-place)
713 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
714 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
715 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
717 (defcustom gnus-article-menu-hook nil
718 "*Hook run after the creation of the article mode menu."
720 :group 'gnus-article-various)
722 (defcustom gnus-article-prepare-hook nil
723 "*A hook called after an article has been prepared in the article buffer."
725 :group 'gnus-article-various)
727 (defcustom gnus-copy-article-ignored-headers nil
728 "List of headers to be removed when copying an article.
729 Each element is a regular expression."
730 :version "23.1" ;; No Gnus
731 :type '(repeat regexp)
732 :group 'gnus-article-various)
734 (make-obsolete-variable 'gnus-article-hide-pgp-hook nil
735 "Gnus 5.10 (Emacs 22.1)")
738 '((t (:weight bold)))
739 "Face used for highlighting a button in the article buffer."
740 :group 'gnus-article-buttons)
742 (defcustom gnus-article-button-face 'gnus-button
743 "Face used for highlighting buttons in the article buffer.
745 An article button is a piece of text that you can activate by pressing
746 `RET' or `mouse-2' above it."
748 :group 'gnus-article-buttons)
750 (defcustom gnus-article-mouse-face 'highlight
751 "Face used for mouse highlighting in the article buffer.
753 Article buttons will be displayed in this face when the cursor is
756 :group 'gnus-article-buttons)
758 (defcustom gnus-signature-face 'gnus-signature
759 "Face used for highlighting a signature in the article buffer.
760 Obsolete; use the face `gnus-signature' for customizations instead."
762 :group 'gnus-article-highlight
763 :group 'gnus-article-signature)
765 (defface gnus-signature
768 "Face used for highlighting a signature in the article buffer."
769 :group 'gnus-article-highlight
770 :group 'gnus-article-signature)
771 ;; backward-compatibility alias
772 (put 'gnus-signature-face 'face-alias 'gnus-signature)
773 (put 'gnus-signature-face 'obsolete-face "22.1")
775 (defface gnus-header-from
778 (:foreground "PaleGreen1"))
781 (:foreground "red3"))
784 "Face used for displaying from headers."
785 :group 'gnus-article-headers
786 :group 'gnus-article-highlight)
787 ;; backward-compatibility alias
788 (put 'gnus-header-from-face 'face-alias 'gnus-header-from)
789 (put 'gnus-header-from-face 'obsolete-face "22.1")
791 (defface gnus-header-subject
794 (:foreground "SeaGreen1"))
797 (:foreground "red4"))
799 (:bold t :italic t)))
800 "Face used for displaying subject headers."
801 :group 'gnus-article-headers
802 :group 'gnus-article-highlight)
803 ;; backward-compatibility alias
804 (put 'gnus-header-subject-face 'face-alias 'gnus-header-subject)
805 (put 'gnus-header-subject-face 'obsolete-face "22.1")
807 (defface gnus-header-newsgroups
810 (:foreground "yellow" :italic t))
813 (:foreground "MidnightBlue" :italic t))
816 "Face used for displaying newsgroups headers.
817 In the default setup this face is only used for crossposted
819 :group 'gnus-article-headers
820 :group 'gnus-article-highlight)
821 ;; backward-compatibility alias
822 (put 'gnus-header-newsgroups-face 'face-alias 'gnus-header-newsgroups)
823 (put 'gnus-header-newsgroups-face 'obsolete-face "22.1")
825 (defface gnus-header-name
828 (:foreground "SpringGreen2"))
831 (:foreground "maroon"))
834 "Face used for displaying header names."
835 :group 'gnus-article-headers
836 :group 'gnus-article-highlight)
837 ;; backward-compatibility alias
838 (put 'gnus-header-name-face 'face-alias 'gnus-header-name)
839 (put 'gnus-header-name-face 'obsolete-face "22.1")
841 (defface gnus-header-content
844 (:foreground "SpringGreen1" :italic t))
847 (:foreground "indianred4" :italic t))
849 (:italic t))) "Face used for displaying header content."
850 :group 'gnus-article-headers
851 :group 'gnus-article-highlight)
852 ;; backward-compatibility alias
853 (put 'gnus-header-content-face 'face-alias 'gnus-header-content)
854 (put 'gnus-header-content-face 'obsolete-face "22.1")
856 (defcustom gnus-header-face-alist
857 '(("From" nil gnus-header-from)
858 ("Subject" nil gnus-header-subject)
859 ("Newsgroups:.*," nil gnus-header-newsgroups)
860 ("" gnus-header-name gnus-header-content))
861 "*Controls highlighting of article headers.
863 An alist of the form (HEADER NAME CONTENT).
865 HEADER is a regular expression which should match the name of a
866 header and NAME and CONTENT are either face names or nil.
868 The name of each header field will be displayed using the face
869 specified by the first element in the list where HEADER matches
870 the header name and NAME is non-nil. Similarly, the content will
871 be displayed by the first non-nil matching CONTENT face."
872 :group 'gnus-article-headers
873 :group 'gnus-article-highlight
874 :type '(repeat (list (regexp :tag "Header")
876 (item :tag "skip" nil)
877 (face :value default))
878 (choice :tag "Content"
879 (item :tag "skip" nil)
880 (face :value default)))))
882 (defcustom gnus-face-properties-alist (if (featurep 'xemacs)
883 '((xface . (:face gnus-x-face)))
884 '((pbm . (:face gnus-x-face))
886 "Alist of image types and properties applied to Face and X-Face images.
889 ;; Specify the altitude of Face images in the From header.
890 \(setq gnus-face-properties-alist
891 '((pbm . (:face gnus-x-face :ascent 80))
892 (png . (:ascent 80))))
894 ;; Show Face images as pressed buttons.
895 \(setq gnus-face-properties-alist
896 '((pbm . (:face gnus-x-face :relief -2))
897 (png . (:relief -2))))
899 See the manual for the valid properties for various image types.
900 Currently, `pbm' is used for X-Face images and `png' is used for Face
901 images in Emacs. Only the `:face' property is effective on the `xface'
902 image type in XEmacs if it is built with the libcompface library."
903 :version "23.1" ;; No Gnus
904 :group 'gnus-article-headers
905 :type '(repeat (cons :format "%v" (symbol :tag "Image type") plist)))
907 (defcustom gnus-article-decode-hook
908 '(article-decode-charset article-decode-encoded-words
909 article-decode-group-name article-decode-idna-rhs)
910 "*Hook run to decode charsets in articles."
911 :group 'gnus-article-headers
914 (defcustom gnus-display-mime-function 'gnus-display-mime
915 "Function to display MIME articles."
916 :group 'gnus-article-mime
919 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
920 "Function used to decode headers.")
922 (defvar gnus-decode-address-function 'mail-decode-encoded-address-region
923 "Function used to decode addresses.")
925 (defvar gnus-article-dumbquotes-map
945 "Table for MS-to-Latin1 translation.")
947 (defcustom gnus-ignored-mime-types nil
948 "List of MIME types that should be ignored by Gnus."
950 :group 'gnus-article-mime
951 :type '(repeat regexp))
953 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
954 "List of MIME types that should not be given buttons when rendered inline.
955 See also `gnus-buttonized-mime-types' which may override this variable.
956 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
958 :group 'gnus-article-mime
959 :type '(repeat regexp))
961 (defcustom gnus-buttonized-mime-types nil
962 "List of MIME types that should be given buttons when rendered inline.
963 If set, this variable overrides `gnus-unbuttonized-mime-types'.
964 To see e.g. security buttons you could set this to
965 `(\"multipart/signed\")'. You could also add \"multipart/alternative\" to
966 this list to display radio buttons that allow you to choose one of two
967 media types those mails include. See also `mm-discouraged-alternatives'.
968 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
970 :group 'gnus-article-mime
971 :type '(repeat regexp))
973 (defcustom gnus-inhibit-mime-unbuttonizing nil
974 "If non-nil, all MIME parts get buttons.
975 When nil (the default value), then some MIME parts do not get buttons,
976 as described by the variables `gnus-buttonized-mime-types' and
977 `gnus-unbuttonized-mime-types'."
979 :group 'gnus-article-mime
982 (defcustom gnus-body-boundary-delimiter "_"
983 "String used to delimit header and body.
984 This variable is used by `gnus-article-treat-body-boundary' which can
985 be controlled by `gnus-treat-body-boundary'."
987 :group 'gnus-article-various
988 :type '(choice (item :tag "None" :value nil)
991 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
993 "Defines the location of the faces database.
994 For information on obtaining this database of pretty pictures, please
995 see http://www.cs.indiana.edu/picons/ftp/index.html"
997 :type '(repeat directory)
998 :link '(url-link :tag "download"
999 "http://www.cs.indiana.edu/picons/ftp/index.html")
1000 :link '(custom-manual "(gnus)Picons")
1003 (defun gnus-picons-installed-p ()
1004 "Say whether picons are installed on your machine."
1005 (let ((installed nil))
1006 (dolist (database gnus-picon-databases)
1007 (when (file-exists-p database)
1008 (setq installed t)))
1011 (defcustom gnus-article-mime-part-function nil
1012 "Function called with a MIME handle as the argument.
1013 This is meant for people who want to do something automatic based
1014 on parts -- for instance, adding Vcard info to a database."
1015 :group 'gnus-article-mime
1016 :type '(choice (const nil)
1019 (defcustom gnus-mime-multipart-functions nil
1020 "An alist of MIME types to functions to display them."
1022 :group 'gnus-article-mime
1023 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
1025 (defcustom gnus-article-date-headers '(combined-lapsed)
1026 "A list of Date header formats to display.
1027 Valid formats are `ut' (universal time), `local' (local time
1028 zone), `english' (readable English), `lapsed' (elapsed time),
1029 `combined-lapsed' (both the original date and the elapsed time),
1030 `original' (the original date header), `iso8601' (ISO8601
1031 format), and `user-defined' (a user-defined format defined by the
1032 `gnus-article-time-format' variable).
1034 You have as many date headers as you want in the article buffer.
1035 Some of these headers are updated automatically. See
1036 `gnus-article-update-date-headers' for details."
1038 :group 'gnus-article-headers
1040 (const :tag "Universal time (UT)" ut)
1041 (const :tag "Local time zone" local)
1042 (const :tag "Readable English" english)
1043 (const :tag "Elapsed time" lapsed)
1044 (const :tag "Original and elapsed time" combined-lapsed)
1045 (const :tag "Original date header" original)
1046 (const :tag "ISO8601 format" iso8601)
1047 (const :tag "User-defined" user-defined)))
1049 (defcustom gnus-article-update-date-headers nil
1050 "A number that says how often to update the date header (in seconds).
1051 If nil, don't update it at all."
1053 :group 'gnus-article-headers
1055 (item :tag "Don't update" :value nil)
1058 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
1059 "Function called with a MIME handle as the argument.
1060 This is meant for people who want to view first matched part.
1061 For `undisplayed-alternative' (default), the first undisplayed
1062 part or alternative part is used. For `undisplayed', the first
1063 undisplayed part is used. For a function, the first part which
1064 the function return t is used. For nil, the first part is
1067 :group 'gnus-article-mime
1069 (item :tag "first" :value nil)
1070 (item :tag "undisplayed" :value undisplayed)
1071 (item :tag "undisplayed or alternative"
1072 :value undisplayed-alternative)
1075 (defcustom gnus-mime-action-alist
1076 '(("save to file" . gnus-mime-save-part)
1077 ("save and strip" . gnus-mime-save-part-and-strip)
1078 ("replace with file" . gnus-mime-replace-part)
1079 ("delete part" . gnus-mime-delete-part)
1080 ("display as text" . gnus-mime-inline-part)
1081 ("view the part" . gnus-mime-view-part)
1082 ("pipe to command" . gnus-mime-pipe-part)
1083 ("toggle display" . gnus-article-press-button)
1084 ("toggle display" . gnus-article-view-part-as-charset)
1085 ("view as type" . gnus-mime-view-part-as-type)
1086 ("view internally" . gnus-mime-view-part-internally)
1087 ("view externally" . gnus-mime-view-part-externally))
1088 "An alist of actions that run on the MIME attachment."
1089 :group 'gnus-article-mime
1090 :type '(repeat (cons (string :tag "name")
1093 (defcustom gnus-auto-select-part 1
1094 "Advance to next MIME part when deleting or stripping parts.
1096 When 0, point will be placed on the same part as before. When
1097 positive (negative), move point forward (backwards) this many
1098 parts. When nil, redisplay article."
1099 :version "23.1" ;; No Gnus
1100 :group 'gnus-article-mime
1101 :type '(choice (const nil :tag "Redisplay article.")
1102 (const 1 :tag "Next part.")
1103 (const 0 :tag "Current part.")
1107 ;;; The treatment variables
1110 (defvar gnus-part-display-hook nil
1111 "Hook called on parts that are to receive treatment.")
1113 (defvar gnus-article-treat-custom
1114 '(choice (const :tag "Off" nil)
1116 (const :tag "Header" head)
1117 (const :tag "First" first)
1118 (const :tag "Last" last)
1119 (integer :tag "Less")
1120 (repeat :tag "Groups" regexp)
1121 (sexp :tag "Predicate")))
1123 (defvar gnus-article-treat-head-custom
1124 '(choice (const :tag "Off" nil)
1125 (const :tag "Header" head)))
1127 (defvar gnus-article-treat-types '("text/plain" "text/x-verbatim"
1128 "text/x-patch" "text/html")
1129 "Part types eligible for treatment.")
1131 (defvar gnus-inhibit-treatment nil
1132 "Whether to inhibit treatment.")
1134 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
1135 "Highlight the signature.
1136 Valid values are nil, t, `head', `first', `last', an integer or a
1137 predicate. See Info node `(gnus)Customizing Articles'."
1138 :group 'gnus-article-treat
1139 :link '(custom-manual "(gnus)Customizing Articles")
1140 :type gnus-article-treat-custom)
1141 (put 'gnus-treat-highlight-signature 'highlight t)
1143 (defcustom gnus-treat-buttonize '(and 100000 (typep "text/plain"))
1145 Valid values are nil, t, `head', `first', `last', an integer or a
1146 predicate. See Info node `(gnus)Customizing Articles'."
1147 :group 'gnus-article-treat
1148 :link '(custom-manual "(gnus)Customizing Articles")
1149 :type gnus-article-treat-custom)
1150 (put 'gnus-treat-buttonize 'highlight t)
1152 (defcustom gnus-treat-buttonize-head 'head
1153 "Add buttons to the head.
1154 Valid values are nil, t, `head', `first', `last', an integer or a
1155 predicate. See Info node `(gnus)Customizing Articles'."
1156 :group 'gnus-article-treat
1157 :link '(custom-manual "(gnus)Customizing Articles")
1158 :type gnus-article-treat-head-custom)
1159 (put 'gnus-treat-buttonize-head 'highlight t)
1161 (defcustom gnus-treat-date 'head
1162 "Display dates according to the `gnus-article-date-headers' variable.
1163 Valid values are nil, t, `head', `first', `last', an integer or a
1164 predicate. See Info node `(gnus)Customizing Articles'."
1166 :group 'gnus-article-treat
1167 :link '(custom-manual "(gnus)Customizing Articles")
1168 :type gnus-article-treat-head-custom)
1170 (defcustom gnus-treat-emphasize 50000
1172 Valid values are nil, t, `head', `first', `last', an integer or a
1173 predicate. See Info node `(gnus)Customizing Articles'."
1174 :group 'gnus-article-treat
1175 :link '(custom-manual "(gnus)Customizing Articles")
1176 :type gnus-article-treat-custom)
1177 (put 'gnus-treat-emphasize 'highlight t)
1179 (defcustom gnus-treat-strip-cr nil
1180 "Remove carriage returns.
1181 Valid values are nil, t, `head', `first', `last', an integer or a
1182 predicate. See Info node `(gnus)Customizing Articles'."
1184 :group 'gnus-article-treat
1185 :link '(custom-manual "(gnus)Customizing Articles")
1186 :type gnus-article-treat-custom)
1188 (defcustom gnus-treat-unsplit-urls nil
1189 "Remove newlines from within URLs.
1190 Valid values are nil, t, `head', `first', `last', an integer or a
1191 predicate. See Info node `(gnus)Customizing Articles'."
1193 :group 'gnus-article-treat
1194 :link '(custom-manual "(gnus)Customizing Articles")
1195 :type gnus-article-treat-custom)
1197 (defcustom gnus-treat-leading-whitespace nil
1198 "Remove leading whitespace in headers.
1199 Valid values are nil, t, `head', `first', `last', an integer or a
1200 predicate. See Info node `(gnus)Customizing Articles'."
1202 :group 'gnus-article-treat
1203 :link '(custom-manual "(gnus)Customizing Articles")
1204 :type gnus-article-treat-custom)
1206 (defcustom gnus-treat-hide-headers 'head
1208 Valid values are nil, t, `head', `first', `last', an integer or a
1209 predicate. See Info node `(gnus)Customizing Articles'."
1210 :group 'gnus-article-treat
1211 :link '(custom-manual "(gnus)Customizing Articles")
1212 :type gnus-article-treat-head-custom)
1214 (defcustom gnus-treat-hide-boring-headers nil
1215 "Hide boring headers.
1216 Valid values are nil, t, `head', `first', `last', an integer or a
1217 predicate. See Info node `(gnus)Customizing Articles'."
1218 :group 'gnus-article-treat
1219 :link '(custom-manual "(gnus)Customizing Articles")
1220 :type gnus-article-treat-head-custom)
1222 (defcustom gnus-treat-hide-signature nil
1223 "Hide the signature.
1224 Valid values are nil, t, `head', `first', `last', an integer or a
1225 predicate. See Info node `(gnus)Customizing Articles'."
1226 :group 'gnus-article-treat
1227 :link '(custom-manual "(gnus)Customizing Articles")
1228 :type gnus-article-treat-custom)
1230 (defcustom gnus-treat-fill-article nil
1232 Valid values are nil, t, `head', `first', `last', an integer or a
1233 predicate. See Info node `(gnus)Customizing Articles'."
1234 :group 'gnus-article-treat
1235 :link '(custom-manual "(gnus)Customizing Articles")
1236 :type gnus-article-treat-custom)
1238 (defcustom gnus-treat-hide-citation nil
1240 Valid values are nil, t, `head', `first', `last', an integer or a
1241 predicate. See Info node `(gnus)Customizing Articles'.
1243 See `gnus-article-highlight-citation' for variables used to
1244 control what it hides."
1245 :group 'gnus-article-treat
1246 :link '(custom-manual "(gnus)Customizing Articles")
1247 :type gnus-article-treat-custom)
1249 (defcustom gnus-treat-hide-citation-maybe nil
1250 "Hide cited text according to certain conditions.
1251 Valid values are nil, t, `head', `first', `last', an integer or a
1252 predicate. See Info node `(gnus)Customizing Articles'.
1254 See `gnus-cite-hide-percentage' and `gnus-cite-hide-absolute' for
1255 how to control what it hides."
1256 :group 'gnus-article-treat
1257 :link '(custom-manual "(gnus)Customizing Articles")
1258 :type gnus-article-treat-custom)
1260 (defcustom gnus-treat-strip-list-identifiers 'head
1261 "Strip list identifiers from `gnus-list-identifiers`.
1262 Valid values are nil, t, `head', `first', `last', an integer or a
1263 predicate. See Info node `(gnus)Customizing Articles'."
1265 :group 'gnus-article-treat
1266 :link '(custom-manual "(gnus)Customizing Articles")
1267 :type gnus-article-treat-custom)
1269 (gnus-define-group-parameter
1272 "Alist of regexps and correspondent identifiers."
1273 :variable-group gnus-article-washing
1275 '(choice :tag "Identifier"
1277 (symbol :tag "Item in `gnus-list-identifiers'" none)
1279 (const :tag "None" nil))
1281 "If non-nil, specify how to remove `identifiers' from articles' subject.
1283 Any symbol is used to look up a regular expression to match the
1284 banner in `gnus-list-identifiers'. A string is used as a regular
1285 expression to match the identifier directly.")
1287 (make-obsolete-variable 'gnus-treat-strip-pgp nil
1288 "Gnus 5.10 (Emacs 22.1)")
1290 (defcustom gnus-treat-strip-pem nil
1291 "Strip PEM signatures.
1292 Valid values are nil, t, `head', `first', `last', an integer or a
1293 predicate. See Info node `(gnus)Customizing Articles'."
1294 :group 'gnus-article-treat
1295 :link '(custom-manual "(gnus)Customizing Articles")
1296 :type gnus-article-treat-custom)
1298 (defcustom gnus-treat-strip-banner t
1299 "Strip banners from articles.
1300 The banner to be stripped is specified in the `banner' group parameter.
1301 Valid values are nil, t, `head', `first', `last', an integer or a
1302 predicate. See Info node `(gnus)Customizing Articles'."
1303 :group 'gnus-article-treat
1304 :link '(custom-manual "(gnus)Customizing Articles")
1305 :type gnus-article-treat-custom)
1307 (defcustom gnus-treat-highlight-headers 'head
1308 "Highlight the headers.
1309 Valid values are nil, t, `head', `first', `last', an integer or a
1310 predicate. See Info node `(gnus)Customizing Articles'."
1311 :group 'gnus-article-treat
1312 :link '(custom-manual "(gnus)Customizing Articles")
1313 :type gnus-article-treat-head-custom)
1314 (put 'gnus-treat-highlight-headers 'highlight t)
1316 (defcustom gnus-treat-highlight-citation t
1317 "Highlight cited text.
1318 Valid values are nil, t, `head', `first', `last', an integer or a
1319 predicate. See Info node `(gnus)Customizing Articles'."
1320 :group 'gnus-article-treat
1321 :link '(custom-manual "(gnus)Customizing Articles")
1322 :type gnus-article-treat-custom)
1323 (put 'gnus-treat-highlight-citation 'highlight t)
1325 (defcustom gnus-treat-strip-headers-in-body t
1326 "Strip the X-No-Archive header line from the beginning of the body.
1327 Valid values are nil, t, `head', `first', `last', an integer or a
1328 predicate. See Info node `(gnus)Customizing Articles'."
1330 :group 'gnus-article-treat
1331 :link '(custom-manual "(gnus)Customizing Articles")
1332 :type gnus-article-treat-custom)
1334 (defcustom gnus-treat-strip-trailing-blank-lines nil
1335 "Strip trailing blank lines.
1336 Valid values are nil, t, `head', `first', `last', an integer or a
1337 predicate. See Info node `(gnus)Customizing Articles'.
1339 When set to t, it also strips trailing blanks in all MIME parts.
1340 Consider to use `last' instead."
1341 :group 'gnus-article-treat
1342 :link '(custom-manual "(gnus)Customizing Articles")
1343 :type gnus-article-treat-custom)
1345 (defcustom gnus-treat-strip-leading-blank-lines nil
1346 "Strip leading blank lines.
1347 Valid values are nil, t, `head', `first', `last', an integer or a
1348 predicate. See Info node `(gnus)Customizing Articles'.
1350 When set to t, it also strips trailing blanks in all MIME parts."
1351 :group 'gnus-article-treat
1352 :link '(custom-manual "(gnus)Customizing Articles")
1353 :type gnus-article-treat-custom)
1355 (defcustom gnus-treat-strip-multiple-blank-lines nil
1356 "Strip multiple blank lines.
1357 Valid values are nil, t, `head', `first', `last', an integer or a
1358 predicate. See Info node `(gnus)Customizing Articles'."
1359 :group 'gnus-article-treat
1360 :link '(custom-manual "(gnus)Customizing Articles")
1361 :type gnus-article-treat-custom)
1363 (defcustom gnus-treat-unfold-headers 'head
1364 "Unfold folded header lines.
1365 Valid values are nil, t, `head', `first', `last', an integer or a
1366 predicate. See Info node `(gnus)Customizing Articles'."
1368 :group 'gnus-article-treat
1369 :link '(custom-manual "(gnus)Customizing Articles")
1370 :type gnus-article-treat-custom)
1372 (defcustom gnus-article-unfold-long-headers nil
1373 "If non-nil, allow unfolding headers even if the header is long.
1374 If it is a regexp, only long headers matching this regexp are unfolded.
1375 If it is t, all long headers are unfolded.
1377 This variable has no effect if `gnus-treat-unfold-headers' is nil."
1378 :version "23.1" ;; No Gnus
1379 :group 'gnus-article-treat
1380 :type '(choice (const nil)
1381 (const :tag "all" t)
1384 (defcustom gnus-treat-fold-headers nil
1386 Valid values are nil, t, `head', `first', `last', an integer or a
1387 predicate. See Info node `(gnus)Customizing Articles'."
1389 :group 'gnus-article-treat
1390 :link '(custom-manual "(gnus)Customizing Articles")
1391 :type gnus-article-treat-custom)
1393 (defcustom gnus-treat-fold-newsgroups 'head
1394 "Fold the Newsgroups and Followup-To headers.
1395 Valid values are nil, t, `head', `first', `last', an integer or a
1396 predicate. See Info node `(gnus)Customizing Articles'."
1398 :group 'gnus-article-treat
1399 :link '(custom-manual "(gnus)Customizing Articles")
1400 :type gnus-article-treat-custom)
1402 (defcustom gnus-treat-overstrike t
1403 "Treat overstrike highlighting.
1404 Valid values are nil, t, `head', `first', `last', an integer or a
1405 predicate. See Info node `(gnus)Customizing Articles'."
1406 :group 'gnus-article-treat
1407 :link '(custom-manual "(gnus)Customizing Articles")
1408 :type gnus-article-treat-custom)
1409 (put 'gnus-treat-overstrike 'highlight t)
1411 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1412 "Treat ANSI SGR control sequences.
1413 Valid values are nil, t, `head', `first', `last', an integer or a
1414 predicate. See Info node `(gnus)Customizing Articles'."
1415 :group 'gnus-article-treat
1416 :link '(custom-manual "(gnus)Customizing Articles")
1417 :type gnus-article-treat-custom)
1419 (make-obsolete-variable 'gnus-treat-display-xface
1420 'gnus-treat-display-x-face "Emacs 22.1")
1422 (defcustom gnus-treat-display-x-face
1423 (and (not noninteractive)
1424 (gnus-image-type-available-p 'xbm)
1425 (if (featurep 'xemacs)
1428 (and (string-match "^0x" (shell-command-to-string "uncompface"))
1429 (executable-find "icontopbm"))
1430 ;; shell-command-to-string may signal an error, e.g. if
1431 ;; shell-file-name is not found.
1434 "Display X-Face headers.
1435 Valid values are nil and `head'.
1436 See Info node `(gnus)Customizing Articles' and Info node
1437 `(gnus)X-Face' for details."
1438 :group 'gnus-article-treat
1440 :link '(custom-manual "(gnus)Customizing Articles")
1441 :link '(custom-manual "(gnus)X-Face")
1442 :type gnus-article-treat-head-custom
1443 :set (lambda (symbol value)
1446 (cond ((or (boundp symbol) (get symbol 'saved-value))
1448 ((boundp 'gnus-treat-display-xface)
1450 ** gnus-treat-display-xface is an obsolete variable;\
1451 use gnus-treat-display-x-face instead")
1452 (default-value 'gnus-treat-display-xface))
1453 ((get 'gnus-treat-display-xface 'saved-value)
1455 ** gnus-treat-display-xface is an obsolete variable;\
1456 use gnus-treat-display-x-face instead")
1457 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1460 (put 'gnus-treat-display-x-face 'highlight t)
1462 (defcustom gnus-treat-display-face
1463 (and (not noninteractive)
1464 (gnus-image-type-available-p 'png)
1466 "Display Face headers.
1467 Valid values are nil, t, `head', `first', `last', an integer or a
1468 predicate. See Info node `(gnus)Customizing Articles' and Info
1469 node `(gnus)Face' for details."
1470 :group 'gnus-article-treat
1472 :link '(custom-manual "(gnus)Customizing Articles")
1473 :link '(custom-manual "(gnus)X-Face")
1474 :type gnus-article-treat-head-custom)
1475 (put 'gnus-treat-display-face 'highlight t)
1477 (defcustom gnus-treat-display-smileys (gnus-image-type-available-p 'xpm)
1479 Valid values are nil, t, `head', `first', `last', an integer or a
1480 predicate. See Info node `(gnus)Customizing Articles' and Info
1481 node `(gnus)Smileys' for details."
1482 :group 'gnus-article-treat
1484 :link '(custom-manual "(gnus)Customizing Articles")
1485 :link '(custom-manual "(gnus)Smileys")
1486 :type gnus-article-treat-custom)
1487 (put 'gnus-treat-display-smileys 'highlight t)
1489 (defcustom gnus-treat-from-picon
1490 (if (and (gnus-image-type-available-p 'xpm)
1491 (gnus-picons-installed-p))
1493 "Display picons in the From header.
1494 Valid values are nil, t, `head', `first', `last', an integer or a
1495 predicate. See Info node `(gnus)Customizing Articles' and Info
1496 node `(gnus)Picons' for details."
1498 :group 'gnus-article-treat
1500 :link '(custom-manual "(gnus)Customizing Articles")
1501 :link '(custom-manual "(gnus)Picons")
1502 :type gnus-article-treat-head-custom)
1503 (put 'gnus-treat-from-picon 'highlight t)
1505 (defcustom gnus-treat-mail-picon
1506 (if (and (gnus-image-type-available-p 'xpm)
1507 (gnus-picons-installed-p))
1509 "Display picons in To and Cc headers.
1510 Valid values are nil, t, `head', `first', `last', an integer or a
1511 predicate. See Info node `(gnus)Customizing Articles' and Info
1512 node `(gnus)Picons' for details."
1514 :group 'gnus-article-treat
1516 :link '(custom-manual "(gnus)Customizing Articles")
1517 :link '(custom-manual "(gnus)Picons")
1518 :type gnus-article-treat-head-custom)
1519 (put 'gnus-treat-mail-picon 'highlight t)
1521 (defcustom gnus-treat-newsgroups-picon
1522 (if (and (gnus-image-type-available-p 'xpm)
1523 (gnus-picons-installed-p))
1525 "Display picons in the Newsgroups and Followup-To headers.
1526 Valid values are nil, t, `head', `first', `last', an integer or a
1527 predicate. See Info node `(gnus)Customizing Articles' and Info
1528 node `(gnus)Picons' for details."
1530 :group 'gnus-article-treat
1532 :link '(custom-manual "(gnus)Customizing Articles")
1533 :link '(custom-manual "(gnus)Picons")
1534 :type gnus-article-treat-head-custom)
1535 (put 'gnus-treat-newsgroups-picon 'highlight t)
1537 (defcustom gnus-treat-from-gravatar nil
1538 "Display gravatars in the From header.
1539 Valid values are nil, t, `head', `first', `last', an integer or a
1540 predicate. See Info node `(gnus)Customizing Articles' and Info
1541 node `(gnus)Gravatars' for details."
1543 :group 'gnus-article-treat
1544 :group 'gnus-gravatar
1545 :link '(custom-manual "(gnus)Customizing Articles")
1546 :link '(custom-manual "(gnus)Gravatars")
1547 :type gnus-article-treat-head-custom)
1548 (put 'gnus-treat-from-gravatar 'highlight t)
1550 (defcustom gnus-treat-mail-gravatar nil
1551 "Display gravatars in To and Cc headers.
1552 Valid values are nil, t, `head', `first', `last', an integer or a
1553 predicate. See Info node `(gnus)Customizing Articles' and Info
1554 node `(gnus)Gravatars' for details."
1556 :group 'gnus-article-treat
1557 :group 'gnus-gravatar
1558 :link '(custom-manual "(gnus)Customizing Articles")
1559 :link '(custom-manual "(gnus)Gravatars")
1560 :type gnus-article-treat-head-custom)
1561 (put 'gnus-treat-mail-gravatar 'highlight t)
1563 (defcustom gnus-treat-body-boundary
1564 (if (or gnus-treat-newsgroups-picon
1565 gnus-treat-mail-picon
1566 gnus-treat-from-picon
1567 gnus-treat-from-gravatar
1568 gnus-treat-mail-gravatar)
1569 ;; If there's much decoration, the user might prefer a boundary.
1572 "Draw a boundary at the end of the headers.
1573 Valid values are nil and `head'.
1574 See Info node `(gnus)Customizing Articles' for details."
1576 :group 'gnus-article-treat
1577 :link '(custom-manual "(gnus)Customizing Articles")
1578 :type gnus-article-treat-head-custom)
1580 (defcustom gnus-treat-capitalize-sentences nil
1581 "Capitalize sentence-starting words.
1582 Valid values are nil, t, `head', `first', `last', an integer or a
1583 predicate. See Info node `(gnus)Customizing Articles'."
1585 :group 'gnus-article-treat
1586 :link '(custom-manual "(gnus)Customizing Articles")
1587 :type gnus-article-treat-custom)
1589 (defcustom gnus-treat-wash-html nil
1591 Valid values are nil, t, `head', `first', `last', an integer or a
1592 predicate. See Info node `(gnus)Customizing Articles'."
1594 :group 'gnus-article-treat
1595 :link '(custom-manual "(gnus)Customizing Articles")
1596 :type gnus-article-treat-custom)
1598 (defcustom gnus-treat-fill-long-lines '(typep "text/plain")
1600 Valid values are nil, t, `head', `first', `last', an integer or a
1601 predicate. See Info node `(gnus)Customizing Articles'."
1603 :group 'gnus-article-treat
1604 :link '(custom-manual "(gnus)Customizing Articles")
1605 :type gnus-article-treat-custom)
1607 (defcustom gnus-treat-x-pgp-sig nil
1609 To automatically treat X-PGP-Sig, set it to head.
1610 Valid values are nil, t, `head', `first', `last', an integer or a
1611 predicate. See Info node `(gnus)Customizing Articles'."
1613 :group 'gnus-article-treat
1614 :group 'mime-security
1615 :link '(custom-manual "(gnus)Customizing Articles")
1616 :type gnus-article-treat-custom)
1618 (defvar gnus-article-encrypt-protocol-alist
1619 '(("PGP" . mml2015-self-encrypt)))
1621 ;; Set to nil if more than one protocol added to
1622 ;; gnus-article-encrypt-protocol-alist.
1623 (defcustom gnus-article-encrypt-protocol "PGP"
1624 "The protocol used for encrypt articles.
1625 It is a string, such as \"PGP\". If nil, ask user."
1628 :group 'mime-security)
1630 (defvar idna-program)
1632 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1633 (mm-coding-system-p 'utf-8)
1635 (executable-find idna-program))
1636 "Whether IDNA decoding of headers is used when viewing messages.
1637 This requires GNU Libidn, and by default only enabled if it is found."
1639 :group 'gnus-article-headers
1642 (defcustom gnus-article-over-scroll nil
1643 "If non-nil, allow scrolling the article buffer even when there no more text."
1645 :group 'gnus-article
1648 (defcustom gnus-inhibit-images nil
1649 "Non-nil means inhibit displaying of images inline in the article body."
1651 :group 'gnus-article
1654 (defcustom gnus-blocked-images 'gnus-block-private-groups
1655 "Images that have URLs matching this regexp will be blocked.
1656 This can also be a function to be evaluated. If so, it will be
1657 called with the group name as the parameter, and should return a
1661 :type '(choice regexp function))
1663 ;;; Internal variables
1665 (defvar gnus-english-month-names
1666 '("January" "February" "March" "April" "May" "June" "July" "August"
1667 "September" "October" "November" "December"))
1669 (defvar article-goto-body-goes-to-point-min-p nil)
1670 (defvar gnus-article-wash-types nil)
1671 (defvar gnus-article-emphasis-alist nil)
1672 (defvar gnus-article-image-alist nil)
1674 (defvar gnus-article-mime-handle-alist-1 nil)
1675 (defvar gnus-treatment-function-alist
1676 '((gnus-treat-strip-cr gnus-article-remove-cr)
1677 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1678 (gnus-treat-strip-banner gnus-article-strip-banner)
1679 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1680 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1681 (gnus-treat-buttonize gnus-article-add-buttons)
1682 (gnus-treat-fill-article gnus-article-fill-cited-article)
1683 (gnus-treat-fill-long-lines gnus-article-fill-cited-long-lines)
1684 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1685 (gnus-treat-display-x-face gnus-article-display-x-face)
1686 (gnus-treat-display-face gnus-article-display-face)
1687 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1688 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1689 (gnus-treat-hide-signature gnus-article-hide-signature)
1690 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1691 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1692 (gnus-treat-from-picon gnus-treat-from-picon)
1693 (gnus-treat-mail-picon gnus-treat-mail-picon)
1694 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1695 (gnus-treat-strip-pem gnus-article-hide-pem)
1696 (gnus-treat-date gnus-article-treat-date)
1697 (gnus-treat-from-gravatar gnus-treat-from-gravatar)
1698 (gnus-treat-mail-gravatar gnus-treat-mail-gravatar)
1699 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1700 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1701 (gnus-treat-strip-trailing-blank-lines
1702 gnus-article-remove-trailing-blank-lines)
1703 (gnus-treat-strip-leading-blank-lines
1704 gnus-article-strip-leading-blank-lines)
1705 (gnus-treat-strip-multiple-blank-lines
1706 gnus-article-strip-multiple-blank-lines)
1707 (gnus-treat-overstrike gnus-article-treat-overstrike)
1708 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1709 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1710 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1711 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1712 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1713 (gnus-treat-display-smileys gnus-treat-smiley)
1714 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1715 (gnus-treat-wash-html gnus-article-wash-html)
1716 (gnus-treat-emphasize gnus-article-emphasize)
1717 (gnus-treat-hide-citation gnus-article-hide-citation)
1718 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1719 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1720 (gnus-treat-body-boundary gnus-article-treat-body-boundary)))
1722 (defvar gnus-article-mime-handle-alist nil)
1723 (defvar article-lapsed-timer nil)
1724 (defvar gnus-article-current-summary nil)
1726 (defvar gnus-article-mode-syntax-table
1727 (let ((table (copy-syntax-table text-mode-syntax-table)))
1728 ;; This causes the citation match run O(2^n).
1729 ;; (modify-syntax-entry ?- "w" table)
1730 (modify-syntax-entry ?> ")<" table)
1731 (modify-syntax-entry ?< "(>" table)
1732 ;; make M-. in article buffers work for `foo' strings
1733 (modify-syntax-entry ?' " " table)
1734 (modify-syntax-entry ?` " " table)
1736 "Syntax table used in article mode buffers.
1737 Initialized from `text-mode-syntax-table.")
1739 (defvar gnus-save-article-buffer nil)
1741 (defvar gnus-number-of-articles-to-be-saved nil)
1743 (defvar gnus-inhibit-hiding nil)
1745 (defvar gnus-article-edit-mode nil)
1747 ;;; Macros for dealing with the article buffer.
1749 (defmacro gnus-with-article-headers (&rest forms)
1750 `(with-current-buffer gnus-article-buffer
1752 (let ((inhibit-read-only t)
1753 (inhibit-point-motion-hooks t)
1754 (case-fold-search t))
1755 (article-narrow-to-head)
1758 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1759 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1761 (defmacro gnus-with-article-buffer (&rest forms)
1762 `(when (buffer-live-p (get-buffer gnus-article-buffer))
1763 (with-current-buffer gnus-article-buffer
1764 (let ((inhibit-read-only t))
1767 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1768 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1770 (defun gnus-article-goto-header (header)
1771 "Go to HEADER, which is a regular expression."
1772 (re-search-forward (concat "^\\(" header "\\):") nil t))
1774 (defsubst gnus-article-hide-text (b e props)
1775 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1776 (gnus-add-text-properties-when 'article-type nil b e props)
1777 (when (memq 'intangible props)
1779 (max (1- b) (point-min))
1780 b 'intangible (cddr (memq 'intangible props)))))
1782 (defsubst gnus-article-unhide-text (b e)
1783 "Remove hidden text properties from region between B and E."
1784 (remove-text-properties b e gnus-hidden-properties)
1785 (when (memq 'intangible gnus-hidden-properties)
1786 (put-text-property (max (1- b) (point-min))
1787 b 'intangible nil)))
1789 (defun gnus-article-hide-text-type (b e type)
1790 "Hide text of TYPE between B and E."
1791 (gnus-add-wash-type type)
1792 (gnus-article-hide-text
1793 b e (cons 'article-type (cons type gnus-hidden-properties))))
1795 (defun gnus-article-unhide-text-type (b e type)
1796 "Unhide text of TYPE between B and E."
1797 (gnus-delete-wash-type type)
1798 (remove-text-properties
1799 b e (cons 'article-type (cons type gnus-hidden-properties)))
1800 (when (memq 'intangible gnus-hidden-properties)
1801 (put-text-property (max (1- b) (point-min))
1802 b 'intangible nil)))
1804 (defun gnus-article-delete-text-of-type (type)
1805 "Delete text of TYPE in the current buffer."
1807 (let ((b (point-min)))
1808 (if (eq type 'multipart)
1809 ;; Remove MIME buttons associated with multipart/alternative parts.
1812 (while (if (get-text-property (point) 'gnus-part)
1814 (when (setq b (next-single-property-change (point)
1819 (skip-chars-forward "\n")
1820 (when (eq (get-text-property b 'article-type) 'multipart)
1821 (delete-region b (point)))))
1822 (while (setq b (text-property-any b (point-max) 'article-type type))
1824 b (or (text-property-not-all b (point-max) 'article-type type)
1827 (defun gnus-article-delete-invisible-text ()
1828 "Delete all invisible text in the current buffer."
1830 (let ((b (point-min)))
1831 (while (setq b (text-property-any b (point-max) 'invisible t))
1833 b (or (text-property-not-all b (point-max) 'invisible t)
1836 (defsubst gnus-article-header-rank ()
1837 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1838 (let ((list gnus-sorted-header-list)
1841 (if (looking-at (car list))
1843 (setq list (cdr list))
1847 (defun article-hide-headers (&optional _arg _delete)
1848 "Hide unwanted headers and possibly sort them as well."
1850 ;; This function might be inhibited.
1851 (unless gnus-inhibit-hiding
1852 (let ((inhibit-read-only t)
1853 (case-fold-search t)
1854 (max (1+ (length gnus-sorted-header-list)))
1855 (inhibit-point-motion-hooks t)
1856 (cur (current-buffer))
1857 ignored visible beg)
1859 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1860 ;; group parameters, so we should go to the summary buffer.
1863 (progn (set-buffer gnus-summary-buffer) t)
1865 (setq ignored (when (not gnus-visible-headers)
1866 (cond ((stringp gnus-ignored-headers)
1867 gnus-ignored-headers)
1868 ((listp gnus-ignored-headers)
1869 (mapconcat 'identity
1870 gnus-ignored-headers
1872 visible (cond ((stringp gnus-visible-headers)
1873 gnus-visible-headers)
1874 ((and gnus-visible-headers
1875 (listp gnus-visible-headers))
1876 (mapconcat 'identity
1877 gnus-visible-headers
1881 ;; First we narrow to just the headers.
1882 (article-narrow-to-head)
1883 ;; Hide any "From " lines at the beginning of (mail) articles.
1884 (while (looking-at "From ")
1887 (delete-region (point-min) (point)))
1888 ;; Then treat the rest of the header lines.
1889 ;; Then we use the two regular expressions
1890 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1891 ;; select which header lines is to remain visible in the
1893 (while (re-search-forward "^[^ \t:]*:" nil t)
1895 ;; Mark the rank of the header.
1897 (point) (1+ (point)) 'message-rank
1898 (if (or (and visible (looking-at visible))
1900 (not (looking-at ignored))))
1901 (gnus-article-header-rank)
1904 (message-sort-headers-1)
1905 (when (setq beg (text-property-any
1906 (point-min) (point-max) 'message-rank (+ 2 max)))
1907 ;; We delete the unwanted headers.
1908 (gnus-add-wash-type 'headers)
1909 (add-text-properties (point-min) (+ 5 (point-min))
1910 '(article-type headers dummy-invisible t))
1911 (delete-region beg (point-max))))))))
1913 (defun article-hide-boring-headers (&optional arg)
1914 "Toggle hiding of headers that aren't very interesting.
1915 If given a negative prefix, always show; if given a positive prefix,
1917 (interactive (gnus-article-hidden-arg))
1918 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1919 (not gnus-show-all-headers))
1922 (let ((inhibit-read-only t)
1923 (inhibit-point-motion-hooks t))
1924 (article-narrow-to-head)
1925 (dolist (elem gnus-boring-article-headers)
1926 (goto-char (point-min))
1928 ;; Hide empty headers.
1930 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1932 (gnus-article-hide-text-type
1936 (if (re-search-forward "^[^ \t]" nil t)
1940 ;; Hide boring Newsgroups header.
1941 ((eq elem 'newsgroups)
1942 (when (gnus-string-equal
1943 (gnus-fetch-field "newsgroups")
1944 (gnus-group-real-name
1945 (if (boundp 'gnus-newsgroup-name)
1948 (gnus-article-hide-header "newsgroups")))
1949 ((eq elem 'to-address)
1950 (let ((to (message-fetch-field "to"))
1952 (gnus-parameter-to-address
1953 (if (boundp 'gnus-newsgroup-name)
1954 gnus-newsgroup-name ""))))
1955 (when (and to to-address
1958 ;; only one address in To
1959 (nth 1 (mail-extract-address-components to))
1961 (gnus-article-hide-header "to"))))
1963 (let ((to (message-fetch-field "to"))
1965 (gnus-parameter-to-list
1966 (if (boundp 'gnus-newsgroup-name)
1967 gnus-newsgroup-name ""))))
1968 (when (and to to-list
1971 ;; only one address in To
1972 (nth 1 (mail-extract-address-components to))
1974 (gnus-article-hide-header "to"))))
1976 (let ((cc (message-fetch-field "cc"))
1978 (gnus-parameter-to-list
1979 (if (boundp 'gnus-newsgroup-name)
1980 gnus-newsgroup-name ""))))
1981 (when (and cc to-list
1984 ;; only one address in CC
1985 (nth 1 (mail-extract-address-components cc))
1987 (gnus-article-hide-header "cc"))))
1988 ((eq elem 'followup-to)
1989 (when (gnus-string-equal
1990 (message-fetch-field "followup-to")
1991 (message-fetch-field "newsgroups"))
1992 (gnus-article-hide-header "followup-to")))
1993 ((eq elem 'reply-to)
1994 (if (gnus-group-find-parameter
1995 gnus-newsgroup-name 'broken-reply-to)
1996 (gnus-article-hide-header "reply-to")
1997 (let ((from (message-fetch-field "from"))
1998 (reply-to (message-fetch-field "reply-to")))
2005 (lambda (x) (downcase (cadr x)))
2006 (mail-extract-address-components from t))
2009 (lambda (x) (downcase (cadr x)))
2010 (mail-extract-address-components reply-to t))
2012 (gnus-article-hide-header "reply-to")))))
2014 (let ((date (with-current-buffer gnus-original-article-buffer
2015 ;; If date in `gnus-article-buffer' is localized
2016 ;; (`gnus-treat-date-user-defined'),
2017 ;; `days-between' might fail.
2018 (message-fetch-field "date"))))
2020 (< (days-between (current-time-string) date)
2022 (gnus-article-hide-header "date"))))
2024 (let ((to (message-fetch-field "to"))
2025 (cc (message-fetch-field "cc")))
2026 (when (> (length to) 1024)
2027 (gnus-article-hide-header "to"))
2028 (when (> (length cc) 1024)
2029 (gnus-article-hide-header "cc"))))
2033 (goto-char (point-min))
2034 (while (re-search-forward "^to:" nil t)
2035 (setq to-count (1+ to-count)))
2036 (when (> to-count 1)
2037 (while (> to-count 0)
2038 (goto-char (point-min))
2040 (re-search-forward "^to:" nil nil to-count)
2042 (narrow-to-region (point) (point-max))
2043 (gnus-article-hide-header "to"))
2044 (setq to-count (1- to-count))))
2045 (goto-char (point-min))
2046 (while (re-search-forward "^cc:" nil t)
2047 (setq cc-count (1+ cc-count)))
2048 (when (> cc-count 1)
2049 (while (> cc-count 0)
2050 (goto-char (point-min))
2052 (re-search-forward "^cc:" nil nil cc-count)
2054 (narrow-to-region (point) (point-max))
2055 (gnus-article-hide-header "cc"))
2056 (setq cc-count (1- cc-count)))))))))))))
2058 (defun gnus-article-hide-header (header)
2060 (goto-char (point-min))
2061 (when (re-search-forward (concat "^" header ":") nil t)
2062 (gnus-article-hide-text-type
2066 (if (re-search-forward "^[^ \t]" nil t)
2071 (defvar gnus-article-normalized-header-length 40
2072 "Length of normalized headers.")
2074 (defun article-normalize-headers ()
2075 "Make all header lines 40 characters long."
2077 (let ((inhibit-read-only t)
2081 (article-narrow-to-head)
2084 ((< (setq column (- (point-at-eol) (point)))
2085 gnus-article-normalized-header-length)
2087 (insert (make-string
2088 (- gnus-article-normalized-header-length column)
2090 ((> column gnus-article-normalized-header-length)
2091 (gnus-put-text-property
2093 (forward-char gnus-article-normalized-header-length)
2100 (forward-line 1))))))
2102 (defun article-treat-dumbquotes ()
2103 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
2104 Note that this function guesses whether a character is a sm*rtq**t* or
2105 not, so it should only be used interactively.
2107 Sm*rtq**t*s are M****s***'s unilateral extension to the
2108 iso-8859-1 character map in an attempt to provide more quoting
2109 characters. If you see something like \\222 or \\264 where
2110 you're expecting some kind of apostrophe or quotation mark, then
2113 (article-translate-strings gnus-article-dumbquotes-map))
2115 (defvar org-entities)
2117 (defun article-treat-non-ascii ()
2118 "Translate many Unicode characters into their ASCII equivalents."
2120 (require 'org-entities)
2121 (let ((table (make-char-table (if (featurep 'xemacs) 'generic))))
2122 (dolist (elem org-entities)
2123 (when (and (listp elem)
2124 (= (length (nth 6 elem)) 1))
2125 (if (featurep 'xemacs)
2126 (put-char-table (aref (nth 6 elem) 0) (nth 4 elem) table)
2127 (set-char-table-range table (aref (nth 6 elem) 0) (nth 4 elem)))))
2129 (when (article-goto-body)
2130 (let ((inhibit-read-only t)
2133 (if (not (setq replace (if (featurep 'xemacs)
2134 (get-char-table (following-char) table)
2135 (aref table (following-char)))))
2138 (setq props (text-properties-at (point)))
2140 (add-text-properties (point) (progn (insert replace) (point))
2142 (insert replace)))))))))
2144 (defun article-translate-strings (map)
2145 "Translate all string in the body of the article according to MAP.
2146 MAP is an alist where the elements are on the form (\"from\" \"to\")."
2148 (when (article-goto-body)
2149 (let ((inhibit-read-only t))
2151 (let ((from (car elem))
2155 (while (search-forward from nil t)
2158 (if (eq (following-char) from)
2162 (forward-char 1)))))))))))
2164 (defun article-treat-overstrike ()
2165 "Translate overstrikes into bold text."
2168 (when (article-goto-body)
2169 (let ((inhibit-read-only t))
2170 (while (search-forward "\b" nil t)
2171 (let ((next (char-after))
2172 (previous (char-after (- (point) 2))))
2173 ;; We do the boldification/underlining by hiding the
2174 ;; overstrikes and putting the proper text property
2178 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
2179 (put-text-property (point) (1+ (point)) 'face 'bold))
2181 (gnus-article-hide-text-type
2182 (1- (point)) (1+ (point)) 'overstrike)
2184 (- (point) 2) (1- (point)) 'face 'underline))
2186 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
2188 (point) (1+ (point)) 'face 'underline)))))))))
2190 (defun article-treat-ansi-sequences ()
2191 "Translate ANSI SGR control sequences into overlays or extents."
2194 (when (article-goto-body)
2195 (let ((inhibit-read-only t))
2196 (ansi-color-apply-on-region (point) (point-max))))))
2198 (defun gnus-article-treat-unfold-headers ()
2199 "Unfold folded message headers.
2200 Only the headers that fit into the current window width will be
2203 (gnus-with-article-headers
2207 (mail-header-narrow-to-field)
2208 (let* ((header (buffer-string))
2210 (or (equal gnus-article-unfold-long-headers t)
2211 (and (stringp gnus-article-unfold-long-headers)
2212 (string-match gnus-article-unfold-long-headers
2216 (goto-char (point-min))
2217 (while (re-search-forward "\n[\t ]" nil t)
2218 (replace-match " " t t)))
2219 (setq length (- (point-max) (point-min) 1))
2220 (when (or unfoldable
2221 (< length (window-width)))
2222 (while (re-search-forward "\n[\t ]" nil t)
2223 (replace-match " " t t))))
2224 (goto-char (point-max)))))))
2226 (defun gnus-article-treat-fold-headers ()
2227 "Fold message headers."
2229 (gnus-with-article-headers
2232 (mail-header-narrow-to-field)
2233 (mail-header-fold-field)
2234 (goto-char (point-max))))))
2236 (defun gnus-treat-smiley ()
2237 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2239 (gnus-with-article-buffer
2240 (if (memq 'smiley gnus-article-wash-types)
2241 (gnus-delete-images 'smiley)
2243 (let ((images (smiley-region (point) (point-max))))
2245 (gnus-add-wash-type 'smiley)
2246 (dolist (image images)
2247 (gnus-add-image 'smiley image)))))))
2249 (defun gnus-article-remove-images ()
2250 "Remove all images from the article buffer."
2252 (gnus-with-article-buffer
2255 (dolist (elem gnus-article-image-alist)
2256 (gnus-delete-images (car elem))))))
2258 (autoload 'w3m-toggle-inline-images "w3m")
2260 (defun gnus-article-show-images ()
2261 "Show any images that are in the HTML-rendered article buffer.
2262 This only works if the article in question is HTML."
2264 (gnus-with-article-buffer
2267 (if (eq mm-text-html-renderer 'w3m)
2268 (let ((mm-inline-text-html-with-images nil))
2269 (w3m-toggle-inline-images))
2270 (dolist (region (gnus-find-text-property-region (point-min) (point-max)
2272 (destructuring-bind (start end function) region
2273 (funcall function (get-text-property start 'image-url)
2276 (defun gnus-article-treat-fold-newsgroups ()
2277 "Unfold folded message headers.
2278 Only the headers that fit into the current window width will be
2281 (gnus-with-article-headers
2282 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2284 (mail-header-narrow-to-field)
2285 (while (re-search-forward ", *" nil t)
2286 (replace-match ", " t t))
2287 (mail-header-fold-field)
2288 (goto-char (point-max))))))
2290 (defcustom gnus-article-truncate-lines (default-value 'truncate-lines)
2291 "Value of `truncate-lines' in Gnus Article buffer.
2292 Valid values are nil, t, `head', `first', `last', an integer or a
2293 predicate. See Info node `(gnus)Customizing Articles'."
2294 :version "23.1" ;; No Gnus
2295 :group 'gnus-article
2296 ;; :link '(custom-manual "(gnus)Customizing Articles")
2299 (defun gnus-article-toggle-truncate-lines (&optional arg)
2300 "Toggle whether to fold or truncate long lines in article the buffer.
2301 If ARG is non-nil and not a number, toggle
2302 `gnus-article-truncate-lines' too. If ARG is a number, truncate
2303 long lines if and only if arg is positive."
2306 ((and (numberp arg) (> arg 0))
2307 (setq gnus-article-truncate-lines t))
2309 (setq gnus-article-truncate-lines nil))
2311 (setq gnus-article-truncate-lines
2312 (not gnus-article-truncate-lines))))
2313 (gnus-with-article-buffer
2315 ((and (numberp arg) (> arg 0))
2316 (setq truncate-lines nil))
2318 (setq truncate-lines t)))
2319 ;; In versions of Emacs 22 (CVS) before 2006-05-26,
2320 ;; `toggle-truncate-lines' needs an argument.
2321 (toggle-truncate-lines)))
2323 (defun gnus-article-treat-body-boundary ()
2324 "Place a boundary line at the end of the headers."
2326 (when (and gnus-body-boundary-delimiter
2327 (> (length gnus-body-boundary-delimiter) 0))
2328 (gnus-with-article-headers
2329 (goto-char (point-max))
2330 (let ((start (point)))
2331 (insert "X-Boundary: ")
2332 (gnus-add-text-properties start (point) '(invisible t intangible t))
2333 (insert (let (str (max (window-width)))
2334 (if (featurep 'xemacs)
2335 (setq max (1- max)))
2336 (while (>= max (length str))
2337 (setq str (concat str gnus-body-boundary-delimiter)))
2338 (substring str 0 max))
2340 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2342 (defun article-fill-long-lines ()
2343 "Fill lines that are wider than the window width."
2346 (let ((inhibit-read-only t)
2347 (width (window-width (get-buffer-window (current-buffer)))))
2350 (let ((adaptive-fill-mode nil)) ;Why? -sm
2353 (when (>= (current-column) (min fill-column width))
2354 (narrow-to-region (min (1+ (point)) (point-max))
2356 (let ((goback (point-marker)))
2357 (fill-paragraph nil)
2358 (goto-char (marker-position goback)))
2360 (forward-line 1)))))))
2362 (defun article-capitalize-sentences ()
2363 "Capitalize the first word in each sentence."
2366 (let ((inhibit-read-only t)
2367 (paragraph-start "^[\n\^L]"))
2371 (forward-sentence)))))
2373 (defun article-remove-cr ()
2374 "Remove trailing CRs and then translate remaining CRs into LFs."
2377 (let ((inhibit-read-only t))
2378 (goto-char (point-min))
2379 (while (re-search-forward "\r+$" nil t)
2380 (replace-match "" t t))
2381 (goto-char (point-min))
2382 (while (search-forward "\r" nil t)
2383 (replace-match "\n" t t)))))
2385 (defun article-remove-trailing-blank-lines ()
2386 "Remove all trailing blank lines from the article."
2389 (let ((inhibit-read-only t))
2390 (goto-char (point-max))
2394 (while (and (not (bobp))
2395 (looking-at "^[ \t]*$")
2396 (not (gnus-annotation-in-region-p
2397 (point) (point-at-eol))))
2402 (defvar gnus-face-properties-alist)
2404 (defun article-display-face (&optional force)
2405 "Display any Face headers in the header."
2406 (interactive (list 'force))
2407 (let ((wash-face-p buffer-read-only))
2408 (gnus-with-article-headers
2409 ;; When displaying parts, this function can be called several times on
2410 ;; the same article, without any intended toggle semantic (as typing `W
2411 ;; D d' would have). So face deletion must occur only when we come from
2412 ;; an interactive command, that is when the *Article* buffer is
2414 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2415 (gnus-delete-images 'face)
2416 (let ((from (message-fetch-field "from"))
2418 (save-current-buffer
2419 (when (and wash-face-p
2420 (gnus-buffer-live-p gnus-original-article-buffer)
2421 (not (re-search-forward "^Face:[\t ]*" nil t)))
2422 (set-buffer gnus-original-article-buffer))
2424 (mail-narrow-to-head)
2426 ;; Check whether this face is censored.
2427 (not (and gnus-article-x-face-too-ugly
2429 (setq from (message-fetch-field "from")))
2430 (string-match gnus-article-x-face-too-ugly
2432 (while (gnus-article-goto-header "Face")
2433 (push (mail-header-field-value) faces)))))
2435 (goto-char (point-min))
2437 (unless (setq from (gnus-article-goto-header "from"))
2440 (insert " [no `from' set]\n"))
2442 (when (setq png (gnus-convert-face-to-png (pop faces)))
2444 (apply 'gnus-create-image png 'png t
2445 (cdr (assq 'png gnus-face-properties-alist))))
2448 (gnus-add-wash-type 'face)
2449 (gnus-add-image 'face image)
2450 (gnus-put-image image nil 'face)))))))))))
2452 (defun article-display-x-face (&optional force)
2453 "Look for an X-Face header and display it if present."
2454 (interactive (list 'force))
2455 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2456 (gnus-with-article-headers
2457 ;; Delete the old process, if any.
2458 (when (process-status "article-x-face")
2459 (delete-process "article-x-face"))
2460 ;; See the comment in `article-display-face'.
2461 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2462 ;; We have already displayed X-Faces, so we remove them
2464 (gnus-delete-images 'xface)
2466 (let ((from (message-fetch-field "from"))
2468 (save-current-buffer
2469 (when (and wash-face-p
2470 (gnus-buffer-live-p gnus-original-article-buffer)
2471 (not (re-search-forward "^X-Face:[\t ]*" nil t)))
2472 ;; If type `W f', use gnus-original-article-buffer,
2473 ;; otherwise use the current buffer because displaying
2474 ;; RFC822 parts calls this function too.
2475 (set-buffer gnus-original-article-buffer))
2477 (mail-narrow-to-head)
2478 (and gnus-article-x-face-command
2480 ;; Check whether this face is censored.
2481 (not (and gnus-article-x-face-too-ugly
2483 (setq from (message-fetch-field "from")))
2484 (string-match gnus-article-x-face-too-ugly
2486 (while (gnus-article-goto-header "X-Face")
2487 (push (mail-header-field-value) x-faces)))))
2489 ;; We display the face.
2490 (cond ((functionp gnus-article-x-face-command)
2491 ;; The command is a lisp function, so we call it.
2492 (mapc gnus-article-x-face-command x-faces))
2493 ((stringp gnus-article-x-face-command)
2494 ;; The command is a string, so we interpret the command
2495 ;; as a, well, command, and fork it off.
2496 (let ((process-connection-type nil))
2497 (gnus-set-process-query-on-exit-flag
2499 "article-x-face" nil shell-file-name
2500 shell-command-switch gnus-article-x-face-command)
2502 ;; Sending multiple EOFs to xv doesn't work,
2503 ;; so we only do a single external face.
2505 (insert (car x-faces))
2506 (process-send-region "article-x-face"
2507 (point-min) (point-max)))
2508 (process-send-eof "article-x-face")))
2510 (error "`%s' set to `%s' is not a function"
2511 gnus-article-x-face-command
2512 'gnus-article-x-face-command)))))))))
2514 (defun article-decode-mime-words ()
2515 "Decode all MIME-encoded words in the article."
2517 (gnus-with-article-buffer
2518 (let ((inhibit-point-motion-hooks t)
2519 (mail-parse-charset gnus-newsgroup-charset)
2520 (mail-parse-ignored-charsets
2521 (with-current-buffer gnus-summary-buffer
2522 gnus-newsgroup-ignored-charsets)))
2523 (mail-decode-encoded-word-region (point-min) (point-max)))))
2525 (defun article-decode-charset (&optional prompt)
2526 "Decode charset-encoded text in the article.
2527 If PROMPT (the prefix), prompt for a coding system to use."
2529 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2530 (inhibit-read-only t)
2531 (mail-parse-charset gnus-newsgroup-charset)
2532 (mail-parse-ignored-charsets
2533 (save-excursion (condition-case nil
2534 (set-buffer gnus-summary-buffer)
2536 gnus-newsgroup-ignored-charsets))
2537 ct cte ctl charset format)
2540 (article-narrow-to-head)
2541 (setq ct (message-fetch-field "Content-Type" t)
2542 cte (message-fetch-field "Content-Transfer-Encoding" t)
2543 ctl (and ct (mail-header-parse-content-type ct))
2546 (mm-read-coding-system "Charset to decode: "))
2548 (mail-content-type-get ctl 'charset)))
2549 format (and ctl (mail-content-type-get ctl 'format)))
2551 (setq cte (mail-header-strip cte)))
2552 (if (and ctl (not (string-match "/" (car ctl))))
2554 (goto-char (point-max)))
2557 (narrow-to-region (point) (point-max))
2558 (when (and (eq mail-parse-charset 'gnus-decoded)
2559 (eq (mm-body-7-or-8) '8bit))
2560 ;; The text code could have been decoded.
2561 (setq charset mail-parse-charset))
2562 (when (and (or (not ctl)
2563 (equal (car ctl) "text/plain"))
2564 (not format)) ;; article with format will decode later.
2566 charset (and cte (intern (downcase
2567 (gnus-strip-whitespace cte))))
2570 (defun article-decode-encoded-words ()
2571 "Remove encoded-word encoding from headers."
2572 (let ((inhibit-point-motion-hooks t)
2573 (mail-parse-charset gnus-newsgroup-charset)
2574 (mail-parse-ignored-charsets
2575 (save-excursion (condition-case nil
2576 (set-buffer gnus-summary-buffer)
2578 gnus-newsgroup-ignored-charsets))
2579 (inhibit-read-only t)
2581 (goto-char (point-min))
2582 (when (search-forward "\n\n" nil 'move)
2589 (memq (char-after) '(?\t ? )))))
2590 (setq start (point))
2592 \\(?:Resent-\\)?\\(?:From\\|Cc\\|To\\|Bcc\\|\\(?:In-\\)?Reply-To\\|Sender\
2593 \\|Mail-Followup-To\\|Mail-Copies-To\\|Approved\\):")
2594 (funcall gnus-decode-address-function start end)
2595 (funcall gnus-decode-header-function start end))
2596 (goto-char (setq end start)))))
2598 (defun article-decode-group-name ()
2599 "Decode group names in Newsgroups, Followup-To and Xref headers."
2600 (let ((inhibit-point-motion-hooks t)
2601 (inhibit-read-only t)
2602 (method (gnus-find-method-for-group gnus-newsgroup-name))
2604 (when (and (or gnus-group-name-charset-method-alist
2605 gnus-group-name-charset-group-alist)
2606 (gnus-buffer-live-p gnus-original-article-buffer))
2608 (article-narrow-to-head)
2609 (dolist (header '("Newsgroups" "Followup-To" "Xref"))
2610 (with-current-buffer gnus-original-article-buffer
2611 (goto-char (point-min)))
2612 (setq regexp (concat "^" header
2613 ":\\([^\n]*\\(?:\n[\t ]+[^\n]+\\)*\\)\n"))
2614 (while (re-search-forward regexp nil t)
2615 (replace-match (save-match-data
2616 (gnus-decode-newsgroups
2617 ;; XXX how to use data in article buffer?
2618 (with-current-buffer gnus-original-article-buffer
2619 (re-search-forward regexp nil t)
2621 gnus-newsgroup-name method))
2623 (goto-char (point-min)))))))
2625 (autoload 'idna-to-unicode "idna")
2627 (defun article-decode-idna-rhs ()
2628 "Decode IDNA strings in RHS in various headers in current buffer.
2629 The following headers are decoded: From:, To:, Cc:, Reply-To:,
2630 Mail-Reply-To: and Mail-Followup-To:."
2633 (let ((inhibit-point-motion-hooks t)
2634 (inhibit-read-only t))
2635 (article-narrow-to-head)
2636 (goto-char (point-min))
2637 (while (re-search-forward "@[^ \t\n\r,>]*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2639 (when (save-match-data
2640 (and (setq ace (match-string 1))
2642 (and (re-search-backward "^[^ \t]" nil t)
2643 (looking-at "From\\|To\\|Cc\\|Reply-To\\|Mail-Reply-To\\|Mail-Followup-To")))
2644 (setq unicode (idna-to-unicode ace))))
2645 (unless (string= ace unicode)
2646 (replace-match unicode nil nil nil 1)))))))))
2648 (defun article-de-quoted-unreadable (&optional force read-charset)
2649 "Translate a quoted-printable-encoded article.
2650 If FORCE, decode the article whether it is marked as quoted-printable
2652 If READ-CHARSET, ask for a coding system."
2653 (interactive (list 'force current-prefix-arg))
2655 (let ((inhibit-read-only t) type charset)
2656 (if (gnus-buffer-live-p gnus-original-article-buffer)
2657 (with-current-buffer gnus-original-article-buffer
2659 (gnus-fetch-field "content-transfer-encoding"))
2660 (let* ((ct (gnus-fetch-field "content-type"))
2661 (ctl (and ct (mail-header-parse-content-type ct))))
2662 (setq charset (and ctl
2663 (mail-content-type-get ctl 'charset)))
2664 (if (stringp charset)
2665 (setq charset (intern (downcase charset)))))))
2667 (setq charset (mm-read-coding-system "Charset: " charset)))
2669 (setq charset gnus-newsgroup-charset))
2671 (and type (let ((case-fold-search t))
2672 (string-match "quoted-printable" type))))
2674 (quoted-printable-decode-region
2675 (point) (point-max) (mm-charset-to-coding-system charset nil t))))))
2677 (defun article-de-base64-unreadable (&optional force read-charset)
2678 "Translate a base64 article.
2679 If FORCE, decode the article whether it is marked as base64 not.
2680 If READ-CHARSET, ask for a coding system."
2681 (interactive (list 'force current-prefix-arg))
2683 (let ((inhibit-read-only t) type charset)
2684 (if (gnus-buffer-live-p gnus-original-article-buffer)
2685 (with-current-buffer gnus-original-article-buffer
2687 (gnus-fetch-field "content-transfer-encoding"))
2688 (let* ((ct (gnus-fetch-field "content-type"))
2689 (ctl (and ct (mail-header-parse-content-type ct))))
2690 (setq charset (and ctl
2691 (mail-content-type-get ctl 'charset)))
2692 (if (stringp charset)
2693 (setq charset (intern (downcase charset)))))))
2695 (setq charset (mm-read-coding-system "Charset: " charset)))
2697 (setq charset gnus-newsgroup-charset))
2699 (and type (let ((case-fold-search t))
2700 (string-match "base64" type))))
2703 (narrow-to-region (point) (point-max))
2704 (base64-decode-region (point-min) (point-max))
2705 (mm-decode-coding-region
2706 (point-min) (point-max)
2707 (mm-charset-to-coding-system charset nil t)))))))
2712 (defun article-decode-HZ ()
2713 "Translate a HZ-encoded article."
2717 (let ((inhibit-read-only t))
2718 (rfc1843-decode-region (point-min) (point-max)))))
2720 (defun article-unsplit-urls ()
2721 "Remove the newlines that some other mailers insert into URLs."
2724 (let ((inhibit-read-only t))
2725 (goto-char (point-min))
2726 (while (re-search-forward
2727 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2728 (replace-match "\\1\\3" t)))
2729 (when (gmm-called-interactively-p 'any)
2730 (gnus-treat-article nil))))
2732 (defun article-wash-html ()
2733 "Format an HTML article."
2736 (buffer-read-only nil))
2737 (when (gnus-buffer-live-p gnus-original-article-buffer)
2738 (with-current-buffer gnus-original-article-buffer
2739 (setq handles (mm-dissect-buffer t t))))
2741 (delete-region (point) (point-max))
2742 (mm-enable-multibyte)
2743 (mm-inline-text-html handles)))
2745 (defvar gnus-article-browse-html-temp-list nil
2746 "List of temporary files created by `gnus-article-browse-html-parts'.
2747 Internal variable.")
2749 (defcustom gnus-article-browse-delete-temp 'ask
2750 "What to do with temporary files from `gnus-article-browse-html-parts'.
2751 If nil, don't delete temporary files. If it is t, delete them on
2752 exit from the summary buffer. If it is the symbol `file', query
2753 on each file, if it is `ask' ask once when exiting from the
2755 :group 'gnus-article
2756 :version "23.1" ;; No Gnus
2757 :type '(choice (const :tag "Don't delete" nil)
2758 (const :tag "Don't ask" t)
2759 (const :tag "Ask" ask)
2760 (const :tag "Ask for each file" file)))
2762 ;; Cf. mm-postponed-undisplay-list / mm-destroy-postponed-undisplay-list.
2764 (defun gnus-article-browse-delete-temp-files (&optional how)
2765 "Delete temp-files created by `gnus-article-browse-html-parts'."
2766 (when (and gnus-article-browse-html-temp-list
2768 (or how (setq how gnus-article-browse-delete-temp))
2770 (let ((files (length gnus-article-browse-html-temp-list)))
2773 "Delete the temporary HTML file? "
2774 (format "Delete all %s temporary HTML files? "
2776 (setq gnus-article-browse-html-temp-list nil)))
2778 (dolist (file gnus-article-browse-html-temp-list)
2779 (cond ((file-directory-p file)
2780 (when (or (not (eq how 'file))
2783 "Delete temporary HTML file(s) in directory `%s'? "
2784 (file-name-as-directory file))))
2785 (gnus-delete-directory file)))
2786 ((file-exists-p file)
2787 (when (or (not (eq how 'file))
2789 (format "Delete temporary HTML file `%s'? " file)))
2790 (delete-file file)))))
2791 ;; Also remove file from the list when not deleted or if file doesn't
2793 (setq gnus-article-browse-html-temp-list nil))
2794 gnus-article-browse-html-temp-list)
2796 (defun gnus-article-browse-html-save-cid-content (cid handles directory abs)
2797 "Find CID content in HANDLES and save it in a file in DIRECTORY.
2798 Return absolute file name if ABS is non-nil, otherwise relative to
2799 the parent of DIRECTORY."
2803 (dolist (handle handles)
2805 ((not (listp handle)))
2806 ;; Exclude broken handles that `gnus-summary-enter-digest-group'
2808 ((not (or (bufferp (car handle)) (stringp (car handle)))))
2809 ((equal (mm-handle-media-supertype handle) "multipart")
2810 (when (setq file (gnus-article-browse-html-save-cid-content
2811 cid handle directory abs))
2812 (throw 'found file)))
2813 ((equal (concat "<" cid ">") (mm-handle-id handle))
2814 (setq file (or (mm-handle-filename handle)
2816 (make-temp-name "cid")
2817 (car (rassoc (car (mm-handle-type handle))
2818 mailcap-mime-extensions))))
2819 afile (expand-file-name file directory))
2820 (mm-save-part-to-file handle afile)
2821 (throw 'found (if abs
2823 (concat (file-name-nondirectory
2824 (directory-file-name directory))
2827 (defun gnus-article-browse-html-parts (list &optional header)
2828 "View all \"text/html\" parts from LIST.
2829 Recurse into multiparts. The optional HEADER that should be a decoded
2830 message header will be added to the bodies of the \"text/html\" parts."
2831 ;; Internal function used by `gnus-article-browse-html-article'.
2832 (let (type file charset content cid-dir tmp-file showed)
2833 ;; Find and show the html-parts.
2834 (dolist (handle list)
2835 ;; If HTML, show it:
2836 (cond ((not (listp handle)))
2837 ((or (equal (car (setq type (mm-handle-type handle))) "text/html")
2838 (and (equal (car type) "message/external-body")
2840 (setq file (mm-handle-filename handle)))
2841 (or (mm-handle-cache handle)
2842 (condition-case code
2843 (progn (mm-extern-cache-contents handle) t)
2845 (gnus-message 3 "%s" (error-message-string code))
2846 (when (>= gnus-verbose 3) (sit-for 2))
2849 (setq handle (mm-handle-cache handle)
2850 type (mm-handle-type handle))
2851 (equal (car type) "text/html"))))
2852 (setq charset (mail-content-type-get type 'charset)
2853 content (mm-get-part handle))
2855 (if (eq charset 'gnus-decoded)
2856 (mm-enable-multibyte)
2857 (mm-disable-multibyte))
2859 ;; resolve cid contents
2860 (let ((case-fold-search t)
2862 (goto-char (point-min))
2863 (when (re-search-forward "<head[\t\n >]" nil t)
2864 (setq st (match-end 0)
2866 (not (re-search-forward "</head[\t\n >]" nil t))
2867 (re-search-backward "<base[\t\n >]" st t))))
2868 (while (re-search-forward "\
2869 <img[\t\n ]+\\(?:[^\t\n >]+[\t\n ]+\\)*src=\"\\(cid:\\([^\"]+\\)\\)\""
2872 (setq cid-dir (mm-make-temp-file "cid" t))
2873 (add-to-list 'gnus-article-browse-html-temp-list cid-dir))
2876 (when (setq cid-file
2877 (gnus-article-browse-html-save-cid-content
2879 (with-current-buffer gnus-article-buffer
2880 gnus-article-mime-handles)
2884 (if (eq system-type 'cygwin)
2887 (with-output-to-string
2888 (call-process "cygpath" nil
2892 (concat "file://" cid-file))))
2893 (replace-match cid-file nil nil nil 1))))
2894 (unless content (setq content (buffer-string))))
2895 (when (or charset header (not file))
2896 (setq tmp-file (mm-make-temp-file
2897 ;; Do we need to care for 8.3 filenames?
2898 "mm-" nil ".html")))
2899 ;; Add a meta html tag to specify charset and a header.
2902 (let (title eheader body hcharset coding)
2904 (mm-enable-multibyte)
2905 (setq case-fold-search t)
2906 (insert header "\n")
2907 (setq title (message-fetch-field "subject"))
2908 (goto-char (point-min))
2909 (while (re-search-forward "\\(<\\)\\|\\(>\\)\\|\\(&\\)\\|\n"
2911 (replace-match (cond ((match-beginning 1) "<")
2912 ((match-beginning 2) ">")
2913 ((match-beginning 3) "&")
2915 (goto-char (point-min))
2916 (while (re-search-forward "^[\t ]+" nil t)
2919 (delete-region (match-beginning 0)
2922 (goto-char (point-min))
2923 (insert "<div align=\"left\">\n")
2924 (goto-char (point-max))
2925 (insert "</div>\n<hr>\n")
2926 ;; We have to examine charset one by one since
2927 ;; charset specified in parts might be different.
2928 (if (eq charset 'gnus-decoded)
2929 (setq charset 'utf-8
2930 eheader (mm-encode-coding-string (buffer-string)
2933 (mm-encode-coding-string title charset))
2934 body (mm-encode-coding-string content charset))
2935 (setq hcharset (mm-find-mime-charset-region (point-min)
2937 (cond ((= (length hcharset) 1)
2938 (setq hcharset (car hcharset)
2939 coding (mm-charset-to-coding-system
2941 ((> (length hcharset) 1)
2942 (setq hcharset 'utf-8
2948 (mm-charset-to-coding-system charset
2950 (if (eq coding body)
2951 (setq eheader (mm-encode-coding-string
2952 (buffer-string) coding)
2954 (mm-encode-coding-string
2957 (setq charset 'utf-8
2958 eheader (mm-encode-coding-string
2959 (buffer-string) charset)
2961 (mm-encode-coding-string
2963 body (mm-encode-coding-string
2964 (mm-decode-coding-string
2967 (setq charset hcharset
2968 eheader (mm-encode-coding-string
2969 (buffer-string) coding)
2971 (mm-encode-coding-string
2974 (setq eheader (mm-string-as-unibyte (buffer-string))
2977 (mm-disable-multibyte)
2980 (mm-add-meta-html-tag handle charset t))
2982 (goto-char (point-min))
2983 (unless (search-forward "<title>" nil t)
2984 (re-search-forward "<head>\\s-*" nil t)
2985 (insert "<title>" title "</title>\n")))
2986 (goto-char (point-min))
2987 (or (re-search-forward
2988 "<body\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t)
2990 "</head\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t))
2992 (mm-write-region (point-min) (point-max)
2993 tmp-file nil nil nil 'binary t))))
2995 (mm-with-unibyte-buffer
2996 (insert (if (eq charset 'gnus-decoded)
2997 (mm-encode-coding-string content
2998 (setq charset 'utf-8))
3000 (if (or (mm-add-meta-html-tag handle charset)
3002 (mm-write-region (point-min) (point-max)
3003 tmp-file nil nil nil 'binary t)
3004 (setq tmp-file nil))))
3006 (mm-save-part-to-file handle tmp-file)))
3008 (add-to-list 'gnus-article-browse-html-temp-list tmp-file))
3009 (add-hook 'gnus-summary-prepare-exit-hook
3010 'gnus-article-browse-delete-temp-files)
3011 (add-hook 'gnus-exit-gnus-hook
3013 (gnus-article-browse-delete-temp-files t)))
3014 ;; FIXME: Warn if there's an <img> tag?
3015 (browse-url-of-file (or tmp-file (expand-file-name file)))
3017 ;; If multipart, recurse
3018 ((equal (mm-handle-media-supertype handle) "multipart")
3019 (when (gnus-article-browse-html-parts handle header)
3021 ((equal (mm-handle-media-type handle) "message/rfc822")
3022 (mm-with-multibyte-buffer
3023 (mm-insert-part handle)
3024 (setq handle (mm-dissect-buffer t t))
3025 (when (and (bufferp (car handle))
3026 (stringp (car (mm-handle-type handle))))
3027 (setq handle (list handle)))
3029 (article-decode-encoded-words)
3030 (let ((gnus-visible-headers
3031 (or (get 'gnus-visible-headers 'standard-value)
3032 gnus-visible-headers)))
3033 (article-hide-headers))
3034 (goto-char (point-min))
3035 (search-forward "\n\n" nil 'move)
3036 (skip-chars-backward "\t\n ")
3037 (setq header (buffer-substring (point-min) (point)))))
3039 (gnus-article-browse-html-parts handle header)
3040 (mm-destroy-parts handle))
3044 (defun gnus-article-browse-html-article (&optional arg)
3045 "View \"text/html\" parts of the current article with a WWW browser.
3046 Inline images embedded in a message using the cid scheme, as they are
3047 generally considered to be safe, will be processed properly.
3048 The message header is added to the beginning of every html part unless
3049 the prefix argument ARG is given.
3051 Warning: Spammers use links to images (using the http scheme) in HTML
3052 articles to verify whether you have read the message. As
3053 `gnus-article-browse-html-article' passes the HTML content to the
3054 browser without eliminating these \"web bugs\" you should only
3055 use it for mails from trusted senders.
3057 If you always want to display HTML parts in the browser, set
3058 `mm-text-html-renderer' to nil.
3060 This command creates temporary files to pass HTML contents including
3061 images if any to the browser, and deletes them when exiting the group
3063 ;; Cf. `mm-w3m-safe-url-regexp'
3066 (gnus-summary-show-article)
3067 (let ((gnus-visible-headers (or (get 'gnus-visible-headers 'standard-value)
3068 gnus-visible-headers))
3069 ;; As we insert a <hr>, there's no need for the body boundary.
3070 (gnus-treat-body-boundary nil))
3071 (gnus-summary-show-article)))
3072 (with-current-buffer gnus-article-buffer
3073 (let ((header (unless arg
3076 (buffer-substring-no-properties
3077 (goto-char (point-min))
3078 (if (search-forward "\n\n" nil t)
3080 (goto-char (point-max))
3081 (skip-chars-backward "\t\n ")
3084 (set-buffer gnus-original-article-buffer)
3085 (setq parts (mm-dissect-buffer t t))
3086 ;; If singlepart, enforce a list.
3087 (when (and (bufferp (car parts))
3088 (stringp (car (mm-handle-type parts))))
3089 (setq parts (list parts)))
3091 (unless (gnus-article-browse-html-parts parts header)
3092 (gnus-error 3 "Mail doesn't contain a \"text/html\" part!"))
3093 (mm-destroy-parts parts)
3095 (gnus-summary-show-article)))))
3097 (defun article-hide-list-identifiers ()
3098 "Remove list identifiers from the Subject header.
3099 The `gnus-list-identifiers' variable specifies what to do."
3101 (let ((inhibit-point-motion-hooks t)
3102 (regexp (gnus-group-get-list-identifiers gnus-newsgroup-name))
3103 (inhibit-read-only t))
3107 (article-narrow-to-head)
3108 (goto-char (point-min))
3109 (while (re-search-forward
3110 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
3112 (delete-region (match-beginning 2) (match-end 0))
3113 (beginning-of-line))
3114 (when (re-search-forward
3115 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
3116 (delete-region (match-beginning 1) (match-end 1))))))))
3118 (defun article-hide-pem (&optional arg)
3119 "Toggle hiding of any PEM headers and signatures in the current article.
3120 If given a negative prefix, always show; if given a positive prefix,
3122 (interactive (gnus-article-hidden-arg))
3123 (unless (gnus-article-check-hidden-text 'pem arg)
3125 (let ((inhibit-read-only t) end)
3126 (goto-char (point-min))
3127 ;; Hide the horrendously ugly "header".
3128 (when (and (search-forward
3129 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
3131 (setq end (1+ (match-beginning 0))))
3132 (gnus-add-wash-type 'pem)
3133 (gnus-article-hide-text-type
3135 (if (search-forward "\n\n" nil t)
3139 ;; Hide the trailer as well
3140 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
3142 (gnus-article-hide-text-type
3143 (match-beginning 0) (match-end 0) 'pem)))))))
3145 (defun article-strip-banner ()
3146 "Strip the banners specified by the `banner' group parameter and by
3147 `gnus-article-address-banner-alist'."
3151 (let ((inhibit-point-motion-hooks t))
3152 (when (gnus-parameter-banner gnus-newsgroup-name)
3153 (article-really-strip-banner
3154 (gnus-parameter-banner gnus-newsgroup-name)))
3155 (when gnus-article-address-banner-alist
3156 ;; Note that the From header is decoded here, so it is
3157 ;; required that the *-extract-address-components function
3158 ;; supports non-ASCII text.
3159 (let ((from (save-restriction
3161 (article-narrow-to-head)
3162 (mail-fetch-field "from"))))
3165 (cadr (funcall gnus-extract-address-components
3168 (dolist (pair gnus-article-address-banner-alist)
3169 (when (string-match (car pair) from)
3171 (article-really-strip-banner (cdr pair)))))))))))))
3173 (defun article-really-strip-banner (banner)
3174 "Strip the banner specified by the argument."
3177 (let ((inhibit-point-motion-hooks t)
3178 (gnus-signature-limit nil)
3179 (inhibit-read-only t))
3182 ((eq banner 'signature)
3183 (when (gnus-article-narrow-to-signature)
3186 (delete-region (point) (point-max))))
3188 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
3189 (while (re-search-forward banner nil t)
3190 (delete-region (match-beginning 0) (match-end 0)))))
3192 (while (re-search-forward banner nil t)
3193 (delete-region (match-beginning 0) (match-end 0)))))))))
3195 (defun article-babel ()
3196 "Translate article using an online translation service."
3199 (gnus-with-article-buffer
3200 (when (article-goto-body)
3201 (let* ((start (point))
3203 (orig (buffer-substring start end))
3204 (trans (babel-as-string orig)))
3206 (narrow-to-region start end)
3207 (delete-region start end)
3210 (defun article-hide-signature (&optional arg)
3211 "Hide the signature in the current article.
3212 If given a negative prefix, always show; if given a positive prefix,
3214 (interactive (gnus-article-hidden-arg))
3215 (unless (gnus-article-check-hidden-text 'signature arg)
3218 (let ((inhibit-read-only t))
3219 (when (gnus-article-narrow-to-signature)
3220 (gnus-article-hide-text-type
3221 (point-min) (point-max) 'signature))))))
3222 (gnus-set-mode-line 'article))
3224 (defun article-strip-headers-in-body ()
3225 "Strip offensive headers from bodies."
3229 (let ((case-fold-search t))
3230 (when (looking-at "x-no-archive:")
3231 (gnus-delete-line)))))
3233 (defun article-strip-leading-blank-lines ()
3234 "Remove all blank lines from the beginning of the article."
3237 (let ((inhibit-point-motion-hooks t)
3238 (inhibit-read-only t))
3239 (when (article-goto-body)
3240 (while (and (not (eobp))
3241 (looking-at "[ \t]*$"))
3242 (gnus-delete-line))))))
3244 (defun article-narrow-to-head ()
3245 "Narrow the buffer to the head of the message.
3246 Point is left at the beginning of the narrowed-to region."
3248 (goto-char (point-min))
3250 ;; Absolutely no headers displayed.
3254 ((search-forward "\n\n" nil 1)
3256 ;; Nothing but headers.
3259 (goto-char (point-min)))
3261 (defun article-goto-body ()
3262 "Place point at the start of the body."
3263 (goto-char (point-min))
3265 ;; This variable is only bound when dealing with separate
3267 (article-goto-body-goes-to-point-min-p
3269 ((search-forward "\n\n" nil t)
3272 (goto-char (point-max))
3275 (defun article-strip-multiple-blank-lines ()
3276 "Replace consecutive blank lines with one empty line."
3279 (let ((inhibit-point-motion-hooks t)
3280 (inhibit-read-only t))
3281 ;; First make all blank lines empty.
3283 (while (re-search-forward "^[ \t]+$" nil t)
3284 (unless (gnus-annotation-in-region-p
3285 (match-beginning 0) (match-end 0))
3286 (replace-match "" nil t)))
3287 ;; Then replace multiple empty lines with a single empty line.
3289 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
3290 (unless (gnus-annotation-in-region-p
3291 (match-beginning 0) (match-end 0))
3292 (delete-region (match-beginning 1) (match-end 1)))))))
3294 (defun article-strip-leading-space ()
3295 "Remove all white space from the beginning of the lines in the article."
3298 (let ((inhibit-point-motion-hooks t)
3299 (inhibit-read-only t))
3301 (while (re-search-forward "^[ \t]+" nil t)
3302 (replace-match "" t t)))))
3304 (defun article-strip-trailing-space ()
3305 "Remove all white space from the end of the lines in the article."
3308 (let ((inhibit-point-motion-hooks t)
3309 (inhibit-read-only t))
3311 (while (re-search-forward "[ \t]+$" nil t)
3312 (replace-match "" t t)))))
3314 (defun article-strip-blank-lines ()
3315 "Strip leading, trailing and multiple blank lines."
3317 (article-strip-leading-blank-lines)
3318 (article-remove-trailing-blank-lines)
3319 (article-strip-multiple-blank-lines))
3321 (defun article-strip-all-blank-lines ()
3322 "Strip all blank lines."
3325 (let ((inhibit-point-motion-hooks t)
3326 (inhibit-read-only t))
3328 (while (re-search-forward "^[ \t]*\n" nil t)
3329 (replace-match "" t t)))))
3331 (defun gnus-article-narrow-to-signature ()
3332 "Narrow to the signature; return t if a signature is found, else nil."
3333 (let ((inhibit-point-motion-hooks t))
3334 (when (gnus-article-search-signature)
3336 ;; Check whether we have some limits to what we consider
3337 ;; to be a signature.
3338 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
3339 (list gnus-signature-limit)))
3341 (while (setq limit (pop limits))
3342 (if (or (and (integerp limit)
3343 (< (- (point-max) (point)) limit))
3345 (< (count-lines (point) (point-max)) limit))
3346 (and (functionp limit)
3348 (and (stringp limit)
3349 (not (re-search-forward limit nil t))))
3350 () ; This limit did not succeed.
3354 (narrow-to-region (point) (point-max))
3357 (defun gnus-article-search-signature ()
3358 "Search the current buffer for the signature separator.
3359 Put point at the beginning of the signature separator."
3360 (let ((cur (point)))
3361 (goto-char (point-max))
3362 (if (if (stringp gnus-signature-separator)
3363 (re-search-backward gnus-signature-separator nil t)
3364 (let ((seps gnus-signature-separator))
3366 (not (re-search-backward (car seps) nil t)))
3373 (defun gnus-article-hidden-arg ()
3374 "Return the current prefix arg as a number, or 0 if no prefix."
3375 (list (if current-prefix-arg
3376 (prefix-numeric-value current-prefix-arg)
3379 (defun gnus-article-check-hidden-text (type arg)
3380 "Return nil if hiding is necessary.
3381 Arg can be nil or a number. nil and positive means hide, negative
3382 means show, 0 means toggle."
3385 (let ((hide (gnus-article-hidden-text-p type)))
3391 (gnus-article-show-hidden-text type)
3394 (if (eq hide 'hidden)
3396 (gnus-article-show-hidden-text type)
3400 (defun gnus-article-hidden-text-p (type)
3401 "Say whether the current buffer contains hidden text of type TYPE."
3402 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
3404 (not (get-text-property pos 'invisible))
3405 (not (get-text-property pos 'dummy-invisible)))
3407 (text-property-any (1+ pos) (point-max) 'article-type type)))
3412 (defun gnus-article-show-hidden-text (type &optional _dummy)
3413 "Show all hidden text of type TYPE.
3414 Originally it is hide instead of DUMMY."
3415 (let ((inhibit-read-only t)
3416 (inhibit-point-motion-hooks t))
3417 (gnus-remove-text-properties-when
3419 (point-min) (point-max)
3420 (cons 'article-type (cons type
3421 gnus-hidden-properties)))
3422 (gnus-delete-wash-type type)))
3424 (defconst article-time-units
3425 `((year . ,(* 365.25 24 60 60))
3426 (week . ,(* 7 24 60 60))
3427 (day . ,(* 24 60 60))
3431 "Mapping from time units to seconds.")
3433 (defun gnus-article-forward-header ()
3434 "Move point to the start of the next header.
3435 If the current header is a continuation header, this can be several
3440 (if (looking-at "[ \t]+[^ \t]")
3444 (defun article-treat-date ()
3445 (article-date-ut (if (gnus-buffer-live-p gnus-summary-buffer)
3446 (with-current-buffer gnus-summary-buffer
3447 gnus-article-date-headers)
3448 gnus-article-date-headers)
3451 (defun article-date-ut (&optional type _highlight date-position)
3452 "Convert DATE date to TYPE in the current article.
3453 The default type is `ut'. See `gnus-article-date-headers' for
3455 (interactive (list 'ut t))
3456 (let* ((case-fold-search t)
3457 (inhibit-read-only t)
3458 (inhibit-point-motion-hooks t)
3459 (visible-date (mail-fetch-field "Date"))
3460 pos date bface eface)
3464 (goto-char date-position)
3465 (setq date (get-text-property (point) 'original-date))
3466 (when (looking-at "[^:]+:[\t ]*")
3467 (setq bface (get-text-property (match-beginning 0) 'face)
3468 eface (get-text-property (match-end 0) 'face)))
3469 (delete-region (point)
3471 (gnus-article-forward-header)
3473 (article-transform-date date type bface eface))
3476 (goto-char (point-min))
3477 (while (or (get-text-property (setq pos (point)) 'original-date)
3478 (and (setq pos (next-single-property-change
3479 (point) 'original-date))
3481 (narrow-to-region pos (if (search-forward "\n\n" nil t)
3482 (1+ (match-beginning 0))
3484 (while (setq pos (text-property-not-all pos (point-max)
3485 'gnus-date-type nil))
3486 (setq date (get-text-property pos 'original-date))
3488 (when (looking-at "[^:]+:[\t ]*")
3489 (setq bface (get-text-property (match-beginning 0) 'face)
3490 eface (get-text-property (match-end 0) 'face)))
3491 (delete-region pos (or (text-property-any pos (point-max)
3492 'gnus-date-type nil)
3494 (unless date ;; the 1st time
3495 (goto-char (point-min))
3496 (while (re-search-forward "^Date:[\t ]*" nil t)
3497 (setq date (get-text-property (match-beginning 0)
3499 bface (get-text-property (match-beginning 0) 'face)
3500 eface (get-text-property (match-end 0) 'face))
3501 (delete-region (point-at-bol) (progn
3502 (gnus-article-forward-header)
3504 (when (and (not date)
3506 (setq date visible-date))
3508 (article-transform-date date type bface eface))
3509 (goto-char (point-max))
3512 (defun article-transform-date (date type bface eface)
3513 (dolist (this-type (cond
3523 (add-text-properties
3526 (insert (article-make-date-line date (or this-type 'ut)) "\n")
3528 (list 'original-date date 'gnus-date-type this-type))))
3531 "\\([^:]+:\\)[\t ]*\\(\\(?:[^\t\n ]+[\t ]+\\)*[^\t\n ]+\\)?")
3532 (put-text-property (match-beginning 1) (match-end 1) 'face bface)
3533 (when (match-beginning 2)
3534 (put-text-property (match-beginning 2) (match-end 2) 'face eface))
3535 (while (and (zerop (forward-line 1))
3536 (looking-at "[\t ]+\\(\\(?:[^\t\n ]+[\t ]+\\)*[^\t\n ]+\\)?"))
3537 (when (match-beginning 1)
3538 (put-text-property (match-beginning 1) (match-end 1) 'face eface))))))
3540 (defun article-make-date-line (date type)
3541 "Return a DATE line of TYPE."
3542 (unless (memq type '(local ut original user-defined iso8601 lapsed english
3544 (error "Unknown conversion type: %s" type))
3546 (let ((time (ignore-errors (date-to-time date))))
3548 ;; Convert to the local timezone.
3550 (concat "Date: " (message-make-date time)))
3551 ;; Convert to Universal Time.
3556 (let* ((e (parse-time-string date))
3557 (tm (apply 'encode-time e))
3559 (ls (- (cadr tm) (car (current-time-zone time)))))
3560 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
3561 ((> ls 65535) (list (1+ ms) (- ls 65536)))
3565 ;; Get the original date from the article.
3566 ((eq type 'original)
3567 (concat "Date: " (if (string-match "\n+$" date)
3568 (substring date 0 (match-beginning 0))
3570 ;; Let the user define the format.
3571 ((eq type 'user-defined)
3572 (let ((format (or (condition-case nil
3573 (with-current-buffer gnus-summary-buffer
3574 gnus-article-time-format)
3576 gnus-article-time-format)))
3577 (if (functionp format)
3578 (funcall format time)
3579 (concat "Date: " (format-time-string format time)))))
3582 (let ((tz (car (current-time-zone time))))
3585 (format-time-string "%Y%m%dT%H%M%S" time)
3586 (format "%s%02d%02d"
3587 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3588 (/ (% (abs tz) 3600) 60)))))
3589 ;; Do a lapsed format.
3591 (concat "Date: " (article-lapsed-string time)))
3592 ;; A combined date/lapsed format.
3593 ((eq type 'combined-lapsed)
3594 (let ((date-string (article-make-date-line date 'original))
3600 (concat " (" (article-lapsed-string time segments) ")"))
3601 (> (+ (length date-string)
3602 (length lapsed-string))
3605 (setq segments (1- segments)))
3607 (concat date-string lapsed-string)
3609 ;; Display the date in proper English
3611 (let ((dtime (decode-time time)))
3614 (number-to-string (nth 3 dtime))
3615 (let ((digit (% (nth 3 dtime) 10)))
3617 ((memq (nth 3 dtime) '(11 12 13)) "th")
3623 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3625 (number-to-string (nth 5 dtime))
3627 (format "%02d" (nth 2 dtime))
3629 (format "%02d" (nth 1 dtime)))))))
3631 (format "Date: %s (from Gnus)" date))))
3633 (defun article-lapsed-string (time &optional max-segments)
3634 ;; If the date is seriously mangled, the timezone functions are
3635 ;; liable to bug out, so we ignore all errors.
3636 (let* ((now (current-time))
3637 (real-time (subtract-time now time))
3638 (real-sec (and real-time
3639 (+ (* (float (car real-time)) 65536)
3641 (sec (and real-time (abs real-sec)))
3644 (unless max-segments
3645 (setq max-segments (length article-time-units)))
3653 ;; This is a bit convoluted, but basically we go
3654 ;; through the time units for years, weeks, etc,
3655 ;; and divide things to see whether that results
3656 ;; in positive answers.
3659 (if (or (zerop (setq num (ffloor (/ sec (cdr unit)))))
3660 (>= segments max-segments))
3661 ;; The (remaining) seconds are too few to
3662 ;; be divided into this time unit.
3664 ;; It's big enough, so we output it.
3665 (setq sec (- sec (* num (cdr unit))))
3667 (concat (if prev ", " "") (int-to-string
3669 " " (symbol-name (car unit))
3670 (if (> num 1) "s" ""))
3672 segments (1+ segments)))))
3673 article-time-units "")
3674 ;; If dates are odd, then it might appear like the
3675 ;; article was sent in the future.
3678 " in the future"))))))
3680 (defun article-date-local (&optional highlight)
3681 "Convert the current article date to the local timezone."
3682 (interactive (list t))
3683 (article-date-ut 'local highlight))
3685 (defun article-date-english (&optional highlight)
3686 "Convert the current article date to something that is proper English."
3687 (interactive (list t))
3688 (article-date-ut 'english highlight))
3690 (defun article-date-original (&optional highlight)
3691 "Convert the current article date to what it was originally.
3692 This is only useful if you have used some other date conversion
3693 function and want to see what the date was before converting."
3694 (interactive (list t))
3695 (article-date-ut 'original highlight))
3697 (defun article-date-lapsed (&optional highlight)
3698 "Convert the current article date to time lapsed since it was sent."
3699 (interactive (list t))
3700 (article-date-ut 'lapsed highlight))
3702 (defun article-date-combined-lapsed (&optional highlight)
3703 "Convert the current article date to time lapsed since it was sent."
3704 (interactive (list t))
3705 (article-date-ut 'combined-lapsed highlight))
3707 (defun article-update-date-lapsed ()
3708 "Function to be run from a timer to update the lapsed time line."
3710 (let ((buffer (current-buffer)))
3714 (set-buffer (window-buffer w))
3715 (when (derived-mode-p 'gnus-article-mode)
3716 (let ((old-line (count-lines (point-min) (point)))
3717 (old-column (- (point) (line-beginning-position)))
3718 (window-start (window-start w))
3721 (while (setq pos (text-property-not-all pos (point-max)
3722 'gnus-date-type nil))
3723 (setq next (or (next-single-property-change pos
3726 (setq type (get-text-property pos 'gnus-date-type))
3727 (when (memq type '(lapsed combined-lapsed user-defined))
3728 (article-date-ut type t pos)
3729 (setq end (or (next-single-property-change pos
3733 (if (/= window-start next)
3734 (setq window-start nil)
3735 (set-window-start w end)))
3738 (goto-char (point-min))
3739 (when (> old-column 0)
3740 (setq old-line (1- old-line)))
3741 (forward-line old-line)
3743 (when (> (current-column) old-column)
3745 (forward-char old-column)))))
3747 (set-buffer buffer))))
3749 (defun gnus-start-date-timer (&optional n)
3750 "Start a timer to update the Date headers in the article buffers.
3751 The numerical prefix says how frequently (in seconds) the function
3756 (gnus-stop-date-timer)
3757 (setq article-lapsed-timer
3758 (run-at-time 1 n 'article-update-date-lapsed)))
3760 (defun gnus-stop-date-timer ()
3761 "Stop the Date timer."
3763 (when article-lapsed-timer
3764 (nnheader-cancel-timer article-lapsed-timer)
3765 (setq article-lapsed-timer nil)))
3767 (defun article-date-user (&optional highlight)
3768 "Convert the current article date to the user-defined format.
3769 This format is defined by the `gnus-article-time-format' variable."
3770 (interactive (list t))
3771 (article-date-ut 'user highlight))
3773 (defun article-date-iso8601 (&optional highlight)
3774 "Convert the current article date to ISO8601."
3775 (interactive (list t))
3776 (article-date-ut 'iso8601 highlight))
3778 (defmacro gnus-article-save-original-date (&rest forms)
3779 "Save the original date as a text property and evaluate FORMS."
3780 `(let* ((case-fold-search t)
3782 (goto-char (point-min))
3783 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3786 (date (when (and start
3787 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3789 (buffer-substring-no-properties start
3790 (match-beginning 0)))))
3791 (goto-char (point-max))
3792 (skip-chars-backward "\n")
3793 (put-text-property (point-min) (point) 'original-date date)
3795 (goto-char (point-max))
3796 (skip-chars-backward "\n")
3797 (put-text-property (point-min) (point) 'original-date date)))
3799 ;; (defun article-show-all ()
3800 ;; "Show all hidden text in the article buffer."
3803 ;; (let ((inhibit-read-only t))
3804 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3806 (defun article-remove-leading-whitespace ()
3807 "Remove excessive whitespace from all headers."
3811 (let ((inhibit-read-only t))
3812 (article-narrow-to-head)
3813 (goto-char (point-min))
3814 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3815 (delete-region (match-beginning 1) (match-end 1)))))))
3817 (defun article-emphasize (&optional arg)
3818 "Emphasize text according to `gnus-emphasis-alist'."
3819 (interactive (gnus-article-hidden-arg))
3820 (unless (gnus-article-check-hidden-text 'emphasis arg)
3824 (with-current-buffer gnus-summary-buffer
3825 gnus-article-emphasis-alist)
3827 gnus-emphasis-alist))
3828 (inhibit-read-only t)
3829 (props (append '(article-type emphasis)
3830 gnus-hidden-properties))
3831 regexp elem beg invisible visible face)
3834 (while (setq elem (pop alist))
3836 (setq regexp (car elem)
3837 invisible (nth 1 elem)
3838 visible (nth 2 elem)
3840 (while (re-search-forward regexp nil t)
3841 (when (and (match-beginning visible) (match-beginning invisible))
3842 (gnus-article-hide-text
3843 (match-beginning invisible) (match-end invisible) props)
3844 (gnus-article-unhide-text-type
3845 (match-beginning visible) (match-end visible) 'emphasis)
3846 (gnus-put-overlay-excluding-newlines
3847 (match-beginning visible) (match-end visible) 'face face)
3848 (gnus-add-wash-type 'emphasis)
3849 (goto-char (match-end invisible)))))))))
3851 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3852 "Setup newsgroup emphasis alist."
3853 (unless gnus-article-emphasis-alist
3854 (let ((name (and gnus-newsgroup-name
3855 (gnus-group-real-name gnus-newsgroup-name))))
3856 (make-local-variable 'gnus-article-emphasis-alist)
3857 (setq gnus-article-emphasis-alist
3859 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3860 (while (setq elem (pop alist))
3861 (when (and name (string-match (car elem) name))
3863 highlight (copy-sequence (cdr elem)))))
3865 (copy-sequence highlight-words)
3866 (if gnus-newsgroup-name
3867 (copy-sequence (gnus-group-find-parameter
3868 gnus-newsgroup-name 'highlight-words t)))
3869 gnus-emphasis-alist)))))
3871 (defvar gnus-summary-article-menu)
3872 (defvar gnus-summary-post-menu)
3874 ;;; Saving functions.
3876 (defun gnus-article-save (save-buffer file &optional num)
3877 "Save the currently selected article."
3878 (when (or (get gnus-default-article-saver :headers)
3879 (not gnus-save-all-headers))
3880 ;; Remove headers according to `gnus-saved-headers' or the value
3881 ;; of the `:headers' property that the saver function might have.
3882 (let ((gnus-visible-headers
3883 (or (symbol-value (get gnus-default-article-saver :headers))
3884 gnus-saved-headers gnus-visible-headers))
3885 ;; Ignore group parameter. See `article-hide-headers'.
3886 (gnus-summary-buffer nil))
3887 (with-current-buffer save-buffer
3888 (article-hide-headers 1 t))))
3889 (save-window-excursion
3890 (if (not gnus-default-article-saver)
3891 (error "No default saver is defined")
3892 ;; !!! Magic! The saving functions all save
3893 ;; `gnus-save-article-buffer' (or so they think), but we
3894 ;; bind that variable to our save-buffer.
3895 (set-buffer gnus-article-buffer)
3896 (let* ((gnus-save-article-buffer save-buffer)
3899 ((not gnus-prompt-before-saving) 'default)
3900 ((eq gnus-prompt-before-saving 'always) nil)
3902 (gnus-number-of-articles-to-be-saved
3903 (when (eq gnus-prompt-before-saving t)
3905 (set-buffer gnus-article-current-summary)
3906 (funcall gnus-default-article-saver filename)))))
3908 (defun gnus-read-save-file-name (prompt &optional filename
3909 function group headers variable
3912 (funcall function group headers (symbol-value variable)))
3917 ((eq filename 'default)
3923 (when (symbol-value dir-var)
3924 (setq default-name (expand-file-name
3925 (file-name-nondirectory default-name)
3926 (symbol-value dir-var))))
3927 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3930 (if (and gnus-number-of-articles-to-be-saved
3931 (> gnus-number-of-articles-to-be-saved 1))
3932 (format "these %d articles"
3933 gnus-number-of-articles-to-be-saved)
3936 ;; Let the split methods have their say.
3938 ;; No split name was found.
3941 (concat prompt " (default "
3942 (file-name-nondirectory default-name) "): ")
3943 (file-name-directory default-name)
3945 ;; A single group name is returned.
3946 ((stringp split-name)
3948 (funcall function split-name headers
3949 (symbol-value variable)))
3951 (concat prompt " (default "
3952 (file-name-nondirectory default-name) "): ")
3953 (file-name-directory default-name)
3955 ;; A single split name was found
3956 ((= 1 (length split-name))
3957 (let* ((name (expand-file-name
3959 gnus-article-save-directory))
3960 (dir (cond ((file-directory-p name)
3961 (file-name-as-directory name))
3962 ((file-exists-p name) name)
3963 (t gnus-article-save-directory))))
3965 (concat prompt " (default " name "): ")
3967 ;; A list of splits was found.
3969 (setq split-name (nreverse split-name))
3971 (let ((file-name-history
3972 (nconc split-name file-name-history)))
3976 (concat prompt " (`M-p' for defaults): ")
3977 gnus-article-save-directory
3979 gnus-article-save-directory)))
3980 (car (push result file-name-history)))))))
3981 ;; Create the directory.
3982 (gnus-make-directory (file-name-directory file))
3983 ;; If we have read a directory, we append the default file name.
3984 (when (file-directory-p file)
3985 (setq file (expand-file-name (file-name-nondirectory
3987 (file-name-as-directory file))))
3988 ;; Possibly translate some characters.
3989 (nnheader-translate-file-chars file))))))
3990 (gnus-make-directory (file-name-directory result))
3992 (set variable result))
3994 (set dir-var (file-name-directory result)))
3997 (defun gnus-article-archive-name (_group)
3998 "Return the first instance of an \"Archive-name\" in the current buffer."
3999 (let ((case-fold-search t))
4000 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
4001 (nnheader-concat gnus-article-save-directory
4002 (match-string 1)))))
4004 (defun gnus-article-nndoc-name (group)
4005 "If GROUP is an nndoc group, return the name of the parent group."
4006 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
4007 (gnus-group-get-parameter group 'save-article-group)))
4009 (defun gnus-summary-save-in-rmail (&optional filename)
4010 "Append this article to Rmail file.
4011 Optional argument FILENAME specifies file name.
4012 Directory to save to is default to `gnus-article-save-directory'."
4013 (setq filename (gnus-read-save-file-name
4014 "Save %s in rmail file" filename
4015 gnus-rmail-save-name gnus-newsgroup-name
4016 gnus-current-headers 'gnus-newsgroup-last-rmail))
4017 (with-current-buffer gnus-save-article-buffer
4021 ;; Note that unlike gnus-summary-save-in-mail, there is no
4022 ;; check to see if filename is Babyl. Rmail in Emacs 23 does
4024 (gnus-output-to-rmail filename))))
4027 (defun gnus-summary-save-in-mail (&optional filename)
4028 "Append this article to Unix mail file.
4029 Optional argument FILENAME specifies file name.
4030 Directory to save to is default to `gnus-article-save-directory'."
4031 (setq filename (gnus-read-save-file-name
4032 "Save %s in Unix mail file" filename
4033 gnus-mail-save-name gnus-newsgroup-name
4034 gnus-current-headers 'gnus-newsgroup-last-mail))
4035 (with-current-buffer gnus-save-article-buffer
4039 (if (and (file-readable-p filename)
4040 (file-regular-p filename)
4041 (mail-file-babyl-p filename))
4042 (gnus-output-to-rmail filename)
4043 (gnus-output-to-mail filename)))))
4046 (put 'gnus-summary-save-in-file :decode t)
4047 (put 'gnus-summary-save-in-file :headers 'gnus-saved-headers)
4048 (defun gnus-summary-save-in-file (&optional filename overwrite)
4049 "Append this article to file.
4050 Optional argument FILENAME specifies file name.
4051 Directory to save to is default to `gnus-article-save-directory'."
4052 (setq filename (gnus-read-save-file-name
4053 "Save %s in file" filename
4054 gnus-file-save-name gnus-newsgroup-name
4055 gnus-current-headers 'gnus-newsgroup-last-file))
4056 (with-current-buffer gnus-save-article-buffer
4060 (when (and overwrite
4061 (file-exists-p filename))
4062 (delete-file filename))
4063 (gnus-output-to-file filename))))
4066 (put 'gnus-summary-write-to-file :decode t)
4067 (put 'gnus-summary-write-to-file :function 'gnus-summary-save-in-file)
4068 (put 'gnus-summary-write-to-file :headers 'gnus-saved-headers)
4069 (defun gnus-summary-write-to-file (&optional filename)
4070 "Write this article to a file, overwriting it if the file exists.
4071 Optional argument FILENAME specifies file name.
4072 The directory to save in defaults to `gnus-article-save-directory'."
4073 (setq filename (gnus-read-save-file-name
4074 "Save %s in file" filename
4075 gnus-file-save-name gnus-newsgroup-name
4076 gnus-current-headers nil 'gnus-newsgroup-last-directory))
4077 (gnus-summary-save-in-file filename t))
4079 (put 'gnus-summary-save-body-in-file :decode t)
4080 (defun gnus-summary-save-body-in-file (&optional filename overwrite)
4081 "Append this article body to a file.
4082 Optional argument FILENAME specifies file name.
4083 The directory to save in defaults to `gnus-article-save-directory'."
4084 (setq filename (gnus-read-save-file-name
4085 "Save %s body in file" filename
4086 gnus-file-save-name gnus-newsgroup-name
4087 gnus-current-headers 'gnus-newsgroup-last-file))
4088 (with-current-buffer gnus-save-article-buffer
4092 (when (article-goto-body)
4093 (narrow-to-region (point) (point-max)))
4094 (when (and overwrite
4095 (file-exists-p filename))
4096 (delete-file filename))
4097 (gnus-output-to-file filename))))
4100 (put 'gnus-summary-write-body-to-file :decode t)
4101 (put 'gnus-summary-write-body-to-file
4102 :function 'gnus-summary-save-body-in-file)
4103 (defun gnus-summary-write-body-to-file (&optional filename)
4104 "Write this article body to a file, overwriting it if the file exists.
4105 Optional argument FILENAME specifies file name.
4106 The directory to save in defaults to `gnus-article-save-directory'."
4107 (setq filename (gnus-read-save-file-name
4108 "Save %s body in file" filename
4109 gnus-file-save-name gnus-newsgroup-name
4110 gnus-current-headers nil 'gnus-newsgroup-last-directory))
4111 (gnus-summary-save-body-in-file filename t))
4113 (put 'gnus-summary-save-in-pipe :decode t)
4114 (put 'gnus-summary-save-in-pipe :headers 'gnus-saved-headers)
4115 (defun gnus-summary-save-in-pipe (&optional command raw)
4116 "Pipe this article to subprocess COMMAND.
4117 Valid values for COMMAND include:
4119 The executable command name and possibly arguments.
4121 You will be prompted for the command in the minibuffer.
4122 the symbol `default'
4123 It will be replaced with the command which the variable
4124 `gnus-summary-pipe-output-default-command' holds or the command
4125 last used for saving.
4126 Non-nil value for RAW overrides `:decode' and `:headers' properties
4127 and the raw article including all headers will be piped."
4128 (let ((article (gnus-summary-article-number))
4130 (get 'gnus-summary-save-in-pipe :decode)))
4131 save-buffer default)
4133 (if (vectorp (gnus-summary-article-header article))
4134 (save-current-buffer
4135 (gnus-summary-select-article decode decode nil article)
4136 (insert-buffer-substring
4140 gnus-original-article-buffer)
4142 (nnheader-set-temp-buffer " *Gnus Save*"))))
4143 ;; Remove unwanted headers.
4144 (when (and (not raw)
4145 (or (get 'gnus-summary-save-in-pipe :headers)
4146 (not gnus-save-all-headers)))
4147 (let ((gnus-visible-headers
4148 (or (symbol-value (get 'gnus-summary-save-in-pipe
4150 gnus-saved-headers gnus-visible-headers))
4151 (gnus-summary-buffer nil))
4152 (article-hide-headers 1 t))))
4153 (error "%d is not a real article" article))
4154 (error "No article to pipe"))
4155 (setq default (or gnus-summary-pipe-output-default-command
4156 gnus-last-shell-command))
4157 (unless (stringp command)
4159 (if (and (eq command 'default) default)
4161 (gnus-read-shell-command "Shell command on this article: "
4163 (when (string-equal command "")
4165 (setq command default)
4166 (error "A command is required")))
4167 (with-current-buffer save-buffer
4170 (shell-command-on-region (point-min) (point-max) command nil)))
4171 (gnus-kill-buffer save-buffer))