1 ;;; gnus-art.el --- article mode commands for Gnus
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006 Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
33 (defvar w3m-minor-mode-map))
36 ;; Avoid the "Recursive load suspected" error in Emacs 21.1.
38 (let ((recursive-load-depth-limit 100))
51 (autoload 'gnus-msg-mail "gnus-msg" nil t)
52 (autoload 'gnus-button-mailto "gnus-msg")
53 (autoload 'gnus-button-reply "gnus-msg" nil t)
54 (autoload 'parse-time-string "parse-time" nil nil)
55 (autoload 'ansi-color-apply-on-region "ansi-color")
56 (autoload 'mm-url-insert-file-contents-external "mm-url")
57 (autoload 'mm-extern-cache-contents "mm-extern")
59 (defgroup gnus-article nil
61 :link '(custom-manual "(gnus)Article Buffer")
64 (defgroup gnus-article-treat nil
65 "Treating article parts."
66 :link '(custom-manual "(gnus)Article Hiding")
69 (defgroup gnus-article-hiding nil
70 "Hiding article parts."
71 :link '(custom-manual "(gnus)Article Hiding")
74 (defgroup gnus-article-highlight nil
75 "Article highlighting."
76 :link '(custom-manual "(gnus)Article Highlighting")
80 (defgroup gnus-article-signature nil
82 :link '(custom-manual "(gnus)Article Signature")
85 (defgroup gnus-article-headers nil
87 :link '(custom-manual "(gnus)Hiding Headers")
90 (defgroup gnus-article-washing nil
91 "Special commands on articles."
92 :link '(custom-manual "(gnus)Article Washing")
95 (defgroup gnus-article-emphasis nil
96 "Fontisizing articles."
97 :link '(custom-manual "(gnus)Article Fontisizing")
100 (defgroup gnus-article-saving nil
102 :link '(custom-manual "(gnus)Saving Articles")
103 :group 'gnus-article)
105 (defgroup gnus-article-mime nil
106 "Worshiping the MIME wonder."
107 :link '(custom-manual "(gnus)Using MIME")
108 :group 'gnus-article)
110 (defgroup gnus-article-buttons nil
111 "Pushable buttons in the article buffer."
112 :link '(custom-manual "(gnus)Article Buttons")
113 :group 'gnus-article)
115 (defgroup gnus-article-various nil
116 "Other article options."
117 :link '(custom-manual "(gnus)Misc Article")
118 :group 'gnus-article)
120 (defcustom gnus-ignored-headers
123 (concat "^" header ":"))
124 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
125 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
126 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
127 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
128 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
129 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
130 "X-Attribution" "X-Originating-IP" "Delivered-To"
131 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
132 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
133 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
134 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
135 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
136 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
137 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
138 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
139 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
140 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
141 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
142 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
143 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
144 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
145 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
146 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
147 "List-[A-Za-z]+" "X-Listprocessor-Version"
148 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
149 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
150 "X-Received" "Content-length" "X-precedence"
151 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
152 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
153 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
154 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
155 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
156 "X-Content-length" "X-Posting-Agent" "Original-Received"
157 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
158 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
159 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
160 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
161 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"
162 "Envelope-To" "X-Spam-Score" "System-Type" "X-Injected-Via-Gmane"
163 "X-Gmane-NNTP-Posting-Host" "Jabber-ID" "Archived-At"
164 "Envelope-Sender" "Envelope-Recipients"))
165 "*All headers that start with this regexp will be hidden.
166 This variable can also be a list of regexps of headers to be ignored.
167 If `gnus-visible-headers' is non-nil, this variable will be ignored."
168 :type '(choice :custom-show nil
171 :group 'gnus-article-hiding)
173 (defcustom gnus-visible-headers
174 "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^[BGF]?Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Mail-Followup-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:\\|^X-Sent:"
175 "*All headers that do not match this regexp will be hidden.
176 This variable can also be a list of regexp of headers to remain visible.
177 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
178 :type '(repeat :value-to-internal (lambda (widget value)
179 (custom-split-regexp-maybe value))
180 :match (lambda (widget value)
182 (widget-editable-list-match widget value)))
184 :group 'gnus-article-hiding)
186 (defcustom gnus-sorted-header-list
187 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
188 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
189 "*This variable is a list of regular expressions.
190 If it is non-nil, headers that match the regular expressions will
191 be placed first in the article buffer in the sequence specified by
193 :type '(repeat regexp)
194 :group 'gnus-article-hiding)
196 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
197 "Headers that are only to be displayed if they have interesting data.
198 Possible values in this list are:
200 'empty Headers with no content.
201 'newsgroups Newsgroup identical to Gnus group.
202 'to-address To identical to To-address.
203 'to-list To identical to To-list.
204 'cc-list CC identical to To-list.
205 'followup-to Followup-to identical to Newsgroups.
206 'reply-to Reply-to identical to From.
207 'date Date less than four days old.
208 'long-to To and/or Cc longer than 1024 characters.
209 'many-to Multiple To and/or Cc."
210 :type '(set (const :tag "Headers with no content." empty)
211 (const :tag "Newsgroups identical to Gnus group." newsgroups)
212 (const :tag "To identical to To-address." to-address)
213 (const :tag "To identical to To-list." to-list)
214 (const :tag "CC identical to To-list." cc-list)
215 (const :tag "Followup-to identical to Newsgroups." followup-to)
216 (const :tag "Reply-to identical to From." reply-to)
217 (const :tag "Date less than four days old." date)
218 (const :tag "To and/or Cc longer than 1024 characters." long-to)
219 (const :tag "Multiple To and/or Cc headers." many-to))
220 :group 'gnus-article-hiding)
222 (defcustom gnus-article-skip-boring nil
223 "Skip over text that is not worth reading.
224 By default, if you set this t, then Gnus will display citations and
225 signatures, but will never scroll down to show you a page consisting
226 only of boring text. Boring text is controlled by
227 `gnus-article-boring-faces'."
230 :group 'gnus-article-hiding)
232 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
233 "Regexp matching signature separator.
234 This can also be a list of regexps. In that case, it will be checked
235 from head to tail looking for a separator. Searches will be done from
236 the end of the buffer."
237 :type '(choice :format "%{%t%}: %[Value Menu%]\n%v"
239 (repeat :tag "List of regexp" regexp))
240 :group 'gnus-article-signature)
242 (defcustom gnus-signature-limit nil
243 "Provide a limit to what is considered a signature.
244 If it is a number, no signature may not be longer (in characters) than
245 that number. If it is a floating point number, no signature may be
246 longer (in lines) than that number. If it is a function, the function
247 will be called without any parameters, and if it returns nil, there is
248 no signature in the buffer. If it is a string, it will be used as a
249 regexp. If it matches, the text in question is not a signature.
251 This can also be a list of the above values."
252 :type '(choice (const nil)
255 (function :value fun)
256 (regexp :value ".*"))
257 :group 'gnus-article-signature)
259 (defcustom gnus-hidden-properties '(invisible t intangible t)
260 "Property list to use for hiding text."
262 :group 'gnus-article-hiding)
264 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
265 ;; frames in a session.
266 (defcustom gnus-article-x-face-command
267 (if (featurep 'xemacs)
268 (if (or (gnus-image-type-available-p 'xface)
269 (gnus-image-type-available-p 'pbm))
270 'gnus-display-x-face-in-from
271 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
272 (if (gnus-image-type-available-p 'pbm)
273 'gnus-display-x-face-in-from
274 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
276 "*String or function to be executed to display an X-Face header.
277 If it is a string, the command will be executed in a sub-shell
278 asynchronously. The compressed face will be piped to this command."
279 :type `(choice string
280 (function-item gnus-display-x-face-in-from)
284 :group 'gnus-article-washing)
286 (defcustom gnus-article-x-face-too-ugly nil
287 "Regexp matching posters whose face shouldn't be shown automatically."
288 :type '(choice regexp (const nil))
289 :group 'gnus-article-washing)
291 (defcustom gnus-article-banner-alist nil
292 "Banner alist for stripping.
294 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
296 :type '(repeat (cons symbol regexp))
297 :group 'gnus-article-washing)
299 (gnus-define-group-parameter
302 "Alist of regexps (to match group names) and banner."
303 :variable-group gnus-article-washing
305 '(choice :tag "Banner"
307 (const :tag "Remove signature" signature)
308 (symbol :tag "Item in `gnus-article-banner-alist'" none)
310 (const :tag "None" nil))
312 "If non-nil, specify how to remove `banners' from articles.
314 Symbol `signature' means to remove signatures delimited by
315 `gnus-signature-separator'. Any other symbol is used to look up a
316 regular expression to match the banner in `gnus-article-banner-alist'.
317 A string is used as a regular expression to match the banner
320 (defcustom gnus-article-address-banner-alist nil
321 "Alist of mail addresses and banners.
322 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
323 to match a mail address in the From: header, BANNER is one of a symbol
324 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
325 If ADDRESS matches author's mail address, it will remove things like
326 advertisements. For example:
328 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
332 (regexp :tag "Address")
333 (choice :tag "Banner" :value nil
334 (const :tag "Remove signature" signature)
335 (symbol :tag "Item in `gnus-article-banner-alist'" none)
337 (const :tag "None" nil))))
339 :group 'gnus-article-washing)
341 (defmacro gnus-emphasis-custom-with-format (&rest body)
343 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
344 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
347 (defun gnus-emphasis-custom-value-to-external (value)
348 (gnus-emphasis-custom-with-format
349 (if (consp (car value))
350 (list (format format (car (car value)) (cdr (car value)))
352 (if (nth 1 value) 2 3)
356 (defun gnus-emphasis-custom-value-to-internal (value)
357 (gnus-emphasis-custom-with-format
358 (let ((regexp (concat "\\`"
359 (format (regexp-quote format)
360 "\\([^()]+\\)" "\\([^()]+\\)")
363 (if (string-match regexp (setq pattern (car value)))
364 (list (cons (match-string 1 pattern) (match-string 2 pattern))
369 (defcustom gnus-emphasis-alist
371 '(("\\*" "\\*" bold nil 2)
374 ("_/" "/_" underline-italic)
375 ("_\\*" "\\*_" underline-bold)
376 ("\\*/" "/\\*" bold-italic)
377 ("_\\*/" "/\\*_" underline-bold-italic))))
379 (gnus-emphasis-custom-with-format
380 (mapcar (lambda (spec)
381 (list (format format (car spec) (cadr spec))
384 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
386 '(;; I've never seen anyone use this strikethru convention whereas I've
387 ;; several times seen it triggered by normal text. --Stef
388 ;; Miles suggests that this form is sometimes used but for italics,
389 ;; so maybe we should map it to `italic'.
390 ;; ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
391 ;; 2 3 gnus-emphasis-strikethru)
392 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
393 2 3 gnus-emphasis-underline))))
394 "*Alist that says how to fontify certain phrases.
395 Each item looks like this:
397 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
399 The first element is a regular expression to be matched. The second
400 is a number that says what regular expression grouping used to find
401 the entire emphasized word. The third is a number that says what
402 regexp grouping should be displayed and highlighted. The fourth
403 is the face used for highlighting."
407 :format "%[Customizing Style%]\n%v"
409 (group :tag "Default"
410 :value ("" 0 0 default)
413 (let ((value (widget-get
414 (cadr (widget-get (widget-get widget :parent)
417 (if (not (eq (nth 2 value) 'default))
421 (gnus-emphasis-custom-value-to-external value))))
422 (widget-group-value-create widget))
424 (integer :format "Match group: %v")
425 (integer :format "Emphasize group: %v")
428 :value (("_" . "_") nil default)
430 (regexp :format "Start regexp: %v")
431 (regexp :format "End regexp: %v"))
432 (boolean :format "Show start and end patterns: %[%v%]\n"
433 :on " On " :off " Off ")
435 :get (lambda (symbol)
436 (mapcar 'gnus-emphasis-custom-value-to-internal
437 (default-value symbol)))
438 :set (lambda (symbol value)
439 (set-default symbol (mapcar 'gnus-emphasis-custom-value-to-external
441 :group 'gnus-article-emphasis)
443 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
444 "A regexp to describe whitespace which should not be emphasized.
445 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
446 The former avoids underlining of leading and trailing whitespace,
447 and the latter avoids underlining any whitespace at all."
449 :group 'gnus-article-emphasis
452 (defface gnus-emphasis-bold '((t (:bold t)))
453 "Face used for displaying strong emphasized text (*word*)."
454 :group 'gnus-article-emphasis)
456 (defface gnus-emphasis-italic '((t (:italic t)))
457 "Face used for displaying italic emphasized text (/word/)."
458 :group 'gnus-article-emphasis)
460 (defface gnus-emphasis-underline '((t (:underline t)))
461 "Face used for displaying underlined emphasized text (_word_)."
462 :group 'gnus-article-emphasis)
464 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
465 "Face used for displaying underlined bold emphasized text (_*word*_)."
466 :group 'gnus-article-emphasis)
468 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
469 "Face used for displaying underlined italic emphasized text (_/word/_)."
470 :group 'gnus-article-emphasis)
472 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
473 "Face used for displaying bold italic emphasized text (/*word*/)."
474 :group 'gnus-article-emphasis)
476 (defface gnus-emphasis-underline-bold-italic
477 '((t (:bold t :italic t :underline t)))
478 "Face used for displaying underlined bold italic emphasized text.
479 Example: (_/*word*/_)."
480 :group 'gnus-article-emphasis)
482 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
483 '((t (:strikethru t)))
484 '((t (:strike-through t))))
485 "Face used for displaying strike-through text (-word-)."
486 :group 'gnus-article-emphasis)
488 (defface gnus-emphasis-highlight-words
489 '((t (:background "black" :foreground "yellow")))
490 "Face used for displaying highlighted words."
491 :group 'gnus-article-emphasis)
493 (defcustom gnus-article-time-format "%a, %d %b %Y %T %Z"
494 "Format for display of Date headers in article bodies.
495 See `format-time-string' for the possible values.
497 The variable can also be function, which should return a complete Date
498 header. The function is called with one argument, the time, which can
499 be fed to `format-time-string'."
500 :type '(choice string function)
501 :link '(custom-manual "(gnus)Article Date")
502 :group 'gnus-article-washing)
504 (defcustom gnus-save-all-headers t
505 "*If non-nil, don't remove any headers before saving.
506 This will be overridden by the `:headers' property that the symbol of
507 the saver function, which is specified by `gnus-default-article-saver',
509 :group 'gnus-article-saving
512 (defcustom gnus-prompt-before-saving 'always
513 "*This variable says how much prompting is to be done when saving articles.
514 If it is nil, no prompting will be done, and the articles will be
515 saved to the default files. If this variable is `always', each and
516 every article that is saved will be preceded by a prompt, even when
517 saving large batches of articles. If this variable is neither nil not
518 `always', there the user will be prompted once for a file name for
519 each invocation of the saving commands."
520 :group 'gnus-article-saving
521 :type '(choice (item always)
522 (item :tag "never" nil)
523 (sexp :tag "once" :format "%t\n" :value t)))
525 (defcustom gnus-saved-headers gnus-visible-headers
526 "Headers to keep if `gnus-save-all-headers' is nil.
527 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
528 If that variable is nil, however, all headers that match this regexp
529 will be kept while the rest will be deleted before saving. This and
530 `gnus-save-all-headers' will be overridden by the `:headers' property
531 that the symbol of the saver function, which is specified by
532 `gnus-default-article-saver', might have."
533 :group 'gnus-article-saving
536 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
537 "A function to save articles in your favourite format.
538 The function will be called by way of the `gnus-summary-save-article'
539 command, and friends such as `gnus-summary-save-article-rmail'.
541 Gnus provides the following functions:
543 * gnus-summary-save-in-rmail (Rmail format)
544 * gnus-summary-save-in-mail (Unix mail format)
545 * gnus-summary-save-in-folder (MH folder)
546 * gnus-summary-save-in-file (article format)
547 * gnus-summary-save-body-in-file (article body)
548 * gnus-summary-save-in-vm (use VM's folder format)
549 * gnus-summary-write-to-file (article format -- overwrite)
550 * gnus-summary-write-body-to-file (article body -- overwrite)
552 The symbol of each function may have the following properties:
555 The value non-nil means save decoded articles. This is meaningful
556 only with `gnus-summary-save-in-file', `gnus-summary-save-body-in-file',
557 `gnus-summary-write-to-file', and `gnus-summary-write-body-to-file'.
560 The value specifies an alternative function which appends, not
561 overwrites, articles to a file. This implies that when saving many
562 articles at a time, `gnus-prompt-before-saving' is bound to t and all
563 articles are saved in a single file. This is meaningful only with
564 `gnus-summary-write-to-file' and `gnus-summary-write-body-to-file'.
567 The value specifies the symbol of a variable of which the value
568 specifies headers to be saved. If it is omitted,
569 `gnus-save-all-headers' and `gnus-saved-headers' control what
570 headers should be saved."
571 :group 'gnus-article-saving
572 :type '(radio (function-item gnus-summary-save-in-rmail)
573 (function-item gnus-summary-save-in-mail)
574 (function-item gnus-summary-save-in-folder)
575 (function-item gnus-summary-save-in-file)
576 (function-item gnus-summary-save-body-in-file)
577 (function-item gnus-summary-save-in-vm)
578 (function-item gnus-summary-write-to-file)
579 (function-item gnus-summary-write-body-to-file)
582 (defcustom gnus-article-save-coding-system
583 (or (and (mm-coding-system-p 'utf-8) 'utf-8)
584 (and (mm-coding-system-p 'iso-2022-7bit) 'iso-2022-7bit)
585 (and (mm-coding-system-p 'emacs-mule) 'emacs-mule)
586 (and (mm-coding-system-p 'escape-quoted) 'escape-quoted))
587 "Coding system used to save decoded articles to a file.
589 The recommended coding systems are `utf-8', `iso-2022-7bit' and so on,
590 which can safely encode any characters in text. This is used by the
593 * gnus-summary-save-article-file
594 * gnus-summary-save-article-body-file
595 * gnus-summary-write-article-file
596 * gnus-summary-write-article-body-file
598 and the functions to which you may set `gnus-default-article-saver':
600 * gnus-summary-save-in-file
601 * gnus-summary-save-body-in-file
602 * gnus-summary-write-to-file
603 * gnus-summary-write-body-to-file
605 Those commands and functions save just text displayed in the article
606 buffer to a file if the value of this variable is non-nil. Note that
607 buttonized MIME parts will be lost in a saved file in that case.
608 Otherwise, raw articles will be saved."
609 :group 'gnus-article-saving
611 :format "%{%t%}:\n %[Value Menu%] %v"
612 (const :tag "Save raw articles" nil)
615 (lambda (arg) (if (mm-coding-system-p (nth 3 arg)) arg))
616 '((const :tag "UTF-8" utf-8)
617 (const :tag "iso-2022-7bit" iso-2022-7bit)
618 (const :tag "Emacs internal" emacs-mule)
619 (const :tag "escape-quoted" escape-quoted))))
620 (symbol :tag "Coding system")))
622 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
623 "A function generating a file name to save articles in Rmail format.
624 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
625 :group 'gnus-article-saving
628 (defcustom gnus-mail-save-name 'gnus-plain-save-name
629 "A function generating a file name to save articles in Unix mail format.
630 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
631 :group 'gnus-article-saving
634 (defcustom gnus-folder-save-name 'gnus-folder-save-name
635 "A function generating a file name to save articles in MH folder.
636 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
637 :group 'gnus-article-saving
640 (defcustom gnus-file-save-name 'gnus-numeric-save-name
641 "A function generating a file name to save articles in article format.
642 The function is called with NEWSGROUP, HEADERS, and optional
644 :group 'gnus-article-saving
647 (defcustom gnus-split-methods
648 '((gnus-article-archive-name)
649 (gnus-article-nndoc-name))
650 "*Variable used to suggest where articles are to be saved.
651 For instance, if you would like to save articles related to Gnus in
652 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
653 you could set this variable to something like:
655 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
656 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
658 This variable is an alist where the key is the match and the
659 value is a list of possible files to save in if the match is
662 If the match is a string, it is used as a regexp match on the
663 article. If the match is a symbol, that symbol will be funcalled
664 from the buffer of the article to be saved with the newsgroup as
665 the parameter. If it is a list, it will be evaled in the same
668 If this form or function returns a string, this string will be
669 used as a possible file name; and if it returns a non-nil list,
670 that list will be used as possible file names."
671 :group 'gnus-article-saving
672 :type '(repeat (choice (list :value (fun) function)
673 (cons :value ("" "") regexp (repeat string))
676 (defcustom gnus-page-delimiter "^\^L"
677 "*Regexp describing what to use as article page delimiters.
678 The default value is \"^\^L\", which is a form linefeed at the
679 beginning of a line."
681 :group 'gnus-article-various)
683 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
684 "*The format specification for the article mode line.
685 See `gnus-summary-mode-line-format' for a closer description.
687 The following additional specs are available:
689 %w The article washing status.
690 %m The number of MIME parts in the article."
692 :group 'gnus-article-various)
694 (defcustom gnus-article-mode-hook nil
695 "*A hook for Gnus article mode."
697 :group 'gnus-article-various)
699 (when (featurep 'xemacs)
700 ;; Extracted from gnus-xmas-define in order to preserve user settings
701 (when (fboundp 'turn-off-scroll-in-place)
702 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
703 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
704 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
706 (defcustom gnus-article-menu-hook nil
707 "*Hook run after the creation of the article mode menu."
709 :group 'gnus-article-various)
711 (defcustom gnus-article-prepare-hook nil
712 "*A hook called after an article has been prepared in the article buffer."
714 :group 'gnus-article-various)
716 (defcustom gnus-copy-article-ignored-headers nil
717 "List of headers to be removed when copying an article.
718 Each element is a regular expression."
719 :version "23.0" ;; No Gnus
720 :type '(repeat regexp)
721 :group 'gnus-article-various)
723 (make-obsolete-variable 'gnus-article-hide-pgp-hook
724 "This variable is obsolete in Gnus 5.10.")
727 '((t (:weight bold)))
728 "Face used for highlighting a button in the article buffer."
729 :group 'gnus-article-buttons)
731 (defcustom gnus-article-button-face 'gnus-button
732 "Face used for highlighting buttons in the article buffer.
734 An article button is a piece of text that you can activate by pressing
735 `RET' or `mouse-2' above it."
737 :group 'gnus-article-buttons)
739 (defcustom gnus-article-mouse-face 'highlight
740 "Face used for mouse highlighting in the article buffer.
742 Article buttons will be displayed in this face when the cursor is
745 :group 'gnus-article-buttons)
747 (defcustom gnus-signature-face 'gnus-signature
748 "Face used for highlighting a signature in the article buffer.
749 Obsolete; use the face `gnus-signature' for customizations instead."
751 :group 'gnus-article-highlight
752 :group 'gnus-article-signature)
754 (defface gnus-signature
757 "Face used for highlighting a signature in the article buffer."
758 :group 'gnus-article-highlight
759 :group 'gnus-article-signature)
760 ;; backward-compatibility alias
761 (put 'gnus-signature-face 'face-alias 'gnus-signature)
763 (defface gnus-header-from
766 (:foreground "spring green"))
769 (:foreground "red3"))
772 "Face used for displaying from headers."
773 :group 'gnus-article-headers
774 :group 'gnus-article-highlight)
775 ;; backward-compatibility alias
776 (put 'gnus-header-from-face 'face-alias 'gnus-header-from)
778 (defface gnus-header-subject
781 (:foreground "SeaGreen3"))
784 (:foreground "red4"))
786 (:bold t :italic t)))
787 "Face used for displaying subject headers."
788 :group 'gnus-article-headers
789 :group 'gnus-article-highlight)
790 ;; backward-compatibility alias
791 (put 'gnus-header-subject-face 'face-alias 'gnus-header-subject)
793 (defface gnus-header-newsgroups
796 (:foreground "yellow" :italic t))
799 (:foreground "MidnightBlue" :italic t))
802 "Face used for displaying newsgroups headers.
803 In the default setup this face is only used for crossposted
805 :group 'gnus-article-headers
806 :group 'gnus-article-highlight)
807 ;; backward-compatibility alias
808 (put 'gnus-header-newsgroups-face 'face-alias 'gnus-header-newsgroups)
810 (defface gnus-header-name
813 (:foreground "SeaGreen"))
816 (:foreground "maroon"))
819 "Face used for displaying header names."
820 :group 'gnus-article-headers
821 :group 'gnus-article-highlight)
822 ;; backward-compatibility alias
823 (put 'gnus-header-name-face 'face-alias 'gnus-header-name)
825 (defface gnus-header-content
828 (:foreground "forest green" :italic t))
831 (:foreground "indianred4" :italic t))
833 (:italic t))) "Face used for displaying header content."
834 :group 'gnus-article-headers
835 :group 'gnus-article-highlight)
836 ;; backward-compatibility alias
837 (put 'gnus-header-content-face 'face-alias 'gnus-header-content)
839 (defcustom gnus-header-face-alist
840 '(("From" nil gnus-header-from)
841 ("Subject" nil gnus-header-subject)
842 ("Newsgroups:.*," nil gnus-header-newsgroups)
843 ("" gnus-header-name gnus-header-content))
844 "*Controls highlighting of article headers.
846 An alist of the form (HEADER NAME CONTENT).
848 HEADER is a regular expression which should match the name of a
849 header and NAME and CONTENT are either face names or nil.
851 The name of each header field will be displayed using the face
852 specified by the first element in the list where HEADER matches
853 the header name and NAME is non-nil. Similarly, the content will
854 be displayed by the first non-nil matching CONTENT face."
855 :group 'gnus-article-headers
856 :group 'gnus-article-highlight
857 :type '(repeat (list (regexp :tag "Header")
859 (item :tag "skip" nil)
860 (face :value default))
861 (choice :tag "Content"
862 (item :tag "skip" nil)
863 (face :value default)))))
865 (defcustom gnus-face-properties-alist (if (featurep 'xemacs)
866 '((xface . (:face gnus-x-face)))
867 '((pbm . (:face gnus-x-face))
869 "Alist of image types and properties applied to Face and X-Face images.
872 ;; Specify the altitude of Face images in the From header.
873 \(setq gnus-face-properties-alist
874 '((pbm . (:face gnus-x-face :ascent 80))
875 (png . (:ascent 80))))
877 ;; Show Face images as pressed buttons.
878 \(setq gnus-face-properties-alist
879 '((pbm . (:face gnus-x-face :relief -2))
880 (png . (:relief -2))))
882 See the manual for the valid properties for various image types.
883 Currently, `pbm' is used for X-Face images and `png' is used for Face
884 images in Emacs. Only the `:face' property is effective on the `xface'
885 image type in XEmacs if it is built with the libcompface library."
886 :version "23.0" ;; No Gnus
887 :group 'gnus-article-headers
888 :type '(repeat (cons :format "%v" (symbol :tag "Image type") plist)))
890 (defcustom gnus-article-decode-hook
891 '(article-decode-charset article-decode-encoded-words
892 article-decode-group-name article-decode-idna-rhs)
893 "*Hook run to decode charsets in articles."
894 :group 'gnus-article-headers
897 (defcustom gnus-display-mime-function 'gnus-display-mime
898 "Function to display MIME articles."
899 :group 'gnus-article-mime
902 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
903 "Function used to decode headers.")
905 (defvar gnus-article-dumbquotes-map
925 "Table for MS-to-Latin1 translation.")
927 (defcustom gnus-ignored-mime-types nil
928 "List of MIME types that should be ignored by Gnus."
930 :group 'gnus-article-mime
931 :type '(repeat regexp))
933 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
934 "List of MIME types that should not be given buttons when rendered inline.
935 See also `gnus-buttonized-mime-types' which may override this variable.
936 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
938 :group 'gnus-article-mime
939 :type '(repeat regexp))
941 (defcustom gnus-buttonized-mime-types nil
942 "List of MIME types that should be given buttons when rendered inline.
943 If set, this variable overrides `gnus-unbuttonized-mime-types'.
944 To see e.g. security buttons you could set this to
945 `(\"multipart/signed\")'. You could also add \"multipart/alternative\" to
946 this list to display radio buttons that allow you to choose one of two
947 media types those mails include. See also `mm-discouraged-alternatives'.
948 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
950 :group 'gnus-article-mime
951 :type '(repeat regexp))
953 (defcustom gnus-inhibit-mime-unbuttonizing nil
954 "If non-nil, all MIME parts get buttons.
955 When nil (the default value), then some MIME parts do not get buttons,
956 as described by the variables `gnus-buttonized-mime-types' and
957 `gnus-unbuttonized-mime-types'."
959 :group 'gnus-article-mime
962 (defcustom gnus-body-boundary-delimiter "_"
963 "String used to delimit header and body.
964 This variable is used by `gnus-article-treat-body-boundary' which can
965 be controlled by `gnus-treat-body-boundary'."
967 :group 'gnus-article-various
968 :type '(choice (item :tag "None" :value nil)
971 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
973 "Defines the location of the faces database.
974 For information on obtaining this database of pretty pictures, please
975 see http://www.cs.indiana.edu/picons/ftp/index.html"
977 :type '(repeat directory)
978 :link '(url-link :tag "download"
979 "http://www.cs.indiana.edu/picons/ftp/index.html")
980 :link '(custom-manual "(gnus)Picons")
983 (defun gnus-picons-installed-p ()
984 "Say whether picons are installed on your machine."
985 (let ((installed nil))
986 (dolist (database gnus-picon-databases)
987 (when (file-exists-p database)
991 (defcustom gnus-article-mime-part-function nil
992 "Function called with a MIME handle as the argument.
993 This is meant for people who want to do something automatic based
994 on parts -- for instance, adding Vcard info to a database."
995 :group 'gnus-article-mime
996 :type '(choice (const nil)
999 (defcustom gnus-mime-multipart-functions nil
1000 "An alist of MIME types to functions to display them."
1002 :group 'gnus-article-mime
1003 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
1005 (defcustom gnus-article-date-lapsed-new-header nil
1006 "Whether the X-Sent and Date headers can coexist.
1007 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
1008 either replace the old \"Date:\" header (if this variable is nil), or
1009 be added below it (otherwise)."
1011 :group 'gnus-article-headers
1014 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
1015 "Function called with a MIME handle as the argument.
1016 This is meant for people who want to view first matched part.
1017 For `undisplayed-alternative' (default), the first undisplayed
1018 part or alternative part is used. For `undisplayed', the first
1019 undisplayed part is used. For a function, the first part which
1020 the function return t is used. For nil, the first part is
1023 :group 'gnus-article-mime
1025 (item :tag "first" :value nil)
1026 (item :tag "undisplayed" :value undisplayed)
1027 (item :tag "undisplayed or alternative"
1028 :value undisplayed-alternative)
1031 (defcustom gnus-mime-action-alist
1032 '(("save to file" . gnus-mime-save-part)
1033 ("save and strip" . gnus-mime-save-part-and-strip)
1034 ("replace with file" . gnus-mime-replace-part)
1035 ("delete part" . gnus-mime-delete-part)
1036 ("display as text" . gnus-mime-inline-part)
1037 ("view the part" . gnus-mime-view-part)
1038 ("pipe to command" . gnus-mime-pipe-part)
1039 ("toggle display" . gnus-article-press-button)
1040 ("toggle display" . gnus-article-view-part-as-charset)
1041 ("view as type" . gnus-mime-view-part-as-type)
1042 ("view internally" . gnus-mime-view-part-internally)
1043 ("view externally" . gnus-mime-view-part-externally))
1044 "An alist of actions that run on the MIME attachment."
1045 :group 'gnus-article-mime
1046 :type '(repeat (cons (string :tag "name")
1049 (defcustom gnus-auto-select-part 1
1050 "Advance to next MIME part when deleting or stripping parts.
1052 When 0, point will be placed on the same part as before. When
1053 positive (negative), move point forward (backwards) this many
1054 parts. When nil, redisplay article."
1055 :version "23.0" ;; No Gnus
1056 :group 'gnus-article-mime
1057 :type '(choice (const nil :tag "Redisplay article.")
1058 (const 1 :tag "Next part.")
1059 (const 0 :tag "Current part.")
1063 ;;; The treatment variables
1066 (defvar gnus-part-display-hook nil
1067 "Hook called on parts that are to receive treatment.")
1069 (defvar gnus-article-treat-custom
1070 '(choice (const :tag "Off" nil)
1072 (const :tag "Header" head)
1073 (const :tag "First" first)
1074 (const :tag "Last" last)
1075 (integer :tag "Less")
1076 (repeat :tag "Groups" regexp)
1077 (sexp :tag "Predicate")))
1079 (defvar gnus-article-treat-head-custom
1080 '(choice (const :tag "Off" nil)
1081 (const :tag "Header" head)))
1083 (defvar gnus-article-treat-types '("text/plain" "text/x-verbatim"
1087 (defvar gnus-inhibit-treatment nil
1088 "Whether to inhibit treatment.")
1090 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
1091 "Highlight the signature.
1092 Valid values are nil, t, `head', `first', `last', an integer or a
1093 predicate. See Info node `(gnus)Customizing Articles'."
1094 :group 'gnus-article-treat
1095 :link '(custom-manual "(gnus)Customizing Articles")
1096 :type gnus-article-treat-custom)
1097 (put 'gnus-treat-highlight-signature 'highlight t)
1099 (defcustom gnus-treat-buttonize 100000
1101 Valid values are nil, t, `head', `first', `last', an integer or a
1102 predicate. See Info node `(gnus)Customizing Articles'."
1103 :group 'gnus-article-treat
1104 :link '(custom-manual "(gnus)Customizing Articles")
1105 :type gnus-article-treat-custom)
1106 (put 'gnus-treat-buttonize 'highlight t)
1108 (defcustom gnus-treat-buttonize-head 'head
1109 "Add buttons to the head.
1110 Valid values are nil, t, `head', `first', `last', an integer or a
1111 predicate. See Info node `(gnus)Customizing Articles'."
1112 :group 'gnus-article-treat
1113 :link '(custom-manual "(gnus)Customizing Articles")
1114 :type gnus-article-treat-head-custom)
1115 (put 'gnus-treat-buttonize-head 'highlight t)
1117 (defcustom gnus-treat-emphasize
1118 (and (or window-system
1122 Valid values are nil, t, `head', `first', `last', an integer or a
1123 predicate. See Info node `(gnus)Customizing Articles'."
1124 :group 'gnus-article-treat
1125 :link '(custom-manual "(gnus)Customizing Articles")
1126 :type gnus-article-treat-custom)
1127 (put 'gnus-treat-emphasize 'highlight t)
1129 (defcustom gnus-treat-strip-cr nil
1130 "Remove carriage returns.
1131 Valid values are nil, t, `head', `first', `last', an integer or a
1132 predicate. See Info node `(gnus)Customizing Articles'."
1134 :group 'gnus-article-treat
1135 :link '(custom-manual "(gnus)Customizing Articles")
1136 :type gnus-article-treat-custom)
1138 (defcustom gnus-treat-unsplit-urls nil
1139 "Remove newlines from within URLs.
1140 Valid values are nil, t, `head', `first', `last', an integer or a
1141 predicate. See Info node `(gnus)Customizing Articles'."
1143 :group 'gnus-article-treat
1144 :link '(custom-manual "(gnus)Customizing Articles")
1145 :type gnus-article-treat-custom)
1147 (defcustom gnus-treat-leading-whitespace nil
1148 "Remove leading whitespace in headers.
1149 Valid values are nil, t, `head', `first', `last', an integer or a
1150 predicate. See Info node `(gnus)Customizing Articles'."
1152 :group 'gnus-article-treat
1153 :link '(custom-manual "(gnus)Customizing Articles")
1154 :type gnus-article-treat-custom)
1156 (defcustom gnus-treat-hide-headers 'head
1158 Valid values are nil, t, `head', `first', `last', an integer or a
1159 predicate. See Info node `(gnus)Customizing Articles'."
1160 :group 'gnus-article-treat
1161 :link '(custom-manual "(gnus)Customizing Articles")
1162 :type gnus-article-treat-head-custom)
1164 (defcustom gnus-treat-hide-boring-headers nil
1165 "Hide boring headers.
1166 Valid values are nil, t, `head', `first', `last', an integer or a
1167 predicate. See Info node `(gnus)Customizing Articles'."
1168 :group 'gnus-article-treat
1169 :link '(custom-manual "(gnus)Customizing Articles")
1170 :type gnus-article-treat-head-custom)
1172 (defcustom gnus-treat-hide-signature nil
1173 "Hide the signature.
1174 Valid values are nil, t, `head', `first', `last', an integer or a
1175 predicate. See Info node `(gnus)Customizing Articles'."
1176 :group 'gnus-article-treat
1177 :link '(custom-manual "(gnus)Customizing Articles")
1178 :type gnus-article-treat-custom)
1180 (defcustom gnus-treat-fill-article nil
1182 Valid values are nil, t, `head', `first', `last', an integer or a
1183 predicate. See Info node `(gnus)Customizing Articles'."
1184 :group 'gnus-article-treat
1185 :link '(custom-manual "(gnus)Customizing Articles")
1186 :type gnus-article-treat-custom)
1188 (defcustom gnus-treat-hide-citation nil
1190 Valid values are nil, t, `head', `first', `last', an integer or a
1191 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-hide-citation-maybe nil
1198 Valid values are nil, t, `head', `first', `last', an integer or a
1199 predicate. See Info node `(gnus)Customizing Articles'."
1200 :group 'gnus-article-treat
1201 :link '(custom-manual "(gnus)Customizing Articles")
1202 :type gnus-article-treat-custom)
1204 (defcustom gnus-treat-strip-list-identifiers 'head
1205 "Strip list identifiers from `gnus-list-identifiers`.
1206 Valid values are nil, t, `head', `first', `last', an integer or a
1207 predicate. See Info node `(gnus)Customizing Articles'."
1209 :group 'gnus-article-treat
1210 :link '(custom-manual "(gnus)Customizing Articles")
1211 :type gnus-article-treat-custom)
1213 (make-obsolete-variable 'gnus-treat-strip-pgp
1214 "This option is obsolete in Gnus 5.10.")
1216 (defcustom gnus-treat-strip-pem nil
1217 "Strip PEM signatures.
1218 Valid values are nil, t, `head', `first', `last', an integer or a
1219 predicate. See Info node `(gnus)Customizing Articles'."
1220 :group 'gnus-article-treat
1221 :link '(custom-manual "(gnus)Customizing Articles")
1222 :type gnus-article-treat-custom)
1224 (defcustom gnus-treat-strip-banner t
1225 "Strip banners from articles.
1226 The banner to be stripped is specified in the `banner' group parameter.
1227 Valid values are nil, t, `head', `first', `last', an integer or a
1228 predicate. See Info node `(gnus)Customizing Articles'."
1229 :group 'gnus-article-treat
1230 :link '(custom-manual "(gnus)Customizing Articles")
1231 :type gnus-article-treat-custom)
1233 (defcustom gnus-treat-highlight-headers 'head
1234 "Highlight the headers.
1235 Valid values are nil, t, `head', `first', `last', an integer or a
1236 predicate. See Info node `(gnus)Customizing Articles'."
1237 :group 'gnus-article-treat
1238 :link '(custom-manual "(gnus)Customizing Articles")
1239 :type gnus-article-treat-head-custom)
1240 (put 'gnus-treat-highlight-headers 'highlight t)
1242 (defcustom gnus-treat-highlight-citation t
1243 "Highlight cited text.
1244 Valid values are nil, t, `head', `first', `last', an integer or a
1245 predicate. See Info node `(gnus)Customizing Articles'."
1246 :group 'gnus-article-treat
1247 :link '(custom-manual "(gnus)Customizing Articles")
1248 :type gnus-article-treat-custom)
1249 (put 'gnus-treat-highlight-citation 'highlight t)
1251 (defcustom gnus-treat-date-ut nil
1252 "Display the Date in UT (GMT).
1253 Valid values are nil, t, `head', `first', `last', an integer or a
1254 predicate. See Info node `(gnus)Customizing Articles'."
1255 :group 'gnus-article-treat
1256 :link '(custom-manual "(gnus)Customizing Articles")
1257 :type gnus-article-treat-head-custom)
1259 (defcustom gnus-treat-date-local nil
1260 "Display the Date in the local timezone.
1261 Valid values are nil, t, `head', `first', `last', an integer or a
1262 predicate. See Info node `(gnus)Customizing Articles'."
1263 :group 'gnus-article-treat
1264 :link '(custom-manual "(gnus)Customizing Articles")
1265 :type gnus-article-treat-head-custom)
1267 (defcustom gnus-treat-date-english nil
1268 "Display the Date in a format that can be read aloud in English.
1269 Valid values are nil, t, `head', `first', `last', an integer or a
1270 predicate. See Info node `(gnus)Customizing Articles'."
1272 :group 'gnus-article-treat
1273 :link '(custom-manual "(gnus)Customizing Articles")
1274 :type gnus-article-treat-head-custom)
1276 (defcustom gnus-treat-date-lapsed nil
1277 "Display the Date header in a way that says how much time has elapsed.
1278 Valid values are nil, t, `head', `first', `last', an integer or a
1279 predicate. See Info node `(gnus)Customizing Articles'."
1280 :group 'gnus-article-treat
1281 :link '(custom-manual "(gnus)Customizing Articles")
1282 :type gnus-article-treat-head-custom)
1284 (defcustom gnus-treat-date-original nil
1285 "Display the date in the original timezone.
1286 Valid values are nil, t, `head', `first', `last', an integer or a
1287 predicate. See Info node `(gnus)Customizing Articles'."
1288 :group 'gnus-article-treat
1289 :link '(custom-manual "(gnus)Customizing Articles")
1290 :type gnus-article-treat-head-custom)
1292 (defcustom gnus-treat-date-iso8601 nil
1293 "Display the date in the ISO8601 format.
1294 Valid values are nil, t, `head', `first', `last', an integer or a
1295 predicate. See Info node `(gnus)Customizing Articles'."
1297 :group 'gnus-article-treat
1298 :link '(custom-manual "(gnus)Customizing Articles")
1299 :type gnus-article-treat-head-custom)
1301 (defcustom gnus-treat-date-user-defined nil
1302 "Display the date in a user-defined format.
1303 The format is defined by the `gnus-article-time-format' variable.
1304 Valid values are nil, t, `head', `first', `last', an integer or a
1305 predicate. See Info node `(gnus)Customizing Articles'."
1306 :group 'gnus-article-treat
1307 :link '(custom-manual "(gnus)Customizing Articles")
1308 :type gnus-article-treat-head-custom)
1310 (defcustom gnus-treat-strip-headers-in-body t
1311 "Strip the X-No-Archive header line from the beginning of the body.
1312 Valid values are nil, t, `head', `first', `last', an integer or a
1313 predicate. See Info node `(gnus)Customizing Articles'."
1315 :group 'gnus-article-treat
1316 :link '(custom-manual "(gnus)Customizing Articles")
1317 :type gnus-article-treat-custom)
1319 (defcustom gnus-treat-strip-trailing-blank-lines nil
1320 "Strip trailing blank lines.
1321 Valid values are nil, t, `head', `first', `last', an integer or a
1322 predicate. See Info node `(gnus)Customizing Articles'.
1324 When set to t, it also strips trailing blanks in all MIME parts.
1325 Consider to use `last' instead."
1326 :group 'gnus-article-treat
1327 :link '(custom-manual "(gnus)Customizing Articles")
1328 :type gnus-article-treat-custom)
1330 (defcustom gnus-treat-strip-leading-blank-lines nil
1331 "Strip leading blank lines.
1332 Valid values are nil, t, `head', `first', `last', an integer or a
1333 predicate. See Info node `(gnus)Customizing Articles'.
1335 When set to t, it also strips trailing blanks in all MIME parts."
1336 :group 'gnus-article-treat
1337 :link '(custom-manual "(gnus)Customizing Articles")
1338 :type gnus-article-treat-custom)
1340 (defcustom gnus-treat-strip-multiple-blank-lines nil
1341 "Strip multiple blank lines.
1342 Valid values are nil, t, `head', `first', `last', an integer or a
1343 predicate. See Info node `(gnus)Customizing Articles'."
1344 :group 'gnus-article-treat
1345 :link '(custom-manual "(gnus)Customizing Articles")
1346 :type gnus-article-treat-custom)
1348 (defcustom gnus-treat-unfold-headers 'head
1349 "Unfold folded header lines.
1350 Valid values are nil, t, `head', `first', `last', an integer or a
1351 predicate. See Info node `(gnus)Customizing Articles'."
1353 :group 'gnus-article-treat
1354 :link '(custom-manual "(gnus)Customizing Articles")
1355 :type gnus-article-treat-custom)
1357 (defcustom gnus-article-unfold-long-headers nil
1358 "If non-nil, allow unfolding headers even if the header is long.
1359 If it is a regexp, only long headers matching this regexp are unfolded.
1360 If it is t, all long headers are unfolded.
1362 This variable has no effect if `gnus-treat-unfold-headers' is nil."
1363 :version "23.0" ;; No Gnus
1364 :group 'gnus-article-treat
1365 :type '(choice (const nil)
1366 (const :tag "all" t)
1369 (defcustom gnus-treat-fold-headers nil
1371 Valid values are nil, t, `head', `first', `last', an integer or a
1372 predicate. See Info node `(gnus)Customizing Articles'."
1374 :group 'gnus-article-treat
1375 :link '(custom-manual "(gnus)Customizing Articles")
1376 :type gnus-article-treat-custom)
1378 (defcustom gnus-treat-fold-newsgroups 'head
1379 "Fold the Newsgroups and Followup-To headers.
1380 Valid values are nil, t, `head', `first', `last', an integer or a
1381 predicate. See Info node `(gnus)Customizing Articles'."
1383 :group 'gnus-article-treat
1384 :link '(custom-manual "(gnus)Customizing Articles")
1385 :type gnus-article-treat-custom)
1387 (defcustom gnus-treat-overstrike t
1388 "Treat overstrike highlighting.
1389 Valid values are nil, t, `head', `first', `last', an integer or a
1390 predicate. See Info node `(gnus)Customizing Articles'."
1391 :group 'gnus-article-treat
1392 :link '(custom-manual "(gnus)Customizing Articles")
1393 :type gnus-article-treat-custom)
1394 (put 'gnus-treat-overstrike 'highlight t)
1396 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1397 "Treat ANSI SGR control sequences.
1398 Valid values are nil, t, `head', `first', `last', an integer or a
1399 predicate. See Info node `(gnus)Customizing Articles'."
1400 :group 'gnus-article-treat
1401 :link '(custom-manual "(gnus)Customizing Articles")
1402 :type gnus-article-treat-custom)
1404 (make-obsolete-variable 'gnus-treat-display-xface
1405 'gnus-treat-display-x-face)
1407 (defcustom gnus-treat-display-x-face
1408 (and (not noninteractive)
1409 (or (and (fboundp 'image-type-available-p)
1410 (image-type-available-p 'xbm)
1411 (string-match "^0x" (shell-command-to-string "uncompface"))
1412 (executable-find "icontopbm"))
1413 (and (featurep 'xemacs)
1416 "Display X-Face headers.
1417 Valid values are nil, t, `head', `first', `last', an integer or a
1418 predicate. See Info node `(gnus)Customizing Articles' and Info
1419 node `(gnus)X-Face' for details."
1420 :group 'gnus-article-treat
1422 :link '(custom-manual "(gnus)Customizing Articles")
1423 :link '(custom-manual "(gnus)X-Face")
1424 :type gnus-article-treat-head-custom
1425 :set (lambda (symbol value)
1428 (cond ((or (boundp symbol) (get symbol 'saved-value))
1430 ((boundp 'gnus-treat-display-xface)
1432 ** gnus-treat-display-xface is an obsolete variable;\
1433 use gnus-treat-display-x-face instead")
1434 (default-value 'gnus-treat-display-xface))
1435 ((get 'gnus-treat-display-xface 'saved-value)
1437 ** gnus-treat-display-xface is an obsolete variable;\
1438 use gnus-treat-display-x-face instead")
1439 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1442 (put 'gnus-treat-display-x-face 'highlight t)
1444 (defcustom gnus-treat-display-face
1445 (and (not noninteractive)
1446 (or (and (fboundp 'image-type-available-p)
1447 (image-type-available-p 'png))
1448 (and (featurep 'xemacs)
1451 "Display Face headers.
1452 Valid values are nil, t, `head', `first', `last', an integer or a
1453 predicate. See Info node `(gnus)Customizing Articles' and Info
1454 node `(gnus)X-Face' for details."
1455 :group 'gnus-article-treat
1457 :link '(custom-manual "(gnus)Customizing Articles")
1458 :link '(custom-manual "(gnus)X-Face")
1459 :type gnus-article-treat-head-custom)
1460 (put 'gnus-treat-display-face 'highlight t)
1462 (defcustom gnus-treat-display-smileys
1463 (if (or (and (featurep 'xemacs)
1465 (and (fboundp 'image-type-available-p)
1466 (image-type-available-p 'pbm)))
1469 Valid values are nil, t, `head', `first', `last', an integer or a
1470 predicate. See Info node `(gnus)Customizing Articles' and Info
1471 node `(gnus)Smileys' for details."
1472 :group 'gnus-article-treat
1474 :link '(custom-manual "(gnus)Customizing Articles")
1475 :link '(custom-manual "(gnus)Smileys")
1476 :type gnus-article-treat-custom)
1477 (put 'gnus-treat-display-smileys 'highlight t)
1479 (defcustom gnus-treat-from-picon
1480 (if (and (gnus-image-type-available-p 'xpm)
1481 (gnus-picons-installed-p))
1483 "Display picons in the From header.
1484 Valid values are nil, t, `head', `first', `last', an integer or a
1485 predicate. See Info node `(gnus)Customizing Articles' and Info
1486 node `(gnus)Picons' for details."
1488 :group 'gnus-article-treat
1490 :link '(custom-manual "(gnus)Customizing Articles")
1491 :link '(custom-manual "(gnus)Picons")
1492 :type gnus-article-treat-head-custom)
1493 (put 'gnus-treat-from-picon 'highlight t)
1495 (defcustom gnus-treat-mail-picon
1496 (if (and (gnus-image-type-available-p 'xpm)
1497 (gnus-picons-installed-p))
1499 "Display picons in To and Cc headers.
1500 Valid values are nil, t, `head', `first', `last', an integer or a
1501 predicate. See Info node `(gnus)Customizing Articles' and Info
1502 node `(gnus)Picons' for details."
1504 :group 'gnus-article-treat
1506 :link '(custom-manual "(gnus)Customizing Articles")
1507 :link '(custom-manual "(gnus)Picons")
1508 :type gnus-article-treat-head-custom)
1509 (put 'gnus-treat-mail-picon 'highlight t)
1511 (defcustom gnus-treat-newsgroups-picon
1512 (if (and (gnus-image-type-available-p 'xpm)
1513 (gnus-picons-installed-p))
1515 "Display picons in the Newsgroups and Followup-To headers.
1516 Valid values are nil, t, `head', `first', `last', an integer or a
1517 predicate. See Info node `(gnus)Customizing Articles' and Info
1518 node `(gnus)Picons' for details."
1520 :group 'gnus-article-treat
1522 :link '(custom-manual "(gnus)Customizing Articles")
1523 :link '(custom-manual "(gnus)Picons")
1524 :type gnus-article-treat-head-custom)
1525 (put 'gnus-treat-newsgroups-picon 'highlight t)
1527 (defcustom gnus-treat-body-boundary
1528 (if (and (eq window-system 'x)
1529 (or gnus-treat-newsgroups-picon
1530 gnus-treat-mail-picon
1531 gnus-treat-from-picon))
1533 "Draw a boundary at the end of the headers.
1534 Valid values are nil and `head'.
1535 See Info node `(gnus)Customizing Articles' for details."
1537 :group 'gnus-article-treat
1538 :link '(custom-manual "(gnus)Customizing Articles")
1539 :type gnus-article-treat-head-custom)
1541 (defcustom gnus-treat-capitalize-sentences nil
1542 "Capitalize sentence-starting words.
1543 Valid values are nil, t, `head', `first', `last', an integer or a
1544 predicate. See Info node `(gnus)Customizing Articles'."
1546 :group 'gnus-article-treat
1547 :link '(custom-manual "(gnus)Customizing Articles")
1548 :type gnus-article-treat-custom)
1550 (defcustom gnus-treat-wash-html nil
1552 Valid values are nil, t, `head', `first', `last', an integer or a
1553 predicate. See Info node `(gnus)Customizing Articles'."
1555 :group 'gnus-article-treat
1556 :link '(custom-manual "(gnus)Customizing Articles")
1557 :type gnus-article-treat-custom)
1559 (defcustom gnus-treat-fill-long-lines nil
1561 Valid values are nil, t, `head', `first', `last', an integer or a
1562 predicate. See Info node `(gnus)Customizing Articles'."
1563 :group 'gnus-article-treat
1564 :link '(custom-manual "(gnus)Customizing Articles")
1565 :type gnus-article-treat-custom)
1567 (defcustom gnus-treat-play-sounds nil
1569 Valid values are nil, t, `head', `first', `last', an integer or a
1570 predicate. See Info node `(gnus)Customizing Articles'."
1572 :group 'gnus-article-treat
1573 :link '(custom-manual "(gnus)Customizing Articles")
1574 :type gnus-article-treat-custom)
1576 (defcustom gnus-treat-translate nil
1577 "Translate articles from one language to another.
1578 Valid values are nil, t, `head', `first', `last', an integer or a
1579 predicate. See Info node `(gnus)Customizing Articles'."
1581 :group 'gnus-article-treat
1582 :link '(custom-manual "(gnus)Customizing Articles")
1583 :type gnus-article-treat-custom)
1585 (defcustom gnus-treat-x-pgp-sig nil
1587 To automatically treat X-PGP-Sig, set it to head.
1588 Valid values are nil, t, `head', `first', `last', an integer or a
1589 predicate. See Info node `(gnus)Customizing Articles'."
1591 :group 'gnus-article-treat
1592 :group 'mime-security
1593 :link '(custom-manual "(gnus)Customizing Articles")
1594 :type gnus-article-treat-custom)
1596 (defvar gnus-article-encrypt-protocol-alist
1597 '(("PGP" . mml2015-self-encrypt)))
1599 ;; Set to nil if more than one protocol added to
1600 ;; gnus-article-encrypt-protocol-alist.
1601 (defcustom gnus-article-encrypt-protocol "PGP"
1602 "The protocol used for encrypt articles.
1603 It is a string, such as \"PGP\". If nil, ask user."
1606 :group 'mime-security)
1608 (defvar gnus-article-wash-function nil
1609 "Function used for converting HTML into text.")
1611 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1612 (mm-coding-system-p 'utf-8)
1613 (executable-find idna-program))
1614 "Whether IDNA decoding of headers is used when viewing messages.
1615 This requires GNU Libidn, and by default only enabled if it is found."
1617 :group 'gnus-article-headers
1620 (defcustom gnus-article-over-scroll nil
1621 "If non-nil, allow scrolling the article buffer even when there no more text."
1623 :group 'gnus-article
1626 ;;; Internal variables
1628 (defvar gnus-english-month-names
1629 '("January" "February" "March" "April" "May" "June" "July" "August"
1630 "September" "October" "November" "December"))
1632 (defvar gnus-button-regexp nil)
1633 (defvar gnus-button-marker-list nil)
1634 ;; Regexp matching any of the regexps from `gnus-button-alist'.
1636 (defvar gnus-button-last nil)
1637 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
1639 (defvar article-goto-body-goes-to-point-min-p nil)
1640 (defvar gnus-article-wash-types nil)
1641 (defvar gnus-article-emphasis-alist nil)
1642 (defvar gnus-article-image-alist nil)
1644 (defvar gnus-article-mime-handle-alist-1 nil)
1645 (defvar gnus-treatment-function-alist
1646 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1647 (gnus-treat-strip-banner gnus-article-strip-banner)
1648 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1649 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1650 (gnus-treat-buttonize gnus-article-add-buttons)
1651 (gnus-treat-fill-article gnus-article-fill-cited-article)
1652 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1653 (gnus-treat-strip-cr gnus-article-remove-cr)
1654 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1655 (gnus-treat-date-ut gnus-article-date-ut)
1656 (gnus-treat-date-local gnus-article-date-local)
1657 (gnus-treat-date-english gnus-article-date-english)
1658 (gnus-treat-date-original gnus-article-date-original)
1659 (gnus-treat-date-user-defined gnus-article-date-user)
1660 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1661 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1662 (gnus-treat-display-x-face gnus-article-display-x-face)
1663 (gnus-treat-display-face gnus-article-display-face)
1664 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1665 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1666 (gnus-treat-hide-signature gnus-article-hide-signature)
1667 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1668 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1669 (gnus-treat-strip-pem gnus-article-hide-pem)
1670 (gnus-treat-from-picon gnus-treat-from-picon)
1671 (gnus-treat-mail-picon gnus-treat-mail-picon)
1672 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1673 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1674 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1675 (gnus-treat-strip-trailing-blank-lines
1676 gnus-article-remove-trailing-blank-lines)
1677 (gnus-treat-strip-leading-blank-lines
1678 gnus-article-strip-leading-blank-lines)
1679 (gnus-treat-strip-multiple-blank-lines
1680 gnus-article-strip-multiple-blank-lines)
1681 (gnus-treat-overstrike gnus-article-treat-overstrike)
1682 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1683 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1684 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1685 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1686 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1687 (gnus-treat-display-smileys gnus-treat-smiley)
1688 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1689 (gnus-treat-wash-html gnus-article-wash-html)
1690 (gnus-treat-emphasize gnus-article-emphasize)
1691 (gnus-treat-hide-citation gnus-article-hide-citation)
1692 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1693 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1694 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1695 (gnus-treat-play-sounds gnus-earcon-display)))
1697 (defvar gnus-article-mime-handle-alist nil)
1698 (defvar article-lapsed-timer nil)
1699 (defvar gnus-article-current-summary nil)
1701 (defvar gnus-article-mode-syntax-table
1702 (let ((table (copy-syntax-table text-mode-syntax-table)))
1703 ;; This causes the citation match run O(2^n).
1704 ;; (modify-syntax-entry ?- "w" table)
1705 (modify-syntax-entry ?> ")<" table)
1706 (modify-syntax-entry ?< "(>" table)
1707 ;; make M-. in article buffers work for `foo' strings
1708 (modify-syntax-entry ?' " " table)
1709 (modify-syntax-entry ?` " " table)
1711 "Syntax table used in article mode buffers.
1712 Initialized from `text-mode-syntax-table.")
1714 (defvar gnus-save-article-buffer nil)
1716 (defvar gnus-article-mode-line-format-alist
1717 (nconc '((?w (gnus-article-wash-status) ?s)
1718 (?m (gnus-article-mime-part-status) ?s))
1719 gnus-summary-mode-line-format-alist))
1721 (defvar gnus-number-of-articles-to-be-saved nil)
1723 (defvar gnus-inhibit-hiding nil)
1725 (defvar gnus-article-edit-mode nil)
1727 ;;; Macros for dealing with the article buffer.
1729 (defmacro gnus-with-article-headers (&rest forms)
1731 (set-buffer gnus-article-buffer)
1733 (let ((inhibit-read-only t)
1734 (inhibit-point-motion-hooks t)
1735 (case-fold-search t))
1736 (article-narrow-to-head)
1739 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1740 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1742 (defmacro gnus-with-article-buffer (&rest forms)
1744 (set-buffer gnus-article-buffer)
1745 (let ((inhibit-read-only t))
1748 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1749 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1751 (defun gnus-article-goto-header (header)
1752 "Go to HEADER, which is a regular expression."
1753 (re-search-forward (concat "^\\(" header "\\):") nil t))
1755 (defsubst gnus-article-hide-text (b e props)
1756 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1757 (gnus-add-text-properties-when 'article-type nil b e props)
1758 (when (memq 'intangible props)
1760 (max (1- b) (point-min))
1761 b 'intangible (cddr (memq 'intangible props)))))
1763 (defsubst gnus-article-unhide-text (b e)
1764 "Remove hidden text properties from region between B and E."
1765 (remove-text-properties b e gnus-hidden-properties)
1766 (when (memq 'intangible gnus-hidden-properties)
1767 (put-text-property (max (1- b) (point-min))
1768 b 'intangible nil)))
1770 (defun gnus-article-hide-text-type (b e type)
1771 "Hide text of TYPE between B and E."
1772 (gnus-add-wash-type type)
1773 (gnus-article-hide-text
1774 b e (cons 'article-type (cons type gnus-hidden-properties))))
1776 (defun gnus-article-unhide-text-type (b e type)
1777 "Unhide text of TYPE between B and E."
1778 (gnus-delete-wash-type type)
1779 (remove-text-properties
1780 b e (cons 'article-type (cons type gnus-hidden-properties)))
1781 (when (memq 'intangible gnus-hidden-properties)
1782 (put-text-property (max (1- b) (point-min))
1783 b 'intangible nil)))
1785 (defun gnus-article-hide-text-of-type (type)
1786 "Hide text of TYPE in the current buffer."
1788 (let ((b (point-min))
1790 (while (setq b (text-property-any b e 'article-type type))
1791 (add-text-properties b (incf b) gnus-hidden-properties)))))
1793 (defun gnus-article-delete-text-of-type (type)
1794 "Delete text of TYPE in the current buffer."
1796 (let ((b (point-min)))
1797 (if (eq type 'multipart)
1798 ;; Remove MIME buttons associated with multipart/alternative parts.
1801 (while (if (get-text-property (point) 'gnus-part)
1803 (when (setq b (next-single-property-change (point)
1808 (skip-chars-forward "\n")
1809 (when (eq (get-text-property b 'article-type) 'multipart)
1810 (delete-region b (point)))))
1811 (while (setq b (text-property-any b (point-max) 'article-type type))
1813 b (or (text-property-not-all b (point-max) 'article-type type)
1816 (defun gnus-article-delete-invisible-text ()
1817 "Delete all invisible text in the current buffer."
1819 (let ((b (point-min)))
1820 (while (setq b (text-property-any b (point-max) 'invisible t))
1822 b (or (text-property-not-all b (point-max) 'invisible t)
1825 (defun gnus-article-text-type-exists-p (type)
1826 "Say whether any text of type TYPE exists in the buffer."
1827 (text-property-any (point-min) (point-max) 'article-type type))
1829 (defsubst gnus-article-header-rank ()
1830 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1831 (let ((list gnus-sorted-header-list)
1834 (if (looking-at (car list))
1836 (setq list (cdr list))
1840 (defun article-hide-headers (&optional arg delete)
1841 "Hide unwanted headers and possibly sort them as well."
1843 ;; This function might be inhibited.
1844 (unless gnus-inhibit-hiding
1845 (let ((inhibit-read-only t)
1846 (case-fold-search t)
1847 (max (1+ (length gnus-sorted-header-list)))
1848 (inhibit-point-motion-hooks t)
1849 (cur (current-buffer))
1850 ignored visible beg)
1852 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1853 ;; group parameters, so we should go to the summary buffer.
1856 (progn (set-buffer gnus-summary-buffer) t)
1858 (setq ignored (when (not gnus-visible-headers)
1859 (cond ((stringp gnus-ignored-headers)
1860 gnus-ignored-headers)
1861 ((listp gnus-ignored-headers)
1862 (mapconcat 'identity
1863 gnus-ignored-headers
1865 visible (cond ((stringp gnus-visible-headers)
1866 gnus-visible-headers)
1867 ((and gnus-visible-headers
1868 (listp gnus-visible-headers))
1869 (mapconcat 'identity
1870 gnus-visible-headers
1874 ;; First we narrow to just the headers.
1875 (article-narrow-to-head)
1876 ;; Hide any "From " lines at the beginning of (mail) articles.
1877 (while (looking-at "From ")
1880 (delete-region (point-min) (point)))
1881 ;; Then treat the rest of the header lines.
1882 ;; Then we use the two regular expressions
1883 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1884 ;; select which header lines is to remain visible in the
1886 (while (re-search-forward "^[^ \t:]*:" nil t)
1888 ;; Mark the rank of the header.
1890 (point) (1+ (point)) 'message-rank
1891 (if (or (and visible (looking-at visible))
1893 (not (looking-at ignored))))
1894 (gnus-article-header-rank)
1897 (message-sort-headers-1)
1898 (when (setq beg (text-property-any
1899 (point-min) (point-max) 'message-rank (+ 2 max)))
1900 ;; We delete the unwanted headers.
1901 (gnus-add-wash-type 'headers)
1902 (add-text-properties (point-min) (+ 5 (point-min))
1903 '(article-type headers dummy-invisible t))
1904 (delete-region beg (point-max))))))))
1906 (defun article-hide-boring-headers (&optional arg)
1907 "Toggle hiding of headers that aren't very interesting.
1908 If given a negative prefix, always show; if given a positive prefix,
1910 (interactive (gnus-article-hidden-arg))
1911 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1912 (not gnus-show-all-headers))
1915 (let ((inhibit-read-only t)
1916 (inhibit-point-motion-hooks t))
1917 (article-narrow-to-head)
1918 (dolist (elem gnus-boring-article-headers)
1919 (goto-char (point-min))
1921 ;; Hide empty headers.
1923 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1925 (gnus-article-hide-text-type
1929 (if (re-search-forward "^[^ \t]" nil t)
1933 ;; Hide boring Newsgroups header.
1934 ((eq elem 'newsgroups)
1935 (when (gnus-string-equal
1936 (gnus-fetch-field "newsgroups")
1937 (gnus-group-real-name
1938 (if (boundp 'gnus-newsgroup-name)
1941 (gnus-article-hide-header "newsgroups")))
1942 ((eq elem 'to-address)
1943 (let ((to (message-fetch-field "to"))
1945 (gnus-parameter-to-address
1946 (if (boundp 'gnus-newsgroup-name)
1947 gnus-newsgroup-name ""))))
1948 (when (and to to-address
1951 ;; only one address in To
1952 (nth 1 (mail-extract-address-components to))
1954 (gnus-article-hide-header "to"))))
1956 (let ((to (message-fetch-field "to"))
1958 (gnus-parameter-to-list
1959 (if (boundp 'gnus-newsgroup-name)
1960 gnus-newsgroup-name ""))))
1961 (when (and to to-list
1964 ;; only one address in To
1965 (nth 1 (mail-extract-address-components to))
1967 (gnus-article-hide-header "to"))))
1969 (let ((cc (message-fetch-field "cc"))
1971 (gnus-parameter-to-list
1972 (if (boundp 'gnus-newsgroup-name)
1973 gnus-newsgroup-name ""))))
1974 (when (and cc to-list
1977 ;; only one address in CC
1978 (nth 1 (mail-extract-address-components cc))
1980 (gnus-article-hide-header "cc"))))
1981 ((eq elem 'followup-to)
1982 (when (gnus-string-equal
1983 (message-fetch-field "followup-to")
1984 (message-fetch-field "newsgroups"))
1985 (gnus-article-hide-header "followup-to")))
1986 ((eq elem 'reply-to)
1987 (if (gnus-group-find-parameter
1988 gnus-newsgroup-name 'broken-reply-to)
1989 (gnus-article-hide-header "reply-to")
1990 (let ((from (message-fetch-field "from"))
1991 (reply-to (message-fetch-field "reply-to")))
1998 (lambda (x) (downcase (cadr x)))
1999 (mail-extract-address-components from t))
2002 (lambda (x) (downcase (cadr x)))
2003 (mail-extract-address-components reply-to t))
2005 (gnus-article-hide-header "reply-to")))))
2007 (let ((date (message-fetch-field "date")))
2009 (< (days-between (current-time-string) date)
2011 (gnus-article-hide-header "date"))))
2013 (let ((to (message-fetch-field "to"))
2014 (cc (message-fetch-field "cc")))
2015 (when (> (length to) 1024)
2016 (gnus-article-hide-header "to"))
2017 (when (> (length cc) 1024)
2018 (gnus-article-hide-header "cc"))))
2022 (goto-char (point-min))
2023 (while (re-search-forward "^to:" nil t)
2024 (setq to-count (1+ to-count)))
2025 (when (> to-count 1)
2026 (while (> to-count 0)
2027 (goto-char (point-min))
2029 (re-search-forward "^to:" nil nil to-count)
2031 (narrow-to-region (point) (point-max))
2032 (gnus-article-hide-header "to"))
2033 (setq to-count (1- to-count))))
2034 (goto-char (point-min))
2035 (while (re-search-forward "^cc:" nil t)
2036 (setq cc-count (1+ cc-count)))
2037 (when (> cc-count 1)
2038 (while (> cc-count 0)
2039 (goto-char (point-min))
2041 (re-search-forward "^cc:" nil nil cc-count)
2043 (narrow-to-region (point) (point-max))
2044 (gnus-article-hide-header "cc"))
2045 (setq cc-count (1- cc-count)))))))))))))
2047 (defun gnus-article-hide-header (header)
2049 (goto-char (point-min))
2050 (when (re-search-forward (concat "^" header ":") nil t)
2051 (gnus-article-hide-text-type
2055 (if (re-search-forward "^[^ \t]" nil t)
2060 (defvar gnus-article-normalized-header-length 40
2061 "Length of normalized headers.")
2063 (defun article-normalize-headers ()
2064 "Make all header lines 40 characters long."
2066 (let ((inhibit-read-only t)
2070 (article-narrow-to-head)
2073 ((< (setq column (- (point-at-eol) (point)))
2074 gnus-article-normalized-header-length)
2076 (insert (make-string
2077 (- gnus-article-normalized-header-length column)
2079 ((> column gnus-article-normalized-header-length)
2080 (gnus-put-text-property
2082 (forward-char gnus-article-normalized-header-length)
2089 (forward-line 1))))))
2091 (defun article-treat-dumbquotes ()
2092 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
2093 Note that this function guesses whether a character is a sm*rtq**t* or
2094 not, so it should only be used interactively.
2096 Sm*rtq**t*s are M****s***'s unilateral extension to the
2097 iso-8859-1 character map in an attempt to provide more quoting
2098 characters. If you see something like \\222 or \\264 where
2099 you're expecting some kind of apostrophe or quotation mark, then
2102 (article-translate-strings gnus-article-dumbquotes-map))
2104 (defun article-translate-characters (from to)
2105 "Translate all characters in the body of the article according to FROM and TO.
2106 FROM is a string of characters to translate from; to is a string of
2107 characters to translate to."
2109 (when (article-goto-body)
2110 (let ((inhibit-read-only t)
2111 (x (make-string 225 ?x))
2113 (while (< (incf i) (length x))
2116 (while (< i (length from))
2117 (aset x (aref from i) (aref to i))
2119 (translate-region (point) (point-max) x)))))
2121 (defun article-translate-strings (map)
2122 "Translate all string in the body of the article according to MAP.
2123 MAP is an alist where the elements are on the form (\"from\" \"to\")."
2125 (when (article-goto-body)
2126 (let ((inhibit-read-only t))
2129 (while (search-forward (car elem) nil t)
2130 (replace-match (cadr elem)))))))))
2132 (defun article-treat-overstrike ()
2133 "Translate overstrikes into bold text."
2136 (when (article-goto-body)
2137 (let ((inhibit-read-only t))
2138 (while (search-forward "\b" nil t)
2139 (let ((next (char-after))
2140 (previous (char-after (- (point) 2))))
2141 ;; We do the boldification/underlining by hiding the
2142 ;; overstrikes and putting the proper text property
2146 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
2147 (put-text-property (point) (1+ (point)) 'face 'bold))
2149 (gnus-article-hide-text-type
2150 (1- (point)) (1+ (point)) 'overstrike)
2152 (- (point) 2) (1- (point)) 'face 'underline))
2154 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
2156 (point) (1+ (point)) 'face 'underline)))))))))
2158 (defun article-treat-ansi-sequences ()
2159 "Translate ANSI SGR control sequences into overlays or extents."
2162 (when (article-goto-body)
2163 (let ((inhibit-read-only t))
2164 (ansi-color-apply-on-region (point) (point-max))))))
2166 (defun gnus-article-treat-unfold-headers ()
2167 "Unfold folded message headers.
2168 Only the headers that fit into the current window width will be
2171 (gnus-with-article-headers
2175 (mail-header-narrow-to-field)
2176 (let* ((header (buffer-string))
2178 (or (equal gnus-article-unfold-long-headers t)
2179 (and (stringp gnus-article-unfold-long-headers)
2180 (string-match gnus-article-unfold-long-headers header)))))
2183 (goto-char (point-min))
2184 (while (re-search-forward "\n[\t ]" nil t)
2185 (replace-match " " t t)))
2186 (setq length (- (point-max) (point-min) 1))
2187 (when (or unfoldable
2188 (< length (window-width)))
2189 (while (re-search-forward "\n[\t ]" nil t)
2190 (replace-match " " t t))))
2191 (goto-char (point-max)))))))
2193 (defun gnus-article-treat-fold-headers ()
2194 "Fold message headers."
2196 (gnus-with-article-headers
2199 (mail-header-narrow-to-field)
2200 (mail-header-fold-field)
2201 (goto-char (point-max))))))
2203 (defun gnus-treat-smiley ()
2204 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2206 (gnus-with-article-buffer
2207 (if (memq 'smiley gnus-article-wash-types)
2208 (gnus-delete-images 'smiley)
2210 (let ((images (smiley-region (point) (point-max))))
2212 (gnus-add-wash-type 'smiley)
2213 (dolist (image images)
2214 (gnus-add-image 'smiley image)))))))
2216 (defun gnus-article-remove-images ()
2217 "Remove all images from the article buffer."
2219 (gnus-with-article-buffer
2220 (dolist (elem gnus-article-image-alist)
2221 (gnus-delete-images (car elem)))))
2223 (defun gnus-article-treat-fold-newsgroups ()
2224 "Unfold folded message headers.
2225 Only the headers that fit into the current window width will be
2228 (gnus-with-article-headers
2229 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2231 (mail-header-narrow-to-field)
2232 (while (re-search-forward ", *" nil t)
2233 (replace-match ", " t t))
2234 (mail-header-fold-field)
2235 (goto-char (point-max))))))
2237 (defcustom gnus-article-truncate-lines default-truncate-lines
2238 "Value of `truncate-lines' in Gnus Article buffer.
2239 Valid values are nil, t, `head', `first', `last', an integer or a
2240 predicate. See Info node `(gnus)Customizing Articles'."
2241 :version "23.0" ;; No Gnus
2242 :group 'gnus-article
2243 ;; :link '(custom-manual "(gnus)Customizing Articles")
2246 (defun gnus-article-toggle-truncate-lines (&optional arg)
2247 "Toggle whether to fold or truncate long lines in article the buffer.
2248 If ARG is non-nil and not a number, toggle
2249 `gnus-article-truncate-lines' too. If ARG is a number, truncate
2250 long lines iff arg is positive."
2253 ((and (numberp arg) (> arg 0))
2254 (setq gnus-article-truncate-lines t))
2256 (setq gnus-article-truncate-lines nil))
2258 (setq gnus-article-truncate-lines
2259 (not gnus-article-truncate-lines))))
2260 (gnus-with-article-buffer
2262 ((and (numberp arg) (> arg 0))
2263 (setq truncate-lines nil))
2265 (setq truncate-lines t)))
2266 ;; In versions of Emacs 22 (CVS) before 2006-05-26,
2267 ;; `toggle-truncate-lines' needs an argument.
2268 (toggle-truncate-lines)))
2270 (defun gnus-article-treat-body-boundary ()
2271 "Place a boundary line at the end of the headers."
2273 (when (and gnus-body-boundary-delimiter
2274 (> (length gnus-body-boundary-delimiter) 0))
2275 (gnus-with-article-headers
2276 (goto-char (point-max))
2277 (let ((start (point)))
2278 (insert "X-Boundary: ")
2279 (gnus-add-text-properties start (point) '(invisible t intangible t))
2281 (while (>= (1- (window-width)) (length str))
2282 (setq str (concat str gnus-body-boundary-delimiter)))
2283 (substring str 0 (1- (window-width))))
2285 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2287 (defun article-fill-long-lines ()
2288 "Fill lines that are wider than the window width."
2291 (let ((inhibit-read-only t)
2292 (width (window-width (get-buffer-window (current-buffer)))))
2295 (let ((adaptive-fill-mode nil)) ;Why? -sm
2298 (when (>= (current-column) (min fill-column width))
2299 (narrow-to-region (min (1+ (point)) (point-max))
2301 (let ((goback (point-marker)))
2302 (fill-paragraph nil)
2303 (goto-char (marker-position goback)))
2305 (forward-line 1)))))))
2307 (defun article-capitalize-sentences ()
2308 "Capitalize the first word in each sentence."
2311 (let ((inhibit-read-only t)
2312 (paragraph-start "^[\n\^L]"))
2316 (forward-sentence)))))
2318 (defun article-remove-cr ()
2319 "Remove trailing CRs and then translate remaining CRs into LFs."
2322 (let ((inhibit-read-only t))
2323 (goto-char (point-min))
2324 (while (re-search-forward "\r+$" nil t)
2325 (replace-match "" t t))
2326 (goto-char (point-min))
2327 (while (search-forward "\r" nil t)
2328 (replace-match "\n" t t)))))
2330 (defun article-remove-trailing-blank-lines ()
2331 "Remove all trailing blank lines from the article."
2334 (let ((inhibit-read-only t))
2335 (goto-char (point-max))
2339 (while (and (not (bobp))
2340 (looking-at "^[ \t]*$")
2341 (not (gnus-annotation-in-region-p
2342 (point) (point-at-eol))))
2348 (defvar gnus-face-properties-alist))
2350 (defun article-display-face ()
2351 "Display any Face headers in the header."
2353 (let ((wash-face-p buffer-read-only))
2354 (gnus-with-article-headers
2355 ;; When displaying parts, this function can be called several times on
2356 ;; the same article, without any intended toggle semantic (as typing `W
2357 ;; D d' would have). So face deletion must occur only when we come from
2358 ;; an interactive command, that is when the *Article* buffer is
2360 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2361 (gnus-delete-images 'face)
2362 (let (face faces from)
2363 (save-current-buffer
2364 (when (and wash-face-p
2365 (gnus-buffer-live-p gnus-original-article-buffer)
2366 (not (re-search-forward "^Face:[\t ]*" nil t)))
2367 (set-buffer gnus-original-article-buffer))
2369 (mail-narrow-to-head)
2370 (while (gnus-article-goto-header "Face")
2371 (push (mail-header-field-value) faces))))
2373 (goto-char (point-min))
2374 (let ((from (gnus-article-goto-header "from"))
2379 (insert "[no `from' set]\n"))
2381 (when (setq png (gnus-convert-face-to-png (pop faces)))
2383 (apply 'gnus-create-image png 'png t
2384 (cdr (assq 'png gnus-face-properties-alist))))
2386 (gnus-add-wash-type 'face)
2387 (gnus-add-image 'face image)
2388 (gnus-put-image image nil 'face))))))))))
2390 (defun article-display-x-face (&optional force)
2391 "Look for an X-Face header and display it if present."
2392 (interactive (list 'force))
2393 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2394 (gnus-with-article-headers
2395 ;; Delete the old process, if any.
2396 (when (process-status "article-x-face")
2397 (delete-process "article-x-face"))
2398 ;; See the comment in `article-display-face'.
2399 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2400 ;; We have already displayed X-Faces, so we remove them
2402 (gnus-delete-images 'xface)
2404 (let (x-faces from face)
2405 (save-current-buffer
2406 (when (and wash-face-p
2407 (gnus-buffer-live-p gnus-original-article-buffer)
2408 (not (re-search-forward "^X-Face:[\t ]*" nil t)))
2409 ;; If type `W f', use gnus-original-article-buffer,
2410 ;; otherwise use the current buffer because displaying
2411 ;; RFC822 parts calls this function too.
2412 (set-buffer gnus-original-article-buffer))
2414 (mail-narrow-to-head)
2415 (while (gnus-article-goto-header "X-Face")
2416 (push (mail-header-field-value) x-faces))
2417 (setq from (message-fetch-field "from"))))
2418 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2419 ;; single external face.
2420 (when (stringp gnus-article-x-face-command)
2421 (setq x-faces (list (car x-faces))))
2423 gnus-article-x-face-command
2425 ;; Check whether this face is censored.
2426 (not gnus-article-x-face-too-ugly)
2428 (not (string-match gnus-article-x-face-too-ugly
2430 (while (setq face (pop x-faces))
2431 ;; We display the face.
2432 (cond ((stringp gnus-article-x-face-command)
2433 ;; The command is a string, so we interpret the command
2434 ;; as a, well, command, and fork it off.
2435 (let ((process-connection-type nil))
2436 (gnus-set-process-query-on-exit-flag
2438 "article-x-face" nil shell-file-name
2439 shell-command-switch gnus-article-x-face-command)
2443 (process-send-region "article-x-face"
2444 (point-min) (point-max)))
2445 (process-send-eof "article-x-face")))
2446 ((functionp gnus-article-x-face-command)
2447 ;; The command is a lisp function, so we call it.
2448 (funcall gnus-article-x-face-command face))
2450 (error "%s is not a function"
2451 gnus-article-x-face-command))))))))))
2453 (defun article-decode-mime-words ()
2454 "Decode all MIME-encoded words in the article."
2456 (gnus-with-article-buffer
2457 (let ((inhibit-point-motion-hooks t)
2458 (mail-parse-charset gnus-newsgroup-charset)
2459 (mail-parse-ignored-charsets
2460 (with-current-buffer gnus-summary-buffer
2461 gnus-newsgroup-ignored-charsets)))
2462 (mail-decode-encoded-word-region (point-min) (point-max)))))
2464 (defun article-decode-charset (&optional prompt)
2465 "Decode charset-encoded text in the article.
2466 If PROMPT (the prefix), prompt for a coding system to use."
2468 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2469 (inhibit-read-only t)
2470 (mail-parse-charset gnus-newsgroup-charset)
2471 (mail-parse-ignored-charsets
2472 (save-excursion (condition-case nil
2473 (set-buffer gnus-summary-buffer)
2475 gnus-newsgroup-ignored-charsets))
2476 ct cte ctl charset format)
2479 (article-narrow-to-head)
2480 (setq ct (message-fetch-field "Content-Type" t)
2481 cte (message-fetch-field "Content-Transfer-Encoding" t)
2482 ctl (and ct (mail-header-parse-content-type ct))
2485 (mm-read-coding-system "Charset to decode: "))
2487 (mail-content-type-get ctl 'charset)))
2488 format (and ctl (mail-content-type-get ctl 'format)))
2490 (setq cte (mail-header-strip cte)))
2491 (if (and ctl (not (string-match "/" (car ctl))))
2493 (goto-char (point-max)))
2496 (narrow-to-region (point) (point-max))
2497 (when (and (eq mail-parse-charset 'gnus-decoded)
2498 (eq (mm-body-7-or-8) '8bit))
2499 ;; The text code could have been decoded.
2500 (setq charset mail-parse-charset))
2501 (when (and (or (not ctl)
2502 (equal (car ctl) "text/plain"))
2503 (not format)) ;; article with format will decode later.
2505 charset (and cte (intern (downcase
2506 (gnus-strip-whitespace cte))))
2509 (defun article-decode-encoded-words ()
2510 "Remove encoded-word encoding from headers."
2511 (let ((inhibit-point-motion-hooks t)
2512 (mail-parse-charset gnus-newsgroup-charset)
2513 (mail-parse-ignored-charsets
2514 (save-excursion (condition-case nil
2515 (set-buffer gnus-summary-buffer)
2517 gnus-newsgroup-ignored-charsets))
2518 (inhibit-read-only t))
2520 (article-narrow-to-head)
2521 (funcall gnus-decode-header-function (point-min) (point-max)))))
2523 (defun article-decode-group-name ()
2524 "Decode group names in `Newsgroups:'."
2525 (let ((inhibit-point-motion-hooks t)
2526 (inhibit-read-only t)
2527 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2528 (when (and (or gnus-group-name-charset-method-alist
2529 gnus-group-name-charset-group-alist)
2530 (gnus-buffer-live-p gnus-original-article-buffer))
2532 (article-narrow-to-head)
2533 (with-current-buffer gnus-original-article-buffer
2534 (goto-char (point-min)))
2535 (while (re-search-forward
2536 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2537 (replace-match (save-match-data
2538 (gnus-decode-newsgroups
2539 ;; XXX how to use data in article buffer?
2540 (with-current-buffer gnus-original-article-buffer
2542 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2545 gnus-newsgroup-name method))
2547 (goto-char (point-min))
2548 (with-current-buffer gnus-original-article-buffer
2549 (goto-char (point-min)))
2550 (while (re-search-forward
2551 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2552 (replace-match (save-match-data
2553 (gnus-decode-newsgroups
2554 ;; XXX how to use data in article buffer?
2555 (with-current-buffer gnus-original-article-buffer
2557 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2560 gnus-newsgroup-name method))
2563 (autoload 'idna-to-unicode "idna")
2565 (defun article-decode-idna-rhs ()
2566 "Decode IDNA strings in RHS in various headers in current buffer.
2567 The following headers are decoded: From:, To:, Cc:, Reply-To:,
2568 Mail-Reply-To: and Mail-Followup-To:."
2571 (let ((inhibit-point-motion-hooks t)
2572 (inhibit-read-only t))
2573 (article-narrow-to-head)
2574 (goto-char (point-min))
2575 (while (re-search-forward "@[^ \t\n\r,>]*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2577 (when (save-match-data
2578 (and (setq ace (match-string 1))
2580 (and (re-search-backward "^[^ \t]" nil t)
2581 (looking-at "From\\|To\\|Cc\\|Reply-To\\|Mail-Reply-To\\|Mail-Followup-To")))
2582 (setq unicode (idna-to-unicode ace))))
2583 (unless (string= ace unicode)
2584 (replace-match unicode nil nil nil 1)))))))))
2586 (defun article-de-quoted-unreadable (&optional force read-charset)
2587 "Translate a quoted-printable-encoded article.
2588 If FORCE, decode the article whether it is marked as quoted-printable
2590 If READ-CHARSET, ask for a coding system."
2591 (interactive (list 'force current-prefix-arg))
2593 (let ((inhibit-read-only t) type charset)
2594 (if (gnus-buffer-live-p gnus-original-article-buffer)
2595 (with-current-buffer gnus-original-article-buffer
2597 (gnus-fetch-field "content-transfer-encoding"))
2598 (let* ((ct (gnus-fetch-field "content-type"))
2599 (ctl (and ct (mail-header-parse-content-type ct))))
2600 (setq charset (and ctl
2601 (mail-content-type-get ctl 'charset)))
2602 (if (stringp charset)
2603 (setq charset (intern (downcase charset)))))))
2605 (setq charset (mm-read-coding-system "Charset: " charset)))
2607 (setq charset gnus-newsgroup-charset))
2609 (and type (let ((case-fold-search t))
2610 (string-match "quoted-printable" type))))
2612 (quoted-printable-decode-region
2613 (point) (point-max) (mm-charset-to-coding-system charset))))))
2615 (defun article-de-base64-unreadable (&optional force read-charset)
2616 "Translate a base64 article.
2617 If FORCE, decode the article whether it is marked as base64 not.
2618 If READ-CHARSET, ask for a coding system."
2619 (interactive (list 'force current-prefix-arg))
2621 (let ((inhibit-read-only t) type charset)
2622 (if (gnus-buffer-live-p gnus-original-article-buffer)
2623 (with-current-buffer gnus-original-article-buffer
2625 (gnus-fetch-field "content-transfer-encoding"))
2626 (let* ((ct (gnus-fetch-field "content-type"))
2627 (ctl (and ct (mail-header-parse-content-type ct))))
2628 (setq charset (and ctl
2629 (mail-content-type-get ctl 'charset)))
2630 (if (stringp charset)
2631 (setq charset (intern (downcase charset)))))))
2633 (setq charset (mm-read-coding-system "Charset: " charset)))
2635 (setq charset gnus-newsgroup-charset))
2637 (and type (let ((case-fold-search t))
2638 (string-match "base64" type))))
2641 (narrow-to-region (point) (point-max))
2642 (base64-decode-region (point-min) (point-max))
2643 (mm-decode-coding-region
2644 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2649 (defun article-decode-HZ ()
2650 "Translate a HZ-encoded article."
2654 (let ((inhibit-read-only t))
2655 (rfc1843-decode-region (point-min) (point-max)))))
2657 (defun article-unsplit-urls ()
2658 "Remove the newlines that some other mailers insert into URLs."
2661 (let ((inhibit-read-only t))
2662 (goto-char (point-min))
2663 (while (re-search-forward
2664 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2665 (replace-match "\\1\\3" t)))
2666 (when (interactive-p)
2667 (gnus-treat-article nil))))
2670 (defun article-wash-html (&optional read-charset)
2671 "Format an HTML article.
2672 If READ-CHARSET, ask for a coding system. If it is a number, the
2673 charset defined in `gnus-summary-show-article-charset-alist' is used."
2676 (let ((inhibit-read-only t)
2679 (if (or (and (numberp read-charset)
2683 gnus-summary-show-article-charset-alist))))
2684 (setq charset (mm-read-coding-system "Charset: ")))
2685 (let ((gnus-summary-show-article-charset-alist
2686 (list (cons 1 charset))))
2687 (with-current-buffer gnus-summary-buffer
2688 (gnus-summary-show-article 1)))
2689 (error "No charset is given"))
2690 (when (gnus-buffer-live-p gnus-original-article-buffer)
2691 (with-current-buffer gnus-original-article-buffer
2692 (let* ((ct (gnus-fetch-field "content-type"))
2693 (ctl (and ct (mail-header-parse-content-type ct))))
2694 (setq charset (and ctl
2695 (mail-content-type-get ctl 'charset)))
2696 (when (stringp charset)
2697 (setq charset (intern (downcase charset)))))))
2699 (setq charset gnus-newsgroup-charset)))
2701 (save-window-excursion
2703 (narrow-to-region (point) (point-max))
2704 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2705 (entry (assq func mm-text-html-washer-alist)))
2707 (setq func (cdr entry)))
2712 (apply (car func) (cdr func))))))))))
2714 (defun gnus-article-wash-html-with-w3 ()
2715 "Wash the current buffer with w3."
2717 (let ((w3-strict-width (window-width))
2718 (url-standalone-mode t)
2719 (url-gateway-unplugged t)
2720 (w3-honor-stylesheets nil))
2722 (w3-region (point-min) (point-max))
2725 (defun gnus-article-wash-html-with-w3m ()
2726 "Wash the current buffer with emacs-w3m."
2728 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2729 w3m-force-redisplay)
2730 (w3m-region (point-min) (point-max)))
2731 (when (and mm-inline-text-html-with-w3m-keymap
2732 (boundp 'w3m-minor-mode-map)
2734 (add-text-properties
2735 (point-min) (point-max)
2736 (list 'keymap w3m-minor-mode-map
2737 ;; Put the mark meaning this part was rendered by emacs-w3m.
2738 'mm-inline-text-html-with-w3m t))))
2740 (eval-when-compile (defvar charset)) ;; Bound by `article-wash-html'.
2742 (defun gnus-article-wash-html-with-w3m-standalone ()
2743 "Wash the current buffer with w3m."
2744 (if (mm-w3m-standalone-supports-m17n-p)
2746 (unless (mm-coding-system-p charset) ;; Bound by `article-wash-html'.
2748 (setq charset 'iso-8859-1))
2749 (let ((coding-system-for-write charset)
2750 (coding-system-for-read charset))
2751 (call-process-region
2752 (point-min) (point-max)
2753 "w3m" t t nil "-dump" "-T" "text/html"
2754 "-I" (symbol-name charset) "-O" (symbol-name charset))))
2755 (mm-inline-wash-with-stdin nil "w3m" "-dump" "-T" "text/html")))
2757 (defvar gnus-article-browse-html-temp-list nil
2758 "List of temporary files created by `gnus-article-browse-html-parts'.
2759 Internal variable.")
2761 (defcustom gnus-article-browse-delete-temp 'ask
2762 "What to do with temporary files from `gnus-article-browse-html-parts'.
2763 If nil, don't delete temporary files. If it is t, delete them on
2764 exit from the summary buffer. If it is the symbol `file', query
2765 on each file, if it is `ask' ask once when exiting from the
2767 :group 'gnus-article
2768 :version "23.0" ;; No Gnus
2769 :type '(choice (const :tag "Don't delete" nil)
2770 (const :tag "Don't ask" t)
2771 (const :tag "Ask" ask)
2772 (const :tag "Ask for each file" file)))
2774 ;; Cf. mm-postponed-undisplay-list / mm-destroy-postponed-undisplay-list.
2776 (defun gnus-article-browse-delete-temp-files (&optional how)
2777 "Delete temp-files created by `gnus-article-browse-html-parts'."
2778 (when (and gnus-article-browse-html-temp-list
2780 (setq how gnus-article-browse-delete-temp)))
2781 (when (and (eq how 'ask)
2783 "Delete all %s temporary HTML file(s)? "
2784 (length gnus-article-browse-html-temp-list)))
2786 (dolist (file gnus-article-browse-html-temp-list)
2787 (when (and (file-exists-p file)
2789 ;; `how' is neither `nil', `ask' nor `t' (i.e. `file'):
2791 (format "Delete temporary HTML file `%s'? " file))))
2792 (delete-file file)))
2793 ;; Also remove file from the list when not deleted or if file doesn't
2795 (setq gnus-article-browse-html-temp-list nil))
2796 gnus-article-browse-html-temp-list)
2798 (defun gnus-article-browse-html-parts (list)
2799 "View all \"text/html\" parts from LIST.
2800 Recurse into multiparts."
2801 ;; Internal function used by `gnus-article-browse-html-article'.
2803 ;; Find and show the html-parts.
2804 (dolist (handle list)
2805 ;; If HTML, show it:
2806 (when (listp handle)
2807 (cond ((and (bufferp (car handle))
2808 (string-match "text/html" (car (mm-handle-type handle))))
2809 (let ((tmp-file (mm-make-temp-file
2810 ;; Do we need to care for 8.3 filenames?
2811 "mm-" nil ".html")))
2812 (mm-save-part-to-file handle tmp-file)
2813 (add-to-list 'gnus-article-browse-html-temp-list tmp-file)
2814 (add-hook 'gnus-summary-prepare-exit-hook
2815 'gnus-article-browse-delete-temp-files)
2816 (add-hook 'gnus-exit-gnus-hook
2818 (gnus-article-browse-delete-temp-files t)))
2819 (browse-url tmp-file)
2821 ;; If multipart, recurse
2822 ((and (stringp (car handle))
2823 (string-match "^multipart/" (car handle))
2826 (gnus-article-browse-html-parts handle))))))))
2829 (defun gnus-article-browse-html-article ()
2830 "View \"text/html\" parts of the current article with a WWW browser."
2832 (save-window-excursion
2833 ;; Open raw article and select the buffer
2834 (gnus-summary-show-article t)
2835 (gnus-summary-select-article-buffer)
2836 (let ((parts (mm-dissect-buffer t t)))
2837 ;; If singlepart, enforce a list.
2838 (when (and (bufferp (car parts))
2839 (stringp (car (mm-handle-type parts))))
2840 (setq parts (list parts)))
2842 (unless (gnus-article-browse-html-parts parts)
2843 (gnus-error 3 "Mail doesn't contain a \"text/html\" part!"))
2844 (gnus-summary-show-article))))
2846 (defun article-hide-list-identifiers ()
2847 "Remove list identifies from the Subject header.
2848 The `gnus-list-identifiers' variable specifies what to do."
2850 (let ((inhibit-point-motion-hooks t)
2851 (regexp (if (consp gnus-list-identifiers)
2852 (mapconcat 'identity gnus-list-identifiers " *\\|")
2853 gnus-list-identifiers))
2854 (inhibit-read-only t))
2858 (article-narrow-to-head)
2859 (goto-char (point-min))
2860 (while (re-search-forward
2861 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2863 (delete-region (match-beginning 2) (match-end 0))
2864 (beginning-of-line))
2865 (when (re-search-forward
2866 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2867 (delete-region (match-beginning 1) (match-end 1))))))))
2869 (defun article-hide-pem (&optional arg)
2870 "Toggle hiding of any PEM headers and signatures in the current article.
2871 If given a negative prefix, always show; if given a positive prefix,
2873 (interactive (gnus-article-hidden-arg))
2874 (unless (gnus-article-check-hidden-text 'pem arg)
2876 (let ((inhibit-read-only t) end)
2877 (goto-char (point-min))
2878 ;; Hide the horrendously ugly "header".
2879 (when (and (search-forward
2880 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2882 (setq end (1+ (match-beginning 0))))
2883 (gnus-add-wash-type 'pem)
2884 (gnus-article-hide-text-type
2886 (if (search-forward "\n\n" nil t)
2890 ;; Hide the trailer as well
2891 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2893 (gnus-article-hide-text-type
2894 (match-beginning 0) (match-end 0) 'pem)))))))
2896 (defun article-strip-banner ()
2897 "Strip the banners specified by the `banner' group parameter and by
2898 `gnus-article-address-banner-alist'."
2902 (let ((inhibit-point-motion-hooks t))
2903 (when (gnus-parameter-banner gnus-newsgroup-name)
2904 (article-really-strip-banner
2905 (gnus-parameter-banner gnus-newsgroup-name)))
2906 (when gnus-article-address-banner-alist
2907 ;; Note that the From header is decoded here, so it is
2908 ;; required that the *-extract-address-components function
2909 ;; supports non-ASCII text.
2910 (let ((from (save-restriction
2912 (article-narrow-to-head)
2913 (mail-fetch-field "from"))))
2916 (cadr (funcall gnus-extract-address-components
2919 (dolist (pair gnus-article-address-banner-alist)
2920 (when (string-match (car pair) from)
2922 (article-really-strip-banner (cdr pair)))))))))))))
2924 (defun article-really-strip-banner (banner)
2925 "Strip the banner specified by the argument."
2928 (let ((inhibit-point-motion-hooks t)
2929 (gnus-signature-limit nil)
2930 (inhibit-read-only t))
2933 ((eq banner 'signature)
2934 (when (gnus-article-narrow-to-signature)
2937 (delete-region (point) (point-max))))
2939 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2940 (while (re-search-forward banner nil t)
2941 (delete-region (match-beginning 0) (match-end 0)))))
2943 (while (re-search-forward banner nil t)
2944 (delete-region (match-beginning 0) (match-end 0)))))))))
2946 (defun article-babel ()
2947 "Translate article using an online translation service."
2950 (gnus-with-article-buffer
2951 (when (article-goto-body)
2952 (let* ((start (point))
2954 (orig (buffer-substring start end))
2955 (trans (babel-as-string orig)))
2957 (narrow-to-region start end)
2958 (delete-region start end)
2961 (defun article-hide-signature (&optional arg)
2962 "Hide the signature in the current article.
2963 If given a negative prefix, always show; if given a positive prefix,
2965 (interactive (gnus-article-hidden-arg))
2966 (unless (gnus-article-check-hidden-text 'signature arg)
2969 (let ((inhibit-read-only t))
2970 (when (gnus-article-narrow-to-signature)
2971 (gnus-article-hide-text-type
2972 (point-min) (point-max) 'signature))))))
2973 (gnus-set-mode-line 'article))
2975 (defun article-strip-headers-in-body ()
2976 "Strip offensive headers from bodies."
2980 (let ((case-fold-search t))
2981 (when (looking-at "x-no-archive:")
2982 (gnus-delete-line)))))
2984 (defun article-strip-leading-blank-lines ()
2985 "Remove all blank lines from the beginning of the article."
2988 (let ((inhibit-point-motion-hooks t)
2989 (inhibit-read-only t))
2990 (when (article-goto-body)
2991 (while (and (not (eobp))
2992 (looking-at "[ \t]*$"))
2993 (gnus-delete-line))))))
2995 (defun article-narrow-to-head ()
2996 "Narrow the buffer to the head of the message.
2997 Point is left at the beginning of the narrowed-to region."
2999 (goto-char (point-min))
3000 (if (search-forward "\n\n" nil 1)
3003 (goto-char (point-min)))
3005 (defun article-goto-body ()
3006 "Place point at the start of the body."
3007 (goto-char (point-min))
3009 ;; This variable is only bound when dealing with separate
3011 (article-goto-body-goes-to-point-min-p
3013 ((search-forward "\n\n" nil t)
3016 (goto-char (point-max))
3019 (defun article-strip-multiple-blank-lines ()
3020 "Replace consecutive blank lines with one empty line."
3023 (let ((inhibit-point-motion-hooks t)
3024 (inhibit-read-only t))
3025 ;; First make all blank lines empty.
3027 (while (re-search-forward "^[ \t]+$" nil t)
3028 (unless (gnus-annotation-in-region-p
3029 (match-beginning 0) (match-end 0))
3030 (replace-match "" nil t)))
3031 ;; Then replace multiple empty lines with a single empty line.
3033 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
3034 (unless (gnus-annotation-in-region-p
3035 (match-beginning 0) (match-end 0))
3036 (delete-region (match-beginning 1) (match-end 1)))))))
3038 (defun article-strip-leading-space ()
3039 "Remove all white space from the beginning of the lines in the article."
3042 (let ((inhibit-point-motion-hooks t)
3043 (inhibit-read-only t))
3045 (while (re-search-forward "^[ \t]+" nil t)
3046 (replace-match "" t t)))))
3048 (defun article-strip-trailing-space ()
3049 "Remove all white space from the end of the lines in the article."
3052 (let ((inhibit-point-motion-hooks t)
3053 (inhibit-read-only t))
3055 (while (re-search-forward "[ \t]+$" nil t)
3056 (replace-match "" t t)))))
3058 (defun article-strip-blank-lines ()
3059 "Strip leading, trailing and multiple blank lines."
3061 (article-strip-leading-blank-lines)
3062 (article-remove-trailing-blank-lines)
3063 (article-strip-multiple-blank-lines))
3065 (defun article-strip-all-blank-lines ()
3066 "Strip all blank lines."
3069 (let ((inhibit-point-motion-hooks t)
3070 (inhibit-read-only t))
3072 (while (re-search-forward "^[ \t]*\n" nil t)
3073 (replace-match "" t t)))))
3075 (defun gnus-article-narrow-to-signature ()
3076 "Narrow to the signature; return t if a signature is found, else nil."
3077 (let ((inhibit-point-motion-hooks t))
3078 (when (gnus-article-search-signature)
3080 ;; Check whether we have some limits to what we consider
3081 ;; to be a signature.
3082 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
3083 (list gnus-signature-limit)))
3085 (while (setq limit (pop limits))
3086 (if (or (and (integerp limit)
3087 (< (- (point-max) (point)) limit))
3089 (< (count-lines (point) (point-max)) limit))
3090 (and (functionp limit)
3092 (and (stringp limit)
3093 (not (re-search-forward limit nil t))))
3094 () ; This limit did not succeed.
3098 (narrow-to-region (point) (point-max))
3101 (defun gnus-article-search-signature ()
3102 "Search the current buffer for the signature separator.
3103 Put point at the beginning of the signature separator."
3104 (let ((cur (point)))
3105 (goto-char (point-max))
3106 (if (if (stringp gnus-signature-separator)
3107 (re-search-backward gnus-signature-separator nil t)
3108 (let ((seps gnus-signature-separator))
3110 (not (re-search-backward (car seps) nil t)))
3117 (defun gnus-article-hidden-arg ()
3118 "Return the current prefix arg as a number, or 0 if no prefix."
3119 (list (if current-prefix-arg
3120 (prefix-numeric-value current-prefix-arg)
3123 (defun gnus-article-check-hidden-text (type arg)
3124 "Return nil if hiding is necessary.
3125 Arg can be nil or a number. nil and positive means hide, negative
3126 means show, 0 means toggle."
3129 (let ((hide (gnus-article-hidden-text-p type)))
3135 (gnus-article-show-hidden-text type)
3138 (if (eq hide 'hidden)
3140 (gnus-article-show-hidden-text type)
3144 (defun gnus-article-hidden-text-p (type)
3145 "Say whether the current buffer contains hidden text of type TYPE."
3146 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
3148 (not (get-text-property pos 'invisible))
3149 (not (get-text-property pos 'dummy-invisible)))
3151 (text-property-any (1+ pos) (point-max) 'article-type type)))
3156 (defun gnus-article-show-hidden-text (type &optional dummy)
3157 "Show all hidden text of type TYPE.
3158 Originally it is hide instead of DUMMY."
3159 (let ((inhibit-read-only t)
3160 (inhibit-point-motion-hooks t))
3161 (gnus-remove-text-properties-when
3163 (point-min) (point-max)
3164 (cons 'article-type (cons type
3165 gnus-hidden-properties)))
3166 (gnus-delete-wash-type type)))
3168 (defconst article-time-units
3169 `((year . ,(* 365.25 24 60 60))
3170 (week . ,(* 7 24 60 60))
3171 (day . ,(* 24 60 60))
3175 "Mapping from time units to seconds.")
3177 (defun gnus-article-forward-header ()
3178 "Move point to the start of the next header.
3179 If the current header is a continuation header, this can be several
3184 (if (looking-at "[ \t]+[^ \t]")
3188 (defun article-date-ut (&optional type highlight)
3189 "Convert DATE date to universal time in the current article.
3190 If TYPE is `local', convert to local time; if it is `lapsed', output
3191 how much time has lapsed since DATE. For `lapsed', the value of
3192 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
3193 should replace the \"Date:\" one, or should be added below it."
3194 (interactive (list 'ut t))
3195 (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
3196 (date-regexp (cond ((not gnus-article-date-lapsed-new-header)
3200 (article-lapsed-timer
3204 (case-fold-search t)
3205 (inhibit-read-only t)
3206 (inhibit-point-motion-hooks t)
3207 pos date bface eface)
3211 (goto-char (point-min))
3212 (while (or (setq date (get-text-property (setq pos (point))
3214 (when (setq pos (next-single-property-change
3215 (point) 'original-date))
3216 (setq date (get-text-property pos 'original-date))
3218 (narrow-to-region pos (or (text-property-any pos (point-max)
3221 (goto-char (point-min))
3222 (when (re-search-forward tdate-regexp nil t)
3223 (setq bface (get-text-property (point-at-bol) 'face)
3224 eface (get-text-property (1- (point-at-eol)) 'face)))
3225 (goto-char (point-min))
3227 ;; Delete any old Date headers.
3228 (while (re-search-forward date-regexp nil t)
3230 (delete-region (point-at-bol) (progn
3231 (gnus-article-forward-header)
3233 (delete-region (point-at-bol) (progn
3234 (gnus-article-forward-header)
3237 (setq pos (point))))
3238 (when (and (not pos)
3239 (re-search-forward tdate-regexp nil t))
3241 (gnus-goto-char pos)
3242 (insert (article-make-date-line date (or type 'ut)))
3248 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
3249 (put-text-property (match-beginning 1) (1+ (match-end 1))
3251 (put-text-property (match-beginning 2) (match-end 2)
3253 (put-text-property (point-min) (1- (point-max)) 'original-date date)
3254 (goto-char (point-max))
3257 (defun article-make-date-line (date type)
3258 "Return a DATE line of TYPE."
3259 (unless (memq type '(local ut original user iso8601 lapsed english))
3260 (error "Unknown conversion type: %s" type))
3262 (let ((time (date-to-time date)))
3264 ;; Convert to the local timezone.
3266 (concat "Date: " (message-make-date time)))
3267 ;; Convert to Universal Time.
3272 (let* ((e (parse-time-string date))
3273 (tm (apply 'encode-time e))
3275 (ls (- (cadr tm) (car (current-time-zone time)))))
3276 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
3277 ((> ls 65535) (list (1+ ms) (- ls 65536)))
3281 ;; Get the original date from the article.
3282 ((eq type 'original)
3283 (concat "Date: " (if (string-match "\n+$" date)
3284 (substring date 0 (match-beginning 0))
3286 ;; Let the user define the format.
3288 (let ((format (or (condition-case nil
3289 (with-current-buffer gnus-summary-buffer
3290 gnus-article-time-format)
3292 gnus-article-time-format)))
3293 (if (functionp format)
3294 (funcall format time)
3295 (concat "Date: " (format-time-string format time)))))
3298 (let ((tz (car (current-time-zone time))))
3301 (format-time-string "%Y%m%dT%H%M%S" time)
3302 (format "%s%02d%02d"
3303 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3304 (/ (% (abs tz) 3600) 60)))))
3305 ;; Do an X-Sent lapsed format.
3307 ;; If the date is seriously mangled, the timezone functions are
3308 ;; liable to bug out, so we ignore all errors.
3309 (let* ((now (current-time))
3310 (real-time (subtract-time now time))
3311 (real-sec (and real-time
3312 (+ (* (float (car real-time)) 65536)
3314 (sec (and real-time (abs real-sec)))
3324 ;; This is a bit convoluted, but basically we go
3325 ;; through the time units for years, weeks, etc,
3326 ;; and divide things to see whether that results
3327 ;; in positive answers.
3330 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3331 ;; The (remaining) seconds are too few to
3332 ;; be divided into this time unit.
3334 ;; It's big enough, so we output it.
3335 (setq sec (- sec (* num (cdr unit))))
3337 (concat (if prev ", " "") (int-to-string
3339 " " (symbol-name (car unit))
3340 (if (> num 1) "s" ""))
3342 article-time-units "")
3343 ;; If dates are odd, then it might appear like the
3344 ;; article was sent in the future.
3347 " in the future"))))))
3348 ;; Display the date in proper English
3350 (let ((dtime (decode-time time)))
3353 (number-to-string (nth 3 dtime))
3354 (let ((digit (% (nth 3 dtime) 10)))
3356 ((memq (nth 3 dtime) '(11 12 13)) "th")
3362 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3364 (number-to-string (nth 5 dtime))
3366 (format "%02d" (nth 2 dtime))
3368 (format "%02d" (nth 1 dtime)))))))
3370 (format "Date: %s (from Gnus)" date))))
3372 (defun article-date-local (&optional highlight)
3373 "Convert the current article date to the local timezone."
3374 (interactive (list t))
3375 (article-date-ut 'local highlight))
3377 (defun article-date-english (&optional highlight)
3378 "Convert the current article date to something that is proper English."
3379 (interactive (list t))
3380 (article-date-ut 'english highlight))
3382 (defun article-date-original (&optional highlight)
3383 "Convert the current article date to what it was originally.
3384 This is only useful if you have used some other date conversion
3385 function and want to see what the date was before converting."
3386 (interactive (list t))
3387 (article-date-ut 'original highlight))
3389 (defun article-date-lapsed (&optional highlight)
3390 "Convert the current article date to time lapsed since it was sent."
3391 (interactive (list t))
3392 (article-date-ut 'lapsed highlight))
3394 (defun article-update-date-lapsed ()
3395 "Function to be run from a timer to update the lapsed time line."
3397 (let (deactivate-mark)
3402 (set-buffer (window-buffer w))
3403 (when (eq major-mode 'gnus-article-mode)
3404 (let ((mark (point-marker)))
3405 (goto-char (point-min))
3406 (when (re-search-forward "^X-Sent:" nil t)
3407 (article-date-lapsed t))
3408 (goto-char (marker-position mark))
3409 (move-marker mark nil))))
3412 (defun gnus-start-date-timer (&optional n)
3413 "Start a timer to update the X-Sent header in the article buffers.
3414 The numerical prefix says how frequently (in seconds) the function
3419 (gnus-stop-date-timer)
3420 (setq article-lapsed-timer
3421 (run-at-time 1 n 'article-update-date-lapsed)))
3423 (defun gnus-stop-date-timer ()
3424 "Stop the X-Sent timer."
3426 (when article-lapsed-timer
3427 (nnheader-cancel-timer article-lapsed-timer)
3428 (setq article-lapsed-timer nil)))
3430 (defun article-date-user (&optional highlight)
3431 "Convert the current article date to the user-defined format.
3432 This format is defined by the `gnus-article-time-format' variable."
3433 (interactive (list t))
3434 (article-date-ut 'user highlight))
3436 (defun article-date-iso8601 (&optional highlight)
3437 "Convert the current article date to ISO8601."
3438 (interactive (list t))
3439 (article-date-ut 'iso8601 highlight))
3441 (defmacro gnus-article-save-original-date (&rest forms)
3442 "Save the original date as a text property and evaluate FORMS."
3443 `(let* ((case-fold-search t)
3445 (goto-char (point-min))
3446 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3449 (date (when (and start
3450 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3452 (buffer-substring-no-properties start
3453 (match-beginning 0)))))
3454 (goto-char (point-max))
3455 (skip-chars-backward "\n")
3456 (put-text-property (point-min) (point) 'original-date date)
3458 (goto-char (point-max))
3459 (skip-chars-backward "\n")
3460 (put-text-property (point-min) (point) 'original-date date)))
3462 ;; (defun article-show-all ()
3463 ;; "Show all hidden text in the article buffer."
3466 ;; (let ((inhibit-read-only t))
3467 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3469 (defun article-remove-leading-whitespace ()
3470 "Remove excessive whitespace from all headers."
3474 (let ((inhibit-read-only t))
3475 (article-narrow-to-head)
3476 (goto-char (point-min))
3477 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3478 (delete-region (match-beginning 1) (match-end 1)))))))
3480 (defun article-emphasize (&optional arg)
3481 "Emphasize text according to `gnus-emphasis-alist'."
3482 (interactive (gnus-article-hidden-arg))
3483 (unless (gnus-article-check-hidden-text 'emphasis arg)
3487 (with-current-buffer gnus-summary-buffer
3488 gnus-article-emphasis-alist)
3490 gnus-emphasis-alist))
3491 (inhibit-read-only t)
3492 (props (append '(article-type emphasis)
3493 gnus-hidden-properties))
3494 regexp elem beg invisible visible face)
3497 (while (setq elem (pop alist))
3499 (setq regexp (car elem)
3500 invisible (nth 1 elem)
3501 visible (nth 2 elem)
3503 (while (re-search-forward regexp nil t)
3504 (when (and (match-beginning visible) (match-beginning invisible))
3505 (gnus-article-hide-text
3506 (match-beginning invisible) (match-end invisible) props)
3507 (gnus-article-unhide-text-type
3508 (match-beginning visible) (match-end visible) 'emphasis)
3509 (gnus-put-overlay-excluding-newlines
3510 (match-beginning visible) (match-end visible) 'face face)
3511 (gnus-add-wash-type 'emphasis)
3512 (goto-char (match-end invisible)))))))))
3514 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3515 "Setup newsgroup emphasis alist."
3516 (unless gnus-article-emphasis-alist
3517 (let ((name (and gnus-newsgroup-name
3518 (gnus-group-real-name gnus-newsgroup-name))))
3519 (make-local-variable 'gnus-article-emphasis-alist)
3520 (setq gnus-article-emphasis-alist
3522 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3523 (while (setq elem (pop alist))
3524 (when (and name (string-match (car elem) name))
3526 highlight (copy-sequence (cdr elem)))))
3528 (copy-sequence highlight-words)
3529 (if gnus-newsgroup-name
3530 (copy-sequence (gnus-group-find-parameter
3531 gnus-newsgroup-name 'highlight-words t)))
3532 gnus-emphasis-alist)))))
3535 (defvar gnus-summary-article-menu)
3536 (defvar gnus-summary-post-menu))
3538 ;;; Saving functions.
3540 (defun gnus-article-save (save-buffer file &optional num)
3541 "Save the currently selected article."
3542 (when (or (get gnus-default-article-saver :headers)
3543 (not gnus-save-all-headers))
3544 ;; Remove headers according to `gnus-saved-headers' or the value
3545 ;; of the `:headers' property that the saver function might have.
3546 (let ((gnus-visible-headers
3547 (or (symbol-value (get gnus-default-article-saver :headers))
3548 gnus-saved-headers gnus-visible-headers))
3549 (gnus-article-buffer save-buffer))
3551 (set-buffer save-buffer)
3552 (article-hide-headers 1 t))))
3553 (save-window-excursion
3554 (if (not gnus-default-article-saver)
3555 (error "No default saver is defined")
3556 ;; !!! Magic! The saving functions all save
3557 ;; `gnus-save-article-buffer' (or so they think), but we
3558 ;; bind that variable to our save-buffer.
3559 (set-buffer gnus-article-buffer)
3560 (let* ((gnus-save-article-buffer save-buffer)
3563 ((not gnus-prompt-before-saving) 'default)
3564 ((eq gnus-prompt-before-saving 'always) nil)
3566 (gnus-number-of-articles-to-be-saved
3567 (when (eq gnus-prompt-before-saving t)
3569 (set-buffer gnus-article-current-summary)
3570 (funcall gnus-default-article-saver filename)))))
3572 (defun gnus-read-save-file-name (prompt &optional filename
3573 function group headers variable
3576 (funcall function group headers (symbol-value variable)))
3581 ((eq filename 'default)
3587 (when (symbol-value dir-var)
3588 (setq default-name (expand-file-name
3589 (file-name-nondirectory default-name)
3590 (symbol-value dir-var))))
3591 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3594 (if (and gnus-number-of-articles-to-be-saved
3595 (> gnus-number-of-articles-to-be-saved 1))
3596 (format "these %d articles"
3597 gnus-number-of-articles-to-be-saved)
3600 ;; Let the split methods have their say.
3602 ;; No split name was found.
3605 (concat prompt " (default "
3606 (file-name-nondirectory default-name) "): ")
3607 (file-name-directory default-name)
3609 ;; A single group name is returned.
3610 ((stringp split-name)
3612 (funcall function split-name headers
3613 (symbol-value variable)))
3615 (concat prompt " (default "
3616 (file-name-nondirectory default-name) "): ")
3617 (file-name-directory default-name)
3619 ;; A single split name was found
3620 ((= 1 (length split-name))
3621 (let* ((name (expand-file-name
3623 gnus-article-save-directory))
3624 (dir (cond ((file-directory-p name)
3625 (file-name-as-directory name))
3626 ((file-exists-p name) name)
3627 (t gnus-article-save-directory))))
3629 (concat prompt " (default " name "): ")
3631 ;; A list of splits was found.
3633 (setq split-name (nreverse split-name))
3635 (let ((file-name-history
3636 (nconc split-name file-name-history)))
3640 (concat prompt " (`M-p' for defaults): ")
3641 gnus-article-save-directory
3643 gnus-article-save-directory)))
3644 (car (push result file-name-history)))))))
3645 ;; Create the directory.
3646 (gnus-make-directory (file-name-directory file))
3647 ;; If we have read a directory, we append the default file name.
3648 (when (file-directory-p file)
3649 (setq file (expand-file-name (file-name-nondirectory
3651 (file-name-as-directory file))))
3652 ;; Possibly translate some characters.
3653 (nnheader-translate-file-chars file))))))
3654 (gnus-make-directory (file-name-directory result))
3656 (set variable result))
3658 (set dir-var (file-name-directory result)))
3661 (defun gnus-article-archive-name (group)
3662 "Return the first instance of an \"Archive-name\" in the current buffer."
3663 (let ((case-fold-search t))
3664 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3665 (nnheader-concat gnus-article-save-directory
3666 (match-string 1)))))
3668 (defun gnus-article-nndoc-name (group)
3669 "If GROUP is an nndoc group, return the name of the parent group."
3670 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3671 (gnus-group-get-parameter group 'save-article-group)))
3673 (defun gnus-summary-save-in-rmail (&optional filename)
3674 "Append this article to Rmail file.
3675 Optional argument FILENAME specifies file name.
3676 Directory to save to is default to `gnus-article-save-directory'."
3677 (setq filename (gnus-read-save-file-name
3678 "Save %s in rmail file" filename
3679 gnus-rmail-save-name gnus-newsgroup-name
3680 gnus-current-headers 'gnus-newsgroup-last-rmail))
3681 (gnus-eval-in-buffer-window gnus-save-article-buffer
3685 (gnus-output-to-rmail filename))))
3688 (defun gnus-summary-save-in-mail (&optional filename)
3689 "Append this article to Unix mail file.
3690 Optional argument FILENAME specifies file name.
3691 Directory to save to is default to `gnus-article-save-directory'."
3692 (setq filename (gnus-read-save-file-name
3693 "Save %s in Unix mail file" filename
3694 gnus-mail-save-name gnus-newsgroup-name
3695 gnus-current-headers 'gnus-newsgroup-last-mail))
3696 (gnus-eval-in-buffer-window gnus-save-article-buffer
3700 (if (and (file-readable-p filename)
3701 (file-regular-p filename)
3702 (mail-file-babyl-p filename))
3703 (rmail-output-to-rmail-file filename t)
3704 (gnus-output-to-mail filename)))))
3707 (put 'gnus-summary-save-in-file :decode t)
3708 (put 'gnus-summary-save-in-file :headers 'gnus-saved-headers)
3709 (defun gnus-summary-save-in-file (&optional filename overwrite)
3710 "Append this article to file.
3711 Optional argument FILENAME specifies file name.
3712 Directory to save to is default to `gnus-article-save-directory'."
3713 (setq filename (gnus-read-save-file-name
3714 "Save %s in file" filename
3715 gnus-file-save-name gnus-newsgroup-name
3716 gnus-current-headers 'gnus-newsgroup-last-file))
3717 (gnus-eval-in-buffer-window gnus-save-article-buffer
3721 (when (and overwrite
3722 (file-exists-p filename))
3723 (delete-file filename))
3724 (gnus-output-to-file filename))))
3727 (put 'gnus-summary-write-to-file :decode t)
3728 (put 'gnus-summary-write-to-file :function 'gnus-summary-save-in-file)
3729 (put 'gnus-summary-write-to-file :headers 'gnus-saved-headers)
3730 (defun gnus-summary-write-to-file (&optional filename)
3731 "Write this article to a file, overwriting it if the file exists.
3732 Optional argument FILENAME specifies file name.
3733 The directory to save in defaults to `gnus-article-save-directory'."
3734 (setq filename (gnus-read-save-file-name
3735 "Save %s in file" filename
3736 gnus-file-save-name gnus-newsgroup-name
3737 gnus-current-headers nil 'gnus-newsgroup-last-directory))
3738 (gnus-summary-save-in-file filename t))
3740 (put 'gnus-summary-save-body-in-file :decode t)
3741 (defun gnus-summary-save-body-in-file (&optional filename overwrite)
3742 "Append this article body to a file.
3743 Optional argument FILENAME specifies file name.
3744 The directory to save in defaults to `gnus-article-save-directory'."
3745 (setq filename (gnus-read-save-file-name
3746 "Save %s body in file" filename
3747 gnus-file-save-name gnus-newsgroup-name
3748 gnus-current-headers 'gnus-newsgroup-last-file))
3749 (gnus-eval-in-buffer-window gnus-save-article-buffer
3753 (when (article-goto-body)
3754 (narrow-to-region (point) (point-max)))
3755 (when (and overwrite
3756 (file-exists-p filename))
3757 (delete-file filename))
3758 (gnus-output-to-file filename))))
3761 (put 'gnus-summary-write-body-to-file :decode t)
3762 (put 'gnus-summary-write-body-to-file
3763 :function 'gnus-summary-save-body-in-file)
3764 (defun gnus-summary-write-body-to-file (&optional filename)
3765 "Write this article body to a file, overwriting it if the file exists.
3766 Optional argument FILENAME specifies file name.
3767 The directory to save in defaults to `gnus-article-save-directory'."
3768 (setq filename (gnus-read-save-file-name
3769 "Save %s body in file" filename
3770 gnus-file-save-name gnus-newsgroup-name
3771 gnus-current-headers nil 'gnus-newsgroup-last-directory))
3772 (gnus-summary-save-body-in-file filename t))
3774 (defun gnus-summary-save-in-pipe (&optional command)
3775 "Pipe this article to subprocess."
3777 (cond ((and (eq command 'default)
3778 gnus-last-shell-command)
3779 gnus-last-shell-command)
3784 "Shell command on %s: "
3785 (if (and gnus-number-of-articles-to-be-saved
3786 (> gnus-number-of-articles-to-be-saved 1))
3787 (format "these %d articles"
3788 gnus-number-of-articles-to-be-saved)
3790 gnus-last-shell-command))))
3791 (when (string-equal command "")
3792 (if gnus-last-shell-command
3793 (setq command gnus-last-shell-command)
3794 (error "A command is required")))
3795 (gnus-eval-in-buffer-window gnus-article-buffer
3798 (shell-command-on-region (point-min) (point-max) command nil)))
3799 (setq gnus-last-shell-command command))
3801 (defun gnus-summary-pipe-to-muttprint (&optional command)
3802 "Pipe this article to muttprint."
3803 (setq command (read-string
3804 "Print using command: " gnus-summary-muttprint-program
3805 nil gnus-summary-muttprint-program))
3806 (gnus-summary-save-in-pipe command))
3808 ;;; Article file names when saving.
3810 (defun gnus-capitalize-newsgroup (newsgroup)
3811 "Capitalize NEWSGROUP name."
3812 (when (not (zerop (length newsgroup)))
3813 (concat (char-to-string (upcase (aref newsgroup 0)))
3814 (substring newsgroup 1))))
3816 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3817 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3818 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3819 Otherwise, it is like ~/News/news/group/num."
3822 (concat (if (gnus-use-long-file-name 'not-save)
3823 (gnus-capitalize-newsgroup newsgroup)
3824 (gnus-newsgroup-directory-form newsgroup))
3825 "/" (int-to-string (mail-header-number headers)))
3826 gnus-article-save-directory)))
3828 (string-equal (file-name-directory default)
3829 (file-name-directory last-file))
3830 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3832 (or last-file default))))
3834 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3835 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3836 If variable `gnus-use-long-file-name' is non-nil, it is
3837 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3840 (concat (if (gnus-use-long-file-name 'not-save)
3842 (gnus-newsgroup-directory-form newsgroup))
3843 "/" (int-to-string (mail-header-number headers)))
3844 gnus-article-save-directory)))
3846 (string-equal (file-name-directory default)
3847 (file-name-directory last-file))
3848 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3850 (or last-file default))))
3852 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3853 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3854 If variable `gnus-use-long-file-name' is non-nil, it is
3855 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3858 (if (gnus-use-long-file-name 'not-save)
3861 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3863 gnus-article-save-directory)))
3865 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3866 "Generate file name from sender."
3867 (let ((from (mail-header-from headers)))
3869 (if (and from (string-match "\\([^ <]+\\)@" from))
3870 (match-string 1 from)
3872 gnus-article-save-directory)))
3874 (defun article-verify-x-pgp-sig ()
3877 (if (gnus-buffer-live-p gnus-original-article-buffer)
3878 (let ((sig (with-current-buffer gnus-original-article-buffer
3879 (gnus-fetch-field "X-PGP-Sig")))
3883 (mml2015-clear-verify-function))
3885 (insert-buffer-substring gnus-original-article-buffer)
3886 (setq items (split-string sig))
3887 (message-narrow-to-head)
3888 (let ((inhibit-point-motion-hooks t)
3889 (case-fold-search t))
3890 ;; Don't verify multiple headers.
3891 (setq headers (mapconcat (lambda (header)
3893 (mail-fetch-field header)
3895 (split-string (nth 1 items) ",") "")))
3896 (delete-region (point-min) (point-max))
3897 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3898 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3903 (if (looking-at "^-")
3906 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3907 (insert "Version: " (car items) "\n\n")
3908 (insert (mapconcat 'identity (cddr items) "\n"))
3909 (insert "\n-----END PGP SIGNATURE-----\n")
3910 (let ((mm-security-handle (list (format "multipart/signed"))))
3911 (mml2015-clean-buffer)
3912 (let ((coding-system-for-write (or gnus-newsgroup-charset
3914 (funcall (mml2015-clear-verify-function)))
3916 (or (mm-handle-multipart-ctl-parameter
3917 mm-security-handle 'gnus-details)
3918 (mm-handle-multipart-ctl-parameter
3919 mm-security-handle 'gnus-info)))))
3921 (let ((inhibit-read-only t) bface eface)
3923 (message-narrow-to-head)
3924 (goto-char (point-max))
3926 (setq bface (get-text-property (point-at-bol) 'face)
3927 eface (get-text-property (1- (point-at-eol)) 'face))
3928 (message-remove-header "X-Gnus-PGP-Verify")
3929 (if (re-search-forward "^X-PGP-Sig:" nil t)
3931 (goto-char (point-max)))
3932 (narrow-to-region (point) (point))
3933 (insert "X-Gnus-PGP-Verify: " info "\n")
3934 (goto-char (point-min))
3937 (if (not (looking-at "^[ \t]"))
3941 (goto-char (point-min))
3942 (when (looking-at "\\([^:]+\\): *")
3943 (put-text-property (match-beginning 1) (1+ (match-end 1))
3945 (put-text-property (match-end 0) (point-max)
3946 'face eface)))))))))
3948 (defun article-verify-cancel-lock ()
3949 "Verify Cancel-Lock header."
3951 (if (gnus-buffer-live-p gnus-original-article-buffer)
3952 (canlock-verify gnus-original-article-buffer)))
3959 (setq afunc (car func)
3962 gfunc (intern (format "gnus-%s" func))))
3964 (when (fboundp afunc)
3965 `(lambda (&optional interactive &rest args)
3966 ,(documentation afunc t)
3967 (interactive (list t))
3969 (set-buffer gnus-article-buffer)
3971 (call-interactively ',afunc)
3972 (apply ',afunc args))))))))
3973 '(article-hide-headers
3974 article-verify-x-pgp-sig
3975 article-verify-cancel-lock
3976 article-hide-boring-headers
3977 article-treat-overstrike
3978 article-treat-ansi-sequences
3979 article-fill-long-lines
3980 article-capitalize-sentences
3982 article-remove-leading-whitespace
3983 article-display-x-face
3984 article-display-face
3985 article-de-quoted-unreadable
3986 article-de-base64-unreadable
3989 article-unsplit-urls
3990 article-hide-list-identifiers
3991 article-strip-banner
3994 article-hide-signature
3995 article-strip-headers-in-body
3996 article-remove-trailing-blank-lines
3997 article-strip-leading-blank-lines
3998 article-strip-multiple-blank-lines
3999 article-strip-leading-space
4000 article-strip-trailing-space
4001 article-strip-blank-lines
4002 article-strip-all-blank-lines
4004 article-date-english
4005 article-date-iso8601
4006 article-date-original
4008 article-decode-mime-words
4009 article-decode-charset
4010 article-decode-encoded-words
4014 article-treat-dumbquotes
4015 article-normalize-headers
4016 ;; (article-show-all . gnus-article-show-all-headers)
4020 ;;; Gnus article mode
4023 (put 'gnus-article-mode 'mode-class 'special)
4025 (set-keymap-parent gnus-article-mode-map widget-keymap)
4027 (gnus-define-keys gnus-article-mode-map
4028 " " gnus-article-goto-next-page
4029 "\177" gnus-article-goto-prev-page
4030 [delete] gnus-article-goto-prev-page
4031 [backspace] gnus-article-goto-prev-page
4032 "\C-c^" gnus-article-refer-article
4033 "h" gnus-article-show-summary
4034 "s" gnus-article-show-summary
4035 "\C-c\C-m" gnus-article-mail
4036 "?" gnus-article-describe-briefly
4037 "e" gnus-summary-edit-article
4038 "<" beginning-of-buffer
4040 "\C-c\C-i" gnus-info-find-node
4042 "R" gnus-article-reply-with-original
4043 "F" gnus-article-followup-with-original
4044 "\C-hk" gnus-article-describe-key
4045 "\C-hc" gnus-article-describe-key-briefly
4047 "\C-d" gnus-article-read-summary-keys
4048 "\M-*" gnus-article-read-summary-keys
4049 "\M-#" gnus-article-read-summary-keys
4050 "\M-^" gnus-article-read-summary-keys
4051 "\M-g" gnus-article-read-summary-keys)
4053 (substitute-key-definition
4054 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
4056 (defun gnus-article-make-menu-bar ()
4057 (unless (boundp 'gnus-article-commands-menu)
4058 (gnus-summary-make-menu-bar))
4059 (gnus-turn-off-edit-menu 'article)
4060 (unless (boundp 'gnus-article-article-menu)
4062 gnus-article-article-menu gnus-article-mode-map ""
4064 ["Scroll forwards" gnus-article-goto-next-page t]
4065 ["Scroll backwards" gnus-article-goto-prev-page t]
4066 ["Show summary" gnus-article-show-summary t]
4067 ["Fetch Message-ID at point" gnus-article-refer-article t]
4068 ["Mail to address at point" gnus-article-mail t]
4069 ["Send a bug report" gnus-bug t]))
4072 gnus-article-treatment-menu gnus-article-mode-map ""
4073 ;; Fixme: this should use :active (and maybe :visible).
4075 ["Hide headers" gnus-article-hide-headers t]
4076 ["Hide signature" gnus-article-hide-signature t]
4077 ["Hide citation" gnus-article-hide-citation t]
4078 ["Treat overstrike" gnus-article-treat-overstrike t]
4079 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
4080 ["Remove carriage return" gnus-article-remove-cr t]
4081 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
4082 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
4083 ["Remove base64" gnus-article-de-base64-unreadable t]
4084 ["Treat html" gnus-article-wash-html t]
4085 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
4086 ["Decode HZ" gnus-article-decode-HZ t]))
4088 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
4090 ;; Note "Post" menu is defined in gnus-sum.el for consistency
4092 (gnus-run-hooks 'gnus-article-menu-hook)))
4094 (defun gnus-article-mode ()
4095 "Major mode for displaying an article.
4097 All normal editing commands are switched off.
4099 The following commands are available in addition to all summary mode
4101 \\<gnus-article-mode-map>
4102 \\[gnus-article-next-page]\t Scroll the article one page forwards
4103 \\[gnus-article-prev-page]\t Scroll the article one page backwards
4104 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
4105 \\[gnus-article-show-summary]\t Display the summary buffer
4106 \\[gnus-article-mail]\t Send a reply to the address near point
4107 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
4108 \\[gnus-info-find-node]\t Go to the Gnus info node"
4110 (kill-all-local-variables)
4111 (gnus-simplify-mode-line)
4112 (setq mode-name "Article")
4113 (setq major-mode 'gnus-article-mode)
4114 (make-local-variable 'minor-mode-alist)
4115 (use-local-map gnus-article-mode-map)
4116 (when (gnus-visual-p 'article-menu 'menu)
4117 (gnus-article-make-menu-bar)
4118 (when gnus-summary-tool-bar-map
4119 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
4120 (gnus-update-format-specifications nil 'article-mode)
4121 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
4122 (set (make-local-variable 'gnus-page-broken) nil)
4123 (make-local-variable 'gnus-button-marker-list)
4124 (make-local-variable 'gnus-article-current-summary)
4125 (make-local-variable 'gnus-article-mime-handles)
4126 (make-local-variable 'gnus-article-decoded-p)
4127 (make-local-variable 'gnus-article-mime-handle-alist)
4128 (make-local-variable 'gnus-article-wash-types)
4129 (make-local-variable 'gnus-article-image-alist)
4130 (make-local-variable 'gnus-article-charset)
4131 (make-local-variable 'gnus-article-ignored-charsets)
4132 ;; Prevent recent Emacsen from displaying non-break space as "\ ".
4133 (set (make-local-variable 'nobreak-char-display) nil)
4134 (setq cursor-in-non-selected-windows nil)
4135 (setq truncate-lines gnus-article-truncate-lines)
4136 (gnus-set-default-directory)
4137 (buffer-disable-undo)
4138 (setq buffer-read-only t
4139 show-trailing-whitespace nil)
4140 (set-syntax-table gnus-article-mode-syntax-table)
4141 (mm-enable-multibyte)
4142 (gnus-run-mode-hooks 'gnus-article-mode-hook))
4144 (defun gnus-article-setup-buffer ()
4145 "Initialize the article buffer."
4146 (let* ((name (if gnus-single-article-buffer "*Article*"
4147 (concat "*Article " gnus-newsgroup-name "*")))
4149 (progn (string-match "\\*Article" name)
4150 (concat " *Original Article"
4151 (substring name (match-end 0))))))
4152 (setq gnus-article-buffer name)
4153 (setq gnus-original-article-buffer original)
4154 (setq gnus-article-mime-handle-alist nil)
4155 (with-current-buffer gnus-summary-buffer
4156 ;; This might be a variable local to the summary buffer.
4157 (unless gnus-single-article-buffer
4158 (setq gnus-article-buffer name)
4159 (setq gnus-original-article-buffer original)
4160 (gnus-set-global-variables)))
4161 (gnus-article-setup-highlight-words)
4162 ;; Init original article buffer.
4164 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
4165 (mm-enable-multibyte)
4166 (setq major-mode 'gnus-original-article-mode)
4167 (make-local-variable 'gnus-original-article))
4168 (if (and (get-buffer name)
4169 (with-current-buffer name
4170 (if gnus-article-edit-mode
4171 (if (y-or-n-p "Article mode edit in progress; discard? ")
4173 (set-buffer-modified-p nil)
4174 (gnus-kill-buffer name)
4177 (error "Action aborted"))
4181 (set (make-local-variable 'gnus-article-edit-mode) nil)
4182 (when gnus-article-mime-handles
4183 (mm-destroy-parts gnus-article-mime-handles)
4184 (setq gnus-article-mime-handles nil))
4185 ;; Set it to nil in article-buffer!
4186 (setq gnus-article-mime-handle-alist nil)
4187 (buffer-disable-undo)
4188 (setq buffer-read-only t)
4189 ;; This list just keeps growing if we don't reset it.
4190 (setq gnus-button-marker-list nil)
4191 (unless (eq major-mode 'gnus-article-mode)
4192 (gnus-article-mode))
4195 (set-buffer (gnus-get-buffer-create name))
4197 (make-local-variable 'gnus-summary-buffer)
4198 (gnus-summary-set-local-parameters gnus-newsgroup-name)
4199 (current-buffer)))))
4201 ;; Set article window start at LINE, where LINE is the number of lines
4202 ;; from the head of the article.
4203 (defun gnus-article-set-window-start (&optional line)
4205 (gnus-get-buffer-window gnus-article-buffer t)
4207 (set-buffer gnus-article-buffer)
4208 (goto-char (point-min))
4211 (gnus-message 6 "Moved to bookmark")
4212 (search-forward "\n\n" nil t)
4216 (defun gnus-article-prepare (article &optional all-headers header)
4217 "Prepare ARTICLE in article mode buffer.
4218 ARTICLE should either be an article number or a Message-ID.
4219 If ARTICLE is an id, HEADER should be the article headers.
4220 If ALL-HEADERS is non-nil, no headers are hidden."
4222 ;; Make sure we start in a summary buffer.
4223 (unless (eq major-mode 'gnus-summary-mode)
4224 (set-buffer gnus-summary-buffer))
4225 (setq gnus-summary-buffer (current-buffer))
4226 (let* ((gnus-article (if header (mail-header-number header) article))
4227 (summary-buffer (current-buffer))
4228 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4229 (group gnus-newsgroup-name)
4232 (gnus-article-setup-buffer)
4233 (set-buffer gnus-article-buffer)
4234 ;; Deactivate active regions.
4235 (when (and (boundp 'transient-mark-mode)
4236 transient-mark-mode)
4237 (setq mark-active nil))
4238 (if (not (setq result (let ((inhibit-read-only t))
4239 (gnus-request-article-this-buffer
4241 ;; There is no such article.
4243 (when (and (numberp article)
4244 (not (memq article gnus-newsgroup-sparse)))
4245 (setq gnus-article-current
4246 (cons gnus-newsgroup-name article))
4247 (set-buffer gnus-summary-buffer)
4248 (setq gnus-current-article article)
4249 (if (and (memq article gnus-newsgroup-undownloaded)
4250 (not (gnus-online (gnus-find-method-for-group
4251 gnus-newsgroup-name))))
4253 (gnus-summary-set-agent-mark article)
4254 (message "Message marked for downloading"))
4255 (gnus-summary-mark-article article gnus-canceled-mark)
4256 (unless (memq article gnus-newsgroup-sparse)
4257 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4258 (if (or (eq result 'pseudo)
4259 (eq result 'nneething))
4262 (set-buffer summary-buffer)
4263 (push article gnus-newsgroup-history)
4264 (setq gnus-last-article gnus-current-article
4265 gnus-current-article 0
4266 gnus-current-headers nil
4267 gnus-article-current nil)
4268 (if (eq result 'nneething)
4269 (gnus-configure-windows 'summary)
4270 (gnus-configure-windows 'article))
4271 (gnus-set-global-variables))
4272 (let ((gnus-article-mime-handle-alist-1
4273 gnus-article-mime-handle-alist))
4274 (gnus-set-mode-line 'article)))
4275 ;; The result from the `request' was an actual article -
4276 ;; or at least some text that is now displayed in the
4278 (when (and (numberp article)
4279 (not (eq article gnus-current-article)))
4280 ;; Seems like a new article has been selected.
4281 ;; `gnus-current-article' must be an article number.
4283 (set-buffer summary-buffer)
4284 (push article gnus-newsgroup-history)
4285 (setq gnus-last-article gnus-current-article
4286 gnus-current-article article
4287 gnus-current-headers
4288 (gnus-summary-article-header gnus-current-article)
4289 gnus-article-current
4290 (cons gnus-newsgroup-name gnus-current-article))
4291 (unless (vectorp gnus-current-headers)
4292 (setq gnus-current-headers nil))
4293 (gnus-summary-goto-subject gnus-current-article)
4294 (when (gnus-summary-show-thread)
4295 ;; If the summary buffer really was folded, the
4296 ;; previous goto may not actually have gone to
4297 ;; the right article, but the thread root instead.
4299 (gnus-summary-goto-subject gnus-current-article))
4300 (gnus-run-hooks 'gnus-mark-article-hook)
4301 (gnus-set-mode-line 'summary)
4302 (when (gnus-visual-p 'article-highlight 'highlight)
4303 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4304 ;; Set the global newsgroup variables here.
4305 (gnus-set-global-variables)
4306 (setq gnus-have-all-headers
4307 (or all-headers gnus-show-all-headers))))
4309 (gnus-configure-windows 'article))
4310 (when (or (numberp article)
4312 (gnus-article-prepare-display)
4314 (goto-char (point-min))
4315 (when gnus-break-pages
4316 (gnus-narrow-to-page)))
4317 (let ((gnus-article-mime-handle-alist-1
4318 gnus-article-mime-handle-alist))
4319 (gnus-set-mode-line 'article))
4323 (set-window-point (get-buffer-window (current-buffer)) (point))
4324 (gnus-configure-windows 'article)
4328 (defun gnus-article-prepare-display ()
4329 "Make the current buffer look like a nice article."
4330 ;; Hooks for getting information from the article.
4331 ;; This hook must be called before being narrowed.
4332 (let ((gnus-article-buffer (current-buffer))
4334 (inhibit-read-only t))
4335 (unless (eq major-mode 'gnus-article-mode)
4336 (gnus-article-mode))
4337 (setq buffer-read-only nil
4338 gnus-article-wash-types nil
4339 gnus-article-image-alist nil)
4340 (gnus-run-hooks 'gnus-tmp-internal-hook)
4341 (when gnus-display-mime-function
4342 (funcall gnus-display-mime-function))
4343 (gnus-run-hooks 'gnus-article-prepare-hook)))
4346 ;;; Gnus MIME viewing functions
4349 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4350 "Format of the MIME buttons.
4352 Valid specifiers include:
4354 %T MIME type, along with additional info
4355 %n The `name' parameter
4356 %d The description, if any
4357 %l The length of the encoded part
4358 %p The part identifier number
4359 %e Dots if the part isn't displayed
4361 General format specifiers can also be used. See Info node
4362 `(gnus)Formatting Variables'.")
4364 (defvar gnus-mime-button-line-format-alist
4365 '((?t gnus-tmp-type ?s)
4366 (?T gnus-tmp-type-long ?s)
4367 (?n gnus-tmp-name ?s)
4368 (?d gnus-tmp-description ?s)
4370 (?l gnus-tmp-length ?d)
4371 (?e gnus-tmp-dots ?s)))
4373 (defvar gnus-mime-button-commands
4374 '((gnus-article-press-button "\r" "Toggle Display")
4375 (gnus-mime-view-part "v" "View Interactively...")
4376 (gnus-mime-view-part-as-type "t" "View As Type...")
4377 (gnus-mime-view-part-as-charset "C" "View As charset...")
4378 (gnus-mime-save-part "o" "Save...")
4379 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4380 (gnus-mime-replace-part "r" "Replace part")
4381 (gnus-mime-delete-part "d" "Delete part")
4382 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4383 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4384 (gnus-mime-view-part-internally "E" "View Internally") ;; Why `E'?
4385 (gnus-mime-view-part-externally "e" "View Externally")
4386 (gnus-mime-print-part "p" "Print")
4387 (gnus-mime-pipe-part "|" "Pipe To Command...")
4388 (gnus-mime-action-on-part "." "Take action on the part...")))
4390 (defun gnus-article-mime-part-status ()
4391 (if gnus-article-mime-handle-alist-1
4392 (if (eq 1 (length gnus-article-mime-handle-alist-1))
4394 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
4397 (defvar gnus-mime-button-map
4398 (let ((map (make-sparse-keymap)))
4399 (define-key map gnus-mouse-2 'gnus-article-push-button)
4400 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4401 (dolist (c gnus-mime-button-commands)
4402 (define-key map (cadr c) (car c)))
4406 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4408 ,@(mapcar (lambda (c)
4409 (vector (caddr c) (car c) :active t))
4410 gnus-mime-button-commands)))
4412 (defun gnus-mime-button-menu (event prefix)
4413 "Construct a context-sensitive menu of MIME commands."
4414 (interactive "e\nP")
4415 (save-window-excursion
4416 (let ((pos (event-start event)))
4417 (select-window (posn-window pos))
4418 (goto-char (posn-point pos))
4419 (gnus-article-check-buffer)
4420 (popup-menu gnus-mime-button-menu nil prefix))))
4422 (defun gnus-mime-view-all-parts (&optional handles)
4423 "View all the MIME parts."
4425 (with-current-buffer gnus-article-buffer
4426 (let ((handles (or handles gnus-article-mime-handles))
4427 (mail-parse-charset gnus-newsgroup-charset)
4428 (mail-parse-ignored-charsets
4429 (with-current-buffer gnus-summary-buffer
4430 gnus-newsgroup-ignored-charsets)))
4432 (mm-remove-parts handles)
4433 (goto-char (point-min))
4434 (or (search-forward "\n\n") (goto-char (point-max)))
4435 (let ((inhibit-read-only t))
4436 (delete-region (point) (point-max))
4437 (mm-display-parts handles))))))
4439 (defun gnus-article-jump-to-part (n)
4440 "Jump to MIME part N."
4442 (pop-to-buffer gnus-article-buffer)
4443 ;; FIXME: why is it necessary?
4445 (let ((parts (length gnus-article-mime-handle-alist)))
4448 (read-string ;; Emacs 21 doesn't have `read-number'.
4449 (format "Jump to part (2..%s): " parts)))))
4450 (unless (and (integerp n) (<= n parts) (>= n 1))
4453 (gnus-message 7 "Invalid part `%s', using %s instead."
4456 (gnus-message 9 "Jumping to part %s." n)
4457 (cond ((>= gnus-auto-select-part 1)
4458 (while (and (<= n parts)
4459 (not (gnus-article-goto-part n)))
4461 ((< gnus-auto-select-part 0)
4462 (while (and (>= n 1)
4463 (not (gnus-article-goto-part n)))
4466 (gnus-article-goto-part n)))))
4469 (defsubst gnus-article-edit-part (handles &optional current-id)
4470 "Edit an article in order to delete a mime part.
4471 This function is exclusively used by `gnus-mime-save-part-and-strip'
4472 and `gnus-mime-delete-part', and not provided at run-time normally."
4473 (gnus-article-edit-article
4475 (buffer-disable-undo)
4477 (let ((mail-parse-charset (or gnus-article-charset
4478 ',gnus-newsgroup-charset))
4479 (mail-parse-ignored-charsets
4480 (or gnus-article-ignored-charsets
4481 ',gnus-newsgroup-ignored-charsets))
4482 (mbl mml-buffer-list))
4483 (setq mml-buffer-list nil)
4484 (insert-buffer-substring gnus-original-article-buffer)
4485 (mime-to-mml ',handles)
4486 (setq gnus-article-mime-handles nil)
4487 (let ((mbl1 mml-buffer-list))
4488 (setq mml-buffer-list mbl)
4489 (set (make-local-variable 'mml-buffer-list) mbl1))
4490 (gnus-make-local-hook 'kill-buffer-hook)
4491 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4492 `(lambda (no-highlight)
4493 (let ((mail-parse-charset (or gnus-article-charset
4494 ',gnus-newsgroup-charset))
4495 (message-options message-options)
4496 (message-options-set-recipient)
4497 (mail-parse-ignored-charsets
4498 (or gnus-article-ignored-charsets
4499 ',gnus-newsgroup-ignored-charsets)))
4501 (mml-destroy-buffers)
4502 (remove-hook 'kill-buffer-hook
4503 'mml-destroy-buffers t)
4504 (kill-local-variable 'mml-buffer-list))
4505 (gnus-summary-edit-article-done
4506 ,(or (mail-header-references gnus-current-headers) "")
4507 ,(gnus-group-read-only-p)
4508 ,gnus-summary-buffer no-highlight))
4510 (gnus-article-edit-done)
4511 (gnus-summary-expand-window)
4512 (gnus-summary-show-article)
4513 (when (and current-id (integerp gnus-auto-select-part))
4514 (gnus-article-jump-to-part
4515 (+ current-id gnus-auto-select-part)))))
4517 (defun gnus-mime-replace-part (file)
4518 "Replace MIME part under point with an external body."
4519 ;; Useful if file has already been saved to disk
4523 (read-file-name "Replace MIME part with file: "
4524 (or mm-default-directory default-directory)
4526 (gnus-mime-save-part-and-strip file))
4528 (defun gnus-mime-save-part-and-strip (&optional file)
4529 "Save the MIME part under point then replace it with an external body.
4530 If FILE is given, use it for the external part."
4532 (gnus-article-check-buffer)
4533 (when (gnus-group-read-only-p)
4534 (error "The current group does not support deleting of parts"))
4535 (when (mm-complicated-handles gnus-article-mime-handles)
4537 The current article has a complicated MIME structure, giving up..."))
4538 (let* ((data (get-text-property (point) 'gnus-data))
4539 (id (get-text-property (point) 'gnus-part))
4541 (handles gnus-article-mime-handles))
4544 (and data (mm-save-part data "Delete MIME part and save to: "))))
4546 (with-current-buffer (mm-handle-buffer data)
4548 (insert "Content-Type: " (mm-handle-media-type data))
4549 (mml-insert-parameter-string (cdr (mm-handle-type data))
4551 ;; Add a filename for the sake of saving the part again.
4552 (mml-insert-parameter
4553 (mail-header-encode-parameter "name" (file-name-nondirectory file)))
4555 (insert "Content-ID: " (message-make-message-id) "\n")
4556 (insert "Content-Transfer-Encoding: binary\n")
4559 (cdr (mm-make-handle nil
4560 `("message/external-body"
4561 (access-type . "LOCAL-FILE")
4563 ;; (set-buffer gnus-summary-buffer)
4564 (gnus-article-edit-part handles id))))
4566 ;; A function like `gnus-summary-save-parts' (`X m', `<MIME> <Extract all
4567 ;; parts...>') but with stripping would be nice.
4569 (defun gnus-mime-delete-part ()
4570 "Delete the MIME part under point.
4571 Replace it with some information about the removed part."
4573 (gnus-article-check-buffer)
4574 (when (gnus-group-read-only-p)
4575 (error "The current group does not support deleting of parts"))
4576 (when (mm-complicated-handles gnus-article-mime-handles)
4578 The current article has a complicated MIME structure, giving up..."))
4579 (when (or gnus-expert-user
4580 (gnus-yes-or-no-p "\
4581 Deleting parts may malfunction or destroy the article; continue? "))
4582 (let* ((data (get-text-property (point) 'gnus-data))
4583 (id (get-text-property (point) 'gnus-part))
4584 (handles gnus-article-mime-handles)
4588 (mail-decode-encoded-word-string (or (mm-handle-description data)
4591 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4593 (type (mm-handle-media-type data)))
4595 (error "No MIME part under point"))
4596 (with-current-buffer (mm-handle-buffer data)
4597 (let ((bsize (format "%s" (buffer-size))))
4602 "| The following attachment has been deleted:\n"
4604 "| Type: " type "\n"
4605 "| Filename: " filename "\n"
4606 "| Size (encoded): " bsize " Byte\n"
4607 "| Description: " description "\n"
4610 (cdr (mm-make-handle
4611 nil `("text/plain") nil nil
4613 (format "Deleted attachment (%s bytes)" bsize))))))
4614 ;; (set-buffer gnus-summary-buffer)
4615 (gnus-article-edit-part handles id))))
4617 (defun gnus-mime-save-part ()
4618 "Save the MIME part under point."
4620 (gnus-article-check-buffer)
4621 (let ((data (get-text-property (point) 'gnus-data)))
4623 (mm-save-part data))))
4625 (defun gnus-mime-pipe-part ()
4626 "Pipe the MIME part under point to a process."
4628 (gnus-article-check-buffer)
4629 (let ((data (get-text-property (point) 'gnus-data)))
4631 (mm-pipe-part data))))
4633 (defun gnus-mime-view-part ()
4634 "Interactively choose a viewing method for the MIME part under point."
4636 (gnus-article-check-buffer)
4637 (let ((data (get-text-property (point) 'gnus-data)))
4639 (setq gnus-article-mime-handles
4641 gnus-article-mime-handles (setq data (copy-sequence data))))
4642 (mm-interactively-view-part data))))
4644 (defun gnus-mime-view-part-as-type-internal ()
4645 (gnus-article-check-buffer)
4646 (let* ((handle (get-text-property (point) 'gnus-data))
4648 ;; Content-Type: foo/bar; name=...
4649 (mail-content-type-get (mm-handle-type handle) 'name)
4650 ;; Content-Disposition: attachment; filename=...
4651 (cdr (assq 'filename (cdr (mm-handle-disposition handle))))))
4652 (def-type (and name (mm-default-file-encoding name))))
4653 (and def-type (cons def-type 0))))
4655 (defun gnus-mime-view-part-as-type (&optional mime-type pred)
4656 "Choose a MIME media type, and view the part as such.
4657 If non-nil, PRED is a predicate to use during completion to limit the
4658 available media-types."
4662 (let ((default (gnus-mime-view-part-as-type-internal)))
4664 (format "View as MIME type (default %s): "
4666 (mapcar #'list (mailcap-mime-types))
4669 (gnus-article-check-buffer)
4670 (let ((handle (get-text-property (point) 'gnus-data)))
4672 (when (equal (mm-handle-media-type handle) "message/external-body")
4673 (unless (mm-handle-cache handle)
4674 (mm-extern-cache-contents handle))
4675 (setq handle (mm-handle-cache handle)))
4677 (mm-make-handle (mm-handle-buffer handle)
4678 (cons mime-type (cdr (mm-handle-type handle)))
4679 (mm-handle-encoding handle)
4680 (mm-handle-undisplayer handle)
4681 (mm-handle-disposition handle)
4682 (mm-handle-description handle)
4684 (mm-handle-id handle)))
4685 (setq gnus-article-mime-handles
4686 (mm-merge-handles gnus-article-mime-handles handle))
4687 (gnus-mm-display-part handle))))
4689 (defun gnus-mime-copy-part (&optional handle arg)
4690 "Put the MIME part under point into a new buffer.
4691 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4693 (interactive (list nil current-prefix-arg))
4694 (gnus-article-check-buffer)
4696 (setq handle (get-text-property (point) 'gnus-data)))
4698 (let ((filename (or (mail-content-type-get (mm-handle-type handle)
4700 (mail-content-type-get (mm-handle-disposition handle)
4702 contents dont-decode charset coding-system)
4703 (mm-with-unibyte-buffer
4704 (mm-insert-part handle)
4705 (setq contents (or (condition-case nil
4706 (mm-decompress-buffer filename nil 'sig)
4708 (setq dont-decode t)
4711 (setq filename (cond (filename (file-name-nondirectory filename))
4712 (dont-decode "*raw data*")
4717 (unless (setq charset (mail-content-type-get
4718 (mm-handle-type handle) 'charset))
4719 (unless (setq coding-system (mm-with-unibyte-buffer
4721 (mm-find-buffer-file-coding-system)))
4722 (setq charset gnus-newsgroup-charset))))
4724 (setq charset (or (cdr (assq arg
4725 gnus-summary-show-article-charset-alist))
4726 (mm-read-coding-system "Charset: ")))))
4727 (switch-to-buffer (generate-new-buffer filename))
4728 (if (or coding-system
4730 (setq coding-system (mm-charset-to-coding-system charset))
4731 (not (eq charset 'ascii))))
4733 (mm-enable-multibyte)
4734 (insert (mm-decode-coding-string contents coding-system))
4735 (setq buffer-file-coding-system
4736 (if (boundp 'last-coding-system-used)
4737 (symbol-value 'last-coding-system-used)
4739 (mm-disable-multibyte)
4741 (setq buffer-file-coding-system mm-binary-coding-system))
4742 ;; We do it this way to make `normal-mode' set the appropriate mode.
4745 (setq buffer-file-name (expand-file-name filename))
4747 (setq buffer-file-name nil))
4748 (goto-char (point-min)))))
4750 (defun gnus-mime-print-part (&optional handle filename)
4751 "Print the MIME part under point."
4752 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4753 (gnus-article-check-buffer)
4754 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4755 (contents (and handle (mm-get-part handle)))
4756 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4757 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4762 (mm-save-part-to-file handle file)
4763 (call-process shell-file-name nil
4764 (generate-new-buffer " *mm*")
4766 shell-command-switch
4768 printer file (mm-handle-type handle))))
4772 (gnus-print-buffer))
4773 (ps-despool filename)))))
4775 (defun gnus-mime-inline-part (&optional handle arg)
4776 "Insert the MIME part under point into the current buffer.
4777 Compressed files like .gz and .bz2 are decompressed."
4778 (interactive (list nil current-prefix-arg))
4779 (gnus-article-check-buffer)
4781 (setq handle (get-text-property (point) 'gnus-data)))
4784 (inhibit-read-only t)
4785 contents charset coding-system)
4786 (if (and (not arg) (mm-handle-undisplayer handle))
4787 (mm-remove-part handle)
4788 (mm-with-unibyte-buffer
4789 (mm-insert-part handle)
4791 (or (mm-decompress-buffer
4792 (or (mail-content-type-get (mm-handle-type handle)
4794 (mail-content-type-get (mm-handle-disposition handle)
4800 (unless (setq charset (mail-content-type-get
4801 (mm-handle-type handle) 'charset))
4802 (unless (setq coding-system
4803 (mm-with-unibyte-buffer
4805 (mm-find-buffer-file-coding-system)))
4806 (setq charset gnus-newsgroup-charset))))
4808 (if (mm-handle-undisplayer handle)
4809 (mm-remove-part handle))
4812 gnus-summary-show-article-charset-alist))
4813 (mm-read-coding-system "Charset: "))))
4815 (if (mm-handle-undisplayer handle)
4816 (mm-remove-part handle))))
4820 (if (or coding-system
4823 (mm-charset-to-coding-system charset))
4824 (not (eq coding-system 'ascii))))
4825 (mm-decode-coding-string contents coding-system)
4826 (mm-string-to-multibyte contents)))
4829 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4830 "Insert the MIME part under point into the current buffer using the
4832 (interactive (list nil current-prefix-arg))
4833 (gnus-article-check-buffer)
4834 (let ((handle (or handle (get-text-property (point) 'gnus-data)))
4835 (fun (get-text-property (point) 'gnus-callback))
4836 (gnus-newsgroup-ignored-charsets 'gnus-all)
4837 gnus-newsgroup-charset type charset)
4839 (if (mm-handle-undisplayer handle)
4840 (mm-remove-part handle))
4842 (setq gnus-newsgroup-charset
4843 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
4844 (mm-read-coding-system "Charset: ")))
4845 ;; Strip the charset parameter from `handle'.
4846 (setq type (mm-handle-type
4847 (if (equal (mm-handle-media-type handle)
4848 "message/external-body")
4850 (unless (mm-handle-cache handle)
4851 (mm-extern-cache-contents handle))
4852 (mm-handle-cache handle))
4854 charset (assq 'charset (cdr type)))
4856 (funcall fun handle)))))
4858 (defun gnus-mime-view-part-externally (&optional handle)
4859 "View the MIME part under point with an external viewer."
4861 (gnus-article-check-buffer)
4862 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4863 (mm-user-display-methods nil)
4864 (mm-inlined-types nil)
4865 (mail-parse-charset gnus-newsgroup-charset)
4866 (mail-parse-ignored-charsets
4867 (with-current-buffer gnus-summary-buffer
4868 gnus-newsgroup-ignored-charsets))
4869 (type (mm-handle-media-type handle))
4870 (method (mailcap-mime-info type))
4871 (mm-enable-external t))
4872 (if (not (stringp method))
4873 (gnus-mime-view-part-as-type
4874 nil (lambda (type) (stringp (mailcap-mime-info type))))
4876 (if (mm-handle-undisplayer handle)
4877 (mm-remove-part handle)
4878 (mm-display-part handle))))))
4880 (defun gnus-mime-view-part-internally (&optional handle)
4881 "View the MIME part under point with an internal viewer.
4882 If no internal viewer is available, use an external viewer."
4884 (gnus-article-check-buffer)
4885 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4886 (mm-inlined-types '(".*"))
4887 (mm-inline-large-images t)
4888 (mail-parse-charset gnus-newsgroup-charset)
4889 (mail-parse-ignored-charsets
4890 (with-current-buffer gnus-summary-buffer
4891 gnus-newsgroup-ignored-charsets))
4892 (inhibit-read-only t))
4893 (if (not (mm-inlinable-p handle))
4894 (gnus-mime-view-part-as-type
4895 nil (lambda (type) (mm-inlinable-p handle type)))
4897 (if (mm-handle-undisplayer handle)
4898 (mm-remove-part handle)
4899 (mm-display-part handle))))))
4901 (defun gnus-mime-action-on-part (&optional action)
4902 "Do something with the MIME attachment at \(point\)."
4904 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4905 (gnus-article-check-buffer)
4906 (let ((action-pair (assoc action gnus-mime-action-alist)))
4908 (funcall (cdr action-pair)))))
4910 (defun gnus-article-part-wrapper (n function &optional no-handle interactive)
4911 "Call FUNCTION on MIME part N.
4912 Unless NO-HANDLE, call FUNCTION with N-th MIME handle as it's only argument.
4913 If INTERACTIVE, call FUNCTION interactivly."
4915 ;; Check whether the article is displayed.
4916 (unless (and (gnus-buffer-live-p gnus-article-buffer)
4917 (setq window (get-buffer-window gnus-article-buffer t))
4918 (frame-visible-p (setq frame (window-frame window))))
4919 (error "No article is displayed"))
4920 (with-current-buffer gnus-article-buffer
4921 ;; Check whether the article displays the right contents.
4922 (unless (with-current-buffer gnus-summary-buffer
4923 (eq gnus-current-article (gnus-summary-article-number)))
4924 (error "You should select the right article first"))
4925 ;; Check whether the specified part exists.
4926 (when (> n (length gnus-article-mime-handle-alist))
4927 (error "No such part")))
4930 ;; To select the window is needed so that the cursor
4931 ;; might be visible on the MIME button.
4932 (select-window (prog1
4934 (setq window (selected-window))
4935 ;; Article may be displayed in the other frame.
4936 (gnus-select-frame-set-input-focus
4939 (setq frame (selected-frame))))))
4940 (when (gnus-article-goto-part n)
4941 ;; We point the cursor and the arrow at the MIME button
4942 ;; when the `function' prompt the user for something.
4943 (let ((cursor-in-non-selected-windows t)
4944 (overlay-arrow-string "=>")
4945 (overlay-arrow-position (point-marker)))
4948 ((and no-handle interactive)
4949 (call-interactively function))
4955 (cdr (assq n gnus-article-mime-handle-alist))))
4958 (cdr (assq n gnus-article-mime-handle-alist)))))
4959 (set-marker overlay-arrow-position nil)
4960 (unless gnus-auto-select-part
4961 (gnus-select-frame-set-input-focus frame)
4962 (select-window window))))
4964 (if gnus-inhibit-mime-unbuttonizing
4965 ;; This is the default though the program shouldn't reach here.
4966 (error "No such part")
4967 ;; The part which doesn't have the MIME button is selected.
4968 ;; So, we display all the buttons and redo it.
4969 (let ((gnus-inhibit-mime-unbuttonizing t))
4970 (gnus-summary-show-article)
4971 (gnus-article-part-wrapper n function no-handle))))))
4973 (defun gnus-article-pipe-part (n)
4974 "Pipe MIME part N, which is the numerical prefix."
4976 (gnus-article-part-wrapper n 'mm-pipe-part))
4978 (defun gnus-article-save-part (n)
4979 "Save MIME part N, which is the numerical prefix."
4981 (gnus-article-part-wrapper n 'mm-save-part))
4983 (defun gnus-article-interactively-view-part (n)
4984 "View MIME part N interactively, which is the numerical prefix."
4986 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4988 (defun gnus-article-copy-part (n)
4989 "Copy MIME part N, which is the numerical prefix."
4991 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4993 (defun gnus-article-view-part-as-charset (n)
4994 "View MIME part N using a specified charset.
4995 N is the numerical prefix."
4997 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4999 (defun gnus-article-view-part-externally (n)
5000 "View MIME part N externally, which is the numerical prefix."
5002 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
5004 (defun gnus-article-inline-part (n)
5005 "Inline MIME part N, which is the numerical prefix."
5007 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
5009 (defun gnus-article-save-part-and-strip (n)
5010 "Save MIME part N and replace it with an external body.
5011 N is the numerical prefix."
5013 (gnus-article-part-wrapper n 'gnus-mime-save-part-and-strip t))
5015 (defun gnus-article-replace-part (n)
5016 "Replace MIME part N with an external body.
5017 N is the numerical prefix."
5019 (gnus-article-part-wrapper n 'gnus-mime-replace-part t t))
5021 (defun gnus-article-delete-part (n)
5022 "Delete MIME part N and add some information about the removed part.
5023 N is the numerical prefix."
5025 (gnus-article-part-wrapper n 'gnus-mime-delete-part t))
5027 (defun gnus-article-view-part-as-type (n)
5028 "Choose a MIME media type, and view part N as such.
5029 N is the numerical prefix."
5031 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-type t))
5033 (defun gnus-article-mime-match-handle-first (condition)
5036 (dolist (ihandle gnus-article-mime-handle-alist)
5038 ((functionp condition)
5039 (funcall condition (cdr ihandle)))
5040 ((eq condition 'undisplayed)
5041 (not (or (mm-handle-undisplayer (cdr ihandle))
5042 (equal (mm-handle-media-type (cdr ihandle))
5043 "multipart/alternative"))))
5044 ((eq condition 'undisplayed-alternative)
5045 (not (mm-handle-undisplayer (cdr ihandle))))
5047 (gnus-article-goto-part (car ihandle))
5048 (or (not n) (< (car ihandle) n)))
5049 (setq n (car ihandle))))
5053 (defun gnus-article-view-part (&optional n)
5054 "View MIME part N, which is the numerical prefix."
5056 (with-current-buffer gnus-article-buffer
5057 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
5058 gnus-article-mime-match-handle-function)))
5059 (when (> n (length gnus-article-mime-handle-alist))
5060 (error "No such part"))
5061 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
5062 (when (gnus-article-goto-part n)
5063 (if (equal (car handle) "multipart/alternative")
5064 (gnus-article-press-button)
5065 (when (eq (gnus-mm-display-part handle) 'internal)
5066 (gnus-set-window-start)))))))
5068 (defsubst gnus-article-mime-total-parts ()
5069 (if (bufferp (car gnus-article-mime-handles))
5071 (1- (length gnus-article-mime-handles))))
5073 (defun gnus-mm-display-part (handle)
5074 "Display HANDLE and fix MIME button."
5075 (let ((id (get-text-property (point) 'gnus-part))
5077 (inhibit-read-only t))
5080 (let ((window (selected-window))
5081 (mail-parse-charset gnus-newsgroup-charset)
5082 (mail-parse-ignored-charsets
5083 (if (gnus-buffer-live-p gnus-summary-buffer)
5084 (with-current-buffer gnus-summary-buffer
5085 gnus-newsgroup-ignored-charsets)
5089 (let ((win (gnus-get-buffer-window (current-buffer) t))
5092 (select-window win))
5095 (if (mm-handle-displayed-p handle)
5096 ;; This will remove the part.
5097 (mm-display-part handle)
5099 (narrow-to-region (point)
5100 (if (eobp) (point) (1+ (point))))
5101 (mm-display-part handle)
5102 ;; We narrow to the part itself and
5103 ;; then call the treatment functions.
5104 (goto-char (point-min))
5106 (narrow-to-region (point) (point-max))
5109 (gnus-article-mime-total-parts)
5110 (mm-handle-media-type handle)))))
5111 (if (window-live-p window)
5112 (select-window window)))))
5115 (gnus-insert-mime-button
5116 handle id (list (mm-handle-displayed-p handle)))
5117 (goto-char point))))
5119 (defun gnus-article-goto-part (n)
5120 "Go to MIME part N."
5121 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
5123 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
5124 (let ((gnus-tmp-name
5125 (or (mail-content-type-get (mm-handle-type handle) 'name)
5126 (mail-content-type-get (mm-handle-disposition handle) 'filename)
5127 (mail-content-type-get (mm-handle-type handle) 'url)
5129 (gnus-tmp-type (mm-handle-media-type handle))
5130 (gnus-tmp-description
5131 (mail-decode-encoded-word-string (or (mm-handle-description handle)
5134 (if (if displayed (car displayed)
5135 (mm-handle-displayed-p handle))
5137 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
5139 gnus-tmp-type-long b e)
5140 (when (string-match ".*/" gnus-tmp-name)
5141 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
5142 (setq gnus-tmp-type-long (concat gnus-tmp-type
5143 (and (not (equal gnus-tmp-name ""))
5144 (concat "; " gnus-tmp-name))))
5145 (unless (equal gnus-tmp-description "")
5146 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
5151 gnus-mime-button-line-format gnus-mime-button-line-format-alist
5152 `(keymap ,gnus-mime-button-map
5153 gnus-callback gnus-mm-display-part
5154 gnus-part ,gnus-tmp-id
5155 article-type annotation
5158 ;; Exclude a newline.
5161 (widget-convert-button
5164 :action 'gnus-widget-press-button
5165 :button-keymap gnus-mime-button-map
5167 (lambda (widget/window &optional overlay pos)
5168 ;; Needed to properly clear the message due to a bug in
5169 ;; wid-edit (XEmacs only).
5170 (if (boundp 'help-echo-owns-message)
5171 (setq help-echo-owns-message t))
5173 "%S: %s the MIME part; %S: more options"
5174 (aref gnus-mouse-2 0)
5175 ;; XEmacs will get a single widget arg; Emacs 21 will get
5176 ;; window, overlay, position.
5177 (if (mm-handle-displayed-p
5179 (with-current-buffer (gnus-overlay-buffer overlay)
5180 (widget-get (widget-at (gnus-overlay-start overlay))
5182 (widget-get widget/window :mime-handle)))
5184 (aref gnus-down-mouse-3 0))))))
5186 (defun gnus-widget-press-button (elems el)
5187 (goto-char (widget-get elems :from))
5188 (gnus-article-press-button))
5190 (defvar gnus-displaying-mime nil)
5192 (defun gnus-display-mime (&optional ihandles)
5193 "Display the MIME parts."
5195 (save-selected-window
5196 (let ((window (get-buffer-window gnus-article-buffer))
5199 (select-window window)
5200 ;; We have to do this since selecting the window
5201 ;; may change the point. So we set the window point.
5202 (set-window-point window point)))
5203 (let ((handles ihandles)
5204 (inhibit-read-only t)
5207 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
5208 (when gnus-article-emulate-mime
5209 (mm-uu-dissect-text-parts handles)))
5210 (gnus-article-emulate-mime
5211 (setq handles (mm-uu-dissect))))
5212 (when (and (not ihandles)
5213 (not gnus-displaying-mime))
5214 ;; Top-level call; we clean up.
5215 (when gnus-article-mime-handles
5216 (mm-destroy-parts gnus-article-mime-handles)
5217 (setq gnus-article-mime-handle-alist nil));; A trick.
5218 (setq gnus-article-mime-handles handles)
5219 ;; We allow users to glean info from the handles.
5220 (when gnus-article-mime-part-function
5221 (gnus-mime-part-function handles)))
5223 (or (not (stringp (car handles)))
5226 (when (and (not ihandles)
5227 (not gnus-displaying-mime))
5228 ;; Clean up for mime parts.
5230 (delete-region (point) (point-max)))
5231 (let ((gnus-displaying-mime t))
5232 (gnus-mime-display-part handles)))
5235 (narrow-to-region (point) (point-max))
5236 (gnus-treat-article nil 1 1)
5239 ;; Highlight the headers.
5243 (narrow-to-region (point-min) (point))
5244 (gnus-article-save-original-date
5245 (gnus-treat-article 'head)))))))
5246 ;; Cope with broken MIME messages.
5247 (goto-char (point-max))
5251 (defcustom gnus-mime-display-multipart-as-mixed nil
5252 "Display \"multipart\" parts as \"multipart/mixed\".
5254 If t, it overrides nil values of
5255 `gnus-mime-display-multipart-alternative-as-mixed' and
5256 `gnus-mime-display-multipart-related-as-mixed'."
5257 :group 'gnus-article-mime
5260 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
5261 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
5263 :group 'gnus-article-mime
5266 (defcustom gnus-mime-display-multipart-related-as-mixed nil
5267 "Display \"multipart/related\" parts as \"multipart/mixed\".
5269 If displaying \"text/html\" is discouraged \(see
5270 `mm-discouraged-alternatives'\) images or other material inside a
5271 \"multipart/related\" part might be overlooked when this variable is nil."
5273 :group 'gnus-article-mime
5276 (defun gnus-mime-display-part (handle)
5278 ;; Maybe a broken MIME message.
5281 ((not (stringp (car handle)))
5282 (gnus-mime-display-single handle))
5283 ;; User-defined multipart
5284 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
5285 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
5287 ;; multipart/alternative
5288 ((and (equal (car handle) "multipart/alternative")
5289 (not (or gnus-mime-display-multipart-as-mixed
5290 gnus-mime-display-multipart-alternative-as-mixed)))
5291 (let ((id (1+ (length gnus-article-mime-handle-alist))))
5292 (push (cons id handle) gnus-article-mime-handle-alist)
5293 (gnus-mime-display-alternative (cdr handle) nil nil id)))
5294 ;; multipart/related
5295 ((and (equal (car handle) "multipart/related")
5296 (not (or gnus-mime-display-multipart-as-mixed
5297 gnus-mime-display-multipart-related-as-mixed)))
5298 ;;;!!!We should find the start part, but we just default
5299 ;;;!!!to the first part.
5300 ;;(gnus-mime-display-part (cadr handle))
5301 ;;;!!! Most multipart/related is an HTML message plus images.
5302 ;;;!!! Unfortunately we are unable to let W3 display those
5303 ;;;!!! included images, so we just display it as a mixed multipart.
5304 ;;(gnus-mime-display-mixed (cdr handle))
5305 ;;;!!! No, w3 can display everything just fine.
5306 (gnus-mime-display-part (cadr handle)))
5307 ((equal (car handle) "multipart/signed")
5308 (gnus-add-wash-type 'signed)
5309 (gnus-mime-display-security handle))
5310 ((equal (car handle) "multipart/encrypted")
5311 (gnus-add-wash-type 'encrypted)
5312 (gnus-mime-display-security handle))
5313 ;; Other multiparts are handled like multipart/mixed.
5315 (gnus-mime-display-mixed (cdr handle)))))
5317 (defun gnus-mime-part-function (handles)
5318 (if (stringp (car handles))
5319 (mapcar 'gnus-mime-part-function (cdr handles))
5320 (funcall gnus-article-mime-part-function handles)))
5322 (defun gnus-mime-display-mixed (handles)
5323 (mapcar 'gnus-mime-display-part handles))
5325 (defun gnus-mime-display-single (handle)
5326 (let ((type (mm-handle-media-type handle))
5327 (ignored gnus-ignored-mime-types)
5334 (when (string-match (pop ignored) type)
5335 (throw 'ignored nil)))
5336 (if (and (setq not-attachment
5337 (and (not (mm-inline-override-p handle))
5338 (or (not (mm-handle-disposition handle))
5339 (equal (car (mm-handle-disposition handle))
5341 (mm-attachment-override-p handle))))
5342 (mm-automatic-display-p handle)
5344 (mm-inlinable-p handle)
5345 (mm-inlined-p handle))
5346 (mm-automatic-external-display-p type)))
5348 (when (equal (mm-handle-media-supertype handle) "text")
5350 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5352 (push (cons id handle) gnus-article-mime-handle-alist)
5354 (equal (mm-handle-media-supertype handle) "message"))
5357 (cond ((not (bolp)) 2)
5358 ((or (bobp) (eq (char-before (1- (point))) ?\n)) 0)
5360 (when (or (not display)
5361 (not (gnus-unbuttonized-mime-type-p type)))
5362 (gnus-insert-mime-button
5363 handle id (list (or display (and not-attachment text))))
5364 (gnus-article-insert-newline)
5365 ;; Remember modify the number of forward lines.
5373 (let ((mail-parse-charset gnus-newsgroup-charset)
5374 (mail-parse-ignored-charsets
5375 (save-excursion (condition-case ()
5376 (set-buffer gnus-summary-buffer)
5378 gnus-newsgroup-ignored-charsets)))
5379 (mm-display-part handle t))
5380 (goto-char (point-max)))
5381 ((and text not-attachment)
5385 (gnus-article-insert-newline)
5388 (let ((charset (mail-content-type-get (mm-handle-type handle)
5390 (cond ((not charset)
5391 (mm-string-as-multibyte (mm-get-part handle)))
5392 ((eq charset 'gnus-decoded)
5393 (with-current-buffer (mm-handle-buffer handle)
5396 (mm-decode-string (mm-get-part handle) charset)))))
5397 (goto-char (point-max))))
5401 (narrow-to-region beg (point))
5404 (gnus-article-mime-total-parts)
5405 (mm-handle-media-type handle)))))))))
5407 (defun gnus-unbuttonized-mime-type-p (type)
5408 "Say whether TYPE is to be unbuttonized."
5409 (unless gnus-inhibit-mime-unbuttonizing
5411 (let ((types gnus-unbuttonized-mime-types))
5413 (when (string-match (pop types) type)
5414 (throw 'found t)))))
5416 (let ((types gnus-buttonized-mime-types))
5418 (when (string-match (pop types) type)
5419 (throw 'found t)))))))))
5421 (defun gnus-article-insert-newline ()
5422 "Insert a newline, but mark it as undeletable."
5423 (gnus-put-text-property
5424 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5426 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5427 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5430 handle (inhibit-read-only t) from props begend not-pref)
5431 (save-window-excursion
5434 (narrow-to-region (car ibegend)
5437 (goto-char (car ibegend))
5440 (delete-region (point-min) (point-max))
5441 (mm-remove-parts handles))
5442 (setq begend (list (point-marker)))
5444 (unless (setq not-pref (cadr (member preferred ihandles)))
5445 (setq not-pref (car ihandles)))
5448 (not (gnus-unbuttonized-mime-type-p
5449 "multipart/alternative")))
5450 (gnus-add-text-properties
5453 (insert (format "%d. " id))
5457 (unless ,(not ibegend)
5458 (setq gnus-article-mime-handle-alist
5459 ',gnus-article-mime-handle-alist))
5460 (gnus-mime-display-alternative
5461 ',ihandles ',not-pref ',begend ,id))
5462 keymap ,gnus-mime-button-map
5463 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5464 face ,gnus-article-button-face
5466 article-type multipart))
5467 (widget-convert-button 'link from (point)
5468 :action 'gnus-widget-press-button
5469 :button-keymap gnus-widget-button-keymap)
5471 (while (setq handle (pop handles))
5472 (gnus-add-text-properties
5475 (insert (format "(%c) %-18s"
5476 (if (equal handle preferred) ?* ? )
5477 (mm-handle-media-type handle)))
5481 (unless ,(not ibegend)
5482 (setq gnus-article-mime-handle-alist
5483 ',gnus-article-mime-handle-alist))
5484 (gnus-mime-display-alternative
5485 ',ihandles ',handle ',begend ,id))
5486 keymap ,gnus-mime-button-map
5487 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5488 face ,gnus-article-button-face
5491 (widget-convert-button 'link from (point)
5492 :action 'gnus-widget-press-button
5493 :button-keymap gnus-widget-button-keymap)
5497 (if (stringp (car preferred))
5498 (gnus-display-mime preferred)
5499 (let ((mail-parse-charset gnus-newsgroup-charset)
5500 (mail-parse-ignored-charsets
5501 (with-current-buffer gnus-summary-buffer
5502 gnus-newsgroup-ignored-charsets)))
5503 (mm-display-part preferred)
5507 (narrow-to-region (car begend) (point-max))
5509 nil (length gnus-article-mime-handle-alist)
5510 (gnus-article-mime-total-parts)
5511 (mm-handle-media-type handle))))))
5512 (goto-char (point-max))
5513 (setcdr begend (point-marker)))))
5515 (goto-char point))))
5517 (defconst gnus-article-wash-status-strings
5518 (let ((alist '((cite "c" "Possible hidden citation text"
5519 " " "All citation text visible")
5520 (headers "h" "Hidden headers"
5521 " " "All headers visible.")
5522 (pgp "p" "Encrypted or signed message status hidden"
5523 " " "No hidden encryption nor digital signature status")
5524 (signature "s" "Signature has been hidden"
5525 " " "Signature is visible")
5526 (overstrike "o" "Overstrike (^H) characters applied"
5527 " " "No overstrike characters applied")
5528 (emphasis "e" "/*_Emphasis_*/ characters applied"
5529 " " "No /*_emphasis_*/ characters applied")))
5531 (dolist (entry alist result)
5532 (let ((key (nth 0 entry))
5533 (on (copy-sequence (nth 1 entry)))
5534 (on-help (nth 2 entry))
5535 (off (copy-sequence (nth 3 entry)))
5536 (off-help (nth 4 entry)))
5537 (put-text-property 0 1 'help-echo on-help on)
5538 (put-text-property 0 1 'help-echo off-help off)
5539 (push (list key on off) result))))
5540 "Alist of strings describing wash status in the mode line.
5541 Each entry has the form (KEY ON OF), where the KEY is a symbol
5542 representing the particular washing function, ON is the string to use
5543 in the article mode line when the washing function is active, and OFF
5544 is the string to use when it is inactive.")
5546 (defun gnus-article-wash-status-entry (key value)
5547 (let ((entry (assoc key gnus-article-wash-status-strings)))
5548 (if value (nth 1 entry) (nth 2 entry))))
5550 (defun gnus-article-wash-status ()
5551 "Return a string which display status of article washing."
5552 (with-current-buffer gnus-article-buffer
5553 (let ((cite (memq 'cite gnus-article-wash-types))
5554 (headers (memq 'headers gnus-article-wash-types))
5555 (boring (memq 'boring-headers gnus-article-wash-types))
5556 (pgp (memq 'pgp gnus-article-wash-types))
5557 (pem (memq 'pem gnus-article-wash-types))
5558 (signed (memq 'signed gnus-article-wash-types))
5559 (encrypted (memq 'encrypted gnus-article-wash-types))
5560 (signature (memq 'signature gnus-article-wash-types))
5561 (overstrike (memq 'overstrike gnus-article-wash-types))
5562 (emphasis (memq 'emphasis gnus-article-wash-types)))
5564 (gnus-article-wash-status-entry 'cite cite)
5565 (gnus-article-wash-status-entry 'headers (or headers boring))
5566 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5567 (gnus-article-wash-status-entry 'signature signature)
5568 (gnus-article-wash-status-entry 'overstrike overstrike)
5569 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5571 (defun gnus-add-wash-type (type)
5572 "Add a washing of TYPE to the current status."
5573 (add-to-list 'gnus-article-wash-types type))
5575 (defun gnus-delete-wash-type (type)
5576 "Add a washing of TYPE to the current status."
5577 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5579 (defun gnus-add-image (category image)
5580 "Add IMAGE of CATEGORY to the list of displayed images."
5581 (let ((entry (assq category gnus-article-image-alist)))
5583 (setq entry (list category))
5584 (push entry gnus-article-image-alist))
5585 (nconc entry (list image))))
5587 (defun gnus-delete-images (category)
5588 "Delete all images in CATEGORY."
5589 (let ((entry (assq category gnus-article-image-alist)))
5590 (dolist (image (cdr entry))
5591 (gnus-remove-image image category))
5592 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5593 (gnus-delete-wash-type category)))
5595 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5597 (defun gnus-article-maybe-hide-headers ()
5598 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5599 Provided for backwards compatibility."
5600 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5601 (not (with-current-buffer gnus-summary-buffer
5602 gnus-have-all-headers)))
5603 (not gnus-inhibit-hiding))
5604 (gnus-article-hide-headers)))
5608 (defun gnus-output-to-file (file-name)
5609 "Append the current article to a file named FILE-NAME.
5610 If `gnus-article-save-coding-system' is non-nil, it is used to encode
5611 text and used as the value of the coding cookie which is added to the
5612 top of a file. Otherwise, this function saves a raw article without
5614 (let* ((artbuf (current-buffer))
5615 (file-name-coding-system nnmail-pathname-coding-system)
5616 (coding gnus-article-save-coding-system)
5617 (coding-system-for-read (if coding
5618 nil ;; Rely on the coding cookie.
5619 mm-text-coding-system))
5620 (coding-system-for-write (or coding
5621 mm-text-coding-system-for-write
5622 mm-text-coding-system))
5623 (exists (file-exists-p file-name)))
5626 (insert-file-contents file-name)
5627 (goto-char (point-min))
5628 ;; Remove the existing coding cookie.
5629 (when (looking-at "X-Gnus-Coding-System: .+\n\n")
5630 (delete-region (match-beginning 0) (match-end 0))))
5631 (goto-char (point-max))
5632 (insert-buffer-substring artbuf)
5633 ;; Append newline at end of the buffer as separator, and then
5635 (goto-char (point-max))
5638 ;; If the coding system is not suitable to encode the text,
5639 ;; ask a user for a proper one.
5640 (when (fboundp 'select-safe-coding-system)
5641 (setq coding (coding-system-base
5642 (save-window-excursion
5643 (select-safe-coding-system (point-min) (point-max)
5645 (setq coding-system-for-write
5646 (or (cdr (assq coding '((mule-utf-8 . utf-8))))
5648 (goto-char (point-min))
5649 ;; Add the coding cookie.
5650 (insert (format "X-Gnus-Coding-System: -*- coding: %s; -*-\n\n"
5651 coding-system-for-write)))
5654 (write-region (point-min) (point-max) file-name nil 'no-message)
5655 (message "Appended to %s" file-name))
5656 (write-region (point-min) (point-max) file-name))))
5659 (defun gnus-narrow-to-page (&optional arg)
5660 "Narrow the article buffer to a page.
5661 If given a numerical ARG, move forward ARG pages."
5663 (setq arg (if arg (prefix-numeric-value arg) 0))
5665 (set-buffer gnus-article-buffer)
5666 (goto-char (point-min))
5668 ;; Remove any old next/prev buttons.
5669 (when (gnus-visual-p 'page-marker)
5670 (let ((inhibit-read-only t))
5671 (gnus-remove-text-with-property 'gnus-prev)
5672 (gnus-remove-text-with-property 'gnus-next)))
5675 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5677 (re-search-forward page-delimiter nil 'move arg)))
5678 (goto-char (match-end 0))
5680 (goto-char (point-min))
5681 (setq gnus-page-broken
5682 (and (re-search-forward page-delimiter nil t) t))))
5683 (when gnus-page-broken
5686 (if (re-search-forward page-delimiter nil 'move)
5689 (when (and (gnus-visual-p 'page-marker)
5690 (> (point-min) (save-restriction (widen) (point-min))))
5692 (goto-char (point-min))
5693 (gnus-insert-prev-page-button)))
5694 (when (and (gnus-visual-p 'page-marker)
5695 (< (point-max) (save-restriction (widen) (point-max))))
5697 (goto-char (point-max))
5698 (gnus-insert-next-page-button))))))
5700 ;; Article mode commands
5702 (defun gnus-article-goto-next-page ()
5703 "Show the next page of the article."
5705 (when (gnus-article-next-page)
5706 (goto-char (point-min))
5707 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5710 (defun gnus-article-goto-prev-page ()
5711 "Show the previous page of the article."
5714 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5715 (gnus-article-prev-page nil)))
5717 ;; This is cleaner but currently breaks `gnus-pick-mode':
5719 ;; (defun gnus-article-goto-next-page ()
5720 ;; "Show the next page of the article."
5722 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5723 ;; (gnus-summary-next-page)))
5725 ;; (defun gnus-article-goto-prev-page ()
5726 ;; "Show the next page of the article."
5728 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5729 ;; (gnus-summary-prev-page)))
5731 (defun gnus-article-next-page (&optional lines)
5732 "Show the next page of the current article.
5733 If end of article, return non-nil. Otherwise return nil.
5734 Argument LINES specifies lines to be scrolled up."
5736 (move-to-window-line -1)
5739 (and (pos-visible-in-window-p) ;Not continuation line.
5740 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5741 ;; Nothing in this page.
5742 (if (or (not gnus-page-broken)
5747 (eobp)))) ;Real end-of-buffer?
5749 (when gnus-article-over-scroll
5750 (gnus-article-next-page-1 lines))
5752 (gnus-narrow-to-page 1) ;Go to next page.
5754 ;; More in this page.
5755 (gnus-article-next-page-1 lines)
5758 (defmacro gnus-article-beginning-of-window ()
5759 "Move point to the beginning of the window.
5760 In Emacs, the point is placed at the line number which `scroll-margin'
5762 (if (featurep 'xemacs)
5763 '(move-to-window-line 0)
5764 '(move-to-window-line
5765 (min (max 0 scroll-margin)
5766 (max 1 (- (window-height)
5767 (if mode-line-format 1 0)
5768 (if header-line-format 1 0)))))))
5770 (defun gnus-article-next-page-1 (lines)
5771 (when (and (not (featurep 'xemacs))
5774 (numberp (symbol-value 'scroll-margin))
5775 (> (symbol-value 'scroll-margin) 0))
5776 ;; Protect against the bug that Emacs 21.x hangs up when scrolling up for
5777 ;; too many number of lines if `scroll-margin' is set as two or greater.
5778 (setq lines (min lines
5779 (max 0 (- (count-lines (window-start) (point-max))
5780 (symbol-value 'scroll-margin))))))
5782 (let ((scroll-in-place nil))
5785 ;; Long lines may cause an end-of-buffer error.
5786 (goto-char (point-max))))
5787 (gnus-article-beginning-of-window))
5789 (defun gnus-article-prev-page (&optional lines)
5790 "Show previous page of current article.
5791 Argument LINES specifies lines to be scrolled down."
5793 (move-to-window-line 0)
5794 (if (and gnus-page-broken
5796 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5798 (gnus-narrow-to-page -1) ;Go to previous page.
5799 (goto-char (point-max))
5803 (let ((scroll-in-place nil))
5804 (scroll-down lines))
5805 (beginning-of-buffer
5806 (goto-char (point-min))))
5807 (gnus-article-beginning-of-window))))
5809 (defun gnus-article-only-boring-p ()
5810 "Decide whether there is only boring text remaining in the article.
5811 Something \"interesting\" is a word of at least two letters that does
5812 not have a face in `gnus-article-boring-faces'."
5813 (when (and gnus-article-skip-boring
5814 (boundp 'gnus-article-boring-faces)
5815 (symbol-value 'gnus-article-boring-faces))
5817 (let ((inhibit-point-motion-hooks t))
5819 (while (re-search-forward "\\b\\w\\w" nil t)
5821 (when (not (gnus-intersection
5822 (gnus-faces-at (point))
5823 (symbol-value 'gnus-article-boring-faces)))
5824 (throw 'only-boring nil)))
5825 (throw 'only-boring t))))))
5827 (defun gnus-article-refer-article ()
5828 "Read article specified by message-id around point."
5831 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5832 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5833 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5834 (let ((msg-id (concat "<" (match-string 0) ">")))
5835 (set-buffer gnus-summary-buffer)
5836 (gnus-summary-refer-article msg-id))
5837 (error "No references around point"))))
5839 (defun gnus-article-show-summary ()
5840 "Reconfigure windows to show summary buffer."
5842 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5843 (error "There is no summary buffer for this article buffer")
5844 (gnus-article-set-globals)
5845 (gnus-configure-windows 'article)
5846 (gnus-summary-goto-subject gnus-current-article)
5847 (gnus-summary-position-point)))
5849 (defun gnus-article-describe-briefly ()
5850 "Describe article mode commands briefly."
5852 (gnus-message 6 (substitute-command-keys "\\<gnus-article-mode-map>\\[gnus-article-goto-next-page]:Next page \\[gnus-article-goto-prev-page]:Prev page \\[gnus-article-show-summary]:Show summary \\[gnus-info-find-node]:Run Info \\[gnus-article-describe-briefly]:This help")))
5854 (defun gnus-article-summary-command ()
5855 "Execute the last keystroke in the summary buffer."
5857 (let ((obuf (current-buffer))
5858 (owin (current-window-configuration))
5860 (switch-to-buffer gnus-article-current-summary 'norecord)
5861 (setq func (lookup-key (current-local-map) (this-command-keys)))
5862 (call-interactively func)
5864 (set-window-configuration owin)
5865 (set-window-point (get-buffer-window (current-buffer)) (point))))
5867 (defun gnus-article-summary-command-nosave ()
5868 "Execute the last keystroke in the summary buffer."
5871 (pop-to-buffer gnus-article-current-summary 'norecord)
5872 (setq func (lookup-key (current-local-map) (this-command-keys)))
5873 (call-interactively func)))
5875 (defun gnus-article-check-buffer ()
5876 "Beep if not in an article buffer."
5877 (unless (equal major-mode 'gnus-article-mode)
5878 (error "Command invoked outside of a Gnus article buffer")))
5880 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5881 "Read a summary buffer key sequence and execute it from the article buffer."
5883 (gnus-article-check-buffer)
5885 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5886 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5887 "=" "^" "\M-^" "|"))
5893 '("n" "Gn" "p" "Gp"))
5896 (set-buffer gnus-article-current-summary)
5897 (let (gnus-pick-mode)
5898 (push (or key last-command-event) unread-command-events)
5899 (setq keys (if (featurep 'xemacs)
5900 (events-to-keys (read-key-sequence nil))
5901 (read-key-sequence nil)))))
5905 (if (or (member keys nosaves)
5906 (member keys nosave-but-article)
5907 (member keys nosave-in-article))
5909 (save-window-excursion
5910 (pop-to-buffer gnus-article-current-summary 'norecord)
5911 ;; We disable the pick minor mode commands.
5912 (let (gnus-pick-mode)
5913 (setq func (lookup-key (current-local-map) keys))))
5917 (unless (member keys nosave-in-article)
5918 (set-buffer gnus-article-current-summary))
5919 (call-interactively func)
5920 (setq new-sum-point (point)))
5921 (when (member keys nosave-but-article)
5922 (pop-to-buffer gnus-article-buffer 'norecord)))
5923 ;; These commands should restore window configuration.
5924 (let ((obuf (current-buffer))
5925 (owin (current-window-configuration))
5927 win func in-buffer selected new-sum-start new-sum-hscroll)
5928 (cond (not-restore-window
5929 (pop-to-buffer gnus-article-current-summary 'norecord))
5930 ((setq win (get-buffer-window gnus-article-current-summary))
5931 (select-window win))
5933 (switch-to-buffer gnus-article-current-summary 'norecord)))
5934 (setq in-buffer (current-buffer))
5935 ;; We disable the pick minor mode commands.
5936 (if (and (setq func (let (gnus-pick-mode)
5937 (lookup-key (current-local-map) keys)))
5940 (call-interactively func)
5941 (when (eq win (selected-window))
5942 (setq new-sum-point (point)
5943 new-sum-start (window-start win)
5944 new-sum-hscroll (window-hscroll win)))
5945 (when (eq in-buffer (current-buffer))
5946 (setq selected (gnus-summary-select-article))
5948 (unless not-restore-window
5949 (set-window-configuration owin))
5950 (when (eq selected 'old)
5952 (set-window-start (get-buffer-window (current-buffer))
5954 (set-window-point (get-buffer-window (current-buffer))
5956 (when (and (not not-restore-window)
5958 (set-window-point win new-sum-point)
5959 (set-window-start win new-sum-start)
5960 (set-window-hscroll win new-sum-hscroll))))
5961 (set-window-configuration owin)
5964 (defun gnus-article-describe-key (key)
5965 "Display documentation of the function invoked by KEY. KEY is a string."
5966 (interactive "kDescribe key: ")
5967 (gnus-article-check-buffer)
5968 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5970 (set-buffer gnus-article-current-summary)
5971 (let (gnus-pick-mode)
5972 (if (featurep 'xemacs)
5974 (push (elt key 0) unread-command-events)
5975 (setq key (events-to-keys
5976 (read-key-sequence "Describe key: "))))
5977 (setq unread-command-events
5979 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5980 (string-to-list key)))
5981 (setq key (read-key-sequence "Describe key: "))))
5983 (describe-key key)))
5985 (defun gnus-article-describe-key-briefly (key &optional insert)
5986 "Display documentation of the function invoked by KEY. KEY is a string."
5987 (interactive "kDescribe key: \nP")
5988 (gnus-article-check-buffer)
5989 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5991 (set-buffer gnus-article-current-summary)
5992 (let (gnus-pick-mode)
5993 (if (featurep 'xemacs)
5995 (push (elt key 0) unread-command-events)
5996 (setq key (events-to-keys
5997 (read-key-sequence "Describe key: "))))
5998 (setq unread-command-events
6000 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
6001 (string-to-list key)))
6002 (setq key (read-key-sequence "Describe key: "))))
6003 (describe-key-briefly key insert))
6004 (describe-key-briefly key insert)))
6006 (defun gnus-article-reply-with-original (&optional wide)
6007 "Start composing a reply mail to the current message.
6008 The text in the region will be yanked. If the region isn't active,
6009 the entire article will be yanked."
6011 (let ((article (cdr gnus-article-current))
6013 (if (not (gnus-region-active-p))
6014 (with-current-buffer gnus-summary-buffer
6015 (gnus-summary-reply (list (list article)) wide))
6016 (setq contents (buffer-substring (point) (mark t)))
6017 ;; Deactivate active regions.
6018 (when (and (boundp 'transient-mark-mode)
6019 transient-mark-mode)
6020 (setq mark-active nil))
6021 (with-current-buffer gnus-summary-buffer
6023 (list (list article contents)) wide)))))
6025 (defun gnus-article-followup-with-original ()
6026 "Compose a followup to the current article.
6027 The text in the region will be yanked. If the region isn't active,
6028 the entire article will be yanked."
6030 (let ((article (cdr gnus-article-current))
6032 (if (not (gnus-region-active-p))
6033 (with-current-buffer gnus-summary-buffer
6034 (gnus-summary-followup (list (list article))))
6035 (setq contents (buffer-substring (point) (mark t)))
6036 ;; Deactivate active regions.
6037 (when (and (boundp 'transient-mark-mode)
6038 transient-mark-mode)
6039 (setq mark-active nil))
6040 (with-current-buffer gnus-summary-buffer
6041 (gnus-summary-followup
6042 (list (list article contents)))))))
6044 (defun gnus-article-hide (&optional arg force)
6045 "Hide all the gruft in the current article.
6046 This means that signatures, cited text and (some) headers will be
6048 If given a prefix, show the hidden text instead."
6049 (interactive (append (gnus-article-hidden-arg) (list 'force)))
6050 (gnus-article-hide-headers arg)
6051 (gnus-article-hide-list-identifiers arg)
6052 (gnus-article-hide-citation-maybe arg force)
6053 (gnus-article-hide-signature arg))
6055 (defun gnus-article-maybe-highlight ()
6056 "Do some article highlighting if article highlighting is requested."
6057 (when (gnus-visual-p 'article-highlight 'highlight)
6058 (gnus-article-highlight-some)))
6060 (defun gnus-check-group-server ()
6061 ;; Make sure the connection to the server is alive.
6062 (unless (gnus-server-opened
6063 (gnus-find-method-for-group gnus-newsgroup-name))
6064 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
6065 (gnus-request-group gnus-newsgroup-name t)))
6068 (autoload 'nneething-get-file-name "nneething"))
6070 (defun gnus-request-article-this-buffer (article group)
6071 "Get an article and insert it into this buffer."
6072 (let (do-update-line sparse-header)
6076 (gnus-kill-all-overlays)
6077 (setq group (or group gnus-newsgroup-name))
6079 ;; Using `gnus-request-article' directly will insert the article into
6080 ;; `nntp-server-buffer' - so we'll save some time by not having to
6081 ;; copy it from the server buffer into the article buffer.
6083 ;; We only request an article by message-id when we do not have the
6084 ;; headers for it, so we'll have to get those.
6085 (when (stringp article)
6086 (gnus-read-header article))
6088 ;; If the article number is negative, that means that this article
6089 ;; doesn't belong in this newsgroup (possibly), so we find its
6090 ;; message-id and request it by id instead of number.
6091 (when (and (numberp article)
6093 (get-buffer gnus-summary-buffer)
6094 (gnus-buffer-exists-p gnus-summary-buffer))
6096 (set-buffer gnus-summary-buffer)
6097 (let ((header (gnus-summary-article-header article)))
6100 ((memq article gnus-newsgroup-sparse)
6101 ;; This is a sparse gap article.
6102 (setq do-update-line article)
6103 (setq article (mail-header-id header))
6104 (setq sparse-header (gnus-read-header article))
6105 (setq gnus-newsgroup-sparse
6106 (delq article gnus-newsgroup-sparse)))
6108 ;; It's a real article.
6109 (setq article (mail-header-id header)))
6111 ;; It is an extracted pseudo-article.
6112 (setq article 'pseudo)
6113 (gnus-request-pseudo-article header))))
6115 (let ((method (gnus-find-method-for-group
6116 gnus-newsgroup-name)))
6117 (when (and (eq (car method) 'nneething)
6119 (let ((dir (nneething-get-file-name
6120 (mail-header-id header))))
6121 (when (and (stringp dir)
6122 (file-directory-p dir))
6123 (setq article 'nneething)
6124 (gnus-group-enter-directory dir))))))))
6127 ;; Refuse to select canceled articles.
6128 ((and (numberp article)
6130 (get-buffer gnus-summary-buffer)
6131 (gnus-buffer-exists-p gnus-summary-buffer)
6132 (eq (cdr (with-current-buffer gnus-summary-buffer
6133 (assq article gnus-newsgroup-reads)))
6134 gnus-canceled-mark))
6136 ;; We first check `gnus-original-article-buffer'.
6137 ((and (get-buffer gnus-original-article-buffer)
6139 (with-current-buffer gnus-original-article-buffer
6140 (and (equal (car gnus-original-article) group)
6141 (eq (cdr gnus-original-article) article))))
6142 (insert-buffer-substring gnus-original-article-buffer)
6144 ;; Check the backlog.
6145 ((and gnus-keep-backlog
6146 (gnus-backlog-request-article group article (current-buffer)))
6148 ;; Check asynchronous pre-fetch.
6149 ((gnus-async-request-fetched-article group article (current-buffer))
6150 (gnus-async-prefetch-next group article gnus-summary-buffer)
6151 (when (and (numberp article) gnus-keep-backlog)
6152 (gnus-backlog-enter-article group article (current-buffer)))
6155 ((and gnus-use-cache
6157 (gnus-cache-request-article article group))
6159 ;; Check the agent cache.
6160 ((gnus-agent-request-article article group)
6162 ;; Get the article and put into the article buffer.
6163 ((or (stringp article)
6165 (let ((gnus-override-method gnus-override-method)
6166 (methods (and (stringp article)
6167 gnus-refer-article-method))
6168 (backend (car (gnus-find-method-for-group
6169 gnus-newsgroup-name)))
6171 (inhibit-read-only t))
6172 (if (or (not (listp methods))
6173 (and (symbolp (car methods))
6174 (assq (car methods) nnoo-definition-alist)))
6175 (setq methods (list methods)))
6176 (when (and (null gnus-override-method)
6178 (setq gnus-override-method (pop methods)))
6180 (when (eq gnus-override-method 'current)
6181 (setq gnus-override-method
6182 (with-current-buffer gnus-summary-buffer
6183 gnus-current-select-method)))
6185 (gnus-kill-all-overlays)
6186 (let ((gnus-newsgroup-name group))
6187 (gnus-check-group-server))
6189 ((gnus-request-article article group (current-buffer))
6190 (when (numberp article)
6191 (gnus-async-prefetch-next group article
6192 gnus-summary-buffer)
6193 (when gnus-keep-backlog
6194 (gnus-backlog-enter-article
6195 group article (current-buffer))))
6196 (setq result 'article))
6198 (setq gnus-override-method (pop methods)))
6199 ((not (string-match "^400 "
6200 (nnheader-get-report backend)))
6201 ;; If we get 400 server disconnect, reconnect and
6202 ;; retry; otherwise, assume the article has expired.
6203 (setq result 'done))))
6204 (and (eq result 'article) 'article)))
6208 ;; Associate this article with the current summary buffer.
6209 (setq gnus-article-current-summary gnus-summary-buffer)
6211 ;; Take the article from the original article buffer
6212 ;; and place it in the buffer it's supposed to be in.
6213 (when (and (get-buffer gnus-article-buffer)
6214 (equal (buffer-name (current-buffer))
6215 (buffer-name (get-buffer gnus-article-buffer))))
6217 (if (get-buffer gnus-original-article-buffer)
6218 (set-buffer gnus-original-article-buffer)
6219 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
6220 (buffer-disable-undo)
6221 (setq major-mode 'gnus-original-article-mode)
6222 (setq buffer-read-only t))
6223 (let ((inhibit-read-only t))
6225 (insert-buffer-substring gnus-article-buffer))
6226 (setq gnus-original-article (cons group article)))
6229 (run-hooks 'gnus-article-decode-hook)
6230 ;; Mark article as decoded or not.
6231 (setq gnus-article-decoded-p gnus-article-decode-hook))
6233 ;; Update sparse articles.
6234 (when (and do-update-line
6235 (or (numberp article)
6237 (let ((buf (current-buffer)))
6238 (set-buffer gnus-summary-buffer)
6239 (gnus-summary-update-article do-update-line sparse-header)
6240 (gnus-summary-goto-subject do-update-line nil t)
6241 (set-window-point (gnus-get-buffer-window (current-buffer) t)
6243 (set-buffer buf))))))
6249 (defcustom gnus-article-edit-mode-hook nil
6250 "Hook run in article edit mode buffers."
6251 :group 'gnus-article-various
6254 (defvar gnus-article-edit-done-function nil)
6256 (defvar gnus-article-edit-mode-map nil)
6258 ;; Should we be using derived.el for this?
6259 (unless gnus-article-edit-mode-map
6260 (setq gnus-article-edit-mode-map (make-keymap))
6261 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
6263 (gnus-define-keys gnus-article-edit-mode-map
6264 "\C-c?" describe-mode
6265 "\C-c\C-c" gnus-article-edit-done
6266 "\C-c\C-k" gnus-article-edit-exit
6267 "\C-c\C-f\C-t" message-goto-to
6268 "\C-c\C-f\C-o" message-goto-from
6269 "\C-c\C-f\C-b" message-goto-bcc
6270 ;;"\C-c\C-f\C-w" message-goto-fcc
6271 "\C-c\C-f\C-c" message-goto-cc
6272 "\C-c\C-f\C-s" message-goto-subject
6273 "\C-c\C-f\C-r" message-goto-reply-to
6274 "\C-c\C-f\C-n" message-goto-newsgroups
6275 "\C-c\C-f\C-d" message-goto-distribution
6276 "\C-c\C-f\C-f" message-goto-followup-to
6277 "\C-c\C-f\C-m" message-goto-mail-followup-to
6278 "\C-c\C-f\C-k" message-goto-keywords
6279 "\C-c\C-f\C-u" message-goto-summary
6280 "\C-c\C-f\C-i" message-insert-or-toggle-importance
6281 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
6282 "\C-c\C-b" message-goto-body
6283 "\C-c\C-i" message-goto-signature
6285 "\C-c\C-t" message-insert-to
6286 "\C-c\C-n" message-insert-newsgroups
6287 "\C-c\C-o" message-sort-headers
6288 "\C-c\C-e" message-elide-region
6289 "\C-c\C-v" message-delete-not-region
6290 "\C-c\C-z" message-kill-to-signature
6291 "\M-\r" message-newline-and-reformat
6292 "\C-c\C-a" mml-attach-file
6293 "\C-a" message-beginning-of-line
6295 "\M-;" comment-region)
6297 (gnus-define-keys (gnus-article-edit-wash-map
6298 "\C-c\C-w" gnus-article-edit-mode-map)
6299 "f" gnus-article-edit-full-stops))
6302 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
6304 ["Fetch To" message-insert-to t]
6305 ["Fetch Newsgroups" message-insert-newsgroups t]
6307 ["To" message-goto-to t]
6308 ["From" message-goto-from t]
6309 ["Subject" message-goto-subject t]
6310 ["Cc" message-goto-cc t]
6311 ["Reply-To" message-goto-reply-to t]
6312 ["Summary" message-goto-summary t]
6313 ["Keywords" message-goto-keywords t]
6314 ["Newsgroups" message-goto-newsgroups t]
6315 ["Followup-To" message-goto-followup-to t]
6316 ["Mail-Followup-To" message-goto-mail-followup-to t]
6317 ["Distribution" message-goto-distribution t]
6318 ["Body" message-goto-body t]
6319 ["Signature" message-goto-signature t]))
6321 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
6322 "Major mode for editing articles.
6323 This is an extended text-mode.
6325 \\{gnus-article-edit-mode-map}"
6326 (make-local-variable 'gnus-article-edit-done-function)
6327 (make-local-variable 'gnus-prev-winconf)
6328 (set (make-local-variable 'font-lock-defaults)
6329 '(message-font-lock-keywords t))
6330 (set (make-local-variable 'mail-header-separator) "")
6331 (set (make-local-variable 'gnus-article-edit-mode) t)
6332 (easy-menu-add message-mode-field-menu message-mode-map)
6334 (setq buffer-read-only nil)
6335 (buffer-enable-undo)
6338 (defun gnus-article-edit (&optional force)
6339 "Edit the current article.
6340 This will have permanent effect only in mail groups.
6341 If FORCE is non-nil, allow editing of articles even in read-only
6344 (when (and (not force)
6345 (gnus-group-read-only-p))
6346 (error "The current newsgroup does not support article editing"))
6347 (gnus-article-date-original)
6348 (gnus-article-edit-article
6350 `(lambda (no-highlight)
6352 (gnus-summary-edit-article-done
6353 ,(or (mail-header-references gnus-current-headers) "")
6354 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
6356 (defun gnus-article-edit-article (start-func exit-func &optional quiet)
6357 "Start editing the contents of the current article buffer."
6358 (let ((winconf (current-window-configuration)))
6359 (set-buffer gnus-article-buffer)
6360 (let ((message-auto-save-directory
6361 ;; Don't associate the article buffer with a draft file.
6363 (gnus-article-edit-mode))
6364 (funcall start-func)
6365 (set-buffer-modified-p nil)
6366 (gnus-configure-windows 'edit-article)
6367 (setq gnus-article-edit-done-function exit-func)
6368 (setq gnus-prev-winconf winconf)
6370 (gnus-message 6 "C-c C-c to end edits"))))
6372 (defun gnus-article-edit-done (&optional arg)
6373 "Update the article edits and exit."
6375 (let ((func gnus-article-edit-done-function)
6376 (buf (current-buffer))
6377 (start (window-start))
6379 (winconf gnus-prev-winconf))
6380 (widen) ;; Widen it in case that users narrowed the buffer.
6383 ;; The cache and backlog have to be flushed somewhat.
6384 (when gnus-keep-backlog
6385 (gnus-backlog-remove-article
6386 (car gnus-article-current) (cdr gnus-article-current)))
6387 ;; Flush original article as well.
6389 (when (get-buffer gnus-original-article-buffer)
6390 (set-buffer gnus-original-article-buffer)
6391 (setq gnus-original-article nil)))
6392 (when gnus-use-cache
6393 (gnus-cache-update-article
6394 (car gnus-article-current) (cdr gnus-article-current)))
6395 ;; We remove all text props from the article buffer.
6396 (kill-all-local-variables)
6397 (set-text-properties (point-min) (point-max) nil)
6399 (set-window-configuration winconf)
6401 (set-window-start (get-buffer-window buf) start)
6402 (set-window-point (get-buffer-window buf) (point)))
6403 (gnus-summary-show-article))
6405 (defun gnus-article-edit-exit ()
6406 "Exit the article editing without updating."
6408 (when (or (not (buffer-modified-p))
6409 (yes-or-no-p "Article modified; kill anyway? "))
6410 (let ((curbuf (current-buffer))
6412 (window-start (window-start)))
6414 (if (gnus-buffer-live-p gnus-original-article-buffer)
6415 (insert-buffer-substring gnus-original-article-buffer))
6416 (let ((winconf gnus-prev-winconf))
6417 (kill-all-local-variables)
6419 (set-window-configuration winconf)
6420 ;; Tippy-toe some to make sure that point remains where it was.
6421 (save-current-buffer
6423 (set-window-start (get-buffer-window (current-buffer)) window-start)
6425 (gnus-summary-show-article)))
6427 (defun gnus-article-edit-full-stops ()
6428 "Interactively repair spacing at end of sentences."
6431 (goto-char (point-min))
6432 (search-forward-regexp "^$" nil t)
6433 (let ((case-fold-search nil))
6434 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
6437 ;;; Article highlights
6440 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6442 ;;; Internal Variables:
6444 (defcustom gnus-button-url-regexp
6445 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
6446 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-z0-9_.]+:[0-9]*\\)?[-a-z0-9_=!?#$@~%&*+\\/:;.,[:word:]]+[-a-z0-9_=#$@~%&*+\\/[:word:]]\\)"
6447 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-z0-9_.]+:[0-9]*\\)?\\([-a-z0-9_=!?#$@~%&*+\\/:;.,]\\|\\w\\)+\\([-a-z0-9_=#$@~%&*+\\/]\\|\\w\\)\\)")
6448 "Regular expression that matches URLs."
6449 :group 'gnus-article-buttons
6452 (defcustom gnus-button-valid-fqdn-regexp
6453 message-valid-fqdn-regexp
6454 "Regular expression that matches a valid FQDN."
6456 :group 'gnus-article-buttons
6459 ;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
6460 (defcustom gnus-button-valid-localpart-regexp
6461 "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t @]*"
6462 "Regular expression that matches a localpart of mail addresses or MIDs."
6464 :group 'gnus-article-buttons
6467 (defcustom gnus-button-man-handler 'manual-entry
6468 "Function to use for displaying man pages.
6469 The function must take at least one argument with a string naming the
6472 :type '(choice (function-item :tag "Man" manual-entry)
6473 (function-item :tag "Woman" woman)
6474 (function :tag "Other"))
6475 :group 'gnus-article-buttons)
6477 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6478 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6479 If the default site is too slow, try to find a CTAN mirror, see
6480 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6481 the variable `gnus-button-handle-ctan'."
6483 :group 'gnus-article-buttons
6484 :link '(custom-manual "(gnus)Group Parameters")
6485 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6486 (const "http://tug.ctan.org/tex-archive/")
6487 (const "http://www.dante.de/CTAN/")
6488 (string :tag "Other")))
6490 (defcustom gnus-button-ctan-handler 'browse-url
6491 "Function to use for displaying CTAN links.
6492 The function must take one argument, the string naming the URL."
6494 :type '(choice (function-item :tag "Browse Url" browse-url)
6495 (function :tag "Other"))
6496 :group 'gnus-article-buttons)
6498 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6499 "Bogus strings removed from CTAN URLs."
6501 :group 'gnus-article-buttons
6502 :type '(choice (const "^/?tex-archive/\\|/")
6503 (regexp :tag "Other")))
6505 (defcustom gnus-button-ctan-directory-regexp
6507 (list "archive-tools" "biblio" "bibliography" "digests" "documentation"
6508 "dviware" "fonts" "graphics" "help" "indexing" "info" "language"
6509 "languages" "macros" "nonfree" "obsolete" "support" "systems"
6510 "tds" "tools" "usergrps" "web") t)
6511 "Regular expression for ctan directories.
6512 It should match all directories in the top level of `gnus-ctan-url'."
6514 :group 'gnus-article-buttons
6517 (defcustom gnus-button-mid-or-mail-regexp
6518 (concat "\\b\\(<?" gnus-button-valid-localpart-regexp "@"
6519 gnus-button-valid-fqdn-regexp
6521 "Regular expression that matches a message ID or a mail address."
6523 :group 'gnus-article-buttons
6526 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6527 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6528 Strings like this can be either a message ID or a mail address. If it is one
6529 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6530 message ID or a mail address, respectively. If this variable is set to the
6531 symbol `ask', always query the user what do do. If it is a function, this
6532 function will be called with the string as it's only argument. The function
6533 must return `mid', `mail', `invalid' or `ask'."
6535 :group 'gnus-article-buttons
6536 :type '(choice (function-item :tag "Heuristic function"
6537 gnus-button-mid-or-mail-heuristic)
6542 (defcustom gnus-button-mid-or-mail-heuristic-alist
6543 '((-10.0 . ".+\\$.+@")
6546 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6547 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6548 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6549 (-1.0 . "^[^a-z]+@")
6551 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6552 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6553 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6554 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6557 (-1.0 . "^[0-9][0-9]")
6559 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6560 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6561 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6562 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6564 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6565 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6568 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6570 ;; compensation for TDMA dated mail addresses:
6571 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6573 (-20.0 . "\\.fsf@") ;; Gnus
6576 (-20.0 . "_-_") ;; Subject change in thread
6578 (-20.0 . "\\.ln@") ;; leafnode
6579 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6580 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6582 ;; (5.0 . "") ;; $local_part_len <= 7
6583 (10.0 . "^[^0-9]+@")
6584 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6585 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6588 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6590 (0.5 . "^[A-Z][a-z]")
6591 (0.5 . "^[A-Z][a-z][a-z]")
6592 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6593 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6594 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6596 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6597 address. The REGEXP is processed with `case-fold-search' set to nil."
6599 :group 'gnus-article-buttons
6600 :type '(repeat (cons (number :tag "Rate")
6601 (regexp :tag "Regexp"))))
6603 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6604 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6605 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6606 address, `ask' if unsure and `invalid' if the string is invalid."
6607 (let ((case-fold-search nil)
6608 (list gnus-button-mid-or-mail-heuristic-alist)
6609 (result 0) rate regexp lpartlen elem)
6611 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6612 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6613 ;; Certain special cases...
6616 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6617 "^[0-9]+\\.[0-9]+@compuserve\\|"
6618 "@public\\.gmane\\.org")
6620 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6621 (setq result 'mail))
6622 (when (string-match "@.*@\\| " mid-or-mail)
6623 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6624 (setq result 'invalid))
6625 ;; Nothing more to do, if result is not a number here...
6626 (when (numberp result)
6628 (setq elem (car list)
6632 (when (string-match regexp mid-or-mail)
6633 (setq result (+ result rate))
6635 9 "`%s' matched `%s', rate `%s', result `%s'."
6636 mid-or-mail regexp rate result)))
6637 (when (<= lpartlen 7)
6638 (setq result (+ result 5.0))
6639 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6640 mid-or-mail result))
6641 (when (>= lpartlen 12)
6642 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6644 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6645 ;; Long local part should contain realname if e-mail address,
6646 ;; too many digits: message-id.
6647 ;; $score -= 5.0 + 0.1 * $local_part_len;
6648 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6649 (setq result (+ result rate))
6651 9 "Many digits in `%s', rate `%s', result `%s'."
6652 mid-or-mail rate result))
6653 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6655 ;; Too few vowels [^aeiouy]{4,}.*\@
6656 (setq result (+ result -5.0))
6658 9 "Few vowels in `%s', rate `%s', result `%s'."
6659 mid-or-mail -5.0 result))
6661 (setq result (+ result 5.0))
6663 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6664 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6665 ;; Maybe we should make this a customizable alist: (condition . 'result)
6667 ((symbolp result) result)
6668 ;; Now convert number into proper results:
6669 ((< result -10.0) 'mid)
6670 ((> result 10.0) 'mail)
6673 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6674 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6675 (url-mid (concat "news" ":" mid-or-mail))
6676 (url-mailto (concat "mailto" ":" mid-or-mail)))
6677 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6678 (when (fboundp pref)
6680 ;; get rid of surrounding angles...
6682 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6683 (if (or (eq 'mid guessed) (eq 'mail guessed))
6687 (save-window-excursion
6688 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6691 (cond ((eq pref 'mid)
6692 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6693 (gnus-button-handle-news url-mid))
6695 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6696 (gnus-url-mailto url-mailto))
6697 (t (gnus-message 3 "Invalid string.")))))
6699 (defun gnus-button-handle-custom (fun arg)
6700 "Call function FUN on argument ARG.
6701 Both FUN and ARG are supposed to be strings. ARG will be passed
6702 as a symbol to FUN."
6703 (funcall (intern fun) (intern arg)))
6705 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6707 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6710 (defun gnus-button-handle-describe-function (url)
6711 "Call `describe-function' when pushing the corresponding URL button."
6714 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6716 (defun gnus-button-handle-describe-variable (url)
6717 "Call `describe-variable' when pushing the corresponding URL button."
6720 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6722 (defun gnus-button-handle-symbol (url)
6723 "Display help on variable or function.
6724 Calls `describe-variable' or `describe-function'."
6725 (let ((sym (intern url)))
6727 ((fboundp sym) (describe-function sym))
6728 ((boundp sym) (describe-variable sym))
6729 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6731 (defun gnus-button-handle-describe-key (url)
6732 "Call `describe-key' when pushing the corresponding URL button."
6734 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6735 (keys (ignore-errors (eval `(kbd ,key-string)))))
6738 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6740 (defun gnus-button-handle-apropos (url)
6741 "Call `apropos' when pushing the corresponding URL button."
6742 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6744 (defun gnus-button-handle-apropos-command (url)
6745 "Call `apropos' when pushing the corresponding URL button."
6747 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6749 (defun gnus-button-handle-apropos-variable (url)
6750 "Call `apropos' when pushing the corresponding URL button."
6752 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6753 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6755 (defun gnus-button-handle-apropos-documentation (url)
6756 "Call `apropos' when pushing the corresponding URL button."
6758 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6759 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6761 (defun gnus-button-handle-library (url)
6762 "Call `locate-library' when pushing the corresponding URL button."
6763 (gnus-message 9 "url=`%s'" url)
6764 (let* ((lib (locate-library url))
6765 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6767 (gnus-message 1 "Cannot locale library `%s'." url)
6768 (find-file-read-only file))))
6770 (defun gnus-button-handle-ctan (url)
6771 "Call `browse-url' when pushing a CTAN URL button."
6773 gnus-button-ctan-handler
6776 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6778 (defcustom gnus-button-tex-level 5
6779 "*Integer that says how many TeX-related buttons Gnus will show.
6780 The higher the number, the more buttons will appear and the more false
6781 positives are possible. Note that you can set this variable local to
6782 specific groups. Setting it higher in TeX groups is probably a good idea.
6783 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6784 how to set variables in specific groups."
6786 :group 'gnus-article-buttons
6787 :link '(custom-manual "(gnus)Group Parameters")
6790 (defcustom gnus-button-man-level 5
6791 "*Integer that says how many man-related buttons Gnus will show.
6792 The higher the number, the more buttons will appear and the more false
6793 positives are possible. Note that you can set this variable local to
6794 specific groups. Setting it higher in Unix groups is probably a good idea.
6795 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6796 how to set variables in specific groups."
6798 :group 'gnus-article-buttons
6799 :link '(custom-manual "(gnus)Group Parameters")
6802 (defcustom gnus-button-emacs-level 5
6803 "*Integer that says how many emacs-related buttons Gnus will show.
6804 The higher the number, the more buttons will appear and the more false
6805 positives are possible. Note that you can set this variable local to
6806 specific groups. Setting it higher in Emacs or Gnus related groups is
6807 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6808 `gnus-parameters' on how to set variables in specific groups."
6810 :group 'gnus-article-buttons
6811 :link '(custom-manual "(gnus)Group Parameters")
6814 (defcustom gnus-button-message-level 5
6815 "*Integer that says how many buttons for news or mail messages will appear.
6816 The higher the number, the more buttons will appear and the more false
6817 positives are possible."
6818 ;; mail addresses, MIDs, URLs for news, ...
6820 :group 'gnus-article-buttons
6823 (defcustom gnus-button-browse-level 5
6824 "*Integer that says how many buttons for browsing will appear.
6825 The higher the number, the more buttons will appear and the more false
6826 positives are possible."
6827 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6829 :group 'gnus-article-buttons
6832 (defcustom gnus-button-alist
6833 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6834 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6835 ((concat "\\b\\(nntp\\|news\\):\\("
6836 gnus-button-valid-localpart-regexp "@[a-z0-9.-]+[a-z]\\)")
6837 0 t gnus-button-handle-news 2)
6838 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6839 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6840 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6841 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6842 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6843 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6844 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6845 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6846 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6847 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6848 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6849 ;; RFC 2368 (The mailto URL scheme)
6850 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6851 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6852 ("\\bmailto:\\([^ \n\t]+\\)"
6853 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6855 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6856 gnus-button-ctan-directory-regexp
6857 "[^][>)!;:,'\n\t ]+\\)")
6858 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6859 ((concat "\\btex-archive/\\("
6860 gnus-button-ctan-directory-regexp
6861 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6862 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6865 gnus-button-ctan-directory-regexp
6866 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6867 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6868 ;; This is info (home-grown style) <info://foo/bar+baz>
6869 ("\\binfo://\\([^'\">\n\t ]+\\)"
6870 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6871 ;; Info GNOME style <info:foo#bar_baz>
6872 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6873 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6874 ;; Info KDE style <info:(foo)bar baz>
6875 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6876 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6877 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6878 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6879 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6880 ;; Info links like `C-h i d m CC Mode RET'
6881 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6883 ("M-x[ \t\n]\\(customize-[^ ]+\\)[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6884 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1 2)
6885 ;; Emacs help commands
6886 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6887 ;; regexp doesn't match arguments containing ` '.
6888 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6889 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6890 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6891 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6892 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6893 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6894 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6895 ;; The following entries may lead to many false positives so don't enable
6896 ;; them by default (use a high button level).
6897 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6898 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6899 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6900 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6901 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6902 ("`\\([a-z][a-z0-9]+-[a-z0-9]+-[-a-z0-9]*[a-z]\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6903 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6904 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6905 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6906 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6907 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6908 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6909 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6910 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6911 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6912 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6913 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6914 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6915 ;; Unlike the other regexps we really have to require quoting
6916 ;; here to determine where it ends.
6917 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6918 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6919 ("<URL: *\\([^<>]*\\)>"
6920 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6921 ;; RFC 2396 (2.4.3., delims) ...
6922 ("\"URL: *\\([^\"]*\\)\""
6923 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6924 ;; RFC 2396 (2.4.3., delims) ...
6925 ("\"URL: *\\([^\"]*\\)\""
6926 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6928 (gnus-button-url-regexp
6929 0 (>= gnus-button-browse-level 0) browse-url 0)
6931 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6932 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6933 gnus-button-handle-man 1)
6934 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6935 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6936 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6937 gnus-button-handle-man 1)
6938 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6939 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6940 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6941 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6942 ;; Recognizing patches to .el files. This is somewhat obscure,
6943 ;; but considering the percentage of Gnus users who hack Emacs
6945 ("^--- \\([^ .]+\\.el\\).*\n.*\n@@ -?\\([0-9]+\\)" 1
6946 (>= gnus-button-message-level 4) gnus-button-patch 1 2)
6947 ("^\\*\\*\\* \\([^ .]+\\.el\\).*\n.*\n\\*+\n\\*\\*\\* \\([0-9]+\\)" 1
6948 (>= gnus-button-message-level 4) gnus-button-patch 1 2)
6949 ;; MID or mail: To avoid too many false positives we don't try to catch
6950 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6951 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6952 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6953 ;; so that non-ambiguous entries (see above) match first.
6954 (gnus-button-mid-or-mail-regexp
6955 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6956 "*Alist of regexps matching buttons in article bodies.
6958 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6959 REGEXP: is the string (case insensitive) matching text around the button (can
6960 also be Lisp expression evaluating to a string),
6961 BUTTON: is the number of the regexp grouping actually matching the button,
6962 FORM: is a Lisp expression which must eval to true for the button to
6964 CALLBACK: is the function to call when the user push this button, and each
6965 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6967 CALLBACK can also be a variable, in that case the value of that
6968 variable it the real callback function."
6969 :group 'gnus-article-buttons
6970 :type '(repeat (list (choice regexp variable sexp)
6971 (integer :tag "Button")
6973 (function :tag "Callback")
6976 (integer :tag "Regexp group")))))
6978 (defcustom gnus-header-button-alist
6979 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6980 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6981 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6982 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6983 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6984 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
6985 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6986 0 (>= gnus-button-browse-level 0) browse-url 0)
6987 ("^Subject:" gnus-button-url-regexp
6988 0 (>= gnus-button-browse-level 0) browse-url 0)
6989 ("^[^:]+:" gnus-button-url-regexp
6990 0 (>= gnus-button-browse-level 0) browse-url 0)
6991 ("^OpenPGP:.*url=" gnus-button-url-regexp
6992 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
6993 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6994 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6995 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6996 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6997 "*Alist of headers and regexps to match buttons in article heads.
6999 This alist is very similar to `gnus-button-alist', except that each
7000 alist has an additional HEADER element first in each entry:
7002 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
7004 HEADER is a regexp to match a header. For a fuller explanation, see
7005 `gnus-button-alist'."
7006 :group 'gnus-article-buttons
7007 :group 'gnus-article-headers
7008 :type '(repeat (list (regexp :tag "Header")
7009 (choice regexp variable)
7010 (integer :tag "Button")
7012 (function :tag "Callback")
7015 (integer :tag "Regexp group")))))
7019 (defun gnus-article-push-button (event)
7020 "Check text under the mouse pointer for a callback function.
7021 If the text under the mouse pointer has a `gnus-callback' property,
7022 call it with the value of the `gnus-data' text property."
7024 (set-buffer (window-buffer (posn-window (event-start event))))
7025 (let* ((pos (posn-point (event-start event)))
7026 (data (get-text-property pos 'gnus-data))
7027 (fun (get-text-property pos 'gnus-callback)))
7030 (funcall fun data))))
7032 (defun gnus-article-press-button ()
7033 "Check text at point for a callback function.
7034 If the text at point has a `gnus-callback' property,
7035 call it with the value of the `gnus-data' text property."
7037 (let ((data (get-text-property (point) 'gnus-data))
7038 (fun (get-text-property (point) 'gnus-callback)))
7040 (funcall fun data))))
7042 (defun gnus-article-highlight (&optional force)
7043 "Highlight current article.
7044 This function calls `gnus-article-highlight-headers',
7045 `gnus-article-highlight-citation',
7046 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7047 do the highlighting. See the documentation for those functions."
7048 (interactive (list 'force))
7049 (gnus-article-highlight-headers)
7050 (gnus-article-highlight-citation force)
7051 (gnus-article-highlight-signature)
7052 (gnus-article-add-buttons force)
7053 (gnus-article-add-buttons-to-head))
7055 (defun gnus-article-highlight-some (&optional force)
7056 "Highlight current article.
7057 This function calls `gnus-article-highlight-headers',
7058 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7059 do the highlighting. See the documentation for those functions."
7060 (interactive (list 'force))
7061 (gnus-article-highlight-headers)
7062 (gnus-article-highlight-signature)
7063 (gnus-article-add-buttons))
7065 (defun gnus-article-highlight-headers ()
7066 "Highlight article headers as specified by `gnus-header-face-alist'."
7068 (gnus-with-article-headers
7069 (let (regexp header-face field-face from hpoints fpoints)
7070 (dolist (entry gnus-header-face-alist)
7071 (goto-char (point-min))
7072 (setq regexp (concat "^\\("
7073 (if (string-equal "" (nth 0 entry))
7077 header-face (nth 1 entry)
7078 field-face (nth 2 entry))
7079 (while (and (re-search-forward regexp nil t)
7083 (unless (search-forward ":" nil t)
7085 (when (and header-face
7086 (not (memq (point) hpoints)))
7087 (push (point) hpoints)
7088 (gnus-put-text-property from (point) 'face header-face))
7089 (when (and field-face
7090 (not (memq (setq from (point)) fpoints)))
7092 (if (re-search-forward "^[^ \t]" nil t)
7094 (goto-char (point-max)))
7095 (gnus-put-text-property from (point) 'face field-face)))))))
7097 (defun gnus-article-highlight-signature ()
7098 "Highlight the signature in an article.
7099 It does this by highlighting everything after
7100 `gnus-signature-separator' using the face `gnus-signature'."
7102 (gnus-with-article-buffer
7103 (let ((inhibit-point-motion-hooks t))
7105 (when (and gnus-signature-face
7106 (gnus-article-narrow-to-signature))
7107 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
7108 'face gnus-signature-face)
7110 (gnus-article-search-signature)
7111 (let ((start (match-beginning 0))
7112 (end (set-marker (make-marker) (1+ (match-end 0)))))
7113 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
7116 (defun gnus-button-in-region-p (b e prop)
7117 "Say whether PROP exists in the region."
7118 (text-property-not-all b e prop nil))
7120 (defun gnus-article-add-buttons (&optional force)
7121 "Find external references in the article and make buttons of them.
7122 \"External references\" are things like Message-IDs and URLs, as
7123 specified by `gnus-button-alist'."
7124 (interactive (list 'force))
7125 (gnus-with-article-buffer
7126 (let ((inhibit-point-motion-hooks t)
7127 (case-fold-search t)
7128 (alist gnus-button-alist)
7130 ;; Remove all old markers.
7131 (let (marker entry new-list)
7132 (while (setq marker (pop gnus-button-marker-list))
7133 (if (or (< marker (point-min)) (>= marker (point-max)))
7134 (push marker new-list)
7136 (when (setq entry (gnus-button-entry))
7137 (put-text-property (match-beginning (nth 1 entry))
7138 (match-end (nth 1 entry))
7139 'gnus-callback nil))
7140 (set-marker marker nil)))
7141 (setq gnus-button-marker-list new-list))
7142 ;; We skip the headers.
7145 (while (setq entry (pop alist))
7146 (setq regexp (eval (car entry)))
7148 (while (re-search-forward regexp nil t)
7149 (let* ((start (and entry (match-beginning (nth 1 entry))))
7150 (end (and entry (match-end (nth 1 entry))))
7151 (from (match-beginning 0)))
7152 (when (and (or (eq t (nth 2 entry))
7153 (eval (nth 2 entry)))
7154 (not (gnus-button-in-region-p
7155 start end 'gnus-callback)))
7156 ;; That optional form returned non-nil, so we add the
7158 (gnus-article-add-button
7159 start end 'gnus-button-push
7160 (car (push (set-marker (make-marker) from)
7161 gnus-button-marker-list))))))))))
7163 ;; Add buttons to the head of an article.
7164 (defun gnus-article-add-buttons-to-head ()
7165 "Add buttons to the head of the article."
7167 (gnus-with-article-headers
7169 (dolist (entry gnus-header-button-alist)
7170 ;; Each alist entry.
7171 (goto-char (point-min))
7172 (while (re-search-forward (car entry) nil t)
7173 ;; Each header matching the entry.
7174 (setq beg (match-beginning 0))
7175 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
7176 (match-beginning 0))
7179 (while (re-search-forward (eval (nth 1 entry)) end t)
7180 ;; Each match within a header.
7181 (let* ((entry (cdr entry))
7182 (start (match-beginning (nth 1 entry)))
7183 (end (match-end (nth 1 entry)))
7184 (form (nth 2 entry)))
7185 (goto-char (match-end 0))
7187 (gnus-article-add-button
7188 start end (nth 3 entry)
7189 (buffer-substring (match-beginning (nth 4 entry))
7190 (match-end (nth 4 entry)))))))
7191 (goto-char end))))))
7193 ;;; External functions:
7195 (defun gnus-article-add-button (from to fun &optional data)
7196 "Create a button between FROM and TO with callback FUN and data DATA."
7197 (when gnus-article-button-face
7198 (gnus-overlay-put (gnus-make-overlay from to)
7199 'face gnus-article-button-face))
7200 (gnus-add-text-properties
7202 (nconc (and gnus-article-mouse-face
7203 (list gnus-mouse-face-prop gnus-article-mouse-face))
7204 (list 'gnus-callback fun)
7205 (and data (list 'gnus-data data))))
7206 (widget-convert-button 'link from to :action 'gnus-widget-press-button
7207 :button-keymap gnus-widget-button-keymap))
7209 ;;; Internal functions:
7211 (defun gnus-article-set-globals ()
7212 (with-current-buffer gnus-summary-buffer
7213 (gnus-set-global-variables)))
7215 (defun gnus-signature-toggle (end)
7216 (gnus-with-article-buffer
7217 (let ((inhibit-point-motion-hooks t))
7218 (if (text-property-any end (point-max) 'article-type 'signature)
7220 (gnus-delete-wash-type 'signature)
7221 (gnus-remove-text-properties-when
7222 'article-type 'signature end (point-max)
7223 (cons 'article-type (cons 'signature
7224 gnus-hidden-properties))))
7225 (gnus-add-wash-type 'signature)
7226 (gnus-add-text-properties-when
7227 'article-type nil end (point-max)
7228 (cons 'article-type (cons 'signature
7229 gnus-hidden-properties)))))
7230 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
7231 (gnus-set-mode-line 'article))))
7233 (defun gnus-button-entry ()
7234 ;; Return the first entry in `gnus-button-alist' matching this place.
7235 (let ((alist gnus-button-alist)
7238 (setq entry (pop alist))
7239 (if (looking-at (eval (car entry)))
7244 (defun gnus-button-push (marker)
7245 ;; Push button starting at MARKER.
7248 (let* ((entry (gnus-button-entry))
7249 (inhibit-point-motion-hooks t)
7251 (args (mapcar (lambda (group)
7252 (let ((string (match-string group)))
7253 (set-text-properties
7254 0 (length string) nil string)
7261 (fboundp (symbol-value fun)))
7262 (apply (symbol-value fun) args))
7264 (gnus-message 1 "You must define `%S' to use this button"
7265 (cons fun args)))))))
7267 (defun gnus-parse-news-url (url)
7268 (let (scheme server port group message-id articles)
7271 (goto-char (point-min))
7272 (when (looking-at "\\([A-Za-z]+\\):")
7273 (setq scheme (match-string 1))
7274 (goto-char (match-end 0)))
7275 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
7276 (setq server (match-string 1))
7277 (setq port (if (stringp (match-string 3))
7278 (string-to-number (match-string 3))
7280 (goto-char (match-end 0)))
7283 ((looking-at "\\(.*@.*\\)")
7284 (setq message-id (match-string 1)))
7285 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7286 (setq group (match-string 1)
7287 articles (split-string (match-string 2) "-")))
7288 ((looking-at "\\([^/]+\\)/?")
7289 (setq group (match-string 1)))
7291 (error "Unknown news URL syntax"))))
7292 (list scheme server port group message-id articles)))
7294 (defun gnus-button-handle-news (url)
7296 (destructuring-bind (scheme server port group message-id articles)
7297 (gnus-parse-news-url url)
7301 (set-buffer gnus-summary-buffer)
7303 (let ((gnus-refer-article-method
7304 (nconc (list (list 'nntp server))
7305 gnus-refer-article-method))
7306 (nntp-port-number (or port "nntp")))
7307 (gnus-message 7 "Fetching %s with %s"
7308 message-id gnus-refer-article-method)
7309 (gnus-summary-refer-article message-id))
7310 (gnus-summary-refer-article message-id))))
7312 (gnus-button-fetch-group url)))))
7314 (defun gnus-button-patch (library line)
7315 "Visit an Emacs Lisp library LIBRARY on line LINE."
7317 (let ((file (locate-library (file-name-nondirectory library))))
7319 (error "Couldn't find library %s" library))
7321 (goto-line (string-to-number line))))
7323 (defun gnus-button-handle-man (url)
7325 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7326 (when (eq gnus-button-man-handler 'woman)
7327 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
7328 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7329 (funcall gnus-button-man-handler url))
7331 (defun gnus-button-handle-info-url (url)
7332 "Fetch an info URL."
7333 (setq url (mm-subst-char-in-string ?+ ?\ url))
7335 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
7336 (gnus-info-find-node
7337 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
7339 ")" (gnus-url-unhex-string (match-string 2 url)))))
7340 ((string-match "([^)\"]+)[^\"]+" url)
7342 (gnus-replace-in-string
7343 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
7344 (gnus-info-find-node url))
7345 (t (error "Can't parse %s" url))))
7347 (defun gnus-button-handle-info-url-gnome (url)
7348 "Fetch GNOME style info URL."
7349 (setq url (mm-subst-char-in-string ?_ ?\ url))
7350 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
7351 (gnus-info-find-node
7353 (gnus-url-unhex-string
7354 (match-string 1 url))
7356 (or (gnus-url-unhex-string
7357 (match-string 2 url))
7359 (error "Can't parse %s" url)))
7361 (defun gnus-button-handle-info-url-kde (url)
7362 "Fetch KDE style info URL."
7363 (gnus-info-find-node (gnus-url-unhex-string url)))
7365 (defun gnus-button-handle-info-keystrokes (url)
7366 "Call `info' when pushing the corresponding URL button."
7367 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
7372 (defun gnus-button-openpgp (url)
7373 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
7375 (mm-url-insert-file-contents-external url)
7376 (pgg-snarf-keys-region (point-min) (point-max))
7377 (pgg-display-output-buffer nil nil nil)))
7379 (defun gnus-button-message-id (message-id)
7381 (with-current-buffer gnus-summary-buffer
7382 (gnus-summary-refer-article message-id)))
7384 (defun gnus-button-fetch-group (address)
7385 "Fetch GROUP specified by ADDRESS."
7386 (if (not (string-match "[:/]" address))
7387 ;; This is just a simple group url.
7388 (gnus-group-read-ephemeral-group address gnus-select-method)
7391 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
7393 (error "Can't parse %s" address)
7394 (gnus-group-read-ephemeral-group
7395 (match-string 4 address)
7396 `(nntp ,(match-string 1 address)
7397 (nntp-address ,(match-string 1 address))
7398 (nntp-port-number ,(if (match-end 3)
7399 (match-string 3 address)
7402 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
7404 (defun gnus-url-parse-query-string (query &optional downcase)
7405 (let (retval pairs cur key val)
7406 (setq pairs (split-string query "&"))
7408 (setq cur (car pairs)
7410 (if (not (string-match "=" cur))
7412 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
7413 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
7415 (setq key (downcase key)))
7416 (setq cur (assoc key retval))
7418 (setcdr cur (cons val (cdr cur)))
7419 (setq retval (cons (list key val) retval)))))
7422 (defun gnus-url-mailto (url)
7423 ;; Send mail to someone
7424 (when (string-match "mailto:/*\\(.*\\)" url)
7425 (setq url (substring url (match-beginning 1) nil)))
7426 (let (to args subject func)
7427 (setq args (gnus-url-parse-query-string
7428 (if (string-match "^\\?" url)
7430 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
7431 (concat "to=" (match-string 1 url) "&"
7432 (match-string 2 url))
7433 (concat "to=" url)))
7435 subject (cdr-safe (assoc "subject" args)))
7438 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
7441 (message-position-on-field (caar args)))
7442 (insert (gnus-replace-in-string
7443 (mapconcat 'identity (reverse (cdar args)) ", ")
7445 (setq args (cdr args)))
7448 (message-goto-subject))))
7450 (defun gnus-button-embedded-url (address)
7451 "Activate ADDRESS with `browse-url'."
7452 (browse-url (gnus-strip-whitespace address)))
7454 ;;; Next/prev buttons in the article buffer.
7456 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
7457 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
7459 (defvar gnus-prev-page-map
7460 (let ((map (make-sparse-keymap)))
7461 (define-key map gnus-mouse-2 'gnus-button-prev-page)
7462 (define-key map "\r" 'gnus-button-prev-page)
7465 (defvar gnus-next-page-map
7466 (let ((map (make-sparse-keymap)))
7467 (unless (>= emacs-major-version 21)
7468 ;; XEmacs doesn't care.
7469 (set-keymap-parent map gnus-article-mode-map))
7470 (define-key map gnus-mouse-2 'gnus-button-next-page)
7471 (define-key map "\r" 'gnus-button-next-page)
7474 (defun gnus-insert-prev-page-button ()
7476 (inhibit-read-only t))
7478 gnus-prev-page-line-format nil
7479 `(keymap ,gnus-prev-page-map
7481 gnus-callback gnus-article-button-prev-page
7482 article-type annotation))
7483 (widget-convert-button
7485 ;; Exclude a newline.
7488 :action 'gnus-button-prev-page
7489 :button-keymap gnus-prev-page-map)))
7491 (defun gnus-button-next-page (&optional args more-args)
7492 "Go to the next page."
7494 (let ((win (selected-window)))
7495 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7496 (gnus-article-next-page)
7497 (select-window win)))
7499 (defun gnus-button-prev-page (&optional args more-args)
7500 "Go to the prev page."
7502 (let ((win (selected-window)))
7503 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7504 (gnus-article-prev-page)
7505 (select-window win)))
7507 (defun gnus-insert-next-page-button ()
7509 (inhibit-read-only t))
7510 (gnus-eval-format gnus-next-page-line-format nil
7511 `(keymap ,gnus-next-page-map
7513 gnus-callback gnus-article-button-next-page
7514 article-type annotation))
7515 (widget-convert-button
7517 ;; Exclude a newline.
7520 :action 'gnus-button-next-page
7521 :button-keymap gnus-next-page-map)))
7523 (defun gnus-article-button-next-page (arg)
7524 "Go to the next page."
7526 (let ((win (selected-window)))
7527 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7528 (gnus-article-next-page)
7529 (select-window win)))
7531 (defun gnus-article-button-prev-page (arg)
7532 "Go to the prev page."
7534 (let ((win (selected-window)))
7535 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7536 (gnus-article-prev-page)
7537 (select-window win)))
7539 (defvar gnus-decode-header-methods
7540 '(mail-decode-encoded-word-region)
7541 "List of methods used to decode headers.
7543 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7544 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
7545 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
7546 whose names match REGEXP.
7549 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7550 mail-decode-encoded-word-region
7551 (\"chinese\" . rfc1843-decode-region))
7554 (defvar gnus-decode-header-methods-cache nil)
7556 (defun gnus-multi-decode-header (start end)
7557 "Apply the functions from `gnus-encoded-word-methods' that match."
7558 (unless (and gnus-decode-header-methods-cache
7559 (eq gnus-newsgroup-name
7560 (car gnus-decode-header-methods-cache)))
7561 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7564 (nconc gnus-decode-header-methods-cache (list x))
7565 (if (and gnus-newsgroup-name
7566 (string-match (car x) gnus-newsgroup-name))
7567 (nconc gnus-decode-header-methods-cache
7569 gnus-decode-header-methods))
7570 (let ((xlist gnus-decode-header-methods-cache))
7573 (narrow-to-region start end)
7575 (funcall (pop xlist) (point-min) (point-max))))))
7578 ;;; Treatment top-level handling.
7581 (defun gnus-treat-article (condition &optional part-number total-parts type)
7582 (let ((length (- (point-max) (point-min)))
7583 (alist gnus-treatment-function-alist)
7584 (article-goto-body-goes-to-point-min-p t)
7588 (let ((list gnus-article-treat-types))
7590 (when (string-match (pop list) type)
7591 (throw 'found t)))))))
7592 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7594 (gnus-run-hooks 'gnus-part-display-hook)
7595 (dolist (elem alist)
7598 (when (gnus-buffer-live-p gnus-summary-buffer)
7599 (set-buffer gnus-summary-buffer))
7600 (symbol-value (car elem))))
7601 (when (and (or (consp val)
7603 (gnus-treat-predicate val)
7604 (or (not (get (car elem) 'highlight))
7607 (funcall (cadr elem)))))))
7609 ;; Dynamic variables.
7611 (defvar part-number)
7612 (defvar total-parts)
7617 (defun gnus-treat-predicate (val)
7624 (stringp (car val)))
7625 (apply 'gnus-or (mapcar `(lambda (s)
7626 (string-match s ,(or gnus-newsgroup-name "")))
7629 (let ((pred (pop val)))
7632 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7634 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7636 (not (gnus-treat-predicate (car val))))
7638 (equal (car val) type))
7640 (error "%S is not a valid predicate" pred)))))
7648 (eq part-number total-parts))
7652 (error "%S is not a valid value" val))))
7654 (defun gnus-article-encrypt-body (protocol &optional n)
7655 "Encrypt the article body."
7658 (or gnus-article-encrypt-protocol
7659 (completing-read "Encrypt protocol: "
7660 gnus-article-encrypt-protocol-alist
7662 current-prefix-arg))
7663 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7665 (error "Can't find the encrypt protocol %s" protocol))
7666 (if (member gnus-newsgroup-name '("nndraft:delayed"
7669 (error "Can't encrypt the article in group %s"
7670 gnus-newsgroup-name))
7671 (gnus-summary-iterate n
7673 (set-buffer gnus-summary-buffer)
7674 (let ((mail-parse-charset gnus-newsgroup-charset)
7675 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7676 (summary-buffer gnus-summary-buffer)
7678 (gnus-set-global-variables)
7679 (when (gnus-group-read-only-p)
7680 (error "The current newsgroup does not support article encrypt"))
7681 (gnus-summary-show-article t)
7683 (or (mail-header-references gnus-current-headers) ""))
7684 (set-buffer gnus-article-buffer)
7685 (let* ((inhibit-read-only t)
7687 (mapcar (lambda (field)
7688 (and (save-restriction
7689 (message-narrow-to-head)
7690 (goto-char (point-min))
7691 (search-forward field nil t))
7693 (message-narrow-to-field)
7695 (delete-region (point-min) (point-max))
7697 '("Content-Type:" "Content-Transfer-Encoding:"
7698 "Content-Disposition:"))))
7699 (message-narrow-to-head)
7700 (message-remove-header "MIME-Version")
7701 (goto-char (point-max))
7702 (setq point (point))
7703 (insert (apply 'concat headers))
7705 (narrow-to-region point (point-max))
7706 (let ((message-options message-options))
7707 (message-options-set 'message-sender user-mail-address)
7708 (message-options-set 'message-recipients user-mail-address)
7709 (message-options-set 'message-sign-encrypt 'not)
7711 (goto-char (point-min))
7712 (insert "MIME-Version: 1.0\n")
7714 (gnus-summary-edit-article-done
7715 references nil summary-buffer t))
7716 (when gnus-keep-backlog
7717 (gnus-backlog-remove-article
7718 (car gnus-article-current) (cdr gnus-article-current)))
7720 (when (get-buffer gnus-original-article-buffer)
7721 (set-buffer gnus-original-article-buffer)
7722 (setq gnus-original-article nil)))
7723 (when gnus-use-cache
7724 (gnus-cache-update-article
7725 (car gnus-article-current) (cdr gnus-article-current))))))))
7727 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7728 "The following specs can be used:
7729 %t The security MIME type
7732 %D Details if button is pressed")
7734 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7735 "The following specs can be used:
7736 %t The security MIME type
7739 %D Details if button is pressed")
7741 (defvar gnus-mime-security-button-line-format-alist
7742 '((?t gnus-tmp-type ?s)
7743 (?i gnus-tmp-info ?s)
7744 (?d gnus-tmp-details ?s)
7745 (?D gnus-tmp-pressed-details ?s)))
7747 (defvar gnus-mime-security-button-commands
7748 '((gnus-article-press-button "\r" "Show Detail")
7752 (gnus-mime-security-save-part "o" "Save...")
7761 (gnus-mime-security-pipe-part "|" "Pipe To Command...")
7764 (defvar gnus-mime-security-button-map
7765 (let ((map (make-sparse-keymap)))
7766 (define-key map gnus-mouse-2 'gnus-article-push-button)
7767 (define-key map gnus-down-mouse-3 'gnus-mime-security-button-menu)
7768 (dolist (c gnus-mime-security-button-commands)
7769 (define-key map (cadr c) (car c)))
7773 gnus-mime-security-button-menu gnus-mime-security-button-map
7774 "Security button menu."
7778 (unless (eq (car c) 'undefined)
7779 (vector (caddr c) (car c) :active t)))
7780 gnus-mime-security-button-commands))))
7782 (defun gnus-mime-security-button-menu (event prefix)
7783 "Construct a context-sensitive menu of security commands."
7784 (interactive "e\nP")
7785 (save-window-excursion
7786 (let ((pos (event-start event)))
7787 (select-window (posn-window pos))
7788 (goto-char (posn-point pos))
7789 (gnus-article-check-buffer)
7790 (popup-menu gnus-mime-security-button-menu nil prefix))))
7792 (defvar gnus-mime-security-details-buffer nil)
7794 (defvar gnus-mime-security-button-pressed nil)
7796 (defvar gnus-mime-security-show-details-inline t
7797 "If non-nil, show details in the article buffer.")
7799 (defun gnus-mime-security-verify-or-decrypt (handle)
7800 (mm-remove-parts (cdr handle))
7801 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7802 point (inhibit-read-only t))
7804 (goto-char (car region)))
7806 (narrow-to-region (point) (point))
7807 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7808 (let* ((mm-verify-option 'known)
7809 (mm-decrypt-option 'known)
7810 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7811 (unless (eq nparts (cdr handle))
7812 (mm-destroy-parts (cdr handle))
7813 (setcdr handle nparts))))
7814 (setq point (point))
7815 (gnus-mime-display-security handle)
7816 (goto-char (point-max)))
7818 (delete-region (point) (cdr region))
7819 (set-marker (car region) nil)
7820 (set-marker (cdr region) nil))
7823 (defun gnus-mime-security-show-details (handle)
7824 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7826 (gnus-message 5 "No details.")
7827 (if gnus-mime-security-show-details-inline
7828 (let ((gnus-mime-security-button-pressed
7829 (not (get-text-property (point) 'gnus-mime-details)))
7830 (gnus-mime-security-button-line-format
7831 (get-text-property (point) 'gnus-line-format))
7832 (inhibit-read-only t))
7834 (while (eq (get-text-property (point) 'gnus-line-format)
7835 gnus-mime-security-button-line-format)
7839 (narrow-to-region (point) (point))
7840 (gnus-insert-mime-security-button handle))
7841 (delete-region (point)
7842 (or (text-property-not-all
7845 gnus-mime-security-button-line-format)
7848 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7849 (with-current-buffer gnus-mime-security-details-buffer
7852 (setq gnus-mime-security-details-buffer
7853 (gnus-get-buffer-create "*MIME Security Details*")))
7854 (with-current-buffer gnus-mime-security-details-buffer
7856 (goto-char (point-min)))
7857 (pop-to-buffer gnus-mime-security-details-buffer)))))
7859 (defun gnus-mime-security-press-button (handle)
7861 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7862 (gnus-mime-security-show-details handle)
7863 (gnus-mime-security-verify-or-decrypt handle))))
7865 (defun gnus-insert-mime-security-button (handle &optional displayed)
7866 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7869 (or (nth 2 (assoc protocol mm-verify-function-alist))
7870 (nth 2 (assoc protocol mm-decrypt-function-alist))
7872 (if (equal (car handle) "multipart/signed")
7873 " Signed" " Encrypted")
7876 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7879 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7880 gnus-tmp-pressed-details
7882 (setq gnus-tmp-details
7883 (if gnus-tmp-details
7884 (concat "\n" gnus-tmp-details)
7886 (setq gnus-tmp-pressed-details
7887 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7892 gnus-mime-security-button-line-format
7893 gnus-mime-security-button-line-format-alist
7894 `(keymap ,gnus-mime-security-button-map
7895 gnus-callback gnus-mime-security-press-button
7896 gnus-line-format ,gnus-mime-security-button-line-format
7897 gnus-mime-details ,gnus-mime-security-button-pressed
7898 article-type annotation
7901 ;; Exclude a newline.
7904 (widget-convert-button
7907 :action 'gnus-widget-press-button
7908 :button-keymap gnus-mime-security-button-map
7910 (lambda (widget/window &optional overlay pos)
7911 ;; Needed to properly clear the message due to a bug in
7912 ;; wid-edit (XEmacs only).
7913 (when (boundp 'help-echo-owns-message)
7914 (setq help-echo-owns-message t))
7916 "%S: show detail; %S: more options"
7917 (aref gnus-mouse-2 0)
7918 (aref gnus-down-mouse-3 0))))))
7920 (defun gnus-mime-display-security (handle)
7922 (narrow-to-region (point) (point))
7923 (unless (gnus-unbuttonized-mime-type-p (car handle))
7924 (gnus-insert-mime-security-button handle))
7925 (gnus-mime-display-part (cadr handle))
7928 (unless (gnus-unbuttonized-mime-type-p (car handle))
7929 (let ((gnus-mime-security-button-line-format
7930 gnus-mime-security-button-end-line-format))
7931 (gnus-insert-mime-security-button handle)))
7932 (mm-set-handle-multipart-parameter
7934 (cons (set-marker (make-marker) (point-min))
7935 (set-marker (make-marker) (point-max))))))
7937 (defun gnus-mime-security-run-function (function)
7938 "Run FUNCTION with the security part under point."
7939 (gnus-article-check-buffer)
7940 (let ((data (get-text-property (point) 'gnus-data))
7942 (when (and (stringp (car-safe data))
7943 (setq buffer (mm-handle-multipart-original-buffer data))
7944 (setq handle (cadr data)))
7945 (if (bufferp (mm-handle-buffer handle))
7947 (setq handle (cons buffer (copy-sequence (cdr handle))))
7948 (mm-handle-set-undisplayer handle nil))
7949 (setq handle (mm-make-handle
7951 (mm-handle-multipart-ctl-parameter handle 'protocol)
7952 nil nil nil nil nil nil)))
7953 (funcall function handle))))
7955 (defun gnus-mime-security-save-part ()
7956 "Save the security part under point."
7958 (gnus-mime-security-run-function 'mm-save-part))
7960 (defun gnus-mime-security-pipe-part ()
7961 "Pipe the security part under point to a process."
7963 (gnus-mime-security-run-function 'mm-pipe-part))
7969 (run-hooks 'gnus-art-load-hook)
7971 ;;; arch-tag: 2654516f-6279-48f9-a83b-05c1fa450c33
7972 ;;; gnus-art.el ends here