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-decode-address-function 'mail-decode-encoded-address-region
906 "Function used to decode addresses.")
908 (defvar gnus-article-dumbquotes-map
928 "Table for MS-to-Latin1 translation.")
930 (defcustom gnus-ignored-mime-types nil
931 "List of MIME types that should be ignored by Gnus."
933 :group 'gnus-article-mime
934 :type '(repeat regexp))
936 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
937 "List of MIME types that should not be given buttons when rendered inline.
938 See also `gnus-buttonized-mime-types' which may override this variable.
939 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
941 :group 'gnus-article-mime
942 :type '(repeat regexp))
944 (defcustom gnus-buttonized-mime-types nil
945 "List of MIME types that should be given buttons when rendered inline.
946 If set, this variable overrides `gnus-unbuttonized-mime-types'.
947 To see e.g. security buttons you could set this to
948 `(\"multipart/signed\")'. You could also add \"multipart/alternative\" to
949 this list to display radio buttons that allow you to choose one of two
950 media types those mails include. See also `mm-discouraged-alternatives'.
951 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
953 :group 'gnus-article-mime
954 :type '(repeat regexp))
956 (defcustom gnus-inhibit-mime-unbuttonizing nil
957 "If non-nil, all MIME parts get buttons.
958 When nil (the default value), then some MIME parts do not get buttons,
959 as described by the variables `gnus-buttonized-mime-types' and
960 `gnus-unbuttonized-mime-types'."
962 :group 'gnus-article-mime
965 (defcustom gnus-body-boundary-delimiter "_"
966 "String used to delimit header and body.
967 This variable is used by `gnus-article-treat-body-boundary' which can
968 be controlled by `gnus-treat-body-boundary'."
970 :group 'gnus-article-various
971 :type '(choice (item :tag "None" :value nil)
974 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
976 "Defines the location of the faces database.
977 For information on obtaining this database of pretty pictures, please
978 see http://www.cs.indiana.edu/picons/ftp/index.html"
980 :type '(repeat directory)
981 :link '(url-link :tag "download"
982 "http://www.cs.indiana.edu/picons/ftp/index.html")
983 :link '(custom-manual "(gnus)Picons")
986 (defun gnus-picons-installed-p ()
987 "Say whether picons are installed on your machine."
988 (let ((installed nil))
989 (dolist (database gnus-picon-databases)
990 (when (file-exists-p database)
994 (defcustom gnus-article-mime-part-function nil
995 "Function called with a MIME handle as the argument.
996 This is meant for people who want to do something automatic based
997 on parts -- for instance, adding Vcard info to a database."
998 :group 'gnus-article-mime
999 :type '(choice (const nil)
1002 (defcustom gnus-mime-multipart-functions nil
1003 "An alist of MIME types to functions to display them."
1005 :group 'gnus-article-mime
1006 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
1008 (defcustom gnus-article-date-lapsed-new-header nil
1009 "Whether the X-Sent and Date headers can coexist.
1010 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
1011 either replace the old \"Date:\" header (if this variable is nil), or
1012 be added below it (otherwise)."
1014 :group 'gnus-article-headers
1017 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
1018 "Function called with a MIME handle as the argument.
1019 This is meant for people who want to view first matched part.
1020 For `undisplayed-alternative' (default), the first undisplayed
1021 part or alternative part is used. For `undisplayed', the first
1022 undisplayed part is used. For a function, the first part which
1023 the function return t is used. For nil, the first part is
1026 :group 'gnus-article-mime
1028 (item :tag "first" :value nil)
1029 (item :tag "undisplayed" :value undisplayed)
1030 (item :tag "undisplayed or alternative"
1031 :value undisplayed-alternative)
1034 (defcustom gnus-mime-action-alist
1035 '(("save to file" . gnus-mime-save-part)
1036 ("save and strip" . gnus-mime-save-part-and-strip)
1037 ("replace with file" . gnus-mime-replace-part)
1038 ("delete part" . gnus-mime-delete-part)
1039 ("display as text" . gnus-mime-inline-part)
1040 ("view the part" . gnus-mime-view-part)
1041 ("pipe to command" . gnus-mime-pipe-part)
1042 ("toggle display" . gnus-article-press-button)
1043 ("toggle display" . gnus-article-view-part-as-charset)
1044 ("view as type" . gnus-mime-view-part-as-type)
1045 ("view internally" . gnus-mime-view-part-internally)
1046 ("view externally" . gnus-mime-view-part-externally))
1047 "An alist of actions that run on the MIME attachment."
1048 :group 'gnus-article-mime
1049 :type '(repeat (cons (string :tag "name")
1052 (defcustom gnus-auto-select-part 1
1053 "Advance to next MIME part when deleting or stripping parts.
1055 When 0, point will be placed on the same part as before. When
1056 positive (negative), move point forward (backwards) this many
1057 parts. When nil, redisplay article."
1058 :version "23.0" ;; No Gnus
1059 :group 'gnus-article-mime
1060 :type '(choice (const nil :tag "Redisplay article.")
1061 (const 1 :tag "Next part.")
1062 (const 0 :tag "Current part.")
1066 ;;; The treatment variables
1069 (defvar gnus-part-display-hook nil
1070 "Hook called on parts that are to receive treatment.")
1072 (defvar gnus-article-treat-custom
1073 '(choice (const :tag "Off" nil)
1075 (const :tag "Header" head)
1076 (const :tag "First" first)
1077 (const :tag "Last" last)
1078 (integer :tag "Less")
1079 (repeat :tag "Groups" regexp)
1080 (sexp :tag "Predicate")))
1082 (defvar gnus-article-treat-head-custom
1083 '(choice (const :tag "Off" nil)
1084 (const :tag "Header" head)))
1086 (defvar gnus-article-treat-types '("text/plain" "text/x-verbatim"
1090 (defvar gnus-inhibit-treatment nil
1091 "Whether to inhibit treatment.")
1093 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
1094 "Highlight the signature.
1095 Valid values are nil, t, `head', `first', `last', an integer or a
1096 predicate. See Info node `(gnus)Customizing Articles'."
1097 :group 'gnus-article-treat
1098 :link '(custom-manual "(gnus)Customizing Articles")
1099 :type gnus-article-treat-custom)
1100 (put 'gnus-treat-highlight-signature 'highlight t)
1102 (defcustom gnus-treat-buttonize 100000
1104 Valid values are nil, t, `head', `first', `last', an integer or a
1105 predicate. See Info node `(gnus)Customizing Articles'."
1106 :group 'gnus-article-treat
1107 :link '(custom-manual "(gnus)Customizing Articles")
1108 :type gnus-article-treat-custom)
1109 (put 'gnus-treat-buttonize 'highlight t)
1111 (defcustom gnus-treat-buttonize-head 'head
1112 "Add buttons to the head.
1113 Valid values are nil, t, `head', `first', `last', an integer or a
1114 predicate. See Info node `(gnus)Customizing Articles'."
1115 :group 'gnus-article-treat
1116 :link '(custom-manual "(gnus)Customizing Articles")
1117 :type gnus-article-treat-head-custom)
1118 (put 'gnus-treat-buttonize-head 'highlight t)
1120 (defcustom gnus-treat-emphasize
1121 (and (or window-system
1125 Valid values are nil, t, `head', `first', `last', an integer or a
1126 predicate. See Info node `(gnus)Customizing Articles'."
1127 :group 'gnus-article-treat
1128 :link '(custom-manual "(gnus)Customizing Articles")
1129 :type gnus-article-treat-custom)
1130 (put 'gnus-treat-emphasize 'highlight t)
1132 (defcustom gnus-treat-strip-cr nil
1133 "Remove carriage returns.
1134 Valid values are nil, t, `head', `first', `last', an integer or a
1135 predicate. See Info node `(gnus)Customizing Articles'."
1137 :group 'gnus-article-treat
1138 :link '(custom-manual "(gnus)Customizing Articles")
1139 :type gnus-article-treat-custom)
1141 (defcustom gnus-treat-unsplit-urls nil
1142 "Remove newlines from within URLs.
1143 Valid values are nil, t, `head', `first', `last', an integer or a
1144 predicate. See Info node `(gnus)Customizing Articles'."
1146 :group 'gnus-article-treat
1147 :link '(custom-manual "(gnus)Customizing Articles")
1148 :type gnus-article-treat-custom)
1150 (defcustom gnus-treat-leading-whitespace nil
1151 "Remove leading whitespace in headers.
1152 Valid values are nil, t, `head', `first', `last', an integer or a
1153 predicate. See Info node `(gnus)Customizing Articles'."
1155 :group 'gnus-article-treat
1156 :link '(custom-manual "(gnus)Customizing Articles")
1157 :type gnus-article-treat-custom)
1159 (defcustom gnus-treat-hide-headers 'head
1161 Valid values are nil, t, `head', `first', `last', an integer or a
1162 predicate. See Info node `(gnus)Customizing Articles'."
1163 :group 'gnus-article-treat
1164 :link '(custom-manual "(gnus)Customizing Articles")
1165 :type gnus-article-treat-head-custom)
1167 (defcustom gnus-treat-hide-boring-headers nil
1168 "Hide boring headers.
1169 Valid values are nil, t, `head', `first', `last', an integer or a
1170 predicate. See Info node `(gnus)Customizing Articles'."
1171 :group 'gnus-article-treat
1172 :link '(custom-manual "(gnus)Customizing Articles")
1173 :type gnus-article-treat-head-custom)
1175 (defcustom gnus-treat-hide-signature nil
1176 "Hide the signature.
1177 Valid values are nil, t, `head', `first', `last', an integer or a
1178 predicate. See Info node `(gnus)Customizing Articles'."
1179 :group 'gnus-article-treat
1180 :link '(custom-manual "(gnus)Customizing Articles")
1181 :type gnus-article-treat-custom)
1183 (defcustom gnus-treat-fill-article nil
1185 Valid values are nil, t, `head', `first', `last', an integer or a
1186 predicate. See Info node `(gnus)Customizing Articles'."
1187 :group 'gnus-article-treat
1188 :link '(custom-manual "(gnus)Customizing Articles")
1189 :type gnus-article-treat-custom)
1191 (defcustom gnus-treat-hide-citation nil
1193 Valid values are nil, t, `head', `first', `last', an integer or a
1194 predicate. See Info node `(gnus)Customizing Articles'."
1195 :group 'gnus-article-treat
1196 :link '(custom-manual "(gnus)Customizing Articles")
1197 :type gnus-article-treat-custom)
1199 (defcustom gnus-treat-hide-citation-maybe nil
1201 Valid values are nil, t, `head', `first', `last', an integer or a
1202 predicate. See Info node `(gnus)Customizing Articles'."
1203 :group 'gnus-article-treat
1204 :link '(custom-manual "(gnus)Customizing Articles")
1205 :type gnus-article-treat-custom)
1207 (defcustom gnus-treat-strip-list-identifiers 'head
1208 "Strip list identifiers from `gnus-list-identifiers`.
1209 Valid values are nil, t, `head', `first', `last', an integer or a
1210 predicate. See Info node `(gnus)Customizing Articles'."
1212 :group 'gnus-article-treat
1213 :link '(custom-manual "(gnus)Customizing Articles")
1214 :type gnus-article-treat-custom)
1216 (make-obsolete-variable 'gnus-treat-strip-pgp
1217 "This option is obsolete in Gnus 5.10.")
1219 (defcustom gnus-treat-strip-pem nil
1220 "Strip PEM signatures.
1221 Valid values are nil, t, `head', `first', `last', an integer or a
1222 predicate. See Info node `(gnus)Customizing Articles'."
1223 :group 'gnus-article-treat
1224 :link '(custom-manual "(gnus)Customizing Articles")
1225 :type gnus-article-treat-custom)
1227 (defcustom gnus-treat-strip-banner t
1228 "Strip banners from articles.
1229 The banner to be stripped is specified in the `banner' group parameter.
1230 Valid values are nil, t, `head', `first', `last', an integer or a
1231 predicate. See Info node `(gnus)Customizing Articles'."
1232 :group 'gnus-article-treat
1233 :link '(custom-manual "(gnus)Customizing Articles")
1234 :type gnus-article-treat-custom)
1236 (defcustom gnus-treat-highlight-headers 'head
1237 "Highlight the headers.
1238 Valid values are nil, t, `head', `first', `last', an integer or a
1239 predicate. See Info node `(gnus)Customizing Articles'."
1240 :group 'gnus-article-treat
1241 :link '(custom-manual "(gnus)Customizing Articles")
1242 :type gnus-article-treat-head-custom)
1243 (put 'gnus-treat-highlight-headers 'highlight t)
1245 (defcustom gnus-treat-highlight-citation t
1246 "Highlight cited text.
1247 Valid values are nil, t, `head', `first', `last', an integer or a
1248 predicate. See Info node `(gnus)Customizing Articles'."
1249 :group 'gnus-article-treat
1250 :link '(custom-manual "(gnus)Customizing Articles")
1251 :type gnus-article-treat-custom)
1252 (put 'gnus-treat-highlight-citation 'highlight t)
1254 (defcustom gnus-treat-date-ut nil
1255 "Display the Date in UT (GMT).
1256 Valid values are nil, t, `head', `first', `last', an integer or a
1257 predicate. See Info node `(gnus)Customizing Articles'."
1258 :group 'gnus-article-treat
1259 :link '(custom-manual "(gnus)Customizing Articles")
1260 :type gnus-article-treat-head-custom)
1262 (defcustom gnus-treat-date-local nil
1263 "Display the Date in the local timezone.
1264 Valid values are nil, t, `head', `first', `last', an integer or a
1265 predicate. See Info node `(gnus)Customizing Articles'."
1266 :group 'gnus-article-treat
1267 :link '(custom-manual "(gnus)Customizing Articles")
1268 :type gnus-article-treat-head-custom)
1270 (defcustom gnus-treat-date-english nil
1271 "Display the Date in a format that can be read aloud in English.
1272 Valid values are nil, t, `head', `first', `last', an integer or a
1273 predicate. See Info node `(gnus)Customizing Articles'."
1275 :group 'gnus-article-treat
1276 :link '(custom-manual "(gnus)Customizing Articles")
1277 :type gnus-article-treat-head-custom)
1279 (defcustom gnus-treat-date-lapsed nil
1280 "Display the Date header in a way that says how much time has elapsed.
1281 Valid values are nil, t, `head', `first', `last', an integer or a
1282 predicate. See Info node `(gnus)Customizing Articles'."
1283 :group 'gnus-article-treat
1284 :link '(custom-manual "(gnus)Customizing Articles")
1285 :type gnus-article-treat-head-custom)
1287 (defcustom gnus-treat-date-original nil
1288 "Display the date in the original timezone.
1289 Valid values are nil, t, `head', `first', `last', an integer or a
1290 predicate. See Info node `(gnus)Customizing Articles'."
1291 :group 'gnus-article-treat
1292 :link '(custom-manual "(gnus)Customizing Articles")
1293 :type gnus-article-treat-head-custom)
1295 (defcustom gnus-treat-date-iso8601 nil
1296 "Display the date in the ISO8601 format.
1297 Valid values are nil, t, `head', `first', `last', an integer or a
1298 predicate. See Info node `(gnus)Customizing Articles'."
1300 :group 'gnus-article-treat
1301 :link '(custom-manual "(gnus)Customizing Articles")
1302 :type gnus-article-treat-head-custom)
1304 (defcustom gnus-treat-date-user-defined nil
1305 "Display the date in a user-defined format.
1306 The format is defined by the `gnus-article-time-format' variable.
1307 Valid values are nil, t, `head', `first', `last', an integer or a
1308 predicate. See Info node `(gnus)Customizing Articles'."
1309 :group 'gnus-article-treat
1310 :link '(custom-manual "(gnus)Customizing Articles")
1311 :type gnus-article-treat-head-custom)
1313 (defcustom gnus-treat-strip-headers-in-body t
1314 "Strip the X-No-Archive header line from the beginning of the body.
1315 Valid values are nil, t, `head', `first', `last', an integer or a
1316 predicate. See Info node `(gnus)Customizing Articles'."
1318 :group 'gnus-article-treat
1319 :link '(custom-manual "(gnus)Customizing Articles")
1320 :type gnus-article-treat-custom)
1322 (defcustom gnus-treat-strip-trailing-blank-lines nil
1323 "Strip trailing blank lines.
1324 Valid values are nil, t, `head', `first', `last', an integer or a
1325 predicate. See Info node `(gnus)Customizing Articles'.
1327 When set to t, it also strips trailing blanks in all MIME parts.
1328 Consider to use `last' instead."
1329 :group 'gnus-article-treat
1330 :link '(custom-manual "(gnus)Customizing Articles")
1331 :type gnus-article-treat-custom)
1333 (defcustom gnus-treat-strip-leading-blank-lines nil
1334 "Strip leading blank lines.
1335 Valid values are nil, t, `head', `first', `last', an integer or a
1336 predicate. See Info node `(gnus)Customizing Articles'.
1338 When set to t, it also strips trailing blanks in all MIME parts."
1339 :group 'gnus-article-treat
1340 :link '(custom-manual "(gnus)Customizing Articles")
1341 :type gnus-article-treat-custom)
1343 (defcustom gnus-treat-strip-multiple-blank-lines nil
1344 "Strip multiple blank lines.
1345 Valid values are nil, t, `head', `first', `last', an integer or a
1346 predicate. See Info node `(gnus)Customizing Articles'."
1347 :group 'gnus-article-treat
1348 :link '(custom-manual "(gnus)Customizing Articles")
1349 :type gnus-article-treat-custom)
1351 (defcustom gnus-treat-unfold-headers 'head
1352 "Unfold folded header lines.
1353 Valid values are nil, t, `head', `first', `last', an integer or a
1354 predicate. See Info node `(gnus)Customizing Articles'."
1356 :group 'gnus-article-treat
1357 :link '(custom-manual "(gnus)Customizing Articles")
1358 :type gnus-article-treat-custom)
1360 (defcustom gnus-article-unfold-long-headers nil
1361 "If non-nil, allow unfolding headers even if the header is long.
1362 If it is a regexp, only long headers matching this regexp are unfolded.
1363 If it is t, all long headers are unfolded.
1365 This variable has no effect if `gnus-treat-unfold-headers' is nil."
1366 :version "23.0" ;; No Gnus
1367 :group 'gnus-article-treat
1368 :type '(choice (const nil)
1369 (const :tag "all" t)
1372 (defcustom gnus-treat-fold-headers nil
1374 Valid values are nil, t, `head', `first', `last', an integer or a
1375 predicate. See Info node `(gnus)Customizing Articles'."
1377 :group 'gnus-article-treat
1378 :link '(custom-manual "(gnus)Customizing Articles")
1379 :type gnus-article-treat-custom)
1381 (defcustom gnus-treat-fold-newsgroups 'head
1382 "Fold the Newsgroups and Followup-To headers.
1383 Valid values are nil, t, `head', `first', `last', an integer or a
1384 predicate. See Info node `(gnus)Customizing Articles'."
1386 :group 'gnus-article-treat
1387 :link '(custom-manual "(gnus)Customizing Articles")
1388 :type gnus-article-treat-custom)
1390 (defcustom gnus-treat-overstrike t
1391 "Treat overstrike highlighting.
1392 Valid values are nil, t, `head', `first', `last', an integer or a
1393 predicate. See Info node `(gnus)Customizing Articles'."
1394 :group 'gnus-article-treat
1395 :link '(custom-manual "(gnus)Customizing Articles")
1396 :type gnus-article-treat-custom)
1397 (put 'gnus-treat-overstrike 'highlight t)
1399 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1400 "Treat ANSI SGR control sequences.
1401 Valid values are nil, t, `head', `first', `last', an integer or a
1402 predicate. See Info node `(gnus)Customizing Articles'."
1403 :group 'gnus-article-treat
1404 :link '(custom-manual "(gnus)Customizing Articles")
1405 :type gnus-article-treat-custom)
1407 (make-obsolete-variable 'gnus-treat-display-xface
1408 'gnus-treat-display-x-face)
1410 (defcustom gnus-treat-display-x-face
1411 (and (not noninteractive)
1412 (or (and (fboundp 'image-type-available-p)
1413 (image-type-available-p 'xbm)
1414 (string-match "^0x" (shell-command-to-string "uncompface"))
1415 (executable-find "icontopbm"))
1416 (and (featurep 'xemacs)
1419 "Display X-Face headers.
1420 Valid values are nil, t, `head', `first', `last', an integer or a
1421 predicate. See Info node `(gnus)Customizing Articles' and Info
1422 node `(gnus)X-Face' for details."
1423 :group 'gnus-article-treat
1425 :link '(custom-manual "(gnus)Customizing Articles")
1426 :link '(custom-manual "(gnus)X-Face")
1427 :type gnus-article-treat-head-custom
1428 :set (lambda (symbol value)
1431 (cond ((or (boundp symbol) (get symbol 'saved-value))
1433 ((boundp 'gnus-treat-display-xface)
1435 ** gnus-treat-display-xface is an obsolete variable;\
1436 use gnus-treat-display-x-face instead")
1437 (default-value 'gnus-treat-display-xface))
1438 ((get 'gnus-treat-display-xface 'saved-value)
1440 ** gnus-treat-display-xface is an obsolete variable;\
1441 use gnus-treat-display-x-face instead")
1442 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1445 (put 'gnus-treat-display-x-face 'highlight t)
1447 (defcustom gnus-treat-display-face
1448 (and (not noninteractive)
1449 (or (and (fboundp 'image-type-available-p)
1450 (image-type-available-p 'png))
1451 (and (featurep 'xemacs)
1454 "Display Face headers.
1455 Valid values are nil, t, `head', `first', `last', an integer or a
1456 predicate. See Info node `(gnus)Customizing Articles' and Info
1457 node `(gnus)X-Face' for details."
1458 :group 'gnus-article-treat
1460 :link '(custom-manual "(gnus)Customizing Articles")
1461 :link '(custom-manual "(gnus)X-Face")
1462 :type gnus-article-treat-head-custom)
1463 (put 'gnus-treat-display-face 'highlight t)
1465 (defcustom gnus-treat-display-smileys
1466 (if (or (and (featurep 'xemacs)
1468 (and (fboundp 'image-type-available-p)
1469 (image-type-available-p 'pbm)))
1472 Valid values are nil, t, `head', `first', `last', an integer or a
1473 predicate. See Info node `(gnus)Customizing Articles' and Info
1474 node `(gnus)Smileys' for details."
1475 :group 'gnus-article-treat
1477 :link '(custom-manual "(gnus)Customizing Articles")
1478 :link '(custom-manual "(gnus)Smileys")
1479 :type gnus-article-treat-custom)
1480 (put 'gnus-treat-display-smileys 'highlight t)
1482 (defcustom gnus-treat-from-picon
1483 (if (and (gnus-image-type-available-p 'xpm)
1484 (gnus-picons-installed-p))
1486 "Display picons in the From header.
1487 Valid values are nil, t, `head', `first', `last', an integer or a
1488 predicate. See Info node `(gnus)Customizing Articles' and Info
1489 node `(gnus)Picons' for details."
1491 :group 'gnus-article-treat
1493 :link '(custom-manual "(gnus)Customizing Articles")
1494 :link '(custom-manual "(gnus)Picons")
1495 :type gnus-article-treat-head-custom)
1496 (put 'gnus-treat-from-picon 'highlight t)
1498 (defcustom gnus-treat-mail-picon
1499 (if (and (gnus-image-type-available-p 'xpm)
1500 (gnus-picons-installed-p))
1502 "Display picons in To and Cc headers.
1503 Valid values are nil, t, `head', `first', `last', an integer or a
1504 predicate. See Info node `(gnus)Customizing Articles' and Info
1505 node `(gnus)Picons' for details."
1507 :group 'gnus-article-treat
1509 :link '(custom-manual "(gnus)Customizing Articles")
1510 :link '(custom-manual "(gnus)Picons")
1511 :type gnus-article-treat-head-custom)
1512 (put 'gnus-treat-mail-picon 'highlight t)
1514 (defcustom gnus-treat-newsgroups-picon
1515 (if (and (gnus-image-type-available-p 'xpm)
1516 (gnus-picons-installed-p))
1518 "Display picons in the Newsgroups and Followup-To headers.
1519 Valid values are nil, t, `head', `first', `last', an integer or a
1520 predicate. See Info node `(gnus)Customizing Articles' and Info
1521 node `(gnus)Picons' for details."
1523 :group 'gnus-article-treat
1525 :link '(custom-manual "(gnus)Customizing Articles")
1526 :link '(custom-manual "(gnus)Picons")
1527 :type gnus-article-treat-head-custom)
1528 (put 'gnus-treat-newsgroups-picon 'highlight t)
1530 (defcustom gnus-treat-body-boundary
1531 (if (and (eq window-system 'x)
1532 (or gnus-treat-newsgroups-picon
1533 gnus-treat-mail-picon
1534 gnus-treat-from-picon))
1536 "Draw a boundary at the end of the headers.
1537 Valid values are nil and `head'.
1538 See Info node `(gnus)Customizing Articles' for details."
1540 :group 'gnus-article-treat
1541 :link '(custom-manual "(gnus)Customizing Articles")
1542 :type gnus-article-treat-head-custom)
1544 (defcustom gnus-treat-capitalize-sentences nil
1545 "Capitalize sentence-starting words.
1546 Valid values are nil, t, `head', `first', `last', an integer or a
1547 predicate. See Info node `(gnus)Customizing Articles'."
1549 :group 'gnus-article-treat
1550 :link '(custom-manual "(gnus)Customizing Articles")
1551 :type gnus-article-treat-custom)
1553 (defcustom gnus-treat-wash-html nil
1555 Valid values are nil, t, `head', `first', `last', an integer or a
1556 predicate. See Info node `(gnus)Customizing Articles'."
1558 :group 'gnus-article-treat
1559 :link '(custom-manual "(gnus)Customizing Articles")
1560 :type gnus-article-treat-custom)
1562 (defcustom gnus-treat-fill-long-lines nil
1564 Valid values are nil, t, `head', `first', `last', an integer or a
1565 predicate. See Info node `(gnus)Customizing Articles'."
1566 :group 'gnus-article-treat
1567 :link '(custom-manual "(gnus)Customizing Articles")
1568 :type gnus-article-treat-custom)
1570 (defcustom gnus-treat-play-sounds nil
1572 Valid values are nil, t, `head', `first', `last', an integer or a
1573 predicate. See Info node `(gnus)Customizing Articles'."
1575 :group 'gnus-article-treat
1576 :link '(custom-manual "(gnus)Customizing Articles")
1577 :type gnus-article-treat-custom)
1579 (defcustom gnus-treat-translate nil
1580 "Translate articles from one language to another.
1581 Valid values are nil, t, `head', `first', `last', an integer or a
1582 predicate. See Info node `(gnus)Customizing Articles'."
1584 :group 'gnus-article-treat
1585 :link '(custom-manual "(gnus)Customizing Articles")
1586 :type gnus-article-treat-custom)
1588 (defcustom gnus-treat-x-pgp-sig nil
1590 To automatically treat X-PGP-Sig, set it to head.
1591 Valid values are nil, t, `head', `first', `last', an integer or a
1592 predicate. See Info node `(gnus)Customizing Articles'."
1594 :group 'gnus-article-treat
1595 :group 'mime-security
1596 :link '(custom-manual "(gnus)Customizing Articles")
1597 :type gnus-article-treat-custom)
1599 (defvar gnus-article-encrypt-protocol-alist
1600 '(("PGP" . mml2015-self-encrypt)))
1602 ;; Set to nil if more than one protocol added to
1603 ;; gnus-article-encrypt-protocol-alist.
1604 (defcustom gnus-article-encrypt-protocol "PGP"
1605 "The protocol used for encrypt articles.
1606 It is a string, such as \"PGP\". If nil, ask user."
1609 :group 'mime-security)
1611 (defvar gnus-article-wash-function nil
1612 "Function used for converting HTML into text.")
1614 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1615 (mm-coding-system-p 'utf-8)
1616 (executable-find idna-program))
1617 "Whether IDNA decoding of headers is used when viewing messages.
1618 This requires GNU Libidn, and by default only enabled if it is found."
1620 :group 'gnus-article-headers
1623 (defcustom gnus-article-over-scroll nil
1624 "If non-nil, allow scrolling the article buffer even when there no more text."
1626 :group 'gnus-article
1629 ;;; Internal variables
1631 (defvar gnus-english-month-names
1632 '("January" "February" "March" "April" "May" "June" "July" "August"
1633 "September" "October" "November" "December"))
1635 (defvar article-goto-body-goes-to-point-min-p nil)
1636 (defvar gnus-article-wash-types nil)
1637 (defvar gnus-article-emphasis-alist nil)
1638 (defvar gnus-article-image-alist nil)
1640 (defvar gnus-article-mime-handle-alist-1 nil)
1641 (defvar gnus-treatment-function-alist
1642 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1643 (gnus-treat-strip-banner gnus-article-strip-banner)
1644 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1645 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1646 (gnus-treat-buttonize gnus-article-add-buttons)
1647 (gnus-treat-fill-article gnus-article-fill-cited-article)
1648 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1649 (gnus-treat-strip-cr gnus-article-remove-cr)
1650 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1651 (gnus-treat-date-ut gnus-article-date-ut)
1652 (gnus-treat-date-local gnus-article-date-local)
1653 (gnus-treat-date-english gnus-article-date-english)
1654 (gnus-treat-date-original gnus-article-date-original)
1655 (gnus-treat-date-user-defined gnus-article-date-user)
1656 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1657 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1658 (gnus-treat-display-x-face gnus-article-display-x-face)
1659 (gnus-treat-display-face gnus-article-display-face)
1660 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1661 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1662 (gnus-treat-hide-signature gnus-article-hide-signature)
1663 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1664 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1665 (gnus-treat-strip-pem gnus-article-hide-pem)
1666 (gnus-treat-from-picon gnus-treat-from-picon)
1667 (gnus-treat-mail-picon gnus-treat-mail-picon)
1668 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1669 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1670 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1671 (gnus-treat-strip-trailing-blank-lines
1672 gnus-article-remove-trailing-blank-lines)
1673 (gnus-treat-strip-leading-blank-lines
1674 gnus-article-strip-leading-blank-lines)
1675 (gnus-treat-strip-multiple-blank-lines
1676 gnus-article-strip-multiple-blank-lines)
1677 (gnus-treat-overstrike gnus-article-treat-overstrike)
1678 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1679 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1680 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1681 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1682 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1683 (gnus-treat-display-smileys gnus-treat-smiley)
1684 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1685 (gnus-treat-wash-html gnus-article-wash-html)
1686 (gnus-treat-emphasize gnus-article-emphasize)
1687 (gnus-treat-hide-citation gnus-article-hide-citation)
1688 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1689 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1690 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1691 (gnus-treat-play-sounds gnus-earcon-display)))
1693 (defvar gnus-article-mime-handle-alist nil)
1694 (defvar article-lapsed-timer nil)
1695 (defvar gnus-article-current-summary nil)
1697 (defvar gnus-article-mode-syntax-table
1698 (let ((table (copy-syntax-table text-mode-syntax-table)))
1699 ;; This causes the citation match run O(2^n).
1700 ;; (modify-syntax-entry ?- "w" table)
1701 (modify-syntax-entry ?> ")<" table)
1702 (modify-syntax-entry ?< "(>" table)
1703 ;; make M-. in article buffers work for `foo' strings
1704 (modify-syntax-entry ?' " " table)
1705 (modify-syntax-entry ?` " " table)
1707 "Syntax table used in article mode buffers.
1708 Initialized from `text-mode-syntax-table.")
1710 (defvar gnus-save-article-buffer nil)
1712 (defvar gnus-article-mode-line-format-alist
1713 (nconc '((?w (gnus-article-wash-status) ?s)
1714 (?m (gnus-article-mime-part-status) ?s))
1715 gnus-summary-mode-line-format-alist))
1717 (defvar gnus-number-of-articles-to-be-saved nil)
1719 (defvar gnus-inhibit-hiding nil)
1721 (defvar gnus-article-edit-mode nil)
1723 ;;; Macros for dealing with the article buffer.
1725 (defmacro gnus-with-article-headers (&rest forms)
1727 (set-buffer gnus-article-buffer)
1729 (let ((inhibit-read-only t)
1730 (inhibit-point-motion-hooks t)
1731 (case-fold-search t))
1732 (article-narrow-to-head)
1735 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1736 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1738 (defmacro gnus-with-article-buffer (&rest forms)
1740 (set-buffer gnus-article-buffer)
1741 (let ((inhibit-read-only t))
1744 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1745 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1747 (defun gnus-article-goto-header (header)
1748 "Go to HEADER, which is a regular expression."
1749 (re-search-forward (concat "^\\(" header "\\):") nil t))
1751 (defsubst gnus-article-hide-text (b e props)
1752 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1753 (gnus-add-text-properties-when 'article-type nil b e props)
1754 (when (memq 'intangible props)
1756 (max (1- b) (point-min))
1757 b 'intangible (cddr (memq 'intangible props)))))
1759 (defsubst gnus-article-unhide-text (b e)
1760 "Remove hidden text properties from region between B and E."
1761 (remove-text-properties b e gnus-hidden-properties)
1762 (when (memq 'intangible gnus-hidden-properties)
1763 (put-text-property (max (1- b) (point-min))
1764 b 'intangible nil)))
1766 (defun gnus-article-hide-text-type (b e type)
1767 "Hide text of TYPE between B and E."
1768 (gnus-add-wash-type type)
1769 (gnus-article-hide-text
1770 b e (cons 'article-type (cons type gnus-hidden-properties))))
1772 (defun gnus-article-unhide-text-type (b e type)
1773 "Unhide text of TYPE between B and E."
1774 (gnus-delete-wash-type type)
1775 (remove-text-properties
1776 b e (cons 'article-type (cons type gnus-hidden-properties)))
1777 (when (memq 'intangible gnus-hidden-properties)
1778 (put-text-property (max (1- b) (point-min))
1779 b 'intangible nil)))
1781 (defun gnus-article-hide-text-of-type (type)
1782 "Hide text of TYPE in the current buffer."
1784 (let ((b (point-min))
1786 (while (setq b (text-property-any b e 'article-type type))
1787 (add-text-properties b (incf b) gnus-hidden-properties)))))
1789 (defun gnus-article-delete-text-of-type (type)
1790 "Delete text of TYPE in the current buffer."
1792 (let ((b (point-min)))
1793 (if (eq type 'multipart)
1794 ;; Remove MIME buttons associated with multipart/alternative parts.
1797 (while (if (get-text-property (point) 'gnus-part)
1799 (when (setq b (next-single-property-change (point)
1804 (skip-chars-forward "\n")
1805 (when (eq (get-text-property b 'article-type) 'multipart)
1806 (delete-region b (point)))))
1807 (while (setq b (text-property-any b (point-max) 'article-type type))
1809 b (or (text-property-not-all b (point-max) 'article-type type)
1812 (defun gnus-article-delete-invisible-text ()
1813 "Delete all invisible text in the current buffer."
1815 (let ((b (point-min)))
1816 (while (setq b (text-property-any b (point-max) 'invisible t))
1818 b (or (text-property-not-all b (point-max) 'invisible t)
1821 (defun gnus-article-text-type-exists-p (type)
1822 "Say whether any text of type TYPE exists in the buffer."
1823 (text-property-any (point-min) (point-max) 'article-type type))
1825 (defsubst gnus-article-header-rank ()
1826 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1827 (let ((list gnus-sorted-header-list)
1830 (if (looking-at (car list))
1832 (setq list (cdr list))
1836 (defun article-hide-headers (&optional arg delete)
1837 "Hide unwanted headers and possibly sort them as well."
1839 ;; This function might be inhibited.
1840 (unless gnus-inhibit-hiding
1841 (let ((inhibit-read-only t)
1842 (case-fold-search t)
1843 (max (1+ (length gnus-sorted-header-list)))
1844 (inhibit-point-motion-hooks t)
1845 (cur (current-buffer))
1846 ignored visible beg)
1848 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1849 ;; group parameters, so we should go to the summary buffer.
1852 (progn (set-buffer gnus-summary-buffer) t)
1854 (setq ignored (when (not gnus-visible-headers)
1855 (cond ((stringp gnus-ignored-headers)
1856 gnus-ignored-headers)
1857 ((listp gnus-ignored-headers)
1858 (mapconcat 'identity
1859 gnus-ignored-headers
1861 visible (cond ((stringp gnus-visible-headers)
1862 gnus-visible-headers)
1863 ((and gnus-visible-headers
1864 (listp gnus-visible-headers))
1865 (mapconcat 'identity
1866 gnus-visible-headers
1870 ;; First we narrow to just the headers.
1871 (article-narrow-to-head)
1872 ;; Hide any "From " lines at the beginning of (mail) articles.
1873 (while (looking-at "From ")
1876 (delete-region (point-min) (point)))
1877 ;; Then treat the rest of the header lines.
1878 ;; Then we use the two regular expressions
1879 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1880 ;; select which header lines is to remain visible in the
1882 (while (re-search-forward "^[^ \t:]*:" nil t)
1884 ;; Mark the rank of the header.
1886 (point) (1+ (point)) 'message-rank
1887 (if (or (and visible (looking-at visible))
1889 (not (looking-at ignored))))
1890 (gnus-article-header-rank)
1893 (message-sort-headers-1)
1894 (when (setq beg (text-property-any
1895 (point-min) (point-max) 'message-rank (+ 2 max)))
1896 ;; We delete the unwanted headers.
1897 (gnus-add-wash-type 'headers)
1898 (add-text-properties (point-min) (+ 5 (point-min))
1899 '(article-type headers dummy-invisible t))
1900 (delete-region beg (point-max))))))))
1902 (defun article-hide-boring-headers (&optional arg)
1903 "Toggle hiding of headers that aren't very interesting.
1904 If given a negative prefix, always show; if given a positive prefix,
1906 (interactive (gnus-article-hidden-arg))
1907 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1908 (not gnus-show-all-headers))
1911 (let ((inhibit-read-only t)
1912 (inhibit-point-motion-hooks t))
1913 (article-narrow-to-head)
1914 (dolist (elem gnus-boring-article-headers)
1915 (goto-char (point-min))
1917 ;; Hide empty headers.
1919 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1921 (gnus-article-hide-text-type
1925 (if (re-search-forward "^[^ \t]" nil t)
1929 ;; Hide boring Newsgroups header.
1930 ((eq elem 'newsgroups)
1931 (when (gnus-string-equal
1932 (gnus-fetch-field "newsgroups")
1933 (gnus-group-real-name
1934 (if (boundp 'gnus-newsgroup-name)
1937 (gnus-article-hide-header "newsgroups")))
1938 ((eq elem 'to-address)
1939 (let ((to (message-fetch-field "to"))
1941 (gnus-parameter-to-address
1942 (if (boundp 'gnus-newsgroup-name)
1943 gnus-newsgroup-name ""))))
1944 (when (and to to-address
1947 ;; only one address in To
1948 (nth 1 (mail-extract-address-components to))
1950 (gnus-article-hide-header "to"))))
1952 (let ((to (message-fetch-field "to"))
1954 (gnus-parameter-to-list
1955 (if (boundp 'gnus-newsgroup-name)
1956 gnus-newsgroup-name ""))))
1957 (when (and to to-list
1960 ;; only one address in To
1961 (nth 1 (mail-extract-address-components to))
1963 (gnus-article-hide-header "to"))))
1965 (let ((cc (message-fetch-field "cc"))
1967 (gnus-parameter-to-list
1968 (if (boundp 'gnus-newsgroup-name)
1969 gnus-newsgroup-name ""))))
1970 (when (and cc to-list
1973 ;; only one address in CC
1974 (nth 1 (mail-extract-address-components cc))
1976 (gnus-article-hide-header "cc"))))
1977 ((eq elem 'followup-to)
1978 (when (gnus-string-equal
1979 (message-fetch-field "followup-to")
1980 (message-fetch-field "newsgroups"))
1981 (gnus-article-hide-header "followup-to")))
1982 ((eq elem 'reply-to)
1983 (if (gnus-group-find-parameter
1984 gnus-newsgroup-name 'broken-reply-to)
1985 (gnus-article-hide-header "reply-to")
1986 (let ((from (message-fetch-field "from"))
1987 (reply-to (message-fetch-field "reply-to")))
1994 (lambda (x) (downcase (cadr x)))
1995 (mail-extract-address-components from t))
1998 (lambda (x) (downcase (cadr x)))
1999 (mail-extract-address-components reply-to t))
2001 (gnus-article-hide-header "reply-to")))))
2003 (let ((date (message-fetch-field "date")))
2005 (< (days-between (current-time-string) date)
2007 (gnus-article-hide-header "date"))))
2009 (let ((to (message-fetch-field "to"))
2010 (cc (message-fetch-field "cc")))
2011 (when (> (length to) 1024)
2012 (gnus-article-hide-header "to"))
2013 (when (> (length cc) 1024)
2014 (gnus-article-hide-header "cc"))))
2018 (goto-char (point-min))
2019 (while (re-search-forward "^to:" nil t)
2020 (setq to-count (1+ to-count)))
2021 (when (> to-count 1)
2022 (while (> to-count 0)
2023 (goto-char (point-min))
2025 (re-search-forward "^to:" nil nil to-count)
2027 (narrow-to-region (point) (point-max))
2028 (gnus-article-hide-header "to"))
2029 (setq to-count (1- to-count))))
2030 (goto-char (point-min))
2031 (while (re-search-forward "^cc:" nil t)
2032 (setq cc-count (1+ cc-count)))
2033 (when (> cc-count 1)
2034 (while (> cc-count 0)
2035 (goto-char (point-min))
2037 (re-search-forward "^cc:" nil nil cc-count)
2039 (narrow-to-region (point) (point-max))
2040 (gnus-article-hide-header "cc"))
2041 (setq cc-count (1- cc-count)))))))))))))
2043 (defun gnus-article-hide-header (header)
2045 (goto-char (point-min))
2046 (when (re-search-forward (concat "^" header ":") nil t)
2047 (gnus-article-hide-text-type
2051 (if (re-search-forward "^[^ \t]" nil t)
2056 (defvar gnus-article-normalized-header-length 40
2057 "Length of normalized headers.")
2059 (defun article-normalize-headers ()
2060 "Make all header lines 40 characters long."
2062 (let ((inhibit-read-only t)
2066 (article-narrow-to-head)
2069 ((< (setq column (- (point-at-eol) (point)))
2070 gnus-article-normalized-header-length)
2072 (insert (make-string
2073 (- gnus-article-normalized-header-length column)
2075 ((> column gnus-article-normalized-header-length)
2076 (gnus-put-text-property
2078 (forward-char gnus-article-normalized-header-length)
2085 (forward-line 1))))))
2087 (defun article-treat-dumbquotes ()
2088 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
2089 Note that this function guesses whether a character is a sm*rtq**t* or
2090 not, so it should only be used interactively.
2092 Sm*rtq**t*s are M****s***'s unilateral extension to the
2093 iso-8859-1 character map in an attempt to provide more quoting
2094 characters. If you see something like \\222 or \\264 where
2095 you're expecting some kind of apostrophe or quotation mark, then
2098 (article-translate-strings gnus-article-dumbquotes-map))
2100 (defun article-translate-characters (from to)
2101 "Translate all characters in the body of the article according to FROM and TO.
2102 FROM is a string of characters to translate from; to is a string of
2103 characters to translate to."
2105 (when (article-goto-body)
2106 (let ((inhibit-read-only t)
2107 (x (make-string 225 ?x))
2109 (while (< (incf i) (length x))
2112 (while (< i (length from))
2113 (aset x (aref from i) (aref to i))
2115 (translate-region (point) (point-max) x)))))
2117 (defun article-translate-strings (map)
2118 "Translate all string in the body of the article according to MAP.
2119 MAP is an alist where the elements are on the form (\"from\" \"to\")."
2121 (when (article-goto-body)
2122 (let ((inhibit-read-only t))
2125 (while (search-forward (car elem) nil t)
2126 (replace-match (cadr elem)))))))))
2128 (defun article-treat-overstrike ()
2129 "Translate overstrikes into bold text."
2132 (when (article-goto-body)
2133 (let ((inhibit-read-only t))
2134 (while (search-forward "\b" nil t)
2135 (let ((next (char-after))
2136 (previous (char-after (- (point) 2))))
2137 ;; We do the boldification/underlining by hiding the
2138 ;; overstrikes and putting the proper text property
2142 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
2143 (put-text-property (point) (1+ (point)) 'face 'bold))
2145 (gnus-article-hide-text-type
2146 (1- (point)) (1+ (point)) 'overstrike)
2148 (- (point) 2) (1- (point)) 'face 'underline))
2150 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
2152 (point) (1+ (point)) 'face 'underline)))))))))
2154 (defun article-treat-ansi-sequences ()
2155 "Translate ANSI SGR control sequences into overlays or extents."
2158 (when (article-goto-body)
2159 (let ((inhibit-read-only t))
2160 (ansi-color-apply-on-region (point) (point-max))))))
2162 (defun gnus-article-treat-unfold-headers ()
2163 "Unfold folded message headers.
2164 Only the headers that fit into the current window width will be
2167 (gnus-with-article-headers
2171 (mail-header-narrow-to-field)
2172 (let* ((header (buffer-string))
2174 (or (equal gnus-article-unfold-long-headers t)
2175 (and (stringp gnus-article-unfold-long-headers)
2176 (string-match gnus-article-unfold-long-headers header)))))
2179 (goto-char (point-min))
2180 (while (re-search-forward "\n[\t ]" nil t)
2181 (replace-match " " t t)))
2182 (setq length (- (point-max) (point-min) 1))
2183 (when (or unfoldable
2184 (< length (window-width)))
2185 (while (re-search-forward "\n[\t ]" nil t)
2186 (replace-match " " t t))))
2187 (goto-char (point-max)))))))
2189 (defun gnus-article-treat-fold-headers ()
2190 "Fold message headers."
2192 (gnus-with-article-headers
2195 (mail-header-narrow-to-field)
2196 (mail-header-fold-field)
2197 (goto-char (point-max))))))
2199 (defun gnus-treat-smiley ()
2200 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2202 (gnus-with-article-buffer
2203 (if (memq 'smiley gnus-article-wash-types)
2204 (gnus-delete-images 'smiley)
2206 (let ((images (smiley-region (point) (point-max))))
2208 (gnus-add-wash-type 'smiley)
2209 (dolist (image images)
2210 (gnus-add-image 'smiley image)))))))
2212 (defun gnus-article-remove-images ()
2213 "Remove all images from the article buffer."
2215 (gnus-with-article-buffer
2216 (dolist (elem gnus-article-image-alist)
2217 (gnus-delete-images (car elem)))))
2219 (defun gnus-article-treat-fold-newsgroups ()
2220 "Unfold folded message headers.
2221 Only the headers that fit into the current window width will be
2224 (gnus-with-article-headers
2225 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2227 (mail-header-narrow-to-field)
2228 (while (re-search-forward ", *" nil t)
2229 (replace-match ", " t t))
2230 (mail-header-fold-field)
2231 (goto-char (point-max))))))
2233 (defcustom gnus-article-truncate-lines default-truncate-lines
2234 "Value of `truncate-lines' in Gnus Article buffer.
2235 Valid values are nil, t, `head', `first', `last', an integer or a
2236 predicate. See Info node `(gnus)Customizing Articles'."
2237 :version "23.0" ;; No Gnus
2238 :group 'gnus-article
2239 ;; :link '(custom-manual "(gnus)Customizing Articles")
2242 (defun gnus-article-toggle-truncate-lines (&optional arg)
2243 "Toggle whether to fold or truncate long lines in article the buffer.
2244 If ARG is non-nil and not a number, toggle
2245 `gnus-article-truncate-lines' too. If ARG is a number, truncate
2246 long lines iff arg is positive."
2249 ((and (numberp arg) (> arg 0))
2250 (setq gnus-article-truncate-lines t))
2252 (setq gnus-article-truncate-lines nil))
2254 (setq gnus-article-truncate-lines
2255 (not gnus-article-truncate-lines))))
2256 (gnus-with-article-buffer
2258 ((and (numberp arg) (> arg 0))
2259 (setq truncate-lines nil))
2261 (setq truncate-lines t)))
2262 ;; In versions of Emacs 22 (CVS) before 2006-05-26,
2263 ;; `toggle-truncate-lines' needs an argument.
2264 (toggle-truncate-lines)))
2266 (defun gnus-article-treat-body-boundary ()
2267 "Place a boundary line at the end of the headers."
2269 (when (and gnus-body-boundary-delimiter
2270 (> (length gnus-body-boundary-delimiter) 0))
2271 (gnus-with-article-headers
2272 (goto-char (point-max))
2273 (let ((start (point)))
2274 (insert "X-Boundary: ")
2275 (gnus-add-text-properties start (point) '(invisible t intangible t))
2277 (while (>= (1- (window-width)) (length str))
2278 (setq str (concat str gnus-body-boundary-delimiter)))
2279 (substring str 0 (1- (window-width))))
2281 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2283 (defun article-fill-long-lines ()
2284 "Fill lines that are wider than the window width."
2287 (let ((inhibit-read-only t)
2288 (width (window-width (get-buffer-window (current-buffer)))))
2291 (let ((adaptive-fill-mode nil)) ;Why? -sm
2294 (when (>= (current-column) (min fill-column width))
2295 (narrow-to-region (min (1+ (point)) (point-max))
2297 (let ((goback (point-marker)))
2298 (fill-paragraph nil)
2299 (goto-char (marker-position goback)))
2301 (forward-line 1)))))))
2303 (defun article-capitalize-sentences ()
2304 "Capitalize the first word in each sentence."
2307 (let ((inhibit-read-only t)
2308 (paragraph-start "^[\n\^L]"))
2312 (forward-sentence)))))
2314 (defun article-remove-cr ()
2315 "Remove trailing CRs and then translate remaining CRs into LFs."
2318 (let ((inhibit-read-only t))
2319 (goto-char (point-min))
2320 (while (re-search-forward "\r+$" nil t)
2321 (replace-match "" t t))
2322 (goto-char (point-min))
2323 (while (search-forward "\r" nil t)
2324 (replace-match "\n" t t)))))
2326 (defun article-remove-trailing-blank-lines ()
2327 "Remove all trailing blank lines from the article."
2330 (let ((inhibit-read-only t))
2331 (goto-char (point-max))
2335 (while (and (not (bobp))
2336 (looking-at "^[ \t]*$")
2337 (not (gnus-annotation-in-region-p
2338 (point) (point-at-eol))))
2344 (defvar gnus-face-properties-alist))
2346 (defun article-display-face ()
2347 "Display any Face headers in the header."
2349 (let ((wash-face-p buffer-read-only))
2350 (gnus-with-article-headers
2351 ;; When displaying parts, this function can be called several times on
2352 ;; the same article, without any intended toggle semantic (as typing `W
2353 ;; D d' would have). So face deletion must occur only when we come from
2354 ;; an interactive command, that is when the *Article* buffer is
2356 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2357 (gnus-delete-images 'face)
2358 (let (face faces from)
2359 (save-current-buffer
2360 (when (and wash-face-p
2361 (gnus-buffer-live-p gnus-original-article-buffer)
2362 (not (re-search-forward "^Face:[\t ]*" nil t)))
2363 (set-buffer gnus-original-article-buffer))
2365 (mail-narrow-to-head)
2366 (while (gnus-article-goto-header "Face")
2367 (push (mail-header-field-value) faces))))
2369 (goto-char (point-min))
2370 (let ((from (gnus-article-goto-header "from"))
2375 (insert "[no `from' set]\n"))
2377 (when (setq png (gnus-convert-face-to-png (pop faces)))
2379 (apply 'gnus-create-image png 'png t
2380 (cdr (assq 'png gnus-face-properties-alist))))
2382 (gnus-add-wash-type 'face)
2383 (gnus-add-image 'face image)
2384 (gnus-put-image image nil 'face))))))))))
2386 (defun article-display-x-face (&optional force)
2387 "Look for an X-Face header and display it if present."
2388 (interactive (list 'force))
2389 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2390 (gnus-with-article-headers
2391 ;; Delete the old process, if any.
2392 (when (process-status "article-x-face")
2393 (delete-process "article-x-face"))
2394 ;; See the comment in `article-display-face'.
2395 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2396 ;; We have already displayed X-Faces, so we remove them
2398 (gnus-delete-images 'xface)
2400 (let (x-faces from face)
2401 (save-current-buffer
2402 (when (and wash-face-p
2403 (gnus-buffer-live-p gnus-original-article-buffer)
2404 (not (re-search-forward "^X-Face:[\t ]*" nil t)))
2405 ;; If type `W f', use gnus-original-article-buffer,
2406 ;; otherwise use the current buffer because displaying
2407 ;; RFC822 parts calls this function too.
2408 (set-buffer gnus-original-article-buffer))
2410 (mail-narrow-to-head)
2411 (while (gnus-article-goto-header "X-Face")
2412 (push (mail-header-field-value) x-faces))
2413 (setq from (message-fetch-field "from"))))
2414 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2415 ;; single external face.
2416 (when (stringp gnus-article-x-face-command)
2417 (setq x-faces (list (car x-faces))))
2419 gnus-article-x-face-command
2421 ;; Check whether this face is censored.
2422 (not gnus-article-x-face-too-ugly)
2424 (not (string-match gnus-article-x-face-too-ugly
2426 (while (setq face (pop x-faces))
2427 ;; We display the face.
2428 (cond ((stringp gnus-article-x-face-command)
2429 ;; The command is a string, so we interpret the command
2430 ;; as a, well, command, and fork it off.
2431 (let ((process-connection-type nil))
2432 (gnus-set-process-query-on-exit-flag
2434 "article-x-face" nil shell-file-name
2435 shell-command-switch gnus-article-x-face-command)
2439 (process-send-region "article-x-face"
2440 (point-min) (point-max)))
2441 (process-send-eof "article-x-face")))
2442 ((functionp gnus-article-x-face-command)
2443 ;; The command is a lisp function, so we call it.
2444 (funcall gnus-article-x-face-command face))
2446 (error "%s is not a function"
2447 gnus-article-x-face-command))))))))))
2449 (defun article-decode-mime-words ()
2450 "Decode all MIME-encoded words in the article."
2452 (gnus-with-article-buffer
2453 (let ((inhibit-point-motion-hooks t)
2454 (mail-parse-charset gnus-newsgroup-charset)
2455 (mail-parse-ignored-charsets
2456 (with-current-buffer gnus-summary-buffer
2457 gnus-newsgroup-ignored-charsets)))
2458 (mail-decode-encoded-word-region (point-min) (point-max)))))
2460 (defun article-decode-charset (&optional prompt)
2461 "Decode charset-encoded text in the article.
2462 If PROMPT (the prefix), prompt for a coding system to use."
2464 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2465 (inhibit-read-only t)
2466 (mail-parse-charset gnus-newsgroup-charset)
2467 (mail-parse-ignored-charsets
2468 (save-excursion (condition-case nil
2469 (set-buffer gnus-summary-buffer)
2471 gnus-newsgroup-ignored-charsets))
2472 ct cte ctl charset format)
2475 (article-narrow-to-head)
2476 (setq ct (message-fetch-field "Content-Type" t)
2477 cte (message-fetch-field "Content-Transfer-Encoding" t)
2478 ctl (and ct (mail-header-parse-content-type ct))
2481 (mm-read-coding-system "Charset to decode: "))
2483 (mail-content-type-get ctl 'charset)))
2484 format (and ctl (mail-content-type-get ctl 'format)))
2486 (setq cte (mail-header-strip cte)))
2487 (if (and ctl (not (string-match "/" (car ctl))))
2489 (goto-char (point-max)))
2492 (narrow-to-region (point) (point-max))
2493 (when (and (eq mail-parse-charset 'gnus-decoded)
2494 (eq (mm-body-7-or-8) '8bit))
2495 ;; The text code could have been decoded.
2496 (setq charset mail-parse-charset))
2497 (when (and (or (not ctl)
2498 (equal (car ctl) "text/plain"))
2499 (not format)) ;; article with format will decode later.
2501 charset (and cte (intern (downcase
2502 (gnus-strip-whitespace cte))))
2505 (defun article-decode-encoded-words ()
2506 "Remove encoded-word encoding from headers."
2507 (let ((inhibit-point-motion-hooks t)
2508 (mail-parse-charset gnus-newsgroup-charset)
2509 (mail-parse-ignored-charsets
2510 (save-excursion (condition-case nil
2511 (set-buffer gnus-summary-buffer)
2513 gnus-newsgroup-ignored-charsets))
2514 (inhibit-read-only t)
2516 (goto-char (point-min))
2517 (when (search-forward "\n\n" nil 'move)
2524 (memq (char-after) '(?\t ? )))))
2525 (setq start (point))
2527 \\(?:Resent-\\)?\\(?:From\\|Cc\\|To\\|Bcc\\|\\(?:In-\\)?Reply-To\\|Sender\
2528 \\|Mail-Followup-To\\|Mail-Copies-To\\|Approved\\):")
2529 (funcall gnus-decode-address-function start end)
2530 (funcall gnus-decode-header-function start end))
2531 (goto-char (setq end start)))))
2533 (defun article-decode-group-name ()
2534 "Decode group names in `Newsgroups:'."
2535 (let ((inhibit-point-motion-hooks t)
2536 (inhibit-read-only t)
2537 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2538 (when (and (or gnus-group-name-charset-method-alist
2539 gnus-group-name-charset-group-alist)
2540 (gnus-buffer-live-p gnus-original-article-buffer))
2542 (article-narrow-to-head)
2543 (with-current-buffer gnus-original-article-buffer
2544 (goto-char (point-min)))
2545 (while (re-search-forward
2546 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2547 (replace-match (save-match-data
2548 (gnus-decode-newsgroups
2549 ;; XXX how to use data in article buffer?
2550 (with-current-buffer gnus-original-article-buffer
2552 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2555 gnus-newsgroup-name method))
2557 (goto-char (point-min))
2558 (with-current-buffer gnus-original-article-buffer
2559 (goto-char (point-min)))
2560 (while (re-search-forward
2561 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2562 (replace-match (save-match-data
2563 (gnus-decode-newsgroups
2564 ;; XXX how to use data in article buffer?
2565 (with-current-buffer gnus-original-article-buffer
2567 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2570 gnus-newsgroup-name method))
2573 (autoload 'idna-to-unicode "idna")
2575 (defun article-decode-idna-rhs ()
2576 "Decode IDNA strings in RHS in various headers in current buffer.
2577 The following headers are decoded: From:, To:, Cc:, Reply-To:,
2578 Mail-Reply-To: and Mail-Followup-To:."
2581 (let ((inhibit-point-motion-hooks t)
2582 (inhibit-read-only t))
2583 (article-narrow-to-head)
2584 (goto-char (point-min))
2585 (while (re-search-forward "@[^ \t\n\r,>]*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2587 (when (save-match-data
2588 (and (setq ace (match-string 1))
2590 (and (re-search-backward "^[^ \t]" nil t)
2591 (looking-at "From\\|To\\|Cc\\|Reply-To\\|Mail-Reply-To\\|Mail-Followup-To")))
2592 (setq unicode (idna-to-unicode ace))))
2593 (unless (string= ace unicode)
2594 (replace-match unicode nil nil nil 1)))))))))
2596 (defun article-de-quoted-unreadable (&optional force read-charset)
2597 "Translate a quoted-printable-encoded article.
2598 If FORCE, decode the article whether it is marked as quoted-printable
2600 If READ-CHARSET, ask for a coding system."
2601 (interactive (list 'force current-prefix-arg))
2603 (let ((inhibit-read-only t) type charset)
2604 (if (gnus-buffer-live-p gnus-original-article-buffer)
2605 (with-current-buffer gnus-original-article-buffer
2607 (gnus-fetch-field "content-transfer-encoding"))
2608 (let* ((ct (gnus-fetch-field "content-type"))
2609 (ctl (and ct (mail-header-parse-content-type ct))))
2610 (setq charset (and ctl
2611 (mail-content-type-get ctl 'charset)))
2612 (if (stringp charset)
2613 (setq charset (intern (downcase charset)))))))
2615 (setq charset (mm-read-coding-system "Charset: " charset)))
2617 (setq charset gnus-newsgroup-charset))
2619 (and type (let ((case-fold-search t))
2620 (string-match "quoted-printable" type))))
2622 (quoted-printable-decode-region
2623 (point) (point-max) (mm-charset-to-coding-system charset))))))
2625 (defun article-de-base64-unreadable (&optional force read-charset)
2626 "Translate a base64 article.
2627 If FORCE, decode the article whether it is marked as base64 not.
2628 If READ-CHARSET, ask for a coding system."
2629 (interactive (list 'force current-prefix-arg))
2631 (let ((inhibit-read-only t) type charset)
2632 (if (gnus-buffer-live-p gnus-original-article-buffer)
2633 (with-current-buffer gnus-original-article-buffer
2635 (gnus-fetch-field "content-transfer-encoding"))
2636 (let* ((ct (gnus-fetch-field "content-type"))
2637 (ctl (and ct (mail-header-parse-content-type ct))))
2638 (setq charset (and ctl
2639 (mail-content-type-get ctl 'charset)))
2640 (if (stringp charset)
2641 (setq charset (intern (downcase charset)))))))
2643 (setq charset (mm-read-coding-system "Charset: " charset)))
2645 (setq charset gnus-newsgroup-charset))
2647 (and type (let ((case-fold-search t))
2648 (string-match "base64" type))))
2651 (narrow-to-region (point) (point-max))
2652 (base64-decode-region (point-min) (point-max))
2653 (mm-decode-coding-region
2654 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2659 (defun article-decode-HZ ()
2660 "Translate a HZ-encoded article."
2664 (let ((inhibit-read-only t))
2665 (rfc1843-decode-region (point-min) (point-max)))))
2667 (defun article-unsplit-urls ()
2668 "Remove the newlines that some other mailers insert into URLs."
2671 (let ((inhibit-read-only t))
2672 (goto-char (point-min))
2673 (while (re-search-forward
2674 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2675 (replace-match "\\1\\3" t)))
2676 (when (interactive-p)
2677 (gnus-treat-article nil))))
2680 (defun article-wash-html (&optional read-charset)
2681 "Format an HTML article.
2682 If READ-CHARSET, ask for a coding system. If it is a number, the
2683 charset defined in `gnus-summary-show-article-charset-alist' is used."
2686 (let ((inhibit-read-only t)
2689 (if (or (and (numberp read-charset)
2693 gnus-summary-show-article-charset-alist))))
2694 (setq charset (mm-read-coding-system "Charset: ")))
2695 (let ((gnus-summary-show-article-charset-alist
2696 (list (cons 1 charset))))
2697 (with-current-buffer gnus-summary-buffer
2698 (gnus-summary-show-article 1)))
2699 (error "No charset is given"))
2700 (when (gnus-buffer-live-p gnus-original-article-buffer)
2701 (with-current-buffer gnus-original-article-buffer
2702 (let* ((ct (gnus-fetch-field "content-type"))
2703 (ctl (and ct (mail-header-parse-content-type ct))))
2704 (setq charset (and ctl
2705 (mail-content-type-get ctl 'charset)))
2706 (when (stringp charset)
2707 (setq charset (intern (downcase charset)))))))
2709 (setq charset gnus-newsgroup-charset)))
2711 (save-window-excursion
2713 (narrow-to-region (point) (point-max))
2714 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2715 (entry (assq func mm-text-html-washer-alist)))
2717 (setq func (cdr entry)))
2722 (apply (car func) (cdr func))))))))))
2724 (defun gnus-article-wash-html-with-w3 ()
2725 "Wash the current buffer with w3."
2727 (let ((w3-strict-width (window-width))
2728 (url-standalone-mode t)
2729 (url-gateway-unplugged t)
2730 (w3-honor-stylesheets nil))
2732 (w3-region (point-min) (point-max))
2735 (defun gnus-article-wash-html-with-w3m ()
2736 "Wash the current buffer with emacs-w3m."
2738 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2739 w3m-force-redisplay)
2740 (w3m-region (point-min) (point-max)))
2741 (when (and mm-inline-text-html-with-w3m-keymap
2742 (boundp 'w3m-minor-mode-map)
2744 (add-text-properties
2745 (point-min) (point-max)
2746 (list 'keymap w3m-minor-mode-map
2747 ;; Put the mark meaning this part was rendered by emacs-w3m.
2748 'mm-inline-text-html-with-w3m t))))
2750 (eval-when-compile (defvar charset)) ;; Bound by `article-wash-html'.
2752 (defun gnus-article-wash-html-with-w3m-standalone ()
2753 "Wash the current buffer with w3m."
2754 (if (mm-w3m-standalone-supports-m17n-p)
2756 (unless (mm-coding-system-p charset) ;; Bound by `article-wash-html'.
2758 (setq charset 'iso-8859-1))
2759 (let ((coding-system-for-write charset)
2760 (coding-system-for-read charset))
2761 (call-process-region
2762 (point-min) (point-max)
2763 "w3m" t t nil "-dump" "-T" "text/html"
2764 "-I" (symbol-name charset) "-O" (symbol-name charset))))
2765 (mm-inline-wash-with-stdin nil "w3m" "-dump" "-T" "text/html")))
2767 (defvar gnus-article-browse-html-temp-list nil
2768 "List of temporary files created by `gnus-article-browse-html-parts'.
2769 Internal variable.")
2771 (defcustom gnus-article-browse-delete-temp 'ask
2772 "What to do with temporary files from `gnus-article-browse-html-parts'.
2773 If nil, don't delete temporary files. If it is t, delete them on
2774 exit from the summary buffer. If it is the symbol `file', query
2775 on each file, if it is `ask' ask once when exiting from the
2777 :group 'gnus-article
2778 :version "23.0" ;; No Gnus
2779 :type '(choice (const :tag "Don't delete" nil)
2780 (const :tag "Don't ask" t)
2781 (const :tag "Ask" ask)
2782 (const :tag "Ask for each file" file)))
2784 ;; Cf. mm-postponed-undisplay-list / mm-destroy-postponed-undisplay-list.
2786 (defun gnus-article-browse-delete-temp-files (&optional how)
2787 "Delete temp-files created by `gnus-article-browse-html-parts'."
2788 (when (and gnus-article-browse-html-temp-list
2790 (setq how gnus-article-browse-delete-temp)))
2791 (when (and (eq how 'ask)
2793 "Delete all %s temporary HTML file(s)? "
2794 (length gnus-article-browse-html-temp-list)))
2796 (dolist (file gnus-article-browse-html-temp-list)
2797 (when (and (file-exists-p file)
2799 ;; `how' is neither `nil', `ask' nor `t' (i.e. `file'):
2801 (format "Delete temporary HTML file `%s'? " file))))
2802 (delete-file file)))
2803 ;; Also remove file from the list when not deleted or if file doesn't
2805 (setq gnus-article-browse-html-temp-list nil))
2806 gnus-article-browse-html-temp-list)
2808 (defun gnus-article-browse-html-parts (list)
2809 "View all \"text/html\" parts from LIST.
2810 Recurse into multiparts."
2811 ;; Internal function used by `gnus-article-browse-html-article'.
2813 ;; Find and show the html-parts.
2814 (dolist (handle list)
2815 ;; If HTML, show it:
2816 (when (listp handle)
2817 (cond ((and (bufferp (car handle))
2818 (string-match "text/html" (car (mm-handle-type handle))))
2819 (let ((tmp-file (mm-make-temp-file
2820 ;; Do we need to care for 8.3 filenames?
2821 "mm-" nil ".html")))
2822 (mm-save-part-to-file handle tmp-file)
2823 (add-to-list 'gnus-article-browse-html-temp-list tmp-file)
2824 (add-hook 'gnus-summary-prepare-exit-hook
2825 'gnus-article-browse-delete-temp-files)
2826 (add-hook 'gnus-exit-gnus-hook
2828 (gnus-article-browse-delete-temp-files t)))
2829 (browse-url-of-file tmp-file)
2831 ;; If multipart, recurse
2832 ((and (stringp (car handle))
2833 (string-match "^multipart/" (car handle))
2836 (gnus-article-browse-html-parts handle))))))))
2839 (defun gnus-article-browse-html-article ()
2840 "View \"text/html\" parts of the current article with a WWW browser."
2842 (save-window-excursion
2843 ;; Open raw article and select the buffer
2844 (gnus-summary-show-article t)
2845 (gnus-summary-select-article-buffer)
2846 (let ((parts (mm-dissect-buffer t t)))
2847 ;; If singlepart, enforce a list.
2848 (when (and (bufferp (car parts))
2849 (stringp (car (mm-handle-type parts))))
2850 (setq parts (list parts)))
2852 (unless (gnus-article-browse-html-parts parts)
2853 (gnus-error 3 "Mail doesn't contain a \"text/html\" part!"))
2854 (gnus-summary-show-article))))
2856 (defun article-hide-list-identifiers ()
2857 "Remove list identifies from the Subject header.
2858 The `gnus-list-identifiers' variable specifies what to do."
2860 (let ((inhibit-point-motion-hooks t)
2861 (regexp (if (consp gnus-list-identifiers)
2862 (mapconcat 'identity gnus-list-identifiers " *\\|")
2863 gnus-list-identifiers))
2864 (inhibit-read-only t))
2868 (article-narrow-to-head)
2869 (goto-char (point-min))
2870 (while (re-search-forward
2871 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2873 (delete-region (match-beginning 2) (match-end 0))
2874 (beginning-of-line))
2875 (when (re-search-forward
2876 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2877 (delete-region (match-beginning 1) (match-end 1))))))))
2879 (defun article-hide-pem (&optional arg)
2880 "Toggle hiding of any PEM headers and signatures in the current article.
2881 If given a negative prefix, always show; if given a positive prefix,
2883 (interactive (gnus-article-hidden-arg))
2884 (unless (gnus-article-check-hidden-text 'pem arg)
2886 (let ((inhibit-read-only t) end)
2887 (goto-char (point-min))
2888 ;; Hide the horrendously ugly "header".
2889 (when (and (search-forward
2890 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2892 (setq end (1+ (match-beginning 0))))
2893 (gnus-add-wash-type 'pem)
2894 (gnus-article-hide-text-type
2896 (if (search-forward "\n\n" nil t)
2900 ;; Hide the trailer as well
2901 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2903 (gnus-article-hide-text-type
2904 (match-beginning 0) (match-end 0) 'pem)))))))
2906 (defun article-strip-banner ()
2907 "Strip the banners specified by the `banner' group parameter and by
2908 `gnus-article-address-banner-alist'."
2912 (let ((inhibit-point-motion-hooks t))
2913 (when (gnus-parameter-banner gnus-newsgroup-name)
2914 (article-really-strip-banner
2915 (gnus-parameter-banner gnus-newsgroup-name)))
2916 (when gnus-article-address-banner-alist
2917 ;; Note that the From header is decoded here, so it is
2918 ;; required that the *-extract-address-components function
2919 ;; supports non-ASCII text.
2920 (let ((from (save-restriction
2922 (article-narrow-to-head)
2923 (mail-fetch-field "from"))))
2926 (cadr (funcall gnus-extract-address-components
2929 (dolist (pair gnus-article-address-banner-alist)
2930 (when (string-match (car pair) from)
2932 (article-really-strip-banner (cdr pair)))))))))))))
2934 (defun article-really-strip-banner (banner)
2935 "Strip the banner specified by the argument."
2938 (let ((inhibit-point-motion-hooks t)
2939 (gnus-signature-limit nil)
2940 (inhibit-read-only t))
2943 ((eq banner 'signature)
2944 (when (gnus-article-narrow-to-signature)
2947 (delete-region (point) (point-max))))
2949 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2950 (while (re-search-forward banner nil t)
2951 (delete-region (match-beginning 0) (match-end 0)))))
2953 (while (re-search-forward banner nil t)
2954 (delete-region (match-beginning 0) (match-end 0)))))))))
2956 (defun article-babel ()
2957 "Translate article using an online translation service."
2960 (gnus-with-article-buffer
2961 (when (article-goto-body)
2962 (let* ((start (point))
2964 (orig (buffer-substring start end))
2965 (trans (babel-as-string orig)))
2967 (narrow-to-region start end)
2968 (delete-region start end)
2971 (defun article-hide-signature (&optional arg)
2972 "Hide the signature in the current article.
2973 If given a negative prefix, always show; if given a positive prefix,
2975 (interactive (gnus-article-hidden-arg))
2976 (unless (gnus-article-check-hidden-text 'signature arg)
2979 (let ((inhibit-read-only t))
2980 (when (gnus-article-narrow-to-signature)
2981 (gnus-article-hide-text-type
2982 (point-min) (point-max) 'signature))))))
2983 (gnus-set-mode-line 'article))
2985 (defun article-strip-headers-in-body ()
2986 "Strip offensive headers from bodies."
2990 (let ((case-fold-search t))
2991 (when (looking-at "x-no-archive:")
2992 (gnus-delete-line)))))
2994 (defun article-strip-leading-blank-lines ()
2995 "Remove all blank lines from the beginning of the article."
2998 (let ((inhibit-point-motion-hooks t)
2999 (inhibit-read-only t))
3000 (when (article-goto-body)
3001 (while (and (not (eobp))
3002 (looking-at "[ \t]*$"))
3003 (gnus-delete-line))))))
3005 (defun article-narrow-to-head ()
3006 "Narrow the buffer to the head of the message.
3007 Point is left at the beginning of the narrowed-to region."
3009 (goto-char (point-min))
3010 (if (search-forward "\n\n" nil 1)
3013 (goto-char (point-min)))
3015 (defun article-goto-body ()
3016 "Place point at the start of the body."
3017 (goto-char (point-min))
3019 ;; This variable is only bound when dealing with separate
3021 (article-goto-body-goes-to-point-min-p
3023 ((search-forward "\n\n" nil t)
3026 (goto-char (point-max))
3029 (defun article-strip-multiple-blank-lines ()
3030 "Replace consecutive blank lines with one empty line."
3033 (let ((inhibit-point-motion-hooks t)
3034 (inhibit-read-only t))
3035 ;; First make all blank lines empty.
3037 (while (re-search-forward "^[ \t]+$" nil t)
3038 (unless (gnus-annotation-in-region-p
3039 (match-beginning 0) (match-end 0))
3040 (replace-match "" nil t)))
3041 ;; Then replace multiple empty lines with a single empty line.
3043 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
3044 (unless (gnus-annotation-in-region-p
3045 (match-beginning 0) (match-end 0))
3046 (delete-region (match-beginning 1) (match-end 1)))))))
3048 (defun article-strip-leading-space ()
3049 "Remove all white space from the beginning 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-trailing-space ()
3059 "Remove all white space from the end of the lines in the article."
3062 (let ((inhibit-point-motion-hooks t)
3063 (inhibit-read-only t))
3065 (while (re-search-forward "[ \t]+$" nil t)
3066 (replace-match "" t t)))))
3068 (defun article-strip-blank-lines ()
3069 "Strip leading, trailing and multiple blank lines."
3071 (article-strip-leading-blank-lines)
3072 (article-remove-trailing-blank-lines)
3073 (article-strip-multiple-blank-lines))
3075 (defun article-strip-all-blank-lines ()
3076 "Strip all blank lines."
3079 (let ((inhibit-point-motion-hooks t)
3080 (inhibit-read-only t))
3082 (while (re-search-forward "^[ \t]*\n" nil t)
3083 (replace-match "" t t)))))
3085 (defun gnus-article-narrow-to-signature ()
3086 "Narrow to the signature; return t if a signature is found, else nil."
3087 (let ((inhibit-point-motion-hooks t))
3088 (when (gnus-article-search-signature)
3090 ;; Check whether we have some limits to what we consider
3091 ;; to be a signature.
3092 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
3093 (list gnus-signature-limit)))
3095 (while (setq limit (pop limits))
3096 (if (or (and (integerp limit)
3097 (< (- (point-max) (point)) limit))
3099 (< (count-lines (point) (point-max)) limit))
3100 (and (functionp limit)
3102 (and (stringp limit)
3103 (not (re-search-forward limit nil t))))
3104 () ; This limit did not succeed.
3108 (narrow-to-region (point) (point-max))
3111 (defun gnus-article-search-signature ()
3112 "Search the current buffer for the signature separator.
3113 Put point at the beginning of the signature separator."
3114 (let ((cur (point)))
3115 (goto-char (point-max))
3116 (if (if (stringp gnus-signature-separator)
3117 (re-search-backward gnus-signature-separator nil t)
3118 (let ((seps gnus-signature-separator))
3120 (not (re-search-backward (car seps) nil t)))
3127 (defun gnus-article-hidden-arg ()
3128 "Return the current prefix arg as a number, or 0 if no prefix."
3129 (list (if current-prefix-arg
3130 (prefix-numeric-value current-prefix-arg)
3133 (defun gnus-article-check-hidden-text (type arg)
3134 "Return nil if hiding is necessary.
3135 Arg can be nil or a number. nil and positive means hide, negative
3136 means show, 0 means toggle."
3139 (let ((hide (gnus-article-hidden-text-p type)))
3145 (gnus-article-show-hidden-text type)
3148 (if (eq hide 'hidden)
3150 (gnus-article-show-hidden-text type)
3154 (defun gnus-article-hidden-text-p (type)
3155 "Say whether the current buffer contains hidden text of type TYPE."
3156 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
3158 (not (get-text-property pos 'invisible))
3159 (not (get-text-property pos 'dummy-invisible)))
3161 (text-property-any (1+ pos) (point-max) 'article-type type)))
3166 (defun gnus-article-show-hidden-text (type &optional dummy)
3167 "Show all hidden text of type TYPE.
3168 Originally it is hide instead of DUMMY."
3169 (let ((inhibit-read-only t)
3170 (inhibit-point-motion-hooks t))
3171 (gnus-remove-text-properties-when
3173 (point-min) (point-max)
3174 (cons 'article-type (cons type
3175 gnus-hidden-properties)))
3176 (gnus-delete-wash-type type)))
3178 (defconst article-time-units
3179 `((year . ,(* 365.25 24 60 60))
3180 (week . ,(* 7 24 60 60))
3181 (day . ,(* 24 60 60))
3185 "Mapping from time units to seconds.")
3187 (defun gnus-article-forward-header ()
3188 "Move point to the start of the next header.
3189 If the current header is a continuation header, this can be several
3194 (if (looking-at "[ \t]+[^ \t]")
3198 (defun article-date-ut (&optional type highlight)
3199 "Convert DATE date to universal time in the current article.
3200 If TYPE is `local', convert to local time; if it is `lapsed', output
3201 how much time has lapsed since DATE. For `lapsed', the value of
3202 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
3203 should replace the \"Date:\" one, or should be added below it."
3204 (interactive (list 'ut t))
3205 (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
3206 (date-regexp (cond ((not gnus-article-date-lapsed-new-header)
3210 (article-lapsed-timer
3214 (case-fold-search t)
3215 (inhibit-read-only t)
3216 (inhibit-point-motion-hooks t)
3217 pos date bface eface)
3221 (goto-char (point-min))
3222 (while (or (setq date (get-text-property (setq pos (point))
3224 (when (setq pos (next-single-property-change
3225 (point) 'original-date))
3226 (setq date (get-text-property pos 'original-date))
3228 (narrow-to-region pos (or (text-property-any pos (point-max)
3231 (goto-char (point-min))
3232 (when (re-search-forward tdate-regexp nil t)
3233 (setq bface (get-text-property (point-at-bol) 'face)
3234 eface (get-text-property (1- (point-at-eol)) 'face)))
3235 (goto-char (point-min))
3237 ;; Delete any old Date headers.
3238 (while (re-search-forward date-regexp nil t)
3240 (delete-region (point-at-bol) (progn
3241 (gnus-article-forward-header)
3243 (delete-region (point-at-bol) (progn
3244 (gnus-article-forward-header)
3247 (setq pos (point))))
3248 (when (and (not pos)
3249 (re-search-forward tdate-regexp nil t))
3251 (gnus-goto-char pos)
3252 (insert (article-make-date-line date (or type 'ut)))
3258 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
3259 (put-text-property (match-beginning 1) (1+ (match-end 1))
3261 (put-text-property (match-beginning 2) (match-end 2)
3263 (put-text-property (point-min) (1- (point-max)) 'original-date date)
3264 (goto-char (point-max))
3267 (defun article-make-date-line (date type)
3268 "Return a DATE line of TYPE."
3269 (unless (memq type '(local ut original user iso8601 lapsed english))
3270 (error "Unknown conversion type: %s" type))
3272 (let ((time (date-to-time date)))
3274 ;; Convert to the local timezone.
3276 (concat "Date: " (message-make-date time)))
3277 ;; Convert to Universal Time.
3282 (let* ((e (parse-time-string date))
3283 (tm (apply 'encode-time e))
3285 (ls (- (cadr tm) (car (current-time-zone time)))))
3286 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
3287 ((> ls 65535) (list (1+ ms) (- ls 65536)))
3291 ;; Get the original date from the article.
3292 ((eq type 'original)
3293 (concat "Date: " (if (string-match "\n+$" date)
3294 (substring date 0 (match-beginning 0))
3296 ;; Let the user define the format.
3298 (let ((format (or (condition-case nil
3299 (with-current-buffer gnus-summary-buffer
3300 gnus-article-time-format)
3302 gnus-article-time-format)))
3303 (if (functionp format)
3304 (funcall format time)
3305 (concat "Date: " (format-time-string format time)))))
3308 (let ((tz (car (current-time-zone time))))
3311 (format-time-string "%Y%m%dT%H%M%S" time)
3312 (format "%s%02d%02d"
3313 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3314 (/ (% (abs tz) 3600) 60)))))
3315 ;; Do an X-Sent lapsed format.
3317 ;; If the date is seriously mangled, the timezone functions are
3318 ;; liable to bug out, so we ignore all errors.
3319 (let* ((now (current-time))
3320 (real-time (subtract-time now time))
3321 (real-sec (and real-time
3322 (+ (* (float (car real-time)) 65536)
3324 (sec (and real-time (abs real-sec)))
3334 ;; This is a bit convoluted, but basically we go
3335 ;; through the time units for years, weeks, etc,
3336 ;; and divide things to see whether that results
3337 ;; in positive answers.
3340 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3341 ;; The (remaining) seconds are too few to
3342 ;; be divided into this time unit.
3344 ;; It's big enough, so we output it.
3345 (setq sec (- sec (* num (cdr unit))))
3347 (concat (if prev ", " "") (int-to-string
3349 " " (symbol-name (car unit))
3350 (if (> num 1) "s" ""))
3352 article-time-units "")
3353 ;; If dates are odd, then it might appear like the
3354 ;; article was sent in the future.
3357 " in the future"))))))
3358 ;; Display the date in proper English
3360 (let ((dtime (decode-time time)))
3363 (number-to-string (nth 3 dtime))
3364 (let ((digit (% (nth 3 dtime) 10)))
3366 ((memq (nth 3 dtime) '(11 12 13)) "th")
3372 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3374 (number-to-string (nth 5 dtime))
3376 (format "%02d" (nth 2 dtime))
3378 (format "%02d" (nth 1 dtime)))))))
3380 (format "Date: %s (from Gnus)" date))))
3382 (defun article-date-local (&optional highlight)
3383 "Convert the current article date to the local timezone."
3384 (interactive (list t))
3385 (article-date-ut 'local highlight))
3387 (defun article-date-english (&optional highlight)
3388 "Convert the current article date to something that is proper English."
3389 (interactive (list t))
3390 (article-date-ut 'english highlight))
3392 (defun article-date-original (&optional highlight)
3393 "Convert the current article date to what it was originally.
3394 This is only useful if you have used some other date conversion
3395 function and want to see what the date was before converting."
3396 (interactive (list t))
3397 (article-date-ut 'original highlight))
3399 (defun article-date-lapsed (&optional highlight)
3400 "Convert the current article date to time lapsed since it was sent."
3401 (interactive (list t))
3402 (article-date-ut 'lapsed highlight))
3404 (defun article-update-date-lapsed ()
3405 "Function to be run from a timer to update the lapsed time line."
3407 (let (deactivate-mark)
3412 (set-buffer (window-buffer w))
3413 (when (eq major-mode 'gnus-article-mode)
3414 (let ((mark (point-marker)))
3415 (goto-char (point-min))
3416 (when (re-search-forward "^X-Sent:" nil t)
3417 (article-date-lapsed t))
3418 (goto-char (marker-position mark))
3419 (move-marker mark nil))))
3422 (defun gnus-start-date-timer (&optional n)
3423 "Start a timer to update the X-Sent header in the article buffers.
3424 The numerical prefix says how frequently (in seconds) the function
3429 (gnus-stop-date-timer)
3430 (setq article-lapsed-timer
3431 (run-at-time 1 n 'article-update-date-lapsed)))
3433 (defun gnus-stop-date-timer ()
3434 "Stop the X-Sent timer."
3436 (when article-lapsed-timer
3437 (nnheader-cancel-timer article-lapsed-timer)
3438 (setq article-lapsed-timer nil)))
3440 (defun article-date-user (&optional highlight)
3441 "Convert the current article date to the user-defined format.
3442 This format is defined by the `gnus-article-time-format' variable."
3443 (interactive (list t))
3444 (article-date-ut 'user highlight))
3446 (defun article-date-iso8601 (&optional highlight)
3447 "Convert the current article date to ISO8601."
3448 (interactive (list t))
3449 (article-date-ut 'iso8601 highlight))
3451 (defmacro gnus-article-save-original-date (&rest forms)
3452 "Save the original date as a text property and evaluate FORMS."
3453 `(let* ((case-fold-search t)
3455 (goto-char (point-min))
3456 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3459 (date (when (and start
3460 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3462 (buffer-substring-no-properties start
3463 (match-beginning 0)))))
3464 (goto-char (point-max))
3465 (skip-chars-backward "\n")
3466 (put-text-property (point-min) (point) 'original-date date)
3468 (goto-char (point-max))
3469 (skip-chars-backward "\n")
3470 (put-text-property (point-min) (point) 'original-date date)))
3472 ;; (defun article-show-all ()
3473 ;; "Show all hidden text in the article buffer."
3476 ;; (let ((inhibit-read-only t))
3477 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3479 (defun article-remove-leading-whitespace ()
3480 "Remove excessive whitespace from all headers."
3484 (let ((inhibit-read-only t))
3485 (article-narrow-to-head)
3486 (goto-char (point-min))
3487 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3488 (delete-region (match-beginning 1) (match-end 1)))))))
3490 (defun article-emphasize (&optional arg)
3491 "Emphasize text according to `gnus-emphasis-alist'."
3492 (interactive (gnus-article-hidden-arg))
3493 (unless (gnus-article-check-hidden-text 'emphasis arg)
3497 (with-current-buffer gnus-summary-buffer
3498 gnus-article-emphasis-alist)
3500 gnus-emphasis-alist))
3501 (inhibit-read-only t)
3502 (props (append '(article-type emphasis)
3503 gnus-hidden-properties))
3504 regexp elem beg invisible visible face)
3507 (while (setq elem (pop alist))
3509 (setq regexp (car elem)
3510 invisible (nth 1 elem)
3511 visible (nth 2 elem)
3513 (while (re-search-forward regexp nil t)
3514 (when (and (match-beginning visible) (match-beginning invisible))
3515 (gnus-article-hide-text
3516 (match-beginning invisible) (match-end invisible) props)
3517 (gnus-article-unhide-text-type
3518 (match-beginning visible) (match-end visible) 'emphasis)
3519 (gnus-put-overlay-excluding-newlines
3520 (match-beginning visible) (match-end visible) 'face face)
3521 (gnus-add-wash-type 'emphasis)
3522 (goto-char (match-end invisible)))))))))
3524 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3525 "Setup newsgroup emphasis alist."
3526 (unless gnus-article-emphasis-alist
3527 (let ((name (and gnus-newsgroup-name
3528 (gnus-group-real-name gnus-newsgroup-name))))
3529 (make-local-variable 'gnus-article-emphasis-alist)
3530 (setq gnus-article-emphasis-alist
3532 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3533 (while (setq elem (pop alist))
3534 (when (and name (string-match (car elem) name))
3536 highlight (copy-sequence (cdr elem)))))
3538 (copy-sequence highlight-words)
3539 (if gnus-newsgroup-name
3540 (copy-sequence (gnus-group-find-parameter
3541 gnus-newsgroup-name 'highlight-words t)))
3542 gnus-emphasis-alist)))))
3545 (defvar gnus-summary-article-menu)
3546 (defvar gnus-summary-post-menu))
3548 ;;; Saving functions.
3550 (defun gnus-article-save (save-buffer file &optional num)
3551 "Save the currently selected article."
3552 (when (or (get gnus-default-article-saver :headers)
3553 (not gnus-save-all-headers))
3554 ;; Remove headers according to `gnus-saved-headers' or the value
3555 ;; of the `:headers' property that the saver function might have.
3556 (let ((gnus-visible-headers
3557 (or (symbol-value (get gnus-default-article-saver :headers))
3558 gnus-saved-headers gnus-visible-headers))
3559 (gnus-article-buffer save-buffer))
3561 (set-buffer save-buffer)
3562 (article-hide-headers 1 t))))
3563 (save-window-excursion
3564 (if (not gnus-default-article-saver)
3565 (error "No default saver is defined")
3566 ;; !!! Magic! The saving functions all save
3567 ;; `gnus-save-article-buffer' (or so they think), but we
3568 ;; bind that variable to our save-buffer.
3569 (set-buffer gnus-article-buffer)
3570 (let* ((gnus-save-article-buffer save-buffer)
3573 ((not gnus-prompt-before-saving) 'default)
3574 ((eq gnus-prompt-before-saving 'always) nil)
3576 (gnus-number-of-articles-to-be-saved
3577 (when (eq gnus-prompt-before-saving t)
3579 (set-buffer gnus-article-current-summary)
3580 (funcall gnus-default-article-saver filename)))))
3582 (defun gnus-read-save-file-name (prompt &optional filename
3583 function group headers variable
3586 (funcall function group headers (symbol-value variable)))
3591 ((eq filename 'default)
3597 (when (symbol-value dir-var)
3598 (setq default-name (expand-file-name
3599 (file-name-nondirectory default-name)
3600 (symbol-value dir-var))))
3601 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3604 (if (and gnus-number-of-articles-to-be-saved
3605 (> gnus-number-of-articles-to-be-saved 1))
3606 (format "these %d articles"
3607 gnus-number-of-articles-to-be-saved)
3610 ;; Let the split methods have their say.
3612 ;; No split name was found.
3615 (concat prompt " (default "
3616 (file-name-nondirectory default-name) "): ")
3617 (file-name-directory default-name)
3619 ;; A single group name is returned.
3620 ((stringp split-name)
3622 (funcall function split-name headers
3623 (symbol-value variable)))
3625 (concat prompt " (default "
3626 (file-name-nondirectory default-name) "): ")
3627 (file-name-directory default-name)
3629 ;; A single split name was found
3630 ((= 1 (length split-name))
3631 (let* ((name (expand-file-name
3633 gnus-article-save-directory))
3634 (dir (cond ((file-directory-p name)
3635 (file-name-as-directory name))
3636 ((file-exists-p name) name)
3637 (t gnus-article-save-directory))))
3639 (concat prompt " (default " name "): ")
3641 ;; A list of splits was found.
3643 (setq split-name (nreverse split-name))
3645 (let ((file-name-history
3646 (nconc split-name file-name-history)))
3650 (concat prompt " (`M-p' for defaults): ")
3651 gnus-article-save-directory
3653 gnus-article-save-directory)))
3654 (car (push result file-name-history)))))))
3655 ;; Create the directory.
3656 (gnus-make-directory (file-name-directory file))
3657 ;; If we have read a directory, we append the default file name.
3658 (when (file-directory-p file)
3659 (setq file (expand-file-name (file-name-nondirectory
3661 (file-name-as-directory file))))
3662 ;; Possibly translate some characters.
3663 (nnheader-translate-file-chars file))))))
3664 (gnus-make-directory (file-name-directory result))
3666 (set variable result))
3668 (set dir-var (file-name-directory result)))
3671 (defun gnus-article-archive-name (group)
3672 "Return the first instance of an \"Archive-name\" in the current buffer."
3673 (let ((case-fold-search t))
3674 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3675 (nnheader-concat gnus-article-save-directory
3676 (match-string 1)))))
3678 (defun gnus-article-nndoc-name (group)
3679 "If GROUP is an nndoc group, return the name of the parent group."
3680 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3681 (gnus-group-get-parameter group 'save-article-group)))
3683 (defun gnus-summary-save-in-rmail (&optional filename)
3684 "Append this article to Rmail file.
3685 Optional argument FILENAME specifies file name.
3686 Directory to save to is default to `gnus-article-save-directory'."
3687 (setq filename (gnus-read-save-file-name
3688 "Save %s in rmail file" filename
3689 gnus-rmail-save-name gnus-newsgroup-name
3690 gnus-current-headers 'gnus-newsgroup-last-rmail))
3691 (gnus-eval-in-buffer-window gnus-save-article-buffer
3695 (gnus-output-to-rmail filename))))
3698 (defun gnus-summary-save-in-mail (&optional filename)
3699 "Append this article to Unix mail file.
3700 Optional argument FILENAME specifies file name.
3701 Directory to save to is default to `gnus-article-save-directory'."
3702 (setq filename (gnus-read-save-file-name
3703 "Save %s in Unix mail file" filename
3704 gnus-mail-save-name gnus-newsgroup-name
3705 gnus-current-headers 'gnus-newsgroup-last-mail))
3706 (gnus-eval-in-buffer-window gnus-save-article-buffer
3710 (if (and (file-readable-p filename)
3711 (file-regular-p filename)
3712 (mail-file-babyl-p filename))
3713 (rmail-output-to-rmail-file filename t)
3714 (gnus-output-to-mail filename)))))
3717 (put 'gnus-summary-save-in-file :decode t)
3718 (put 'gnus-summary-save-in-file :headers 'gnus-saved-headers)
3719 (defun gnus-summary-save-in-file (&optional filename overwrite)
3720 "Append this article to file.
3721 Optional argument FILENAME specifies file name.
3722 Directory to save to is default to `gnus-article-save-directory'."
3723 (setq filename (gnus-read-save-file-name
3724 "Save %s in file" filename
3725 gnus-file-save-name gnus-newsgroup-name
3726 gnus-current-headers 'gnus-newsgroup-last-file))
3727 (gnus-eval-in-buffer-window gnus-save-article-buffer
3731 (when (and overwrite
3732 (file-exists-p filename))
3733 (delete-file filename))
3734 (gnus-output-to-file filename))))
3737 (put 'gnus-summary-write-to-file :decode t)
3738 (put 'gnus-summary-write-to-file :function 'gnus-summary-save-in-file)
3739 (put 'gnus-summary-write-to-file :headers 'gnus-saved-headers)
3740 (defun gnus-summary-write-to-file (&optional filename)
3741 "Write this article to a file, overwriting it if the file exists.
3742 Optional argument FILENAME specifies file name.
3743 The directory to save in defaults to `gnus-article-save-directory'."
3744 (setq filename (gnus-read-save-file-name
3745 "Save %s in file" filename
3746 gnus-file-save-name gnus-newsgroup-name
3747 gnus-current-headers nil 'gnus-newsgroup-last-directory))
3748 (gnus-summary-save-in-file filename t))
3750 (put 'gnus-summary-save-body-in-file :decode t)
3751 (defun gnus-summary-save-body-in-file (&optional filename overwrite)
3752 "Append this article body to a file.
3753 Optional argument FILENAME specifies file name.
3754 The directory to save in defaults to `gnus-article-save-directory'."
3755 (setq filename (gnus-read-save-file-name
3756 "Save %s body in file" filename
3757 gnus-file-save-name gnus-newsgroup-name
3758 gnus-current-headers 'gnus-newsgroup-last-file))
3759 (gnus-eval-in-buffer-window gnus-save-article-buffer
3763 (when (article-goto-body)
3764 (narrow-to-region (point) (point-max)))
3765 (when (and overwrite
3766 (file-exists-p filename))
3767 (delete-file filename))
3768 (gnus-output-to-file filename))))
3771 (put 'gnus-summary-write-body-to-file :decode t)
3772 (put 'gnus-summary-write-body-to-file
3773 :function 'gnus-summary-save-body-in-file)
3774 (defun gnus-summary-write-body-to-file (&optional filename)
3775 "Write this article body to a file, overwriting it if the file exists.
3776 Optional argument FILENAME specifies file name.
3777 The directory to save in defaults to `gnus-article-save-directory'."
3778 (setq filename (gnus-read-save-file-name
3779 "Save %s body in file" filename
3780 gnus-file-save-name gnus-newsgroup-name
3781 gnus-current-headers nil 'gnus-newsgroup-last-directory))
3782 (gnus-summary-save-body-in-file filename t))
3784 (defun gnus-summary-save-in-pipe (&optional command)
3785 "Pipe this article to subprocess."
3787 (cond ((and (eq command 'default)
3788 gnus-last-shell-command)
3789 gnus-last-shell-command)
3794 "Shell command on %s: "
3795 (if (and gnus-number-of-articles-to-be-saved
3796 (> gnus-number-of-articles-to-be-saved 1))
3797 (format "these %d articles"
3798 gnus-number-of-articles-to-be-saved)
3800 gnus-last-shell-command))))
3801 (when (string-equal command "")
3802 (if gnus-last-shell-command
3803 (setq command gnus-last-shell-command)
3804 (error "A command is required")))
3805 (gnus-eval-in-buffer-window gnus-article-buffer
3808 (shell-command-on-region (point-min) (point-max) command nil)))
3809 (setq gnus-last-shell-command command))
3811 (defun gnus-summary-pipe-to-muttprint (&optional command)
3812 "Pipe this article to muttprint."
3813 (setq command (read-string
3814 "Print using command: " gnus-summary-muttprint-program
3815 nil gnus-summary-muttprint-program))
3816 (gnus-summary-save-in-pipe command))
3818 ;;; Article file names when saving.
3820 (defun gnus-capitalize-newsgroup (newsgroup)
3821 "Capitalize NEWSGROUP name."
3822 (when (not (zerop (length newsgroup)))
3823 (concat (char-to-string (upcase (aref newsgroup 0)))
3824 (substring newsgroup 1))))
3826 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3827 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3828 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3829 Otherwise, it is like ~/News/news/group/num."
3832 (concat (if (gnus-use-long-file-name 'not-save)
3833 (gnus-capitalize-newsgroup newsgroup)
3834 (gnus-newsgroup-directory-form newsgroup))
3835 "/" (int-to-string (mail-header-number headers)))
3836 gnus-article-save-directory)))
3838 (string-equal (file-name-directory default)
3839 (file-name-directory last-file))
3840 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3842 (or last-file default))))
3844 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3845 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3846 If variable `gnus-use-long-file-name' is non-nil, it is
3847 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3850 (concat (if (gnus-use-long-file-name 'not-save)
3852 (gnus-newsgroup-directory-form newsgroup))
3853 "/" (int-to-string (mail-header-number headers)))
3854 gnus-article-save-directory)))
3856 (string-equal (file-name-directory default)
3857 (file-name-directory last-file))
3858 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3860 (or last-file default))))
3862 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3863 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3864 If variable `gnus-use-long-file-name' is non-nil, it is
3865 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3868 (if (gnus-use-long-file-name 'not-save)
3871 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3873 gnus-article-save-directory)))
3875 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3876 "Generate file name from sender."
3877 (let ((from (mail-header-from headers)))
3879 (if (and from (string-match "\\([^ <]+\\)@" from))
3880 (match-string 1 from)
3882 gnus-article-save-directory)))
3884 (defun article-verify-x-pgp-sig ()
3887 (if (gnus-buffer-live-p gnus-original-article-buffer)
3888 (let ((sig (with-current-buffer gnus-original-article-buffer
3889 (gnus-fetch-field "X-PGP-Sig")))
3893 (mml2015-clear-verify-function))
3895 (insert-buffer-substring gnus-original-article-buffer)
3896 (setq items (split-string sig))
3897 (message-narrow-to-head)
3898 (let ((inhibit-point-motion-hooks t)
3899 (case-fold-search t))
3900 ;; Don't verify multiple headers.
3901 (setq headers (mapconcat (lambda (header)
3903 (mail-fetch-field header)
3905 (split-string (nth 1 items) ",") "")))
3906 (delete-region (point-min) (point-max))
3907 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3908 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3913 (if (looking-at "^-")
3916 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3917 (insert "Version: " (car items) "\n\n")
3918 (insert (mapconcat 'identity (cddr items) "\n"))
3919 (insert "\n-----END PGP SIGNATURE-----\n")
3920 (let ((mm-security-handle (list (format "multipart/signed"))))
3921 (mml2015-clean-buffer)
3922 (let ((coding-system-for-write (or gnus-newsgroup-charset
3924 (funcall (mml2015-clear-verify-function)))
3926 (or (mm-handle-multipart-ctl-parameter
3927 mm-security-handle 'gnus-details)
3928 (mm-handle-multipart-ctl-parameter
3929 mm-security-handle 'gnus-info)))))
3931 (let ((inhibit-read-only t) bface eface)
3933 (message-narrow-to-head)
3934 (goto-char (point-max))
3936 (setq bface (get-text-property (point-at-bol) 'face)
3937 eface (get-text-property (1- (point-at-eol)) 'face))
3938 (message-remove-header "X-Gnus-PGP-Verify")
3939 (if (re-search-forward "^X-PGP-Sig:" nil t)
3941 (goto-char (point-max)))
3942 (narrow-to-region (point) (point))
3943 (insert "X-Gnus-PGP-Verify: " info "\n")
3944 (goto-char (point-min))
3947 (if (not (looking-at "^[ \t]"))
3951 (goto-char (point-min))
3952 (when (looking-at "\\([^:]+\\): *")
3953 (put-text-property (match-beginning 1) (1+ (match-end 1))
3955 (put-text-property (match-end 0) (point-max)
3956 'face eface)))))))))
3958 (defun article-verify-cancel-lock ()
3959 "Verify Cancel-Lock header."
3961 (if (gnus-buffer-live-p gnus-original-article-buffer)
3962 (canlock-verify gnus-original-article-buffer)))
3969 (setq afunc (car func)
3972 gfunc (intern (format "gnus-%s" func))))
3974 (when (fboundp afunc)
3975 `(lambda (&optional interactive &rest args)
3976 ,(documentation afunc t)
3977 (interactive (list t))
3979 (set-buffer gnus-article-buffer)
3981 (call-interactively ',afunc)
3982 (apply ',afunc args))))))))
3983 '(article-hide-headers
3984 article-verify-x-pgp-sig
3985 article-verify-cancel-lock
3986 article-hide-boring-headers
3987 article-treat-overstrike
3988 article-treat-ansi-sequences
3989 article-fill-long-lines
3990 article-capitalize-sentences
3992 article-remove-leading-whitespace
3993 article-display-x-face
3994 article-display-face
3995 article-de-quoted-unreadable
3996 article-de-base64-unreadable
3999 article-unsplit-urls
4000 article-hide-list-identifiers
4001 article-strip-banner
4004 article-hide-signature
4005 article-strip-headers-in-body
4006 article-remove-trailing-blank-lines
4007 article-strip-leading-blank-lines
4008 article-strip-multiple-blank-lines
4009 article-strip-leading-space
4010 article-strip-trailing-space
4011 article-strip-blank-lines
4012 article-strip-all-blank-lines
4014 article-date-english
4015 article-date-iso8601
4016 article-date-original
4018 article-decode-mime-words
4019 article-decode-charset
4020 article-decode-encoded-words
4024 article-treat-dumbquotes
4025 article-normalize-headers
4026 ;; (article-show-all . gnus-article-show-all-headers)
4030 ;;; Gnus article mode
4033 (put 'gnus-article-mode 'mode-class 'special)
4035 (set-keymap-parent gnus-article-mode-map widget-keymap)
4037 (gnus-define-keys gnus-article-mode-map
4038 " " gnus-article-goto-next-page
4039 "\177" gnus-article-goto-prev-page
4040 [delete] gnus-article-goto-prev-page
4041 [backspace] gnus-article-goto-prev-page
4042 "\C-c^" gnus-article-refer-article
4043 "h" gnus-article-show-summary
4044 "s" gnus-article-show-summary
4045 "\C-c\C-m" gnus-article-mail
4046 "?" gnus-article-describe-briefly
4047 "e" gnus-summary-edit-article
4048 "<" beginning-of-buffer
4050 "\C-c\C-i" gnus-info-find-node
4052 "R" gnus-article-reply-with-original
4053 "F" gnus-article-followup-with-original
4054 "\C-hk" gnus-article-describe-key
4055 "\C-hc" gnus-article-describe-key-briefly
4057 "\C-d" gnus-article-read-summary-keys
4058 "\M-*" gnus-article-read-summary-keys
4059 "\M-#" gnus-article-read-summary-keys
4060 "\M-^" gnus-article-read-summary-keys
4061 "\M-g" gnus-article-read-summary-keys)
4063 (substitute-key-definition
4064 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
4066 (defun gnus-article-make-menu-bar ()
4067 (unless (boundp 'gnus-article-commands-menu)
4068 (gnus-summary-make-menu-bar))
4069 (gnus-turn-off-edit-menu 'article)
4070 (unless (boundp 'gnus-article-article-menu)
4072 gnus-article-article-menu gnus-article-mode-map ""
4074 ["Scroll forwards" gnus-article-goto-next-page t]
4075 ["Scroll backwards" gnus-article-goto-prev-page t]
4076 ["Show summary" gnus-article-show-summary t]
4077 ["Fetch Message-ID at point" gnus-article-refer-article t]
4078 ["Mail to address at point" gnus-article-mail t]
4079 ["Send a bug report" gnus-bug t]))
4082 gnus-article-treatment-menu gnus-article-mode-map ""
4083 ;; Fixme: this should use :active (and maybe :visible).
4085 ["Hide headers" gnus-article-hide-headers t]
4086 ["Hide signature" gnus-article-hide-signature t]
4087 ["Hide citation" gnus-article-hide-citation t]
4088 ["Treat overstrike" gnus-article-treat-overstrike t]
4089 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
4090 ["Remove carriage return" gnus-article-remove-cr t]
4091 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
4092 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
4093 ["Remove base64" gnus-article-de-base64-unreadable t]
4094 ["Treat html" gnus-article-wash-html t]
4095 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
4096 ["Decode HZ" gnus-article-decode-HZ t]))
4098 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
4100 ;; Note "Post" menu is defined in gnus-sum.el for consistency
4102 (gnus-run-hooks 'gnus-article-menu-hook)))
4104 (defun gnus-article-mode ()
4105 "Major mode for displaying an article.
4107 All normal editing commands are switched off.
4109 The following commands are available in addition to all summary mode
4111 \\<gnus-article-mode-map>
4112 \\[gnus-article-next-page]\t Scroll the article one page forwards
4113 \\[gnus-article-prev-page]\t Scroll the article one page backwards
4114 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
4115 \\[gnus-article-show-summary]\t Display the summary buffer
4116 \\[gnus-article-mail]\t Send a reply to the address near point
4117 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
4118 \\[gnus-info-find-node]\t Go to the Gnus info node"
4120 (kill-all-local-variables)
4121 (gnus-simplify-mode-line)
4122 (setq mode-name "Article")
4123 (setq major-mode 'gnus-article-mode)
4124 (make-local-variable 'minor-mode-alist)
4125 (use-local-map gnus-article-mode-map)
4126 (when (gnus-visual-p 'article-menu 'menu)
4127 (gnus-article-make-menu-bar)
4128 (when gnus-summary-tool-bar-map
4129 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
4130 (gnus-update-format-specifications nil 'article-mode)
4131 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
4132 (set (make-local-variable 'gnus-page-broken) nil)
4133 (make-local-variable 'gnus-button-marker-list)
4134 (make-local-variable 'gnus-article-current-summary)
4135 (make-local-variable 'gnus-article-mime-handles)
4136 (make-local-variable 'gnus-article-decoded-p)
4137 (make-local-variable 'gnus-article-mime-handle-alist)
4138 (make-local-variable 'gnus-article-wash-types)
4139 (make-local-variable 'gnus-article-image-alist)
4140 (make-local-variable 'gnus-article-charset)
4141 (make-local-variable 'gnus-article-ignored-charsets)
4142 ;; Prevent recent Emacsen from displaying non-break space as "\ ".
4143 (set (make-local-variable 'nobreak-char-display) nil)
4144 (setq cursor-in-non-selected-windows nil)
4145 (setq truncate-lines gnus-article-truncate-lines)
4146 (gnus-set-default-directory)
4147 (buffer-disable-undo)
4148 (setq buffer-read-only t
4149 show-trailing-whitespace nil)
4150 (set-syntax-table gnus-article-mode-syntax-table)
4151 (mm-enable-multibyte)
4152 (gnus-run-mode-hooks 'gnus-article-mode-hook))
4154 (defvar gnus-button-marker-list nil
4155 "Regexp matching any of the regexps from `gnus-button-alist'.
4156 Internal variable.")
4158 (defun gnus-article-setup-buffer ()
4159 "Initialize the article buffer."
4160 (let* ((name (if gnus-single-article-buffer "*Article*"
4161 (concat "*Article " gnus-newsgroup-name "*")))
4163 (progn (string-match "\\*Article" name)
4164 (concat " *Original Article"
4165 (substring name (match-end 0))))))
4166 (setq gnus-article-buffer name)
4167 (setq gnus-original-article-buffer original)
4168 (setq gnus-article-mime-handle-alist nil)
4169 (with-current-buffer gnus-summary-buffer
4170 ;; This might be a variable local to the summary buffer.
4171 (unless gnus-single-article-buffer
4172 (setq gnus-article-buffer name)
4173 (setq gnus-original-article-buffer original)
4174 (gnus-set-global-variables)))
4175 (gnus-article-setup-highlight-words)
4176 ;; Init original article buffer.
4178 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
4179 (mm-enable-multibyte)
4180 (setq major-mode 'gnus-original-article-mode)
4181 (make-local-variable 'gnus-original-article))
4182 (if (and (get-buffer name)
4183 (with-current-buffer name
4184 (if gnus-article-edit-mode
4185 (if (y-or-n-p "Article mode edit in progress; discard? ")
4187 (set-buffer-modified-p nil)
4188 (gnus-kill-buffer name)
4191 (error "Action aborted"))
4195 (set (make-local-variable 'gnus-article-edit-mode) nil)
4196 (when gnus-article-mime-handles
4197 (mm-destroy-parts gnus-article-mime-handles)
4198 (setq gnus-article-mime-handles nil))
4199 ;; Set it to nil in article-buffer!
4200 (setq gnus-article-mime-handle-alist nil)
4201 (buffer-disable-undo)
4202 (setq buffer-read-only t)
4203 ;; This list just keeps growing if we don't reset it.
4204 (setq gnus-button-marker-list nil)
4205 (unless (eq major-mode 'gnus-article-mode)
4206 (gnus-article-mode))
4209 (set-buffer (gnus-get-buffer-create name))
4211 (make-local-variable 'gnus-summary-buffer)
4212 (gnus-summary-set-local-parameters gnus-newsgroup-name)
4213 (current-buffer)))))
4215 ;; Set article window start at LINE, where LINE is the number of lines
4216 ;; from the head of the article.
4217 (defun gnus-article-set-window-start (&optional line)
4219 (gnus-get-buffer-window gnus-article-buffer t)
4221 (set-buffer gnus-article-buffer)
4222 (goto-char (point-min))
4225 (gnus-message 6 "Moved to bookmark")
4226 (search-forward "\n\n" nil t)
4230 (defun gnus-article-prepare (article &optional all-headers header)
4231 "Prepare ARTICLE in article mode buffer.
4232 ARTICLE should either be an article number or a Message-ID.
4233 If ARTICLE is an id, HEADER should be the article headers.
4234 If ALL-HEADERS is non-nil, no headers are hidden."
4236 ;; Make sure we start in a summary buffer.
4237 (unless (eq major-mode 'gnus-summary-mode)
4238 (set-buffer gnus-summary-buffer))
4239 (setq gnus-summary-buffer (current-buffer))
4240 (let* ((gnus-article (if header (mail-header-number header) article))
4241 (summary-buffer (current-buffer))
4242 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4243 (group gnus-newsgroup-name)
4246 (gnus-article-setup-buffer)
4247 (set-buffer gnus-article-buffer)
4248 ;; Deactivate active regions.
4249 (when (and (boundp 'transient-mark-mode)
4250 transient-mark-mode)
4251 (setq mark-active nil))
4252 (if (not (setq result (let ((inhibit-read-only t))
4253 (gnus-request-article-this-buffer
4255 ;; There is no such article.
4257 (when (and (numberp article)
4258 (not (memq article gnus-newsgroup-sparse)))
4259 (setq gnus-article-current
4260 (cons gnus-newsgroup-name article))
4261 (set-buffer gnus-summary-buffer)
4262 (setq gnus-current-article article)
4263 (if (and (memq article gnus-newsgroup-undownloaded)
4264 (not (gnus-online (gnus-find-method-for-group
4265 gnus-newsgroup-name))))
4267 (gnus-summary-set-agent-mark article)
4268 (message "Message marked for downloading"))
4269 (gnus-summary-mark-article article gnus-canceled-mark)
4270 (unless (memq article gnus-newsgroup-sparse)
4271 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4272 (if (or (eq result 'pseudo)
4273 (eq result 'nneething))
4276 (set-buffer summary-buffer)
4277 (push article gnus-newsgroup-history)
4278 (setq gnus-last-article gnus-current-article
4279 gnus-current-article 0
4280 gnus-current-headers nil
4281 gnus-article-current nil)
4282 (if (eq result 'nneething)
4283 (gnus-configure-windows 'summary)
4284 (gnus-configure-windows 'article))
4285 (gnus-set-global-variables))
4286 (let ((gnus-article-mime-handle-alist-1
4287 gnus-article-mime-handle-alist))
4288 (gnus-set-mode-line 'article)))
4289 ;; The result from the `request' was an actual article -
4290 ;; or at least some text that is now displayed in the
4292 (when (and (numberp article)
4293 (not (eq article gnus-current-article)))
4294 ;; Seems like a new article has been selected.
4295 ;; `gnus-current-article' must be an article number.
4297 (set-buffer summary-buffer)
4298 (push article gnus-newsgroup-history)
4299 (setq gnus-last-article gnus-current-article
4300 gnus-current-article article
4301 gnus-current-headers
4302 (gnus-summary-article-header gnus-current-article)
4303 gnus-article-current
4304 (cons gnus-newsgroup-name gnus-current-article))
4305 (unless (vectorp gnus-current-headers)
4306 (setq gnus-current-headers nil))
4307 (gnus-summary-goto-subject gnus-current-article)
4308 (when (gnus-summary-show-thread)
4309 ;; If the summary buffer really was folded, the
4310 ;; previous goto may not actually have gone to
4311 ;; the right article, but the thread root instead.
4313 (gnus-summary-goto-subject gnus-current-article))
4314 (gnus-run-hooks 'gnus-mark-article-hook)
4315 (gnus-set-mode-line 'summary)
4316 (when (gnus-visual-p 'article-highlight 'highlight)
4317 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4318 ;; Set the global newsgroup variables here.
4319 (gnus-set-global-variables)
4320 (setq gnus-have-all-headers
4321 (or all-headers gnus-show-all-headers))))
4323 (gnus-configure-windows 'article))
4324 (when (or (numberp article)
4326 (gnus-article-prepare-display)
4328 (goto-char (point-min))
4329 (when gnus-break-pages
4330 (gnus-narrow-to-page)))
4331 (let ((gnus-article-mime-handle-alist-1
4332 gnus-article-mime-handle-alist))
4333 (gnus-set-mode-line 'article))
4337 (set-window-point (get-buffer-window (current-buffer)) (point))
4338 (gnus-configure-windows 'article)
4342 (defun gnus-article-prepare-display ()
4343 "Make the current buffer look like a nice article."
4344 ;; Hooks for getting information from the article.
4345 ;; This hook must be called before being narrowed.
4346 (let ((gnus-article-buffer (current-buffer))
4348 (inhibit-read-only t))
4349 (unless (eq major-mode 'gnus-article-mode)
4350 (gnus-article-mode))
4351 (setq buffer-read-only nil
4352 gnus-article-wash-types nil
4353 gnus-article-image-alist nil)
4354 (gnus-run-hooks 'gnus-tmp-internal-hook)
4355 (when gnus-display-mime-function
4356 (funcall gnus-display-mime-function))
4357 (gnus-run-hooks 'gnus-article-prepare-hook)))
4360 ;;; Gnus MIME viewing functions
4363 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4364 "Format of the MIME buttons.
4366 Valid specifiers include:
4368 %T MIME type, along with additional info
4369 %n The `name' parameter
4370 %d The description, if any
4371 %l The length of the encoded part
4372 %p The part identifier number
4373 %e Dots if the part isn't displayed
4375 General format specifiers can also be used. See Info node
4376 `(gnus)Formatting Variables'.")
4378 (defvar gnus-mime-button-line-format-alist
4379 '((?t gnus-tmp-type ?s)
4380 (?T gnus-tmp-type-long ?s)
4381 (?n gnus-tmp-name ?s)
4382 (?d gnus-tmp-description ?s)
4384 (?l gnus-tmp-length ?d)
4385 (?e gnus-tmp-dots ?s)))
4387 (defvar gnus-mime-button-commands
4388 '((gnus-article-press-button "\r" "Toggle Display")
4389 (gnus-mime-view-part "v" "View Interactively...")
4390 (gnus-mime-view-part-as-type "t" "View As Type...")
4391 (gnus-mime-view-part-as-charset "C" "View As charset...")
4392 (gnus-mime-save-part "o" "Save...")
4393 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4394 (gnus-mime-replace-part "r" "Replace part")
4395 (gnus-mime-delete-part "d" "Delete part")
4396 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4397 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4398 (gnus-mime-view-part-internally "E" "View Internally") ;; Why `E'?
4399 (gnus-mime-view-part-externally "e" "View Externally")
4400 (gnus-mime-print-part "p" "Print")
4401 (gnus-mime-pipe-part "|" "Pipe To Command...")
4402 (gnus-mime-action-on-part "." "Take action on the part...")))
4404 (defun gnus-article-mime-part-status ()
4405 (if gnus-article-mime-handle-alist-1
4406 (if (eq 1 (length gnus-article-mime-handle-alist-1))
4408 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
4411 (defvar gnus-mime-button-map
4412 (let ((map (make-sparse-keymap)))
4413 (define-key map gnus-mouse-2 'gnus-article-push-button)
4414 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4415 (dolist (c gnus-mime-button-commands)
4416 (define-key map (cadr c) (car c)))
4420 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4422 ,@(mapcar (lambda (c)
4423 (vector (caddr c) (car c) :active t))
4424 gnus-mime-button-commands)))
4426 (defun gnus-mime-button-menu (event prefix)
4427 "Construct a context-sensitive menu of MIME commands."
4428 (interactive "e\nP")
4429 (save-window-excursion
4430 (let ((pos (event-start event)))
4431 (select-window (posn-window pos))
4432 (goto-char (posn-point pos))
4433 (gnus-article-check-buffer)
4434 (popup-menu gnus-mime-button-menu nil prefix))))
4436 (defun gnus-mime-view-all-parts (&optional handles)
4437 "View all the MIME parts."
4439 (with-current-buffer gnus-article-buffer
4440 (let ((handles (or handles gnus-article-mime-handles))
4441 (mail-parse-charset gnus-newsgroup-charset)
4442 (mail-parse-ignored-charsets
4443 (with-current-buffer gnus-summary-buffer
4444 gnus-newsgroup-ignored-charsets)))
4446 (mm-remove-parts handles)
4447 (goto-char (point-min))
4448 (or (search-forward "\n\n") (goto-char (point-max)))
4449 (let ((inhibit-read-only t))
4450 (delete-region (point) (point-max))
4451 (mm-display-parts handles))))))
4453 (defun gnus-article-jump-to-part (n)
4454 "Jump to MIME part N."
4456 (pop-to-buffer gnus-article-buffer)
4457 ;; FIXME: why is it necessary?
4459 (let ((parts (length gnus-article-mime-handle-alist)))
4462 (read-string ;; Emacs 21 doesn't have `read-number'.
4463 (format "Jump to part (2..%s): " parts)))))
4464 (unless (and (integerp n) (<= n parts) (>= n 1))
4467 (gnus-message 7 "Invalid part `%s', using %s instead."
4470 (gnus-message 9 "Jumping to part %s." n)
4471 (cond ((>= gnus-auto-select-part 1)
4472 (while (and (<= n parts)
4473 (not (gnus-article-goto-part n)))
4475 ((< gnus-auto-select-part 0)
4476 (while (and (>= n 1)
4477 (not (gnus-article-goto-part n)))
4480 (gnus-article-goto-part n)))))
4483 (defsubst gnus-article-edit-part (handles &optional current-id)
4484 "Edit an article in order to delete a mime part.
4485 This function is exclusively used by `gnus-mime-save-part-and-strip'
4486 and `gnus-mime-delete-part', and not provided at run-time normally."
4487 (gnus-article-edit-article
4489 (buffer-disable-undo)
4491 (let ((mail-parse-charset (or gnus-article-charset
4492 ',gnus-newsgroup-charset))
4493 (mail-parse-ignored-charsets
4494 (or gnus-article-ignored-charsets
4495 ',gnus-newsgroup-ignored-charsets))
4496 (mbl mml-buffer-list))
4497 (setq mml-buffer-list nil)
4498 (insert-buffer-substring gnus-original-article-buffer)
4499 (mime-to-mml ',handles)
4500 (setq gnus-article-mime-handles nil)
4501 (let ((mbl1 mml-buffer-list))
4502 (setq mml-buffer-list mbl)
4503 (set (make-local-variable 'mml-buffer-list) mbl1))
4504 (gnus-make-local-hook 'kill-buffer-hook)
4505 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4506 `(lambda (no-highlight)
4507 (let ((mail-parse-charset (or gnus-article-charset
4508 ',gnus-newsgroup-charset))
4509 (message-options message-options)
4510 (message-options-set-recipient)
4511 (mail-parse-ignored-charsets
4512 (or gnus-article-ignored-charsets
4513 ',gnus-newsgroup-ignored-charsets)))
4515 (mml-destroy-buffers)
4516 (remove-hook 'kill-buffer-hook
4517 'mml-destroy-buffers t)
4518 (kill-local-variable 'mml-buffer-list))
4519 (gnus-summary-edit-article-done
4520 ,(or (mail-header-references gnus-current-headers) "")
4521 ,(gnus-group-read-only-p)
4522 ,gnus-summary-buffer no-highlight))
4524 (gnus-article-edit-done)
4525 (gnus-summary-expand-window)
4526 (gnus-summary-show-article)
4527 (when (and current-id (integerp gnus-auto-select-part))
4528 (gnus-article-jump-to-part
4529 (+ current-id gnus-auto-select-part)))))
4531 (defun gnus-mime-replace-part (file)
4532 "Replace MIME part under point with an external body."
4533 ;; Useful if file has already been saved to disk
4537 (read-file-name "Replace MIME part with file: "
4538 (or mm-default-directory default-directory)
4540 (gnus-mime-save-part-and-strip file))
4542 (defun gnus-mime-save-part-and-strip (&optional file)
4543 "Save the MIME part under point then replace it with an external body.
4544 If FILE is given, use it for the external part."
4546 (gnus-article-check-buffer)
4547 (when (gnus-group-read-only-p)
4548 (error "The current group does not support deleting of parts"))
4549 (when (mm-complicated-handles gnus-article-mime-handles)
4551 The current article has a complicated MIME structure, giving up..."))
4552 (let* ((data (get-text-property (point) 'gnus-data))
4553 (id (get-text-property (point) 'gnus-part))
4555 (handles gnus-article-mime-handles))
4558 (and data (mm-save-part data "Delete MIME part and save to: "))))
4560 (with-current-buffer (mm-handle-buffer data)
4562 (insert "Content-Type: " (mm-handle-media-type data))
4563 (mml-insert-parameter-string (cdr (mm-handle-type data))
4565 ;; Add a filename for the sake of saving the part again.
4566 (mml-insert-parameter
4567 (mail-header-encode-parameter "name" (file-name-nondirectory file)))
4569 (insert "Content-ID: " (message-make-message-id) "\n")
4570 (insert "Content-Transfer-Encoding: binary\n")
4573 (cdr (mm-make-handle nil
4574 `("message/external-body"
4575 (access-type . "LOCAL-FILE")
4577 ;; (set-buffer gnus-summary-buffer)
4578 (gnus-article-edit-part handles id))))
4580 ;; A function like `gnus-summary-save-parts' (`X m', `<MIME> <Extract all
4581 ;; parts...>') but with stripping would be nice.
4583 (defun gnus-mime-delete-part ()
4584 "Delete the MIME part under point.
4585 Replace it with some information about the removed part."
4587 (gnus-article-check-buffer)
4588 (when (gnus-group-read-only-p)
4589 (error "The current group does not support deleting of parts"))
4590 (when (mm-complicated-handles gnus-article-mime-handles)
4592 The current article has a complicated MIME structure, giving up..."))
4593 (when (or gnus-expert-user
4594 (gnus-yes-or-no-p "\
4595 Deleting parts may malfunction or destroy the article; continue? "))
4596 (let* ((data (get-text-property (point) 'gnus-data))
4597 (id (get-text-property (point) 'gnus-part))
4598 (handles gnus-article-mime-handles)
4601 (mail-decode-encoded-word-string (or (mm-handle-description data)
4604 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4606 (type (mm-handle-media-type data)))
4608 (error "No MIME part under point"))
4609 (with-current-buffer (mm-handle-buffer data)
4610 (let ((bsize (format "%s" (buffer-size))))
4615 "| The following attachment has been deleted:\n"
4617 "| Type: " type "\n"
4618 "| Filename: " filename "\n"
4619 "| Size (encoded): " bsize " Byte\n"
4620 "| Description: " description "\n"
4623 (cdr (mm-make-handle
4624 nil `("text/plain") nil nil
4626 (format "Deleted attachment (%s bytes)" bsize))))))
4627 ;; (set-buffer gnus-summary-buffer)
4628 (gnus-article-edit-part handles id))))
4630 (defun gnus-mime-save-part ()
4631 "Save the MIME part under point."
4633 (gnus-article-check-buffer)
4634 (let ((data (get-text-property (point) 'gnus-data)))
4636 (mm-save-part data))))
4638 (defun gnus-mime-pipe-part ()
4639 "Pipe the MIME part under point to a process."
4641 (gnus-article-check-buffer)
4642 (let ((data (get-text-property (point) 'gnus-data)))
4644 (mm-pipe-part data))))
4646 (defun gnus-mime-view-part ()
4647 "Interactively choose a viewing method for the MIME part under point."
4649 (gnus-article-check-buffer)
4650 (let ((data (get-text-property (point) 'gnus-data)))
4652 (setq gnus-article-mime-handles
4654 gnus-article-mime-handles (setq data (copy-sequence data))))
4655 (mm-interactively-view-part data))))
4657 (defun gnus-mime-view-part-as-type-internal ()
4658 (gnus-article-check-buffer)
4659 (let* ((handle (get-text-property (point) 'gnus-data))
4661 ;; Content-Type: foo/bar; name=...
4662 (mail-content-type-get (mm-handle-type handle) 'name)
4663 ;; Content-Disposition: attachment; filename=...
4664 (cdr (assq 'filename (cdr (mm-handle-disposition handle))))))
4665 (def-type (and name (mm-default-file-encoding name))))
4666 (and def-type (cons def-type 0))))
4668 (defun gnus-mime-view-part-as-type (&optional mime-type pred)
4669 "Choose a MIME media type, and view the part as such.
4670 If non-nil, PRED is a predicate to use during completion to limit the
4671 available media-types."
4675 (let ((default (gnus-mime-view-part-as-type-internal)))
4677 (format "View as MIME type (default %s): "
4679 (mapcar #'list (mailcap-mime-types))
4682 (gnus-article-check-buffer)
4683 (let ((handle (get-text-property (point) 'gnus-data)))
4685 (when (equal (mm-handle-media-type handle) "message/external-body")
4686 (unless (mm-handle-cache handle)
4687 (mm-extern-cache-contents handle))
4688 (setq handle (mm-handle-cache handle)))
4690 (mm-make-handle (mm-handle-buffer handle)
4691 (cons mime-type (cdr (mm-handle-type handle)))
4692 (mm-handle-encoding handle)
4693 (mm-handle-undisplayer handle)
4694 (mm-handle-disposition handle)
4695 (mm-handle-description handle)
4697 (mm-handle-id handle)))
4698 (setq gnus-article-mime-handles
4699 (mm-merge-handles gnus-article-mime-handles handle))
4700 (gnus-mm-display-part handle))))
4702 (defun gnus-mime-copy-part (&optional handle arg)
4703 "Put the MIME part under point into a new buffer.
4704 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4706 (interactive (list nil current-prefix-arg))
4707 (gnus-article-check-buffer)
4709 (setq handle (get-text-property (point) 'gnus-data)))
4711 (let ((filename (or (mail-content-type-get (mm-handle-type handle)
4713 (mail-content-type-get (mm-handle-disposition handle)
4715 contents dont-decode charset coding-system)
4716 (mm-with-unibyte-buffer
4717 (mm-insert-part handle)
4718 (setq contents (or (condition-case nil
4719 (mm-decompress-buffer filename nil 'sig)
4721 (setq dont-decode t)
4724 (setq filename (cond (filename (file-name-nondirectory filename))
4725 (dont-decode "*raw data*")
4730 (unless (setq charset (mail-content-type-get
4731 (mm-handle-type handle) 'charset))
4732 (unless (setq coding-system (mm-with-unibyte-buffer
4734 (mm-find-buffer-file-coding-system)))
4735 (setq charset gnus-newsgroup-charset))))
4737 (setq charset (or (cdr (assq arg
4738 gnus-summary-show-article-charset-alist))
4739 (mm-read-coding-system "Charset: ")))))
4740 (switch-to-buffer (generate-new-buffer filename))
4741 (if (or coding-system
4743 (setq coding-system (mm-charset-to-coding-system charset))
4744 (not (eq charset 'ascii))))
4746 (mm-enable-multibyte)
4747 (insert (mm-decode-coding-string contents coding-system))
4748 (setq buffer-file-coding-system
4749 (if (boundp 'last-coding-system-used)
4750 (symbol-value 'last-coding-system-used)
4752 (mm-disable-multibyte)
4754 (setq buffer-file-coding-system mm-binary-coding-system))
4755 ;; We do it this way to make `normal-mode' set the appropriate mode.
4758 (setq buffer-file-name (expand-file-name filename))
4760 (setq buffer-file-name nil))
4761 (goto-char (point-min)))))
4763 (defun gnus-mime-print-part (&optional handle filename)
4764 "Print the MIME part under point."
4765 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4766 (gnus-article-check-buffer)
4767 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4768 (contents (and handle (mm-get-part handle)))
4769 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4770 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4775 (mm-save-part-to-file handle file)
4776 (call-process shell-file-name nil
4777 (generate-new-buffer " *mm*")
4779 shell-command-switch
4781 printer file (mm-handle-type handle))))
4785 (gnus-print-buffer))
4786 (ps-despool filename)))))
4788 (defun gnus-mime-inline-part (&optional handle arg)
4789 "Insert the MIME part under point into the current buffer.
4790 Compressed files like .gz and .bz2 are decompressed."
4791 (interactive (list nil current-prefix-arg))
4792 (gnus-article-check-buffer)
4794 (setq handle (get-text-property (point) 'gnus-data)))
4797 (inhibit-read-only t)
4798 contents charset coding-system)
4799 (if (and (not arg) (mm-handle-undisplayer handle))
4800 (mm-remove-part handle)
4801 (mm-with-unibyte-buffer
4802 (mm-insert-part handle)
4804 (or (mm-decompress-buffer
4805 (or (mail-content-type-get (mm-handle-type handle)
4807 (mail-content-type-get (mm-handle-disposition handle)
4813 (unless (setq charset (mail-content-type-get
4814 (mm-handle-type handle) 'charset))
4815 (unless (setq coding-system
4816 (mm-with-unibyte-buffer
4818 (mm-find-buffer-file-coding-system)))
4819 (setq charset gnus-newsgroup-charset))))
4821 (if (mm-handle-undisplayer handle)
4822 (mm-remove-part handle))
4825 gnus-summary-show-article-charset-alist))
4826 (mm-read-coding-system "Charset: "))))
4828 (if (mm-handle-undisplayer handle)
4829 (mm-remove-part handle))))
4833 (if (or coding-system
4836 (mm-charset-to-coding-system charset))
4837 (not (eq coding-system 'ascii))))
4838 (mm-decode-coding-string contents coding-system)
4839 (mm-string-to-multibyte contents)))
4842 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4843 "Insert the MIME part under point into the current buffer using the
4845 (interactive (list nil current-prefix-arg))
4846 (gnus-article-check-buffer)
4847 (let ((handle (or handle (get-text-property (point) 'gnus-data)))
4848 (fun (get-text-property (point) 'gnus-callback))
4849 (gnus-newsgroup-ignored-charsets 'gnus-all)
4850 gnus-newsgroup-charset type charset)
4852 (if (mm-handle-undisplayer handle)
4853 (mm-remove-part handle))
4855 (setq gnus-newsgroup-charset
4856 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
4857 (mm-read-coding-system "Charset: ")))
4858 ;; Strip the charset parameter from `handle'.
4859 (setq type (mm-handle-type
4860 (if (equal (mm-handle-media-type handle)
4861 "message/external-body")
4863 (unless (mm-handle-cache handle)
4864 (mm-extern-cache-contents handle))
4865 (mm-handle-cache handle))
4867 charset (assq 'charset (cdr type)))
4869 (funcall fun handle)))))
4871 (defun gnus-mime-view-part-externally (&optional handle)
4872 "View the MIME part under point with an external viewer."
4874 (gnus-article-check-buffer)
4875 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4876 (mm-user-display-methods nil)
4877 (mm-inlined-types nil)
4878 (mail-parse-charset gnus-newsgroup-charset)
4879 (mail-parse-ignored-charsets
4880 (with-current-buffer gnus-summary-buffer
4881 gnus-newsgroup-ignored-charsets))
4882 (type (mm-handle-media-type handle))
4883 (method (mailcap-mime-info type))
4884 (mm-enable-external t))
4885 (if (not (stringp method))
4886 (gnus-mime-view-part-as-type
4887 nil (lambda (type) (stringp (mailcap-mime-info type))))
4889 (if (mm-handle-undisplayer handle)
4890 (mm-remove-part handle)
4891 (mm-display-part handle))))))
4893 (defun gnus-mime-view-part-internally (&optional handle)
4894 "View the MIME part under point with an internal viewer.
4895 If no internal viewer is available, use an external viewer."
4897 (gnus-article-check-buffer)
4898 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4899 (mm-inlined-types '(".*"))
4900 (mm-inline-large-images t)
4901 (mail-parse-charset gnus-newsgroup-charset)
4902 (mail-parse-ignored-charsets
4903 (with-current-buffer gnus-summary-buffer
4904 gnus-newsgroup-ignored-charsets))
4905 (inhibit-read-only t))
4906 (if (not (mm-inlinable-p handle))
4907 (gnus-mime-view-part-as-type
4908 nil (lambda (type) (mm-inlinable-p handle type)))
4910 (if (mm-handle-undisplayer handle)
4911 (mm-remove-part handle)
4912 (mm-display-part handle))))))
4914 (defun gnus-mime-action-on-part (&optional action)
4915 "Do something with the MIME attachment at \(point\)."
4917 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4918 (gnus-article-check-buffer)
4919 (let ((action-pair (assoc action gnus-mime-action-alist)))
4921 (funcall (cdr action-pair)))))
4923 (defun gnus-article-part-wrapper (n function &optional no-handle interactive)
4924 "Call FUNCTION on MIME part N.
4925 Unless NO-HANDLE, call FUNCTION with N-th MIME handle as it's only argument.
4926 If INTERACTIVE, call FUNCTION interactivly."
4928 ;; Check whether the article is displayed.
4929 (unless (and (gnus-buffer-live-p gnus-article-buffer)
4930 (setq window (get-buffer-window gnus-article-buffer t))
4931 (frame-visible-p (setq frame (window-frame window))))
4932 (error "No article is displayed"))
4933 (with-current-buffer gnus-article-buffer
4934 ;; Check whether the article displays the right contents.
4935 (unless (with-current-buffer gnus-summary-buffer
4936 (eq gnus-current-article (gnus-summary-article-number)))
4937 (error "You should select the right article first"))
4938 ;; Check whether the specified part exists.
4939 (when (> n (length gnus-article-mime-handle-alist))
4940 (error "No such part")))
4943 ;; To select the window is needed so that the cursor
4944 ;; might be visible on the MIME button.
4945 (select-window (prog1
4947 (setq window (selected-window))
4948 ;; Article may be displayed in the other frame.
4949 (gnus-select-frame-set-input-focus
4952 (setq frame (selected-frame))))))
4953 (when (gnus-article-goto-part n)
4954 ;; We point the cursor and the arrow at the MIME button
4955 ;; when the `function' prompt the user for something.
4956 (let ((cursor-in-non-selected-windows t)
4957 (overlay-arrow-string "=>")
4958 (overlay-arrow-position (point-marker)))
4961 ((and no-handle interactive)
4962 (call-interactively function))
4968 (cdr (assq n gnus-article-mime-handle-alist))))
4971 (cdr (assq n gnus-article-mime-handle-alist)))))
4972 (set-marker overlay-arrow-position nil)
4973 (unless gnus-auto-select-part
4974 (gnus-select-frame-set-input-focus frame)
4975 (select-window window))))
4977 (if gnus-inhibit-mime-unbuttonizing
4978 ;; This is the default though the program shouldn't reach here.
4979 (error "No such part")
4980 ;; The part which doesn't have the MIME button is selected.
4981 ;; So, we display all the buttons and redo it.
4982 (let ((gnus-inhibit-mime-unbuttonizing t))
4983 (gnus-summary-show-article)
4984 (gnus-article-part-wrapper n function no-handle))))))
4986 (defun gnus-article-pipe-part (n)
4987 "Pipe MIME part N, which is the numerical prefix."
4989 (gnus-article-part-wrapper n 'mm-pipe-part))
4991 (defun gnus-article-save-part (n)
4992 "Save MIME part N, which is the numerical prefix."
4994 (gnus-article-part-wrapper n 'mm-save-part))
4996 (defun gnus-article-interactively-view-part (n)
4997 "View MIME part N interactively, which is the numerical prefix."
4999 (gnus-article-part-wrapper n 'mm-interactively-view-part))
5001 (defun gnus-article-copy-part (n)
5002 "Copy MIME part N, which is the numerical prefix."
5004 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
5006 (defun gnus-article-view-part-as-charset (n)
5007 "View MIME part N using a specified charset.
5008 N is the numerical prefix."
5010 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
5012 (defun gnus-article-view-part-externally (n)
5013 "View MIME part N externally, which is the numerical prefix."
5015 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
5017 (defun gnus-article-inline-part (n)
5018 "Inline MIME part N, which is the numerical prefix."
5020 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
5022 (defun gnus-article-save-part-and-strip (n)
5023 "Save MIME part N and replace it with an external body.
5024 N is the numerical prefix."
5026 (gnus-article-part-wrapper n 'gnus-mime-save-part-and-strip t))
5028 (defun gnus-article-replace-part (n)
5029 "Replace MIME part N with an external body.
5030 N is the numerical prefix."
5032 (gnus-article-part-wrapper n 'gnus-mime-replace-part t t))
5034 (defun gnus-article-delete-part (n)
5035 "Delete MIME part N and add some information about the removed part.
5036 N is the numerical prefix."
5038 (gnus-article-part-wrapper n 'gnus-mime-delete-part t))
5040 (defun gnus-article-view-part-as-type (n)
5041 "Choose a MIME media type, and view part N as such.
5042 N is the numerical prefix."
5044 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-type t))
5046 (defun gnus-article-mime-match-handle-first (condition)
5049 (dolist (ihandle gnus-article-mime-handle-alist)
5051 ((functionp condition)
5052 (funcall condition (cdr ihandle)))
5053 ((eq condition 'undisplayed)
5054 (not (or (mm-handle-undisplayer (cdr ihandle))
5055 (equal (mm-handle-media-type (cdr ihandle))
5056 "multipart/alternative"))))
5057 ((eq condition 'undisplayed-alternative)
5058 (not (mm-handle-undisplayer (cdr ihandle))))
5060 (gnus-article-goto-part (car ihandle))
5061 (or (not n) (< (car ihandle) n)))
5062 (setq n (car ihandle))))
5066 (defun gnus-article-view-part (&optional n)
5067 "View MIME part N, which is the numerical prefix."
5069 (with-current-buffer gnus-article-buffer
5070 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
5071 gnus-article-mime-match-handle-function)))
5072 (when (> n (length gnus-article-mime-handle-alist))
5073 (error "No such part"))
5074 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
5075 (when (gnus-article-goto-part n)
5076 (if (equal (car handle) "multipart/alternative")
5077 (gnus-article-press-button)
5078 (when (eq (gnus-mm-display-part handle) 'internal)
5079 (gnus-set-window-start)))))))
5081 (defsubst gnus-article-mime-total-parts ()
5082 (if (bufferp (car gnus-article-mime-handles))
5084 (1- (length gnus-article-mime-handles))))
5086 (defun gnus-mm-display-part (handle)
5087 "Display HANDLE and fix MIME button."
5088 (let ((id (get-text-property (point) 'gnus-part))
5090 (inhibit-read-only t))
5093 (let ((window (selected-window))
5094 (mail-parse-charset gnus-newsgroup-charset)
5095 (mail-parse-ignored-charsets
5096 (if (gnus-buffer-live-p gnus-summary-buffer)
5097 (with-current-buffer gnus-summary-buffer
5098 gnus-newsgroup-ignored-charsets)
5102 (let ((win (gnus-get-buffer-window (current-buffer) t))
5105 (select-window win))
5108 (if (mm-handle-displayed-p handle)
5109 ;; This will remove the part.
5110 (mm-display-part handle)
5112 (narrow-to-region (point)
5113 (if (eobp) (point) (1+ (point))))
5114 (mm-display-part handle)
5115 ;; We narrow to the part itself and
5116 ;; then call the treatment functions.
5117 (goto-char (point-min))
5119 (narrow-to-region (point) (point-max))
5122 (gnus-article-mime-total-parts)
5123 (mm-handle-media-type handle)))))
5124 (if (window-live-p window)
5125 (select-window window)))))
5128 (gnus-insert-mime-button
5129 handle id (list (mm-handle-displayed-p handle)))
5130 (goto-char point))))
5132 (defun gnus-article-goto-part (n)
5133 "Go to MIME part N."
5134 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
5136 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
5137 (let ((gnus-tmp-name
5138 (or (mail-content-type-get (mm-handle-type handle) 'name)
5139 (mail-content-type-get (mm-handle-disposition handle) 'filename)
5140 (mail-content-type-get (mm-handle-type handle) 'url)
5142 (gnus-tmp-type (mm-handle-media-type handle))
5143 (gnus-tmp-description
5144 (mail-decode-encoded-word-string (or (mm-handle-description handle)
5147 (if (if displayed (car displayed)
5148 (mm-handle-displayed-p handle))
5150 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
5152 gnus-tmp-type-long b e)
5153 (when (string-match ".*/" gnus-tmp-name)
5154 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
5155 (setq gnus-tmp-type-long (concat gnus-tmp-type
5156 (and (not (equal gnus-tmp-name ""))
5157 (concat "; " gnus-tmp-name))))
5158 (unless (equal gnus-tmp-description "")
5159 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
5164 gnus-mime-button-line-format gnus-mime-button-line-format-alist
5165 `(keymap ,gnus-mime-button-map
5166 gnus-callback gnus-mm-display-part
5167 gnus-part ,gnus-tmp-id
5168 article-type annotation
5171 ;; Exclude a newline.
5174 (when gnus-article-button-face
5175 (gnus-overlay-put (gnus-make-overlay b e)
5176 'face gnus-article-button-face))
5177 (widget-convert-button
5180 :action 'gnus-widget-press-button
5181 :button-keymap gnus-mime-button-map
5183 (lambda (widget/window &optional overlay pos)
5184 ;; Needed to properly clear the message due to a bug in
5185 ;; wid-edit (XEmacs only).
5186 (if (boundp 'help-echo-owns-message)
5187 (setq help-echo-owns-message t))
5189 "%S: %s the MIME part; %S: more options"
5190 (aref gnus-mouse-2 0)
5191 ;; XEmacs will get a single widget arg; Emacs 21 will get
5192 ;; window, overlay, position.
5193 (if (mm-handle-displayed-p
5195 (with-current-buffer (gnus-overlay-buffer overlay)
5196 (widget-get (widget-at (gnus-overlay-start overlay))
5198 (widget-get widget/window :mime-handle)))
5200 (aref gnus-down-mouse-3 0))))))
5202 (defun gnus-widget-press-button (elems el)
5203 (goto-char (widget-get elems :from))
5204 (gnus-article-press-button))
5206 (defvar gnus-displaying-mime nil)
5208 (defun gnus-display-mime (&optional ihandles)
5209 "Display the MIME parts."
5211 (save-selected-window
5212 (let ((window (get-buffer-window gnus-article-buffer))
5215 (select-window window)
5216 ;; We have to do this since selecting the window
5217 ;; may change the point. So we set the window point.
5218 (set-window-point window point)))
5219 (let ((handles ihandles)
5220 (inhibit-read-only t)
5223 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
5224 (when gnus-article-emulate-mime
5225 (mm-uu-dissect-text-parts handles)))
5226 (gnus-article-emulate-mime
5227 (setq handles (mm-uu-dissect))))
5228 (when (and (not ihandles)
5229 (not gnus-displaying-mime))
5230 ;; Top-level call; we clean up.
5231 (when gnus-article-mime-handles
5232 (mm-destroy-parts gnus-article-mime-handles)
5233 (setq gnus-article-mime-handle-alist nil));; A trick.
5234 (setq gnus-article-mime-handles handles)
5235 ;; We allow users to glean info from the handles.
5236 (when gnus-article-mime-part-function
5237 (gnus-mime-part-function handles)))
5239 (or (not (stringp (car handles)))
5242 (when (and (not ihandles)
5243 (not gnus-displaying-mime))
5244 ;; Clean up for mime parts.
5246 (delete-region (point) (point-max)))
5247 (let ((gnus-displaying-mime t))
5248 (gnus-mime-display-part handles)))
5251 (narrow-to-region (point) (point-max))
5252 (gnus-treat-article nil 1 1)
5255 ;; Highlight the headers.
5259 (narrow-to-region (point-min) (point))
5260 (gnus-article-save-original-date
5261 (gnus-treat-article 'head)))))))
5262 ;; Cope with broken MIME messages.
5263 (goto-char (point-max))
5267 (defcustom gnus-mime-display-multipart-as-mixed nil
5268 "Display \"multipart\" parts as \"multipart/mixed\".
5270 If t, it overrides nil values of
5271 `gnus-mime-display-multipart-alternative-as-mixed' and
5272 `gnus-mime-display-multipart-related-as-mixed'."
5273 :group 'gnus-article-mime
5276 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
5277 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
5279 :group 'gnus-article-mime
5282 (defcustom gnus-mime-display-multipart-related-as-mixed nil
5283 "Display \"multipart/related\" parts as \"multipart/mixed\".
5285 If displaying \"text/html\" is discouraged \(see
5286 `mm-discouraged-alternatives'\) images or other material inside a
5287 \"multipart/related\" part might be overlooked when this variable is nil."
5289 :group 'gnus-article-mime
5292 (defun gnus-mime-display-part (handle)
5294 ;; Maybe a broken MIME message.
5297 ((not (stringp (car handle)))
5298 (gnus-mime-display-single handle))
5299 ;; User-defined multipart
5300 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
5301 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
5303 ;; multipart/alternative
5304 ((and (equal (car handle) "multipart/alternative")
5305 (not (or gnus-mime-display-multipart-as-mixed
5306 gnus-mime-display-multipart-alternative-as-mixed)))
5307 (let ((id (1+ (length gnus-article-mime-handle-alist))))
5308 (push (cons id handle) gnus-article-mime-handle-alist)
5309 (gnus-mime-display-alternative (cdr handle) nil nil id)))
5310 ;; multipart/related
5311 ((and (equal (car handle) "multipart/related")
5312 (not (or gnus-mime-display-multipart-as-mixed
5313 gnus-mime-display-multipart-related-as-mixed)))
5314 ;;;!!!We should find the start part, but we just default
5315 ;;;!!!to the first part.
5316 ;;(gnus-mime-display-part (cadr handle))
5317 ;;;!!! Most multipart/related is an HTML message plus images.
5318 ;;;!!! Unfortunately we are unable to let W3 display those
5319 ;;;!!! included images, so we just display it as a mixed multipart.
5320 ;;(gnus-mime-display-mixed (cdr handle))
5321 ;;;!!! No, w3 can display everything just fine.
5322 (gnus-mime-display-part (cadr handle)))
5323 ((equal (car handle) "multipart/signed")
5324 (gnus-add-wash-type 'signed)
5325 (gnus-mime-display-security handle))
5326 ((equal (car handle) "multipart/encrypted")
5327 (gnus-add-wash-type 'encrypted)
5328 (gnus-mime-display-security handle))
5329 ;; Other multiparts are handled like multipart/mixed.
5331 (gnus-mime-display-mixed (cdr handle)))))
5333 (defun gnus-mime-part-function (handles)
5334 (if (stringp (car handles))
5335 (mapcar 'gnus-mime-part-function (cdr handles))
5336 (funcall gnus-article-mime-part-function handles)))
5338 (defun gnus-mime-display-mixed (handles)
5339 (mapcar 'gnus-mime-display-part handles))
5341 (defun gnus-mime-display-single (handle)
5342 (let ((type (mm-handle-media-type handle))
5343 (ignored gnus-ignored-mime-types)
5350 (when (string-match (pop ignored) type)
5351 (throw 'ignored nil)))
5352 (if (and (setq not-attachment
5353 (and (not (mm-inline-override-p handle))
5354 (or (not (mm-handle-disposition handle))
5355 (equal (car (mm-handle-disposition handle))
5357 (mm-attachment-override-p handle))))
5358 (mm-automatic-display-p handle)
5360 (mm-inlinable-p handle)
5361 (mm-inlined-p handle))
5362 (mm-automatic-external-display-p type)))
5364 (when (equal (mm-handle-media-supertype handle) "text")
5366 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5368 (push (cons id handle) gnus-article-mime-handle-alist)
5370 (equal (mm-handle-media-supertype handle) "message"))
5373 (cond ((not (bolp)) 2)
5374 ((or (bobp) (eq (char-before (1- (point))) ?\n)) 0)
5376 (when (or (not display)
5377 (not (gnus-unbuttonized-mime-type-p type)))
5378 (gnus-insert-mime-button
5379 handle id (list (or display (and not-attachment text))))
5380 (gnus-article-insert-newline)
5381 ;; Remember modify the number of forward lines.
5389 (let ((mail-parse-charset gnus-newsgroup-charset)
5390 (mail-parse-ignored-charsets
5391 (save-excursion (condition-case ()
5392 (set-buffer gnus-summary-buffer)
5394 gnus-newsgroup-ignored-charsets)))
5395 (mm-display-part handle t))
5396 (goto-char (point-max)))
5397 ((and text not-attachment)
5401 (gnus-article-insert-newline)
5404 (let ((charset (mail-content-type-get (mm-handle-type handle)
5406 (cond ((not charset)
5407 (mm-string-as-multibyte (mm-get-part handle)))
5408 ((eq charset 'gnus-decoded)
5409 (with-current-buffer (mm-handle-buffer handle)
5412 (mm-decode-string (mm-get-part handle) charset)))))
5413 (goto-char (point-max))))
5417 (narrow-to-region beg (point))
5420 (gnus-article-mime-total-parts)
5421 (mm-handle-media-type handle)))))))))
5423 (defun gnus-unbuttonized-mime-type-p (type)
5424 "Say whether TYPE is to be unbuttonized."
5425 (unless gnus-inhibit-mime-unbuttonizing
5427 (let ((types gnus-unbuttonized-mime-types))
5429 (when (string-match (pop types) type)
5430 (throw 'found t)))))
5432 (let ((types gnus-buttonized-mime-types))
5434 (when (string-match (pop types) type)
5435 (throw 'found t)))))))))
5437 (defun gnus-article-insert-newline ()
5438 "Insert a newline, but mark it as undeletable."
5439 (gnus-put-text-property
5440 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5442 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5443 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5446 handle (inhibit-read-only t) from props begend not-pref)
5447 (save-window-excursion
5450 (narrow-to-region (car ibegend)
5453 (goto-char (car ibegend))
5456 (delete-region (point-min) (point-max))
5457 (mm-remove-parts handles))
5458 (setq begend (list (point-marker)))
5460 (unless (setq not-pref (cadr (member preferred ihandles)))
5461 (setq not-pref (car ihandles)))
5464 (not (gnus-unbuttonized-mime-type-p
5465 "multipart/alternative")))
5466 (gnus-add-text-properties
5469 (insert (format "%d. " id))
5473 (unless ,(not ibegend)
5474 (setq gnus-article-mime-handle-alist
5475 ',gnus-article-mime-handle-alist))
5476 (gnus-mime-display-alternative
5477 ',ihandles ',not-pref ',begend ,id))
5478 keymap ,gnus-mime-button-map
5479 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5480 face ,gnus-article-button-face
5482 article-type multipart))
5483 (widget-convert-button 'link from (point)
5484 :action 'gnus-widget-press-button
5485 :button-keymap gnus-widget-button-keymap)
5487 (while (setq handle (pop handles))
5488 (gnus-add-text-properties
5491 (insert (format "(%c) %-18s"
5492 (if (equal handle preferred) ?* ? )
5493 (mm-handle-media-type handle)))
5497 (unless ,(not ibegend)
5498 (setq gnus-article-mime-handle-alist
5499 ',gnus-article-mime-handle-alist))
5500 (gnus-mime-display-alternative
5501 ',ihandles ',handle ',begend ,id))
5502 keymap ,gnus-mime-button-map
5503 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5504 face ,gnus-article-button-face
5507 (widget-convert-button 'link from (point)
5508 :action 'gnus-widget-press-button
5509 :button-keymap gnus-widget-button-keymap)
5513 (if (stringp (car preferred))
5514 (gnus-display-mime preferred)
5515 (let ((mail-parse-charset gnus-newsgroup-charset)
5516 (mail-parse-ignored-charsets
5517 (with-current-buffer gnus-summary-buffer
5518 gnus-newsgroup-ignored-charsets)))
5519 (mm-display-part preferred)
5523 (narrow-to-region (car begend) (point-max))
5525 nil (length gnus-article-mime-handle-alist)
5526 (gnus-article-mime-total-parts)
5527 (mm-handle-media-type handle))))))
5528 (goto-char (point-max))
5529 (setcdr begend (point-marker)))))
5531 (goto-char point))))
5533 (defconst gnus-article-wash-status-strings
5534 (let ((alist '((cite "c" "Possible hidden citation text"
5535 " " "All citation text visible")
5536 (headers "h" "Hidden headers"
5537 " " "All headers visible.")
5538 (pgp "p" "Encrypted or signed message status hidden"
5539 " " "No hidden encryption nor digital signature status")
5540 (signature "s" "Signature has been hidden"
5541 " " "Signature is visible")
5542 (overstrike "o" "Overstrike (^H) characters applied"
5543 " " "No overstrike characters applied")
5544 (emphasis "e" "/*_Emphasis_*/ characters applied"
5545 " " "No /*_emphasis_*/ characters applied")))
5547 (dolist (entry alist result)
5548 (let ((key (nth 0 entry))
5549 (on (copy-sequence (nth 1 entry)))
5550 (on-help (nth 2 entry))
5551 (off (copy-sequence (nth 3 entry)))
5552 (off-help (nth 4 entry)))
5553 (put-text-property 0 1 'help-echo on-help on)
5554 (put-text-property 0 1 'help-echo off-help off)
5555 (push (list key on off) result))))
5556 "Alist of strings describing wash status in the mode line.
5557 Each entry has the form (KEY ON OF), where the KEY is a symbol
5558 representing the particular washing function, ON is the string to use
5559 in the article mode line when the washing function is active, and OFF
5560 is the string to use when it is inactive.")
5562 (defun gnus-article-wash-status-entry (key value)
5563 (let ((entry (assoc key gnus-article-wash-status-strings)))
5564 (if value (nth 1 entry) (nth 2 entry))))
5566 (defun gnus-article-wash-status ()
5567 "Return a string which display status of article washing."
5568 (with-current-buffer gnus-article-buffer
5569 (let ((cite (memq 'cite gnus-article-wash-types))
5570 (headers (memq 'headers gnus-article-wash-types))
5571 (boring (memq 'boring-headers gnus-article-wash-types))
5572 (pgp (memq 'pgp gnus-article-wash-types))
5573 (pem (memq 'pem gnus-article-wash-types))
5574 (signed (memq 'signed gnus-article-wash-types))
5575 (encrypted (memq 'encrypted gnus-article-wash-types))
5576 (signature (memq 'signature gnus-article-wash-types))
5577 (overstrike (memq 'overstrike gnus-article-wash-types))
5578 (emphasis (memq 'emphasis gnus-article-wash-types)))
5580 (gnus-article-wash-status-entry 'cite cite)
5581 (gnus-article-wash-status-entry 'headers (or headers boring))
5582 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5583 (gnus-article-wash-status-entry 'signature signature)
5584 (gnus-article-wash-status-entry 'overstrike overstrike)
5585 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5587 (defun gnus-add-wash-type (type)
5588 "Add a washing of TYPE to the current status."
5589 (add-to-list 'gnus-article-wash-types type))
5591 (defun gnus-delete-wash-type (type)
5592 "Add a washing of TYPE to the current status."
5593 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5595 (defun gnus-add-image (category image)
5596 "Add IMAGE of CATEGORY to the list of displayed images."
5597 (let ((entry (assq category gnus-article-image-alist)))
5599 (setq entry (list category))
5600 (push entry gnus-article-image-alist))
5601 (nconc entry (list image))))
5603 (defun gnus-delete-images (category)
5604 "Delete all images in CATEGORY."
5605 (let ((entry (assq category gnus-article-image-alist)))
5606 (dolist (image (cdr entry))
5607 (gnus-remove-image image category))
5608 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5609 (gnus-delete-wash-type category)))
5611 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5613 (defun gnus-article-maybe-hide-headers ()
5614 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5615 Provided for backwards compatibility."
5616 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5617 (not (with-current-buffer gnus-summary-buffer
5618 gnus-have-all-headers)))
5619 (not gnus-inhibit-hiding))
5620 (gnus-article-hide-headers)))
5624 (defun gnus-output-to-file (file-name)
5625 "Append the current article to a file named FILE-NAME.
5626 If `gnus-article-save-coding-system' is non-nil, it is used to encode
5627 text and used as the value of the coding cookie which is added to the
5628 top of a file. Otherwise, this function saves a raw article without
5630 (let* ((artbuf (current-buffer))
5631 (file-name-coding-system nnmail-pathname-coding-system)
5632 (coding gnus-article-save-coding-system)
5633 (coding-system-for-read (if coding
5634 nil ;; Rely on the coding cookie.
5635 mm-text-coding-system))
5636 (coding-system-for-write (or coding
5637 mm-text-coding-system-for-write
5638 mm-text-coding-system))
5639 (exists (file-exists-p file-name)))
5642 (insert-file-contents file-name)
5643 (goto-char (point-min))
5644 ;; Remove the existing coding cookie.
5645 (when (looking-at "X-Gnus-Coding-System: .+\n\n")
5646 (delete-region (match-beginning 0) (match-end 0))))
5647 (goto-char (point-max))
5648 (insert-buffer-substring artbuf)
5649 ;; Append newline at end of the buffer as separator, and then
5651 (goto-char (point-max))
5654 ;; If the coding system is not suitable to encode the text,
5655 ;; ask a user for a proper one.
5656 (when (fboundp 'select-safe-coding-system)
5657 (setq coding (coding-system-base
5658 (save-window-excursion
5659 (select-safe-coding-system (point-min) (point-max)
5661 (setq coding-system-for-write
5662 (or (cdr (assq coding '((mule-utf-8 . utf-8))))
5664 (goto-char (point-min))
5665 ;; Add the coding cookie.
5666 (insert (format "X-Gnus-Coding-System: -*- coding: %s; -*-\n\n"
5667 coding-system-for-write)))
5670 (write-region (point-min) (point-max) file-name nil 'no-message)
5671 (message "Appended to %s" file-name))
5672 (write-region (point-min) (point-max) file-name))))
5675 (defun gnus-narrow-to-page (&optional arg)
5676 "Narrow the article buffer to a page.
5677 If given a numerical ARG, move forward ARG pages."
5679 (setq arg (if arg (prefix-numeric-value arg) 0))
5681 (set-buffer gnus-article-buffer)
5682 (goto-char (point-min))
5684 ;; Remove any old next/prev buttons.
5685 (when (gnus-visual-p 'page-marker)
5686 (let ((inhibit-read-only t))
5687 (gnus-remove-text-with-property 'gnus-prev)
5688 (gnus-remove-text-with-property 'gnus-next)))
5691 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5693 (re-search-forward page-delimiter nil 'move arg)))
5694 (goto-char (match-end 0))
5696 (goto-char (point-min))
5697 (setq gnus-page-broken
5698 (and (re-search-forward page-delimiter nil t) t))))
5699 (when gnus-page-broken
5702 (if (re-search-forward page-delimiter nil 'move)
5705 (when (and (gnus-visual-p 'page-marker)
5706 (> (point-min) (save-restriction (widen) (point-min))))
5708 (goto-char (point-min))
5709 (gnus-insert-prev-page-button)))
5710 (when (and (gnus-visual-p 'page-marker)
5711 (< (point-max) (save-restriction (widen) (point-max))))
5713 (goto-char (point-max))
5714 (gnus-insert-next-page-button))))))
5716 ;; Article mode commands
5718 (defun gnus-article-goto-next-page ()
5719 "Show the next page of the article."
5721 (when (gnus-article-next-page)
5722 (goto-char (point-min))
5723 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5726 (defun gnus-article-goto-prev-page ()
5727 "Show the previous page of the article."
5730 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5731 (gnus-article-prev-page nil)))
5733 ;; This is cleaner but currently breaks `gnus-pick-mode':
5735 ;; (defun gnus-article-goto-next-page ()
5736 ;; "Show the next page of the article."
5738 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5739 ;; (gnus-summary-next-page)))
5741 ;; (defun gnus-article-goto-prev-page ()
5742 ;; "Show the next page of the article."
5744 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5745 ;; (gnus-summary-prev-page)))
5747 (defun gnus-article-next-page (&optional lines)
5748 "Show the next page of the current article.
5749 If end of article, return non-nil. Otherwise return nil.
5750 Argument LINES specifies lines to be scrolled up."
5752 (move-to-window-line -1)
5755 (and (pos-visible-in-window-p) ;Not continuation line.
5756 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5757 ;; Nothing in this page.
5758 (if (or (not gnus-page-broken)
5763 (eobp)))) ;Real end-of-buffer?
5765 (when gnus-article-over-scroll
5766 (gnus-article-next-page-1 lines))
5768 (gnus-narrow-to-page 1) ;Go to next page.
5770 ;; More in this page.
5771 (gnus-article-next-page-1 lines)
5774 (defmacro gnus-article-beginning-of-window ()
5775 "Move point to the beginning of the window.
5776 In Emacs, the point is placed at the line number which `scroll-margin'
5778 (if (featurep 'xemacs)
5779 '(move-to-window-line 0)
5780 '(move-to-window-line
5781 (min (max 0 scroll-margin)
5782 (max 1 (- (window-height)
5783 (if mode-line-format 1 0)
5784 (if header-line-format 1 0)))))))
5786 (defun gnus-article-next-page-1 (lines)
5787 (when (and (not (featurep 'xemacs))
5790 (numberp (symbol-value 'scroll-margin))
5791 (> (symbol-value 'scroll-margin) 0))
5792 ;; Protect against the bug that Emacs 21.x hangs up when scrolling up for
5793 ;; too many number of lines if `scroll-margin' is set as two or greater.
5794 (setq lines (min lines
5795 (max 0 (- (count-lines (window-start) (point-max))
5796 (symbol-value 'scroll-margin))))))
5798 (let ((scroll-in-place nil))
5801 ;; Long lines may cause an end-of-buffer error.
5802 (goto-char (point-max))))
5803 (gnus-article-beginning-of-window))
5805 (defun gnus-article-prev-page (&optional lines)
5806 "Show previous page of current article.
5807 Argument LINES specifies lines to be scrolled down."
5809 (move-to-window-line 0)
5810 (if (and gnus-page-broken
5812 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5814 (gnus-narrow-to-page -1) ;Go to previous page.
5815 (goto-char (point-max))
5819 (let ((scroll-in-place nil))
5820 (scroll-down lines))
5821 (beginning-of-buffer
5822 (goto-char (point-min))))
5823 (gnus-article-beginning-of-window))))
5825 (defun gnus-article-only-boring-p ()
5826 "Decide whether there is only boring text remaining in the article.
5827 Something \"interesting\" is a word of at least two letters that does
5828 not have a face in `gnus-article-boring-faces'."
5829 (when (and gnus-article-skip-boring
5830 (boundp 'gnus-article-boring-faces)
5831 (symbol-value 'gnus-article-boring-faces))
5833 (let ((inhibit-point-motion-hooks t))
5835 (while (re-search-forward "\\b\\w\\w" nil t)
5837 (when (not (gnus-intersection
5838 (gnus-faces-at (point))
5839 (symbol-value 'gnus-article-boring-faces)))
5840 (throw 'only-boring nil)))
5841 (throw 'only-boring t))))))
5843 (defun gnus-article-refer-article ()
5844 "Read article specified by message-id around point."
5847 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5848 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5849 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5850 (let ((msg-id (concat "<" (match-string 0) ">")))
5851 (set-buffer gnus-summary-buffer)
5852 (gnus-summary-refer-article msg-id))
5853 (error "No references around point"))))
5855 (defun gnus-article-show-summary ()
5856 "Reconfigure windows to show summary buffer."
5858 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5859 (error "There is no summary buffer for this article buffer")
5860 (gnus-article-set-globals)
5861 (gnus-configure-windows 'article)
5862 (gnus-summary-goto-subject gnus-current-article)
5863 (gnus-summary-position-point)))
5865 (defun gnus-article-describe-briefly ()
5866 "Describe article mode commands briefly."
5868 (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")))
5870 (defun gnus-article-summary-command ()
5871 "Execute the last keystroke in the summary buffer."
5873 (let ((obuf (current-buffer))
5874 (owin (current-window-configuration))
5876 (switch-to-buffer gnus-article-current-summary 'norecord)
5877 (setq func (lookup-key (current-local-map) (this-command-keys)))
5878 (call-interactively func)
5880 (set-window-configuration owin)
5881 (set-window-point (get-buffer-window (current-buffer)) (point))))
5883 (defun gnus-article-summary-command-nosave ()
5884 "Execute the last keystroke in the summary buffer."
5887 (pop-to-buffer gnus-article-current-summary 'norecord)
5888 (setq func (lookup-key (current-local-map) (this-command-keys)))
5889 (call-interactively func)))
5891 (defun gnus-article-check-buffer ()
5892 "Beep if not in an article buffer."
5893 (unless (equal major-mode 'gnus-article-mode)
5894 (error "Command invoked outside of a Gnus article buffer")))
5896 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5897 "Read a summary buffer key sequence and execute it from the article buffer."
5899 (gnus-article-check-buffer)
5901 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5902 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5903 "=" "^" "\M-^" "|"))
5909 '("n" "Gn" "p" "Gp"))
5912 (set-buffer gnus-article-current-summary)
5913 (let (gnus-pick-mode)
5914 (push (or key last-command-event) unread-command-events)
5915 (setq keys (if (featurep 'xemacs)
5916 (events-to-keys (read-key-sequence nil))
5917 (read-key-sequence nil)))))
5921 (if (or (member keys nosaves)
5922 (member keys nosave-but-article)
5923 (member keys nosave-in-article))
5925 (save-window-excursion
5926 (pop-to-buffer gnus-article-current-summary 'norecord)
5927 ;; We disable the pick minor mode commands.
5928 (let (gnus-pick-mode)
5929 (setq func (lookup-key (current-local-map) keys))))
5933 (unless (member keys nosave-in-article)
5934 (set-buffer gnus-article-current-summary))
5935 (call-interactively func)
5936 (setq new-sum-point (point)))
5937 (when (member keys nosave-but-article)
5938 (pop-to-buffer gnus-article-buffer 'norecord)))
5939 ;; These commands should restore window configuration.
5940 (let ((obuf (current-buffer))
5941 (owin (current-window-configuration))
5943 win func in-buffer selected new-sum-start new-sum-hscroll)
5944 (cond (not-restore-window
5945 (pop-to-buffer gnus-article-current-summary 'norecord))
5946 ((setq win (get-buffer-window gnus-article-current-summary))
5947 (select-window win))
5949 (switch-to-buffer gnus-article-current-summary 'norecord)))
5950 (setq in-buffer (current-buffer))
5951 ;; We disable the pick minor mode commands.
5952 (if (and (setq func (let (gnus-pick-mode)
5953 (lookup-key (current-local-map) keys)))
5956 (call-interactively func)
5957 (when (eq win (selected-window))
5958 (setq new-sum-point (point)
5959 new-sum-start (window-start win)
5960 new-sum-hscroll (window-hscroll win)))
5961 (when (eq in-buffer (current-buffer))
5962 (setq selected (gnus-summary-select-article))
5964 (unless not-restore-window
5965 (set-window-configuration owin))
5966 (when (eq selected 'old)
5968 (set-window-start (get-buffer-window (current-buffer))
5970 (set-window-point (get-buffer-window (current-buffer))
5972 (when (and (not not-restore-window)
5974 (set-window-point win new-sum-point)
5975 (set-window-start win new-sum-start)
5976 (set-window-hscroll win new-sum-hscroll))))
5977 (set-window-configuration owin)
5980 (defun gnus-article-describe-key (key)
5981 "Display documentation of the function invoked by KEY. KEY is a string."
5982 (interactive "kDescribe key: ")
5983 (gnus-article-check-buffer)
5984 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5986 (set-buffer gnus-article-current-summary)
5987 (let (gnus-pick-mode)
5988 (if (featurep 'xemacs)
5990 (push (elt key 0) unread-command-events)
5991 (setq key (events-to-keys
5992 (read-key-sequence "Describe key: "))))
5993 (setq unread-command-events
5995 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5996 (string-to-list key)))
5997 (setq key (read-key-sequence "Describe key: "))))
5999 (describe-key key)))
6001 (defun gnus-article-describe-key-briefly (key &optional insert)
6002 "Display documentation of the function invoked by KEY. KEY is a string."
6003 (interactive "kDescribe key: \nP")
6004 (gnus-article-check-buffer)
6005 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
6007 (set-buffer gnus-article-current-summary)
6008 (let (gnus-pick-mode)
6009 (if (featurep 'xemacs)
6011 (push (elt key 0) unread-command-events)
6012 (setq key (events-to-keys
6013 (read-key-sequence "Describe key: "))))
6014 (setq unread-command-events
6016 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
6017 (string-to-list key)))
6018 (setq key (read-key-sequence "Describe key: "))))
6019 (describe-key-briefly key insert))
6020 (describe-key-briefly key insert)))
6022 (defun gnus-article-reply-with-original (&optional wide)
6023 "Start composing a reply mail to the current message.
6024 The text in the region will be yanked. If the region isn't active,
6025 the entire article will be yanked."
6027 (let ((article (cdr gnus-article-current))
6029 (if (not (gnus-region-active-p))
6030 (with-current-buffer gnus-summary-buffer
6031 (gnus-summary-reply (list (list article)) wide))
6032 (setq contents (buffer-substring (point) (mark t)))
6033 ;; Deactivate active regions.
6034 (when (and (boundp 'transient-mark-mode)
6035 transient-mark-mode)
6036 (setq mark-active nil))
6037 (with-current-buffer gnus-summary-buffer
6039 (list (list article contents)) wide)))))
6041 (defun gnus-article-followup-with-original ()
6042 "Compose a followup to the current article.
6043 The text in the region will be yanked. If the region isn't active,
6044 the entire article will be yanked."
6046 (let ((article (cdr gnus-article-current))
6048 (if (not (gnus-region-active-p))
6049 (with-current-buffer gnus-summary-buffer
6050 (gnus-summary-followup (list (list article))))
6051 (setq contents (buffer-substring (point) (mark t)))
6052 ;; Deactivate active regions.
6053 (when (and (boundp 'transient-mark-mode)
6054 transient-mark-mode)
6055 (setq mark-active nil))
6056 (with-current-buffer gnus-summary-buffer
6057 (gnus-summary-followup
6058 (list (list article contents)))))))
6060 (defun gnus-article-hide (&optional arg force)
6061 "Hide all the gruft in the current article.
6062 This means that signatures, cited text and (some) headers will be
6064 If given a prefix, show the hidden text instead."
6065 (interactive (append (gnus-article-hidden-arg) (list 'force)))
6066 (gnus-article-hide-headers arg)
6067 (gnus-article-hide-list-identifiers arg)
6068 (gnus-article-hide-citation-maybe arg force)
6069 (gnus-article-hide-signature arg))
6071 (defun gnus-article-maybe-highlight ()
6072 "Do some article highlighting if article highlighting is requested."
6073 (when (gnus-visual-p 'article-highlight 'highlight)
6074 (gnus-article-highlight-some)))
6076 (defun gnus-check-group-server ()
6077 ;; Make sure the connection to the server is alive.
6078 (unless (gnus-server-opened
6079 (gnus-find-method-for-group gnus-newsgroup-name))
6080 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
6081 (gnus-request-group gnus-newsgroup-name t)))
6084 (autoload 'nneething-get-file-name "nneething"))
6086 (defun gnus-request-article-this-buffer (article group)
6087 "Get an article and insert it into this buffer."
6088 (let (do-update-line sparse-header)
6092 (gnus-kill-all-overlays)
6093 (setq group (or group gnus-newsgroup-name))
6095 ;; Using `gnus-request-article' directly will insert the article into
6096 ;; `nntp-server-buffer' - so we'll save some time by not having to
6097 ;; copy it from the server buffer into the article buffer.
6099 ;; We only request an article by message-id when we do not have the
6100 ;; headers for it, so we'll have to get those.
6101 (when (stringp article)
6102 (gnus-read-header article))
6104 ;; If the article number is negative, that means that this article
6105 ;; doesn't belong in this newsgroup (possibly), so we find its
6106 ;; message-id and request it by id instead of number.
6107 (when (and (numberp article)
6109 (get-buffer gnus-summary-buffer)
6110 (gnus-buffer-exists-p gnus-summary-buffer))
6112 (set-buffer gnus-summary-buffer)
6113 (let ((header (gnus-summary-article-header article)))
6116 ((memq article gnus-newsgroup-sparse)
6117 ;; This is a sparse gap article.
6118 (setq do-update-line article)
6119 (setq article (mail-header-id header))
6120 (setq sparse-header (gnus-read-header article))
6121 (setq gnus-newsgroup-sparse
6122 (delq article gnus-newsgroup-sparse)))
6124 ;; It's a real article.
6125 (setq article (mail-header-id header)))
6127 ;; It is an extracted pseudo-article.
6128 (setq article 'pseudo)
6129 (gnus-request-pseudo-article header))))
6131 (let ((method (gnus-find-method-for-group
6132 gnus-newsgroup-name)))
6133 (when (and (eq (car method) 'nneething)
6135 (let ((dir (nneething-get-file-name
6136 (mail-header-id header))))
6137 (when (and (stringp dir)
6138 (file-directory-p dir))
6139 (setq article 'nneething)
6140 (gnus-group-enter-directory dir))))))))
6143 ;; Refuse to select canceled articles.
6144 ((and (numberp article)
6146 (get-buffer gnus-summary-buffer)
6147 (gnus-buffer-exists-p gnus-summary-buffer)
6148 (eq (cdr (with-current-buffer gnus-summary-buffer
6149 (assq article gnus-newsgroup-reads)))
6150 gnus-canceled-mark))
6152 ;; We first check `gnus-original-article-buffer'.
6153 ((and (get-buffer gnus-original-article-buffer)
6155 (with-current-buffer gnus-original-article-buffer
6156 (and (equal (car gnus-original-article) group)
6157 (eq (cdr gnus-original-article) article))))
6158 (insert-buffer-substring gnus-original-article-buffer)
6160 ;; Check the backlog.
6161 ((and gnus-keep-backlog
6162 (gnus-backlog-request-article group article (current-buffer)))
6164 ;; Check asynchronous pre-fetch.
6165 ((gnus-async-request-fetched-article group article (current-buffer))
6166 (gnus-async-prefetch-next group article gnus-summary-buffer)
6167 (when (and (numberp article) gnus-keep-backlog)
6168 (gnus-backlog-enter-article group article (current-buffer)))
6171 ((and gnus-use-cache
6173 (gnus-cache-request-article article group))
6175 ;; Check the agent cache.
6176 ((gnus-agent-request-article article group)
6178 ;; Get the article and put into the article buffer.
6179 ((or (stringp article)
6181 (let ((gnus-override-method gnus-override-method)
6182 (methods (and (stringp article)
6183 gnus-refer-article-method))
6184 (backend (car (gnus-find-method-for-group
6185 gnus-newsgroup-name)))
6187 (inhibit-read-only t))
6188 (if (or (not (listp methods))
6189 (and (symbolp (car methods))
6190 (assq (car methods) nnoo-definition-alist)))
6191 (setq methods (list methods)))
6192 (when (and (null gnus-override-method)
6194 (setq gnus-override-method (pop methods)))
6196 (when (eq gnus-override-method 'current)
6197 (setq gnus-override-method
6198 (with-current-buffer gnus-summary-buffer
6199 gnus-current-select-method)))
6201 (gnus-kill-all-overlays)
6202 (let ((gnus-newsgroup-name group))
6203 (gnus-check-group-server))
6205 ((gnus-request-article article group (current-buffer))
6206 (when (numberp article)
6207 (gnus-async-prefetch-next group article
6208 gnus-summary-buffer)
6209 (when gnus-keep-backlog
6210 (gnus-backlog-enter-article
6211 group article (current-buffer))))
6212 (setq result 'article))
6214 (setq gnus-override-method (pop methods)))
6215 ((not (string-match "^400 "
6216 (nnheader-get-report backend)))
6217 ;; If we get 400 server disconnect, reconnect and
6218 ;; retry; otherwise, assume the article has expired.
6219 (setq result 'done))))
6220 (and (eq result 'article) 'article)))
6224 ;; Associate this article with the current summary buffer.
6225 (setq gnus-article-current-summary gnus-summary-buffer)
6227 ;; Take the article from the original article buffer
6228 ;; and place it in the buffer it's supposed to be in.
6229 (when (and (get-buffer gnus-article-buffer)
6230 (equal (buffer-name (current-buffer))
6231 (buffer-name (get-buffer gnus-article-buffer))))
6233 (if (get-buffer gnus-original-article-buffer)
6234 (set-buffer gnus-original-article-buffer)
6235 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
6236 (buffer-disable-undo)
6237 (setq major-mode 'gnus-original-article-mode)
6238 (setq buffer-read-only t))
6239 (let ((inhibit-read-only t))
6241 (insert-buffer-substring gnus-article-buffer))
6242 (setq gnus-original-article (cons group article)))
6245 (run-hooks 'gnus-article-decode-hook)
6246 ;; Mark article as decoded or not.
6247 (setq gnus-article-decoded-p gnus-article-decode-hook))
6249 ;; Update sparse articles.
6250 (when (and do-update-line
6251 (or (numberp article)
6253 (let ((buf (current-buffer)))
6254 (set-buffer gnus-summary-buffer)
6255 (gnus-summary-update-article do-update-line sparse-header)
6256 (gnus-summary-goto-subject do-update-line nil t)
6257 (set-window-point (gnus-get-buffer-window (current-buffer) t)
6259 (set-buffer buf))))))
6265 (defcustom gnus-article-edit-mode-hook nil
6266 "Hook run in article edit mode buffers."
6267 :group 'gnus-article-various
6270 (defvar gnus-article-edit-done-function nil)
6272 (defvar gnus-article-edit-mode-map nil)
6274 ;; Should we be using derived.el for this?
6275 (unless gnus-article-edit-mode-map
6276 (setq gnus-article-edit-mode-map (make-keymap))
6277 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
6279 (gnus-define-keys gnus-article-edit-mode-map
6280 "\C-c?" describe-mode
6281 "\C-c\C-c" gnus-article-edit-done
6282 "\C-c\C-k" gnus-article-edit-exit
6283 "\C-c\C-f\C-t" message-goto-to
6284 "\C-c\C-f\C-o" message-goto-from
6285 "\C-c\C-f\C-b" message-goto-bcc
6286 ;;"\C-c\C-f\C-w" message-goto-fcc
6287 "\C-c\C-f\C-c" message-goto-cc
6288 "\C-c\C-f\C-s" message-goto-subject
6289 "\C-c\C-f\C-r" message-goto-reply-to
6290 "\C-c\C-f\C-n" message-goto-newsgroups
6291 "\C-c\C-f\C-d" message-goto-distribution
6292 "\C-c\C-f\C-f" message-goto-followup-to
6293 "\C-c\C-f\C-m" message-goto-mail-followup-to
6294 "\C-c\C-f\C-k" message-goto-keywords
6295 "\C-c\C-f\C-u" message-goto-summary
6296 "\C-c\C-f\C-i" message-insert-or-toggle-importance
6297 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
6298 "\C-c\C-b" message-goto-body
6299 "\C-c\C-i" message-goto-signature
6301 "\C-c\C-t" message-insert-to
6302 "\C-c\C-n" message-insert-newsgroups
6303 "\C-c\C-o" message-sort-headers
6304 "\C-c\C-e" message-elide-region
6305 "\C-c\C-v" message-delete-not-region
6306 "\C-c\C-z" message-kill-to-signature
6307 "\M-\r" message-newline-and-reformat
6308 "\C-c\C-a" mml-attach-file
6309 "\C-a" message-beginning-of-line
6311 "\M-;" comment-region)
6313 (gnus-define-keys (gnus-article-edit-wash-map
6314 "\C-c\C-w" gnus-article-edit-mode-map)
6315 "f" gnus-article-edit-full-stops))
6318 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
6320 ["Fetch To" message-insert-to t]
6321 ["Fetch Newsgroups" message-insert-newsgroups t]
6323 ["To" message-goto-to t]
6324 ["From" message-goto-from t]
6325 ["Subject" message-goto-subject t]
6326 ["Cc" message-goto-cc t]
6327 ["Reply-To" message-goto-reply-to t]
6328 ["Summary" message-goto-summary t]
6329 ["Keywords" message-goto-keywords t]
6330 ["Newsgroups" message-goto-newsgroups t]
6331 ["Followup-To" message-goto-followup-to t]
6332 ["Mail-Followup-To" message-goto-mail-followup-to t]
6333 ["Distribution" message-goto-distribution t]
6334 ["Body" message-goto-body t]
6335 ["Signature" message-goto-signature t]))
6337 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
6338 "Major mode for editing articles.
6339 This is an extended text-mode.
6341 \\{gnus-article-edit-mode-map}"
6342 (make-local-variable 'gnus-article-edit-done-function)
6343 (make-local-variable 'gnus-prev-winconf)
6344 (set (make-local-variable 'font-lock-defaults)
6345 '(message-font-lock-keywords t))
6346 (set (make-local-variable 'mail-header-separator) "")
6347 (set (make-local-variable 'gnus-article-edit-mode) t)
6348 (easy-menu-add message-mode-field-menu message-mode-map)
6350 (setq buffer-read-only nil)
6351 (buffer-enable-undo)
6354 (defun gnus-article-edit (&optional force)
6355 "Edit the current article.
6356 This will have permanent effect only in mail groups.
6357 If FORCE is non-nil, allow editing of articles even in read-only
6360 (when (and (not force)
6361 (gnus-group-read-only-p))
6362 (error "The current newsgroup does not support article editing"))
6363 (gnus-article-date-original)
6364 (gnus-article-edit-article
6366 `(lambda (no-highlight)
6368 (gnus-summary-edit-article-done
6369 ,(or (mail-header-references gnus-current-headers) "")
6370 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
6372 (defun gnus-article-edit-article (start-func exit-func &optional quiet)
6373 "Start editing the contents of the current article buffer."
6374 (let ((winconf (current-window-configuration)))
6375 (set-buffer gnus-article-buffer)
6376 (let ((message-auto-save-directory
6377 ;; Don't associate the article buffer with a draft file.
6379 (gnus-article-edit-mode))
6380 (funcall start-func)
6381 (set-buffer-modified-p nil)
6382 (gnus-configure-windows 'edit-article)
6383 (setq gnus-article-edit-done-function exit-func)
6384 (setq gnus-prev-winconf winconf)
6386 (gnus-message 6 "C-c C-c to end edits"))))
6388 (defun gnus-article-edit-done (&optional arg)
6389 "Update the article edits and exit."
6391 (let ((func gnus-article-edit-done-function)
6392 (buf (current-buffer))
6393 (start (window-start))
6395 (winconf gnus-prev-winconf))
6396 (widen) ;; Widen it in case that users narrowed the buffer.
6399 ;; The cache and backlog have to be flushed somewhat.
6400 (when gnus-keep-backlog
6401 (gnus-backlog-remove-article
6402 (car gnus-article-current) (cdr gnus-article-current)))
6403 ;; Flush original article as well.
6405 (when (get-buffer gnus-original-article-buffer)
6406 (set-buffer gnus-original-article-buffer)
6407 (setq gnus-original-article nil)))
6408 (when gnus-use-cache
6409 (gnus-cache-update-article
6410 (car gnus-article-current) (cdr gnus-article-current)))
6411 ;; We remove all text props from the article buffer.
6412 (kill-all-local-variables)
6413 (set-text-properties (point-min) (point-max) nil)
6415 (set-window-configuration winconf)
6417 (set-window-start (get-buffer-window buf) start)
6418 (set-window-point (get-buffer-window buf) (point)))
6419 (gnus-summary-show-article))
6421 (defun gnus-article-edit-exit ()
6422 "Exit the article editing without updating."
6424 (when (or (not (buffer-modified-p))
6425 (yes-or-no-p "Article modified; kill anyway? "))
6426 (let ((curbuf (current-buffer))
6428 (window-start (window-start)))
6430 (if (gnus-buffer-live-p gnus-original-article-buffer)
6431 (insert-buffer-substring gnus-original-article-buffer))
6432 (let ((winconf gnus-prev-winconf))
6433 (kill-all-local-variables)
6435 (set-window-configuration winconf)
6436 ;; Tippy-toe some to make sure that point remains where it was.
6437 (save-current-buffer
6439 (set-window-start (get-buffer-window (current-buffer)) window-start)
6441 (gnus-summary-show-article)))
6443 (defun gnus-article-edit-full-stops ()
6444 "Interactively repair spacing at end of sentences."
6447 (goto-char (point-min))
6448 (search-forward-regexp "^$" nil t)
6449 (let ((case-fold-search nil))
6450 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
6453 ;;; Article highlights
6456 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6458 ;;; Internal Variables:
6460 (defcustom gnus-button-url-regexp
6462 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|"
6463 "nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)"
6464 "\\(//[-a-z0-9_.]+:[0-9]*\\)?"
6465 (if (string-match "[[:digit:]]" "1") ;; Support POSIX?
6466 "[-a-z0-9_=!?#$@~%&*+\\/:;.,[:word:]]+[-a-z0-9_=#$@~%&*+\\/[:word:]]"
6467 (concat ;; XEmacs 21.4 doesn't support POSIX.
6468 "\\([-a-z0-9_=!?#$@~%&*+\\/:;.,]\\|\\w\\)+"
6469 "\\([-a-z0-9_=#$@~%&*+\\/]\\|\\w\\)"))
6471 "Regular expression that matches URLs."
6472 :group 'gnus-article-buttons
6475 (defcustom gnus-button-valid-fqdn-regexp
6476 message-valid-fqdn-regexp
6477 "Regular expression that matches a valid FQDN."
6479 :group 'gnus-article-buttons
6482 ;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
6483 (defcustom gnus-button-valid-localpart-regexp
6484 "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t @]*"
6485 "Regular expression that matches a localpart of mail addresses or MIDs."
6487 :group 'gnus-article-buttons
6490 (defcustom gnus-button-man-handler 'manual-entry
6491 "Function to use for displaying man pages.
6492 The function must take at least one argument with a string naming the
6495 :type '(choice (function-item :tag "Man" manual-entry)
6496 (function-item :tag "Woman" woman)
6497 (function :tag "Other"))
6498 :group 'gnus-article-buttons)
6500 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6501 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6502 If the default site is too slow, try to find a CTAN mirror, see
6503 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6504 the variable `gnus-button-handle-ctan'."
6506 :group 'gnus-article-buttons
6507 :link '(custom-manual "(gnus)Group Parameters")
6508 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6509 (const "http://tug.ctan.org/tex-archive/")
6510 (const "http://www.dante.de/CTAN/")
6511 (string :tag "Other")))
6513 (defcustom gnus-button-ctan-handler 'browse-url
6514 "Function to use for displaying CTAN links.
6515 The function must take one argument, the string naming the URL."
6517 :type '(choice (function-item :tag "Browse Url" browse-url)
6518 (function :tag "Other"))
6519 :group 'gnus-article-buttons)
6521 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6522 "Bogus strings removed from CTAN URLs."
6524 :group 'gnus-article-buttons
6525 :type '(choice (const "^/?tex-archive/\\|/")
6526 (regexp :tag "Other")))
6528 (defcustom gnus-button-ctan-directory-regexp
6530 (list "archive-tools" "biblio" "bibliography" "digests" "documentation"
6531 "dviware" "fonts" "graphics" "help" "indexing" "info" "language"
6532 "languages" "macros" "nonfree" "obsolete" "support" "systems"
6533 "tds" "tools" "usergrps" "web") t)
6534 "Regular expression for ctan directories.
6535 It should match all directories in the top level of `gnus-ctan-url'."
6537 :group 'gnus-article-buttons
6540 (defcustom gnus-button-mid-or-mail-regexp
6541 (concat "\\b\\(<?" gnus-button-valid-localpart-regexp "@"
6542 gnus-button-valid-fqdn-regexp
6544 "Regular expression that matches a message ID or a mail address."
6546 :group 'gnus-article-buttons
6549 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6550 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6551 Strings like this can be either a message ID or a mail address. If it is one
6552 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6553 message ID or a mail address, respectively. If this variable is set to the
6554 symbol `ask', always query the user what do do. If it is a function, this
6555 function will be called with the string as it's only argument. The function
6556 must return `mid', `mail', `invalid' or `ask'."
6558 :group 'gnus-article-buttons
6559 :type '(choice (function-item :tag "Heuristic function"
6560 gnus-button-mid-or-mail-heuristic)
6565 (defcustom gnus-button-mid-or-mail-heuristic-alist
6566 '((-10.0 . ".+\\$.+@")
6569 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6570 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6571 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6572 (-1.0 . "^[^a-z]+@")
6574 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6575 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6576 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6577 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6580 (-1.0 . "^[0-9][0-9]")
6582 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6583 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6584 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6585 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6587 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6588 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6591 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6593 ;; compensation for TDMA dated mail addresses:
6594 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6596 (-20.0 . "\\.fsf@") ;; Gnus
6599 (-20.0 . "_-_") ;; Subject change in thread
6601 (-20.0 . "\\.ln@") ;; leafnode
6602 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6603 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6605 ;; (5.0 . "") ;; $local_part_len <= 7
6606 (10.0 . "^[^0-9]+@")
6607 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6608 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6611 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6613 (0.5 . "^[A-Z][a-z]")
6614 (0.5 . "^[A-Z][a-z][a-z]")
6615 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6616 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6617 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6619 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6620 address. The REGEXP is processed with `case-fold-search' set to nil."
6622 :group 'gnus-article-buttons
6623 :type '(repeat (cons (number :tag "Rate")
6624 (regexp :tag "Regexp"))))
6626 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6627 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6628 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6629 address, `ask' if unsure and `invalid' if the string is invalid."
6630 (let ((case-fold-search nil)
6631 (list gnus-button-mid-or-mail-heuristic-alist)
6632 (result 0) rate regexp lpartlen elem)
6634 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6635 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6636 ;; Certain special cases...
6639 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6640 "^[0-9]+\\.[0-9]+@compuserve\\|"
6641 "@public\\.gmane\\.org")
6643 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6644 (setq result 'mail))
6645 (when (string-match "@.*@\\| " mid-or-mail)
6646 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6647 (setq result 'invalid))
6648 ;; Nothing more to do, if result is not a number here...
6649 (when (numberp result)
6651 (setq elem (car list)
6655 (when (string-match regexp mid-or-mail)
6656 (setq result (+ result rate))
6658 9 "`%s' matched `%s', rate `%s', result `%s'."
6659 mid-or-mail regexp rate result)))
6660 (when (<= lpartlen 7)
6661 (setq result (+ result 5.0))
6662 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6663 mid-or-mail result))
6664 (when (>= lpartlen 12)
6665 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6667 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6668 ;; Long local part should contain realname if e-mail address,
6669 ;; too many digits: message-id.
6670 ;; $score -= 5.0 + 0.1 * $local_part_len;
6671 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6672 (setq result (+ result rate))
6674 9 "Many digits in `%s', rate `%s', result `%s'."
6675 mid-or-mail rate result))
6676 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6678 ;; Too few vowels [^aeiouy]{4,}.*\@
6679 (setq result (+ result -5.0))
6681 9 "Few vowels in `%s', rate `%s', result `%s'."
6682 mid-or-mail -5.0 result))
6684 (setq result (+ result 5.0))
6686 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6687 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6688 ;; Maybe we should make this a customizable alist: (condition . 'result)
6690 ((symbolp result) result)
6691 ;; Now convert number into proper results:
6692 ((< result -10.0) 'mid)
6693 ((> result 10.0) 'mail)
6696 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6697 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6698 (url-mid (concat "news" ":" mid-or-mail))
6699 (url-mailto (concat "mailto" ":" mid-or-mail)))
6700 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6701 (when (fboundp pref)
6703 ;; get rid of surrounding angles...
6705 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6706 (if (or (eq 'mid guessed) (eq 'mail guessed))
6710 (save-window-excursion
6711 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6714 (cond ((eq pref 'mid)
6715 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6716 (gnus-button-handle-news url-mid))
6718 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6719 (gnus-url-mailto url-mailto))
6720 (t (gnus-message 3 "Invalid string.")))))
6722 (defun gnus-button-handle-custom (fun arg)
6723 "Call function FUN on argument ARG.
6724 Both FUN and ARG are supposed to be strings. ARG will be passed
6725 as a symbol to FUN."
6726 (funcall (intern fun)
6727 (if (string-match "^customize-apropos" fun)
6731 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6733 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6736 (defun gnus-button-handle-describe-function (url)
6737 "Call `describe-function' when pushing the corresponding URL button."
6740 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6742 (defun gnus-button-handle-describe-variable (url)
6743 "Call `describe-variable' when pushing the corresponding URL button."
6746 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6748 (defun gnus-button-handle-symbol (url)
6749 "Display help on variable or function.
6750 Calls `describe-variable' or `describe-function'."
6751 (let ((sym (intern url)))
6753 ((fboundp sym) (describe-function sym))
6754 ((boundp sym) (describe-variable sym))
6755 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6757 (defun gnus-button-handle-describe-key (url)
6758 "Call `describe-key' when pushing the corresponding URL button."
6760 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6761 (keys (ignore-errors (eval `(kbd ,key-string)))))
6764 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6766 (defun gnus-button-handle-apropos (url)
6767 "Call `apropos' when pushing the corresponding URL button."
6768 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6770 (defun gnus-button-handle-apropos-command (url)
6771 "Call `apropos' when pushing the corresponding URL button."
6773 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6775 (defun gnus-button-handle-apropos-variable (url)
6776 "Call `apropos' when pushing the corresponding URL button."
6778 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6779 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6781 (defun gnus-button-handle-apropos-documentation (url)
6782 "Call `apropos' when pushing the corresponding URL button."
6784 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6785 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6787 (defun gnus-button-handle-library (url)
6788 "Call `locate-library' when pushing the corresponding URL button."
6789 (gnus-message 9 "url=`%s'" url)
6790 (let* ((lib (locate-library url))
6791 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6793 (gnus-message 1 "Cannot locale library `%s'." url)
6794 (find-file-read-only file))))
6796 (defun gnus-button-handle-ctan (url)
6797 "Call `browse-url' when pushing a CTAN URL button."
6799 gnus-button-ctan-handler
6802 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6804 (defcustom gnus-button-tex-level 5
6805 "*Integer that says how many TeX-related buttons Gnus will show.
6806 The higher the number, the more buttons will appear and the more false
6807 positives are possible. Note that you can set this variable local to
6808 specific groups. Setting it higher in TeX groups is probably a good idea.
6809 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6810 how to set variables in specific groups."
6812 :group 'gnus-article-buttons
6813 :link '(custom-manual "(gnus)Group Parameters")
6816 (defcustom gnus-button-man-level 5
6817 "*Integer that says how many man-related buttons Gnus will show.
6818 The higher the number, the more buttons will appear and the more false
6819 positives are possible. Note that you can set this variable local to
6820 specific groups. Setting it higher in Unix groups is probably a good idea.
6821 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6822 how to set variables in specific groups."
6824 :group 'gnus-article-buttons
6825 :link '(custom-manual "(gnus)Group Parameters")
6828 (defcustom gnus-button-emacs-level 5
6829 "*Integer that says how many emacs-related buttons Gnus will show.
6830 The higher the number, the more buttons will appear and the more false
6831 positives are possible. Note that you can set this variable local to
6832 specific groups. Setting it higher in Emacs or Gnus related groups is
6833 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6834 `gnus-parameters' on how to set variables in specific groups."
6836 :group 'gnus-article-buttons
6837 :link '(custom-manual "(gnus)Group Parameters")
6840 (defcustom gnus-button-message-level 5
6841 "*Integer that says how many buttons for news or mail messages will appear.
6842 The higher the number, the more buttons will appear and the more false
6843 positives are possible."
6844 ;; mail addresses, MIDs, URLs for news, ...
6846 :group 'gnus-article-buttons
6849 (defcustom gnus-button-browse-level 5
6850 "*Integer that says how many buttons for browsing will appear.
6851 The higher the number, the more buttons will appear and the more false
6852 positives are possible."
6853 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6855 :group 'gnus-article-buttons
6858 (defcustom gnus-button-alist
6859 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6860 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6861 ((concat "\\b\\(nntp\\|news\\):\\("
6862 gnus-button-valid-localpart-regexp "@[a-z0-9.-]+[a-z]\\)")
6863 0 t gnus-button-handle-news 2)
6864 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6865 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6866 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6867 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6868 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6869 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6870 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6871 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6872 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6873 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6874 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6875 ;; RFC 2368 (The mailto URL scheme)
6876 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6877 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6878 ("\\bmailto:\\([^ \n\t]+\\)"
6879 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6881 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6882 gnus-button-ctan-directory-regexp
6883 "[^][>)!;:,'\n\t ]+\\)")
6884 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6885 ((concat "\\btex-archive/\\("
6886 gnus-button-ctan-directory-regexp
6887 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6888 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6891 gnus-button-ctan-directory-regexp
6892 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6893 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6894 ;; This is info (home-grown style) <info://foo/bar+baz>
6895 ("\\binfo://\\([^'\">\n\t ]+\\)"
6896 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6897 ;; Info GNOME style <info:foo#bar_baz>
6898 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6899 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6900 ;; Info KDE style <info:(foo)bar baz>
6901 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6902 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6903 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6904 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6905 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6906 ;; Info links like `C-h i d m CC Mode RET'
6907 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6909 ("M-x[ \t\n]\\(customize-[^ ]+\\)[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6910 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1 2)
6911 ;; Emacs help commands
6912 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6913 ;; regexp doesn't match arguments containing ` '.
6914 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6915 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6916 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6917 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6918 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6919 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6920 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6921 ;; The following entries may lead to many false positives so don't enable
6922 ;; them by default (use a high button level).
6923 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6924 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6925 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6926 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6927 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6928 ("`\\([a-z][a-z0-9]+-[a-z0-9]+-[-a-z0-9]*[a-z]\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6929 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6930 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6931 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6932 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6933 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6934 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6935 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6936 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6937 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6938 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6939 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6940 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6941 ;; Unlike the other regexps we really have to require quoting
6942 ;; here to determine where it ends.
6943 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6944 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6945 ("<URL: *\\([^<>]*\\)>"
6946 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6947 ;; RFC 2396 (2.4.3., delims) ...
6948 ("\"URL: *\\([^\"]*\\)\""
6949 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6950 ;; RFC 2396 (2.4.3., delims) ...
6951 ("\"URL: *\\([^\"]*\\)\""
6952 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6954 (gnus-button-url-regexp
6955 0 (>= gnus-button-browse-level 0) browse-url 0)
6957 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6958 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6959 gnus-button-handle-man 1)
6960 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6961 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6962 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6963 gnus-button-handle-man 1)
6964 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6965 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6966 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6967 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6968 ;; Recognizing patches to .el files. This is somewhat obscure,
6969 ;; but considering the percentage of Gnus users who hack Emacs
6971 ("^--- \\([^ .]+\\.el\\).*\n.*\n@@ -?\\([0-9]+\\)" 1
6972 (>= gnus-button-message-level 4) gnus-button-patch 1 2)
6973 ("^\\*\\*\\* \\([^ .]+\\.el\\).*\n.*\n\\*+\n\\*\\*\\* \\([0-9]+\\)" 1
6974 (>= gnus-button-message-level 4) gnus-button-patch 1 2)
6975 ;; MID or mail: To avoid too many false positives we don't try to catch
6976 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6977 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6978 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6979 ;; so that non-ambiguous entries (see above) match first.
6980 (gnus-button-mid-or-mail-regexp
6981 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6982 "*Alist of regexps matching buttons in article bodies.
6984 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6985 REGEXP: is the string (case insensitive) matching text around the button (can
6986 also be Lisp expression evaluating to a string),
6987 BUTTON: is the number of the regexp grouping actually matching the button,
6988 FORM: is a Lisp expression which must eval to true for the button to
6990 CALLBACK: is the function to call when the user push this button, and each
6991 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6993 CALLBACK can also be a variable, in that case the value of that
6994 variable it the real callback function."
6995 :group 'gnus-article-buttons
6996 :type '(repeat (list (choice regexp variable sexp)
6997 (integer :tag "Button")
6999 (function :tag "Callback")
7002 (integer :tag "Regexp group")))))
7004 (defcustom gnus-header-button-alist
7005 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
7006 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
7007 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
7008 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
7009 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
7010 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
7011 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
7012 0 (>= gnus-button-browse-level 0) browse-url 0)
7013 ("^Subject:" gnus-button-url-regexp
7014 0 (>= gnus-button-browse-level 0) browse-url 0)
7015 ("^[^:]+:" gnus-button-url-regexp
7016 0 (>= gnus-button-browse-level 0) browse-url 0)
7017 ("^OpenPGP:.*url=" gnus-button-url-regexp
7018 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
7019 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
7020 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7021 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
7022 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
7023 "*Alist of headers and regexps to match buttons in article heads.
7025 This alist is very similar to `gnus-button-alist', except that each
7026 alist has an additional HEADER element first in each entry:
7028 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
7030 HEADER is a regexp to match a header. For a fuller explanation, see
7031 `gnus-button-alist'."
7032 :group 'gnus-article-buttons
7033 :group 'gnus-article-headers
7034 :type '(repeat (list (regexp :tag "Header")
7035 (choice regexp variable)
7036 (integer :tag "Button")
7038 (function :tag "Callback")
7041 (integer :tag "Regexp group")))))
7045 (defun gnus-article-push-button (event)
7046 "Check text under the mouse pointer for a callback function.
7047 If the text under the mouse pointer has a `gnus-callback' property,
7048 call it with the value of the `gnus-data' text property."
7050 (set-buffer (window-buffer (posn-window (event-start event))))
7051 (let* ((pos (posn-point (event-start event)))
7052 (data (get-text-property pos 'gnus-data))
7053 (fun (get-text-property pos 'gnus-callback)))
7056 (funcall fun data))))
7058 (defun gnus-article-press-button ()
7059 "Check text at point for a callback function.
7060 If the text at point has a `gnus-callback' property,
7061 call it with the value of the `gnus-data' text property."
7063 (let ((data (get-text-property (point) 'gnus-data))
7064 (fun (get-text-property (point) 'gnus-callback)))
7066 (funcall fun data))))
7068 (defun gnus-article-highlight (&optional force)
7069 "Highlight current article.
7070 This function calls `gnus-article-highlight-headers',
7071 `gnus-article-highlight-citation',
7072 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7073 do the highlighting. See the documentation for those functions."
7074 (interactive (list 'force))
7075 (gnus-article-highlight-headers)
7076 (gnus-article-highlight-citation force)
7077 (gnus-article-highlight-signature)
7078 (gnus-article-add-buttons force)
7079 (gnus-article-add-buttons-to-head))
7081 (defun gnus-article-highlight-some (&optional force)
7082 "Highlight current article.
7083 This function calls `gnus-article-highlight-headers',
7084 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7085 do the highlighting. See the documentation for those functions."
7086 (interactive (list 'force))
7087 (gnus-article-highlight-headers)
7088 (gnus-article-highlight-signature)
7089 (gnus-article-add-buttons))
7091 (defun gnus-article-highlight-headers ()
7092 "Highlight article headers as specified by `gnus-header-face-alist'."
7094 (gnus-with-article-headers
7095 (let (regexp header-face field-face from hpoints fpoints)
7096 (dolist (entry gnus-header-face-alist)
7097 (goto-char (point-min))
7098 (setq regexp (concat "^\\("
7099 (if (string-equal "" (nth 0 entry))
7103 header-face (nth 1 entry)
7104 field-face (nth 2 entry))
7105 (while (and (re-search-forward regexp nil t)
7109 (unless (search-forward ":" nil t)
7111 (when (and header-face
7112 (not (memq (point) hpoints)))
7113 (push (point) hpoints)
7114 (gnus-put-text-property from (point) 'face header-face))
7115 (when (and field-face
7116 (not (memq (setq from (point)) fpoints)))
7118 (if (re-search-forward "^[^ \t]" nil t)
7120 (goto-char (point-max)))
7121 (gnus-put-text-property from (point) 'face field-face)))))))
7123 (defun gnus-article-highlight-signature ()
7124 "Highlight the signature in an article.
7125 It does this by highlighting everything after
7126 `gnus-signature-separator' using the face `gnus-signature'."
7128 (gnus-with-article-buffer
7129 (let ((inhibit-point-motion-hooks t))
7131 (when (and gnus-signature-face
7132 (gnus-article-narrow-to-signature))
7133 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
7134 'face gnus-signature-face)
7136 (gnus-article-search-signature)
7137 (let ((start (match-beginning 0))
7138 (end (set-marker (make-marker) (1+ (match-end 0)))))
7139 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
7142 (defun gnus-button-in-region-p (b e prop)
7143 "Say whether PROP exists in the region."
7144 (text-property-not-all b e prop nil))
7146 (defun gnus-article-add-buttons (&optional force)
7147 "Find external references in the article and make buttons of them.
7148 \"External references\" are things like Message-IDs and URLs, as
7149 specified by `gnus-button-alist'."
7150 (interactive (list 'force))
7151 (gnus-with-article-buffer
7152 (let ((inhibit-point-motion-hooks t)
7153 (case-fold-search t)
7154 (alist gnus-button-alist)
7156 ;; Remove all old markers.
7157 (let (marker entry new-list)
7158 (while (setq marker (pop gnus-button-marker-list))
7159 (if (or (< marker (point-min)) (>= marker (point-max)))
7160 (push marker new-list)
7162 (when (setq entry (gnus-button-entry))
7163 (put-text-property (match-beginning (nth 1 entry))
7164 (match-end (nth 1 entry))
7165 'gnus-callback nil))
7166 (set-marker marker nil)))
7167 (setq gnus-button-marker-list new-list))
7168 ;; We skip the headers.
7171 (while (setq entry (pop alist))
7172 (setq regexp (eval (car entry)))
7174 (while (re-search-forward regexp nil t)
7175 (let* ((start (and entry (match-beginning (nth 1 entry))))
7176 (end (and entry (match-end (nth 1 entry))))
7177 (from (match-beginning 0)))
7178 (when (and (or (eq t (nth 2 entry))
7179 (eval (nth 2 entry)))
7180 (not (gnus-button-in-region-p
7181 start end 'gnus-callback)))
7182 ;; That optional form returned non-nil, so we add the
7184 (gnus-article-add-button
7185 start end 'gnus-button-push
7186 (car (push (set-marker (make-marker) from)
7187 gnus-button-marker-list))))))))))
7189 ;; Add buttons to the head of an article.
7190 (defun gnus-article-add-buttons-to-head ()
7191 "Add buttons to the head of the article."
7193 (gnus-with-article-headers
7195 (dolist (entry gnus-header-button-alist)
7196 ;; Each alist entry.
7197 (goto-char (point-min))
7198 (while (re-search-forward (car entry) nil t)
7199 ;; Each header matching the entry.
7200 (setq beg (match-beginning 0))
7201 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
7202 (match-beginning 0))
7205 (while (re-search-forward (eval (nth 1 entry)) end t)
7206 ;; Each match within a header.
7207 (let* ((entry (cdr entry))
7208 (start (match-beginning (nth 1 entry)))
7209 (end (match-end (nth 1 entry)))
7210 (form (nth 2 entry)))
7211 (goto-char (match-end 0))
7213 (gnus-article-add-button
7214 start end (nth 3 entry)
7215 (buffer-substring (match-beginning (nth 4 entry))
7216 (match-end (nth 4 entry)))))))
7217 (goto-char end))))))
7219 ;;; External functions:
7221 (defun gnus-article-add-button (from to fun &optional data)
7222 "Create a button between FROM and TO with callback FUN and data DATA."
7223 (when gnus-article-button-face
7224 (gnus-overlay-put (gnus-make-overlay from to)
7225 'face gnus-article-button-face))
7226 (gnus-add-text-properties
7228 (nconc (and gnus-article-mouse-face
7229 (list gnus-mouse-face-prop gnus-article-mouse-face))
7230 (list 'gnus-callback fun)
7231 (and data (list 'gnus-data data))))
7232 (widget-convert-button 'link from to :action 'gnus-widget-press-button
7233 :button-keymap gnus-widget-button-keymap))
7235 ;;; Internal functions:
7237 (defun gnus-article-set-globals ()
7238 (with-current-buffer gnus-summary-buffer
7239 (gnus-set-global-variables)))
7241 (defun gnus-signature-toggle (end)
7242 (gnus-with-article-buffer
7243 (let ((inhibit-point-motion-hooks t))
7244 (if (text-property-any end (point-max) 'article-type 'signature)
7246 (gnus-delete-wash-type 'signature)
7247 (gnus-remove-text-properties-when
7248 'article-type 'signature end (point-max)
7249 (cons 'article-type (cons 'signature
7250 gnus-hidden-properties))))
7251 (gnus-add-wash-type 'signature)
7252 (gnus-add-text-properties-when
7253 'article-type nil end (point-max)
7254 (cons 'article-type (cons 'signature
7255 gnus-hidden-properties)))))
7256 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
7257 (gnus-set-mode-line 'article))))
7259 (defun gnus-button-entry ()
7260 ;; Return the first entry in `gnus-button-alist' matching this place.
7261 (let ((alist gnus-button-alist)
7264 (setq entry (pop alist))
7265 (if (looking-at (eval (car entry)))
7270 (defun gnus-button-push (marker)
7271 ;; Push button starting at MARKER.
7274 (let* ((entry (gnus-button-entry))
7275 (inhibit-point-motion-hooks t)
7277 (args (mapcar (lambda (group)
7278 (let ((string (match-string group)))
7279 (set-text-properties
7280 0 (length string) nil string)
7287 (fboundp (symbol-value fun)))
7288 (apply (symbol-value fun) args))
7290 (gnus-message 1 "You must define `%S' to use this button"
7291 (cons fun args)))))))
7293 (defun gnus-parse-news-url (url)
7294 (let (scheme server port group message-id articles)
7297 (goto-char (point-min))
7298 (when (looking-at "\\([A-Za-z]+\\):")
7299 (setq scheme (match-string 1))
7300 (goto-char (match-end 0)))
7301 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
7302 (setq server (match-string 1))
7303 (setq port (if (stringp (match-string 3))
7304 (string-to-number (match-string 3))
7306 (goto-char (match-end 0)))
7309 ((looking-at "\\(.*@.*\\)")
7310 (setq message-id (match-string 1)))
7311 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7312 (setq group (match-string 1)
7313 articles (split-string (match-string 2) "-")))
7314 ((looking-at "\\([^/]+\\)/?")
7315 (setq group (match-string 1)))
7317 (error "Unknown news URL syntax"))))
7318 (list scheme server port group message-id articles)))
7320 (defun gnus-button-handle-news (url)
7322 (destructuring-bind (scheme server port group message-id articles)
7323 (gnus-parse-news-url url)
7327 (set-buffer gnus-summary-buffer)
7329 (let ((gnus-refer-article-method
7330 (nconc (list (list 'nntp server))
7331 gnus-refer-article-method))
7332 (nntp-port-number (or port "nntp")))
7333 (gnus-message 7 "Fetching %s with %s"
7334 message-id gnus-refer-article-method)
7335 (gnus-summary-refer-article message-id))
7336 (gnus-summary-refer-article message-id))))
7338 (gnus-button-fetch-group url)))))
7340 (defun gnus-button-patch (library line)
7341 "Visit an Emacs Lisp library LIBRARY on line LINE."
7343 (let ((file (locate-library (file-name-nondirectory library))))
7345 (error "Couldn't find library %s" library))
7347 (goto-line (string-to-number line))))
7349 (defun gnus-button-handle-man (url)
7351 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7352 (when (eq gnus-button-man-handler 'woman)
7353 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
7354 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7355 (funcall gnus-button-man-handler url))
7357 (defun gnus-button-handle-info-url (url)
7358 "Fetch an info URL."
7359 (setq url (mm-subst-char-in-string ?+ ?\ url))
7361 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
7362 (gnus-info-find-node
7363 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
7365 ")" (gnus-url-unhex-string (match-string 2 url)))))
7366 ((string-match "([^)\"]+)[^\"]+" url)
7368 (gnus-replace-in-string
7369 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
7370 (gnus-info-find-node url))
7371 (t (error "Can't parse %s" url))))
7373 (defun gnus-button-handle-info-url-gnome (url)
7374 "Fetch GNOME style info URL."
7375 (setq url (mm-subst-char-in-string ?_ ?\ url))
7376 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
7377 (gnus-info-find-node
7379 (gnus-url-unhex-string
7380 (match-string 1 url))
7382 (or (gnus-url-unhex-string
7383 (match-string 2 url))
7385 (error "Can't parse %s" url)))
7387 (defun gnus-button-handle-info-url-kde (url)
7388 "Fetch KDE style info URL."
7389 (gnus-info-find-node (gnus-url-unhex-string url)))
7391 (defun gnus-button-handle-info-keystrokes (url)
7392 "Call `info' when pushing the corresponding URL button."
7393 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
7398 (defun gnus-button-openpgp (url)
7399 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
7401 (mm-url-insert-file-contents-external url)
7402 (pgg-snarf-keys-region (point-min) (point-max))
7403 (pgg-display-output-buffer nil nil nil)))
7405 (defun gnus-button-message-id (message-id)
7407 (with-current-buffer gnus-summary-buffer
7408 (gnus-summary-refer-article message-id)))
7410 (defun gnus-button-fetch-group (address)
7411 "Fetch GROUP specified by ADDRESS."
7412 (if (not (string-match "[:/]" address))
7413 ;; This is just a simple group url.
7414 (gnus-group-read-ephemeral-group address gnus-select-method)
7417 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
7419 (error "Can't parse %s" address)
7420 (gnus-group-read-ephemeral-group
7421 (match-string 4 address)
7422 `(nntp ,(match-string 1 address)
7423 (nntp-address ,(match-string 1 address))
7424 (nntp-port-number ,(if (match-end 3)
7425 (match-string 3 address)
7428 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
7430 (defun gnus-url-parse-query-string (query &optional downcase)
7431 (let (retval pairs cur key val)
7432 (setq pairs (split-string query "&"))
7434 (setq cur (car pairs)
7436 (if (not (string-match "=" cur))
7438 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
7439 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
7441 (setq key (downcase key)))
7442 (setq cur (assoc key retval))
7444 (setcdr cur (cons val (cdr cur)))
7445 (setq retval (cons (list key val) retval)))))
7448 (defun gnus-url-mailto (url)
7449 ;; Send mail to someone
7450 (when (string-match "mailto:/*\\(.*\\)" url)
7451 (setq url (substring url (match-beginning 1) nil)))
7452 (let (to args subject func)
7453 (setq args (gnus-url-parse-query-string
7454 (if (string-match "^\\?" url)
7456 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
7457 (concat "to=" (match-string 1 url) "&"
7458 (match-string 2 url))
7459 (concat "to=" url)))
7461 subject (cdr-safe (assoc "subject" args)))
7464 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
7467 (message-position-on-field (caar args)))
7468 (insert (gnus-replace-in-string
7469 (mapconcat 'identity (reverse (cdar args)) ", ")
7471 (setq args (cdr args)))
7474 (message-goto-subject))))
7476 (defun gnus-button-embedded-url (address)
7477 "Activate ADDRESS with `browse-url'."
7478 (browse-url (gnus-strip-whitespace address)))
7480 ;;; Next/prev buttons in the article buffer.
7482 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
7483 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
7485 (defvar gnus-prev-page-map
7486 (let ((map (make-sparse-keymap)))
7487 (define-key map gnus-mouse-2 'gnus-button-prev-page)
7488 (define-key map "\r" 'gnus-button-prev-page)
7491 (defvar gnus-next-page-map
7492 (let ((map (make-sparse-keymap)))
7493 (unless (>= emacs-major-version 21)
7494 ;; XEmacs doesn't care.
7495 (set-keymap-parent map gnus-article-mode-map))
7496 (define-key map gnus-mouse-2 'gnus-button-next-page)
7497 (define-key map "\r" 'gnus-button-next-page)
7500 (defun gnus-insert-prev-page-button ()
7503 (inhibit-read-only t))
7505 gnus-prev-page-line-format nil
7506 `(keymap ,gnus-prev-page-map
7508 gnus-callback gnus-article-button-prev-page
7509 article-type annotation))
7512 ;; Exclude a newline.
7515 (when gnus-article-button-face
7516 (gnus-overlay-put (gnus-make-overlay b e)
7517 'face gnus-article-button-face))
7518 (widget-convert-button
7520 :action 'gnus-button-prev-page
7521 :button-keymap gnus-prev-page-map)))
7523 (defun gnus-button-next-page (&optional args more-args)
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-button-prev-page (&optional args more-args)
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 (defun gnus-insert-next-page-button ()
7542 (inhibit-read-only t))
7543 (gnus-eval-format gnus-next-page-line-format nil
7544 `(keymap ,gnus-next-page-map
7546 gnus-callback gnus-article-button-next-page
7547 article-type annotation))
7550 ;; Exclude a newline.
7553 (when gnus-article-button-face
7554 (gnus-overlay-put (gnus-make-overlay b e)
7555 'face gnus-article-button-face))
7556 (widget-convert-button
7558 :action 'gnus-button-next-page
7559 :button-keymap gnus-next-page-map)))
7561 (defun gnus-article-button-next-page (arg)
7562 "Go to the next page."
7564 (let ((win (selected-window)))
7565 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7566 (gnus-article-next-page)
7567 (select-window win)))
7569 (defun gnus-article-button-prev-page (arg)
7570 "Go to the prev page."
7572 (let ((win (selected-window)))
7573 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7574 (gnus-article-prev-page)
7575 (select-window win)))
7577 (defvar gnus-decode-header-methods
7578 '(mail-decode-encoded-word-region)
7579 "List of methods used to decode headers.
7581 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7582 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
7583 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
7584 whose names match REGEXP.
7587 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7588 mail-decode-encoded-word-region
7589 (\"chinese\" . rfc1843-decode-region))
7592 (defvar gnus-decode-header-methods-cache nil)
7594 (defun gnus-multi-decode-header (start end)
7595 "Apply the functions from `gnus-encoded-word-methods' that match."
7596 (unless (and gnus-decode-header-methods-cache
7597 (eq gnus-newsgroup-name
7598 (car gnus-decode-header-methods-cache)))
7599 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7602 (nconc gnus-decode-header-methods-cache (list x))
7603 (if (and gnus-newsgroup-name
7604 (string-match (car x) gnus-newsgroup-name))
7605 (nconc gnus-decode-header-methods-cache
7607 gnus-decode-header-methods))
7608 (let ((xlist gnus-decode-header-methods-cache))
7611 (narrow-to-region start end)
7613 (funcall (pop xlist) (point-min) (point-max))))))
7616 ;;; Treatment top-level handling.
7619 (defun gnus-treat-article (condition &optional part-number total-parts type)
7620 (let ((length (- (point-max) (point-min)))
7621 (alist gnus-treatment-function-alist)
7622 (article-goto-body-goes-to-point-min-p t)
7626 (let ((list gnus-article-treat-types))
7628 (when (string-match (pop list) type)
7629 (throw 'found t)))))))
7630 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7632 (gnus-run-hooks 'gnus-part-display-hook)
7633 (dolist (elem alist)
7636 (when (gnus-buffer-live-p gnus-summary-buffer)
7637 (set-buffer gnus-summary-buffer))
7638 (symbol-value (car elem))))
7639 (when (and (or (consp val)
7641 (gnus-treat-predicate val)
7642 (or (not (get (car elem) 'highlight))
7645 (funcall (cadr elem)))))))
7647 ;; Dynamic variables.
7649 (defvar part-number)
7650 (defvar total-parts)
7655 (defun gnus-treat-predicate (val)
7662 (stringp (car val)))
7663 (apply 'gnus-or (mapcar `(lambda (s)
7664 (string-match s ,(or gnus-newsgroup-name "")))
7667 (let ((pred (pop val)))
7670 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7672 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7674 (not (gnus-treat-predicate (car val))))
7676 (equal (car val) type))
7678 (error "%S is not a valid predicate" pred)))))
7686 (eq part-number total-parts))
7690 (error "%S is not a valid value" val))))
7692 (defun gnus-article-encrypt-body (protocol &optional n)
7693 "Encrypt the article body."
7696 (or gnus-article-encrypt-protocol
7697 (completing-read "Encrypt protocol: "
7698 gnus-article-encrypt-protocol-alist
7700 current-prefix-arg))
7701 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7703 (error "Can't find the encrypt protocol %s" protocol))
7704 (if (member gnus-newsgroup-name '("nndraft:delayed"
7707 (error "Can't encrypt the article in group %s"
7708 gnus-newsgroup-name))
7709 (gnus-summary-iterate n
7711 (set-buffer gnus-summary-buffer)
7712 (let ((mail-parse-charset gnus-newsgroup-charset)
7713 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7714 (summary-buffer gnus-summary-buffer)
7716 (gnus-set-global-variables)
7717 (when (gnus-group-read-only-p)
7718 (error "The current newsgroup does not support article encrypt"))
7719 (gnus-summary-show-article t)
7721 (or (mail-header-references gnus-current-headers) ""))
7722 (set-buffer gnus-article-buffer)
7723 (let* ((inhibit-read-only t)
7725 (mapcar (lambda (field)
7726 (and (save-restriction
7727 (message-narrow-to-head)
7728 (goto-char (point-min))
7729 (search-forward field nil t))
7731 (message-narrow-to-field)
7733 (delete-region (point-min) (point-max))
7735 '("Content-Type:" "Content-Transfer-Encoding:"
7736 "Content-Disposition:"))))
7737 (message-narrow-to-head)
7738 (message-remove-header "MIME-Version")
7739 (goto-char (point-max))
7740 (setq point (point))
7741 (insert (apply 'concat headers))
7743 (narrow-to-region point (point-max))
7744 (let ((message-options message-options))
7745 (message-options-set 'message-sender user-mail-address)
7746 (message-options-set 'message-recipients user-mail-address)
7747 (message-options-set 'message-sign-encrypt 'not)
7749 (goto-char (point-min))
7750 (insert "MIME-Version: 1.0\n")
7752 (gnus-summary-edit-article-done
7753 references nil summary-buffer t))
7754 (when gnus-keep-backlog
7755 (gnus-backlog-remove-article
7756 (car gnus-article-current) (cdr gnus-article-current)))
7758 (when (get-buffer gnus-original-article-buffer)
7759 (set-buffer gnus-original-article-buffer)
7760 (setq gnus-original-article nil)))
7761 (when gnus-use-cache
7762 (gnus-cache-update-article
7763 (car gnus-article-current) (cdr gnus-article-current))))))))
7765 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7766 "The following specs can be used:
7767 %t The security MIME type
7770 %D Details if button is pressed")
7772 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7773 "The following specs can be used:
7774 %t The security MIME type
7777 %D Details if button is pressed")
7779 (defvar gnus-mime-security-button-line-format-alist
7780 '((?t gnus-tmp-type ?s)
7781 (?i gnus-tmp-info ?s)
7782 (?d gnus-tmp-details ?s)
7783 (?D gnus-tmp-pressed-details ?s)))
7785 (defvar gnus-mime-security-button-commands
7786 '((gnus-article-press-button "\r" "Show Detail")
7790 (gnus-mime-security-save-part "o" "Save...")
7799 (gnus-mime-security-pipe-part "|" "Pipe To Command...")
7802 (defvar gnus-mime-security-button-map
7803 (let ((map (make-sparse-keymap)))
7804 (define-key map gnus-mouse-2 'gnus-article-push-button)
7805 (define-key map gnus-down-mouse-3 'gnus-mime-security-button-menu)
7806 (dolist (c gnus-mime-security-button-commands)
7807 (define-key map (cadr c) (car c)))
7811 gnus-mime-security-button-menu gnus-mime-security-button-map
7812 "Security button menu."
7816 (unless (eq (car c) 'undefined)
7817 (vector (caddr c) (car c) :active t)))
7818 gnus-mime-security-button-commands))))
7820 (defun gnus-mime-security-button-menu (event prefix)
7821 "Construct a context-sensitive menu of security commands."
7822 (interactive "e\nP")
7823 (save-window-excursion
7824 (let ((pos (event-start event)))
7825 (select-window (posn-window pos))
7826 (goto-char (posn-point pos))
7827 (gnus-article-check-buffer)
7828 (popup-menu gnus-mime-security-button-menu nil prefix))))
7830 (defvar gnus-mime-security-details-buffer nil)
7832 (defvar gnus-mime-security-button-pressed nil)
7834 (defvar gnus-mime-security-show-details-inline t
7835 "If non-nil, show details in the article buffer.")
7837 (defun gnus-mime-security-verify-or-decrypt (handle)
7838 (mm-remove-parts (cdr handle))
7839 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7840 point (inhibit-read-only t))
7842 (goto-char (car region)))
7844 (narrow-to-region (point) (point))
7845 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7846 (let* ((mm-verify-option 'known)
7847 (mm-decrypt-option 'known)
7848 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7849 (unless (eq nparts (cdr handle))
7850 (mm-destroy-parts (cdr handle))
7851 (setcdr handle nparts))))
7852 (setq point (point))
7853 (gnus-mime-display-security handle)
7854 (goto-char (point-max)))
7856 (delete-region (point) (cdr region))
7857 (set-marker (car region) nil)
7858 (set-marker (cdr region) nil))
7861 (defun gnus-mime-security-show-details (handle)
7862 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7864 (gnus-message 5 "No details.")
7865 (if gnus-mime-security-show-details-inline
7866 (let ((gnus-mime-security-button-pressed
7867 (not (get-text-property (point) 'gnus-mime-details)))
7868 (gnus-mime-security-button-line-format
7869 (get-text-property (point) 'gnus-line-format))
7870 (inhibit-read-only t))
7872 (while (eq (get-text-property (point) 'gnus-line-format)
7873 gnus-mime-security-button-line-format)
7877 (narrow-to-region (point) (point))
7878 (gnus-insert-mime-security-button handle))
7879 (delete-region (point)
7880 (or (text-property-not-all
7883 gnus-mime-security-button-line-format)
7886 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7887 (with-current-buffer gnus-mime-security-details-buffer
7890 (setq gnus-mime-security-details-buffer
7891 (gnus-get-buffer-create "*MIME Security Details*")))
7892 (with-current-buffer gnus-mime-security-details-buffer
7894 (goto-char (point-min)))
7895 (pop-to-buffer gnus-mime-security-details-buffer)))))
7897 (defun gnus-mime-security-press-button (handle)
7899 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7900 (gnus-mime-security-show-details handle)
7901 (gnus-mime-security-verify-or-decrypt handle))))
7903 (defun gnus-insert-mime-security-button (handle &optional displayed)
7904 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7907 (or (nth 2 (assoc protocol mm-verify-function-alist))
7908 (nth 2 (assoc protocol mm-decrypt-function-alist))
7910 (if (equal (car handle) "multipart/signed")
7911 " Signed" " Encrypted")
7914 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7917 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7918 gnus-tmp-pressed-details
7920 (setq gnus-tmp-details
7921 (if gnus-tmp-details
7922 (concat "\n" gnus-tmp-details)
7924 (setq gnus-tmp-pressed-details
7925 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7930 gnus-mime-security-button-line-format
7931 gnus-mime-security-button-line-format-alist
7932 `(keymap ,gnus-mime-security-button-map
7933 gnus-callback gnus-mime-security-press-button
7934 gnus-line-format ,gnus-mime-security-button-line-format
7935 gnus-mime-details ,gnus-mime-security-button-pressed
7936 article-type annotation
7939 ;; Exclude a newline.
7942 (when gnus-article-button-face
7943 (gnus-overlay-put (gnus-make-overlay b e)
7944 'face gnus-article-button-face))
7945 (widget-convert-button
7948 :action 'gnus-widget-press-button
7949 :button-keymap gnus-mime-security-button-map
7951 (lambda (widget/window &optional overlay pos)
7952 ;; Needed to properly clear the message due to a bug in
7953 ;; wid-edit (XEmacs only).
7954 (when (boundp 'help-echo-owns-message)
7955 (setq help-echo-owns-message t))
7957 "%S: show detail; %S: more options"
7958 (aref gnus-mouse-2 0)
7959 (aref gnus-down-mouse-3 0))))))
7961 (defun gnus-mime-display-security (handle)
7963 (narrow-to-region (point) (point))
7964 (unless (gnus-unbuttonized-mime-type-p (car handle))
7965 (gnus-insert-mime-security-button handle))
7966 (gnus-mime-display-part (cadr handle))
7969 (unless (gnus-unbuttonized-mime-type-p (car handle))
7970 (let ((gnus-mime-security-button-line-format
7971 gnus-mime-security-button-end-line-format))
7972 (gnus-insert-mime-security-button handle)))
7973 (mm-set-handle-multipart-parameter
7975 (cons (set-marker (make-marker) (point-min))
7976 (set-marker (make-marker) (point-max))))))
7978 (defun gnus-mime-security-run-function (function)
7979 "Run FUNCTION with the security part under point."
7980 (gnus-article-check-buffer)
7981 (let ((data (get-text-property (point) 'gnus-data))
7983 (when (and (stringp (car-safe data))
7984 (setq buffer (mm-handle-multipart-original-buffer data))
7985 (setq handle (cadr data)))
7986 (if (bufferp (mm-handle-buffer handle))
7988 (setq handle (cons buffer (copy-sequence (cdr handle))))
7989 (mm-handle-set-undisplayer handle nil))
7990 (setq handle (mm-make-handle
7992 (mm-handle-multipart-ctl-parameter handle 'protocol)
7993 nil nil nil nil nil nil)))
7994 (funcall function handle))))
7996 (defun gnus-mime-security-save-part ()
7997 "Save the security part under point."
7999 (gnus-mime-security-run-function 'mm-save-part))
8001 (defun gnus-mime-security-pipe-part ()
8002 "Pipe the security part under point to a process."
8004 (gnus-mime-security-run-function 'mm-pipe-part))
8010 (run-hooks 'gnus-art-load-hook)
8012 ;;; arch-tag: 2654516f-6279-48f9-a83b-05c1fa450c33
8013 ;;; gnus-art.el ends here