1 ;;; gnus-art.el --- article mode commands for Gnus
3 ;; Copyright (C) 1996-2015 Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
30 (defvar w3m-minor-mode-map)
47 (autoload 'gnus-msg-mail "gnus-msg" nil t)
48 (autoload 'gnus-button-mailto "gnus-msg")
49 (autoload 'gnus-button-reply "gnus-msg" nil t)
50 (autoload 'parse-time-string "parse-time" nil nil)
51 (autoload 'ansi-color-apply-on-region "ansi-color")
52 (autoload 'mm-url-insert-file-contents-external "mm-url")
53 (autoload 'mm-extern-cache-contents "mm-extern")
54 (autoload 'url-expand-file-name "url-expand")
56 (defgroup gnus-article nil
58 :link '(custom-manual "(gnus)Article Buffer")
61 (defgroup gnus-article-treat nil
62 "Treating article parts."
63 :link '(custom-manual "(gnus)Article Hiding")
66 (defgroup gnus-article-hiding nil
67 "Hiding article parts."
68 :link '(custom-manual "(gnus)Article Hiding")
71 (defgroup gnus-article-highlight nil
72 "Article highlighting."
73 :link '(custom-manual "(gnus)Article Highlighting")
77 (defgroup gnus-article-signature nil
79 :link '(custom-manual "(gnus)Article Signature")
82 (defgroup gnus-article-headers nil
84 :link '(custom-manual "(gnus)Hiding Headers")
87 (defgroup gnus-article-washing nil
88 "Special commands on articles."
89 :link '(custom-manual "(gnus)Article Washing")
92 (defgroup gnus-article-emphasis nil
93 "Fontisizing articles."
94 :link '(custom-manual "(gnus)Article Fontisizing")
97 (defgroup gnus-article-saving nil
99 :link '(custom-manual "(gnus)Saving Articles")
100 :group 'gnus-article)
102 (defgroup gnus-article-mime nil
103 "Worshiping the MIME wonder."
104 :link '(custom-manual "(gnus)Using MIME")
105 :group 'gnus-article)
107 (defgroup gnus-article-buttons nil
108 "Pushable buttons in the article buffer."
109 :link '(custom-manual "(gnus)Article Buttons")
110 :group 'gnus-article)
112 (defgroup gnus-article-various nil
113 "Other article options."
114 :link '(custom-manual "(gnus)Misc Article")
115 :group 'gnus-article)
117 (defcustom gnus-ignored-headers
120 (concat "^" header ":"))
121 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
122 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
123 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
124 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
125 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
126 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
127 "X-Attribution" "X-Originating-IP" "Delivered-To"
128 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
129 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
130 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
131 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
132 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
133 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
134 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
135 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
136 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
137 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
138 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
139 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
140 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
141 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
142 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
143 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
144 "List-[A-Za-z]+" "X-Listprocessor-Version"
145 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
146 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
147 "X-Received" "Content-length" "X-precedence"
148 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
149 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
150 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
151 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
152 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
153 "X-Content-length" "X-Posting-Agent" "Original-Received"
154 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
155 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
156 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
157 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
158 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"
159 "Envelope-To" "X-Spam-Score" "System-Type" "X-Injected-Via-Gmane"
160 "X-Gmane-NNTP-Posting-Host" "Jabber-ID" "Archived-At"
161 "Envelope-Sender" "Envelope-Recipients"))
162 "*All headers that start with this regexp will be hidden.
163 This variable can also be a list of regexps of headers to be ignored.
164 If `gnus-visible-headers' is non-nil, this variable will be ignored."
165 :type '(choice regexp
167 :group 'gnus-article-hiding)
169 (defcustom gnus-visible-headers
170 "^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:"
171 "*All headers that do not match this regexp will be hidden.
172 This variable can also be a list of regexp of headers to remain visible.
173 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
175 (repeat :value-to-internal (lambda (widget value)
176 (custom-split-regexp-maybe value))
177 :match (lambda (widget value)
179 (widget-editable-list-match widget value)))
181 (const :tag "Use gnus-ignored-headers" nil)
183 :group 'gnus-article-hiding)
185 (defcustom gnus-sorted-header-list
186 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
187 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
188 "*This variable is a list of regular expressions.
189 If it is non-nil, headers that match the regular expressions will
190 be placed first in the article buffer in the sequence specified by
192 :type '(repeat regexp)
193 :group 'gnus-article-hiding)
195 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
196 "Headers that are only to be displayed if they have interesting data.
197 Possible values in this list are:
199 'empty Headers with no content.
200 'newsgroups Newsgroup identical to Gnus group.
201 'to-address To identical to To-address.
202 'to-list To identical to To-list.
203 'cc-list CC identical to To-list.
204 'followup-to Followup-to identical to Newsgroups.
205 'reply-to Reply-to identical to From.
206 'date Date less than four days old.
207 'long-to To and/or Cc longer than 1024 characters.
208 'many-to Multiple To and/or Cc."
209 :type '(set (const :tag "Headers with no content." empty)
210 (const :tag "Newsgroups identical to Gnus group." newsgroups)
211 (const :tag "To identical to To-address." to-address)
212 (const :tag "To identical to To-list." to-list)
213 (const :tag "CC identical to To-list." cc-list)
214 (const :tag "Followup-to identical to Newsgroups." followup-to)
215 (const :tag "Reply-to identical to From." reply-to)
216 (const :tag "Date less than four days old." date)
217 (const :tag "To and/or Cc longer than 1024 characters." long-to)
218 (const :tag "Multiple To and/or Cc headers." many-to))
219 :group 'gnus-article-hiding)
221 (defcustom gnus-article-skip-boring nil
222 "Skip over text that is not worth reading.
223 By default, if you set this t, then Gnus will display citations and
224 signatures, but will never scroll down to show you a page consisting
225 only of boring text. Boring text is controlled by
226 `gnus-article-boring-faces'."
229 :group 'gnus-article-hiding)
231 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
232 "Regexp matching signature separator.
233 This can also be a list of regexps. In that case, it will be checked
234 from head to tail looking for a separator. Searches will be done from
235 the end of the buffer."
236 :type '(choice :format "%{%t%}: %[Value Menu%]\n%v"
238 (repeat :tag "List of regexp" regexp))
239 :group 'gnus-article-signature)
241 (defcustom gnus-signature-limit nil
242 "Provide a limit to what is considered a signature.
243 If it is a number, no signature may not be longer (in characters) than
244 that number. If it is a floating point number, no signature may be
245 longer (in lines) than that number. If it is a function, the function
246 will be called without any parameters, and if it returns nil, there is
247 no signature in the buffer. If it is a string, it will be used as a
248 regexp. If it matches, the text in question is not a signature.
250 This can also be a list of the above values."
251 :type '(choice (const nil)
255 (regexp :value ".*"))
256 :group 'gnus-article-signature)
258 (defcustom gnus-hidden-properties
259 ;; We use to have `intangible' here as well, but Emacs's command loop moves
260 ;; point out of invisible text anyway, so `intangible' is clearly not
261 ;; needed there. And XEmacs doesn't handle `intangible' anyway.
263 "Property list to use for hiding text."
265 :group 'gnus-article-hiding)
267 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
268 ;; frames in a session.
269 (defcustom gnus-article-x-face-command
270 (if (featurep 'xemacs)
271 (if (or (gnus-image-type-available-p 'xface)
272 (gnus-image-type-available-p 'pbm))
273 'gnus-display-x-face-in-from
275 '/* Format_version=1, Width=48, Height=48, Depth=1, Valid_bits_per_item=16 */'\
276 ; uncompface; } | icontopbm | ee -")
277 (if (gnus-image-type-available-p 'pbm)
278 'gnus-display-x-face-in-from
280 '/* Format_version=1, Width=48, Height=48, Depth=1, Valid_bits_per_item=16 */'\
281 ; uncompface; } | icontopbm | display -"))
282 "*String or function to be executed to display an X-Face header.
283 If it is a string, the command will be executed in a sub-shell
284 asynchronously. The compressed face will be piped to this command."
285 :type `(choice string
286 (function-item gnus-display-x-face-in-from)
290 :group 'gnus-article-washing)
292 (defcustom gnus-article-x-face-too-ugly nil
293 "Regexp matching posters whose face shouldn't be shown automatically."
294 :type '(choice regexp (const nil))
295 :group 'gnus-article-washing)
297 (defcustom gnus-article-banner-alist nil
298 "Banner alist for stripping.
300 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
302 :type '(repeat (cons symbol regexp))
303 :group 'gnus-article-washing)
305 (gnus-define-group-parameter
308 "Alist of regexps (to match group names) and banner."
309 :variable-group gnus-article-washing
311 '(choice :tag "Banner"
313 (const :tag "Remove signature" signature)
314 (symbol :tag "Item in `gnus-article-banner-alist'" none)
316 (const :tag "None" nil))
318 "If non-nil, specify how to remove `banners' from articles.
320 Symbol `signature' means to remove signatures delimited by
321 `gnus-signature-separator'. Any other symbol is used to look up a
322 regular expression to match the banner in `gnus-article-banner-alist'.
323 A string is used as a regular expression to match the banner
326 (defcustom gnus-article-address-banner-alist nil
327 "Alist of mail addresses and banners.
328 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
329 to match a mail address in the From: header, BANNER is one of a symbol
330 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
331 If ADDRESS matches author's mail address, it will remove things like
332 advertisements. For example:
334 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
338 (regexp :tag "Address")
339 (choice :tag "Banner" :value nil
340 (const :tag "Remove signature" signature)
341 (symbol :tag "Item in `gnus-article-banner-alist'" none)
343 (const :tag "None" nil))))
345 :group 'gnus-article-washing)
347 (defmacro gnus-emphasis-custom-with-format (&rest body)
349 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
350 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
353 (defun gnus-emphasis-custom-value-to-external (value)
354 (gnus-emphasis-custom-with-format
355 (if (consp (car value))
356 (list (format format (car (car value)) (cdr (car value)))
358 (if (nth 1 value) 2 3)
362 (defun gnus-emphasis-custom-value-to-internal (value)
363 (gnus-emphasis-custom-with-format
364 (let ((regexp (concat "\\`"
365 (format (regexp-quote format)
366 "\\([^()]+\\)" "\\([^()]+\\)")
369 (if (string-match regexp (setq pattern (car value)))
370 (list (cons (match-string 1 pattern) (match-string 2 pattern))
375 (defcustom gnus-emphasis-alist
377 '(("\\*" "\\*" bold nil 2)
380 ("_/" "/_" underline-italic)
381 ("_\\*" "\\*_" underline-bold)
382 ("\\*/" "/\\*" bold-italic)
383 ("_\\*/" "/\\*_" underline-bold-italic))))
385 (gnus-emphasis-custom-with-format
386 (mapcar (lambda (spec)
387 (list (format format (car spec) (cadr spec))
390 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
392 '(;; I've never seen anyone use this strikethru convention whereas I've
393 ;; several times seen it triggered by normal text. --Stef
394 ;; Miles suggests that this form is sometimes used but for italics,
395 ;; so maybe we should map it to `italic'.
396 ;; ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
397 ;; 2 3 gnus-emphasis-strikethru)
398 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
399 2 3 gnus-emphasis-underline))))
400 "*Alist that says how to fontify certain phrases.
401 Each item looks like this:
403 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
405 The first element is a regular expression to be matched. The second
406 is a number that says what regular expression grouping used to find
407 the entire emphasized word. The third is a number that says what
408 regexp grouping should be displayed and highlighted. The fourth
409 is the face used for highlighting."
413 :format "%[Customizing Style%]\n%v"
415 (group :tag "Default"
416 :value ("" 0 0 default)
419 (let ((value (widget-get
420 (cadr (widget-get (widget-get widget :parent)
423 (if (not (eq (nth 2 value) 'default))
427 (gnus-emphasis-custom-value-to-external value))))
428 (widget-group-value-create widget))
430 (integer :format "Match group: %v")
431 (integer :format "Emphasize group: %v")
434 :value (("_" . "_") nil default)
436 (regexp :format "Start regexp: %v")
437 (regexp :format "End regexp: %v"))
438 (boolean :format "Show start and end patterns: %[%v%]\n"
439 :on " On " :off " Off ")
441 :get (lambda (symbol)
442 (mapcar 'gnus-emphasis-custom-value-to-internal
443 (default-value symbol)))
444 :set (lambda (symbol value)
445 (set-default symbol (mapcar 'gnus-emphasis-custom-value-to-external
447 :group 'gnus-article-emphasis)
449 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
450 "A regexp to describe whitespace which should not be emphasized.
451 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
452 The former avoids underlining of leading and trailing whitespace,
453 and the latter avoids underlining any whitespace at all."
455 :group 'gnus-article-emphasis
458 (defface gnus-emphasis-bold '((t (:bold t)))
459 "Face used for displaying strong emphasized text (*word*)."
460 :group 'gnus-article-emphasis)
462 (defface gnus-emphasis-italic '((t (:italic t)))
463 "Face used for displaying italic emphasized text (/word/)."
464 :group 'gnus-article-emphasis)
466 (defface gnus-emphasis-underline '((t (:underline t)))
467 "Face used for displaying underlined emphasized text (_word_)."
468 :group 'gnus-article-emphasis)
470 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
471 "Face used for displaying underlined bold emphasized text (_*word*_)."
472 :group 'gnus-article-emphasis)
474 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
475 "Face used for displaying underlined italic emphasized text (_/word/_)."
476 :group 'gnus-article-emphasis)
478 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
479 "Face used for displaying bold italic emphasized text (/*word*/)."
480 :group 'gnus-article-emphasis)
482 (defface gnus-emphasis-underline-bold-italic
483 '((t (:bold t :italic t :underline t)))
484 "Face used for displaying underlined bold italic emphasized text.
485 Example: (_/*word*/_)."
486 :group 'gnus-article-emphasis)
488 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
489 '((t (:strikethru t)))
490 '((t (:strike-through t))))
491 "Face used for displaying strike-through text (-word-)."
492 :group 'gnus-article-emphasis)
494 (defface gnus-emphasis-highlight-words
495 '((t (:background "black" :foreground "yellow")))
496 "Face used for displaying highlighted words."
497 :group 'gnus-article-emphasis)
499 (defcustom gnus-article-time-format "%a, %d %b %Y %T %Z"
500 "Format for display of Date headers in article bodies.
501 See `format-time-string' for the possible values.
503 The variable can also be function, which should return a complete Date
504 header. The function is called with one argument, the time, which can
505 be fed to `format-time-string'."
506 :type '(choice string function)
507 :link '(custom-manual "(gnus)Article Date")
508 :group 'gnus-article-washing)
510 (defcustom gnus-save-all-headers t
511 "*If non-nil, don't remove any headers before saving.
512 This will be overridden by the `:headers' property that the symbol of
513 the saver function, which is specified by `gnus-default-article-saver',
515 :group 'gnus-article-saving
518 (defcustom gnus-prompt-before-saving 'always
519 "*This variable says how much prompting is to be done when saving articles.
520 If it is nil, no prompting will be done, and the articles will be
521 saved to the default files. If this variable is `always', each and
522 every article that is saved will be preceded by a prompt, even when
523 saving large batches of articles. If this variable is neither nil not
524 `always', there the user will be prompted once for a file name for
525 each invocation of the saving commands."
526 :group 'gnus-article-saving
527 :type '(choice (item always)
528 (item :tag "never" nil)
529 (sexp :tag "once" :format "%t\n" :value t)))
531 (defcustom gnus-saved-headers gnus-visible-headers
532 "Headers to keep if `gnus-save-all-headers' is nil.
533 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
534 If that variable is nil, however, all headers that match this regexp
535 will be kept while the rest will be deleted before saving. This and
536 `gnus-save-all-headers' will be overridden by the `:headers' property
537 that the symbol of the saver function, which is specified by
538 `gnus-default-article-saver', might have."
539 :group 'gnus-article-saving
542 ;; Note that "Rmail format" is mbox since Emacs 23, but Babyl before.
543 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
544 "A function to save articles in your favorite format.
545 The function will be called by way of the `gnus-summary-save-article'
546 command, and friends such as `gnus-summary-save-article-rmail'.
548 Gnus provides the following functions:
550 * gnus-summary-save-in-rmail (Rmail format)
551 * gnus-summary-save-in-mail (Unix mail format)
552 * gnus-summary-save-in-folder (MH folder)
553 * gnus-summary-save-in-file (article format)
554 * gnus-summary-save-body-in-file (article body)
555 * gnus-summary-save-in-vm (use VM's folder format)
556 * gnus-summary-write-to-file (article format -- overwrite)
557 * gnus-summary-write-body-to-file (article body -- overwrite)
558 * gnus-summary-save-in-pipe (article format)
560 The symbol of each function may have the following properties:
563 The value non-nil means save decoded articles. This is meaningful
564 only with `gnus-summary-save-in-file', `gnus-summary-save-body-in-file',
565 `gnus-summary-write-to-file', `gnus-summary-write-body-to-file', and
566 `gnus-summary-save-in-pipe'.
569 The value specifies an alternative function which appends, not
570 overwrites, articles to a file. This implies that when saving many
571 articles at a time, `gnus-prompt-before-saving' is bound to t and all
572 articles are saved in a single file. This is meaningful only with
573 `gnus-summary-write-to-file' and `gnus-summary-write-body-to-file'.
576 The value specifies the symbol of a variable of which the value
577 specifies headers to be saved. If it is omitted,
578 `gnus-save-all-headers' and `gnus-saved-headers' control what
579 headers should be saved."
580 :group 'gnus-article-saving
581 :type '(radio (function-item gnus-summary-save-in-rmail)
582 (function-item gnus-summary-save-in-mail)
583 (function-item gnus-summary-save-in-folder)
584 (function-item gnus-summary-save-in-file)
585 (function-item gnus-summary-save-body-in-file)
586 (function-item gnus-summary-save-in-vm)
587 (function-item gnus-summary-write-to-file)
588 (function-item gnus-summary-write-body-to-file)
589 (function-item gnus-summary-save-in-pipe)
592 (defcustom gnus-article-save-coding-system
593 (or (and (mm-coding-system-p 'utf-8) 'utf-8)
594 (and (mm-coding-system-p 'iso-2022-7bit) 'iso-2022-7bit)
595 (and (mm-coding-system-p 'emacs-mule) 'emacs-mule)
596 (and (mm-coding-system-p 'escape-quoted) 'escape-quoted))
597 "Coding system used to save decoded articles to a file.
599 The recommended coding systems are `utf-8', `iso-2022-7bit' and so on,
600 which can safely encode any characters in text. This is used by the
603 * gnus-summary-save-article-file
604 * gnus-summary-save-article-body-file
605 * gnus-summary-write-article-file
606 * gnus-summary-write-article-body-file
608 and the functions to which you may set `gnus-default-article-saver':
610 * gnus-summary-save-in-file
611 * gnus-summary-save-body-in-file
612 * gnus-summary-write-to-file
613 * gnus-summary-write-body-to-file
615 Those commands and functions save just text displayed in the article
616 buffer to a file if the value of this variable is non-nil. Note that
617 buttonized MIME parts will be lost in a saved file in that case.
618 Otherwise, raw articles will be saved."
619 :group 'gnus-article-saving
621 :format "%{%t%}:\n %[Value Menu%] %v"
622 (const :tag "Save raw articles" nil)
625 (lambda (arg) (if (mm-coding-system-p (nth 3 arg)) arg))
626 '((const :tag "UTF-8" utf-8)
627 (const :tag "iso-2022-7bit" iso-2022-7bit)
628 (const :tag "Emacs internal" emacs-mule)
629 (const :tag "escape-quoted" escape-quoted))))
630 (symbol :tag "Coding system")))
632 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
633 "A function generating a file name to save articles in Rmail format.
634 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
635 :group 'gnus-article-saving
638 (defcustom gnus-mail-save-name 'gnus-plain-save-name
639 "A function generating a file name to save articles in Unix mail format.
640 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
641 :group 'gnus-article-saving
644 (defcustom gnus-folder-save-name 'gnus-folder-save-name
645 "A function generating a file name to save articles in MH folder.
646 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
647 :group 'gnus-article-saving
650 (defcustom gnus-file-save-name 'gnus-numeric-save-name
651 "A function generating a file name to save articles in article format.
652 The function is called with NEWSGROUP, HEADERS, and optional
654 :group 'gnus-article-saving
657 (defcustom gnus-split-methods
658 '((gnus-article-archive-name)
659 (gnus-article-nndoc-name))
660 "*Variable used to suggest where articles are to be saved.
661 For instance, if you would like to save articles related to Gnus in
662 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
663 you could set this variable to something like:
665 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
666 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
668 This variable is an alist where the key is the match and the
669 value is a list of possible files to save in if the match is
672 If the match is a string, it is used as a regexp match on the
673 article. If the match is a symbol, that symbol will be funcalled
674 from the buffer of the article to be saved with the newsgroup as the
675 parameter. If it is a list, it will be evalled in the same buffer.
677 If this form or function returns a string, this string will be used as a
678 possible file name; and if it returns a non-nil list, that list will be
679 used as possible file names."
680 :group 'gnus-article-saving
681 :type '(repeat (choice (list :value (fun) function)
682 (cons :value ("" "") regexp (repeat string))
685 (defcustom gnus-page-delimiter "^\^L"
686 "*Regexp describing what to use as article page delimiters.
687 The default value is \"^\^L\", which is a form linefeed at the
688 beginning of a line."
690 :group 'gnus-article-various)
692 (defcustom gnus-article-mode-line-format "Gnus: %g %S%m"
693 "*The format specification for the article mode line.
694 See `gnus-summary-mode-line-format' for a closer description.
696 The following additional specs are available:
698 %w The article washing status.
699 %m The number of MIME parts in the article."
702 :group 'gnus-article-various)
704 (defcustom gnus-article-mode-hook nil
705 "*A hook for Gnus article mode."
707 :group 'gnus-article-various)
709 (when (featurep 'xemacs)
710 ;; Extracted from gnus-xmas-define in order to preserve user settings
711 (when (fboundp 'turn-off-scroll-in-place)
712 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
713 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
714 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
716 (defcustom gnus-article-menu-hook nil
717 "*Hook run after the creation of the article mode menu."
719 :group 'gnus-article-various)
721 (defcustom gnus-article-prepare-hook nil
722 "*A hook called after an article has been prepared in the article buffer."
724 :group 'gnus-article-various)
726 (defcustom gnus-copy-article-ignored-headers nil
727 "List of headers to be removed when copying an article.
728 Each element is a regular expression."
729 :version "23.1" ;; No Gnus
730 :type '(repeat regexp)
731 :group 'gnus-article-various)
733 (make-obsolete-variable 'gnus-article-hide-pgp-hook nil
734 "Gnus 5.10 (Emacs 22.1)")
737 '((t (:weight bold)))
738 "Face used for highlighting a button in the article buffer."
739 :group 'gnus-article-buttons)
741 (defcustom gnus-article-button-face 'gnus-button
742 "Face used for highlighting buttons in the article buffer.
744 An article button is a piece of text that you can activate by pressing
745 `RET' or `mouse-2' above it."
747 :group 'gnus-article-buttons)
749 (defcustom gnus-article-mouse-face 'highlight
750 "Face used for mouse highlighting in the article buffer.
752 Article buttons will be displayed in this face when the cursor is
755 :group 'gnus-article-buttons)
757 (defcustom gnus-signature-face 'gnus-signature
758 "Face used for highlighting a signature in the article buffer.
759 Obsolete; use the face `gnus-signature' for customizations instead."
761 :group 'gnus-article-highlight
762 :group 'gnus-article-signature)
764 (defface gnus-signature
767 "Face used for highlighting a signature in the article buffer."
768 :group 'gnus-article-highlight
769 :group 'gnus-article-signature)
770 ;; backward-compatibility alias
771 (put 'gnus-signature-face 'face-alias 'gnus-signature)
772 (put 'gnus-signature-face 'obsolete-face "22.1")
774 (defface gnus-header-from
777 (:foreground "PaleGreen1"))
780 (:foreground "red3"))
783 "Face used for displaying from headers."
784 :group 'gnus-article-headers
785 :group 'gnus-article-highlight)
786 ;; backward-compatibility alias
787 (put 'gnus-header-from-face 'face-alias 'gnus-header-from)
788 (put 'gnus-header-from-face 'obsolete-face "22.1")
790 (defface gnus-header-subject
793 (:foreground "SeaGreen1"))
796 (:foreground "red4"))
798 (:bold t :italic t)))
799 "Face used for displaying subject headers."
800 :group 'gnus-article-headers
801 :group 'gnus-article-highlight)
802 ;; backward-compatibility alias
803 (put 'gnus-header-subject-face 'face-alias 'gnus-header-subject)
804 (put 'gnus-header-subject-face 'obsolete-face "22.1")
806 (defface gnus-header-newsgroups
809 (:foreground "yellow" :italic t))
812 (:foreground "MidnightBlue" :italic t))
815 "Face used for displaying newsgroups headers.
816 In the default setup this face is only used for crossposted
818 :group 'gnus-article-headers
819 :group 'gnus-article-highlight)
820 ;; backward-compatibility alias
821 (put 'gnus-header-newsgroups-face 'face-alias 'gnus-header-newsgroups)
822 (put 'gnus-header-newsgroups-face 'obsolete-face "22.1")
824 (defface gnus-header-name
827 (:foreground "SpringGreen2"))
830 (:foreground "maroon"))
833 "Face used for displaying header names."
834 :group 'gnus-article-headers
835 :group 'gnus-article-highlight)
836 ;; backward-compatibility alias
837 (put 'gnus-header-name-face 'face-alias 'gnus-header-name)
838 (put 'gnus-header-name-face 'obsolete-face "22.1")
840 (defface gnus-header-content
843 (:foreground "SpringGreen1" :italic t))
846 (:foreground "indianred4" :italic t))
848 (:italic t))) "Face used for displaying header content."
849 :group 'gnus-article-headers
850 :group 'gnus-article-highlight)
851 ;; backward-compatibility alias
852 (put 'gnus-header-content-face 'face-alias 'gnus-header-content)
853 (put 'gnus-header-content-face 'obsolete-face "22.1")
855 (defcustom gnus-header-face-alist
856 '(("From" nil gnus-header-from)
857 ("Subject" nil gnus-header-subject)
858 ("Newsgroups:.*," nil gnus-header-newsgroups)
859 ("" gnus-header-name gnus-header-content))
860 "*Controls highlighting of article headers.
862 An alist of the form (HEADER NAME CONTENT).
864 HEADER is a regular expression which should match the name of a
865 header and NAME and CONTENT are either face names or nil.
867 The name of each header field will be displayed using the face
868 specified by the first element in the list where HEADER matches
869 the header name and NAME is non-nil. Similarly, the content will
870 be displayed by the first non-nil matching CONTENT face."
871 :group 'gnus-article-headers
872 :group 'gnus-article-highlight
873 :type '(repeat (list (regexp :tag "Header")
875 (item :tag "skip" nil)
876 (face :value default))
877 (choice :tag "Content"
878 (item :tag "skip" nil)
879 (face :value default)))))
881 (defcustom gnus-face-properties-alist (if (featurep 'xemacs)
882 '((xface . (:face gnus-x-face)))
883 '((pbm . (:face gnus-x-face))
885 "Alist of image types and properties applied to Face and X-Face images.
888 ;; Specify the altitude of Face images in the From header.
889 \(setq gnus-face-properties-alist
890 '((pbm . (:face gnus-x-face :ascent 80))
891 (png . (:ascent 80))))
893 ;; Show Face images as pressed buttons.
894 \(setq gnus-face-properties-alist
895 '((pbm . (:face gnus-x-face :relief -2))
896 (png . (:relief -2))))
898 See the manual for the valid properties for various image types.
899 Currently, `pbm' is used for X-Face images and `png' is used for Face
900 images in Emacs. Only the `:face' property is effective on the `xface'
901 image type in XEmacs if it is built with the libcompface library."
902 :version "23.1" ;; No Gnus
903 :group 'gnus-article-headers
904 :type '(repeat (cons :format "%v" (symbol :tag "Image type") plist)))
906 (defcustom gnus-article-decode-hook
907 '(article-decode-charset article-decode-encoded-words
908 article-decode-group-name article-decode-idna-rhs)
909 "*Hook run to decode charsets in articles."
910 :group 'gnus-article-headers
913 (defcustom gnus-display-mime-function 'gnus-display-mime
914 "Function to display MIME articles."
915 :group 'gnus-article-mime
918 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
919 "Function used to decode headers.")
921 (defvar gnus-decode-address-function 'mail-decode-encoded-address-region
922 "Function used to decode addresses.")
924 (defvar gnus-article-dumbquotes-map
944 "Table for MS-to-Latin1 translation.")
946 (defcustom gnus-ignored-mime-types nil
947 "List of MIME types that should be ignored by Gnus."
949 :group 'gnus-article-mime
950 :type '(repeat regexp))
952 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
953 "List of MIME types that should not be given buttons when rendered inline.
954 See also `gnus-buttonized-mime-types' which may override this variable.
955 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
957 :group 'gnus-article-mime
958 :type '(repeat regexp))
960 (defcustom gnus-buttonized-mime-types nil
961 "List of MIME types that should be given buttons when rendered inline.
962 If set, this variable overrides `gnus-unbuttonized-mime-types'.
963 To see e.g. security buttons you could set this to
964 `(\"multipart/signed\")'. You could also add \"multipart/alternative\" to
965 this list to display radio buttons that allow you to choose one of two
966 media types those mails include. See also `mm-discouraged-alternatives'.
967 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
969 :group 'gnus-article-mime
970 :type '(repeat regexp))
972 (defcustom gnus-inhibit-mime-unbuttonizing nil
973 "If non-nil, all MIME parts get buttons.
974 When nil (the default value), then some MIME parts do not get buttons,
975 as described by the variables `gnus-buttonized-mime-types' and
976 `gnus-unbuttonized-mime-types'."
978 :group 'gnus-article-mime
981 (defcustom gnus-body-boundary-delimiter "_"
982 "String used to delimit header and body.
983 This variable is used by `gnus-article-treat-body-boundary' which can
984 be controlled by `gnus-treat-body-boundary'."
986 :group 'gnus-article-various
987 :type '(choice (item :tag "None" :value nil)
990 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
992 "Defines the location of the faces database.
993 For information on obtaining this database of pretty pictures, please
994 see http://www.cs.indiana.edu/picons/ftp/index.html"
996 :type '(repeat directory)
997 :link '(url-link :tag "download"
998 "http://www.cs.indiana.edu/picons/ftp/index.html")
999 :link '(custom-manual "(gnus)Picons")
1002 (defun gnus-picons-installed-p ()
1003 "Say whether picons are installed on your machine."
1004 (let ((installed nil))
1005 (dolist (database gnus-picon-databases)
1006 (when (file-exists-p database)
1007 (setq installed t)))
1010 (defcustom gnus-article-mime-part-function nil
1011 "Function called with a MIME handle as the argument.
1012 This is meant for people who want to do something automatic based
1013 on parts -- for instance, adding Vcard info to a database."
1014 :group 'gnus-article-mime
1015 :type '(choice (const nil)
1018 (defcustom gnus-mime-multipart-functions nil
1019 "An alist of MIME types to functions to display them."
1021 :group 'gnus-article-mime
1022 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
1024 (defcustom gnus-article-date-headers '(combined-lapsed)
1025 "A list of Date header formats to display.
1026 Valid formats are `ut' (universal time), `local' (local time
1027 zone), `english' (readable English), `lapsed' (elapsed time),
1028 `combined-lapsed' (both the original date and the elapsed time),
1029 `original' (the original date header), `iso8601' (ISO8601
1030 format), and `user-defined' (a user-defined format defined by the
1031 `gnus-article-time-format' variable).
1033 You have as many date headers as you want in the article buffer.
1034 Some of these headers are updated automatically. See
1035 `gnus-article-update-date-headers' for details."
1037 :group 'gnus-article-headers
1039 (const :tag "Universal time (UT)" ut)
1040 (const :tag "Local time zone" local)
1041 (const :tag "Readable English" english)
1042 (const :tag "Elapsed time" lapsed)
1043 (const :tag "Original and elapsed time" combined-lapsed)
1044 (const :tag "Original date header" original)
1045 (const :tag "ISO8601 format" iso8601)
1046 (const :tag "User-defined" user-defined)))
1048 (defcustom gnus-article-update-date-headers nil
1049 "A number that says how often to update the date header (in seconds).
1050 If nil, don't update it at all."
1052 :group 'gnus-article-headers
1054 (item :tag "Don't update" :value nil)
1057 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
1058 "Function called with a MIME handle as the argument.
1059 This is meant for people who want to view first matched part.
1060 For `undisplayed-alternative' (default), the first undisplayed
1061 part or alternative part is used. For `undisplayed', the first
1062 undisplayed part is used. For a function, the first part which
1063 the function return t is used. For nil, the first part is
1066 :group 'gnus-article-mime
1068 (item :tag "first" :value nil)
1069 (item :tag "undisplayed" :value undisplayed)
1070 (item :tag "undisplayed or alternative"
1071 :value undisplayed-alternative)
1074 (defcustom gnus-mime-action-alist
1075 '(("save to file" . gnus-mime-save-part)
1076 ("save and strip" . gnus-mime-save-part-and-strip)
1077 ("replace with file" . gnus-mime-replace-part)
1078 ("delete part" . gnus-mime-delete-part)
1079 ("display as text" . gnus-mime-inline-part)
1080 ("view the part" . gnus-mime-view-part)
1081 ("pipe to command" . gnus-mime-pipe-part)
1082 ("toggle display" . gnus-article-press-button)
1083 ("toggle display" . gnus-article-view-part-as-charset)
1084 ("view as type" . gnus-mime-view-part-as-type)
1085 ("view internally" . gnus-mime-view-part-internally)
1086 ("view externally" . gnus-mime-view-part-externally))
1087 "An alist of actions that run on the MIME attachment."
1088 :group 'gnus-article-mime
1089 :type '(repeat (cons (string :tag "name")
1092 (defcustom gnus-auto-select-part 1
1093 "Advance to next MIME part when deleting or stripping parts.
1095 When 0, point will be placed on the same part as before. When
1096 positive (negative), move point forward (backwards) this many
1097 parts. When nil, redisplay article."
1098 :version "23.1" ;; No Gnus
1099 :group 'gnus-article-mime
1100 :type '(choice (const nil :tag "Redisplay article.")
1101 (const 1 :tag "Next part.")
1102 (const 0 :tag "Current part.")
1106 ;;; The treatment variables
1109 (defvar gnus-part-display-hook nil
1110 "Hook called on parts that are to receive treatment.")
1112 (defvar gnus-article-treat-custom
1113 '(choice (const :tag "Off" nil)
1115 (const :tag "Header" head)
1116 (const :tag "First" first)
1117 (const :tag "Last" last)
1118 (integer :tag "Less")
1119 (repeat :tag "Groups" regexp)
1120 (sexp :tag "Predicate")))
1122 (defvar gnus-article-treat-head-custom
1123 '(choice (const :tag "Off" nil)
1124 (const :tag "Header" head)))
1126 (defvar gnus-article-treat-types '("text/plain" "text/x-verbatim"
1127 "text/x-patch" "text/html")
1128 "Part types eligible for treatment.")
1130 (defvar gnus-inhibit-treatment nil
1131 "Whether to inhibit treatment.")
1133 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
1134 "Highlight the signature.
1135 Valid values are nil, t, `head', `first', `last', an integer or a
1136 predicate. See Info node `(gnus)Customizing Articles'."
1137 :group 'gnus-article-treat
1138 :link '(custom-manual "(gnus)Customizing Articles")
1139 :type gnus-article-treat-custom)
1140 (put 'gnus-treat-highlight-signature 'highlight t)
1142 (defcustom gnus-treat-buttonize '(and 100000 (typep "text/plain"))
1144 Valid values are nil, t, `head', `first', `last', an integer or a
1145 predicate. See Info node `(gnus)Customizing Articles'."
1146 :group 'gnus-article-treat
1147 :link '(custom-manual "(gnus)Customizing Articles")
1148 :type gnus-article-treat-custom)
1149 (put 'gnus-treat-buttonize 'highlight t)
1151 (defcustom gnus-treat-buttonize-head 'head
1152 "Add buttons to the head.
1153 Valid values are nil, t, `head', `first', `last', an integer or a
1154 predicate. See Info node `(gnus)Customizing Articles'."
1155 :group 'gnus-article-treat
1156 :link '(custom-manual "(gnus)Customizing Articles")
1157 :type gnus-article-treat-head-custom)
1158 (put 'gnus-treat-buttonize-head 'highlight t)
1160 (defcustom gnus-treat-date 'head
1161 "Display dates according to the `gnus-article-date-headers' variable.
1162 Valid values are nil, t, `head', `first', `last', an integer or a
1163 predicate. See Info node `(gnus)Customizing Articles'."
1165 :group 'gnus-article-treat
1166 :link '(custom-manual "(gnus)Customizing Articles")
1167 :type gnus-article-treat-head-custom)
1169 (defcustom gnus-treat-emphasize 50000
1171 Valid values are nil, t, `head', `first', `last', an integer or a
1172 predicate. See Info node `(gnus)Customizing Articles'."
1173 :group 'gnus-article-treat
1174 :link '(custom-manual "(gnus)Customizing Articles")
1175 :type gnus-article-treat-custom)
1176 (put 'gnus-treat-emphasize 'highlight t)
1178 (defcustom gnus-treat-strip-cr nil
1179 "Remove carriage returns.
1180 Valid values are nil, t, `head', `first', `last', an integer or a
1181 predicate. See Info node `(gnus)Customizing Articles'."
1183 :group 'gnus-article-treat
1184 :link '(custom-manual "(gnus)Customizing Articles")
1185 :type gnus-article-treat-custom)
1187 (defcustom gnus-treat-unsplit-urls nil
1188 "Remove newlines from within URLs.
1189 Valid values are nil, t, `head', `first', `last', an integer or a
1190 predicate. See Info node `(gnus)Customizing Articles'."
1192 :group 'gnus-article-treat
1193 :link '(custom-manual "(gnus)Customizing Articles")
1194 :type gnus-article-treat-custom)
1196 (defcustom gnus-treat-leading-whitespace nil
1197 "Remove leading whitespace in headers.
1198 Valid values are nil, t, `head', `first', `last', an integer or a
1199 predicate. See Info node `(gnus)Customizing Articles'."
1201 :group 'gnus-article-treat
1202 :link '(custom-manual "(gnus)Customizing Articles")
1203 :type gnus-article-treat-custom)
1205 (defcustom gnus-treat-hide-headers 'head
1207 Valid values are nil, t, `head', `first', `last', an integer or a
1208 predicate. See Info node `(gnus)Customizing Articles'."
1209 :group 'gnus-article-treat
1210 :link '(custom-manual "(gnus)Customizing Articles")
1211 :type gnus-article-treat-head-custom)
1213 (defcustom gnus-treat-hide-boring-headers nil
1214 "Hide boring headers.
1215 Valid values are nil, t, `head', `first', `last', an integer or a
1216 predicate. See Info node `(gnus)Customizing Articles'."
1217 :group 'gnus-article-treat
1218 :link '(custom-manual "(gnus)Customizing Articles")
1219 :type gnus-article-treat-head-custom)
1221 (defcustom gnus-treat-hide-signature nil
1222 "Hide the signature.
1223 Valid values are nil, t, `head', `first', `last', an integer or a
1224 predicate. See Info node `(gnus)Customizing Articles'."
1225 :group 'gnus-article-treat
1226 :link '(custom-manual "(gnus)Customizing Articles")
1227 :type gnus-article-treat-custom)
1229 (defcustom gnus-treat-fill-article nil
1231 Valid values are nil, t, `head', `first', `last', an integer or a
1232 predicate. See Info node `(gnus)Customizing Articles'."
1233 :group 'gnus-article-treat
1234 :link '(custom-manual "(gnus)Customizing Articles")
1235 :type gnus-article-treat-custom)
1237 (defcustom gnus-treat-hide-citation nil
1239 Valid values are nil, t, `head', `first', `last', an integer or a
1240 predicate. See Info node `(gnus)Customizing Articles'.
1242 See `gnus-article-highlight-citation' for variables used to
1243 control what it hides."
1244 :group 'gnus-article-treat
1245 :link '(custom-manual "(gnus)Customizing Articles")
1246 :type gnus-article-treat-custom)
1248 (defcustom gnus-treat-hide-citation-maybe nil
1249 "Hide cited text according to certain conditions.
1250 Valid values are nil, t, `head', `first', `last', an integer or a
1251 predicate. See Info node `(gnus)Customizing Articles'.
1253 See `gnus-cite-hide-percentage' and `gnus-cite-hide-absolute' for
1254 how to control what it hides."
1255 :group 'gnus-article-treat
1256 :link '(custom-manual "(gnus)Customizing Articles")
1257 :type gnus-article-treat-custom)
1259 (defcustom gnus-treat-strip-list-identifiers 'head
1260 "Strip list identifiers from `gnus-list-identifiers`.
1261 Valid values are nil, t, `head', `first', `last', an integer or a
1262 predicate. See Info node `(gnus)Customizing Articles'."
1264 :group 'gnus-article-treat
1265 :link '(custom-manual "(gnus)Customizing Articles")
1266 :type gnus-article-treat-custom)
1268 (gnus-define-group-parameter
1271 "Alist of regexps and correspondent identifiers."
1272 :variable-group gnus-article-washing
1274 '(choice :tag "Identifier"
1276 (symbol :tag "Item in `gnus-list-identifiers'" none)
1278 (const :tag "None" nil))
1280 "If non-nil, specify how to remove `identifiers' from articles' subject.
1282 Any symbol is used to look up a regular expression to match the
1283 banner in `gnus-list-identifiers'. A string is used as a regular
1284 expression to match the identifier directly.")
1286 (make-obsolete-variable 'gnus-treat-strip-pgp nil
1287 "Gnus 5.10 (Emacs 22.1)")
1289 (defcustom gnus-treat-strip-pem nil
1290 "Strip PEM signatures.
1291 Valid values are nil, t, `head', `first', `last', an integer or a
1292 predicate. See Info node `(gnus)Customizing Articles'."
1293 :group 'gnus-article-treat
1294 :link '(custom-manual "(gnus)Customizing Articles")
1295 :type gnus-article-treat-custom)
1297 (defcustom gnus-treat-strip-banner t
1298 "Strip banners from articles.
1299 The banner to be stripped is specified in the `banner' group parameter.
1300 Valid values are nil, t, `head', `first', `last', an integer or a
1301 predicate. See Info node `(gnus)Customizing Articles'."
1302 :group 'gnus-article-treat
1303 :link '(custom-manual "(gnus)Customizing Articles")
1304 :type gnus-article-treat-custom)
1306 (defcustom gnus-treat-highlight-headers 'head
1307 "Highlight the headers.
1308 Valid values are nil, t, `head', `first', `last', an integer or a
1309 predicate. See Info node `(gnus)Customizing Articles'."
1310 :group 'gnus-article-treat
1311 :link '(custom-manual "(gnus)Customizing Articles")
1312 :type gnus-article-treat-head-custom)
1313 (put 'gnus-treat-highlight-headers 'highlight t)
1315 (defcustom gnus-treat-highlight-citation t
1316 "Highlight cited text.
1317 Valid values are nil, t, `head', `first', `last', an integer or a
1318 predicate. See Info node `(gnus)Customizing Articles'."
1319 :group 'gnus-article-treat
1320 :link '(custom-manual "(gnus)Customizing Articles")
1321 :type gnus-article-treat-custom)
1322 (put 'gnus-treat-highlight-citation 'highlight t)
1324 (defcustom gnus-treat-strip-headers-in-body t
1325 "Strip the X-No-Archive header line from the beginning of the body.
1326 Valid values are nil, t, `head', `first', `last', an integer or a
1327 predicate. See Info node `(gnus)Customizing Articles'."
1329 :group 'gnus-article-treat
1330 :link '(custom-manual "(gnus)Customizing Articles")
1331 :type gnus-article-treat-custom)
1333 (defcustom gnus-treat-strip-trailing-blank-lines nil
1334 "Strip trailing 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 Consider to use `last' instead."
1340 :group 'gnus-article-treat
1341 :link '(custom-manual "(gnus)Customizing Articles")
1342 :type gnus-article-treat-custom)
1344 (defcustom gnus-treat-strip-leading-blank-lines nil
1345 "Strip leading blank lines.
1346 Valid values are nil, t, `head', `first', `last', an integer or a
1347 predicate. See Info node `(gnus)Customizing Articles'.
1349 When set to t, it also strips trailing blanks in all MIME parts."
1350 :group 'gnus-article-treat
1351 :link '(custom-manual "(gnus)Customizing Articles")
1352 :type gnus-article-treat-custom)
1354 (defcustom gnus-treat-strip-multiple-blank-lines nil
1355 "Strip multiple blank lines.
1356 Valid values are nil, t, `head', `first', `last', an integer or a
1357 predicate. See Info node `(gnus)Customizing Articles'."
1358 :group 'gnus-article-treat
1359 :link '(custom-manual "(gnus)Customizing Articles")
1360 :type gnus-article-treat-custom)
1362 (defcustom gnus-treat-unfold-headers 'head
1363 "Unfold folded header lines.
1364 Valid values are nil, t, `head', `first', `last', an integer or a
1365 predicate. See Info node `(gnus)Customizing Articles'."
1367 :group 'gnus-article-treat
1368 :link '(custom-manual "(gnus)Customizing Articles")
1369 :type gnus-article-treat-custom)
1371 (defcustom gnus-article-unfold-long-headers nil
1372 "If non-nil, allow unfolding headers even if the header is long.
1373 If it is a regexp, only long headers matching this regexp are unfolded.
1374 If it is t, all long headers are unfolded.
1376 This variable has no effect if `gnus-treat-unfold-headers' is nil."
1377 :version "23.1" ;; No Gnus
1378 :group 'gnus-article-treat
1379 :type '(choice (const nil)
1380 (const :tag "all" t)
1383 (defcustom gnus-treat-fold-headers nil
1385 Valid values are nil, t, `head', `first', `last', an integer or a
1386 predicate. See Info node `(gnus)Customizing Articles'."
1388 :group 'gnus-article-treat
1389 :link '(custom-manual "(gnus)Customizing Articles")
1390 :type gnus-article-treat-custom)
1392 (defcustom gnus-treat-fold-newsgroups 'head
1393 "Fold the Newsgroups and Followup-To headers.
1394 Valid values are nil, t, `head', `first', `last', an integer or a
1395 predicate. See Info node `(gnus)Customizing Articles'."
1397 :group 'gnus-article-treat
1398 :link '(custom-manual "(gnus)Customizing Articles")
1399 :type gnus-article-treat-custom)
1401 (defcustom gnus-treat-overstrike t
1402 "Treat overstrike highlighting.
1403 Valid values are nil, t, `head', `first', `last', an integer or a
1404 predicate. See Info node `(gnus)Customizing Articles'."
1405 :group 'gnus-article-treat
1406 :link '(custom-manual "(gnus)Customizing Articles")
1407 :type gnus-article-treat-custom)
1408 (put 'gnus-treat-overstrike 'highlight t)
1410 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1411 "Treat ANSI SGR control sequences.
1412 Valid values are nil, t, `head', `first', `last', an integer or a
1413 predicate. See Info node `(gnus)Customizing Articles'."
1414 :group 'gnus-article-treat
1415 :link '(custom-manual "(gnus)Customizing Articles")
1416 :type gnus-article-treat-custom)
1418 (make-obsolete-variable 'gnus-treat-display-xface
1419 'gnus-treat-display-x-face "Emacs 22.1")
1421 (defcustom gnus-treat-display-x-face
1422 (and (not noninteractive)
1423 (gnus-image-type-available-p 'xbm)
1424 (if (featurep 'xemacs)
1427 (and (string-match "^0x" (shell-command-to-string "uncompface"))
1428 (executable-find "icontopbm"))
1429 ;; shell-command-to-string may signal an error, e.g. if
1430 ;; shell-file-name is not found.
1433 "Display X-Face headers.
1434 Valid values are nil and `head'.
1435 See Info node `(gnus)Customizing Articles' and Info node
1436 `(gnus)X-Face' for details."
1437 :group 'gnus-article-treat
1439 :link '(custom-manual "(gnus)Customizing Articles")
1440 :link '(custom-manual "(gnus)X-Face")
1441 :type gnus-article-treat-head-custom
1442 :set (lambda (symbol value)
1445 (cond ((or (boundp symbol) (get symbol 'saved-value))
1447 ((boundp 'gnus-treat-display-xface)
1449 ** gnus-treat-display-xface is an obsolete variable;\
1450 use gnus-treat-display-x-face instead")
1451 (default-value 'gnus-treat-display-xface))
1452 ((get 'gnus-treat-display-xface 'saved-value)
1454 ** gnus-treat-display-xface is an obsolete variable;\
1455 use gnus-treat-display-x-face instead")
1456 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1459 (put 'gnus-treat-display-x-face 'highlight t)
1461 (defcustom gnus-treat-display-face
1462 (and (not noninteractive)
1463 (gnus-image-type-available-p 'png)
1465 "Display Face headers.
1466 Valid values are nil, t, `head', `first', `last', an integer or a
1467 predicate. See Info node `(gnus)Customizing Articles' and Info
1468 node `(gnus)Face' for details."
1469 :group 'gnus-article-treat
1471 :link '(custom-manual "(gnus)Customizing Articles")
1472 :link '(custom-manual "(gnus)X-Face")
1473 :type gnus-article-treat-head-custom)
1474 (put 'gnus-treat-display-face 'highlight t)
1476 (defcustom gnus-treat-display-smileys (gnus-image-type-available-p 'xpm)
1478 Valid values are nil, t, `head', `first', `last', an integer or a
1479 predicate. See Info node `(gnus)Customizing Articles' and Info
1480 node `(gnus)Smileys' for details."
1481 :group 'gnus-article-treat
1483 :link '(custom-manual "(gnus)Customizing Articles")
1484 :link '(custom-manual "(gnus)Smileys")
1485 :type gnus-article-treat-custom)
1486 (put 'gnus-treat-display-smileys 'highlight t)
1488 (defcustom gnus-treat-from-picon
1489 (if (and (gnus-image-type-available-p 'xpm)
1490 (gnus-picons-installed-p))
1492 "Display picons in the From header.
1493 Valid values are nil, t, `head', `first', `last', an integer or a
1494 predicate. See Info node `(gnus)Customizing Articles' and Info
1495 node `(gnus)Picons' for details."
1497 :group 'gnus-article-treat
1499 :link '(custom-manual "(gnus)Customizing Articles")
1500 :link '(custom-manual "(gnus)Picons")
1501 :type gnus-article-treat-head-custom)
1502 (put 'gnus-treat-from-picon 'highlight t)
1504 (defcustom gnus-treat-mail-picon
1505 (if (and (gnus-image-type-available-p 'xpm)
1506 (gnus-picons-installed-p))
1508 "Display picons in To and Cc headers.
1509 Valid values are nil, t, `head', `first', `last', an integer or a
1510 predicate. See Info node `(gnus)Customizing Articles' and Info
1511 node `(gnus)Picons' for details."
1513 :group 'gnus-article-treat
1515 :link '(custom-manual "(gnus)Customizing Articles")
1516 :link '(custom-manual "(gnus)Picons")
1517 :type gnus-article-treat-head-custom)
1518 (put 'gnus-treat-mail-picon 'highlight t)
1520 (defcustom gnus-treat-newsgroups-picon
1521 (if (and (gnus-image-type-available-p 'xpm)
1522 (gnus-picons-installed-p))
1524 "Display picons in the Newsgroups and Followup-To headers.
1525 Valid values are nil, t, `head', `first', `last', an integer or a
1526 predicate. See Info node `(gnus)Customizing Articles' and Info
1527 node `(gnus)Picons' for details."
1529 :group 'gnus-article-treat
1531 :link '(custom-manual "(gnus)Customizing Articles")
1532 :link '(custom-manual "(gnus)Picons")
1533 :type gnus-article-treat-head-custom)
1534 (put 'gnus-treat-newsgroups-picon 'highlight t)
1536 (defcustom gnus-treat-from-gravatar nil
1537 "Display gravatars in the From header.
1538 Valid values are nil, t, `head', `first', `last', an integer or a
1539 predicate. See Info node `(gnus)Customizing Articles' and Info
1540 node `(gnus)Gravatars' for details."
1542 :group 'gnus-article-treat
1543 :group 'gnus-gravatar
1544 :link '(custom-manual "(gnus)Customizing Articles")
1545 :link '(custom-manual "(gnus)Gravatars")
1546 :type gnus-article-treat-head-custom)
1547 (put 'gnus-treat-from-gravatar 'highlight t)
1549 (defcustom gnus-treat-mail-gravatar nil
1550 "Display gravatars in To and Cc headers.
1551 Valid values are nil, t, `head', `first', `last', an integer or a
1552 predicate. See Info node `(gnus)Customizing Articles' and Info
1553 node `(gnus)Gravatars' for details."
1555 :group 'gnus-article-treat
1556 :group 'gnus-gravatar
1557 :link '(custom-manual "(gnus)Customizing Articles")
1558 :link '(custom-manual "(gnus)Gravatars")
1559 :type gnus-article-treat-head-custom)
1560 (put 'gnus-treat-mail-gravatar 'highlight t)
1562 (defcustom gnus-treat-body-boundary
1563 (if (or gnus-treat-newsgroups-picon
1564 gnus-treat-mail-picon
1565 gnus-treat-from-picon
1566 gnus-treat-from-gravatar
1567 gnus-treat-mail-gravatar)
1568 ;; If there's much decoration, the user might prefer a boundary.
1571 "Draw a boundary at the end of the headers.
1572 Valid values are nil and `head'.
1573 See Info node `(gnus)Customizing Articles' for details."
1575 :group 'gnus-article-treat
1576 :link '(custom-manual "(gnus)Customizing Articles")
1577 :type gnus-article-treat-head-custom)
1579 (defcustom gnus-treat-capitalize-sentences nil
1580 "Capitalize sentence-starting words.
1581 Valid values are nil, t, `head', `first', `last', an integer or a
1582 predicate. See Info node `(gnus)Customizing Articles'."
1584 :group 'gnus-article-treat
1585 :link '(custom-manual "(gnus)Customizing Articles")
1586 :type gnus-article-treat-custom)
1588 (defcustom gnus-treat-wash-html nil
1590 Valid values are nil, t, `head', `first', `last', an integer or a
1591 predicate. See Info node `(gnus)Customizing Articles'."
1593 :group 'gnus-article-treat
1594 :link '(custom-manual "(gnus)Customizing Articles")
1595 :type gnus-article-treat-custom)
1597 (defcustom gnus-treat-fill-long-lines '(typep "text/plain")
1599 Valid values are nil, t, `head', `first', `last', an integer or a
1600 predicate. See Info node `(gnus)Customizing Articles'."
1602 :group 'gnus-article-treat
1603 :link '(custom-manual "(gnus)Customizing Articles")
1604 :type gnus-article-treat-custom)
1606 (defcustom gnus-treat-x-pgp-sig nil
1608 To automatically treat X-PGP-Sig, set it to head.
1609 Valid values are nil, t, `head', `first', `last', an integer or a
1610 predicate. See Info node `(gnus)Customizing Articles'."
1612 :group 'gnus-article-treat
1613 :group 'mime-security
1614 :link '(custom-manual "(gnus)Customizing Articles")
1615 :type gnus-article-treat-custom)
1617 (defvar gnus-article-encrypt-protocol-alist
1618 '(("PGP" . mml2015-self-encrypt)))
1620 ;; Set to nil if more than one protocol added to
1621 ;; gnus-article-encrypt-protocol-alist.
1622 (defcustom gnus-article-encrypt-protocol "PGP"
1623 "The protocol used for encrypt articles.
1624 It is a string, such as \"PGP\". If nil, ask user."
1627 :group 'mime-security)
1629 (defvar idna-program)
1631 (defcustom gnus-use-idna (and (mm-coding-system-p 'utf-8)
1635 (invalid-operation))
1637 (executable-find idna-program))
1638 "Whether IDNA decoding of headers is used when viewing messages.
1639 This requires GNU Libidn, and by default only enabled if it is found."
1641 :group 'gnus-article-headers
1644 (defcustom gnus-article-over-scroll nil
1645 "If non-nil, allow scrolling the article buffer even when there no more text."
1647 :group 'gnus-article
1650 (defcustom gnus-inhibit-images nil
1651 "Non-nil means inhibit displaying of images inline in the article body."
1653 :group 'gnus-article
1656 (defcustom gnus-blocked-images 'gnus-block-private-groups
1657 "Images that have URLs matching this regexp will be blocked.
1658 This can also be a function to be evaluated. If so, it will be
1659 called with the group name as the parameter, and should return a
1663 :type '(choice regexp function))
1665 ;;; Internal variables
1667 (defvar gnus-english-month-names
1668 '("January" "February" "March" "April" "May" "June" "July" "August"
1669 "September" "October" "November" "December"))
1671 (defvar article-goto-body-goes-to-point-min-p nil)
1672 (defvar gnus-article-wash-types nil)
1673 (defvar gnus-article-emphasis-alist nil)
1674 (defvar gnus-article-image-alist nil)
1676 (defvar gnus-article-mime-handle-alist-1 nil)
1677 (defvar gnus-treatment-function-alist
1678 '((gnus-treat-strip-cr gnus-article-remove-cr)
1679 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1680 (gnus-treat-strip-banner gnus-article-strip-banner)
1681 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1682 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1683 (gnus-treat-buttonize gnus-article-add-buttons)
1684 (gnus-treat-fill-article gnus-article-fill-cited-article)
1685 (gnus-treat-fill-long-lines gnus-article-fill-cited-long-lines)
1686 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1687 (gnus-treat-display-x-face gnus-article-display-x-face)
1688 (gnus-treat-display-face gnus-article-display-face)
1689 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1690 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1691 (gnus-treat-hide-signature gnus-article-hide-signature)
1692 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1693 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1694 (gnus-treat-from-picon gnus-treat-from-picon)
1695 (gnus-treat-mail-picon gnus-treat-mail-picon)
1696 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1697 (gnus-treat-strip-pem gnus-article-hide-pem)
1698 (gnus-treat-date gnus-article-treat-date)
1699 (gnus-treat-from-gravatar gnus-treat-from-gravatar)
1700 (gnus-treat-mail-gravatar gnus-treat-mail-gravatar)
1701 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1702 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1703 (gnus-treat-strip-trailing-blank-lines
1704 gnus-article-remove-trailing-blank-lines)
1705 (gnus-treat-strip-leading-blank-lines
1706 gnus-article-strip-leading-blank-lines)
1707 (gnus-treat-strip-multiple-blank-lines
1708 gnus-article-strip-multiple-blank-lines)
1709 (gnus-treat-overstrike gnus-article-treat-overstrike)
1710 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1711 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1712 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1713 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1714 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1715 (gnus-treat-display-smileys gnus-treat-smiley)
1716 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1717 (gnus-treat-wash-html gnus-article-wash-html)
1718 (gnus-treat-emphasize gnus-article-emphasize)
1719 (gnus-treat-hide-citation gnus-article-hide-citation)
1720 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1721 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1722 (gnus-treat-body-boundary gnus-article-treat-body-boundary)))
1724 (defvar gnus-article-mime-handle-alist nil)
1725 (defvar article-lapsed-timer nil)
1726 (defvar gnus-article-current-summary nil)
1728 (defvar gnus-article-mode-syntax-table
1729 (let ((table (copy-syntax-table text-mode-syntax-table)))
1730 ;; This causes the citation match run O(2^n).
1731 ;; (modify-syntax-entry ?- "w" table)
1732 (modify-syntax-entry ?> ")<" table)
1733 (modify-syntax-entry ?< "(>" table)
1734 ;; make M-. in article buffers work for `foo' strings
1735 (modify-syntax-entry ?' " " table)
1736 (modify-syntax-entry ?` " " table)
1738 "Syntax table used in article mode buffers.
1739 Initialized from `text-mode-syntax-table.")
1741 (defvar gnus-save-article-buffer nil)
1743 (defvar gnus-number-of-articles-to-be-saved nil)
1745 (defvar gnus-inhibit-hiding nil)
1747 (defvar gnus-article-edit-mode nil)
1749 ;;; Macros for dealing with the article buffer.
1751 (defmacro gnus-with-article-headers (&rest forms)
1752 `(with-current-buffer gnus-article-buffer
1754 (let ((inhibit-read-only t)
1755 (inhibit-point-motion-hooks t)
1756 (case-fold-search t))
1757 (article-narrow-to-head)
1760 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1761 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1763 (defmacro gnus-with-article-buffer (&rest forms)
1764 `(when (buffer-live-p (get-buffer gnus-article-buffer))
1765 (with-current-buffer gnus-article-buffer
1766 (let ((inhibit-read-only t))
1769 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1770 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1772 (defun gnus-article-goto-header (header)
1773 "Go to HEADER, which is a regular expression."
1774 (re-search-forward (concat "^\\(" header "\\):") nil t))
1776 (defsubst gnus-article-hide-text (b e props)
1777 "Set text PROPS on the B to E region."
1778 (gnus-add-text-properties-when 'article-type nil b e props))
1780 (defsubst gnus-article-unhide-text (b e)
1781 "Remove hidden text properties from region between B and E."
1782 (remove-text-properties b e gnus-hidden-properties))
1784 (defun gnus-article-hide-text-type (b e type)
1785 "Hide text of TYPE between B and E."
1786 (gnus-add-wash-type type)
1787 (gnus-article-hide-text
1788 b e (cons 'article-type (cons type gnus-hidden-properties))))
1790 (defun gnus-article-unhide-text-type (b e type)
1791 "Unhide text of TYPE between B and E."
1792 (gnus-delete-wash-type type)
1793 (remove-text-properties
1794 b e (cons 'article-type (cons type gnus-hidden-properties))))
1796 (defun gnus-article-delete-text-of-type (type)
1797 "Delete text of TYPE in the current buffer."
1799 (let ((b (point-min)))
1800 (if (eq type 'multipart)
1801 ;; Remove MIME buttons associated with multipart/alternative parts.
1804 (while (if (get-text-property (point) 'gnus-part)
1806 (when (setq b (next-single-property-change (point)
1811 (skip-chars-forward "\n")
1812 (when (eq (get-text-property b 'article-type) 'multipart)
1813 (delete-region b (point)))))
1814 (while (setq b (text-property-any b (point-max) 'article-type type))
1816 b (or (text-property-not-all b (point-max) 'article-type type)
1819 (defun gnus-article-delete-invisible-text ()
1820 "Delete all invisible text in the current buffer."
1822 (let ((b (point-min)))
1823 (while (setq b (text-property-any b (point-max) 'invisible t))
1825 b (or (text-property-not-all b (point-max) 'invisible t)
1828 (defsubst gnus-article-header-rank ()
1829 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1830 (let ((list gnus-sorted-header-list)
1833 (if (looking-at (car list))
1835 (setq list (cdr list))
1839 (defun article-hide-headers (&optional _arg _delete)
1840 "Hide unwanted headers and possibly sort them as well."
1842 ;; This function might be inhibited.
1843 (unless gnus-inhibit-hiding
1844 (let ((inhibit-read-only t)
1845 (case-fold-search t)
1846 (max (1+ (length gnus-sorted-header-list)))
1847 (inhibit-point-motion-hooks t)
1848 (cur (current-buffer))
1849 ignored visible beg)
1851 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1852 ;; group parameters, so we should go to the summary buffer.
1855 (progn (set-buffer gnus-summary-buffer) t)
1857 (setq ignored (when (not gnus-visible-headers)
1858 (cond ((stringp gnus-ignored-headers)
1859 gnus-ignored-headers)
1860 ((listp gnus-ignored-headers)
1861 (mapconcat 'identity
1862 gnus-ignored-headers
1864 visible (cond ((stringp gnus-visible-headers)
1865 gnus-visible-headers)
1866 ((and gnus-visible-headers
1867 (listp gnus-visible-headers))
1868 (mapconcat 'identity
1869 gnus-visible-headers
1873 ;; First we narrow to just the headers.
1874 (article-narrow-to-head)
1875 ;; Hide any "From " lines at the beginning of (mail) articles.
1876 (while (looking-at "From ")
1879 (delete-region (point-min) (point)))
1880 ;; Then treat the rest of the header lines.
1881 ;; Then we use the two regular expressions
1882 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1883 ;; select which header lines is to remain visible in the
1885 (while (re-search-forward "^[^ \t:]*:" nil t)
1887 ;; Mark the rank of the header.
1889 (point) (1+ (point)) 'message-rank
1890 (if (or (and visible (looking-at visible))
1892 (not (looking-at ignored))))
1893 (gnus-article-header-rank)
1896 (message-sort-headers-1)
1897 (when (setq beg (text-property-any
1898 (point-min) (point-max) 'message-rank (+ 2 max)))
1899 ;; We delete the unwanted headers.
1900 (gnus-add-wash-type 'headers)
1901 (add-text-properties (point-min) (+ 5 (point-min))
1902 '(article-type headers dummy-invisible t))
1903 (delete-region beg (point-max))))))))
1905 (defun article-hide-boring-headers (&optional arg)
1906 "Toggle hiding of headers that aren't very interesting.
1907 If given a negative prefix, always show; if given a positive prefix,
1909 (interactive (gnus-article-hidden-arg))
1910 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1911 (not gnus-show-all-headers))
1914 (let ((inhibit-read-only t)
1915 (inhibit-point-motion-hooks t))
1916 (article-narrow-to-head)
1917 (dolist (elem gnus-boring-article-headers)
1918 (goto-char (point-min))
1920 ;; Hide empty headers.
1922 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1924 (gnus-article-hide-text-type
1928 (if (re-search-forward "^[^ \t]" nil t)
1932 ;; Hide boring Newsgroups header.
1933 ((eq elem 'newsgroups)
1934 (when (gnus-string-equal
1935 (gnus-fetch-field "newsgroups")
1936 (gnus-group-real-name
1937 (if (boundp 'gnus-newsgroup-name)
1940 (gnus-article-hide-header "newsgroups")))
1941 ((eq elem 'to-address)
1942 (let ((to (message-fetch-field "to"))
1944 (gnus-parameter-to-address
1945 (if (boundp 'gnus-newsgroup-name)
1946 gnus-newsgroup-name ""))))
1947 (when (and to to-address
1950 ;; only one address in To
1951 (nth 1 (mail-extract-address-components to))
1953 (gnus-article-hide-header "to"))))
1955 (let ((to (message-fetch-field "to"))
1957 (gnus-parameter-to-list
1958 (if (boundp 'gnus-newsgroup-name)
1959 gnus-newsgroup-name ""))))
1960 (when (and to to-list
1963 ;; only one address in To
1964 (nth 1 (mail-extract-address-components to))
1966 (gnus-article-hide-header "to"))))
1968 (let ((cc (message-fetch-field "cc"))
1970 (gnus-parameter-to-list
1971 (if (boundp 'gnus-newsgroup-name)
1972 gnus-newsgroup-name ""))))
1973 (when (and cc to-list
1976 ;; only one address in CC
1977 (nth 1 (mail-extract-address-components cc))
1979 (gnus-article-hide-header "cc"))))
1980 ((eq elem 'followup-to)
1981 (when (gnus-string-equal
1982 (message-fetch-field "followup-to")
1983 (message-fetch-field "newsgroups"))
1984 (gnus-article-hide-header "followup-to")))
1985 ((eq elem 'reply-to)
1986 (if (gnus-group-find-parameter
1987 gnus-newsgroup-name 'broken-reply-to)
1988 (gnus-article-hide-header "reply-to")
1989 (let ((from (message-fetch-field "from"))
1990 (reply-to (message-fetch-field "reply-to")))
1997 (lambda (x) (downcase (cadr x)))
1998 (mail-extract-address-components from t))
2001 (lambda (x) (downcase (cadr x)))
2002 (mail-extract-address-components reply-to t))
2004 (gnus-article-hide-header "reply-to")))))
2006 (let ((date (with-current-buffer gnus-original-article-buffer
2007 ;; If date in `gnus-article-buffer' is localized
2008 ;; (`gnus-treat-date-user-defined'),
2009 ;; `days-between' might fail.
2010 (message-fetch-field "date"))))
2012 (< (days-between (current-time-string) date)
2014 (gnus-article-hide-header "date"))))
2016 (let ((to (message-fetch-field "to"))
2017 (cc (message-fetch-field "cc")))
2018 (when (> (length to) 1024)
2019 (gnus-article-hide-header "to"))
2020 (when (> (length cc) 1024)
2021 (gnus-article-hide-header "cc"))))
2025 (goto-char (point-min))
2026 (while (re-search-forward "^to:" nil t)
2027 (setq to-count (1+ to-count)))
2028 (when (> to-count 1)
2029 (while (> to-count 0)
2030 (goto-char (point-min))
2032 (re-search-forward "^to:" nil nil to-count)
2034 (narrow-to-region (point) (point-max))
2035 (gnus-article-hide-header "to"))
2036 (setq to-count (1- to-count))))
2037 (goto-char (point-min))
2038 (while (re-search-forward "^cc:" nil t)
2039 (setq cc-count (1+ cc-count)))
2040 (when (> cc-count 1)
2041 (while (> cc-count 0)
2042 (goto-char (point-min))
2044 (re-search-forward "^cc:" nil nil cc-count)
2046 (narrow-to-region (point) (point-max))
2047 (gnus-article-hide-header "cc"))
2048 (setq cc-count (1- cc-count)))))))))))))
2050 (defun gnus-article-hide-header (header)
2052 (goto-char (point-min))
2053 (when (re-search-forward (concat "^" header ":") nil t)
2054 (gnus-article-hide-text-type
2058 (if (re-search-forward "^[^ \t]" nil t)
2063 (defvar gnus-article-normalized-header-length 40
2064 "Length of normalized headers.")
2066 (defun article-normalize-headers ()
2067 "Make all header lines 40 characters long."
2069 (let ((inhibit-read-only t)
2073 (article-narrow-to-head)
2076 ((< (setq column (- (point-at-eol) (point)))
2077 gnus-article-normalized-header-length)
2079 (insert (make-string
2080 (- gnus-article-normalized-header-length column)
2082 ((> column gnus-article-normalized-header-length)
2083 (gnus-put-text-property
2085 (forward-char gnus-article-normalized-header-length)
2092 (forward-line 1))))))
2094 (defun article-treat-dumbquotes ()
2095 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
2096 Note that this function guesses whether a character is a sm*rtq**t* or
2097 not, so it should only be used interactively.
2099 Sm*rtq**t*s are M****s***'s unilateral extension to the
2100 iso-8859-1 character map in an attempt to provide more quoting
2101 characters. If you see something like \\222 or \\264 where
2102 you're expecting some kind of apostrophe or quotation mark, then
2105 (article-translate-strings gnus-article-dumbquotes-map))
2107 (defvar org-entities)
2109 (defun article-treat-non-ascii ()
2110 "Translate many Unicode characters into their ASCII equivalents."
2112 (require 'org-entities)
2113 (let ((table (make-char-table (if (featurep 'xemacs) 'generic))))
2114 (dolist (elem org-entities)
2115 (when (and (listp elem)
2116 (= (length (nth 6 elem)) 1))
2117 (if (featurep 'xemacs)
2118 (put-char-table (aref (nth 6 elem) 0) (nth 4 elem) table)
2119 (set-char-table-range table (aref (nth 6 elem) 0) (nth 4 elem)))))
2121 (when (article-goto-body)
2122 (let ((inhibit-read-only t)
2125 (if (not (setq replace (if (featurep 'xemacs)
2126 (get-char-table (following-char) table)
2127 (aref table (following-char)))))
2130 (setq props (text-properties-at (point)))
2132 (add-text-properties (point) (progn (insert replace) (point))
2134 (insert replace)))))))))
2136 (defun article-translate-strings (map)
2137 "Translate all string in the body of the article according to MAP.
2138 MAP is an alist where the elements are on the form (\"from\" \"to\")."
2140 (when (article-goto-body)
2141 (let ((inhibit-read-only t))
2143 (let ((from (car elem))
2147 (while (search-forward from nil t)
2150 (if (eq (following-char) from)
2154 (forward-char 1)))))))))))
2156 (defun article-treat-overstrike ()
2157 "Translate overstrikes into bold text."
2160 (when (article-goto-body)
2161 (let ((inhibit-read-only t))
2162 (while (search-forward "\b" nil t)
2163 (let ((next (char-after))
2164 (previous (char-after (- (point) 2))))
2165 ;; We do the boldification/underlining by hiding the
2166 ;; overstrikes and putting the proper text property
2170 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
2171 (put-text-property (point) (1+ (point)) 'face 'bold))
2173 (gnus-article-hide-text-type
2174 (1- (point)) (1+ (point)) 'overstrike)
2176 (- (point) 2) (1- (point)) 'face 'underline))
2178 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
2180 (point) (1+ (point)) 'face 'underline)))))))))
2182 (defun article-treat-ansi-sequences ()
2183 "Translate ANSI SGR control sequences into overlays or extents."
2186 (when (article-goto-body)
2187 (let ((inhibit-read-only t))
2188 (ansi-color-apply-on-region (point) (point-max))))))
2190 (defun gnus-article-treat-unfold-headers ()
2191 "Unfold folded message headers.
2192 Only the headers that fit into the current window width will be
2195 (gnus-with-article-headers
2199 (mail-header-narrow-to-field)
2200 (let* ((header (buffer-string))
2202 (or (equal gnus-article-unfold-long-headers t)
2203 (and (stringp gnus-article-unfold-long-headers)
2204 (string-match gnus-article-unfold-long-headers
2208 (goto-char (point-min))
2209 (while (re-search-forward "\n[\t ]" nil t)
2210 (replace-match " " t t)))
2211 (setq length (- (point-max) (point-min) 1))
2212 (when (or unfoldable
2213 (< length (window-width)))
2214 (while (re-search-forward "\n[\t ]" nil t)
2215 (replace-match " " t t))))
2216 (goto-char (point-max)))))))
2218 (defun gnus-article-treat-fold-headers ()
2219 "Fold message headers."
2221 (gnus-with-article-headers
2224 (mail-header-narrow-to-field)
2225 (mail-header-fold-field)
2226 (goto-char (point-max))))))
2228 (defun gnus-treat-smiley ()
2229 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2231 (gnus-with-article-buffer
2232 (if (memq 'smiley gnus-article-wash-types)
2233 (gnus-delete-images 'smiley)
2235 (let ((images (smiley-region (point) (point-max))))
2237 (gnus-add-wash-type 'smiley)
2238 (dolist (image images)
2239 (gnus-add-image 'smiley image)))))))
2241 (defun gnus-article-remove-images ()
2242 "Remove all images from the article buffer."
2244 (gnus-with-article-buffer
2247 (dolist (elem gnus-article-image-alist)
2248 (gnus-delete-images (car elem))))))
2250 (autoload 'w3m-toggle-inline-images "w3m")
2252 (defun gnus-article-show-images ()
2253 "Show any images that are in the HTML-rendered article buffer.
2254 This only works if the article in question is HTML."
2256 (gnus-with-article-buffer
2259 (if (eq mm-text-html-renderer 'w3m)
2260 (let ((mm-inline-text-html-with-images nil))
2261 (w3m-toggle-inline-images))
2262 (dolist (region (gnus-find-text-property-region (point-min) (point-max)
2264 (destructuring-bind (start end function) region
2265 (funcall function (get-text-property start 'image-url)
2268 (defun gnus-article-treat-fold-newsgroups ()
2269 "Unfold folded message headers.
2270 Only the headers that fit into the current window width will be
2273 (gnus-with-article-headers
2274 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2276 (mail-header-narrow-to-field)
2277 (while (re-search-forward ", *" nil t)
2278 (replace-match ", " t t))
2279 (mail-header-fold-field)
2280 (goto-char (point-max))))))
2282 (defcustom gnus-article-truncate-lines (default-value 'truncate-lines)
2283 "Value of `truncate-lines' in Gnus Article buffer.
2284 Valid values are nil, t, `head', `first', `last', an integer or a
2285 predicate. See Info node `(gnus)Customizing Articles'."
2286 :version "23.1" ;; No Gnus
2287 :group 'gnus-article
2288 ;; :link '(custom-manual "(gnus)Customizing Articles")
2291 (defun gnus-article-toggle-truncate-lines (&optional arg)
2292 "Toggle whether to fold or truncate long lines in article the buffer.
2293 If ARG is non-nil and not a number, toggle
2294 `gnus-article-truncate-lines' too. If ARG is a number, truncate
2295 long lines if and only if arg is positive."
2298 ((and (numberp arg) (> arg 0))
2299 (setq gnus-article-truncate-lines t))
2301 (setq gnus-article-truncate-lines nil))
2303 (setq gnus-article-truncate-lines
2304 (not gnus-article-truncate-lines))))
2305 (gnus-with-article-buffer
2307 ((and (numberp arg) (> arg 0))
2308 (setq truncate-lines nil))
2310 (setq truncate-lines t)))
2311 ;; In versions of Emacs 22 (CVS) before 2006-05-26,
2312 ;; `toggle-truncate-lines' needs an argument.
2313 (toggle-truncate-lines)))
2315 (defun gnus-article-treat-body-boundary ()
2316 "Place a boundary line at the end of the headers."
2318 (when (and gnus-body-boundary-delimiter
2319 (> (length gnus-body-boundary-delimiter) 0))
2320 (gnus-with-article-headers
2321 (goto-char (point-max))
2322 (let ((start (point)))
2323 (insert "X-Boundary: ")
2324 (gnus-add-text-properties start (point) gnus-hidden-properties)
2325 (insert (let (str (max (window-width)))
2326 (if (featurep 'xemacs)
2327 (setq max (1- max)))
2328 (while (>= max (length str))
2329 (setq str (concat str gnus-body-boundary-delimiter)))
2330 (substring str 0 max))
2332 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2334 (defun article-fill-long-lines ()
2335 "Fill lines that are wider than the window width."
2338 (let ((inhibit-read-only t)
2339 (width (window-width (get-buffer-window (current-buffer)))))
2342 (let ((adaptive-fill-mode nil)) ;Why? -sm
2345 (when (>= (current-column) (min fill-column width))
2346 (narrow-to-region (min (1+ (point)) (point-max))
2348 (let ((goback (point-marker)))
2349 (fill-paragraph nil)
2350 (goto-char (marker-position goback)))
2352 (forward-line 1)))))))
2354 (defun article-capitalize-sentences ()
2355 "Capitalize the first word in each sentence."
2358 (let ((inhibit-read-only t)
2359 (paragraph-start "^[\n\^L]"))
2363 (forward-sentence)))))
2365 (defun article-remove-cr ()
2366 "Remove trailing CRs and then translate remaining CRs into LFs."
2369 (let ((inhibit-read-only t))
2370 (goto-char (point-min))
2371 (while (re-search-forward "\r+$" nil t)
2372 (replace-match "" t t))
2373 (goto-char (point-min))
2374 (while (search-forward "\r" nil t)
2375 (replace-match "\n" t t)))))
2377 (defun article-remove-trailing-blank-lines ()
2378 "Remove all trailing blank lines from the article."
2381 (let ((inhibit-read-only t))
2382 (goto-char (point-max))
2386 (while (and (not (bobp))
2387 (looking-at "^[ \t]*$")
2388 (not (gnus-annotation-in-region-p
2389 (point) (point-at-eol))))
2394 (defvar gnus-face-properties-alist)
2396 (defun article-display-face (&optional force)
2397 "Display any Face headers in the header."
2398 (interactive (list 'force))
2399 (let ((wash-face-p buffer-read-only))
2400 (gnus-with-article-headers
2401 ;; When displaying parts, this function can be called several times on
2402 ;; the same article, without any intended toggle semantic (as typing `W
2403 ;; D d' would have). So face deletion must occur only when we come from
2404 ;; an interactive command, that is when the *Article* buffer is
2406 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2407 (gnus-delete-images 'face)
2408 (let ((from (message-fetch-field "from"))
2410 (save-current-buffer
2411 (when (and wash-face-p
2412 (gnus-buffer-live-p gnus-original-article-buffer)
2413 (not (re-search-forward "^Face:[\t ]*" nil t)))
2414 (set-buffer gnus-original-article-buffer))
2416 (mail-narrow-to-head)
2418 ;; Check whether this face is censored.
2419 (not (and gnus-article-x-face-too-ugly
2421 (setq from (message-fetch-field "from")))
2422 (string-match gnus-article-x-face-too-ugly
2424 (while (gnus-article-goto-header "Face")
2425 (push (mail-header-field-value) faces)))))
2427 (goto-char (point-min))
2429 (unless (setq from (gnus-article-goto-header "from"))
2432 (insert " [no `from' set]\n"))
2434 (when (setq png (gnus-convert-face-to-png (pop faces)))
2436 (apply 'gnus-create-image png 'png t
2437 (cdr (assq 'png gnus-face-properties-alist))))
2440 (gnus-add-wash-type 'face)
2441 (gnus-add-image 'face image)
2442 (gnus-put-image image nil 'face)))))))))))
2444 (defun article-display-x-face (&optional force)
2445 "Look for an X-Face header and display it if present."
2446 (interactive (list 'force))
2447 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2448 (gnus-with-article-headers
2449 ;; Delete the old process, if any.
2450 (when (process-status "article-x-face")
2451 (delete-process "article-x-face"))
2452 ;; See the comment in `article-display-face'.
2453 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2454 ;; We have already displayed X-Faces, so we remove them
2456 (gnus-delete-images 'xface)
2458 (let ((from (message-fetch-field "from"))
2460 (save-current-buffer
2461 (when (and wash-face-p
2462 (gnus-buffer-live-p gnus-original-article-buffer)
2463 (not (re-search-forward "^X-Face:[\t ]*" nil t)))
2464 ;; If type `W f', use gnus-original-article-buffer,
2465 ;; otherwise use the current buffer because displaying
2466 ;; RFC822 parts calls this function too.
2467 (set-buffer gnus-original-article-buffer))
2469 (mail-narrow-to-head)
2470 (and gnus-article-x-face-command
2472 ;; Check whether this face is censored.
2473 (not (and gnus-article-x-face-too-ugly
2475 (setq from (message-fetch-field "from")))
2476 (string-match gnus-article-x-face-too-ugly
2478 (while (gnus-article-goto-header "X-Face")
2479 (push (mail-header-field-value) x-faces)))))
2481 ;; We display the face.
2482 (cond ((functionp gnus-article-x-face-command)
2483 ;; The command is a lisp function, so we call it.
2484 (mapc gnus-article-x-face-command x-faces))
2485 ((stringp gnus-article-x-face-command)
2486 ;; The command is a string, so we interpret the command
2487 ;; as a, well, command, and fork it off.
2488 (let ((process-connection-type nil))
2489 (gnus-set-process-query-on-exit-flag
2491 "article-x-face" nil shell-file-name
2492 shell-command-switch gnus-article-x-face-command)
2494 ;; Sending multiple EOFs to xv doesn't work,
2495 ;; so we only do a single external face.
2497 (insert (car x-faces))
2498 (process-send-region "article-x-face"
2499 (point-min) (point-max)))
2500 (process-send-eof "article-x-face")))
2502 (error "`%s' set to `%s' is not a function"
2503 gnus-article-x-face-command
2504 'gnus-article-x-face-command)))))))))
2506 (defun article-decode-mime-words ()
2507 "Decode all MIME-encoded words in the article."
2509 (gnus-with-article-buffer
2510 (let ((inhibit-point-motion-hooks t)
2511 (mail-parse-charset gnus-newsgroup-charset)
2512 (mail-parse-ignored-charsets
2513 (with-current-buffer gnus-summary-buffer
2514 gnus-newsgroup-ignored-charsets)))
2515 (mail-decode-encoded-word-region (point-min) (point-max)))))
2517 (defun article-decode-charset (&optional prompt)
2518 "Decode charset-encoded text in the article.
2519 If PROMPT (the prefix), prompt for a coding system to use."
2521 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2522 (inhibit-read-only t)
2523 (mail-parse-charset gnus-newsgroup-charset)
2524 (mail-parse-ignored-charsets
2525 (save-excursion (condition-case nil
2526 (set-buffer gnus-summary-buffer)
2528 gnus-newsgroup-ignored-charsets))
2529 ct cte ctl charset format)
2532 (article-narrow-to-head)
2533 (setq ct (message-fetch-field "Content-Type" t)
2534 cte (message-fetch-field "Content-Transfer-Encoding" t)
2535 ctl (and ct (mail-header-parse-content-type ct))
2538 (mm-read-coding-system "Charset to decode: "))
2540 (mail-content-type-get ctl 'charset)))
2541 format (and ctl (mail-content-type-get ctl 'format)))
2543 (setq cte (mail-header-strip cte)))
2544 (if (and ctl (not (string-match "/" (car ctl))))
2546 (goto-char (point-max)))
2549 (narrow-to-region (point) (point-max))
2550 (when (and (eq mail-parse-charset 'gnus-decoded)
2551 (eq (mm-body-7-or-8) '8bit))
2552 ;; The text code could have been decoded.
2553 (setq charset mail-parse-charset))
2554 (when (and (or (not ctl)
2555 (equal (car ctl) "text/plain"))
2556 (not format)) ;; article with format will decode later.
2558 charset (and cte (intern (downcase
2559 (gnus-strip-whitespace cte))))
2562 (defun article-decode-encoded-words ()
2563 "Remove encoded-word encoding from headers."
2564 (let ((inhibit-point-motion-hooks t)
2565 (mail-parse-charset gnus-newsgroup-charset)
2566 (mail-parse-ignored-charsets
2567 (save-excursion (condition-case nil
2568 (set-buffer gnus-summary-buffer)
2570 gnus-newsgroup-ignored-charsets))
2571 (inhibit-read-only t)
2573 (goto-char (point-min))
2574 (when (search-forward "\n\n" nil 'move)
2581 (memq (char-after) '(?\t ? )))))
2582 (setq start (point))
2584 \\(?:Resent-\\)?\\(?:From\\|Cc\\|To\\|Bcc\\|\\(?:In-\\)?Reply-To\\|Sender\
2585 \\|Mail-Followup-To\\|Mail-Copies-To\\|Approved\\):")
2586 (funcall gnus-decode-address-function start end)
2587 (funcall gnus-decode-header-function start end))
2588 (goto-char (setq end start)))))
2590 (defun article-decode-group-name ()
2591 "Decode group names in Newsgroups, Followup-To and Xref headers."
2592 (let ((inhibit-point-motion-hooks t)
2593 (inhibit-read-only t)
2594 (method (gnus-find-method-for-group gnus-newsgroup-name))
2596 (when (and (or gnus-group-name-charset-method-alist
2597 gnus-group-name-charset-group-alist)
2598 (gnus-buffer-live-p gnus-original-article-buffer))
2600 (article-narrow-to-head)
2601 (dolist (header '("Newsgroups" "Followup-To" "Xref"))
2602 (with-current-buffer gnus-original-article-buffer
2603 (goto-char (point-min)))
2604 (setq regexp (concat "^" header
2605 ":\\([^\n]*\\(?:\n[\t ]+[^\n]+\\)*\\)\n"))
2606 (while (re-search-forward regexp nil t)
2607 (replace-match (save-match-data
2608 (gnus-decode-newsgroups
2609 ;; XXX how to use data in article buffer?
2610 (with-current-buffer gnus-original-article-buffer
2611 (re-search-forward regexp nil t)
2613 gnus-newsgroup-name method))
2615 (goto-char (point-min)))))))
2617 (autoload 'idna-to-unicode "idna")
2619 (defun article-decode-idna-rhs ()
2620 "Decode IDNA strings in RHS in various headers in current buffer.
2621 The following headers are decoded: From:, To:, Cc:, Reply-To:,
2622 Mail-Reply-To: and Mail-Followup-To:."
2625 (let ((inhibit-point-motion-hooks t)
2626 (inhibit-read-only t))
2627 (article-narrow-to-head)
2628 (goto-char (point-min))
2629 (while (re-search-forward "@[^ \t\n\r,>]*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2631 (when (save-match-data
2632 (and (setq ace (match-string 1))
2634 (and (re-search-backward "^[^ \t]" nil t)
2635 (looking-at "From\\|To\\|Cc\\|Reply-To\\|Mail-Reply-To\\|Mail-Followup-To")))
2636 (setq unicode (idna-to-unicode ace))))
2637 (unless (string= ace unicode)
2638 (replace-match unicode nil nil nil 1)))))))))
2640 (defun article-de-quoted-unreadable (&optional force read-charset)
2641 "Translate a quoted-printable-encoded article.
2642 If FORCE, decode the article whether it is marked as quoted-printable
2644 If READ-CHARSET, ask for a coding system."
2645 (interactive (list 'force current-prefix-arg))
2647 (let ((inhibit-read-only t) type charset)
2648 (if (gnus-buffer-live-p gnus-original-article-buffer)
2649 (with-current-buffer gnus-original-article-buffer
2651 (gnus-fetch-field "content-transfer-encoding"))
2652 (let* ((ct (gnus-fetch-field "content-type"))
2653 (ctl (and ct (mail-header-parse-content-type ct))))
2654 (setq charset (and ctl
2655 (mail-content-type-get ctl 'charset)))
2656 (if (stringp charset)
2657 (setq charset (intern (downcase charset)))))))
2659 (setq charset (mm-read-coding-system "Charset: " charset)))
2661 (setq charset gnus-newsgroup-charset))
2663 (and type (let ((case-fold-search t))
2664 (string-match "quoted-printable" type))))
2666 (quoted-printable-decode-region
2667 (point) (point-max) (mm-charset-to-coding-system charset nil t))))))
2669 (defun article-de-base64-unreadable (&optional force read-charset)
2670 "Translate a base64 article.
2671 If FORCE, decode the article whether it is marked as base64 not.
2672 If READ-CHARSET, ask for a coding system."
2673 (interactive (list 'force current-prefix-arg))
2675 (let ((inhibit-read-only t) type charset)
2676 (if (gnus-buffer-live-p gnus-original-article-buffer)
2677 (with-current-buffer gnus-original-article-buffer
2679 (gnus-fetch-field "content-transfer-encoding"))
2680 (let* ((ct (gnus-fetch-field "content-type"))
2681 (ctl (and ct (mail-header-parse-content-type ct))))
2682 (setq charset (and ctl
2683 (mail-content-type-get ctl 'charset)))
2684 (if (stringp charset)
2685 (setq charset (intern (downcase charset)))))))
2687 (setq charset (mm-read-coding-system "Charset: " charset)))
2689 (setq charset gnus-newsgroup-charset))
2691 (and type (let ((case-fold-search t))
2692 (string-match "base64" type))))
2695 (narrow-to-region (point) (point-max))
2696 (base64-decode-region (point-min) (point-max))
2697 (mm-decode-coding-region
2698 (point-min) (point-max)
2699 (mm-charset-to-coding-system charset nil t)))))))
2704 (defun article-decode-HZ ()
2705 "Translate a HZ-encoded article."
2709 (let ((inhibit-read-only t))
2710 (rfc1843-decode-region (point-min) (point-max)))))
2712 (defun article-unsplit-urls ()
2713 "Remove the newlines that some other mailers insert into URLs."
2716 (let ((inhibit-read-only t))
2717 (goto-char (point-min))
2718 (while (re-search-forward
2719 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2720 (replace-match "\\1\\3" t)))
2721 (when (gmm-called-interactively-p 'any)
2722 (gnus-treat-article nil))))
2724 (defun article-wash-html ()
2725 "Format an HTML article."
2728 (buffer-read-only nil))
2729 (when (gnus-buffer-live-p gnus-original-article-buffer)
2730 (with-current-buffer gnus-original-article-buffer
2731 (setq handles (mm-dissect-buffer t t))))
2733 (delete-region (point) (point-max))
2734 (mm-enable-multibyte)
2735 (mm-inline-text-html handles)))
2737 (defvar gnus-article-browse-html-temp-list nil
2738 "List of temporary files created by `gnus-article-browse-html-parts'.
2739 Internal variable.")
2741 (defcustom gnus-article-browse-delete-temp 'ask
2742 "What to do with temporary files from `gnus-article-browse-html-parts'.
2743 If nil, don't delete temporary files. If it is t, delete them on
2744 exit from the summary buffer. If it is the symbol `file', query
2745 on each file, if it is `ask' ask once when exiting from the
2747 :group 'gnus-article
2748 :version "23.1" ;; No Gnus
2749 :type '(choice (const :tag "Don't delete" nil)
2750 (const :tag "Don't ask" t)
2751 (const :tag "Ask" ask)
2752 (const :tag "Ask for each file" file)))
2754 ;; Cf. mm-postponed-undisplay-list / mm-destroy-postponed-undisplay-list.
2756 (defun gnus-article-browse-delete-temp-files (&optional how)
2757 "Delete temp-files created by `gnus-article-browse-html-parts'."
2758 (when (and gnus-article-browse-html-temp-list
2760 (or how (setq how gnus-article-browse-delete-temp))
2762 (let ((files (length gnus-article-browse-html-temp-list)))
2765 "Delete the temporary HTML file? "
2766 (format "Delete all %s temporary HTML files? "
2768 (setq gnus-article-browse-html-temp-list nil)))
2770 (dolist (file gnus-article-browse-html-temp-list)
2771 (cond ((file-directory-p file)
2772 (when (or (not (eq how 'file))
2775 "Delete temporary HTML file(s) in directory `%s'? "
2776 (file-name-as-directory file))))
2777 (gnus-delete-directory file)))
2778 ((file-exists-p file)
2779 (when (or (not (eq how 'file))
2781 (format "Delete temporary HTML file `%s'? " file)))
2782 (delete-file file)))))
2783 ;; Also remove file from the list when not deleted or if file doesn't
2785 (setq gnus-article-browse-html-temp-list nil))
2786 gnus-article-browse-html-temp-list)
2788 (defun gnus-article-browse-html-save-cid-content (cid handles directory)
2789 "Find CID content in HANDLES and save it in a file in DIRECTORY.
2790 Return file name relative to the parent of DIRECTORY."
2794 (dolist (handle handles)
2796 ((not (listp handle)))
2797 ;; Exclude broken handles that `gnus-summary-enter-digest-group'
2799 ((not (or (bufferp (car handle)) (stringp (car handle)))))
2800 ((equal (mm-handle-media-supertype handle) "multipart")
2801 (when (setq file (gnus-article-browse-html-save-cid-content
2802 cid handle directory))
2803 (throw 'found file)))
2804 ((equal (concat "<" cid ">") (mm-handle-id handle))
2805 (setq file (or (mm-handle-filename handle)
2807 (make-temp-name "cid")
2808 (car (rassoc (car (mm-handle-type handle))
2809 mailcap-mime-extensions))))
2810 afile (expand-file-name file directory))
2811 (mm-save-part-to-file handle afile)
2812 (throw 'found (concat (file-name-nondirectory
2813 (directory-file-name directory))
2816 (defun gnus-article-browse-html-parts (list &optional header)
2817 "View all \"text/html\" parts from LIST.
2818 Recurse into multiparts. The optional HEADER that should be a decoded
2819 message header will be added to the bodies of the \"text/html\" parts."
2820 ;; Internal function used by `gnus-article-browse-html-article'.
2821 (let (type file charset content cid-dir tmp-file showed)
2822 ;; Find and show the html-parts.
2823 (dolist (handle list)
2824 ;; If HTML, show it:
2825 (cond ((not (listp handle)))
2826 ((or (equal (car (setq type (mm-handle-type handle))) "text/html")
2827 (and (equal (car type) "message/external-body")
2829 (setq file (mm-handle-filename handle)))
2830 (or (mm-handle-cache handle)
2831 (condition-case code
2832 (progn (mm-extern-cache-contents handle) t)
2834 (gnus-message 3 "%s" (error-message-string code))
2835 (when (>= gnus-verbose 3) (sit-for 2))
2838 (setq handle (mm-handle-cache handle)
2839 type (mm-handle-type handle))
2840 (equal (car type) "text/html"))))
2841 (setq charset (mail-content-type-get type 'charset)
2842 content (mm-get-part handle))
2844 (if (eq charset 'gnus-decoded)
2845 (mm-enable-multibyte)
2846 (mm-disable-multibyte))
2848 ;; resolve cid contents
2849 (let ((case-fold-search t)
2850 st base regexp cid-file)
2851 (goto-char (point-min))
2852 (when (and (re-search-forward "<head[\t\n >]" nil t)
2854 (setq st (match-end 0))
2855 (re-search-forward "</head[\t\n >]" nil t))
2856 (re-search-backward "<base\
2857 \\(?:[\t\n ]+[^\t\n >]+\\)*[\t\n ]+href=\"\\([^\"]+\\)\"[^>]*>" st t))
2858 (setq base (match-string 1))
2859 (replace-match "<!--\\&-->")
2861 (dolist (tag '(("a" . "href") ("form" . "action")
2863 (setq regexp (concat "<" (car tag)
2864 "\\(?:[\t\n ]+[^\t\n >]+\\)*[\t\n ]+"
2865 (cdr tag) "=\"\\([^\"]+\\)"))
2866 (while (re-search-forward regexp nil t)
2870 (url-expand-file-name (match-string 1)
2872 (error (match-string 1)))
2873 (delete-region (match-beginning 1)
2876 (while (re-search-forward "\
2877 <img[\t\n ]+\\(?:[^\t\n >]+[\t\n ]+\\)*src=\"\\(cid:\\([^\"]+\\)\\)\""
2880 (setq cid-dir (mm-make-temp-file "cid" t))
2881 (add-to-list 'gnus-article-browse-html-temp-list cid-dir))
2884 (when (setq cid-file
2885 (gnus-article-browse-html-save-cid-content
2887 (with-current-buffer gnus-article-buffer
2888 gnus-article-mime-handles)
2890 (replace-match cid-file nil nil nil 1))))
2891 (unless content (setq content (buffer-string))))
2892 (when (or charset header (not file))
2893 (setq tmp-file (mm-make-temp-file
2894 ;; Do we need to care for 8.3 filenames?
2895 "mm-" nil ".html")))
2896 ;; Add a meta html tag to specify charset and a header.
2899 (let (title eheader body hcharset coding)
2901 (mm-enable-multibyte)
2902 (setq case-fold-search t)
2903 (insert header "\n")
2904 (setq title (message-fetch-field "subject"))
2905 (goto-char (point-min))
2906 (while (re-search-forward "\\(<\\)\\|\\(>\\)\\|\\(&\\)\\|\n"
2908 (replace-match (cond ((match-beginning 1) "<")
2909 ((match-beginning 2) ">")
2910 ((match-beginning 3) "&")
2912 (goto-char (point-min))
2913 (while (re-search-forward "^[\t ]+" nil t)
2916 (delete-region (match-beginning 0)
2919 (goto-char (point-min))
2920 (insert "<div align=\"left\">\n")
2921 (goto-char (point-max))
2922 (insert "</div>\n<hr>\n")
2923 ;; We have to examine charset one by one since
2924 ;; charset specified in parts might be different.
2925 (if (eq charset 'gnus-decoded)
2926 (setq charset 'utf-8
2927 eheader (mm-encode-coding-string (buffer-string)
2930 (mm-encode-coding-string title charset))
2931 body (mm-encode-coding-string content charset))
2932 (setq hcharset (mm-find-mime-charset-region (point-min)
2934 (cond ((= (length hcharset) 1)
2935 (setq hcharset (car hcharset)
2936 coding (mm-charset-to-coding-system
2938 ((> (length hcharset) 1)
2939 (setq hcharset 'utf-8
2945 (mm-charset-to-coding-system charset
2947 (if (eq coding body)
2948 (setq eheader (mm-encode-coding-string
2949 (buffer-string) coding)
2951 (mm-encode-coding-string
2954 (setq charset 'utf-8
2955 eheader (mm-encode-coding-string
2956 (buffer-string) charset)
2958 (mm-encode-coding-string
2960 body (mm-encode-coding-string
2961 (mm-decode-coding-string
2964 (setq charset hcharset
2965 eheader (mm-encode-coding-string
2966 (buffer-string) coding)
2968 (mm-encode-coding-string
2971 (setq eheader (mm-string-as-unibyte (buffer-string))
2974 (mm-disable-multibyte)
2977 (mm-add-meta-html-tag handle charset t))
2979 (goto-char (point-min))
2980 (unless (search-forward "<title>" nil t)
2981 (re-search-forward "<head>\\s-*" nil t)
2982 (insert "<title>" title "</title>\n")))
2983 (goto-char (point-min))
2984 (or (re-search-forward
2985 "<body\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t)
2987 "</head\\(?:\\s-+[^>]+\\|\\s-*\\)>\\s-*" nil t))
2989 (mm-write-region (point-min) (point-max)
2990 tmp-file nil nil nil 'binary t))))
2992 (mm-with-unibyte-buffer
2993 (insert (if (eq charset 'gnus-decoded)
2994 (mm-encode-coding-string content
2995 (setq charset 'utf-8))
2997 (if (or (mm-add-meta-html-tag handle charset)
2999 (mm-write-region (point-min) (point-max)
3000 tmp-file nil nil nil 'binary t)
3001 (setq tmp-file nil))))
3003 (mm-save-part-to-file handle tmp-file)))
3005 (add-to-list 'gnus-article-browse-html-temp-list tmp-file))
3006 (add-hook 'gnus-summary-prepare-exit-hook
3007 'gnus-article-browse-delete-temp-files)
3008 (add-hook 'gnus-exit-gnus-hook
3010 (gnus-article-browse-delete-temp-files t)))
3011 ;; FIXME: Warn if there's an <img> tag?
3012 (browse-url-of-file (or tmp-file (expand-file-name file)))
3014 ;; If multipart, recurse
3015 ((equal (mm-handle-media-supertype handle) "multipart")
3016 (when (gnus-article-browse-html-parts handle header)
3018 ((equal (mm-handle-media-type handle) "message/rfc822")
3019 (mm-with-multibyte-buffer
3020 (mm-insert-part handle)
3021 (setq handle (mm-dissect-buffer t t))
3022 (when (and (bufferp (car handle))
3023 (stringp (car (mm-handle-type handle))))
3024 (setq handle (list handle)))
3026 (article-decode-encoded-words)
3027 (let ((gnus-visible-headers
3028 (or (get 'gnus-visible-headers 'standard-value)
3029 gnus-visible-headers)))
3030 (article-hide-headers))
3031 (goto-char (point-min))
3032 (search-forward "\n\n" nil 'move)
3033 (skip-chars-backward "\t\n ")
3034 (setq header (buffer-substring (point-min) (point)))))
3036 (gnus-article-browse-html-parts handle header)
3037 (mm-destroy-parts handle))
3041 (defun gnus-article-browse-html-article (&optional arg)
3042 "View \"text/html\" parts of the current article with a WWW browser.
3043 Inline images embedded in a message using the cid scheme, as they are
3044 generally considered to be safe, will be processed properly.
3045 The message header is added to the beginning of every html part unless
3046 the prefix argument ARG is given.
3048 Warning: Spammers use links to images (using the http scheme) in HTML
3049 articles to verify whether you have read the message. As
3050 `gnus-article-browse-html-article' passes the HTML content to the
3051 browser without eliminating these \"web bugs\" you should only
3052 use it for mails from trusted senders.
3054 If you always want to display HTML parts in the browser, set
3055 `mm-text-html-renderer' to nil.
3057 This command creates temporary files to pass HTML contents including
3058 images if any to the browser, and deletes them when exiting the group
3060 ;; Cf. `mm-w3m-safe-url-regexp'
3063 (gnus-summary-show-article)
3064 (let ((gnus-visible-headers (or (get 'gnus-visible-headers 'standard-value)
3065 gnus-visible-headers))
3066 ;; As we insert a <hr>, there's no need for the body boundary.
3067 (gnus-treat-body-boundary nil))
3068 (gnus-summary-show-article)))
3069 (with-current-buffer gnus-article-buffer
3070 (let ((header (unless arg
3073 (buffer-substring-no-properties
3074 (goto-char (point-min))
3075 (if (search-forward "\n\n" nil t)
3077 (goto-char (point-max))
3078 (skip-chars-backward "\t\n ")
3081 (set-buffer gnus-original-article-buffer)
3082 (setq parts (mm-dissect-buffer t t))
3083 ;; If singlepart, enforce a list.
3084 (when (and (bufferp (car parts))
3085 (stringp (car (mm-handle-type parts))))
3086 (setq parts (list parts)))
3088 (unless (gnus-article-browse-html-parts parts header)
3089 (gnus-error 3 "Mail doesn't contain a \"text/html\" part!"))
3090 (mm-destroy-parts parts)
3092 (gnus-summary-show-article)))))
3094 (defun article-hide-list-identifiers ()
3095 "Remove list identifiers from the Subject header.
3096 The `gnus-list-identifiers' variable specifies what to do."
3098 (let ((inhibit-point-motion-hooks t)
3099 (regexp (gnus-group-get-list-identifiers gnus-newsgroup-name))
3100 (inhibit-read-only t))
3104 (article-narrow-to-head)
3105 (goto-char (point-min))
3106 (while (re-search-forward
3107 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
3109 (delete-region (match-beginning 2) (match-end 0))
3110 (beginning-of-line))
3111 (when (re-search-forward
3112 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
3113 (delete-region (match-beginning 1) (match-end 1))))))))
3115 (defun article-hide-pem (&optional arg)
3116 "Toggle hiding of any PEM headers and signatures in the current article.
3117 If given a negative prefix, always show; if given a positive prefix,
3119 (interactive (gnus-article-hidden-arg))
3120 (unless (gnus-article-check-hidden-text 'pem arg)
3122 (let ((inhibit-read-only t) end)
3123 (goto-char (point-min))
3124 ;; Hide the horrendously ugly "header".
3125 (when (and (search-forward
3126 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
3128 (setq end (1+ (match-beginning 0))))
3129 (gnus-add-wash-type 'pem)
3130 (gnus-article-hide-text-type
3132 (if (search-forward "\n\n" nil t)
3136 ;; Hide the trailer as well
3137 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
3139 (gnus-article-hide-text-type
3140 (match-beginning 0) (match-end 0) 'pem)))))))
3142 (defun article-strip-banner ()
3143 "Strip the banners specified by the `banner' group parameter and by
3144 `gnus-article-address-banner-alist'."
3148 (let ((inhibit-point-motion-hooks t))
3149 (when (gnus-parameter-banner gnus-newsgroup-name)
3150 (article-really-strip-banner
3151 (gnus-parameter-banner gnus-newsgroup-name)))
3152 (when gnus-article-address-banner-alist
3153 ;; Note that the From header is decoded here, so it is
3154 ;; required that the *-extract-address-components function
3155 ;; supports non-ASCII text.
3156 (let ((from (save-restriction
3158 (article-narrow-to-head)
3159 (mail-fetch-field "from"))))
3162 (cadr (funcall gnus-extract-address-components
3165 (dolist (pair gnus-article-address-banner-alist)
3166 (when (string-match (car pair) from)
3168 (article-really-strip-banner (cdr pair)))))))))))))
3170 (defun article-really-strip-banner (banner)
3171 "Strip the banner specified by the argument."
3174 (let ((inhibit-point-motion-hooks t)
3175 (gnus-signature-limit nil)
3176 (inhibit-read-only t))
3179 ((eq banner 'signature)
3180 (when (gnus-article-narrow-to-signature)
3183 (delete-region (point) (point-max))))
3185 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
3186 (while (re-search-forward banner nil t)
3187 (delete-region (match-beginning 0) (match-end 0)))))
3189 (while (re-search-forward banner nil t)
3190 (delete-region (match-beginning 0) (match-end 0)))))))))
3192 (defun article-babel ()
3193 "Translate article using an online translation service."
3196 (gnus-with-article-buffer
3197 (when (article-goto-body)
3198 (let* ((start (point))
3200 (orig (buffer-substring start end))
3201 (trans (babel-as-string orig)))
3203 (narrow-to-region start end)
3204 (delete-region start end)
3207 (defun article-hide-signature (&optional arg)
3208 "Hide the signature in the current article.
3209 If given a negative prefix, always show; if given a positive prefix,
3211 (interactive (gnus-article-hidden-arg))
3212 (unless (gnus-article-check-hidden-text 'signature arg)
3215 (let ((inhibit-read-only t))
3216 (when (gnus-article-narrow-to-signature)
3217 (gnus-article-hide-text-type
3218 (point-min) (point-max) 'signature))))))
3219 (gnus-set-mode-line 'article))
3221 (defun article-strip-headers-in-body ()
3222 "Strip offensive headers from bodies."
3226 (let ((case-fold-search t))
3227 (when (looking-at "x-no-archive:")
3228 (gnus-delete-line)))))
3230 (defun article-strip-leading-blank-lines ()
3231 "Remove all blank lines from the beginning of the article."
3234 (let ((inhibit-point-motion-hooks t)
3235 (inhibit-read-only t))
3236 (when (article-goto-body)
3237 (while (and (not (eobp))
3238 (looking-at "[ \t]*$"))
3239 (gnus-delete-line))))))
3241 (defun article-narrow-to-head ()
3242 "Narrow the buffer to the head of the message.
3243 Point is left at the beginning of the narrowed-to region."
3245 (goto-char (point-min))
3247 ;; Absolutely no headers displayed.
3251 ((search-forward "\n\n" nil 1)
3253 ;; Nothing but headers.
3256 (goto-char (point-min)))
3258 (defun article-goto-body ()
3259 "Place point at the start of the body."
3260 (goto-char (point-min))
3262 ;; This variable is only bound when dealing with separate
3264 (article-goto-body-goes-to-point-min-p
3266 ((search-forward "\n\n" nil t)
3269 (goto-char (point-max))
3272 (defun article-strip-multiple-blank-lines ()
3273 "Replace consecutive blank lines with one empty line."
3276 (let ((inhibit-point-motion-hooks t)
3277 (inhibit-read-only t))
3278 ;; First make all blank lines empty.
3280 (while (re-search-forward "^[ \t]+$" nil t)
3281 (unless (gnus-annotation-in-region-p
3282 (match-beginning 0) (match-end 0))
3283 (replace-match "" nil t)))
3284 ;; Then replace multiple empty lines with a single empty line.
3286 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
3287 (unless (gnus-annotation-in-region-p
3288 (match-beginning 0) (match-end 0))
3289 (delete-region (match-beginning 1) (match-end 1)))))))
3291 (defun article-strip-leading-space ()
3292 "Remove all white space from the beginning of the lines in the article."
3295 (let ((inhibit-point-motion-hooks t)
3296 (inhibit-read-only t))
3298 (while (re-search-forward "^[ \t]+" nil t)
3299 (replace-match "" t t)))))
3301 (defun article-strip-trailing-space ()
3302 "Remove all white space from the end of the lines in the article."
3305 (let ((inhibit-point-motion-hooks t)
3306 (inhibit-read-only t))
3308 (while (re-search-forward "[ \t]+$" nil t)
3309 (replace-match "" t t)))))
3311 (defun article-strip-blank-lines ()
3312 "Strip leading, trailing and multiple blank lines."
3314 (article-strip-leading-blank-lines)
3315 (article-remove-trailing-blank-lines)
3316 (article-strip-multiple-blank-lines))
3318 (defun article-strip-all-blank-lines ()
3319 "Strip all blank lines."
3322 (let ((inhibit-point-motion-hooks t)
3323 (inhibit-read-only t))
3325 (while (re-search-forward "^[ \t]*\n" nil t)
3326 (replace-match "" t t)))))
3328 (defun gnus-article-narrow-to-signature ()
3329 "Narrow to the signature; return t if a signature is found, else nil."
3330 (let ((inhibit-point-motion-hooks t))
3331 (when (gnus-article-search-signature)
3333 ;; Check whether we have some limits to what we consider
3334 ;; to be a signature.
3335 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
3336 (list gnus-signature-limit)))
3338 (while (setq limit (pop limits))
3339 (if (or (and (integerp limit)
3340 (< (- (point-max) (point)) limit))
3342 (< (count-lines (point) (point-max)) limit))
3343 (and (functionp limit)
3345 (and (stringp limit)
3346 (not (re-search-forward limit nil t))))
3347 () ; This limit did not succeed.
3351 (narrow-to-region (point) (point-max))
3354 (defun gnus-article-search-signature ()
3355 "Search the current buffer for the signature separator.
3356 Put point at the beginning of the signature separator."
3357 (let ((cur (point)))
3358 (goto-char (point-max))
3359 (if (if (stringp gnus-signature-separator)
3360 (re-search-backward gnus-signature-separator nil t)
3361 (let ((seps gnus-signature-separator))
3363 (not (re-search-backward (car seps) nil t)))
3370 (defun gnus-article-hidden-arg ()
3371 "Return the current prefix arg as a number, or 0 if no prefix."
3372 (list (if current-prefix-arg
3373 (prefix-numeric-value current-prefix-arg)
3376 (defun gnus-article-check-hidden-text (type arg)
3377 "Return nil if hiding is necessary.
3378 Arg can be nil or a number. nil and positive means hide, negative
3379 means show, 0 means toggle."
3382 (let ((hide (gnus-article-hidden-text-p type)))
3388 (gnus-article-show-hidden-text type)
3391 (if (eq hide 'hidden)
3393 (gnus-article-show-hidden-text type)
3397 (defun gnus-article-hidden-text-p (type)
3398 "Say whether the current buffer contains hidden text of type TYPE."
3399 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
3401 (not (get-text-property pos 'invisible))
3402 (not (get-text-property pos 'dummy-invisible)))
3404 (text-property-any (1+ pos) (point-max) 'article-type type)))
3409 (defun gnus-article-show-hidden-text (type &optional _dummy)
3410 "Show all hidden text of type TYPE.
3411 Originally it is hide instead of DUMMY."
3412 (let ((inhibit-read-only t)
3413 (inhibit-point-motion-hooks t))
3414 (gnus-remove-text-properties-when
3416 (point-min) (point-max)
3417 (cons 'article-type (cons type
3418 gnus-hidden-properties)))
3419 (gnus-delete-wash-type type)))
3421 (defconst article-time-units
3422 `((year . ,(* 365.25 24 60 60))
3423 (week . ,(* 7 24 60 60))
3424 (day . ,(* 24 60 60))
3428 "Mapping from time units to seconds.")
3430 (defun gnus-article-forward-header ()
3431 "Move point to the start of the next header.
3432 If the current header is a continuation header, this can be several
3437 (if (looking-at "[ \t]+[^ \t]")
3441 (defun article-treat-date ()
3442 (article-date-ut (if (gnus-buffer-live-p gnus-summary-buffer)
3443 (with-current-buffer gnus-summary-buffer
3444 gnus-article-date-headers)
3445 gnus-article-date-headers)
3448 (defun article-date-ut (&optional type _highlight date-position)
3449 "Convert DATE date to TYPE in the current article.
3450 The default type is `ut'. See `gnus-article-date-headers' for
3452 (interactive (list 'ut t))
3453 (let* ((case-fold-search t)
3454 (inhibit-read-only t)
3455 (inhibit-point-motion-hooks t)
3456 (visible-date (mail-fetch-field "Date"))
3457 pos date bface eface)
3461 (goto-char date-position)
3462 (setq date (get-text-property (point) 'original-date))
3463 (when (looking-at "[^:]+:[\t ]*")
3464 (setq bface (get-text-property (match-beginning 0) 'face)
3465 eface (get-text-property (match-end 0) 'face)))
3466 (delete-region (point)
3468 (gnus-article-forward-header)
3470 (article-transform-date date type bface eface))
3473 (goto-char (point-min))
3474 (while (or (get-text-property (setq pos (point)) 'original-date)
3475 (and (setq pos (next-single-property-change
3476 (point) 'original-date))
3478 (narrow-to-region pos (if (search-forward "\n\n" nil t)
3479 (1+ (match-beginning 0))
3481 (while (setq pos (text-property-not-all pos (point-max)
3482 'gnus-date-type nil))
3483 (setq date (get-text-property pos 'original-date))
3485 (when (looking-at "[^:]+:[\t ]*")
3486 (setq bface (get-text-property (match-beginning 0) 'face)
3487 eface (get-text-property (match-end 0) 'face)))
3488 (delete-region pos (or (text-property-any pos (point-max)
3489 'gnus-date-type nil)
3491 (unless date ;; the 1st time
3492 (goto-char (point-min))
3493 (while (re-search-forward "^Date:[\t ]*" nil t)
3494 (setq date (get-text-property (match-beginning 0)
3496 bface (get-text-property (match-beginning 0) 'face)
3497 eface (get-text-property (match-end 0) 'face))
3498 (delete-region (point-at-bol) (progn
3499 (gnus-article-forward-header)
3501 (when (and (not date)
3503 (setq date visible-date))
3505 (article-transform-date date type bface eface))
3506 (goto-char (point-max))
3509 (defun article-transform-date (date type bface eface)
3510 (dolist (this-type (cond
3520 (add-text-properties
3523 (insert (article-make-date-line date (or this-type 'ut)) "\n")
3525 (list 'original-date date 'gnus-date-type this-type))))
3528 "\\([^:]+:\\)[\t ]*\\(\\(?:[^\t\n ]+[\t ]+\\)*[^\t\n ]+\\)?")
3529 (put-text-property (match-beginning 1) (match-end 1) 'face bface)
3530 (when (match-beginning 2)
3531 (put-text-property (match-beginning 2) (match-end 2) 'face eface))
3532 (while (and (zerop (forward-line 1))
3533 (looking-at "[\t ]+\\(\\(?:[^\t\n ]+[\t ]+\\)*[^\t\n ]+\\)?"))
3534 (when (match-beginning 1)
3535 (put-text-property (match-beginning 1) (match-end 1) 'face eface))))))
3537 (defun article-make-date-line (date type)
3538 "Return a DATE line of TYPE."
3539 (unless (memq type '(local ut original user-defined iso8601 lapsed english
3541 (error "Unknown conversion type: %s" type))
3543 (let ((time (ignore-errors (date-to-time date))))
3545 ;; Convert to the local timezone.
3547 (concat "Date: " (message-make-date time)))
3548 ;; Convert to Universal Time.
3553 (let* ((e (parse-time-string date))
3554 (tm (apply 'encode-time e))
3556 (ls (- (cadr tm) (car (current-time-zone time)))))
3557 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
3558 ((> ls 65535) (list (1+ ms) (- ls 65536)))
3562 ;; Get the original date from the article.
3563 ((eq type 'original)
3564 (concat "Date: " (if (string-match "\n+$" date)
3565 (substring date 0 (match-beginning 0))
3567 ;; Let the user define the format.
3568 ((eq type 'user-defined)
3569 (let ((format (or (condition-case nil
3570 (with-current-buffer gnus-summary-buffer
3571 gnus-article-time-format)
3573 gnus-article-time-format)))
3574 (if (functionp format)
3575 (funcall format time)
3576 (concat "Date: " (format-time-string format time)))))
3579 (let ((tz (car (current-time-zone time))))
3582 (format-time-string "%Y%m%dT%H%M%S" time)
3583 (format "%s%02d%02d"
3584 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3585 (/ (% (abs tz) 3600) 60)))))
3586 ;; Do a lapsed format.
3588 (concat "Date: " (article-lapsed-string time)))
3589 ;; A combined date/lapsed format.
3590 ((eq type 'combined-lapsed)
3591 (let ((date-string (article-make-date-line date 'original))
3597 (concat " (" (article-lapsed-string time segments) ")"))
3598 (> (+ (length date-string)
3599 (length lapsed-string))
3602 (setq segments (1- segments)))
3604 (concat date-string lapsed-string)
3606 ;; Display the date in proper English
3608 (let ((dtime (decode-time time)))
3611 (number-to-string (nth 3 dtime))
3612 (let ((digit (% (nth 3 dtime) 10)))
3614 ((memq (nth 3 dtime) '(11 12 13)) "th")
3620 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3622 (number-to-string (nth 5 dtime))
3624 (format "%02d" (nth 2 dtime))
3626 (format "%02d" (nth 1 dtime)))))))
3628 (format "Date: %s (from Gnus)" date))))
3630 (defun article-lapsed-string (time &optional max-segments)
3631 ;; If the date is seriously mangled, the timezone functions are
3632 ;; liable to bug out, so we ignore all errors.
3633 (let* ((now (current-time))
3634 (real-time (subtract-time now time))
3635 (real-sec (and real-time
3636 (+ (* (float (car real-time)) 65536)
3638 (sec (and real-time (abs real-sec)))
3641 (unless max-segments
3642 (setq max-segments (length article-time-units)))
3650 ;; This is a bit convoluted, but basically we go
3651 ;; through the time units for years, weeks, etc,
3652 ;; and divide things to see whether that results
3653 ;; in positive answers.
3656 (if (or (zerop (setq num (ffloor (/ sec (cdr unit)))))
3657 (>= segments max-segments))
3658 ;; The (remaining) seconds are too few to
3659 ;; be divided into this time unit.
3661 ;; It's big enough, so we output it.
3662 (setq sec (- sec (* num (cdr unit))))
3664 (concat (if prev ", " "") (int-to-string
3666 " " (symbol-name (car unit))
3667 (if (> num 1) "s" ""))
3669 segments (1+ segments)))))
3670 article-time-units "")
3671 ;; If dates are odd, then it might appear like the
3672 ;; article was sent in the future.
3675 " in the future"))))))
3677 (defun article-date-local (&optional highlight)
3678 "Convert the current article date to the local timezone."
3679 (interactive (list t))
3680 (article-date-ut 'local highlight))
3682 (defun article-date-english (&optional highlight)
3683 "Convert the current article date to something that is proper English."
3684 (interactive (list t))
3685 (article-date-ut 'english highlight))
3687 (defun article-date-original (&optional highlight)
3688 "Convert the current article date to what it was originally.
3689 This is only useful if you have used some other date conversion
3690 function and want to see what the date was before converting."
3691 (interactive (list t))
3692 (article-date-ut 'original highlight))
3694 (defun article-date-lapsed (&optional highlight)
3695 "Convert the current article date to time lapsed since it was sent."
3696 (interactive (list t))
3697 (article-date-ut 'lapsed highlight))
3699 (defun article-date-combined-lapsed (&optional highlight)
3700 "Convert the current article date to time lapsed since it was sent."
3701 (interactive (list t))
3702 (article-date-ut 'combined-lapsed highlight))
3704 (defun article-update-date-lapsed ()
3705 "Function to be run from a timer to update the lapsed time line."
3707 (let ((buffer (current-buffer)))
3711 (set-buffer (window-buffer w))
3712 (when (derived-mode-p 'gnus-article-mode)
3713 (let ((old-line (count-lines (point-min) (point)))
3714 (old-column (- (point) (line-beginning-position)))
3715 (window-start (window-start w))
3718 (while (setq pos (text-property-not-all pos (point-max)
3719 'gnus-date-type nil))
3720 (setq next (or (next-single-property-change pos
3723 (setq type (get-text-property pos 'gnus-date-type))
3724 (when (memq type '(lapsed combined-lapsed user-defined))
3725 (article-date-ut type t pos)
3726 (setq end (or (next-single-property-change pos
3730 (if (/= window-start next)
3731 (setq window-start nil)
3732 (set-window-start w end)))
3735 (goto-char (point-min))
3736 (when (> old-column 0)
3737 (setq old-line (1- old-line)))
3738 (forward-line old-line)
3740 (when (> (current-column) old-column)
3742 (forward-char old-column)))))
3744 (set-buffer buffer))))
3746 (defun gnus-start-date-timer (&optional n)
3747 "Start a timer to update the Date headers in the article buffers.
3748 The numerical prefix says how frequently (in seconds) the function
3753 (gnus-stop-date-timer)
3754 (setq article-lapsed-timer
3755 (run-at-time 1 n 'article-update-date-lapsed)))
3757 (defun gnus-stop-date-timer ()
3758 "Stop the Date timer."
3760 (when article-lapsed-timer
3761 (nnheader-cancel-timer article-lapsed-timer)
3762 (setq article-lapsed-timer nil)))
3764 (defun article-date-user (&optional highlight)
3765 "Convert the current article date to the user-defined format.
3766 This format is defined by the `gnus-article-time-format' variable."
3767 (interactive (list t))
3768 (article-date-ut 'user highlight))
3770 (defun article-date-iso8601 (&optional highlight)
3771 "Convert the current article date to ISO8601."
3772 (interactive (list t))
3773 (article-date-ut 'iso8601 highlight))
3775 (defmacro gnus-article-save-original-date (&rest forms)
3776 "Save the original date as a text property and evaluate FORMS."
3777 `(let* ((case-fold-search t)
3779 (goto-char (point-min))
3780 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3783 (date (when (and start
3784 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3786 (buffer-substring-no-properties start
3787 (match-beginning 0)))))
3788 (goto-char (point-max))
3789 (skip-chars-backward "\n")
3790 (put-text-property (point-min) (point) 'original-date date)
3792 (goto-char (point-max))
3793 (skip-chars-backward "\n")
3794 (put-text-property (point-min) (point) 'original-date date)))
3796 ;; (defun article-show-all ()
3797 ;; "Show all hidden text in the article buffer."
3800 ;; (let ((inhibit-read-only t))
3801 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3803 (defun article-remove-leading-whitespace ()
3804 "Remove excessive whitespace from all headers."
3808 (let ((inhibit-read-only t))
3809 (article-narrow-to-head)
3810 (goto-char (point-min))
3811 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3812 (delete-region (match-beginning 1) (match-end 1)))))))
3814 (defun article-emphasize (&optional arg)
3815 "Emphasize text according to `gnus-emphasis-alist'."
3816 (interactive (gnus-article-hidden-arg))
3817 (unless (gnus-article-check-hidden-text 'emphasis arg)
3821 (with-current-buffer gnus-summary-buffer
3822 gnus-article-emphasis-alist)
3824 gnus-emphasis-alist))
3825 (inhibit-read-only t)
3826 (props (append '(article-type emphasis)
3827 gnus-hidden-properties))
3828 regexp elem beg invisible visible face)
3831 (while (setq elem (pop alist))
3833 (setq regexp (car elem)
3834 invisible (nth 1 elem)
3835 visible (nth 2 elem)
3837 (while (re-search-forward regexp nil t)
3838 (when (and (match-beginning visible) (match-beginning invisible))
3839 (gnus-article-hide-text
3840 (match-beginning invisible) (match-end invisible) props)
3841 (gnus-article-unhide-text-type
3842 (match-beginning visible) (match-end visible) 'emphasis)
3843 (gnus-put-overlay-excluding-newlines
3844 (match-beginning visible) (match-end visible) 'face face)
3845 (gnus-add-wash-type 'emphasis)
3846 (goto-char (match-end invisible)))))))))
3848 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3849 "Setup newsgroup emphasis alist."
3850 (unless gnus-article-emphasis-alist
3851 (let ((name (and gnus-newsgroup-name
3852 (gnus-group-real-name gnus-newsgroup-name))))
3853 (make-local-variable 'gnus-article-emphasis-alist)
3854 (setq gnus-article-emphasis-alist
3856 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3857 (while (setq elem (pop alist))
3858 (when (and name (string-match (car elem) name))
3860 highlight (copy-sequence (cdr elem)))))
3862 (copy-sequence highlight-words)
3863 (if gnus-newsgroup-name
3864 (copy-sequence (gnus-group-find-parameter
3865 gnus-newsgroup-name 'highlight-words t)))
3866 gnus-emphasis-alist)))))
3868 (defvar gnus-summary-article-menu)
3869 (defvar gnus-summary-post-menu)
3871 ;;; Saving functions.
3873 (defun gnus-article-save (save-buffer file &optional num)
3874 "Save the currently selected article."
3875 (when (or (get gnus-default-article-saver :headers)
3876 (not gnus-save-all-headers))
3877 ;; Remove headers according to `gnus-saved-headers' or the value
3878 ;; of the `:headers' property that the saver function might have.
3879 (let ((gnus-visible-headers
3880 (or (symbol-value (get gnus-default-article-saver :headers))
3881 gnus-saved-headers gnus-visible-headers))
3882 ;; Ignore group parameter. See `article-hide-headers'.
3883 (gnus-summary-buffer nil))
3884 (with-current-buffer save-buffer
3885 (article-hide-headers 1 t))))
3886 (save-window-excursion
3887 (if (not gnus-default-article-saver)
3888 (error "No default saver is defined")
3889 ;; !!! Magic! The saving functions all save
3890 ;; `gnus-save-article-buffer' (or so they think), but we
3891 ;; bind that variable to our save-buffer.
3892 (set-buffer gnus-article-buffer)
3893 (let* ((gnus-save-article-buffer save-buffer)
3896 ((not gnus-prompt-before-saving) 'default)
3897 ((eq gnus-prompt-before-saving 'always) nil)
3899 (gnus-number-of-articles-to-be-saved
3900 (when (eq gnus-prompt-before-saving t)
3902 (set-buffer gnus-article-current-summary)
3903 (funcall gnus-default-article-saver filename)))))
3905 (defun gnus-read-save-file-name (prompt &optional filename
3906 function group headers variable
3909 (funcall function group headers (symbol-value variable)))
3914 ((eq filename 'default)
3920 (when (symbol-value dir-var)
3921 (setq default-name (expand-file-name
3922 (file-name-nondirectory default-name)
3923 (symbol-value dir-var))))
3924 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3927 (if (and gnus-number-of-articles-to-be-saved
3928 (> gnus-number-of-articles-to-be-saved 1))
3929 (format "these %d articles"
3930 gnus-number-of-articles-to-be-saved)
3933 ;; Let the split methods have their say.
3935 ;; No split name was found.
3938 (concat prompt " (default "
3939 (file-name-nondirectory default-name) "): ")
3940 (file-name-directory default-name)
3942 ;; A single group name is returned.
3943 ((stringp split-name)
3945 (funcall function split-name headers
3946 (symbol-value variable)))
3948 (concat prompt " (default "
3949 (file-name-nondirectory default-name) "): ")
3950 (file-name-directory default-name)
3952 ;; A single split name was found
3953 ((= 1 (length split-name))
3954 (let* ((name (expand-file-name
3956 gnus-article-save-directory))
3957 (dir (cond ((file-directory-p name)
3958 (file-name-as-directory name))
3959 ((file-exists-p name) name)
3960 (t gnus-article-save-directory))))
3962 (concat prompt " (default " name "): ")
3964 ;; A list of splits was found.
3966 (setq split-name (nreverse split-name))
3968 (let ((file-name-history
3969 (nconc split-name file-name-history)))
3973 (concat prompt " (`M-p' for defaults): ")
3974 gnus-article-save-directory
3976 gnus-article-save-directory)))
3977 (car (push result file-name-history)))))))
3978 ;; Create the directory.
3979 (gnus-make-directory (file-name-directory file))
3980 ;; If we have read a directory, we append the default file name.
3981 (when (file-directory-p file)
3982 (setq file (expand-file-name (file-name-nondirectory
3984 (file-name-as-directory file))))
3985 ;; Possibly translate some characters.
3986 (nnheader-translate-file-chars file))))))
3987 (gnus-make-directory (file-name-directory result))
3989 (set variable result))
3991 (set dir-var (file-name-directory result)))
3994 (defun gnus-article-archive-name (_group)
3995 "Return the first instance of an \"Archive-name\" in the current buffer."
3996 (let ((case-fold-search t))
3997 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3998 (nnheader-concat gnus-article-save-directory
3999 (match-string 1)))))
4001 (defun gnus-article-nndoc-name (group)
4002 "If GROUP is an nndoc group, return the name of the parent group."
4003 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
4004 (gnus-group-get-parameter group 'save-article-group)))
4006 (defun gnus-summary-save-in-rmail (&optional filename)
4007 "Append this article to Rmail file.
4008 Optional argument FILENAME specifies file name.
4009 Directory to save to is default to `gnus-article-save-directory'."
4010 (setq filename (gnus-read-save-file-name
4011 "Save %s in rmail file" filename
4012 gnus-rmail-save-name gnus-newsgroup-name
4013 gnus-current-headers 'gnus-newsgroup-last-rmail))
4014 (with-current-buffer gnus-save-article-buffer
4018 ;; Note that unlike gnus-summary-save-in-mail, there is no
4019 ;; check to see if filename is Babyl. Rmail in Emacs 23 does
4021 (gnus-output-to-rmail filename))))
4024 (defun gnus-summary-save-in-mail (&optional filename)
4025 "Append this article to Unix mail file.
4026 Optional argument FILENAME specifies file name.
4027 Directory to save to is default to `gnus-article-save-directory'."
4028 (setq filename (gnus-read-save-file-name
4029 "Save %s in Unix mail file" filename
4030 gnus-mail-save-name gnus-newsgroup-name
4031 gnus-current-headers 'gnus-newsgroup-last-mail))
4032 (with-current-buffer gnus-save-article-buffer
4036 (if (and (file-readable-p filename)
4037 (file-regular-p filename)
4038 (mail-file-babyl-p filename))
4039 (gnus-output-to-rmail filename)
4040 (gnus-output-to-mail filename)))))
4043 (put 'gnus-summary-save-in-file :decode t)
4044 (put 'gnus-summary-save-in-file :headers 'gnus-saved-headers)
4045 (defun gnus-summary-save-in-file (&optional filename overwrite)
4046 "Append this article to file.
4047 Optional argument FILENAME specifies file name.
4048 Directory to save to is default to `gnus-article-save-directory'."
4049 (setq filename (gnus-read-save-file-name
4050 "Save %s in file" filename
4051 gnus-file-save-name gnus-newsgroup-name
4052 gnus-current-headers 'gnus-newsgroup-last-file))
4053 (with-current-buffer gnus-save-article-buffer
4057 (when (and overwrite
4058 (file-exists-p filename))
4059 (delete-file filename))
4060 (gnus-output-to-file filename))))
4063 (put 'gnus-summary-write-to-file :decode t)
4064 (put 'gnus-summary-write-to-file :function 'gnus-summary-save-in-file)
4065 (put 'gnus-summary-write-to-file :headers 'gnus-saved-headers)
4066 (defun gnus-summary-write-to-file (&optional filename)
4067 "Write this article to a file, overwriting it if the file exists.
4068 Optional argument FILENAME specifies file name.
4069 The directory to save in defaults to `gnus-article-save-directory'."
4070 (setq filename (gnus-read-save-file-name
4071 "Save %s in file" filename
4072 gnus-file-save-name gnus-newsgroup-name
4073 gnus-current-headers nil 'gnus-newsgroup-last-directory))
4074 (gnus-summary-save-in-file filename t))
4076 (put 'gnus-summary-save-body-in-file :decode t)
4077 (defun gnus-summary-save-body-in-file (&optional filename overwrite)
4078 "Append this article body to a file.
4079 Optional argument FILENAME specifies file name.
4080 The directory to save in defaults to `gnus-article-save-directory'."
4081 (setq filename (gnus-read-save-file-name
4082 "Save %s body in file" filename
4083 gnus-file-save-name gnus-newsgroup-name
4084 gnus-current-headers 'gnus-newsgroup-last-file))
4085 (with-current-buffer gnus-save-article-buffer
4089 (when (article-goto-body)
4090 (narrow-to-region (point) (point-max)))
4091 (when (and overwrite
4092 (file-exists-p filename))
4093 (delete-file filename))
4094 (gnus-output-to-file filename))))
4097 (put 'gnus-summary-write-body-to-file :decode t)
4098 (put 'gnus-summary-write-body-to-file
4099 :function 'gnus-summary-save-body-in-file)
4100 (defun gnus-summary-write-body-to-file (&optional filename)
4101 "Write this article body to a file, overwriting it if the file exists.
4102 Optional argument FILENAME specifies file name.
4103 The directory to save in defaults to `gnus-article-save-directory'."
4104 (setq filename (gnus-read-save-file-name
4105 "Save %s body in file" filename
4106 gnus-file-save-name gnus-newsgroup-name
4107 gnus-current-headers nil 'gnus-newsgroup-last-directory))
4108 (gnus-summary-save-body-in-file filename t))
4110 (put 'gnus-summary-save-in-pipe :decode t)
4111 (put 'gnus-summary-save-in-pipe :headers 'gnus-saved-headers)
4112 (defun gnus-summary-save-in-pipe (&optional command raw)
4113 "Pipe this article to subprocess COMMAND.
4114 Valid values for COMMAND include:
4116 The executable command name and possibly arguments.
4118 You will be prompted for the command in the minibuffer.
4119 the symbol `default'
4120 It will be replaced with the command which the variable
4121 `gnus-summary-pipe-output-default-command' holds or the command
4122 last used for saving.
4123 Non-nil value for RAW overrides `:decode' and `:headers' properties
4124 and the raw article including all headers will be piped."
4125 (let ((article (gnus-summary-article-number))
4127 (get 'gnus-summary-save-in-pipe :decode)))
4128 save-buffer default)
4130 (if (vectorp (gnus-summary-article-header article))
4131 (save-current-buffer
4132 (gnus-summary-select-article decode decode nil article)
4133 (insert-buffer-substring
4137 gnus-original-article-buffer)
4139 (nnheader-set-temp-buffer " *Gnus Save*"))))
4140 ;; Remove unwanted headers.
4141 (when (and (not raw)
4142 (or (get 'gnus-summary-save-in-pipe :headers)
4143 (not gnus-save-all-headers)))
4144 (let ((gnus-visible-headers
4145 (or (symbol-value (get 'gnus-summary-save-in-pipe
4147 gnus-saved-headers gnus-visible-headers))
4148 (gnus-summary-buffer nil))
4149 (article-hide-headers 1 t))))
4150 (error "%d is not a real article" article))
4151 (error "No article to pipe"))
4152 (setq default (or gnus-summary-pipe-output-default-command
4153 gnus-last-shell-command))
4154 (unless (stringp command)
4156 (if (and (eq command 'default) default)
4158 (gnus-read-shell-command "Shell command on this article: "
4160 (when (string-equal command "")
4162 (setq command default)
4163 (error "A command is required")))
4164 (with-current-buffer save-buffer
4167 (shell-command-on-region (point-min) (point-max) command nil)))
4168 (gnus-kill-buffer save-buffer))
4169 (setq gnus-summary-pipe-output-default-command command))
4171 (defun gnus-summary-pipe-to-muttprint (&optional command)
4172 "Pipe this article to muttprint."
4173 (unless (stringp command)
4174 (setq command (read-string
4175 "Print using command: " gnus-summary-muttprint-program
4176 nil gnus-summary-muttprint-program)))
4177 (let ((gnus-summary-pipe-output-default-command
4178 gnus-summary-pipe-output-default-command))
4179 (gnus-summary-save-in-pipe command))
4180 (setq gnus-summary-muttprint-program command))
4182 ;;; Article file names when saving.
4184 (defun gnus-capitalize-newsgroup (newsgroup)
4185 "Capitalize NEWSGROUP name."
4186 (when (not (zerop (length newsgroup)))
4187 (concat (char-to-string (upcase (aref newsgroup 0)))
4188 (substring newsgroup 1))))
4190 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
4191 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4192 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
4193 Otherwise, it is like ~/News/news/group/num."
4196 (concat (if (gnus-use-long-file-name 'not-save)
4197 (gnus-capitalize-newsgroup newsgroup)
4198 (gnus-newsgroup-directory-form newsgroup))
4199 "/" (int-to-string (mail-header-number headers)))
4200 gnus-article-save-directory)))
4202 (string-equal (file-name-directory default)
4203 (file-name-directory last-file))
4204 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
4206 (or last-file default))))
4208 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
4209 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4210 If variable `gnus-use-long-file-name' is non-nil, it is
4211 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
4214 (concat (if (gnus-use-long-file-name 'not-save)
4216 (gnus-newsgroup-directory-form newsgroup))
4217 "/" (int-to-string (mail-header-number headers)))
4218 gnus-article-save-directory)))
4220 (string-equal (file-name-directory default)
4221 (file-name-directory last-file))
4222 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
4224 (or last-file default))))
4226 (defun gnus-plain-save-name (newsgroup _headers &optional last-file)
4227 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
4228 If variable `gnus-use-long-file-name' is non-nil, it is
4229 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
4232 (if (gnus-use-long-file-name 'not-save)
4235 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
4237 gnus-article-save-directory)))
4239 (defun gnus-sender-save-name (_newsgroup headers &optional _last-file)
4240 "Generate file name from sender."
4241 (let ((from (mail-header-from headers)))
4243 (if (and from (string-match "\\([^ <]+\\)@" from))
4244 (match-string 1 from)
4246 gnus-article-save-directory)))
4248 (defun article-verify-x-pgp-sig ()
4250 ;; <ftp://ftp.isc.org/pub/pgpcontrol/FORMAT>
4252 (if (gnus-buffer-live-p gnus-original-article-buffer)
4253 (let ((sig (with-current-buffer gnus-original-article-buffer
4254 (gnus-fetch-field "X-PGP-Sig")))
4258 (mml2015-clear-verify-function))
4260 (insert-buffer-substring gnus-original-article-buffer)
4261 (setq items (split-string sig))
4262 (message-narrow-to-head)
4263 (let ((inhibit-point-motion-hooks t)
4264 (case-fold-search t))
4265 ;; Don't verify multiple headers.
4266 (setq headers (mapconcat (lambda (header)
4268 (mail-fetch-field header)
4270 (split-string (nth 1 items) ",") "")))
4271 (delete-region (point-min) (point-max))
4272 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
4273 (insert "X-Signed-Headers: " (nth 1 items) "\n")
4278 (if (looking-at "^-")
4281 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
4282 (insert "Version: " (car items) "\n\n")
4283 (insert (mapconcat 'identity (cddr items) "\n"))
4284 (insert "\n-----END PGP SIGNATURE-----\n")
4285 (let ((mm-security-handle (list (format "multipart/signed"))))
4286 (mml2015-clean-buffer)
4287 (let ((coding-system-for-write (or gnus-newsgroup-charset
4289 (funcall (mml2015-clear-verify-function)))
4291 (or (mm-handle-multipart-ctl-parameter
4292 mm-security-handle 'gnus-details)
4293 (mm-handle-multipart-ctl-parameter
4294 mm-security-handle 'gnus-info)))))
4296 (let ((inhibit-read-only t) bface eface)
4298 (message-narrow-to-head)
4299 (goto-char (point-max))
4301 (setq bface (get-text-property (point-at-bol) 'face)
4302 eface (get-text-property (1- (point-at-eol)) 'face))
4303 (message-remove-header "X-Gnus-PGP-Verify")
4304 (if (re-search-forward "^X-PGP-Sig:" nil t)
4306 (goto-char (point-max)))
4307 (narrow-to-region (point) (point))
4308 (insert "X-Gnus-PGP-Verify: " info "\n")
4309 (goto-char (point-min))
4312 (if (not (looking-at "^[ \t]"))
4316 (goto-char (point-min))
4317 (when (looking-at "\\([^:]+\\): *")
4318 (put-text-property (match-beginning 1) (1+ (match-end 1))
4320 (put-text-property (match-end 0) (point-max)
4321 'face eface)))))))))
4323 (autoload 'canlock-verify "canlock" nil t) ;; for XEmacs.
4325 (defun article-verify-cancel-lock ()
4326 "Verify Cancel-Lock header."
4328 (if (gnus-buffer-live-p gnus-original-article-buffer)
4329 (canlock-verify gnus-original-article-buffer)))
4336 (setq afunc (car func)
4339 gfunc (intern (format "gnus-%s" func))))
4341 (when (fboundp afunc)
4342 `(lambda (&optional interactive &rest args)
4343 ,(documentation afunc t)
4344 (interactive (list t))
4345 (with-current-buffer gnus-article-buffer
4347 (call-interactively ',afunc)
4348 (apply ',afunc args))))))))
4349 '(article-hide-headers
4350 article-verify-x-pgp-sig
4351 article-verify-cancel-lock
4352 article-hide-boring-headers
4353 article-treat-overstrike
4354 article-treat-ansi-sequences
4355 article-fill-long-lines
4356 article-capitalize-sentences
4358 article-remove-leading-whitespace
4359 article-display-x-face
4360 article-display-face
4361 article-de-quoted-unreadable
4362 article-de-base64-unreadable
4365 article-unsplit-urls
4366 article-hide-list-identifiers
4367 article-strip-banner
4370 article-hide-signature
4371 article-strip-headers-in-body
4372 article-remove-trailing-blank-lines
4373 article-strip-leading-blank-lines
4374 article-strip-multiple-blank-lines
4375 article-strip-leading-space
4376 article-strip-trailing-space
4377 article-strip-blank-lines
4378 article-strip-all-blank-lines
4380 article-date-english
4381 article-date-iso8601
4382 article-date-original
4385 article-decode-mime-words
4386 article-decode-charset
4387 article-decode-encoded-words
4390 article-date-combined-lapsed
4392 article-treat-dumbquotes
4393 article-treat-non-ascii
4394 article-normalize-headers
4395 ;;(article-show-all . gnus-article-show-all-headers)
4399 ;;; Gnus article mode
4402 (put 'gnus-article-mode 'mode-class 'special)
4404 (set-keymap-parent gnus-article-mode-map widget-keymap)
4406 (gnus-define-keys gnus-article-mode-map
4407 " " gnus-article-goto-next-page
4408 [?\S-\ ] gnus-article-goto-prev-page
4409 "\177" gnus-article-goto-prev-page
4410 [delete] gnus-article-goto-prev-page
4411 "\C-c^" gnus-article-refer-article
4412 "h" gnus-article-show-summary
4413 "s" gnus-article-show-summary
4414 "\C-c\C-m" gnus-article-mail
4415 "?" gnus-article-describe-briefly
4416 "<" beginning-of-buffer
4418 "\C-c\C-i" gnus-info-find-node
4420 "R" gnus-article-reply-with-original
4421 "F" gnus-article-followup-with-original
4422 "\C-hk" gnus-article-describe-key
4423 "\C-hc" gnus-article-describe-key-briefly
4424 "\C-hb" gnus-article-describe-bindings
4426 "e" gnus-article-read-summary-keys
4427 "\C-d" gnus-article-read-summary-keys
4428 "\M-*" gnus-article-read-summary-keys
4429 "\M-#" gnus-article-read-summary-keys
4430 "\M-^" gnus-article-read-summary-keys
4431 "\M-g" gnus-article-read-summary-keys)
4433 (substitute-key-definition
4434 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
4436 (defvar gnus-article-send-map)
4438 (gnus-define-keys (gnus-article-send-map "S" gnus-article-mode-map)
4439 "W" gnus-article-wide-reply-with-original)
4440 (if (featurep 'xemacs)
4441 (set-keymap-default-binding gnus-article-send-map
4442 'gnus-article-read-summary-send-keys)
4443 (define-key gnus-article-send-map [t] 'gnus-article-read-summary-send-keys))
4445 (defun gnus-article-make-menu-bar ()
4446 (unless (boundp 'gnus-article-commands-menu)
4447 (gnus-summary-make-menu-bar))
4448 (unless (boundp 'gnus-article-article-menu)
4450 gnus-article-article-menu gnus-article-mode-map ""
4452 ["Scroll forwards" gnus-article-goto-next-page t]
4453 ["Scroll backwards" gnus-article-goto-prev-page t]
4454 ["Show summary" gnus-article-show-summary t]
4455 ["Fetch Message-ID at point" gnus-article-refer-article t]
4456 ["Mail to address at point" gnus-article-mail t]
4457 ["Send a bug report" gnus-bug t]))
4460 gnus-article-treatment-menu gnus-article-mode-map ""
4461 ;; Fixme: this should use :active (and maybe :visible).
4463 ["Hide headers" gnus-article-hide-headers t]
4464 ["Hide signature" gnus-article-hide-signature t]
4465 ["Hide citation" gnus-article-hide-citation t]
4466 ["Treat overstrike" gnus-article-treat-overstrike t]
4467 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
4468 ["Remove carriage return" gnus-article-remove-cr t]
4469 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
4470 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
4471 ["Remove base64" gnus-article-de-base64-unreadable t]
4472 ["Treat html" gnus-article-wash-html t]
4473 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
4474 ["Decode HZ" gnus-article-decode-HZ t]))
4476 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
4478 ;; Note "Post" menu is defined in gnus-sum.el for consistency
4480 (gnus-run-hooks 'gnus-article-menu-hook)))
4482 (defvar bookmark-make-record-function)
4483 (defvar shr-put-image-function)
4485 (define-derived-mode gnus-article-mode fundamental-mode "Article"
4486 "Major mode for displaying an article.
4488 All normal editing commands are switched off.
4490 The following commands are available in addition to all summary mode
4492 \\<gnus-article-mode-map>
4493 \\[gnus-article-next-page]\t Scroll the article one page forwards
4494 \\[gnus-article-prev-page]\t Scroll the article one page backwards
4495 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
4496 \\[gnus-article-show-summary]\t Display the summary buffer
4497 \\[gnus-article-mail]\t Send a reply to the address near point
4498 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
4499 \\[gnus-info-find-node]\t Go to the Gnus info node"
4500 (gnus-simplify-mode-line)
4501 (make-local-variable 'minor-mode-alist)
4502 (when (gnus-visual-p 'article-menu 'menu)
4503 (gnus-article-make-menu-bar)
4504 (when gnus-summary-tool-bar-map
4505 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
4506 (gnus-update-format-specifications nil 'article-mode)
4507 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
4508 (set (make-local-variable 'gnus-page-broken) nil)
4509 (make-local-variable 'gnus-article-current-summary)
4510 (make-local-variable 'gnus-article-mime-handles)
4511 (make-local-variable 'gnus-article-decoded-p)
4512 (make-local-variable 'gnus-article-mime-handle-alist)
4513 (make-local-variable 'gnus-article-wash-types)
4514 (make-local-variable 'gnus-article-image-alist)
4515 (make-local-variable 'gnus-article-charset)
4516 (make-local-variable 'gnus-article-ignored-charsets)
4517 (set (make-local-variable 'bookmark-make-record-function)
4518 'gnus-summary-bookmark-make-record)
4519 ;; Prevent Emacs 22 from displaying non-break space with `nobreak-space'
4521 (set (make-local-variable 'nobreak-char-display) nil)
4522 ;; Enable `gnus-article-remove-images' to delete images shr.el renders.
4523 (set (make-local-variable 'shr-put-image-function) 'gnus-shr-put-image)
4524 (setq cursor-in-non-selected-windows nil)
4525 (gnus-set-default-directory)
4526 (buffer-disable-undo)
4527 (setq buffer-read-only t
4528 show-trailing-whitespace nil)
4529 (mm-enable-multibyte))
4531 (defun gnus-article-setup-buffer ()
4532 "Initialize the article buffer."
4533 (let* ((name (if gnus-single-article-buffer "*Article*"
4535 (gnus-group-decoded-name gnus-newsgroup-name)
4538 (progn (string-match "\\*Article" name)
4539 (concat " *Original Article"
4540 (substring name (match-end 0))))))
4541 (setq gnus-article-buffer name)
4542 (setq gnus-original-article-buffer original)
4543 (setq gnus-article-mime-handle-alist nil)
4544 (with-current-buffer gnus-summary-buffer
4545 ;; This might be a variable local to the summary buffer.
4546 (unless gnus-single-article-buffer
4547 (setq gnus-article-buffer name)
4548 (setq gnus-original-article-buffer original)
4549 (gnus-set-global-variables)))
4550 (gnus-article-setup-highlight-words)
4551 ;; Init original article buffer.
4552 (with-current-buffer (gnus-get-buffer-create gnus-original-article-buffer)
4553 (mm-enable-multibyte)
4554 (setq major-mode 'gnus-original-article-mode)
4555 (make-local-variable 'gnus-original-article))
4556 (if (and (get-buffer name)
4557 (with-current-buffer name
4558 (if gnus-article-edit-mode
4559 (if (y-or-n-p "Article mode edit in progress; discard? ")
4561 (set-buffer-modified-p nil)
4562 (gnus-kill-buffer name)
4565 (error "Action aborted"))
4567 (let ((summary gnus-summary-buffer))
4568 (with-current-buffer name
4569 (set (make-local-variable 'gnus-article-edit-mode) nil)
4570 (gnus-article-stop-animations)
4571 (when gnus-article-mime-handles
4572 (mm-destroy-parts gnus-article-mime-handles)
4573 (setq gnus-article-mime-handles nil))
4574 ;; Set it to nil in article-buffer!
4575 (setq gnus-article-mime-handle-alist nil)
4576 (buffer-disable-undo)
4577 (setq buffer-read-only t)
4578 (unless (derived-mode-p 'gnus-article-mode)
4579 (gnus-article-mode))
4580 (set (make-local-variable 'gnus-summary-buffer) summary)
4581 (setq truncate-lines gnus-article-truncate-lines)
4583 (let ((summary gnus-summary-buffer))
4584 (with-current-buffer (gnus-get-buffer-create name)
4586 (setq truncate-lines gnus-article-truncate-lines)
4587 (set (make-local-variable 'gnus-summary-buffer) summary)
4588 (gnus-summary-set-local-parameters gnus-newsgroup-name)
4589 (when article-lapsed-timer
4590 (gnus-stop-date-timer))
4591 (when gnus-article-update-date-headers
4592 (gnus-start-date-timer gnus-article-update-date-headers))
4593 (current-buffer))))))
4595 (defun gnus-article-stop-animations ()
4596 (dolist (timer (and (boundp 'timer-list)
4598 (when (eq (gnus-timer--function timer) 'image-animate-timeout)
4599 (cancel-timer timer))))
4601 (defun gnus-stop-downloads ()
4602 (when (boundp 'url-queue)
4603 (set (intern "url-queue" obarray) nil)))
4605 ;; Set article window start at LINE, where LINE is the number of lines
4606 ;; from the head of the article.
4607 (defun gnus-article-set-window-start (&optional line)
4608 (let ((article-window (gnus-get-buffer-window gnus-article-buffer t)))
4609 (when article-window
4612 (with-current-buffer gnus-article-buffer
4613 (goto-char (point-min))
4616 (gnus-message 6 "Moved to bookmark")
4617 (search-forward "\n\n" nil t)
4621 (defvar gnus-tmp-internal-hook)
4623 (defun gnus-article-prepare (article &optional all-headers _header)
4624 "Prepare ARTICLE in article mode buffer.
4625 ARTICLE should either be an article number or a Message-ID.
4626 If ARTICLE is an id, HEADER should be the article headers.
4627 If ALL-HEADERS is non-nil, no headers are hidden."
4628 (save-excursion ;FIXME: Shouldn't that be save-current-buffer?
4629 ;; Make sure we start in a summary buffer.
4630 (unless (derived-mode-p 'gnus-summary-mode)
4631 (set-buffer gnus-summary-buffer))
4632 (setq gnus-summary-buffer (current-buffer))
4633 (let* ((summary-buffer (current-buffer))
4634 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4635 (group gnus-newsgroup-name)
4638 (gnus-article-setup-buffer)
4639 (set-buffer gnus-article-buffer)
4640 ;; Deactivate active regions.
4641 (when (and (boundp 'transient-mark-mode)
4642 transient-mark-mode)
4643 (setq mark-active nil))
4644 (if (not (setq result (let ((inhibit-read-only t))
4645 (gnus-request-article-this-buffer
4647 ;; There is no such article.
4649 (when (and (numberp article)
4650 (not (memq article gnus-newsgroup-sparse)))
4651 (setq gnus-article-current
4652 (cons gnus-newsgroup-name article))
4653 (set-buffer gnus-summary-buffer)
4654 (setq gnus-current-article article)
4655 (if (and (memq article gnus-newsgroup-undownloaded)
4656 (not (gnus-online (gnus-find-method-for-group
4657 gnus-newsgroup-name))))
4659 (gnus-summary-set-agent-mark article)
4660 (message "Message marked for downloading"))
4661 (gnus-summary-mark-article article gnus-canceled-mark)
4662 (unless (memq article gnus-newsgroup-sparse)
4663 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4664 (if (or (eq result 'pseudo)
4665 (eq result 'nneething))
4667 (with-current-buffer summary-buffer
4668 (push article gnus-newsgroup-history)
4669 (setq gnus-last-article gnus-current-article
4670 gnus-current-article 0
4671 gnus-current-headers nil
4672 gnus-article-current nil)
4673 (if (eq result 'nneething)
4674 (gnus-configure-windows 'summary)
4675 (gnus-configure-windows 'article))
4676 (gnus-set-global-variables))
4677 (let ((gnus-article-mime-handle-alist-1
4678 gnus-article-mime-handle-alist))
4679 (gnus-set-mode-line 'article)))
4680 ;; The result from the `request' was an actual article -
4681 ;; or at least some text that is now displayed in the
4683 (when (and (numberp article)
4684 (not (eq article gnus-current-article)))
4685 ;; Seems like a new article has been selected.
4686 ;; `gnus-current-article' must be an article number.
4687 (with-current-buffer summary-buffer
4688 (push article gnus-newsgroup-history)
4689 (setq gnus-last-article gnus-current-article
4690 gnus-current-article article
4691 gnus-current-headers
4692 (gnus-summary-article-header gnus-current-article)
4693 gnus-article-current
4694 (cons gnus-newsgroup-name gnus-current-article))
4695 (unless (vectorp gnus-current-headers)
4696 (setq gnus-current-headers nil))
4697 (gnus-summary-goto-subject gnus-current-article)
4698 (when (gnus-summary-show-thread)
4699 ;; If the summary buffer really was folded, the
4700 ;; previous goto may not actually have gone to
4701 ;; the right article, but the thread root instead.
4703 (gnus-summary-goto-subject gnus-current-article))
4704 (gnus-run-hooks 'gnus-mark-article-hook)
4705 (gnus-set-mode-line 'summary)
4706 (when (gnus-visual-p 'article-highlight 'highlight)
4707 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4708 ;; Set the global newsgroup variables here.
4709 (gnus-set-global-variables)
4710 (setq gnus-have-all-headers
4711 (or all-headers gnus-show-all-headers))))
4713 (gnus-configure-windows 'article))
4714 (when (or (numberp article)
4716 (gnus-article-prepare-display)
4718 (goto-char (point-min))
4719 (when gnus-break-pages
4720 (gnus-narrow-to-page)))
4721 (let ((gnus-article-mime-handle-alist-1
4722 gnus-article-mime-handle-alist))
4723 (gnus-set-mode-line 'article))
4727 (set-window-point (get-buffer-window (current-buffer)) (point))
4728 (gnus-configure-windows 'article)
4729 (gnus-run-hooks 'gnus-article-prepare-hook)
4732 (defvar gnus-mime-display-attachment-buttons-in-header)
4735 (defun gnus-article-prepare-display ()
4736 "Make the current buffer look like a nice article."
4737 ;; Hooks for getting information from the article.
4738 ;; This hook must be called before being narrowed.
4739 (let ((gnus-article-buffer (current-buffer))
4741 (inhibit-read-only t))
4742 (unless (derived-mode-p 'gnus-article-mode)
4743 (gnus-article-mode))
4744 (setq buffer-read-only nil
4745 gnus-article-wash-types nil
4746 gnus-article-image-alist nil)
4747 (gnus-run-hooks 'gnus-tmp-internal-hook)
4748 (when gnus-display-mime-function
4749 (funcall gnus-display-mime-function))
4750 ;; Add attachment buttons to the header.
4751 (when gnus-mime-display-attachment-buttons-in-header
4752 (gnus-mime-buttonize-attachments-in-header))))
4755 ;;; Gnus Sticky Article Mode
4758 (define-derived-mode gnus-sticky-article-mode gnus-article-mode "StickyArticle"
4759 "Mode for sticky articles."
4760 ;; Release bindings that won't work.
4761 (substitute-key-definition 'gnus-article-read-summary-keys 'undefined
4762 gnus-sticky-article-mode-map)
4763 (substitute-key-definition 'gnus-article-refer-article 'undefined
4764 gnus-sticky-article-mode-map)
4765 (dolist (k '("e" "h" "s" "F" "R"))
4766 (define-key gnus-sticky-article-mode-map k nil))
4767 (define-key gnus-sticky-article-mode-map "k" 'gnus-kill-sticky-article-buffer)
4768 (define-key gnus-sticky-article-mode-map "q" 'bury-buffer)
4769 (define-key gnus-sticky-article-mode-map "\C-hc" 'describe-key-briefly)
4770 (define-key gnus-sticky-article-mode-map "\C-hk" 'describe-key))
4772 (defun gnus-sticky-article (arg)
4773 "Make the current article sticky.
4774 If a prefix ARG is given, ask for a name for this sticky article buffer."
4776 (gnus-summary-show-thread)
4777 (gnus-summary-select-article nil nil 'pseudo)
4778 (let (new-art-buf-name)
4779 (gnus-eval-in-buffer-window gnus-article-buffer
4780 (setq new-art-buf-name
4784 (read-from-minibuffer "Sticky article buffer name: ")
4785 (gnus-with-article-headers
4786 (gnus-article-goto-header "subject")
4787 (setq new-art-buf-name
4788 (buffer-substring-no-properties
4789 (line-beginning-position) (line-end-position)))
4790 (goto-char (point-min))
4791 (gnus-article-goto-header "from")
4792 (setq new-art-buf-name
4794 new-art-buf-name ", "
4795 (buffer-substring-no-properties
4796 (line-beginning-position) (line-end-position))))
4797 (goto-char (point-min))
4798 (gnus-article-goto-header "date")
4799 (setq new-art-buf-name
4801 new-art-buf-name ", "
4802 (buffer-substring-no-properties
4803 (line-beginning-position) (line-end-position))))))
4805 (if (and (gnus-buffer-live-p new-art-buf-name)
4806 (with-current-buffer new-art-buf-name
4807 (derived-mode-p 'gnus-sticky-article-mode)))
4808 (switch-to-buffer new-art-buf-name)
4809 (setq new-art-buf-name (rename-buffer new-art-buf-name t)))
4810 (gnus-sticky-article-mode))
4811 (setq gnus-article-buffer new-art-buf-name))
4812 (gnus-summary-recenter)
4813 (gnus-summary-position-point))
4815 (defun gnus-kill-sticky-article-buffer (&optional buffer)
4816 "Kill the given sticky article BUFFER.
4817 If none is given, assume the current buffer and kill it if it has
4818 `gnus-sticky-article-mode'."
4821 (setq buffer (current-buffer)))
4822 (with-current-buffer buffer
4823 (when (derived-mode-p 'gnus-sticky-article-mode)
4824 (gnus-kill-buffer buffer))))
4826 (defun gnus-kill-sticky-article-buffers (arg)
4827 "Kill all sticky article buffers.
4828 If a prefix ARG is given, ask for confirmation."
4830 (dolist (buf (gnus-buffers))
4831 (with-current-buffer buf
4832 (when (derived-mode-p 'gnus-sticky-article-mode)
4834 (gnus-kill-buffer buf)
4835 (when (yes-or-no-p (concat "Kill buffer " (buffer-name buf) "? "))
4836 (gnus-kill-buffer buf)))))))
4839 ;;; Gnus MIME viewing functions
4842 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4843 "Format of the MIME buttons.
4845 Valid specifiers include:
4847 %T MIME type, along with additional info
4848 %n The `name' parameter
4849 %d The description, if any
4850 %l The length of the encoded part
4851 %p The part identifier number
4852 %e Dots if the part isn't displayed
4854 General format specifiers can also be used. See Info node
4855 `(gnus)Formatting Variables'.")
4857 (defvar gnus-tmp-type)
4858 (defvar gnus-tmp-type-long)
4859 (defvar gnus-tmp-name)
4860 (defvar gnus-tmp-description)
4861 (defvar gnus-tmp-id)
4862 (defvar gnus-tmp-length)
4863 (defvar gnus-tmp-dots)
4864 (defvar gnus-tmp-info)
4865 (defvar gnus-tmp-pressed-details)
4867 (defvar gnus-mime-button-line-format-alist
4868 '((?t gnus-tmp-type ?s)
4869 (?T gnus-tmp-type-long ?s)
4870 (?n gnus-tmp-name ?s)
4871 (?d gnus-tmp-description ?s)
4873 (?l gnus-tmp-length ?d)
4874 (?e gnus-tmp-dots ?s)))
4876 (defvar gnus-mime-button-commands
4877 '((gnus-article-press-button "\r" "Toggle Display")
4878 (gnus-mime-view-part "v" "View Interactively...")
4879 (gnus-mime-view-part-as-type "t" "View As Type...")
4880 (gnus-mime-view-part-as-charset "C" "View As charset...")
4881 (gnus-mime-save-part "o" "Save...")
4882 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4883 (gnus-mime-replace-part "r" "Replace part")
4884 (gnus-mime-delete-part "d" "Delete part")
4885 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4886 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4887 (gnus-mime-view-part-internally "E" "View Internally") ;; Why `E'?
4888 (gnus-mime-view-part-externally "e" "View Externally")
4889 (gnus-mime-print-part "p" "Print")
4890 (gnus-mime-pipe-part "|" "Pipe To Command...")
4891 (gnus-mime-action-on-part "." "Take action on the part...")))
4893 (defun gnus-article-mime-part-status ()
4894 (if gnus-article-mime-handle-alist-1
4895 (if (eq 1 (length gnus-article-mime-handle-alist-1))
4897 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
4900 (defvar gnus-mime-button-map
4901 (let ((map (make-sparse-keymap)))
4902 (define-key map gnus-mouse-2 'gnus-article-push-button)
4903 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4904 (dolist (c gnus-mime-button-commands)
4905 (define-key map (cadr c) (car c)))
4909 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4911 ,@(mapcar (lambda (c)
4912 (vector (caddr c) (car c) :active t))
4913 gnus-mime-button-commands)))
4915 (defvar gnus-url-button-commands
4916 '((gnus-article-copy-string "u" "Copy URL to kill ring")))
4918 (defvar gnus-url-button-map
4919 (let ((map (make-sparse-keymap)))
4920 (dolist (c gnus-url-button-commands)
4921 (define-key map (cadr c) (car c)))
4925 gnus-url-button-menu gnus-url-button-map "URL button menu."
4927 ,@(mapcar (lambda (c)
4928 (vector (caddr c) (car c) :active t))
4929 gnus-url-button-commands)))
4931 (defmacro gnus-bind-safe-url-regexp (&rest body)
4932 "Bind `mm-w3m-safe-url-regexp' according to `gnus-safe-html-newsgroups'."
4933 `(let ((mm-w3m-safe-url-regexp
4934 (let ((group (if (and (derived-mode-p 'gnus-article-mode)
4936 gnus-article-current-summary))
4937 (with-current-buffer gnus-article-current-summary
4938 gnus-newsgroup-name)
4939 gnus-newsgroup-name)))
4940 (if (cond ((not group)
4941 ;; Maybe we're in a mml-preview buffer
4942 ;; and no group is selected.
4944 ((stringp gnus-safe-html-newsgroups)
4945 (string-match gnus-safe-html-newsgroups group))
4946 ((consp gnus-safe-html-newsgroups)
4947 (member group gnus-safe-html-newsgroups)))
4949 mm-w3m-safe-url-regexp))))
4952 (defun gnus-mime-button-menu (event prefix)
4953 "Construct a context-sensitive menu of MIME commands."
4954 (interactive "e\nP")
4955 (save-window-excursion
4956 (let ((pos (event-start event)))
4957 (select-window (posn-window pos))
4958 (goto-char (posn-point pos))
4959 (gnus-article-check-buffer)
4960 (popup-menu gnus-mime-button-menu nil prefix))))
4962 (defun gnus-mime-view-all-parts (&optional handles)
4963 "View all the MIME parts."
4965 (with-current-buffer gnus-article-buffer
4966 (let ((handles (or handles gnus-article-mime-handles))
4967 (mail-parse-charset gnus-newsgroup-charset)
4968 (mail-parse-ignored-charsets
4969 (with-current-buffer gnus-summary-buffer
4970 gnus-newsgroup-ignored-charsets)))
4972 (mm-remove-parts handles)
4973 (goto-char (point-min))
4974 (or (search-forward "\n\n") (goto-char (point-max)))
4975 (let ((inhibit-read-only t))
4976 (delete-region (point) (point-max))
4977 (gnus-bind-safe-url-regexp (mm-display-parts handles)))))))
4979 (defun gnus-article-jump-to-part (n)
4980 "Jump to MIME part N."
4982 (let ((parts (with-current-buffer gnus-article-buffer
4983 (length gnus-article-mime-handle-alist))))
4985 (error "No such part"))
4986 (pop-to-buffer gnus-article-buffer)
4988 (setq n (if (= parts 1)
4990 (read-number (format "Jump to part (1..%s): " parts)))))
4991 (unless (and (integerp n) (<= n parts) (>= n 1))
4994 (gnus-message 7 "Invalid part `%s', using %s instead."
4997 (gnus-message 9 "Jumping to part %s." n)
4998 (cond ((>= gnus-auto-select-part 1)
4999 (while (and (<= n parts)
5000 (not (gnus-article-goto-part n)))
5002 ((< gnus-auto-select-part 0)
5003 (while (and (>= n 1)
5004 (not (gnus-article-goto-part n)))
5007 (gnus-article-goto-part n)))))
5009 (defvar gnus-mime-buttonized-part-id nil
5010 "ID of a mime part that should be buttonized.
5011 `gnus-mime-save-part-and-strip' and `gnus-mime-delete-part' bind it.")
5014 (defsubst gnus-article-edit-part (handles &optional current-id)
5015 "Edit an article in order to delete a mime part.
5016 This function is exclusively used by `gnus-mime-save-part-and-strip'
5017 and `gnus-mime-delete-part', and not provided at run-time normally."
5018 (gnus-article-edit-article
5020 (buffer-disable-undo)
5021 (let ((mail-parse-charset (or gnus-article-charset
5022 ',gnus-newsgroup-charset))
5023 (mail-parse-ignored-charsets
5024 (or gnus-article-ignored-charsets
5025 ',gnus-newsgroup-ignored-charsets))
5026 (mbl mml-buffer-list))
5027 (setq mml-buffer-list nil)
5028 ;; A new text must be inserted before deleting existing ones
5029 ;; at the end so as not to move existing markers of which
5030 ;; the insertion type is t.
5034 (goto-char (point-max))
5035 (insert-buffer-substring gnus-original-article-buffer)))
5036 (mime-to-mml ',handles)
5037 (setq gnus-article-mime-handles nil)
5038 (let ((mbl1 mml-buffer-list))
5039 (setq mml-buffer-list mbl)
5040 (set (make-local-variable 'mml-buffer-list) mbl1))
5041 (gnus-make-local-hook 'kill-buffer-hook)
5042 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
5043 `(lambda (no-highlight)
5044 (let ((mail-parse-charset (or gnus-article-charset
5045 ',gnus-newsgroup-charset))
5046 (message-options message-options)
5047 (message-options-set-recipient)
5048 (mail-parse-ignored-charsets
5049 (or gnus-article-ignored-charsets
5050 ',gnus-newsgroup-ignored-charsets)))
5052 (mml-destroy-buffers)
5053 (remove-hook 'kill-buffer-hook
5054 'mml-destroy-buffers t)
5055 (kill-local-variable 'mml-buffer-list))
5056 (gnus-summary-edit-article-done
5057 ,(or (mail-header-references gnus-current-headers) "")
5058 ,(gnus-group-read-only-p)
5059 ,gnus-summary-buffer no-highlight))
5061 ;; Force buttonizing this part.
5062 (let ((gnus-mime-buttonized-part-id current-id))
5063 (gnus-article-edit-done))
5064 (gnus-configure-windows 'article)
5066 (when (and current-id (integerp gnus-auto-select-part))
5067 (gnus-article-jump-to-part
5068 (min (max (+ current-id gnus-auto-select-part) 1)
5069 (with-current-buffer gnus-article-buffer
5070 (length gnus-article-mime-handle-alist)))))))
5072 (defun gnus-mime-replace-part (file)
5073 "Replace MIME part under point with an external body."
5074 ;; Useful if file has already been saved to disk
5077 (read-file-name "Replace MIME part with file: "
5078 (or mm-default-directory default-directory)
5080 (gnus-mime-save-part-and-strip file))
5082 (defun gnus-mime-save-part-and-strip (&optional file)
5083 "Save the MIME part under point then replace it with an external body.
5084 If FILE is given, use it for the external part."
5086 (gnus-article-check-buffer)
5087 (when (gnus-group-read-only-p)
5088 (error "The current group does not support deleting of parts"))
5089 (when (mm-complicated-handles gnus-article-mime-handles)
5091 The current article has a complicated MIME structure, giving up..."))
5092 (let* ((data (get-text-property (point) 'gnus-data))
5093 (id (get-text-property (point) 'gnus-part))
5094 (handles gnus-article-mime-handles))
5097 (and data (mm-save-part data "Delete MIME part and save to: "))))
5099 (with-current-buffer (mm-handle-buffer data)
5101 (insert "Content-Type: " (mm-handle-media-type data))
5102 (mml-insert-parameter-string (cdr (mm-handle-type data))
5104 ;; Add a filename for the sake of saving the part again.
5105 (mml-insert-parameter
5106 (mail-header-encode-parameter "name" (file-name-nondirectory file)))
5108 (insert "Content-ID: " (message-make-message-id) "\n")
5109 (insert "Content-Transfer-Encoding: binary\n")
5112 (cdr (mm-make-handle nil
5113 `("message/external-body"
5114 (access-type . "LOCAL-FILE")
5116 ;; (set-buffer gnus-summary-buffer)
5117 (gnus-article-edit-part handles id))))
5119 ;; A function like `gnus-summary-save-parts' (`X m', `<MIME> <Extract all
5120 ;; parts...>') but with stripping would be nice.
5122 (defun gnus-mime-delete-part ()
5123 "Delete the MIME part under point.
5124 Replace it with some information about the removed part."
5126 (gnus-article-check-buffer)
5127 (when (gnus-group-read-only-p)
5128 (error "The current group does not support deleting of parts"))
5129 (when (mm-complicated-handles gnus-article-mime-handles)
5131 The current article has a complicated MIME structure, giving up..."))
5132 (when (or gnus-expert-user
5133 (gnus-yes-or-no-p "\
5134 Deleting parts may malfunction or destroy the article; continue? "))
5135 (let* ((data (get-text-property (point) 'gnus-data))
5136 (id (get-text-property (point) 'gnus-part))
5137 (handles gnus-article-mime-handles)
5139 (let ((desc (mm-handle-description data)))
5141 (mail-decode-encoded-word-string desc))))
5142 (filename (or (mm-handle-filename data) "(none)"))
5143 (type (mm-handle-media-type data)))
5145 (error "No MIME part under point"))
5146 (with-current-buffer (mm-handle-buffer data)
5147 (let ((bsize (buffer-size)))
5152 "| The following attachment has been deleted:\n"
5154 "| Type: " type "\n"
5155 "| Filename: " filename "\n"
5156 "| Size (encoded): " (format "%s byte%s\n"
5157 bsize (if (= bsize 1)
5161 (concat "| Description: " description "\n"))
5164 (cdr (mm-make-handle
5165 nil `("text/plain" (charset . gnus-decoded)) nil nil
5167 (format "Deleted attachment (%s bytes)" bsize))))))
5168 ;; (set-buffer gnus-summary-buffer)
5169 (gnus-article-edit-part handles id))))
5171 (defun gnus-mime-save-part ()
5172 "Save the MIME part under point."
5174 (gnus-article-check-buffer)
5175 (let ((data (get-text-property (point) 'gnus-data)))
5177 (mm-save-part data))))
5179 (defun gnus-mime-pipe-part (&optional cmd)
5180 "Pipe the MIME part under point to a process.
5181 Use CMD as the process."
5183 (gnus-article-check-buffer)
5184 (let ((data (get-text-property (point) 'gnus-data)))
5186 (mm-pipe-part data cmd))))
5188 (defun gnus-mime-view-part ()
5189 "Interactively choose a viewing method for the MIME part under point."
5191 (gnus-article-check-buffer)
5192 (let ((data (get-text-property (point) 'gnus-data)))
5194 (setq gnus-article-mime-handles
5196 gnus-article-mime-handles (setq data (copy-sequence data))))
5197 (mm-interactively-view-part data))))
5199 (defun gnus-mime-view-part-as-type-internal ()
5200 (gnus-article-check-buffer)
5201 (let* ((handle (get-text-property (point) 'gnus-data))
5203 ;; Content-Type: foo/bar; name=...
5204 (mail-content-type-get (mm-handle-type handle) 'name)
5205 ;; Content-Disposition: attachment; filename=...
5206 (cdr (assq 'filename (cdr (mm-handle-disposition handle))))))
5207 (def-type (and name (mm-default-file-encoding name))))
5208 (or (and def-type (cons def-type 0))
5210 (equal (mm-handle-media-supertype handle) "text")
5211 '("text/plain" . 0))
5212 '("application/octet-stream" . 0))))
5214 (defun gnus-mime-view-part-as-type (&optional mime-type pred)
5215 "Choose a MIME media type, and view the part as such.
5216 If non-nil, PRED is a predicate to use during completion to limit the
5217 available media-types."
5221 (let ((default (gnus-mime-view-part-as-type-internal)))
5222 (gnus-completing-read
5225 (gnus-remove-if-not pred (mailcap-mime-types))
5226 (mailcap-mime-types))
5229 (gnus-article-check-buffer)
5230 (let ((handle (get-text-property (point) 'gnus-data)))
5232 (when (equal (mm-handle-media-type handle) "message/external-body")
5233 (unless (mm-handle-cache handle)
5234 (mm-extern-cache-contents handle))
5235 (setq handle (mm-handle-cache handle)))
5237 (mm-make-handle (mm-handle-buffer handle)
5238 (cons mime-type (cdr (mm-handle-type handle)))
5239 (mm-handle-encoding handle)
5240 (mm-handle-undisplayer handle)
5241 (mm-handle-disposition handle)
5242 (mm-handle-description handle)
5244 (mm-handle-id handle)))
5245 (setq gnus-article-mime-handles
5246 (mm-merge-handles gnus-article-mime-handles handle))
5247 (when (mm-handle-displayed-p handle)
5248 (mm-remove-part handle))
5249 (gnus-mm-display-part handle))))
5251 (defun gnus-mime-copy-part (&optional handle arg)
5252 "Put the MIME part under point into a new buffer.
5253 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
5255 (interactive (list nil current-prefix-arg))
5256 (gnus-article-check-buffer)
5258 (setq handle (get-text-property (point) 'gnus-data)))
5260 (let ((filename (mm-handle-filename handle))
5261 contents dont-decode charset coding-system)
5262 (mm-with-unibyte-buffer
5263 (mm-insert-part handle)
5264 (setq contents (or (condition-case nil
5265 (mm-decompress-buffer filename nil 'sig)
5267 (setq dont-decode t)
5270 (setq filename (cond (filename (file-name-nondirectory filename))
5271 (dont-decode "*raw data*")
5276 (unless (setq charset (mail-content-type-get
5277 (mm-handle-type handle) 'charset))
5278 (unless (setq coding-system (mm-with-unibyte-buffer
5280 (mm-find-buffer-file-coding-system)))
5281 (setq charset gnus-newsgroup-charset))))
5283 (setq charset (or (cdr (assq arg
5284 gnus-summary-show-article-charset-alist))
5285 (mm-read-coding-system "Charset: ")))))
5286 (switch-to-buffer (generate-new-buffer filename))
5287 (if (or coding-system
5289 (setq coding-system (mm-charset-to-coding-system
5291 (not (eq coding-system 'ascii))))
5293 (mm-enable-multibyte)
5294 (insert (mm-decode-coding-string contents coding-system))
5295 (setq buffer-file-coding-system
5296 (if (boundp 'last-coding-system-used)
5297 (symbol-value 'last-coding-system-used)
5299 (mm-disable-multibyte)
5301 (setq buffer-file-coding-system mm-binary-coding-system))
5302 ;; We do it this way to make `normal-mode' set the appropriate mode.
5305 (setq buffer-file-name (expand-file-name filename))
5307 (setq buffer-file-name nil))
5308 (goto-char (point-min)))))
5310 (defun gnus-mime-print-part (&optional handle filename)
5311 "Print the MIME part under point."
5312 (interactive (list nil (ps-print-preprint current-prefix-arg)))
5313 (gnus-article-check-buffer)
5314 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5315 (contents (and handle (mm-get-part handle)))
5316 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
5317 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
5322 (mm-save-part-to-file handle file)
5323 (call-process shell-file-name nil
5324 (generate-new-buffer " *mm*")
5326 shell-command-switch
5328 printer file (mm-handle-type handle))))
5332 (gnus-print-buffer))
5333 (ps-despool filename)))))
5335 (defun gnus-mime-inline-part (&optional handle arg)
5336 "Insert the MIME part under point into the current buffer.
5337 Compressed files like .gz and .bz2 are decompressed."
5338 (interactive (list nil current-prefix-arg))
5339 (gnus-article-check-buffer)
5340 (let* ((inhibit-read-only t)
5342 (btn ;; position where the MIME button exists
5344 (if (eq handle (get-text-property b 'gnus-data))
5347 (or (text-property-any (point) (point-max) 'gnus-data handle)
5348 (text-property-any (point-min) (point) 'gnus-data handle)))
5349 (setq handle (get-text-property b 'gnus-data))
5355 (setq start (next-single-property-change btn 'gnus-data
5357 btn (previous-single-property-change start
5360 (if (and (not arg) (mm-handle-undisplayer handle))
5362 (setq b (copy-marker b)
5363 btn (copy-marker btn))
5364 (mm-remove-part handle))
5368 (if (mm-handle-undisplayer handle)
5369 (mm-remove-part handle)))
5370 ((mm-handle-undisplayer handle)
5371 (mm-remove-part handle)))
5374 ;; This is a header button.
5376 (mm-display-inline handle))
5377 ;; Toggle the button appearance between `[button]...' and `[button]'.
5379 (setq btn (prog1 (marker-position btn)
5380 (set-marker btn nil))))
5382 (let ((displayed-p (mm-handle-displayed-p handle)))
5383 (gnus-insert-mime-button handle (get-text-property btn 'gnus-part)
5385 (if (featurep 'emacs)
5388 (next-single-property-change (point) 'gnus-data nil (point-max)))
5389 (let* ((end (next-single-property-change (point) 'gnus-data))
5390 (annots (annotations-at (or end (point-max)))))
5391 (delete-region (point)
5393 (if annots (1+ end) end)
5395 (dolist (annot annots)
5396 (set-extent-endpoints annot (point) (point)))))
5397 (setq start (point))
5398 (if (search-backward "\n\n" nil t)
5401 (unless (or displayed-p (eolp))
5402 ;; Add extra newline.
5403 (insert (propertize (buffer-substring (1- start) start)
5404 'gnus-undeletable t))))
5405 ;; We're in the article header.
5407 (dolist (ovl (gnus-overlays-in btn (point)))
5408 (gnus-overlay-put ovl 'gnus-button-attachment-extra t)
5409 (gnus-overlay-put ovl 'face nil))
5411 (message-narrow-to-field)
5412 (let ((gnus-treatment-function-alist
5413 '((gnus-treat-highlight-headers
5414 gnus-article-highlight-headers))))
5415 (gnus-treat-article 'head)))))
5417 (setq b (prog1 (marker-position b)
5418 (set-marker b nil))))
5421 (defun gnus-mime-set-charset-parameters (handle charset)
5422 "Set CHARSET to parameters in HANDLE.
5423 CHARSET may either be a string or a symbol."
5424 (unless (stringp charset)
5425 (setq charset (symbol-name charset)))
5426 (if (stringp (car handle))
5427 (dolist (h (cdr handle))
5428 (gnus-mime-set-charset-parameters h charset))
5429 (let* ((type (mm-handle-type (if (equal (mm-handle-media-type handle)
5430 "message/external-body")
5432 (unless (mm-handle-cache handle)
5433 (mm-extern-cache-contents handle))
5434 (mm-handle-cache handle))
5436 (param (assq 'charset (cdr type))))
5438 (setcdr param charset)
5439 (setcdr type (cons (cons 'charset charset) (cdr type)))))))
5441 (defun gnus-mime-view-part-as-charset (&optional handle arg)
5442 "Insert the MIME part under point into the current buffer using the
5444 (interactive (list nil current-prefix-arg))
5445 (gnus-article-check-buffer)
5446 (let ((handle (or handle (get-text-property (point) 'gnus-data)))
5447 (fun (get-text-property (point) 'gnus-callback))
5448 (gnus-newsgroup-ignored-charsets 'gnus-all)
5449 charset form preferred parts)
5456 gnus-summary-show-article-charset-alist))
5457 (mm-read-coding-system "Charset: "))))
5458 (if (mm-handle-undisplayer handle)
5459 (mm-remove-part handle)))
5460 (gnus-mime-set-charset-parameters handle charset)
5461 (when (and (consp (setq form (cdr-safe fun)))
5462 (setq form (ignore-errors
5463 (assq 'gnus-mime-display-alternative form)))
5464 (setq preferred (caddr form))
5466 (when (eq (car preferred) 'quote)
5467 (setq preferred (cadr preferred)))
5468 (not (equal preferred
5469 (get-text-property (point) 'gnus-data))))
5470 (setq parts (get-text-property (point) 'gnus-part))
5471 (setq parts (cdr (assq parts
5472 gnus-article-mime-handle-alist)))
5473 (equal (mm-handle-media-type parts) "multipart/alternative")
5474 (setq parts (reverse (cdr parts))))
5476 (list 'quote (or (cadr (member preferred parts))
5478 (funcall fun handle)))))
5480 (defun gnus-mime-view-part-externally (&optional handle)
5481 "View the MIME part under point with an external viewer."
5483 (gnus-article-check-buffer)
5484 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5485 (mm-inlined-types nil)
5486 (mail-parse-charset gnus-newsgroup-charset)
5487 (mail-parse-ignored-charsets
5488 (with-current-buffer gnus-summary-buffer
5489 gnus-newsgroup-ignored-charsets))
5490 (type (mm-handle-media-type handle))
5491 (method (mailcap-mime-info type))
5492 (mm-enable-external t))
5493 (if (not (stringp method))
5494 (gnus-mime-view-part-as-type
5495 nil (lambda (type) (stringp (mailcap-mime-info type))))
5497 (mm-display-part handle nil t)))))
5499 (defun gnus-mime-view-part-internally (&optional handle)
5500 "View the MIME part under point with an internal viewer.
5501 If no internal viewer is available, use an external viewer."
5503 (gnus-article-check-buffer)
5504 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5505 (mm-inlined-types '(".*"))
5506 (mm-inline-large-images t)
5507 (mail-parse-charset gnus-newsgroup-charset)
5508 (mail-parse-ignored-charsets
5509 (with-current-buffer gnus-summary-buffer
5510 gnus-newsgroup-ignored-charsets))
5511 (inhibit-read-only t))
5512 (if (not (mm-inlinable-p handle))
5513 (gnus-mime-view-part-as-type
5514 nil (lambda (type) (mm-inlinable-p handle type)))
5516 (gnus-bind-safe-url-regexp
5517 (mm-display-part handle nil t))))))
5519 (defun gnus-mime-action-on-part (&optional action)
5520 "Do something with the MIME attachment at \(point\)."
5522 (list (gnus-completing-read "Action" (mapcar 'car gnus-mime-action-alist) t)))
5523 (gnus-article-check-buffer)
5524 (let ((action-pair (assoc action gnus-mime-action-alist)))
5526 (funcall (cdr action-pair)))))
5528 (defun gnus-article-part-wrapper (n function &optional no-handle interactive)
5529 "Call FUNCTION on MIME part N.
5530 Unless NO-HANDLE, call FUNCTION with N-th MIME handle as its only argument.
5531 If INTERACTIVE, call FUNCTION interactively."
5533 ;; Check whether the article is displayed.
5534 (unless (and (gnus-buffer-live-p gnus-article-buffer)
5535 (setq window (get-buffer-window gnus-article-buffer t))
5536 (frame-visible-p (setq frame (window-frame window))))
5537 (error "No article is displayed"))
5538 (with-current-buffer gnus-article-buffer
5539 ;; Check whether the article displays the right contents.
5540 (unless (with-current-buffer gnus-summary-buffer
5541 (eq gnus-current-article (gnus-summary-article-number)))
5542 (error "You should select the right article first"))
5544 (setq n (prefix-numeric-value n))
5546 (setq n (or (get-text-property pt 'gnus-part)
5548 (get-text-property (1- pt) 'gnus-part))
5549 (get-text-property (prog2
5555 (or (and (setq pt (previous-single-property-change
5558 (next-single-property-change (point) 'gnus-part)
5562 ;; Check whether the specified part exists.
5563 (when (> n (length gnus-article-mime-handle-alist))
5564 (error "No such part")))
5567 ;; To select the window is needed so that the cursor
5568 ;; might be visible on the MIME button.
5569 (select-window (prog1
5571 (setq window (selected-window))
5572 ;; Article may be displayed in the other frame.
5573 (gnus-select-frame-set-input-focus
5576 (setq frame (selected-frame))))))
5577 (when (gnus-article-goto-part n)
5578 ;; We point the cursor and the arrow at the MIME button
5579 ;; when the `function' prompt the user for something.
5580 (unless (and (pos-visible-in-window-p)
5581 (> (count-lines (point) (window-end))
5582 (/ (1- (window-height)) 3)))
5583 (recenter (/ (1- (window-height)) 3)))
5584 (let ((cursor-in-non-selected-windows t)
5585 (overlay-arrow-string "=>")
5586 (overlay-arrow-position (point-marker)))
5589 ((and no-handle interactive)
5590 (call-interactively function))
5595 function (get-text-property (point) 'gnus-data)))
5598 (get-text-property (point) 'gnus-data))))
5599 (set-marker overlay-arrow-position nil)
5600 (unless gnus-auto-select-part
5601 (gnus-select-frame-set-input-focus frame)
5602 (select-window window))))
5604 (if gnus-inhibit-mime-unbuttonizing
5605 ;; This is the default though the program shouldn't reach here.
5606 (error "No such part")
5607 ;; The part which doesn't have the MIME button is selected.
5608 ;; So, we display all the buttons and redo it.
5609 (let ((gnus-inhibit-mime-unbuttonizing t))
5610 (gnus-summary-show-article)
5611 (gnus-article-part-wrapper n function no-handle))))))
5613 (defun gnus-article-pipe-part (n)
5614 "Pipe MIME part N, which is the numerical prefix."
5616 (gnus-article-part-wrapper n 'mm-pipe-part))
5618 (defun gnus-article-save-part (n)
5619 "Save MIME part N, which is the numerical prefix."
5621 (gnus-article-part-wrapper n 'mm-save-part))
5623 (defun gnus-article-interactively-view-part (n)
5624 "View MIME part N interactively, which is the numerical prefix."
5626 (gnus-article-part-wrapper n 'mm-interactively-view-part))
5628 (defun gnus-article-copy-part (n)
5629 "Copy MIME part N, which is the numerical prefix."
5631 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
5633 (defun gnus-article-view-part-as-charset (n)
5634 "View MIME part N using a specified charset.
5635 N is the numerical prefix."
5637 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
5639 (defun gnus-article-view-part-externally (n)
5640 "View MIME part N externally, which is the numerical prefix."
5642 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
5644 (defun gnus-article-inline-part (n)
5645 "Inline MIME part N, which is the numerical prefix."
5647 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
5649 (defun gnus-article-save-part-and-strip (n)
5650 "Save MIME part N and replace it with an external body.
5651 N is the numerical prefix."
5653 (gnus-article-part-wrapper n 'gnus-mime-save-part-and-strip t))
5655 (defun gnus-article-replace-part (n)
5656 "Replace MIME part N with an external body.
5657 N is the numerical prefix."
5659 (gnus-article-part-wrapper n 'gnus-mime-replace-part t t))
5661 (defun gnus-article-delete-part (n)
5662 "Delete MIME part N and add some information about the removed part.
5663 N is the numerical prefix."
5665 (gnus-article-part-wrapper n 'gnus-mime-delete-part t))
5667 (defun gnus-article-view-part-as-type (n)
5668 "Choose a MIME media type, and view part N as such.
5669 N is the numerical prefix."
5671 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-type t))
5673 (defun gnus-article-mime-match-handle-first (condition)
5676 (dolist (ihandle gnus-article-mime-handle-alist)
5678 ((functionp condition)
5679 (funcall condition (cdr ihandle)))
5680 ((eq condition 'undisplayed)
5681 (not (or (mm-handle-undisplayer (cdr ihandle))
5682 (equal (mm-handle-media-type (cdr ihandle))
5683 "multipart/alternative"))))
5684 ((eq condition 'undisplayed-alternative)
5685 (not (mm-handle-undisplayer (cdr ihandle))))
5687 (gnus-article-goto-part (car ihandle))
5688 (or (not n) (< (car ihandle) n)))
5689 (setq n (car ihandle))))
5693 (defun gnus-article-view-part (&optional n)
5694 "View MIME part N, which is the numerical prefix.
5695 If the part is already shown, hide the part. If N is nil, view
5698 (with-current-buffer gnus-article-buffer
5699 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
5700 gnus-article-mime-match-handle-function)))
5701 (when (> n (length gnus-article-mime-handle-alist))
5702 (error "No such part"))
5703 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
5704 (when (gnus-article-goto-part n)
5705 (if (equal (car handle) "multipart/alternative")
5707 (beginning-of-line) ;; Make it toggle subparts
5708 (gnus-article-press-button))
5709 (when (eq (gnus-mm-display-part handle) 'internal)
5710 (gnus-set-window-start)))))))
5712 (defsubst gnus-article-mime-total-parts ()
5713 (if (bufferp (car gnus-article-mime-handles))
5715 (1- (length gnus-article-mime-handles))))
5717 (defun gnus-mm-display-part (handle)
5718 "Display HANDLE and fix MIME button."
5719 (let ((id (get-text-property (point) 'gnus-part))
5721 (inhibit-read-only t)
5722 (window (selected-window))
5723 (mail-parse-charset gnus-newsgroup-charset)
5724 (mail-parse-ignored-charsets
5725 (if (gnus-buffer-live-p gnus-summary-buffer)
5726 (with-current-buffer gnus-summary-buffer
5727 gnus-newsgroup-ignored-charsets)
5732 (let ((win (gnus-get-buffer-window (current-buffer) t)))
5736 (setq start (next-single-property-change point 'gnus-data
5738 point (previous-single-property-change start 'gnus-data))
5739 (if (mm-handle-displayed-p handle)
5740 ;; This will remove the part.
5741 (setq point (copy-marker point)
5742 retval (mm-display-part handle))
5743 (let ((part (or (and (mm-inlinable-p handle)
5744 (mm-inlined-p handle)
5747 (gnus-bind-safe-url-regexp
5748 (setq retval (mm-display-part handle)))
5749 (unless (zerop (buffer-size))
5750 (buffer-string))))))
5753 ;; This is a header button.
5755 (cond ((stringp part)
5757 (narrow-to-region (point)
5760 (unless (bolp) (insert "\n"))
5762 (gnus-treat-article nil id
5763 (gnus-article-mime-total-parts)
5764 (mm-handle-media-type handle))
5765 (mm-handle-set-undisplayer
5768 (let ((inhibit-read-only t))
5769 (delete-region ,(copy-marker (point-min) t)
5770 ,(point-max-marker)))))))
5772 (mm-display-inline handle))))))
5773 (when (markerp point)
5774 (setq point (prog1 (marker-position point)
5775 (set-marker point nil))))
5777 ;; Toggle the button appearance between `[button]...' and `[button]'.
5778 (let ((displayed-p (mm-handle-displayed-p handle)))
5779 (gnus-insert-mime-button handle id (list displayed-p))
5780 (if (featurep 'emacs)
5783 (next-single-property-change (point) 'gnus-data nil (point-max)))
5784 (let* ((end (next-single-property-change (point) 'gnus-data))
5785 (annots (annotations-at (or end (point-max)))))
5786 (delete-region (point)
5788 (if annots (1+ end) end)
5790 (dolist (annot annots)
5791 (set-extent-endpoints annot (point) (point)))))
5792 (setq start (point))
5793 (if (search-backward "\n\n" nil t)
5796 (unless (or displayed-p (eolp))
5797 ;; Add extra newline.
5798 (insert (propertize (buffer-substring (1- start) start)
5799 'gnus-undeletable t))))
5800 ;; We're in the article header.
5802 (dolist (ovl (gnus-overlays-in point (point)))
5803 (gnus-overlay-put ovl 'gnus-button-attachment-extra t)
5804 (gnus-overlay-put ovl 'face nil))
5806 (message-narrow-to-field)
5807 (let ((gnus-treatment-function-alist
5808 '((gnus-treat-highlight-headers
5809 gnus-article-highlight-headers))))
5810 (gnus-treat-article 'head)))))
5812 (if (window-live-p window)
5813 (select-window window)))
5816 (defun gnus-article-goto-part (n)
5817 "Go to MIME part N."
5818 (when gnus-break-pages
5822 (let ((start (or (text-property-any (point) (point-max) 'gnus-part n)
5823 ;; There may be header buttons.
5824 (text-property-any (point-min) (point) 'gnus-part n)))
5825 part handle end next handles)
5828 (if (setq handle (get-text-property start 'gnus-data))
5830 ;; Go to the displayed subpart, assuming this is
5831 ;; multipart/alternative.
5834 (while (and (not handle)
5837 (setq next (text-property-not-all part end
5840 handle (get-text-property part 'gnus-data))
5841 (push (cons handle part) handles)
5842 (unless (mm-handle-displayed-p handle)
5844 part (text-property-any part end 'gnus-data nil))))
5846 ;; No subpart is displayed, so we find preferred one.
5848 (cdr (assq (mm-preferred-alternative
5849 (nreverse (mapcar 'car handles)))
5852 (goto-char (1+ part))
5854 (when gnus-break-pages
5855 (gnus-narrow-to-page))))
5857 (defun gnus-insert-mime-button (handle id &optional displayed)
5858 (let ((gnus-tmp-name
5859 (or (mm-handle-filename handle)
5860 (mail-content-type-get (mm-handle-type handle) 'url)
5863 (gnus-tmp-type (mm-handle-media-type handle))
5864 (gnus-tmp-description (or (mm-handle-description handle) ""))
5866 (if (if displayed (car displayed)
5867 (mm-handle-displayed-p handle))
5869 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
5871 gnus-tmp-type-long b e)
5872 (when (string-match ".*/" gnus-tmp-name)
5873 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
5874 (setq gnus-tmp-type-long (concat gnus-tmp-type
5875 (and (not (equal gnus-tmp-name ""))
5876 (concat "; " gnus-tmp-name))))
5877 (unless (equal gnus-tmp-description "")
5878 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
5881 gnus-mime-button-line-format gnus-mime-button-line-format-alist
5882 `(keymap ,gnus-mime-button-map
5883 gnus-callback gnus-mm-display-part
5884 gnus-part ,gnus-tmp-id
5885 article-type annotation
5889 ;; Exclude a newline.
5892 (when gnus-article-button-face
5893 (gnus-overlay-put (gnus-make-overlay b e nil t)
5894 'face gnus-article-button-face))
5895 (widget-convert-button
5898 :action 'gnus-widget-press-button
5899 :button-keymap gnus-mime-button-map
5902 ;; Needed to properly clear the message due to a bug in
5903 ;; wid-edit (XEmacs only).
5904 (if (boundp 'help-echo-owns-message)
5905 (setq help-echo-owns-message t))
5907 "%S: %s the MIME part; %S: more options"
5908 (aref gnus-mouse-2 0)
5909 (if (mm-handle-displayed-p (widget-get widget :mime-handle))
5911 (aref gnus-down-mouse-3 0))))))
5913 (defun gnus-widget-press-button (elems _el)
5914 (goto-char (widget-get elems :from))
5915 (gnus-article-press-button))
5917 (defvar gnus-displaying-mime nil)
5919 (defun gnus-display-mime (&optional ihandles)
5920 "Display the MIME parts."
5922 (save-selected-window
5923 (let ((window (get-buffer-window gnus-article-buffer))
5926 (select-window window)
5927 ;; We have to do this since selecting the window
5928 ;; may change the point. So we set the window point.
5929 (set-window-point window point)))
5930 (let ((handles ihandles)
5931 (inhibit-read-only t))
5933 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
5934 (when gnus-article-emulate-mime
5935 (mm-uu-dissect-text-parts handles)))
5936 (gnus-article-emulate-mime
5937 (setq handles (mm-uu-dissect))))
5938 (when (and (not ihandles)
5939 (not gnus-displaying-mime))
5940 ;; Top-level call; we clean up.
5941 (when gnus-article-mime-handles
5942 (mm-destroy-parts gnus-article-mime-handles)
5943 (setq gnus-article-mime-handle-alist nil));; A trick.
5944 (setq gnus-article-mime-handles handles)
5945 ;; We allow users to glean info from the handles.
5946 (when gnus-article-mime-part-function
5947 (gnus-mime-part-function handles)))
5949 (or (not (stringp (car handles)))
5952 (when (and (not ihandles)
5953 (not gnus-displaying-mime))
5954 ;; Clean up for mime parts.
5956 (delete-region (point) (point-max)))
5957 (let ((gnus-displaying-mime t))
5958 (gnus-mime-display-part handles)))
5961 (narrow-to-region (point) (point-max))
5962 (gnus-treat-article nil 1 1 "text/plain")
5965 ;; Highlight the headers.
5969 (narrow-to-region (point-min) (point))
5970 (gnus-article-save-original-date
5971 (gnus-treat-article 'head)))))))
5972 ;; Cope with broken MIME messages.
5973 (goto-char (point-max))
5977 (defcustom gnus-mime-display-multipart-as-mixed nil
5978 "Display \"multipart\" parts as \"multipart/mixed\".
5980 If t, it overrides nil values of
5981 `gnus-mime-display-multipart-alternative-as-mixed' and
5982 `gnus-mime-display-multipart-related-as-mixed'."
5983 :group 'gnus-article-mime
5986 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
5987 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
5989 :group 'gnus-article-mime
5992 (defcustom gnus-mime-display-multipart-related-as-mixed nil
5993 "Display \"multipart/related\" parts as \"multipart/mixed\".
5995 If displaying \"text/html\" is discouraged \(see
5996 `mm-discouraged-alternatives'\) images or other material inside a
5997 \"multipart/related\" part might be overlooked when this variable is nil."
5999 :group 'gnus-article-mime
6002 (defcustom gnus-mime-display-attachment-buttons-in-header t
6003 "Add attachment buttons in the end of the header of an article.
6004 Since MIME attachments tend to be put at the end of an article, we may
6005 overlook them if there is a huge body. This option offers you a copy
6006 of all non-inlinable MIME parts as buttons shown in front of an article.
6007 If nil, don't show those extra buttons."
6009 :group 'gnus-article-mime
6012 (defun gnus-mime-display-part (handle)
6014 ;; Maybe a broken MIME message.
6017 ((not (stringp (car handle)))
6018 (gnus-mime-display-single handle))
6019 ;; User-defined multipart
6020 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
6021 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
6023 ;; multipart/alternative
6024 ((and (equal (car handle) "multipart/alternative")
6025 (not (or gnus-mime-display-multipart-as-mixed
6026 gnus-mime-display-multipart-alternative-as-mixed)))
6027 (let ((id (1+ (length gnus-article-mime-handle-alist))))
6028 (push (cons id handle) gnus-article-mime-handle-alist)
6029 (gnus-mime-display-alternative (cdr handle) nil nil id)))
6030 ;; multipart/related
6031 ((and (equal (car handle) "multipart/related")
6032 (not (or gnus-mime-display-multipart-as-mixed
6033 gnus-mime-display-multipart-related-as-mixed)))
6034 (gnus-mime-display-part (cadr handle)))
6035 ((equal (car handle) "multipart/signed")
6036 (gnus-add-wash-type 'signed)
6037 (gnus-mime-display-security handle))
6038 ((equal (car handle) "multipart/encrypted")
6039 (gnus-add-wash-type 'encrypted)
6040 (gnus-mime-display-security handle))
6041 ;; Other multiparts are handled like multipart/mixed.
6043 (gnus-mime-display-mixed (cdr handle)))))
6045 (defun gnus-mime-part-function (handles)
6046 (if (stringp (car handles))
6047 (mapcar 'gnus-mime-part-function (cdr handles))
6048 (funcall gnus-article-mime-part-function handles)))
6050 (defun gnus-mime-display-mixed (handles)
6051 (mapcar 'gnus-mime-display-part handles))
6053 (defun gnus-mime-display-single (handle)
6054 (let ((type (mm-handle-media-type handle))
6055 (ignored gnus-ignored-mime-types)
6061 (when (string-match (pop ignored) type)
6062 (throw 'ignored nil)))
6063 (if (and (not (and (if (gnus-buffer-live-p gnus-summary-buffer)
6064 (with-current-buffer gnus-summary-buffer
6065 gnus-inhibit-images)
6066 gnus-inhibit-images)
6067 (string-match "\\`image/" type)))
6068 (setq not-attachment
6069 (and (not (mm-inline-override-p handle))
6070 (or (not (mm-handle-disposition handle))
6071 (equal (car (mm-handle-disposition handle))
6073 (mm-attachment-override-p handle))))
6074 (mm-automatic-display-p handle)
6076 (mm-inlinable-p handle)
6077 (mm-inlined-p handle))
6078 (mm-automatic-external-display-p type)))
6080 (when (equal (mm-handle-media-supertype handle) "text")
6082 (let ((id (car (rassq handle gnus-article-mime-handle-alist)))
6085 (setq id (1+ (length gnus-article-mime-handle-alist)))
6086 (push (cons id handle) gnus-article-mime-handle-alist))
6088 (equal (mm-handle-media-supertype handle) "message"))
6091 (cond ((not (bolp)) 2)
6092 ((or (bobp) (eq (char-before (1- (point))) ?\n)) 0)
6094 (when (or (not display)
6095 (not (gnus-unbuttonized-mime-type-p type))
6096 (eq id gnus-mime-buttonized-part-id))
6097 (gnus-insert-mime-button
6098 handle id (list (or display (and not-attachment text)))))
6102 (let ((mail-parse-charset gnus-newsgroup-charset)
6103 (mail-parse-ignored-charsets
6104 (save-excursion (condition-case ()
6105 (set-buffer gnus-summary-buffer)
6107 gnus-newsgroup-ignored-charsets)))
6108 (gnus-bind-safe-url-regexp (mm-display-part handle t))))
6109 ((and text not-attachment)
6110 (mm-display-inline handle)))
6111 (goto-char (point-max))
6112 (if (string-match "\\`image/" type)
6113 (gnus-article-insert-newline)
6115 (= (skip-chars-backward "\n") -1)
6116 (unless (eobp) (forward-char 1)))
6117 (gnus-article-insert-newline)
6118 (put-text-property (point) (point-max) 'gnus-undeletable t))
6119 (goto-char (point-max)))
6123 (narrow-to-region beg (point))
6124 (if (eq handle gnus-article-mime-handles)
6125 ;; The format=flowed case.
6126 (gnus-treat-article nil 1 1 (mm-handle-media-type handle))
6127 ;; Don't count signature parts that are never displayed.
6128 ;; The part number should be re-calculated supposing this
6129 ;; might be a message/rfc822 part.
6131 (dolist (part gnus-article-mime-handles)
6132 (unless (or (stringp part)
6133 (equal (car (mm-handle-type part))
6134 "application/pgp-signature"))
6135 (push part handles)))
6137 nil (length (memq handle handles)) (length handles)
6138 (mm-handle-media-type handle)))))))))))
6140 (defun gnus-unbuttonized-mime-type-p (type)
6141 "Say whether TYPE is to be unbuttonized."
6142 (unless gnus-inhibit-mime-unbuttonizing
6144 (let ((types gnus-unbuttonized-mime-types))
6146 (when (string-match (pop types) type)
6147 (throw 'found t)))))
6149 (let ((types gnus-buttonized-mime-types))
6151 (when (string-match (pop types) ty