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)
49 (autoload 'gnus-msg-mail "gnus-msg" nil t)
50 (autoload 'gnus-button-mailto "gnus-msg")
51 (autoload 'gnus-button-reply "gnus-msg" nil t)
52 (autoload 'parse-time-string "parse-time" nil nil)
53 (autoload 'ansi-color-apply-on-region "ansi-color")
54 (autoload 'mm-url-insert-file-contents-external "mm-url")
55 (autoload 'mm-extern-cache-contents "mm-extern")
57 (defgroup gnus-article nil
59 :link '(custom-manual "(gnus)Article Buffer")
62 (defgroup gnus-article-treat nil
63 "Treating article parts."
64 :link '(custom-manual "(gnus)Article Hiding")
67 (defgroup gnus-article-hiding nil
68 "Hiding article parts."
69 :link '(custom-manual "(gnus)Article Hiding")
72 (defgroup gnus-article-highlight nil
73 "Article highlighting."
74 :link '(custom-manual "(gnus)Article Highlighting")
78 (defgroup gnus-article-signature nil
80 :link '(custom-manual "(gnus)Article Signature")
83 (defgroup gnus-article-headers nil
85 :link '(custom-manual "(gnus)Hiding Headers")
88 (defgroup gnus-article-washing nil
89 "Special commands on articles."
90 :link '(custom-manual "(gnus)Article Washing")
93 (defgroup gnus-article-emphasis nil
94 "Fontisizing articles."
95 :link '(custom-manual "(gnus)Article Fontisizing")
98 (defgroup gnus-article-saving nil
100 :link '(custom-manual "(gnus)Saving Articles")
101 :group 'gnus-article)
103 (defgroup gnus-article-mime nil
104 "Worshiping the MIME wonder."
105 :link '(custom-manual "(gnus)Using MIME")
106 :group 'gnus-article)
108 (defgroup gnus-article-buttons nil
109 "Pushable buttons in the article buffer."
110 :link '(custom-manual "(gnus)Article Buttons")
111 :group 'gnus-article)
113 (defgroup gnus-article-various nil
114 "Other article options."
115 :link '(custom-manual "(gnus)Misc Article")
116 :group 'gnus-article)
118 (defcustom gnus-ignored-headers
121 (concat "^" header ":"))
122 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
123 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
124 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
125 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
126 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
127 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
128 "X-Attribution" "X-Originating-IP" "Delivered-To"
129 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
130 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
131 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
132 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
133 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
134 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
135 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
136 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
137 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
138 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
139 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
140 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
141 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
142 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
143 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
144 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
145 "List-[A-Za-z]+" "X-Listprocessor-Version"
146 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
147 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
148 "X-Received" "Content-length" "X-precedence"
149 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
150 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
151 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
152 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
153 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
154 "X-Content-length" "X-Posting-Agent" "Original-Received"
155 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
156 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
157 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
158 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
159 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"
160 "Envelope-To" "X-Spam-Score" "System-Type" "X-Injected-Via-Gmane"
161 "X-Gmane-NNTP-Posting-Host" "Jabber-ID" "Archived-At"
162 "Envelope-Sender" "Envelope-Recipients"))
163 "*All headers that start with this regexp will be hidden.
164 This variable can also be a list of regexps of headers to be ignored.
165 If `gnus-visible-headers' is non-nil, this variable will be ignored."
166 :type '(choice :custom-show nil
169 :group 'gnus-article-hiding)
171 (defcustom gnus-visible-headers
172 "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^[BGF]?Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Mail-Followup-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:"
173 "*All headers that do not match this regexp will be hidden.
174 This variable can also be a list of regexp of headers to remain visible.
175 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
177 (repeat :value-to-internal (lambda (widget value)
178 (custom-split-regexp-maybe value))
179 :match (lambda (widget value)
181 (widget-editable-list-match widget value)))
183 (const :tag "Use gnus-ignored-headers" nil)
185 :group 'gnus-article-hiding)
187 (defcustom gnus-sorted-header-list
188 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
189 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
190 "*This variable is a list of regular expressions.
191 If it is non-nil, headers that match the regular expressions will
192 be placed first in the article buffer in the sequence specified by
194 :type '(repeat regexp)
195 :group 'gnus-article-hiding)
197 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
198 "Headers that are only to be displayed if they have interesting data.
199 Possible values in this list are:
201 'empty Headers with no content.
202 'newsgroups Newsgroup identical to Gnus group.
203 'to-address To identical to To-address.
204 'to-list To identical to To-list.
205 'cc-list CC identical to To-list.
206 'followup-to Followup-to identical to Newsgroups.
207 'reply-to Reply-to identical to From.
208 'date Date less than four days old.
209 'long-to To and/or Cc longer than 1024 characters.
210 'many-to Multiple To and/or Cc."
211 :type '(set (const :tag "Headers with no content." empty)
212 (const :tag "Newsgroups identical to Gnus group." newsgroups)
213 (const :tag "To identical to To-address." to-address)
214 (const :tag "To identical to To-list." to-list)
215 (const :tag "CC identical to To-list." cc-list)
216 (const :tag "Followup-to identical to Newsgroups." followup-to)
217 (const :tag "Reply-to identical to From." reply-to)
218 (const :tag "Date less than four days old." date)
219 (const :tag "To and/or Cc longer than 1024 characters." long-to)
220 (const :tag "Multiple To and/or Cc headers." many-to))
221 :group 'gnus-article-hiding)
223 (defcustom gnus-article-skip-boring nil
224 "Skip over text that is not worth reading.
225 By default, if you set this t, then Gnus will display citations and
226 signatures, but will never scroll down to show you a page consisting
227 only of boring text. Boring text is controlled by
228 `gnus-article-boring-faces'."
231 :group 'gnus-article-hiding)
233 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
234 "Regexp matching signature separator.
235 This can also be a list of regexps. In that case, it will be checked
236 from head to tail looking for a separator. Searches will be done from
237 the end of the buffer."
238 :type '(choice :format "%{%t%}: %[Value Menu%]\n%v"
240 (repeat :tag "List of regexp" regexp))
241 :group 'gnus-article-signature)
243 (defcustom gnus-signature-limit nil
244 "Provide a limit to what is considered a signature.
245 If it is a number, no signature may not be longer (in characters) than
246 that number. If it is a floating point number, no signature may be
247 longer (in lines) than that number. If it is a function, the function
248 will be called without any parameters, and if it returns nil, there is
249 no signature in the buffer. If it is a string, it will be used as a
250 regexp. If it matches, the text in question is not a signature.
252 This can also be a list of the above values."
253 :type '(choice (const nil)
257 (regexp :value ".*"))
258 :group 'gnus-article-signature)
260 (defcustom gnus-hidden-properties '(invisible t intangible t)
261 "Property list to use for hiding text."
263 :group 'gnus-article-hiding)
265 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
266 ;; frames in a session.
267 (defcustom gnus-article-x-face-command
268 (if (featurep 'xemacs)
269 (if (or (gnus-image-type-available-p 'xface)
270 (gnus-image-type-available-p 'pbm))
271 'gnus-display-x-face-in-from
272 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
273 (if (gnus-image-type-available-p 'pbm)
274 'gnus-display-x-face-in-from
275 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
277 "*String or function to be executed to display an X-Face header.
278 If it is a string, the command will be executed in a sub-shell
279 asynchronously. The compressed face will be piped to this command."
280 :type `(choice string
281 (function-item gnus-display-x-face-in-from)
285 :group 'gnus-article-washing)
287 (defcustom gnus-article-x-face-too-ugly nil
288 "Regexp matching posters whose face shouldn't be shown automatically."
289 :type '(choice regexp (const nil))
290 :group 'gnus-article-washing)
292 (defcustom gnus-article-banner-alist nil
293 "Banner alist for stripping.
295 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
297 :type '(repeat (cons symbol regexp))
298 :group 'gnus-article-washing)
300 (gnus-define-group-parameter
303 "Alist of regexps (to match group names) and banner."
304 :variable-group gnus-article-washing
306 '(choice :tag "Banner"
308 (const :tag "Remove signature" signature)
309 (symbol :tag "Item in `gnus-article-banner-alist'" none)
311 (const :tag "None" nil))
313 "If non-nil, specify how to remove `banners' from articles.
315 Symbol `signature' means to remove signatures delimited by
316 `gnus-signature-separator'. Any other symbol is used to look up a
317 regular expression to match the banner in `gnus-article-banner-alist'.
318 A string is used as a regular expression to match the banner
321 (defcustom gnus-article-address-banner-alist nil
322 "Alist of mail addresses and banners.
323 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
324 to match a mail address in the From: header, BANNER is one of a symbol
325 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
326 If ADDRESS matches author's mail address, it will remove things like
327 advertisements. For example:
329 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
333 (regexp :tag "Address")
334 (choice :tag "Banner" :value nil
335 (const :tag "Remove signature" signature)
336 (symbol :tag "Item in `gnus-article-banner-alist'" none)
338 (const :tag "None" nil))))
340 :group 'gnus-article-washing)
342 (defmacro gnus-emphasis-custom-with-format (&rest body)
344 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
345 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
348 (defun gnus-emphasis-custom-value-to-external (value)
349 (gnus-emphasis-custom-with-format
350 (if (consp (car value))
351 (list (format format (car (car value)) (cdr (car value)))
353 (if (nth 1 value) 2 3)
357 (defun gnus-emphasis-custom-value-to-internal (value)
358 (gnus-emphasis-custom-with-format
359 (let ((regexp (concat "\\`"
360 (format (regexp-quote format)
361 "\\([^()]+\\)" "\\([^()]+\\)")
364 (if (string-match regexp (setq pattern (car value)))
365 (list (cons (match-string 1 pattern) (match-string 2 pattern))
370 (defcustom gnus-emphasis-alist
372 '(("\\*" "\\*" bold nil 2)
375 ("_/" "/_" underline-italic)
376 ("_\\*" "\\*_" underline-bold)
377 ("\\*/" "/\\*" bold-italic)
378 ("_\\*/" "/\\*_" underline-bold-italic))))
380 (gnus-emphasis-custom-with-format
381 (mapcar (lambda (spec)
382 (list (format format (car spec) (cadr spec))
385 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
387 '(;; I've never seen anyone use this strikethru convention whereas I've
388 ;; several times seen it triggered by normal text. --Stef
389 ;; Miles suggests that this form is sometimes used but for italics,
390 ;; so maybe we should map it to `italic'.
391 ;; ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
392 ;; 2 3 gnus-emphasis-strikethru)
393 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
394 2 3 gnus-emphasis-underline))))
395 "*Alist that says how to fontify certain phrases.
396 Each item looks like this:
398 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
400 The first element is a regular expression to be matched. The second
401 is a number that says what regular expression grouping used to find
402 the entire emphasized word. The third is a number that says what
403 regexp grouping should be displayed and highlighted. The fourth
404 is the face used for highlighting."
408 :format "%[Customizing Style%]\n%v"
410 (group :tag "Default"
411 :value ("" 0 0 default)
414 (let ((value (widget-get
415 (cadr (widget-get (widget-get widget :parent)
418 (if (not (eq (nth 2 value) 'default))
422 (gnus-emphasis-custom-value-to-external value))))
423 (widget-group-value-create widget))
425 (integer :format "Match group: %v")
426 (integer :format "Emphasize group: %v")
429 :value (("_" . "_") nil default)
431 (regexp :format "Start regexp: %v")
432 (regexp :format "End regexp: %v"))
433 (boolean :format "Show start and end patterns: %[%v%]\n"
434 :on " On " :off " Off ")
436 :get (lambda (symbol)
437 (mapcar 'gnus-emphasis-custom-value-to-internal
438 (default-value symbol)))
439 :set (lambda (symbol value)
440 (set-default symbol (mapcar 'gnus-emphasis-custom-value-to-external
442 :group 'gnus-article-emphasis)
444 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
445 "A regexp to describe whitespace which should not be emphasized.
446 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
447 The former avoids underlining of leading and trailing whitespace,
448 and the latter avoids underlining any whitespace at all."
450 :group 'gnus-article-emphasis
453 (defface gnus-emphasis-bold '((t (:bold t)))
454 "Face used for displaying strong emphasized text (*word*)."
455 :group 'gnus-article-emphasis)
457 (defface gnus-emphasis-italic '((t (:italic t)))
458 "Face used for displaying italic emphasized text (/word/)."
459 :group 'gnus-article-emphasis)
461 (defface gnus-emphasis-underline '((t (:underline t)))
462 "Face used for displaying underlined emphasized text (_word_)."
463 :group 'gnus-article-emphasis)
465 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
466 "Face used for displaying underlined bold emphasized text (_*word*_)."
467 :group 'gnus-article-emphasis)
469 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
470 "Face used for displaying underlined italic emphasized text (_/word/_)."
471 :group 'gnus-article-emphasis)
473 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
474 "Face used for displaying bold italic emphasized text (/*word*/)."
475 :group 'gnus-article-emphasis)
477 (defface gnus-emphasis-underline-bold-italic
478 '((t (:bold t :italic t :underline t)))
479 "Face used for displaying underlined bold italic emphasized text.
480 Example: (_/*word*/_)."
481 :group 'gnus-article-emphasis)
483 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
484 '((t (:strikethru t)))
485 '((t (:strike-through t))))
486 "Face used for displaying strike-through text (-word-)."
487 :group 'gnus-article-emphasis)
489 (defface gnus-emphasis-highlight-words
490 '((t (:background "black" :foreground "yellow")))
491 "Face used for displaying highlighted words."
492 :group 'gnus-article-emphasis)
494 (defcustom gnus-article-time-format "%a, %d %b %Y %T %Z"
495 "Format for display of Date headers in article bodies.
496 See `format-time-string' for the possible values.
498 The variable can also be function, which should return a complete Date
499 header. The function is called with one argument, the time, which can
500 be fed to `format-time-string'."
501 :type '(choice string function)
502 :link '(custom-manual "(gnus)Article Date")
503 :group 'gnus-article-washing)
505 (defcustom gnus-save-all-headers t
506 "*If non-nil, don't remove any headers before saving.
507 This will be overridden by the `:headers' property that the symbol of
508 the saver function, which is specified by `gnus-default-article-saver',
510 :group 'gnus-article-saving
513 (defcustom gnus-prompt-before-saving 'always
514 "*This variable says how much prompting is to be done when saving articles.
515 If it is nil, no prompting will be done, and the articles will be
516 saved to the default files. If this variable is `always', each and
517 every article that is saved will be preceded by a prompt, even when
518 saving large batches of articles. If this variable is neither nil not
519 `always', there the user will be prompted once for a file name for
520 each invocation of the saving commands."
521 :group 'gnus-article-saving
522 :type '(choice (item always)
523 (item :tag "never" nil)
524 (sexp :tag "once" :format "%t\n" :value t)))
526 (defcustom gnus-saved-headers gnus-visible-headers
527 "Headers to keep if `gnus-save-all-headers' is nil.
528 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
529 If that variable is nil, however, all headers that match this regexp
530 will be kept while the rest will be deleted before saving. This and
531 `gnus-save-all-headers' will be overridden by the `:headers' property
532 that the symbol of the saver function, which is specified by
533 `gnus-default-article-saver', might have."
534 :group 'gnus-article-saving
537 ;; Note that "Rmail format" is mbox since Emacs 23, but Babyl before.
538 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
539 "A function to save articles in your favourite format.
540 The function will be called by way of the `gnus-summary-save-article'
541 command, and friends such as `gnus-summary-save-article-rmail'.
543 Gnus provides the following functions:
545 * gnus-summary-save-in-rmail (Rmail format)
546 * gnus-summary-save-in-mail (Unix mail format)
547 * gnus-summary-save-in-folder (MH folder)
548 * gnus-summary-save-in-file (article format)
549 * gnus-summary-save-body-in-file (article body)
550 * gnus-summary-save-in-vm (use VM's folder format)
551 * gnus-summary-write-to-file (article format -- overwrite)
552 * gnus-summary-write-body-to-file (article body -- overwrite)
553 * gnus-summary-save-in-pipe (article format)
555 The symbol of each function may have the following properties:
558 The value non-nil means save decoded articles. This is meaningful
559 only with `gnus-summary-save-in-file', `gnus-summary-save-body-in-file',
560 `gnus-summary-write-to-file', `gnus-summary-write-body-to-file', and
561 `gnus-summary-save-in-pipe'.
564 The value specifies an alternative function which appends, not
565 overwrites, articles to a file. This implies that when saving many
566 articles at a time, `gnus-prompt-before-saving' is bound to t and all
567 articles are saved in a single file. This is meaningful only with
568 `gnus-summary-write-to-file' and `gnus-summary-write-body-to-file'.
571 The value specifies the symbol of a variable of which the value
572 specifies headers to be saved. If it is omitted,
573 `gnus-save-all-headers' and `gnus-saved-headers' control what
574 headers should be saved."
575 :group 'gnus-article-saving
576 :type '(radio (function-item gnus-summary-save-in-rmail)
577 (function-item gnus-summary-save-in-mail)
578 (function-item gnus-summary-save-in-folder)
579 (function-item gnus-summary-save-in-file)
580 (function-item gnus-summary-save-body-in-file)
581 (function-item gnus-summary-save-in-vm)
582 (function-item gnus-summary-write-to-file)
583 (function-item gnus-summary-write-body-to-file)
584 (function-item gnus-summary-save-in-pipe)
587 (defcustom gnus-article-save-coding-system
588 (or (and (mm-coding-system-p 'utf-8) 'utf-8)
589 (and (mm-coding-system-p 'iso-2022-7bit) 'iso-2022-7bit)
590 (and (mm-coding-system-p 'emacs-mule) 'emacs-mule)
591 (and (mm-coding-system-p 'escape-quoted) 'escape-quoted))
592 "Coding system used to save decoded articles to a file.
594 The recommended coding systems are `utf-8', `iso-2022-7bit' and so on,
595 which can safely encode any characters in text. This is used by the
598 * gnus-summary-save-article-file
599 * gnus-summary-save-article-body-file
600 * gnus-summary-write-article-file
601 * gnus-summary-write-article-body-file
603 and the functions to which you may set `gnus-default-article-saver':
605 * gnus-summary-save-in-file
606 * gnus-summary-save-body-in-file
607 * gnus-summary-write-to-file
608 * gnus-summary-write-body-to-file
610 Those commands and functions save just text displayed in the article
611 buffer to a file if the value of this variable is non-nil. Note that
612 buttonized MIME parts will be lost in a saved file in that case.
613 Otherwise, raw articles will be saved."
614 :group 'gnus-article-saving
616 :format "%{%t%}:\n %[Value Menu%] %v"
617 (const :tag "Save raw articles" nil)
620 (lambda (arg) (if (mm-coding-system-p (nth 3 arg)) arg))
621 '((const :tag "UTF-8" utf-8)
622 (const :tag "iso-2022-7bit" iso-2022-7bit)
623 (const :tag "Emacs internal" emacs-mule)
624 (const :tag "escape-quoted" escape-quoted))))
625 (symbol :tag "Coding system")))
627 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
628 "A function generating a file name to save articles in Rmail format.
629 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
630 :group 'gnus-article-saving
633 (defcustom gnus-mail-save-name 'gnus-plain-save-name
634 "A function generating a file name to save articles in Unix mail format.
635 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
636 :group 'gnus-article-saving
639 (defcustom gnus-folder-save-name 'gnus-folder-save-name
640 "A function generating a file name to save articles in MH folder.
641 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
642 :group 'gnus-article-saving
645 (defcustom gnus-file-save-name 'gnus-numeric-save-name
646 "A function generating a file name to save articles in article format.
647 The function is called with NEWSGROUP, HEADERS, and optional
649 :group 'gnus-article-saving
652 (defcustom gnus-split-methods
653 '((gnus-article-archive-name)
654 (gnus-article-nndoc-name))
655 "*Variable used to suggest where articles are to be saved.
656 For instance, if you would like to save articles related to Gnus in
657 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
658 you could set this variable to something like:
660 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
661 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
663 This variable is an alist where the key is the match and the
664 value is a list of possible files to save in if the match is
667 If the match is a string, it is used as a regexp match on the
668 article. If the match is a symbol, that symbol will be funcalled
669 from the buffer of the article to be saved with the newsgroup as the
670 parameter. If it is a list, it will be evaled in the same buffer.
672 If this form or function returns a string, this string will be used as a
673 possible file name; and if it returns a non-nil list, that list will be
674 used as possible file names."
675 :group 'gnus-article-saving
676 :type '(repeat (choice (list :value (fun) function)
677 (cons :value ("" "") regexp (repeat string))
680 (defcustom gnus-page-delimiter "^\^L"
681 "*Regexp describing what to use as article page delimiters.
682 The default value is \"^\^L\", which is a form linefeed at the
683 beginning of a line."
685 :group 'gnus-article-various)
687 (defcustom gnus-article-mode-line-format "Gnus: %g %S%m"
688 "*The format specification for the article mode line.
689 See `gnus-summary-mode-line-format' for a closer description.
691 The following additional specs are available:
693 %w The article washing status.
694 %m The number of MIME parts in the article."
697 :group 'gnus-article-various)
699 (defcustom gnus-article-mode-hook nil
700 "*A hook for Gnus article mode."
702 :group 'gnus-article-various)
704 (when (featurep 'xemacs)
705 ;; Extracted from gnus-xmas-define in order to preserve user settings
706 (when (fboundp 'turn-off-scroll-in-place)
707 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
708 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
709 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
711 (defcustom gnus-article-menu-hook nil
712 "*Hook run after the creation of the article mode menu."
714 :group 'gnus-article-various)
716 (defcustom gnus-article-prepare-hook nil
717 "*A hook called after an article has been prepared in the article buffer."
719 :group 'gnus-article-various)
721 (defcustom gnus-copy-article-ignored-headers nil
722 "List of headers to be removed when copying an article.
723 Each element is a regular expression."
724 :version "23.1" ;; No Gnus
725 :type '(repeat regexp)
726 :group 'gnus-article-various)
728 (make-obsolete-variable 'gnus-article-hide-pgp-hook nil
729 "Gnus 5.10 (Emacs 22.1)")
732 '((t (:weight bold)))
733 "Face used for highlighting a button in the article buffer."
734 :group 'gnus-article-buttons)
736 (defcustom gnus-article-button-face 'gnus-button
737 "Face used for highlighting buttons in the article buffer.
739 An article button is a piece of text that you can activate by pressing
740 `RET' or `mouse-2' above it."
742 :group 'gnus-article-buttons)
744 (defcustom gnus-article-mouse-face 'highlight
745 "Face used for mouse highlighting in the article buffer.
747 Article buttons will be displayed in this face when the cursor is
750 :group 'gnus-article-buttons)
752 (defcustom gnus-signature-face 'gnus-signature
753 "Face used for highlighting a signature in the article buffer.
754 Obsolete; use the face `gnus-signature' for customizations instead."
756 :group 'gnus-article-highlight
757 :group 'gnus-article-signature)
759 (defface gnus-signature
762 "Face used for highlighting a signature in the article buffer."
763 :group 'gnus-article-highlight
764 :group 'gnus-article-signature)
765 ;; backward-compatibility alias
766 (put 'gnus-signature-face 'face-alias 'gnus-signature)
767 (put 'gnus-signature-face 'obsolete-face "22.1")
769 (defface gnus-header-from
772 (:foreground "PaleGreen1"))
775 (:foreground "red3"))
778 "Face used for displaying from headers."
779 :group 'gnus-article-headers
780 :group 'gnus-article-highlight)
781 ;; backward-compatibility alias
782 (put 'gnus-header-from-face 'face-alias 'gnus-header-from)
783 (put 'gnus-header-from-face 'obsolete-face "22.1")
785 (defface gnus-header-subject
788 (:foreground "SeaGreen1"))
791 (:foreground "red4"))
793 (:bold t :italic t)))
794 "Face used for displaying subject headers."
795 :group 'gnus-article-headers
796 :group 'gnus-article-highlight)
797 ;; backward-compatibility alias
798 (put 'gnus-header-subject-face 'face-alias 'gnus-header-subject)
799 (put 'gnus-header-subject-face 'obsolete-face "22.1")
801 (defface gnus-header-newsgroups
804 (:foreground "yellow" :italic t))
807 (:foreground "MidnightBlue" :italic t))
810 "Face used for displaying newsgroups headers.
811 In the default setup this face is only used for crossposted
813 :group 'gnus-article-headers
814 :group 'gnus-article-highlight)
815 ;; backward-compatibility alias
816 (put 'gnus-header-newsgroups-face 'face-alias 'gnus-header-newsgroups)
817 (put 'gnus-header-newsgroups-face 'obsolete-face "22.1")
819 (defface gnus-header-name
822 (:foreground "SpringGreen2"))
825 (:foreground "maroon"))
828 "Face used for displaying header names."
829 :group 'gnus-article-headers
830 :group 'gnus-article-highlight)
831 ;; backward-compatibility alias
832 (put 'gnus-header-name-face 'face-alias 'gnus-header-name)
833 (put 'gnus-header-name-face 'obsolete-face "22.1")
835 (defface gnus-header-content
838 (:foreground "SpringGreen1" :italic t))
841 (:foreground "indianred4" :italic t))
843 (:italic t))) "Face used for displaying header content."
844 :group 'gnus-article-headers
845 :group 'gnus-article-highlight)
846 ;; backward-compatibility alias
847 (put 'gnus-header-content-face 'face-alias 'gnus-header-content)
848 (put 'gnus-header-content-face 'obsolete-face "22.1")
850 (defcustom gnus-header-face-alist
851 '(("From" nil gnus-header-from)
852 ("Subject" nil gnus-header-subject)
853 ("Newsgroups:.*," nil gnus-header-newsgroups)
854 ("" gnus-header-name gnus-header-content))
855 "*Controls highlighting of article headers.
857 An alist of the form (HEADER NAME CONTENT).
859 HEADER is a regular expression which should match the name of a
860 header and NAME and CONTENT are either face names or nil.
862 The name of each header field will be displayed using the face
863 specified by the first element in the list where HEADER matches
864 the header name and NAME is non-nil. Similarly, the content will
865 be displayed by the first non-nil matching CONTENT face."
866 :group 'gnus-article-headers
867 :group 'gnus-article-highlight
868 :type '(repeat (list (regexp :tag "Header")
870 (item :tag "skip" nil)
871 (face :value default))
872 (choice :tag "Content"
873 (item :tag "skip" nil)
874 (face :value default)))))
876 (defcustom gnus-face-properties-alist (if (featurep 'xemacs)
877 '((xface . (:face gnus-x-face)))
878 '((pbm . (:face gnus-x-face))
880 "Alist of image types and properties applied to Face and X-Face images.
883 ;; Specify the altitude of Face images in the From header.
884 \(setq gnus-face-properties-alist
885 '((pbm . (:face gnus-x-face :ascent 80))
886 (png . (:ascent 80))))
888 ;; Show Face images as pressed buttons.
889 \(setq gnus-face-properties-alist
890 '((pbm . (:face gnus-x-face :relief -2))
891 (png . (:relief -2))))
893 See the manual for the valid properties for various image types.
894 Currently, `pbm' is used for X-Face images and `png' is used for Face
895 images in Emacs. Only the `:face' property is effective on the `xface'
896 image type in XEmacs if it is built with the libcompface library."
897 :version "23.1" ;; No Gnus
898 :group 'gnus-article-headers
899 :type '(repeat (cons :format "%v" (symbol :tag "Image type") plist)))
901 (defcustom gnus-article-decode-hook
902 '(article-decode-charset article-decode-encoded-words
903 article-decode-group-name article-decode-idna-rhs)
904 "*Hook run to decode charsets in articles."
905 :group 'gnus-article-headers
908 (defcustom gnus-display-mime-function 'gnus-display-mime
909 "Function to display MIME articles."
910 :group 'gnus-article-mime
913 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
914 "Function used to decode headers.")
916 (defvar gnus-decode-address-function 'mail-decode-encoded-address-region
917 "Function used to decode addresses.")
919 (defvar gnus-article-dumbquotes-map
939 "Table for MS-to-Latin1 translation.")
941 (defcustom gnus-ignored-mime-types nil
942 "List of MIME types that should be ignored by Gnus."
944 :group 'gnus-article-mime
945 :type '(repeat regexp))
947 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
948 "List of MIME types that should not be given buttons when rendered inline.
949 See also `gnus-buttonized-mime-types' which may override this variable.
950 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
952 :group 'gnus-article-mime
953 :type '(repeat regexp))
955 (defcustom gnus-buttonized-mime-types nil
956 "List of MIME types that should be given buttons when rendered inline.
957 If set, this variable overrides `gnus-unbuttonized-mime-types'.
958 To see e.g. security buttons you could set this to
959 `(\"multipart/signed\")'. You could also add \"multipart/alternative\" to
960 this list to display radio buttons that allow you to choose one of two
961 media types those mails include. See also `mm-discouraged-alternatives'.
962 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
964 :group 'gnus-article-mime
965 :type '(repeat regexp))
967 (defcustom gnus-inhibit-mime-unbuttonizing nil
968 "If non-nil, all MIME parts get buttons.
969 When nil (the default value), then some MIME parts do not get buttons,
970 as described by the variables `gnus-buttonized-mime-types' and
971 `gnus-unbuttonized-mime-types'."
973 :group 'gnus-article-mime
976 (defcustom gnus-body-boundary-delimiter "_"
977 "String used to delimit header and body.
978 This variable is used by `gnus-article-treat-body-boundary' which can
979 be controlled by `gnus-treat-body-boundary'."
981 :group 'gnus-article-various
982 :type '(choice (item :tag "None" :value nil)
985 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
987 "Defines the location of the faces database.
988 For information on obtaining this database of pretty pictures, please
989 see http://www.cs.indiana.edu/picons/ftp/index.html"
991 :type '(repeat directory)
992 :link '(url-link :tag "download"
993 "http://www.cs.indiana.edu/picons/ftp/index.html")
994 :link '(custom-manual "(gnus)Picons")
997 (defun gnus-picons-installed-p ()
998 "Say whether picons are installed on your machine."
999 (let ((installed nil))
1000 (dolist (database gnus-picon-databases)
1001 (when (file-exists-p database)
1002 (setq installed t)))
1005 (defcustom gnus-article-mime-part-function nil
1006 "Function called with a MIME handle as the argument.
1007 This is meant for people who want to do something automatic based
1008 on parts -- for instance, adding Vcard info to a database."
1009 :group 'gnus-article-mime
1010 :type '(choice (const nil)
1013 (defcustom gnus-mime-multipart-functions nil
1014 "An alist of MIME types to functions to display them."
1016 :group 'gnus-article-mime
1017 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
1019 (defcustom gnus-article-date-headers '(combined-lapsed)
1020 "A list of Date header formats to display.
1021 Valid formats are `ut' (universal time), `local' (local time
1022 zone), `english' (readable English), `lapsed' (elapsed time),
1023 `combined-lapsed' (both the original date and the elapsed time),
1024 `original' (the original date header), `iso8601' (ISO8601
1025 format), and `user-defined' (a user-defined format defined by the
1026 `gnus-article-time-format' variable).
1028 You have as many date headers as you want in the article buffer.
1029 Some of these headers are updated automatically. See
1030 `gnus-article-update-date-headers' for details."
1032 :group 'gnus-article-headers
1034 (item :tag "Universal time (UT)" :value 'ut)
1035 (item :tag "Local time zone" :value 'local)
1036 (item :tag "Readable English" :value 'english)
1037 (item :tag "Elapsed time" :value 'lapsed)
1038 (item :tag "Original and elapsed time" :value 'combined-lapsed)
1039 (item :tag "Original date header" :value 'original)
1040 (item :tag "ISO8601 format" :value 'iso8601)
1041 (item :tag "User-defined" :value 'user-defined)))
1043 (defcustom gnus-article-update-date-headers 1
1044 "A number that says how often to update the date header (in seconds).
1045 If nil, don't update it at all."
1047 :group 'gnus-article-headers
1049 (item :tag "Don't update" :value nil)
1052 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
1053 "Function called with a MIME handle as the argument.
1054 This is meant for people who want to view first matched part.
1055 For `undisplayed-alternative' (default), the first undisplayed
1056 part or alternative part is used. For `undisplayed', the first
1057 undisplayed part is used. For a function, the first part which
1058 the function return t is used. For nil, the first part is
1061 :group 'gnus-article-mime
1063 (item :tag "first" :value nil)
1064 (item :tag "undisplayed" :value undisplayed)
1065 (item :tag "undisplayed or alternative"
1066 :value undisplayed-alternative)
1069 (defcustom gnus-mime-action-alist
1070 '(("save to file" . gnus-mime-save-part)
1071 ("save and strip" . gnus-mime-save-part-and-strip)
1072 ("replace with file" . gnus-mime-replace-part)
1073 ("delete part" . gnus-mime-delete-part)
1074 ("display as text" . gnus-mime-inline-part)
1075 ("view the part" . gnus-mime-view-part)
1076 ("pipe to command" . gnus-mime-pipe-part)
1077 ("toggle display" . gnus-article-press-button)
1078 ("toggle display" . gnus-article-view-part-as-charset)
1079 ("view as type" . gnus-mime-view-part-as-type)
1080 ("view internally" . gnus-mime-view-part-internally)
1081 ("view externally" . gnus-mime-view-part-externally))
1082 "An alist of actions that run on the MIME attachment."
1083 :group 'gnus-article-mime
1084 :type '(repeat (cons (string :tag "name")
1087 (defcustom gnus-auto-select-part 1
1088 "Advance to next MIME part when deleting or stripping parts.
1090 When 0, point will be placed on the same part as before. When
1091 positive (negative), move point forward (backwards) this many
1092 parts. When nil, redisplay article."
1093 :version "23.1" ;; No Gnus
1094 :group 'gnus-article-mime
1095 :type '(choice (const nil :tag "Redisplay article.")
1096 (const 1 :tag "Next part.")
1097 (const 0 :tag "Current part.")
1101 ;;; The treatment variables
1104 (defvar gnus-part-display-hook nil
1105 "Hook called on parts that are to receive treatment.")
1107 (defvar gnus-article-treat-custom
1108 '(choice (const :tag "Off" nil)
1110 (const :tag "Header" head)
1111 (const :tag "First" first)
1112 (const :tag "Last" last)
1113 (integer :tag "Less")
1114 (repeat :tag "Groups" regexp)
1115 (sexp :tag "Predicate")))
1117 (defvar gnus-article-treat-head-custom
1118 '(choice (const :tag "Off" nil)
1119 (const :tag "Header" head)))
1121 (defvar gnus-article-treat-types '("text/plain" "text/x-verbatim"
1125 (defvar gnus-inhibit-treatment nil
1126 "Whether to inhibit treatment.")
1128 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
1129 "Highlight the signature.
1130 Valid values are nil, t, `head', `first', `last', an integer or a
1131 predicate. See Info node `(gnus)Customizing Articles'."
1132 :group 'gnus-article-treat
1133 :link '(custom-manual "(gnus)Customizing Articles")
1134 :type gnus-article-treat-custom)
1135 (put 'gnus-treat-highlight-signature 'highlight t)
1137 (defcustom gnus-treat-buttonize 100000
1139 Valid values are nil, t, `head', `first', `last', an integer or a
1140 predicate. See Info node `(gnus)Customizing Articles'."
1141 :group 'gnus-article-treat
1142 :link '(custom-manual "(gnus)Customizing Articles")
1143 :type gnus-article-treat-custom)
1144 (put 'gnus-treat-buttonize 'highlight t)
1146 (defcustom gnus-treat-buttonize-head 'head
1147 "Add buttons to the head.
1148 Valid values are nil, t, `head', `first', `last', an integer or a
1149 predicate. See Info node `(gnus)Customizing Articles'."
1150 :group 'gnus-article-treat
1151 :link '(custom-manual "(gnus)Customizing Articles")
1152 :type gnus-article-treat-head-custom)
1153 (put 'gnus-treat-buttonize-head 'highlight t)
1155 (defcustom gnus-treat-date 'head
1156 "Display dates according to the `gnus-article-date-headers' variable.
1157 Valid values are nil, t, `head', `first', `last', an integer or a
1158 predicate. See Info node `(gnus)Customizing Articles'."
1160 :group 'gnus-article-treat
1161 :link '(custom-manual "(gnus)Customizing Articles")
1162 :type gnus-article-treat-head-custom)
1164 (defcustom gnus-treat-emphasize 50000
1166 Valid values are nil, t, `head', `first', `last', an integer or a
1167 predicate. See Info node `(gnus)Customizing Articles'."
1168 :group 'gnus-article-treat
1169 :link '(custom-manual "(gnus)Customizing Articles")
1170 :type gnus-article-treat-custom)
1171 (put 'gnus-treat-emphasize 'highlight t)
1173 (defcustom gnus-treat-strip-cr nil
1174 "Remove carriage returns.
1175 Valid values are nil, t, `head', `first', `last', an integer or a
1176 predicate. See Info node `(gnus)Customizing Articles'."
1178 :group 'gnus-article-treat
1179 :link '(custom-manual "(gnus)Customizing Articles")
1180 :type gnus-article-treat-custom)
1182 (defcustom gnus-treat-unsplit-urls nil
1183 "Remove newlines from within URLs.
1184 Valid values are nil, t, `head', `first', `last', an integer or a
1185 predicate. See Info node `(gnus)Customizing Articles'."
1187 :group 'gnus-article-treat
1188 :link '(custom-manual "(gnus)Customizing Articles")
1189 :type gnus-article-treat-custom)
1191 (defcustom gnus-treat-leading-whitespace nil
1192 "Remove leading whitespace in headers.
1193 Valid values are nil, t, `head', `first', `last', an integer or a
1194 predicate. See Info node `(gnus)Customizing Articles'."
1196 :group 'gnus-article-treat
1197 :link '(custom-manual "(gnus)Customizing Articles")
1198 :type gnus-article-treat-custom)
1200 (defcustom gnus-treat-hide-headers 'head
1202 Valid values are nil, t, `head', `first', `last', an integer or a
1203 predicate. See Info node `(gnus)Customizing Articles'."
1204 :group 'gnus-article-treat
1205 :link '(custom-manual "(gnus)Customizing Articles")
1206 :type gnus-article-treat-head-custom)
1208 (defcustom gnus-treat-hide-boring-headers nil
1209 "Hide boring headers.
1210 Valid values are nil, t, `head', `first', `last', an integer or a
1211 predicate. See Info node `(gnus)Customizing Articles'."
1212 :group 'gnus-article-treat
1213 :link '(custom-manual "(gnus)Customizing Articles")
1214 :type gnus-article-treat-head-custom)
1216 (defcustom gnus-treat-hide-signature nil
1217 "Hide the signature.
1218 Valid values are nil, t, `head', `first', `last', an integer or a
1219 predicate. See Info node `(gnus)Customizing Articles'."
1220 :group 'gnus-article-treat
1221 :link '(custom-manual "(gnus)Customizing Articles")
1222 :type gnus-article-treat-custom)
1224 (defcustom gnus-treat-fill-article nil
1226 Valid values are nil, t, `head', `first', `last', an integer or a
1227 predicate. See Info node `(gnus)Customizing Articles'."
1228 :group 'gnus-article-treat
1229 :link '(custom-manual "(gnus)Customizing Articles")
1230 :type gnus-article-treat-custom)
1232 (defcustom gnus-treat-hide-citation nil
1234 Valid values are nil, t, `head', `first', `last', an integer or a
1235 predicate. See Info node `(gnus)Customizing Articles'."
1236 :group 'gnus-article-treat
1237 :link '(custom-manual "(gnus)Customizing Articles")
1238 :type gnus-article-treat-custom)
1240 (defcustom gnus-treat-hide-citation-maybe nil
1242 Valid values are nil, t, `head', `first', `last', an integer or a
1243 predicate. See Info node `(gnus)Customizing Articles'."
1244 :group 'gnus-article-treat
1245 :link '(custom-manual "(gnus)Customizing Articles")
1246 :type gnus-article-treat-custom)
1248 (defcustom gnus-treat-strip-list-identifiers 'head
1249 "Strip list identifiers from `gnus-list-identifiers`.
1250 Valid values are nil, t, `head', `first', `last', an integer or a
1251 predicate. See Info node `(gnus)Customizing Articles'."
1253 :group 'gnus-article-treat
1254 :link '(custom-manual "(gnus)Customizing Articles")
1255 :type gnus-article-treat-custom)
1257 (gnus-define-group-parameter
1260 "Alist of regexps and correspondent identifiers."
1261 :variable-group gnus-article-washing
1263 '(choice :tag "Identifier"
1265 (symbol :tag "Item in `gnus-list-identifiers'" none)
1267 (const :tag "None" nil))
1269 "If non-nil, specify how to remove `identifiers' from articles' subject.
1271 Any symbol is used to look up a regular expression to match the
1272 banner in `gnus-list-identifiers'. A string is used as a regular
1273 expression to match the identifier directly.")
1275 (make-obsolete-variable 'gnus-treat-strip-pgp nil
1276 "Gnus 5.10 (Emacs 22.1)")
1278 (defcustom gnus-treat-strip-pem nil
1279 "Strip PEM signatures.
1280 Valid values are nil, t, `head', `first', `last', an integer or a
1281 predicate. See Info node `(gnus)Customizing Articles'."
1282 :group 'gnus-article-treat
1283 :link '(custom-manual "(gnus)Customizing Articles")
1284 :type gnus-article-treat-custom)
1286 (defcustom gnus-treat-strip-banner t
1287 "Strip banners from articles.
1288 The banner to be stripped is specified in the `banner' group parameter.
1289 Valid values are nil, t, `head', `first', `last', an integer or a
1290 predicate. See Info node `(gnus)Customizing Articles'."
1291 :group 'gnus-article-treat
1292 :link '(custom-manual "(gnus)Customizing Articles")
1293 :type gnus-article-treat-custom)
1295 (defcustom gnus-treat-highlight-headers 'head
1296 "Highlight the headers.
1297 Valid values are nil, t, `head', `first', `last', an integer or a
1298 predicate. See Info node `(gnus)Customizing Articles'."
1299 :group 'gnus-article-treat
1300 :link '(custom-manual "(gnus)Customizing Articles")
1301 :type gnus-article-treat-head-custom)
1302 (put 'gnus-treat-highlight-headers 'highlight t)
1304 (defcustom gnus-treat-highlight-citation t
1305 "Highlight cited text.
1306 Valid values are nil, t, `head', `first', `last', an integer or a
1307 predicate. See Info node `(gnus)Customizing Articles'."
1308 :group 'gnus-article-treat
1309 :link '(custom-manual "(gnus)Customizing Articles")
1310 :type gnus-article-treat-custom)
1311 (put 'gnus-treat-highlight-citation 'highlight t)
1313 (defcustom gnus-treat-strip-headers-in-body t
1314 "Strip the X-No-Archive header line from the beginning of the body.
1315 Valid values are nil, t, `head', `first', `last', an integer or a
1316 predicate. See Info node `(gnus)Customizing Articles'."
1318 :group 'gnus-article-treat
1319 :link '(custom-manual "(gnus)Customizing Articles")
1320 :type gnus-article-treat-custom)
1322 (defcustom gnus-treat-strip-trailing-blank-lines nil
1323 "Strip trailing blank lines.
1324 Valid values are nil, t, `head', `first', `last', an integer or a
1325 predicate. See Info node `(gnus)Customizing Articles'.
1327 When set to t, it also strips trailing blanks in all MIME parts.
1328 Consider to use `last' instead."
1329 :group 'gnus-article-treat
1330 :link '(custom-manual "(gnus)Customizing Articles")
1331 :type gnus-article-treat-custom)
1333 (defcustom gnus-treat-strip-leading-blank-lines nil
1334 "Strip leading blank lines.
1335 Valid values are nil, t, `head', `first', `last', an integer or a
1336 predicate. See Info node `(gnus)Customizing Articles'.
1338 When set to t, it also strips trailing blanks in all MIME parts."
1339 :group 'gnus-article-treat
1340 :link '(custom-manual "(gnus)Customizing Articles")
1341 :type gnus-article-treat-custom)
1343 (defcustom gnus-treat-strip-multiple-blank-lines nil
1344 "Strip multiple blank lines.
1345 Valid values are nil, t, `head', `first', `last', an integer or a
1346 predicate. See Info node `(gnus)Customizing Articles'."
1347 :group 'gnus-article-treat
1348 :link '(custom-manual "(gnus)Customizing Articles")
1349 :type gnus-article-treat-custom)
1351 (defcustom gnus-treat-unfold-headers 'head
1352 "Unfold folded header lines.
1353 Valid values are nil, t, `head', `first', `last', an integer or a
1354 predicate. See Info node `(gnus)Customizing Articles'."
1356 :group 'gnus-article-treat
1357 :link '(custom-manual "(gnus)Customizing Articles")
1358 :type gnus-article-treat-custom)
1360 (defcustom gnus-article-unfold-long-headers nil
1361 "If non-nil, allow unfolding headers even if the header is long.
1362 If it is a regexp, only long headers matching this regexp are unfolded.
1363 If it is t, all long headers are unfolded.
1365 This variable has no effect if `gnus-treat-unfold-headers' is nil."
1366 :version "23.1" ;; No Gnus
1367 :group 'gnus-article-treat
1368 :type '(choice (const nil)
1369 (const :tag "all" t)
1372 (defcustom gnus-treat-fold-headers nil
1374 Valid values are nil, t, `head', `first', `last', an integer or a
1375 predicate. See Info node `(gnus)Customizing Articles'."
1377 :group 'gnus-article-treat
1378 :link '(custom-manual "(gnus)Customizing Articles")
1379 :type gnus-article-treat-custom)
1381 (defcustom gnus-treat-fold-newsgroups 'head
1382 "Fold the Newsgroups and Followup-To headers.
1383 Valid values are nil, t, `head', `first', `last', an integer or a
1384 predicate. See Info node `(gnus)Customizing Articles'."
1386 :group 'gnus-article-treat
1387 :link '(custom-manual "(gnus)Customizing Articles")
1388 :type gnus-article-treat-custom)
1390 (defcustom gnus-treat-overstrike t
1391 "Treat overstrike highlighting.
1392 Valid values are nil, t, `head', `first', `last', an integer or a
1393 predicate. See Info node `(gnus)Customizing Articles'."
1394 :group 'gnus-article-treat
1395 :link '(custom-manual "(gnus)Customizing Articles")
1396 :type gnus-article-treat-custom)
1397 (put 'gnus-treat-overstrike 'highlight t)
1399 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1400 "Treat ANSI SGR control sequences.
1401 Valid values are nil, t, `head', `first', `last', an integer or a
1402 predicate. See Info node `(gnus)Customizing Articles'."
1403 :group 'gnus-article-treat
1404 :link '(custom-manual "(gnus)Customizing Articles")
1405 :type gnus-article-treat-custom)
1407 (make-obsolete-variable 'gnus-treat-display-xface
1408 'gnus-treat-display-x-face "Emacs 22.1")
1410 (defcustom gnus-treat-display-x-face
1411 (and (not noninteractive)
1412 (gnus-image-type-available-p 'xbm)
1413 (if (featurep 'xemacs)
1416 (and (string-match "^0x" (shell-command-to-string "uncompface"))
1417 (executable-find "icontopbm"))
1418 ;; shell-command-to-string may signal an error, e.g. if
1419 ;; shell-file-name is not found.
1422 "Display X-Face headers.
1423 Valid values are nil and `head'.
1424 See Info node `(gnus)Customizing Articles' and Info node
1425 `(gnus)X-Face' for details."
1426 :group 'gnus-article-treat
1428 :link '(custom-manual "(gnus)Customizing Articles")
1429 :link '(custom-manual "(gnus)X-Face")
1430 :type gnus-article-treat-head-custom
1431 :set (lambda (symbol value)
1434 (cond ((or (boundp symbol) (get symbol 'saved-value))
1436 ((boundp 'gnus-treat-display-xface)
1438 ** gnus-treat-display-xface is an obsolete variable;\
1439 use gnus-treat-display-x-face instead")
1440 (default-value 'gnus-treat-display-xface))
1441 ((get 'gnus-treat-display-xface 'saved-value)
1443 ** gnus-treat-display-xface is an obsolete variable;\
1444 use gnus-treat-display-x-face instead")
1445 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1448 (put 'gnus-treat-display-x-face 'highlight t)
1450 (defcustom gnus-treat-display-face
1451 (and (not noninteractive)
1452 (gnus-image-type-available-p 'png)
1454 "Display Face headers.
1455 Valid values are nil, t, `head', `first', `last', an integer or a
1456 predicate. See Info node `(gnus)Customizing Articles' and Info
1457 node `(gnus)Face' for details."
1458 :group 'gnus-article-treat
1460 :link '(custom-manual "(gnus)Customizing Articles")
1461 :link '(custom-manual "(gnus)X-Face")
1462 :type gnus-article-treat-head-custom)
1463 (put 'gnus-treat-display-face 'highlight t)
1465 (defcustom gnus-treat-display-smileys (gnus-image-type-available-p 'xpm)
1467 Valid values are nil, t, `head', `first', `last', an integer or a
1468 predicate. See Info node `(gnus)Customizing Articles' and Info
1469 node `(gnus)Smileys' for details."
1470 :group 'gnus-article-treat
1472 :link '(custom-manual "(gnus)Customizing Articles")
1473 :link '(custom-manual "(gnus)Smileys")
1474 :type gnus-article-treat-custom)
1475 (put 'gnus-treat-display-smileys 'highlight t)
1477 (defcustom gnus-treat-from-picon
1478 (if (and (gnus-image-type-available-p 'xpm)
1479 (gnus-picons-installed-p))
1481 "Display picons in the From header.
1482 Valid values are nil, t, `head', `first', `last', an integer or a
1483 predicate. See Info node `(gnus)Customizing Articles' and Info
1484 node `(gnus)Picons' for details."
1486 :group 'gnus-article-treat
1488 :link '(custom-manual "(gnus)Customizing Articles")
1489 :link '(custom-manual "(gnus)Picons")
1490 :type gnus-article-treat-head-custom)
1491 (put 'gnus-treat-from-picon 'highlight t)
1493 (defcustom gnus-treat-mail-picon
1494 (if (and (gnus-image-type-available-p 'xpm)
1495 (gnus-picons-installed-p))
1497 "Display picons in To and Cc headers.
1498 Valid values are nil, t, `head', `first', `last', an integer or a
1499 predicate. See Info node `(gnus)Customizing Articles' and Info
1500 node `(gnus)Picons' for details."
1502 :group 'gnus-article-treat
1504 :link '(custom-manual "(gnus)Customizing Articles")
1505 :link '(custom-manual "(gnus)Picons")
1506 :type gnus-article-treat-head-custom)
1507 (put 'gnus-treat-mail-picon 'highlight t)
1509 (defcustom gnus-treat-newsgroups-picon
1510 (if (and (gnus-image-type-available-p 'xpm)
1511 (gnus-picons-installed-p))
1513 "Display picons in the Newsgroups and Followup-To headers.
1514 Valid values are nil, t, `head', `first', `last', an integer or a
1515 predicate. See Info node `(gnus)Customizing Articles' and Info
1516 node `(gnus)Picons' for details."
1518 :group 'gnus-article-treat
1520 :link '(custom-manual "(gnus)Customizing Articles")
1521 :link '(custom-manual "(gnus)Picons")
1522 :type gnus-article-treat-head-custom)
1523 (put 'gnus-treat-newsgroups-picon 'highlight t)
1525 (defcustom gnus-treat-from-gravatar nil
1526 "Display gravatars in the From header.
1527 Valid values are nil, t, `head', `first', `last', an integer or a
1528 predicate. See Info node `(gnus)Customizing Articles' and Info
1529 node `(gnus)Gravatars' for details."
1531 :group 'gnus-article-treat
1532 :group 'gnus-gravatar
1533 :link '(custom-manual "(gnus)Customizing Articles")
1534 :link '(custom-manual "(gnus)Gravatars")
1535 :type gnus-article-treat-head-custom)
1536 (put 'gnus-treat-from-gravatar 'highlight t)
1538 (defcustom gnus-treat-mail-gravatar nil
1539 "Display gravatars in To and Cc headers.
1540 Valid values are nil, t, `head', `first', `last', an integer or a
1541 predicate. See Info node `(gnus)Customizing Articles' and Info
1542 node `(gnus)Gravatars' for details."
1544 :group 'gnus-article-treat
1545 :group 'gnus-gravatar
1546 :link '(custom-manual "(gnus)Customizing Articles")
1547 :link '(custom-manual "(gnus)Gravatars")
1548 :type gnus-article-treat-head-custom)
1549 (put 'gnus-treat-mail-gravatar 'highlight t)
1551 (defcustom gnus-treat-body-boundary
1552 (if (or gnus-treat-newsgroups-picon
1553 gnus-treat-mail-picon
1554 gnus-treat-from-picon
1555 gnus-treat-from-gravatar
1556 gnus-treat-mail-gravatar)
1557 ;; If there's much decoration, the user might prefer a boundery.
1560 "Draw a boundary at the end of the headers.
1561 Valid values are nil and `head'.
1562 See Info node `(gnus)Customizing Articles' for details."
1564 :group 'gnus-article-treat
1565 :link '(custom-manual "(gnus)Customizing Articles")
1566 :type gnus-article-treat-head-custom)
1568 (defcustom gnus-treat-capitalize-sentences nil
1569 "Capitalize sentence-starting words.
1570 Valid values are nil, t, `head', `first', `last', an integer or a
1571 predicate. See Info node `(gnus)Customizing Articles'."
1573 :group 'gnus-article-treat
1574 :link '(custom-manual "(gnus)Customizing Articles")
1575 :type gnus-article-treat-custom)
1577 (defcustom gnus-treat-wash-html nil
1579 Valid values are nil, t, `head', `first', `last', an integer or a
1580 predicate. See Info node `(gnus)Customizing Articles'."
1582 :group 'gnus-article-treat
1583 :link '(custom-manual "(gnus)Customizing Articles")
1584 :type gnus-article-treat-custom)
1586 (defcustom gnus-treat-fill-long-lines '(typep "text/plain")
1588 Valid values are nil, t, `head', `first', `last', an integer or a
1589 predicate. See Info node `(gnus)Customizing Articles'."
1591 :group 'gnus-article-treat
1592 :link '(custom-manual "(gnus)Customizing Articles")
1593 :type gnus-article-treat-custom)
1595 (defcustom gnus-treat-x-pgp-sig nil
1597 To automatically treat X-PGP-Sig, set it to head.
1598 Valid values are nil, t, `head', `first', `last', an integer or a
1599 predicate. See Info node `(gnus)Customizing Articles'."
1601 :group 'gnus-article-treat
1602 :group 'mime-security
1603 :link '(custom-manual "(gnus)Customizing Articles")
1604 :type gnus-article-treat-custom)
1606 (defvar gnus-article-encrypt-protocol-alist
1607 '(("PGP" . mml2015-self-encrypt)))
1609 ;; Set to nil if more than one protocol added to
1610 ;; gnus-article-encrypt-protocol-alist.
1611 (defcustom gnus-article-encrypt-protocol "PGP"
1612 "The protocol used for encrypt articles.
1613 It is a string, such as \"PGP\". If nil, ask user."
1616 :group 'mime-security)
1618 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1619 (mm-coding-system-p 'utf-8)
1620 (executable-find idna-program))
1621 "Whether IDNA decoding of headers is used when viewing messages.
1622 This requires GNU Libidn, and by default only enabled if it is found."
1624 :group 'gnus-article-headers
1627 (defcustom gnus-article-over-scroll nil
1628 "If non-nil, allow scrolling the article buffer even when there no more text."
1630 :group 'gnus-article
1633 (defcustom gnus-inhibit-images nil
1634 "Non-nil means inhibit displaying of images inline in the article body."
1636 :group 'gnus-article
1639 (defcustom gnus-blocked-images 'gnus-block-private-groups
1640 "Images that have URLs matching this regexp will be blocked.
1641 This can also be a function to be evaluated. If so, it will be
1642 called with the group name as the parameter, and should return a
1648 ;;; Internal variables
1650 (defvar gnus-english-month-names
1651 '("January" "February" "March" "April" "May" "June" "July" "August"
1652 "September" "October" "November" "December"))
1654 (defvar article-goto-body-goes-to-point-min-p nil)
1655 (defvar gnus-article-wash-types nil)
1656 (defvar gnus-article-emphasis-alist nil)
1657 (defvar gnus-article-image-alist nil)
1659 (defvar gnus-article-mime-handle-alist-1 nil)
1660 (defvar gnus-treatment-function-alist
1661 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1662 (gnus-treat-strip-banner gnus-article-strip-banner)
1663 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1664 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1665 (gnus-treat-buttonize gnus-article-add-buttons)
1666 (gnus-treat-fill-article gnus-article-fill-cited-article)
1667 (gnus-treat-fill-long-lines gnus-article-fill-cited-long-lines)
1668 (gnus-treat-strip-cr gnus-article-remove-cr)
1669 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1670 (gnus-treat-display-x-face gnus-article-display-x-face)
1671 (gnus-treat-display-face gnus-article-display-face)
1672 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1673 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1674 (gnus-treat-hide-signature gnus-article-hide-signature)
1675 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1676 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1677 (gnus-treat-from-picon gnus-treat-from-picon)
1678 (gnus-treat-mail-picon gnus-treat-mail-picon)
1679 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1680 (gnus-treat-strip-pem gnus-article-hide-pem)
1681 (gnus-treat-date gnus-article-treat-date)
1682 (gnus-treat-from-gravatar gnus-treat-from-gravatar)
1683 (gnus-treat-mail-gravatar gnus-treat-mail-gravatar)
1684 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1685 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1686 (gnus-treat-strip-trailing-blank-lines
1687 gnus-article-remove-trailing-blank-lines)
1688 (gnus-treat-strip-leading-blank-lines
1689 gnus-article-strip-leading-blank-lines)
1690 (gnus-treat-strip-multiple-blank-lines
1691 gnus-article-strip-multiple-blank-lines)
1692 (gnus-treat-overstrike gnus-article-treat-overstrike)
1693 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1694 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1695 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1696 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1697 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1698 (gnus-treat-display-smileys gnus-treat-smiley)
1699 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1700 (gnus-treat-wash-html gnus-article-wash-html)
1701 (gnus-treat-emphasize gnus-article-emphasize)
1702 (gnus-treat-hide-citation gnus-article-hide-citation)
1703 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1704 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1705 (gnus-treat-body-boundary gnus-article-treat-body-boundary)))
1707 (defvar gnus-article-mime-handle-alist nil)
1708 (defvar article-lapsed-timer nil)
1709 (defvar gnus-article-current-summary nil)
1711 (defvar gnus-article-mode-syntax-table
1712 (let ((table (copy-syntax-table text-mode-syntax-table)))
1713 ;; This causes the citation match run O(2^n).
1714 ;; (modify-syntax-entry ?- "w" table)
1715 (modify-syntax-entry ?> ")<" table)
1716 (modify-syntax-entry ?< "(>" table)
1717 ;; make M-. in article buffers work for `foo' strings
1718 (modify-syntax-entry ?' " " table)
1719 (modify-syntax-entry ?` " " table)
1721 "Syntax table used in article mode buffers.
1722 Initialized from `text-mode-syntax-table.")
1724 (defvar gnus-save-article-buffer nil)
1726 (defvar gnus-number-of-articles-to-be-saved nil)
1728 (defvar gnus-inhibit-hiding nil)
1730 (defvar gnus-article-edit-mode nil)
1732 ;;; Macros for dealing with the article buffer.
1734 (defmacro gnus-with-article-headers (&rest forms)
1735 `(with-current-buffer gnus-article-buffer
1737 (let ((inhibit-read-only t)
1738 (inhibit-point-motion-hooks t)
1739 (case-fold-search t))
1740 (article-narrow-to-head)
1743 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1744 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1746 (defmacro gnus-with-article-buffer (&rest forms)
1747 `(when (buffer-live-p (get-buffer gnus-article-buffer))
1748 (with-current-buffer gnus-article-buffer
1749 (let ((inhibit-read-only t))
1752 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1753 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1755 (defun gnus-article-goto-header (header)
1756 "Go to HEADER, which is a regular expression."
1757 (re-search-forward (concat "^\\(" header "\\):") nil t))
1759 (defsubst gnus-article-hide-text (b e props)
1760 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1761 (gnus-add-text-properties-when 'article-type nil b e props)
1762 (when (memq 'intangible props)
1764 (max (1- b) (point-min))
1765 b 'intangible (cddr (memq 'intangible props)))))
1767 (defsubst gnus-article-unhide-text (b e)
1768 "Remove hidden text properties from region between B and E."
1769 (remove-text-properties b e gnus-hidden-properties)
1770 (when (memq 'intangible gnus-hidden-properties)
1771 (put-text-property (max (1- b) (point-min))
1772 b 'intangible nil)))
1774 (defun gnus-article-hide-text-type (b e type)
1775 "Hide text of TYPE between B and E."
1776 (gnus-add-wash-type type)
1777 (gnus-article-hide-text
1778 b e (cons 'article-type (cons type gnus-hidden-properties))))
1780 (defun gnus-article-unhide-text-type (b e type)
1781 "Unhide text of TYPE between B and E."
1782 (gnus-delete-wash-type type)
1783 (remove-text-properties
1784 b e (cons 'article-type (cons type gnus-hidden-properties)))
1785 (when (memq 'intangible gnus-hidden-properties)
1786 (put-text-property (max (1- b) (point-min))
1787 b 'intangible nil)))
1789 (defun gnus-article-hide-text-of-type (type)
1790 "Hide text of TYPE in the current buffer."
1792 (let ((b (point-min))
1794 (while (setq b (text-property-any b e 'article-type type))
1795 (add-text-properties b (incf b) gnus-hidden-properties)))))
1797 (defun gnus-article-delete-text-of-type (type)
1798 "Delete text of TYPE in the current buffer."
1800 (let ((b (point-min)))
1801 (if (eq type 'multipart)
1802 ;; Remove MIME buttons associated with multipart/alternative parts.
1805 (while (if (get-text-property (point) 'gnus-part)
1807 (when (setq b (next-single-property-change (point)
1812 (skip-chars-forward "\n")
1813 (when (eq (get-text-property b 'article-type) 'multipart)
1814 (delete-region b (point)))))
1815 (while (setq b (text-property-any b (point-max) 'article-type type))
1817 b (or (text-property-not-all b (point-max) 'article-type type)
1820 (defun gnus-article-delete-invisible-text ()
1821 "Delete all invisible text in the current buffer."
1823 (let ((b (point-min)))
1824 (while (setq b (text-property-any b (point-max) 'invisible t))
1826 b (or (text-property-not-all b (point-max) 'invisible t)
1829 (defun gnus-article-text-type-exists-p (type)
1830 "Say whether any text of type TYPE exists in the buffer."
1831 (text-property-any (point-min) (point-max) 'article-type type))
1833 (defsubst gnus-article-header-rank ()
1834 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1835 (let ((list gnus-sorted-header-list)
1838 (if (looking-at (car list))
1840 (setq list (cdr list))
1844 (defun article-hide-headers (&optional arg delete)
1845 "Hide unwanted headers and possibly sort them as well."
1847 ;; This function might be inhibited.
1848 (unless gnus-inhibit-hiding
1849 (let ((inhibit-read-only t)
1850 (case-fold-search t)
1851 (max (1+ (length gnus-sorted-header-list)))
1852 (inhibit-point-motion-hooks t)
1853 (cur (current-buffer))
1854 ignored visible beg)
1856 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1857 ;; group parameters, so we should go to the summary buffer.
1860 (progn (set-buffer gnus-summary-buffer) t)
1862 (setq ignored (when (not gnus-visible-headers)
1863 (cond ((stringp gnus-ignored-headers)
1864 gnus-ignored-headers)
1865 ((listp gnus-ignored-headers)
1866 (mapconcat 'identity
1867 gnus-ignored-headers
1869 visible (cond ((stringp gnus-visible-headers)
1870 gnus-visible-headers)
1871 ((and gnus-visible-headers
1872 (listp gnus-visible-headers))
1873 (mapconcat 'identity
1874 gnus-visible-headers
1878 ;; First we narrow to just the headers.
1879 (article-narrow-to-head)
1880 ;; Hide any "From " lines at the beginning of (mail) articles.
1881 (while (looking-at "From ")
1884 (delete-region (point-min) (point)))
1885 ;; Then treat the rest of the header lines.
1886 ;; Then we use the two regular expressions
1887 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1888 ;; select which header lines is to remain visible in the
1890 (while (re-search-forward "^[^ \t:]*:" nil t)
1892 ;; Mark the rank of the header.
1894 (point) (1+ (point)) 'message-rank
1895 (if (or (and visible (looking-at visible))
1897 (not (looking-at ignored))))
1898 (gnus-article-header-rank)
1901 (message-sort-headers-1)
1902 (when (setq beg (text-property-any
1903 (point-min) (point-max) 'message-rank (+ 2 max)))
1904 ;; We delete the unwanted headers.
1905 (gnus-add-wash-type 'headers)
1906 (add-text-properties (point-min) (+ 5 (point-min))
1907 '(article-type headers dummy-invisible t))
1908 (delete-region beg (point-max))))))))
1910 (defun article-hide-boring-headers (&optional arg)
1911 "Toggle hiding of headers that aren't very interesting.
1912 If given a negative prefix, always show; if given a positive prefix,
1914 (interactive (gnus-article-hidden-arg))
1915 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1916 (not gnus-show-all-headers))
1919 (let ((inhibit-read-only t)
1920 (inhibit-point-motion-hooks t))
1921 (article-narrow-to-head)
1922 (dolist (elem gnus-boring-article-headers)
1923 (goto-char (point-min))
1925 ;; Hide empty headers.
1927 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1929 (gnus-article-hide-text-type
1933 (if (re-search-forward "^[^ \t]" nil t)
1937 ;; Hide boring Newsgroups header.
1938 ((eq elem 'newsgroups)
1939 (when (gnus-string-equal
1940 (gnus-fetch-field "newsgroups")
1941 (gnus-group-real-name
1942 (if (boundp 'gnus-newsgroup-name)
1945 (gnus-article-hide-header "newsgroups")))
1946 ((eq elem 'to-address)
1947 (let ((to (message-fetch-field "to"))
1949 (gnus-parameter-to-address
1950 (if (boundp 'gnus-newsgroup-name)
1951 gnus-newsgroup-name ""))))
1952 (when (and to to-address
1955 ;; only one address in To
1956 (nth 1 (mail-extract-address-components to))
1958 (gnus-article-hide-header "to"))))
1960 (let ((to (message-fetch-field "to"))
1962 (gnus-parameter-to-list
1963 (if (boundp 'gnus-newsgroup-name)
1964 gnus-newsgroup-name ""))))
1965 (when (and to to-list
1968 ;; only one address in To
1969 (nth 1 (mail-extract-address-components to))
1971 (gnus-article-hide-header "to"))))
1973 (let ((cc (message-fetch-field "cc"))
1975 (gnus-parameter-to-list
1976 (if (boundp 'gnus-newsgroup-name)
1977 gnus-newsgroup-name ""))))
1978 (when (and cc to-list
1981 ;; only one address in CC
1982 (nth 1 (mail-extract-address-components cc))
1984 (gnus-article-hide-header "cc"))))
1985 ((eq elem 'followup-to)
1986 (when (gnus-string-equal
1987 (message-fetch-field "followup-to")
1988 (message-fetch-field "newsgroups"))
1989 (gnus-article-hide-header "followup-to")))
1990 ((eq elem 'reply-to)
1991 (if (gnus-group-find-parameter
1992 gnus-newsgroup-name 'broken-reply-to)
1993 (gnus-article-hide-header "reply-to")
1994 (let ((from (message-fetch-field "from"))
1995 (reply-to (message-fetch-field "reply-to")))
2002 (lambda (x) (downcase (cadr x)))
2003 (mail-extract-address-components from t))
2006 (lambda (x) (downcase (cadr x)))
2007 (mail-extract-address-components reply-to t))
2009 (gnus-article-hide-header "reply-to")))))
2011 (let ((date (with-current-buffer gnus-original-article-buffer
2012 ;; If date in `gnus-article-buffer' is localized
2013 ;; (`gnus-treat-date-user-defined'),
2014 ;; `days-between' might fail.
2015 (message-fetch-field "date"))))
2017 (< (days-between (current-time-string) date)
2019 (gnus-article-hide-header "date"))))
2021 (let ((to (message-fetch-field "to"))
2022 (cc (message-fetch-field "cc")))
2023 (when (> (length to) 1024)
2024 (gnus-article-hide-header "to"))
2025 (when (> (length cc) 1024)
2026 (gnus-article-hide-header "cc"))))
2030 (goto-char (point-min))
2031 (while (re-search-forward "^to:" nil t)
2032 (setq to-count (1+ to-count)))
2033 (when (> to-count 1)
2034 (while (> to-count 0)
2035 (goto-char (point-min))
2037 (re-search-forward "^to:" nil nil to-count)
2039 (narrow-to-region (point) (point-max))
2040 (gnus-article-hide-header "to"))
2041 (setq to-count (1- to-count))))
2042 (goto-char (point-min))
2043 (while (re-search-forward "^cc:" nil t)
2044 (setq cc-count (1+ cc-count)))
2045 (when (> cc-count 1)
2046 (while (> cc-count 0)
2047 (goto-char (point-min))
2049 (re-search-forward "^cc:" nil nil cc-count)
2051 (narrow-to-region (point) (point-max))
2052 (gnus-article-hide-header "cc"))
2053 (setq cc-count (1- cc-count)))))))))))))
2055 (defun gnus-article-hide-header (header)
2057 (goto-char (point-min))
2058 (when (re-search-forward (concat "^" header ":") nil t)
2059 (gnus-article-hide-text-type
2063 (if (re-search-forward "^[^ \t]" nil t)
2068 (defvar gnus-article-normalized-header-length 40
2069 "Length of normalized headers.")
2071 (defun article-normalize-headers ()
2072 "Make all header lines 40 characters long."
2074 (let ((inhibit-read-only t)
2078 (article-narrow-to-head)
2081 ((< (setq column (- (point-at-eol) (point)))
2082 gnus-article-normalized-header-length)
2084 (insert (make-string
2085 (- gnus-article-normalized-header-length column)
2087 ((> column gnus-article-normalized-header-length)
2088 (gnus-put-text-property
2090 (forward-char gnus-article-normalized-header-length)
2097 (forward-line 1))))))
2099 (defun article-treat-dumbquotes ()
2100 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
2101 Note that this function guesses whether a character is a sm*rtq**t* or
2102 not, so it should only be used interactively.
2104 Sm*rtq**t*s are M****s***'s unilateral extension to the
2105 iso-8859-1 character map in an attempt to provide more quoting
2106 characters. If you see something like \\222 or \\264 where
2107 you're expecting some kind of apostrophe or quotation mark, then
2110 (article-translate-strings gnus-article-dumbquotes-map))
2112 (defvar org-entities)
2114 (defun article-treat-non-ascii ()
2115 "Translate many Unicode characters into their ASCII equivalents."
2117 (require 'org-entities)
2118 (let ((table (make-char-table (if (featurep 'xemacs) 'generic))))
2119 (dolist (elem org-entities)
2120 (when (and (listp elem)
2121 (= (length (nth 6 elem)) 1))
2122 (if (featurep 'xemacs)
2123 (put-char-table (aref (nth 6 elem) 0) (nth 4 elem) table)
2124 (set-char-table-range table (aref (nth 6 elem) 0) (nth 4 elem)))))
2126 (when (article-goto-body)
2127 (let ((inhibit-read-only t)
2130 (if (not (setq replace (if (featurep 'xemacs)
2131 (get-char-table (following-char) table)
2132 (aref table (following-char)))))
2135 (setq props (text-properties-at (point)))
2137 (add-text-properties (point) (progn (insert replace) (point))
2139 (insert replace)))))))))
2141 (defun article-translate-characters (from to)
2142 "Translate all characters in the body of the article according to FROM and TO.
2143 FROM is a string of characters to translate from; to is a string of
2144 characters to translate to."
2146 (when (article-goto-body)
2147 (let ((inhibit-read-only t)
2148 (x (make-string 225 ?x))
2150 (while (< (incf i) (length x))
2153 (while (< i (length from))
2154 (aset x (aref from i) (aref to i))
2156 (translate-region (point) (point-max) x)))))
2158 (defun article-translate-strings (map)
2159 "Translate all string in the body of the article according to MAP.
2160 MAP is an alist where the elements are on the form (\"from\" \"to\")."
2162 (when (article-goto-body)
2163 (let ((inhibit-read-only t))
2165 (let ((from (car elem))
2169 (while (search-forward from nil t)
2172 (if (eq (following-char) from)
2176 (forward-char 1)))))))))))
2178 (defun article-treat-overstrike ()
2179 "Translate overstrikes into bold text."
2182 (when (article-goto-body)
2183 (let ((inhibit-read-only t))
2184 (while (search-forward "\b" nil t)
2185 (let ((next (char-after))
2186 (previous (char-after (- (point) 2))))
2187 ;; We do the boldification/underlining by hiding the
2188 ;; overstrikes and putting the proper text property
2192 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
2193 (put-text-property (point) (1+ (point)) 'face 'bold))
2195 (gnus-article-hide-text-type
2196 (1- (point)) (1+ (point)) 'overstrike)
2198 (- (point) 2) (1- (point)) 'face 'underline))
2200 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
2202 (point) (1+ (point)) 'face 'underline)))))))))
2204 (defun article-treat-ansi-sequences ()
2205 "Translate ANSI SGR control sequences into overlays or extents."
2208 (when (article-goto-body)
2209 (let ((inhibit-read-only t))
2210 (ansi-color-apply-on-region (point) (point-max))))))
2212 (defun gnus-article-treat-unfold-headers ()
2213 "Unfold folded message headers.
2214 Only the headers that fit into the current window width will be
2217 (gnus-with-article-headers
2221 (mail-header-narrow-to-field)
2222 (let* ((header (buffer-string))
2224 (or (equal gnus-article-unfold-long-headers t)
2225 (and (stringp gnus-article-unfold-long-headers)
2226 (string-match gnus-article-unfold-long-headers header)))))
2229 (goto-char (point-min))
2230 (while (re-search-forward "\n[\t ]" nil t)
2231 (replace-match " " t t)))
2232 (setq length (- (point-max) (point-min) 1))
2233 (when (or unfoldable
2234 (< length (window-width)))
2235 (while (re-search-forward "\n[\t ]" nil t)
2236 (replace-match " " t t))))
2237 (goto-char (point-max)))))))
2239 (defun gnus-article-treat-fold-headers ()
2240 "Fold message headers."
2242 (gnus-with-article-headers
2245 (mail-header-narrow-to-field)
2246 (mail-header-fold-field)
2247 (goto-char (point-max))))))
2249 (defun gnus-treat-smiley ()
2250 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2252 (gnus-with-article-buffer
2253 (if (memq 'smiley gnus-article-wash-types)
2254 (gnus-delete-images 'smiley)
2256 (let ((images (smiley-region (point) (point-max))))
2258 (gnus-add-wash-type 'smiley)
2259 (dolist (image images)
2260 (gnus-add-image 'smiley image)))))))
2262 (defun gnus-article-remove-images ()
2263 "Remove all images from the article buffer."
2265 (gnus-with-article-buffer
2268 (dolist (elem gnus-article-image-alist)
2269 (gnus-delete-images (car elem))))))
2271 (defun gnus-article-show-images ()
2272 "Show any images that are in the HTML-rendered article buffer.
2273 This only works if the article in question is HTML."
2275 (gnus-with-article-buffer
2278 (dolist (region (gnus-find-text-property-region (point-min) (point-max)
2280 (destructuring-bind (start end function) region
2281 (funcall function (get-text-property start 'image-url)
2284 (defun gnus-article-treat-fold-newsgroups ()
2285 "Unfold folded message headers.
2286 Only the headers that fit into the current window width will be
2289 (gnus-with-article-headers
2290 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2292 (mail-header-narrow-to-field)
2293 (while (re-search-forward ", *" nil t)
2294 (replace-match ", " t t))
2295 (mail-header-fold-field)
2296 (goto-char (point-max))))))
2298 (defcustom gnus-article-truncate-lines (default-value 'truncate-lines)
2299 "Value of `truncate-lines' in Gnus Article buffer.
2300 Valid values are nil, t, `head', `first', `last', an integer or a
2301 predicate. See Info node `(gnus)Customizing Articles'."
2302 :version "23.1" ;; No Gnus
2303 :group 'gnus-article
2304 ;; :link '(custom-manual "(gnus)Customizing Articles")
2307 (defun gnus-article-toggle-truncate-lines (&optional arg)
2308 "Toggle whether to fold or truncate long lines in article the buffer.
2309 If ARG is non-nil and not a number, toggle
2310 `gnus-article-truncate-lines' too. If ARG is a number, truncate
2311 long lines if and only if arg is positive."
2314 ((and (numberp arg) (> arg 0))
2315 (setq gnus-article-truncate-lines t))
2317 (setq gnus-article-truncate-lines nil))
2319 (setq gnus-article-truncate-lines
2320 (not gnus-article-truncate-lines))))
2321 (gnus-with-article-buffer
2323 ((and (numberp arg) (> arg 0))
2324 (setq truncate-lines nil))
2326 (setq truncate-lines t)))
2327 ;; In versions of Emacs 22 (CVS) before 2006-05-26,
2328 ;; `toggle-truncate-lines' needs an argument.
2329 (toggle-truncate-lines)))
2331 (defun gnus-article-treat-body-boundary ()
2332 "Place a boundary line at the end of the headers."
2334 (when (and gnus-body-boundary-delimiter
2335 (> (length gnus-body-boundary-delimiter) 0))
2336 (gnus-with-article-headers
2337 (goto-char (point-max))
2338 (let ((start (point)))
2339 (insert "X-Boundary: ")
2340 (gnus-add-text-properties start (point) '(invisible t intangible t))
2341 (insert (let (str (max (window-width)))
2342 (if (featurep 'xemacs)
2343 (setq max (1- max)))
2344 (while (>= max (length str))
2345 (setq str (concat str gnus-body-boundary-delimiter)))
2346 (substring str 0 max))
2348 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2350 (defun article-fill-long-lines ()
2351 "Fill lines that are wider than the window width."
2354 (let ((inhibit-read-only t)
2355 (width (window-width (get-buffer-window (current-buffer)))))
2358 (let ((adaptive-fill-mode nil)) ;Why? -sm
2361 (when (>= (current-column) (min fill-column width))
2362 (narrow-to-region (min (1+ (point)) (point-max))
2364 (let ((goback (point-marker)))
2365 (fill-paragraph nil)
2366 (goto-char (marker-position goback)))
2368 (forward-line 1)))))))
2370 (defun article-capitalize-sentences ()
2371 "Capitalize the first word in each sentence."
2374 (let ((inhibit-read-only t)
2375 (paragraph-start "^[\n\^L]"))
2379 (forward-sentence)))))
2381 (defun article-remove-cr ()
2382 "Remove trailing CRs and then translate remaining CRs into LFs."
2385 (let ((inhibit-read-only t))
2386 (goto-char (point-min))
2387 (while (re-search-forward "\r+$" nil t)
2388 (replace-match "" t t))
2389 (goto-char (point-min))
2390 (while (search-forward "\r" nil t)
2391 (replace-match "\n" t t)))))
2393 (defun article-remove-trailing-blank-lines ()
2394 "Remove all trailing blank lines from the article."
2397 (let ((inhibit-read-only t))
2398 (goto-char (point-max))
2402 (while (and (not (bobp))
2403 (looking-at "^[ \t]*$")
2404 (not (gnus-annotation-in-region-p
2405 (point) (point-at-eol))))
2410 (defvar gnus-face-properties-alist)
2412 (defun article-display-face (&optional force)
2413 "Display any Face headers in the header."
2414 (interactive (list 'force))
2415 (let ((wash-face-p buffer-read-only))
2416 (gnus-with-article-headers
2417 ;; When displaying parts, this function can be called several times on
2418 ;; the same article, without any intended toggle semantic (as typing `W
2419 ;; D d' would have). So face deletion must occur only when we come from
2420 ;; an interactive command, that is when the *Article* buffer is
2422 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2423 (gnus-delete-images 'face)
2424 (let ((from (message-fetch-field "from"))
2426 (save-current-buffer
2427 (when (and wash-face-p
2428 (gnus-buffer-live-p gnus-original-article-buffer)
2429 (not (re-search-forward "^Face:[\t ]*" nil t)))
2430 (set-buffer gnus-original-article-buffer))
2432 (mail-narrow-to-head)
2434 ;; Check whether this face is censored.
2435 (not (and gnus-article-x-face-too-ugly
2437 (setq from (message-fetch-field "from")))
2438 (string-match gnus-article-x-face-too-ugly
2440 (while (gnus-article-goto-header "Face")
2441 (push (mail-header-field-value) faces)))))
2443 (goto-char (point-min))
2445 (unless (setq from (gnus-article-goto-header "from"))
2448 (insert " [no `from' set]\n"))
2450 (when (setq png (gnus-convert-face-to-png (pop faces)))
2452 (apply 'gnus-create-image png 'png t
2453 (cdr (assq 'png gnus-face-properties-alist))))
2455 (gnus-add-wash-type 'face)
2456 (gnus-add-image 'face image)
2457 (gnus-put-image image nil 'face))))))))))
2459 (defun article-display-x-face (&optional force)
2460 "Look for an X-Face header and display it if present."
2461 (interactive (list 'force))
2462 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2463 (gnus-with-article-headers
2464 ;; Delete the old process, if any.
2465 (when (process-status "article-x-face")
2466 (delete-process "article-x-face"))
2467 ;; See the comment in `article-display-face'.
2468 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2469 ;; We have already displayed X-Faces, so we remove them
2471 (gnus-delete-images 'xface)
2473 (let ((from (message-fetch-field "from"))
2475 (save-current-buffer
2476 (when (and wash-face-p
2477 (gnus-buffer-live-p gnus-original-article-buffer)
2478 (not (re-search-forward "^X-Face:[\t ]*" nil t)))
2479 ;; If type `W f', use gnus-original-article-buffer,
2480 ;; otherwise use the current buffer because displaying
2481 ;; RFC822 parts calls this function too.
2482 (set-buffer gnus-original-article-buffer))
2484 (mail-narrow-to-head)
2485 (and gnus-article-x-face-command
2487 ;; Check whether this face is censored.
2488 (not (and gnus-article-x-face-too-ugly
2490 (setq from (message-fetch-field "from")))
2491 (string-match gnus-article-x-face-too-ugly
2493 (while (gnus-article-goto-header "X-Face")
2494 (push (mail-header-field-value) x-faces)))))
2496 ;; We display the face.
2497 (cond ((functionp gnus-article-x-face-command)
2498 ;; The command is a lisp function, so we call it.
2499 (mapc gnus-article-x-face-command x-faces))
2500 ((stringp gnus-article-x-face-command)
2501 ;; The command is a string, so we interpret the command
2502 ;; as a, well, command, and fork it off.
2503 (let ((process-connection-type nil))
2504 (gnus-set-process-query-on-exit-flag
2506 "article-x-face" nil shell-file-name
2507 shell-command-switch gnus-article-x-face-command)
2509 ;; Sending multiple EOFs to xv doesn't work,
2510 ;; so we only do a single external face.
2512 (insert (car x-faces))
2513 (process-send-region "article-x-face"
2514 (point-min) (point-max)))
2515 (process-send-eof "article-x-face")))
2517 (error "`%s' set to `%s' is not a function"
2518 gnus-article-x-face-command
2519 'gnus-article-x-face-command)))))))))
2521 (defun article-decode-mime-words ()
2522 "Decode all MIME-encoded words in the article."
2524 (gnus-with-article-buffer
2525 (let ((inhibit-point-motion-hooks t)
2526 (mail-parse-charset gnus-newsgroup-charset)
2527 (mail-parse-ignored-charsets
2528 (with-current-buffer gnus-summary-buffer
2529 gnus-newsgroup-ignored-charsets)))
2530 (mail-decode-encoded-word-region (point-min) (point-max)))))
2532 (defun article-decode-charset (&optional prompt)
2533 "Decode charset-encoded text in the article.
2534 If PROMPT (the prefix), prompt for a coding system to use."
2536 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2537 (inhibit-read-only t)
2538 (mail-parse-charset gnus-newsgroup-charset)
2539 (mail-parse-ignored-charsets
2540 (save-excursion (condition-case nil
2541 (set-buffer gnus-summary-buffer)
2543 gnus-newsgroup-ignored-charsets))
2544 ct cte ctl charset format)
2547 (article-narrow-to-head)
2548 (setq ct (message-fetch-field "Content-Type" t)
2549 cte (message-fetch-field "Content-Transfer-Encoding" t)
2550 ctl (and ct (mail-header-parse-content-type ct))
2553 (mm-read-coding-system "Charset to decode: "))
2555 (mail-content-type-get ctl 'charset)))
2556 format (and ctl (mail-content-type-get ctl 'format)))
2558 (setq cte (mail-header-strip cte)))
2559 (if (and ctl (not (string-match "/" (car ctl))))
2561 (goto-char (point-max)))
2564 (narrow-to-region (point) (point-max))
2565 (when (and (eq mail-parse-charset 'gnus-decoded)
2566 (eq (mm-body-7-or-8) '8bit))
2567 ;; The text code could have been decoded.
2568 (setq charset mail-parse-charset))
2569 (when (and (or (not ctl)
2570 (equal (car ctl) "text/plain"))
2571 (not format)) ;; article with format will decode later.
2573 charset (and cte (intern (downcase
2574 (gnus-strip-whitespace cte))))
2577 (defun article-decode-encoded-words ()
2578 "Remove encoded-word encoding from headers."
2579 (let ((inhibit-point-motion-hooks t)
2580 (mail-parse-charset gnus-newsgroup-charset)
2581 (mail-parse-ignored-charsets
2582 (save-excursion (condition-case nil
2583 (set-buffer gnus-summary-buffer)
2585 gnus-newsgroup-ignored-charsets))
2586 (inhibit-read-only t)
2588 (goto-char (point-min))
2589 (when (search-forward "\n\n" nil 'move)
2596 (memq (char-after) '(?\t ? )))))
2597 (setq start (point))
2599 \\(?:Resent-\\)?\\(?:From\\|Cc\\|To\\|Bcc\\|\\(?:In-\\)?Reply-To\\|Sender\
2600 \\|Mail-Followup-To\\|Mail-Copies-To\\|Approved\\):")
2601 (funcall gnus-decode-address-function start end)
2602 (funcall gnus-decode-header-function start end))
2603 (goto-char (setq end start)))))
2605 (defun article-decode-group-name ()
2606 "Decode group names in Newsgroups, Followup-To and Xref headers."
2607 (let ((inhibit-point-motion-hooks t)
2608 (inhibit-read-only t)
2609 (method (gnus-find-method-for-group gnus-newsgroup-name))
2611 (when (and (or gnus-group-name-charset-method-alist
2612 gnus-group-name-charset-group-alist)
2613 (gnus-buffer-live-p gnus-original-article-buffer))
2615 (article-narrow-to-head)
2616 (dolist (header '("Newsgroups" "Followup-To" "Xref"))
2617 (with-current-buffer gnus-original-article-buffer
2618 (goto-char (point-min)))
2619 (setq regexp (concat "^" header
2620 ":\\([^\n]*\\(?:\n[\t ]+[^\n]+\\)*\\)\n"))
2621 (while (re-search-forward regexp nil t)
2622 (replace-match (save-match-data
2623 (gnus-decode-newsgroups
2624 ;; XXX how to use data in article buffer?
2625 (with-current-buffer gnus-original-article-buffer
2626 (re-search-forward regexp nil t)
2628 gnus-newsgroup-name method))
2630 (goto-char (point-min)))))))
2632 (autoload 'idna-to-unicode "idna")
2634 (defun article-decode-idna-rhs ()
2635 "Decode IDNA strings in RHS in various headers in current buffer.
2636 The following headers are decoded: From:, To:, Cc:, Reply-To:,
2637 Mail-Reply-To: and Mail-Followup-To:."
2640 (let ((inhibit-point-motion-hooks t)
2641 (inhibit-read-only t))
2642 (article-narrow-to-head)
2643 (goto-char (point-min))
2644 (while (re-search-forward "@[^ \t\n\r,>]*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2646 (when (save-match-data
2647 (and (setq ace (match-string 1))
2649 (and (re-search-backward "^[^ \t]" nil t)
2650 (looking-at "From\\|To\\|Cc\\|Reply-To\\|Mail-Reply-To\\|Mail-Followup-To")))
2651 (setq unicode (idna-to-unicode ace))))
2652 (unless (string= ace unicode)
2653 (replace-match unicode nil nil nil 1)))))))))
2655 (defun article-de-quoted-unreadable (&optional force read-charset)
2656 "Translate a quoted-printable-encoded article.
2657 If FORCE, decode the article whether it is marked as quoted-printable
2659 If READ-CHARSET, ask for a coding system."
2660 (interactive (list 'force current-prefix-arg))
2662 (let ((inhibit-read-only t) type charset)
2663 (if (gnus-buffer-live-p gnus-original-article-buffer)
2664 (with-current-buffer gnus-original-article-buffer
2666 (gnus-fetch-field "content-transfer-encoding"))
2667 (let* ((ct (gnus-fetch-field "content-type"))
2668 (ctl (and ct (mail-header-parse-content-type ct))))
2669 (setq charset (and ctl
2670 (mail-content-type-get ctl 'charset)))
2671 (if (stringp charset)
2672 (setq charset (intern (downcase charset)))))))
2674 (setq charset (mm-read-coding-system "Charset: " charset)))
2676 (setq charset gnus-newsgroup-charset))
2678 (and type (let ((case-fold-search t))
2679 (string-match "quoted-printable" type))))
2681 (quoted-printable-decode-region
2682 (point) (point-max) (mm-charset-to-coding-system charset))))))
2684 (defun article-de-base64-unreadable (&optional force read-charset)
2685 "Translate a base64 article.
2686 If FORCE, decode the article whether it is marked as base64 not.
2687 If READ-CHARSET, ask for a coding system."
2688 (interactive (list 'force current-prefix-arg))
2690 (let ((inhibit-read-only t) type charset)
2691 (if (gnus-buffer-live-p gnus-original-article-buffer)
2692 (with-current-buffer gnus-original-article-buffer
2694 (gnus-fetch-field "content-transfer-encoding"))
2695 (let* ((ct (gnus-fetch-field "content-type"))
2696 (ctl (and ct (mail-header-parse-content-type ct))))
2697 (setq charset (and ctl
2698 (mail-content-type-get ctl 'charset)))
2699 (if (stringp charset)
2700 (setq charset (intern (downcase charset)))))))
2702 (setq charset (mm-read-coding-system "Charset: " charset)))
2704 (setq charset gnus-newsgroup-charset))
2706 (and type (let ((case-fold-search t))
2707 (string-match "base64" type))))
2710 (narrow-to-region (point) (point-max))
2711 (base64-decode-region (point-min) (point-max))
2712 (mm-decode-coding-region
2713 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2718 (defun article-decode-HZ ()
2719 "Translate a HZ-encoded article."
2723 (let ((inhibit-read-only t))
2724 (rfc1843-decode-region (point-min) (point-max)))))
2726 (defun article-unsplit-urls ()
2727 "Remove the newlines that some other mailers insert into URLs."
2730 (let ((inhibit-read-only t))
2731 (goto-char (point-min))
2732 (while (re-search-forward
2733 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2734 (replace-match "\\1\\3" t)))
2735 (when (interactive-p)
2736 (gnus-treat-article nil))))
2738 (defun article-wash-html ()
2739 "Format an HTML article."
2742 (buffer-read-only nil))
2743 (when (gnus-buffer-live-p gnus-original-article-buffer)
2744 (setq handles (mm-dissect-buffer t t)))
2746 (delete-region (point) (point-max))
2747 (mm-inline-text-html handles)))
2749 (defvar gnus-article-browse-html-temp-list nil
2750 "List of temporary files created by `gnus-article-browse-html-parts'.
2751 Internal variable.")
2753 (defcustom gnus-article-browse-delete-temp 'ask
2754 "What to do with temporary files from `gnus-article-browse-html-parts'.
2755 If nil, don't delete temporary files. If it is t, delete them on
2756 exit from the summary buffer. If it is the symbol `file', query
2757 on each file, if it is `ask' ask once when exiting from the
2759 :group 'gnus-article
2760 :version "23.1" ;; No Gnus
2761 :type '(choice (const :tag "Don't delete" nil)
2762 (const :tag "Don't ask" t)
2763 (const :tag "Ask" ask)
2764 (const :tag "Ask for each file" file)))
2766 ;; Cf. mm-postponed-undisplay-list / mm-destroy-postponed-undisplay-list.
2768 (defun gnus-article-browse-delete-temp-files (&optional how)
2769 "Delete temp-files created by `gnus-article-browse-html-parts'."
2770 (when (and gnus-article-browse-html-temp-list
2772 (or how (setq how gnus-article-browse-delete-temp))
2774 (let ((files (length gnus-article-browse-html-temp-list)))
2775 (gnus-y-or-n-p (format
2776 "Delete all %s temporary HTML file%s? "
2778 (if (> files 1) "s" ""))))
2780 (dolist (file gnus-article-browse-html-temp-list)
2781 (cond ((file-directory-p file)
2782 (when (or (not (eq how 'file))
2785 "Delete temporary HTML file(s) in directory `%s'? "
2786 (file-name-as-directory file))))
2787 (gnus-delete-directory file)))
2788 ((file-exists-p file)
2789 (when (or (not (eq how 'file))
2791 (format "Delete temporary HTML file `%s'? " file)))
2792 (delete-file file)))))
2793 ;; Also remove file from the list when not deleted or if file doesn't
2795 (setq gnus-article-browse-html-temp-list nil))
2796 gnus-article-browse-html-temp-list)
2798 (defun gnus-article-browse-html-save-cid-content (cid handles directory)
2799 "Find CID content in HANDLES and save it in a file in DIRECTORY.
2804 (dolist (handle handles)
2806 ((not (listp handle)))
2807 ((equal (mm-handle-media-supertype handle) "multipart")
2808 (when (setq file (gnus-article-browse-html-save-cid-content
2809 cid handle directory))
2810 (throw 'found file)))
2811 ((equal (concat "<" cid ">") (mm-handle-id handle))
2814 (or (mm-handle-filename handle)
2816 (make-temp-name "cid")
2817 (car (rassoc (car (mm-handle-type handle)) mailcap-mime-extensions))))
2819 (mm-save-part-to-file handle file)
2820 (throw 'found file))))))))
2822 (defun gnus-article-browse-html-parts (list &optional header)
2823 "View all \"text/html\" parts from LIST.
2824 Recurse into multiparts. The optional HEADER that should be a decoded
2825 message header will be added to the bodies of the \"text/html\" parts."
2826 ;; Internal function used by `gnus-article-browse-html-article'.
2827 (let (type file charset content cid-dir tmp-file showed)
2828 ;; Find and show the html-parts.
2829 (dolist (handle list)
2830 ;; If HTML, show it:
2831 (cond ((not (listp handle)))
2832 ((or (equal (car (setq type (mm-handle-type handle))) "text/html")
2833 (and (equal (car type) "message/external-body")
2835 (setq file (mm-handle-filename handle)))
2836 (or (mm-handle-cache handle)
2837 (condition-case code
2838 (progn (mm-extern-cache-contents handle) t)
2840 (gnus-message 3 "%s" (error-message-string code))
2841 (when (>= gnus-verbose 3) (sit-for 2))
2844 (setq handle (mm-handle-cache handle)
2845 type (mm-handle-type handle))
2846 (equal (car type) "text/html"))))
2847 (setq charset (mail-content-type-get type 'charset)
2848 content (mm-get-part handle))
2850 (if (eq charset 'gnus-decoded)
2851 (mm-enable-multibyte)
2852 (mm-disable-multibyte))
2854 ;; resolve cid contents
2855 (let ((case-fold-search t)
2857 (goto-char (point-min))
2858 (while (re-search-forward "\
2859 <img[\t\n ]+\\(?:[^\t\n >]+[\t\n ]+\\)*src=\"\\(cid:\\([^\"]+\\)\\)\""
2862 (setq cid-dir (mm-make-temp-file "cid" t))
2863 (add-to-list 'gnus-article-browse-html-temp-list cid-dir))
2866 (when (setq cid-file
2867 (gnus-article-browse-html-save-cid-content
2869 (with-current-buffer gnus-article-buffer
2870 gnus-article-mime-handles)
2872 (replace-match (concat "file://" cid-file)
2874 (unless content (setq content (buffer-string))))
2875 (when (or charset header (not file))
2876 (setq tmp-file (mm-make-temp-file
2877 ;; Do we need to care for 8.3 filenames?
2878 "mm-" nil ".html")))
2879 ;; Add a meta html tag to specify charset and a header.
2882 (let (title eheader body hcharset coding force-charset)
2884 (mm-enable-multibyte)
2885 (setq case-fold-search t)
2886 (insert header "\n")
2887 (setq title (message-fetch-field "subject"))
2888 (goto-char (point-min))
2889 (while (re-search-forward "\\(<\\)\\|\\(>\\)\\|&" nil t)
2890 (replace-match (cond ((match-beginning 1) "<")
2891 ((match-beginning 2) ">")
2893 (goto-char (point-min))
2895 (goto-char (point-max))
2896 (insert "</pre>\n<hr>\n")
2897 ;; We have to examine charset one by one since
2898 ;; charset specified in parts might be different.
2899 (if (eq charset 'gnus-decoded)
2900 (setq charset 'utf-8
2901 eheader (mm-encode-coding-string (buffer-string)
2904 (mm-encode-coding-string title charset))
2905 body (mm-encode-coding-string content charset)
2907 (setq hcharset (mm-find-mime-charset-region (point-min)
2909 (cond ((= (length hcharset) 1)
2910 (setq hcharset (car hcharset)
2911 coding (mm-charset-to-coding-system
2913 ((> (length hcharset) 1)
2914 (setq hcharset 'utf-8
2920 (mm-charset-to-coding-system charset))
2921 (if (eq coding body)
2922 (setq eheader (mm-encode-coding-string
2923 (buffer-string) coding)
2925 (mm-encode-coding-string
2928 (setq charset 'utf-8
2929 eheader (mm-encode-coding-string
2930 (buffer-string) charset)
2932 (mm-encode-coding-string
2934 body (mm-encode-coding-string
2935 (mm-decode-coding-string
2939 (setq charset hcharset
2940 eheader (mm-encode-coding-string
2941 (buffer-string) coding)
2943 (mm-encode-coding-string
2946 (setq eheader (mm-string-as-unibyte (buffer-string))
2949 (mm-disable-multibyte)
2952 (mm-add-meta-html-tag handle charset force-charset))
2954 (goto-char (point-min))
2955 (unless (search-forward "<title>" nil t)
2956 (re-search-forward "<head>\\s-*" nil t)
2957 (insert "<title>" title "</title>\n")))
2958 (goto-char (point-min))
2959 (or (re-search-forward
2960 "<body\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t)
2962 "</head\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t))
2964 (mm-write-region (point-min) (point-max)
2965 tmp-file nil nil nil 'binary t))))
2967 (mm-with-unibyte-buffer
2968 (insert (if (eq charset 'gnus-decoded)
2969 (mm-encode-coding-string content
2970 (setq charset 'utf-8))
2972 (if (or (mm-add-meta-html-tag handle charset)
2974 (mm-write-region (point-min) (point-max)
2975 tmp-file nil nil nil 'binary t)
2976 (setq tmp-file nil))))
2978 (mm-save-part-to-file handle tmp-file)))
2980 (add-to-list 'gnus-article-browse-html-temp-list tmp-file))
2981 (add-hook 'gnus-summary-prepare-exit-hook
2982 'gnus-article-browse-delete-temp-files)
2983 (add-hook 'gnus-exit-gnus-hook
2985 (gnus-article-browse-delete-temp-files t)))
2986 ;; FIXME: Warn if there's an <img> tag?
2987 (browse-url-of-file (or tmp-file (expand-file-name file)))
2989 ;; If multipart, recurse
2990 ((equal (mm-handle-media-supertype handle) "multipart")
2991 (when (gnus-article-browse-html-parts handle header)
2993 ((equal (mm-handle-media-type handle) "message/rfc822")
2994 (mm-with-multibyte-buffer
2995 (mm-insert-part handle)
2996 (setq handle (mm-dissect-buffer t t))
2997 (when (and (bufferp (car handle))
2998 (stringp (car (mm-handle-type handle))))
2999 (setq handle (list handle)))
3001 (article-decode-encoded-words)
3002 (let ((gnus-visible-headers
3003 (or (get 'gnus-visible-headers 'standard-value)
3004 gnus-visible-headers)))
3005 (article-hide-headers))
3006 (goto-char (point-min))
3007 (search-forward "\n\n" nil 'move)
3008 (skip-chars-backward "\t\n ")
3009 (setq header (buffer-substring (point-min) (point)))))
3011 (gnus-article-browse-html-parts handle header)
3012 (mm-destroy-parts handle))
3016 (defun gnus-article-browse-html-article (&optional arg)
3017 "View \"text/html\" parts of the current article with a WWW browser.
3018 Inline images embedded in a message using the cid scheme, as they are
3019 generally considered to be safe, will be processed properly.
3020 The message header is added to the beginning of every html part unless
3021 the prefix argument ARG is given.
3023 Warning: Spammers use links to images (using the http scheme) in HTML
3024 articles to verify whether you have read the message. As
3025 `gnus-article-browse-html-article' passes the HTML content to the
3026 browser without eliminating these \"web bugs\" you should only
3027 use it for mails from trusted senders.
3029 If you always want to display HTML parts in the browser, set
3030 `mm-text-html-renderer' to nil.
3032 This command creates temporary files to pass HTML contents including
3033 images if any to the browser, and deletes them when exiting the group
3035 ;; Cf. `mm-w3m-safe-url-regexp'
3038 (gnus-summary-show-article)
3039 (let ((gnus-visible-headers (or (get 'gnus-visible-headers 'standard-value)
3040 gnus-visible-headers))
3041 ;; As we insert a <hr>, there's no need for the body boundary.
3042 (gnus-treat-body-boundary nil))
3043 (gnus-summary-show-article)))
3044 (with-current-buffer gnus-article-buffer
3045 (let ((header (unless arg
3048 (buffer-substring-no-properties
3049 (goto-char (point-min))
3050 (if (search-forward "\n\n" nil t)
3052 (goto-char (point-max))
3053 (skip-chars-backward "\t\n ")
3056 (set-buffer gnus-original-article-buffer)
3057 (setq parts (mm-dissect-buffer t t))
3058 ;; If singlepart, enforce a list.
3059 (when (and (bufferp (car parts))
3060 (stringp (car (mm-handle-type parts))))
3061 (setq parts (list parts)))
3063 (unless (gnus-article-browse-html-parts parts header)
3064 (gnus-error 3 "Mail doesn't contain a \"text/html\" part!"))
3065 (mm-destroy-parts parts)
3067 (gnus-summary-show-article)))))
3069 (defun article-hide-list-identifiers ()
3070 "Remove list identifies from the Subject header.
3071 The `gnus-list-identifiers' variable specifies what to do."
3073 (let ((inhibit-point-motion-hooks t)
3074 (regexp (gnus-group-get-list-identifiers gnus-newsgroup-name))
3075 (inhibit-read-only t))
3079 (article-narrow-to-head)
3080 (goto-char (point-min))
3081 (while (re-search-forward
3082 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
3084 (delete-region (match-beginning 2) (match-end 0))
3085 (beginning-of-line))
3086 (when (re-search-forward
3087 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
3088 (delete-region (match-beginning 1) (match-end 1))))))))
3090 (defun article-hide-pem (&optional arg)
3091 "Toggle hiding of any PEM headers and signatures in the current article.
3092 If given a negative prefix, always show; if given a positive prefix,
3094 (interactive (gnus-article-hidden-arg))
3095 (unless (gnus-article-check-hidden-text 'pem arg)
3097 (let ((inhibit-read-only t) end)
3098 (goto-char (point-min))
3099 ;; Hide the horrendously ugly "header".
3100 (when (and (search-forward
3101 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
3103 (setq end (1+ (match-beginning 0))))
3104 (gnus-add-wash-type 'pem)
3105 (gnus-article-hide-text-type
3107 (if (search-forward "\n\n" nil t)
3111 ;; Hide the trailer as well
3112 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
3114 (gnus-article-hide-text-type
3115 (match-beginning 0) (match-end 0) 'pem)))))))
3117 (defun article-strip-banner ()
3118 "Strip the banners specified by the `banner' group parameter and by
3119 `gnus-article-address-banner-alist'."
3123 (let ((inhibit-point-motion-hooks t))
3124 (when (gnus-parameter-banner gnus-newsgroup-name)
3125 (article-really-strip-banner
3126 (gnus-parameter-banner gnus-newsgroup-name)))
3127 (when gnus-article-address-banner-alist
3128 ;; Note that the From header is decoded here, so it is
3129 ;; required that the *-extract-address-components function
3130 ;; supports non-ASCII text.
3131 (let ((from (save-restriction
3133 (article-narrow-to-head)
3134 (mail-fetch-field "from"))))
3137 (cadr (funcall gnus-extract-address-components
3140 (dolist (pair gnus-article-address-banner-alist)
3141 (when (string-match (car pair) from)
3143 (article-really-strip-banner (cdr pair)))))))))))))
3145 (defun article-really-strip-banner (banner)
3146 "Strip the banner specified by the argument."
3149 (let ((inhibit-point-motion-hooks t)
3150 (gnus-signature-limit nil)
3151 (inhibit-read-only t))
3154 ((eq banner 'signature)
3155 (when (gnus-article-narrow-to-signature)
3158 (delete-region (point) (point-max))))
3160 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
3161 (while (re-search-forward banner nil t)
3162 (delete-region (match-beginning 0) (match-end 0)))))
3164 (while (re-search-forward banner nil t)
3165 (delete-region (match-beginning 0) (match-end 0)))))))))
3167 (defun article-babel ()
3168 "Translate article using an online translation service."
3171 (gnus-with-article-buffer
3172 (when (article-goto-body)
3173 (let* ((start (point))
3175 (orig (buffer-substring start end))
3176 (trans (babel-as-string orig)))
3178 (narrow-to-region start end)
3179 (delete-region start end)
3182 (defun article-hide-signature (&optional arg)
3183 "Hide the signature in the current article.
3184 If given a negative prefix, always show; if given a positive prefix,
3186 (interactive (gnus-article-hidden-arg))
3187 (unless (gnus-article-check-hidden-text 'signature arg)
3190 (let ((inhibit-read-only t))
3191 (when (gnus-article-narrow-to-signature)
3192 (gnus-article-hide-text-type
3193 (point-min) (point-max) 'signature))))))
3194 (gnus-set-mode-line 'article))
3196 (defun article-strip-headers-in-body ()
3197 "Strip offensive headers from bodies."
3201 (let ((case-fold-search t))
3202 (when (looking-at "x-no-archive:")
3203 (gnus-delete-line)))))
3205 (defun article-strip-leading-blank-lines ()
3206 "Remove all blank lines from the beginning of the article."
3209 (let ((inhibit-point-motion-hooks t)
3210 (inhibit-read-only t))
3211 (when (article-goto-body)
3212 (while (and (not (eobp))
3213 (looking-at "[ \t]*$"))
3214 (gnus-delete-line))))))
3216 (defun article-narrow-to-head ()
3217 "Narrow the buffer to the head of the message.
3218 Point is left at the beginning of the narrowed-to region."
3220 (goto-char (point-min))
3221 (if (search-forward "\n\n" nil 1)
3224 (goto-char (point-min)))
3226 (defun article-goto-body ()
3227 "Place point at the start of the body."
3228 (goto-char (point-min))
3230 ;; This variable is only bound when dealing with separate
3232 (article-goto-body-goes-to-point-min-p
3234 ((search-forward "\n\n" nil t)
3237 (goto-char (point-max))
3240 (defun article-strip-multiple-blank-lines ()
3241 "Replace consecutive blank lines with one empty line."
3244 (let ((inhibit-point-motion-hooks t)
3245 (inhibit-read-only t))
3246 ;; First make all blank lines empty.
3248 (while (re-search-forward "^[ \t]+$" nil t)
3249 (unless (gnus-annotation-in-region-p
3250 (match-beginning 0) (match-end 0))
3251 (replace-match "" nil t)))
3252 ;; Then replace multiple empty lines with a single empty line.
3254 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
3255 (unless (gnus-annotation-in-region-p
3256 (match-beginning 0) (match-end 0))
3257 (delete-region (match-beginning 1) (match-end 1)))))))
3259 (defun article-strip-leading-space ()
3260 "Remove all white space from the beginning of the lines in the article."
3263 (let ((inhibit-point-motion-hooks t)
3264 (inhibit-read-only t))
3266 (while (re-search-forward "^[ \t]+" nil t)
3267 (replace-match "" t t)))))
3269 (defun article-strip-trailing-space ()
3270 "Remove all white space from the end of the lines in the article."
3273 (let ((inhibit-point-motion-hooks t)
3274 (inhibit-read-only t))
3276 (while (re-search-forward "[ \t]+$" nil t)
3277 (replace-match "" t t)))))
3279 (defun article-strip-blank-lines ()
3280 "Strip leading, trailing and multiple blank lines."
3282 (article-strip-leading-blank-lines)
3283 (article-remove-trailing-blank-lines)
3284 (article-strip-multiple-blank-lines))
3286 (defun article-strip-all-blank-lines ()
3287 "Strip all blank lines."
3290 (let ((inhibit-point-motion-hooks t)
3291 (inhibit-read-only t))
3293 (while (re-search-forward "^[ \t]*\n" nil t)
3294 (replace-match "" t t)))))
3296 (defun gnus-article-narrow-to-signature ()
3297 "Narrow to the signature; return t if a signature is found, else nil."
3298 (let ((inhibit-point-motion-hooks t))
3299 (when (gnus-article-search-signature)
3301 ;; Check whether we have some limits to what we consider
3302 ;; to be a signature.
3303 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
3304 (list gnus-signature-limit)))
3306 (while (setq limit (pop limits))
3307 (if (or (and (integerp limit)
3308 (< (- (point-max) (point)) limit))
3310 (< (count-lines (point) (point-max)) limit))
3311 (and (functionp limit)
3313 (and (stringp limit)
3314 (not (re-search-forward limit nil t))))
3315 () ; This limit did not succeed.
3319 (narrow-to-region (point) (point-max))
3322 (defun gnus-article-search-signature ()
3323 "Search the current buffer for the signature separator.
3324 Put point at the beginning of the signature separator."
3325 (let ((cur (point)))
3326 (goto-char (point-max))
3327 (if (if (stringp gnus-signature-separator)
3328 (re-search-backward gnus-signature-separator nil t)
3329 (let ((seps gnus-signature-separator))
3331 (not (re-search-backward (car seps) nil t)))
3338 (defun gnus-article-hidden-arg ()
3339 "Return the current prefix arg as a number, or 0 if no prefix."
3340 (list (if current-prefix-arg
3341 (prefix-numeric-value current-prefix-arg)
3344 (defun gnus-article-check-hidden-text (type arg)
3345 "Return nil if hiding is necessary.
3346 Arg can be nil or a number. nil and positive means hide, negative
3347 means show, 0 means toggle."
3350 (let ((hide (gnus-article-hidden-text-p type)))
3356 (gnus-article-show-hidden-text type)
3359 (if (eq hide 'hidden)
3361 (gnus-article-show-hidden-text type)
3365 (defun gnus-article-hidden-text-p (type)
3366 "Say whether the current buffer contains hidden text of type TYPE."
3367 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
3369 (not (get-text-property pos 'invisible))
3370 (not (get-text-property pos 'dummy-invisible)))
3372 (text-property-any (1+ pos) (point-max) 'article-type type)))
3377 (defun gnus-article-show-hidden-text (type &optional dummy)
3378 "Show all hidden text of type TYPE.
3379 Originally it is hide instead of DUMMY."
3380 (let ((inhibit-read-only t)
3381 (inhibit-point-motion-hooks t))
3382 (gnus-remove-text-properties-when
3384 (point-min) (point-max)
3385 (cons 'article-type (cons type
3386 gnus-hidden-properties)))
3387 (gnus-delete-wash-type type)))
3389 (defconst article-time-units
3390 `((year . ,(* 365.25 24 60 60))
3391 (week . ,(* 7 24 60 60))
3392 (day . ,(* 24 60 60))
3396 "Mapping from time units to seconds.")
3398 (defun gnus-article-forward-header ()
3399 "Move point to the start of the next header.
3400 If the current header is a continuation header, this can be several
3405 (if (looking-at "[ \t]+[^ \t]")
3409 (defun article-treat-date ()
3410 (article-date-ut (if (gnus-buffer-live-p gnus-summary-buffer)
3411 (with-current-buffer gnus-summary-buffer
3412 gnus-article-date-headers)
3413 gnus-article-date-headers)
3416 (defun article-date-ut (&optional type highlight date-position)
3417 "Convert DATE date to TYPE in the current article.
3418 The default type is `ut'. See `gnus-article-date-headers' for
3420 (interactive (list 'ut t))
3421 (let* ((case-fold-search t)
3422 (inhibit-read-only t)
3423 (inhibit-point-motion-hooks t)
3425 (visible-date (mail-fetch-field "Date"))
3426 pos date bface eface)
3429 (goto-char (point-min))
3430 (when (re-search-forward "^Date:" nil t)
3431 (setq bface (get-text-property (point-at-bol) 'face)
3432 eface (get-text-property (1- (point-at-eol)) 'face)))
3433 (goto-char (point-min))
3434 ;; Delete any old Date headers.
3437 (goto-char date-position)
3438 (setq date (get-text-property (point) 'original-date))
3439 (delete-region (point)
3441 (gnus-article-forward-header)
3443 (article-transform-date date type bface eface))
3444 (while (re-search-forward "^Date:" nil t)
3445 (setq date (get-text-property (match-beginning 0) 'original-date))
3446 (delete-region (point-at-bol) (progn
3447 (gnus-article-forward-header)
3449 (when (and (not date)
3451 (setq date visible-date))
3453 (article-transform-date date type bface eface)))))))
3455 (defun article-transform-date (date type bface eface)
3456 (dolist (this-type (cond
3463 (insert (article-make-date-line date (or this-type 'ut)) "\n")
3466 (put-text-property (point) (1+ (point))
3467 'original-date date)
3468 (put-text-property (point) (1+ (point))
3469 'gnus-date-type this-type)
3471 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
3472 (put-text-property (match-beginning 1) (1+ (match-end 1))
3474 (put-text-property (match-beginning 2) (match-end 2)
3478 (defun article-make-date-line (date type)
3479 "Return a DATE line of TYPE."
3480 (unless (memq type '(local ut original user-defined iso8601 lapsed english
3482 (error "Unknown conversion type: %s" type))
3484 (let ((time (ignore-errors (date-to-time date))))
3486 ;; Convert to the local timezone.
3488 (concat "Date: " (message-make-date time)))
3489 ;; Convert to Universal Time.
3494 (let* ((e (parse-time-string date))
3495 (tm (apply 'encode-time e))
3497 (ls (- (cadr tm) (car (current-time-zone time)))))
3498 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
3499 ((> ls 65535) (list (1+ ms) (- ls 65536)))
3503 ;; Get the original date from the article.
3504 ((eq type 'original)
3505 (concat "Date: " (if (string-match "\n+$" date)
3506 (substring date 0 (match-beginning 0))
3508 ;; Let the user define the format.
3509 ((eq type 'user-defined)
3510 (let ((format (or (condition-case nil
3511 (with-current-buffer gnus-summary-buffer
3512 gnus-article-time-format)
3514 gnus-article-time-format)))
3515 (if (functionp format)
3516 (funcall format time)
3517 (concat "Date: " (format-time-string format time)))))
3520 (let ((tz (car (current-time-zone time))))
3523 (format-time-string "%Y%m%dT%H%M%S" time)
3524 (format "%s%02d%02d"
3525 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3526 (/ (% (abs tz) 3600) 60)))))
3527 ;; Do a lapsed format.
3529 (concat "Date: " (article-lapsed-string time)))
3530 ;; A combined date/lapsed format.
3531 ((eq type 'combined-lapsed)
3532 (let ((date-string (article-make-date-line date 'original))
3538 (concat " (" (article-lapsed-string time segments) ")"))
3539 (> (+ (length date-string)
3540 (length lapsed-string))
3543 (setq segments (1- segments)))
3545 (concat date-string lapsed-string)
3547 ;; Display the date in proper English
3549 (let ((dtime (decode-time time)))
3552 (number-to-string (nth 3 dtime))
3553 (let ((digit (% (nth 3 dtime) 10)))
3555 ((memq (nth 3 dtime) '(11 12 13)) "th")
3561 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3563 (number-to-string (nth 5 dtime))
3565 (format "%02d" (nth 2 dtime))
3567 (format "%02d" (nth 1 dtime)))))))
3569 (format "Date: %s (from Gnus)" date))))
3571 (defun article-lapsed-string (time &optional max-segments)
3572 ;; If the date is seriously mangled, the timezone functions are
3573 ;; liable to bug out, so we ignore all errors.
3574 (let* ((now (current-time))
3575 (real-time (subtract-time now time))
3576 (real-sec (and real-time
3577 (+ (* (float (car real-time)) 65536)
3579 (sec (and real-time (abs real-sec)))
3582 (unless max-segments
3583 (setq max-segments (length article-time-units)))
3591 ;; This is a bit convoluted, but basically we go
3592 ;; through the time units for years, weeks, etc,
3593 ;; and divide things to see whether that results
3594 ;; in positive answers.
3597 (if (or (zerop (setq num (ffloor (/ sec (cdr unit)))))
3598 (>= segments max-segments))
3599 ;; The (remaining) seconds are too few to
3600 ;; be divided into this time unit.
3602 ;; It's big enough, so we output it.
3603 (setq sec (- sec (* num (cdr unit))))
3605 (concat (if prev ", " "") (int-to-string
3607 " " (symbol-name (car unit))
3608 (if (> num 1) "s" ""))
3610 segments (1+ segments)))))
3611 article-time-units "")
3612 ;; If dates are odd, then it might appear like the
3613 ;; article was sent in the future.
3616 " in the future"))))))
3618 (defun article-date-local (&optional highlight)
3619 "Convert the current article date to the local timezone."
3620 (interactive (list t))
3621 (article-date-ut 'local highlight))
3623 (defun article-date-english (&optional highlight)
3624 "Convert the current article date to something that is proper English."
3625 (interactive (list t))
3626 (article-date-ut 'english highlight))
3628 (defun article-date-original (&optional highlight)
3629 "Convert the current article date to what it was originally.
3630 This is only useful if you have used some other date conversion
3631 function and want to see what the date was before converting."
3632 (interactive (list t))
3633 (article-date-ut 'original highlight))
3635 (defun article-date-lapsed (&optional highlight)
3636 "Convert the current article date to time lapsed since it was sent."
3637 (interactive (list t))
3638 (article-date-ut 'lapsed highlight))
3640 (defun article-date-combined-lapsed (&optional highlight)
3641 "Convert the current article date to time lapsed since it was sent."
3642 (interactive (list t))
3643 (article-date-ut 'combined-lapsed highlight))
3645 (defun article-update-date-lapsed ()
3646 "Function to be run from a timer to update the lapsed time line."
3648 (let ((buffer (current-buffer)))
3652 (set-buffer (window-buffer w))
3653 (when (eq major-mode 'gnus-article-mode)
3654 (let ((old-line (count-lines (point-min) (point)))
3655 (old-column (- (point) (line-beginning-position)))
3657 (window-start (get-buffer-window (current-buffer)))))
3658 (goto-char (point-min))
3659 (while (re-search-forward "^Date:" nil t)
3660 (let ((type (get-text-property (match-beginning 0)
3662 (when (memq type '(lapsed combined-lapsed user-format))
3663 (when (and window-start
3664 (not (= window-start
3668 (setq window-start nil))
3670 (article-date-ut type t (match-beginning 0)))
3673 (set-window-start (get-buffer-window (current-buffer))
3675 (goto-char (point-min))
3676 (when (> old-column 0)
3677 (setq old-line (1- old-line)))
3678 (forward-line old-line)
3680 (when (> (current-column) old-column)
3682 (forward-char old-column)))))
3684 (set-buffer buffer))))
3686 (defun gnus-start-date-timer (&optional n)
3687 "Start a timer to update the Date headers in the article buffers.
3688 The numerical prefix says how frequently (in seconds) the function
3693 (gnus-stop-date-timer)
3694 (setq article-lapsed-timer
3695 (run-at-time 1 n 'article-update-date-lapsed)))
3697 (defun gnus-stop-date-timer ()
3698 "Stop the Date timer."
3700 (when article-lapsed-timer
3701 (nnheader-cancel-timer article-lapsed-timer)
3702 (setq article-lapsed-timer nil)))
3704 (defun article-date-user (&optional highlight)
3705 "Convert the current article date to the user-defined format.
3706 This format is defined by the `gnus-article-time-format' variable."
3707 (interactive (list t))
3708 (article-date-ut 'user highlight))
3710 (defun article-date-iso8601 (&optional highlight)
3711 "Convert the current article date to ISO8601."
3712 (interactive (list t))
3713 (article-date-ut 'iso8601 highlight))
3715 (defmacro gnus-article-save-original-date (&rest forms)
3716 "Save the original date as a text property and evaluate FORMS."
3717 `(let* ((case-fold-search t)
3719 (goto-char (point-min))
3720 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3723 (date (when (and start
3724 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3726 (buffer-substring-no-properties start
3727 (match-beginning 0)))))
3728 (goto-char (point-max))
3729 (skip-chars-backward "\n")
3730 (put-text-property (point-min) (point) 'original-date date)
3732 (goto-char (point-max))
3733 (skip-chars-backward "\n")
3734 (put-text-property (point-min) (point) 'original-date date)))
3736 ;; (defun article-show-all ()
3737 ;; "Show all hidden text in the article buffer."
3740 ;; (let ((inhibit-read-only t))
3741 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3743 (defun article-remove-leading-whitespace ()
3744 "Remove excessive whitespace from all headers."
3748 (let ((inhibit-read-only t))
3749 (article-narrow-to-head)
3750 (goto-char (point-min))
3751 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3752 (delete-region (match-beginning 1) (match-end 1)))))))
3754 (defun article-emphasize (&optional arg)
3755 "Emphasize text according to `gnus-emphasis-alist'."
3756 (interactive (gnus-article-hidden-arg))
3757 (unless (gnus-article-check-hidden-text 'emphasis arg)
3761 (with-current-buffer gnus-summary-buffer
3762 gnus-article-emphasis-alist)
3764 gnus-emphasis-alist))
3765 (inhibit-read-only t)
3766 (props (append '(article-type emphasis)
3767 gnus-hidden-properties))
3768 regexp elem beg invisible visible face)
3771 (while (setq elem (pop alist))
3773 (setq regexp (car elem)
3774 invisible (nth 1 elem)
3775 visible (nth 2 elem)
3777 (while (re-search-forward regexp nil t)
3778 (when (and (match-beginning visible) (match-beginning invisible))
3779 (gnus-article-hide-text
3780 (match-beginning invisible) (match-end invisible) props)
3781 (gnus-article-unhide-text-type
3782 (match-beginning visible) (match-end visible) 'emphasis)
3783 (gnus-put-overlay-excluding-newlines
3784 (match-beginning visible) (match-end visible) 'face face)
3785 (gnus-add-wash-type 'emphasis)
3786 (goto-char (match-end invisible)))))))))
3788 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3789 "Setup newsgroup emphasis alist."
3790 (unless gnus-article-emphasis-alist
3791 (let ((name (and gnus-newsgroup-name
3792 (gnus-group-real-name gnus-newsgroup-name))))
3793 (make-local-variable 'gnus-article-emphasis-alist)
3794 (setq gnus-article-emphasis-alist
3796 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3797 (while (setq elem (pop alist))
3798 (when (and name (string-match (car elem) name))
3800 highlight (copy-sequence (cdr elem)))))
3802 (copy-sequence highlight-words)
3803 (if gnus-newsgroup-name
3804 (copy-sequence (gnus-group-find-parameter
3805 gnus-newsgroup-name 'highlight-words t)))
3806 gnus-emphasis-alist)))))
3808 (defvar gnus-summary-article-menu)
3809 (defvar gnus-summary-post-menu)
3811 ;;; Saving functions.
3813 (defun gnus-article-save (save-buffer file &optional num)
3814 "Save the currently selected article."
3815 (when (or (get gnus-default-article-saver :headers)
3816 (not gnus-save-all-headers))
3817 ;; Remove headers according to `gnus-saved-headers' or the value
3818 ;; of the `:headers' property that the saver function might have.
3819 (let ((gnus-visible-headers
3820 (or (symbol-value (get gnus-default-article-saver :headers))
3821 gnus-saved-headers gnus-visible-headers))
3822 ;; Ignore group parameter. See `article-hide-headers'.
3823 (gnus-summary-buffer nil))
3824 (with-current-buffer save-buffer
3825 (article-hide-headers 1 t))))
3826 (save-window-excursion
3827 (if (not gnus-default-article-saver)
3828 (error "No default saver is defined")
3829 ;; !!! Magic! The saving functions all save
3830 ;; `gnus-save-article-buffer' (or so they think), but we
3831 ;; bind that variable to our save-buffer.
3832 (set-buffer gnus-article-buffer)
3833 (let* ((gnus-save-article-buffer save-buffer)
3836 ((not gnus-prompt-before-saving) 'default)
3837 ((eq gnus-prompt-before-saving 'always) nil)
3839 (gnus-number-of-articles-to-be-saved
3840 (when (eq gnus-prompt-before-saving t)
3842 (set-buffer gnus-article-current-summary)
3843 (funcall gnus-default-article-saver filename)))))
3845 (defun gnus-read-save-file-name (prompt &optional filename
3846 function group headers variable
3849 (funcall function group headers (symbol-value variable)))
3854 ((eq filename 'default)
3860 (when (symbol-value dir-var)
3861 (setq default-name (expand-file-name
3862 (file-name-nondirectory default-name)
3863 (symbol-value dir-var))))
3864 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3867 (if (and gnus-number-of-articles-to-be-saved
3868 (> gnus-number-of-articles-to-be-saved 1))
3869 (format "these %d articles"
3870 gnus-number-of-articles-to-be-saved)
3873 ;; Let the split methods have their say.
3875 ;; No split name was found.
3878 (concat prompt " (default "
3879 (file-name-nondirectory default-name) "): ")
3880 (file-name-directory default-name)
3882 ;; A single group name is returned.
3883 ((stringp split-name)
3885 (funcall function split-name headers
3886 (symbol-value variable)))
3888 (concat prompt " (default "
3889 (file-name-nondirectory default-name) "): ")
3890 (file-name-directory default-name)
3892 ;; A single split name was found
3893 ((= 1 (length split-name))
3894 (let* ((name (expand-file-name
3896 gnus-article-save-directory))
3897 (dir (cond ((file-directory-p name)
3898 (file-name-as-directory name))
3899 ((file-exists-p name) name)
3900 (t gnus-article-save-directory))))
3902 (concat prompt " (default " name "): ")
3904 ;; A list of splits was found.
3906 (setq split-name (nreverse split-name))
3908 (let ((file-name-history
3909 (nconc split-name file-name-history)))
3913 (concat prompt " (`M-p' for defaults): ")
3914 gnus-article-save-directory
3916 gnus-article-save-directory)))
3917 (car (push result file-name-history)))))))
3918 ;; Create the directory.
3919 (gnus-make-directory (file-name-directory file))
3920 ;; If we have read a directory, we append the default file name.
3921 (when (file-directory-p file)
3922 (setq file (expand-file-name (file-name-nondirectory
3924 (file-name-as-directory file))))
3925 ;; Possibly translate some characters.
3926 (nnheader-translate-file-chars file))))))
3927 (gnus-make-directory (file-name-directory result))
3929 (set variable result))
3931 (set dir-var (file-name-directory result)))
3934 (defun gnus-article-archive-name (group)
3935 "Return the first instance of an \"Archive-name\" in the current buffer."
3936 (let ((case-fold-search t))
3937 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3938 (nnheader-concat gnus-article-save-directory
3939 (match-string 1)))))
3941 (defun gnus-article-nndoc-name (group)
3942 "If GROUP is an nndoc group, return the name of the parent group."
3943 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3944 (gnus-group-get-parameter group 'save-article-group)))
3946 (defun gnus-summary-save-in-rmail (&optional filename)
3947 "Append this article to Rmail file.
3948 Optional argument FILENAME specifies file name.
3949 Directory to save to is default to `gnus-article-save-directory'."
3950 (setq filename (gnus-read-save-file-name
3951 "Save %s in rmail file" filename
3952 gnus-rmail-save-name gnus-newsgroup-name
3953 gnus-current-headers 'gnus-newsgroup-last-rmail))
3954 (with-current-buffer gnus-save-article-buffer
3958 ;; Note that unlike gnus-summary-save-in-mail, there is no
3959 ;; check to see if filename is Babyl. Rmail in Emacs 23 does
3961 (gnus-output-to-rmail filename))))
3964 (defun gnus-summary-save-in-mail (&optional filename)
3965 "Append this article to Unix mail file.
3966 Optional argument FILENAME specifies file name.
3967 Directory to save to is default to `gnus-article-save-directory'."
3968 (setq filename (gnus-read-save-file-name
3969 "Save %s in Unix mail file" filename
3970 gnus-mail-save-name gnus-newsgroup-name
3971 gnus-current-headers 'gnus-newsgroup-last-mail))
3972 (with-current-buffer gnus-save-article-buffer
3976 (if (and (file-readable-p filename)
3977 (file-regular-p filename)
3978 (mail-file-babyl-p filename))
3979 (gnus-output-to-rmail filename)
3980 (gnus-output-to-mail filename)))))
3983 (put 'gnus-summary-save-in-file :decode t)
3984 (put 'gnus-summary-save-in-file :headers 'gnus-saved-headers)
3985 (defun gnus-summary-save-in-file (&optional filename overwrite)
3986 "Append this article to file.
3987 Optional argument FILENAME specifies file name.
3988 Directory to save to is default to `gnus-article-save-directory'."
3989 (setq filename (gnus-read-save-file-name
3990 "Save %s in file" filename
3991 gnus-file-save-name gnus-newsgroup-name
3992 gnus-current-headers 'gnus-newsgroup-last-file))
3993 (with-current-buffer gnus-save-article-buffer
3997 (when (and overwrite
3998 (file-exists-p filename))
3999 (delete-file filename))
4000 (gnus-output-to-file filename))))
4003 (put 'gnus-summary-write-to-file :decode t)
4004 (put 'gnus-summary-write-to-file :function 'gnus-summary-save-in-file)
4005 (put 'gnus-summary-write-to-file :headers 'gnus-saved-headers)
4006 (defun gnus-summary-write-to-file (&optional filename)
4007 "Write this article to a file, overwriting it if the file exists.
4008 Optional argument FILENAME specifies file name.
4009 The directory to save in defaults to `gnus-article-save-directory'."
4010 (setq filename (gnus-read-save-file-name
4011 "Save %s in file" filename
4012 gnus-file-save-name gnus-newsgroup-name
4013 gnus-current-headers nil 'gnus-newsgroup-last-directory))
4014 (gnus-summary-save-in-file filename t))
4016 (put 'gnus-summary-save-body-in-file :decode t)
4017 (defun gnus-summary-save-body-in-file (&optional filename overwrite)
4018 "Append this article body to a file.
4019 Optional argument FILENAME specifies file name.
4020 The directory to save in defaults to `gnus-article-save-directory'."
4021 (setq filename (gnus-read-save-file-name
4022 "Save %s body in file" filename
4023 gnus-file-save-name gnus-newsgroup-name
4024 gnus-current-headers 'gnus-newsgroup-last-file))
4025 (with-current-buffer gnus-save-article-buffer
4029 (when (article-goto-body)
4030 (narrow-to-region (point) (point-max)))
4031 (when (and overwrite
4032 (file-exists-p filename))
4033 (delete-file filename))
4034 (gnus-output-to-file filename))))
4037 (put 'gnus-summary-write-body-to-file :decode t)
4038 (put 'gnus-summary-write-body-to-file
4039 :function 'gnus-summary-save-body-in-file)
4040 (defun gnus-summary-write-body-to-file (&optional filename)
4041 "Write this article body to a file, overwriting it if the file exists.
4042 Optional argument FILENAME specifies file name.
4043 The directory to save in defaults to `gnus-article-save-directory'."
4044 (setq filename (gnus-read-save-file-name
4045 "Save %s body in file" filename
4046 gnus-file-save-name gnus-newsgroup-name
4047 gnus-current-headers nil 'gnus-newsgroup-last-directory))
4048 (gnus-summary-save-body-in-file filename t))
4050 (put 'gnus-summary-save-in-pipe :decode t)
4051 (put 'gnus-summary-save-in-pipe :headers 'gnus-saved-headers)
4052 (defun gnus-summary-save-in-pipe (&optional command raw)
4053 "Pipe this article to subprocess COMMAND.
4054 Valid values for COMMAND include:
4056 The executable command name and possibly arguments.
4058 You will be prompted for the command in the minibuffer.
4059 the symbol `default'
4060 It will be replaced with the command which the variable
4061 `gnus-summary-pipe-output-default-command' holds or the command
4062 last used for saving.
4063 Non-nil value for RAW overrides `:decode' and `:headers' properties
4064 and the raw article including all headers will be piped."
4065 (let ((article (gnus-summary-article-number))
4067 (get 'gnus-summary-save-in-pipe :decode)))
4068 save-buffer default)
4070 (if (vectorp (gnus-summary-article-header article))
4071 (save-current-buffer
4072 (gnus-summary-select-article decode decode nil article)
4073 (insert-buffer-substring
4077 gnus-original-article-buffer)
4079 (nnheader-set-temp-buffer " *Gnus Save*"))))
4080 ;; Remove unwanted headers.
4081 (when (and (not raw)
4082 (or (get 'gnus-summary-save-in-pipe :headers)
4083 (not gnus-save-all-headers)))
4084 (let ((gnus-visible-headers
4085 (or (symbol-value (get 'gnus-summary-save-in-pipe
4087 gnus-saved-headers gnus-visible-headers))
4088 (gnus-summary-buffer nil))
4089 (article-hide-headers 1 t))))
4090 (error "%d is not a real article" article))
4091 (error "No article to pipe"))
4092 (setq default (or gnus-summary-pipe-output-default-command
4093 gnus-last-shell-command))
4094 (unless (stringp command)
4096 (if (and (eq command 'default) default)
4098 (gnus-read-shell-command "Shell command on this article: "
4100 (when (string-equal command "")
4102 (setq command default)
4103 (error "A command is required")))
4104 (with-current-buffer save-buffer
4107 (shell-command-on-region (point-min) (point-max) command nil)))
4108 (gnus-kill-buffer save-buffer))
4109 (setq gnus-summary-pipe-output-default-command command))
4111 (defun gnus-summary-pipe-to-muttprint (&optional command)
4112 "Pipe this article to muttprint."
4113 (unless (stringp command)
4114 (setq command (read-string
4115 "Print using command: " gnus-summary-muttprint-program
4116 nil gnus-summary-muttprint-program)))
4117 (let ((gnus-summary-pipe-output-default-command
4118 gnus-summary-pipe-output-default-command))
4119 (gnus-summary-save-in-pipe command))
4120 (setq gnus-summary-muttprint-program command))
4122 ;;; Article file names when saving.
4124 (defun gnus-capitalize-newsgroup (newsgroup)
4125 "Capitalize NEWSGROUP name."
4126 (when (not (zerop (length newsgroup)))
4127 (concat (char-to-string (upcase (aref newsgroup 0)))
4128 (substring newsgroup 1))))
4130 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
4131 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4132 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
4133 Otherwise, it is like ~/News/news/group/num."
4136 (concat (if (gnus-use-long-file-name 'not-save)
4137 (gnus-capitalize-newsgroup newsgroup)
4138 (gnus-newsgroup-directory-form newsgroup))
4139 "/" (int-to-string (mail-header-number headers)))
4140 gnus-article-save-directory)))
4142 (string-equal (file-name-directory default)
4143 (file-name-directory last-file))
4144 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
4146 (or last-file default))))
4148 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
4149 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4150 If variable `gnus-use-long-file-name' is non-nil, it is
4151 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
4154 (concat (if (gnus-use-long-file-name 'not-save)
4156 (gnus-newsgroup-directory-form newsgroup))
4157 "/" (int-to-string (mail-header-number headers)))
4158 gnus-article-save-directory)))
4160 (string-equal (file-name-directory default)
4161 (file-name-directory last-file))
4162 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
4164 (or last-file default))))
4166 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
4167 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4168 If variable `gnus-use-long-file-name' is non-nil, it is
4169 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
4172 (if (gnus-use-long-file-name 'not-save)
4175 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
4177 gnus-article-save-directory)))
4179 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
4180 "Generate file name from sender."
4181 (let ((from (mail-header-from headers)))
4183 (if (and from (string-match "\\([^ <]+\\)@" from))
4184 (match-string 1 from)
4186 gnus-article-save-directory)))
4188 (defun article-verify-x-pgp-sig ()
4190 ;; <ftp://ftp.isc.org/pub/pgpcontrol/FORMAT>
4192 (if (gnus-buffer-live-p gnus-original-article-buffer)
4193 (let ((sig (with-current-buffer gnus-original-article-buffer
4194 (gnus-fetch-field "X-PGP-Sig")))
4198 (mml2015-clear-verify-function))
4200 (insert-buffer-substring gnus-original-article-buffer)
4201 (setq items (split-string sig))
4202 (message-narrow-to-head)
4203 (let ((inhibit-point-motion-hooks t)
4204 (case-fold-search t))
4205 ;; Don't verify multiple headers.
4206 (setq headers (mapconcat (lambda (header)
4208 (mail-fetch-field header)
4210 (split-string (nth 1 items) ",") "")))
4211 (delete-region (point-min) (point-max))
4212 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
4213 (insert "X-Signed-Headers: " (nth 1 items) "\n")
4218 (if (looking-at "^-")
4221 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
4222 (insert "Version: " (car items) "\n\n")
4223 (insert (mapconcat 'identity (cddr items) "\n"))
4224 (insert "\n-----END PGP SIGNATURE-----\n")
4225 (let ((mm-security-handle (list (format "multipart/signed"))))
4226 (mml2015-clean-buffer)
4227 (let ((coding-system-for-write (or gnus-newsgroup-charset
4229 (funcall (mml2015-clear-verify-function)))
4231 (or (mm-handle-multipart-ctl-parameter
4232 mm-security-handle 'gnus-details)
4233 (mm-handle-multipart-ctl-parameter
4234 mm-security-handle 'gnus-info)))))
4236 (let ((inhibit-read-only t) bface eface)
4238 (message-narrow-to-head)
4239 (goto-char (point-max))
4241 (setq bface (get-text-property (point-at-bol) 'face)
4242 eface (get-text-property (1- (point-at-eol)) 'face))
4243 (message-remove-header "X-Gnus-PGP-Verify")
4244 (if (re-search-forward "^X-PGP-Sig:" nil t)
4246 (goto-char (point-max)))
4247 (narrow-to-region (point) (point))
4248 (insert "X-Gnus-PGP-Verify: " info "\n")
4249 (goto-char (point-min))
4252 (if (not (looking-at "^[ \t]"))
4256 (goto-char (point-min))
4257 (when (looking-at "\\([^:]+\\): *")
4258 (put-text-property (match-beginning 1) (1+ (match-end 1))
4260 (put-text-property (match-end 0) (point-max)
4261 'face eface)))))))))
4263 (autoload 'canlock-verify "canlock" nil t) ;; for XEmacs.
4265 (defun article-verify-cancel-lock ()
4266 "Verify Cancel-Lock header."
4268 (if (gnus-buffer-live-p gnus-original-article-buffer)
4269 (canlock-verify gnus-original-article-buffer)))
4276 (setq afunc (car func)
4279 gfunc (intern (format "gnus-%s" func))))
4281 (when (fboundp afunc)
4282 `(lambda (&optional interactive &rest args)
4283 ,(documentation afunc t)
4284 (interactive (list t))
4285 (with-current-buffer gnus-article-buffer
4287 (call-interactively ',afunc)
4288 (apply ',afunc args))))))))
4289 '(article-hide-headers
4290 article-verify-x-pgp-sig
4291 article-verify-cancel-lock
4292 article-hide-boring-headers
4293 article-treat-overstrike
4294 article-treat-ansi-sequences
4295 article-fill-long-lines
4296 article-capitalize-sentences
4298 article-remove-leading-whitespace
4299 article-display-x-face
4300 article-display-face
4301 article-de-quoted-unreadable
4302 article-de-base64-unreadable
4305 article-unsplit-urls
4306 article-hide-list-identifiers
4307 article-strip-banner
4310 article-hide-signature
4311 article-strip-headers-in-body
4312 article-remove-trailing-blank-lines
4313 article-strip-leading-blank-lines
4314 article-strip-multiple-blank-lines
4315 article-strip-leading-space
4316 article-strip-trailing-space
4317 article-strip-blank-lines
4318 article-strip-all-blank-lines
4320 article-date-english
4321 article-date-iso8601
4322 article-date-original
4325 article-decode-mime-words
4326 article-decode-charset
4327 article-decode-encoded-words
4330 article-date-combined-lapsed
4332 article-treat-dumbquotes
4333 article-treat-non-ascii
4334 article-normalize-headers
4335 ;;(article-show-all . gnus-article-show-all-headers)
4339 ;;; Gnus article mode
4342 (put 'gnus-article-mode 'mode-class 'special)
4344 (set-keymap-parent gnus-article-mode-map widget-keymap)
4346 (gnus-define-keys gnus-article-mode-map
4347 " " gnus-article-goto-next-page
4348 "\177" gnus-article-goto-prev-page
4349 [delete] gnus-article-goto-prev-page
4350 [backspace] gnus-article-goto-prev-page
4351 "\C-c^" gnus-article-refer-article
4352 "h" gnus-article-show-summary
4353 "s" gnus-article-show-summary
4354 "\C-c\C-m" gnus-article-mail
4355 "?" gnus-article-describe-briefly
4356 "<" beginning-of-buffer
4358 "\C-c\C-i" gnus-info-find-node
4360 "R" gnus-article-reply-with-original
4361 "F" gnus-article-followup-with-original
4362 "\C-hk" gnus-article-describe-key
4363 "\C-hc" gnus-article-describe-key-briefly
4364 "\C-hb" gnus-article-describe-bindings
4366 "e" gnus-article-read-summary-keys
4367 "\C-d" gnus-article-read-summary-keys
4368 "\M-*" gnus-article-read-summary-keys
4369 "\M-#" gnus-article-read-summary-keys
4370 "\M-^" gnus-article-read-summary-keys
4371 "\M-g" gnus-article-read-summary-keys)
4373 (substitute-key-definition
4374 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
4376 (gnus-define-keys (gnus-article-send-map "S" gnus-article-mode-map)
4377 "W" gnus-article-wide-reply-with-original)
4378 (if (featurep 'xemacs)
4379 (set-keymap-default-binding gnus-article-send-map
4380 'gnus-article-read-summary-send-keys)
4381 (define-key gnus-article-send-map [t] 'gnus-article-read-summary-send-keys))
4383 (defun gnus-article-make-menu-bar ()
4384 (unless (boundp 'gnus-article-commands-menu)
4385 (gnus-summary-make-menu-bar))
4386 (unless (boundp 'gnus-article-article-menu)
4388 gnus-article-article-menu gnus-article-mode-map ""
4390 ["Scroll forwards" gnus-article-goto-next-page t]
4391 ["Scroll backwards" gnus-article-goto-prev-page t]
4392 ["Show summary" gnus-article-show-summary t]
4393 ["Fetch Message-ID at point" gnus-article-refer-article t]
4394 ["Mail to address at point" gnus-article-mail t]
4395 ["Send a bug report" gnus-bug t]))
4398 gnus-article-treatment-menu gnus-article-mode-map ""
4399 ;; Fixme: this should use :active (and maybe :visible).
4401 ["Hide headers" gnus-article-hide-headers t]
4402 ["Hide signature" gnus-article-hide-signature t]
4403 ["Hide citation" gnus-article-hide-citation t]
4404 ["Treat overstrike" gnus-article-treat-overstrike t]
4405 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
4406 ["Remove carriage return" gnus-article-remove-cr t]
4407 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
4408 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
4409 ["Remove base64" gnus-article-de-base64-unreadable t]
4410 ["Treat html" gnus-article-wash-html t]
4411 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
4412 ["Decode HZ" gnus-article-decode-HZ t]))
4414 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
4416 ;; Note "Post" menu is defined in gnus-sum.el for consistency
4418 (gnus-run-hooks 'gnus-article-menu-hook)))
4420 (defvar bookmark-make-record-function)
4421 (defvar shr-put-image-function)
4423 (defun gnus-article-mode ()
4424 "Major mode for displaying an article.
4426 All normal editing commands are switched off.
4428 The following commands are available in addition to all summary mode
4430 \\<gnus-article-mode-map>
4431 \\[gnus-article-next-page]\t Scroll the article one page forwards
4432 \\[gnus-article-prev-page]\t Scroll the article one page backwards
4433 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
4434 \\[gnus-article-show-summary]\t Display the summary buffer
4435 \\[gnus-article-mail]\t Send a reply to the address near point
4436 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
4437 \\[gnus-info-find-node]\t Go to the Gnus info node"
4439 (kill-all-local-variables)
4440 (gnus-simplify-mode-line)
4441 (setq mode-name "Article")
4442 (setq major-mode 'gnus-article-mode)
4443 (make-local-variable 'minor-mode-alist)
4444 (use-local-map gnus-article-mode-map)
4445 (when (gnus-visual-p 'article-menu 'menu)
4446 (gnus-article-make-menu-bar)
4447 (when gnus-summary-tool-bar-map
4448 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
4449 (gnus-update-format-specifications nil 'article-mode)
4450 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
4451 (set (make-local-variable 'gnus-page-broken) nil)
4452 (make-local-variable 'gnus-article-current-summary)
4453 (make-local-variable 'gnus-article-mime-handles)
4454 (make-local-variable 'gnus-article-decoded-p)
4455 (make-local-variable 'gnus-article-mime-handle-alist)
4456 (make-local-variable 'gnus-article-wash-types)
4457 (make-local-variable 'gnus-article-image-alist)
4458 (make-local-variable 'gnus-article-charset)
4459 (make-local-variable 'gnus-article-ignored-charsets)
4460 (set (make-local-variable 'bookmark-make-record-function)
4461 'gnus-summary-bookmark-make-record)
4462 ;; Prevent Emacs 22 from displaying non-break space with `nobreak-space'
4464 (set (make-local-variable 'nobreak-char-display) nil)
4465 ;; Enable `gnus-article-remove-images' to delete images shr.el renders.
4466 (set (make-local-variable 'shr-put-image-function) 'gnus-shr-put-image)
4467 (setq cursor-in-non-selected-windows nil)
4468 (gnus-set-default-directory)
4469 (buffer-disable-undo)
4470 (setq buffer-read-only t
4471 show-trailing-whitespace nil)
4472 (set-syntax-table gnus-article-mode-syntax-table)
4473 (mm-enable-multibyte)
4474 (gnus-run-mode-hooks 'gnus-article-mode-hook))
4476 (defun gnus-article-setup-buffer ()
4477 "Initialize the article buffer."
4478 (let* ((name (if gnus-single-article-buffer "*Article*"
4479 (concat "*Article " gnus-newsgroup-name "*")))
4481 (progn (string-match "\\*Article" name)
4482 (concat " *Original Article"
4483 (substring name (match-end 0))))))
4484 (setq gnus-article-buffer name)
4485 (setq gnus-original-article-buffer original)
4486 (setq gnus-article-mime-handle-alist nil)
4487 (with-current-buffer gnus-summary-buffer
4488 ;; This might be a variable local to the summary buffer.
4489 (unless gnus-single-article-buffer
4490 (setq gnus-article-buffer name)
4491 (setq gnus-original-article-buffer original)
4492 (gnus-set-global-variables)))
4493 (gnus-article-setup-highlight-words)
4494 ;; Init original article buffer.
4495 (with-current-buffer (gnus-get-buffer-create gnus-original-article-buffer)
4496 (mm-enable-multibyte)
4497 (setq major-mode 'gnus-original-article-mode)
4498 (make-local-variable 'gnus-original-article))
4499 (if (and (get-buffer name)
4500 (with-current-buffer name
4501 (if gnus-article-edit-mode
4502 (if (y-or-n-p "Article mode edit in progress; discard? ")
4504 (set-buffer-modified-p nil)
4505 (gnus-kill-buffer name)
4508 (error "Action aborted"))
4510 (with-current-buffer name
4511 (set (make-local-variable 'gnus-article-edit-mode) nil)
4512 (when gnus-article-mime-handles
4513 (mm-destroy-parts gnus-article-mime-handles)
4514 (setq gnus-article-mime-handles nil))
4515 ;; Set it to nil in article-buffer!
4516 (setq gnus-article-mime-handle-alist nil)
4517 (buffer-disable-undo)
4518 (setq buffer-read-only t)
4519 (unless (eq major-mode 'gnus-article-mode)
4520 (gnus-article-mode))
4521 (setq truncate-lines gnus-article-truncate-lines)
4523 (with-current-buffer (gnus-get-buffer-create name)
4525 (setq truncate-lines gnus-article-truncate-lines)
4526 (make-local-variable 'gnus-summary-buffer)
4527 (setq gnus-summary-buffer
4528 (gnus-summary-buffer-name gnus-newsgroup-name))
4529 (gnus-summary-set-local-parameters gnus-newsgroup-name)
4530 (when article-lapsed-timer
4531 (gnus-stop-date-timer))
4532 (when gnus-article-update-date-headers
4533 (gnus-start-date-timer gnus-article-update-date-headers))
4534 (current-buffer)))))
4536 ;; Set article window start at LINE, where LINE is the number of lines
4537 ;; from the head of the article.
4538 (defun gnus-article-set-window-start (&optional line)
4539 (let ((article-window (gnus-get-buffer-window gnus-article-buffer t)))
4540 (when article-window
4543 (with-current-buffer gnus-article-buffer
4544 (goto-char (point-min))
4547 (gnus-message 6 "Moved to bookmark")
4548 (search-forward "\n\n" nil t)
4552 (defun gnus-article-prepare (article &optional all-headers header)
4553 "Prepare ARTICLE in article mode buffer.
4554 ARTICLE should either be an article number or a Message-ID.
4555 If ARTICLE is an id, HEADER should be the article headers.
4556 If ALL-HEADERS is non-nil, no headers are hidden."
4558 ;; Make sure we start in a summary buffer.
4559 (unless (eq major-mode 'gnus-summary-mode)
4560 (set-buffer gnus-summary-buffer))
4561 (setq gnus-summary-buffer (current-buffer))
4562 (let* ((gnus-article (if header (mail-header-number header) article))
4563 (summary-buffer (current-buffer))
4564 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4565 (group gnus-newsgroup-name)
4568 (gnus-article-setup-buffer)
4569 (set-buffer gnus-article-buffer)
4570 ;; Deactivate active regions.
4571 (when (and (boundp 'transient-mark-mode)
4572 transient-mark-mode)
4573 (setq mark-active nil))
4574 (if (not (setq result (let ((inhibit-read-only t))
4575 (gnus-request-article-this-buffer
4577 ;; There is no such article.
4579 (when (and (numberp article)
4580 (not (memq article gnus-newsgroup-sparse)))
4581 (setq gnus-article-current
4582 (cons gnus-newsgroup-name article))
4583 (set-buffer gnus-summary-buffer)
4584 (setq gnus-current-article article)
4585 (if (and (memq article gnus-newsgroup-undownloaded)
4586 (not (gnus-online (gnus-find-method-for-group
4587 gnus-newsgroup-name))))
4589 (gnus-summary-set-agent-mark article)
4590 (message "Message marked for downloading"))
4591 (gnus-summary-mark-article article gnus-canceled-mark)
4592 (unless (memq article gnus-newsgroup-sparse)
4593 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4594 (if (or (eq result 'pseudo)
4595 (eq result 'nneething))
4597 (with-current-buffer summary-buffer
4598 (push article gnus-newsgroup-history)
4599 (setq gnus-last-article gnus-current-article
4600 gnus-current-article 0
4601 gnus-current-headers nil
4602 gnus-article-current nil)
4603 (if (eq result 'nneething)
4604 (gnus-configure-windows 'summary)
4605 (gnus-configure-windows 'article))
4606 (gnus-set-global-variables))
4607 (let ((gnus-article-mime-handle-alist-1
4608 gnus-article-mime-handle-alist))
4609 (gnus-set-mode-line 'article)))
4610 ;; The result from the `request' was an actual article -
4611 ;; or at least some text that is now displayed in the
4613 (when (and (numberp article)
4614 (not (eq article gnus-current-article)))
4615 ;; Seems like a new article has been selected.
4616 ;; `gnus-current-article' must be an article number.
4617 (with-current-buffer summary-buffer
4618 (push article gnus-newsgroup-history)
4619 (setq gnus-last-article gnus-current-article
4620 gnus-current-article article
4621 gnus-current-headers
4622 (gnus-summary-article-header gnus-current-article)
4623 gnus-article-current
4624 (cons gnus-newsgroup-name gnus-current-article))
4625 (unless (vectorp gnus-current-headers)
4626 (setq gnus-current-headers nil))
4627 (gnus-summary-goto-subject gnus-current-article)
4628 (when (gnus-summary-show-thread)
4629 ;; If the summary buffer really was folded, the
4630 ;; previous goto may not actually have gone to
4631 ;; the right article, but the thread root instead.
4633 (gnus-summary-goto-subject gnus-current-article))
4634 (gnus-run-hooks 'gnus-mark-article-hook)
4635 (gnus-set-mode-line 'summary)
4636 (when (gnus-visual-p 'article-highlight 'highlight)
4637 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4638 ;; Set the global newsgroup variables here.
4639 (gnus-set-global-variables)
4640 (setq gnus-have-all-headers
4641 (or all-headers gnus-show-all-headers))))
4643 (gnus-configure-windows 'article))
4644 (when (or (numberp article)
4646 (gnus-article-prepare-display)
4648 (goto-char (point-min))
4649 (when gnus-break-pages
4650 (gnus-narrow-to-page)))
4651 (let ((gnus-article-mime-handle-alist-1
4652 gnus-article-mime-handle-alist))
4653 (gnus-set-mode-line 'article))
4657 (set-window-point (get-buffer-window (current-buffer)) (point))
4658 (gnus-configure-windows 'article)
4659 (gnus-run-hooks 'gnus-article-prepare-hook)
4663 (defun gnus-article-prepare-display ()
4664 "Make the current buffer look like a nice article."
4665 ;; Hooks for getting information from the article.
4666 ;; This hook must be called before being narrowed.
4667 (let ((gnus-article-buffer (current-buffer))
4669 (inhibit-read-only t))
4670 (unless (eq major-mode 'gnus-article-mode)
4671 (gnus-article-mode))
4672 (setq buffer-read-only nil
4673 gnus-article-wash-types nil
4674 gnus-article-image-alist nil)
4675 (gnus-run-hooks 'gnus-tmp-internal-hook)
4676 (when gnus-display-mime-function
4677 (funcall gnus-display-mime-function))))
4680 ;;; Gnus Sticky Article Mode
4683 (define-derived-mode gnus-sticky-article-mode gnus-article-mode "StickyArticle"
4684 "Mode for sticky articles."
4685 ;; Release bindings that won't work.
4686 (substitute-key-definition 'gnus-article-read-summary-keys 'undefined
4687 gnus-sticky-article-mode-map)
4688 (substitute-key-definition 'gnus-article-refer-article 'undefined
4689 gnus-sticky-article-mode-map)
4690 (dolist (k '("e" "h" "s" "F" "R"))
4691 (define-key gnus-sticky-article-mode-map k nil))
4692 (define-key gnus-sticky-article-mode-map "k" 'gnus-kill-sticky-article-buffer)
4693 (define-key gnus-sticky-article-mode-map "q" 'bury-buffer)
4694 (define-key gnus-sticky-article-mode-map "\C-hc" 'describe-key-briefly)
4695 (define-key gnus-sticky-article-mode-map "\C-hk" 'describe-key))
4697 (defun gnus-sticky-article (arg)
4698 "Make the current article sticky.
4699 If a prefix ARG is given, ask for a name for this sticky article buffer."
4701 (gnus-summary-show-thread)
4702 (gnus-summary-select-article nil nil 'pseudo)
4703 (let (new-art-buf-name)
4704 (gnus-eval-in-buffer-window gnus-article-buffer
4705 (setq new-art-buf-name
4709 (read-from-minibuffer "Sticky article buffer name: ")
4710 (gnus-with-article-headers
4711 (gnus-article-goto-header "subject")
4712 (setq new-art-buf-name
4713 (buffer-substring-no-properties
4714 (line-beginning-position) (line-end-position)))
4715 (goto-char (point-min))
4716 (gnus-article-goto-header "from")
4717 (setq new-art-buf-name
4719 new-art-buf-name ", "
4720 (buffer-substring-no-properties
4721 (line-beginning-position) (line-end-position))))
4722 (goto-char (point-min))
4723 (gnus-article-goto-header "date")
4724 (setq new-art-buf-name
4726 new-art-buf-name ", "
4727 (buffer-substring-no-properties
4728 (line-beginning-position) (line-end-position))))))
4730 (if (and (gnus-buffer-live-p new-art-buf-name)
4731 (with-current-buffer new-art-buf-name
4732 (eq major-mode 'gnus-sticky-article-mode)))
4733 (switch-to-buffer new-art-buf-name)
4734 (setq new-art-buf-name (rename-buffer new-art-buf-name t)))
4735 (gnus-sticky-article-mode))
4736 (setq gnus-article-buffer new-art-buf-name))
4737 (gnus-summary-recenter)
4738 (gnus-summary-position-point))
4740 (defun gnus-kill-sticky-article-buffer (&optional buffer)
4741 "Kill the given sticky article BUFFER.
4742 If none is given, assume the current buffer and kill it if it has
4743 `gnus-sticky-article-mode'."
4746 (setq buffer (current-buffer)))
4747 (with-current-buffer buffer
4748 (when (eq major-mode 'gnus-sticky-article-mode)
4749 (gnus-kill-buffer buffer))))
4751 (defun gnus-kill-sticky-article-buffers (arg)
4752 "Kill all sticky article buffers.
4753 If a prefix ARG is given, ask for confirmation."
4755 (dolist (buf (gnus-buffers))
4756 (with-current-buffer buf
4757 (when (eq major-mode 'gnus-sticky-article-mode)
4759 (gnus-kill-buffer buf)
4760 (when (yes-or-no-p (concat "Kill buffer " (buffer-name buf) "? "))
4761 (gnus-kill-buffer buf)))))))
4764 ;;; Gnus MIME viewing functions
4767 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4768 "Format of the MIME buttons.
4770 Valid specifiers include:
4772 %T MIME type, along with additional info
4773 %n The `name' parameter
4774 %d The description, if any
4775 %l The length of the encoded part
4776 %p The part identifier number
4777 %e Dots if the part isn't displayed
4779 General format specifiers can also be used. See Info node
4780 `(gnus)Formatting Variables'.")
4782 (defvar gnus-mime-button-line-format-alist
4783 '((?t gnus-tmp-type ?s)
4784 (?T gnus-tmp-type-long ?s)
4785 (?n gnus-tmp-name ?s)
4786 (?d gnus-tmp-description ?s)
4788 (?l gnus-tmp-length ?d)
4789 (?e gnus-tmp-dots ?s)))
4791 (defvar gnus-mime-button-commands
4792 '((gnus-article-press-button "\r" "Toggle Display")
4793 (gnus-mime-view-part "v" "View Interactively...")
4794 (gnus-mime-view-part-as-type "t" "View As Type...")
4795 (gnus-mime-view-part-as-charset "C" "View As charset...")
4796 (gnus-mime-save-part "o" "Save...")
4797 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4798 (gnus-mime-replace-part "r" "Replace part")
4799 (gnus-mime-delete-part "d" "Delete part")
4800 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4801 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4802 (gnus-mime-view-part-internally "E" "View Internally") ;; Why `E'?
4803 (gnus-mime-view-part-externally "e" "View Externally")
4804 (gnus-mime-print-part "p" "Print")
4805 (gnus-mime-pipe-part "|" "Pipe To Command...")
4806 (gnus-mime-action-on-part "." "Take action on the part...")))
4808 (defun gnus-article-mime-part-status ()
4809 (if gnus-article-mime-handle-alist-1
4810 (if (eq 1 (length gnus-article-mime-handle-alist-1))
4812 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
4815 (defvar gnus-mime-button-map
4816 (let ((map (make-sparse-keymap)))
4817 (define-key map gnus-mouse-2 'gnus-article-push-button)
4818 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4819 (dolist (c gnus-mime-button-commands)
4820 (define-key map (cadr c) (car c)))
4824 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4826 ,@(mapcar (lambda (c)
4827 (vector (caddr c) (car c) :active t))
4828 gnus-mime-button-commands)))
4830 (defvar gnus-url-button-commands
4831 '((gnus-article-copy-string "u" "Copy URL to kill ring")))
4833 (defvar gnus-url-button-map
4834 (let ((map (make-sparse-keymap)))
4835 (dolist (c gnus-url-button-commands)
4836 (define-key map (cadr c) (car c)))
4840 gnus-url-button-menu gnus-url-button-map "URL button menu."
4842 ,@(mapcar (lambda (c)
4843 (vector (caddr c) (car c) :active t))
4844 gnus-url-button-commands)))
4846 (defmacro gnus-bind-safe-url-regexp (&rest body)
4847 "Bind `mm-w3m-safe-url-regexp' according to `gnus-safe-html-newsgroups'."
4848 `(let ((mm-w3m-safe-url-regexp
4849 (let ((group (if (and (eq major-mode 'gnus-article-mode)
4851 gnus-article-current-summary))
4852 (with-current-buffer gnus-article-current-summary
4853 gnus-newsgroup-name)
4854 gnus-newsgroup-name)))
4855 (if (cond ((not group)
4856 ;; Maybe we're in a mml-preview buffer
4857 ;; and no group is selected.
4859 ((stringp gnus-safe-html-newsgroups)
4860 (string-match gnus-safe-html-newsgroups group))
4861 ((consp gnus-safe-html-newsgroups)
4862 (member group gnus-safe-html-newsgroups)))
4864 mm-w3m-safe-url-regexp))))
4867 (defun gnus-mime-button-menu (event prefix)
4868 "Construct a context-sensitive menu of MIME commands."
4869 (interactive "e\nP")
4870 (save-window-excursion
4871 (let ((pos (event-start event)))
4872 (select-window (posn-window pos))
4873 (goto-char (posn-point pos))
4874 (gnus-article-check-buffer)
4875 (popup-menu gnus-mime-button-menu nil prefix))))
4877 (defun gnus-mime-view-all-parts (&optional handles)
4878 "View all the MIME parts."
4880 (with-current-buffer gnus-article-buffer
4881 (let ((handles (or handles gnus-article-mime-handles))
4882 (mail-parse-charset gnus-newsgroup-charset)
4883 (mail-parse-ignored-charsets
4884 (with-current-buffer gnus-summary-buffer
4885 gnus-newsgroup-ignored-charsets)))
4887 (mm-remove-parts handles)
4888 (goto-char (point-min))
4889 (or (search-forward "\n\n") (goto-char (point-max)))
4890 (let ((inhibit-read-only t))