1 ;;; gnus-art.el --- article mode commands for Gnus
3 ;; Copyright (C) 1996-2011 Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
27 ;; For Emacs <22.2 and XEmacs.
29 (unless (fboundp 'declare-function) (defmacro declare-function (&rest r))))
33 (defvar w3m-minor-mode-map)
48 (autoload 'gnus-msg-mail "gnus-msg" nil t)
49 (autoload 'gnus-button-mailto "gnus-msg")
50 (autoload 'gnus-button-reply "gnus-msg" nil t)
51 (autoload 'parse-time-string "parse-time" nil nil)
52 (autoload 'ansi-color-apply-on-region "ansi-color")
53 (autoload 'mm-url-insert-file-contents-external "mm-url")
54 (autoload 'mm-extern-cache-contents "mm-extern")
56 (defgroup gnus-article nil
58 :link '(custom-manual "(gnus)Article Buffer")
61 (defgroup gnus-article-treat nil
62 "Treating article parts."
63 :link '(custom-manual "(gnus)Article Hiding")
66 (defgroup gnus-article-hiding nil
67 "Hiding article parts."
68 :link '(custom-manual "(gnus)Article Hiding")
71 (defgroup gnus-article-highlight nil
72 "Article highlighting."
73 :link '(custom-manual "(gnus)Article Highlighting")
77 (defgroup gnus-article-signature nil
79 :link '(custom-manual "(gnus)Article Signature")
82 (defgroup gnus-article-headers nil
84 :link '(custom-manual "(gnus)Hiding Headers")
87 (defgroup gnus-article-washing nil
88 "Special commands on articles."
89 :link '(custom-manual "(gnus)Article Washing")
92 (defgroup gnus-article-emphasis nil
93 "Fontisizing articles."
94 :link '(custom-manual "(gnus)Article Fontisizing")
97 (defgroup gnus-article-saving nil
99 :link '(custom-manual "(gnus)Saving Articles")
100 :group 'gnus-article)
102 (defgroup gnus-article-mime nil
103 "Worshiping the MIME wonder."
104 :link '(custom-manual "(gnus)Using MIME")
105 :group 'gnus-article)
107 (defgroup gnus-article-buttons nil
108 "Pushable buttons in the article buffer."
109 :link '(custom-manual "(gnus)Article Buttons")
110 :group 'gnus-article)
112 (defgroup gnus-article-various nil
113 "Other article options."
114 :link '(custom-manual "(gnus)Misc Article")
115 :group 'gnus-article)
117 (defcustom gnus-ignored-headers
120 (concat "^" header ":"))
121 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
122 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
123 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
124 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
125 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
126 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
127 "X-Attribution" "X-Originating-IP" "Delivered-To"
128 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
129 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
130 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
131 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
132 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
133 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
134 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
135 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
136 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
137 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
138 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
139 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
140 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
141 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
142 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
143 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
144 "List-[A-Za-z]+" "X-Listprocessor-Version"
145 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
146 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
147 "X-Received" "Content-length" "X-precedence"
148 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
149 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
150 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
151 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
152 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
153 "X-Content-length" "X-Posting-Agent" "Original-Received"
154 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
155 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
156 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
157 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
158 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"
159 "Envelope-To" "X-Spam-Score" "System-Type" "X-Injected-Via-Gmane"
160 "X-Gmane-NNTP-Posting-Host" "Jabber-ID" "Archived-At"
161 "Envelope-Sender" "Envelope-Recipients"))
162 "*All headers that start with this regexp will be hidden.
163 This variable can also be a list of regexps of headers to be ignored.
164 If `gnus-visible-headers' is non-nil, this variable will be ignored."
165 :type '(choice :custom-show nil
168 :group 'gnus-article-hiding)
170 (defcustom gnus-visible-headers
171 "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^[BGF]?Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Mail-Followup-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:\\|^X-Sent:"
172 "*All headers that do not match this regexp will be hidden.
173 This variable can also be a list of regexp of headers to remain visible.
174 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
176 (repeat :value-to-internal (lambda (widget value)
177 (custom-split-regexp-maybe value))
178 :match (lambda (widget value)
180 (widget-editable-list-match widget value)))
182 (const :tag "Use gnus-ignored-headers" nil)
184 :group 'gnus-article-hiding)
186 (defcustom gnus-sorted-header-list
187 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
188 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
189 "*This variable is a list of regular expressions.
190 If it is non-nil, headers that match the regular expressions will
191 be placed first in the article buffer in the sequence specified by
193 :type '(repeat regexp)
194 :group 'gnus-article-hiding)
196 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
197 "Headers that are only to be displayed if they have interesting data.
198 Possible values in this list are:
200 'empty Headers with no content.
201 'newsgroups Newsgroup identical to Gnus group.
202 'to-address To identical to To-address.
203 'to-list To identical to To-list.
204 'cc-list CC identical to To-list.
205 'followup-to Followup-to identical to Newsgroups.
206 'reply-to Reply-to identical to From.
207 'date Date less than four days old.
208 'long-to To and/or Cc longer than 1024 characters.
209 'many-to Multiple To and/or Cc."
210 :type '(set (const :tag "Headers with no content." empty)
211 (const :tag "Newsgroups identical to Gnus group." newsgroups)
212 (const :tag "To identical to To-address." to-address)
213 (const :tag "To identical to To-list." to-list)
214 (const :tag "CC identical to To-list." cc-list)
215 (const :tag "Followup-to identical to Newsgroups." followup-to)
216 (const :tag "Reply-to identical to From." reply-to)
217 (const :tag "Date less than four days old." date)
218 (const :tag "To and/or Cc longer than 1024 characters." long-to)
219 (const :tag "Multiple To and/or Cc headers." many-to))
220 :group 'gnus-article-hiding)
222 (defcustom gnus-article-skip-boring nil
223 "Skip over text that is not worth reading.
224 By default, if you set this t, then Gnus will display citations and
225 signatures, but will never scroll down to show you a page consisting
226 only of boring text. Boring text is controlled by
227 `gnus-article-boring-faces'."
230 :group 'gnus-article-hiding)
232 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
233 "Regexp matching signature separator.
234 This can also be a list of regexps. In that case, it will be checked
235 from head to tail looking for a separator. Searches will be done from
236 the end of the buffer."
237 :type '(choice :format "%{%t%}: %[Value Menu%]\n%v"
239 (repeat :tag "List of regexp" regexp))
240 :group 'gnus-article-signature)
242 (defcustom gnus-signature-limit nil
243 "Provide a limit to what is considered a signature.
244 If it is a number, no signature may not be longer (in characters) than
245 that number. If it is a floating point number, no signature may be
246 longer (in lines) than that number. If it is a function, the function
247 will be called without any parameters, and if it returns nil, there is
248 no signature in the buffer. If it is a string, it will be used as a
249 regexp. If it matches, the text in question is not a signature.
251 This can also be a list of the above values."
252 :type '(choice (const nil)
256 (regexp :value ".*"))
257 :group 'gnus-article-signature)
259 (defcustom gnus-hidden-properties '(invisible t intangible t)
260 "Property list to use for hiding text."
262 :group 'gnus-article-hiding)
264 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
265 ;; frames in a session.
266 (defcustom gnus-article-x-face-command
267 (if (featurep 'xemacs)
268 (if (or (gnus-image-type-available-p 'xface)
269 (gnus-image-type-available-p 'pbm))
270 'gnus-display-x-face-in-from
271 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
272 (if (gnus-image-type-available-p 'pbm)
273 'gnus-display-x-face-in-from
274 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
276 "*String or function to be executed to display an X-Face header.
277 If it is a string, the command will be executed in a sub-shell
278 asynchronously. The compressed face will be piped to this command."
279 :type `(choice string
280 (function-item gnus-display-x-face-in-from)
284 :group 'gnus-article-washing)
286 (defcustom gnus-article-x-face-too-ugly nil
287 "Regexp matching posters whose face shouldn't be shown automatically."
288 :type '(choice regexp (const nil))
289 :group 'gnus-article-washing)
291 (defcustom gnus-article-banner-alist nil
292 "Banner alist for stripping.
294 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
296 :type '(repeat (cons symbol regexp))
297 :group 'gnus-article-washing)
299 (gnus-define-group-parameter
302 "Alist of regexps (to match group names) and banner."
303 :variable-group gnus-article-washing
305 '(choice :tag "Banner"
307 (const :tag "Remove signature" signature)
308 (symbol :tag "Item in `gnus-article-banner-alist'" none)
310 (const :tag "None" nil))
312 "If non-nil, specify how to remove `banners' from articles.
314 Symbol `signature' means to remove signatures delimited by
315 `gnus-signature-separator'. Any other symbol is used to look up a
316 regular expression to match the banner in `gnus-article-banner-alist'.
317 A string is used as a regular expression to match the banner
320 (defcustom gnus-article-address-banner-alist nil
321 "Alist of mail addresses and banners.
322 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
323 to match a mail address in the From: header, BANNER is one of a symbol
324 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
325 If ADDRESS matches author's mail address, it will remove things like
326 advertisements. For example:
328 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
332 (regexp :tag "Address")
333 (choice :tag "Banner" :value nil
334 (const :tag "Remove signature" signature)
335 (symbol :tag "Item in `gnus-article-banner-alist'" none)
337 (const :tag "None" nil))))
339 :group 'gnus-article-washing)
341 (defmacro gnus-emphasis-custom-with-format (&rest body)
343 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
344 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
347 (defun gnus-emphasis-custom-value-to-external (value)
348 (gnus-emphasis-custom-with-format
349 (if (consp (car value))
350 (list (format format (car (car value)) (cdr (car value)))
352 (if (nth 1 value) 2 3)
356 (defun gnus-emphasis-custom-value-to-internal (value)
357 (gnus-emphasis-custom-with-format
358 (let ((regexp (concat "\\`"
359 (format (regexp-quote format)
360 "\\([^()]+\\)" "\\([^()]+\\)")
363 (if (string-match regexp (setq pattern (car value)))
364 (list (cons (match-string 1 pattern) (match-string 2 pattern))
369 (defcustom gnus-emphasis-alist
371 '(("\\*" "\\*" bold nil 2)
374 ("_/" "/_" underline-italic)
375 ("_\\*" "\\*_" underline-bold)
376 ("\\*/" "/\\*" bold-italic)
377 ("_\\*/" "/\\*_" underline-bold-italic))))
379 (gnus-emphasis-custom-with-format
380 (mapcar (lambda (spec)
381 (list (format format (car spec) (cadr spec))
384 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
386 '(;; I've never seen anyone use this strikethru convention whereas I've
387 ;; several times seen it triggered by normal text. --Stef
388 ;; Miles suggests that this form is sometimes used but for italics,
389 ;; so maybe we should map it to `italic'.
390 ;; ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
391 ;; 2 3 gnus-emphasis-strikethru)
392 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
393 2 3 gnus-emphasis-underline))))
394 "*Alist that says how to fontify certain phrases.
395 Each item looks like this:
397 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
399 The first element is a regular expression to be matched. The second
400 is a number that says what regular expression grouping used to find
401 the entire emphasized word. The third is a number that says what
402 regexp grouping should be displayed and highlighted. The fourth
403 is the face used for highlighting."
407 :format "%[Customizing Style%]\n%v"
409 (group :tag "Default"
410 :value ("" 0 0 default)
413 (let ((value (widget-get
414 (cadr (widget-get (widget-get widget :parent)
417 (if (not (eq (nth 2 value) 'default))
421 (gnus-emphasis-custom-value-to-external value))))
422 (widget-group-value-create widget))
424 (integer :format "Match group: %v")
425 (integer :format "Emphasize group: %v")
428 :value (("_" . "_") nil default)
430 (regexp :format "Start regexp: %v")
431 (regexp :format "End regexp: %v"))
432 (boolean :format "Show start and end patterns: %[%v%]\n"
433 :on " On " :off " Off ")
435 :get (lambda (symbol)
436 (mapcar 'gnus-emphasis-custom-value-to-internal
437 (default-value symbol)))
438 :set (lambda (symbol value)
439 (set-default symbol (mapcar 'gnus-emphasis-custom-value-to-external
441 :group 'gnus-article-emphasis)
443 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
444 "A regexp to describe whitespace which should not be emphasized.
445 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
446 The former avoids underlining of leading and trailing whitespace,
447 and the latter avoids underlining any whitespace at all."
449 :group 'gnus-article-emphasis
452 (defface gnus-emphasis-bold '((t (:bold t)))
453 "Face used for displaying strong emphasized text (*word*)."
454 :group 'gnus-article-emphasis)
456 (defface gnus-emphasis-italic '((t (:italic t)))
457 "Face used for displaying italic emphasized text (/word/)."
458 :group 'gnus-article-emphasis)
460 (defface gnus-emphasis-underline '((t (:underline t)))
461 "Face used for displaying underlined emphasized text (_word_)."
462 :group 'gnus-article-emphasis)
464 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
465 "Face used for displaying underlined bold emphasized text (_*word*_)."
466 :group 'gnus-article-emphasis)
468 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
469 "Face used for displaying underlined italic emphasized text (_/word/_)."
470 :group 'gnus-article-emphasis)
472 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
473 "Face used for displaying bold italic emphasized text (/*word*/)."
474 :group 'gnus-article-emphasis)
476 (defface gnus-emphasis-underline-bold-italic
477 '((t (:bold t :italic t :underline t)))
478 "Face used for displaying underlined bold italic emphasized text.
479 Example: (_/*word*/_)."
480 :group 'gnus-article-emphasis)
482 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
483 '((t (:strikethru t)))
484 '((t (:strike-through t))))
485 "Face used for displaying strike-through text (-word-)."
486 :group 'gnus-article-emphasis)
488 (defface gnus-emphasis-highlight-words
489 '((t (:background "black" :foreground "yellow")))
490 "Face used for displaying highlighted words."
491 :group 'gnus-article-emphasis)
493 (defcustom gnus-article-time-format "%a, %d %b %Y %T %Z"
494 "Format for display of Date headers in article bodies.
495 See `format-time-string' for the possible values.
497 The variable can also be function, which should return a complete Date
498 header. The function is called with one argument, the time, which can
499 be fed to `format-time-string'."
500 :type '(choice string function)
501 :link '(custom-manual "(gnus)Article Date")
502 :group 'gnus-article-washing)
504 (defcustom gnus-save-all-headers t
505 "*If non-nil, don't remove any headers before saving.
506 This will be overridden by the `:headers' property that the symbol of
507 the saver function, which is specified by `gnus-default-article-saver',
509 :group 'gnus-article-saving
512 (defcustom gnus-prompt-before-saving 'always
513 "*This variable says how much prompting is to be done when saving articles.
514 If it is nil, no prompting will be done, and the articles will be
515 saved to the default files. If this variable is `always', each and
516 every article that is saved will be preceded by a prompt, even when
517 saving large batches of articles. If this variable is neither nil not
518 `always', there the user will be prompted once for a file name for
519 each invocation of the saving commands."
520 :group 'gnus-article-saving
521 :type '(choice (item always)
522 (item :tag "never" nil)
523 (sexp :tag "once" :format "%t\n" :value t)))
525 (defcustom gnus-saved-headers gnus-visible-headers
526 "Headers to keep if `gnus-save-all-headers' is nil.
527 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
528 If that variable is nil, however, all headers that match this regexp
529 will be kept while the rest will be deleted before saving. This and
530 `gnus-save-all-headers' will be overridden by the `:headers' property
531 that the symbol of the saver function, which is specified by
532 `gnus-default-article-saver', might have."
533 :group 'gnus-article-saving
536 ;; Note that "Rmail format" is mbox since Emacs 23, but Babyl before.
537 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
538 "A function to save articles in your favourite format.
539 The function will be called by way of the `gnus-summary-save-article'
540 command, and friends such as `gnus-summary-save-article-rmail'.
542 Gnus provides the following functions:
544 * gnus-summary-save-in-rmail (Rmail format)
545 * gnus-summary-save-in-mail (Unix mail format)
546 * gnus-summary-save-in-folder (MH folder)
547 * gnus-summary-save-in-file (article format)
548 * gnus-summary-save-body-in-file (article body)
549 * gnus-summary-save-in-vm (use VM's folder format)
550 * gnus-summary-write-to-file (article format -- overwrite)
551 * gnus-summary-write-body-to-file (article body -- overwrite)
552 * gnus-summary-save-in-pipe (article format)
554 The symbol of each function may have the following properties:
557 The value non-nil means save decoded articles. This is meaningful
558 only with `gnus-summary-save-in-file', `gnus-summary-save-body-in-file',
559 `gnus-summary-write-to-file', `gnus-summary-write-body-to-file', and
560 `gnus-summary-save-in-pipe'.
563 The value specifies an alternative function which appends, not
564 overwrites, articles to a file. This implies that when saving many
565 articles at a time, `gnus-prompt-before-saving' is bound to t and all
566 articles are saved in a single file. This is meaningful only with
567 `gnus-summary-write-to-file' and `gnus-summary-write-body-to-file'.
570 The value specifies the symbol of a variable of which the value
571 specifies headers to be saved. If it is omitted,
572 `gnus-save-all-headers' and `gnus-saved-headers' control what
573 headers should be saved."
574 :group 'gnus-article-saving
575 :type '(radio (function-item gnus-summary-save-in-rmail)
576 (function-item gnus-summary-save-in-mail)
577 (function-item gnus-summary-save-in-folder)
578 (function-item gnus-summary-save-in-file)
579 (function-item gnus-summary-save-body-in-file)
580 (function-item gnus-summary-save-in-vm)
581 (function-item gnus-summary-write-to-file)
582 (function-item gnus-summary-write-body-to-file)
583 (function-item gnus-summary-save-in-pipe)
586 (defcustom gnus-article-save-coding-system
587 (or (and (mm-coding-system-p 'utf-8) 'utf-8)
588 (and (mm-coding-system-p 'iso-2022-7bit) 'iso-2022-7bit)
589 (and (mm-coding-system-p 'emacs-mule) 'emacs-mule)
590 (and (mm-coding-system-p 'escape-quoted) 'escape-quoted))
591 "Coding system used to save decoded articles to a file.
593 The recommended coding systems are `utf-8', `iso-2022-7bit' and so on,
594 which can safely encode any characters in text. This is used by the
597 * gnus-summary-save-article-file
598 * gnus-summary-save-article-body-file
599 * gnus-summary-write-article-file
600 * gnus-summary-write-article-body-file
602 and the functions to which you may set `gnus-default-article-saver':
604 * gnus-summary-save-in-file
605 * gnus-summary-save-body-in-file
606 * gnus-summary-write-to-file
607 * gnus-summary-write-body-to-file
609 Those commands and functions save just text displayed in the article
610 buffer to a file if the value of this variable is non-nil. Note that
611 buttonized MIME parts will be lost in a saved file in that case.
612 Otherwise, raw articles will be saved."
613 :group 'gnus-article-saving
615 :format "%{%t%}:\n %[Value Menu%] %v"
616 (const :tag "Save raw articles" nil)
619 (lambda (arg) (if (mm-coding-system-p (nth 3 arg)) arg))
620 '((const :tag "UTF-8" utf-8)
621 (const :tag "iso-2022-7bit" iso-2022-7bit)
622 (const :tag "Emacs internal" emacs-mule)
623 (const :tag "escape-quoted" escape-quoted))))
624 (symbol :tag "Coding system")))
626 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
627 "A function generating a file name to save articles in Rmail format.
628 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
629 :group 'gnus-article-saving
632 (defcustom gnus-mail-save-name 'gnus-plain-save-name
633 "A function generating a file name to save articles in Unix mail format.
634 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
635 :group 'gnus-article-saving
638 (defcustom gnus-folder-save-name 'gnus-folder-save-name
639 "A function generating a file name to save articles in MH folder.
640 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
641 :group 'gnus-article-saving
644 (defcustom gnus-file-save-name 'gnus-numeric-save-name
645 "A function generating a file name to save articles in article format.
646 The function is called with NEWSGROUP, HEADERS, and optional
648 :group 'gnus-article-saving
651 (defcustom gnus-split-methods
652 '((gnus-article-archive-name)
653 (gnus-article-nndoc-name))
654 "*Variable used to suggest where articles are to be saved.
655 For instance, if you would like to save articles related to Gnus in
656 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
657 you could set this variable to something like:
659 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
660 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
662 This variable is an alist where the key is the match and the
663 value is a list of possible files to save in if the match is
666 If the match is a string, it is used as a regexp match on the
667 article. If the match is a symbol, that symbol will be funcalled
668 from the buffer of the article to be saved with the newsgroup as the
669 parameter. If it is a list, it will be evaled in the same buffer.
671 If this form or function returns a string, this string will be used as a
672 possible file name; and if it returns a non-nil list, that list will be
673 used as possible file names."
674 :group 'gnus-article-saving
675 :type '(repeat (choice (list :value (fun) function)
676 (cons :value ("" "") regexp (repeat string))
679 (defcustom gnus-page-delimiter "^\^L"
680 "*Regexp describing what to use as article page delimiters.
681 The default value is \"^\^L\", which is a form linefeed at the
682 beginning of a line."
684 :group 'gnus-article-various)
686 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
687 "*The format specification for the article mode line.
688 See `gnus-summary-mode-line-format' for a closer description.
690 The following additional specs are available:
692 %w The article washing status.
693 %m The number of MIME parts in the article."
695 :group 'gnus-article-various)
697 (defcustom gnus-article-mode-hook nil
698 "*A hook for Gnus article mode."
700 :group 'gnus-article-various)
702 (when (featurep 'xemacs)
703 ;; Extracted from gnus-xmas-define in order to preserve user settings
704 (when (fboundp 'turn-off-scroll-in-place)
705 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
706 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
707 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
709 (defcustom gnus-article-menu-hook nil
710 "*Hook run after the creation of the article mode menu."
712 :group 'gnus-article-various)
714 (defcustom gnus-article-prepare-hook nil
715 "*A hook called after an article has been prepared in the article buffer."
717 :group 'gnus-article-various)
719 (defcustom gnus-copy-article-ignored-headers nil
720 "List of headers to be removed when copying an article.
721 Each element is a regular expression."
722 :version "23.1" ;; No Gnus
723 :type '(repeat regexp)
724 :group 'gnus-article-various)
726 (make-obsolete-variable 'gnus-article-hide-pgp-hook nil
727 "Gnus 5.10 (Emacs 22.1)")
730 '((t (:weight bold)))
731 "Face used for highlighting a button in the article buffer."
732 :group 'gnus-article-buttons)
734 (defcustom gnus-article-button-face 'gnus-button
735 "Face used for highlighting buttons in the article buffer.
737 An article button is a piece of text that you can activate by pressing
738 `RET' or `mouse-2' above it."
740 :group 'gnus-article-buttons)
742 (defcustom gnus-article-mouse-face 'highlight
743 "Face used for mouse highlighting in the article buffer.
745 Article buttons will be displayed in this face when the cursor is
748 :group 'gnus-article-buttons)
750 (defcustom gnus-signature-face 'gnus-signature
751 "Face used for highlighting a signature in the article buffer.
752 Obsolete; use the face `gnus-signature' for customizations instead."
754 :group 'gnus-article-highlight
755 :group 'gnus-article-signature)
757 (defface gnus-signature
760 "Face used for highlighting a signature in the article buffer."
761 :group 'gnus-article-highlight
762 :group 'gnus-article-signature)
763 ;; backward-compatibility alias
764 (put 'gnus-signature-face 'face-alias 'gnus-signature)
765 (put 'gnus-signature-face 'obsolete-face "22.1")
767 (defface gnus-header-from
770 (:foreground "PaleGreen1"))
773 (:foreground "red3"))
776 "Face used for displaying from headers."
777 :group 'gnus-article-headers
778 :group 'gnus-article-highlight)
779 ;; backward-compatibility alias
780 (put 'gnus-header-from-face 'face-alias 'gnus-header-from)
781 (put 'gnus-header-from-face 'obsolete-face "22.1")
783 (defface gnus-header-subject
786 (:foreground "SeaGreen1"))
789 (:foreground "red4"))
791 (:bold t :italic t)))
792 "Face used for displaying subject headers."
793 :group 'gnus-article-headers
794 :group 'gnus-article-highlight)
795 ;; backward-compatibility alias
796 (put 'gnus-header-subject-face 'face-alias 'gnus-header-subject)
797 (put 'gnus-header-subject-face 'obsolete-face "22.1")
799 (defface gnus-header-newsgroups
802 (:foreground "yellow" :italic t))
805 (:foreground "MidnightBlue" :italic t))
808 "Face used for displaying newsgroups headers.
809 In the default setup this face is only used for crossposted
811 :group 'gnus-article-headers
812 :group 'gnus-article-highlight)
813 ;; backward-compatibility alias
814 (put 'gnus-header-newsgroups-face 'face-alias 'gnus-header-newsgroups)
815 (put 'gnus-header-newsgroups-face 'obsolete-face "22.1")
817 (defface gnus-header-name
820 (:foreground "SpringGreen2"))
823 (:foreground "maroon"))
826 "Face used for displaying header names."
827 :group 'gnus-article-headers
828 :group 'gnus-article-highlight)
829 ;; backward-compatibility alias
830 (put 'gnus-header-name-face 'face-alias 'gnus-header-name)
831 (put 'gnus-header-name-face 'obsolete-face "22.1")
833 (defface gnus-header-content
836 (:foreground "SpringGreen1" :italic t))
839 (:foreground "indianred4" :italic t))
841 (:italic t))) "Face used for displaying header content."
842 :group 'gnus-article-headers
843 :group 'gnus-article-highlight)
844 ;; backward-compatibility alias
845 (put 'gnus-header-content-face 'face-alias 'gnus-header-content)
846 (put 'gnus-header-content-face 'obsolete-face "22.1")
848 (defcustom gnus-header-face-alist
849 '(("From" nil gnus-header-from)
850 ("Subject" nil gnus-header-subject)
851 ("Newsgroups:.*," nil gnus-header-newsgroups)
852 ("" gnus-header-name gnus-header-content))
853 "*Controls highlighting of article headers.
855 An alist of the form (HEADER NAME CONTENT).
857 HEADER is a regular expression which should match the name of a
858 header and NAME and CONTENT are either face names or nil.
860 The name of each header field will be displayed using the face
861 specified by the first element in the list where HEADER matches
862 the header name and NAME is non-nil. Similarly, the content will
863 be displayed by the first non-nil matching CONTENT face."
864 :group 'gnus-article-headers
865 :group 'gnus-article-highlight
866 :type '(repeat (list (regexp :tag "Header")
868 (item :tag "skip" nil)
869 (face :value default))
870 (choice :tag "Content"
871 (item :tag "skip" nil)
872 (face :value default)))))
874 (defcustom gnus-face-properties-alist (if (featurep 'xemacs)
875 '((xface . (:face gnus-x-face)))
876 '((pbm . (:face gnus-x-face))
878 "Alist of image types and properties applied to Face and X-Face images.
881 ;; Specify the altitude of Face images in the From header.
882 \(setq gnus-face-properties-alist
883 '((pbm . (:face gnus-x-face :ascent 80))
884 (png . (:ascent 80))))
886 ;; Show Face images as pressed buttons.
887 \(setq gnus-face-properties-alist
888 '((pbm . (:face gnus-x-face :relief -2))
889 (png . (:relief -2))))
891 See the manual for the valid properties for various image types.
892 Currently, `pbm' is used for X-Face images and `png' is used for Face
893 images in Emacs. Only the `:face' property is effective on the `xface'
894 image type in XEmacs if it is built with the libcompface library."
895 :version "23.1" ;; No Gnus
896 :group 'gnus-article-headers
897 :type '(repeat (cons :format "%v" (symbol :tag "Image type") plist)))
899 (defcustom gnus-article-decode-hook
900 '(article-decode-charset article-decode-encoded-words
901 article-decode-group-name article-decode-idna-rhs)
902 "*Hook run to decode charsets in articles."
903 :group 'gnus-article-headers
906 (defcustom gnus-display-mime-function 'gnus-display-mime
907 "Function to display MIME articles."
908 :group 'gnus-article-mime
911 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
912 "Function used to decode headers.")
914 (defvar gnus-decode-address-function 'mail-decode-encoded-address-region
915 "Function used to decode addresses.")
917 (defvar gnus-article-dumbquotes-map
937 "Table for MS-to-Latin1 translation.")
939 (defcustom gnus-ignored-mime-types nil
940 "List of MIME types that should be ignored by Gnus."
942 :group 'gnus-article-mime
943 :type '(repeat regexp))
945 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
946 "List of MIME types that should not be given buttons when rendered inline.
947 See also `gnus-buttonized-mime-types' which may override this variable.
948 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
950 :group 'gnus-article-mime
951 :type '(repeat regexp))
953 (defcustom gnus-buttonized-mime-types nil
954 "List of MIME types that should be given buttons when rendered inline.
955 If set, this variable overrides `gnus-unbuttonized-mime-types'.
956 To see e.g. security buttons you could set this to
957 `(\"multipart/signed\")'. You could also add \"multipart/alternative\" to
958 this list to display radio buttons that allow you to choose one of two
959 media types those mails include. See also `mm-discouraged-alternatives'.
960 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
962 :group 'gnus-article-mime
963 :type '(repeat regexp))
965 (defcustom gnus-inhibit-mime-unbuttonizing nil
966 "If non-nil, all MIME parts get buttons.
967 When nil (the default value), then some MIME parts do not get buttons,
968 as described by the variables `gnus-buttonized-mime-types' and
969 `gnus-unbuttonized-mime-types'."
971 :group 'gnus-article-mime
974 (defcustom gnus-body-boundary-delimiter "_"
975 "String used to delimit header and body.
976 This variable is used by `gnus-article-treat-body-boundary' which can
977 be controlled by `gnus-treat-body-boundary'."
979 :group 'gnus-article-various
980 :type '(choice (item :tag "None" :value nil)
983 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
985 "Defines the location of the faces database.
986 For information on obtaining this database of pretty pictures, please
987 see http://www.cs.indiana.edu/picons/ftp/index.html"
989 :type '(repeat directory)
990 :link '(url-link :tag "download"
991 "http://www.cs.indiana.edu/picons/ftp/index.html")
992 :link '(custom-manual "(gnus)Picons")
995 (defun gnus-picons-installed-p ()
996 "Say whether picons are installed on your machine."
997 (let ((installed nil))
998 (dolist (database gnus-picon-databases)
999 (when (file-exists-p database)
1000 (setq installed t)))
1003 (defcustom gnus-article-mime-part-function nil
1004 "Function called with a MIME handle as the argument.
1005 This is meant for people who want to do something automatic based
1006 on parts -- for instance, adding Vcard info to a database."
1007 :group 'gnus-article-mime
1008 :type '(choice (const nil)
1011 (defcustom gnus-mime-multipart-functions nil
1012 "An alist of MIME types to functions to display them."
1014 :group 'gnus-article-mime
1015 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
1017 (defcustom gnus-article-date-lapsed-new-header nil
1018 "Whether the X-Sent and Date headers can coexist.
1019 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
1020 either replace the old \"Date:\" header (if this variable is nil), or
1021 be added below it (otherwise)."
1023 :group 'gnus-article-headers
1026 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
1027 "Function called with a MIME handle as the argument.
1028 This is meant for people who want to view first matched part.
1029 For `undisplayed-alternative' (default), the first undisplayed
1030 part or alternative part is used. For `undisplayed', the first
1031 undisplayed part is used. For a function, the first part which
1032 the function return t is used. For nil, the first part is
1035 :group 'gnus-article-mime
1037 (item :tag "first" :value nil)
1038 (item :tag "undisplayed" :value undisplayed)
1039 (item :tag "undisplayed or alternative"
1040 :value undisplayed-alternative)
1043 (defcustom gnus-mime-action-alist
1044 '(("save to file" . gnus-mime-save-part)
1045 ("save and strip" . gnus-mime-save-part-and-strip)
1046 ("replace with file" . gnus-mime-replace-part)
1047 ("delete part" . gnus-mime-delete-part)
1048 ("display as text" . gnus-mime-inline-part)
1049 ("view the part" . gnus-mime-view-part)
1050 ("pipe to command" . gnus-mime-pipe-part)
1051 ("toggle display" . gnus-article-press-button)
1052 ("toggle display" . gnus-article-view-part-as-charset)
1053 ("view as type" . gnus-mime-view-part-as-type)
1054 ("view internally" . gnus-mime-view-part-internally)
1055 ("view externally" . gnus-mime-view-part-externally))
1056 "An alist of actions that run on the MIME attachment."
1057 :group 'gnus-article-mime
1058 :type '(repeat (cons (string :tag "name")
1061 (defcustom gnus-auto-select-part 1
1062 "Advance to next MIME part when deleting or stripping parts.
1064 When 0, point will be placed on the same part as before. When
1065 positive (negative), move point forward (backwards) this many
1066 parts. When nil, redisplay article."
1067 :version "23.1" ;; No Gnus
1068 :group 'gnus-article-mime
1069 :type '(choice (const nil :tag "Redisplay article.")
1070 (const 1 :tag "Next part.")
1071 (const 0 :tag "Current part.")
1075 ;;; The treatment variables
1078 (defvar gnus-part-display-hook nil
1079 "Hook called on parts that are to receive treatment.")
1081 (defvar gnus-article-treat-custom
1082 '(choice (const :tag "Off" nil)
1084 (const :tag "Header" head)
1085 (const :tag "First" first)
1086 (const :tag "Last" last)
1087 (integer :tag "Less")
1088 (repeat :tag "Groups" regexp)
1089 (sexp :tag "Predicate")))
1091 (defvar gnus-article-treat-head-custom
1092 '(choice (const :tag "Off" nil)
1093 (const :tag "Header" head)))
1095 (defvar gnus-article-treat-types '("text/plain" "text/x-verbatim"
1099 (defvar gnus-inhibit-treatment nil
1100 "Whether to inhibit treatment.")
1102 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
1103 "Highlight the signature.
1104 Valid values are nil, t, `head', `first', `last', an integer or a
1105 predicate. See Info node `(gnus)Customizing Articles'."
1106 :group 'gnus-article-treat
1107 :link '(custom-manual "(gnus)Customizing Articles")
1108 :type gnus-article-treat-custom)
1109 (put 'gnus-treat-highlight-signature 'highlight t)
1111 (defcustom gnus-treat-buttonize 100000
1113 Valid values are nil, t, `head', `first', `last', an integer or a
1114 predicate. See Info node `(gnus)Customizing Articles'."
1115 :group 'gnus-article-treat
1116 :link '(custom-manual "(gnus)Customizing Articles")
1117 :type gnus-article-treat-custom)
1118 (put 'gnus-treat-buttonize 'highlight t)
1120 (defcustom gnus-treat-buttonize-head 'head
1121 "Add buttons to the head.
1122 Valid values are nil, t, `head', `first', `last', an integer or a
1123 predicate. See Info node `(gnus)Customizing Articles'."
1124 :group 'gnus-article-treat
1125 :link '(custom-manual "(gnus)Customizing Articles")
1126 :type gnus-article-treat-head-custom)
1127 (put 'gnus-treat-buttonize-head 'highlight t)
1129 (defcustom gnus-treat-emphasize 50000
1131 Valid values are nil, t, `head', `first', `last', an integer or a
1132 predicate. See Info node `(gnus)Customizing Articles'."
1133 :group 'gnus-article-treat
1134 :link '(custom-manual "(gnus)Customizing Articles")
1135 :type gnus-article-treat-custom)
1136 (put 'gnus-treat-emphasize 'highlight t)
1138 (defcustom gnus-treat-strip-cr nil
1139 "Remove carriage returns.
1140 Valid values are nil, t, `head', `first', `last', an integer or a
1141 predicate. See Info node `(gnus)Customizing Articles'."
1143 :group 'gnus-article-treat
1144 :link '(custom-manual "(gnus)Customizing Articles")
1145 :type gnus-article-treat-custom)
1147 (defcustom gnus-treat-unsplit-urls nil
1148 "Remove newlines from within URLs.
1149 Valid values are nil, t, `head', `first', `last', an integer or a
1150 predicate. See Info node `(gnus)Customizing Articles'."
1152 :group 'gnus-article-treat
1153 :link '(custom-manual "(gnus)Customizing Articles")
1154 :type gnus-article-treat-custom)
1156 (defcustom gnus-treat-leading-whitespace nil
1157 "Remove leading whitespace in headers.
1158 Valid values are nil, t, `head', `first', `last', an integer or a
1159 predicate. See Info node `(gnus)Customizing Articles'."
1161 :group 'gnus-article-treat
1162 :link '(custom-manual "(gnus)Customizing Articles")
1163 :type gnus-article-treat-custom)
1165 (defcustom gnus-treat-hide-headers 'head
1167 Valid values are nil, t, `head', `first', `last', an integer or a
1168 predicate. See Info node `(gnus)Customizing Articles'."
1169 :group 'gnus-article-treat
1170 :link '(custom-manual "(gnus)Customizing Articles")
1171 :type gnus-article-treat-head-custom)
1173 (defcustom gnus-treat-hide-boring-headers nil
1174 "Hide boring headers.
1175 Valid values are nil, t, `head', `first', `last', an integer or a
1176 predicate. See Info node `(gnus)Customizing Articles'."
1177 :group 'gnus-article-treat
1178 :link '(custom-manual "(gnus)Customizing Articles")
1179 :type gnus-article-treat-head-custom)
1181 (defcustom gnus-treat-hide-signature nil
1182 "Hide the signature.
1183 Valid values are nil, t, `head', `first', `last', an integer or a
1184 predicate. See Info node `(gnus)Customizing Articles'."
1185 :group 'gnus-article-treat
1186 :link '(custom-manual "(gnus)Customizing Articles")
1187 :type gnus-article-treat-custom)
1189 (defcustom gnus-treat-fill-article nil
1191 Valid values are nil, t, `head', `first', `last', an integer or a
1192 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-hide-citation nil
1199 Valid values are nil, t, `head', `first', `last', an integer or a
1200 predicate. See Info node `(gnus)Customizing Articles'."
1201 :group 'gnus-article-treat
1202 :link '(custom-manual "(gnus)Customizing Articles")
1203 :type gnus-article-treat-custom)
1205 (defcustom gnus-treat-hide-citation-maybe nil
1207 Valid values are nil, t, `head', `first', `last', an integer or a
1208 predicate. See Info node `(gnus)Customizing Articles'."
1209 :group 'gnus-article-treat
1210 :link '(custom-manual "(gnus)Customizing Articles")
1211 :type gnus-article-treat-custom)
1213 (defcustom gnus-treat-strip-list-identifiers 'head
1214 "Strip list identifiers from `gnus-list-identifiers`.
1215 Valid values are nil, t, `head', `first', `last', an integer or a
1216 predicate. See Info node `(gnus)Customizing Articles'."
1218 :group 'gnus-article-treat
1219 :link '(custom-manual "(gnus)Customizing Articles")
1220 :type gnus-article-treat-custom)
1222 (make-obsolete-variable 'gnus-treat-strip-pgp nil
1223 "Gnus 5.10 (Emacs 22.1)")
1225 (defcustom gnus-treat-strip-pem nil
1226 "Strip PEM signatures.
1227 Valid values are nil, t, `head', `first', `last', an integer or a
1228 predicate. See Info node `(gnus)Customizing Articles'."
1229 :group 'gnus-article-treat
1230 :link '(custom-manual "(gnus)Customizing Articles")
1231 :type gnus-article-treat-custom)
1233 (defcustom gnus-treat-strip-banner t
1234 "Strip banners from articles.
1235 The banner to be stripped is specified in the `banner' group parameter.
1236 Valid values are nil, t, `head', `first', `last', an integer or a
1237 predicate. See Info node `(gnus)Customizing Articles'."
1238 :group 'gnus-article-treat
1239 :link '(custom-manual "(gnus)Customizing Articles")
1240 :type gnus-article-treat-custom)
1242 (defcustom gnus-treat-highlight-headers 'head
1243 "Highlight the headers.
1244 Valid values are nil, t, `head', `first', `last', an integer or a
1245 predicate. See Info node `(gnus)Customizing Articles'."
1246 :group 'gnus-article-treat
1247 :link '(custom-manual "(gnus)Customizing Articles")
1248 :type gnus-article-treat-head-custom)
1249 (put 'gnus-treat-highlight-headers 'highlight t)
1251 (defcustom gnus-treat-highlight-citation t
1252 "Highlight cited text.
1253 Valid values are nil, t, `head', `first', `last', an integer or a
1254 predicate. See Info node `(gnus)Customizing Articles'."
1255 :group 'gnus-article-treat
1256 :link '(custom-manual "(gnus)Customizing Articles")
1257 :type gnus-article-treat-custom)
1258 (put 'gnus-treat-highlight-citation 'highlight t)
1260 (defcustom gnus-treat-date-ut nil
1261 "Display the Date in UT (GMT).
1262 Valid values are nil, t, `head', `first', `last', an integer or a
1263 predicate. See Info node `(gnus)Customizing Articles'."
1264 :group 'gnus-article-treat
1265 :link '(custom-manual "(gnus)Customizing Articles")
1266 :type gnus-article-treat-head-custom)
1268 (defcustom gnus-treat-date-local nil
1269 "Display the Date in the local timezone.
1270 Valid values are nil, t, `head', `first', `last', an integer or a
1271 predicate. See Info node `(gnus)Customizing Articles'."
1272 :group 'gnus-article-treat
1273 :link '(custom-manual "(gnus)Customizing Articles")
1274 :type gnus-article-treat-head-custom)
1276 (defcustom gnus-treat-date-english nil
1277 "Display the Date in a format that can be read aloud in English.
1278 Valid values are nil, t, `head', `first', `last', an integer or a
1279 predicate. See Info node `(gnus)Customizing Articles'."
1281 :group 'gnus-article-treat
1282 :link '(custom-manual "(gnus)Customizing Articles")
1283 :type gnus-article-treat-head-custom)
1285 (defcustom gnus-treat-date-lapsed nil
1286 "Display the Date header in a way that says how much time has elapsed.
1287 Valid values are nil, t, `head', `first', `last', an integer or a
1288 predicate. See Info node `(gnus)Customizing Articles'."
1289 :group 'gnus-article-treat
1290 :link '(custom-manual "(gnus)Customizing Articles")
1291 :type gnus-article-treat-head-custom)
1293 (defcustom gnus-treat-date-original nil
1294 "Display the date in the original timezone.
1295 Valid values are nil, t, `head', `first', `last', an integer or a
1296 predicate. See Info node `(gnus)Customizing Articles'."
1297 :group 'gnus-article-treat
1298 :link '(custom-manual "(gnus)Customizing Articles")
1299 :type gnus-article-treat-head-custom)
1301 (defcustom gnus-treat-date-iso8601 nil
1302 "Display the date in the ISO8601 format.
1303 Valid values are nil, t, `head', `first', `last', an integer or a
1304 predicate. See Info node `(gnus)Customizing Articles'."
1306 :group 'gnus-article-treat
1307 :link '(custom-manual "(gnus)Customizing Articles")
1308 :type gnus-article-treat-head-custom)
1310 (defcustom gnus-treat-date-user-defined nil
1311 "Display the date in a user-defined format.
1312 The format is defined by the `gnus-article-time-format' variable.
1313 Valid values are nil, t, `head', `first', `last', an integer or a
1314 predicate. See Info node `(gnus)Customizing Articles'."
1315 :group 'gnus-article-treat
1316 :link '(custom-manual "(gnus)Customizing Articles")
1317 :type gnus-article-treat-head-custom)
1319 (defcustom gnus-treat-strip-headers-in-body t
1320 "Strip the X-No-Archive header line from the beginning of the body.
1321 Valid values are nil, t, `head', `first', `last', an integer or a
1322 predicate. See Info node `(gnus)Customizing Articles'."
1324 :group 'gnus-article-treat
1325 :link '(custom-manual "(gnus)Customizing Articles")
1326 :type gnus-article-treat-custom)
1328 (defcustom gnus-treat-strip-trailing-blank-lines nil
1329 "Strip trailing blank lines.
1330 Valid values are nil, t, `head', `first', `last', an integer or a
1331 predicate. See Info node `(gnus)Customizing Articles'.
1333 When set to t, it also strips trailing blanks in all MIME parts.
1334 Consider to use `last' instead."
1335 :group 'gnus-article-treat
1336 :link '(custom-manual "(gnus)Customizing Articles")
1337 :type gnus-article-treat-custom)
1339 (defcustom gnus-treat-strip-leading-blank-lines nil
1340 "Strip leading blank lines.
1341 Valid values are nil, t, `head', `first', `last', an integer or a
1342 predicate. See Info node `(gnus)Customizing Articles'.
1344 When set to t, it also strips trailing blanks in all MIME parts."
1345 :group 'gnus-article-treat
1346 :link '(custom-manual "(gnus)Customizing Articles")
1347 :type gnus-article-treat-custom)
1349 (defcustom gnus-treat-strip-multiple-blank-lines nil
1350 "Strip multiple blank lines.
1351 Valid values are nil, t, `head', `first', `last', an integer or a
1352 predicate. See Info node `(gnus)Customizing Articles'."
1353 :group 'gnus-article-treat
1354 :link '(custom-manual "(gnus)Customizing Articles")
1355 :type gnus-article-treat-custom)
1357 (defcustom gnus-treat-unfold-headers 'head
1358 "Unfold folded header lines.
1359 Valid values are nil, t, `head', `first', `last', an integer or a
1360 predicate. See Info node `(gnus)Customizing Articles'."
1362 :group 'gnus-article-treat
1363 :link '(custom-manual "(gnus)Customizing Articles")
1364 :type gnus-article-treat-custom)
1366 (defcustom gnus-article-unfold-long-headers nil
1367 "If non-nil, allow unfolding headers even if the header is long.
1368 If it is a regexp, only long headers matching this regexp are unfolded.
1369 If it is t, all long headers are unfolded.
1371 This variable has no effect if `gnus-treat-unfold-headers' is nil."
1372 :version "23.1" ;; No Gnus
1373 :group 'gnus-article-treat
1374 :type '(choice (const nil)
1375 (const :tag "all" t)
1378 (defcustom gnus-treat-fold-headers nil
1380 Valid values are nil, t, `head', `first', `last', an integer or a
1381 predicate. See Info node `(gnus)Customizing Articles'."
1383 :group 'gnus-article-treat
1384 :link '(custom-manual "(gnus)Customizing Articles")
1385 :type gnus-article-treat-custom)
1387 (defcustom gnus-treat-fold-newsgroups 'head
1388 "Fold the Newsgroups and Followup-To headers.
1389 Valid values are nil, t, `head', `first', `last', an integer or a
1390 predicate. See Info node `(gnus)Customizing Articles'."
1392 :group 'gnus-article-treat
1393 :link '(custom-manual "(gnus)Customizing Articles")
1394 :type gnus-article-treat-custom)
1396 (defcustom gnus-treat-overstrike t
1397 "Treat overstrike highlighting.
1398 Valid values are nil, t, `head', `first', `last', an integer or a
1399 predicate. See Info node `(gnus)Customizing Articles'."
1400 :group 'gnus-article-treat
1401 :link '(custom-manual "(gnus)Customizing Articles")
1402 :type gnus-article-treat-custom)
1403 (put 'gnus-treat-overstrike 'highlight t)
1405 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1406 "Treat ANSI SGR control sequences.
1407 Valid values are nil, t, `head', `first', `last', an integer or a
1408 predicate. See Info node `(gnus)Customizing Articles'."
1409 :group 'gnus-article-treat
1410 :link '(custom-manual "(gnus)Customizing Articles")
1411 :type gnus-article-treat-custom)
1413 (make-obsolete-variable 'gnus-treat-display-xface
1414 'gnus-treat-display-x-face "Emacs 22.1")
1416 (defcustom gnus-treat-display-x-face
1417 (and (not noninteractive)
1418 (gnus-image-type-available-p 'xbm)
1419 (if (featurep 'xemacs)
1422 (and (string-match "^0x" (shell-command-to-string "uncompface"))
1423 (executable-find "icontopbm"))
1424 ;; shell-command-to-string may signal an error, e.g. if
1425 ;; shell-file-name is not found.
1428 "Display X-Face headers.
1429 Valid values are nil and `head'.
1430 See Info node `(gnus)Customizing Articles' and Info node
1431 `(gnus)X-Face' for details."
1432 :group 'gnus-article-treat
1434 :link '(custom-manual "(gnus)Customizing Articles")
1435 :link '(custom-manual "(gnus)X-Face")
1436 :type gnus-article-treat-head-custom
1437 :set (lambda (symbol value)
1440 (cond ((or (boundp symbol) (get symbol 'saved-value))
1442 ((boundp 'gnus-treat-display-xface)
1444 ** gnus-treat-display-xface is an obsolete variable;\
1445 use gnus-treat-display-x-face instead")
1446 (default-value 'gnus-treat-display-xface))
1447 ((get 'gnus-treat-display-xface 'saved-value)
1449 ** gnus-treat-display-xface is an obsolete variable;\
1450 use gnus-treat-display-x-face instead")
1451 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1454 (put 'gnus-treat-display-x-face 'highlight t)
1456 (defcustom gnus-treat-display-face
1457 (and (not noninteractive)
1458 (gnus-image-type-available-p 'png)
1460 "Display Face headers.
1461 Valid values are nil, t, `head', `first', `last', an integer or a
1462 predicate. See Info node `(gnus)Customizing Articles' and Info
1463 node `(gnus)Face' for details."
1464 :group 'gnus-article-treat
1466 :link '(custom-manual "(gnus)Customizing Articles")
1467 :link '(custom-manual "(gnus)X-Face")
1468 :type gnus-article-treat-head-custom)
1469 (put 'gnus-treat-display-face 'highlight t)
1471 (defcustom gnus-treat-display-smileys (gnus-image-type-available-p 'xpm)
1473 Valid values are nil, t, `head', `first', `last', an integer or a
1474 predicate. See Info node `(gnus)Customizing Articles' and Info
1475 node `(gnus)Smileys' for details."
1476 :group 'gnus-article-treat
1478 :link '(custom-manual "(gnus)Customizing Articles")
1479 :link '(custom-manual "(gnus)Smileys")
1480 :type gnus-article-treat-custom)
1481 (put 'gnus-treat-display-smileys 'highlight t)
1483 (defcustom gnus-treat-from-picon
1484 (if (and (gnus-image-type-available-p 'xpm)
1485 (gnus-picons-installed-p))
1487 "Display picons in the From header.
1488 Valid values are nil, t, `head', `first', `last', an integer or a
1489 predicate. See Info node `(gnus)Customizing Articles' and Info
1490 node `(gnus)Picons' for details."
1492 :group 'gnus-article-treat
1494 :link '(custom-manual "(gnus)Customizing Articles")
1495 :link '(custom-manual "(gnus)Picons")
1496 :type gnus-article-treat-head-custom)
1497 (put 'gnus-treat-from-picon 'highlight t)
1499 (defcustom gnus-treat-mail-picon
1500 (if (and (gnus-image-type-available-p 'xpm)
1501 (gnus-picons-installed-p))
1503 "Display picons in To and Cc headers.
1504 Valid values are nil, t, `head', `first', `last', an integer or a
1505 predicate. See Info node `(gnus)Customizing Articles' and Info
1506 node `(gnus)Picons' for details."
1508 :group 'gnus-article-treat
1510 :link '(custom-manual "(gnus)Customizing Articles")
1511 :link '(custom-manual "(gnus)Picons")
1512 :type gnus-article-treat-head-custom)
1513 (put 'gnus-treat-mail-picon 'highlight t)
1515 (defcustom gnus-treat-newsgroups-picon
1516 (if (and (gnus-image-type-available-p 'xpm)
1517 (gnus-picons-installed-p))
1519 "Display picons in the Newsgroups and Followup-To headers.
1520 Valid values are nil, t, `head', `first', `last', an integer or a
1521 predicate. See Info node `(gnus)Customizing Articles' and Info
1522 node `(gnus)Picons' for details."
1524 :group 'gnus-article-treat
1526 :link '(custom-manual "(gnus)Customizing Articles")
1527 :link '(custom-manual "(gnus)Picons")
1528 :type gnus-article-treat-head-custom)
1529 (put 'gnus-treat-newsgroups-picon 'highlight t)
1531 (defcustom gnus-treat-from-gravatar nil
1532 "Display gravatars in the From header.
1533 Valid values are nil, t, `head', `first', `last', an integer or a
1534 predicate. See Info node `(gnus)Customizing Articles' and Info
1535 node `(gnus)Gravatars' for details."
1537 :group 'gnus-article-treat
1538 :group 'gnus-gravatar
1539 :link '(custom-manual "(gnus)Customizing Articles")
1540 :link '(custom-manual "(gnus)Gravatars")
1541 :type gnus-article-treat-head-custom)
1542 (put 'gnus-treat-from-gravatar 'highlight t)
1544 (defcustom gnus-treat-mail-gravatar nil
1545 "Display gravatars in To and Cc headers.
1546 Valid values are nil, t, `head', `first', `last', an integer or a
1547 predicate. See Info node `(gnus)Customizing Articles' and Info
1548 node `(gnus)Gravatars' for details."
1550 :group 'gnus-article-treat
1551 :group 'gnus-gravatar
1552 :link '(custom-manual "(gnus)Customizing Articles")
1553 :link '(custom-manual "(gnus)Gravatars")
1554 :type gnus-article-treat-head-custom)
1555 (put 'gnus-treat-mail-gravatar 'highlight t)
1557 (defcustom gnus-treat-body-boundary
1558 (if (or gnus-treat-newsgroups-picon
1559 gnus-treat-mail-picon
1560 gnus-treat-from-picon
1561 gnus-treat-from-gravatar
1562 gnus-treat-mail-gravatar)
1563 ;; If there's much decoration, the user might prefer a boundery.
1566 "Draw a boundary at the end of the headers.
1567 Valid values are nil and `head'.
1568 See Info node `(gnus)Customizing Articles' for details."
1570 :group 'gnus-article-treat
1571 :link '(custom-manual "(gnus)Customizing Articles")
1572 :type gnus-article-treat-head-custom)
1574 (defcustom gnus-treat-capitalize-sentences nil
1575 "Capitalize sentence-starting words.
1576 Valid values are nil, t, `head', `first', `last', an integer or a
1577 predicate. See Info node `(gnus)Customizing Articles'."
1579 :group 'gnus-article-treat
1580 :link '(custom-manual "(gnus)Customizing Articles")
1581 :type gnus-article-treat-custom)
1583 (defcustom gnus-treat-wash-html nil
1585 Valid values are nil, t, `head', `first', `last', an integer or a
1586 predicate. See Info node `(gnus)Customizing Articles'."
1588 :group 'gnus-article-treat
1589 :link '(custom-manual "(gnus)Customizing Articles")
1590 :type gnus-article-treat-custom)
1592 (defcustom gnus-treat-fill-long-lines '(typep "text/plain")
1594 Valid values are nil, t, `head', `first', `last', an integer or a
1595 predicate. See Info node `(gnus)Customizing Articles'."
1597 :group 'gnus-article-treat
1598 :link '(custom-manual "(gnus)Customizing Articles")
1599 :type gnus-article-treat-custom)
1601 (defcustom gnus-treat-x-pgp-sig nil
1603 To automatically treat X-PGP-Sig, set it to head.
1604 Valid values are nil, t, `head', `first', `last', an integer or a
1605 predicate. See Info node `(gnus)Customizing Articles'."
1607 :group 'gnus-article-treat
1608 :group 'mime-security
1609 :link '(custom-manual "(gnus)Customizing Articles")
1610 :type gnus-article-treat-custom)
1612 (defvar gnus-article-encrypt-protocol-alist
1613 '(("PGP" . mml2015-self-encrypt)))
1615 ;; Set to nil if more than one protocol added to
1616 ;; gnus-article-encrypt-protocol-alist.
1617 (defcustom gnus-article-encrypt-protocol "PGP"
1618 "The protocol used for encrypt articles.
1619 It is a string, such as \"PGP\". If nil, ask user."
1622 :group 'mime-security)
1624 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1625 (mm-coding-system-p 'utf-8)
1626 (executable-find idna-program))
1627 "Whether IDNA decoding of headers is used when viewing messages.
1628 This requires GNU Libidn, and by default only enabled if it is found."
1630 :group 'gnus-article-headers
1633 (defcustom gnus-article-over-scroll nil
1634 "If non-nil, allow scrolling the article buffer even when there no more text."
1636 :group 'gnus-article
1639 (defcustom gnus-inhibit-images nil
1640 "Non-nil means inhibit displaying of images inline in the article body."
1642 :group 'gnus-article
1645 (defcustom gnus-blocked-images 'gnus-block-private-groups
1646 "Images that have URLs matching this regexp will be blocked.
1647 This can also be a function to be evaluated. If so, it will be
1648 called with the group name as the parameter, and should return a
1654 ;;; Internal variables
1656 (defvar gnus-english-month-names
1657 '("January" "February" "March" "April" "May" "June" "July" "August"
1658 "September" "October" "November" "December"))
1660 (defvar article-goto-body-goes-to-point-min-p nil)
1661 (defvar gnus-article-wash-types nil)
1662 (defvar gnus-article-emphasis-alist nil)
1663 (defvar gnus-article-image-alist nil)
1665 (defvar gnus-article-mime-handle-alist-1 nil)
1666 (defvar gnus-treatment-function-alist
1667 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1668 (gnus-treat-strip-banner gnus-article-strip-banner)
1669 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1670 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1671 (gnus-treat-buttonize gnus-article-add-buttons)
1672 (gnus-treat-fill-article gnus-article-fill-cited-article)
1673 (gnus-treat-fill-long-lines gnus-article-fill-cited-long-lines)
1674 (gnus-treat-strip-cr gnus-article-remove-cr)
1675 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1676 (gnus-treat-date-ut gnus-article-date-ut)
1677 (gnus-treat-date-local gnus-article-date-local)
1678 (gnus-treat-date-english gnus-article-date-english)
1679 (gnus-treat-date-original gnus-article-date-original)
1680 (gnus-treat-date-user-defined gnus-article-date-user)
1681 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1682 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1683 (gnus-treat-display-x-face gnus-article-display-x-face)
1684 (gnus-treat-display-face gnus-article-display-face)
1685 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1686 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1687 (gnus-treat-hide-signature gnus-article-hide-signature)
1688 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1689 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1690 (gnus-treat-from-picon gnus-treat-from-picon)
1691 (gnus-treat-mail-picon gnus-treat-mail-picon)
1692 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1693 (gnus-treat-strip-pem gnus-article-hide-pem)
1694 (gnus-treat-from-gravatar gnus-treat-from-gravatar)
1695 (gnus-treat-mail-gravatar gnus-treat-mail-gravatar)
1696 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1697 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1698 (gnus-treat-strip-trailing-blank-lines
1699 gnus-article-remove-trailing-blank-lines)
1700 (gnus-treat-strip-leading-blank-lines
1701 gnus-article-strip-leading-blank-lines)
1702 (gnus-treat-strip-multiple-blank-lines
1703 gnus-article-strip-multiple-blank-lines)
1704 (gnus-treat-overstrike gnus-article-treat-overstrike)
1705 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1706 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1707 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1708 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1709 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1710 (gnus-treat-display-smileys gnus-treat-smiley)
1711 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1712 (gnus-treat-wash-html gnus-article-wash-html)
1713 (gnus-treat-emphasize gnus-article-emphasize)
1714 (gnus-treat-hide-citation gnus-article-hide-citation)
1715 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1716 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1717 (gnus-treat-body-boundary gnus-article-treat-body-boundary)))
1719 (defvar gnus-article-mime-handle-alist nil)
1720 (defvar article-lapsed-timer nil)
1721 (defvar gnus-article-current-summary nil)
1723 (defvar gnus-article-mode-syntax-table
1724 (let ((table (copy-syntax-table text-mode-syntax-table)))
1725 ;; This causes the citation match run O(2^n).
1726 ;; (modify-syntax-entry ?- "w" table)
1727 (modify-syntax-entry ?> ")<" table)
1728 (modify-syntax-entry ?< "(>" table)
1729 ;; make M-. in article buffers work for `foo' strings
1730 (modify-syntax-entry ?' " " table)
1731 (modify-syntax-entry ?` " " table)
1733 "Syntax table used in article mode buffers.
1734 Initialized from `text-mode-syntax-table.")
1736 (defvar gnus-save-article-buffer nil)
1738 (defvar gnus-number-of-articles-to-be-saved nil)
1740 (defvar gnus-inhibit-hiding nil)
1742 (defvar gnus-article-edit-mode nil)
1744 ;;; Macros for dealing with the article buffer.
1746 (defmacro gnus-with-article-headers (&rest forms)
1747 `(with-current-buffer gnus-article-buffer
1749 (let ((inhibit-read-only t)
1750 (inhibit-point-motion-hooks t)
1751 (case-fold-search t))
1752 (article-narrow-to-head)
1755 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1756 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1758 (defmacro gnus-with-article-buffer (&rest forms)
1759 `(with-current-buffer gnus-article-buffer
1760 (let ((inhibit-read-only t))
1763 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1764 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1766 (defun gnus-article-goto-header (header)
1767 "Go to HEADER, which is a regular expression."
1768 (re-search-forward (concat "^\\(" header "\\):") nil t))
1770 (defsubst gnus-article-hide-text (b e props)
1771 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1772 (gnus-add-text-properties-when 'article-type nil b e props)
1773 (when (memq 'intangible props)
1775 (max (1- b) (point-min))
1776 b 'intangible (cddr (memq 'intangible props)))))
1778 (defsubst gnus-article-unhide-text (b e)
1779 "Remove hidden text properties from region between B and E."
1780 (remove-text-properties b e gnus-hidden-properties)
1781 (when (memq 'intangible gnus-hidden-properties)
1782 (put-text-property (max (1- b) (point-min))
1783 b 'intangible nil)))
1785 (defun gnus-article-hide-text-type (b e type)
1786 "Hide text of TYPE between B and E."
1787 (gnus-add-wash-type type)
1788 (gnus-article-hide-text
1789 b e (cons 'article-type (cons type gnus-hidden-properties))))
1791 (defun gnus-article-unhide-text-type (b e type)
1792 "Unhide text of TYPE between B and E."
1793 (gnus-delete-wash-type type)
1794 (remove-text-properties
1795 b e (cons 'article-type (cons type gnus-hidden-properties)))
1796 (when (memq 'intangible gnus-hidden-properties)
1797 (put-text-property (max (1- b) (point-min))
1798 b 'intangible nil)))
1800 (defun gnus-article-hide-text-of-type (type)
1801 "Hide text of TYPE in the current buffer."
1803 (let ((b (point-min))
1805 (while (setq b (text-property-any b e 'article-type type))
1806 (add-text-properties b (incf b) gnus-hidden-properties)))))
1808 (defun gnus-article-delete-text-of-type (type)
1809 "Delete text of TYPE in the current buffer."
1811 (let ((b (point-min)))
1812 (if (eq type 'multipart)
1813 ;; Remove MIME buttons associated with multipart/alternative parts.
1816 (while (if (get-text-property (point) 'gnus-part)
1818 (when (setq b (next-single-property-change (point)
1823 (skip-chars-forward "\n")
1824 (when (eq (get-text-property b 'article-type) 'multipart)
1825 (delete-region b (point)))))
1826 (while (setq b (text-property-any b (point-max) 'article-type type))
1828 b (or (text-property-not-all b (point-max) 'article-type type)
1831 (defun gnus-article-delete-invisible-text ()
1832 "Delete all invisible text in the current buffer."
1834 (let ((b (point-min)))
1835 (while (setq b (text-property-any b (point-max) 'invisible t))
1837 b (or (text-property-not-all b (point-max) 'invisible t)
1840 (defun gnus-article-text-type-exists-p (type)
1841 "Say whether any text of type TYPE exists in the buffer."
1842 (text-property-any (point-min) (point-max) 'article-type type))
1844 (defsubst gnus-article-header-rank ()
1845 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1846 (let ((list gnus-sorted-header-list)
1849 (if (looking-at (car list))
1851 (setq list (cdr list))
1855 (defun article-hide-headers (&optional arg delete)
1856 "Hide unwanted headers and possibly sort them as well."
1858 ;; This function might be inhibited.
1859 (unless gnus-inhibit-hiding
1860 (let ((inhibit-read-only t)
1861 (case-fold-search t)
1862 (max (1+ (length gnus-sorted-header-list)))
1863 (inhibit-point-motion-hooks t)
1864 (cur (current-buffer))
1865 ignored visible beg)
1867 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1868 ;; group parameters, so we should go to the summary buffer.
1871 (progn (set-buffer gnus-summary-buffer) t)
1873 (setq ignored (when (not gnus-visible-headers)
1874 (cond ((stringp gnus-ignored-headers)
1875 gnus-ignored-headers)
1876 ((listp gnus-ignored-headers)
1877 (mapconcat 'identity
1878 gnus-ignored-headers
1880 visible (cond ((stringp gnus-visible-headers)
1881 gnus-visible-headers)
1882 ((and gnus-visible-headers
1883 (listp gnus-visible-headers))
1884 (mapconcat 'identity
1885 gnus-visible-headers
1889 ;; First we narrow to just the headers.
1890 (article-narrow-to-head)
1891 ;; Hide any "From " lines at the beginning of (mail) articles.
1892 (while (looking-at "From ")
1895 (delete-region (point-min) (point)))
1896 ;; Then treat the rest of the header lines.
1897 ;; Then we use the two regular expressions
1898 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1899 ;; select which header lines is to remain visible in the
1901 (while (re-search-forward "^[^ \t:]*:" nil t)
1903 ;; Mark the rank of the header.
1905 (point) (1+ (point)) 'message-rank
1906 (if (or (and visible (looking-at visible))
1908 (not (looking-at ignored))))
1909 (gnus-article-header-rank)
1912 (message-sort-headers-1)
1913 (when (setq beg (text-property-any
1914 (point-min) (point-max) 'message-rank (+ 2 max)))
1915 ;; We delete the unwanted headers.
1916 (gnus-add-wash-type 'headers)
1917 (add-text-properties (point-min) (+ 5 (point-min))
1918 '(article-type headers dummy-invisible t))
1919 (delete-region beg (point-max))))))))
1921 (defun article-hide-boring-headers (&optional arg)
1922 "Toggle hiding of headers that aren't very interesting.
1923 If given a negative prefix, always show; if given a positive prefix,
1925 (interactive (gnus-article-hidden-arg))
1926 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1927 (not gnus-show-all-headers))
1930 (let ((inhibit-read-only t)
1931 (inhibit-point-motion-hooks t))
1932 (article-narrow-to-head)
1933 (dolist (elem gnus-boring-article-headers)
1934 (goto-char (point-min))
1936 ;; Hide empty headers.
1938 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1940 (gnus-article-hide-text-type
1944 (if (re-search-forward "^[^ \t]" nil t)
1948 ;; Hide boring Newsgroups header.
1949 ((eq elem 'newsgroups)
1950 (when (gnus-string-equal
1951 (gnus-fetch-field "newsgroups")
1952 (gnus-group-real-name
1953 (if (boundp 'gnus-newsgroup-name)
1956 (gnus-article-hide-header "newsgroups")))
1957 ((eq elem 'to-address)
1958 (let ((to (message-fetch-field "to"))
1960 (gnus-parameter-to-address
1961 (if (boundp 'gnus-newsgroup-name)
1962 gnus-newsgroup-name ""))))
1963 (when (and to to-address
1966 ;; only one address in To
1967 (nth 1 (mail-extract-address-components to))
1969 (gnus-article-hide-header "to"))))
1971 (let ((to (message-fetch-field "to"))
1973 (gnus-parameter-to-list
1974 (if (boundp 'gnus-newsgroup-name)
1975 gnus-newsgroup-name ""))))
1976 (when (and to to-list
1979 ;; only one address in To
1980 (nth 1 (mail-extract-address-components to))
1982 (gnus-article-hide-header "to"))))
1984 (let ((cc (message-fetch-field "cc"))
1986 (gnus-parameter-to-list
1987 (if (boundp 'gnus-newsgroup-name)
1988 gnus-newsgroup-name ""))))
1989 (when (and cc to-list
1992 ;; only one address in CC
1993 (nth 1 (mail-extract-address-components cc))
1995 (gnus-article-hide-header "cc"))))
1996 ((eq elem 'followup-to)
1997 (when (gnus-string-equal
1998 (message-fetch-field "followup-to")
1999 (message-fetch-field "newsgroups"))
2000 (gnus-article-hide-header "followup-to")))
2001 ((eq elem 'reply-to)
2002 (if (gnus-group-find-parameter
2003 gnus-newsgroup-name 'broken-reply-to)
2004 (gnus-article-hide-header "reply-to")
2005 (let ((from (message-fetch-field "from"))
2006 (reply-to (message-fetch-field "reply-to")))
2013 (lambda (x) (downcase (cadr x)))
2014 (mail-extract-address-components from t))
2017 (lambda (x) (downcase (cadr x)))
2018 (mail-extract-address-components reply-to t))
2020 (gnus-article-hide-header "reply-to")))))
2022 (let ((date (with-current-buffer gnus-original-article-buffer
2023 ;; If date in `gnus-article-buffer' is localized
2024 ;; (`gnus-treat-date-user-defined'),
2025 ;; `days-between' might fail.
2026 (message-fetch-field "date"))))
2028 (< (days-between (current-time-string) date)
2030 (gnus-article-hide-header "date"))))
2032 (let ((to (message-fetch-field "to"))
2033 (cc (message-fetch-field "cc")))
2034 (when (> (length to) 1024)
2035 (gnus-article-hide-header "to"))
2036 (when (> (length cc) 1024)
2037 (gnus-article-hide-header "cc"))))
2041 (goto-char (point-min))
2042 (while (re-search-forward "^to:" nil t)
2043 (setq to-count (1+ to-count)))
2044 (when (> to-count 1)
2045 (while (> to-count 0)
2046 (goto-char (point-min))
2048 (re-search-forward "^to:" nil nil to-count)
2050 (narrow-to-region (point) (point-max))
2051 (gnus-article-hide-header "to"))
2052 (setq to-count (1- to-count))))
2053 (goto-char (point-min))
2054 (while (re-search-forward "^cc:" nil t)
2055 (setq cc-count (1+ cc-count)))
2056 (when (> cc-count 1)
2057 (while (> cc-count 0)
2058 (goto-char (point-min))
2060 (re-search-forward "^cc:" nil nil cc-count)
2062 (narrow-to-region (point) (point-max))
2063 (gnus-article-hide-header "cc"))
2064 (setq cc-count (1- cc-count)))))))))))))
2066 (defun gnus-article-hide-header (header)
2068 (goto-char (point-min))
2069 (when (re-search-forward (concat "^" header ":") nil t)
2070 (gnus-article-hide-text-type
2074 (if (re-search-forward "^[^ \t]" nil t)
2079 (defvar gnus-article-normalized-header-length 40
2080 "Length of normalized headers.")
2082 (defun article-normalize-headers ()
2083 "Make all header lines 40 characters long."
2085 (let ((inhibit-read-only t)
2089 (article-narrow-to-head)
2092 ((< (setq column (- (point-at-eol) (point)))
2093 gnus-article-normalized-header-length)
2095 (insert (make-string
2096 (- gnus-article-normalized-header-length column)
2098 ((> column gnus-article-normalized-header-length)
2099 (gnus-put-text-property
2101 (forward-char gnus-article-normalized-header-length)
2108 (forward-line 1))))))
2110 (defun article-treat-dumbquotes ()
2111 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
2112 Note that this function guesses whether a character is a sm*rtq**t* or
2113 not, so it should only be used interactively.
2115 Sm*rtq**t*s are M****s***'s unilateral extension to the
2116 iso-8859-1 character map in an attempt to provide more quoting
2117 characters. If you see something like \\222 or \\264 where
2118 you're expecting some kind of apostrophe or quotation mark, then
2121 (article-translate-strings gnus-article-dumbquotes-map))
2123 (defvar org-entities)
2125 (defun article-treat-non-ascii ()
2126 "Translate many Unicode characters into their ASCII equivalents."
2128 (require 'org-entities)
2129 (let ((table (make-char-table (if (featurep 'xemacs) 'generic))))
2130 (dolist (elem org-entities)
2131 (when (and (listp elem)
2132 (= (length (nth 6 elem)) 1))
2133 (if (featurep 'xemacs)
2134 (put-char-table (aref (nth 6 elem) 0) (nth 4 elem) table)
2135 (set-char-table-range table (aref (nth 6 elem) 0) (nth 4 elem)))))
2137 (when (article-goto-body)
2138 (let ((inhibit-read-only t)
2141 (if (not (setq replace (if (featurep 'xemacs)
2142 (get-char-table (following-char) table)
2143 (aref table (following-char)))))
2146 (setq props (text-properties-at (point)))
2148 (add-text-properties (point) (progn (insert replace) (point))
2150 (insert replace)))))))))
2152 (defun article-translate-characters (from to)
2153 "Translate all characters in the body of the article according to FROM and TO.
2154 FROM is a string of characters to translate from; to is a string of
2155 characters to translate to."
2157 (when (article-goto-body)
2158 (let ((inhibit-read-only t)
2159 (x (make-string 225 ?x))
2161 (while (< (incf i) (length x))
2164 (while (< i (length from))
2165 (aset x (aref from i) (aref to i))
2167 (translate-region (point) (point-max) x)))))
2169 (defun article-translate-strings (map)
2170 "Translate all string in the body of the article according to MAP.
2171 MAP is an alist where the elements are on the form (\"from\" \"to\")."
2173 (when (article-goto-body)
2174 (let ((inhibit-read-only t))
2176 (let ((from (car elem))
2180 (while (search-forward from nil t)
2183 (if (eq (following-char) from)
2187 (forward-char 1)))))))))))
2189 (defun article-treat-overstrike ()
2190 "Translate overstrikes into bold text."
2193 (when (article-goto-body)
2194 (let ((inhibit-read-only t))
2195 (while (search-forward "\b" nil t)
2196 (let ((next (char-after))
2197 (previous (char-after (- (point) 2))))
2198 ;; We do the boldification/underlining by hiding the
2199 ;; overstrikes and putting the proper text property
2203 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
2204 (put-text-property (point) (1+ (point)) 'face 'bold))
2206 (gnus-article-hide-text-type
2207 (1- (point)) (1+ (point)) 'overstrike)
2209 (- (point) 2) (1- (point)) 'face 'underline))
2211 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
2213 (point) (1+ (point)) 'face 'underline)))))))))
2215 (defun article-treat-ansi-sequences ()
2216 "Translate ANSI SGR control sequences into overlays or extents."
2219 (when (article-goto-body)
2220 (let ((inhibit-read-only t))
2221 (ansi-color-apply-on-region (point) (point-max))))))
2223 (defun gnus-article-treat-unfold-headers ()
2224 "Unfold folded message headers.
2225 Only the headers that fit into the current window width will be
2228 (gnus-with-article-headers
2232 (mail-header-narrow-to-field)
2233 (let* ((header (buffer-string))
2235 (or (equal gnus-article-unfold-long-headers t)
2236 (and (stringp gnus-article-unfold-long-headers)
2237 (string-match gnus-article-unfold-long-headers header)))))
2240 (goto-char (point-min))
2241 (while (re-search-forward "\n[\t ]" nil t)
2242 (replace-match " " t t)))
2243 (setq length (- (point-max) (point-min) 1))
2244 (when (or unfoldable
2245 (< length (window-width)))
2246 (while (re-search-forward "\n[\t ]" nil t)
2247 (replace-match " " t t))))
2248 (goto-char (point-max)))))))
2250 (defun gnus-article-treat-fold-headers ()
2251 "Fold message headers."
2253 (gnus-with-article-headers
2256 (mail-header-narrow-to-field)
2257 (mail-header-fold-field)
2258 (goto-char (point-max))))))
2260 (defun gnus-treat-smiley ()
2261 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2263 (gnus-with-article-buffer
2264 (if (memq 'smiley gnus-article-wash-types)
2265 (gnus-delete-images 'smiley)
2267 (let ((images (smiley-region (point) (point-max))))
2269 (gnus-add-wash-type 'smiley)
2270 (dolist (image images)
2271 (gnus-add-image 'smiley image)))))))
2273 (defun gnus-article-remove-images ()
2274 "Remove all images from the article buffer."
2276 (gnus-with-article-buffer
2279 (dolist (elem gnus-article-image-alist)
2280 (gnus-delete-images (car elem))))))
2282 (defun gnus-article-show-images ()
2283 "Show any images that are in the HTML-rendered article buffer.
2284 This only works if the article in question is HTML."
2286 (gnus-with-article-buffer
2289 (dolist (region (gnus-find-text-property-region (point-min) (point-max)
2291 (destructuring-bind (start end function) region
2292 (funcall function (get-text-property start 'image-url)
2295 (defun gnus-article-treat-fold-newsgroups ()
2296 "Unfold folded message headers.
2297 Only the headers that fit into the current window width will be
2300 (gnus-with-article-headers
2301 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2303 (mail-header-narrow-to-field)
2304 (while (re-search-forward ", *" nil t)
2305 (replace-match ", " t t))
2306 (mail-header-fold-field)
2307 (goto-char (point-max))))))
2309 (defcustom gnus-article-truncate-lines (default-value 'truncate-lines)
2310 "Value of `truncate-lines' in Gnus Article buffer.
2311 Valid values are nil, t, `head', `first', `last', an integer or a
2312 predicate. See Info node `(gnus)Customizing Articles'."
2313 :version "23.1" ;; No Gnus
2314 :group 'gnus-article
2315 ;; :link '(custom-manual "(gnus)Customizing Articles")
2318 (defun gnus-article-toggle-truncate-lines (&optional arg)
2319 "Toggle whether to fold or truncate long lines in article the buffer.
2320 If ARG is non-nil and not a number, toggle
2321 `gnus-article-truncate-lines' too. If ARG is a number, truncate
2322 long lines if and only if arg is positive."
2325 ((and (numberp arg) (> arg 0))
2326 (setq gnus-article-truncate-lines t))
2328 (setq gnus-article-truncate-lines nil))
2330 (setq gnus-article-truncate-lines
2331 (not gnus-article-truncate-lines))))
2332 (gnus-with-article-buffer
2334 ((and (numberp arg) (> arg 0))
2335 (setq truncate-lines nil))
2337 (setq truncate-lines t)))
2338 ;; In versions of Emacs 22 (CVS) before 2006-05-26,
2339 ;; `toggle-truncate-lines' needs an argument.
2340 (toggle-truncate-lines)))
2342 (defun gnus-article-treat-body-boundary ()
2343 "Place a boundary line at the end of the headers."
2345 (when (and gnus-body-boundary-delimiter
2346 (> (length gnus-body-boundary-delimiter) 0))
2347 (gnus-with-article-headers
2348 (goto-char (point-max))
2349 (let ((start (point)))
2350 (insert "X-Boundary: ")
2351 (gnus-add-text-properties start (point) '(invisible t intangible t))
2353 (while (>= (window-width) (length str))
2354 (setq str (concat str gnus-body-boundary-delimiter)))
2355 (substring str 0 (window-width)))
2357 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2359 (defun article-fill-long-lines ()
2360 "Fill lines that are wider than the window width."
2363 (let ((inhibit-read-only t)
2364 (width (window-width (get-buffer-window (current-buffer)))))
2367 (let ((adaptive-fill-mode nil)) ;Why? -sm
2370 (when (>= (current-column) (min fill-column width))
2371 (narrow-to-region (min (1+ (point)) (point-max))
2373 (let ((goback (point-marker)))
2374 (fill-paragraph nil)
2375 (goto-char (marker-position goback)))
2377 (forward-line 1)))))))
2379 (defun article-capitalize-sentences ()
2380 "Capitalize the first word in each sentence."
2383 (let ((inhibit-read-only t)
2384 (paragraph-start "^[\n\^L]"))
2388 (forward-sentence)))))
2390 (defun article-remove-cr ()
2391 "Remove trailing CRs and then translate remaining CRs into LFs."
2394 (let ((inhibit-read-only t))
2395 (goto-char (point-min))
2396 (while (re-search-forward "\r+$" nil t)
2397 (replace-match "" t t))
2398 (goto-char (point-min))
2399 (while (search-forward "\r" nil t)
2400 (replace-match "\n" t t)))))
2402 (defun article-remove-trailing-blank-lines ()
2403 "Remove all trailing blank lines from the article."
2406 (let ((inhibit-read-only t))
2407 (goto-char (point-max))
2411 (while (and (not (bobp))
2412 (looking-at "^[ \t]*$")
2413 (not (gnus-annotation-in-region-p
2414 (point) (point-at-eol))))
2419 (defvar gnus-face-properties-alist)
2421 (defun article-display-face (&optional force)
2422 "Display any Face headers in the header."
2423 (interactive (list 'force))
2424 (let ((wash-face-p buffer-read-only))
2425 (gnus-with-article-headers
2426 ;; When displaying parts, this function can be called several times on
2427 ;; the same article, without any intended toggle semantic (as typing `W
2428 ;; D d' would have). So face deletion must occur only when we come from
2429 ;; an interactive command, that is when the *Article* buffer is
2431 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2432 (gnus-delete-images 'face)
2433 (let ((from (message-fetch-field "from"))
2435 (save-current-buffer
2436 (when (and wash-face-p
2437 (gnus-buffer-live-p gnus-original-article-buffer)
2438 (not (re-search-forward "^Face:[\t ]*" nil t)))
2439 (set-buffer gnus-original-article-buffer))
2441 (mail-narrow-to-head)
2443 ;; Check whether this face is censored.
2444 (not (and gnus-article-x-face-too-ugly
2446 (setq from (message-fetch-field "from")))
2447 (string-match gnus-article-x-face-too-ugly
2449 (while (gnus-article-goto-header "Face")
2450 (push (mail-header-field-value) faces)))))
2452 (goto-char (point-min))
2454 (unless (setq from (gnus-article-goto-header "from"))
2457 (insert " [no `from' set]\n"))
2459 (when (setq png (gnus-convert-face-to-png (pop faces)))
2461 (apply 'gnus-create-image png 'png t
2462 (cdr (assq 'png gnus-face-properties-alist))))
2464 (gnus-add-wash-type 'face)
2465 (gnus-add-image 'face image)
2466 (gnus-put-image image nil 'face))))))))))
2468 (defun article-display-x-face (&optional force)
2469 "Look for an X-Face header and display it if present."
2470 (interactive (list 'force))
2471 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2472 (gnus-with-article-headers
2473 ;; Delete the old process, if any.
2474 (when (process-status "article-x-face")
2475 (delete-process "article-x-face"))
2476 ;; See the comment in `article-display-face'.
2477 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2478 ;; We have already displayed X-Faces, so we remove them
2480 (gnus-delete-images 'xface)
2482 (let ((from (message-fetch-field "from"))
2484 (save-current-buffer
2485 (when (and wash-face-p
2486 (gnus-buffer-live-p gnus-original-article-buffer)
2487 (not (re-search-forward "^X-Face:[\t ]*" nil t)))
2488 ;; If type `W f', use gnus-original-article-buffer,
2489 ;; otherwise use the current buffer because displaying
2490 ;; RFC822 parts calls this function too.
2491 (set-buffer gnus-original-article-buffer))
2493 (mail-narrow-to-head)
2494 (and gnus-article-x-face-command
2496 ;; Check whether this face is censored.
2497 (not (and gnus-article-x-face-too-ugly
2499 (setq from (message-fetch-field "from")))
2500 (string-match gnus-article-x-face-too-ugly
2502 (while (gnus-article-goto-header "X-Face")
2503 (push (mail-header-field-value) x-faces)))))
2505 ;; We display the face.
2506 (cond ((functionp gnus-article-x-face-command)
2507 ;; The command is a lisp function, so we call it.
2508 (mapc gnus-article-x-face-command x-faces))
2509 ((stringp gnus-article-x-face-command)
2510 ;; The command is a string, so we interpret the command
2511 ;; as a, well, command, and fork it off.
2512 (let ((process-connection-type nil))
2513 (gnus-set-process-query-on-exit-flag
2515 "article-x-face" nil shell-file-name
2516 shell-command-switch gnus-article-x-face-command)
2518 ;; Sending multiple EOFs to xv doesn't work,
2519 ;; so we only do a single external face.
2521 (insert (car x-faces))
2522 (process-send-region "article-x-face"
2523 (point-min) (point-max)))
2524 (process-send-eof "article-x-face")))
2526 (error "`%s' set to `%s' is not a function"
2527 gnus-article-x-face-command
2528 'gnus-article-x-face-command)))))))))
2530 (defun article-decode-mime-words ()
2531 "Decode all MIME-encoded words in the article."
2533 (gnus-with-article-buffer
2534 (let ((inhibit-point-motion-hooks t)
2535 (mail-parse-charset gnus-newsgroup-charset)
2536 (mail-parse-ignored-charsets
2537 (with-current-buffer gnus-summary-buffer
2538 gnus-newsgroup-ignored-charsets)))
2539 (mail-decode-encoded-word-region (point-min) (point-max)))))
2541 (defun article-decode-charset (&optional prompt)
2542 "Decode charset-encoded text in the article.
2543 If PROMPT (the prefix), prompt for a coding system to use."
2545 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2546 (inhibit-read-only t)
2547 (mail-parse-charset gnus-newsgroup-charset)
2548 (mail-parse-ignored-charsets
2549 (save-excursion (condition-case nil
2550 (set-buffer gnus-summary-buffer)
2552 gnus-newsgroup-ignored-charsets))
2553 ct cte ctl charset format)
2556 (article-narrow-to-head)
2557 (setq ct (message-fetch-field "Content-Type" t)
2558 cte (message-fetch-field "Content-Transfer-Encoding" t)
2559 ctl (and ct (mail-header-parse-content-type ct))
2562 (mm-read-coding-system "Charset to decode: "))
2564 (mail-content-type-get ctl 'charset)))
2565 format (and ctl (mail-content-type-get ctl 'format)))
2567 (setq cte (mail-header-strip cte)))
2568 (if (and ctl (not (string-match "/" (car ctl))))
2570 (goto-char (point-max)))
2573 (narrow-to-region (point) (point-max))
2574 (when (and (eq mail-parse-charset 'gnus-decoded)
2575 (eq (mm-body-7-or-8) '8bit))
2576 ;; The text code could have been decoded.
2577 (setq charset mail-parse-charset))
2578 (when (and (or (not ctl)
2579 (equal (car ctl) "text/plain"))
2580 (not format)) ;; article with format will decode later.
2582 charset (and cte (intern (downcase
2583 (gnus-strip-whitespace cte))))
2586 (defun article-decode-encoded-words ()
2587 "Remove encoded-word encoding from headers."
2588 (let ((inhibit-point-motion-hooks t)
2589 (mail-parse-charset gnus-newsgroup-charset)
2590 (mail-parse-ignored-charsets
2591 (save-excursion (condition-case nil
2592 (set-buffer gnus-summary-buffer)
2594 gnus-newsgroup-ignored-charsets))
2595 (inhibit-read-only t)
2597 (goto-char (point-min))
2598 (when (search-forward "\n\n" nil 'move)
2605 (memq (char-after) '(?\t ? )))))
2606 (setq start (point))
2608 \\(?:Resent-\\)?\\(?:From\\|Cc\\|To\\|Bcc\\|\\(?:In-\\)?Reply-To\\|Sender\
2609 \\|Mail-Followup-To\\|Mail-Copies-To\\|Approved\\):")
2610 (funcall gnus-decode-address-function start end)
2611 (funcall gnus-decode-header-function start end))
2612 (goto-char (setq end start)))))
2614 (defun article-decode-group-name ()
2615 "Decode group names in Newsgroups, Followup-To and Xref headers."
2616 (let ((inhibit-point-motion-hooks t)
2617 (inhibit-read-only t)
2618 (method (gnus-find-method-for-group gnus-newsgroup-name))
2620 (when (and (or gnus-group-name-charset-method-alist
2621 gnus-group-name-charset-group-alist)
2622 (gnus-buffer-live-p gnus-original-article-buffer))
2624 (article-narrow-to-head)
2625 (dolist (header '("Newsgroups" "Followup-To" "Xref"))
2626 (with-current-buffer gnus-original-article-buffer
2627 (goto-char (point-min)))
2628 (setq regexp (concat "^" header
2629 ":\\([^\n]*\\(?:\n[\t ]+[^\n]+\\)*\\)\n"))
2630 (while (re-search-forward regexp nil t)
2631 (replace-match (save-match-data
2632 (gnus-decode-newsgroups
2633 ;; XXX how to use data in article buffer?
2634 (with-current-buffer gnus-original-article-buffer
2635 (re-search-forward regexp nil t)
2637 gnus-newsgroup-name method))
2639 (goto-char (point-min)))))))
2641 (autoload 'idna-to-unicode "idna")
2643 (defun article-decode-idna-rhs ()
2644 "Decode IDNA strings in RHS in various headers in current buffer.
2645 The following headers are decoded: From:, To:, Cc:, Reply-To:,
2646 Mail-Reply-To: and Mail-Followup-To:."
2649 (let ((inhibit-point-motion-hooks t)
2650 (inhibit-read-only t))
2651 (article-narrow-to-head)
2652 (goto-char (point-min))
2653 (while (re-search-forward "@[^ \t\n\r,>]*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2655 (when (save-match-data
2656 (and (setq ace (match-string 1))
2658 (and (re-search-backward "^[^ \t]" nil t)
2659 (looking-at "From\\|To\\|Cc\\|Reply-To\\|Mail-Reply-To\\|Mail-Followup-To")))
2660 (setq unicode (idna-to-unicode ace))))
2661 (unless (string= ace unicode)
2662 (replace-match unicode nil nil nil 1)))))))))
2664 (defun article-de-quoted-unreadable (&optional force read-charset)
2665 "Translate a quoted-printable-encoded article.
2666 If FORCE, decode the article whether it is marked as quoted-printable
2668 If READ-CHARSET, ask for a coding system."
2669 (interactive (list 'force current-prefix-arg))
2671 (let ((inhibit-read-only t) type charset)
2672 (if (gnus-buffer-live-p gnus-original-article-buffer)
2673 (with-current-buffer gnus-original-article-buffer
2675 (gnus-fetch-field "content-transfer-encoding"))
2676 (let* ((ct (gnus-fetch-field "content-type"))
2677 (ctl (and ct (mail-header-parse-content-type ct))))
2678 (setq charset (and ctl
2679 (mail-content-type-get ctl 'charset)))
2680 (if (stringp charset)
2681 (setq charset (intern (downcase charset)))))))
2683 (setq charset (mm-read-coding-system "Charset: " charset)))
2685 (setq charset gnus-newsgroup-charset))
2687 (and type (let ((case-fold-search t))
2688 (string-match "quoted-printable" type))))
2690 (quoted-printable-decode-region
2691 (point) (point-max) (mm-charset-to-coding-system charset))))))
2693 (defun article-de-base64-unreadable (&optional force read-charset)
2694 "Translate a base64 article.
2695 If FORCE, decode the article whether it is marked as base64 not.
2696 If READ-CHARSET, ask for a coding system."
2697 (interactive (list 'force current-prefix-arg))
2699 (let ((inhibit-read-only t) type charset)
2700 (if (gnus-buffer-live-p gnus-original-article-buffer)
2701 (with-current-buffer gnus-original-article-buffer
2703 (gnus-fetch-field "content-transfer-encoding"))
2704 (let* ((ct (gnus-fetch-field "content-type"))
2705 (ctl (and ct (mail-header-parse-content-type ct))))
2706 (setq charset (and ctl
2707 (mail-content-type-get ctl 'charset)))
2708 (if (stringp charset)
2709 (setq charset (intern (downcase charset)))))))
2711 (setq charset (mm-read-coding-system "Charset: " charset)))
2713 (setq charset gnus-newsgroup-charset))
2715 (and type (let ((case-fold-search t))
2716 (string-match "base64" type))))
2719 (narrow-to-region (point) (point-max))
2720 (base64-decode-region (point-min) (point-max))
2721 (mm-decode-coding-region
2722 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2727 (defun article-decode-HZ ()
2728 "Translate a HZ-encoded article."
2732 (let ((inhibit-read-only t))
2733 (rfc1843-decode-region (point-min) (point-max)))))
2735 (defun article-unsplit-urls ()
2736 "Remove the newlines that some other mailers insert into URLs."
2739 (let ((inhibit-read-only t))
2740 (goto-char (point-min))
2741 (while (re-search-forward
2742 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2743 (replace-match "\\1\\3" t)))
2744 (when (interactive-p)
2745 (gnus-treat-article nil))))
2747 (defun article-wash-html ()
2748 "Format an HTML article."
2751 (buffer-read-only nil))
2752 (when (gnus-buffer-live-p gnus-original-article-buffer)
2753 (setq handles (mm-dissect-buffer t t)))
2755 (delete-region (point) (point-max))
2756 (mm-inline-text-html handles)))
2758 (defvar gnus-article-browse-html-temp-list nil
2759 "List of temporary files created by `gnus-article-browse-html-parts'.
2760 Internal variable.")
2762 (defcustom gnus-article-browse-delete-temp 'ask
2763 "What to do with temporary files from `gnus-article-browse-html-parts'.
2764 If nil, don't delete temporary files. If it is t, delete them on
2765 exit from the summary buffer. If it is the symbol `file', query
2766 on each file, if it is `ask' ask once when exiting from the
2768 :group 'gnus-article
2769 :version "23.1" ;; No Gnus
2770 :type '(choice (const :tag "Don't delete" nil)
2771 (const :tag "Don't ask" t)
2772 (const :tag "Ask" ask)
2773 (const :tag "Ask for each file" file)))
2775 ;; Cf. mm-postponed-undisplay-list / mm-destroy-postponed-undisplay-list.
2777 (defun gnus-article-browse-delete-temp-files (&optional how)
2778 "Delete temp-files created by `gnus-article-browse-html-parts'."
2779 (when (and gnus-article-browse-html-temp-list
2781 (or how (setq how gnus-article-browse-delete-temp))
2783 (let ((files (length gnus-article-browse-html-temp-list)))
2784 (gnus-y-or-n-p (format
2785 "Delete all %s temporary HTML file%s? "
2787 (if (> files 1) "s" ""))))
2789 (dolist (file gnus-article-browse-html-temp-list)
2790 (cond ((file-directory-p file)
2791 (when (or (not (eq how 'file))
2794 "Delete temporary HTML file(s) in directory `%s'? "
2795 (file-name-as-directory file))))
2796 (gnus-delete-directory file)))
2797 ((file-exists-p file)
2798 (when (or (not (eq how 'file))
2800 (format "Delete temporary HTML file `%s'? " file)))
2801 (delete-file file)))))
2802 ;; Also remove file from the list when not deleted or if file doesn't
2804 (setq gnus-article-browse-html-temp-list nil))
2805 gnus-article-browse-html-temp-list)
2807 (defun gnus-article-browse-html-save-cid-content (cid handles directory)
2808 "Find CID content in HANDLES and save it in a file in DIRECTORY.
2813 (dolist (handle handles)
2815 ((not (listp handle)))
2816 ((equal (mm-handle-media-supertype handle) "multipart")
2817 (when (setq file (gnus-article-browse-html-save-cid-content
2818 cid handle directory))
2819 (throw 'found file)))
2820 ((equal (concat "<" cid ">") (mm-handle-id handle))
2823 (or (mail-content-type-get
2824 (mm-handle-disposition handle) 'filename)
2825 (mail-content-type-get
2826 (setq type (mm-handle-type handle)) 'name)
2828 (make-temp-name "cid")
2829 (car (rassoc (car type) mailcap-mime-extensions))))
2831 (mm-save-part-to-file handle file)
2832 (throw 'found file))))))))
2834 (defun gnus-article-browse-html-parts (list &optional header)
2835 "View all \"text/html\" parts from LIST.
2836 Recurse into multiparts. The optional HEADER that should be a decoded
2837 message header will be added to the bodies of the \"text/html\" parts."
2838 ;; Internal function used by `gnus-article-browse-html-article'.
2839 (let (type file charset content cid-dir tmp-file showed)
2840 ;; Find and show the html-parts.
2841 (dolist (handle list)
2842 ;; If HTML, show it:
2843 (cond ((not (listp handle)))
2844 ((or (equal (car (setq type (mm-handle-type handle))) "text/html")
2845 (and (equal (car type) "message/external-body")
2847 (setq file (or (mail-content-type-get type 'name)
2848 (mail-content-type-get
2849 (mm-handle-disposition handle)
2851 (or (mm-handle-cache handle)
2852 (condition-case code
2853 (progn (mm-extern-cache-contents handle) t)
2855 (gnus-message 3 "%s" (error-message-string code))
2856 (when (>= gnus-verbose 3) (sit-for 2))
2859 (setq handle (mm-handle-cache handle)
2860 type (mm-handle-type handle))
2861 (equal (car type) "text/html"))))
2862 (setq charset (mail-content-type-get type 'charset)
2863 content (mm-get-part handle))
2865 (if (eq charset 'gnus-decoded)
2866 (mm-enable-multibyte)
2867 (mm-disable-multibyte))
2869 ;; resolve cid contents
2870 (let ((case-fold-search t)
2872 (goto-char (point-min))
2873 (while (re-search-forward "\
2874 <img[\t\n ]+\\(?:[^\t\n >]+[\t\n ]+\\)*src=\"\\(cid:\\([^\"]+\\)\\)\""
2877 (setq cid-dir (mm-make-temp-file "cid" t))
2878 (add-to-list 'gnus-article-browse-html-temp-list cid-dir))
2881 (when (setq cid-file
2882 (gnus-article-browse-html-save-cid-content
2884 (with-current-buffer gnus-article-buffer
2885 gnus-article-mime-handles)
2887 (replace-match (concat "file://" cid-file)
2889 (unless content (setq content (buffer-string))))
2890 (when (or charset header (not file))
2891 (setq tmp-file (mm-make-temp-file
2892 ;; Do we need to care for 8.3 filenames?
2893 "mm-" nil ".html")))
2894 ;; Add a meta html tag to specify charset and a header.
2897 (let (title eheader body hcharset coding force-charset)
2899 (mm-enable-multibyte)
2900 (setq case-fold-search t)
2901 (insert header "\n")
2902 (setq title (message-fetch-field "subject"))
2903 (goto-char (point-min))
2904 (while (re-search-forward "\\(<\\)\\|\\(>\\)\\|&" nil t)
2905 (replace-match (cond ((match-beginning 1) "<")
2906 ((match-beginning 2) ">")
2908 (goto-char (point-min))
2910 (goto-char (point-max))
2911 (insert "</pre>\n<hr>\n")
2912 ;; We have to examine charset one by one since
2913 ;; charset specified in parts might be different.
2914 (if (eq charset 'gnus-decoded)
2915 (setq charset 'utf-8
2916 eheader (mm-encode-coding-string (buffer-string)
2919 (mm-encode-coding-string title charset))
2920 body (mm-encode-coding-string content charset)
2922 (setq hcharset (mm-find-mime-charset-region (point-min)
2924 (cond ((= (length hcharset) 1)
2925 (setq hcharset (car hcharset)
2926 coding (mm-charset-to-coding-system
2928 ((> (length hcharset) 1)
2929 (setq hcharset 'utf-8
2935 (mm-charset-to-coding-system charset))
2936 (if (eq coding body)
2937 (setq eheader (mm-encode-coding-string
2938 (buffer-string) coding)
2940 (mm-encode-coding-string
2943 (setq charset 'utf-8
2944 eheader (mm-encode-coding-string
2945 (buffer-string) charset)
2947 (mm-encode-coding-string
2949 body (mm-encode-coding-string
2950 (mm-decode-coding-string
2954 (setq charset hcharset
2955 eheader (mm-encode-coding-string
2956 (buffer-string) coding)
2958 (mm-encode-coding-string
2961 (setq eheader (mm-string-as-unibyte (buffer-string))
2964 (mm-disable-multibyte)
2967 (mm-add-meta-html-tag handle charset force-charset))
2969 (goto-char (point-min))
2970 (unless (search-forward "<title>" nil t)
2971 (re-search-forward "<head>\\s-*" nil t)
2972 (insert "<title>" title "</title>\n")))
2973 (goto-char (point-min))
2974 (or (re-search-forward
2975 "<body\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t)
2977 "</head\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t))
2979 (mm-write-region (point-min) (point-max)
2980 tmp-file nil nil nil 'binary t))))
2982 (mm-with-unibyte-buffer
2983 (insert (if (eq charset 'gnus-decoded)
2984 (mm-encode-coding-string content
2985 (setq charset 'utf-8))
2987 (if (or (mm-add-meta-html-tag handle charset)
2989 (mm-write-region (point-min) (point-max)
2990 tmp-file nil nil nil 'binary t)
2991 (setq tmp-file nil))))
2993 (mm-save-part-to-file handle tmp-file)))
2995 (add-to-list 'gnus-article-browse-html-temp-list tmp-file))
2996 (add-hook 'gnus-summary-prepare-exit-hook
2997 'gnus-article-browse-delete-temp-files)
2998 (add-hook 'gnus-exit-gnus-hook
3000 (gnus-article-browse-delete-temp-files t)))
3001 ;; FIXME: Warn if there's an <img> tag?
3002 (browse-url-of-file (or tmp-file (expand-file-name file)))
3004 ;; If multipart, recurse
3005 ((equal (mm-handle-media-supertype handle) "multipart")
3006 (when (gnus-article-browse-html-parts handle header)
3008 ((equal (mm-handle-media-type handle) "message/rfc822")
3009 (mm-with-multibyte-buffer
3010 (mm-insert-part handle)
3011 (setq handle (mm-dissect-buffer t t))
3012 (when (and (bufferp (car handle))
3013 (stringp (car (mm-handle-type handle))))
3014 (setq handle (list handle)))
3016 (article-decode-encoded-words)
3017 (let ((gnus-visible-headers
3018 (or (get 'gnus-visible-headers 'standard-value)
3019 gnus-visible-headers)))
3020 (article-hide-headers))
3021 (goto-char (point-min))
3022 (search-forward "\n\n" nil 'move)
3023 (skip-chars-backward "\t\n ")
3024 (setq header (buffer-substring (point-min) (point)))))
3026 (gnus-article-browse-html-parts handle header)
3027 (mm-destroy-parts handle))
3031 (defun gnus-article-browse-html-article (&optional arg)
3032 "View \"text/html\" parts of the current article with a WWW browser.
3033 Inline images embedded in a message using the cid scheme, as they are
3034 generally considered to be safe, will be processed properly.
3035 The message header is added to the beginning of every html part unless
3036 the prefix argument ARG is given.
3038 Warning: Spammers use links to images (using the http scheme) in HTML
3039 articles to verify whether you have read the message. As
3040 `gnus-article-browse-html-article' passes the HTML content to the
3041 browser without eliminating these \"web bugs\" you should only
3042 use it for mails from trusted senders.
3044 If you always want to display HTML parts in the browser, set
3045 `mm-text-html-renderer' to nil.
3047 This command creates temporary files to pass HTML contents including
3048 images if any to the browser, and deletes them when exiting the group
3050 ;; Cf. `mm-w3m-safe-url-regexp'
3053 (gnus-summary-show-article)
3054 (let ((gnus-visible-headers (or (get 'gnus-visible-headers 'standard-value)
3055 gnus-visible-headers))
3056 ;; As we insert a <hr>, there's no need for the body boundary.
3057 (gnus-treat-body-boundary nil))
3058 (gnus-summary-show-article)))
3059 (with-current-buffer gnus-article-buffer
3060 (let ((header (unless arg
3063 (buffer-substring-no-properties
3064 (goto-char (point-min))
3065 (if (search-forward "\n\n" nil t)
3067 (goto-char (point-max))
3068 (skip-chars-backward "\t\n ")
3071 (set-buffer gnus-original-article-buffer)
3072 (setq parts (mm-dissect-buffer t t))
3073 ;; If singlepart, enforce a list.
3074 (when (and (bufferp (car parts))
3075 (stringp (car (mm-handle-type parts))))
3076 (setq parts (list parts)))
3078 (unless (gnus-article-browse-html-parts parts header)
3079 (gnus-error 3 "Mail doesn't contain a \"text/html\" part!"))
3080 (mm-destroy-parts parts)
3082 (gnus-summary-show-article)))))
3084 (defun article-hide-list-identifiers ()
3085 "Remove list identifies from the Subject header.
3086 The `gnus-list-identifiers' variable specifies what to do."
3088 (let ((inhibit-point-motion-hooks t)
3089 (regexp (if (consp gnus-list-identifiers)
3090 (mapconcat 'identity gnus-list-identifiers " *\\|")
3091 gnus-list-identifiers))
3092 (inhibit-read-only t))
3096 (article-narrow-to-head)
3097 (goto-char (point-min))
3098 (while (re-search-forward
3099 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
3101 (delete-region (match-beginning 2) (match-end 0))
3102 (beginning-of-line))
3103 (when (re-search-forward
3104 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
3105 (delete-region (match-beginning 1) (match-end 1))))))))
3107 (defun article-hide-pem (&optional arg)
3108 "Toggle hiding of any PEM headers and signatures in the current article.
3109 If given a negative prefix, always show; if given a positive prefix,
3111 (interactive (gnus-article-hidden-arg))
3112 (unless (gnus-article-check-hidden-text 'pem arg)
3114 (let ((inhibit-read-only t) end)
3115 (goto-char (point-min))
3116 ;; Hide the horrendously ugly "header".
3117 (when (and (search-forward
3118 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
3120 (setq end (1+ (match-beginning 0))))
3121 (gnus-add-wash-type 'pem)
3122 (gnus-article-hide-text-type
3124 (if (search-forward "\n\n" nil t)
3128 ;; Hide the trailer as well
3129 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
3131 (gnus-article-hide-text-type
3132 (match-beginning 0) (match-end 0) 'pem)))))))
3134 (defun article-strip-banner ()
3135 "Strip the banners specified by the `banner' group parameter and by
3136 `gnus-article-address-banner-alist'."
3140 (let ((inhibit-point-motion-hooks t))
3141 (when (gnus-parameter-banner gnus-newsgroup-name)
3142 (article-really-strip-banner
3143 (gnus-parameter-banner gnus-newsgroup-name)))
3144 (when gnus-article-address-banner-alist
3145 ;; Note that the From header is decoded here, so it is
3146 ;; required that the *-extract-address-components function
3147 ;; supports non-ASCII text.
3148 (let ((from (save-restriction
3150 (article-narrow-to-head)
3151 (mail-fetch-field "from"))))
3154 (cadr (funcall gnus-extract-address-components
3157 (dolist (pair gnus-article-address-banner-alist)
3158 (when (string-match (car pair) from)
3160 (article-really-strip-banner (cdr pair)))))))))))))
3162 (defun article-really-strip-banner (banner)
3163 "Strip the banner specified by the argument."
3166 (let ((inhibit-point-motion-hooks t)
3167 (gnus-signature-limit nil)
3168 (inhibit-read-only t))
3171 ((eq banner 'signature)
3172 (when (gnus-article-narrow-to-signature)
3175 (delete-region (point) (point-max))))
3177 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
3178 (while (re-search-forward banner nil t)
3179 (delete-region (match-beginning 0) (match-end 0)))))
3181 (while (re-search-forward banner nil t)
3182 (delete-region (match-beginning 0) (match-end 0)))))))))
3184 (defun article-babel ()
3185 "Translate article using an online translation service."
3188 (gnus-with-article-buffer
3189 (when (article-goto-body)
3190 (let* ((start (point))
3192 (orig (buffer-substring start end))
3193 (trans (babel-as-string orig)))
3195 (narrow-to-region start end)
3196 (delete-region start end)
3199 (defun article-hide-signature (&optional arg)
3200 "Hide the signature in the current article.
3201 If given a negative prefix, always show; if given a positive prefix,
3203 (interactive (gnus-article-hidden-arg))
3204 (unless (gnus-article-check-hidden-text 'signature arg)
3207 (let ((inhibit-read-only t))
3208 (when (gnus-article-narrow-to-signature)
3209 (gnus-article-hide-text-type
3210 (point-min) (point-max) 'signature))))))
3211 (gnus-set-mode-line 'article))
3213 (defun article-strip-headers-in-body ()
3214 "Strip offensive headers from bodies."
3218 (let ((case-fold-search t))
3219 (when (looking-at "x-no-archive:")
3220 (gnus-delete-line)))))
3222 (defun article-strip-leading-blank-lines ()
3223 "Remove all blank lines from the beginning of the article."
3226 (let ((inhibit-point-motion-hooks t)
3227 (inhibit-read-only t))
3228 (when (article-goto-body)
3229 (while (and (not (eobp))
3230 (looking-at "[ \t]*$"))
3231 (gnus-delete-line))))))
3233 (defun article-narrow-to-head ()
3234 "Narrow the buffer to the head of the message.
3235 Point is left at the beginning of the narrowed-to region."
3237 (goto-char (point-min))
3238 (if (search-forward "\n\n" nil 1)
3241 (goto-char (point-min)))
3243 (defun article-goto-body ()
3244 "Place point at the start of the body."
3245 (goto-char (point-min))
3247 ;; This variable is only bound when dealing with separate
3249 (article-goto-body-goes-to-point-min-p
3251 ((search-forward "\n\n" nil t)
3254 (goto-char (point-max))
3257 (defun article-strip-multiple-blank-lines ()
3258 "Replace consecutive blank lines with one empty line."
3261 (let ((inhibit-point-motion-hooks t)
3262 (inhibit-read-only t))
3263 ;; First make all blank lines empty.
3265 (while (re-search-forward "^[ \t]+$" nil t)
3266 (unless (gnus-annotation-in-region-p
3267 (match-beginning 0) (match-end 0))
3268 (replace-match "" nil t)))
3269 ;; Then replace multiple empty lines with a single empty line.
3271 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
3272 (unless (gnus-annotation-in-region-p
3273 (match-beginning 0) (match-end 0))
3274 (delete-region (match-beginning 1) (match-end 1)))))))
3276 (defun article-strip-leading-space ()
3277 "Remove all white space from the beginning of the lines in the article."
3280 (let ((inhibit-point-motion-hooks t)
3281 (inhibit-read-only t))
3283 (while (re-search-forward "^[ \t]+" nil t)
3284 (replace-match "" t t)))))
3286 (defun article-strip-trailing-space ()
3287 "Remove all white space from the end of the lines in the article."
3290 (let ((inhibit-point-motion-hooks t)
3291 (inhibit-read-only t))
3293 (while (re-search-forward "[ \t]+$" nil t)
3294 (replace-match "" t t)))))
3296 (defun article-strip-blank-lines ()
3297 "Strip leading, trailing and multiple blank lines."
3299 (article-strip-leading-blank-lines)
3300 (article-remove-trailing-blank-lines)
3301 (article-strip-multiple-blank-lines))
3303 (defun article-strip-all-blank-lines ()
3304 "Strip all blank lines."
3307 (let ((inhibit-point-motion-hooks t)
3308 (inhibit-read-only t))
3310 (while (re-search-forward "^[ \t]*\n" nil t)
3311 (replace-match "" t t)))))
3313 (defun gnus-article-narrow-to-signature ()
3314 "Narrow to the signature; return t if a signature is found, else nil."
3315 (let ((inhibit-point-motion-hooks t))
3316 (when (gnus-article-search-signature)
3318 ;; Check whether we have some limits to what we consider
3319 ;; to be a signature.
3320 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
3321 (list gnus-signature-limit)))
3323 (while (setq limit (pop limits))
3324 (if (or (and (integerp limit)
3325 (< (- (point-max) (point)) limit))
3327 (< (count-lines (point) (point-max)) limit))
3328 (and (functionp limit)
3330 (and (stringp limit)
3331 (not (re-search-forward limit nil t))))
3332 () ; This limit did not succeed.
3336 (narrow-to-region (point) (point-max))
3339 (defun gnus-article-search-signature ()
3340 "Search the current buffer for the signature separator.
3341 Put point at the beginning of the signature separator."
3342 (let ((cur (point)))
3343 (goto-char (point-max))
3344 (if (if (stringp gnus-signature-separator)
3345 (re-search-backward gnus-signature-separator nil t)
3346 (let ((seps gnus-signature-separator))
3348 (not (re-search-backward (car seps) nil t)))
3355 (defun gnus-article-hidden-arg ()
3356 "Return the current prefix arg as a number, or 0 if no prefix."
3357 (list (if current-prefix-arg
3358 (prefix-numeric-value current-prefix-arg)
3361 (defun gnus-article-check-hidden-text (type arg)
3362 "Return nil if hiding is necessary.
3363 Arg can be nil or a number. nil and positive means hide, negative
3364 means show, 0 means toggle."
3367 (let ((hide (gnus-article-hidden-text-p type)))
3373 (gnus-article-show-hidden-text type)
3376 (if (eq hide 'hidden)
3378 (gnus-article-show-hidden-text type)
3382 (defun gnus-article-hidden-text-p (type)
3383 "Say whether the current buffer contains hidden text of type TYPE."
3384 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
3386 (not (get-text-property pos 'invisible))
3387 (not (get-text-property pos 'dummy-invisible)))
3389 (text-property-any (1+ pos) (point-max) 'article-type type)))
3394 (defun gnus-article-show-hidden-text (type &optional dummy)
3395 "Show all hidden text of type TYPE.
3396 Originally it is hide instead of DUMMY."
3397 (let ((inhibit-read-only t)
3398 (inhibit-point-motion-hooks t))
3399 (gnus-remove-text-properties-when
3401 (point-min) (point-max)
3402 (cons 'article-type (cons type
3403 gnus-hidden-properties)))
3404 (gnus-delete-wash-type type)))
3406 (defconst article-time-units
3407 `((year . ,(* 365.25 24 60 60))
3408 (week . ,(* 7 24 60 60))
3409 (day . ,(* 24 60 60))
3413 "Mapping from time units to seconds.")
3415 (defun gnus-article-forward-header ()
3416 "Move point to the start of the next header.
3417 If the current header is a continuation header, this can be several
3422 (if (looking-at "[ \t]+[^ \t]")
3426 (defun article-date-ut (&optional type highlight)
3427 "Convert DATE date to universal time in the current article.
3428 If TYPE is `local', convert to local time; if it is `lapsed', output
3429 how much time has lapsed since DATE. For `lapsed', the value of
3430 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
3431 should replace the \"Date:\" one, or should be added below it."
3432 (interactive (list 'ut t))
3433 (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
3434 (date-regexp (cond ((not gnus-article-date-lapsed-new-header)
3438 (article-lapsed-timer
3442 (case-fold-search t)
3443 (inhibit-read-only t)
3444 (inhibit-point-motion-hooks t)
3445 pos date bface eface)
3449 (goto-char (point-min))
3450 (while (or (setq date (get-text-property (setq pos (point))
3452 (when (setq pos (next-single-property-change
3453 (point) 'original-date))
3454 (setq date (get-text-property pos 'original-date))
3457 pos (if (setq pos (text-property-any pos (point-max)
3458 'original-date nil))
3461 (if (or (bolp) (eobp))
3465 (goto-char (point-min))
3466 (when (re-search-forward tdate-regexp nil t)
3467 (setq bface (get-text-property (point-at-bol) 'face)
3468 eface (get-text-property (1- (point-at-eol)) 'face)))
3469 (goto-char (point-min))
3471 ;; Delete any old Date headers.
3472 (while (re-search-forward date-regexp nil t)
3474 (delete-region (point-at-bol) (progn
3475 (gnus-article-forward-header)
3477 (delete-region (point-at-bol) (progn
3478 (gnus-article-forward-header)
3481 (setq pos (point))))
3482 (when (and (not pos)
3483 (re-search-forward tdate-regexp nil t))
3485 (gnus-goto-char pos)
3486 (insert (article-make-date-line date (or type 'ut)))
3492 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
3493 (put-text-property (match-beginning 1) (1+ (match-end 1))
3495 (put-text-property (match-beginning 2) (match-end 2)
3497 (put-text-property (point-min) (1- (point-max)) 'original-date date)
3498 (goto-char (point-max))
3501 (defun article-make-date-line (date type)
3502 "Return a DATE line of TYPE."
3503 (unless (memq type '(local ut original user iso8601 lapsed english))
3504 (error "Unknown conversion type: %s" type))
3506 (let ((time (date-to-time date)))
3508 ;; Convert to the local timezone.
3510 (concat "Date: " (message-make-date time)))
3511 ;; Convert to Universal Time.
3516 (let* ((e (parse-time-string date))
3517 (tm (apply 'encode-time e))
3519 (ls (- (cadr tm) (car (current-time-zone time)))))
3520 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
3521 ((> ls 65535) (list (1+ ms) (- ls 65536)))
3525 ;; Get the original date from the article.
3526 ((eq type 'original)
3527 (concat "Date: " (if (string-match "\n+$" date)
3528 (substring date 0 (match-beginning 0))
3530 ;; Let the user define the format.
3532 (let ((format (or (condition-case nil
3533 (with-current-buffer gnus-summary-buffer
3534 gnus-article-time-format)
3536 gnus-article-time-format)))
3537 (if (functionp format)
3538 (funcall format time)
3539 (concat "Date: " (format-time-string format time)))))
3542 (let ((tz (car (current-time-zone time))))
3545 (format-time-string "%Y%m%dT%H%M%S" time)
3546 (format "%s%02d%02d"
3547 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3548 (/ (% (abs tz) 3600) 60)))))
3549 ;; Do an X-Sent lapsed format.
3551 ;; If the date is seriously mangled, the timezone functions are
3552 ;; liable to bug out, so we ignore all errors.
3553 (let* ((now (current-time))
3554 (real-time (subtract-time now time))
3555 (real-sec (and real-time
3556 (+ (* (float (car real-time)) 65536)
3558 (sec (and real-time (abs real-sec)))
3568 ;; This is a bit convoluted, but basically we go
3569 ;; through the time units for years, weeks, etc,
3570 ;; and divide things to see whether that results
3571 ;; in positive answers.
3574 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3575 ;; The (remaining) seconds are too few to
3576 ;; be divided into this time unit.
3578 ;; It's big enough, so we output it.
3579 (setq sec (- sec (* num (cdr unit))))
3581 (concat (if prev ", " "") (int-to-string
3583 " " (symbol-name (car unit))
3584 (if (> num 1) "s" ""))
3586 article-time-units "")
3587 ;; If dates are odd, then it might appear like the
3588 ;; article was sent in the future.
3591 " in the future"))))))
3592 ;; Display the date in proper English
3594 (let ((dtime (decode-time time)))
3597 (number-to-string (nth 3 dtime))
3598 (let ((digit (% (nth 3 dtime) 10)))
3600 ((memq (nth 3 dtime) '(11 12 13)) "th")
3606 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3608 (number-to-string (nth 5 dtime))
3610 (format "%02d" (nth 2 dtime))
3612 (format "%02d" (nth 1 dtime)))))))
3614 (format "Date: %s (from Gnus)" date))))
3616 (defun article-date-local (&optional highlight)
3617 "Convert the current article date to the local timezone."
3618 (interactive (list t))
3619 (article-date-ut 'local highlight))
3621 (defun article-date-english (&optional highlight)
3622 "Convert the current article date to something that is proper English."
3623 (interactive (list t))
3624 (article-date-ut 'english highlight))
3626 (defun article-date-original (&optional highlight)
3627 "Convert the current article date to what it was originally.
3628 This is only useful if you have used some other date conversion
3629 function and want to see what the date was before converting."
3630 (interactive (list t))
3631 (article-date-ut 'original highlight))
3633 (defun article-date-lapsed (&optional highlight)
3634 "Convert the current article date to time lapsed since it was sent."
3635 (interactive (list t))
3636 (article-date-ut 'lapsed highlight))
3638 (defun article-update-date-lapsed ()
3639 "Function to be run from a timer to update the lapsed time line."
3641 (let (deactivate-mark)
3646 (set-buffer (window-buffer w))
3647 (when (eq major-mode 'gnus-article-mode)
3648 (let ((mark (point-marker)))
3649 (goto-char (point-min))
3650 (when (re-search-forward "^X-Sent:" nil t)
3651 (article-date-lapsed t))
3652 (goto-char (marker-position mark))
3653 (move-marker mark nil))))
3656 (defun gnus-start-date-timer (&optional n)
3657 "Start a timer to update the X-Sent header in the article buffers.
3658 The numerical prefix says how frequently (in seconds) the function
3663 (gnus-stop-date-timer)
3664 (setq article-lapsed-timer
3665 (run-at-time 1 n 'article-update-date-lapsed)))
3667 (defun gnus-stop-date-timer ()
3668 "Stop the X-Sent timer."
3670 (when article-lapsed-timer
3671 (nnheader-cancel-timer article-lapsed-timer)
3672 (setq article-lapsed-timer nil)))
3674 (defun article-date-user (&optional highlight)
3675 "Convert the current article date to the user-defined format.
3676 This format is defined by the `gnus-article-time-format' variable."
3677 (interactive (list t))
3678 (article-date-ut 'user highlight))
3680 (defun article-date-iso8601 (&optional highlight)
3681 "Convert the current article date to ISO8601."
3682 (interactive (list t))
3683 (article-date-ut 'iso8601 highlight))
3685 (defmacro gnus-article-save-original-date (&rest forms)
3686 "Save the original date as a text property and evaluate FORMS."
3687 `(let* ((case-fold-search t)
3689 (goto-char (point-min))
3690 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3693 (date (when (and start
3694 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3696 (buffer-substring-no-properties start
3697 (match-beginning 0)))))
3698 (goto-char (point-max))
3699 (skip-chars-backward "\n")
3700 (put-text-property (point-min) (point) 'original-date date)
3702 (goto-char (point-max))
3703 (skip-chars-backward "\n")
3704 (put-text-property (point-min) (point) 'original-date date)))
3706 ;; (defun article-show-all ()
3707 ;; "Show all hidden text in the article buffer."
3710 ;; (let ((inhibit-read-only t))
3711 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3713 (defun article-remove-leading-whitespace ()
3714 "Remove excessive whitespace from all headers."
3718 (let ((inhibit-read-only t))
3719 (article-narrow-to-head)
3720 (goto-char (point-min))
3721 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3722 (delete-region (match-beginning 1) (match-end 1)))))))
3724 (defun article-emphasize (&optional arg)
3725 "Emphasize text according to `gnus-emphasis-alist'."
3726 (interactive (gnus-article-hidden-arg))
3727 (unless (gnus-article-check-hidden-text 'emphasis arg)
3731 (with-current-buffer gnus-summary-buffer
3732 gnus-article-emphasis-alist)
3734 gnus-emphasis-alist))
3735 (inhibit-read-only t)
3736 (props (append '(article-type emphasis)
3737 gnus-hidden-properties))
3738 regexp elem beg invisible visible face)
3741 (while (setq elem (pop alist))
3743 (setq regexp (car elem)
3744 invisible (nth 1 elem)
3745 visible (nth 2 elem)
3747 (while (re-search-forward regexp nil t)
3748 (when (and (match-beginning visible) (match-beginning invisible))
3749 (gnus-article-hide-text
3750 (match-beginning invisible) (match-end invisible) props)
3751 (gnus-article-unhide-text-type
3752 (match-beginning visible) (match-end visible) 'emphasis)
3753 (gnus-put-overlay-excluding-newlines
3754 (match-beginning visible) (match-end visible) 'face face)
3755 (gnus-add-wash-type 'emphasis)
3756 (goto-char (match-end invisible)))))))))
3758 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3759 "Setup newsgroup emphasis alist."
3760 (unless gnus-article-emphasis-alist
3761 (let ((name (and gnus-newsgroup-name
3762 (gnus-group-real-name gnus-newsgroup-name))))
3763 (make-local-variable 'gnus-article-emphasis-alist)
3764 (setq gnus-article-emphasis-alist
3766 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3767 (while (setq elem (pop alist))
3768 (when (and name (string-match (car elem) name))
3770 highlight (copy-sequence (cdr elem)))))
3772 (copy-sequence highlight-words)
3773 (if gnus-newsgroup-name
3774 (copy-sequence (gnus-group-find-parameter
3775 gnus-newsgroup-name 'highlight-words t)))
3776 gnus-emphasis-alist)))))
3778 (defvar gnus-summary-article-menu)
3779 (defvar gnus-summary-post-menu)
3781 ;;; Saving functions.
3783 (defun gnus-article-save (save-buffer file &optional num)
3784 "Save the currently selected article."
3785 (when (or (get gnus-default-article-saver :headers)
3786 (not gnus-save-all-headers))
3787 ;; Remove headers according to `gnus-saved-headers' or the value
3788 ;; of the `:headers' property that the saver function might have.
3789 (let ((gnus-visible-headers
3790 (or (symbol-value (get gnus-default-article-saver :headers))
3791 gnus-saved-headers gnus-visible-headers))
3792 ;; Ignore group parameter. See `article-hide-headers'.
3793 (gnus-summary-buffer nil))
3794 (with-current-buffer save-buffer
3795 (article-hide-headers 1 t))))
3796 (save-window-excursion
3797 (if (not gnus-default-article-saver)
3798 (error "No default saver is defined")
3799 ;; !!! Magic! The saving functions all save
3800 ;; `gnus-save-article-buffer' (or so they think), but we
3801 ;; bind that variable to our save-buffer.
3802 (set-buffer gnus-article-buffer)
3803 (let* ((gnus-save-article-buffer save-buffer)
3806 ((not gnus-prompt-before-saving) 'default)
3807 ((eq gnus-prompt-before-saving 'always) nil)
3809 (gnus-number-of-articles-to-be-saved
3810 (when (eq gnus-prompt-before-saving t)
3812 (set-buffer gnus-article-current-summary)
3813 (funcall gnus-default-article-saver filename)))))
3815 (defun gnus-read-save-file-name (prompt &optional filename
3816 function group headers variable
3819 (funcall function group headers (symbol-value variable)))
3824 ((eq filename 'default)
3830 (when (symbol-value dir-var)
3831 (setq default-name (expand-file-name
3832 (file-name-nondirectory default-name)
3833 (symbol-value dir-var))))
3834 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3837 (if (and gnus-number-of-articles-to-be-saved
3838 (> gnus-number-of-articles-to-be-saved 1))
3839 (format "these %d articles"
3840 gnus-number-of-articles-to-be-saved)
3843 ;; Let the split methods have their say.
3845 ;; No split name was found.
3848 (concat prompt " (default "
3849 (file-name-nondirectory default-name) "): ")
3850 (file-name-directory default-name)
3852 ;; A single group name is returned.
3853 ((stringp split-name)
3855 (funcall function split-name headers
3856 (symbol-value variable)))
3858 (concat prompt " (default "
3859 (file-name-nondirectory default-name) "): ")
3860 (file-name-directory default-name)
3862 ;; A single split name was found
3863 ((= 1 (length split-name))
3864 (let* ((name (expand-file-name
3866 gnus-article-save-directory))
3867 (dir (cond ((file-directory-p name)
3868 (file-name-as-directory name))
3869 ((file-exists-p name) name)
3870 (t gnus-article-save-directory))))
3872 (concat prompt " (default " name "): ")
3874 ;; A list of splits was found.
3876 (setq split-name (nreverse split-name))
3878 (let ((file-name-history
3879 (nconc split-name file-name-history)))
3883 (concat prompt " (`M-p' for defaults): ")
3884 gnus-article-save-directory
3886 gnus-article-save-directory)))
3887 (car (push result file-name-history)))))))
3888 ;; Create the directory.
3889 (gnus-make-directory (file-name-directory file))
3890 ;; If we have read a directory, we append the default file name.
3891 (when (file-directory-p file)
3892 (setq file (expand-file-name (file-name-nondirectory
3894 (file-name-as-directory file))))
3895 ;; Possibly translate some characters.
3896 (nnheader-translate-file-chars file))))))
3897 (gnus-make-directory (file-name-directory result))
3899 (set variable result))
3901 (set dir-var (file-name-directory result)))
3904 (defun gnus-article-archive-name (group)
3905 "Return the first instance of an \"Archive-name\" in the current buffer."
3906 (let ((case-fold-search t))
3907 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3908 (nnheader-concat gnus-article-save-directory
3909 (match-string 1)))))
3911 (defun gnus-article-nndoc-name (group)
3912 "If GROUP is an nndoc group, return the name of the parent group."
3913 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3914 (gnus-group-get-parameter group 'save-article-group)))
3916 (defun gnus-summary-save-in-rmail (&optional filename)
3917 "Append this article to Rmail file.
3918 Optional argument FILENAME specifies file name.
3919 Directory to save to is default to `gnus-article-save-directory'."
3920 (setq filename (gnus-read-save-file-name
3921 "Save %s in rmail file" filename
3922 gnus-rmail-save-name gnus-newsgroup-name
3923 gnus-current-headers 'gnus-newsgroup-last-rmail))
3924 (with-current-buffer gnus-save-article-buffer
3928 ;; Note that unlike gnus-summary-save-in-mail, there is no
3929 ;; check to see if filename is Babyl. Rmail in Emacs 23 does
3931 (gnus-output-to-rmail filename))))
3934 (defun gnus-summary-save-in-mail (&optional filename)
3935 "Append this article to Unix mail file.
3936 Optional argument FILENAME specifies file name.
3937 Directory to save to is default to `gnus-article-save-directory'."
3938 (setq filename (gnus-read-save-file-name
3939 "Save %s in Unix mail file" filename
3940 gnus-mail-save-name gnus-newsgroup-name
3941 gnus-current-headers 'gnus-newsgroup-last-mail))
3942 (with-current-buffer gnus-save-article-buffer
3946 (if (and (file-readable-p filename)
3947 (file-regular-p filename)
3948 (mail-file-babyl-p filename))
3949 (gnus-output-to-rmail filename)
3950 (gnus-output-to-mail filename)))))
3953 (put 'gnus-summary-save-in-file :decode t)
3954 (put 'gnus-summary-save-in-file :headers 'gnus-saved-headers)
3955 (defun gnus-summary-save-in-file (&optional filename overwrite)
3956 "Append this article to file.
3957 Optional argument FILENAME specifies file name.
3958 Directory to save to is default to `gnus-article-save-directory'."
3959 (setq filename (gnus-read-save-file-name
3960 "Save %s in file" filename
3961 gnus-file-save-name gnus-newsgroup-name
3962 gnus-current-headers 'gnus-newsgroup-last-file))
3963 (with-current-buffer gnus-save-article-buffer
3967 (when (and overwrite
3968 (file-exists-p filename))
3969 (delete-file filename))
3970 (gnus-output-to-file filename))))
3973 (put 'gnus-summary-write-to-file :decode t)
3974 (put 'gnus-summary-write-to-file :function 'gnus-summary-save-in-file)
3975 (put 'gnus-summary-write-to-file :headers 'gnus-saved-headers)
3976 (defun gnus-summary-write-to-file (&optional filename)
3977 "Write this article to a file, overwriting it if the file exists.
3978 Optional argument FILENAME specifies file name.
3979 The directory to save in defaults to `gnus-article-save-directory'."
3980 (setq filename (gnus-read-save-file-name
3981 "Save %s in file" filename
3982 gnus-file-save-name gnus-newsgroup-name
3983 gnus-current-headers nil 'gnus-newsgroup-last-directory))
3984 (gnus-summary-save-in-file filename t))
3986 (put 'gnus-summary-save-body-in-file :decode t)
3987 (defun gnus-summary-save-body-in-file (&optional filename overwrite)
3988 "Append this article body to a file.
3989 Optional argument FILENAME specifies file name.
3990 The directory to save in defaults to `gnus-article-save-directory'."
3991 (setq filename (gnus-read-save-file-name
3992 "Save %s body in file" filename
3993 gnus-file-save-name gnus-newsgroup-name
3994 gnus-current-headers 'gnus-newsgroup-last-file))
3995 (with-current-buffer gnus-save-article-buffer
3999 (when (article-goto-body)
4000 (narrow-to-region (point) (point-max)))
4001 (when (and overwrite
4002 (file-exists-p filename))
4003 (delete-file filename))
4004 (gnus-output-to-file filename))))
4007 (put 'gnus-summary-write-body-to-file :decode t)
4008 (put 'gnus-summary-write-body-to-file
4009 :function 'gnus-summary-save-body-in-file)
4010 (defun gnus-summary-write-body-to-file (&optional filename)
4011 "Write this article body to a file, overwriting it if the file exists.
4012 Optional argument FILENAME specifies file name.
4013 The directory to save in defaults to `gnus-article-save-directory'."
4014 (setq filename (gnus-read-save-file-name
4015 "Save %s body in file" filename
4016 gnus-file-save-name gnus-newsgroup-name
4017 gnus-current-headers nil 'gnus-newsgroup-last-directory))
4018 (gnus-summary-save-body-in-file filename t))
4020 (put 'gnus-summary-save-in-pipe :decode t)
4021 (put 'gnus-summary-save-in-pipe :headers 'gnus-saved-headers)
4022 (defun gnus-summary-save-in-pipe (&optional command raw)
4023 "Pipe this article to subprocess COMMAND.
4024 Valid values for COMMAND include:
4026 The executable command name and possibly arguments.
4028 You will be prompted for the command in the minibuffer.
4029 the symbol `default'
4030 It will be replaced with the command which the variable
4031 `gnus-summary-pipe-output-default-command' holds or the command
4032 last used for saving.
4033 Non-nil value for RAW overrides `:decode' and `:headers' properties
4034 and the raw article including all headers will be piped."
4035 (let ((article (gnus-summary-article-number))
4037 (get 'gnus-summary-save-in-pipe :decode)))
4038 save-buffer default)
4040 (if (vectorp (gnus-summary-article-header article))
4041 (save-current-buffer
4042 (gnus-summary-select-article decode decode nil article)
4043 (insert-buffer-substring
4047 gnus-original-article-buffer)
4049 (nnheader-set-temp-buffer " *Gnus Save*"))))
4050 ;; Remove unwanted headers.
4051 (when (and (not raw)
4052 (or (get 'gnus-summary-save-in-pipe :headers)
4053 (not gnus-save-all-headers)))
4054 (let ((gnus-visible-headers
4055 (or (symbol-value (get 'gnus-summary-save-in-pipe
4057 gnus-saved-headers gnus-visible-headers))
4058 (gnus-summary-buffer nil))
4059 (article-hide-headers 1 t))))
4060 (error "%d is not a real article" article))
4061 (error "No article to pipe"))
4062 (setq default (or gnus-summary-pipe-output-default-command
4063 gnus-last-shell-command))
4064 (unless (stringp command)
4066 (if (and (eq command 'default) default)
4068 (gnus-read-shell-command "Shell command on this article: "
4070 (when (string-equal command "")
4072 (setq command default)
4073 (error "A command is required")))
4074 (with-current-buffer save-buffer
4077 (shell-command-on-region (point-min) (point-max) command nil)))
4078 (gnus-kill-buffer save-buffer))
4079 (setq gnus-summary-pipe-output-default-command command))
4081 (defun gnus-summary-pipe-to-muttprint (&optional command)
4082 "Pipe this article to muttprint."
4083 (unless (stringp command)
4084 (setq command (read-string
4085 "Print using command: " gnus-summary-muttprint-program
4086 nil gnus-summary-muttprint-program)))
4087 (let ((gnus-summary-pipe-output-default-command
4088 gnus-summary-pipe-output-default-command))
4089 (gnus-summary-save-in-pipe command))
4090 (setq gnus-summary-muttprint-program command))
4092 ;;; Article file names when saving.
4094 (defun gnus-capitalize-newsgroup (newsgroup)
4095 "Capitalize NEWSGROUP name."
4096 (when (not (zerop (length newsgroup)))
4097 (concat (char-to-string (upcase (aref newsgroup 0)))
4098 (substring newsgroup 1))))
4100 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
4101 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4102 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
4103 Otherwise, it is like ~/News/news/group/num."
4106 (concat (if (gnus-use-long-file-name 'not-save)
4107 (gnus-capitalize-newsgroup newsgroup)
4108 (gnus-newsgroup-directory-form newsgroup))
4109 "/" (int-to-string (mail-header-number headers)))
4110 gnus-article-save-directory)))
4112 (string-equal (file-name-directory default)
4113 (file-name-directory last-file))
4114 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
4116 (or last-file default))))
4118 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
4119 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4120 If variable `gnus-use-long-file-name' is non-nil, it is
4121 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
4124 (concat (if (gnus-use-long-file-name 'not-save)
4126 (gnus-newsgroup-directory-form newsgroup))
4127 "/" (int-to-string (mail-header-number headers)))
4128 gnus-article-save-directory)))
4130 (string-equal (file-name-directory default)
4131 (file-name-directory last-file))
4132 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
4134 (or last-file default))))
4136 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
4137 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4138 If variable `gnus-use-long-file-name' is non-nil, it is
4139 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
4142 (if (gnus-use-long-file-name 'not-save)
4145 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
4147 gnus-article-save-directory)))
4149 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
4150 "Generate file name from sender."
4151 (let ((from (mail-header-from headers)))
4153 (if (and from (string-match "\\([^ <]+\\)@" from))
4154 (match-string 1 from)
4156 gnus-article-save-directory)))
4158 (defun article-verify-x-pgp-sig ()
4160 ;; <ftp://ftp.isc.org/pub/pgpcontrol/FORMAT>
4162 (if (gnus-buffer-live-p gnus-original-article-buffer)
4163 (let ((sig (with-current-buffer gnus-original-article-buffer
4164 (gnus-fetch-field "X-PGP-Sig")))
4168 (mml2015-clear-verify-function))
4170 (insert-buffer-substring gnus-original-article-buffer)
4171 (setq items (split-string sig))
4172 (message-narrow-to-head)
4173 (let ((inhibit-point-motion-hooks t)
4174 (case-fold-search t))
4175 ;; Don't verify multiple headers.
4176 (setq headers (mapconcat (lambda (header)
4178 (mail-fetch-field header)
4180 (split-string (nth 1 items) ",") "")))
4181 (delete-region (point-min) (point-max))
4182 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
4183 (insert "X-Signed-Headers: " (nth 1 items) "\n")
4188 (if (looking-at "^-")
4191 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
4192 (insert "Version: " (car items) "\n\n")
4193 (insert (mapconcat 'identity (cddr items) "\n"))
4194 (insert "\n-----END PGP SIGNATURE-----\n")
4195 (let ((mm-security-handle (list (format "multipart/signed"))))
4196 (mml2015-clean-buffer)
4197 (let ((coding-system-for-write (or gnus-newsgroup-charset
4199 (funcall (mml2015-clear-verify-function)))
4201 (or (mm-handle-multipart-ctl-parameter
4202 mm-security-handle 'gnus-details)
4203 (mm-handle-multipart-ctl-parameter
4204 mm-security-handle 'gnus-info)))))
4206 (let ((inhibit-read-only t) bface eface)
4208 (message-narrow-to-head)
4209 (goto-char (point-max))
4211 (setq bface (get-text-property (point-at-bol) 'face)
4212 eface (get-text-property (1- (point-at-eol)) 'face))
4213 (message-remove-header "X-Gnus-PGP-Verify")
4214 (if (re-search-forward "^X-PGP-Sig:" nil t)
4216 (goto-char (point-max)))
4217 (narrow-to-region (point) (point))
4218 (insert "X-Gnus-PGP-Verify: " info "\n")
4219 (goto-char (point-min))
4222 (if (not (looking-at "^[ \t]"))
4226 (goto-char (point-min))
4227 (when (looking-at "\\([^:]+\\): *")
4228 (put-text-property (match-beginning 1) (1+ (match-end 1))
4230 (put-text-property (match-end 0) (point-max)
4231 'face eface)))))))))
4233 (autoload 'canlock-verify "canlock" nil t) ;; for XEmacs.
4235 (defun article-verify-cancel-lock ()
4236 "Verify Cancel-Lock header."
4238 (if (gnus-buffer-live-p gnus-original-article-buffer)
4239 (canlock-verify gnus-original-article-buffer)))
4246 (setq afunc (car func)
4249 gfunc (intern (format "gnus-%s" func))))
4251 (when (fboundp afunc)
4252 `(lambda (&optional interactive &rest args)
4253 ,(documentation afunc t)
4254 (interactive (list t))
4255 (with-current-buffer gnus-article-buffer
4257 (call-interactively ',afunc)
4258 (apply ',afunc args))))))))
4259 '(article-hide-headers
4260 article-verify-x-pgp-sig
4261 article-verify-cancel-lock
4262 article-hide-boring-headers
4263 article-treat-overstrike
4264 article-treat-ansi-sequences
4265 article-fill-long-lines
4266 article-capitalize-sentences
4268 article-remove-leading-whitespace
4269 article-display-x-face
4270 article-display-face
4271 article-de-quoted-unreadable
4272 article-de-base64-unreadable
4275 article-unsplit-urls
4276 article-hide-list-identifiers
4277 article-strip-banner
4280 article-hide-signature
4281 article-strip-headers-in-body
4282 article-remove-trailing-blank-lines
4283 article-strip-leading-blank-lines
4284 article-strip-multiple-blank-lines
4285 article-strip-leading-space
4286 article-strip-trailing-space
4287 article-strip-blank-lines
4288 article-strip-all-blank-lines
4290 article-date-english
4291 article-date-iso8601
4292 article-date-original
4294 article-decode-mime-words
4295 article-decode-charset
4296 article-decode-encoded-words
4300 article-treat-dumbquotes
4301 article-treat-non-ascii
4302 article-normalize-headers
4303 ;;(article-show-all . gnus-article-show-all-headers)
4307 ;;; Gnus article mode
4310 (put 'gnus-article-mode 'mode-class 'special)
4312 (set-keymap-parent gnus-article-mode-map widget-keymap)
4314 (gnus-define-keys gnus-article-mode-map
4315 " " gnus-article-goto-next-page
4316 "\177" gnus-article-goto-prev-page
4317 [delete] gnus-article-goto-prev-page
4318 [backspace] gnus-article-goto-prev-page
4319 "\C-c^" gnus-article-refer-article
4320 "h" gnus-article-show-summary
4321 "s" gnus-article-show-summary
4322 "\C-c\C-m" gnus-article-mail
4323 "?" gnus-article-describe-briefly