1 ;;; gnus-art.el --- article mode commands for Gnus
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006, 2007 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)
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 the
665 parameter. If it is a list, it will be evaled in the same buffer.
667 If this form or function returns a string, this string will be used as a
668 possible file name; and if it returns a non-nil list, that list will be
669 used as possible file names."
670 :group 'gnus-article-saving
671 :type '(repeat (choice (list :value (fun) function)
672 (cons :value ("" "") regexp (repeat string))
675 (defcustom gnus-page-delimiter "^\^L"
676 "*Regexp describing what to use as article page delimiters.
677 The default value is \"^\^L\", which is a form linefeed at the
678 beginning of a line."
680 :group 'gnus-article-various)
682 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
683 "*The format specification for the article mode line.
684 See `gnus-summary-mode-line-format' for a closer description.
686 The following additional specs are available:
688 %w The article washing status.
689 %m The number of MIME parts in the article."
691 :group 'gnus-article-various)
693 (defcustom gnus-article-mode-hook nil
694 "*A hook for Gnus article mode."
696 :group 'gnus-article-various)
698 (when (featurep 'xemacs)
699 ;; Extracted from gnus-xmas-define in order to preserve user settings
700 (when (fboundp 'turn-off-scroll-in-place)
701 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
702 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
703 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
705 (defcustom gnus-article-menu-hook nil
706 "*Hook run after the creation of the article mode menu."
708 :group 'gnus-article-various)
710 (defcustom gnus-article-prepare-hook nil
711 "*A hook called after an article has been prepared in the article buffer."
713 :group 'gnus-article-various)
715 (defcustom gnus-copy-article-ignored-headers nil
716 "List of headers to be removed when copying an article.
717 Each element is a regular expression."
718 :version "23.0" ;; No Gnus
719 :type '(repeat regexp)
720 :group 'gnus-article-various)
722 (make-obsolete-variable 'gnus-article-hide-pgp-hook
723 "This variable is obsolete in Gnus 5.10.")
726 '((t (:weight bold)))
727 "Face used for highlighting a button in the article buffer."
728 :group 'gnus-article-buttons)
730 (defcustom gnus-article-button-face 'gnus-button
731 "Face used for highlighting buttons in the article buffer.
733 An article button is a piece of text that you can activate by pressing
734 `RET' or `mouse-2' above it."
736 :group 'gnus-article-buttons)
738 (defcustom gnus-article-mouse-face 'highlight
739 "Face used for mouse highlighting in the article buffer.
741 Article buttons will be displayed in this face when the cursor is
744 :group 'gnus-article-buttons)
746 (defcustom gnus-signature-face 'gnus-signature
747 "Face used for highlighting a signature in the article buffer.
748 Obsolete; use the face `gnus-signature' for customizations instead."
750 :group 'gnus-article-highlight
751 :group 'gnus-article-signature)
753 (defface gnus-signature
756 "Face used for highlighting a signature in the article buffer."
757 :group 'gnus-article-highlight
758 :group 'gnus-article-signature)
759 ;; backward-compatibility alias
760 (put 'gnus-signature-face 'face-alias 'gnus-signature)
762 (defface gnus-header-from
765 (:foreground "PaleGreen1"))
768 (:foreground "red3"))
771 "Face used for displaying from headers."
772 :group 'gnus-article-headers
773 :group 'gnus-article-highlight)
774 ;; backward-compatibility alias
775 (put 'gnus-header-from-face 'face-alias 'gnus-header-from)
777 (defface gnus-header-subject
780 (:foreground "SeaGreen1"))
783 (:foreground "red4"))
785 (:bold t :italic t)))
786 "Face used for displaying subject headers."
787 :group 'gnus-article-headers
788 :group 'gnus-article-highlight)
789 ;; backward-compatibility alias
790 (put 'gnus-header-subject-face 'face-alias 'gnus-header-subject)
792 (defface gnus-header-newsgroups
795 (:foreground "yellow" :italic t))
798 (:foreground "MidnightBlue" :italic t))
801 "Face used for displaying newsgroups headers.
802 In the default setup this face is only used for crossposted
804 :group 'gnus-article-headers
805 :group 'gnus-article-highlight)
806 ;; backward-compatibility alias
807 (put 'gnus-header-newsgroups-face 'face-alias 'gnus-header-newsgroups)
809 (defface gnus-header-name
812 (:foreground "SpringGreen2"))
815 (:foreground "maroon"))
818 "Face used for displaying header names."
819 :group 'gnus-article-headers
820 :group 'gnus-article-highlight)
821 ;; backward-compatibility alias
822 (put 'gnus-header-name-face 'face-alias 'gnus-header-name)
824 (defface gnus-header-content
827 (:foreground "SpringGreen1" :italic t))
830 (:foreground "indianred4" :italic t))
832 (:italic t))) "Face used for displaying header content."
833 :group 'gnus-article-headers
834 :group 'gnus-article-highlight)
835 ;; backward-compatibility alias
836 (put 'gnus-header-content-face 'face-alias 'gnus-header-content)
838 (defcustom gnus-header-face-alist
839 '(("From" nil gnus-header-from)
840 ("Subject" nil gnus-header-subject)
841 ("Newsgroups:.*," nil gnus-header-newsgroups)
842 ("" gnus-header-name gnus-header-content))
843 "*Controls highlighting of article headers.
845 An alist of the form (HEADER NAME CONTENT).
847 HEADER is a regular expression which should match the name of a
848 header and NAME and CONTENT are either face names or nil.
850 The name of each header field will be displayed using the face
851 specified by the first element in the list where HEADER matches
852 the header name and NAME is non-nil. Similarly, the content will
853 be displayed by the first non-nil matching CONTENT face."
854 :group 'gnus-article-headers
855 :group 'gnus-article-highlight
856 :type '(repeat (list (regexp :tag "Header")
858 (item :tag "skip" nil)
859 (face :value default))
860 (choice :tag "Content"
861 (item :tag "skip" nil)
862 (face :value default)))))
864 (defcustom gnus-face-properties-alist (if (featurep 'xemacs)
865 '((xface . (:face gnus-x-face)))
866 '((pbm . (:face gnus-x-face))
868 "Alist of image types and properties applied to Face and X-Face images.
871 ;; Specify the altitude of Face images in the From header.
872 \(setq gnus-face-properties-alist
873 '((pbm . (:face gnus-x-face :ascent 80))
874 (png . (:ascent 80))))
876 ;; Show Face images as pressed buttons.
877 \(setq gnus-face-properties-alist
878 '((pbm . (:face gnus-x-face :relief -2))
879 (png . (:relief -2))))
881 See the manual for the valid properties for various image types.
882 Currently, `pbm' is used for X-Face images and `png' is used for Face
883 images in Emacs. Only the `:face' property is effective on the `xface'
884 image type in XEmacs if it is built with the libcompface library."
885 :version "23.0" ;; No Gnus
886 :group 'gnus-article-headers
887 :type '(repeat (cons :format "%v" (symbol :tag "Image type") plist)))
889 (defcustom gnus-article-decode-hook
890 '(article-decode-charset article-decode-encoded-words
891 article-decode-group-name article-decode-idna-rhs)
892 "*Hook run to decode charsets in articles."
893 :group 'gnus-article-headers
896 (defcustom gnus-display-mime-function 'gnus-display-mime
897 "Function to display MIME articles."
898 :group 'gnus-article-mime
901 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
902 "Function used to decode headers.")
904 (defvar gnus-decode-address-function 'mail-decode-encoded-address-region
905 "Function used to decode addresses.")
907 (defvar gnus-article-dumbquotes-map
927 "Table for MS-to-Latin1 translation.")
929 (defcustom gnus-ignored-mime-types nil
930 "List of MIME types that should be ignored by Gnus."
932 :group 'gnus-article-mime
933 :type '(repeat regexp))
935 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
936 "List of MIME types that should not be given buttons when rendered inline.
937 See also `gnus-buttonized-mime-types' which may override this variable.
938 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
940 :group 'gnus-article-mime
941 :type '(repeat regexp))
943 (defcustom gnus-buttonized-mime-types nil
944 "List of MIME types that should be given buttons when rendered inline.
945 If set, this variable overrides `gnus-unbuttonized-mime-types'.
946 To see e.g. security buttons you could set this to
947 `(\"multipart/signed\")'. You could also add \"multipart/alternative\" to
948 this list to display radio buttons that allow you to choose one of two
949 media types those mails include. See also `mm-discouraged-alternatives'.
950 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
952 :group 'gnus-article-mime
953 :type '(repeat regexp))
955 (defcustom gnus-inhibit-mime-unbuttonizing nil
956 "If non-nil, all MIME parts get buttons.
957 When nil (the default value), then some MIME parts do not get buttons,
958 as described by the variables `gnus-buttonized-mime-types' and
959 `gnus-unbuttonized-mime-types'."
961 :group 'gnus-article-mime
964 (defcustom gnus-body-boundary-delimiter "_"
965 "String used to delimit header and body.
966 This variable is used by `gnus-article-treat-body-boundary' which can
967 be controlled by `gnus-treat-body-boundary'."
969 :group 'gnus-article-various
970 :type '(choice (item :tag "None" :value nil)
973 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
975 "Defines the location of the faces database.
976 For information on obtaining this database of pretty pictures, please
977 see http://www.cs.indiana.edu/picons/ftp/index.html"
979 :type '(repeat directory)
980 :link '(url-link :tag "download"
981 "http://www.cs.indiana.edu/picons/ftp/index.html")
982 :link '(custom-manual "(gnus)Picons")
985 (defun gnus-picons-installed-p ()
986 "Say whether picons are installed on your machine."
987 (let ((installed nil))
988 (dolist (database gnus-picon-databases)
989 (when (file-exists-p database)
993 (defcustom gnus-article-mime-part-function nil
994 "Function called with a MIME handle as the argument.
995 This is meant for people who want to do something automatic based
996 on parts -- for instance, adding Vcard info to a database."
997 :group 'gnus-article-mime
998 :type '(choice (const nil)
1001 (defcustom gnus-mime-multipart-functions nil
1002 "An alist of MIME types to functions to display them."
1004 :group 'gnus-article-mime
1005 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
1007 (defcustom gnus-article-date-lapsed-new-header nil
1008 "Whether the X-Sent and Date headers can coexist.
1009 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
1010 either replace the old \"Date:\" header (if this variable is nil), or
1011 be added below it (otherwise)."
1013 :group 'gnus-article-headers
1016 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
1017 "Function called with a MIME handle as the argument.
1018 This is meant for people who want to view first matched part.
1019 For `undisplayed-alternative' (default), the first undisplayed
1020 part or alternative part is used. For `undisplayed', the first
1021 undisplayed part is used. For a function, the first part which
1022 the function return t is used. For nil, the first part is
1025 :group 'gnus-article-mime
1027 (item :tag "first" :value nil)
1028 (item :tag "undisplayed" :value undisplayed)
1029 (item :tag "undisplayed or alternative"
1030 :value undisplayed-alternative)
1033 (defcustom gnus-mime-action-alist
1034 '(("save to file" . gnus-mime-save-part)
1035 ("save and strip" . gnus-mime-save-part-and-strip)
1036 ("replace with file" . gnus-mime-replace-part)
1037 ("delete part" . gnus-mime-delete-part)
1038 ("display as text" . gnus-mime-inline-part)
1039 ("view the part" . gnus-mime-view-part)
1040 ("pipe to command" . gnus-mime-pipe-part)
1041 ("toggle display" . gnus-article-press-button)
1042 ("toggle display" . gnus-article-view-part-as-charset)
1043 ("view as type" . gnus-mime-view-part-as-type)
1044 ("view internally" . gnus-mime-view-part-internally)
1045 ("view externally" . gnus-mime-view-part-externally))
1046 "An alist of actions that run on the MIME attachment."
1047 :group 'gnus-article-mime
1048 :type '(repeat (cons (string :tag "name")
1051 (defcustom gnus-auto-select-part 1
1052 "Advance to next MIME part when deleting or stripping parts.
1054 When 0, point will be placed on the same part as before. When
1055 positive (negative), move point forward (backwards) this many
1056 parts. When nil, redisplay article."
1057 :version "23.0" ;; No Gnus
1058 :group 'gnus-article-mime
1059 :type '(choice (const nil :tag "Redisplay article.")
1060 (const 1 :tag "Next part.")
1061 (const 0 :tag "Current part.")
1065 ;;; The treatment variables
1068 (defvar gnus-part-display-hook nil
1069 "Hook called on parts that are to receive treatment.")
1071 (defvar gnus-article-treat-custom
1072 '(choice (const :tag "Off" nil)
1074 (const :tag "Header" head)
1075 (const :tag "First" first)
1076 (const :tag "Last" last)
1077 (integer :tag "Less")
1078 (repeat :tag "Groups" regexp)
1079 (sexp :tag "Predicate")))
1081 (defvar gnus-article-treat-head-custom
1082 '(choice (const :tag "Off" nil)
1083 (const :tag "Header" head)))
1085 (defvar gnus-article-treat-types '("text/plain" "text/x-verbatim"
1089 (defvar gnus-inhibit-treatment nil
1090 "Whether to inhibit treatment.")
1092 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
1093 "Highlight the signature.
1094 Valid values are nil, t, `head', `first', `last', an integer or a
1095 predicate. See Info node `(gnus)Customizing Articles'."
1096 :group 'gnus-article-treat
1097 :link '(custom-manual "(gnus)Customizing Articles")
1098 :type gnus-article-treat-custom)
1099 (put 'gnus-treat-highlight-signature 'highlight t)
1101 (defcustom gnus-treat-buttonize 100000
1103 Valid values are nil, t, `head', `first', `last', an integer or a
1104 predicate. See Info node `(gnus)Customizing Articles'."
1105 :group 'gnus-article-treat
1106 :link '(custom-manual "(gnus)Customizing Articles")
1107 :type gnus-article-treat-custom)
1108 (put 'gnus-treat-buttonize 'highlight t)
1110 (defcustom gnus-treat-buttonize-head 'head
1111 "Add buttons to the head.
1112 Valid values are nil, t, `head', `first', `last', an integer or a
1113 predicate. See Info node `(gnus)Customizing Articles'."
1114 :group 'gnus-article-treat
1115 :link '(custom-manual "(gnus)Customizing Articles")
1116 :type gnus-article-treat-head-custom)
1117 (put 'gnus-treat-buttonize-head 'highlight t)
1119 (defcustom gnus-treat-emphasize
1120 (and (or window-system
1124 Valid values are nil, t, `head', `first', `last', an integer or a
1125 predicate. See Info node `(gnus)Customizing Articles'."
1126 :group 'gnus-article-treat
1127 :link '(custom-manual "(gnus)Customizing Articles")
1128 :type gnus-article-treat-custom)
1129 (put 'gnus-treat-emphasize 'highlight t)
1131 (defcustom gnus-treat-strip-cr nil
1132 "Remove carriage returns.
1133 Valid values are nil, t, `head', `first', `last', an integer or a
1134 predicate. See Info node `(gnus)Customizing Articles'."
1136 :group 'gnus-article-treat
1137 :link '(custom-manual "(gnus)Customizing Articles")
1138 :type gnus-article-treat-custom)
1140 (defcustom gnus-treat-unsplit-urls nil
1141 "Remove newlines from within URLs.
1142 Valid values are nil, t, `head', `first', `last', an integer or a
1143 predicate. See Info node `(gnus)Customizing Articles'."
1145 :group 'gnus-article-treat
1146 :link '(custom-manual "(gnus)Customizing Articles")
1147 :type gnus-article-treat-custom)
1149 (defcustom gnus-treat-leading-whitespace nil
1150 "Remove leading whitespace in headers.
1151 Valid values are nil, t, `head', `first', `last', an integer or a
1152 predicate. See Info node `(gnus)Customizing Articles'."
1154 :group 'gnus-article-treat
1155 :link '(custom-manual "(gnus)Customizing Articles")
1156 :type gnus-article-treat-custom)
1158 (defcustom gnus-treat-hide-headers 'head
1160 Valid values are nil, t, `head', `first', `last', an integer or a
1161 predicate. See Info node `(gnus)Customizing Articles'."
1162 :group 'gnus-article-treat
1163 :link '(custom-manual "(gnus)Customizing Articles")
1164 :type gnus-article-treat-head-custom)
1166 (defcustom gnus-treat-hide-boring-headers nil
1167 "Hide boring headers.
1168 Valid values are nil, t, `head', `first', `last', an integer or a
1169 predicate. See Info node `(gnus)Customizing Articles'."
1170 :group 'gnus-article-treat
1171 :link '(custom-manual "(gnus)Customizing Articles")
1172 :type gnus-article-treat-head-custom)
1174 (defcustom gnus-treat-hide-signature nil
1175 "Hide the signature.
1176 Valid values are nil, t, `head', `first', `last', an integer or a
1177 predicate. See Info node `(gnus)Customizing Articles'."
1178 :group 'gnus-article-treat
1179 :link '(custom-manual "(gnus)Customizing Articles")
1180 :type gnus-article-treat-custom)
1182 (defcustom gnus-treat-fill-article nil
1184 Valid values are nil, t, `head', `first', `last', an integer or a
1185 predicate. See Info node `(gnus)Customizing Articles'."
1186 :group 'gnus-article-treat
1187 :link '(custom-manual "(gnus)Customizing Articles")
1188 :type gnus-article-treat-custom)
1190 (defcustom gnus-treat-hide-citation nil
1192 Valid values are nil, t, `head', `first', `last', an integer or a
1193 predicate. See Info node `(gnus)Customizing Articles'."
1194 :group 'gnus-article-treat
1195 :link '(custom-manual "(gnus)Customizing Articles")
1196 :type gnus-article-treat-custom)
1198 (defcustom gnus-treat-hide-citation-maybe nil
1200 Valid values are nil, t, `head', `first', `last', an integer or a
1201 predicate. See Info node `(gnus)Customizing Articles'."
1202 :group 'gnus-article-treat
1203 :link '(custom-manual "(gnus)Customizing Articles")
1204 :type gnus-article-treat-custom)
1206 (defcustom gnus-treat-strip-list-identifiers 'head
1207 "Strip list identifiers from `gnus-list-identifiers`.
1208 Valid values are nil, t, `head', `first', `last', an integer or a
1209 predicate. See Info node `(gnus)Customizing Articles'."
1211 :group 'gnus-article-treat
1212 :link '(custom-manual "(gnus)Customizing Articles")
1213 :type gnus-article-treat-custom)
1215 (make-obsolete-variable 'gnus-treat-strip-pgp
1216 "This option is obsolete in Gnus 5.10.")
1218 (defcustom gnus-treat-strip-pem nil
1219 "Strip PEM signatures.
1220 Valid values are nil, t, `head', `first', `last', an integer or a
1221 predicate. See Info node `(gnus)Customizing Articles'."
1222 :group 'gnus-article-treat
1223 :link '(custom-manual "(gnus)Customizing Articles")
1224 :type gnus-article-treat-custom)
1226 (defcustom gnus-treat-strip-banner t
1227 "Strip banners from articles.
1228 The banner to be stripped is specified in the `banner' group parameter.
1229 Valid values are nil, t, `head', `first', `last', an integer or a
1230 predicate. See Info node `(gnus)Customizing Articles'."
1231 :group 'gnus-article-treat
1232 :link '(custom-manual "(gnus)Customizing Articles")
1233 :type gnus-article-treat-custom)
1235 (defcustom gnus-treat-highlight-headers 'head
1236 "Highlight the headers.
1237 Valid values are nil, t, `head', `first', `last', an integer or a
1238 predicate. See Info node `(gnus)Customizing Articles'."
1239 :group 'gnus-article-treat
1240 :link '(custom-manual "(gnus)Customizing Articles")
1241 :type gnus-article-treat-head-custom)
1242 (put 'gnus-treat-highlight-headers 'highlight t)
1244 (defcustom gnus-treat-highlight-citation t
1245 "Highlight cited text.
1246 Valid values are nil, t, `head', `first', `last', an integer or a
1247 predicate. See Info node `(gnus)Customizing Articles'."
1248 :group 'gnus-article-treat
1249 :link '(custom-manual "(gnus)Customizing Articles")
1250 :type gnus-article-treat-custom)
1251 (put 'gnus-treat-highlight-citation 'highlight t)
1253 (defcustom gnus-treat-date-ut nil
1254 "Display the Date in UT (GMT).
1255 Valid values are nil, t, `head', `first', `last', an integer or a
1256 predicate. See Info node `(gnus)Customizing Articles'."
1257 :group 'gnus-article-treat
1258 :link '(custom-manual "(gnus)Customizing Articles")
1259 :type gnus-article-treat-head-custom)
1261 (defcustom gnus-treat-date-local nil
1262 "Display the Date in the local timezone.
1263 Valid values are nil, t, `head', `first', `last', an integer or a
1264 predicate. See Info node `(gnus)Customizing Articles'."
1265 :group 'gnus-article-treat
1266 :link '(custom-manual "(gnus)Customizing Articles")
1267 :type gnus-article-treat-head-custom)
1269 (defcustom gnus-treat-date-english nil
1270 "Display the Date in a format that can be read aloud in English.
1271 Valid values are nil, t, `head', `first', `last', an integer or a
1272 predicate. See Info node `(gnus)Customizing Articles'."
1274 :group 'gnus-article-treat
1275 :link '(custom-manual "(gnus)Customizing Articles")
1276 :type gnus-article-treat-head-custom)
1278 (defcustom gnus-treat-date-lapsed nil
1279 "Display the Date header in a way that says how much time has elapsed.
1280 Valid values are nil, t, `head', `first', `last', an integer or a
1281 predicate. See Info node `(gnus)Customizing Articles'."
1282 :group 'gnus-article-treat
1283 :link '(custom-manual "(gnus)Customizing Articles")
1284 :type gnus-article-treat-head-custom)
1286 (defcustom gnus-treat-date-original nil
1287 "Display the date in the original timezone.
1288 Valid values are nil, t, `head', `first', `last', an integer or a
1289 predicate. See Info node `(gnus)Customizing Articles'."
1290 :group 'gnus-article-treat
1291 :link '(custom-manual "(gnus)Customizing Articles")
1292 :type gnus-article-treat-head-custom)
1294 (defcustom gnus-treat-date-iso8601 nil
1295 "Display the date in the ISO8601 format.
1296 Valid values are nil, t, `head', `first', `last', an integer or a
1297 predicate. See Info node `(gnus)Customizing Articles'."
1299 :group 'gnus-article-treat
1300 :link '(custom-manual "(gnus)Customizing Articles")
1301 :type gnus-article-treat-head-custom)
1303 (defcustom gnus-treat-date-user-defined nil
1304 "Display the date in a user-defined format.
1305 The format is defined by the `gnus-article-time-format' variable.
1306 Valid values are nil, t, `head', `first', `last', an integer or a
1307 predicate. See Info node `(gnus)Customizing Articles'."
1308 :group 'gnus-article-treat
1309 :link '(custom-manual "(gnus)Customizing Articles")
1310 :type gnus-article-treat-head-custom)
1312 (defcustom gnus-treat-strip-headers-in-body t
1313 "Strip the X-No-Archive header line from the beginning of the body.
1314 Valid values are nil, t, `head', `first', `last', an integer or a
1315 predicate. See Info node `(gnus)Customizing Articles'."
1317 :group 'gnus-article-treat
1318 :link '(custom-manual "(gnus)Customizing Articles")
1319 :type gnus-article-treat-custom)
1321 (defcustom gnus-treat-strip-trailing-blank-lines nil
1322 "Strip trailing blank lines.
1323 Valid values are nil, t, `head', `first', `last', an integer or a
1324 predicate. See Info node `(gnus)Customizing Articles'.
1326 When set to t, it also strips trailing blanks in all MIME parts.
1327 Consider to use `last' instead."
1328 :group 'gnus-article-treat
1329 :link '(custom-manual "(gnus)Customizing Articles")
1330 :type gnus-article-treat-custom)
1332 (defcustom gnus-treat-strip-leading-blank-lines nil
1333 "Strip leading blank lines.
1334 Valid values are nil, t, `head', `first', `last', an integer or a
1335 predicate. See Info node `(gnus)Customizing Articles'.
1337 When set to t, it also strips trailing blanks in all MIME parts."
1338 :group 'gnus-article-treat
1339 :link '(custom-manual "(gnus)Customizing Articles")
1340 :type gnus-article-treat-custom)
1342 (defcustom gnus-treat-strip-multiple-blank-lines nil
1343 "Strip multiple blank lines.
1344 Valid values are nil, t, `head', `first', `last', an integer or a
1345 predicate. See Info node `(gnus)Customizing Articles'."
1346 :group 'gnus-article-treat
1347 :link '(custom-manual "(gnus)Customizing Articles")
1348 :type gnus-article-treat-custom)
1350 (defcustom gnus-treat-unfold-headers 'head
1351 "Unfold folded header lines.
1352 Valid values are nil, t, `head', `first', `last', an integer or a
1353 predicate. See Info node `(gnus)Customizing Articles'."
1355 :group 'gnus-article-treat
1356 :link '(custom-manual "(gnus)Customizing Articles")
1357 :type gnus-article-treat-custom)
1359 (defcustom gnus-article-unfold-long-headers nil
1360 "If non-nil, allow unfolding headers even if the header is long.
1361 If it is a regexp, only long headers matching this regexp are unfolded.
1362 If it is t, all long headers are unfolded.
1364 This variable has no effect if `gnus-treat-unfold-headers' is nil."
1365 :version "23.0" ;; No Gnus
1366 :group 'gnus-article-treat
1367 :type '(choice (const nil)
1368 (const :tag "all" t)
1371 (defcustom gnus-treat-fold-headers nil
1373 Valid values are nil, t, `head', `first', `last', an integer or a
1374 predicate. See Info node `(gnus)Customizing Articles'."
1376 :group 'gnus-article-treat
1377 :link '(custom-manual "(gnus)Customizing Articles")
1378 :type gnus-article-treat-custom)
1380 (defcustom gnus-treat-fold-newsgroups 'head
1381 "Fold the Newsgroups and Followup-To headers.
1382 Valid values are nil, t, `head', `first', `last', an integer or a
1383 predicate. See Info node `(gnus)Customizing Articles'."
1385 :group 'gnus-article-treat
1386 :link '(custom-manual "(gnus)Customizing Articles")
1387 :type gnus-article-treat-custom)
1389 (defcustom gnus-treat-overstrike t
1390 "Treat overstrike highlighting.
1391 Valid values are nil, t, `head', `first', `last', an integer or a
1392 predicate. See Info node `(gnus)Customizing Articles'."
1393 :group 'gnus-article-treat
1394 :link '(custom-manual "(gnus)Customizing Articles")
1395 :type gnus-article-treat-custom)
1396 (put 'gnus-treat-overstrike 'highlight t)
1398 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1399 "Treat ANSI SGR control sequences.
1400 Valid values are nil, t, `head', `first', `last', an integer or a
1401 predicate. See Info node `(gnus)Customizing Articles'."
1402 :group 'gnus-article-treat
1403 :link '(custom-manual "(gnus)Customizing Articles")
1404 :type gnus-article-treat-custom)
1406 (make-obsolete-variable 'gnus-treat-display-xface
1407 'gnus-treat-display-x-face)
1409 (defcustom gnus-treat-display-x-face
1410 (and (not noninteractive)
1411 (gnus-image-type-available-p 'xbm)
1412 (if (featurep 'xemacs)
1414 (and (string-match "^0x" (shell-command-to-string "uncompface"))
1415 (executable-find "icontopbm")))
1417 "Display X-Face headers.
1418 Valid values are nil and `head'.
1419 See Info node `(gnus)Customizing Articles' and Info node
1420 `(gnus)X-Face' for details."
1421 :group 'gnus-article-treat
1423 :link '(custom-manual "(gnus)Customizing Articles")
1424 :link '(custom-manual "(gnus)X-Face")
1425 :type gnus-article-treat-head-custom
1426 :set (lambda (symbol value)
1429 (cond ((or (boundp symbol) (get symbol 'saved-value))
1431 ((boundp 'gnus-treat-display-xface)
1433 ** gnus-treat-display-xface is an obsolete variable;\
1434 use gnus-treat-display-x-face instead")
1435 (default-value 'gnus-treat-display-xface))
1436 ((get 'gnus-treat-display-xface 'saved-value)
1438 ** gnus-treat-display-xface is an obsolete variable;\
1439 use gnus-treat-display-x-face instead")
1440 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1443 (put 'gnus-treat-display-x-face 'highlight t)
1445 (defcustom gnus-treat-display-face
1446 (and (not noninteractive)
1447 (gnus-image-type-available-p 'png)
1449 "Display Face headers.
1450 Valid values are nil, t, `head', `first', `last', an integer or a
1451 predicate. See Info node `(gnus)Customizing Articles' and Info
1452 node `(gnus)X-Face' for details."
1453 :group 'gnus-article-treat
1455 :link '(custom-manual "(gnus)Customizing Articles")
1456 :link '(custom-manual "(gnus)X-Face")
1457 :type gnus-article-treat-head-custom)
1458 (put 'gnus-treat-display-face 'highlight t)
1460 (defcustom gnus-treat-display-smileys (gnus-image-type-available-p 'xpm)
1462 Valid values are nil, t, `head', `first', `last', an integer or a
1463 predicate. See Info node `(gnus)Customizing Articles' and Info
1464 node `(gnus)Smileys' for details."
1465 :group 'gnus-article-treat
1467 :link '(custom-manual "(gnus)Customizing Articles")
1468 :link '(custom-manual "(gnus)Smileys")
1469 :type gnus-article-treat-custom)
1470 (put 'gnus-treat-display-smileys 'highlight t)
1472 (defcustom gnus-treat-from-picon
1473 (if (and (gnus-image-type-available-p 'xpm)
1474 (gnus-picons-installed-p))
1476 "Display picons in the From header.
1477 Valid values are nil, t, `head', `first', `last', an integer or a
1478 predicate. See Info node `(gnus)Customizing Articles' and Info
1479 node `(gnus)Picons' for details."
1481 :group 'gnus-article-treat
1483 :link '(custom-manual "(gnus)Customizing Articles")
1484 :link '(custom-manual "(gnus)Picons")
1485 :type gnus-article-treat-head-custom)
1486 (put 'gnus-treat-from-picon 'highlight t)
1488 (defcustom gnus-treat-mail-picon
1489 (if (and (gnus-image-type-available-p 'xpm)
1490 (gnus-picons-installed-p))
1492 "Display picons in To and Cc headers.
1493 Valid values are nil, t, `head', `first', `last', an integer or a
1494 predicate. See Info node `(gnus)Customizing Articles' and Info
1495 node `(gnus)Picons' for details."
1497 :group 'gnus-article-treat
1499 :link '(custom-manual "(gnus)Customizing Articles")
1500 :link '(custom-manual "(gnus)Picons")
1501 :type gnus-article-treat-head-custom)
1502 (put 'gnus-treat-mail-picon 'highlight t)
1504 (defcustom gnus-treat-newsgroups-picon
1505 (if (and (gnus-image-type-available-p 'xpm)
1506 (gnus-picons-installed-p))
1508 "Display picons in the Newsgroups and Followup-To headers.
1509 Valid values are nil, t, `head', `first', `last', an integer or a
1510 predicate. See Info node `(gnus)Customizing Articles' and Info
1511 node `(gnus)Picons' for details."
1513 :group 'gnus-article-treat
1515 :link '(custom-manual "(gnus)Customizing Articles")
1516 :link '(custom-manual "(gnus)Picons")
1517 :type gnus-article-treat-head-custom)
1518 (put 'gnus-treat-newsgroups-picon 'highlight t)
1520 (defcustom gnus-treat-body-boundary
1521 (if (and (eq window-system 'x)
1522 (or gnus-treat-newsgroups-picon
1523 gnus-treat-mail-picon
1524 gnus-treat-from-picon))
1526 "Draw a boundary at the end of the headers.
1527 Valid values are nil and `head'.
1528 See Info node `(gnus)Customizing Articles' for details."
1530 :group 'gnus-article-treat
1531 :link '(custom-manual "(gnus)Customizing Articles")
1532 :type gnus-article-treat-head-custom)
1534 (defcustom gnus-treat-capitalize-sentences nil
1535 "Capitalize sentence-starting words.
1536 Valid values are nil, t, `head', `first', `last', an integer or a
1537 predicate. See Info node `(gnus)Customizing Articles'."
1539 :group 'gnus-article-treat
1540 :link '(custom-manual "(gnus)Customizing Articles")
1541 :type gnus-article-treat-custom)
1543 (defcustom gnus-treat-wash-html nil
1545 Valid values are nil, t, `head', `first', `last', an integer or a
1546 predicate. See Info node `(gnus)Customizing Articles'."
1548 :group 'gnus-article-treat
1549 :link '(custom-manual "(gnus)Customizing Articles")
1550 :type gnus-article-treat-custom)
1552 (defcustom gnus-treat-fill-long-lines nil
1554 Valid values are nil, t, `head', `first', `last', an integer or a
1555 predicate. See Info node `(gnus)Customizing Articles'."
1556 :group 'gnus-article-treat
1557 :link '(custom-manual "(gnus)Customizing Articles")
1558 :type gnus-article-treat-custom)
1560 (defcustom gnus-treat-play-sounds nil
1562 Valid values are nil, t, `head', `first', `last', an integer or a
1563 predicate. See Info node `(gnus)Customizing Articles'."
1565 :group 'gnus-article-treat
1566 :link '(custom-manual "(gnus)Customizing Articles")
1567 :type gnus-article-treat-custom)
1569 (defcustom gnus-treat-translate nil
1570 "Translate articles from one language to another.
1571 Valid values are nil, t, `head', `first', `last', an integer or a
1572 predicate. See Info node `(gnus)Customizing Articles'."
1574 :group 'gnus-article-treat
1575 :link '(custom-manual "(gnus)Customizing Articles")
1576 :type gnus-article-treat-custom)
1578 (defcustom gnus-treat-x-pgp-sig nil
1580 To automatically treat X-PGP-Sig, set it to head.
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 :group 'mime-security
1586 :link '(custom-manual "(gnus)Customizing Articles")
1587 :type gnus-article-treat-custom)
1589 (defvar gnus-article-encrypt-protocol-alist
1590 '(("PGP" . mml2015-self-encrypt)))
1592 ;; Set to nil if more than one protocol added to
1593 ;; gnus-article-encrypt-protocol-alist.
1594 (defcustom gnus-article-encrypt-protocol "PGP"
1595 "The protocol used for encrypt articles.
1596 It is a string, such as \"PGP\". If nil, ask user."
1599 :group 'mime-security)
1601 (defvar gnus-article-wash-function nil
1602 "Function used for converting HTML into text.")
1604 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1605 (mm-coding-system-p 'utf-8)
1606 (executable-find idna-program))
1607 "Whether IDNA decoding of headers is used when viewing messages.
1608 This requires GNU Libidn, and by default only enabled if it is found."
1610 :group 'gnus-article-headers
1613 (defcustom gnus-article-over-scroll nil
1614 "If non-nil, allow scrolling the article buffer even when there no more text."
1616 :group 'gnus-article
1619 ;;; Internal variables
1621 (defvar gnus-english-month-names
1622 '("January" "February" "March" "April" "May" "June" "July" "August"
1623 "September" "October" "November" "December"))
1625 (defvar article-goto-body-goes-to-point-min-p nil)
1626 (defvar gnus-article-wash-types nil)
1627 (defvar gnus-article-emphasis-alist nil)
1628 (defvar gnus-article-image-alist nil)
1630 (defvar gnus-article-mime-handle-alist-1 nil)
1631 (defvar gnus-treatment-function-alist
1632 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1633 (gnus-treat-strip-banner gnus-article-strip-banner)
1634 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1635 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1636 (gnus-treat-buttonize gnus-article-add-buttons)
1637 (gnus-treat-fill-article gnus-article-fill-cited-article)
1638 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1639 (gnus-treat-strip-cr gnus-article-remove-cr)
1640 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1641 (gnus-treat-date-ut gnus-article-date-ut)
1642 (gnus-treat-date-local gnus-article-date-local)
1643 (gnus-treat-date-english gnus-article-date-english)
1644 (gnus-treat-date-original gnus-article-date-original)
1645 (gnus-treat-date-user-defined gnus-article-date-user)
1646 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1647 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1648 (gnus-treat-display-x-face gnus-article-display-x-face)
1649 (gnus-treat-display-face gnus-article-display-face)
1650 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1651 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1652 (gnus-treat-hide-signature gnus-article-hide-signature)
1653 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1654 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1655 (gnus-treat-strip-pem gnus-article-hide-pem)
1656 (gnus-treat-from-picon gnus-treat-from-picon)
1657 (gnus-treat-mail-picon gnus-treat-mail-picon)
1658 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1659 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1660 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1661 (gnus-treat-strip-trailing-blank-lines
1662 gnus-article-remove-trailing-blank-lines)
1663 (gnus-treat-strip-leading-blank-lines
1664 gnus-article-strip-leading-blank-lines)
1665 (gnus-treat-strip-multiple-blank-lines
1666 gnus-article-strip-multiple-blank-lines)
1667 (gnus-treat-overstrike gnus-article-treat-overstrike)
1668 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1669 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1670 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1671 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1672 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1673 (gnus-treat-display-smileys gnus-treat-smiley)
1674 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1675 (gnus-treat-wash-html gnus-article-wash-html)
1676 (gnus-treat-emphasize gnus-article-emphasize)
1677 (gnus-treat-hide-citation gnus-article-hide-citation)
1678 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1679 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1680 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1681 (gnus-treat-play-sounds gnus-earcon-display)))
1683 (defvar gnus-article-mime-handle-alist nil)
1684 (defvar article-lapsed-timer nil)
1685 (defvar gnus-article-current-summary nil)
1687 (defvar gnus-article-mode-syntax-table
1688 (let ((table (copy-syntax-table text-mode-syntax-table)))
1689 ;; This causes the citation match run O(2^n).
1690 ;; (modify-syntax-entry ?- "w" table)
1691 (modify-syntax-entry ?> ")<" table)
1692 (modify-syntax-entry ?< "(>" table)
1693 ;; make M-. in article buffers work for `foo' strings
1694 (modify-syntax-entry ?' " " table)
1695 (modify-syntax-entry ?` " " table)
1697 "Syntax table used in article mode buffers.
1698 Initialized from `text-mode-syntax-table.")
1700 (defvar gnus-save-article-buffer nil)
1702 (defvar gnus-article-mode-line-format-alist
1703 (nconc '((?w (gnus-article-wash-status) ?s)
1704 (?m (gnus-article-mime-part-status) ?s))
1705 gnus-summary-mode-line-format-alist))
1707 (defvar gnus-number-of-articles-to-be-saved nil)
1709 (defvar gnus-inhibit-hiding nil)
1711 (defvar gnus-article-edit-mode nil)
1713 ;;; Macros for dealing with the article buffer.
1715 (defmacro gnus-with-article-headers (&rest forms)
1717 (set-buffer gnus-article-buffer)
1719 (let ((inhibit-read-only t)
1720 (inhibit-point-motion-hooks t)
1721 (case-fold-search t))
1722 (article-narrow-to-head)
1725 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1726 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1728 (defmacro gnus-with-article-buffer (&rest forms)
1730 (set-buffer gnus-article-buffer)
1731 (let ((inhibit-read-only t))
1734 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1735 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1737 (defun gnus-article-goto-header (header)
1738 "Go to HEADER, which is a regular expression."
1739 (re-search-forward (concat "^\\(" header "\\):") nil t))
1741 (defsubst gnus-article-hide-text (b e props)
1742 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1743 (gnus-add-text-properties-when 'article-type nil b e props)
1744 (when (memq 'intangible props)
1746 (max (1- b) (point-min))
1747 b 'intangible (cddr (memq 'intangible props)))))
1749 (defsubst gnus-article-unhide-text (b e)
1750 "Remove hidden text properties from region between B and E."
1751 (remove-text-properties b e gnus-hidden-properties)
1752 (when (memq 'intangible gnus-hidden-properties)
1753 (put-text-property (max (1- b) (point-min))
1754 b 'intangible nil)))
1756 (defun gnus-article-hide-text-type (b e type)
1757 "Hide text of TYPE between B and E."
1758 (gnus-add-wash-type type)
1759 (gnus-article-hide-text
1760 b e (cons 'article-type (cons type gnus-hidden-properties))))
1762 (defun gnus-article-unhide-text-type (b e type)
1763 "Unhide text of TYPE between B and E."
1764 (gnus-delete-wash-type type)
1765 (remove-text-properties
1766 b e (cons 'article-type (cons type gnus-hidden-properties)))
1767 (when (memq 'intangible gnus-hidden-properties)
1768 (put-text-property (max (1- b) (point-min))
1769 b 'intangible nil)))
1771 (defun gnus-article-hide-text-of-type (type)
1772 "Hide text of TYPE in the current buffer."
1774 (let ((b (point-min))
1776 (while (setq b (text-property-any b e 'article-type type))
1777 (add-text-properties b (incf b) gnus-hidden-properties)))))
1779 (defun gnus-article-delete-text-of-type (type)
1780 "Delete text of TYPE in the current buffer."
1782 (let ((b (point-min)))
1783 (if (eq type 'multipart)
1784 ;; Remove MIME buttons associated with multipart/alternative parts.
1787 (while (if (get-text-property (point) 'gnus-part)
1789 (when (setq b (next-single-property-change (point)
1794 (skip-chars-forward "\n")
1795 (when (eq (get-text-property b 'article-type) 'multipart)
1796 (delete-region b (point)))))
1797 (while (setq b (text-property-any b (point-max) 'article-type type))
1799 b (or (text-property-not-all b (point-max) 'article-type type)
1802 (defun gnus-article-delete-invisible-text ()
1803 "Delete all invisible text in the current buffer."
1805 (let ((b (point-min)))
1806 (while (setq b (text-property-any b (point-max) 'invisible t))
1808 b (or (text-property-not-all b (point-max) 'invisible t)
1811 (defun gnus-article-text-type-exists-p (type)
1812 "Say whether any text of type TYPE exists in the buffer."
1813 (text-property-any (point-min) (point-max) 'article-type type))
1815 (defsubst gnus-article-header-rank ()
1816 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1817 (let ((list gnus-sorted-header-list)
1820 (if (looking-at (car list))
1822 (setq list (cdr list))
1826 (defun article-hide-headers (&optional arg delete)
1827 "Hide unwanted headers and possibly sort them as well."
1829 ;; This function might be inhibited.
1830 (unless gnus-inhibit-hiding
1831 (let ((inhibit-read-only t)
1832 (case-fold-search t)
1833 (max (1+ (length gnus-sorted-header-list)))
1834 (inhibit-point-motion-hooks t)
1835 (cur (current-buffer))
1836 ignored visible beg)
1838 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1839 ;; group parameters, so we should go to the summary buffer.
1842 (progn (set-buffer gnus-summary-buffer) t)
1844 (setq ignored (when (not gnus-visible-headers)
1845 (cond ((stringp gnus-ignored-headers)
1846 gnus-ignored-headers)
1847 ((listp gnus-ignored-headers)
1848 (mapconcat 'identity
1849 gnus-ignored-headers
1851 visible (cond ((stringp gnus-visible-headers)
1852 gnus-visible-headers)
1853 ((and gnus-visible-headers
1854 (listp gnus-visible-headers))
1855 (mapconcat 'identity
1856 gnus-visible-headers
1860 ;; First we narrow to just the headers.
1861 (article-narrow-to-head)
1862 ;; Hide any "From " lines at the beginning of (mail) articles.
1863 (while (looking-at "From ")
1866 (delete-region (point-min) (point)))
1867 ;; Then treat the rest of the header lines.
1868 ;; Then we use the two regular expressions
1869 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1870 ;; select which header lines is to remain visible in the
1872 (while (re-search-forward "^[^ \t:]*:" nil t)
1874 ;; Mark the rank of the header.
1876 (point) (1+ (point)) 'message-rank
1877 (if (or (and visible (looking-at visible))
1879 (not (looking-at ignored))))
1880 (gnus-article-header-rank)
1883 (message-sort-headers-1)
1884 (when (setq beg (text-property-any
1885 (point-min) (point-max) 'message-rank (+ 2 max)))
1886 ;; We delete the unwanted headers.
1887 (gnus-add-wash-type 'headers)
1888 (add-text-properties (point-min) (+ 5 (point-min))
1889 '(article-type headers dummy-invisible t))
1890 (delete-region beg (point-max))))))))
1892 (defun article-hide-boring-headers (&optional arg)
1893 "Toggle hiding of headers that aren't very interesting.
1894 If given a negative prefix, always show; if given a positive prefix,
1896 (interactive (gnus-article-hidden-arg))
1897 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1898 (not gnus-show-all-headers))
1901 (let ((inhibit-read-only t)
1902 (inhibit-point-motion-hooks t))
1903 (article-narrow-to-head)
1904 (dolist (elem gnus-boring-article-headers)
1905 (goto-char (point-min))
1907 ;; Hide empty headers.
1909 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1911 (gnus-article-hide-text-type
1915 (if (re-search-forward "^[^ \t]" nil t)
1919 ;; Hide boring Newsgroups header.
1920 ((eq elem 'newsgroups)
1921 (when (gnus-string-equal
1922 (gnus-fetch-field "newsgroups")
1923 (gnus-group-real-name
1924 (if (boundp 'gnus-newsgroup-name)
1927 (gnus-article-hide-header "newsgroups")))
1928 ((eq elem 'to-address)
1929 (let ((to (message-fetch-field "to"))
1931 (gnus-parameter-to-address
1932 (if (boundp 'gnus-newsgroup-name)
1933 gnus-newsgroup-name ""))))
1934 (when (and to to-address
1937 ;; only one address in To
1938 (nth 1 (mail-extract-address-components to))
1940 (gnus-article-hide-header "to"))))
1942 (let ((to (message-fetch-field "to"))
1944 (gnus-parameter-to-list
1945 (if (boundp 'gnus-newsgroup-name)
1946 gnus-newsgroup-name ""))))
1947 (when (and to to-list
1950 ;; only one address in To
1951 (nth 1 (mail-extract-address-components to))
1953 (gnus-article-hide-header "to"))))
1955 (let ((cc (message-fetch-field "cc"))
1957 (gnus-parameter-to-list
1958 (if (boundp 'gnus-newsgroup-name)
1959 gnus-newsgroup-name ""))))
1960 (when (and cc to-list
1963 ;; only one address in CC
1964 (nth 1 (mail-extract-address-components cc))
1966 (gnus-article-hide-header "cc"))))
1967 ((eq elem 'followup-to)
1968 (when (gnus-string-equal
1969 (message-fetch-field "followup-to")
1970 (message-fetch-field "newsgroups"))
1971 (gnus-article-hide-header "followup-to")))
1972 ((eq elem 'reply-to)
1973 (if (gnus-group-find-parameter
1974 gnus-newsgroup-name 'broken-reply-to)
1975 (gnus-article-hide-header "reply-to")
1976 (let ((from (message-fetch-field "from"))
1977 (reply-to (message-fetch-field "reply-to")))
1984 (lambda (x) (downcase (cadr x)))
1985 (mail-extract-address-components from t))
1988 (lambda (x) (downcase (cadr x)))
1989 (mail-extract-address-components reply-to t))
1991 (gnus-article-hide-header "reply-to")))))
1993 (let ((date (with-current-buffer gnus-original-article-buffer
1994 ;; If date in `gnus-article-buffer' is localized
1995 ;; (`gnus-treat-date-user-defined'),
1996 ;; `days-between' might fail.
1997 (message-fetch-field "date"))))
1999 (< (days-between (current-time-string) date)
2001 (gnus-article-hide-header "date"))))
2003 (let ((to (message-fetch-field "to"))
2004 (cc (message-fetch-field "cc")))
2005 (when (> (length to) 1024)
2006 (gnus-article-hide-header "to"))
2007 (when (> (length cc) 1024)
2008 (gnus-article-hide-header "cc"))))
2012 (goto-char (point-min))
2013 (while (re-search-forward "^to:" nil t)
2014 (setq to-count (1+ to-count)))
2015 (when (> to-count 1)
2016 (while (> to-count 0)
2017 (goto-char (point-min))
2019 (re-search-forward "^to:" nil nil to-count)
2021 (narrow-to-region (point) (point-max))
2022 (gnus-article-hide-header "to"))
2023 (setq to-count (1- to-count))))
2024 (goto-char (point-min))
2025 (while (re-search-forward "^cc:" nil t)
2026 (setq cc-count (1+ cc-count)))
2027 (when (> cc-count 1)
2028 (while (> cc-count 0)
2029 (goto-char (point-min))
2031 (re-search-forward "^cc:" nil nil cc-count)
2033 (narrow-to-region (point) (point-max))
2034 (gnus-article-hide-header "cc"))
2035 (setq cc-count (1- cc-count)))))))))))))
2037 (defun gnus-article-hide-header (header)
2039 (goto-char (point-min))
2040 (when (re-search-forward (concat "^" header ":") nil t)
2041 (gnus-article-hide-text-type
2045 (if (re-search-forward "^[^ \t]" nil t)
2050 (defvar gnus-article-normalized-header-length 40
2051 "Length of normalized headers.")
2053 (defun article-normalize-headers ()
2054 "Make all header lines 40 characters long."
2056 (let ((inhibit-read-only t)
2060 (article-narrow-to-head)
2063 ((< (setq column (- (point-at-eol) (point)))
2064 gnus-article-normalized-header-length)
2066 (insert (make-string
2067 (- gnus-article-normalized-header-length column)
2069 ((> column gnus-article-normalized-header-length)
2070 (gnus-put-text-property
2072 (forward-char gnus-article-normalized-header-length)
2079 (forward-line 1))))))
2081 (defun article-treat-dumbquotes ()
2082 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
2083 Note that this function guesses whether a character is a sm*rtq**t* or
2084 not, so it should only be used interactively.
2086 Sm*rtq**t*s are M****s***'s unilateral extension to the
2087 iso-8859-1 character map in an attempt to provide more quoting
2088 characters. If you see something like \\222 or \\264 where
2089 you're expecting some kind of apostrophe or quotation mark, then
2092 (article-translate-strings gnus-article-dumbquotes-map))
2094 (defun article-translate-characters (from to)
2095 "Translate all characters in the body of the article according to FROM and TO.
2096 FROM is a string of characters to translate from; to is a string of
2097 characters to translate to."
2099 (when (article-goto-body)
2100 (let ((inhibit-read-only t)
2101 (x (make-string 225 ?x))
2103 (while (< (incf i) (length x))
2106 (while (< i (length from))
2107 (aset x (aref from i) (aref to i))
2109 (translate-region (point) (point-max) x)))))
2111 (defun article-translate-strings (map)
2112 "Translate all string in the body of the article according to MAP.
2113 MAP is an alist where the elements are on the form (\"from\" \"to\")."
2115 (when (article-goto-body)
2116 (let ((inhibit-read-only t))
2119 (while (search-forward (car elem) nil t)
2120 (replace-match (cadr elem)))))))))
2122 (defun article-treat-overstrike ()
2123 "Translate overstrikes into bold text."
2126 (when (article-goto-body)
2127 (let ((inhibit-read-only t))
2128 (while (search-forward "\b" nil t)
2129 (let ((next (char-after))
2130 (previous (char-after (- (point) 2))))
2131 ;; We do the boldification/underlining by hiding the
2132 ;; overstrikes and putting the proper text property
2136 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
2137 (put-text-property (point) (1+ (point)) 'face 'bold))
2139 (gnus-article-hide-text-type
2140 (1- (point)) (1+ (point)) 'overstrike)
2142 (- (point) 2) (1- (point)) 'face 'underline))
2144 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
2146 (point) (1+ (point)) 'face 'underline)))))))))
2148 (defun article-treat-ansi-sequences ()
2149 "Translate ANSI SGR control sequences into overlays or extents."
2152 (when (article-goto-body)
2153 (let ((inhibit-read-only t))
2154 (ansi-color-apply-on-region (point) (point-max))))))
2156 (defun gnus-article-treat-unfold-headers ()
2157 "Unfold folded message headers.
2158 Only the headers that fit into the current window width will be
2161 (gnus-with-article-headers
2165 (mail-header-narrow-to-field)
2166 (let* ((header (buffer-string))
2168 (or (equal gnus-article-unfold-long-headers t)
2169 (and (stringp gnus-article-unfold-long-headers)
2170 (string-match gnus-article-unfold-long-headers header)))))
2173 (goto-char (point-min))
2174 (while (re-search-forward "\n[\t ]" nil t)
2175 (replace-match " " t t)))
2176 (setq length (- (point-max) (point-min) 1))
2177 (when (or unfoldable
2178 (< length (window-width)))
2179 (while (re-search-forward "\n[\t ]" nil t)
2180 (replace-match " " t t))))
2181 (goto-char (point-max)))))))
2183 (defun gnus-article-treat-fold-headers ()
2184 "Fold message headers."
2186 (gnus-with-article-headers
2189 (mail-header-narrow-to-field)
2190 (mail-header-fold-field)
2191 (goto-char (point-max))))))
2193 (defun gnus-treat-smiley ()
2194 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2196 (gnus-with-article-buffer
2197 (if (memq 'smiley gnus-article-wash-types)
2198 (gnus-delete-images 'smiley)
2200 (let ((images (smiley-region (point) (point-max))))
2202 (gnus-add-wash-type 'smiley)
2203 (dolist (image images)
2204 (gnus-add-image 'smiley image)))))))
2206 (defun gnus-article-remove-images ()
2207 "Remove all images from the article buffer."
2209 (gnus-with-article-buffer
2210 (dolist (elem gnus-article-image-alist)
2211 (gnus-delete-images (car elem)))))
2213 (defun gnus-article-treat-fold-newsgroups ()
2214 "Unfold folded message headers.
2215 Only the headers that fit into the current window width will be
2218 (gnus-with-article-headers
2219 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2221 (mail-header-narrow-to-field)
2222 (while (re-search-forward ", *" nil t)
2223 (replace-match ", " t t))
2224 (mail-header-fold-field)
2225 (goto-char (point-max))))))
2227 (defcustom gnus-article-truncate-lines default-truncate-lines
2228 "Value of `truncate-lines' in Gnus Article buffer.
2229 Valid values are nil, t, `head', `first', `last', an integer or a
2230 predicate. See Info node `(gnus)Customizing Articles'."
2231 :version "23.0" ;; No Gnus
2232 :group 'gnus-article
2233 ;; :link '(custom-manual "(gnus)Customizing Articles")
2236 (defun gnus-article-toggle-truncate-lines (&optional arg)
2237 "Toggle whether to fold or truncate long lines in article the buffer.
2238 If ARG is non-nil and not a number, toggle
2239 `gnus-article-truncate-lines' too. If ARG is a number, truncate
2240 long lines iff arg is positive."
2243 ((and (numberp arg) (> arg 0))
2244 (setq gnus-article-truncate-lines t))
2246 (setq gnus-article-truncate-lines nil))
2248 (setq gnus-article-truncate-lines
2249 (not gnus-article-truncate-lines))))
2250 (gnus-with-article-buffer
2252 ((and (numberp arg) (> arg 0))
2253 (setq truncate-lines nil))
2255 (setq truncate-lines t)))
2256 ;; In versions of Emacs 22 (CVS) before 2006-05-26,
2257 ;; `toggle-truncate-lines' needs an argument.
2258 (toggle-truncate-lines)))
2260 (defun gnus-article-treat-body-boundary ()
2261 "Place a boundary line at the end of the headers."
2263 (when (and gnus-body-boundary-delimiter
2264 (> (length gnus-body-boundary-delimiter) 0))
2265 (gnus-with-article-headers
2266 (goto-char (point-max))
2267 (let ((start (point)))
2268 (insert "X-Boundary: ")
2269 (gnus-add-text-properties start (point) '(invisible t intangible t))
2271 (while (>= (1- (window-width)) (length str))
2272 (setq str (concat str gnus-body-boundary-delimiter)))
2273 (substring str 0 (1- (window-width))))
2275 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2277 (defun article-fill-long-lines ()
2278 "Fill lines that are wider than the window width."
2281 (let ((inhibit-read-only t)
2282 (width (window-width (get-buffer-window (current-buffer)))))
2285 (let ((adaptive-fill-mode nil)) ;Why? -sm
2288 (when (>= (current-column) (min fill-column width))
2289 (narrow-to-region (min (1+ (point)) (point-max))
2291 (let ((goback (point-marker)))
2292 (fill-paragraph nil)
2293 (goto-char (marker-position goback)))
2295 (forward-line 1)))))))
2297 (defun article-capitalize-sentences ()
2298 "Capitalize the first word in each sentence."
2301 (let ((inhibit-read-only t)
2302 (paragraph-start "^[\n\^L]"))
2306 (forward-sentence)))))
2308 (defun article-remove-cr ()
2309 "Remove trailing CRs and then translate remaining CRs into LFs."
2312 (let ((inhibit-read-only t))
2313 (goto-char (point-min))
2314 (while (re-search-forward "\r+$" nil t)
2315 (replace-match "" t t))
2316 (goto-char (point-min))
2317 (while (search-forward "\r" nil t)
2318 (replace-match "\n" t t)))))
2320 (defun article-remove-trailing-blank-lines ()
2321 "Remove all trailing blank lines from the article."
2324 (let ((inhibit-read-only t))
2325 (goto-char (point-max))
2329 (while (and (not (bobp))
2330 (looking-at "^[ \t]*$")
2331 (not (gnus-annotation-in-region-p
2332 (point) (point-at-eol))))
2338 (defvar gnus-face-properties-alist))
2340 (defun article-display-face ()
2341 "Display any Face headers in the header."
2343 (let ((wash-face-p buffer-read-only))
2344 (gnus-with-article-headers
2345 ;; When displaying parts, this function can be called several times on
2346 ;; the same article, without any intended toggle semantic (as typing `W
2347 ;; D d' would have). So face deletion must occur only when we come from
2348 ;; an interactive command, that is when the *Article* buffer is
2350 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2351 (gnus-delete-images 'face)
2352 (let (face faces from)
2353 (save-current-buffer
2354 (when (and wash-face-p
2355 (gnus-buffer-live-p gnus-original-article-buffer)
2356 (not (re-search-forward "^Face:[\t ]*" nil t)))
2357 (set-buffer gnus-original-article-buffer))
2359 (mail-narrow-to-head)
2360 (while (gnus-article-goto-header "Face")
2361 (push (mail-header-field-value) faces))))
2363 (goto-char (point-min))
2364 (let ((from (gnus-article-goto-header "from"))
2369 (insert "[no `from' set]\n"))
2371 (when (setq png (gnus-convert-face-to-png (pop faces)))
2373 (apply 'gnus-create-image png 'png t
2374 (cdr (assq 'png gnus-face-properties-alist))))
2376 (gnus-add-wash-type 'face)
2377 (gnus-add-image 'face image)
2378 (gnus-put-image image nil 'face))))))))))
2380 (defun article-display-x-face (&optional force)
2381 "Look for an X-Face header and display it if present."
2382 (interactive (list 'force))
2383 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2384 (gnus-with-article-headers
2385 ;; Delete the old process, if any.
2386 (when (process-status "article-x-face")
2387 (delete-process "article-x-face"))
2388 ;; See the comment in `article-display-face'.
2389 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2390 ;; We have already displayed X-Faces, so we remove them
2392 (gnus-delete-images 'xface)
2394 (let (x-faces from face)
2395 (save-current-buffer
2396 (when (and wash-face-p
2397 (gnus-buffer-live-p gnus-original-article-buffer)
2398 (not (re-search-forward "^X-Face:[\t ]*" nil t)))
2399 ;; If type `W f', use gnus-original-article-buffer,
2400 ;; otherwise use the current buffer because displaying
2401 ;; RFC822 parts calls this function too.
2402 (set-buffer gnus-original-article-buffer))
2404 (mail-narrow-to-head)
2405 (while (gnus-article-goto-header "X-Face")
2406 (push (mail-header-field-value) x-faces))
2407 (setq from (message-fetch-field "from"))))
2408 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2409 ;; single external face.
2410 (when (stringp gnus-article-x-face-command)
2411 (setq x-faces (list (car x-faces))))
2413 gnus-article-x-face-command
2415 ;; Check whether this face is censored.
2416 (not gnus-article-x-face-too-ugly)
2418 (not (string-match gnus-article-x-face-too-ugly
2420 (while (setq face (pop x-faces))
2421 ;; We display the face.
2422 (cond ((stringp gnus-article-x-face-command)
2423 ;; The command is a string, so we interpret the command
2424 ;; as a, well, command, and fork it off.
2425 (let ((process-connection-type nil))
2426 (gnus-set-process-query-on-exit-flag
2428 "article-x-face" nil shell-file-name
2429 shell-command-switch gnus-article-x-face-command)
2433 (process-send-region "article-x-face"
2434 (point-min) (point-max)))
2435 (process-send-eof "article-x-face")))
2436 ((functionp gnus-article-x-face-command)
2437 ;; The command is a lisp function, so we call it.
2438 (funcall gnus-article-x-face-command face))
2440 (error "%s is not a function"
2441 gnus-article-x-face-command))))))))))
2443 (defun article-decode-mime-words ()
2444 "Decode all MIME-encoded words in the article."
2446 (gnus-with-article-buffer
2447 (let ((inhibit-point-motion-hooks t)
2448 (mail-parse-charset gnus-newsgroup-charset)
2449 (mail-parse-ignored-charsets
2450 (with-current-buffer gnus-summary-buffer
2451 gnus-newsgroup-ignored-charsets)))
2452 (mail-decode-encoded-word-region (point-min) (point-max)))))
2454 (defun article-decode-charset (&optional prompt)
2455 "Decode charset-encoded text in the article.
2456 If PROMPT (the prefix), prompt for a coding system to use."
2458 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2459 (inhibit-read-only t)
2460 (mail-parse-charset gnus-newsgroup-charset)
2461 (mail-parse-ignored-charsets
2462 (save-excursion (condition-case nil
2463 (set-buffer gnus-summary-buffer)
2465 gnus-newsgroup-ignored-charsets))
2466 ct cte ctl charset format)
2469 (article-narrow-to-head)
2470 (setq ct (message-fetch-field "Content-Type" t)
2471 cte (message-fetch-field "Content-Transfer-Encoding" t)
2472 ctl (and ct (mail-header-parse-content-type ct))
2475 (mm-read-coding-system "Charset to decode: "))
2477 (mail-content-type-get ctl 'charset)))
2478 format (and ctl (mail-content-type-get ctl 'format)))
2480 (setq cte (mail-header-strip cte)))
2481 (if (and ctl (not (string-match "/" (car ctl))))
2483 (goto-char (point-max)))
2486 (narrow-to-region (point) (point-max))
2487 (when (and (eq mail-parse-charset 'gnus-decoded)
2488 (eq (mm-body-7-or-8) '8bit))
2489 ;; The text code could have been decoded.
2490 (setq charset mail-parse-charset))
2491 (when (and (or (not ctl)
2492 (equal (car ctl) "text/plain"))
2493 (not format)) ;; article with format will decode later.
2495 charset (and cte (intern (downcase
2496 (gnus-strip-whitespace cte))))
2499 (defun article-decode-encoded-words ()
2500 "Remove encoded-word encoding from headers."
2501 (let ((inhibit-point-motion-hooks t)
2502 (mail-parse-charset gnus-newsgroup-charset)
2503 (mail-parse-ignored-charsets
2504 (save-excursion (condition-case nil
2505 (set-buffer gnus-summary-buffer)
2507 gnus-newsgroup-ignored-charsets))
2508 (inhibit-read-only t)
2510 (goto-char (point-min))
2511 (when (search-forward "\n\n" nil 'move)
2518 (memq (char-after) '(?\t ? )))))
2519 (setq start (point))
2521 \\(?:Resent-\\)?\\(?:From\\|Cc\\|To\\|Bcc\\|\\(?:In-\\)?Reply-To\\|Sender\
2522 \\|Mail-Followup-To\\|Mail-Copies-To\\|Approved\\):")
2523 (funcall gnus-decode-address-function start end)
2524 (funcall gnus-decode-header-function start end))
2525 (goto-char (setq end start)))))
2527 (defun article-decode-group-name ()
2528 "Decode group names in Newsgroups, Followup-To and Xref headers."
2529 (let ((inhibit-point-motion-hooks t)
2530 (inhibit-read-only t)
2531 (method (gnus-find-method-for-group gnus-newsgroup-name))
2533 (when (and (or gnus-group-name-charset-method-alist
2534 gnus-group-name-charset-group-alist)
2535 (gnus-buffer-live-p gnus-original-article-buffer))
2537 (article-narrow-to-head)
2538 (dolist (header '("Newsgroups" "Followup-To" "Xref"))
2539 (with-current-buffer gnus-original-article-buffer
2540 (goto-char (point-min)))
2541 (setq regexp (concat "^" header
2542 ":\\([^\n]*\\(?:\n[\t ]+[^\n]+\\)*\\)\n"))
2543 (while (re-search-forward regexp nil t)
2544 (replace-match (save-match-data
2545 (gnus-decode-newsgroups
2546 ;; XXX how to use data in article buffer?
2547 (with-current-buffer gnus-original-article-buffer
2548 (re-search-forward regexp nil t)
2550 gnus-newsgroup-name method))
2552 (goto-char (point-min)))))))
2554 (autoload 'idna-to-unicode "idna")
2556 (defun article-decode-idna-rhs ()
2557 "Decode IDNA strings in RHS in various headers in current buffer.
2558 The following headers are decoded: From:, To:, Cc:, Reply-To:,
2559 Mail-Reply-To: and Mail-Followup-To:."
2562 (let ((inhibit-point-motion-hooks t)
2563 (inhibit-read-only t))
2564 (article-narrow-to-head)
2565 (goto-char (point-min))
2566 (while (re-search-forward "@[^ \t\n\r,>]*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2568 (when (save-match-data
2569 (and (setq ace (match-string 1))
2571 (and (re-search-backward "^[^ \t]" nil t)
2572 (looking-at "From\\|To\\|Cc\\|Reply-To\\|Mail-Reply-To\\|Mail-Followup-To")))
2573 (setq unicode (idna-to-unicode ace))))
2574 (unless (string= ace unicode)
2575 (replace-match unicode nil nil nil 1)))))))))
2577 (defun article-de-quoted-unreadable (&optional force read-charset)
2578 "Translate a quoted-printable-encoded article.
2579 If FORCE, decode the article whether it is marked as quoted-printable
2581 If READ-CHARSET, ask for a coding system."
2582 (interactive (list 'force current-prefix-arg))
2584 (let ((inhibit-read-only t) type charset)
2585 (if (gnus-buffer-live-p gnus-original-article-buffer)
2586 (with-current-buffer gnus-original-article-buffer
2588 (gnus-fetch-field "content-transfer-encoding"))
2589 (let* ((ct (gnus-fetch-field "content-type"))
2590 (ctl (and ct (mail-header-parse-content-type ct))))
2591 (setq charset (and ctl
2592 (mail-content-type-get ctl 'charset)))
2593 (if (stringp charset)
2594 (setq charset (intern (downcase charset)))))))
2596 (setq charset (mm-read-coding-system "Charset: " charset)))
2598 (setq charset gnus-newsgroup-charset))
2600 (and type (let ((case-fold-search t))
2601 (string-match "quoted-printable" type))))
2603 (quoted-printable-decode-region
2604 (point) (point-max) (mm-charset-to-coding-system charset))))))
2606 (defun article-de-base64-unreadable (&optional force read-charset)
2607 "Translate a base64 article.
2608 If FORCE, decode the article whether it is marked as base64 not.
2609 If READ-CHARSET, ask for a coding system."
2610 (interactive (list 'force current-prefix-arg))
2612 (let ((inhibit-read-only t) type charset)
2613 (if (gnus-buffer-live-p gnus-original-article-buffer)
2614 (with-current-buffer gnus-original-article-buffer
2616 (gnus-fetch-field "content-transfer-encoding"))
2617 (let* ((ct (gnus-fetch-field "content-type"))
2618 (ctl (and ct (mail-header-parse-content-type ct))))
2619 (setq charset (and ctl
2620 (mail-content-type-get ctl 'charset)))
2621 (if (stringp charset)
2622 (setq charset (intern (downcase charset)))))))
2624 (setq charset (mm-read-coding-system "Charset: " charset)))
2626 (setq charset gnus-newsgroup-charset))
2628 (and type (let ((case-fold-search t))
2629 (string-match "base64" type))))
2632 (narrow-to-region (point) (point-max))
2633 (base64-decode-region (point-min) (point-max))
2634 (mm-decode-coding-region
2635 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2640 (defun article-decode-HZ ()
2641 "Translate a HZ-encoded article."
2645 (let ((inhibit-read-only t))
2646 (rfc1843-decode-region (point-min) (point-max)))))
2648 (defun article-unsplit-urls ()
2649 "Remove the newlines that some other mailers insert into URLs."
2652 (let ((inhibit-read-only t))
2653 (goto-char (point-min))
2654 (while (re-search-forward
2655 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2656 (replace-match "\\1\\3" t)))
2657 (when (interactive-p)
2658 (gnus-treat-article nil))))
2661 (defun article-wash-html (&optional read-charset)
2662 "Format an HTML article.
2663 If READ-CHARSET, ask for a coding system. If it is a number, the
2664 charset defined in `gnus-summary-show-article-charset-alist' is used."
2667 (let ((inhibit-read-only t)
2670 (if (or (and (numberp read-charset)
2674 gnus-summary-show-article-charset-alist))))
2675 (setq charset (mm-read-coding-system "Charset: ")))
2676 (let ((gnus-summary-show-article-charset-alist
2677 (list (cons 1 charset))))
2678 (with-current-buffer gnus-summary-buffer
2679 (gnus-summary-show-article 1)))
2680 (error "No charset is given"))
2681 (when (gnus-buffer-live-p gnus-original-article-buffer)
2682 (with-current-buffer gnus-original-article-buffer
2683 (let* ((ct (gnus-fetch-field "content-type"))
2684 (ctl (and ct (mail-header-parse-content-type ct))))
2685 (setq charset (and ctl
2686 (mail-content-type-get ctl 'charset)))
2687 (when (stringp charset)
2688 (setq charset (intern (downcase charset)))))))
2690 (setq charset gnus-newsgroup-charset)))
2692 (save-window-excursion
2694 (narrow-to-region (point) (point-max))
2695 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2696 (entry (assq func mm-text-html-washer-alist)))
2698 (setq func (cdr entry)))
2703 (apply (car func) (cdr func))))))))))
2705 (defun gnus-article-wash-html-with-w3 ()
2706 "Wash the current buffer with w3."
2708 (let ((w3-strict-width (window-width))
2709 (url-standalone-mode t)
2710 (url-gateway-unplugged t)
2711 (w3-honor-stylesheets nil))
2713 (w3-region (point-min) (point-max))
2716 (defun gnus-article-wash-html-with-w3m ()
2717 "Wash the current buffer with emacs-w3m."
2719 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2720 w3m-force-redisplay)
2721 (w3m-region (point-min) (point-max)))
2722 (when (and mm-inline-text-html-with-w3m-keymap
2723 (boundp 'w3m-minor-mode-map)
2725 (add-text-properties
2726 (point-min) (point-max)
2727 (list 'keymap w3m-minor-mode-map
2728 ;; Put the mark meaning this part was rendered by emacs-w3m.
2729 'mm-inline-text-html-with-w3m t))))
2731 (eval-when-compile (defvar charset)) ;; Bound by `article-wash-html'.
2733 (defun gnus-article-wash-html-with-w3m-standalone ()
2734 "Wash the current buffer with w3m."
2735 (if (mm-w3m-standalone-supports-m17n-p)
2737 (unless (mm-coding-system-p charset) ;; Bound by `article-wash-html'.
2739 (setq charset 'iso-8859-1))
2740 (let ((coding-system-for-write charset)
2741 (coding-system-for-read charset))
2742 (call-process-region
2743 (point-min) (point-max)
2744 "w3m" t t nil "-dump" "-T" "text/html"
2745 "-I" (symbol-name charset) "-O" (symbol-name charset))))
2746 (mm-inline-wash-with-stdin nil "w3m" "-dump" "-T" "text/html")))
2748 (defvar gnus-article-browse-html-temp-list nil
2749 "List of temporary files created by `gnus-article-browse-html-parts'.
2750 Internal variable.")
2752 (defcustom gnus-article-browse-delete-temp 'ask
2753 "What to do with temporary files from `gnus-article-browse-html-parts'.
2754 If nil, don't delete temporary files. If it is t, delete them on
2755 exit from the summary buffer. If it is the symbol `file', query
2756 on each file, if it is `ask' ask once when exiting from the
2758 :group 'gnus-article
2759 :version "23.0" ;; No Gnus
2760 :type '(choice (const :tag "Don't delete" nil)
2761 (const :tag "Don't ask" t)
2762 (const :tag "Ask" ask)
2763 (const :tag "Ask for each file" file)))
2765 ;; Cf. mm-postponed-undisplay-list / mm-destroy-postponed-undisplay-list.
2767 (defun gnus-article-browse-delete-temp-files (&optional how)
2768 "Delete temp-files created by `gnus-article-browse-html-parts'."
2769 (when (and gnus-article-browse-html-temp-list
2771 (setq how gnus-article-browse-delete-temp)))
2772 (when (and (eq how 'ask)
2774 "Delete all %s temporary HTML file(s)? "
2775 (length gnus-article-browse-html-temp-list)))
2777 (dolist (file gnus-article-browse-html-temp-list)
2778 (when (and (file-exists-p file)
2780 ;; `how' is neither `nil', `ask' nor `t' (i.e. `file'):
2782 (format "Delete temporary HTML file `%s'? " file))))
2783 (delete-file file)))
2784 ;; Also remove file from the list when not deleted or if file doesn't
2786 (setq gnus-article-browse-html-temp-list nil))
2787 gnus-article-browse-html-temp-list)
2789 (defun gnus-article-browse-html-parts (list)
2790 "View all \"text/html\" parts from LIST.
2791 Recurse into multiparts."
2792 ;; Internal function used by `gnus-article-browse-html-article'.
2794 ;; Find and show the html-parts.
2795 (dolist (handle list)
2796 ;; If HTML, show it:
2797 (when (listp handle)
2798 (cond ((and (bufferp (car handle))
2799 (string-match "text/html" (car (mm-handle-type handle))))
2800 (let ((tmp-file (mm-make-temp-file
2801 ;; Do we need to care for 8.3 filenames?
2802 "mm-" nil ".html")))
2803 (mm-save-part-to-file handle tmp-file)
2804 (add-to-list 'gnus-article-browse-html-temp-list tmp-file)
2805 (add-hook 'gnus-summary-prepare-exit-hook
2806 'gnus-article-browse-delete-temp-files)
2807 (add-hook 'gnus-exit-gnus-hook
2809 (gnus-article-browse-delete-temp-files t)))
2810 ;; FIXME: Warn if there's an <img> tag?
2811 (browse-url-of-file tmp-file)
2813 ;; If multipart, recurse
2814 ((and (stringp (car handle))
2815 (string-match "^multipart/" (car handle))
2818 (gnus-article-browse-html-parts handle))))))))
2821 ;; FIXME: Documentation in texi/gnus.texi missing.
2822 (defun gnus-article-browse-html-article ()
2823 "View \"text/html\" parts of the current article with a WWW browser.
2825 Warning: Spammers use links to images in HTML articles to verify
2826 whether you have read the message. As
2827 `gnus-article-browse-html-article' passes the unmodified HTML
2828 content to the browser without eliminating these \"web bugs\" you
2829 should only use it for mails from trusted senders."
2830 ;; Cf. `mm-w3m-safe-url-regexp'
2832 (save-window-excursion
2833 ;; Open raw article and select the buffer
2834 (gnus-summary-show-article t)
2835 (gnus-summary-select-article-buffer)
2836 (let ((parts (mm-dissect-buffer t t)))
2837 ;; If singlepart, enforce a list.
2838 (when (and (bufferp (car parts))
2839 (stringp (car (mm-handle-type parts))))
2840 (setq parts (list parts)))
2842 (unless (gnus-article-browse-html-parts parts)
2843 (gnus-error 3 "Mail doesn't contain a \"text/html\" part!"))
2844 (gnus-summary-show-article))))
2846 (defun article-hide-list-identifiers ()
2847 "Remove list identifies from the Subject header.
2848 The `gnus-list-identifiers' variable specifies what to do."
2850 (let ((inhibit-point-motion-hooks t)
2851 (regexp (if (consp gnus-list-identifiers)
2852 (mapconcat 'identity gnus-list-identifiers " *\\|")
2853 gnus-list-identifiers))
2854 (inhibit-read-only t))
2858 (article-narrow-to-head)
2859 (goto-char (point-min))
2860 (while (re-search-forward
2861 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2863 (delete-region (match-beginning 2) (match-end 0))
2864 (beginning-of-line))
2865 (when (re-search-forward
2866 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2867 (delete-region (match-beginning 1) (match-end 1))))))))
2869 (defun article-hide-pem (&optional arg)
2870 "Toggle hiding of any PEM headers and signatures in the current article.
2871 If given a negative prefix, always show; if given a positive prefix,
2873 (interactive (gnus-article-hidden-arg))
2874 (unless (gnus-article-check-hidden-text 'pem arg)
2876 (let ((inhibit-read-only t) end)
2877 (goto-char (point-min))
2878 ;; Hide the horrendously ugly "header".
2879 (when (and (search-forward
2880 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2882 (setq end (1+ (match-beginning 0))))
2883 (gnus-add-wash-type 'pem)
2884 (gnus-article-hide-text-type
2886 (if (search-forward "\n\n" nil t)
2890 ;; Hide the trailer as well
2891 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2893 (gnus-article-hide-text-type
2894 (match-beginning 0) (match-end 0) 'pem)))))))
2896 (defun article-strip-banner ()
2897 "Strip the banners specified by the `banner' group parameter and by
2898 `gnus-article-address-banner-alist'."
2902 (let ((inhibit-point-motion-hooks t))
2903 (when (gnus-parameter-banner gnus-newsgroup-name)
2904 (article-really-strip-banner
2905 (gnus-parameter-banner gnus-newsgroup-name)))
2906 (when gnus-article-address-banner-alist
2907 ;; Note that the From header is decoded here, so it is
2908 ;; required that the *-extract-address-components function
2909 ;; supports non-ASCII text.
2910 (let ((from (save-restriction
2912 (article-narrow-to-head)
2913 (mail-fetch-field "from"))))
2916 (cadr (funcall gnus-extract-address-components
2919 (dolist (pair gnus-article-address-banner-alist)
2920 (when (string-match (car pair) from)
2922 (article-really-strip-banner (cdr pair)))))))))))))
2924 (defun article-really-strip-banner (banner)
2925 "Strip the banner specified by the argument."
2928 (let ((inhibit-point-motion-hooks t)
2929 (gnus-signature-limit nil)
2930 (inhibit-read-only t))
2933 ((eq banner 'signature)
2934 (when (gnus-article-narrow-to-signature)
2937 (delete-region (point) (point-max))))
2939 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2940 (while (re-search-forward banner nil t)
2941 (delete-region (match-beginning 0) (match-end 0)))))
2943 (while (re-search-forward banner nil t)
2944 (delete-region (match-beginning 0) (match-end 0)))))))))
2946 (defun article-babel ()
2947 "Translate article using an online translation service."
2950 (gnus-with-article-buffer
2951 (when (article-goto-body)
2952 (let* ((start (point))
2954 (orig (buffer-substring start end))
2955 (trans (babel-as-string orig)))
2957 (narrow-to-region start end)
2958 (delete-region start end)
2961 (defun article-hide-signature (&optional arg)
2962 "Hide the signature in the current article.
2963 If given a negative prefix, always show; if given a positive prefix,
2965 (interactive (gnus-article-hidden-arg))
2966 (unless (gnus-article-check-hidden-text 'signature arg)
2969 (let ((inhibit-read-only t))
2970 (when (gnus-article-narrow-to-signature)
2971 (gnus-article-hide-text-type
2972 (point-min) (point-max) 'signature))))))
2973 (gnus-set-mode-line 'article))
2975 (defun article-strip-headers-in-body ()
2976 "Strip offensive headers from bodies."
2980 (let ((case-fold-search t))
2981 (when (looking-at "x-no-archive:")
2982 (gnus-delete-line)))))
2984 (defun article-strip-leading-blank-lines ()
2985 "Remove all blank lines from the beginning of the article."
2988 (let ((inhibit-point-motion-hooks t)
2989 (inhibit-read-only t))
2990 (when (article-goto-body)
2991 (while (and (not (eobp))
2992 (looking-at "[ \t]*$"))
2993 (gnus-delete-line))))))
2995 (defun article-narrow-to-head ()
2996 "Narrow the buffer to the head of the message.
2997 Point is left at the beginning of the narrowed-to region."
2999 (goto-char (point-min))
3000 (if (search-forward "\n\n" nil 1)
3003 (goto-char (point-min)))
3005 (defun article-goto-body ()
3006 "Place point at the start of the body."
3007 (goto-char (point-min))
3009 ;; This variable is only bound when dealing with separate
3011 (article-goto-body-goes-to-point-min-p
3013 ((search-forward "\n\n" nil t)
3016 (goto-char (point-max))
3019 (defun article-strip-multiple-blank-lines ()
3020 "Replace consecutive blank lines with one empty line."
3023 (let ((inhibit-point-motion-hooks t)
3024 (inhibit-read-only t))
3025 ;; First make all blank lines empty.
3027 (while (re-search-forward "^[ \t]+$" nil t)
3028 (unless (gnus-annotation-in-region-p
3029 (match-beginning 0) (match-end 0))
3030 (replace-match "" nil t)))
3031 ;; Then replace multiple empty lines with a single empty line.
3033 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
3034 (unless (gnus-annotation-in-region-p
3035 (match-beginning 0) (match-end 0))
3036 (delete-region (match-beginning 1) (match-end 1)))))))
3038 (defun article-strip-leading-space ()
3039 "Remove all white space from the beginning of the lines in the article."
3042 (let ((inhibit-point-motion-hooks t)
3043 (inhibit-read-only t))
3045 (while (re-search-forward "^[ \t]+" nil t)
3046 (replace-match "" t t)))))
3048 (defun article-strip-trailing-space ()
3049 "Remove all white space from the end of the lines in the article."
3052 (let ((inhibit-point-motion-hooks t)
3053 (inhibit-read-only t))
3055 (while (re-search-forward "[ \t]+$" nil t)
3056 (replace-match "" t t)))))
3058 (defun article-strip-blank-lines ()
3059 "Strip leading, trailing and multiple blank lines."
3061 (article-strip-leading-blank-lines)
3062 (article-remove-trailing-blank-lines)
3063 (article-strip-multiple-blank-lines))
3065 (defun article-strip-all-blank-lines ()
3066 "Strip all blank lines."
3069 (let ((inhibit-point-motion-hooks t)
3070 (inhibit-read-only t))
3072 (while (re-search-forward "^[ \t]*\n" nil t)
3073 (replace-match "" t t)))))
3075 (defun gnus-article-narrow-to-signature ()
3076 "Narrow to the signature; return t if a signature is found, else nil."
3077 (let ((inhibit-point-motion-hooks t))
3078 (when (gnus-article-search-signature)
3080 ;; Check whether we have some limits to what we consider
3081 ;; to be a signature.
3082 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
3083 (list gnus-signature-limit)))
3085 (while (setq limit (pop limits))
3086 (if (or (and (integerp limit)
3087 (< (- (point-max) (point)) limit))
3089 (< (count-lines (point) (point-max)) limit))
3090 (and (functionp limit)
3092 (and (stringp limit)
3093 (not (re-search-forward limit nil t))))
3094 () ; This limit did not succeed.
3098 (narrow-to-region (point) (point-max))
3101 (defun gnus-article-search-signature ()
3102 "Search the current buffer for the signature separator.
3103 Put point at the beginning of the signature separator."
3104 (let ((cur (point)))
3105 (goto-char (point-max))
3106 (if (if (stringp gnus-signature-separator)
3107 (re-search-backward gnus-signature-separator nil t)
3108 (let ((seps gnus-signature-separator))
3110 (not (re-search-backward (car seps) nil t)))
3117 (defun gnus-article-hidden-arg ()
3118 "Return the current prefix arg as a number, or 0 if no prefix."
3119 (list (if current-prefix-arg
3120 (prefix-numeric-value current-prefix-arg)
3123 (defun gnus-article-check-hidden-text (type arg)
3124 "Return nil if hiding is necessary.
3125 Arg can be nil or a number. nil and positive means hide, negative
3126 means show, 0 means toggle."
3129 (let ((hide (gnus-article-hidden-text-p type)))
3135 (gnus-article-show-hidden-text type)
3138 (if (eq hide 'hidden)
3140 (gnus-article-show-hidden-text type)
3144 (defun gnus-article-hidden-text-p (type)
3145 "Say whether the current buffer contains hidden text of type TYPE."
3146 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
3148 (not (get-text-property pos 'invisible))
3149 (not (get-text-property pos 'dummy-invisible)))
3151 (text-property-any (1+ pos) (point-max) 'article-type type)))
3156 (defun gnus-article-show-hidden-text (type &optional dummy)
3157 "Show all hidden text of type TYPE.
3158 Originally it is hide instead of DUMMY."
3159 (let ((inhibit-read-only t)
3160 (inhibit-point-motion-hooks t))
3161 (gnus-remove-text-properties-when
3163 (point-min) (point-max)
3164 (cons 'article-type (cons type
3165 gnus-hidden-properties)))
3166 (gnus-delete-wash-type type)))
3168 (defconst article-time-units
3169 `((year . ,(* 365.25 24 60 60))
3170 (week . ,(* 7 24 60 60))
3171 (day . ,(* 24 60 60))
3175 "Mapping from time units to seconds.")
3177 (defun gnus-article-forward-header ()
3178 "Move point to the start of the next header.
3179 If the current header is a continuation header, this can be several
3184 (if (looking-at "[ \t]+[^ \t]")
3188 (defun article-date-ut (&optional type highlight)
3189 "Convert DATE date to universal time in the current article.
3190 If TYPE is `local', convert to local time; if it is `lapsed', output
3191 how much time has lapsed since DATE. For `lapsed', the value of
3192 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
3193 should replace the \"Date:\" one, or should be added below it."
3194 (interactive (list 'ut t))
3195 (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
3196 (date-regexp (cond ((not gnus-article-date-lapsed-new-header)
3200 (article-lapsed-timer
3204 (case-fold-search t)
3205 (inhibit-read-only t)
3206 (inhibit-point-motion-hooks t)
3207 pos date bface eface)
3211 (goto-char (point-min))
3212 (while (or (setq date (get-text-property (setq pos (point))
3214 (when (setq pos (next-single-property-change
3215 (point) 'original-date))
3216 (setq date (get-text-property pos 'original-date))
3218 (narrow-to-region pos (or (text-property-any pos (point-max)
3221 (goto-char (point-min))
3222 (when (re-search-forward tdate-regexp nil t)
3223 (setq bface (get-text-property (point-at-bol) 'face)
3224 eface (get-text-property (1- (point-at-eol)) 'face)))
3225 (goto-char (point-min))
3227 ;; Delete any old Date headers.
3228 (while (re-search-forward date-regexp nil t)
3230 (delete-region (point-at-bol) (progn
3231 (gnus-article-forward-header)
3233 (delete-region (point-at-bol) (progn
3234 (gnus-article-forward-header)
3237 (setq pos (point))))
3238 (when (and (not pos)
3239 (re-search-forward tdate-regexp nil t))
3241 (gnus-goto-char pos)
3242 (insert (article-make-date-line date (or type 'ut)))
3248 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
3249 (put-text-property (match-beginning 1) (1+ (match-end 1))
3251 (put-text-property (match-beginning 2) (match-end 2)
3253 (put-text-property (point-min) (1- (point-max)) 'original-date date)
3254 (goto-char (point-max))
3257 (defun article-make-date-line (date type)
3258 "Return a DATE line of TYPE."
3259 (unless (memq type '(local ut original user iso8601 lapsed english))
3260 (error "Unknown conversion type: %s" type))
3262 (let ((time (date-to-time date)))
3264 ;; Convert to the local timezone.
3266 (concat "Date: " (message-make-date time)))
3267 ;; Convert to Universal Time.
3272 (let* ((e (parse-time-string date))
3273 (tm (apply 'encode-time e))
3275 (ls (- (cadr tm) (car (current-time-zone time)))))
3276 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
3277 ((> ls 65535) (list (1+ ms) (- ls 65536)))
3281 ;; Get the original date from the article.
3282 ((eq type 'original)
3283 (concat "Date: " (if (string-match "\n+$" date)
3284 (substring date 0 (match-beginning 0))
3286 ;; Let the user define the format.
3288 (let ((format (or (condition-case nil
3289 (with-current-buffer gnus-summary-buffer
3290 gnus-article-time-format)
3292 gnus-article-time-format)))
3293 (if (functionp format)
3294 (funcall format time)
3295 (concat "Date: " (format-time-string format time)))))
3298 (let ((tz (car (current-time-zone time))))
3301 (format-time-string "%Y%m%dT%H%M%S" time)
3302 (format "%s%02d%02d"
3303 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3304 (/ (% (abs tz) 3600) 60)))))
3305 ;; Do an X-Sent lapsed format.
3307 ;; If the date is seriously mangled, the timezone functions are
3308 ;; liable to bug out, so we ignore all errors.
3309 (let* ((now (current-time))
3310 (real-time (subtract-time now time))
3311 (real-sec (and real-time
3312 (+ (* (float (car real-time)) 65536)
3314 (sec (and real-time (abs real-sec)))
3324 ;; This is a bit convoluted, but basically we go
3325 ;; through the time units for years, weeks, etc,
3326 ;; and divide things to see whether that results
3327 ;; in positive answers.
3330 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3331 ;; The (remaining) seconds are too few to
3332 ;; be divided into this time unit.
3334 ;; It's big enough, so we output it.
3335 (setq sec (- sec (* num (cdr unit))))
3337 (concat (if prev ", " "") (int-to-string
3339 " " (symbol-name (car unit))
3340 (if (> num 1) "s" ""))
3342 article-time-units "")
3343 ;; If dates are odd, then it might appear like the
3344 ;; article was sent in the future.
3347 " in the future"))))))
3348 ;; Display the date in proper English
3350 (let ((dtime (decode-time time)))
3353 (number-to-string (nth 3 dtime))
3354 (let ((digit (% (nth 3 dtime) 10)))
3356 ((memq (nth 3 dtime) '(11 12 13)) "th")
3362 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3364 (number-to-string (nth 5 dtime))
3366 (format "%02d" (nth 2 dtime))
3368 (format "%02d" (nth 1 dtime)))))))
3370 (format "Date: %s (from Gnus)" date))))
3372 (defun article-date-local (&optional highlight)
3373 "Convert the current article date to the local timezone."
3374 (interactive (list t))
3375 (article-date-ut 'local highlight))
3377 (defun article-date-english (&optional highlight)
3378 "Convert the current article date to something that is proper English."
3379 (interactive (list t))
3380 (article-date-ut 'english highlight))
3382 (defun article-date-original (&optional highlight)
3383 "Convert the current article date to what it was originally.
3384 This is only useful if you have used some other date conversion
3385 function and want to see what the date was before converting."
3386 (interactive (list t))
3387 (article-date-ut 'original highlight))
3389 (defun article-date-lapsed (&optional highlight)
3390 "Convert the current article date to time lapsed since it was sent."
3391 (interactive (list t))
3392 (article-date-ut 'lapsed highlight))
3394 (defun article-update-date-lapsed ()
3395 "Function to be run from a timer to update the lapsed time line."
3397 (let (deactivate-mark)
3402 (set-buffer (window-buffer w))
3403 (when (eq major-mode 'gnus-article-mode)
3404 (let ((mark (point-marker)))
3405 (goto-char (point-min))
3406 (when (re-search-forward "^X-Sent:" nil t)
3407 (article-date-lapsed t))
3408 (goto-char (marker-position mark))
3409 (move-marker mark nil))))
3412 (defun gnus-start-date-timer (&optional n)
3413 "Start a timer to update the X-Sent header in the article buffers.
3414 The numerical prefix says how frequently (in seconds) the function
3419 (gnus-stop-date-timer)
3420 (setq article-lapsed-timer
3421 (run-at-time 1 n 'article-update-date-lapsed)))
3423 (defun gnus-stop-date-timer ()
3424 "Stop the X-Sent timer."
3426 (when article-lapsed-timer
3427 (nnheader-cancel-timer article-lapsed-timer)
3428 (setq article-lapsed-timer nil)))
3430 (defun article-date-user (&optional highlight)
3431 "Convert the current article date to the user-defined format.
3432 This format is defined by the `gnus-article-time-format' variable."
3433 (interactive (list t))
3434 (article-date-ut 'user highlight))
3436 (defun article-date-iso8601 (&optional highlight)
3437 "Convert the current article date to ISO8601."
3438 (interactive (list t))
3439 (article-date-ut 'iso8601 highlight))
3441 (defmacro gnus-article-save-original-date (&rest forms)
3442 "Save the original date as a text property and evaluate FORMS."
3443 `(let* ((case-fold-search t)
3445 (goto-char (point-min))
3446 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3449 (date (when (and start
3450 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3452 (buffer-substring-no-properties start
3453 (match-beginning 0)))))
3454 (goto-char (point-max))
3455 (skip-chars-backward "\n")
3456 (put-text-property (point-min) (point) 'original-date date)
3458 (goto-char (point-max))
3459 (skip-chars-backward "\n")
3460 (put-text-property (point-min) (point) 'original-date date)))
3462 ;; (defun article-show-all ()
3463 ;; "Show all hidden text in the article buffer."
3466 ;; (let ((inhibit-read-only t))
3467 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3469 (defun article-remove-leading-whitespace ()
3470 "Remove excessive whitespace from all headers."
3474 (let ((inhibit-read-only t))
3475 (article-narrow-to-head)
3476 (goto-char (point-min))
3477 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3478 (delete-region (match-beginning 1) (match-end 1)))))))
3480 (defun article-emphasize (&optional arg)
3481 "Emphasize text according to `gnus-emphasis-alist'."
3482 (interactive (gnus-article-hidden-arg))
3483 (unless (gnus-article-check-hidden-text 'emphasis arg)
3487 (with-current-buffer gnus-summary-buffer
3488 gnus-article-emphasis-alist)
3490 gnus-emphasis-alist))
3491 (inhibit-read-only t)
3492 (props (append '(article-type emphasis)
3493 gnus-hidden-properties))
3494 regexp elem beg invisible visible face)
3497 (while (setq elem (pop alist))
3499 (setq regexp (car elem)
3500 invisible (nth 1 elem)
3501 visible (nth 2 elem)
3503 (while (re-search-forward regexp nil t)
3504 (when (and (match-beginning visible) (match-beginning invisible))
3505 (gnus-article-hide-text
3506 (match-beginning invisible) (match-end invisible) props)
3507 (gnus-article-unhide-text-type
3508 (match-beginning visible) (match-end visible) 'emphasis)
3509 (gnus-put-overlay-excluding-newlines
3510 (match-beginning visible) (match-end visible) 'face face)
3511 (gnus-add-wash-type 'emphasis)
3512 (goto-char (match-end invisible)))))))))
3514 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3515 "Setup newsgroup emphasis alist."
3516 (unless gnus-article-emphasis-alist
3517 (let ((name (and gnus-newsgroup-name
3518 (gnus-group-real-name gnus-newsgroup-name))))
3519 (make-local-variable 'gnus-article-emphasis-alist)
3520 (setq gnus-article-emphasis-alist
3522 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3523 (while (setq elem (pop alist))
3524 (when (and name (string-match (car elem) name))
3526 highlight (copy-sequence (cdr elem)))))
3528 (copy-sequence highlight-words)
3529 (if gnus-newsgroup-name
3530 (copy-sequence (gnus-group-find-parameter
3531 gnus-newsgroup-name 'highlight-words t)))
3532 gnus-emphasis-alist)))))
3535 (defvar gnus-summary-article-menu)
3536 (defvar gnus-summary-post-menu))
3538 ;;; Saving functions.
3540 (defun gnus-article-save (save-buffer file &optional num)
3541 "Save the currently selected article."
3542 (when (or (get gnus-default-article-saver :headers)
3543 (not gnus-save-all-headers))
3544 ;; Remove headers according to `gnus-saved-headers' or the value
3545 ;; of the `:headers' property that the saver function might have.
3546 (let ((gnus-visible-headers
3547 (or (symbol-value (get gnus-default-article-saver :headers))
3548 gnus-saved-headers gnus-visible-headers))
3549 (gnus-article-buffer save-buffer))
3551 (set-buffer save-buffer)
3552 (article-hide-headers 1 t))))
3553 (save-window-excursion
3554 (if (not gnus-default-article-saver)
3555 (error "No default saver is defined")
3556 ;; !!! Magic! The saving functions all save
3557 ;; `gnus-save-article-buffer' (or so they think), but we
3558 ;; bind that variable to our save-buffer.
3559 (set-buffer gnus-article-buffer)
3560 (let* ((gnus-save-article-buffer save-buffer)
3563 ((not gnus-prompt-before-saving) 'default)
3564 ((eq gnus-prompt-before-saving 'always) nil)
3566 (gnus-number-of-articles-to-be-saved
3567 (when (eq gnus-prompt-before-saving t)
3569 (set-buffer gnus-article-current-summary)
3570 (funcall gnus-default-article-saver filename)))))
3572 (defun gnus-read-save-file-name (prompt &optional filename
3573 function group headers variable
3576 (funcall function group headers (symbol-value variable)))
3581 ((eq filename 'default)
3587 (when (symbol-value dir-var)
3588 (setq default-name (expand-file-name
3589 (file-name-nondirectory default-name)
3590 (symbol-value dir-var))))
3591 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3594 (if (and gnus-number-of-articles-to-be-saved
3595 (> gnus-number-of-articles-to-be-saved 1))
3596 (format "these %d articles"
3597 gnus-number-of-articles-to-be-saved)
3600 ;; Let the split methods have their say.
3602 ;; No split name was found.
3605 (concat prompt " (default "
3606 (file-name-nondirectory default-name) "): ")
3607 (file-name-directory default-name)
3609 ;; A single group name is returned.
3610 ((stringp split-name)
3612 (funcall function split-name headers
3613 (symbol-value variable)))
3615 (concat prompt " (default "
3616 (file-name-nondirectory default-name) "): ")
3617 (file-name-directory default-name)
3619 ;; A single split name was found
3620 ((= 1 (length split-name))
3621 (let* ((name (expand-file-name
3623 gnus-article-save-directory))
3624 (dir (cond ((file-directory-p name)
3625 (file-name-as-directory name))
3626 ((file-exists-p name) name)
3627 (t gnus-article-save-directory))))
3629 (concat prompt " (default " name "): ")
3631 ;; A list of splits was found.
3633 (setq split-name (nreverse split-name))
3635 (let ((file-name-history
3636 (nconc split-name file-name-history)))
3640 (concat prompt " (`M-p' for defaults): ")
3641 gnus-article-save-directory
3643 gnus-article-save-directory)))
3644 (car (push result file-name-history)))))))
3645 ;; Create the directory.
3646 (gnus-make-directory (file-name-directory file))
3647 ;; If we have read a directory, we append the default file name.
3648 (when (file-directory-p file)
3649 (setq file (expand-file-name (file-name-nondirectory
3651 (file-name-as-directory file))))
3652 ;; Possibly translate some characters.
3653 (nnheader-translate-file-chars file))))))
3654 (gnus-make-directory (file-name-directory result))
3656 (set variable result))
3658 (set dir-var (file-name-directory result)))
3661 (defun gnus-article-archive-name (group)
3662 "Return the first instance of an \"Archive-name\" in the current buffer."
3663 (let ((case-fold-search t))
3664 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3665 (nnheader-concat gnus-article-save-directory
3666 (match-string 1)))))
3668 (defun gnus-article-nndoc-name (group)
3669 "If GROUP is an nndoc group, return the name of the parent group."
3670 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3671 (gnus-group-get-parameter group 'save-article-group)))
3673 (defun gnus-summary-save-in-rmail (&optional filename)
3674 "Append this article to Rmail file.
3675 Optional argument FILENAME specifies file name.
3676 Directory to save to is default to `gnus-article-save-directory'."
3677 (setq filename (gnus-read-save-file-name
3678 "Save %s in rmail file" filename
3679 gnus-rmail-save-name gnus-newsgroup-name
3680 gnus-current-headers 'gnus-newsgroup-last-rmail))
3681 (gnus-eval-in-buffer-window gnus-save-article-buffer
3685 (gnus-output-to-rmail filename))))
3688 (defun gnus-summary-save-in-mail (&optional filename)
3689 "Append this article to Unix mail file.
3690 Optional argument FILENAME specifies file name.
3691 Directory to save to is default to `gnus-article-save-directory'."
3692 (setq filename (gnus-read-save-file-name
3693 "Save %s in Unix mail file" filename
3694 gnus-mail-save-name gnus-newsgroup-name
3695 gnus-current-headers 'gnus-newsgroup-last-mail))
3696 (gnus-eval-in-buffer-window gnus-save-article-buffer
3700 (if (and (file-readable-p filename)
3701 (file-regular-p filename)
3702 (mail-file-babyl-p filename))
3703 (rmail-output-to-rmail-file filename t)
3704 (gnus-output-to-mail filename)))))
3707 (put 'gnus-summary-save-in-file :decode t)
3708 (put 'gnus-summary-save-in-file :headers 'gnus-saved-headers)
3709 (defun gnus-summary-save-in-file (&optional filename overwrite)
3710 "Append this article to file.
3711 Optional argument FILENAME specifies file name.
3712 Directory to save to is default to `gnus-article-save-directory'."
3713 (setq filename (gnus-read-save-file-name
3714 "Save %s in file" filename
3715 gnus-file-save-name gnus-newsgroup-name
3716 gnus-current-headers 'gnus-newsgroup-last-file))
3717 (gnus-eval-in-buffer-window gnus-save-article-buffer
3721 (when (and overwrite
3722 (file-exists-p filename))
3723 (delete-file filename))
3724 (gnus-output-to-file filename))))
3727 (put 'gnus-summary-write-to-file :decode t)
3728 (put 'gnus-summary-write-to-file :function 'gnus-summary-save-in-file)
3729 (put 'gnus-summary-write-to-file :headers 'gnus-saved-headers)
3730 (defun gnus-summary-write-to-file (&optional filename)
3731 "Write this article to a file, overwriting it if the file exists.
3732 Optional argument FILENAME specifies file name.
3733 The directory to save in defaults to `gnus-article-save-directory'."
3734 (setq filename (gnus-read-save-file-name
3735 "Save %s in file" filename
3736 gnus-file-save-name gnus-newsgroup-name
3737 gnus-current-headers nil 'gnus-newsgroup-last-directory))
3738 (gnus-summary-save-in-file filename t))
3740 (put 'gnus-summary-save-body-in-file :decode t)
3741 (defun gnus-summary-save-body-in-file (&optional filename overwrite)
3742 "Append this article body to a file.
3743 Optional argument FILENAME specifies file name.
3744 The directory to save in defaults to `gnus-article-save-directory'."
3745 (setq filename (gnus-read-save-file-name
3746 "Save %s body in file" filename
3747 gnus-file-save-name gnus-newsgroup-name
3748 gnus-current-headers 'gnus-newsgroup-last-file))
3749 (gnus-eval-in-buffer-window gnus-save-article-buffer
3753 (when (article-goto-body)
3754 (narrow-to-region (point) (point-max)))
3755 (when (and overwrite
3756 (file-exists-p filename))
3757 (delete-file filename))
3758 (gnus-output-to-file filename))))
3761 (put 'gnus-summary-write-body-to-file :decode t)
3762 (put 'gnus-summary-write-body-to-file
3763 :function 'gnus-summary-save-body-in-file)
3764 (defun gnus-summary-write-body-to-file (&optional filename)
3765 "Write this article body to a file, overwriting it if the file exists.
3766 Optional argument FILENAME specifies file name.
3767 The directory to save in defaults to `gnus-article-save-directory'."
3768 (setq filename (gnus-read-save-file-name
3769 "Save %s body in file" filename
3770 gnus-file-save-name gnus-newsgroup-name
3771 gnus-current-headers nil 'gnus-newsgroup-last-directory))
3772 (gnus-summary-save-body-in-file filename t))
3774 (defun gnus-summary-save-in-pipe (&optional command)
3775 "Pipe this article to subprocess."
3777 (cond ((and (eq command 'default)
3778 gnus-last-shell-command)
3779 gnus-last-shell-command)
3784 "Shell command on %s: "
3785 (if (and gnus-number-of-articles-to-be-saved
3786 (> gnus-number-of-articles-to-be-saved 1))
3787 (format "these %d articles"
3788 gnus-number-of-articles-to-be-saved)
3790 gnus-last-shell-command))))
3791 (when (string-equal command "")
3792 (if gnus-last-shell-command
3793 (setq command gnus-last-shell-command)
3794 (error "A command is required")))
3795 (gnus-eval-in-buffer-window gnus-article-buffer
3798 (shell-command-on-region (point-min) (point-max) command nil)))
3799 (setq gnus-last-shell-command command))
3801 (defun gnus-summary-pipe-to-muttprint (&optional command)
3802 "Pipe this article to muttprint."
3803 (setq command (read-string
3804 "Print using command: " gnus-summary-muttprint-program
3805 nil gnus-summary-muttprint-program))
3806 (gnus-summary-save-in-pipe command))
3808 ;;; Article file names when saving.
3810 (defun gnus-capitalize-newsgroup (newsgroup)
3811 "Capitalize NEWSGROUP name."
3812 (when (not (zerop (length newsgroup)))
3813 (concat (char-to-string (upcase (aref newsgroup 0)))
3814 (substring newsgroup 1))))
3816 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3817 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3818 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3819 Otherwise, it is like ~/News/news/group/num."
3822 (concat (if (gnus-use-long-file-name 'not-save)
3823 (gnus-capitalize-newsgroup newsgroup)
3824 (gnus-newsgroup-directory-form newsgroup))
3825 "/" (int-to-string (mail-header-number headers)))
3826 gnus-article-save-directory)))
3828 (string-equal (file-name-directory default)
3829 (file-name-directory last-file))
3830 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3832 (or last-file default))))
3834 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3835 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3836 If variable `gnus-use-long-file-name' is non-nil, it is
3837 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3840 (concat (if (gnus-use-long-file-name 'not-save)
3842 (gnus-newsgroup-directory-form newsgroup))
3843 "/" (int-to-string (mail-header-number headers)))
3844 gnus-article-save-directory)))
3846 (string-equal (file-name-directory default)
3847 (file-name-directory last-file))
3848 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3850 (or last-file default))))
3852 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3853 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3854 If variable `gnus-use-long-file-name' is non-nil, it is
3855 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3858 (if (gnus-use-long-file-name 'not-save)
3861 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3863 gnus-article-save-directory)))
3865 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3866 "Generate file name from sender."
3867 (let ((from (mail-header-from headers)))
3869 (if (and from (string-match "\\([^ <]+\\)@" from))
3870 (match-string 1 from)
3872 gnus-article-save-directory)))
3874 (defun article-verify-x-pgp-sig ()
3877 (if (gnus-buffer-live-p gnus-original-article-buffer)
3878 (let ((sig (with-current-buffer gnus-original-article-buffer
3879 (gnus-fetch-field "X-PGP-Sig")))
3883 (mml2015-clear-verify-function))
3885 (insert-buffer-substring gnus-original-article-buffer)
3886 (setq items (split-string sig))
3887 (message-narrow-to-head)
3888 (let ((inhibit-point-motion-hooks t)
3889 (case-fold-search t))
3890 ;; Don't verify multiple headers.
3891 (setq headers (mapconcat (lambda (header)
3893 (mail-fetch-field header)
3895 (split-string (nth 1 items) ",") "")))
3896 (delete-region (point-min) (point-max))
3897 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3898 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3903 (if (looking-at "^-")
3906 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3907 (insert "Version: " (car items) "\n\n")
3908 (insert (mapconcat 'identity (cddr items) "\n"))
3909 (insert "\n-----END PGP SIGNATURE-----\n")
3910 (let ((mm-security-handle (list (format "multipart/signed"))))
3911 (mml2015-clean-buffer)
3912 (let ((coding-system-for-write (or gnus-newsgroup-charset
3914 (funcall (mml2015-clear-verify-function)))
3916 (or (mm-handle-multipart-ctl-parameter
3917 mm-security-handle 'gnus-details)
3918 (mm-handle-multipart-ctl-parameter
3919 mm-security-handle 'gnus-info)))))
3921 (let ((inhibit-read-only t) bface eface)
3923 (message-narrow-to-head)
3924 (goto-char (point-max))
3926 (setq bface (get-text-property (point-at-bol) 'face)
3927 eface (get-text-property (1- (point-at-eol)) 'face))
3928 (message-remove-header "X-Gnus-PGP-Verify")
3929 (if (re-search-forward "^X-PGP-Sig:" nil t)
3931 (goto-char (point-max)))
3932 (narrow-to-region (point) (point))
3933 (insert "X-Gnus-PGP-Verify: " info "\n")
3934 (goto-char (point-min))
3937 (if (not (looking-at "^[ \t]"))
3941 (goto-char (point-min))
3942 (when (looking-at "\\([^:]+\\): *")
3943 (put-text-property (match-beginning 1) (1+ (match-end 1))
3945 (put-text-property (match-end 0) (point-max)
3946 'face eface)))))))))
3948 (defun article-verify-cancel-lock ()
3949 "Verify Cancel-Lock header."
3951 (if (gnus-buffer-live-p gnus-original-article-buffer)
3952 (canlock-verify gnus-original-article-buffer)))
3959 (setq afunc (car func)
3962 gfunc (intern (format "gnus-%s" func))))
3964 (when (fboundp afunc)
3965 `(lambda (&optional interactive &rest args)
3966 ,(documentation afunc t)
3967 (interactive (list t))
3969 (set-buffer gnus-article-buffer)
3971 (call-interactively ',afunc)
3972 (apply ',afunc args))))))))
3973 '(article-hide-headers
3974 article-verify-x-pgp-sig
3975 article-verify-cancel-lock
3976 article-hide-boring-headers
3977 article-treat-overstrike
3978 article-treat-ansi-sequences
3979 article-fill-long-lines
3980 article-capitalize-sentences
3982 article-remove-leading-whitespace
3983 article-display-x-face
3984 article-display-face
3985 article-de-quoted-unreadable
3986 article-de-base64-unreadable
3989 article-unsplit-urls
3990 article-hide-list-identifiers
3991 article-strip-banner
3994 article-hide-signature
3995 article-strip-headers-in-body
3996 article-remove-trailing-blank-lines
3997 article-strip-leading-blank-lines
3998 article-strip-multiple-blank-lines
3999 article-strip-leading-space
4000 article-strip-trailing-space
4001 article-strip-blank-lines
4002 article-strip-all-blank-lines
4004 article-date-english
4005 article-date-iso8601
4006 article-date-original
4008 article-decode-mime-words
4009 article-decode-charset
4010 article-decode-encoded-words
4014 article-treat-dumbquotes
4015 article-normalize-headers
4016 ;; (article-show-all . gnus-article-show-all-headers)
4020 ;;; Gnus article mode
4023 (put 'gnus-article-mode 'mode-class 'special)
4025 (set-keymap-parent gnus-article-mode-map widget-keymap)
4027 (gnus-define-keys gnus-article-mode-map
4028 " " gnus-article-goto-next-page
4029 "\177" gnus-article-goto-prev-page
4030 [delete] gnus-article-goto-prev-page
4031 [backspace] gnus-article-goto-prev-page
4032 "\C-c^" gnus-article-refer-article
4033 "h" gnus-article-show-summary
4034 "s" gnus-article-show-summary
4035 "\C-c\C-m" gnus-article-mail
4036 "?" gnus-article-describe-briefly
4037 "e" gnus-summary-edit-article
4038 "<" beginning-of-buffer
4040 "\C-c\C-i" gnus-info-find-node
4042 "R" gnus-article-reply-with-original
4043 "F" gnus-article-followup-with-original
4044 "\C-hk" gnus-article-describe-key
4045 "\C-hc" gnus-article-describe-key-briefly
4047 "\C-d" gnus-article-read-summary-keys
4048 "\M-*" gnus-article-read-summary-keys
4049 "\M-#" gnus-article-read-summary-keys
4050 "\M-^" gnus-article-read-summary-keys
4051 "\M-g" gnus-article-read-summary-keys)
4053 (substitute-key-definition
4054 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
4056 (defun gnus-article-make-menu-bar ()
4057 (unless (boundp 'gnus-article-commands-menu)
4058 (gnus-summary-make-menu-bar))
4059 (gnus-turn-off-edit-menu 'article)
4060 (unless (boundp 'gnus-article-article-menu)
4062 gnus-article-article-menu gnus-article-mode-map ""
4064 ["Scroll forwards" gnus-article-goto-next-page t]
4065 ["Scroll backwards" gnus-article-goto-prev-page t]
4066 ["Show summary" gnus-article-show-summary t]
4067 ["Fetch Message-ID at point" gnus-article-refer-article t]
4068 ["Mail to address at point" gnus-article-mail t]
4069 ["Send a bug report" gnus-bug t]))
4072 gnus-article-treatment-menu gnus-article-mode-map ""
4073 ;; Fixme: this should use :active (and maybe :visible).
4075 ["Hide headers" gnus-article-hide-headers t]
4076 ["Hide signature" gnus-article-hide-signature t]
4077 ["Hide citation" gnus-article-hide-citation t]
4078 ["Treat overstrike" gnus-article-treat-overstrike t]
4079 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
4080 ["Remove carriage return" gnus-article-remove-cr t]
4081 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
4082 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
4083 ["Remove base64" gnus-article-de-base64-unreadable t]
4084 ["Treat html" gnus-article-wash-html t]
4085 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
4086 ["Decode HZ" gnus-article-decode-HZ t]))
4088 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
4090 ;; Note "Post" menu is defined in gnus-sum.el for consistency
4092 (gnus-run-hooks 'gnus-article-menu-hook)))
4094 (defun gnus-article-mode ()
4095 "Major mode for displaying an article.
4097 All normal editing commands are switched off.
4099 The following commands are available in addition to all summary mode
4101 \\<gnus-article-mode-map>
4102 \\[gnus-article-next-page]\t Scroll the article one page forwards
4103 \\[gnus-article-prev-page]\t Scroll the article one page backwards
4104 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
4105 \\[gnus-article-show-summary]\t Display the summary buffer
4106 \\[gnus-article-mail]\t Send a reply to the address near point
4107 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
4108 \\[gnus-info-find-node]\t Go to the Gnus info node"
4110 (kill-all-local-variables)
4111 (gnus-simplify-mode-line)
4112 (setq mode-name "Article")
4113 (setq major-mode 'gnus-article-mode)
4114 (make-local-variable 'minor-mode-alist)
4115 (use-local-map gnus-article-mode-map)
4116 (when (gnus-visual-p 'article-menu 'menu)
4117 (gnus-article-make-menu-bar)
4118 (when gnus-summary-tool-bar-map
4119 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
4120 (gnus-update-format-specifications nil 'article-mode)
4121 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
4122 (set (make-local-variable 'gnus-page-broken) nil)
4123 (make-local-variable 'gnus-button-marker-list)
4124 (make-local-variable 'gnus-article-current-summary)
4125 (make-local-variable 'gnus-article-mime-handles)
4126 (make-local-variable 'gnus-article-decoded-p)
4127 (make-local-variable 'gnus-article-mime-handle-alist)
4128 (make-local-variable 'gnus-article-wash-types)
4129 (make-local-variable 'gnus-article-image-alist)
4130 (make-local-variable 'gnus-article-charset)
4131 (make-local-variable 'gnus-article-ignored-charsets)
4132 ;; Prevent Emacs 22 from displaying non-break space with `nobreak-space'
4134 (set (make-local-variable 'nobreak-char-display) nil)
4135 (setq cursor-in-non-selected-windows nil)
4136 (setq truncate-lines gnus-article-truncate-lines)
4137 (gnus-set-default-directory)
4138 (buffer-disable-undo)
4139 (setq buffer-read-only t
4140 show-trailing-whitespace nil)
4141 (set-syntax-table gnus-article-mode-syntax-table)
4142 (mm-enable-multibyte)
4143 (gnus-run-mode-hooks 'gnus-article-mode-hook))
4145 (defvar gnus-button-marker-list nil
4146 "Regexp matching any of the regexps from `gnus-button-alist'.
4147 Internal variable.")
4149 (defun gnus-article-setup-buffer ()
4150 "Initialize the article buffer."
4151 (let* ((name (if gnus-single-article-buffer "*Article*"
4152 (concat "*Article " gnus-newsgroup-name "*")))
4154 (progn (string-match "\\*Article" name)
4155 (concat " *Original Article"
4156 (substring name (match-end 0))))))
4157 (setq gnus-article-buffer name)
4158 (setq gnus-original-article-buffer original)
4159 (setq gnus-article-mime-handle-alist nil)
4160 (with-current-buffer gnus-summary-buffer
4161 ;; This might be a variable local to the summary buffer.
4162 (unless gnus-single-article-buffer
4163 (setq gnus-article-buffer name)
4164 (setq gnus-original-article-buffer original)
4165 (gnus-set-global-variables)))
4166 (gnus-article-setup-highlight-words)
4167 ;; Init original article buffer.
4169 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
4170 (mm-enable-multibyte)
4171 (setq major-mode 'gnus-original-article-mode)
4172 (make-local-variable 'gnus-original-article))
4173 (if (and (get-buffer name)
4174 (with-current-buffer name
4175 (if gnus-article-edit-mode
4176 (if (y-or-n-p "Article mode edit in progress; discard? ")
4178 (set-buffer-modified-p nil)
4179 (gnus-kill-buffer name)
4182 (error "Action aborted"))
4186 (set (make-local-variable 'gnus-article-edit-mode) nil)
4187 (when gnus-article-mime-handles
4188 (mm-destroy-parts gnus-article-mime-handles)
4189 (setq gnus-article-mime-handles nil))
4190 ;; Set it to nil in article-buffer!
4191 (setq gnus-article-mime-handle-alist nil)
4192 (buffer-disable-undo)
4193 (setq buffer-read-only t)
4194 ;; This list just keeps growing if we don't reset it.
4195 (setq gnus-button-marker-list nil)
4196 (unless (eq major-mode 'gnus-article-mode)
4197 (gnus-article-mode))
4200 (set-buffer (gnus-get-buffer-create name))
4202 (make-local-variable 'gnus-summary-buffer)
4203 (setq gnus-summary-buffer
4204 (gnus-summary-buffer-name gnus-newsgroup-name))
4205 (gnus-summary-set-local-parameters gnus-newsgroup-name)
4206 (current-buffer)))))
4208 ;; Set article window start at LINE, where LINE is the number of lines
4209 ;; from the head of the article.
4210 (defun gnus-article-set-window-start (&optional line)
4211 (let ((article-window (gnus-get-buffer-window gnus-article-buffer t)))
4212 (when article-window
4216 (set-buffer gnus-article-buffer)
4217 (goto-char (point-min))
4220 (gnus-message 6 "Moved to bookmark")
4221 (search-forward "\n\n" nil t)
4225 (defun gnus-article-prepare (article &optional all-headers header)
4226 "Prepare ARTICLE in article mode buffer.
4227 ARTICLE should either be an article number or a Message-ID.
4228 If ARTICLE is an id, HEADER should be the article headers.
4229 If ALL-HEADERS is non-nil, no headers are hidden."
4231 ;; Make sure we start in a summary buffer.
4232 (unless (eq major-mode 'gnus-summary-mode)
4233 (set-buffer gnus-summary-buffer))
4234 (setq gnus-summary-buffer (current-buffer))
4235 (let* ((gnus-article (if header (mail-header-number header) article))
4236 (summary-buffer (current-buffer))
4237 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4238 (group gnus-newsgroup-name)
4241 (gnus-article-setup-buffer)
4242 (set-buffer gnus-article-buffer)
4243 ;; Deactivate active regions.
4244 (when (and (boundp 'transient-mark-mode)
4245 transient-mark-mode)
4246 (setq mark-active nil))
4247 (if (not (setq result (let ((inhibit-read-only t))
4248 (gnus-request-article-this-buffer
4250 ;; There is no such article.
4252 (when (and (numberp article)
4253 (not (memq article gnus-newsgroup-sparse)))
4254 (setq gnus-article-current
4255 (cons gnus-newsgroup-name article))
4256 (set-buffer gnus-summary-buffer)
4257 (setq gnus-current-article article)
4258 (if (and (memq article gnus-newsgroup-undownloaded)
4259 (not (gnus-online (gnus-find-method-for-group
4260 gnus-newsgroup-name))))
4262 (gnus-summary-set-agent-mark article)
4263 (message "Message marked for downloading"))
4264 (gnus-summary-mark-article article gnus-canceled-mark)
4265 (unless (memq article gnus-newsgroup-sparse)
4266 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4267 (if (or (eq result 'pseudo)
4268 (eq result 'nneething))
4271 (set-buffer summary-buffer)
4272 (push article gnus-newsgroup-history)
4273 (setq gnus-last-article gnus-current-article
4274 gnus-current-article 0
4275 gnus-current-headers nil
4276 gnus-article-current nil)
4277 (if (eq result 'nneething)
4278 (gnus-configure-windows 'summary)
4279 (gnus-configure-windows 'article))
4280 (gnus-set-global-variables))
4281 (let ((gnus-article-mime-handle-alist-1
4282 gnus-article-mime-handle-alist))
4283 (gnus-set-mode-line 'article)))
4284 ;; The result from the `request' was an actual article -
4285 ;; or at least some text that is now displayed in the
4287 (when (and (numberp article)
4288 (not (eq article gnus-current-article)))
4289 ;; Seems like a new article has been selected.
4290 ;; `gnus-current-article' must be an article number.
4292 (set-buffer summary-buffer)
4293 (push article gnus-newsgroup-history)
4294 (setq gnus-last-article gnus-current-article
4295 gnus-current-article article
4296 gnus-current-headers
4297 (gnus-summary-article-header gnus-current-article)
4298 gnus-article-current
4299 (cons gnus-newsgroup-name gnus-current-article))
4300 (unless (vectorp gnus-current-headers)
4301 (setq gnus-current-headers nil))
4302 (gnus-summary-goto-subject gnus-current-article)
4303 (when (gnus-summary-show-thread)
4304 ;; If the summary buffer really was folded, the
4305 ;; previous goto may not actually have gone to
4306 ;; the right article, but the thread root instead.
4308 (gnus-summary-goto-subject gnus-current-article))
4309 (gnus-run-hooks 'gnus-mark-article-hook)
4310 (gnus-set-mode-line 'summary)
4311 (when (gnus-visual-p 'article-highlight 'highlight)
4312 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4313 ;; Set the global newsgroup variables here.
4314 (gnus-set-global-variables)
4315 (setq gnus-have-all-headers
4316 (or all-headers gnus-show-all-headers))))
4318 (gnus-configure-windows 'article))
4319 (when (or (numberp article)
4321 (gnus-article-prepare-display)
4323 (goto-char (point-min))
4324 (when gnus-break-pages
4325 (gnus-narrow-to-page)))
4326 (let ((gnus-article-mime-handle-alist-1
4327 gnus-article-mime-handle-alist))
4328 (gnus-set-mode-line 'article))
4332 (set-window-point (get-buffer-window (current-buffer)) (point))
4333 (gnus-configure-windows 'article)
4337 (defun gnus-article-prepare-display ()
4338 "Make the current buffer look like a nice article."
4339 ;; Hooks for getting information from the article.
4340 ;; This hook must be called before being narrowed.
4341 (let ((gnus-article-buffer (current-buffer))
4343 (inhibit-read-only t))
4344 (unless (eq major-mode 'gnus-article-mode)
4345 (gnus-article-mode))
4346 (setq buffer-read-only nil
4347 gnus-article-wash-types nil
4348 gnus-article-image-alist nil)
4349 (gnus-run-hooks 'gnus-tmp-internal-hook)
4350 (when gnus-display-mime-function
4351 (funcall gnus-display-mime-function))
4352 (gnus-run-hooks 'gnus-article-prepare-hook)))
4355 ;;; Gnus Sticky Article Mode
4358 (define-derived-mode gnus-sticky-article-mode gnus-article-mode "StickyArticle"
4359 "Mode for sticky articles."
4360 ;; Release bindings that won't work.
4361 (substitute-key-definition 'gnus-article-read-summary-keys 'undefined
4362 gnus-sticky-article-mode-map)
4363 (substitute-key-definition 'gnus-article-refer-article 'undefined
4364 gnus-sticky-article-mode-map)
4365 (dolist (k '("e" "h" "s" "F" "R"))
4366 (define-key gnus-sticky-article-mode-map k nil))
4367 (define-key gnus-sticky-article-mode-map "k" 'gnus-kill-sticky-article-buffer)
4368 (define-key gnus-sticky-article-mode-map "q" 'bury-buffer)
4369 (define-key gnus-sticky-article-mode-map "\C-hc" 'describe-key-briefly)
4370 (define-key gnus-sticky-article-mode-map "\C-hk" 'describe-key))
4372 (defun gnus-sticky-article (arg)
4373 "Make the current article sticky.
4374 If a prefix ARG is given, ask for a name for this sticky article buffer."
4376 (gnus-summary-show-thread)
4377 (gnus-summary-select-article nil nil 'pseudo)
4378 (let (new-art-buf-name)
4379 (gnus-eval-in-buffer-window gnus-article-buffer
4380 (setq new-art-buf-name
4384 (read-from-minibuffer "Sticky article buffer name: ")
4385 (gnus-with-article-headers
4386 (gnus-article-goto-header "subject")
4387 (setq new-art-buf-name
4388 (buffer-substring-no-properties
4389 (line-beginning-position) (line-end-position)))
4390 (goto-char (point-min))
4391 (gnus-article-goto-header "from")
4392 (setq new-art-buf-name
4394 new-art-buf-name ", "
4395 (buffer-substring-no-properties
4396 (line-beginning-position) (line-end-position))))
4397 (goto-char (point-min))
4398 (gnus-article-goto-header "date")
4399 (setq new-art-buf-name
4401 new-art-buf-name ", "
4402 (buffer-substring-no-properties
4403 (line-beginning-position) (line-end-position))))))
4405 (if (and (gnus-buffer-live-p new-art-buf-name)
4406 (with-current-buffer new-art-buf-name
4407 (eq major-mode 'gnus-sticky-article-mode)))
4408 (switch-to-buffer new-art-buf-name)
4409 (setq new-art-buf-name (rename-buffer new-art-buf-name t)))
4410 (gnus-sticky-article-mode))
4411 (setq gnus-article-buffer new-art-buf-name))
4412 (gnus-summary-recenter)
4413 (gnus-summary-position-point))
4415 (defun gnus-kill-sticky-article-buffer (&optional buffer)
4416 "Kill the given sticky article BUFFER.
4417 If none is given, assume the current buffer and kill it if it has
4418 `gnus-sticky-article-mode'."
4421 (setq buffer (current-buffer)))
4422 (with-current-buffer buffer
4423 (when (eq major-mode 'gnus-sticky-article-mode)
4424 (gnus-kill-buffer buffer))))
4426 (defun gnus-kill-sticky-article-buffers (arg)
4427 "Kill all sticky article buffers.
4428 If a prefix ARG is given, ask for confirmation."
4430 (dolist (buf (gnus-buffers))
4431 (with-current-buffer buf
4432 (when (eq major-mode 'gnus-sticky-article-mode)
4434 (gnus-kill-buffer buf)
4435 (when (yes-or-no-p (concat "Kill buffer " (buffer-name buf) "? "))
4436 (gnus-kill-buffer buf)))))))
4439 ;;; Gnus MIME viewing functions
4442 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4443 "Format of the MIME buttons.
4445 Valid specifiers include:
4447 %T MIME type, along with additional info
4448 %n The `name' parameter
4449 %d The description, if any
4450 %l The length of the encoded part
4451 %p The part identifier number
4452 %e Dots if the part isn't displayed
4454 General format specifiers can also be used. See Info node
4455 `(gnus)Formatting Variables'.")
4457 (defvar gnus-mime-button-line-format-alist
4458 '((?t gnus-tmp-type ?s)
4459 (?T gnus-tmp-type-long ?s)
4460 (?n gnus-tmp-name ?s)
4461 (?d gnus-tmp-description ?s)
4463 (?l gnus-tmp-length ?d)
4464 (?e gnus-tmp-dots ?s)))
4466 (defvar gnus-mime-button-commands
4467 '((gnus-article-press-button "\r" "Toggle Display")
4468 (gnus-mime-view-part "v" "View Interactively...")
4469 (gnus-mime-view-part-as-type "t" "View As Type...")
4470 (gnus-mime-view-part-as-charset "C" "View As charset...")
4471 (gnus-mime-save-part "o" "Save...")
4472 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4473 (gnus-mime-replace-part "r" "Replace part")
4474 (gnus-mime-delete-part "d" "Delete part")
4475 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4476 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4477 (gnus-mime-view-part-internally "E" "View Internally") ;; Why `E'?
4478 (gnus-mime-view-part-externally "e" "View Externally")
4479 (gnus-mime-print-part "p" "Print")
4480 (gnus-mime-pipe-part "|" "Pipe To Command...")
4481 (gnus-mime-action-on-part "." "Take action on the part...")))
4483 (defun gnus-article-mime-part-status ()
4484 (if gnus-article-mime-handle-alist-1
4485 (if (eq 1 (length gnus-article-mime-handle-alist-1))
4487 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
4490 (defvar gnus-mime-button-map
4491 (let ((map (make-sparse-keymap)))
4492 (define-key map gnus-mouse-2 'gnus-article-push-button)
4493 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4494 (dolist (c gnus-mime-button-commands)
4495 (define-key map (cadr c) (car c)))
4499 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4501 ,@(mapcar (lambda (c)
4502 (vector (caddr c) (car c) :active t))
4503 gnus-mime-button-commands)))
4505 (defun gnus-mime-button-menu (event prefix)
4506 "Construct a context-sensitive menu of MIME commands."
4507 (interactive "e\nP")
4508 (save-window-excursion
4509 (let ((pos (event-start event)))
4510 (select-window (posn-window pos))
4511 (goto-char (posn-point pos))
4512 (gnus-article-check-buffer)
4513 (popup-menu gnus-mime-button-menu nil prefix))))
4515 (defun gnus-mime-view-all-parts (&optional handles)
4516 "View all the MIME parts."
4518 (with-current-buffer gnus-article-buffer
4519 (let ((handles (or handles gnus-article-mime-handles))
4520 (mail-parse-charset gnus-newsgroup-charset)
4521 (mail-parse-ignored-charsets
4522 (with-current-buffer gnus-summary-buffer
4523 gnus-newsgroup-ignored-charsets)))
4525 (mm-remove-parts handles)
4526 (goto-char (point-min))
4527 (or (search-forward "\n\n") (goto-char (point-max)))
4528 (let ((inhibit-read-only t))
4529 (delete-region (point) (point-max))
4530 (mm-display-parts handles))))))
4532 (defun gnus-article-jump-to-part (n)
4533 "Jump to MIME part N."
4535 (pop-to-buffer gnus-article-buffer)
4536 ;; FIXME: why is it necessary?
4538 (let ((parts (length gnus-article-mime-handle-alist)))
4541 (read-string ;; Emacs 21 doesn't have `read-number'.
4542 (format "Jump to part (2..%s): " parts)))))
4543 (unless (and (integerp n) (<= n parts) (>= n 1))
4546 (gnus-message 7 "Invalid part `%s', using %s instead."
4549 (gnus-message 9 "Jumping to part %s." n)
4550 (cond ((>= gnus-auto-select-part 1)
4551 (while (and (<= n parts)
4552 (not (gnus-article-goto-part n)))
4554 ((< gnus-auto-select-part 0)
4555 (while (and (>= n 1)
4556 (not (gnus-article-goto-part n)))
4559 (gnus-article-goto-part n)))))
4562 (defsubst gnus-article-edit-part (handles &optional current-id)
4563 "Edit an article in order to delete a mime part.
4564 This function is exclusively used by `gnus-mime-save-part-and-strip'
4565 and `gnus-mime-delete-part', and not provided at run-time normally."
4566 (gnus-article-edit-article
4568 (buffer-disable-undo)
4570 (let ((mail-parse-charset (or gnus-article-charset
4571 ',gnus-newsgroup-charset))
4572 (mail-parse-ignored-charsets
4573 (or gnus-article-ignored-charsets
4574 ',gnus-newsgroup-ignored-charsets))
4575 (mbl mml-buffer-list))
4576 (setq mml-buffer-list nil)
4577 (insert-buffer-substring gnus-original-article-buffer)
4578 (mime-to-mml ',handles)
4579 (setq gnus-article-mime-handles nil)
4580 (let ((mbl1 mml-buffer-list))
4581 (setq mml-buffer-list mbl)
4582 (set (make-local-variable 'mml-buffer-list) mbl1))
4583 (gnus-make-local-hook 'kill-buffer-hook)
4584 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4585 `(lambda (no-highlight)
4586 (let ((mail-parse-charset (or gnus-article-charset
4587 ',gnus-newsgroup-charset))
4588 (message-options message-options)
4589 (message-options-set-recipient)
4590 (mail-parse-ignored-charsets
4591 (or gnus-article-ignored-charsets
4592 ',gnus-newsgroup-ignored-charsets)))
4594 (mml-destroy-buffers)
4595 (remove-hook 'kill-buffer-hook
4596 'mml-destroy-buffers t)
4597 (kill-local-variable 'mml-buffer-list))
4598 (gnus-summary-edit-article-done
4599 ,(or (mail-header-references gnus-current-headers) "")
4600 ,(gnus-group-read-only-p)
4601 ,gnus-summary-buffer no-highlight))
4603 (gnus-article-edit-done)
4604 (gnus-summary-expand-window)
4605 (gnus-summary-show-article)
4606 (when (and current-id (integerp gnus-auto-select-part))
4607 (gnus-article-jump-to-part
4608 (if (text-property-any (point-min) (point-max)
4609 'gnus-part (+ current-id gnus-auto-select-part))
4610 (+ current-id gnus-auto-select-part)
4611 (with-current-buffer gnus-article-buffer
4612 (length gnus-article-mime-handle-alist)))))))
4614 (defun gnus-mime-replace-part (file)
4615 "Replace MIME part under point with an external body."
4616 ;; Useful if file has already been saved to disk
4620 (read-file-name "Replace MIME part with file: "
4621 (or mm-default-directory default-directory)
4623 (gnus-mime-save-part-and-strip file))
4625 (defun gnus-mime-save-part-and-strip (&optional file)
4626 "Save the MIME part under point then replace it with an external body.
4627 If FILE is given, use it for the external part."
4629 (gnus-article-check-buffer)
4630 (when (gnus-group-read-only-p)
4631 (error "The current group does not support deleting of parts"))
4632 (when (mm-complicated-handles gnus-article-mime-handles)
4634 The current article has a complicated MIME structure, giving up..."))
4635 (let* ((data (get-text-property (point) 'gnus-data))
4636 (id (get-text-property (point) 'gnus-part))
4638 (handles gnus-article-mime-handles))
4641 (and data (mm-save-part data "Delete MIME part and save to: "))))
4643 (with-current-buffer (mm-handle-buffer data)
4645 (insert "Content-Type: " (mm-handle-media-type data))
4646 (mml-insert-parameter-string (cdr (mm-handle-type data))
4648 ;; Add a filename for the sake of saving the part again.
4649 (mml-insert-parameter
4650 (mail-header-encode-parameter "name" (file-name-nondirectory file)))
4652 (insert "Content-ID: " (message-make-message-id) "\n")
4653 (insert "Content-Transfer-Encoding: binary\n")
4656 (cdr (mm-make-handle nil
4657 `("message/external-body"
4658 (access-type . "LOCAL-FILE")
4660 ;; (set-buffer gnus-summary-buffer)
4661 (gnus-article-edit-part handles id))))
4663 ;; A function like `gnus-summary-save-parts' (`X m', `<MIME> <Extract all
4664 ;; parts...>') but with stripping would be nice.
4666 (defun gnus-mime-delete-part ()
4667 "Delete the MIME part under point.
4668 Replace it with some information about the removed part."
4670 (gnus-article-check-buffer)
4671 (when (gnus-group-read-only-p)
4672 (error "The current group does not support deleting of parts"))
4673 (when (mm-complicated-handles gnus-article-mime-handles)
4675 The current article has a complicated MIME structure, giving up..."))
4676 (when (or gnus-expert-user
4677 (gnus-yes-or-no-p "\
4678 Deleting parts may malfunction or destroy the article; continue? "))
4679 (let* ((data (get-text-property (point) 'gnus-data))
4680 (id (get-text-property (point) 'gnus-part))
4681 (handles gnus-article-mime-handles)
4684 (mail-decode-encoded-word-string (or (mm-handle-description data)
4687 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4689 (type (mm-handle-media-type data)))
4691 (error "No MIME part under point"))
4692 (with-current-buffer (mm-handle-buffer data)
4693 (let ((bsize (format "%s" (buffer-size))))
4698 "| The following attachment has been deleted:\n"
4700 "| Type: " type "\n"
4701 "| Filename: " filename "\n"
4702 "| Size (encoded): " bsize " Byte\n"
4703 "| Description: " description "\n"
4706 (cdr (mm-make-handle
4707 nil `("text/plain") nil nil
4709 (format "Deleted attachment (%s bytes)" bsize))))))
4710 ;; (set-buffer gnus-summary-buffer)
4711 (gnus-article-edit-part handles id))))
4713 (defun gnus-mime-save-part ()
4714 "Save the MIME part under point."
4716 (gnus-article-check-buffer)
4717 (let ((data (get-text-property (point) 'gnus-data)))
4719 (mm-save-part data))))
4721 (defun gnus-mime-pipe-part ()
4722 "Pipe the MIME part under point to a process."
4724 (gnus-article-check-buffer)
4725 (let ((data (get-text-property (point) 'gnus-data)))
4727 (mm-pipe-part data))))
4729 (defun gnus-mime-view-part ()
4730 "Interactively choose a viewing method for the MIME part under point."
4732 (gnus-article-check-buffer)
4733 (let ((data (get-text-property (point) 'gnus-data)))
4735 (setq gnus-article-mime-handles
4737 gnus-article-mime-handles (setq data (copy-sequence data))))
4738 (mm-interactively-view-part data))))
4740 (defun gnus-mime-view-part-as-type-internal ()
4741 (gnus-article-check-buffer)
4742 (let* ((handle (get-text-property (point) 'gnus-data))
4744 ;; Content-Type: foo/bar; name=...
4745 (mail-content-type-get (mm-handle-type handle) 'name)
4746 ;; Content-Disposition: attachment; filename=...
4747 (cdr (assq 'filename (cdr (mm-handle-disposition handle))))))
4748 (def-type (and name (mm-default-file-encoding name))))
4749 (or (and def-type (cons def-type 0))
4751 (equal (mm-handle-media-supertype handle) "text")
4752 '("text/plain" . 0))
4753 '("application/octet-stream" . 0))))
4755 (defun gnus-mime-view-part-as-type (&optional mime-type pred)
4756 "Choose a MIME media type, and view the part as such.
4757 If non-nil, PRED is a predicate to use during completion to limit the
4758 available media-types."
4762 (let ((default (gnus-mime-view-part-as-type-internal)))
4764 (format "View as MIME type (default %s): "
4766 (mapcar #'list (mailcap-mime-types))
4769 (gnus-article-check-buffer)
4770 (let ((handle (get-text-property (point) 'gnus-data)))
4772 (when (equal (mm-handle-media-type handle) "message/external-body")
4773 (unless (mm-handle-cache handle)
4774 (mm-extern-cache-contents handle))
4775 (setq handle (mm-handle-cache handle)))
4777 (mm-make-handle (mm-handle-buffer handle)
4778 (cons mime-type (cdr (mm-handle-type handle)))
4779 (mm-handle-encoding handle)
4780 (mm-handle-undisplayer handle)
4781 (mm-handle-disposition handle)
4782 (mm-handle-description handle)
4784 (mm-handle-id handle)))
4785 (setq gnus-article-mime-handles
4786 (mm-merge-handles gnus-article-mime-handles handle))
4787 (when (mm-handle-displayed-p handle)
4788 (mm-remove-part handle))
4789 (gnus-mm-display-part handle))))
4791 (defun gnus-mime-copy-part (&optional handle arg)
4792 "Put the MIME part under point into a new buffer.
4793 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4795 (interactive (list nil current-prefix-arg))
4796 (gnus-article-check-buffer)
4798 (setq handle (get-text-property (point) 'gnus-data)))
4800 (let ((filename (or (mail-content-type-get (mm-handle-type handle)
4802 (mail-content-type-get (mm-handle-disposition handle)
4804 contents dont-decode charset coding-system)
4805 (mm-with-unibyte-buffer
4806 (mm-insert-part handle)
4807 (setq contents (or (condition-case nil
4808 (mm-decompress-buffer filename nil 'sig)
4810 (setq dont-decode t)
4813 (setq filename (cond (filename (file-name-nondirectory filename))
4814 (dont-decode "*raw data*")
4819 (unless (setq charset (mail-content-type-get
4820 (mm-handle-type handle) 'charset))
4821 (unless (setq coding-system (mm-with-unibyte-buffer
4823 (mm-find-buffer-file-coding-system)))
4824 (setq charset gnus-newsgroup-charset))))
4826 (setq charset (or (cdr (assq arg
4827 gnus-summary-show-article-charset-alist))
4828 (mm-read-coding-system "Charset: ")))))
4829 (switch-to-buffer (generate-new-buffer filename))
4830 (if (or coding-system
4832 (setq coding-system (mm-charset-to-coding-system charset))
4833 (not (eq charset 'ascii))))
4835 (mm-enable-multibyte)
4836 (insert (mm-decode-coding-string contents coding-system))
4837 (setq buffer-file-coding-system
4838 (if (boundp 'last-coding-system-used)
4839 (symbol-value 'last-coding-system-used)
4841 (mm-disable-multibyte)
4843 (setq buffer-file-coding-system mm-binary-coding-system))
4844 ;; We do it this way to make `normal-mode' set the appropriate mode.
4847 (setq buffer-file-name (expand-file-name filename))
4849 (setq buffer-file-name nil))
4850 (goto-char (point-min)))))
4852 (defun gnus-mime-print-part (&optional handle filename)
4853 "Print the MIME part under point."
4854 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4855 (gnus-article-check-buffer)
4856 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4857 (contents (and handle (mm-get-part handle)))
4858 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4859 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4864 (mm-save-part-to-file handle file)
4865 (call-process shell-file-name nil
4866 (generate-new-buffer " *mm*")
4868 shell-command-switch
4870 printer file (mm-handle-type handle))))
4874 (gnus-print-buffer))
4875 (ps-despool filename)))))
4877 (defun gnus-mime-inline-part (&optional handle arg)
4878 "Insert the MIME part under point into the current buffer.
4879 Compressed files like .gz and .bz2 are decompressed."
4880 (interactive (list nil current-prefix-arg))
4881 (gnus-article-check-buffer)
4883 (setq handle (get-text-property (point) 'gnus-data)))
4886 (inhibit-read-only t)
4887 contents charset coding-system)
4888 (if (and (not arg) (mm-handle-undisplayer handle))
4889 (mm-remove-part handle)
4890 (mm-with-unibyte-buffer
4891 (mm-insert-part handle)
4893 (or (mm-decompress-buffer
4894 (or (mail-content-type-get (mm-handle-type handle)
4896 (mail-content-type-get (mm-handle-disposition handle)
4902 (unless (setq charset (mail-content-type-get
4903 (mm-handle-type handle) 'charset))
4904 (unless (setq coding-system
4905 (mm-with-unibyte-buffer
4907 (mm-find-buffer-file-coding-system)))
4908 (setq charset gnus-newsgroup-charset))))
4910 (if (mm-handle-undisplayer handle)
4911 (mm-remove-part handle))
4914 gnus-summary-show-article-charset-alist))
4915 (mm-read-coding-system "Charset: "))))
4917 (if (mm-handle-undisplayer handle)
4918 (mm-remove-part handle))))
4922 (if (or coding-system
4925 (mm-charset-to-coding-system charset))
4926 (not (eq coding-system 'ascii))))
4927 (mm-decode-coding-string contents coding-system)
4928 (mm-string-to-multibyte contents)))
4931 (defun gnus-mime-strip-charset-parameters (handle)
4932 "Strip charset parameters from HANDLE."
4933 (if (stringp (car handle))
4934 (mapc #'gnus-mime-strip-charset-parameters (cdr handle))
4935 (let* ((type (mm-handle-type (if (equal (mm-handle-media-type handle)
4936 "message/external-body")
4938 (unless (mm-handle-cache handle)
4939 (mm-extern-cache-contents handle))
4940 (mm-handle-cache handle))
4942 (charset (assq 'charset (cdr type))))
4944 (delq charset type)))))
4946 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4947 "Insert the MIME part under point into the current buffer using the
4949 (interactive (list nil current-prefix-arg))
4950 (gnus-article-check-buffer)
4951 (let ((handle (or handle (get-text-property (point) 'gnus-data)))
4952 (fun (get-text-property (point) 'gnus-callback))
4953 (gnus-newsgroup-ignored-charsets 'gnus-all)
4954 gnus-newsgroup-charset form preferred parts)
4958 (setq gnus-newsgroup-charset
4961 gnus-summary-show-article-charset-alist))
4962 (mm-read-coding-system "Charset: "))))
4963 (if (mm-handle-undisplayer handle)
4964 (mm-remove-part handle)))
4965 (gnus-mime-strip-charset-parameters handle)
4966 (when (and (consp (setq form (cdr-safe fun)))
4967 (setq form (ignore-errors
4968 (assq 'gnus-mime-display-alternative form)))
4969 (setq preferred (caddr form))
4971 (when (eq (car preferred) 'quote)
4972 (setq preferred (cadr preferred)))
4973 (not (equal preferred
4974 (get-text-property (point) 'gnus-data))))
4975 (setq parts (get-text-property (point) 'gnus-part))
4976 (setq parts (cdr (assq parts
4977 gnus-article-mime-handle-alist)))
4978 (equal (mm-handle-media-type parts) "multipart/alternative")
4979 (setq parts (reverse (cdr parts))))
4981 (list 'quote (or (cadr (member preferred parts))
4983 (funcall fun handle)))))
4985 (defun gnus-mime-view-part-externally (&optional handle)
4986 "View the MIME part under point with an external viewer."
4988 (gnus-article-check-buffer)
4989 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4990 (mm-user-display-methods nil)
4991 (mm-inlined-types nil)
4992 (mail-parse-charset gnus-newsgroup-charset)
4993 (mail-parse-ignored-charsets
4994 (with-current-buffer gnus-summary-buffer
4995 gnus-newsgroup-ignored-charsets))
4996 (type (mm-handle-media-type handle))
4997 (method (mailcap-mime-info type))
4998 (mm-enable-external t))
4999 (if (not (stringp method))
5000 (gnus-mime-view-part-as-type
5001 nil (lambda (types) (stringp (mailcap-mime-info (car types)))))
5003 (if (mm-handle-undisplayer handle)
5004 (mm-remove-part handle)
5005 (mm-display-part handle))))))
5007 (defun gnus-mime-view-part-internally (&optional handle)
5008 "View the MIME part under point with an internal viewer.
5009 If no internal viewer is available, use an external viewer."
5011 (gnus-article-check-buffer)
5012 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
5013 (mm-inlined-types '(".*"))
5014 (mm-inline-large-images t)
5015 (mail-parse-charset gnus-newsgroup-charset)
5016 (mail-parse-ignored-charsets
5017 (with-current-buffer gnus-summary-buffer
5018 gnus-newsgroup-ignored-charsets))
5019 (inhibit-read-only t))
5020 (if (not (mm-inlinable-p handle))
5021 (gnus-mime-view-part-as-type
5022 nil (lambda (types) (mm-inlinable-p handle (car types))))
5024 (if (mm-handle-undisplayer handle)
5025 (mm-remove-part handle)
5026 (mm-display-part handle))))))
5028 (defun gnus-mime-action-on-part (&optional action)
5029 "Do something with the MIME attachment at \(point\)."
5031 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
5032 (gnus-article-check-buffer)
5033 (let ((action-pair (assoc action gnus-mime-action-alist)))
5035 (funcall (cdr action-pair)))))
5037 (defun gnus-article-part-wrapper (n function &optional no-handle interactive)
5038 "Call FUNCTION on MIME part N.
5039 Unless NO-HANDLE, call FUNCTION with N-th MIME handle as it's only argument.
5040 If INTERACTIVE, call FUNCTION interactivly."
5042 ;; Check whether the article is displayed.
5043 (unless (and (gnus-buffer-live-p gnus-article-buffer)
5044 (setq window (get-buffer-window gnus-article-buffer t))
5045 (frame-visible-p (setq frame (window-frame window))))
5046 (error "No article is displayed"))
5047 (with-current-buffer gnus-article-buffer
5048 ;; Check whether the article displays the right contents.
5049 (unless (with-current-buffer gnus-summary-buffer
5050 (eq gnus-current-article (gnus-summary-article-number)))
5051 (error "You should select the right article first"))
5053 (setq n (prefix-numeric-value n))
5055 (setq n (or (get-text-property pt 'gnus-part)
5057 (get-text-property (1- pt) 'gnus-part))
5058 (get-text-property (prog2
5064 (or (and (setq pt (previous-single-property-change
5067 (next-single-property-change (point) 'gnus-part)
5071 ;; Check whether the specified part exists.
5072 (when (> n (length gnus-article-mime-handle-alist))
5073 (error "No such part")))
5076 ;; To select the window is needed so that the cursor
5077 ;; might be visible on the MIME button.
5078 (select-window (prog1
5080 (setq window (selected-window))
5081 ;; Article may be displayed in the other frame.
5082 (gnus-select-frame-set-input-focus
5085 (setq frame (selected-frame))))))
5086 (when (gnus-article-goto-part n)
5087 ;; We point the cursor and the arrow at the MIME button
5088 ;; when the `function' prompt the user for something.
5089 (let ((cursor-in-non-selected-windows t)
5090 (overlay-arrow-string "=>")
5091 (overlay-arrow-position (point-marker)))
5094 ((and no-handle interactive)
5095 (call-interactively function))
5101 (cdr (assq n gnus-article-mime-handle-alist))))
5104 (cdr (assq n gnus-article-mime-handle-alist)))))
5105 (set-marker overlay-arrow-position nil)
5106 (unless gnus-auto-select-part
5107 (gnus-select-frame-set-input-focus frame)
5108 (select-window window))))
5110 (if gnus-inhibit-mime-unbuttonizing
5111 ;; This is the default though the program shouldn't reach here.
5112 (error "No such part")
5113 ;; The part which doesn't have the MIME button is selected.
5114 ;; So, we display all the buttons and redo it.
5115 (let ((gnus-inhibit-mime-unbuttonizing t))
5116 (gnus-summary-show-article)
5117 (gnus-article-part-wrapper n function no-handle))))))
5119 (defun gnus-article-pipe-part (n)
5120 "Pipe MIME part N, which is the numerical prefix."
5122 (gnus-article-part-wrapper n 'mm-pipe-part))
5124 (defun gnus-article-save-part (n)
5125 "Save MIME part N, which is the numerical prefix."
5127 (gnus-article-part-wrapper n 'mm-save-part))
5129 (defun gnus-article-interactively-view-part (n)
5130 "View MIME part N interactively, which is the numerical prefix."
5132 (gnus-article-part-wrapper n 'mm-interactively-view-part))
5134 (defun gnus-article-copy-part (n)
5135 "Copy MIME part N, which is the numerical prefix."
5137 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
5139 (defun gnus-article-view-part-as-charset (n)
5140 "View MIME part N using a specified charset.
5141 N is the numerical prefix."
5143 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
5145 (defun gnus-article-view-part-externally (n)
5146 "View MIME part N externally, which is the numerical prefix."
5148 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
5150 (defun gnus-article-inline-part (n)
5151 "Inline MIME part N, which is the numerical prefix."
5153 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
5155 (defun gnus-article-save-part-and-strip (n)
5156 "Save MIME part N and replace it with an external body.
5157 N is the numerical prefix."
5159 (gnus-article-part-wrapper n 'gnus-mime-save-part-and-strip t))
5161 (defun gnus-article-replace-part (n)
5162 "Replace MIME part N with an external body.
5163 N is the numerical prefix."
5165 (gnus-article-part-wrapper n 'gnus-mime-replace-part t t))
5167 (defun gnus-article-delete-part (n)
5168 "Delete MIME part N and add some information about the removed part.
5169 N is the numerical prefix."
5171 (gnus-article-part-wrapper n 'gnus-mime-delete-part t))
5173 (defun gnus-article-view-part-as-type (n)
5174 "Choose a MIME media type, and view part N as such.
5175 N is the numerical prefix."
5177 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-type t))
5179 (defun gnus-article-mime-match-handle-first (condition)
5182 (dolist (ihandle gnus-article-mime-handle-alist)
5184 ((functionp condition)
5185 (funcall condition (cdr ihandle)))
5186 ((eq condition 'undisplayed)
5187 (not (or (mm-handle-undisplayer (cdr ihandle))
5188 (equal (mm-handle-media-type (cdr ihandle))
5189 "multipart/alternative"))))
5190 ((eq condition 'undisplayed-alternative)
5191 (not (mm-handle-undisplayer (cdr ihandle))))
5193 (gnus-article-goto-part (car ihandle))
5194 (or (not n) (< (car ihandle) n)))
5195 (setq n (car ihandle))))
5199 (defun gnus-article-view-part (&optional n)
5200 "View MIME part N, which is the numerical prefix."
5202 (with-current-buffer gnus-article-buffer
5203 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
5204 gnus-article-mime-match-handle-function)))
5205 (when (> n (length gnus-article-mime-handle-alist))
5206 (error "No such part"))
5207 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
5208 (when (gnus-article-goto-part n)
5209 (if (equal (car handle) "multipart/alternative")
5210 (gnus-article-press-button)
5211 (when (eq (gnus-mm-display-part handle) 'internal)
5212 (gnus-set-window-start)))))))
5214 (defsubst gnus-article-mime-total-parts ()
5215 (if (bufferp (car gnus-article-mime-handles))
5217 (1- (length gnus-article-mime-handles))))
5219 (defun gnus-mm-display-part (handle)
5220 "Display HANDLE and fix MIME button."
5221 (let ((id (get-text-property (point) 'gnus-part))
5223 (inhibit-read-only t))
5226 (let ((window (selected-window))
5227 (mail-parse-charset gnus-newsgroup-charset)
5228 (mail-parse-ignored-charsets
5229 (if (gnus-buffer-live-p gnus-summary-buffer)
5230 (with-current-buffer gnus-summary-buffer
5231 gnus-newsgroup-ignored-charsets)
5235 (let ((win (gnus-get-buffer-window (current-buffer) t))
5238 (select-window win))
5241 (if (mm-handle-displayed-p handle)
5242 ;; This will remove the part.
5243 (mm-display-part handle)
5245 (narrow-to-region (point)
5246 (if (eobp) (point) (1+ (point))))
5247 (mm-display-part handle)
5248 ;; We narrow to the part itself and
5249 ;; then call the treatment functions.
5250 (goto-char (point-min))
5252 (narrow-to-region (point) (point-max))
5255 (gnus-article-mime-total-parts)
5256 (mm-handle-media-type handle)))))
5257 (if (window-live-p window)
5258 (select-window window)))))
5261 (gnus-insert-mime-button
5262 handle id (list (mm-handle-displayed-p handle)))
5263 (goto-char point))))
5265 (defun gnus-article-goto-part (n)
5266 "Go to MIME part N."
5267 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
5269 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
5270 (let ((gnus-tmp-name
5271 (or (mail-content-type-get (mm-handle-type handle) 'name)
5272 (mail-content-type-get (mm-handle-disposition handle) 'filename)
5273 (mail-content-type-get (mm-handle-type handle) 'url)
5275 (gnus-tmp-type (mm-handle-media-type handle))
5276 (gnus-tmp-description
5277 (mail-decode-encoded-word-string (or (mm-handle-description handle)
5280 (if (if displayed (car displayed)
5281 (mm-handle-displayed-p handle))
5283 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
5285 gnus-tmp-type-long b e)
5286 (when (string-match ".*/" gnus-tmp-name)
5287 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
5288 (setq gnus-tmp-type-long (concat gnus-tmp-type
5289 (and (not (equal gnus-tmp-name ""))
5290 (concat "; " gnus-tmp-name))))
5291 (unless (equal gnus-tmp-description "")
5292 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
5297 gnus-mime-button-line-format gnus-mime-button-line-format-alist
5298 `(keymap ,gnus-mime-button-map
5299 gnus-callback gnus-mm-display-part
5300 gnus-part ,gnus-tmp-id
5301 article-type annotation
5304 ;; Exclude a newline.
5307 (when gnus-article-button-face
5308 (gnus-overlay-put (gnus-make-overlay b e nil t)
5309 'face gnus-article-button-face))
5310 (widget-convert-button
5313 :action 'gnus-widget-press-button
5314 :button-keymap gnus-mime-button-map
5316 (lambda (widget/window &optional overlay pos)
5317 ;; Needed to properly clear the message due to a bug in
5318 ;; wid-edit (XEmacs only).
5319 (if (boundp 'help-echo-owns-message)
5320 (setq help-echo-owns-message t))
5322 "%S: %s the MIME part; %S: more options"
5323 (aref gnus-mouse-2 0)
5324 ;; XEmacs will get a single widget arg; Emacs 21 will get
5325 ;; window, overlay, position.
5326 (if (mm-handle-displayed-p
5328 (with-current-buffer (gnus-overlay-buffer overlay)
5329 (widget-get (widget-at (gnus-overlay-start overlay))
5331 (widget-get widget/window :mime-handle)))
5333 (aref gnus-down-mouse-3 0))))))
5335 (defun gnus-widget-press-button (elems el)
5336 (goto-char (widget-get elems :from))
5337 (gnus-article-press-button))
5339 (defvar gnus-displaying-mime nil)
5341 (defun gnus-display-mime (&optional ihandles)
5342 "Display the MIME parts."
5344 (save-selected-window
5345 (let ((window (get-buffer-window gnus-article-buffer))
5348 (select-window window)
5349 ;; We have to do this since selecting the window
5350 ;; may change the point. So we set the window point.
5351 (set-window-point window point)))
5352 (let ((handles ihandles)
5353 (inhibit-read-only t)
5356 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
5357 (when gnus-article-emulate-mime
5358 (mm-uu-dissect-text-parts handles)))
5359 (gnus-article-emulate-mime
5360 (setq handles (mm-uu-dissect))))
5361 (when (and (not ihandles)
5362 (not gnus-displaying-mime))
5363 ;; Top-level call; we clean up.
5364 (when gnus-article-mime-handles
5365 (mm-destroy-parts gnus-article-mime-handles)
5366 (setq gnus-article-mime-handle-alist nil));; A trick.
5367 (setq gnus-article-mime-handles handles)
5368 ;; We allow users to glean info from the handles.
5369 (when gnus-article-mime-part-function
5370 (gnus-mime-part-function handles)))
5372 (or (not (stringp (car handles)))
5375 (when (and (not ihandles)
5376 (not gnus-displaying-mime))
5377 ;; Clean up for mime parts.
5379 (delete-region (point) (point-max)))
5380 (let ((gnus-displaying-mime t))
5381 (gnus-mime-display-part handles)))
5384 (narrow-to-region (point) (point-max))
5385 (gnus-treat-article nil 1 1)
5388 ;; Highlight the headers.
5392 (narrow-to-region (point-min) (point))
5393 (gnus-article-save-original-date
5394 (gnus-treat-article 'head)))))))
5395 ;; Cope with broken MIME messages.
5396 (goto-char (point-max))
5400 (defcustom gnus-mime-display-multipart-as-mixed nil
5401 "Display \"multipart\" parts as \"multipart/mixed\".
5403 If t, it overrides nil values of
5404 `gnus-mime-display-multipart-alternative-as-mixed' and
5405 `gnus-mime-display-multipart-related-as-mixed'."
5406 :group 'gnus-article-mime
5409 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
5410 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
5412 :group 'gnus-article-mime
5415 (defcustom gnus-mime-display-multipart-related-as-mixed nil
5416 "Display \"multipart/related\" parts as \"multipart/mixed\".
5418 If displaying \"text/html\" is discouraged \(see
5419 `mm-discouraged-alternatives'\) images or other material inside a
5420 \"multipart/related\" part might be overlooked when this variable is nil."
5422 :group 'gnus-article-mime
5425 (defun gnus-mime-display-part (handle)
5427 ;; Maybe a broken MIME message.
5430 ((not (stringp (car handle)))
5431 (gnus-mime-display-single handle))
5432 ;; User-defined multipart
5433 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
5434 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
5436 ;; multipart/alternative
5437 ((and (equal (car handle) "multipart/alternative")
5438 (not (or gnus-mime-display-multipart-as-mixed
5439 gnus-mime-display-multipart-alternative-as-mixed)))
5440 (let ((id (1+ (length gnus-article-mime-handle-alist))))
5441 (push (cons id handle) gnus-article-mime-handle-alist)
5442 (gnus-mime-display-alternative (cdr handle) nil nil id)))
5443 ;; multipart/related
5444 ((and (equal (car handle) "multipart/related")
5445 (not (or gnus-mime-display-multipart-as-mixed
5446 gnus-mime-display-multipart-related-as-mixed)))
5447 ;;;!!!We should find the start part, but we just default
5448 ;;;!!!to the first part.
5449 ;;(gnus-mime-display-part (cadr handle))
5450 ;;;!!! Most multipart/related is an HTML message plus images.
5451 ;;;!!! Unfortunately we are unable to let W3 display those
5452 ;;;!!! included images, so we just display it as a mixed multipart.
5453 ;;(gnus-mime-display-mixed (cdr handle))
5454 ;;;!!! No, w3 can display everything just fine.
5455 (gnus-mime-display-part (cadr handle)))
5456 ((equal (car handle) "multipart/signed")
5457 (gnus-add-wash-type 'signed)
5458 (gnus-mime-display-security handle))
5459 ((equal (car handle) "multipart/encrypted")
5460 (gnus-add-wash-type 'encrypted)
5461 (gnus-mime-display-security handle))
5462 ;; Other multiparts are handled like multipart/mixed.
5464 (gnus-mime-display-mixed (cdr handle)))))
5466 (defun gnus-mime-part-function (handles)
5467 (if (stringp (car handles))
5468 (mapcar 'gnus-mime-part-function (cdr handles))
5469 (funcall gnus-article-mime-part-function handles)))
5471 (defun gnus-mime-display-mixed (handles)
5472 (mapcar 'gnus-mime-display-part handles))
5474 (defun gnus-mime-display-single (handle)
5475 (let ((type (mm-handle-media-type handle))
5476 (ignored gnus-ignored-mime-types)
5483 (when (string-match (pop ignored) type)
5484 (throw 'ignored nil)))
5485 (if (and (setq not-attachment
5486 (and (not (mm-inline-override-p handle))
5487 (or (not (mm-handle-disposition handle))
5488 (equal (car (mm-handle-disposition handle))
5490 (mm-attachment-override-p handle))))
5491 (mm-automatic-display-p handle)
5493 (mm-inlinable-p handle)
5494 (mm-inlined-p handle))
5495 (mm-automatic-external-display-p type)))
5497 (when (equal (mm-handle-media-supertype handle) "text")
5499 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5501 (push (cons id handle) gnus-article-mime-handle-alist)
5503 (equal (mm-handle-media-supertype handle) "message"))
5506 (cond ((not (bolp)) 2)
5507 ((or (bobp) (eq (char-before (1- (point))) ?\n)) 0)
5509 (when (or (not display)
5510 (not (gnus-unbuttonized-mime-type-p type)))
5511 (gnus-insert-mime-button
5512 handle id (list (or display (and not-attachment text))))
5513 (gnus-article-insert-newline)
5514 ;; Remember modify the number of forward lines.
5522 (let ((mail-parse-charset gnus-newsgroup-charset)
5523 (mail-parse-ignored-charsets
5524 (save-excursion (condition-case ()
5525 (set-buffer gnus-summary-buffer)
5527 gnus-newsgroup-ignored-charsets)))
5528 (mm-display-part handle t))
5529 (goto-char (point-max)))
5530 ((and text not-attachment)
5534 (gnus-article-insert-newline)
5537 (let ((charset (or (mail-content-type-get (mm-handle-type handle)
5539 (and (equal type "text/calendar") 'utf-8))))
5540 (cond ((not charset)
5541 (mm-string-as-multibyte (mm-get-part handle)))
5542 ((eq charset 'gnus-decoded)
5543 (with-current-buffer (mm-handle-buffer handle)
5546 (mm-decode-string (mm-get-part handle) charset)))))
5547 (goto-char (point-max))))
5551 (narrow-to-region beg (point))
5552 (if (eq handle gnus-article-mime-handles)
5553 ;; The format=flowed case.
5554 (gnus-treat-article nil 1 1 (mm-handle-media-type handle))
5555 ;; Don't count signature parts that are never displayed.
5556 ;; The part number should be re-calculated supposing this
5557 ;; might be a message/rfc822 part.
5559 (dolist (part gnus-article-mime-handles)
5560 (unless (or (stringp part)
5561 (equal (car (mm-handle-type part))
5562 "application/pgp-signature"))
5563 (push part handles)))
5565 nil (length (memq handle handles)) (length handles)
5566 (mm-handle-media-type handle)))))))))))
5568 (defun gnus-unbuttonized-mime-type-p (type)
5569 "Say whether TYPE is to be unbuttonized."
5570 (unless gnus-inhibit-mime-unbuttonizing
5572 (let ((types gnus-unbuttonized-mime-types))
5574 (when (string-match (pop types) type)
5575 (throw 'found t)))))
5577 (let ((types gnus-buttonized-mime-types))
5579 (when (string-match (pop types) type)
5580 (throw 'found t)))))))))
5582 (defun gnus-article-insert-newline ()
5583 "Insert a newline, but mark it as undeletable."
5584 (gnus-put-text-property
5585 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5587 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5588 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5591 handle (inhibit-read-only t) from props begend not-pref)
5592 (save-window-excursion
5595 (narrow-to-region (car ibegend)
5598 (goto-char (car ibegend))
5601 (delete-region (point-min) (point-max))
5602 (mm-remove-parts handles))
5603 (setq begend (list (point-marker)))
5605 (unless (setq not-pref (cadr (member preferred ihandles)))
5606 (setq not-pref (car ihandles)))
5609 (not (gnus-unbuttonized-mime-type-p
5610 "multipart/alternative")))
5611 (gnus-add-text-properties
5614 (insert (format "%d. " id))
5618 (unless ,(not ibegend)
5619 (setq gnus-article-mime-handle-alist
5620 ',gnus-article-mime-handle-alist))
5621 (gnus-mime-display-alternative
5622 ',ihandles ',not-pref ',begend ,id))
5623 keymap ,gnus-mime-button-map
5624 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5625 face ,gnus-article-button-face
5627 article-type multipart))
5628 (widget-convert-button 'link from (point)
5629 :action 'gnus-widget-press-button
5630 :button-keymap gnus-widget-button-keymap)
5632 (while (setq handle (pop handles))
5633 (gnus-add-text-properties
5636 (insert (format "(%c) %-18s"
5637 (if (equal handle preferred) ?* ? )
5638 (mm-handle-media-type handle)))
5642 (unless ,(not ibegend)
5643 (setq gnus-article-mime-handle-alist
5644 ',gnus-article-mime-handle-alist))
5645 (gnus-mime-display-alternative
5646 ',ihandles ',handle ',begend ,id))
5647 keymap ,gnus-mime-button-map
5648 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5649 face ,gnus-article-button-face
5652 (widget-convert-button 'link from (point)
5653 :action 'gnus-widget-press-button
5654 :button-keymap gnus-widget-button-keymap)
5658 (if (stringp (car preferred))
5659 (gnus-display-mime preferred)
5660 (let ((mail-parse-charset gnus-newsgroup-charset)
5661 (mail-parse-ignored-charsets
5662 (with-current-buffer gnus-summary-buffer
5663 gnus-newsgroup-ignored-charsets)))
5664 (mm-display-part preferred)
5668 (narrow-to-region (car begend) (point-max))
5670 nil (length gnus-article-mime-handle-alist)
5671 (gnus-article-mime-total-parts)
5672 (mm-handle-media-type handle))))))
5673 (goto-char (point-max))
5674 (setcdr begend (point-marker)))))
5676 (goto-char point))))
5678 (defconst gnus-article-wash-status-strings
5679 (let ((alist '((cite "c" "Possible hidden citation text"
5680 " " "All citation text visible")
5681 (headers "h" "Hidden headers"
5682 " " "All headers visible.")
5683 (pgp "p" "Encrypted or signed message status hidden"
5684 " " "No hidden encryption nor digital signature status")
5685 (signature "s" "Signature has been hidden"
5686 " " "Signature is visible")
5687 (overstrike "o" "Overstrike (^H) characters applied"
5688 " " "No overstrike characters applied")
5689 (emphasis "e" "/*_Emphasis_*/ characters applied"
5690 " " "No /*_emphasis_*/ characters applied")))
5692 (dolist (entry alist result)
5693 (let ((key (nth 0 entry))
5694 (on (copy-sequence (nth 1 entry)))
5695 (on-help (nth 2 entry))
5696 (off (copy-sequence (nth 3 entry)))
5697 (off-help (nth 4 entry)))
5698 (put-text-property 0 1 'help-echo on-help on)
5699 (put-text-property 0 1 'help-echo off-help off)
5700 (push (list key on off) result))))
5701 "Alist of strings describing wash status in the mode line.
5702 Each entry has the form (KEY ON OF), where the KEY is a symbol
5703 representing the particular washing function, ON is the string to use
5704 in the article mode line when the washing function is active, and OFF
5705 is the string to use when it is inactive.")
5707 (defun gnus-article-wash-status-entry (key value)
5708 (let ((entry (assoc key gnus-article-wash-status-strings)))
5709 (if value (nth 1 entry) (nth 2 entry))))
5711 (defun gnus-article-wash-status ()
5712 "Return a string which display status of article washing."
5713 (with-current-buffer gnus-article-buffer
5714 (let ((cite (memq 'cite gnus-article-wash-types))
5715 (headers (memq 'headers gnus-article-wash-types))
5716 (boring (memq 'boring-headers gnus-article-wash-types))
5717 (pgp (memq 'pgp gnus-article-wash-types))
5718 (pem (memq 'pem gnus-article-wash-types))
5719 (signed (memq 'signed gnus-article-wash-types))
5720 (encrypted (memq 'encrypted gnus-article-wash-types))
5721 (signature (memq 'signature gnus-article-wash-types))
5722 (overstrike (memq 'overstrike gnus-article-wash-types))
5723 (emphasis (memq 'emphasis gnus-article-wash-types)))
5725 (gnus-article-wash-status-entry 'cite cite)
5726 (gnus-article-wash-status-entry 'headers (or headers boring))
5727 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5728 (gnus-article-wash-status-entry 'signature signature)
5729 (gnus-article-wash-status-entry 'overstrike overstrike)
5730 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5732 (defun gnus-add-wash-type (type)
5733 "Add a washing of TYPE to the current status."
5734 (add-to-list 'gnus-article-wash-types type))
5736 (defun gnus-delete-wash-type (type)
5737 "Add a washing of TYPE to the current status."
5738 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5740 (defun gnus-add-image (category image)
5741 "Add IMAGE of CATEGORY to the list of displayed images."
5742 (let ((entry (assq category gnus-article-image-alist)))
5744 (setq entry (list category))
5745 (push entry gnus-article-image-alist))
5746 (nconc entry (list image))))
5748 (defun gnus-delete-images (category)
5749 "Delete all images in CATEGORY."
5750 (let ((entry (assq category gnus-article-image-alist)))
5751 (dolist (image (cdr entry))
5752 (gnus-remove-image image category))
5753 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5754 (gnus-delete-wash-type category)))
5756 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5758 (defun gnus-article-maybe-hide-headers ()
5759 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5760 Provided for backwards compatibility."
5761 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5762 (not (with-current-buffer gnus-summary-buffer
5763 gnus-have-all-headers)))
5764 (not gnus-inhibit-hiding))
5765 (gnus-article-hide-headers)))
5769 (defun gnus-output-to-file (file-name)
5770 "Append the current article to a file named FILE-NAME.
5771 If `gnus-article-save-coding-system' is non-nil, it is used to encode
5772 text and used as the value of the coding cookie which is added to the
5773 top of a file. Otherwise, this function saves a raw article without
5775 (let* ((artbuf (current-buffer))
5776 (file-name-coding-system nnmail-pathname-coding-system)
5777 (coding gnus-article-save-coding-system)
5778 (coding-system-for-read (if coding
5779 nil ;; Rely on the coding cookie.
5780 mm-text-coding-system))
5781 (coding-system-for-write (or coding
5782 mm-text-coding-system-for-write
5783 mm-text-coding-system))
5784 (exists (file-exists-p file-name)))
5787 (insert-file-contents file-name)
5788 (goto-char (point-min))
5789 ;; Remove the existing coding cookie.
5790 (when (looking-at "X-Gnus-Coding-System: .+\n\n")
5791 (delete-region (match-beginning 0) (match-end 0))))
5792 (goto-char (point-max))
5793 (insert-buffer-substring artbuf)
5794 ;; Append newline at end of the buffer as separator, and then
5796 (goto-char (point-max))
5799 ;; If the coding system is not suitable to encode the text,
5800 ;; ask a user for a proper one.
5801 (when (fboundp 'select-safe-coding-system)
5802 (setq coding (coding-system-base
5803 (save-window-excursion
5804 (select-safe-coding-system (point-min) (point-max)
5806 (setq coding-system-for-write
5807 (or (cdr (assq coding '((mule-utf-8 . utf-8))))
5809 (goto-char (point-min))
5810 ;; Add the coding cookie.
5811 (insert (format "X-Gnus-Coding-System: -*- coding: %s; -*-\n\n"
5812 coding-system-for-write)))
5815 (write-region (point-min) (point-max) file-name nil 'no-message)
5816 (message "Appended to %s" file-name))
5817 (write-region (point-min) (point-max) file-name))))
5820 (defun gnus-narrow-to-page (&optional arg)
5821 "Narrow the article buffer to a page.
5822 If given a numerical ARG, move forward ARG pages."
5824 (setq arg (if arg (prefix-numeric-value arg) 0))
5826 (set-buffer gnus-article-buffer)
5827 (goto-char (point-min))
5829 ;; Remove any old next/prev buttons.
5830 (when (gnus-visual-p 'page-marker)
5831 (let ((inhibit-read-only t))
5832 (gnus-remove-text-with-property 'gnus-prev)
5833 (gnus-remove-text-with-property 'gnus-next)))
5836 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5838 (re-search-forward page-delimiter nil 'move arg)))
5839 (goto-char (match-end 0))
5841 (goto-char (point-min))
5842 (setq gnus-page-broken
5843 (and (re-search-forward page-delimiter nil t) t))))
5844 (when gnus-page-broken
5847 (if (re-search-forward page-delimiter nil 'move)
5850 (when (and (gnus-visual-p 'page-marker)
5851 (> (point-min) (save-restriction (widen) (point-min))))
5853 (goto-char (point-min))
5854 (gnus-insert-prev-page-button)))
5855 (when (and (gnus-visual-p 'page-marker)
5856 (< (point-max) (save-restriction (widen) (point-max))))
5858 (goto-char (point-max))
5859 (gnus-insert-next-page-button))))))
5861 ;; Article mode commands
5863 (defun gnus-article-goto-next-page ()
5864 "Show the next page of the article."
5866 (when (gnus-article-next-page)
5867 (goto-char (point-min))
5868 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5871 (defun gnus-article-goto-prev-page ()
5872 "Show the previous page of the article."
5875 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5876 (gnus-article-prev-page nil)))
5878 ;; This is cleaner but currently breaks `gnus-pick-mode':
5880 ;; (defun gnus-article-goto-next-page ()
5881 ;; "Show the next page of the article."
5883 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5884 ;; (gnus-summary-next-page)))
5886 ;; (defun gnus-article-goto-prev-page ()
5887 ;; "Show the next page of the article."
5889 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5890 ;; (gnus-summary-prev-page)))
5892 (defun gnus-article-next-page (&optional lines)
5893 "Show the next page of the current article.
5894 If end of article, return non-nil. Otherwise return nil.
5895 Argument LINES specifies lines to be scrolled up."
5897 (move-to-window-line -1)
5900 (and (pos-visible-in-window-p) ;Not continuation line.
5901 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5902 ;; Nothing in this page.
5903 (if (or (not gnus-page-broken)
5908 (eobp)))) ;Real end-of-buffer?
5910 (when gnus-article-over-scroll
5911 (gnus-article-next-page-1 lines))
5913 (gnus-narrow-to-page 1) ;Go to next page.
5915 ;; More in this page.
5916 (gnus-article-next-page-1 lines)
5919 (defmacro gnus-article-beginning-of-window ()
5920 "Move point to the beginning of the window.
5921 In Emacs, the point is placed at the line number which `scroll-margin'
5923 (if (featurep 'xemacs)
5924 '(move-to-window-line 0)
5925 '(move-to-window-line
5926 (min (max 0 scroll-margin)
5927 (max 1 (- (window-height)
5928 (if mode-line-format 1 0)
5929 (if header-line-format 1 0)))))))
5931 (defun gnus-article-next-page-1 (lines)
5932 (when (and (not (featurep 'xemacs))
5935 (numberp (symbol-value 'scroll-margin))
5936 (> (symbol-value 'scroll-margin) 0))
5937 ;; Protect against the bug that Emacs 21.x hangs up when scrolling up for
5938 ;; too many number of lines if `scroll-margin' is set as two or greater.
5939 (setq lines (min lines
5940 (max 0 (- (count-lines (window-start) (point-max))
5941 (symbol-value 'scroll-margin))))))
5943 (let ((scroll-in-place nil))
5946 ;; Long lines may cause an end-of-buffer error.
5947 (goto-char (point-max))))
5948 (gnus-article-beginning-of-window))
5950 (defun gnus-article-prev-page (&optional lines)
5951 "Show previous page of current article.
5952 Argument LINES specifies lines to be scrolled down."
5954 (move-to-window-line 0)
5955 (if (and gnus-page-broken
5957 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5959 (gnus-narrow-to-page -1) ;Go to previous page.
5960 (goto-char (point-max))
5964 (let ((scroll-in-place nil))
5965 (scroll-down lines))
5966 (beginning-of-buffer
5967 (goto-char (point-min))))
5968 (gnus-article-beginning-of-window))))
5970 (defun gnus-article-only-boring-p ()
5971 "Decide whether there is only boring text remaining in the article.
5972 Something \"interesting\" is a word of at least two letters that does
5973 not have a face in `gnus-article-boring-faces'."
5974 (when (and gnus-article-skip-boring
5975 (boundp 'gnus-article-boring-faces)
5976 (symbol-value 'gnus-article-boring-faces))
5978 (let ((inhibit-point-motion-hooks t))
5980 (while (re-search-forward "\\b\\w\\w" nil t)
5982 (when (not (gnus-intersection
5983 (gnus-faces-at (point))
5984 (symbol-value 'gnus-article-boring-faces)))
5985 (throw 'only-boring nil)))
5986 (throw 'only-boring t))))))
5988 (defun gnus-article-refer-article ()
5989 "Read article specified by message-id around point."
5992 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5993 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5994 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5995 (let ((msg-id (concat "<" (match-string 0) ">")))
5996 (set-buffer gnus-summary-buffer)
5997 (gnus-summary-refer-article msg-id))
5998 (error "No references around point"))))
6000 (defun gnus-article-show-summary ()
6001 "Reconfigure windows to show summary buffer."
6003 (if (not (gnus-buffer-live-p gnus-summary-buffer))
6004 (error "There is no summary buffer for this article buffer")
6005 (gnus-article-set-globals)
6006 (gnus-configure-windows 'article)
6007 (gnus-summary-goto-subject gnus-current-article)
6008 (gnus-summary-position-point)))
6010 (defun gnus-article-describe-briefly ()
6011 "Describe article mode commands briefly."
6013 (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")))
6015 (defun gnus-article-summary-command ()
6016 "Execute the last keystroke in the summary buffer."
6018 (let ((obuf (current-buffer))
6019 (owin (current-window-configuration))
6021 (switch-to-buffer gnus-article-current-summary 'norecord)
6022 (setq func (lookup-key (current-local-map) (this-command-keys)))
6023 (call-interactively func)
6025 (set-window-configuration owin)
6026 (set-window-point (get-buffer-window (current-buffer)) (point))))
6028 (defun gnus-article-summary-command-nosave ()
6029 "Execute the last keystroke in the summary buffer."
6032 (pop-to-buffer gnus-article-current-summary)
6033 (setq func (lookup-key (current-local-map) (this-command-keys)))
6034 (call-interactively func)))
6036 (defun gnus-article-check-buffer ()
6037 "Beep if not in an article buffer."
6038 (unless (equal major-mode 'gnus-article-mode)
6039 (error "Command invoked outside of a Gnus article buffer")))
6041 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
6042 "Read a summary buffer key sequence and execute it from the article buffer."
6044 (gnus-article-check-buffer)
6046 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
6047 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
6048 "=" "^" "\M-^" "|"))
6054 '("n" "Gn" "p" "Gp"))
6057 (set-buffer gnus-article-current-summary)
6058 (let (gnus-pick-mode)
6059 (push (or key last-command-event) unread-command-events)
6060 (setq keys (if (featurep 'xemacs)
6061 (events-to-keys (read-key-sequence nil))
6062 (read-key-sequence nil)))))
6067 ((eq (aref keys (1- (length keys))) ?\C-h)
6068 (with-current-buffer gnus-article-current-summary
6069 (describe-bindings (substring keys 0 -1))))
6070 ((or (member keys nosaves)
6071 (member keys nosave-but-article)
6072 (member keys nosave-in-article))
6074 (save-window-excursion
6075 (pop-to-buffer gnus-article-current-summary)
6076 ;; We disable the pick minor mode commands.
6077 (let (gnus-pick-mode)
6078 (setq func (lookup-key (current-local-map) keys))))
6082 (unless (member keys nosave-in-article)
6083 (set-buffer gnus-article-current-summary))
6084 (call-interactively func)
6085 (setq new-sum-point (point)))
6086 (when (member keys nosave-but-article)
6087 (pop-to-buffer gnus-article-buffer))))
6089 ;; These commands should restore window configuration.
6090 (let ((obuf (current-buffer))
6091 (owin (current-window-configuration))
6092 win func in-buffer selected new-sum-start new-sum-hscroll err)
6093 (cond (not-restore-window
6094 (pop-to-buffer gnus-article-current-summary)
6095 (setq win (selected-window)))
6096 ((setq win (get-buffer-window gnus-article-current-summary))
6097 (select-window win))
6099 (let ((summary-buffer gnus-article-current-summary))
6100 (gnus-configure-windows 'article)
6101 (unless (setq win (get-buffer-window summary-buffer 'visible))
6102 (let ((gnus-buffer-configuration
6103 '(article ((vertical 1.0
6104 (summary 0.25 point)
6106 (gnus-configure-windows 'article))
6107 (setq win (get-buffer-window summary-buffer 'visible)))
6108 (gnus-select-frame-set-input-focus (window-frame win))
6109 (select-window win))))
6110 (setq in-buffer (current-buffer))
6111 ;; We disable the pick minor mode commands.
6112 (if (and (setq func (let (gnus-pick-mode)
6113 (lookup-key (current-local-map) keys)))
6115 (condition-case code
6117 (call-interactively func)
6123 (when (eq win (selected-window))
6124 (setq new-sum-point (point)
6125 new-sum-start (window-start win)
6126 new-sum-hscroll (window-hscroll win)))
6127 (when (or (eq in-buffer (current-buffer))
6128 (when (eq obuf (current-buffer))
6129 (set-buffer in-buffer)
6131 (setq selected (gnus-summary-select-article))
6133 (unless not-restore-window
6134 (set-window-configuration owin))
6135 (when (and (eq selected 'old)
6137 (set-window-start (get-buffer-window (current-buffer))
6139 (set-window-point (get-buffer-window (current-buffer))
6140 (if (article-goto-body)
6143 (when (and (not not-restore-window)
6145 (with-current-buffer (window-buffer win)
6146 (eq major-mode 'gnus-summary-mode)))
6147 (set-window-point win new-sum-point)
6148 (set-window-start win new-sum-start)
6149 (set-window-hscroll win new-sum-hscroll))))
6150 (set-window-configuration owin)
6152 (signal (car err) (cdr err))
6155 (defun gnus-article-describe-key (key)
6156 "Display documentation of the function invoked by KEY. KEY is a string."
6157 (interactive "kDescribe key: ")
6158 (gnus-article-check-buffer)
6159 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
6161 (set-buffer gnus-article-current-summary)
6162 (let (gnus-pick-mode)
6163 (if (featurep 'xemacs)
6165 (push (elt key 0) unread-command-events)
6166 (setq key (events-to-keys
6167 (read-key-sequence "Describe key: "))))
6168 (setq unread-command-events
6170 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
6171 (string-to-list key)))
6172 (setq key (read-key-sequence "Describe key: "))))
6174 (describe-key key)))
6176 (defun gnus-article-describe-key-briefly (key &optional insert)
6177 "Display documentation of the function invoked by KEY. KEY is a string."
6178 (interactive "kDescribe key: \nP")
6179 (gnus-article-check-buffer)
6180 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
6182 (set-buffer gnus-article-current-summary)
6183 (let (gnus-pick-mode)
6184 (if (featurep 'xemacs)
6186 (push (elt key 0) unread-command-events)
6187 (setq key (events-to-keys
6188 (read-key-sequence "Describe key: "))))
6189 (setq unread-command-events
6191 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
6192 (string-to-list key)))
6193 (setq key (read-key-sequence "Describe key: "))))
6194 (describe-key-briefly key insert))
6195 (describe-key-briefly key insert)))
6197 (defun gnus-article-reply-with-original (&optional wide)
6198 "Start composing a reply mail to the current message.
6199 The text in the region will be yanked. If the region isn't active,
6200 the entire article will be yanked."
6202 (let ((article (cdr gnus-article-current))
6204 (if (not (gnus-region-active-p))
6205 (with-current-buffer gnus-summary-buffer
6206 (gnus-summary-reply (list (list article)) wide))
6207 (setq contents (buffer-substring (point) (mark t)))
6208 ;; Deactivate active regions.
6209 (when (and (boundp 'transient-mark-mode)
6210 transient-mark-mode)
6211 (setq mark-active nil))
6212 (with-current-buffer gnus-summary-buffer
6214 (list (list article contents)) wide)))))
6216 (defun gnus-article-followup-with-original ()
6217 "Compose a followup to the current article.
6218 The text in the region will be yanked. If the region isn't active,
6219 the entire article will be yanked."
6221 (let ((article (cdr gnus-article-current))
6223 (if (not (gnus-region-active-p))
6224 (with-current-buffer gnus-summary-buffer
6225 (gnus-summary-followup (list (list article))))
6226 (setq contents (buffer-substring (point) (mark t)))
6227 ;; Deactivate active regions.
6228 (when (and (boundp 'transient-mark-mode)
6229 transient-mark-mode)
6230 (setq mark-active nil))
6231 (with-current-buffer gnus-summary-buffer
6232 (gnus-summary-followup
6233 (list (list article contents)))))))
6235 (defun gnus-article-hide (&optional arg force)
6236 "Hide all the gruft in the current article.
6237 This means that signatures, cited text and (some) headers will be
6239 If given a prefix, show the hidden text instead."
6240 (interactive (append (gnus-article-hidden-arg) (list 'force)))
6241 (gnus-article-hide-headers arg)
6242 (gnus-article-hide-list-identifiers arg)
6243 (gnus-article-hide-citation-maybe arg force)
6244 (gnus-article-hide-signature arg))
6246 (defun gnus-article-maybe-highlight ()
6247 "Do some article highlighting if article highlighting is requested."
6248 (when (gnus-visual-p 'article-highlight 'highlight)
6249 (gnus-article-highlight-some)))
6251 (defun gnus-check-group-server ()
6252 ;; Make sure the connection to the server is alive.
6253 (unless (gnus-server-opened
6254 (gnus-find-method-for-group gnus-newsgroup-name))
6255 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
6256 (gnus-request-group gnus-newsgroup-name t)))
6259 (autoload 'nneething-get-file-name "nneething"))
6261 (defun gnus-request-article-this-buffer (article group)
6262 "Get an article and insert it into this buffer."
6263 (let (do-update-line sparse-header)
6267 (gnus-kill-all-overlays)
6268 (setq group (or group gnus-newsgroup-name))
6270 ;; Using `gnus-request-article' directly will insert the article into
6271 ;; `nntp-server-buffer' - so we'll save some time by not having to
6272 ;; copy it from the server buffer into the article buffer.
6274 ;; We only request an article by message-id when we do not have the
6275 ;; headers for it, so we'll have to get those.
6276 (when (stringp article)
6277 (gnus-read-header article))
6279 ;; If the article number is negative, that means that this article
6280 ;; doesn't belong in this newsgroup (possibly), so we find its
6281 ;; message-id and request it by id instead of number.
6282 (when (and (numberp article)
6284 (get-buffer gnus-summary-buffer)
6285 (gnus-buffer-exists-p gnus-summary-buffer))
6287 (set-buffer gnus-summary-buffer)
6288 (let ((header (gnus-summary-article-header article)))
6291 ((memq article gnus-newsgroup-sparse)
6292 ;; This is a sparse gap article.
6293 (setq do-update-line article)
6294 (setq article (mail-header-id header))
6295 (setq sparse-header (gnus-read-header article))
6296 (setq gnus-newsgroup-sparse
6297 (delq article gnus-newsgroup-sparse)))
6299 ;; It's a real article.
6300 (setq article (mail-header-id header)))
6302 ;; It is an extracted pseudo-article.
6303 (setq article 'pseudo)
6304 (gnus-request-pseudo-article header))))
6306 (let ((method (gnus-find-method-for-group
6307 gnus-newsgroup-name)))
6308 (when (and (eq (car method) 'nneething)
6310 (let ((dir (nneething-get-file-name
6311 (mail-header-id header))))
6312 (when (and (stringp dir)
6313 (file-directory-p dir))
6314 (setq article 'nneething)
6315 (gnus-group-enter-directory dir))))))))
6318 ;; Refuse to select canceled articles.
6319 ((and (numberp article)
6321 (get-buffer gnus-summary-buffer)
6322 (gnus-buffer-exists-p gnus-summary-buffer)
6323 (eq (cdr (with-current-buffer gnus-summary-buffer
6324 (assq article gnus-newsgroup-reads)))
6325 gnus-canceled-mark))
6327 ;; We first check `gnus-original-article-buffer'.
6328 ((and (get-buffer gnus-original-article-buffer)
6330 (with-current-buffer gnus-original-article-buffer
6331 (and (equal (car gnus-original-article) group)
6332 (eq (cdr gnus-original-article) article))))
6333 (insert-buffer-substring gnus-original-article-buffer)
6335 ;; Check the backlog.
6336 ((and gnus-keep-backlog
6337 (gnus-backlog-request-article group article (current-buffer)))
6339 ;; Check asynchronous pre-fetch.
6340 ((gnus-async-request-fetched-article group article (current-buffer))
6341 (gnus-async-prefetch-next group article gnus-summary-buffer)
6342 (when (and (numberp article) gnus-keep-backlog)
6343 (gnus-backlog-enter-article group article (current-buffer)))
6346 ((and gnus-use-cache
6348 (gnus-cache-request-article article group))
6350 ;; Check the agent cache.
6351 ((gnus-agent-request-article article group)
6353 ;; Get the article and put into the article buffer.
6354 ((or (stringp article)
6356 (let ((gnus-override-method gnus-override-method)
6357 (methods (and (stringp article)
6358 gnus-refer-article-method))
6359 (backend (car (gnus-find-method-for-group
6360 gnus-newsgroup-name)))
6362 (inhibit-read-only t))
6363 (if (or (not (listp methods))
6364 (and (symbolp (car methods))
6365 (assq (car methods) nnoo-definition-alist)))
6366 (setq methods (list methods)))
6367 (when (and (null gnus-override-method)
6369 (setq gnus-override-method (pop methods)))
6371 (when (eq gnus-override-method 'current)
6372 (setq gnus-override-method
6373 (with-current-buffer gnus-summary-buffer
6374 gnus-current-select-method)))
6376 (gnus-kill-all-overlays)
6377 (let ((gnus-newsgroup-name group))
6378 (gnus-check-group-server))
6380 ((gnus-request-article article group (current-buffer))
6381 (when (numberp article)
6382 (gnus-async-prefetch-next group article
6383 gnus-summary-buffer)
6384 (when gnus-keep-backlog
6385 (gnus-backlog-enter-article
6386 group article (current-buffer))))
6387 (setq result 'article))
6389 (setq gnus-override-method (pop methods)))
6390 ((not (string-match "^400 "
6391 (nnheader-get-report backend)))
6392 ;; If we get 400 server disconnect, reconnect and
6393 ;; retry; otherwise, assume the article has expired.
6394 (setq result 'done))))
6395 (and (eq result 'article) 'article)))
6399 ;; Associate this article with the current summary buffer.
6400 (setq gnus-article-current-summary gnus-summary-buffer)
6402 ;; Take the article from the original article buffer
6403 ;; and place it in the buffer it's supposed to be in.
6404 (when (and (get-buffer gnus-article-buffer)
6405 (equal (buffer-name (current-buffer))
6406 (buffer-name (get-buffer gnus-article-buffer))))
6408 (if (get-buffer gnus-original-article-buffer)
6409 (set-buffer gnus-original-article-buffer)
6410 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
6411 (buffer-disable-undo)
6412 (setq major-mode 'gnus-original-article-mode)
6413 (setq buffer-read-only t))
6414 (let ((inhibit-read-only t))
6416 (insert-buffer-substring gnus-article-buffer))
6417 (setq gnus-original-article (cons group article)))
6420 (run-hooks 'gnus-article-decode-hook)
6421 ;; Mark article as decoded or not.
6422 (setq gnus-article-decoded-p gnus-article-decode-hook))
6424 ;; Update sparse articles.
6425 (when (and do-update-line
6426 (or (numberp article)
6428 (let ((buf (current-buffer)))
6429 (set-buffer gnus-summary-buffer)
6430 (gnus-summary-update-article do-update-line sparse-header)
6431 (gnus-summary-goto-subject do-update-line nil t)
6432 (set-window-point (gnus-get-buffer-window (current-buffer) t)
6434 (set-buffer buf))))))
6440 (defcustom gnus-article-edit-mode-hook nil
6441 "Hook run in article edit mode buffers."
6442 :group 'gnus-article-various
6445 (defvar gnus-article-edit-done-function nil)
6447 (defvar gnus-article-edit-mode-map nil)
6449 ;; Should we be using derived.el for this?
6450 (unless gnus-article-edit-mode-map
6451 (setq gnus-article-edit-mode-map (make-keymap))
6452 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
6454 (gnus-define-keys gnus-article-edit-mode-map
6455 "\C-c?" describe-mode
6456 "\C-c\C-c" gnus-article-edit-done
6457 "\C-c\C-k" gnus-article-edit-exit
6458 "\C-c\C-f\C-t" message-goto-to
6459 "\C-c\C-f\C-o" message-goto-from
6460 "\C-c\C-f\C-b" message-goto-bcc
6461 ;;"\C-c\C-f\C-w" message-goto-fcc
6462 "\C-c\C-f\C-c" message-goto-cc
6463 "\C-c\C-f\C-s" message-goto-subject
6464 "\C-c\C-f\C-r" message-goto-reply-to
6465 "\C-c\C-f\C-n" message-goto-newsgroups
6466 "\C-c\C-f\C-d" message-goto-distribution
6467 "\C-c\C-f\C-f" message-goto-followup-to
6468 "\C-c\C-f\C-m" message-goto-mail-followup-to
6469 "\C-c\C-f\C-k" message-goto-keywords
6470 "\C-c\C-f\C-u" message-goto-summary
6471 "\C-c\C-f\C-i" message-insert-or-toggle-importance
6472 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
6473 "\C-c\C-b" message-goto-body
6474 "\C-c\C-i" message-goto-signature
6476 "\C-c\C-t" message-insert-to
6477 "\C-c\C-n" message-insert-newsgroups
6478 "\C-c\C-o" message-sort-headers
6479 "\C-c\C-e" message-elide-region
6480 "\C-c\C-v" message-delete-not-region
6481 "\C-c\C-z" message-kill-to-signature
6482 "\M-\r" message-newline-and-reformat
6483 "\C-c\C-a" mml-attach-file
6484 "\C-a" message-beginning-of-line
6486 "\M-;" comment-region)
6488 (gnus-define-keys (gnus-article-edit-wash-map
6489 "\C-c\C-w" gnus-article-edit-mode-map)
6490 "f" gnus-article-edit-full-stops))
6493 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
6495 ["Fetch To" message-insert-to t]
6496 ["Fetch Newsgroups" message-insert-newsgroups t]
6498 ["To" message-goto-to t]
6499 ["From" message-goto-from t]
6500 ["Subject" message-goto-subject t]
6501 ["Cc" message-goto-cc t]
6502 ["Reply-To" message-goto-reply-to t]
6503 ["Summary" message-goto-summary t]
6504 ["Keywords" message-goto-keywords t]
6505 ["Newsgroups" message-goto-newsgroups t]
6506 ["Followup-To" message-goto-followup-to t]
6507 ["Mail-Followup-To" message-goto-mail-followup-to t]
6508 ["Distribution" message-goto-distribution t]
6509 ["Body" message-goto-body t]
6510 ["Signature" message-goto-signature t]))
6512 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
6513 "Major mode for editing articles.
6514 This is an extended text-mode.
6516 \\{gnus-article-edit-mode-map}"
6517 (make-local-variable 'gnus-article-edit-done-function)
6518 (make-local-variable 'gnus-prev-winconf)
6519 (set (make-local-variable 'font-lock-defaults)
6520 '(message-font-lock-keywords t))
6521 (set (make-local-variable 'mail-header-separator) "")
6522 (set (make-local-variable 'gnus-article-edit-mode) t)
6523 (easy-menu-add message-mode-field-menu message-mode-map)
6525 (setq buffer-read-only nil)
6526 (buffer-enable-undo)
6529 (defun gnus-article-edit (&optional force)
6530 "Edit the current article.
6531 This will have permanent effect only in mail groups.
6532 If FORCE is non-nil, allow editing of articles even in read-only
6535 (when (and (not force)
6536 (gnus-group-read-only-p))
6537 (error "The current newsgroup does not support article editing"))
6538 (gnus-article-date-original)
6539 (gnus-article-edit-article
6541 `(lambda (no-highlight)
6543 (gnus-summary-edit-article-done
6544 ,(or (mail-header-references gnus-current-headers) "")
6545 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
6547 (defun gnus-article-edit-article (start-func exit-func &optional quiet)
6548 "Start editing the contents of the current article buffer."
6549 (let ((winconf (current-window-configuration)))
6550 (set-buffer gnus-article-buffer)
6551 (let ((message-auto-save-directory
6552 ;; Don't associate the article buffer with a draft file.
6554 (gnus-article-edit-mode))
6555 (funcall start-func)
6556 (set-buffer-modified-p nil)
6557 (gnus-configure-windows 'edit-article)
6558 (setq gnus-article-edit-done-function exit-func)
6559 (setq gnus-prev-winconf winconf)
6561 (gnus-message 6 "C-c C-c to end edits"))))
6563 (defun gnus-article-edit-done (&optional arg)
6564 "Update the article edits and exit."
6566 (let ((func gnus-article-edit-done-function)
6567 (buf (current-buffer))
6568 (start (window-start))
6570 (winconf gnus-prev-winconf))
6571 (widen) ;; Widen it in case that users narrowed the buffer.
6574 ;; The cache and backlog have to be flushed somewhat.
6575 (when gnus-keep-backlog
6576 (gnus-backlog-remove-article
6577 (car gnus-article-current) (cdr gnus-article-current)))
6578 ;; Flush original article as well.
6580 (when (get-buffer gnus-original-article-buffer)
6581 (set-buffer gnus-original-article-buffer)
6582 (setq gnus-original-article nil)))
6583 (when gnus-use-cache
6584 (gnus-cache-update-article
6585 (car gnus-article-current) (cdr gnus-article-current)))
6586 ;; We remove all text props from the article buffer.
6587 (kill-all-local-variables)
6588 (set-text-properties (point-min) (point-max) nil)
6590 (set-window-configuration winconf)
6592 (set-window-start (get-buffer-window buf) start)
6593 (set-window-point (get-buffer-window buf) (point)))
6594 (gnus-summary-show-article))
6596 (defun gnus-article-edit-exit ()
6597 "Exit the article editing without updating."
6599 (when (or (not (buffer-modified-p))
6600 (yes-or-no-p "Article modified; kill anyway? "))
6601 (let ((curbuf (current-buffer))
6603 (window-start (window-start)))
6605 (if (gnus-buffer-live-p gnus-original-article-buffer)
6606 (insert-buffer-substring gnus-original-article-buffer))
6607 (let ((winconf gnus-prev-winconf))
6608 (kill-all-local-variables)
6610 (set-window-configuration winconf)
6611 ;; Tippy-toe some to make sure that point remains where it was.
6612 (save-current-buffer
6614 (set-window-start (get-buffer-window (current-buffer)) window-start)
6616 (gnus-summary-show-article)))
6618 (defun gnus-article-edit-full-stops ()
6619 "Interactively repair spacing at end of sentences."
6622 (goto-char (point-min))
6623 (search-forward-regexp "^$" nil t)
6624 (let ((case-fold-search nil))
6625 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
6628 ;;; Article highlights
6631 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6633 ;;; Internal Variables:
6635 (defcustom gnus-button-url-regexp
6637 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|"
6638 "nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)"
6639 "\\(//[-a-z0-9_.]+:[0-9]*\\)?"
6640 (if (string-match "[[:digit:]]" "1") ;; Support POSIX?
6641 (let ((chars "-a-z0-9_=#$@~%&*+\\/[:word:]")
6645 ;; Match paired parentheses, e.g. in Wikipedia URLs:
6646 "[" chars punct "]+" "(" "[" chars punct "]+" "[" chars "]*)" "[" chars "]"
6648 "[" chars punct "]+" "[" chars "]"
6650 (concat ;; XEmacs 21.4 doesn't support POSIX.
6651 "\\([-a-z0-9_=!?#$@~%&*+\\/:;.,]\\|\\w\\)+"
6652 "\\([-a-z0-9_=#$@~%&*+\\/]\\|\\w\\)"))
6654 "Regular expression that matches URLs."
6655 :group 'gnus-article-buttons
6658 (defcustom gnus-button-valid-fqdn-regexp
6659 message-valid-fqdn-regexp
6660 "Regular expression that matches a valid FQDN."
6662 :group 'gnus-article-buttons
6665 ;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
6666 (defcustom gnus-button-valid-localpart-regexp
6667 "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t @]*"
6668 "Regular expression that matches a localpart of mail addresses or MIDs."
6670 :group 'gnus-article-buttons
6673 (defcustom gnus-button-man-handler 'manual-entry
6674 "Function to use for displaying man pages.
6675 The function must take at least one argument with a string naming the
6678 :type '(choice (function-item :tag "Man" manual-entry)
6679 (function-item :tag "Woman" woman)
6680 (function :tag "Other"))
6681 :group 'gnus-article-buttons)
6683 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6684 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6685 If the default site is too slow, try to find a CTAN mirror, see
6686 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6687 the variable `gnus-button-handle-ctan'."
6689 :group 'gnus-article-buttons
6690 :link '(custom-manual "(gnus)Group Parameters")
6691 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6692 (const "http://tug.ctan.org/tex-archive/")
6693 (const "http://www.dante.de/CTAN/")
6694 (string :tag "Other")))
6696 (defcustom gnus-button-ctan-handler 'browse-url
6697 "Function to use for displaying CTAN links.
6698 The function must take one argument, the string naming the URL."
6700 :type '(choice (function-item :tag "Browse Url" browse-url)
6701 (function :tag "Other"))
6702 :group 'gnus-article-buttons)
6704 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6705 "Bogus strings removed from CTAN URLs."
6707 :group 'gnus-article-buttons
6708 :type '(choice (const "^/?tex-archive/\\|/")
6709 (regexp :tag "Other")))
6711 (defcustom gnus-button-ctan-directory-regexp
6713 (list "archive-tools" "biblio" "bibliography" "digests" "documentation"
6714 "dviware" "fonts" "graphics" "help" "indexing" "info" "language"
6715 "languages" "macros" "nonfree" "obsolete" "support" "systems"
6716 "tds" "tools" "usergrps" "web") t)
6717 "Regular expression for ctan directories.
6718 It should match all directories in the top level of `gnus-ctan-url'."
6720 :group 'gnus-article-buttons
6723 (defcustom gnus-button-mid-or-mail-regexp
6724 (concat "\\b\\(<?" gnus-button-valid-localpart-regexp "@"
6725 gnus-button-valid-fqdn-regexp
6727 "Regular expression that matches a message ID or a mail address."
6729 :group 'gnus-article-buttons
6732 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6733 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6734 Strings like this can be either a message ID or a mail address. If it is one
6735 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6736 message ID or a mail address, respectively. If this variable is set to the
6737 symbol `ask', always query the user what do do. If it is a function, this
6738 function will be called with the string as its only argument. The function
6739 must return `mid', `mail', `invalid' or `ask'."
6741 :group 'gnus-article-buttons
6742 :type '(choice (function-item :tag "Heuristic function"
6743 gnus-button-mid-or-mail-heuristic)
6748 (defcustom gnus-button-mid-or-mail-heuristic-alist
6749 '((-10.0 . ".+\\$.+@")
6752 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6753 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6754 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6755 (-1.0 . "^[^a-z]+@")
6757 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6758 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6759 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6760 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6763 (-1.0 . "^[0-9][0-9]")
6765 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6766 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6767 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6768 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6770 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6771 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6774 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6776 ;; compensation for TDMA dated mail addresses:
6777 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6779 (-20.0 . "\\.fsf@") ;; Gnus
6782 (-20.0 . "_-_") ;; Subject change in thread
6784 (-20.0 . "\\.ln@") ;; leafnode
6785 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6786 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6788 ;; (5.0 . "") ;; $local_part_len <= 7
6789 (10.0 . "^[^0-9]+@")
6790 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6791 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6794 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6796 (0.5 . "^[A-Z][a-z]")
6797 (0.5 . "^[A-Z][a-z][a-z]")
6798 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6799 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6800 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6802 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6803 address. The REGEXP is processed with `case-fold-search' set to nil."
6805 :group 'gnus-article-buttons
6806 :type '(repeat (cons (number :tag "Rate")
6807 (regexp :tag "Regexp"))))
6809 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6810 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6811 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6812 address, `ask' if unsure and `invalid' if the string is invalid."
6813 (let ((case-fold-search nil)
6814 (list gnus-button-mid-or-mail-heuristic-alist)
6815 (result 0) rate regexp lpartlen elem)
6817 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6818 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6819 ;; Certain special cases...
6822 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6823 "^[0-9]+\\.[0-9]+@compuserve\\|"
6824 "@public\\.gmane\\.org")
6826 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6827 (setq result 'mail))
6828 (when (string-match "@.*@\\| " mid-or-mail)
6829 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6830 (setq result 'invalid))
6831 ;; Nothing more to do, if result is not a number here...
6832 (when (numberp result)
6834 (setq elem (car list)
6838 (when (string-match regexp mid-or-mail)
6839 (setq result (+ result rate))
6841 9 "`%s' matched `%s', rate `%s', result `%s'."
6842 mid-or-mail regexp rate result)))
6843 (when (<= lpartlen 7)
6844 (setq result (+ result 5.0))
6845 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6846 mid-or-mail result))
6847 (when (>= lpartlen 12)
6848 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6850 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6851 ;; Long local part should contain realname if e-mail address,
6852 ;; too many digits: message-id.
6853 ;; $score -= 5.0 + 0.1 * $local_part_len;
6854 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6855 (setq result (+ result rate))
6857 9 "Many digits in `%s', rate `%s', result `%s'."
6858 mid-or-mail rate result))
6859 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6861 ;; Too few vowels [^aeiouy]{4,}.*\@
6862 (setq result (+ result -5.0))
6864 9 "Few vowels in `%s', rate `%s', result `%s'."
6865 mid-or-mail -5.0 result))
6867 (setq result (+ result 5.0))
6869 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6870 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6871 ;; Maybe we should make this a customizable alist: (condition . 'result)
6873 ((symbolp result) result)
6874 ;; Now convert number into proper results:
6875 ((< result -10.0) 'mid)
6876 ((> result 10.0) 'mail)
6879 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6880 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6881 (url-mid (concat "news" ":" mid-or-mail))
6882 (url-mailto (concat "mailto" ":" mid-or-mail)))
6883 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6884 (when (fboundp pref)
6886 ;; get rid of surrounding angles...
6888 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6889 (if (or (eq 'mid guessed) (eq 'mail guessed))
6893 (save-window-excursion
6894 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6897 (cond ((eq pref 'mid)
6898 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6899 (gnus-button-handle-news url-mid))
6901 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6902 (gnus-url-mailto url-mailto))
6903 (t (gnus-message 3 "Invalid string.")))))
6905 (defun gnus-button-handle-custom (fun arg)
6906 "Call function FUN on argument ARG.
6907 Both FUN and ARG are supposed to be strings. ARG will be passed
6908 as a symbol to FUN."
6909 (funcall (intern fun)
6910 (if (string-match "^customize-apropos" fun)
6914 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6916 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6919 (defun gnus-button-handle-describe-function (url)
6920 "Call `describe-function' when pushing the corresponding URL button."
6923 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6925 (defun gnus-button-handle-describe-variable (url)
6926 "Call `describe-variable' when pushing the corresponding URL button."
6929 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6931 (defun gnus-button-handle-symbol (url)
6932 "Display help on variable or function.
6933 Calls `describe-variable' or `describe-function'."
6934 (let ((sym (intern url)))
6936 ((fboundp sym) (describe-function sym))
6937 ((boundp sym) (describe-variable sym))
6938 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6940 (defun gnus-button-handle-describe-key (url)
6941 "Call `describe-key' when pushing the corresponding URL button."
6943 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6944 (keys (ignore-errors (eval `(kbd ,key-string)))))
6947 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6949 (defun gnus-button-handle-apropos (url)
6950 "Call `apropos' when pushing the corresponding URL button."
6951 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6953 (defun gnus-button-handle-apropos-command (url)
6954 "Call `apropos' when pushing the corresponding URL button."
6956 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6958 (defun gnus-button-handle-apropos-variable (url)
6959 "Call `apropos' when pushing the corresponding URL button."
6961 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6962 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6964 (defun gnus-button-handle-apropos-documentation (url)
6965 "Call `apropos' when pushing the corresponding URL button."
6967 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6968 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6970 (defun gnus-button-handle-library (url)
6971 "Call `locate-library' when pushing the corresponding URL button."
6972 (gnus-message 9 "url=`%s'" url)
6973 (let* ((lib (locate-library url))
6974 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6976 (gnus-message 1 "Cannot locale library `%s'." url)
6977 (find-file-read-only file))))
6979 (defun gnus-button-handle-ctan (url)
6980 "Call `browse-url' when pushing a CTAN URL button."
6982 gnus-button-ctan-handler
6985 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6987 (defcustom gnus-button-tex-level 5
6988 "*Integer that says how many TeX-related buttons Gnus will show.
6989 The higher the number, the more buttons will appear and the more false
6990 positives are possible. Note that you can set this variable local to
6991 specific groups. Setting it higher in TeX groups is probably a good idea.
6992 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6993 how to set variables in specific groups."
6995 :group 'gnus-article-buttons
6996 :link '(custom-manual "(gnus)Group Parameters")
6999 (defcustom gnus-button-man-level 5
7000 "*Integer that says how many man-related buttons Gnus will show.
7001 The higher the number, the more buttons will appear and the more false
7002 positives are possible. Note that you can set this variable local to
7003 specific groups. Setting it higher in Unix groups is probably a good idea.
7004 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
7005 how to set variables in specific groups."
7007 :group 'gnus-article-buttons
7008 :link '(custom-manual "(gnus)Group Parameters")
7011 (defcustom gnus-button-emacs-level 5
7012 "*Integer that says how many emacs-related buttons Gnus will show.
7013 The higher the number, the more buttons will appear and the more false
7014 positives are possible. Note that you can set this variable local to
7015 specific groups. Setting it higher in Emacs or Gnus related groups is
7016 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
7017 `gnus-parameters' on how to set variables in specific groups."
7019 :group 'gnus-article-buttons
7020 :link '(custom-manual "(gnus)Group Parameters")
7023 (defcustom gnus-button-message-level 5
7024 "*Integer that says how many buttons for news or mail messages will appear.
7025 The higher the number, the more buttons will appear and the more false
7026 positives are possible."
7027 ;; mail addresses, MIDs, URLs for news, ...
7029 :group 'gnus-article-buttons
7032 (defcustom gnus-button-browse-level 5
7033 "*Integer that says how many buttons for browsing will appear.
7034 The higher the number, the more buttons will appear and the more false
7035 positives are possible."
7036 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
7038 :group 'gnus-article-buttons
7041 (defcustom gnus-button-alist
7042 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
7043 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
7044 ((concat "\\b\\(nntp\\|news\\):\\("
7045 gnus-button-valid-localpart-regexp "@[a-z0-9.-]+[a-z]\\)")
7046 0 t gnus-button-handle-news 2)
7047 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
7048 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
7049 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
7050 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
7051 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
7052 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
7053 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
7054 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
7055 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
7056 ("\\b\\(mid\\|message-id\\):? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
7057 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
7058 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
7059 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
7060 ;; RFC 2368 (The mailto URL scheme)
7061 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
7062 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7063 ("\\bmailto:\\([^ \n\t]+\\)"
7064 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7066 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
7067 gnus-button-ctan-directory-regexp
7068 "[^][>)!;:,'\n\t ]+\\)")
7069 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
7070 ((concat "\\btex-archive/\\("
7071 gnus-button-ctan-directory-regexp
7072 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
7073 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
7076 gnus-button-ctan-directory-regexp
7077 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
7078 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
7079 ;; This is info (home-grown style) <info://foo/bar+baz>
7080 ("\\binfo://\\([^'\">\n\t ]+\\)"
7081 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
7082 ;; Info GNOME style <info:foo#bar_baz>
7083 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
7084 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
7085 ;; Info KDE style <info:(foo)bar baz>
7086 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
7087 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
7088 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
7089 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
7090 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
7091 ;; Info links like `C-h i d m CC Mode RET'
7092 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
7094 ("M-x[ \t\n]\\(customize-[^ ]+\\)[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
7095 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1 2)
7096 ;; Emacs help commands
7097 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
7098 ;; regexp doesn't match arguments containing ` '.
7099 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
7100 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
7101 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
7102 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
7103 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
7104 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
7105 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
7106 ;; The following entries may lead to many false positives so don't enable
7107 ;; them by default (use a high button level).
7108 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
7109 ;; Exclude [.?] for URLs in gmane.emacs.cvs
7110 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
7111 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
7112 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
7113 ("`\\([a-z][a-z0-9]+-[a-z0-9]+-[-a-z0-9]*[a-z]\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
7114 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
7115 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
7116 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
7117 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
7118 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
7119 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
7120 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
7121 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
7122 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
7123 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
7124 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
7125 ("`\\(\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
7126 ;; Unlike the other regexps we really have to require quoting
7127 ;; here to determine where it ends.
7128 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
7129 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
7130 ("<URL: *\\([^<>]*\\)>"
7131 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
7132 ;; RFC 2396 (2.4.3., delims) ...
7133 ("\"URL: *\\([^\"]*\\)\""
7134 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
7135 ;; RFC 2396 (2.4.3., delims) ...
7136 ("\"URL: *\\([^\"]*\\)\""
7137 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
7139 (gnus-button-url-regexp
7140 0 (>= gnus-button-browse-level 0) browse-url 0)
7142 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
7143 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
7144 gnus-button-handle-man 1)
7145 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
7146 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
7147 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
7148 gnus-button-handle-man 1)
7149 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
7150 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
7151 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
7152 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
7153 ;; Recognizing patches to .el files. This is somewhat obscure,
7154 ;; but considering the percentage of Gnus users who hack Emacs
7156 ("^--- \\([^ .]+\\.el\\).*\n.*\n@@ -?\\([0-9]+\\)" 1
7157 (>= gnus-button-message-level 4) gnus-button-patch 1 2)
7158 ("^\\*\\*\\* \\([^ .]+\\.el\\).*\n.*\n\\*+\n\\*\\*\\* \\([0-9]+\\)" 1
7159 (>= gnus-button-message-level 4) gnus-button-patch 1 2)
7160 ;; MID or mail: To avoid too many false positives we don't try to catch
7161 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
7162 ;; at least one dot. TLD must contain two or three chars or be a know TLD
7163 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
7164 ;; so that non-ambiguous entries (see above) match first.
7165 (gnus-button-mid-or-mail-regexp
7166 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
7167 "*Alist of regexps matching buttons in article bodies.
7169 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
7170 REGEXP: is the string (case insensitive) matching text around the button (can
7171 also be Lisp expression evaluating to a string),
7172 BUTTON: is the number of the regexp grouping actually matching the button,
7173 FORM: is a Lisp expression which must eval to true for the button to
7175 CALLBACK: is the function to call when the user push this button, and each
7176 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
7178 CALLBACK can also be a variable, in that case the value of that
7179 variable it the real callback function."
7180 :group 'gnus-article-buttons
7181 :type '(repeat (list (choice regexp variable sexp)
7182 (integer :tag "Button")
7184 (function :tag "Callback")
7187 (integer :tag "Regexp group")))))
7189 (defcustom gnus-header-button-alist
7190 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
7191 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
7192 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
7193 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
7194 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
7195 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
7196 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
7197 0 (>= gnus-button-browse-level 0) browse-url 0)
7198 ("^Subject:" gnus-button-url-regexp
7199 0 (>= gnus-button-browse-level 0) browse-url 0)
7200 ("^[^:]+:" gnus-button-url-regexp
7201 0 (>= gnus-button-browse-level 0) browse-url 0)
7202 ("^OpenPGP:.*url=" gnus-button-url-regexp
7203 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
7204 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
7205 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
7206 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
7207 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
7208 "*Alist of headers and regexps to match buttons in article heads.
7210 This alist is very similar to `gnus-button-alist', except that each
7211 alist has an additional HEADER element first in each entry:
7213 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
7215 HEADER is a regexp to match a header. For a fuller explanation, see
7216 `gnus-button-alist'."
7217 :group 'gnus-article-buttons
7218 :group 'gnus-article-headers
7219 :type '(repeat (list (regexp :tag "Header")
7220 (choice regexp variable)
7221 (integer :tag "Button")
7223 (function :tag "Callback")
7226 (integer :tag "Regexp group")))))
7230 (defun gnus-article-push-button (event)
7231 "Check text under the mouse pointer for a callback function.
7232 If the text under the mouse pointer has a `gnus-callback' property,
7233 call it with the value of the `gnus-data' text property."
7235 (set-buffer (window-buffer (posn-window (event-start event))))
7236 (let* ((pos (posn-point (event-start event)))
7237 (data (get-text-property pos 'gnus-data))
7238 (fun (get-text-property pos 'gnus-callback)))
7241 (funcall fun data))))
7243 (defun gnus-article-press-button ()
7244 "Check text at point for a callback function.
7245 If the text at point has a `gnus-callback' property,
7246 call it with the value of the `gnus-data' text property."
7248 (let ((data (get-text-property (point) 'gnus-data))
7249 (fun (get-text-property (point) 'gnus-callback)))
7251 (funcall fun data))))
7253 (defun gnus-article-highlight (&optional force)
7254 "Highlight current article.
7255 This function calls `gnus-article-highlight-headers',
7256 `gnus-article-highlight-citation',
7257 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7258 do the highlighting. See the documentation for those functions."
7259 (interactive (list 'force))
7260 (gnus-article-highlight-headers)
7261 (gnus-article-highlight-citation force)
7262 (gnus-article-highlight-signature)
7263 (gnus-article-add-buttons force)
7264 (gnus-article-add-buttons-to-head))
7266 (defun gnus-article-highlight-some (&optional force)
7267 "Highlight current article.
7268 This function calls `gnus-article-highlight-headers',
7269 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7270 do the highlighting. See the documentation for those functions."
7271 (interactive (list 'force))
7272 (gnus-article-highlight-headers)
7273 (gnus-article-highlight-signature)
7274 (gnus-article-add-buttons))
7276 (defun gnus-article-highlight-headers ()
7277 "Highlight article headers as specified by `gnus-header-face-alist'."
7279 (gnus-with-article-headers
7280 (let (regexp header-face field-face from hpoints fpoints)
7281 (dolist (entry gnus-header-face-alist)
7282 (goto-char (point-min))
7283 (setq regexp (concat "^\\("
7284 (if (string-equal "" (nth 0 entry))
7288 header-face (nth 1 entry)
7289 field-face (nth 2 entry))
7290 (while (and (re-search-forward regexp nil t)
7294 (unless (search-forward ":" nil t)
7296 (when (and header-face
7297 (not (memq (point) hpoints)))
7298 (push (point) hpoints)
7299 (gnus-put-text-property from (point) 'face header-face))
7300 (when (and field-face
7301 (not (memq (setq from (point)) fpoints)))
7303 (if (re-search-forward "^[^ \t]" nil t)
7305 (goto-char (point-max)))
7306 (gnus-put-text-property from (point) 'face field-face)))))))
7308 (defun gnus-article-highlight-signature ()
7309 "Highlight the signature in an article.
7310 It does this by highlighting everything after
7311 `gnus-signature-separator' using the face `gnus-signature'."
7313 (gnus-with-article-buffer
7314 (let ((inhibit-point-motion-hooks t))
7316 (when (and gnus-signature-face
7317 (gnus-article-narrow-to-signature))
7318 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
7319 'face gnus-signature-face)
7321 (gnus-article-search-signature)
7322 (let ((start (match-beginning 0))
7323 (end (set-marker (make-marker) (1+ (match-end 0)))))
7324 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
7327 (defun gnus-button-in-region-p (b e prop)
7328 "Say whether PROP exists in the region."
7329 (text-property-not-all b e prop nil))
7331 (defun gnus-article-add-buttons (&optional force)
7332 "Find external references in the article and make buttons of them.
7333 \"External references\" are things like Message-IDs and URLs, as
7334 specified by `gnus-button-alist'."
7335 (interactive (list 'force))
7336 (gnus-with-article-buffer
7337 (let ((inhibit-point-motion-hooks t)
7338 (case-fold-search t)
7339 (alist gnus-button-alist)
7341 ;; Remove all old markers.
7342 (let (marker entry new-list)
7343 (while (setq marker (pop gnus-button-marker-list))
7344 (if (or (< marker (point-min)) (>= marker (point-max)))
7345 (push marker new-list)
7347 (when (setq entry (gnus-button-entry))
7348 (put-text-property (match-beginning (nth 1 entry))
7349 (match-end (nth 1 entry))
7350 'gnus-callback nil))
7351 (set-marker marker nil)))
7352 (setq gnus-button-marker-list new-list))
7353 ;; We skip the headers.
7356 (while (setq entry (pop alist))
7357 (setq regexp (eval (car entry)))
7359 (while (re-search-forward regexp nil t)
7360 (let* ((start (and entry (match-beginning (nth 1 entry))))
7361 (end (and entry (match-end (nth 1 entry))))
7362 (from (match-beginning 0)))
7363 (when (and (or (eq t (nth 2 entry))
7364 (eval (nth 2 entry)))
7365 (not (gnus-button-in-region-p
7366 start end 'gnus-callback)))
7367 ;; That optional form returned non-nil, so we add the
7369 (gnus-article-add-button
7370 start end 'gnus-button-push
7371 (car (push (set-marker (make-marker) from)
7372 gnus-button-marker-list))))))))))
7374 ;; Add buttons to the head of an article.
7375 (defun gnus-article-add-buttons-to-head ()
7376 "Add buttons to the head of the article."
7378 (gnus-with-article-headers
7380 (dolist (entry gnus-header-button-alist)
7381 ;; Each alist entry.
7382 (goto-char (point-min))
7383 (while (re-search-forward (car entry) nil t)
7384 ;; Each header matching the entry.
7385 (setq beg (match-beginning 0))
7386 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
7387 (match-beginning 0))
7390 (while (re-search-forward (eval (nth 1 entry)) end t)
7391 ;; Each match within a header.
7392 (let* ((entry (cdr entry))
7393 (start (match-beginning (nth 1 entry)))
7394 (end (match-end (nth 1 entry)))
7395 (form (nth 2 entry)))
7396 (goto-char (match-end 0))
7398 (gnus-article-add-button
7399 start end (nth 3 entry)
7400 (buffer-substring (match-beginning (nth 4 entry))
7401 (match-end (nth 4 entry)))))))
7402 (goto-char end))))))
7404 ;;; External functions:
7406 (defun gnus-article-add-button (from to fun &optional data)
7407 "Create a button between FROM and TO with callback FUN and data DATA."
7408 (when gnus-article-button-face
7409 (gnus-overlay-put (gnus-make-overlay from to)
7410 'face gnus-article-button-face))
7411 (gnus-add-text-properties
7413 (nconc (and gnus-article-mouse-face
7414 (list gnus-mouse-face-prop gnus-article-mouse-face))
7415 (list 'gnus-callback fun)
7416 (and data (list 'gnus-data data))))
7417 (widget-convert-button 'link from to :action 'gnus-widget-press-button
7418 :button-keymap gnus-widget-button-keymap))
7420 ;;; Internal functions:
7422 (defun gnus-article-set-globals ()
7423 (with-current-buffer gnus-summary-buffer
7424 (gnus-set-global-variables)))
7426 (defun gnus-signature-toggle (end)
7427 (gnus-with-article-buffer
7428 (let ((inhibit-point-motion-hooks t))
7429 (if (text-property-any end (point-max) 'article-type 'signature)
7431 (gnus-delete-wash-type 'signature)
7432 (gnus-remove-text-properties-when
7433 'article-type 'signature end (point-max)
7434 (cons 'article-type (cons 'signature
7435 gnus-hidden-properties))))
7436 (gnus-add-wash-type 'signature)
7437 (gnus-add-text-properties-when
7438 'article-type nil end (point-max)
7439 (cons 'article-type (cons 'signature
7440 gnus-hidden-properties)))))
7441 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
7442 (gnus-set-mode-line 'article))))
7444 (defun gnus-button-entry ()
7445 ;; Return the first entry in `gnus-button-alist' matching this place.
7446 (let ((alist gnus-button-alist)
7449 (setq entry (pop alist))
7450 (if (looking-at (eval (car entry)))
7455 (defun gnus-button-push (marker)
7456 ;; Push button starting at MARKER.
7459 (let* ((entry (gnus-button-entry))
7460 (inhibit-point-motion-hooks t)
7462 (args (mapcar (lambda (group)
7463 (let ((string (match-string group)))
7464 (set-text-properties
7465 0 (length string) nil string)
7472 (fboundp (symbol-value fun)))
7473 (apply (symbol-value fun) args))
7475 (gnus-message 1 "You must define `%S' to use this button"
7476 (cons fun args)))))))
7478 (defun gnus-parse-news-url (url)
7479 (let (scheme server port group message-id articles)
7482 (goto-char (point-min))
7483 (when (looking-at "\\([A-Za-z]+\\):")
7484 (setq scheme (match-string 1))
7485 (goto-char (match-end 0)))
7486 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
7487 (setq server (match-string 1))
7488 (setq port (if (stringp (match-string 3))
7489 (string-to-number (match-string 3))
7491 (goto-char (match-end 0)))
7494 ((looking-at "\\(.*@.*\\)")
7495 (setq message-id (match-string 1)))
7496 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7497 (setq group (match-string 1)
7498 articles (split-string (match-string 2) "-")))
7499 ((looking-at "\\([^/]+\\)/?")
7500 (setq group (match-string 1)))
7502 (error "Unknown news URL syntax"))))
7503 (list scheme server port group message-id articles)))
7505 (defun gnus-button-handle-news (url)
7507 (destructuring-bind (scheme server port group message-id articles)
7508 (gnus-parse-news-url url)
7512 (set-buffer gnus-summary-buffer)
7514 (let ((gnus-refer-article-method
7515 (nconc (list (list 'nntp server))
7516 gnus-refer-article-method))
7517 (nntp-port-number (or port "nntp")))
7518 (gnus-message 7 "Fetching %s with %s"
7519 message-id gnus-refer-article-method)
7520 (gnus-summary-refer-article message-id))
7521 (gnus-summary-refer-article message-id))))
7523 (gnus-button-fetch-group url)))))
7525 (defun gnus-button-patch (library line)
7526 "Visit an Emacs Lisp library LIBRARY on line LINE."
7528 (let ((file (locate-library (file-name-nondirectory library))))
7530 (error "Couldn't find library %s" library))
7532 (goto-line (string-to-number line))))
7534 (defun gnus-button-handle-man (url)
7536 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7537 (when (eq gnus-button-man-handler 'woman)
7538 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
7539 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7540 (funcall gnus-button-man-handler url))
7542 (defun gnus-button-handle-info-url (url)
7543 "Fetch an info URL."
7544 (setq url (mm-subst-char-in-string ?+ ?\ url))
7546 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
7547 (gnus-info-find-node
7548 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
7550 ")" (gnus-url-unhex-string (match-string 2 url)))))
7551 ((string-match "([^)\"]+)[^\"]+" url)
7553 (gnus-replace-in-string
7554 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
7555 (gnus-info-find-node url))
7556 (t (error "Can't parse %s" url))))
7558 (defun gnus-button-handle-info-url-gnome (url)
7559 "Fetch GNOME style info URL."
7560 (setq url (mm-subst-char-in-string ?_ ?\ url))
7561 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
7562 (gnus-info-find-node
7564 (gnus-url-unhex-string
7565 (match-string 1 url))
7567 (or (gnus-url-unhex-string
7568 (match-string 2 url))
7570 (error "Can't parse %s" url)))
7572 (defun gnus-button-handle-info-url-kde (url)
7573 "Fetch KDE style info URL."
7574 (gnus-info-find-node (gnus-url-unhex-string url)))
7576 (defun gnus-button-handle-info-keystrokes (url)
7577 "Call `info' when pushing the corresponding URL button."
7578 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
7583 (defun gnus-button-openpgp (url)
7584 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
7586 (mm-url-insert-file-contents-external url)
7587 (pgg-snarf-keys-region (point-min) (point-max))
7588 (pgg-display-output-buffer nil nil nil)))
7590 (defun gnus-button-message-id (message-id)
7592 (with-current-buffer gnus-summary-buffer
7593 (gnus-summary-refer-article message-id)))
7595 (defun gnus-button-fetch-group (address &rest ignore)
7596 "Fetch GROUP specified by ADDRESS."
7597 (when (string-match "\\`\\(nntp\\|news\\):\\(//\\)?\\(.*\\)\\'"
7599 ;; Allow to use `gnus-button-fetch-group' in `browse-url-browser-function'
7600 ;; for nntp:// and news://
7601 (setq address (match-string 3 address)))
7602 (if (not (string-match "[:/]" address))
7603 ;; This is just a simple group url.
7604 (gnus-group-read-ephemeral-group address gnus-select-method)
7607 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
7609 (error "Can't parse %s" address)
7610 (gnus-group-read-ephemeral-group
7611 (match-string 4 address)
7612 `(nntp ,(match-string 1 address)
7613 (nntp-address ,(match-string 1 address))
7614 (nntp-port-number ,(if (match-end 3)
7615 (match-string 3 address)
7618 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
7620 (defun gnus-url-parse-query-string (query &optional downcase)
7621 (let (retval pairs cur key val)
7622 (setq pairs (split-string query "&"))
7624 (setq cur (car pairs)
7626 (if (not (string-match "=" cur))
7628 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
7629 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
7631 (setq key (downcase key)))
7632 (setq cur (assoc key retval))
7634 (setcdr cur (cons val (cdr cur)))
7635 (setq retval (cons (list key val) retval)))))
7638 (defun gnus-url-mailto (url)
7639 ;; Send mail to someone
7640 (when (string-match "mailto:/*\\(.*\\)" url)
7641 (setq url (substring url (match-beginning 1) nil)))
7642 (let (to args subject func)
7643 (setq args (gnus-url-parse-query-string
7644 (if (string-match "^\\?" url)
7646 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
7647 (concat "to=" (match-string 1 url) "&"
7648 (match-string 2 url))
7649 (concat "to=" url)))
7651 subject (cdr-safe (assoc "subject" args)))
7654 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
7657 (message-position-on-field (caar args)))
7658 (insert (gnus-replace-in-string
7659 (mapconcat 'identity (reverse (cdar args)) ", ")
7661 (setq args (cdr args)))
7664 (message-goto-subject))))
7666 (defun gnus-button-embedded-url (address)
7667 "Activate ADDRESS with `browse-url'."
7668 (browse-url (gnus-strip-whitespace address)))
7670 ;;; Next/prev buttons in the article buffer.
7672 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
7673 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
7675 (defvar gnus-prev-page-map
7676 (let ((map (make-sparse-keymap)))
7677 (define-key map gnus-mouse-2 'gnus-button-prev-page)
7678 (define-key map "\r" 'gnus-button-prev-page)
7681 (defvar gnus-next-page-map
7682 (let ((map (make-sparse-keymap)))
7683 (unless (>= emacs-major-version 21)
7684 ;; XEmacs doesn't care.
7685 (set-keymap-parent map gnus-article-mode-map))
7686 (define-key map gnus-mouse-2 'gnus-button-next-page)
7687 (define-key map "\r" 'gnus-button-next-page)
7690 (defun gnus-insert-prev-page-button ()
7692 (inhibit-read-only t))
7694 gnus-prev-page-line-format nil
7695 `(keymap ,gnus-prev-page-map
7697 gnus-callback gnus-article-button-prev-page
7698 article-type annotation))
7700 ;; Exclude a newline.
7703 (when gnus-article-button-face
7704 (gnus-overlay-put (gnus-make-overlay b e)
7705 'face gnus-article-button-face))
7706 (widget-convert-button
7708 :action 'gnus-button-prev-page
7709 :button-keymap gnus-prev-page-map)))
7711 (defun gnus-button-next-page (&optional args more-args)
7712 "Go to the next page."
7714 (let ((win (selected-window)))
7715 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7716 (gnus-article-next-page)
7717 (select-window win)))
7719 (defun gnus-button-prev-page (&optional args more-args)
7720 "Go to the prev page."
7722 (let ((win (selected-window)))
7723 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7724 (gnus-article-prev-page)
7725 (select-window win)))
7727 (defun gnus-insert-next-page-button ()
7729 (inhibit-read-only t))
7730 (gnus-eval-format gnus-next-page-line-format nil
7731 `(keymap ,gnus-next-page-map
7733 gnus-callback gnus-article-button-next-page
7734 article-type annotation))
7736 ;; Exclude a newline.
7739 (when gnus-article-button-face
7740 (gnus-overlay-put (gnus-make-overlay b e)
7741 'face gnus-article-button-face))
7742 (widget-convert-button
7744 :action 'gnus-button-next-page
7745 :button-keymap gnus-next-page-map)))
7747 (defun gnus-article-button-next-page (arg)
7748 "Go to the next page."
7750 (let ((win (selected-window)))
7751 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7752 (gnus-article-next-page)
7753 (select-window win)))
7755 (defun gnus-article-button-prev-page (arg)
7756 "Go to the prev page."
7758 (let ((win (selected-window)))
7759 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7760 (gnus-article-prev-page)
7761 (select-window win)))
7763 (defvar gnus-decode-header-methods
7764 '(mail-decode-encoded-word-region)
7765 "List of methods used to decode headers.
7767 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7768 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
7769 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
7770 whose names match REGEXP.
7773 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7774 mail-decode-encoded-word-region
7775 (\"chinese\" . rfc1843-decode-region))
7778 (defvar gnus-decode-header-methods-cache nil)
7780 (defun gnus-multi-decode-header (start end)
7781 "Apply the functions from `gnus-encoded-word-methods' that match."
7782 (unless (and gnus-decode-header-methods-cache
7783 (eq gnus-newsgroup-name
7784 (car gnus-decode-header-methods-cache)))
7785 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7788 (nconc gnus-decode-header-methods-cache (list x))
7789 (if (and gnus-newsgroup-name
7790 (string-match (car x) gnus-newsgroup-name))
7791 (nconc gnus-decode-header-methods-cache
7793 gnus-decode-header-methods))
7794 (let ((xlist gnus-decode-header-methods-cache))
7797 (narrow-to-region start end)
7799 (funcall (pop xlist) (point-min) (point-max))))))
7802 ;;; Treatment top-level handling.
7805 (defun gnus-treat-article (condition &optional part-number total-parts type)
7806 (let ((length (- (point-max) (point-min)))
7807 (alist gnus-treatment-function-alist)
7808 (article-goto-body-goes-to-point-min-p t)
7812 (let ((list gnus-article-treat-types))
7814 (when (string-match (pop list) type)
7815 (throw 'found t)))))))
7816 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7818 (gnus-run-hooks 'gnus-part-display-hook)
7819 (dolist (elem alist)
7822 (when (gnus-buffer-live-p gnus-summary-buffer)
7823 (set-buffer gnus-summary-buffer))
7824 (symbol-value (car elem))))
7825 (when (and (or (consp val)
7827 (gnus-treat-predicate val)
7828 (or (not (get (car elem) 'highlight))
7831 (funcall (cadr elem)))))))
7833 ;; Dynamic variables.
7835 (defvar part-number)
7836 (defvar total-parts)
7841 (defun gnus-treat-predicate (val)
7848 (stringp (car val)))
7849 (apply 'gnus-or (mapcar `(lambda (s)
7850 (string-match s ,(or gnus-newsgroup-name "")))
7853 (let ((pred (pop val)))
7856 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7858 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7860 (not (gnus-treat-predicate (car val))))
7862 (equal (car val) type))
7864 (error "%S is not a valid predicate" pred)))))
7872 (eq part-number total-parts))
7876 (error "%S is not a valid value" val))))
7878 (defun gnus-article-encrypt-body (protocol &optional n)
7879 "Encrypt the article body."
7882 (or gnus-article-encrypt-protocol
7883 (completing-read "Encrypt protocol: "
7884 gnus-article-encrypt-protocol-alist
7886 current-prefix-arg))
7887 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7889 (error "Can't find the encrypt protocol %s" protocol))
7890 (if (member gnus-newsgroup-name '("nndraft:delayed"
7893 (error "Can't encrypt the article in group %s"
7894 gnus-newsgroup-name))
7895 (gnus-summary-iterate n
7897 (set-buffer gnus-summary-buffer)
7898 (let ((mail-parse-charset gnus-newsgroup-charset)
7899 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7900 (summary-buffer gnus-summary-buffer)
7902 (gnus-set-global-variables)
7903 (when (gnus-group-read-only-p)
7904 (error "The current newsgroup does not support article encrypt"))
7905 (gnus-summary-show-article t)
7907 (or (mail-header-references gnus-current-headers) ""))
7908 (set-buffer gnus-article-buffer)
7909 (let* ((inhibit-read-only t)
7911 (mapcar (lambda (field)
7912 (and (save-restriction
7913 (message-narrow-to-head)
7914 (goto-char (point-min))
7915 (search-forward field nil t))
7917 (message-narrow-to-field)
7919 (delete-region (point-min) (point-max))
7921 '("Content-Type:" "Content-Transfer-Encoding:"
7922 "Content-Disposition:"))))
7923 (message-narrow-to-head)
7924 (message-remove-header "MIME-Version")
7925 (goto-char (point-max))
7926 (setq point (point))
7927 (insert (apply 'concat headers))
7929 (narrow-to-region point (point-max))
7930 (let ((message-options message-options))
7931 (message-options-set 'message-sender user-mail-address)
7932 (message-options-set 'message-recipients user-mail-address)
7933 (message-options-set 'message-sign-encrypt 'not)
7935 (goto-char (point-min))
7936 (insert "MIME-Version: 1.0\n")
7938 (gnus-summary-edit-article-done
7939 references nil summary-buffer t))
7940 (when gnus-keep-backlog
7941 (gnus-backlog-remove-article
7942 (car gnus-article-current) (cdr gnus-article-current)))
7944 (when (get-buffer gnus-original-article-buffer)
7945 (set-buffer gnus-original-article-buffer)
7946 (setq gnus-original-article nil)))
7947 (when gnus-use-cache
7948 (gnus-cache-update-article
7949 (car gnus-article-current) (cdr gnus-article-current))))))))
7951 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7952 "The following specs can be used:
7953 %t The security MIME type
7956 %D Details if button is pressed")
7958 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7959 "The following specs can be used:
7960 %t The security MIME type
7963 %D Details if button is pressed")
7965 (defvar gnus-mime-security-button-line-format-alist
7966 '((?t gnus-tmp-type ?s)
7967 (?i gnus-tmp-info ?s)
7968 (?d gnus-tmp-details ?s)
7969 (?D gnus-tmp-pressed-details ?s)))
7971 (defvar gnus-mime-security-button-commands
7972 '((gnus-article-press-button "\r" "Show Detail")
7976 (gnus-mime-security-save-part "o" "Save...")
7985 (gnus-mime-security-pipe-part "|" "Pipe To Command...")
7988 (defvar gnus-mime-security-button-map
7989 (let ((map (make-sparse-keymap)))
7990 (define-key map gnus-mouse-2 'gnus-article-push-button)
7991 (define-key map gnus-down-mouse-3 'gnus-mime-security-button-menu)
7992 (dolist (c gnus-mime-security-button-commands)
7993 (define-key map (cadr c) (car c)))
7997 gnus-mime-security-button-menu gnus-mime-security-button-map
7998 "Security button menu."
8002 (unless (eq (car c) 'undefined)
8003 (vector (caddr c) (car c) :active t)))
8004 gnus-mime-security-button-commands))))
8006 (defun gnus-mime-security-button-menu (event prefix)
8007 "Construct a context-sensitive menu of security commands."
8008 (interactive "e\nP")
8009 (save-window-excursion
8010 (let ((pos (event-start event)))
8011 (select-window (posn-window pos))
8012 (goto-char (posn-point pos))
8013 (gnus-article-check-buffer)
8014 (popup-menu gnus-mime-security-button-menu nil prefix))))
8016 (defvar gnus-mime-security-details-buffer nil)
8018 (defvar gnus-mime-security-button-pressed nil)
8020 (defvar gnus-mime-security-show-details-inline t
8021 "If non-nil, show details in the article buffer.")
8023 (defun gnus-mime-security-verify-or-decrypt (handle)
8024 (mm-remove-parts (cdr handle))
8025 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
8026 point (inhibit-read-only t))
8028 (goto-char (car region)))
8029 (setq point (point))
8030 (with-current-buffer (mm-handle-multipart-original-buffer handle)
8031 (let* ((mm-verify-option 'known)
8032 (mm-decrypt-option 'known)
8033 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
8034 (unless (eq nparts (cdr handle))
8035 (mm-destroy-parts (cdr handle))
8036 (setcdr handle nparts))))
8037 (gnus-mime-display-security handle)
8039 (delete-region (point) (cdr region))
8040 (set-marker (car region) nil)
8041 (set-marker (cdr region) nil))
8044 (defun gnus-mime-security-show-details (handle)
8045 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
8047 (gnus-message 5 "No details.")
8048 (if gnus-mime-security-show-details-inline
8049 (let ((gnus-mime-security-button-pressed
8050 (not (get-text-property (point) 'gnus-mime-details)))
8051 (gnus-mime-security-button-line-format
8052 (get-text-property (point) 'gnus-line-format))
8053 (inhibit-read-only t))
8055 (while (eq (get-text-property (point) 'gnus-line-format)
8056 gnus-mime-security-button-line-format)
8060 (narrow-to-region (point) (point))
8061 (gnus-insert-mime-security-button handle))
8062 (delete-region (point)
8063 (or (text-property-not-all
8066 gnus-mime-security-button-line-format)
8069 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
8070 (with-current-buffer gnus-mime-security-details-buffer
8073 (setq gnus-mime-security-details-buffer
8074 (gnus-get-buffer-create "*MIME Security Details*")))
8075 (with-current-buffer gnus-mime-security-details-buffer
8077 (goto-char (point-min)))
8078 (pop-to-buffer gnus-mime-security-details-buffer)))))
8080 (defun gnus-mime-security-press-button (handle)
8082 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
8083 (gnus-mime-security-show-details handle)
8084 (gnus-mime-security-verify-or-decrypt handle))))
8086 (defun gnus-insert-mime-security-button (handle &optional displayed)
8087 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
8090 (or (nth 2 (assoc protocol mm-verify-function-alist))
8091 (nth 2 (assoc protocol mm-decrypt-function-alist))
8093 (if (equal (car handle) "multipart/signed")
8094 " Signed" " Encrypted")
8097 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
8100 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
8101 gnus-tmp-pressed-details
8103 (setq gnus-tmp-details
8104 (if gnus-tmp-details
8105 (concat "\n" gnus-tmp-details)
8107 (setq gnus-tmp-pressed-details
8108 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
8113 gnus-mime-security-button-line-format
8114 gnus-mime-security-button-line-format-alist
8115 `(keymap ,gnus-mime-security-button-map
8116 gnus-callback gnus-mime-security-press-button
8117 gnus-line-format ,gnus-mime-security-button-line-format
8118 gnus-mime-details ,gnus-mime-security-button-pressed
8119 article-type annotation
8122 ;; Exclude a newline.
8125 (when gnus-article-button-face
8126 (gnus-overlay-put (gnus-make-overlay b e nil t)
8127 'face gnus-article-button-face))
8128 (widget-convert-button
8131 :action 'gnus-widget-press-button
8132 :button-keymap gnus-mime-security-button-map
8134 (lambda (widget/window &optional overlay pos)
8135 ;; Needed to properly clear the message due to a bug in
8136 ;; wid-edit (XEmacs only).
8137 (when (boundp 'help-echo-owns-message)
8138 (setq help-echo-owns-message t))
8140 "%S: show detail; %S: more options"
8141 (aref gnus-mouse-2 0)
8142 (aref gnus-down-mouse-3 0))))))
8144 (defun gnus-mime-display-security (handle)
8146 (narrow-to-region (point) (point))
8147 (unless (gnus-unbuttonized-mime-type-p (car handle))
8148 (gnus-insert-mime-security-button handle))
8149 (gnus-mime-display-part (cadr handle))
8152 (unless (gnus-unbuttonized-mime-type-p (car handle))
8153 (let ((gnus-mime-security-button-line-format
8154 gnus-mime-security-button-end-line-format))
8155 (gnus-insert-mime-security-button handle)))
8156 (mm-set-handle-multipart-parameter
8158 (cons (set-marker (make-marker) (point-min))
8159 (set-marker (make-marker) (point-max))))
8160 (goto-char (point-max))))
8162 (defun gnus-mime-security-run-function (function)
8163 "Run FUNCTION with the security part under point."
8164 (gnus-article-check-buffer)
8165 (let ((data (get-text-property (point) 'gnus-data))
8167 (when (and (stringp (car-safe data))
8168 (setq buffer (mm-handle-multipart-original-buffer data))
8169 (setq handle (cadr data)))
8170 (if (bufferp (mm-handle-buffer handle))
8172 (setq handle (cons buffer (copy-sequence (cdr handle))))
8173 (mm-handle-set-undisplayer handle nil))
8174 (setq handle (mm-make-handle
8176 (mm-handle-multipart-ctl-parameter handle 'protocol)
8177 nil nil nil nil nil nil)))
8178 (funcall function handle))))
8180 (defun gnus-mime-security-save-part ()
8181 "Save the security part under point."
8183 (gnus-mime-security-run-function 'mm-save-part))
8185 (defun gnus-mime-security-pipe-part ()
8186 "Pipe the security part under point to a process."
8188 (gnus-mime-security-run-function 'mm-pipe-part))
8194 (run-hooks 'gnus-art-load-hook)
8196 ;;; arch-tag: 2654516f-6279-48f9-a83b-05c1fa450c33
8197 ;;; gnus-art.el ends here