1 ;;; gnus-art.el --- article mode commands for Gnus
3 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 ;; 2005, 2006 Free Software Foundation, Inc.
6 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 ;; Boston, MA 02110-1301, USA.
33 (defvar w3m-minor-mode-map))
36 ;; Avoid the "Recursive load suspected" error in Emacs 21.1.
38 (let ((recursive-load-depth-limit 100))
51 (autoload 'gnus-msg-mail "gnus-msg" nil t)
52 (autoload 'gnus-button-mailto "gnus-msg")
53 (autoload 'gnus-button-reply "gnus-msg" nil t)
54 (autoload 'parse-time-string "parse-time" nil nil)
55 (autoload 'ansi-color-apply-on-region "ansi-color")
56 (autoload 'mm-url-insert-file-contents-external "mm-url")
57 (autoload 'mm-extern-cache-contents "mm-extern")
59 (defgroup gnus-article nil
61 :link '(custom-manual "(gnus)Article Buffer")
64 (defgroup gnus-article-treat nil
65 "Treating article parts."
66 :link '(custom-manual "(gnus)Article Hiding")
69 (defgroup gnus-article-hiding nil
70 "Hiding article parts."
71 :link '(custom-manual "(gnus)Article Hiding")
74 (defgroup gnus-article-highlight nil
75 "Article highlighting."
76 :link '(custom-manual "(gnus)Article Highlighting")
80 (defgroup gnus-article-signature nil
82 :link '(custom-manual "(gnus)Article Signature")
85 (defgroup gnus-article-headers nil
87 :link '(custom-manual "(gnus)Hiding Headers")
90 (defgroup gnus-article-washing nil
91 "Special commands on articles."
92 :link '(custom-manual "(gnus)Article Washing")
95 (defgroup gnus-article-emphasis nil
96 "Fontisizing articles."
97 :link '(custom-manual "(gnus)Article Fontisizing")
100 (defgroup gnus-article-saving nil
102 :link '(custom-manual "(gnus)Saving Articles")
103 :group 'gnus-article)
105 (defgroup gnus-article-mime nil
106 "Worshiping the MIME wonder."
107 :link '(custom-manual "(gnus)Using MIME")
108 :group 'gnus-article)
110 (defgroup gnus-article-buttons nil
111 "Pushable buttons in the article buffer."
112 :link '(custom-manual "(gnus)Article Buttons")
113 :group 'gnus-article)
115 (defgroup gnus-article-various nil
116 "Other article options."
117 :link '(custom-manual "(gnus)Misc Article")
118 :group 'gnus-article)
120 (defcustom gnus-ignored-headers
123 (concat "^" header ":"))
124 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
125 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
126 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
127 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
128 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
129 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
130 "X-Attribution" "X-Originating-IP" "Delivered-To"
131 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
132 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
133 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
134 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
135 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
136 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
137 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
138 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
139 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
140 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
141 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
142 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
143 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
144 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
145 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
146 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
147 "List-[A-Za-z]+" "X-Listprocessor-Version"
148 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
149 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
150 "X-Received" "Content-length" "X-precedence"
151 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
152 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
153 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
154 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
155 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
156 "X-Content-length" "X-Posting-Agent" "Original-Received"
157 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
158 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
159 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
160 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
161 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"
162 "Envelope-To" "X-Spam-Score" "System-Type" "X-Injected-Via-Gmane"
163 "X-Gmane-NNTP-Posting-Host" "Jabber-ID" "Archived-At"
164 "Envelope-Sender" "Envelope-Recipients"))
165 "*All headers that start with this regexp will be hidden.
166 This variable can also be a list of regexps of headers to be ignored.
167 If `gnus-visible-headers' is non-nil, this variable will be ignored."
168 :type '(choice :custom-show nil
171 :group 'gnus-article-hiding)
173 (defcustom gnus-visible-headers
174 "^From:\\|^Newsgroups:\\|^Subject:\\|^Date:\\|^Followup-To:\\|^Reply-To:\\|^Organization:\\|^Summary:\\|^Keywords:\\|^To:\\|^[BGF]?Cc:\\|^Posted-To:\\|^Mail-Copies-To:\\|^Mail-Followup-To:\\|^Apparently-To:\\|^Gnus-Warning:\\|^Resent-From:\\|^X-Sent:"
175 "*All headers that do not match this regexp will be hidden.
176 This variable can also be a list of regexp of headers to remain visible.
177 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
178 :type '(repeat :value-to-internal (lambda (widget value)
179 (custom-split-regexp-maybe value))
180 :match (lambda (widget value)
182 (widget-editable-list-match widget value)))
184 :group 'gnus-article-hiding)
186 (defcustom gnus-sorted-header-list
187 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
188 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
189 "*This variable is a list of regular expressions.
190 If it is non-nil, headers that match the regular expressions will
191 be placed first in the article buffer in the sequence specified by
193 :type '(repeat regexp)
194 :group 'gnus-article-hiding)
196 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
197 "Headers that are only to be displayed if they have interesting data.
198 Possible values in this list are:
200 'empty Headers with no content.
201 'newsgroups Newsgroup identical to Gnus group.
202 'to-address To identical to To-address.
203 'to-list To identical to To-list.
204 'cc-list CC identical to To-list.
205 'followup-to Followup-to identical to Newsgroups.
206 'reply-to Reply-to identical to From.
207 'date Date less than four days old.
208 'long-to To and/or Cc longer than 1024 characters.
209 'many-to Multiple To and/or Cc."
210 :type '(set (const :tag "Headers with no content." empty)
211 (const :tag "Newsgroups identical to Gnus group." newsgroups)
212 (const :tag "To identical to To-address." to-address)
213 (const :tag "To identical to To-list." to-list)
214 (const :tag "CC identical to To-list." cc-list)
215 (const :tag "Followup-to identical to Newsgroups." followup-to)
216 (const :tag "Reply-to identical to From." reply-to)
217 (const :tag "Date less than four days old." date)
218 (const :tag "To and/or Cc longer than 1024 characters." long-to)
219 (const :tag "Multiple To and/or Cc headers." many-to))
220 :group 'gnus-article-hiding)
222 (defcustom gnus-article-skip-boring nil
223 "Skip over text that is not worth reading.
224 By default, if you set this t, then Gnus will display citations and
225 signatures, but will never scroll down to show you a page consisting
226 only of boring text. Boring text is controlled by
227 `gnus-article-boring-faces'."
230 :group 'gnus-article-hiding)
232 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
233 "Regexp matching signature separator.
234 This can also be a list of regexps. In that case, it will be checked
235 from head to tail looking for a separator. Searches will be done from
236 the end of the buffer."
237 :type '(choice :format "%{%t%}: %[Value Menu%]\n%v"
239 (repeat :tag "List of regexp" regexp))
240 :group 'gnus-article-signature)
242 (defcustom gnus-signature-limit nil
243 "Provide a limit to what is considered a signature.
244 If it is a number, no signature may not be longer (in characters) than
245 that number. If it is a floating point number, no signature may be
246 longer (in lines) than that number. If it is a function, the function
247 will be called without any parameters, and if it returns nil, there is
248 no signature in the buffer. If it is a string, it will be used as a
249 regexp. If it matches, the text in question is not a signature.
251 This can also be a list of the above values."
252 :type '(choice (const nil)
255 (function :value fun)
256 (regexp :value ".*"))
257 :group 'gnus-article-signature)
259 (defcustom gnus-hidden-properties '(invisible t intangible t)
260 "Property list to use for hiding text."
262 :group 'gnus-article-hiding)
264 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
265 ;; frames in a session.
266 (defcustom gnus-article-x-face-command
267 (if (featurep 'xemacs)
268 (if (or (gnus-image-type-available-p 'xface)
269 (gnus-image-type-available-p 'pbm))
270 'gnus-display-x-face-in-from
271 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -")
272 (if (gnus-image-type-available-p 'pbm)
273 'gnus-display-x-face-in-from
274 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
276 "*String or function to be executed to display an X-Face header.
277 If it is a string, the command will be executed in a sub-shell
278 asynchronously. The compressed face will be piped to this command."
279 :type `(choice string
280 (function-item gnus-display-x-face-in-from)
284 :group 'gnus-article-washing)
286 (defcustom gnus-article-x-face-too-ugly nil
287 "Regexp matching posters whose face shouldn't be shown automatically."
288 :type '(choice regexp (const nil))
289 :group 'gnus-article-washing)
291 (defcustom gnus-article-banner-alist nil
292 "Banner alist for stripping.
294 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
296 :type '(repeat (cons symbol regexp))
297 :group 'gnus-article-washing)
299 (gnus-define-group-parameter
302 "Alist of regexps (to match group names) and banner."
303 :variable-group gnus-article-washing
305 '(choice :tag "Banner"
307 (const :tag "Remove signature" signature)
308 (symbol :tag "Item in `gnus-article-banner-alist'" none)
310 (const :tag "None" nil))
312 "If non-nil, specify how to remove `banners' from articles.
314 Symbol `signature' means to remove signatures delimited by
315 `gnus-signature-separator'. Any other symbol is used to look up a
316 regular expression to match the banner in `gnus-article-banner-alist'.
317 A string is used as a regular expression to match the banner
320 (defcustom gnus-article-address-banner-alist nil
321 "Alist of mail addresses and banners.
322 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
323 to match a mail address in the From: header, BANNER is one of a symbol
324 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
325 If ADDRESS matches author's mail address, it will remove things like
326 advertisements. For example:
328 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
332 (regexp :tag "Address")
333 (choice :tag "Banner" :value nil
334 (const :tag "Remove signature" signature)
335 (symbol :tag "Item in `gnus-article-banner-alist'" none)
337 (const :tag "None" nil))))
339 :group 'gnus-article-washing)
341 (defmacro gnus-emphasis-custom-with-format (&rest body)
343 \\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\
344 \\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)"))
347 (defun gnus-emphasis-custom-value-to-external (value)
348 (gnus-emphasis-custom-with-format
349 (if (consp (car value))
350 (list (format format (car (car value)) (cdr (car value)))
352 (if (nth 1 value) 2 3)
356 (defun gnus-emphasis-custom-value-to-internal (value)
357 (gnus-emphasis-custom-with-format
358 (let ((regexp (concat "\\`"
359 (format (regexp-quote format)
360 "\\([^()]+\\)" "\\([^()]+\\)")
363 (if (string-match regexp (setq pattern (car value)))
364 (list (cons (match-string 1 pattern) (match-string 2 pattern))
369 (defcustom gnus-emphasis-alist
371 '(("\\*" "\\*" bold nil 2)
374 ("_/" "/_" underline-italic)
375 ("_\\*" "\\*_" underline-bold)
376 ("\\*/" "/\\*" bold-italic)
377 ("_\\*/" "/\\*_" underline-bold-italic))))
379 (gnus-emphasis-custom-with-format
380 (mapcar (lambda (spec)
381 (list (format format (car spec) (cadr spec))
384 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
386 '(;; I've never seen anyone use this strikethru convention whereas I've
387 ;; several times seen it triggered by normal text. --Stef
388 ;; Miles suggests that this form is sometimes used but for italics,
389 ;; so maybe we should map it to `italic'.
390 ;; ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
391 ;; 2 3 gnus-emphasis-strikethru)
392 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
393 2 3 gnus-emphasis-underline))))
394 "*Alist that says how to fontify certain phrases.
395 Each item looks like this:
397 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
399 The first element is a regular expression to be matched. The second
400 is a number that says what regular expression grouping used to find
401 the entire emphasized word. The third is a number that says what
402 regexp grouping should be displayed and highlighted. The fourth
403 is the face used for highlighting."
407 :format "%[Customizing Style%]\n%v"
409 (group :tag "Default"
410 :value ("" 0 0 default)
413 (let ((value (widget-get
414 (cadr (widget-get (widget-get widget :parent)
417 (if (not (eq (nth 2 value) 'default))
421 (gnus-emphasis-custom-value-to-external value))))
422 (widget-group-value-create widget))
424 (integer :format "Match group: %v")
425 (integer :format "Emphasize group: %v")
428 :value (("_" . "_") nil default)
430 (regexp :format "Start regexp: %v")
431 (regexp :format "End regexp: %v"))
432 (boolean :format "Show start and end patterns: %[%v%]\n"
433 :on " On " :off " Off ")
435 :get (lambda (symbol)
436 (mapcar 'gnus-emphasis-custom-value-to-internal
437 (default-value symbol)))
438 :set (lambda (symbol value)
439 (set-default symbol (mapcar 'gnus-emphasis-custom-value-to-external
441 :group 'gnus-article-emphasis)
443 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
444 "A regexp to describe whitespace which should not be emphasized.
445 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
446 The former avoids underlining of leading and trailing whitespace,
447 and the latter avoids underlining any whitespace at all."
449 :group 'gnus-article-emphasis
452 (defface gnus-emphasis-bold '((t (:bold t)))
453 "Face used for displaying strong emphasized text (*word*)."
454 :group 'gnus-article-emphasis)
456 (defface gnus-emphasis-italic '((t (:italic t)))
457 "Face used for displaying italic emphasized text (/word/)."
458 :group 'gnus-article-emphasis)
460 (defface gnus-emphasis-underline '((t (:underline t)))
461 "Face used for displaying underlined emphasized text (_word_)."
462 :group 'gnus-article-emphasis)
464 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
465 "Face used for displaying underlined bold emphasized text (_*word*_)."
466 :group 'gnus-article-emphasis)
468 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
469 "Face used for displaying underlined italic emphasized text (_/word/_)."
470 :group 'gnus-article-emphasis)
472 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
473 "Face used for displaying bold italic emphasized text (/*word*/)."
474 :group 'gnus-article-emphasis)
476 (defface gnus-emphasis-underline-bold-italic
477 '((t (:bold t :italic t :underline t)))
478 "Face used for displaying underlined bold italic emphasized text.
479 Example: (_/*word*/_)."
480 :group 'gnus-article-emphasis)
482 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
483 '((t (:strikethru t)))
484 '((t (:strike-through t))))
485 "Face used for displaying strike-through text (-word-)."
486 :group 'gnus-article-emphasis)
488 (defface gnus-emphasis-highlight-words
489 '((t (:background "black" :foreground "yellow")))
490 "Face used for displaying highlighted words."
491 :group 'gnus-article-emphasis)
493 (defcustom gnus-article-time-format "%a, %d %b %Y %T %Z"
494 "Format for display of Date headers in article bodies.
495 See `format-time-string' for the possible values.
497 The variable can also be function, which should return a complete Date
498 header. The function is called with one argument, the time, which can
499 be fed to `format-time-string'."
500 :type '(choice string function)
501 :link '(custom-manual "(gnus)Article Date")
502 :group 'gnus-article-washing)
504 (defcustom gnus-save-all-headers t
505 "*If non-nil, don't remove any headers before saving."
506 :group 'gnus-article-saving
509 (defcustom gnus-prompt-before-saving 'always
510 "*This variable says how much prompting is to be done when saving articles.
511 If it is nil, no prompting will be done, and the articles will be
512 saved to the default files. If this variable is `always', each and
513 every article that is saved will be preceded by a prompt, even when
514 saving large batches of articles. If this variable is neither nil not
515 `always', there the user will be prompted once for a file name for
516 each invocation of the saving commands."
517 :group 'gnus-article-saving
518 :type '(choice (item always)
519 (item :tag "never" nil)
520 (sexp :tag "once" :format "%t\n" :value t)))
522 (defcustom gnus-saved-headers gnus-visible-headers
523 "Headers to keep if `gnus-save-all-headers' is nil.
524 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
525 If that variable is nil, however, all headers that match this regexp
526 will be kept while the rest will be deleted before saving."
527 :group 'gnus-article-saving
530 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
531 "A function to save articles in your favourite format.
532 The function will be called by way of the `gnus-summary-save-article'
533 command, and friends such as `gnus-summary-save-article-rmail'.
535 Gnus provides the following functions:
537 * gnus-summary-save-in-rmail (Rmail format)
538 * gnus-summary-save-in-mail (Unix mail format)
539 * gnus-summary-save-in-folder (MH folder)
540 * gnus-summary-save-in-file (article format)
541 * gnus-summary-save-body-in-file (article body)
542 * gnus-summary-save-in-vm (use VM's folder format)
543 * gnus-summary-write-to-file (article format -- overwrite)
544 * gnus-summary-write-body-to-file (article body -- overwrite)."
545 :group 'gnus-article-saving
546 :type '(radio (function-item gnus-summary-save-in-rmail)
547 (function-item gnus-summary-save-in-mail)
548 (function-item gnus-summary-save-in-folder)
549 (function-item gnus-summary-save-in-file)
550 (function-item gnus-summary-save-body-in-file)
551 (function-item gnus-summary-save-in-vm)
552 (function-item gnus-summary-write-to-file)
553 (function-item gnus-summary-write-body-to-file)
556 (defcustom gnus-article-save-coding-system
557 (or (and (mm-coding-system-p 'utf-8) 'utf-8)
558 (and (mm-coding-system-p 'iso-2022-7bit) 'iso-2022-7bit)
559 (and (mm-coding-system-p 'emacs-mule) 'emacs-mule)
560 (and (mm-coding-system-p 'escape-quoted) 'escape-quoted))
561 "Coding system used to save decoded articles to a file.
563 The recommended coding systems are `utf-8', `iso-2022-7bit' and so on,
564 which can safely encode any characters in text. This is used by the
567 * gnus-summary-save-article-file
568 * gnus-summary-save-article-body-file
569 * gnus-summary-write-article-file
570 * gnus-summary-write-article-body-file
572 and the functions to which you may set `gnus-default-article-saver':
574 * gnus-summary-save-in-file
575 * gnus-summary-save-body-in-file
576 * gnus-summary-write-to-file
577 * gnus-summary-write-body-to-file
579 Those commands and functions save just text displayed in the article
580 buffer to a file if the value of this variable is non-nil. Note that
581 buttonized MIME parts will be lost in a saved file in that case.
582 Otherwise, raw articles will be saved."
583 :group 'gnus-article-saving
585 :format "%{%t%}:\n %[Value Menu%] %v"
586 (const :tag "Save raw articles" nil)
589 (lambda (arg) (if (mm-coding-system-p (nth 3 arg)) arg))
590 '((const :tag "UTF-8" utf-8)
591 (const :tag "iso-2022-7bit" iso-2022-7bit)
592 (const :tag "Emacs internal" emacs-mule)
593 (const :tag "escape-quoted" escape-quoted))))
594 (symbol :tag "Coding system")))
596 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
597 "A function generating a file name to save articles in Rmail format.
598 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
599 :group 'gnus-article-saving
602 (defcustom gnus-mail-save-name 'gnus-plain-save-name
603 "A function generating a file name to save articles in Unix mail format.
604 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
605 :group 'gnus-article-saving
608 (defcustom gnus-folder-save-name 'gnus-folder-save-name
609 "A function generating a file name to save articles in MH folder.
610 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
611 :group 'gnus-article-saving
614 (defcustom gnus-file-save-name 'gnus-numeric-save-name
615 "A function generating a file name to save articles in article format.
616 The function is called with NEWSGROUP, HEADERS, and optional
618 :group 'gnus-article-saving
621 (defcustom gnus-split-methods
622 '((gnus-article-archive-name)
623 (gnus-article-nndoc-name))
624 "*Variable used to suggest where articles are to be saved.
625 For instance, if you would like to save articles related to Gnus in
626 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
627 you could set this variable to something like:
629 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
630 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
632 This variable is an alist where the key is the match and the
633 value is a list of possible files to save in if the match is
636 If the match is a string, it is used as a regexp match on the
637 article. If the match is a symbol, that symbol will be funcalled
638 from the buffer of the article to be saved with the newsgroup as
639 the parameter. If it is a list, it will be evaled in the same
642 If this form or function returns a string, this string will be
643 used as a possible file name; and if it returns a non-nil list,
644 that list will be used as possible file names."
645 :group 'gnus-article-saving
646 :type '(repeat (choice (list :value (fun) function)
647 (cons :value ("" "") regexp (repeat string))
650 (defcustom gnus-page-delimiter "^\^L"
651 "*Regexp describing what to use as article page delimiters.
652 The default value is \"^\^L\", which is a form linefeed at the
653 beginning of a line."
655 :group 'gnus-article-various)
657 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
658 "*The format specification for the article mode line.
659 See `gnus-summary-mode-line-format' for a closer description.
661 The following additional specs are available:
663 %w The article washing status.
664 %m The number of MIME parts in the article."
666 :group 'gnus-article-various)
668 (defcustom gnus-article-mode-hook nil
669 "*A hook for Gnus article mode."
671 :group 'gnus-article-various)
673 (when (featurep 'xemacs)
674 ;; Extracted from gnus-xmas-define in order to preserve user settings
675 (when (fboundp 'turn-off-scroll-in-place)
676 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
677 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
678 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
680 (defcustom gnus-article-menu-hook nil
681 "*Hook run after the creation of the article mode menu."
683 :group 'gnus-article-various)
685 (defcustom gnus-article-prepare-hook nil
686 "*A hook called after an article has been prepared in the article buffer."
688 :group 'gnus-article-various)
690 (defcustom gnus-copy-article-ignored-headers nil
691 "List of headers to be removed when copying an article.
692 Each element is a regular expression."
693 :version "23.0" ;; No Gnus
694 :type '(repeat regexp)
695 :group 'gnus-article-various)
697 (make-obsolete-variable 'gnus-article-hide-pgp-hook
698 "This variable is obsolete in Gnus 5.10.")
701 '((t (:weight bold)))
702 "Face used for highlighting a button in the article buffer."
703 :group 'gnus-article-buttons)
705 (defcustom gnus-article-button-face 'gnus-button
706 "Face used for highlighting buttons in the article buffer.
708 An article button is a piece of text that you can activate by pressing
709 `RET' or `mouse-2' above it."
711 :group 'gnus-article-buttons)
713 (defcustom gnus-article-mouse-face 'highlight
714 "Face used for mouse highlighting in the article buffer.
716 Article buttons will be displayed in this face when the cursor is
719 :group 'gnus-article-buttons)
721 (defcustom gnus-signature-face 'gnus-signature
722 "Face used for highlighting a signature in the article buffer.
723 Obsolete; use the face `gnus-signature' for customizations instead."
725 :group 'gnus-article-highlight
726 :group 'gnus-article-signature)
728 (defface gnus-signature
731 "Face used for highlighting a signature in the article buffer."
732 :group 'gnus-article-highlight
733 :group 'gnus-article-signature)
734 ;; backward-compatibility alias
735 (put 'gnus-signature-face 'face-alias 'gnus-signature)
737 (defface gnus-header-from
740 (:foreground "spring green"))
743 (:foreground "red3"))
746 "Face used for displaying from headers."
747 :group 'gnus-article-headers
748 :group 'gnus-article-highlight)
749 ;; backward-compatibility alias
750 (put 'gnus-header-from-face 'face-alias 'gnus-header-from)
752 (defface gnus-header-subject
755 (:foreground "SeaGreen3"))
758 (:foreground "red4"))
760 (:bold t :italic t)))
761 "Face used for displaying subject headers."
762 :group 'gnus-article-headers
763 :group 'gnus-article-highlight)
764 ;; backward-compatibility alias
765 (put 'gnus-header-subject-face 'face-alias 'gnus-header-subject)
767 (defface gnus-header-newsgroups
770 (:foreground "yellow" :italic t))
773 (:foreground "MidnightBlue" :italic t))
776 "Face used for displaying newsgroups headers.
777 In the default setup this face is only used for crossposted
779 :group 'gnus-article-headers
780 :group 'gnus-article-highlight)
781 ;; backward-compatibility alias
782 (put 'gnus-header-newsgroups-face 'face-alias 'gnus-header-newsgroups)
784 (defface gnus-header-name
787 (:foreground "SeaGreen"))
790 (:foreground "maroon"))
793 "Face used for displaying header names."
794 :group 'gnus-article-headers
795 :group 'gnus-article-highlight)
796 ;; backward-compatibility alias
797 (put 'gnus-header-name-face 'face-alias 'gnus-header-name)
799 (defface gnus-header-content
802 (:foreground "forest green" :italic t))
805 (:foreground "indianred4" :italic t))
807 (:italic t))) "Face used for displaying header content."
808 :group 'gnus-article-headers
809 :group 'gnus-article-highlight)
810 ;; backward-compatibility alias
811 (put 'gnus-header-content-face 'face-alias 'gnus-header-content)
813 (defcustom gnus-header-face-alist
814 '(("From" nil gnus-header-from)
815 ("Subject" nil gnus-header-subject)
816 ("Newsgroups:.*," nil gnus-header-newsgroups)
817 ("" gnus-header-name gnus-header-content))
818 "*Controls highlighting of article headers.
820 An alist of the form (HEADER NAME CONTENT).
822 HEADER is a regular expression which should match the name of a
823 header and NAME and CONTENT are either face names or nil.
825 The name of each header field will be displayed using the face
826 specified by the first element in the list where HEADER matches
827 the header name and NAME is non-nil. Similarly, the content will
828 be displayed by the first non-nil matching CONTENT face."
829 :group 'gnus-article-headers
830 :group 'gnus-article-highlight
831 :type '(repeat (list (regexp :tag "Header")
833 (item :tag "skip" nil)
834 (face :value default))
835 (choice :tag "Content"
836 (item :tag "skip" nil)
837 (face :value default)))))
839 (defcustom gnus-face-properties-alist (if (featurep 'xemacs)
840 '((xface . (:face gnus-x-face)))
841 '((pbm . (:face gnus-x-face))
843 "Alist of image types and properties applied to Face and X-Face images.
846 ;; Specify the altitude of Face images in the From header.
847 \(setq gnus-face-properties-alist
848 '((pbm . (:face gnus-x-face :ascent 80))
849 (png . (:ascent 80))))
851 ;; Show Face images as pressed buttons.
852 \(setq gnus-face-properties-alist
853 '((pbm . (:face gnus-x-face :relief -2))
854 (png . (:relief -2))))
856 See the manual for the valid properties for various image types.
857 Currently, `pbm' is used for X-Face images and `png' is used for Face
858 images in Emacs. Only the `:face' property is effective on the `xface'
859 image type in XEmacs if it is built with the libcompface library."
860 :version "23.0" ;; No Gnus
861 :group 'gnus-article-headers
862 :type '(repeat (cons :format "%v" (symbol :tag "Image type") plist)))
864 (defcustom gnus-article-decode-hook
865 '(article-decode-charset article-decode-encoded-words
866 article-decode-group-name article-decode-idna-rhs)
867 "*Hook run to decode charsets in articles."
868 :group 'gnus-article-headers
871 (defcustom gnus-display-mime-function 'gnus-display-mime
872 "Function to display MIME articles."
873 :group 'gnus-article-mime
876 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
877 "Function used to decode headers.")
879 (defvar gnus-article-dumbquotes-map
899 "Table for MS-to-Latin1 translation.")
901 (defcustom gnus-ignored-mime-types nil
902 "List of MIME types that should be ignored by Gnus."
904 :group 'gnus-article-mime
905 :type '(repeat regexp))
907 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
908 "List of MIME types that should not be given buttons when rendered inline.
909 See also `gnus-buttonized-mime-types' which may override this variable.
910 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
912 :group 'gnus-article-mime
913 :type '(repeat regexp))
915 (defcustom gnus-buttonized-mime-types nil
916 "List of MIME types that should be given buttons when rendered inline.
917 If set, this variable overrides `gnus-unbuttonized-mime-types'.
918 To see e.g. security buttons you could set this to
919 `(\"multipart/signed\")'. You could also add \"multipart/alternative\" to
920 this list to display radio buttons that allow you to choose one of two
921 media types those mails include. See also `mm-discouraged-alternatives'.
922 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
924 :group 'gnus-article-mime
925 :type '(repeat regexp))
927 (defcustom gnus-inhibit-mime-unbuttonizing nil
928 "If non-nil, all MIME parts get buttons.
929 When nil (the default value), then some MIME parts do not get buttons,
930 as described by the variables `gnus-buttonized-mime-types' and
931 `gnus-unbuttonized-mime-types'."
933 :group 'gnus-article-mime
936 (defcustom gnus-body-boundary-delimiter "_"
937 "String used to delimit header and body.
938 This variable is used by `gnus-article-treat-body-boundary' which can
939 be controlled by `gnus-treat-body-boundary'."
941 :group 'gnus-article-various
942 :type '(choice (item :tag "None" :value nil)
945 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces"
947 "Defines the location of the faces database.
948 For information on obtaining this database of pretty pictures, please
949 see http://www.cs.indiana.edu/picons/ftp/index.html"
951 :type '(repeat directory)
952 :link '(url-link :tag "download"
953 "http://www.cs.indiana.edu/picons/ftp/index.html")
954 :link '(custom-manual "(gnus)Picons")
957 (defun gnus-picons-installed-p ()
958 "Say whether picons are installed on your machine."
959 (let ((installed nil))
960 (dolist (database gnus-picon-databases)
961 (when (file-exists-p database)
965 (defcustom gnus-article-mime-part-function nil
966 "Function called with a MIME handle as the argument.
967 This is meant for people who want to do something automatic based
968 on parts -- for instance, adding Vcard info to a database."
969 :group 'gnus-article-mime
970 :type '(choice (const nil)
973 (defcustom gnus-mime-multipart-functions nil
974 "An alist of MIME types to functions to display them."
976 :group 'gnus-article-mime
977 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
979 (defcustom gnus-article-date-lapsed-new-header nil
980 "Whether the X-Sent and Date headers can coexist.
981 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
982 either replace the old \"Date:\" header (if this variable is nil), or
983 be added below it (otherwise)."
985 :group 'gnus-article-headers
988 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
989 "Function called with a MIME handle as the argument.
990 This is meant for people who want to view first matched part.
991 For `undisplayed-alternative' (default), the first undisplayed
992 part or alternative part is used. For `undisplayed', the first
993 undisplayed part is used. For a function, the first part which
994 the function return t is used. For nil, the first part is
997 :group 'gnus-article-mime
999 (item :tag "first" :value nil)
1000 (item :tag "undisplayed" :value undisplayed)
1001 (item :tag "undisplayed or alternative"
1002 :value undisplayed-alternative)
1005 (defcustom gnus-mime-action-alist
1006 '(("save to file" . gnus-mime-save-part)
1007 ("save and strip" . gnus-mime-save-part-and-strip)
1008 ("replace with file" . gnus-mime-replace-part)
1009 ("delete part" . gnus-mime-delete-part)
1010 ("display as text" . gnus-mime-inline-part)
1011 ("view the part" . gnus-mime-view-part)
1012 ("pipe to command" . gnus-mime-pipe-part)
1013 ("toggle display" . gnus-article-press-button)
1014 ("toggle display" . gnus-article-view-part-as-charset)
1015 ("view as type" . gnus-mime-view-part-as-type)
1016 ("view internally" . gnus-mime-view-part-internally)
1017 ("view externally" . gnus-mime-view-part-externally))
1018 "An alist of actions that run on the MIME attachment."
1019 :group 'gnus-article-mime
1020 :type '(repeat (cons (string :tag "name")
1023 (defcustom gnus-auto-select-part 1
1024 "Advance to next MIME part when deleting or stripping parts.
1026 When 0, point will be placed on the same part as before. When
1027 positive (negative), move point forward (backwards) this many
1028 parts. When nil, redisplay article."
1029 :version "23.0" ;; No Gnus
1030 :group 'gnus-article-mime
1031 :type '(choice (const nil :tag "Redisplay article.")
1032 (const 1 :tag "Next part.")
1033 (const 0 :tag "Current part.")
1037 ;;; The treatment variables
1040 (defvar gnus-part-display-hook nil
1041 "Hook called on parts that are to receive treatment.")
1043 (defvar gnus-article-treat-custom
1044 '(choice (const :tag "Off" nil)
1046 (const :tag "Header" head)
1047 (const :tag "First" first)
1048 (const :tag "Last" last)
1049 (integer :tag "Less")
1050 (repeat :tag "Groups" regexp)
1051 (sexp :tag "Predicate")))
1053 (defvar gnus-article-treat-head-custom
1054 '(choice (const :tag "Off" nil)
1055 (const :tag "Header" head)))
1057 (defvar gnus-article-treat-types '("text/plain" "text/x-verbatim"
1061 (defvar gnus-inhibit-treatment nil
1062 "Whether to inhibit treatment.")
1064 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
1065 "Highlight the signature.
1066 Valid values are nil, t, `head', `first', `last', an integer or a
1067 predicate. See Info node `(gnus)Customizing Articles'."
1068 :group 'gnus-article-treat
1069 :link '(custom-manual "(gnus)Customizing Articles")
1070 :type gnus-article-treat-custom)
1071 (put 'gnus-treat-highlight-signature 'highlight t)
1073 (defcustom gnus-treat-buttonize 100000
1075 Valid values are nil, t, `head', `first', `last', an integer or a
1076 predicate. See Info node `(gnus)Customizing Articles'."
1077 :group 'gnus-article-treat
1078 :link '(custom-manual "(gnus)Customizing Articles")
1079 :type gnus-article-treat-custom)
1080 (put 'gnus-treat-buttonize 'highlight t)
1082 (defcustom gnus-treat-buttonize-head 'head
1083 "Add buttons to the head.
1084 Valid values are nil, t, `head', `first', `last', an integer or a
1085 predicate. See Info node `(gnus)Customizing Articles'."
1086 :group 'gnus-article-treat
1087 :link '(custom-manual "(gnus)Customizing Articles")
1088 :type gnus-article-treat-head-custom)
1089 (put 'gnus-treat-buttonize-head 'highlight t)
1091 (defcustom gnus-treat-emphasize
1092 (and (or window-system
1096 Valid values are nil, t, `head', `first', `last', an integer or a
1097 predicate. See Info node `(gnus)Customizing Articles'."
1098 :group 'gnus-article-treat
1099 :link '(custom-manual "(gnus)Customizing Articles")
1100 :type gnus-article-treat-custom)
1101 (put 'gnus-treat-emphasize 'highlight t)
1103 (defcustom gnus-treat-strip-cr nil
1104 "Remove carriage returns.
1105 Valid values are nil, t, `head', `first', `last', an integer or a
1106 predicate. See Info node `(gnus)Customizing Articles'."
1108 :group 'gnus-article-treat
1109 :link '(custom-manual "(gnus)Customizing Articles")
1110 :type gnus-article-treat-custom)
1112 (defcustom gnus-treat-unsplit-urls nil
1113 "Remove newlines from within URLs.
1114 Valid values are nil, t, `head', `first', `last', an integer or a
1115 predicate. See Info node `(gnus)Customizing Articles'."
1117 :group 'gnus-article-treat
1118 :link '(custom-manual "(gnus)Customizing Articles")
1119 :type gnus-article-treat-custom)
1121 (defcustom gnus-treat-leading-whitespace nil
1122 "Remove leading whitespace in headers.
1123 Valid values are nil, t, `head', `first', `last', an integer or a
1124 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)
1130 (defcustom gnus-treat-hide-headers 'head
1132 Valid values are nil, t, `head', `first', `last', an integer or a
1133 predicate. See Info node `(gnus)Customizing Articles'."
1134 :group 'gnus-article-treat
1135 :link '(custom-manual "(gnus)Customizing Articles")
1136 :type gnus-article-treat-head-custom)
1138 (defcustom gnus-treat-hide-boring-headers nil
1139 "Hide boring headers.
1140 Valid values are nil, t, `head', `first', `last', an integer or a
1141 predicate. See Info node `(gnus)Customizing Articles'."
1142 :group 'gnus-article-treat
1143 :link '(custom-manual "(gnus)Customizing Articles")
1144 :type gnus-article-treat-head-custom)
1146 (defcustom gnus-treat-hide-signature nil
1147 "Hide the signature.
1148 Valid values are nil, t, `head', `first', `last', an integer or a
1149 predicate. See Info node `(gnus)Customizing Articles'."
1150 :group 'gnus-article-treat
1151 :link '(custom-manual "(gnus)Customizing Articles")
1152 :type gnus-article-treat-custom)
1154 (defcustom gnus-treat-fill-article nil
1156 Valid values are nil, t, `head', `first', `last', an integer or a
1157 predicate. See Info node `(gnus)Customizing Articles'."
1158 :group 'gnus-article-treat
1159 :link '(custom-manual "(gnus)Customizing Articles")
1160 :type gnus-article-treat-custom)
1162 (defcustom gnus-treat-hide-citation nil
1164 Valid values are nil, t, `head', `first', `last', an integer or a
1165 predicate. See Info node `(gnus)Customizing Articles'."
1166 :group 'gnus-article-treat
1167 :link '(custom-manual "(gnus)Customizing Articles")
1168 :type gnus-article-treat-custom)
1170 (defcustom gnus-treat-hide-citation-maybe nil
1172 Valid values are nil, t, `head', `first', `last', an integer or a
1173 predicate. See Info node `(gnus)Customizing Articles'."
1174 :group 'gnus-article-treat
1175 :link '(custom-manual "(gnus)Customizing Articles")
1176 :type gnus-article-treat-custom)
1178 (defcustom gnus-treat-strip-list-identifiers 'head
1179 "Strip list identifiers from `gnus-list-identifiers`.
1180 Valid values are nil, t, `head', `first', `last', an integer or a
1181 predicate. See Info node `(gnus)Customizing Articles'."
1183 :group 'gnus-article-treat
1184 :link '(custom-manual "(gnus)Customizing Articles")
1185 :type gnus-article-treat-custom)
1187 (make-obsolete-variable 'gnus-treat-strip-pgp
1188 "This option is obsolete in Gnus 5.10.")
1190 (defcustom gnus-treat-strip-pem nil
1191 "Strip PEM signatures.
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-strip-banner t
1199 "Strip banners from articles.
1200 The banner to be stripped is specified in the `banner' group parameter.
1201 Valid values are nil, t, `head', `first', `last', an integer or a
1202 predicate. See Info node `(gnus)Customizing Articles'."
1203 :group 'gnus-article-treat
1204 :link '(custom-manual "(gnus)Customizing Articles")
1205 :type gnus-article-treat-custom)
1207 (defcustom gnus-treat-highlight-headers 'head
1208 "Highlight the headers.
1209 Valid values are nil, t, `head', `first', `last', an integer or a
1210 predicate. See Info node `(gnus)Customizing Articles'."
1211 :group 'gnus-article-treat
1212 :link '(custom-manual "(gnus)Customizing Articles")
1213 :type gnus-article-treat-head-custom)
1214 (put 'gnus-treat-highlight-headers 'highlight t)
1216 (defcustom gnus-treat-highlight-citation t
1217 "Highlight cited text.
1218 Valid values are nil, t, `head', `first', `last', an integer or a
1219 predicate. See Info node `(gnus)Customizing Articles'."
1220 :group 'gnus-article-treat
1221 :link '(custom-manual "(gnus)Customizing Articles")
1222 :type gnus-article-treat-custom)
1223 (put 'gnus-treat-highlight-citation 'highlight t)
1225 (defcustom gnus-treat-date-ut nil
1226 "Display the Date in UT (GMT).
1227 Valid values are nil, t, `head', `first', `last', an integer or a
1228 predicate. See Info node `(gnus)Customizing Articles'."
1229 :group 'gnus-article-treat
1230 :link '(custom-manual "(gnus)Customizing Articles")
1231 :type gnus-article-treat-head-custom)
1233 (defcustom gnus-treat-date-local nil
1234 "Display the Date in the local timezone.
1235 Valid values are nil, t, `head', `first', `last', an integer or a
1236 predicate. See Info node `(gnus)Customizing Articles'."
1237 :group 'gnus-article-treat
1238 :link '(custom-manual "(gnus)Customizing Articles")
1239 :type gnus-article-treat-head-custom)
1241 (defcustom gnus-treat-date-english nil
1242 "Display the Date in a format that can be read aloud in English.
1243 Valid values are nil, t, `head', `first', `last', an integer or a
1244 predicate. See Info node `(gnus)Customizing Articles'."
1246 :group 'gnus-article-treat
1247 :link '(custom-manual "(gnus)Customizing Articles")
1248 :type gnus-article-treat-head-custom)
1250 (defcustom gnus-treat-date-lapsed nil
1251 "Display the Date header in a way that says how much time has elapsed.
1252 Valid values are nil, t, `head', `first', `last', an integer or a
1253 predicate. See Info node `(gnus)Customizing Articles'."
1254 :group 'gnus-article-treat
1255 :link '(custom-manual "(gnus)Customizing Articles")
1256 :type gnus-article-treat-head-custom)
1258 (defcustom gnus-treat-date-original nil
1259 "Display the date in the original timezone.
1260 Valid values are nil, t, `head', `first', `last', an integer or a
1261 predicate. See Info node `(gnus)Customizing Articles'."
1262 :group 'gnus-article-treat
1263 :link '(custom-manual "(gnus)Customizing Articles")
1264 :type gnus-article-treat-head-custom)
1266 (defcustom gnus-treat-date-iso8601 nil
1267 "Display the date in the ISO8601 format.
1268 Valid values are nil, t, `head', `first', `last', an integer or a
1269 predicate. See Info node `(gnus)Customizing Articles'."
1271 :group 'gnus-article-treat
1272 :link '(custom-manual "(gnus)Customizing Articles")
1273 :type gnus-article-treat-head-custom)
1275 (defcustom gnus-treat-date-user-defined nil
1276 "Display the date in a user-defined format.
1277 The format is defined by the `gnus-article-time-format' variable.
1278 Valid values are nil, t, `head', `first', `last', an integer or a
1279 predicate. See Info node `(gnus)Customizing Articles'."
1280 :group 'gnus-article-treat
1281 :link '(custom-manual "(gnus)Customizing Articles")
1282 :type gnus-article-treat-head-custom)
1284 (defcustom gnus-treat-strip-headers-in-body t
1285 "Strip the X-No-Archive header line from the beginning of the body.
1286 Valid values are nil, t, `head', `first', `last', an integer or a
1287 predicate. See Info node `(gnus)Customizing Articles'."
1289 :group 'gnus-article-treat
1290 :link '(custom-manual "(gnus)Customizing Articles")
1291 :type gnus-article-treat-custom)
1293 (defcustom gnus-treat-strip-trailing-blank-lines nil
1294 "Strip trailing blank lines.
1295 Valid values are nil, t, `head', `first', `last', an integer or a
1296 predicate. See Info node `(gnus)Customizing Articles'.
1298 When set to t, it also strips trailing blanks in all MIME parts.
1299 Consider to use `last' instead."
1300 :group 'gnus-article-treat
1301 :link '(custom-manual "(gnus)Customizing Articles")
1302 :type gnus-article-treat-custom)
1304 (defcustom gnus-treat-strip-leading-blank-lines nil
1305 "Strip leading blank lines.
1306 Valid values are nil, t, `head', `first', `last', an integer or a
1307 predicate. See Info node `(gnus)Customizing Articles'.
1309 When set to t, it also strips trailing blanks in all MIME parts."
1310 :group 'gnus-article-treat
1311 :link '(custom-manual "(gnus)Customizing Articles")
1312 :type gnus-article-treat-custom)
1314 (defcustom gnus-treat-strip-multiple-blank-lines nil
1315 "Strip multiple blank lines.
1316 Valid values are nil, t, `head', `first', `last', an integer or a
1317 predicate. See Info node `(gnus)Customizing Articles'."
1318 :group 'gnus-article-treat
1319 :link '(custom-manual "(gnus)Customizing Articles")
1320 :type gnus-article-treat-custom)
1322 (defcustom gnus-treat-unfold-headers 'head
1323 "Unfold folded header lines.
1324 Valid values are nil, t, `head', `first', `last', an integer or a
1325 predicate. See Info node `(gnus)Customizing Articles'."
1327 :group 'gnus-article-treat
1328 :link '(custom-manual "(gnus)Customizing Articles")
1329 :type gnus-article-treat-custom)
1331 (defcustom gnus-article-unfold-long-headers nil
1332 "If non-nil, allow unfolding headers even if the header is long.
1333 If it is a regexp, only long headers matching this regexp are unfolded.
1334 If it is t, all long headers are unfolded.
1336 This variable has no effect if `gnus-treat-unfold-headers' is nil."
1337 :version "23.0" ;; No Gnus
1338 :group 'gnus-article-treat
1339 :type '(choice (const nil)
1340 (const :tag "all" t)
1343 (defcustom gnus-treat-fold-headers nil
1345 Valid values are nil, t, `head', `first', `last', an integer or a
1346 predicate. See Info node `(gnus)Customizing Articles'."
1348 :group 'gnus-article-treat
1349 :link '(custom-manual "(gnus)Customizing Articles")
1350 :type gnus-article-treat-custom)
1352 (defcustom gnus-treat-fold-newsgroups 'head
1353 "Fold the Newsgroups and Followup-To headers.
1354 Valid values are nil, t, `head', `first', `last', an integer or a
1355 predicate. See Info node `(gnus)Customizing Articles'."
1357 :group 'gnus-article-treat
1358 :link '(custom-manual "(gnus)Customizing Articles")
1359 :type gnus-article-treat-custom)
1361 (defcustom gnus-treat-overstrike t
1362 "Treat overstrike highlighting.
1363 Valid values are nil, t, `head', `first', `last', an integer or a
1364 predicate. See Info node `(gnus)Customizing Articles'."
1365 :group 'gnus-article-treat
1366 :link '(custom-manual "(gnus)Customizing Articles")
1367 :type gnus-article-treat-custom)
1368 (put 'gnus-treat-overstrike 'highlight t)
1370 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1371 "Treat ANSI SGR control sequences.
1372 Valid values are nil, t, `head', `first', `last', an integer or a
1373 predicate. See Info node `(gnus)Customizing Articles'."
1374 :group 'gnus-article-treat
1375 :link '(custom-manual "(gnus)Customizing Articles")
1376 :type gnus-article-treat-custom)
1378 (make-obsolete-variable 'gnus-treat-display-xface
1379 'gnus-treat-display-x-face)
1381 (defcustom gnus-treat-display-x-face
1382 (and (not noninteractive)
1383 (or (and (fboundp 'image-type-available-p)
1384 (image-type-available-p 'xbm)
1385 (string-match "^0x" (shell-command-to-string "uncompface"))
1386 (executable-find "icontopbm"))
1387 (and (featurep 'xemacs)
1390 "Display X-Face headers.
1391 Valid values are nil, t, `head', `first', `last', an integer or a
1392 predicate. See Info node `(gnus)Customizing Articles' and Info
1393 node `(gnus)X-Face' for details."
1394 :group 'gnus-article-treat
1396 :link '(custom-manual "(gnus)Customizing Articles")
1397 :link '(custom-manual "(gnus)X-Face")
1398 :type gnus-article-treat-head-custom
1399 :set (lambda (symbol value)
1402 (cond ((or (boundp symbol) (get symbol 'saved-value))
1404 ((boundp 'gnus-treat-display-xface)
1406 ** gnus-treat-display-xface is an obsolete variable;\
1407 use gnus-treat-display-x-face instead")
1408 (default-value 'gnus-treat-display-xface))
1409 ((get 'gnus-treat-display-xface 'saved-value)
1411 ** gnus-treat-display-xface is an obsolete variable;\
1412 use gnus-treat-display-x-face instead")
1413 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1416 (put 'gnus-treat-display-x-face 'highlight t)
1418 (defcustom gnus-treat-display-face
1419 (and (not noninteractive)
1420 (or (and (fboundp 'image-type-available-p)
1421 (image-type-available-p 'png))
1422 (and (featurep 'xemacs)
1425 "Display Face headers.
1426 Valid values are nil, t, `head', `first', `last', an integer or a
1427 predicate. See Info node `(gnus)Customizing Articles' and Info
1428 node `(gnus)X-Face' for details."
1429 :group 'gnus-article-treat
1431 :link '(custom-manual "(gnus)Customizing Articles")
1432 :link '(custom-manual "(gnus)X-Face")
1433 :type gnus-article-treat-head-custom)
1434 (put 'gnus-treat-display-face 'highlight t)
1436 (defcustom gnus-treat-display-smileys
1437 (if (or (and (featurep 'xemacs)
1439 (and (fboundp 'image-type-available-p)
1440 (image-type-available-p 'pbm)))
1443 Valid values are nil, t, `head', `first', `last', an integer or a
1444 predicate. See Info node `(gnus)Customizing Articles' and Info
1445 node `(gnus)Smileys' for details."
1446 :group 'gnus-article-treat
1448 :link '(custom-manual "(gnus)Customizing Articles")
1449 :link '(custom-manual "(gnus)Smileys")
1450 :type gnus-article-treat-custom)
1451 (put 'gnus-treat-display-smileys 'highlight t)
1453 (defcustom gnus-treat-from-picon
1454 (if (and (gnus-image-type-available-p 'xpm)
1455 (gnus-picons-installed-p))
1457 "Display picons in the From header.
1458 Valid values are nil, t, `head', `first', `last', an integer or a
1459 predicate. See Info node `(gnus)Customizing Articles' and Info
1460 node `(gnus)Picons' for details."
1462 :group 'gnus-article-treat
1464 :link '(custom-manual "(gnus)Customizing Articles")
1465 :link '(custom-manual "(gnus)Picons")
1466 :type gnus-article-treat-head-custom)
1467 (put 'gnus-treat-from-picon 'highlight t)
1469 (defcustom gnus-treat-mail-picon
1470 (if (and (gnus-image-type-available-p 'xpm)
1471 (gnus-picons-installed-p))
1473 "Display picons in To and Cc headers.
1474 Valid values are nil, t, `head', `first', `last', an integer or a
1475 predicate. See Info node `(gnus)Customizing Articles' and Info
1476 node `(gnus)Picons' for details."
1478 :group 'gnus-article-treat
1480 :link '(custom-manual "(gnus)Customizing Articles")
1481 :link '(custom-manual "(gnus)Picons")
1482 :type gnus-article-treat-head-custom)
1483 (put 'gnus-treat-mail-picon 'highlight t)
1485 (defcustom gnus-treat-newsgroups-picon
1486 (if (and (gnus-image-type-available-p 'xpm)
1487 (gnus-picons-installed-p))
1489 "Display picons in the Newsgroups and Followup-To headers.
1490 Valid values are nil, t, `head', `first', `last', an integer or a
1491 predicate. See Info node `(gnus)Customizing Articles' and Info
1492 node `(gnus)Picons' for details."
1494 :group 'gnus-article-treat
1496 :link '(custom-manual "(gnus)Customizing Articles")
1497 :link '(custom-manual "(gnus)Picons")
1498 :type gnus-article-treat-head-custom)
1499 (put 'gnus-treat-newsgroups-picon 'highlight t)
1501 (defcustom gnus-treat-body-boundary
1502 (if (and (eq window-system 'x)
1503 (or gnus-treat-newsgroups-picon
1504 gnus-treat-mail-picon
1505 gnus-treat-from-picon))
1507 "Draw a boundary at the end of the headers.
1508 Valid values are nil and `head'.
1509 See Info node `(gnus)Customizing Articles' for details."
1511 :group 'gnus-article-treat
1512 :link '(custom-manual "(gnus)Customizing Articles")
1513 :type gnus-article-treat-head-custom)
1515 (defcustom gnus-treat-capitalize-sentences nil
1516 "Capitalize sentence-starting words.
1517 Valid values are nil, t, `head', `first', `last', an integer or a
1518 predicate. See Info node `(gnus)Customizing Articles'."
1520 :group 'gnus-article-treat
1521 :link '(custom-manual "(gnus)Customizing Articles")
1522 :type gnus-article-treat-custom)
1524 (defcustom gnus-treat-wash-html nil
1526 Valid values are nil, t, `head', `first', `last', an integer or a
1527 predicate. See Info node `(gnus)Customizing Articles'."
1529 :group 'gnus-article-treat
1530 :link '(custom-manual "(gnus)Customizing Articles")
1531 :type gnus-article-treat-custom)
1533 (defcustom gnus-treat-fill-long-lines nil
1535 Valid values are nil, t, `head', `first', `last', an integer or a
1536 predicate. See Info node `(gnus)Customizing Articles'."
1537 :group 'gnus-article-treat
1538 :link '(custom-manual "(gnus)Customizing Articles")
1539 :type gnus-article-treat-custom)
1541 (defcustom gnus-treat-play-sounds nil
1543 Valid values are nil, t, `head', `first', `last', an integer or a
1544 predicate. See Info node `(gnus)Customizing Articles'."
1546 :group 'gnus-article-treat
1547 :link '(custom-manual "(gnus)Customizing Articles")
1548 :type gnus-article-treat-custom)
1550 (defcustom gnus-treat-translate nil
1551 "Translate articles from one language to another.
1552 Valid values are nil, t, `head', `first', `last', an integer or a
1553 predicate. See Info node `(gnus)Customizing Articles'."
1555 :group 'gnus-article-treat
1556 :link '(custom-manual "(gnus)Customizing Articles")
1557 :type gnus-article-treat-custom)
1559 (defcustom gnus-treat-x-pgp-sig nil
1561 To automatically treat X-PGP-Sig, set it to head.
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 :group 'mime-security
1567 :link '(custom-manual "(gnus)Customizing Articles")
1568 :type gnus-article-treat-custom)
1570 (defvar gnus-article-encrypt-protocol-alist
1571 '(("PGP" . mml2015-self-encrypt)))
1573 ;; Set to nil if more than one protocol added to
1574 ;; gnus-article-encrypt-protocol-alist.
1575 (defcustom gnus-article-encrypt-protocol "PGP"
1576 "The protocol used for encrypt articles.
1577 It is a string, such as \"PGP\". If nil, ask user."
1580 :group 'mime-security)
1582 (defvar gnus-article-wash-function nil
1583 "Function used for converting HTML into text.")
1585 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1586 (mm-coding-system-p 'utf-8)
1587 (executable-find idna-program))
1588 "Whether IDNA decoding of headers is used when viewing messages.
1589 This requires GNU Libidn, and by default only enabled if it is found."
1591 :group 'gnus-article-headers
1594 (defcustom gnus-article-over-scroll nil
1595 "If non-nil, allow scrolling the article buffer even when there no more text."
1597 :group 'gnus-article
1600 ;;; Internal variables
1602 (defvar gnus-english-month-names
1603 '("January" "February" "March" "April" "May" "June" "July" "August"
1604 "September" "October" "November" "December"))
1606 (defvar gnus-button-regexp nil)
1607 (defvar gnus-button-marker-list nil)
1608 ;; Regexp matching any of the regexps from `gnus-button-alist'.
1610 (defvar gnus-button-last nil)
1611 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
1613 (defvar article-goto-body-goes-to-point-min-p nil)
1614 (defvar gnus-article-wash-types nil)
1615 (defvar gnus-article-emphasis-alist nil)
1616 (defvar gnus-article-image-alist nil)
1618 (defvar gnus-article-mime-handle-alist-1 nil)
1619 (defvar gnus-treatment-function-alist
1620 '((gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1621 (gnus-treat-strip-banner gnus-article-strip-banner)
1622 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1623 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1624 (gnus-treat-buttonize gnus-article-add-buttons)
1625 (gnus-treat-fill-article gnus-article-fill-cited-article)
1626 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1627 (gnus-treat-strip-cr gnus-article-remove-cr)
1628 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1629 (gnus-treat-date-ut gnus-article-date-ut)
1630 (gnus-treat-date-local gnus-article-date-local)
1631 (gnus-treat-date-english gnus-article-date-english)
1632 (gnus-treat-date-original gnus-article-date-original)
1633 (gnus-treat-date-user-defined gnus-article-date-user)
1634 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1635 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1636 (gnus-treat-display-x-face gnus-article-display-x-face)
1637 (gnus-treat-display-face gnus-article-display-face)
1638 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1639 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1640 (gnus-treat-hide-signature gnus-article-hide-signature)
1641 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1642 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1643 (gnus-treat-strip-pem gnus-article-hide-pem)
1644 (gnus-treat-from-picon gnus-treat-from-picon)
1645 (gnus-treat-mail-picon gnus-treat-mail-picon)
1646 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1647 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1648 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1649 (gnus-treat-strip-trailing-blank-lines
1650 gnus-article-remove-trailing-blank-lines)
1651 (gnus-treat-strip-leading-blank-lines
1652 gnus-article-strip-leading-blank-lines)
1653 (gnus-treat-strip-multiple-blank-lines
1654 gnus-article-strip-multiple-blank-lines)
1655 (gnus-treat-overstrike gnus-article-treat-overstrike)
1656 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1657 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1658 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1659 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1660 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1661 (gnus-treat-display-smileys gnus-treat-smiley)
1662 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1663 (gnus-treat-wash-html gnus-article-wash-html)
1664 (gnus-treat-emphasize gnus-article-emphasize)
1665 (gnus-treat-hide-citation gnus-article-hide-citation)
1666 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1667 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1668 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1669 (gnus-treat-play-sounds gnus-earcon-display)))
1671 (defvar gnus-article-mime-handle-alist nil)
1672 (defvar article-lapsed-timer nil)
1673 (defvar gnus-article-current-summary nil)
1675 (defvar gnus-article-mode-syntax-table
1676 (let ((table (copy-syntax-table text-mode-syntax-table)))
1677 ;; This causes the citation match run O(2^n).
1678 ;; (modify-syntax-entry ?- "w" table)
1679 (modify-syntax-entry ?> ")<" table)
1680 (modify-syntax-entry ?< "(>" table)
1681 ;; make M-. in article buffers work for `foo' strings
1682 (modify-syntax-entry ?' " " table)
1683 (modify-syntax-entry ?` " " table)
1685 "Syntax table used in article mode buffers.
1686 Initialized from `text-mode-syntax-table.")
1688 (defvar gnus-save-article-buffer nil)
1690 (defvar gnus-article-mode-line-format-alist
1691 (nconc '((?w (gnus-article-wash-status) ?s)
1692 (?m (gnus-article-mime-part-status) ?s))
1693 gnus-summary-mode-line-format-alist))
1695 (defvar gnus-number-of-articles-to-be-saved nil)
1697 (defvar gnus-inhibit-hiding nil)
1699 (defvar gnus-article-edit-mode nil)
1701 ;;; Macros for dealing with the article buffer.
1703 (defmacro gnus-with-article-headers (&rest forms)
1705 (set-buffer gnus-article-buffer)
1707 (let ((inhibit-read-only t)
1708 (inhibit-point-motion-hooks t)
1709 (case-fold-search t))
1710 (article-narrow-to-head)
1713 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1714 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1716 (defmacro gnus-with-article-buffer (&rest forms)
1718 (set-buffer gnus-article-buffer)
1719 (let ((inhibit-read-only t))
1722 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1723 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1725 (defun gnus-article-goto-header (header)
1726 "Go to HEADER, which is a regular expression."
1727 (re-search-forward (concat "^\\(" header "\\):") nil t))
1729 (defsubst gnus-article-hide-text (b e props)
1730 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1731 (gnus-add-text-properties-when 'article-type nil b e props)
1732 (when (memq 'intangible props)
1734 (max (1- b) (point-min))
1735 b 'intangible (cddr (memq 'intangible props)))))
1737 (defsubst gnus-article-unhide-text (b e)
1738 "Remove hidden text properties from region between B and E."
1739 (remove-text-properties b e gnus-hidden-properties)
1740 (when (memq 'intangible gnus-hidden-properties)
1741 (put-text-property (max (1- b) (point-min))
1742 b 'intangible nil)))
1744 (defun gnus-article-hide-text-type (b e type)
1745 "Hide text of TYPE between B and E."
1746 (gnus-add-wash-type type)
1747 (gnus-article-hide-text
1748 b e (cons 'article-type (cons type gnus-hidden-properties))))
1750 (defun gnus-article-unhide-text-type (b e type)
1751 "Unhide text of TYPE between B and E."
1752 (gnus-delete-wash-type type)
1753 (remove-text-properties
1754 b e (cons 'article-type (cons type gnus-hidden-properties)))
1755 (when (memq 'intangible gnus-hidden-properties)
1756 (put-text-property (max (1- b) (point-min))
1757 b 'intangible nil)))
1759 (defun gnus-article-hide-text-of-type (type)
1760 "Hide text of TYPE in the current buffer."
1762 (let ((b (point-min))
1764 (while (setq b (text-property-any b e 'article-type type))
1765 (add-text-properties b (incf b) gnus-hidden-properties)))))
1767 (defun gnus-article-delete-text-of-type (type)
1768 "Delete text of TYPE in the current buffer."
1770 (let ((b (point-min)))
1771 (if (eq type 'multipart)
1772 ;; Remove MIME buttons associated with multipart/alternative parts.
1775 (while (if (get-text-property (point) 'gnus-part)
1777 (when (setq b (next-single-property-change (point)
1782 (skip-chars-forward "\n")
1783 (when (eq (get-text-property b 'article-type) 'multipart)
1784 (delete-region b (point)))))
1785 (while (setq b (text-property-any b (point-max) 'article-type type))
1787 b (or (text-property-not-all b (point-max) 'article-type type)
1790 (defun gnus-article-delete-invisible-text ()
1791 "Delete all invisible text in the current buffer."
1793 (let ((b (point-min)))
1794 (while (setq b (text-property-any b (point-max) 'invisible t))
1796 b (or (text-property-not-all b (point-max) 'invisible t)
1799 (defun gnus-article-text-type-exists-p (type)
1800 "Say whether any text of type TYPE exists in the buffer."
1801 (text-property-any (point-min) (point-max) 'article-type type))
1803 (defsubst gnus-article-header-rank ()
1804 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1805 (let ((list gnus-sorted-header-list)
1808 (if (looking-at (car list))
1810 (setq list (cdr list))
1814 (defun article-hide-headers (&optional arg delete)
1815 "Hide unwanted headers and possibly sort them as well."
1817 ;; This function might be inhibited.
1818 (unless gnus-inhibit-hiding
1819 (let ((inhibit-read-only nil)
1820 (case-fold-search t)
1821 (max (1+ (length gnus-sorted-header-list)))
1822 (inhibit-point-motion-hooks t)
1823 (cur (current-buffer))
1824 ignored visible beg)
1826 ;; `gnus-ignored-headers' and `gnus-visible-headers' may be
1827 ;; group parameters, so we should go to the summary buffer.
1830 (progn (set-buffer gnus-summary-buffer) t)
1832 (setq ignored (when (not gnus-visible-headers)
1833 (cond ((stringp gnus-ignored-headers)
1834 gnus-ignored-headers)
1835 ((listp gnus-ignored-headers)
1836 (mapconcat 'identity
1837 gnus-ignored-headers
1839 visible (cond ((stringp gnus-visible-headers)
1840 gnus-visible-headers)
1841 ((and gnus-visible-headers
1842 (listp gnus-visible-headers))
1843 (mapconcat 'identity
1844 gnus-visible-headers
1848 ;; First we narrow to just the headers.
1849 (article-narrow-to-head)
1850 ;; Hide any "From " lines at the beginning of (mail) articles.
1851 (while (looking-at "From ")
1854 (delete-region (point-min) (point)))
1855 ;; Then treat the rest of the header lines.
1856 ;; Then we use the two regular expressions
1857 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1858 ;; select which header lines is to remain visible in the
1860 (while (re-search-forward "^[^ \t:]*:" nil t)
1862 ;; Mark the rank of the header.
1864 (point) (1+ (point)) 'message-rank
1865 (if (or (and visible (looking-at visible))
1867 (not (looking-at ignored))))
1868 (gnus-article-header-rank)
1871 (message-sort-headers-1)
1872 (when (setq beg (text-property-any
1873 (point-min) (point-max) 'message-rank (+ 2 max)))
1874 ;; We delete the unwanted headers.
1875 (gnus-add-wash-type 'headers)
1876 (add-text-properties (point-min) (+ 5 (point-min))
1877 '(article-type headers dummy-invisible t))
1878 (delete-region beg (point-max))))))))
1880 (defun article-hide-boring-headers (&optional arg)
1881 "Toggle hiding of headers that aren't very interesting.
1882 If given a negative prefix, always show; if given a positive prefix,
1884 (interactive (gnus-article-hidden-arg))
1885 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1886 (not gnus-show-all-headers))
1889 (let ((inhibit-read-only t)
1890 (inhibit-point-motion-hooks t))
1891 (article-narrow-to-head)
1892 (dolist (elem gnus-boring-article-headers)
1893 (goto-char (point-min))
1895 ;; Hide empty headers.
1897 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1899 (gnus-article-hide-text-type
1903 (if (re-search-forward "^[^ \t]" nil t)
1907 ;; Hide boring Newsgroups header.
1908 ((eq elem 'newsgroups)
1909 (when (gnus-string-equal
1910 (gnus-fetch-field "newsgroups")
1911 (gnus-group-real-name
1912 (if (boundp 'gnus-newsgroup-name)
1915 (gnus-article-hide-header "newsgroups")))
1916 ((eq elem 'to-address)
1917 (let ((to (message-fetch-field "to"))
1919 (gnus-parameter-to-address
1920 (if (boundp 'gnus-newsgroup-name)
1921 gnus-newsgroup-name ""))))
1922 (when (and to to-address
1925 ;; only one address in To
1926 (nth 1 (mail-extract-address-components to))
1928 (gnus-article-hide-header "to"))))
1930 (let ((to (message-fetch-field "to"))
1932 (gnus-parameter-to-list
1933 (if (boundp 'gnus-newsgroup-name)
1934 gnus-newsgroup-name ""))))
1935 (when (and to to-list
1938 ;; only one address in To
1939 (nth 1 (mail-extract-address-components to))
1941 (gnus-article-hide-header "to"))))
1943 (let ((cc (message-fetch-field "cc"))
1945 (gnus-parameter-to-list
1946 (if (boundp 'gnus-newsgroup-name)
1947 gnus-newsgroup-name ""))))
1948 (when (and cc to-list
1951 ;; only one address in CC
1952 (nth 1 (mail-extract-address-components cc))
1954 (gnus-article-hide-header "cc"))))
1955 ((eq elem 'followup-to)
1956 (when (gnus-string-equal
1957 (message-fetch-field "followup-to")
1958 (message-fetch-field "newsgroups"))
1959 (gnus-article-hide-header "followup-to")))
1960 ((eq elem 'reply-to)
1961 (if (gnus-group-find-parameter
1962 gnus-newsgroup-name 'broken-reply-to)
1963 (gnus-article-hide-header "reply-to")
1964 (let ((from (message-fetch-field "from"))
1965 (reply-to (message-fetch-field "reply-to")))
1972 (lambda (x) (downcase (cadr x)))
1973 (mail-extract-address-components from t))
1976 (lambda (x) (downcase (cadr x)))
1977 (mail-extract-address-components reply-to t))
1979 (gnus-article-hide-header "reply-to")))))
1981 (let ((date (message-fetch-field "date")))
1983 (< (days-between (current-time-string) date)
1985 (gnus-article-hide-header "date"))))
1987 (let ((to (message-fetch-field "to"))
1988 (cc (message-fetch-field "cc")))
1989 (when (> (length to) 1024)
1990 (gnus-article-hide-header "to"))
1991 (when (> (length cc) 1024)
1992 (gnus-article-hide-header "cc"))))
1996 (goto-char (point-min))
1997 (while (re-search-forward "^to:" nil t)
1998 (setq to-count (1+ to-count)))
1999 (when (> to-count 1)
2000 (while (> to-count 0)
2001 (goto-char (point-min))
2003 (re-search-forward "^to:" nil nil to-count)
2005 (narrow-to-region (point) (point-max))
2006 (gnus-article-hide-header "to"))
2007 (setq to-count (1- to-count))))
2008 (goto-char (point-min))
2009 (while (re-search-forward "^cc:" nil t)
2010 (setq cc-count (1+ cc-count)))
2011 (when (> cc-count 1)
2012 (while (> cc-count 0)
2013 (goto-char (point-min))
2015 (re-search-forward "^cc:" nil nil cc-count)
2017 (narrow-to-region (point) (point-max))
2018 (gnus-article-hide-header "cc"))
2019 (setq cc-count (1- cc-count)))))))))))))
2021 (defun gnus-article-hide-header (header)
2023 (goto-char (point-min))
2024 (when (re-search-forward (concat "^" header ":") nil t)
2025 (gnus-article-hide-text-type
2029 (if (re-search-forward "^[^ \t]" nil t)
2034 (defvar gnus-article-normalized-header-length 40
2035 "Length of normalized headers.")
2037 (defun article-normalize-headers ()
2038 "Make all header lines 40 characters long."
2040 (let ((inhibit-read-only t)
2044 (article-narrow-to-head)
2047 ((< (setq column (- (point-at-eol) (point)))
2048 gnus-article-normalized-header-length)
2050 (insert (make-string
2051 (- gnus-article-normalized-header-length column)
2053 ((> column gnus-article-normalized-header-length)
2054 (gnus-put-text-property
2056 (forward-char gnus-article-normalized-header-length)
2063 (forward-line 1))))))
2065 (defun article-treat-dumbquotes ()
2066 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
2067 Note that this function guesses whether a character is a sm*rtq**t* or
2068 not, so it should only be used interactively.
2070 Sm*rtq**t*s are M****s***'s unilateral extension to the
2071 iso-8859-1 character map in an attempt to provide more quoting
2072 characters. If you see something like \\222 or \\264 where
2073 you're expecting some kind of apostrophe or quotation mark, then
2076 (article-translate-strings gnus-article-dumbquotes-map))
2078 (defun article-translate-characters (from to)
2079 "Translate all characters in the body of the article according to FROM and TO.
2080 FROM is a string of characters to translate from; to is a string of
2081 characters to translate to."
2083 (when (article-goto-body)
2084 (let ((inhibit-read-only t)
2085 (x (make-string 225 ?x))
2087 (while (< (incf i) (length x))
2090 (while (< i (length from))
2091 (aset x (aref from i) (aref to i))
2093 (translate-region (point) (point-max) x)))))
2095 (defun article-translate-strings (map)
2096 "Translate all string in the body of the article according to MAP.
2097 MAP is an alist where the elements are on the form (\"from\" \"to\")."
2099 (when (article-goto-body)
2100 (let ((inhibit-read-only t))
2103 (while (search-forward (car elem) nil t)
2104 (replace-match (cadr elem)))))))))
2106 (defun article-treat-overstrike ()
2107 "Translate overstrikes into bold text."
2110 (when (article-goto-body)
2111 (let ((inhibit-read-only t))
2112 (while (search-forward "\b" nil t)
2113 (let ((next (char-after))
2114 (previous (char-after (- (point) 2))))
2115 ;; We do the boldification/underlining by hiding the
2116 ;; overstrikes and putting the proper text property
2120 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
2121 (put-text-property (point) (1+ (point)) 'face 'bold))
2123 (gnus-article-hide-text-type
2124 (1- (point)) (1+ (point)) 'overstrike)
2126 (- (point) 2) (1- (point)) 'face 'underline))
2128 (gnus-article-hide-text-type (- (point) 2) (point) 'overstrike)
2130 (point) (1+ (point)) 'face 'underline)))))))))
2132 (defun article-treat-ansi-sequences ()
2133 "Translate ANSI SGR control sequences into overlays or extents."
2136 (when (article-goto-body)
2137 (let ((inhibit-read-only t))
2138 (ansi-color-apply-on-region (point) (point-max))))))
2140 (defun gnus-article-treat-unfold-headers ()
2141 "Unfold folded message headers.
2142 Only the headers that fit into the current window width will be
2145 (gnus-with-article-headers
2149 (mail-header-narrow-to-field)
2150 (let* ((header (buffer-string))
2152 (or (equal gnus-article-unfold-long-headers t)
2153 (and (stringp gnus-article-unfold-long-headers)
2154 (string-match gnus-article-unfold-long-headers header)))))
2157 (goto-char (point-min))
2158 (while (re-search-forward "\n[\t ]" nil t)
2159 (replace-match " " t t)))
2160 (setq length (- (point-max) (point-min) 1))
2161 (when (or unfoldable
2162 (< length (window-width)))
2163 (while (re-search-forward "\n[\t ]" nil t)
2164 (replace-match " " t t))))
2165 (goto-char (point-max)))))))
2167 (defun gnus-article-treat-fold-headers ()
2168 "Fold message headers."
2170 (gnus-with-article-headers
2173 (mail-header-narrow-to-field)
2174 (mail-header-fold-field)
2175 (goto-char (point-max))))))
2177 (defun gnus-treat-smiley ()
2178 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2180 (gnus-with-article-buffer
2181 (if (memq 'smiley gnus-article-wash-types)
2182 (gnus-delete-images 'smiley)
2184 (let ((images (smiley-region (point) (point-max))))
2186 (gnus-add-wash-type 'smiley)
2187 (dolist (image images)
2188 (gnus-add-image 'smiley image)))))))
2190 (defun gnus-article-remove-images ()
2191 "Remove all images from the article buffer."
2193 (gnus-with-article-buffer
2194 (dolist (elem gnus-article-image-alist)
2195 (gnus-delete-images (car elem)))))
2197 (defun gnus-article-treat-fold-newsgroups ()
2198 "Unfold folded message headers.
2199 Only the headers that fit into the current window width will be
2202 (gnus-with-article-headers
2203 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2205 (mail-header-narrow-to-field)
2206 (while (re-search-forward ", *" nil t)
2207 (replace-match ", " t t))
2208 (mail-header-fold-field)
2209 (goto-char (point-max))))))
2211 (defcustom gnus-article-truncate-lines truncate-lines
2212 "Value of `truncate-lines' in Gnus Article buffer.
2213 Valid values are nil, t, `head', `first', `last', an integer or a
2214 predicate. See Info node `(gnus)Customizing Articles'."
2215 :version "23.0" ;; No Gnus
2216 :group 'gnus-article
2217 ;; :link '(custom-manual "(gnus)Customizing Articles")
2220 (defun gnus-article-toggle-truncate-lines (&optional arg)
2221 "Toggle whether to fold or truncate long lines in article the buffer.
2222 If ARG is non-nil and not a number, toggle
2223 `gnus-article-truncate-lines' too. If ARG is a number, truncate
2224 long lines iff arg is positive."
2226 (when (and arg (not (numberp arg)))
2227 (setq gnus-article-truncate-lines
2228 (not gnus-article-truncate-lines)))
2229 (gnus-with-article-buffer
2230 ;; In versions of Emacs 22 (CVS) before 2006-05-26,
2231 ;; `toggle-truncate-lines' need an argument.
2232 (toggle-truncate-lines)))
2234 (defun gnus-article-treat-body-boundary ()
2235 "Place a boundary line at the end of the headers."
2237 (when (and gnus-body-boundary-delimiter
2238 (> (length gnus-body-boundary-delimiter) 0))
2239 (gnus-with-article-headers
2240 (goto-char (point-max))
2241 (let ((start (point)))
2242 (insert "X-Boundary: ")
2243 (gnus-add-text-properties start (point) '(invisible t intangible t))
2245 (while (>= (1- (window-width)) (length str))
2246 (setq str (concat str gnus-body-boundary-delimiter)))
2247 (substring str 0 (1- (window-width))))
2249 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2251 (defun article-fill-long-lines ()
2252 "Fill lines that are wider than the window width."
2255 (let ((inhibit-read-only t)
2256 (width (window-width (get-buffer-window (current-buffer)))))
2259 (let ((adaptive-fill-mode nil)) ;Why? -sm
2262 (when (>= (current-column) (min fill-column width))
2263 (narrow-to-region (min (1+ (point)) (point-max))
2265 (let ((goback (point-marker)))
2266 (fill-paragraph nil)
2267 (goto-char (marker-position goback)))
2269 (forward-line 1)))))))
2271 (defun article-capitalize-sentences ()
2272 "Capitalize the first word in each sentence."
2275 (let ((inhibit-read-only t)
2276 (paragraph-start "^[\n\^L]"))
2280 (forward-sentence)))))
2282 (defun article-remove-cr ()
2283 "Remove trailing CRs and then translate remaining CRs into LFs."
2286 (let ((inhibit-read-only t))
2287 (goto-char (point-min))
2288 (while (re-search-forward "\r+$" nil t)
2289 (replace-match "" t t))
2290 (goto-char (point-min))
2291 (while (search-forward "\r" nil t)
2292 (replace-match "\n" t t)))))
2294 (defun article-remove-trailing-blank-lines ()
2295 "Remove all trailing blank lines from the article."
2298 (let ((inhibit-read-only t))
2299 (goto-char (point-max))
2303 (while (and (not (bobp))
2304 (looking-at "^[ \t]*$")
2305 (not (gnus-annotation-in-region-p
2306 (point) (point-at-eol))))
2312 (defvar gnus-face-properties-alist))
2314 (defun article-display-face ()
2315 "Display any Face headers in the header."
2317 (let ((wash-face-p buffer-read-only))
2318 (gnus-with-article-headers
2319 ;; When displaying parts, this function can be called several times on
2320 ;; the same article, without any intended toggle semantic (as typing `W
2321 ;; D d' would have). So face deletion must occur only when we come from
2322 ;; an interactive command, that is when the *Article* buffer is
2324 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2325 (gnus-delete-images 'face)
2326 (let (face faces from)
2327 (save-current-buffer
2328 (when (and wash-face-p
2329 (gnus-buffer-live-p gnus-original-article-buffer)
2330 (not (re-search-forward "^Face:[\t ]*" nil t)))
2331 (set-buffer gnus-original-article-buffer))
2333 (mail-narrow-to-head)
2334 (while (gnus-article-goto-header "Face")
2335 (push (mail-header-field-value) faces))))
2337 (goto-char (point-min))
2338 (let ((from (gnus-article-goto-header "from"))
2343 (insert "[no `from' set]\n"))
2345 (when (setq png (gnus-convert-face-to-png (pop faces)))
2347 (apply 'gnus-create-image png 'png t
2348 (cdr (assq 'png gnus-face-properties-alist))))
2350 (gnus-add-wash-type 'face)
2351 (gnus-add-image 'face image)
2352 (gnus-put-image image nil 'face))))))))))
2354 (defun article-display-x-face (&optional force)
2355 "Look for an X-Face header and display it if present."
2356 (interactive (list 'force))
2357 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2358 (gnus-with-article-headers
2359 ;; Delete the old process, if any.
2360 (when (process-status "article-x-face")
2361 (delete-process "article-x-face"))
2362 ;; See the comment in `article-display-face'.
2363 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2364 ;; We have already displayed X-Faces, so we remove them
2366 (gnus-delete-images 'xface)
2368 (let (x-faces from face)
2369 (save-current-buffer
2370 (when (and wash-face-p
2371 (gnus-buffer-live-p gnus-original-article-buffer)
2372 (not (re-search-forward "^X-Face:[\t ]*" nil t)))
2373 ;; If type `W f', use gnus-original-article-buffer,
2374 ;; otherwise use the current buffer because displaying
2375 ;; RFC822 parts calls this function too.
2376 (set-buffer gnus-original-article-buffer))
2378 (mail-narrow-to-head)
2379 (while (gnus-article-goto-header "X-Face")
2380 (push (mail-header-field-value) x-faces))
2381 (setq from (message-fetch-field "from"))))
2382 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2383 ;; single external face.
2384 (when (stringp gnus-article-x-face-command)
2385 (setq x-faces (list (car x-faces))))
2387 gnus-article-x-face-command
2389 ;; Check whether this face is censored.
2390 (not gnus-article-x-face-too-ugly)
2392 (not (string-match gnus-article-x-face-too-ugly
2394 (while (setq face (pop x-faces))
2395 ;; We display the face.
2396 (cond ((stringp gnus-article-x-face-command)
2397 ;; The command is a string, so we interpret the command
2398 ;; as a, well, command, and fork it off.
2399 (let ((process-connection-type nil))
2400 (gnus-set-process-query-on-exit-flag
2402 "article-x-face" nil shell-file-name
2403 shell-command-switch gnus-article-x-face-command)
2407 (process-send-region "article-x-face"
2408 (point-min) (point-max)))
2409 (process-send-eof "article-x-face")))
2410 ((functionp gnus-article-x-face-command)
2411 ;; The command is a lisp function, so we call it.
2412 (funcall gnus-article-x-face-command face))
2414 (error "%s is not a function"
2415 gnus-article-x-face-command))))))))))
2417 (defun article-decode-mime-words ()
2418 "Decode all MIME-encoded words in the article."
2420 (gnus-with-article-buffer
2421 (let ((inhibit-point-motion-hooks t)
2422 (mail-parse-charset gnus-newsgroup-charset)
2423 (mail-parse-ignored-charsets
2424 (with-current-buffer gnus-summary-buffer
2425 gnus-newsgroup-ignored-charsets)))
2426 (mail-decode-encoded-word-region (point-min) (point-max)))))
2428 (defun article-decode-charset (&optional prompt)
2429 "Decode charset-encoded text in the article.
2430 If PROMPT (the prefix), prompt for a coding system to use."
2432 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2433 (inhibit-read-only t)
2434 (mail-parse-charset gnus-newsgroup-charset)
2435 (mail-parse-ignored-charsets
2436 (save-excursion (condition-case nil
2437 (set-buffer gnus-summary-buffer)
2439 gnus-newsgroup-ignored-charsets))
2440 ct cte ctl charset format)
2443 (article-narrow-to-head)
2444 (setq ct (message-fetch-field "Content-Type" t)
2445 cte (message-fetch-field "Content-Transfer-Encoding" t)
2446 ctl (and ct (mail-header-parse-content-type ct))
2449 (mm-read-coding-system "Charset to decode: "))
2451 (mail-content-type-get ctl 'charset)))
2452 format (and ctl (mail-content-type-get ctl 'format)))
2454 (setq cte (mail-header-strip cte)))
2455 (if (and ctl (not (string-match "/" (car ctl))))
2457 (goto-char (point-max)))
2460 (narrow-to-region (point) (point-max))
2461 (when (and (eq mail-parse-charset 'gnus-decoded)
2462 (eq (mm-body-7-or-8) '8bit))
2463 ;; The text code could have been decoded.
2464 (setq charset mail-parse-charset))
2465 (when (and (or (not ctl)
2466 (equal (car ctl) "text/plain"))
2467 (not format)) ;; article with format will decode later.
2469 charset (and cte (intern (downcase
2470 (gnus-strip-whitespace cte))))
2473 (defun article-decode-encoded-words ()
2474 "Remove encoded-word encoding from headers."
2475 (let ((inhibit-point-motion-hooks t)
2476 (mail-parse-charset gnus-newsgroup-charset)
2477 (mail-parse-ignored-charsets
2478 (save-excursion (condition-case nil
2479 (set-buffer gnus-summary-buffer)
2481 gnus-newsgroup-ignored-charsets))
2482 (inhibit-read-only t))
2484 (article-narrow-to-head)
2485 (funcall gnus-decode-header-function (point-min) (point-max)))))
2487 (defun article-decode-group-name ()
2488 "Decode group names in `Newsgroups:'."
2489 (let ((inhibit-point-motion-hooks t)
2490 (inhibit-read-only t)
2491 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2492 (when (and (or gnus-group-name-charset-method-alist
2493 gnus-group-name-charset-group-alist)
2494 (gnus-buffer-live-p gnus-original-article-buffer))
2496 (article-narrow-to-head)
2497 (with-current-buffer gnus-original-article-buffer
2498 (goto-char (point-min)))
2499 (while (re-search-forward
2500 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2501 (replace-match (save-match-data
2502 (gnus-decode-newsgroups
2503 ;; XXX how to use data in article buffer?
2504 (with-current-buffer gnus-original-article-buffer
2506 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2509 gnus-newsgroup-name method))
2511 (goto-char (point-min))
2512 (with-current-buffer gnus-original-article-buffer
2513 (goto-char (point-min)))
2514 (while (re-search-forward
2515 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2516 (replace-match (save-match-data
2517 (gnus-decode-newsgroups
2518 ;; XXX how to use data in article buffer?
2519 (with-current-buffer gnus-original-article-buffer
2521 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2524 gnus-newsgroup-name method))
2527 (autoload 'idna-to-unicode "idna")
2529 (defun article-decode-idna-rhs ()
2530 "Decode IDNA strings in RHS in various headers in current buffer.
2531 The following headers are decoded: From:, To:, Cc:, Reply-To:,
2532 Mail-Reply-To: and Mail-Followup-To:."
2535 (let ((inhibit-point-motion-hooks t)
2536 (inhibit-read-only t))
2537 (article-narrow-to-head)
2538 (goto-char (point-min))
2539 (while (re-search-forward "@[^ \t\n\r,>]*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2541 (when (save-match-data
2542 (and (setq ace (match-string 1))
2544 (and (re-search-backward "^[^ \t]" nil t)
2545 (looking-at "From\\|To\\|Cc\\|Reply-To\\|Mail-Reply-To\\|Mail-Followup-To")))
2546 (setq unicode (idna-to-unicode ace))))
2547 (unless (string= ace unicode)
2548 (replace-match unicode nil nil nil 1)))))))))
2550 (defun article-de-quoted-unreadable (&optional force read-charset)
2551 "Translate a quoted-printable-encoded article.
2552 If FORCE, decode the article whether it is marked as quoted-printable
2554 If READ-CHARSET, ask for a coding system."
2555 (interactive (list 'force current-prefix-arg))
2557 (let ((inhibit-read-only t) type charset)
2558 (if (gnus-buffer-live-p gnus-original-article-buffer)
2559 (with-current-buffer gnus-original-article-buffer
2561 (gnus-fetch-field "content-transfer-encoding"))
2562 (let* ((ct (gnus-fetch-field "content-type"))
2563 (ctl (and ct (mail-header-parse-content-type ct))))
2564 (setq charset (and ctl
2565 (mail-content-type-get ctl 'charset)))
2566 (if (stringp charset)
2567 (setq charset (intern (downcase charset)))))))
2569 (setq charset (mm-read-coding-system "Charset: " charset)))
2571 (setq charset gnus-newsgroup-charset))
2573 (and type (let ((case-fold-search t))
2574 (string-match "quoted-printable" type))))
2576 (quoted-printable-decode-region
2577 (point) (point-max) (mm-charset-to-coding-system charset))))))
2579 (defun article-de-base64-unreadable (&optional force read-charset)
2580 "Translate a base64 article.
2581 If FORCE, decode the article whether it is marked as base64 not.
2582 If READ-CHARSET, ask for a coding system."
2583 (interactive (list 'force current-prefix-arg))
2585 (let ((inhibit-read-only t) type charset)
2586 (if (gnus-buffer-live-p gnus-original-article-buffer)
2587 (with-current-buffer gnus-original-article-buffer
2589 (gnus-fetch-field "content-transfer-encoding"))
2590 (let* ((ct (gnus-fetch-field "content-type"))
2591 (ctl (and ct (mail-header-parse-content-type ct))))
2592 (setq charset (and ctl
2593 (mail-content-type-get ctl 'charset)))
2594 (if (stringp charset)
2595 (setq charset (intern (downcase charset)))))))
2597 (setq charset (mm-read-coding-system "Charset: " charset)))
2599 (setq charset gnus-newsgroup-charset))
2601 (and type (let ((case-fold-search t))
2602 (string-match "base64" type))))
2605 (narrow-to-region (point) (point-max))
2606 (base64-decode-region (point-min) (point-max))
2607 (mm-decode-coding-region
2608 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2613 (defun article-decode-HZ ()
2614 "Translate a HZ-encoded article."
2618 (let ((inhibit-read-only t))
2619 (rfc1843-decode-region (point-min) (point-max)))))
2621 (defun article-unsplit-urls ()
2622 "Remove the newlines that some other mailers insert into URLs."
2625 (let ((inhibit-read-only t))
2626 (goto-char (point-min))
2627 (while (re-search-forward
2628 "\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2629 (replace-match "\\1\\3" t)))
2630 (when (interactive-p)
2631 (gnus-treat-article nil))))
2634 (defun article-wash-html (&optional read-charset)
2635 "Format an HTML article.
2636 If READ-CHARSET, ask for a coding system. If it is a number, the
2637 charset defined in `gnus-summary-show-article-charset-alist' is used."
2640 (let ((inhibit-read-only t)
2643 (if (or (and (numberp read-charset)
2647 gnus-summary-show-article-charset-alist))))
2648 (setq charset (mm-read-coding-system "Charset: ")))
2649 (let ((gnus-summary-show-article-charset-alist
2650 (list (cons 1 charset))))
2651 (with-current-buffer gnus-summary-buffer
2652 (gnus-summary-show-article 1)))
2653 (error "No charset is given"))
2654 (when (gnus-buffer-live-p gnus-original-article-buffer)
2655 (with-current-buffer gnus-original-article-buffer
2656 (let* ((ct (gnus-fetch-field "content-type"))
2657 (ctl (and ct (mail-header-parse-content-type ct))))
2658 (setq charset (and ctl
2659 (mail-content-type-get ctl 'charset)))
2660 (when (stringp charset)
2661 (setq charset (intern (downcase charset)))))))
2663 (setq charset gnus-newsgroup-charset)))
2665 (save-window-excursion
2667 (narrow-to-region (point) (point-max))
2668 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2669 (entry (assq func mm-text-html-washer-alist)))
2671 (setq func (cdr entry)))
2676 (apply (car func) (cdr func))))))))))
2678 (defun gnus-article-wash-html-with-w3 ()
2679 "Wash the current buffer with w3."
2681 (let ((w3-strict-width (window-width))
2682 (url-standalone-mode t)
2683 (url-gateway-unplugged t)
2684 (w3-honor-stylesheets nil))
2686 (w3-region (point-min) (point-max))
2689 (defun gnus-article-wash-html-with-w3m ()
2690 "Wash the current buffer with emacs-w3m."
2692 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2693 w3m-force-redisplay)
2694 (w3m-region (point-min) (point-max)))
2695 (when (and mm-inline-text-html-with-w3m-keymap
2696 (boundp 'w3m-minor-mode-map)
2698 (add-text-properties
2699 (point-min) (point-max)
2700 (list 'keymap w3m-minor-mode-map
2701 ;; Put the mark meaning this part was rendered by emacs-w3m.
2702 'mm-inline-text-html-with-w3m t))))
2704 (eval-when-compile (defvar charset)) ;; Bound by `article-wash-html'.
2706 (defun gnus-article-wash-html-with-w3m-standalone ()
2707 "Wash the current buffer with w3m."
2708 (if (mm-w3m-standalone-supports-m17n-p)
2710 (unless (mm-coding-system-p charset) ;; Bound by `article-wash-html'.
2712 (setq charset 'iso-8859-1))
2713 (let ((coding-system-for-write charset)
2714 (coding-system-for-read charset))
2715 (call-process-region
2716 (point-min) (point-max)
2717 "w3m" t t nil "-dump" "-T" "text/html"
2718 "-I" (symbol-name charset) "-O" (symbol-name charset))))
2719 (mm-inline-wash-with-stdin nil "w3m" "-dump" "-T" "text/html")))
2721 (defvar gnus-article-browse-html-temp-list nil
2722 "List of temporary files created by `gnus-article-browse-html-parts'.
2723 Internal variable.")
2725 (defcustom gnus-article-browse-delete-temp 'ask
2726 "What to do with temporary files from `gnus-article-browse-html-parts'.
2727 If nil, don't delete temporary files. If it is t, delete them on
2728 exit from the summary buffer. If it is the symbol `file', query
2729 on each file, if it is `ask' ask once when exiting from the
2731 :group 'gnus-article
2732 :version "23.0" ;; No Gnus
2733 :type '(choice (const :tag "Don't delete" nil)
2734 (const :tag "Don't ask" t)
2735 (const :tag "Ask" ask)
2736 (const :tag "Ask for each file" file)))
2738 ;; Cf. mm-postponed-undisplay-list / mm-destroy-postponed-undisplay-list.
2740 (defun gnus-article-browse-delete-temp-files (&optional how)
2741 "Delete temp-files created by `gnus-article-browse-html-parts'."
2742 (when (and gnus-article-browse-html-temp-list
2744 (setq how gnus-article-browse-delete-temp)))
2745 (when (and (eq how 'ask)
2747 "Delete all %s temporary HTML file(s)? "
2748 (length gnus-article-browse-html-temp-list)))
2750 (dolist (file gnus-article-browse-html-temp-list)
2751 (when (and (file-exists-p file)
2753 ;; `how' is neither `nil', `ask' nor `t' (i.e. `file'):
2755 (format "Delete temporary HTML file `%s'? " file))))
2756 (delete-file file)))
2757 ;; Also remove file from the list when not deleted or if file doesn't
2759 (setq gnus-article-browse-html-temp-list nil))
2760 gnus-article-browse-html-temp-list)
2762 (defun gnus-article-browse-html-parts (list)
2763 "View all \"text/html\" parts from LIST.
2764 Recurse into multiparts."
2765 ;; Internal function used by `gnus-article-browse-html-article'.
2767 ;; Find and show the html-parts.
2768 (dolist (handle list)
2769 ;; If HTML, show it:
2770 (when (listp handle)
2771 (cond ((and (bufferp (car handle))
2772 (string-match "text/html" (car (mm-handle-type handle))))
2773 (let ((tmp-file (mm-make-temp-file
2774 ;; Do we need to care for 8.3 filenames?
2775 "mm-" nil ".html")))
2776 (mm-save-part-to-file handle tmp-file)
2777 (add-to-list 'gnus-article-browse-html-temp-list tmp-file)
2778 (add-hook 'gnus-summary-prepare-exit-hook
2779 'gnus-article-browse-delete-temp-files)
2780 (add-hook 'gnus-exit-gnus-hook
2782 (gnus-article-browse-delete-temp-files t)))
2783 (browse-url tmp-file)
2785 ;; If multipart, recurse
2786 ((and (stringp (car handle))
2787 (string-match "^multipart/" (car handle))
2790 (gnus-article-browse-html-parts handle))))))))
2793 (defun gnus-article-browse-html-article ()
2794 "View \"text/html\" parts of the current article with a WWW browser."
2796 (save-window-excursion
2797 ;; Open raw article and select the buffer
2798 (gnus-summary-show-article t)
2799 (gnus-summary-select-article-buffer)
2800 (let ((parts (mm-dissect-buffer t t)))
2801 ;; If singlepart, enforce a list.
2802 (when (and (bufferp (car parts))
2803 (stringp (car (mm-handle-type parts))))
2804 (setq parts (list parts)))
2806 (unless (gnus-article-browse-html-parts parts)
2807 (gnus-error 3 "Mail doesn't contain a \"text/html\" part!"))
2808 (gnus-summary-show-article))))
2810 (defun article-hide-list-identifiers ()
2811 "Remove list identifies from the Subject header.
2812 The `gnus-list-identifiers' variable specifies what to do."
2814 (let ((inhibit-point-motion-hooks t)
2815 (regexp (if (consp gnus-list-identifiers)
2816 (mapconcat 'identity gnus-list-identifiers " *\\|")
2817 gnus-list-identifiers))
2818 (inhibit-read-only t))
2822 (article-narrow-to-head)
2823 (goto-char (point-min))
2824 (while (re-search-forward
2825 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2827 (delete-region (match-beginning 2) (match-end 0))
2828 (beginning-of-line))
2829 (when (re-search-forward
2830 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2831 (delete-region (match-beginning 1) (match-end 1))))))))
2833 (defun article-hide-pem (&optional arg)
2834 "Toggle hiding of any PEM headers and signatures in the current article.
2835 If given a negative prefix, always show; if given a positive prefix,
2837 (interactive (gnus-article-hidden-arg))
2838 (unless (gnus-article-check-hidden-text 'pem arg)
2840 (let ((inhibit-read-only t) end)
2841 (goto-char (point-min))
2842 ;; Hide the horrendously ugly "header".
2843 (when (and (search-forward
2844 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2846 (setq end (1+ (match-beginning 0))))
2847 (gnus-add-wash-type 'pem)
2848 (gnus-article-hide-text-type
2850 (if (search-forward "\n\n" nil t)
2854 ;; Hide the trailer as well
2855 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2857 (gnus-article-hide-text-type
2858 (match-beginning 0) (match-end 0) 'pem)))))))
2860 (defun article-strip-banner ()
2861 "Strip the banners specified by the `banner' group parameter and by
2862 `gnus-article-address-banner-alist'."
2866 (let ((inhibit-point-motion-hooks t))
2867 (when (gnus-parameter-banner gnus-newsgroup-name)
2868 (article-really-strip-banner
2869 (gnus-parameter-banner gnus-newsgroup-name)))
2870 (when gnus-article-address-banner-alist
2871 ;; Note that the From header is decoded here, so it is
2872 ;; required that the *-extract-address-components function
2873 ;; supports non-ASCII text.
2874 (let ((from (save-restriction
2876 (article-narrow-to-head)
2877 (mail-fetch-field "from"))))
2880 (cadr (funcall gnus-extract-address-components
2883 (dolist (pair gnus-article-address-banner-alist)
2884 (when (string-match (car pair) from)
2886 (article-really-strip-banner (cdr pair)))))))))))))
2888 (defun article-really-strip-banner (banner)
2889 "Strip the banner specified by the argument."
2892 (let ((inhibit-point-motion-hooks t)
2893 (gnus-signature-limit nil)
2894 (inhibit-read-only t))
2897 ((eq banner 'signature)
2898 (when (gnus-article-narrow-to-signature)
2901 (delete-region (point) (point-max))))
2903 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2904 (while (re-search-forward banner nil t)
2905 (delete-region (match-beginning 0) (match-end 0)))))
2907 (while (re-search-forward banner nil t)
2908 (delete-region (match-beginning 0) (match-end 0)))))))))
2910 (defun article-babel ()
2911 "Translate article using an online translation service."
2914 (gnus-with-article-buffer
2915 (when (article-goto-body)
2916 (let* ((start (point))
2918 (orig (buffer-substring start end))
2919 (trans (babel-as-string orig)))
2921 (narrow-to-region start end)
2922 (delete-region start end)
2925 (defun article-hide-signature (&optional arg)
2926 "Hide the signature in the current article.
2927 If given a negative prefix, always show; if given a positive prefix,
2929 (interactive (gnus-article-hidden-arg))
2930 (unless (gnus-article-check-hidden-text 'signature arg)
2933 (let ((inhibit-read-only t))
2934 (when (gnus-article-narrow-to-signature)
2935 (gnus-article-hide-text-type
2936 (point-min) (point-max) 'signature))))))
2937 (gnus-set-mode-line 'article))
2939 (defun article-strip-headers-in-body ()
2940 "Strip offensive headers from bodies."
2944 (let ((case-fold-search t))
2945 (when (looking-at "x-no-archive:")
2946 (gnus-delete-line)))))
2948 (defun article-strip-leading-blank-lines ()
2949 "Remove all blank lines from the beginning of the article."
2952 (let ((inhibit-point-motion-hooks t)
2953 (inhibit-read-only t))
2954 (when (article-goto-body)
2955 (while (and (not (eobp))
2956 (looking-at "[ \t]*$"))
2957 (gnus-delete-line))))))
2959 (defun article-narrow-to-head ()
2960 "Narrow the buffer to the head of the message.
2961 Point is left at the beginning of the narrowed-to region."
2963 (goto-char (point-min))
2964 (if (search-forward "\n\n" nil 1)
2967 (goto-char (point-min)))
2969 (defun article-goto-body ()
2970 "Place point at the start of the body."
2971 (goto-char (point-min))
2973 ;; This variable is only bound when dealing with separate
2975 (article-goto-body-goes-to-point-min-p
2977 ((search-forward "\n\n" nil t)
2980 (goto-char (point-max))
2983 (defun article-strip-multiple-blank-lines ()
2984 "Replace consecutive blank lines with one empty line."
2987 (let ((inhibit-point-motion-hooks t)
2988 (inhibit-read-only t))
2989 ;; First make all blank lines empty.
2991 (while (re-search-forward "^[ \t]+$" nil t)
2992 (unless (gnus-annotation-in-region-p
2993 (match-beginning 0) (match-end 0))
2994 (replace-match "" nil t)))
2995 ;; Then replace multiple empty lines with a single empty line.
2997 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2998 (unless (gnus-annotation-in-region-p
2999 (match-beginning 0) (match-end 0))
3000 (delete-region (match-beginning 1) (match-end 1)))))))
3002 (defun article-strip-leading-space ()
3003 "Remove all white space from the beginning of the lines in the article."
3006 (let ((inhibit-point-motion-hooks t)
3007 (inhibit-read-only t))
3009 (while (re-search-forward "^[ \t]+" nil t)
3010 (replace-match "" t t)))))
3012 (defun article-strip-trailing-space ()
3013 "Remove all white space from the end of the lines in the article."
3016 (let ((inhibit-point-motion-hooks t)
3017 (inhibit-read-only t))
3019 (while (re-search-forward "[ \t]+$" nil t)
3020 (replace-match "" t t)))))
3022 (defun article-strip-blank-lines ()
3023 "Strip leading, trailing and multiple blank lines."
3025 (article-strip-leading-blank-lines)
3026 (article-remove-trailing-blank-lines)
3027 (article-strip-multiple-blank-lines))
3029 (defun article-strip-all-blank-lines ()
3030 "Strip all blank lines."
3033 (let ((inhibit-point-motion-hooks t)
3034 (inhibit-read-only t))
3036 (while (re-search-forward "^[ \t]*\n" nil t)
3037 (replace-match "" t t)))))
3039 (defun gnus-article-narrow-to-signature ()
3040 "Narrow to the signature; return t if a signature is found, else nil."
3041 (let ((inhibit-point-motion-hooks t))
3042 (when (gnus-article-search-signature)
3044 ;; Check whether we have some limits to what we consider
3045 ;; to be a signature.
3046 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
3047 (list gnus-signature-limit)))
3049 (while (setq limit (pop limits))
3050 (if (or (and (integerp limit)
3051 (< (- (point-max) (point)) limit))
3053 (< (count-lines (point) (point-max)) limit))
3054 (and (functionp limit)
3056 (and (stringp limit)
3057 (not (re-search-forward limit nil t))))
3058 () ; This limit did not succeed.
3062 (narrow-to-region (point) (point-max))
3065 (defun gnus-article-search-signature ()
3066 "Search the current buffer for the signature separator.
3067 Put point at the beginning of the signature separator."
3068 (let ((cur (point)))
3069 (goto-char (point-max))
3070 (if (if (stringp gnus-signature-separator)
3071 (re-search-backward gnus-signature-separator nil t)
3072 (let ((seps gnus-signature-separator))
3074 (not (re-search-backward (car seps) nil t)))
3081 (defun gnus-article-hidden-arg ()
3082 "Return the current prefix arg as a number, or 0 if no prefix."
3083 (list (if current-prefix-arg
3084 (prefix-numeric-value current-prefix-arg)
3087 (defun gnus-article-check-hidden-text (type arg)
3088 "Return nil if hiding is necessary.
3089 Arg can be nil or a number. nil and positive means hide, negative
3090 means show, 0 means toggle."
3093 (let ((hide (gnus-article-hidden-text-p type)))
3099 (gnus-article-show-hidden-text type)
3102 (if (eq hide 'hidden)
3104 (gnus-article-show-hidden-text type)
3108 (defun gnus-article-hidden-text-p (type)
3109 "Say whether the current buffer contains hidden text of type TYPE."
3110 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
3112 (not (get-text-property pos 'invisible))
3113 (not (get-text-property pos 'dummy-invisible)))
3115 (text-property-any (1+ pos) (point-max) 'article-type type)))
3120 (defun gnus-article-show-hidden-text (type &optional dummy)
3121 "Show all hidden text of type TYPE.
3122 Originally it is hide instead of DUMMY."
3123 (let ((inhibit-read-only t)
3124 (inhibit-point-motion-hooks t))
3125 (gnus-remove-text-properties-when
3127 (point-min) (point-max)
3128 (cons 'article-type (cons type
3129 gnus-hidden-properties)))
3130 (gnus-delete-wash-type type)))
3132 (defconst article-time-units
3133 `((year . ,(* 365.25 24 60 60))
3134 (week . ,(* 7 24 60 60))
3135 (day . ,(* 24 60 60))
3139 "Mapping from time units to seconds.")
3141 (defun gnus-article-forward-header ()
3142 "Move point to the start of the next header.
3143 If the current header is a continuation header, this can be several
3148 (if (looking-at "[ \t]+[^ \t]")
3152 (defun article-date-ut (&optional type highlight)
3153 "Convert DATE date to universal time in the current article.
3154 If TYPE is `local', convert to local time; if it is `lapsed', output
3155 how much time has lapsed since DATE. For `lapsed', the value of
3156 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
3157 should replace the \"Date:\" one, or should be added below it."
3158 (interactive (list 'ut t))
3159 (let* ((tdate-regexp "^Date:[ \t]\\|^X-Sent:[ \t]")
3160 (date-regexp (cond ((not gnus-article-date-lapsed-new-header)
3164 (article-lapsed-timer
3168 (case-fold-search t)
3169 (inhibit-read-only t)
3170 (inhibit-point-motion-hooks t)
3171 pos date bface eface)
3175 (goto-char (point-min))
3176 (while (or (setq date (get-text-property (setq pos (point))
3178 (when (setq pos (next-single-property-change
3179 (point) 'original-date))
3180 (setq date (get-text-property pos 'original-date))
3182 (narrow-to-region pos (or (text-property-any pos (point-max)
3185 (goto-char (point-min))
3186 (when (re-search-forward tdate-regexp nil t)
3187 (setq bface (get-text-property (point-at-bol) 'face)
3188 eface (get-text-property (1- (point-at-eol)) 'face)))
3189 (goto-char (point-min))
3191 ;; Delete any old Date headers.
3192 (while (re-search-forward date-regexp nil t)
3194 (delete-region (point-at-bol) (progn
3195 (gnus-article-forward-header)
3197 (delete-region (point-at-bol) (progn
3198 (gnus-article-forward-header)
3201 (setq pos (point))))
3202 (when (and (not pos)
3203 (re-search-forward tdate-regexp nil t))
3205 (gnus-goto-char pos)
3206 (insert (article-make-date-line date (or type 'ut)))
3212 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
3213 (put-text-property (match-beginning 1) (1+ (match-end 1))
3215 (put-text-property (match-beginning 2) (match-end 2)
3217 (put-text-property (point-min) (1- (point-max)) 'original-date date)
3218 (goto-char (point-max))
3221 (defun article-make-date-line (date type)
3222 "Return a DATE line of TYPE."
3223 (unless (memq type '(local ut original user iso8601 lapsed english))
3224 (error "Unknown conversion type: %s" type))
3226 (let ((time (date-to-time date)))
3228 ;; Convert to the local timezone.
3230 (concat "Date: " (message-make-date time)))
3231 ;; Convert to Universal Time.
3236 (let* ((e (parse-time-string date))
3237 (tm (apply 'encode-time e))
3239 (ls (- (cadr tm) (car (current-time-zone time)))))
3240 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
3241 ((> ls 65535) (list (1+ ms) (- ls 65536)))
3245 ;; Get the original date from the article.
3246 ((eq type 'original)
3247 (concat "Date: " (if (string-match "\n+$" date)
3248 (substring date 0 (match-beginning 0))
3250 ;; Let the user define the format.
3252 (let ((format (or (condition-case nil
3253 (with-current-buffer gnus-summary-buffer
3254 gnus-article-time-format)
3256 gnus-article-time-format)))
3257 (if (functionp format)
3258 (funcall format time)
3259 (concat "Date: " (format-time-string format time)))))
3262 (let ((tz (car (current-time-zone time))))
3265 (format-time-string "%Y%m%dT%H%M%S" time)
3266 (format "%s%02d%02d"
3267 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3268 (/ (% (abs tz) 3600) 60)))))
3269 ;; Do an X-Sent lapsed format.
3271 ;; If the date is seriously mangled, the timezone functions are
3272 ;; liable to bug out, so we ignore all errors.
3273 (let* ((now (current-time))
3274 (real-time (subtract-time now time))
3275 (real-sec (and real-time
3276 (+ (* (float (car real-time)) 65536)
3278 (sec (and real-time (abs real-sec)))
3288 ;; This is a bit convoluted, but basically we go
3289 ;; through the time units for years, weeks, etc,
3290 ;; and divide things to see whether that results
3291 ;; in positive answers.
3294 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3295 ;; The (remaining) seconds are too few to
3296 ;; be divided into this time unit.
3298 ;; It's big enough, so we output it.
3299 (setq sec (- sec (* num (cdr unit))))
3301 (concat (if prev ", " "") (int-to-string
3303 " " (symbol-name (car unit))
3304 (if (> num 1) "s" ""))
3306 article-time-units "")
3307 ;; If dates are odd, then it might appear like the
3308 ;; article was sent in the future.
3311 " in the future"))))))
3312 ;; Display the date in proper English
3314 (let ((dtime (decode-time time)))
3317 (number-to-string (nth 3 dtime))
3318 (let ((digit (% (nth 3 dtime) 10)))
3320 ((memq (nth 3 dtime) '(11 12 13)) "th")
3326 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3328 (number-to-string (nth 5 dtime))
3330 (format "%02d" (nth 2 dtime))
3332 (format "%02d" (nth 1 dtime)))))))
3334 (format "Date: %s (from Gnus)" date))))
3336 (defun article-date-local (&optional highlight)
3337 "Convert the current article date to the local timezone."
3338 (interactive (list t))
3339 (article-date-ut 'local highlight))
3341 (defun article-date-english (&optional highlight)
3342 "Convert the current article date to something that is proper English."
3343 (interactive (list t))
3344 (article-date-ut 'english highlight))
3346 (defun article-date-original (&optional highlight)
3347 "Convert the current article date to what it was originally.
3348 This is only useful if you have used some other date conversion
3349 function and want to see what the date was before converting."
3350 (interactive (list t))
3351 (article-date-ut 'original highlight))
3353 (defun article-date-lapsed (&optional highlight)
3354 "Convert the current article date to time lapsed since it was sent."
3355 (interactive (list t))
3356 (article-date-ut 'lapsed highlight))
3358 (defun article-update-date-lapsed ()
3359 "Function to be run from a timer to update the lapsed time line."
3361 (let (deactivate-mark)
3366 (set-buffer (window-buffer w))
3367 (when (eq major-mode 'gnus-article-mode)
3368 (let ((mark (point-marker)))
3369 (goto-char (point-min))
3370 (when (re-search-forward "^X-Sent:" nil t)
3371 (article-date-lapsed t))
3372 (goto-char (marker-position mark))
3373 (move-marker mark nil))))
3376 (defun gnus-start-date-timer (&optional n)
3377 "Start a timer to update the X-Sent header in the article buffers.
3378 The numerical prefix says how frequently (in seconds) the function
3383 (gnus-stop-date-timer)
3384 (setq article-lapsed-timer
3385 (run-at-time 1 n 'article-update-date-lapsed)))
3387 (defun gnus-stop-date-timer ()
3388 "Stop the X-Sent timer."
3390 (when article-lapsed-timer
3391 (nnheader-cancel-timer article-lapsed-timer)
3392 (setq article-lapsed-timer nil)))
3394 (defun article-date-user (&optional highlight)
3395 "Convert the current article date to the user-defined format.
3396 This format is defined by the `gnus-article-time-format' variable."
3397 (interactive (list t))
3398 (article-date-ut 'user highlight))
3400 (defun article-date-iso8601 (&optional highlight)
3401 "Convert the current article date to ISO8601."
3402 (interactive (list t))
3403 (article-date-ut 'iso8601 highlight))
3405 (defmacro gnus-article-save-original-date (&rest forms)
3406 "Save the original date as a text property and evaluate FORMS."
3407 `(let* ((case-fold-search t)
3409 (goto-char (point-min))
3410 (when (and (re-search-forward "^date:[\t\n ]+" nil t)
3413 (date (when (and start
3414 (re-search-forward "[\t ]*\n\\(?:[^\t ]\\|\\'\\)"
3416 (buffer-substring-no-properties start
3417 (match-beginning 0)))))
3418 (goto-char (point-max))
3419 (skip-chars-backward "\n")
3420 (put-text-property (point-min) (point) 'original-date date)
3422 (goto-char (point-max))
3423 (skip-chars-backward "\n")
3424 (put-text-property (point-min) (point) 'original-date date)))
3426 ;; (defun article-show-all ()
3427 ;; "Show all hidden text in the article buffer."
3430 ;; (let ((inhibit-read-only t))
3431 ;; (gnus-article-unhide-text (point-min) (point-max)))))
3433 (defun article-remove-leading-whitespace ()
3434 "Remove excessive whitespace from all headers."
3438 (let ((inhibit-read-only t))
3439 (article-narrow-to-head)
3440 (goto-char (point-min))
3441 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3442 (delete-region (match-beginning 1) (match-end 1)))))))
3444 (defun article-emphasize (&optional arg)
3445 "Emphasize text according to `gnus-emphasis-alist'."
3446 (interactive (gnus-article-hidden-arg))
3447 (unless (gnus-article-check-hidden-text 'emphasis arg)
3451 (with-current-buffer gnus-summary-buffer
3452 gnus-article-emphasis-alist)
3454 gnus-emphasis-alist))
3455 (inhibit-read-only t)
3456 (props (append '(article-type emphasis)
3457 gnus-hidden-properties))
3458 regexp elem beg invisible visible face)
3461 (while (setq elem (pop alist))
3463 (setq regexp (car elem)
3464 invisible (nth 1 elem)
3465 visible (nth 2 elem)
3467 (while (re-search-forward regexp nil t)
3468 (when (and (match-beginning visible) (match-beginning invisible))
3469 (gnus-article-hide-text
3470 (match-beginning invisible) (match-end invisible) props)
3471 (gnus-article-unhide-text-type
3472 (match-beginning visible) (match-end visible) 'emphasis)
3473 (gnus-put-overlay-excluding-newlines
3474 (match-beginning visible) (match-end visible) 'face face)
3475 (gnus-add-wash-type 'emphasis)
3476 (goto-char (match-end invisible)))))))))
3478 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3479 "Setup newsgroup emphasis alist."
3480 (unless gnus-article-emphasis-alist
3481 (let ((name (and gnus-newsgroup-name
3482 (gnus-group-real-name gnus-newsgroup-name))))
3483 (make-local-variable 'gnus-article-emphasis-alist)
3484 (setq gnus-article-emphasis-alist
3486 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3487 (while (setq elem (pop alist))
3488 (when (and name (string-match (car elem) name))
3490 highlight (copy-sequence (cdr elem)))))
3492 (copy-sequence highlight-words)
3493 (if gnus-newsgroup-name
3494 (copy-sequence (gnus-group-find-parameter
3495 gnus-newsgroup-name 'highlight-words t)))
3496 gnus-emphasis-alist)))))
3499 (defvar gnus-summary-article-menu)
3500 (defvar gnus-summary-post-menu))
3502 ;;; Saving functions.
3504 (defun gnus-article-save (save-buffer file &optional num)
3505 "Save the currently selected article."
3506 (unless gnus-save-all-headers
3507 ;; Remove headers according to `gnus-saved-headers'.
3508 (let ((gnus-visible-headers
3509 (or gnus-saved-headers gnus-visible-headers))
3510 (gnus-article-buffer save-buffer))
3512 (set-buffer save-buffer)
3513 (article-hide-headers 1 t))))
3514 (save-window-excursion
3515 (if (not gnus-default-article-saver)
3516 (error "No default saver is defined")
3517 ;; !!! Magic! The saving functions all save
3518 ;; `gnus-save-article-buffer' (or so they think), but we
3519 ;; bind that variable to our save-buffer.
3520 (set-buffer gnus-article-buffer)
3521 (let* ((gnus-save-article-buffer save-buffer)
3524 ((not gnus-prompt-before-saving) 'default)
3525 ((eq gnus-prompt-before-saving 'always) nil)
3527 (gnus-number-of-articles-to-be-saved
3528 (when (eq gnus-prompt-before-saving t)
3530 (set-buffer gnus-article-current-summary)
3531 (funcall gnus-default-article-saver filename)))))
3533 (defun gnus-read-save-file-name (prompt &optional filename
3534 function group headers variable
3537 (funcall function group headers (symbol-value variable)))
3542 ((eq filename 'default)
3548 (when (symbol-value dir-var)
3549 (setq default-name (expand-file-name
3550 (file-name-nondirectory default-name)
3551 (symbol-value dir-var))))
3552 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3555 (if (and gnus-number-of-articles-to-be-saved
3556 (> gnus-number-of-articles-to-be-saved 1))
3557 (format "these %d articles"
3558 gnus-number-of-articles-to-be-saved)
3561 ;; Let the split methods have their say.
3563 ;; No split name was found.
3566 (concat prompt " (default "
3567 (file-name-nondirectory default-name) "): ")
3568 (file-name-directory default-name)
3570 ;; A single group name is returned.
3571 ((stringp split-name)
3573 (funcall function split-name headers
3574 (symbol-value variable)))
3576 (concat prompt " (default "
3577 (file-name-nondirectory default-name) "): ")
3578 (file-name-directory default-name)
3580 ;; A single split name was found
3581 ((= 1 (length split-name))
3582 (let* ((name (expand-file-name
3584 gnus-article-save-directory))
3585 (dir (cond ((file-directory-p name)
3586 (file-name-as-directory name))
3587 ((file-exists-p name) name)
3588 (t gnus-article-save-directory))))
3590 (concat prompt " (default " name "): ")
3592 ;; A list of splits was found.
3594 (setq split-name (nreverse split-name))
3596 (let ((file-name-history
3597 (nconc split-name file-name-history)))
3601 (concat prompt " (`M-p' for defaults): ")
3602 gnus-article-save-directory
3604 gnus-article-save-directory)))
3605 (car (push result file-name-history)))))))
3606 ;; Create the directory.
3607 (gnus-make-directory (file-name-directory file))
3608 ;; If we have read a directory, we append the default file name.
3609 (when (file-directory-p file)
3610 (setq file (expand-file-name (file-name-nondirectory
3612 (file-name-as-directory file))))
3613 ;; Possibly translate some characters.
3614 (nnheader-translate-file-chars file))))))
3615 (gnus-make-directory (file-name-directory result))
3617 (set variable result))
3619 (set dir-var (file-name-directory result)))
3622 (defun gnus-article-archive-name (group)
3623 "Return the first instance of an \"Archive-name\" in the current buffer."
3624 (let ((case-fold-search t))
3625 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3626 (nnheader-concat gnus-article-save-directory
3627 (match-string 1)))))
3629 (defun gnus-article-nndoc-name (group)
3630 "If GROUP is an nndoc group, return the name of the parent group."
3631 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3632 (gnus-group-get-parameter group 'save-article-group)))
3634 (defun gnus-summary-save-in-rmail (&optional filename)
3635 "Append this article to Rmail file.
3636 Optional argument FILENAME specifies file name.
3637 Directory to save to is default to `gnus-article-save-directory'."
3638 (setq filename (gnus-read-save-file-name
3639 "Save %s in rmail file" filename
3640 gnus-rmail-save-name gnus-newsgroup-name
3641 gnus-current-headers 'gnus-newsgroup-last-rmail))
3642 (gnus-eval-in-buffer-window gnus-save-article-buffer
3646 (gnus-output-to-rmail filename))))
3649 (defun gnus-summary-save-in-mail (&optional filename)
3650 "Append this article to Unix mail file.
3651 Optional argument FILENAME specifies file name.
3652 Directory to save to is default to `gnus-article-save-directory'."
3653 (setq filename (gnus-read-save-file-name
3654 "Save %s in Unix mail file" filename
3655 gnus-mail-save-name gnus-newsgroup-name
3656 gnus-current-headers 'gnus-newsgroup-last-mail))
3657 (gnus-eval-in-buffer-window gnus-save-article-buffer
3661 (if (and (file-readable-p filename)
3662 (file-regular-p filename)
3663 (mail-file-babyl-p filename))
3664 (rmail-output-to-rmail-file filename t)
3665 (gnus-output-to-mail filename)))))
3668 (put 'gnus-summary-save-in-file :decode t)
3669 (defun gnus-summary-save-in-file (&optional filename overwrite)
3670 "Append this article to file.
3671 Optional argument FILENAME specifies file name.
3672 Directory to save to is default to `gnus-article-save-directory'."
3673 (setq filename (gnus-read-save-file-name
3674 "Save %s in file" filename
3675 gnus-file-save-name gnus-newsgroup-name
3676 gnus-current-headers 'gnus-newsgroup-last-file))
3677 (gnus-eval-in-buffer-window gnus-save-article-buffer
3681 (when (and overwrite
3682 (file-exists-p filename))
3683 (delete-file filename))
3684 (gnus-output-to-file filename))))
3687 (put 'gnus-summary-write-to-file :decode t)
3688 (put 'gnus-summary-write-to-file :function 'gnus-summary-save-in-file)
3689 (defun gnus-summary-write-to-file (&optional filename)
3690 "Write this article to a file, overwriting it if the file exists.
3691 Optional argument FILENAME specifies file name.
3692 The directory to save in defaults to `gnus-article-save-directory'."
3693 (setq filename (gnus-read-save-file-name
3694 "Save %s in file" filename
3695 gnus-file-save-name gnus-newsgroup-name
3696 gnus-current-headers nil 'gnus-newsgroup-last-directory))
3697 (gnus-summary-save-in-file filename t))
3699 (put 'gnus-summary-save-body-in-file :decode t)
3700 (defun gnus-summary-save-body-in-file (&optional filename overwrite)
3701 "Append this article body to a file.
3702 Optional argument FILENAME specifies file name.
3703 The directory to save in defaults to `gnus-article-save-directory'."
3704 (setq filename (gnus-read-save-file-name
3705 "Save %s body in file" filename
3706 gnus-file-save-name gnus-newsgroup-name
3707 gnus-current-headers 'gnus-newsgroup-last-file))
3708 (gnus-eval-in-buffer-window gnus-save-article-buffer
3712 (when (article-goto-body)
3713 (narrow-to-region (point) (point-max)))
3714 (when (and overwrite
3715 (file-exists-p filename))
3716 (delete-file filename))
3717 (gnus-output-to-file filename))))
3720 (put 'gnus-summary-write-body-to-file :decode t)
3721 (put 'gnus-summary-write-body-to-file
3722 :function 'gnus-summary-save-body-in-file)
3723 (defun gnus-summary-write-body-to-file (&optional filename)
3724 "Write this article body to a file, overwriting it if the file exists.
3725 Optional argument FILENAME specifies file name.
3726 The directory to save in defaults to `gnus-article-save-directory'."
3727 (setq filename (gnus-read-save-file-name
3728 "Save %s body in file" filename
3729 gnus-file-save-name gnus-newsgroup-name
3730 gnus-current-headers nil 'gnus-newsgroup-last-directory))
3731 (gnus-summary-save-body-in-file filename t))
3733 (defun gnus-summary-save-in-pipe (&optional command)
3734 "Pipe this article to subprocess."
3736 (cond ((and (eq command 'default)
3737 gnus-last-shell-command)
3738 gnus-last-shell-command)
3743 "Shell command on %s: "
3744 (if (and gnus-number-of-articles-to-be-saved
3745 (> gnus-number-of-articles-to-be-saved 1))
3746 (format "these %d articles"
3747 gnus-number-of-articles-to-be-saved)
3749 gnus-last-shell-command))))
3750 (when (string-equal command "")
3751 (if gnus-last-shell-command
3752 (setq command gnus-last-shell-command)
3753 (error "A command is required")))
3754 (gnus-eval-in-buffer-window gnus-article-buffer
3757 (shell-command-on-region (point-min) (point-max) command nil)))
3758 (setq gnus-last-shell-command command))
3760 (defun gnus-summary-pipe-to-muttprint (&optional command)
3761 "Pipe this article to muttprint."
3762 (setq command (read-string
3763 "Print using command: " gnus-summary-muttprint-program
3764 nil gnus-summary-muttprint-program))
3765 (gnus-summary-save-in-pipe command))
3767 ;;; Article file names when saving.
3769 (defun gnus-capitalize-newsgroup (newsgroup)
3770 "Capitalize NEWSGROUP name."
3771 (when (not (zerop (length newsgroup)))
3772 (concat (char-to-string (upcase (aref newsgroup 0)))
3773 (substring newsgroup 1))))
3775 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3776 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3777 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3778 Otherwise, it is like ~/News/news/group/num."
3781 (concat (if (gnus-use-long-file-name 'not-save)
3782 (gnus-capitalize-newsgroup newsgroup)
3783 (gnus-newsgroup-directory-form newsgroup))
3784 "/" (int-to-string (mail-header-number headers)))
3785 gnus-article-save-directory)))
3787 (string-equal (file-name-directory default)
3788 (file-name-directory last-file))
3789 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3791 (or last-file default))))
3793 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3794 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3795 If variable `gnus-use-long-file-name' is non-nil, it is
3796 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3799 (concat (if (gnus-use-long-file-name 'not-save)
3801 (gnus-newsgroup-directory-form newsgroup))
3802 "/" (int-to-string (mail-header-number headers)))
3803 gnus-article-save-directory)))
3805 (string-equal (file-name-directory default)
3806 (file-name-directory last-file))
3807 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3809 (or last-file default))))
3811 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3812 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3813 If variable `gnus-use-long-file-name' is non-nil, it is
3814 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3817 (if (gnus-use-long-file-name 'not-save)
3820 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3822 gnus-article-save-directory)))
3824 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3825 "Generate file name from sender."
3826 (let ((from (mail-header-from headers)))
3828 (if (and from (string-match "\\([^ <]+\\)@" from))
3829 (match-string 1 from)
3831 gnus-article-save-directory)))
3833 (defun article-verify-x-pgp-sig ()
3836 (if (gnus-buffer-live-p gnus-original-article-buffer)
3837 (let ((sig (with-current-buffer gnus-original-article-buffer
3838 (gnus-fetch-field "X-PGP-Sig")))
3842 (mml2015-clear-verify-function))
3844 (insert-buffer-substring gnus-original-article-buffer)
3845 (setq items (split-string sig))
3846 (message-narrow-to-head)
3847 (let ((inhibit-point-motion-hooks t)
3848 (case-fold-search t))
3849 ;; Don't verify multiple headers.
3850 (setq headers (mapconcat (lambda (header)
3852 (mail-fetch-field header)
3854 (split-string (nth 1 items) ",") "")))
3855 (delete-region (point-min) (point-max))
3856 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3857 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3862 (if (looking-at "^-")
3865 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3866 (insert "Version: " (car items) "\n\n")
3867 (insert (mapconcat 'identity (cddr items) "\n"))
3868 (insert "\n-----END PGP SIGNATURE-----\n")
3869 (let ((mm-security-handle (list (format "multipart/signed"))))
3870 (mml2015-clean-buffer)
3871 (let ((coding-system-for-write (or gnus-newsgroup-charset
3873 (funcall (mml2015-clear-verify-function)))
3875 (or (mm-handle-multipart-ctl-parameter
3876 mm-security-handle 'gnus-details)
3877 (mm-handle-multipart-ctl-parameter
3878 mm-security-handle 'gnus-info)))))
3880 (let ((inhibit-read-only t) bface eface)
3882 (message-narrow-to-head)
3883 (goto-char (point-max))
3885 (setq bface (get-text-property (point-at-bol) 'face)
3886 eface (get-text-property (1- (point-at-eol)) 'face))
3887 (message-remove-header "X-Gnus-PGP-Verify")
3888 (if (re-search-forward "^X-PGP-Sig:" nil t)
3890 (goto-char (point-max)))
3891 (narrow-to-region (point) (point))
3892 (insert "X-Gnus-PGP-Verify: " info "\n")
3893 (goto-char (point-min))
3896 (if (not (looking-at "^[ \t]"))
3900 (goto-char (point-min))
3901 (when (looking-at "\\([^:]+\\): *")
3902 (put-text-property (match-beginning 1) (1+ (match-end 1))
3904 (put-text-property (match-end 0) (point-max)
3905 'face eface)))))))))
3907 (defun article-verify-cancel-lock ()
3908 "Verify Cancel-Lock header."
3910 (if (gnus-buffer-live-p gnus-original-article-buffer)
3911 (canlock-verify gnus-original-article-buffer)))
3918 (setq afunc (car func)
3921 gfunc (intern (format "gnus-%s" func))))
3923 (when (fboundp afunc)
3924 `(lambda (&optional interactive &rest args)
3925 ,(documentation afunc t)
3926 (interactive (list t))
3928 (set-buffer gnus-article-buffer)
3930 (call-interactively ',afunc)
3931 (apply ',afunc args))))))))
3932 '(article-hide-headers
3933 article-verify-x-pgp-sig
3934 article-verify-cancel-lock
3935 article-hide-boring-headers
3936 article-treat-overstrike
3937 article-treat-ansi-sequences
3938 article-fill-long-lines
3939 article-capitalize-sentences
3941 article-remove-leading-whitespace
3942 article-display-x-face
3943 article-display-face
3944 article-de-quoted-unreadable
3945 article-de-base64-unreadable
3948 article-unsplit-urls
3949 article-hide-list-identifiers
3950 article-strip-banner
3953 article-hide-signature
3954 article-strip-headers-in-body
3955 article-remove-trailing-blank-lines
3956 article-strip-leading-blank-lines
3957 article-strip-multiple-blank-lines
3958 article-strip-leading-space
3959 article-strip-trailing-space
3960 article-strip-blank-lines
3961 article-strip-all-blank-lines
3963 article-date-english
3964 article-date-iso8601
3965 article-date-original
3967 article-decode-mime-words
3968 article-decode-charset
3969 article-decode-encoded-words
3973 article-treat-dumbquotes
3974 article-normalize-headers
3975 ;; (article-show-all . gnus-article-show-all-headers)
3979 ;;; Gnus article mode
3982 (put 'gnus-article-mode 'mode-class 'special)
3984 (set-keymap-parent gnus-article-mode-map widget-keymap)
3986 (gnus-define-keys gnus-article-mode-map
3987 " " gnus-article-goto-next-page
3988 "\177" gnus-article-goto-prev-page
3989 [delete] gnus-article-goto-prev-page
3990 [backspace] gnus-article-goto-prev-page
3991 "\C-c^" gnus-article-refer-article
3992 "h" gnus-article-show-summary
3993 "s" gnus-article-show-summary
3994 "\C-c\C-m" gnus-article-mail
3995 "?" gnus-article-describe-briefly
3996 "e" gnus-summary-edit-article
3997 "<" beginning-of-buffer
3999 "\C-c\C-i" gnus-info-find-node
4001 "R" gnus-article-reply-with-original
4002 "F" gnus-article-followup-with-original
4003 "\C-hk" gnus-article-describe-key
4004 "\C-hc" gnus-article-describe-key-briefly
4006 "\C-d" gnus-article-read-summary-keys
4007 "\M-*" gnus-article-read-summary-keys
4008 "\M-#" gnus-article-read-summary-keys
4009 "\M-^" gnus-article-read-summary-keys
4010 "\M-g" gnus-article-read-summary-keys)
4012 (substitute-key-definition
4013 'undefined 'gnus-article-read-summary-keys gnus-article-mode-map)
4015 (defun gnus-article-make-menu-bar ()
4016 (unless (boundp 'gnus-article-commands-menu)
4017 (gnus-summary-make-menu-bar))
4018 (gnus-turn-off-edit-menu 'article)
4019 (unless (boundp 'gnus-article-article-menu)
4021 gnus-article-article-menu gnus-article-mode-map ""
4023 ["Scroll forwards" gnus-article-goto-next-page t]
4024 ["Scroll backwards" gnus-article-goto-prev-page t]
4025 ["Show summary" gnus-article-show-summary t]
4026 ["Fetch Message-ID at point" gnus-article-refer-article t]
4027 ["Mail to address at point" gnus-article-mail t]
4028 ["Send a bug report" gnus-bug t]))
4031 gnus-article-treatment-menu gnus-article-mode-map ""
4032 ;; Fixme: this should use :active (and maybe :visible).
4034 ["Hide headers" gnus-article-hide-headers t]
4035 ["Hide signature" gnus-article-hide-signature t]
4036 ["Hide citation" gnus-article-hide-citation t]
4037 ["Treat overstrike" gnus-article-treat-overstrike t]
4038 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
4039 ["Remove carriage return" gnus-article-remove-cr t]
4040 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
4041 ["Remove quoted-unreadable" gnus-article-de-quoted-unreadable t]
4042 ["Remove base64" gnus-article-de-base64-unreadable t]
4043 ["Treat html" gnus-article-wash-html t]
4044 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
4045 ["Decode HZ" gnus-article-decode-HZ t]))
4047 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
4049 ;; Note "Post" menu is defined in gnus-sum.el for consistency
4051 (gnus-run-hooks 'gnus-article-menu-hook)))
4053 (defun gnus-article-mode ()
4054 "Major mode for displaying an article.
4056 All normal editing commands are switched off.
4058 The following commands are available in addition to all summary mode
4060 \\<gnus-article-mode-map>
4061 \\[gnus-article-next-page]\t Scroll the article one page forwards
4062 \\[gnus-article-prev-page]\t Scroll the article one page backwards
4063 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
4064 \\[gnus-article-show-summary]\t Display the summary buffer
4065 \\[gnus-article-mail]\t Send a reply to the address near point
4066 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
4067 \\[gnus-info-find-node]\t Go to the Gnus info node"
4069 (kill-all-local-variables)
4070 (gnus-simplify-mode-line)
4071 (setq mode-name "Article")
4072 (setq major-mode 'gnus-article-mode)
4073 (make-local-variable 'minor-mode-alist)
4074 (use-local-map gnus-article-mode-map)
4075 (when (gnus-visual-p 'article-menu 'menu)
4076 (gnus-article-make-menu-bar)
4077 (when gnus-summary-tool-bar-map
4078 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
4079 (gnus-update-format-specifications nil 'article-mode)
4080 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
4081 (set (make-local-variable 'gnus-page-broken) nil)
4082 (make-local-variable 'gnus-button-marker-list)
4083 (make-local-variable 'gnus-article-current-summary)
4084 (make-local-variable 'gnus-article-mime-handles)
4085 (make-local-variable 'gnus-article-decoded-p)
4086 (make-local-variable 'gnus-article-mime-handle-alist)
4087 (make-local-variable 'gnus-article-wash-types)
4088 (make-local-variable 'gnus-article-image-alist)
4089 (make-local-variable 'gnus-article-charset)
4090 (make-local-variable 'gnus-article-ignored-charsets)
4091 ;; Prevent recent Emacsen from displaying non-break space as "\ ".
4092 (set (make-local-variable 'nobreak-char-display) nil)
4093 (setq cursor-in-non-selected-windows nil)
4094 (setq truncate-lines gnus-article-truncate-lines)
4095 (gnus-set-default-directory)
4096 (buffer-disable-undo)
4097 (setq buffer-read-only t
4098 show-trailing-whitespace nil)
4099 (set-syntax-table gnus-article-mode-syntax-table)
4100 (mm-enable-multibyte)
4101 (gnus-run-mode-hooks 'gnus-article-mode-hook))
4103 (defun gnus-article-setup-buffer ()
4104 "Initialize the article buffer."
4105 (let* ((name (if gnus-single-article-buffer "*Article*"
4106 (concat "*Article " gnus-newsgroup-name "*")))
4108 (progn (string-match "\\*Article" name)
4109 (concat " *Original Article"
4110 (substring name (match-end 0))))))
4111 (setq gnus-article-buffer name)
4112 (setq gnus-original-article-buffer original)
4113 (setq gnus-article-mime-handle-alist nil)
4114 (with-current-buffer gnus-summary-buffer
4115 ;; This might be a variable local to the summary buffer.
4116 (unless gnus-single-article-buffer
4117 (setq gnus-article-buffer name)
4118 (setq gnus-original-article-buffer original)
4119 (gnus-set-global-variables)))
4120 (gnus-article-setup-highlight-words)
4121 ;; Init original article buffer.
4123 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
4124 (mm-enable-multibyte)
4125 (setq major-mode 'gnus-original-article-mode)
4126 (make-local-variable 'gnus-original-article))
4127 (if (and (get-buffer name)
4128 (with-current-buffer name
4129 (if gnus-article-edit-mode
4130 (if (y-or-n-p "Article mode edit in progress; discard? ")
4132 (set-buffer-modified-p nil)
4133 (gnus-kill-buffer name)
4136 (error "Action aborted"))
4140 (set (make-local-variable 'gnus-article-edit-mode) nil)
4141 (when gnus-article-mime-handles
4142 (mm-destroy-parts gnus-article-mime-handles)
4143 (setq gnus-article-mime-handles nil))
4144 ;; Set it to nil in article-buffer!
4145 (setq gnus-article-mime-handle-alist nil)
4146 (buffer-disable-undo)
4147 (setq buffer-read-only t)
4148 ;; This list just keeps growing if we don't reset it.
4149 (setq gnus-button-marker-list nil)
4150 (unless (eq major-mode 'gnus-article-mode)
4151 (gnus-article-mode))
4154 (set-buffer (gnus-get-buffer-create name))
4156 (make-local-variable 'gnus-summary-buffer)
4157 (gnus-summary-set-local-parameters gnus-newsgroup-name)
4158 (current-buffer)))))
4160 ;; Set article window start at LINE, where LINE is the number of lines
4161 ;; from the head of the article.
4162 (defun gnus-article-set-window-start (&optional line)
4164 (gnus-get-buffer-window gnus-article-buffer t)
4166 (set-buffer gnus-article-buffer)
4167 (goto-char (point-min))
4170 (gnus-message 6 "Moved to bookmark")
4171 (search-forward "\n\n" nil t)
4175 (defun gnus-article-prepare (article &optional all-headers header)
4176 "Prepare ARTICLE in article mode buffer.
4177 ARTICLE should either be an article number or a Message-ID.
4178 If ARTICLE is an id, HEADER should be the article headers.
4179 If ALL-HEADERS is non-nil, no headers are hidden."
4181 ;; Make sure we start in a summary buffer.
4182 (unless (eq major-mode 'gnus-summary-mode)
4183 (set-buffer gnus-summary-buffer))
4184 (setq gnus-summary-buffer (current-buffer))
4185 (let* ((gnus-article (if header (mail-header-number header) article))
4186 (summary-buffer (current-buffer))
4187 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
4188 (group gnus-newsgroup-name)
4191 (gnus-article-setup-buffer)
4192 (set-buffer gnus-article-buffer)
4193 ;; Deactivate active regions.
4194 (when (and (boundp 'transient-mark-mode)
4195 transient-mark-mode)
4196 (setq mark-active nil))
4197 (if (not (setq result (let ((inhibit-read-only t))
4198 (gnus-request-article-this-buffer
4200 ;; There is no such article.
4202 (when (and (numberp article)
4203 (not (memq article gnus-newsgroup-sparse)))
4204 (setq gnus-article-current
4205 (cons gnus-newsgroup-name article))
4206 (set-buffer gnus-summary-buffer)
4207 (setq gnus-current-article article)
4208 (if (and (memq article gnus-newsgroup-undownloaded)
4209 (not (gnus-online (gnus-find-method-for-group
4210 gnus-newsgroup-name))))
4212 (gnus-summary-set-agent-mark article)
4213 (message "Message marked for downloading"))
4214 (gnus-summary-mark-article article gnus-canceled-mark)
4215 (unless (memq article gnus-newsgroup-sparse)
4216 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4217 (if (or (eq result 'pseudo)
4218 (eq result 'nneething))
4221 (set-buffer summary-buffer)
4222 (push article gnus-newsgroup-history)
4223 (setq gnus-last-article gnus-current-article
4224 gnus-current-article 0
4225 gnus-current-headers nil
4226 gnus-article-current nil)
4227 (if (eq result 'nneething)
4228 (gnus-configure-windows 'summary)
4229 (gnus-configure-windows 'article))
4230 (gnus-set-global-variables))
4231 (let ((gnus-article-mime-handle-alist-1
4232 gnus-article-mime-handle-alist))
4233 (gnus-set-mode-line 'article)))
4234 ;; The result from the `request' was an actual article -
4235 ;; or at least some text that is now displayed in the
4237 (when (and (numberp article)
4238 (not (eq article gnus-current-article)))
4239 ;; Seems like a new article has been selected.
4240 ;; `gnus-current-article' must be an article number.
4242 (set-buffer summary-buffer)
4243 (push article gnus-newsgroup-history)
4244 (setq gnus-last-article gnus-current-article
4245 gnus-current-article article
4246 gnus-current-headers
4247 (gnus-summary-article-header gnus-current-article)
4248 gnus-article-current
4249 (cons gnus-newsgroup-name gnus-current-article))
4250 (unless (vectorp gnus-current-headers)
4251 (setq gnus-current-headers nil))
4252 (gnus-summary-goto-subject gnus-current-article)
4253 (when (gnus-summary-show-thread)
4254 ;; If the summary buffer really was folded, the
4255 ;; previous goto may not actually have gone to
4256 ;; the right article, but the thread root instead.
4258 (gnus-summary-goto-subject gnus-current-article))
4259 (gnus-run-hooks 'gnus-mark-article-hook)
4260 (gnus-set-mode-line 'summary)
4261 (when (gnus-visual-p 'article-highlight 'highlight)
4262 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4263 ;; Set the global newsgroup variables here.
4264 (gnus-set-global-variables)
4265 (setq gnus-have-all-headers
4266 (or all-headers gnus-show-all-headers))))
4268 (gnus-configure-windows 'article))
4269 (when (or (numberp article)
4271 (gnus-article-prepare-display)
4273 (goto-char (point-min))
4274 (when gnus-break-pages
4275 (gnus-narrow-to-page)))
4276 (let ((gnus-article-mime-handle-alist-1
4277 gnus-article-mime-handle-alist))
4278 (gnus-set-mode-line 'article))
4282 (set-window-point (get-buffer-window (current-buffer)) (point))
4283 (gnus-configure-windows 'article)
4287 (defun gnus-article-prepare-display ()
4288 "Make the current buffer look like a nice article."
4289 ;; Hooks for getting information from the article.
4290 ;; This hook must be called before being narrowed.
4291 (let ((gnus-article-buffer (current-buffer))
4293 (inhibit-read-only t))
4294 (unless (eq major-mode 'gnus-article-mode)
4295 (gnus-article-mode))
4296 (setq buffer-read-only nil
4297 gnus-article-wash-types nil
4298 gnus-article-image-alist nil)
4299 (gnus-run-hooks 'gnus-tmp-internal-hook)
4300 (when gnus-display-mime-function
4301 (funcall gnus-display-mime-function))
4302 (gnus-run-hooks 'gnus-article-prepare-hook)))
4305 ;;; Gnus MIME viewing functions
4308 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4309 "Format of the MIME buttons.
4311 Valid specifiers include:
4313 %T MIME type, along with additional info
4314 %n The `name' parameter
4315 %d The description, if any
4316 %l The length of the encoded part
4317 %p The part identifier number
4318 %e Dots if the part isn't displayed
4320 General format specifiers can also be used. See Info node
4321 `(gnus)Formatting Variables'.")
4323 (defvar gnus-mime-button-line-format-alist
4324 '((?t gnus-tmp-type ?s)
4325 (?T gnus-tmp-type-long ?s)
4326 (?n gnus-tmp-name ?s)
4327 (?d gnus-tmp-description ?s)
4329 (?l gnus-tmp-length ?d)
4330 (?e gnus-tmp-dots ?s)))
4332 (defvar gnus-mime-button-commands
4333 '((gnus-article-press-button "\r" "Toggle Display")
4334 (gnus-mime-view-part "v" "View Interactively...")
4335 (gnus-mime-view-part-as-type "t" "View As Type...")
4336 (gnus-mime-view-part-as-charset "C" "View As charset...")
4337 (gnus-mime-save-part "o" "Save...")
4338 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4339 (gnus-mime-replace-part "r" "Replace part")
4340 (gnus-mime-delete-part "d" "Delete part")
4341 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4342 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4343 (gnus-mime-view-part-internally "E" "View Internally") ;; Why `E'?
4344 (gnus-mime-view-part-externally "e" "View Externally")
4345 (gnus-mime-print-part "p" "Print")
4346 (gnus-mime-pipe-part "|" "Pipe To Command...")
4347 (gnus-mime-action-on-part "." "Take action on the part...")))
4349 (defun gnus-article-mime-part-status ()
4350 (if gnus-article-mime-handle-alist-1
4351 (if (eq 1 (length gnus-article-mime-handle-alist-1))
4353 (format " (%d parts)" (length gnus-article-mime-handle-alist-1)))
4356 (defvar gnus-mime-button-map
4357 (let ((map (make-sparse-keymap)))
4358 (define-key map gnus-mouse-2 'gnus-article-push-button)
4359 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4360 (dolist (c gnus-mime-button-commands)
4361 (define-key map (cadr c) (car c)))
4365 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4367 ,@(mapcar (lambda (c)
4368 (vector (caddr c) (car c) :active t))
4369 gnus-mime-button-commands)))
4371 (defun gnus-mime-button-menu (event prefix)
4372 "Construct a context-sensitive menu of MIME commands."
4373 (interactive "e\nP")
4374 (save-window-excursion
4375 (let ((pos (event-start event)))
4376 (select-window (posn-window pos))
4377 (goto-char (posn-point pos))
4378 (gnus-article-check-buffer)
4379 (popup-menu gnus-mime-button-menu nil prefix))))
4381 (defun gnus-mime-view-all-parts (&optional handles)
4382 "View all the MIME parts."
4384 (with-current-buffer gnus-article-buffer
4385 (let ((handles (or handles gnus-article-mime-handles))
4386 (mail-parse-charset gnus-newsgroup-charset)
4387 (mail-parse-ignored-charsets
4388 (with-current-buffer gnus-summary-buffer
4389 gnus-newsgroup-ignored-charsets)))
4391 (mm-remove-parts handles)
4392 (goto-char (point-min))
4393 (or (search-forward "\n\n") (goto-char (point-max)))
4394 (let ((inhibit-read-only t))
4395 (delete-region (point) (point-max))
4396 (mm-display-parts handles))))))
4398 (defun gnus-article-jump-to-part (n)
4399 "Jump to MIME part N."
4401 (pop-to-buffer gnus-article-buffer)
4402 ;; FIXME: why is it necessary?
4404 (let ((parts (length gnus-article-mime-handle-alist)))
4407 (read-string ;; Emacs 21 doesn't have `read-number'.
4408 (format "Jump to part (2..%s): " parts)))))
4409 (unless (and (integerp n) (<= n parts) (>= n 1))
4412 (gnus-message 7 "Invalid part `%s', using %s instead."
4415 (gnus-message 9 "Jumping to part %s." n)
4416 (cond ((>= gnus-auto-select-part 1)
4417 (while (and (<= n parts)
4418 (not (gnus-article-goto-part n)))
4420 ((< gnus-auto-select-part 0)
4421 (while (and (>= n 1)
4422 (not (gnus-article-goto-part n)))
4425 (gnus-article-goto-part n)))))
4428 (defsubst gnus-article-edit-part (handles &optional current-id)
4429 "Edit an article in order to delete a mime part.
4430 This function is exclusively used by `gnus-mime-save-part-and-strip'
4431 and `gnus-mime-delete-part', and not provided at run-time normally."
4432 (gnus-article-edit-article
4434 (buffer-disable-undo)
4436 (let ((mail-parse-charset (or gnus-article-charset
4437 ',gnus-newsgroup-charset))
4438 (mail-parse-ignored-charsets
4439 (or gnus-article-ignored-charsets
4440 ',gnus-newsgroup-ignored-charsets))
4441 (mbl mml-buffer-list))
4442 (setq mml-buffer-list nil)
4443 (insert-buffer-substring gnus-original-article-buffer)
4444 (mime-to-mml ',handles)
4445 (setq gnus-article-mime-handles nil)
4446 (let ((mbl1 mml-buffer-list))
4447 (setq mml-buffer-list mbl)
4448 (set (make-local-variable 'mml-buffer-list) mbl1))
4449 (gnus-make-local-hook 'kill-buffer-hook)
4450 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4451 `(lambda (no-highlight)
4452 (let ((mail-parse-charset (or gnus-article-charset
4453 ',gnus-newsgroup-charset))
4454 (message-options message-options)
4455 (message-options-set-recipient)
4456 (mail-parse-ignored-charsets
4457 (or gnus-article-ignored-charsets
4458 ',gnus-newsgroup-ignored-charsets)))
4460 (mml-destroy-buffers)
4461 (remove-hook 'kill-buffer-hook
4462 'mml-destroy-buffers t)
4463 (kill-local-variable 'mml-buffer-list))
4464 (gnus-summary-edit-article-done
4465 ,(or (mail-header-references gnus-current-headers) "")
4466 ,(gnus-group-read-only-p)
4467 ,gnus-summary-buffer no-highlight))
4469 (gnus-article-edit-done)
4470 (gnus-summary-expand-window)
4471 (gnus-summary-show-article)
4472 (when (and current-id (integerp gnus-auto-select-part))
4473 (gnus-article-jump-to-part
4474 (+ current-id gnus-auto-select-part)))))
4476 (defun gnus-mime-replace-part (file)
4477 "Replace MIME part under point with an external body."
4478 ;; Useful if file has already been saved to disk
4482 (read-file-name "Replace MIME part with file: "
4483 (or mm-default-directory default-directory)
4485 (gnus-mime-save-part-and-strip file))
4487 (defun gnus-mime-save-part-and-strip (&optional file)
4488 "Save the MIME part under point then replace it with an external body.
4489 If FILE is given, use it for the external part."
4491 (gnus-article-check-buffer)
4492 (when (gnus-group-read-only-p)
4493 (error "The current group does not support deleting of parts"))
4494 (when (mm-complicated-handles gnus-article-mime-handles)
4496 The current article has a complicated MIME structure, giving up..."))
4497 (let* ((data (get-text-property (point) 'gnus-data))
4498 (id (get-text-property (point) 'gnus-part))
4500 (handles gnus-article-mime-handles))
4503 (and data (mm-save-part data "Delete MIME part and save to: "))))
4505 (with-current-buffer (mm-handle-buffer data)
4507 (insert "Content-Type: " (mm-handle-media-type data))
4508 (mml-insert-parameter-string (cdr (mm-handle-type data))
4510 ;; Add a filename for the sake of saving the part again.
4511 (mml-insert-parameter
4512 (mail-header-encode-parameter "name" (file-name-nondirectory file)))
4514 (insert "Content-ID: " (message-make-message-id) "\n")
4515 (insert "Content-Transfer-Encoding: binary\n")
4518 (cdr (mm-make-handle nil
4519 `("message/external-body"
4520 (access-type . "LOCAL-FILE")
4522 ;; (set-buffer gnus-summary-buffer)
4523 (gnus-article-edit-part handles id))))
4525 ;; A function like `gnus-summary-save-parts' (`X m', `<MIME> <Extract all
4526 ;; parts...>') but with stripping would be nice.
4528 (defun gnus-mime-delete-part ()
4529 "Delete the MIME part under point.
4530 Replace it with some information about the removed part."
4532 (gnus-article-check-buffer)
4533 (when (gnus-group-read-only-p)
4534 (error "The current group does not support deleting of parts"))
4535 (when (mm-complicated-handles gnus-article-mime-handles)
4537 The current article has a complicated MIME structure, giving up..."))
4538 (when (or gnus-expert-user
4539 (gnus-yes-or-no-p "\
4540 Deleting parts may malfunction or destroy the article; continue? "))
4541 (let* ((data (get-text-property (point) 'gnus-data))
4542 (id (get-text-property (point) 'gnus-part))
4543 (handles gnus-article-mime-handles)
4547 (mail-decode-encoded-word-string (or (mm-handle-description data)
4550 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4552 (type (mm-handle-media-type data)))
4554 (error "No MIME part under point"))
4555 (with-current-buffer (mm-handle-buffer data)
4556 (let ((bsize (format "%s" (buffer-size))))
4561 "| The following attachment has been deleted:\n"
4563 "| Type: " type "\n"
4564 "| Filename: " filename "\n"
4565 "| Size (encoded): " bsize " Byte\n"
4566 "| Description: " description "\n"
4569 (cdr (mm-make-handle
4570 nil `("text/plain") nil nil
4572 (format "Deleted attachment (%s bytes)" bsize))))))
4573 ;; (set-buffer gnus-summary-buffer)
4574 (gnus-article-edit-part handles id))))
4576 (defun gnus-mime-save-part ()
4577 "Save the MIME part under point."
4579 (gnus-article-check-buffer)
4580 (let ((data (get-text-property (point) 'gnus-data)))
4582 (mm-save-part data))))
4584 (defun gnus-mime-pipe-part ()
4585 "Pipe the MIME part under point to a process."
4587 (gnus-article-check-buffer)
4588 (let ((data (get-text-property (point) 'gnus-data)))
4590 (mm-pipe-part data))))
4592 (defun gnus-mime-view-part ()
4593 "Interactively choose a viewing method for the MIME part under point."
4595 (gnus-article-check-buffer)
4596 (let ((data (get-text-property (point) 'gnus-data)))
4598 (setq gnus-article-mime-handles
4600 gnus-article-mime-handles (setq data (copy-sequence data))))
4601 (mm-interactively-view-part data))))
4603 (defun gnus-mime-view-part-as-type-internal ()
4604 (gnus-article-check-buffer)
4605 (let* ((handle (get-text-property (point) 'gnus-data))
4607 ;; Content-Type: foo/bar; name=...
4608 (mail-content-type-get (mm-handle-type handle) 'name)
4609 ;; Content-Disposition: attachment; filename=...
4610 (cdr (assq 'filename (cdr (mm-handle-disposition handle))))))
4611 (def-type (and name (mm-default-file-encoding name))))
4612 (and def-type (cons def-type 0))))
4614 (defun gnus-mime-view-part-as-type (&optional mime-type pred)
4615 "Choose a MIME media type, and view the part as such.
4616 If non-nil, PRED is a predicate to use during completion to limit the
4617 available media-types."
4621 (let ((default (gnus-mime-view-part-as-type-internal)))
4623 (format "View as MIME type (default %s): "
4625 (mapcar #'list (mailcap-mime-types))
4628 (gnus-article-check-buffer)
4629 (let ((handle (get-text-property (point) 'gnus-data)))
4631 (when (equal (mm-handle-media-type handle) "message/external-body")
4632 (unless (mm-handle-cache handle)
4633 (mm-extern-cache-contents handle))
4634 (setq handle (mm-handle-cache handle)))
4636 (mm-make-handle (mm-handle-buffer handle)
4637 (cons mime-type (cdr (mm-handle-type handle)))
4638 (mm-handle-encoding handle)
4639 (mm-handle-undisplayer handle)
4640 (mm-handle-disposition handle)
4641 (mm-handle-description handle)
4643 (mm-handle-id handle)))
4644 (setq gnus-article-mime-handles
4645 (mm-merge-handles gnus-article-mime-handles handle))
4646 (gnus-mm-display-part handle))))
4648 (defun gnus-mime-copy-part (&optional handle arg)
4649 "Put the MIME part under point into a new buffer.
4650 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4652 (interactive (list nil current-prefix-arg))
4653 (gnus-article-check-buffer)
4655 (setq handle (get-text-property (point) 'gnus-data)))
4657 (let ((filename (or (mail-content-type-get (mm-handle-type handle)
4659 (mail-content-type-get (mm-handle-disposition handle)
4661 contents dont-decode charset coding-system)
4662 (mm-with-unibyte-buffer
4663 (mm-insert-part handle)
4664 (setq contents (or (condition-case nil
4665 (mm-decompress-buffer filename nil 'sig)
4667 (setq dont-decode t)
4670 (setq filename (cond (filename (file-name-nondirectory filename))
4671 (dont-decode "*raw data*")
4676 (unless (setq charset (mail-content-type-get
4677 (mm-handle-type handle) 'charset))
4678 (unless (setq coding-system (mm-with-unibyte-buffer
4680 (mm-find-buffer-file-coding-system)))
4681 (setq charset gnus-newsgroup-charset))))
4683 (setq charset (or (cdr (assq arg
4684 gnus-summary-show-article-charset-alist))
4685 (mm-read-coding-system "Charset: ")))))
4686 (switch-to-buffer (generate-new-buffer filename))
4687 (if (or coding-system
4689 (setq coding-system (mm-charset-to-coding-system charset))
4690 (not (eq charset 'ascii))))
4692 (mm-enable-multibyte)
4693 (insert (mm-decode-coding-string contents coding-system))
4694 (setq buffer-file-coding-system
4695 (if (boundp 'last-coding-system-used)
4696 (symbol-value 'last-coding-system-used)
4698 (mm-disable-multibyte)
4700 (setq buffer-file-coding-system mm-binary-coding-system))
4701 ;; We do it this way to make `normal-mode' set the appropriate mode.
4704 (setq buffer-file-name (expand-file-name filename))
4706 (setq buffer-file-name nil))
4707 (goto-char (point-min)))))
4709 (defun gnus-mime-print-part (&optional handle filename)
4710 "Print the MIME part under point."
4711 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4712 (gnus-article-check-buffer)
4713 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4714 (contents (and handle (mm-get-part handle)))
4715 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4716 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4721 (mm-save-part-to-file handle file)
4722 (call-process shell-file-name nil
4723 (generate-new-buffer " *mm*")
4725 shell-command-switch
4727 printer file (mm-handle-type handle))))
4731 (gnus-print-buffer))
4732 (ps-despool filename)))))
4734 (defun gnus-mime-inline-part (&optional handle arg)
4735 "Insert the MIME part under point into the current buffer.
4736 Compressed files like .gz and .bz2 are decompressed."
4737 (interactive (list nil current-prefix-arg))
4738 (gnus-article-check-buffer)
4740 (setq handle (get-text-property (point) 'gnus-data)))
4743 (inhibit-read-only t)
4744 contents charset coding-system)
4745 (if (and (not arg) (mm-handle-undisplayer handle))
4746 (mm-remove-part handle)
4747 (mm-with-unibyte-buffer
4748 (mm-insert-part handle)
4750 (or (mm-decompress-buffer
4751 (or (mail-content-type-get (mm-handle-type handle)
4753 (mail-content-type-get (mm-handle-disposition handle)
4759 (unless (setq charset (mail-content-type-get
4760 (mm-handle-type handle) 'charset))
4761 (unless (setq coding-system
4762 (mm-with-unibyte-buffer
4764 (mm-find-buffer-file-coding-system)))
4765 (setq charset gnus-newsgroup-charset))))
4767 (if (mm-handle-undisplayer handle)
4768 (mm-remove-part handle))
4771 gnus-summary-show-article-charset-alist))
4772 (mm-read-coding-system "Charset: "))))
4774 (if (mm-handle-undisplayer handle)
4775 (mm-remove-part handle))))
4779 (if (or coding-system
4782 (mm-charset-to-coding-system charset))
4783 (not (eq coding-system 'ascii))))
4784 (mm-decode-coding-string contents coding-system)
4785 (mm-string-to-multibyte contents)))
4788 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4789 "Insert the MIME part under point into the current buffer using the
4791 (interactive (list nil current-prefix-arg))
4792 (gnus-article-check-buffer)
4793 (let ((handle (or handle (get-text-property (point) 'gnus-data)))
4794 (fun (get-text-property (point) 'gnus-callback))
4795 (gnus-newsgroup-ignored-charsets 'gnus-all)
4796 gnus-newsgroup-charset type charset)
4798 (if (mm-handle-undisplayer handle)
4799 (mm-remove-part handle))
4801 (setq gnus-newsgroup-charset
4802 (or (cdr (assq arg gnus-summary-show-article-charset-alist))
4803 (mm-read-coding-system "Charset: ")))
4804 ;; Strip the charset parameter from `handle'.
4805 (setq type (mm-handle-type
4806 (if (equal (mm-handle-media-type handle)
4807 "message/external-body")
4809 (unless (mm-handle-cache handle)
4810 (mm-extern-cache-contents handle))
4811 (mm-handle-cache handle))
4813 charset (assq 'charset (cdr type)))
4815 (funcall fun handle)))))
4817 (defun gnus-mime-view-part-externally (&optional handle)
4818 "View the MIME part under point with an external viewer."
4820 (gnus-article-check-buffer)
4821 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4822 (mm-user-display-methods nil)
4823 (mm-inlined-types nil)
4824 (mail-parse-charset gnus-newsgroup-charset)
4825 (mail-parse-ignored-charsets
4826 (with-current-buffer gnus-summary-buffer
4827 gnus-newsgroup-ignored-charsets))
4828 (type (mm-handle-media-type handle))
4829 (method (mailcap-mime-info type))
4830 (mm-enable-external t))
4831 (if (not (stringp method))
4832 (gnus-mime-view-part-as-type
4833 nil (lambda (type) (stringp (mailcap-mime-info type))))
4835 (if (mm-handle-undisplayer handle)
4836 (mm-remove-part handle)
4837 (mm-display-part handle))))))
4839 (defun gnus-mime-view-part-internally (&optional handle)
4840 "View the MIME part under point with an internal viewer.
4841 If no internal viewer is available, use an external viewer."
4843 (gnus-article-check-buffer)
4844 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4845 (mm-inlined-types '(".*"))
4846 (mm-inline-large-images t)
4847 (mail-parse-charset gnus-newsgroup-charset)
4848 (mail-parse-ignored-charsets
4849 (with-current-buffer gnus-summary-buffer
4850 gnus-newsgroup-ignored-charsets))
4851 (inhibit-read-only t))
4852 (if (not (mm-inlinable-p handle))
4853 (gnus-mime-view-part-as-type
4854 nil (lambda (type) (mm-inlinable-p handle type)))
4856 (if (mm-handle-undisplayer handle)
4857 (mm-remove-part handle)
4858 (mm-display-part handle))))))
4860 (defun gnus-mime-action-on-part (&optional action)
4861 "Do something with the MIME attachment at \(point\)."
4863 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4864 (gnus-article-check-buffer)
4865 (let ((action-pair (assoc action gnus-mime-action-alist)))
4867 (funcall (cdr action-pair)))))
4869 (defun gnus-article-part-wrapper (n function &optional no-handle interactive)
4870 "Call FUNCTION on MIME part N.
4871 Unless NO-HANDLE, call FUNCTION with N-th MIME handle as it's only argument.
4872 If INTERACTIVE, call FUNCTION interactivly."
4874 ;; Check whether the article is displayed.
4875 (unless (and (gnus-buffer-live-p gnus-article-buffer)
4876 (setq window (get-buffer-window gnus-article-buffer t))
4877 (frame-visible-p (setq frame (window-frame window))))
4878 (error "No article is displayed"))
4879 (with-current-buffer gnus-article-buffer
4880 ;; Check whether the article displays the right contents.
4881 (unless (with-current-buffer gnus-summary-buffer
4882 (eq gnus-current-article (gnus-summary-article-number)))
4883 (error "You should select the right article first"))
4884 ;; Check whether the specified part exists.
4885 (when (> n (length gnus-article-mime-handle-alist))
4886 (error "No such part")))
4889 ;; To select the window is needed so that the cursor
4890 ;; might be visible on the MIME button.
4891 (select-window (prog1
4893 (setq window (selected-window))
4894 ;; Article may be displayed in the other frame.
4895 (gnus-select-frame-set-input-focus
4898 (setq frame (selected-frame))))))
4899 (when (gnus-article-goto-part n)
4900 ;; We point the cursor and the arrow at the MIME button
4901 ;; when the `function' prompt the user for something.
4902 (let ((cursor-in-non-selected-windows t)
4903 (overlay-arrow-string "=>")
4904 (overlay-arrow-position (point-marker)))
4907 ((and no-handle interactive)
4908 (call-interactively function))
4914 (cdr (assq n gnus-article-mime-handle-alist))))
4917 (cdr (assq n gnus-article-mime-handle-alist)))))
4918 (set-marker overlay-arrow-position nil)
4919 (unless gnus-auto-select-part
4920 (gnus-select-frame-set-input-focus frame)
4921 (select-window window))))
4923 (if gnus-inhibit-mime-unbuttonizing
4924 ;; This is the default though the program shouldn't reach here.
4925 (error "No such part")
4926 ;; The part which doesn't have the MIME button is selected.
4927 ;; So, we display all the buttons and redo it.
4928 (let ((gnus-inhibit-mime-unbuttonizing t))
4929 (gnus-summary-show-article)
4930 (gnus-article-part-wrapper n function no-handle))))))
4932 (defun gnus-article-pipe-part (n)
4933 "Pipe MIME part N, which is the numerical prefix."
4935 (gnus-article-part-wrapper n 'mm-pipe-part))
4937 (defun gnus-article-save-part (n)
4938 "Save MIME part N, which is the numerical prefix."
4940 (gnus-article-part-wrapper n 'mm-save-part))
4942 (defun gnus-article-interactively-view-part (n)
4943 "View MIME part N interactively, which is the numerical prefix."
4945 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4947 (defun gnus-article-copy-part (n)
4948 "Copy MIME part N, which is the numerical prefix."
4950 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4952 (defun gnus-article-view-part-as-charset (n)
4953 "View MIME part N using a specified charset.
4954 N is the numerical prefix."
4956 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4958 (defun gnus-article-view-part-externally (n)
4959 "View MIME part N externally, which is the numerical prefix."
4961 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4963 (defun gnus-article-inline-part (n)
4964 "Inline MIME part N, which is the numerical prefix."
4966 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4968 (defun gnus-article-save-part-and-strip (n)
4969 "Save MIME part N and replace it with an external body.
4970 N is the numerical prefix."
4972 (gnus-article-part-wrapper n 'gnus-mime-save-part-and-strip t))
4974 (defun gnus-article-replace-part (n)
4975 "Replace MIME part N with an external body.
4976 N is the numerical prefix."
4978 (gnus-article-part-wrapper n 'gnus-mime-replace-part t t))
4980 (defun gnus-article-delete-part (n)
4981 "Delete MIME part N and add some information about the removed part.
4982 N is the numerical prefix."
4984 (gnus-article-part-wrapper n 'gnus-mime-delete-part t))
4986 (defun gnus-article-view-part-as-type (n)
4987 "Choose a MIME media type, and view part N as such.
4988 N is the numerical prefix."
4990 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-type t))
4992 (defun gnus-article-mime-match-handle-first (condition)
4995 (dolist (ihandle gnus-article-mime-handle-alist)
4997 ((functionp condition)
4998 (funcall condition (cdr ihandle)))
4999 ((eq condition 'undisplayed)
5000 (not (or (mm-handle-undisplayer (cdr ihandle))
5001 (equal (mm-handle-media-type (cdr ihandle))
5002 "multipart/alternative"))))
5003 ((eq condition 'undisplayed-alternative)
5004 (not (mm-handle-undisplayer (cdr ihandle))))
5006 (gnus-article-goto-part (car ihandle))
5007 (or (not n) (< (car ihandle) n)))
5008 (setq n (car ihandle))))
5012 (defun gnus-article-view-part (&optional n)
5013 "View MIME part N, which is the numerical prefix."
5015 (with-current-buffer gnus-article-buffer
5016 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
5017 gnus-article-mime-match-handle-function)))
5018 (when (> n (length gnus-article-mime-handle-alist))
5019 (error "No such part"))
5020 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
5021 (when (gnus-article-goto-part n)
5022 (if (equal (car handle) "multipart/alternative")
5023 (gnus-article-press-button)
5024 (when (eq (gnus-mm-display-part handle) 'internal)
5025 (gnus-set-window-start)))))))
5027 (defsubst gnus-article-mime-total-parts ()
5028 (if (bufferp (car gnus-article-mime-handles))
5030 (1- (length gnus-article-mime-handles))))
5032 (defun gnus-mm-display-part (handle)
5033 "Display HANDLE and fix MIME button."
5034 (let ((id (get-text-property (point) 'gnus-part))
5036 (inhibit-read-only t))
5039 (let ((window (selected-window))
5040 (mail-parse-charset gnus-newsgroup-charset)
5041 (mail-parse-ignored-charsets
5042 (if (gnus-buffer-live-p gnus-summary-buffer)
5043 (with-current-buffer gnus-summary-buffer
5044 gnus-newsgroup-ignored-charsets)
5048 (let ((win (gnus-get-buffer-window (current-buffer) t))
5051 (select-window win))
5054 (if (mm-handle-displayed-p handle)
5055 ;; This will remove the part.
5056 (mm-display-part handle)
5058 (narrow-to-region (point)
5059 (if (eobp) (point) (1+ (point))))
5060 (mm-display-part handle)
5061 ;; We narrow to the part itself and
5062 ;; then call the treatment functions.
5063 (goto-char (point-min))
5065 (narrow-to-region (point) (point-max))
5068 (gnus-article-mime-total-parts)
5069 (mm-handle-media-type handle)))))
5070 (if (window-live-p window)
5071 (select-window window)))))
5074 (gnus-insert-mime-button
5075 handle id (list (mm-handle-displayed-p handle)))
5076 (goto-char point))))
5078 (defun gnus-article-goto-part (n)
5079 "Go to MIME part N."
5080 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
5082 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
5083 (let ((gnus-tmp-name
5084 (or (mail-content-type-get (mm-handle-type handle) 'name)
5085 (mail-content-type-get (mm-handle-disposition handle) 'filename)
5086 (mail-content-type-get (mm-handle-type handle) 'url)
5088 (gnus-tmp-type (mm-handle-media-type handle))
5089 (gnus-tmp-description
5090 (mail-decode-encoded-word-string (or (mm-handle-description handle)
5093 (if (if displayed (car displayed)
5094 (mm-handle-displayed-p handle))
5096 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
5098 gnus-tmp-type-long b e)
5099 (when (string-match ".*/" gnus-tmp-name)
5100 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
5101 (setq gnus-tmp-type-long (concat gnus-tmp-type
5102 (and (not (equal gnus-tmp-name ""))
5103 (concat "; " gnus-tmp-name))))
5104 (unless (equal gnus-tmp-description "")
5105 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
5110 gnus-mime-button-line-format gnus-mime-button-line-format-alist
5111 `(keymap ,gnus-mime-button-map
5112 gnus-callback gnus-mm-display-part
5113 gnus-part ,gnus-tmp-id
5114 article-type annotation
5117 ;; Exclude a newline.
5120 (widget-convert-button
5123 :action 'gnus-widget-press-button
5124 :button-keymap gnus-mime-button-map
5126 (lambda (widget/window &optional overlay pos)
5127 ;; Needed to properly clear the message due to a bug in
5128 ;; wid-edit (XEmacs only).
5129 (if (boundp 'help-echo-owns-message)
5130 (setq help-echo-owns-message t))
5132 "%S: %s the MIME part; %S: more options"
5133 (aref gnus-mouse-2 0)
5134 ;; XEmacs will get a single widget arg; Emacs 21 will get
5135 ;; window, overlay, position.
5136 (if (mm-handle-displayed-p
5138 (with-current-buffer (gnus-overlay-buffer overlay)
5139 (widget-get (widget-at (gnus-overlay-start overlay))
5141 (widget-get widget/window :mime-handle)))
5143 (aref gnus-down-mouse-3 0))))))
5145 (defun gnus-widget-press-button (elems el)
5146 (goto-char (widget-get elems :from))
5147 (gnus-article-press-button))
5149 (defvar gnus-displaying-mime nil)
5151 (defun gnus-display-mime (&optional ihandles)
5152 "Display the MIME parts."
5154 (save-selected-window
5155 (let ((window (get-buffer-window gnus-article-buffer))
5158 (select-window window)
5159 ;; We have to do this since selecting the window
5160 ;; may change the point. So we set the window point.
5161 (set-window-point window point)))
5162 (let ((handles ihandles)
5163 (inhibit-read-only t)
5166 ((setq handles (mm-dissect-buffer nil gnus-article-loose-mime))
5167 (when gnus-article-emulate-mime
5168 (mm-uu-dissect-text-parts handles)))
5169 (gnus-article-emulate-mime
5170 (setq handles (mm-uu-dissect))))
5171 (when (and (not ihandles)
5172 (not gnus-displaying-mime))
5173 ;; Top-level call; we clean up.
5174 (when gnus-article-mime-handles
5175 (mm-destroy-parts gnus-article-mime-handles)
5176 (setq gnus-article-mime-handle-alist nil));; A trick.
5177 (setq gnus-article-mime-handles handles)
5178 ;; We allow users to glean info from the handles.
5179 (when gnus-article-mime-part-function
5180 (gnus-mime-part-function handles)))
5182 (or (not (stringp (car handles)))
5185 (when (and (not ihandles)
5186 (not gnus-displaying-mime))
5187 ;; Clean up for mime parts.
5189 (delete-region (point) (point-max)))
5190 (let ((gnus-displaying-mime t))
5191 (gnus-mime-display-part handles)))
5194 (narrow-to-region (point) (point-max))
5195 (gnus-treat-article nil 1 1)
5198 ;; Highlight the headers.
5202 (narrow-to-region (point-min) (point))
5203 (gnus-article-save-original-date
5204 (gnus-treat-article 'head)))))))))
5206 (defcustom gnus-mime-display-multipart-as-mixed nil
5207 "Display \"multipart\" parts as \"multipart/mixed\".
5209 If t, it overrides nil values of
5210 `gnus-mime-display-multipart-alternative-as-mixed' and
5211 `gnus-mime-display-multipart-related-as-mixed'."
5212 :group 'gnus-article-mime
5215 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
5216 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
5218 :group 'gnus-article-mime
5221 (defcustom gnus-mime-display-multipart-related-as-mixed nil
5222 "Display \"multipart/related\" parts as \"multipart/mixed\".
5224 If displaying \"text/html\" is discouraged \(see
5225 `mm-discouraged-alternatives'\) images or other material inside a
5226 \"multipart/related\" part might be overlooked when this variable is nil."
5228 :group 'gnus-article-mime
5231 (defun gnus-mime-display-part (handle)
5233 ;; Maybe a broken MIME message.
5236 ((not (stringp (car handle)))
5237 (gnus-mime-display-single handle))
5238 ;; User-defined multipart
5239 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
5240 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
5242 ;; multipart/alternative
5243 ((and (equal (car handle) "multipart/alternative")
5244 (not (or gnus-mime-display-multipart-as-mixed
5245 gnus-mime-display-multipart-alternative-as-mixed)))
5246 (let ((id (1+ (length gnus-article-mime-handle-alist))))
5247 (push (cons id handle) gnus-article-mime-handle-alist)
5248 (gnus-mime-display-alternative (cdr handle) nil nil id)))
5249 ;; multipart/related
5250 ((and (equal (car handle) "multipart/related")
5251 (not (or gnus-mime-display-multipart-as-mixed
5252 gnus-mime-display-multipart-related-as-mixed)))
5253 ;;;!!!We should find the start part, but we just default
5254 ;;;!!!to the first part.
5255 ;;(gnus-mime-display-part (cadr handle))
5256 ;;;!!! Most multipart/related is an HTML message plus images.
5257 ;;;!!! Unfortunately we are unable to let W3 display those
5258 ;;;!!! included images, so we just display it as a mixed multipart.
5259 ;;(gnus-mime-display-mixed (cdr handle))
5260 ;;;!!! No, w3 can display everything just fine.
5261 (gnus-mime-display-part (cadr handle)))
5262 ((equal (car handle) "multipart/signed")
5263 (gnus-add-wash-type 'signed)
5264 (gnus-mime-display-security handle))
5265 ((equal (car handle) "multipart/encrypted")
5266 (gnus-add-wash-type 'encrypted)
5267 (gnus-mime-display-security handle))
5268 ;; Other multiparts are handled like multipart/mixed.
5270 (gnus-mime-display-mixed (cdr handle)))))
5272 (defun gnus-mime-part-function (handles)
5273 (if (stringp (car handles))
5274 (mapcar 'gnus-mime-part-function (cdr handles))
5275 (funcall gnus-article-mime-part-function handles)))
5277 (defun gnus-mime-display-mixed (handles)
5278 (mapcar 'gnus-mime-display-part handles))
5280 (defun gnus-mime-display-single (handle)
5281 (let ((type (mm-handle-media-type handle))
5282 (ignored gnus-ignored-mime-types)
5289 (when (string-match (pop ignored) type)
5290 (throw 'ignored nil)))
5291 (if (and (setq not-attachment
5292 (and (not (mm-inline-override-p handle))
5293 (or (not (mm-handle-disposition handle))
5294 (equal (car (mm-handle-disposition handle))
5296 (mm-attachment-override-p handle))))
5297 (mm-automatic-display-p handle)
5299 (mm-inlinable-p handle)
5300 (mm-inlined-p handle))
5301 (mm-automatic-external-display-p type)))
5303 (when (equal (mm-handle-media-supertype handle) "text")
5305 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5307 (push (cons id handle) gnus-article-mime-handle-alist)
5309 (equal (mm-handle-media-supertype handle) "message"))
5312 (cond ((not (bolp)) 2)
5313 ((or (bobp) (eq (char-before (1- (point))) ?\n)) 0)
5315 (when (or (not display)
5316 (not (gnus-unbuttonized-mime-type-p type)))
5317 (gnus-insert-mime-button
5318 handle id (list (or display (and not-attachment text))))
5319 (gnus-article-insert-newline)
5320 ;; Remember modify the number of forward lines.
5328 (let ((mail-parse-charset gnus-newsgroup-charset)
5329 (mail-parse-ignored-charsets
5330 (save-excursion (condition-case ()
5331 (set-buffer gnus-summary-buffer)
5333 gnus-newsgroup-ignored-charsets)))
5334 (mm-display-part handle t))
5335 (goto-char (point-max)))
5336 ((and text not-attachment)
5340 (gnus-article-insert-newline)
5343 (let ((charset (mail-content-type-get (mm-handle-type handle)
5345 (cond ((not charset)
5346 (mm-string-as-multibyte (mm-get-part handle)))
5347 ((eq charset 'gnus-decoded)
5348 (with-current-buffer (mm-handle-buffer handle)
5351 (mm-decode-string (mm-get-part handle) charset)))))
5352 (goto-char (point-max))))
5356 (narrow-to-region beg (point))
5359 (gnus-article-mime-total-parts)
5360 (mm-handle-media-type handle)))))))))
5362 (defun gnus-unbuttonized-mime-type-p (type)
5363 "Say whether TYPE is to be unbuttonized."
5364 (unless gnus-inhibit-mime-unbuttonizing
5366 (let ((types gnus-unbuttonized-mime-types))
5368 (when (string-match (pop types) type)
5369 (throw 'found t)))))
5371 (let ((types gnus-buttonized-mime-types))
5373 (when (string-match (pop types) type)
5374 (throw 'found t)))))))))
5376 (defun gnus-article-insert-newline ()
5377 "Insert a newline, but mark it as undeletable."
5378 (gnus-put-text-property
5379 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5381 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5382 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5385 handle (inhibit-read-only t) from props begend not-pref)
5386 (save-window-excursion
5389 (narrow-to-region (car ibegend)
5392 (goto-char (car ibegend))
5395 (delete-region (point-min) (point-max))
5396 (mm-remove-parts handles))
5397 (setq begend (list (point-marker)))
5399 (unless (setq not-pref (cadr (member preferred ihandles)))
5400 (setq not-pref (car ihandles)))
5403 (not (gnus-unbuttonized-mime-type-p
5404 "multipart/alternative")))
5405 (gnus-add-text-properties
5408 (insert (format "%d. " id))
5412 (unless ,(not ibegend)
5413 (setq gnus-article-mime-handle-alist
5414 ',gnus-article-mime-handle-alist))
5415 (gnus-mime-display-alternative
5416 ',ihandles ',not-pref ',begend ,id))
5417 keymap ,gnus-mime-button-map
5418 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5419 face ,gnus-article-button-face
5421 article-type multipart))
5422 (widget-convert-button 'link from (point)
5423 :action 'gnus-widget-press-button
5424 :button-keymap gnus-widget-button-keymap)
5426 (while (setq handle (pop handles))
5427 (gnus-add-text-properties
5430 (insert (format "(%c) %-18s"
5431 (if (equal handle preferred) ?* ? )
5432 (mm-handle-media-type handle)))
5436 (unless ,(not ibegend)
5437 (setq gnus-article-mime-handle-alist
5438 ',gnus-article-mime-handle-alist))
5439 (gnus-mime-display-alternative
5440 ',ihandles ',handle ',begend ,id))
5441 keymap ,gnus-mime-button-map
5442 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5443 face ,gnus-article-button-face
5446 (widget-convert-button 'link from (point)
5447 :action 'gnus-widget-press-button
5448 :button-keymap gnus-widget-button-keymap)
5452 (if (stringp (car preferred))
5453 (gnus-display-mime preferred)
5454 (let ((mail-parse-charset gnus-newsgroup-charset)
5455 (mail-parse-ignored-charsets
5456 (with-current-buffer gnus-summary-buffer
5457 gnus-newsgroup-ignored-charsets)))
5458 (mm-display-part preferred)
5462 (narrow-to-region (car begend) (point-max))
5464 nil (length gnus-article-mime-handle-alist)
5465 (gnus-article-mime-total-parts)
5466 (mm-handle-media-type handle))))))
5467 (goto-char (point-max))
5468 (setcdr begend (point-marker)))))
5470 (goto-char point))))
5472 (defconst gnus-article-wash-status-strings
5473 (let ((alist '((cite "c" "Possible hidden citation text"
5474 " " "All citation text visible")
5475 (headers "h" "Hidden headers"
5476 " " "All headers visible.")
5477 (pgp "p" "Encrypted or signed message status hidden"
5478 " " "No hidden encryption nor digital signature status")
5479 (signature "s" "Signature has been hidden"
5480 " " "Signature is visible")
5481 (overstrike "o" "Overstrike (^H) characters applied"
5482 " " "No overstrike characters applied")
5483 (emphasis "e" "/*_Emphasis_*/ characters applied"
5484 " " "No /*_emphasis_*/ characters applied")))
5486 (dolist (entry alist result)
5487 (let ((key (nth 0 entry))
5488 (on (copy-sequence (nth 1 entry)))
5489 (on-help (nth 2 entry))
5490 (off (copy-sequence (nth 3 entry)))
5491 (off-help (nth 4 entry)))
5492 (put-text-property 0 1 'help-echo on-help on)
5493 (put-text-property 0 1 'help-echo off-help off)
5494 (push (list key on off) result))))
5495 "Alist of strings describing wash status in the mode line.
5496 Each entry has the form (KEY ON OF), where the KEY is a symbol
5497 representing the particular washing function, ON is the string to use
5498 in the article mode line when the washing function is active, and OFF
5499 is the string to use when it is inactive.")
5501 (defun gnus-article-wash-status-entry (key value)
5502 (let ((entry (assoc key gnus-article-wash-status-strings)))
5503 (if value (nth 1 entry) (nth 2 entry))))
5505 (defun gnus-article-wash-status ()
5506 "Return a string which display status of article washing."
5507 (with-current-buffer gnus-article-buffer
5508 (let ((cite (memq 'cite gnus-article-wash-types))
5509 (headers (memq 'headers gnus-article-wash-types))
5510 (boring (memq 'boring-headers gnus-article-wash-types))
5511 (pgp (memq 'pgp gnus-article-wash-types))
5512 (pem (memq 'pem gnus-article-wash-types))
5513 (signed (memq 'signed gnus-article-wash-types))
5514 (encrypted (memq 'encrypted gnus-article-wash-types))
5515 (signature (memq 'signature gnus-article-wash-types))
5516 (overstrike (memq 'overstrike gnus-article-wash-types))
5517 (emphasis (memq 'emphasis gnus-article-wash-types)))
5519 (gnus-article-wash-status-entry 'cite cite)
5520 (gnus-article-wash-status-entry 'headers (or headers boring))
5521 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5522 (gnus-article-wash-status-entry 'signature signature)
5523 (gnus-article-wash-status-entry 'overstrike overstrike)
5524 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5526 (defun gnus-add-wash-type (type)
5527 "Add a washing of TYPE to the current status."
5528 (add-to-list 'gnus-article-wash-types type))
5530 (defun gnus-delete-wash-type (type)
5531 "Add a washing of TYPE to the current status."
5532 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5534 (defun gnus-add-image (category image)
5535 "Add IMAGE of CATEGORY to the list of displayed images."
5536 (let ((entry (assq category gnus-article-image-alist)))
5538 (setq entry (list category))
5539 (push entry gnus-article-image-alist))
5540 (nconc entry (list image))))
5542 (defun gnus-delete-images (category)
5543 "Delete all images in CATEGORY."
5544 (let ((entry (assq category gnus-article-image-alist)))
5545 (dolist (image (cdr entry))
5546 (gnus-remove-image image category))
5547 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5548 (gnus-delete-wash-type category)))
5550 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5552 (defun gnus-article-maybe-hide-headers ()
5553 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5554 Provided for backwards compatibility."
5555 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5556 (not (with-current-buffer gnus-summary-buffer
5557 gnus-have-all-headers)))
5558 (not gnus-inhibit-hiding))
5559 (gnus-article-hide-headers)))
5563 (defun gnus-output-to-file (file-name)
5564 "Append the current article to a file named FILE-NAME.
5565 If `gnus-article-save-coding-system' is non-nil, it is used to encode
5566 text and used as the value of the coding cookie which is added to the
5567 top of a file. Otherwise, this function saves a raw article without
5569 (let* ((artbuf (current-buffer))
5570 (file-name-coding-system nnmail-pathname-coding-system)
5571 (coding gnus-article-save-coding-system)
5572 (coding-system-for-read (if coding
5573 nil ;; Rely on the coding cookie.
5574 mm-text-coding-system))
5575 (coding-system-for-write (or coding
5576 mm-text-coding-system-for-write
5577 mm-text-coding-system))
5578 (exists (file-exists-p file-name)))
5581 (insert-file-contents file-name)
5582 (goto-char (point-min))
5583 ;; Remove the existing coding cookie.
5584 (when (looking-at "X-Gnus-Coding-System: .+\n\n")
5585 (delete-region (match-beginning 0) (match-end 0))))
5586 (goto-char (point-max))
5587 (insert-buffer-substring artbuf)
5588 ;; Append newline at end of the buffer as separator, and then
5590 (goto-char (point-max))
5593 ;; If the coding system is not suitable to encode the text,
5594 ;; ask a user for a proper one.
5595 (when (fboundp 'select-safe-coding-system)
5596 (setq coding (coding-system-base
5597 (save-window-excursion
5598 (select-safe-coding-system (point-min) (point-max)
5600 (setq coding-system-for-write
5601 (or (cdr (assq coding '((mule-utf-8 . utf-8))))
5603 (goto-char (point-min))
5604 ;; Add the coding cookie.
5605 (insert (format "X-Gnus-Coding-System: -*- coding: %s; -*-\n\n"
5606 coding-system-for-write)))
5609 (write-region (point-min) (point-max) file-name nil 'no-message)
5610 (message "Appended to %s" file-name))
5611 (write-region (point-min) (point-max) file-name))))
5614 (defun gnus-narrow-to-page (&optional arg)
5615 "Narrow the article buffer to a page.
5616 If given a numerical ARG, move forward ARG pages."
5618 (setq arg (if arg (prefix-numeric-value arg) 0))
5620 (set-buffer gnus-article-buffer)
5621 (goto-char (point-min))
5623 ;; Remove any old next/prev buttons.
5624 (when (gnus-visual-p 'page-marker)
5625 (let ((inhibit-read-only t))
5626 (gnus-remove-text-with-property 'gnus-prev)
5627 (gnus-remove-text-with-property 'gnus-next)))
5630 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5632 (re-search-forward page-delimiter nil 'move arg)))
5633 (goto-char (match-end 0))
5635 (goto-char (point-min))
5636 (setq gnus-page-broken
5637 (and (re-search-forward page-delimiter nil t) t))))
5638 (when gnus-page-broken
5641 (if (re-search-forward page-delimiter nil 'move)
5644 (when (and (gnus-visual-p 'page-marker)
5645 (> (point-min) (save-restriction (widen) (point-min))))
5647 (goto-char (point-min))
5648 (gnus-insert-prev-page-button)))
5649 (when (and (gnus-visual-p 'page-marker)
5650 (< (point-max) (save-restriction (widen) (point-max))))
5652 (goto-char (point-max))
5653 (gnus-insert-next-page-button))))))
5655 ;; Article mode commands
5657 (defun gnus-article-goto-next-page ()
5658 "Show the next page of the article."
5660 (when (gnus-article-next-page)
5661 (goto-char (point-min))
5662 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5665 (defun gnus-article-goto-prev-page ()
5666 "Show the previous page of the article."
5669 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5670 (gnus-article-prev-page nil)))
5672 ;; This is cleaner but currently breaks `gnus-pick-mode':
5674 ;; (defun gnus-article-goto-next-page ()
5675 ;; "Show the next page of the article."
5677 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5678 ;; (gnus-summary-next-page)))
5680 ;; (defun gnus-article-goto-prev-page ()
5681 ;; "Show the next page of the article."
5683 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5684 ;; (gnus-summary-prev-page)))
5686 (defun gnus-article-next-page (&optional lines)
5687 "Show the next page of the current article.
5688 If end of article, return non-nil. Otherwise return nil.
5689 Argument LINES specifies lines to be scrolled up."
5691 (move-to-window-line -1)
5694 (and (pos-visible-in-window-p) ;Not continuation line.
5695 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5696 ;; Nothing in this page.
5697 (if (or (not gnus-page-broken)
5702 (eobp)))) ;Real end-of-buffer?
5704 (when gnus-article-over-scroll
5705 (gnus-article-next-page-1 lines))
5707 (gnus-narrow-to-page 1) ;Go to next page.
5709 ;; More in this page.
5710 (gnus-article-next-page-1 lines)
5713 (defmacro gnus-article-beginning-of-window ()
5714 "Move point to the beginning of the window.
5715 In Emacs, the point is placed at the line number which `scroll-margin'
5717 (if (featurep 'xemacs)
5718 '(move-to-window-line 0)
5719 '(move-to-window-line
5720 (min (max 0 scroll-margin)
5721 (max 1 (- (window-height)
5722 (if mode-line-format 1 0)
5723 (if header-line-format 1 0)))))))
5725 (defun gnus-article-next-page-1 (lines)
5726 (when (and (not (featurep 'xemacs))
5729 (numberp (symbol-value 'scroll-margin))
5730 (> (symbol-value 'scroll-margin) 0))
5731 ;; Protect against the bug that Emacs 21.x hangs up when scrolling up for
5732 ;; too many number of lines if `scroll-margin' is set as two or greater.
5733 (setq lines (min lines
5734 (max 0 (- (count-lines (window-start) (point-max))
5735 (symbol-value 'scroll-margin))))))
5737 (let ((scroll-in-place nil))
5740 ;; Long lines may cause an end-of-buffer error.
5741 (goto-char (point-max))))
5742 (gnus-article-beginning-of-window))
5744 (defun gnus-article-prev-page (&optional lines)
5745 "Show previous page of current article.
5746 Argument LINES specifies lines to be scrolled down."
5748 (move-to-window-line 0)
5749 (if (and gnus-page-broken
5751 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5753 (gnus-narrow-to-page -1) ;Go to previous page.
5754 (goto-char (point-max))
5758 (let ((scroll-in-place nil))
5759 (scroll-down lines))
5760 (beginning-of-buffer
5761 (goto-char (point-min))))
5762 (gnus-article-beginning-of-window))))
5764 (defun gnus-article-only-boring-p ()
5765 "Decide whether there is only boring text remaining in the article.
5766 Something \"interesting\" is a word of at least two letters that does
5767 not have a face in `gnus-article-boring-faces'."
5768 (when (and gnus-article-skip-boring
5769 (boundp 'gnus-article-boring-faces)
5770 (symbol-value 'gnus-article-boring-faces))
5772 (let ((inhibit-point-motion-hooks t))
5774 (while (re-search-forward "\\b\\w\\w" nil t)
5776 (when (not (gnus-intersection
5777 (gnus-faces-at (point))
5778 (symbol-value 'gnus-article-boring-faces)))
5779 (throw 'only-boring nil)))
5780 (throw 'only-boring t))))))
5782 (defun gnus-article-refer-article ()
5783 "Read article specified by message-id around point."
5786 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5787 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5788 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5789 (let ((msg-id (concat "<" (match-string 0) ">")))
5790 (set-buffer gnus-summary-buffer)
5791 (gnus-summary-refer-article msg-id))
5792 (error "No references around point"))))
5794 (defun gnus-article-show-summary ()
5795 "Reconfigure windows to show summary buffer."
5797 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5798 (error "There is no summary buffer for this article buffer")
5799 (gnus-article-set-globals)
5800 (gnus-configure-windows 'article)
5801 (gnus-summary-goto-subject gnus-current-article)
5802 (gnus-summary-position-point)))
5804 (defun gnus-article-describe-briefly ()
5805 "Describe article mode commands briefly."
5807 (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")))
5809 (defun gnus-article-summary-command ()
5810 "Execute the last keystroke in the summary buffer."
5812 (let ((obuf (current-buffer))
5813 (owin (current-window-configuration))
5815 (switch-to-buffer gnus-article-current-summary 'norecord)
5816 (setq func (lookup-key (current-local-map) (this-command-keys)))
5817 (call-interactively func)
5819 (set-window-configuration owin)
5820 (set-window-point (get-buffer-window (current-buffer)) (point))))
5822 (defun gnus-article-summary-command-nosave ()
5823 "Execute the last keystroke in the summary buffer."
5826 (pop-to-buffer gnus-article-current-summary 'norecord)
5827 (setq func (lookup-key (current-local-map) (this-command-keys)))
5828 (call-interactively func)))
5830 (defun gnus-article-check-buffer ()
5831 "Beep if not in an article buffer."
5832 (unless (equal major-mode 'gnus-article-mode)
5833 (error "Command invoked outside of a Gnus article buffer")))
5835 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5836 "Read a summary buffer key sequence and execute it from the article buffer."
5838 (gnus-article-check-buffer)
5840 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5841 "Zc" "ZC" "ZE" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5842 "=" "^" "\M-^" "|"))
5848 '("n" "Gn" "p" "Gp"))
5851 (set-buffer gnus-article-current-summary)
5852 (let (gnus-pick-mode)
5853 (push (or key last-command-event) unread-command-events)
5854 (setq keys (if (featurep 'xemacs)
5855 (events-to-keys (read-key-sequence nil))
5856 (read-key-sequence nil)))))
5860 (if (or (member keys nosaves)
5861 (member keys nosave-but-article)
5862 (member keys nosave-in-article))
5864 (save-window-excursion
5865 (pop-to-buffer gnus-article-current-summary 'norecord)
5866 ;; We disable the pick minor mode commands.
5867 (let (gnus-pick-mode)
5868 (setq func (lookup-key (current-local-map) keys))))
5872 (unless (member keys nosave-in-article)
5873 (set-buffer gnus-article-current-summary))
5874 (call-interactively func)
5875 (setq new-sum-point (point)))
5876 (when (member keys nosave-but-article)
5877 (pop-to-buffer gnus-article-buffer 'norecord)))
5878 ;; These commands should restore window configuration.
5879 (let ((obuf (current-buffer))
5880 (owin (current-window-configuration))
5882 win func in-buffer selected new-sum-start new-sum-hscroll)
5883 (cond (not-restore-window
5884 (pop-to-buffer gnus-article-current-summary 'norecord))
5885 ((setq win (get-buffer-window gnus-article-current-summary))
5886 (select-window win))
5888 (switch-to-buffer gnus-article-current-summary 'norecord)))
5889 (setq in-buffer (current-buffer))
5890 ;; We disable the pick minor mode commands.
5891 (if (and (setq func (let (gnus-pick-mode)
5892 (lookup-key (current-local-map) keys)))
5895 (call-interactively func)
5896 (when (eq win (selected-window))
5897 (setq new-sum-point (point)
5898 new-sum-start (window-start win)
5899 new-sum-hscroll (window-hscroll win)))
5900 (when (eq in-buffer (current-buffer))
5901 (setq selected (gnus-summary-select-article))
5903 (unless not-restore-window
5904 (set-window-configuration owin))
5905 (when (eq selected 'old)
5907 (set-window-start (get-buffer-window (current-buffer))
5909 (set-window-point (get-buffer-window (current-buffer))
5911 (when (and (not not-restore-window)
5913 (set-window-point win new-sum-point)
5914 (set-window-start win new-sum-start)
5915 (set-window-hscroll win new-sum-hscroll))))
5916 (set-window-configuration owin)
5919 (defun gnus-article-describe-key (key)
5920 "Display documentation of the function invoked by KEY. KEY is a string."
5921 (interactive "kDescribe key: ")
5922 (gnus-article-check-buffer)
5923 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5925 (set-buffer gnus-article-current-summary)
5926 (let (gnus-pick-mode)
5927 (if (featurep 'xemacs)
5929 (push (elt key 0) unread-command-events)
5930 (setq key (events-to-keys
5931 (read-key-sequence "Describe key: "))))
5932 (setq unread-command-events
5934 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5935 (string-to-list key)))
5936 (setq key (read-key-sequence "Describe key: "))))
5938 (describe-key key)))
5940 (defun gnus-article-describe-key-briefly (key &optional insert)
5941 "Display documentation of the function invoked by KEY. KEY is a string."
5942 (interactive "kDescribe key: \nP")
5943 (gnus-article-check-buffer)
5944 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5946 (set-buffer gnus-article-current-summary)
5947 (let (gnus-pick-mode)
5948 (if (featurep 'xemacs)
5950 (push (elt key 0) unread-command-events)
5951 (setq key (events-to-keys
5952 (read-key-sequence "Describe key: "))))
5953 (setq unread-command-events
5955 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5956 (string-to-list key)))
5957 (setq key (read-key-sequence "Describe key: "))))
5958 (describe-key-briefly key insert))
5959 (describe-key-briefly key insert)))
5961 (defun gnus-article-reply-with-original (&optional wide)
5962 "Start composing a reply mail to the current message.
5963 The text in the region will be yanked. If the region isn't active,
5964 the entire article will be yanked."
5966 (let ((article (cdr gnus-article-current))
5968 (if (not (gnus-region-active-p))
5969 (with-current-buffer gnus-summary-buffer
5970 (gnus-summary-reply (list (list article)) wide))
5971 (setq contents (buffer-substring (point) (mark t)))
5972 ;; Deactivate active regions.
5973 (when (and (boundp 'transient-mark-mode)
5974 transient-mark-mode)
5975 (setq mark-active nil))
5976 (with-current-buffer gnus-summary-buffer
5978 (list (list article contents)) wide)))))
5980 (defun gnus-article-followup-with-original ()
5981 "Compose a followup to the current article.
5982 The text in the region will be yanked. If the region isn't active,
5983 the entire article will be yanked."
5985 (let ((article (cdr gnus-article-current))
5987 (if (not (gnus-region-active-p))
5988 (with-current-buffer gnus-summary-buffer
5989 (gnus-summary-followup (list (list article))))
5990 (setq contents (buffer-substring (point) (mark t)))
5991 ;; Deactivate active regions.
5992 (when (and (boundp 'transient-mark-mode)
5993 transient-mark-mode)
5994 (setq mark-active nil))
5995 (with-current-buffer gnus-summary-buffer
5996 (gnus-summary-followup
5997 (list (list article contents)))))))
5999 (defun gnus-article-hide (&optional arg force)
6000 "Hide all the gruft in the current article.
6001 This means that signatures, cited text and (some) headers will be
6003 If given a prefix, show the hidden text instead."
6004 (interactive (append (gnus-article-hidden-arg) (list 'force)))
6005 (gnus-article-hide-headers arg)
6006 (gnus-article-hide-list-identifiers arg)
6007 (gnus-article-hide-citation-maybe arg force)
6008 (gnus-article-hide-signature arg))
6010 (defun gnus-article-maybe-highlight ()
6011 "Do some article highlighting if article highlighting is requested."
6012 (when (gnus-visual-p 'article-highlight 'highlight)
6013 (gnus-article-highlight-some)))
6015 (defun gnus-check-group-server ()
6016 ;; Make sure the connection to the server is alive.
6017 (unless (gnus-server-opened
6018 (gnus-find-method-for-group gnus-newsgroup-name))
6019 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
6020 (gnus-request-group gnus-newsgroup-name t)))
6023 (autoload 'nneething-get-file-name "nneething"))
6025 (defun gnus-request-article-this-buffer (article group)
6026 "Get an article and insert it into this buffer."
6027 (let (do-update-line sparse-header)
6031 (gnus-kill-all-overlays)
6032 (setq group (or group gnus-newsgroup-name))
6034 ;; Using `gnus-request-article' directly will insert the article into
6035 ;; `nntp-server-buffer' - so we'll save some time by not having to
6036 ;; copy it from the server buffer into the article buffer.
6038 ;; We only request an article by message-id when we do not have the
6039 ;; headers for it, so we'll have to get those.
6040 (when (stringp article)
6041 (gnus-read-header article))
6043 ;; If the article number is negative, that means that this article
6044 ;; doesn't belong in this newsgroup (possibly), so we find its
6045 ;; message-id and request it by id instead of number.
6046 (when (and (numberp article)
6048 (get-buffer gnus-summary-buffer)
6049 (gnus-buffer-exists-p gnus-summary-buffer))
6051 (set-buffer gnus-summary-buffer)
6052 (let ((header (gnus-summary-article-header article)))
6055 ((memq article gnus-newsgroup-sparse)
6056 ;; This is a sparse gap article.
6057 (setq do-update-line article)
6058 (setq article (mail-header-id header))
6059 (setq sparse-header (gnus-read-header article))
6060 (setq gnus-newsgroup-sparse
6061 (delq article gnus-newsgroup-sparse)))
6063 ;; It's a real article.
6064 (setq article (mail-header-id header)))
6066 ;; It is an extracted pseudo-article.
6067 (setq article 'pseudo)
6068 (gnus-request-pseudo-article header))))
6070 (let ((method (gnus-find-method-for-group
6071 gnus-newsgroup-name)))
6072 (when (and (eq (car method) 'nneething)
6074 (let ((dir (nneething-get-file-name
6075 (mail-header-id header))))
6076 (when (and (stringp dir)
6077 (file-directory-p dir))
6078 (setq article 'nneething)
6079 (gnus-group-enter-directory dir))))))))
6082 ;; Refuse to select canceled articles.
6083 ((and (numberp article)
6085 (get-buffer gnus-summary-buffer)
6086 (gnus-buffer-exists-p gnus-summary-buffer)
6087 (eq (cdr (with-current-buffer gnus-summary-buffer
6088 (assq article gnus-newsgroup-reads)))
6089 gnus-canceled-mark))
6091 ;; We first check `gnus-original-article-buffer'.
6092 ((and (get-buffer gnus-original-article-buffer)
6094 (with-current-buffer gnus-original-article-buffer
6095 (and (equal (car gnus-original-article) group)
6096 (eq (cdr gnus-original-article) article))))
6097 (insert-buffer-substring gnus-original-article-buffer)
6099 ;; Check the backlog.
6100 ((and gnus-keep-backlog
6101 (gnus-backlog-request-article group article (current-buffer)))
6103 ;; Check asynchronous pre-fetch.
6104 ((gnus-async-request-fetched-article group article (current-buffer))
6105 (gnus-async-prefetch-next group article gnus-summary-buffer)
6106 (when (and (numberp article) gnus-keep-backlog)
6107 (gnus-backlog-enter-article group article (current-buffer)))
6110 ((and gnus-use-cache
6112 (gnus-cache-request-article article group))
6114 ;; Check the agent cache.
6115 ((gnus-agent-request-article article group)
6117 ;; Get the article and put into the article buffer.
6118 ((or (stringp article)
6120 (let ((gnus-override-method gnus-override-method)
6121 (methods (and (stringp article)
6122 gnus-refer-article-method))
6123 (backend (car (gnus-find-method-for-group
6124 gnus-newsgroup-name)))
6126 (inhibit-read-only t))
6127 (if (or (not (listp methods))
6128 (and (symbolp (car methods))
6129 (assq (car methods) nnoo-definition-alist)))
6130 (setq methods (list methods)))
6131 (when (and (null gnus-override-method)
6133 (setq gnus-override-method (pop methods)))
6135 (when (eq gnus-override-method 'current)
6136 (setq gnus-override-method
6137 (with-current-buffer gnus-summary-buffer
6138 gnus-current-select-method)))
6140 (gnus-kill-all-overlays)
6141 (let ((gnus-newsgroup-name group))
6142 (gnus-check-group-server))
6144 ((gnus-request-article article group (current-buffer))
6145 (when (numberp article)
6146 (gnus-async-prefetch-next group article
6147 gnus-summary-buffer)
6148 (when gnus-keep-backlog
6149 (gnus-backlog-enter-article
6150 group article (current-buffer))))
6151 (setq result 'article))
6153 (setq gnus-override-method (pop methods)))
6154 ((not (string-match "^400 "
6155 (nnheader-get-report backend)))
6156 ;; If we get 400 server disconnect, reconnect and
6157 ;; retry; otherwise, assume the article has expired.
6158 (setq result 'done))))
6159 (and (eq result 'article) 'article)))
6163 ;; Associate this article with the current summary buffer.
6164 (setq gnus-article-current-summary gnus-summary-buffer)
6166 ;; Take the article from the original article buffer
6167 ;; and place it in the buffer it's supposed to be in.
6168 (when (and (get-buffer gnus-article-buffer)
6169 (equal (buffer-name (current-buffer))
6170 (buffer-name (get-buffer gnus-article-buffer))))
6172 (if (get-buffer gnus-original-article-buffer)
6173 (set-buffer gnus-original-article-buffer)
6174 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
6175 (buffer-disable-undo)
6176 (setq major-mode 'gnus-original-article-mode)
6177 (setq buffer-read-only t))
6178 (let ((inhibit-read-only t))
6180 (insert-buffer-substring gnus-article-buffer))
6181 (setq gnus-original-article (cons group article)))
6184 (run-hooks 'gnus-article-decode-hook)
6185 ;; Mark article as decoded or not.
6186 (setq gnus-article-decoded-p gnus-article-decode-hook))
6188 ;; Update sparse articles.
6189 (when (and do-update-line
6190 (or (numberp article)
6192 (let ((buf (current-buffer)))
6193 (set-buffer gnus-summary-buffer)
6194 (gnus-summary-update-article do-update-line sparse-header)
6195 (gnus-summary-goto-subject do-update-line nil t)
6196 (set-window-point (gnus-get-buffer-window (current-buffer) t)
6198 (set-buffer buf))))))
6204 (defcustom gnus-article-edit-mode-hook nil
6205 "Hook run in article edit mode buffers."
6206 :group 'gnus-article-various
6209 (defvar gnus-article-edit-done-function nil)
6211 (defvar gnus-article-edit-mode-map nil)
6213 ;; Should we be using derived.el for this?
6214 (unless gnus-article-edit-mode-map
6215 (setq gnus-article-edit-mode-map (make-keymap))
6216 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
6218 (gnus-define-keys gnus-article-edit-mode-map
6219 "\C-c?" describe-mode
6220 "\C-c\C-c" gnus-article-edit-done
6221 "\C-c\C-k" gnus-article-edit-exit
6222 "\C-c\C-f\C-t" message-goto-to
6223 "\C-c\C-f\C-o" message-goto-from
6224 "\C-c\C-f\C-b" message-goto-bcc
6225 ;;"\C-c\C-f\C-w" message-goto-fcc
6226 "\C-c\C-f\C-c" message-goto-cc
6227 "\C-c\C-f\C-s" message-goto-subject
6228 "\C-c\C-f\C-r" message-goto-reply-to
6229 "\C-c\C-f\C-n" message-goto-newsgroups
6230 "\C-c\C-f\C-d" message-goto-distribution
6231 "\C-c\C-f\C-f" message-goto-followup-to
6232 "\C-c\C-f\C-m" message-goto-mail-followup-to
6233 "\C-c\C-f\C-k" message-goto-keywords
6234 "\C-c\C-f\C-u" message-goto-summary
6235 "\C-c\C-f\C-i" message-insert-or-toggle-importance
6236 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
6237 "\C-c\C-b" message-goto-body
6238 "\C-c\C-i" message-goto-signature
6240 "\C-c\C-t" message-insert-to
6241 "\C-c\C-n" message-insert-newsgroups
6242 "\C-c\C-o" message-sort-headers
6243 "\C-c\C-e" message-elide-region
6244 "\C-c\C-v" message-delete-not-region
6245 "\C-c\C-z" message-kill-to-signature
6246 "\M-\r" message-newline-and-reformat
6247 "\C-c\C-a" mml-attach-file
6248 "\C-a" message-beginning-of-line
6250 "\M-;" comment-region)
6252 (gnus-define-keys (gnus-article-edit-wash-map
6253 "\C-c\C-w" gnus-article-edit-mode-map)
6254 "f" gnus-article-edit-full-stops))
6257 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
6259 ["Fetch To" message-insert-to t]
6260 ["Fetch Newsgroups" message-insert-newsgroups t]
6262 ["To" message-goto-to t]
6263 ["From" message-goto-from t]
6264 ["Subject" message-goto-subject t]
6265 ["Cc" message-goto-cc t]
6266 ["Reply-To" message-goto-reply-to t]
6267 ["Summary" message-goto-summary t]
6268 ["Keywords" message-goto-keywords t]
6269 ["Newsgroups" message-goto-newsgroups t]
6270 ["Followup-To" message-goto-followup-to t]
6271 ["Mail-Followup-To" message-goto-mail-followup-to t]
6272 ["Distribution" message-goto-distribution t]
6273 ["Body" message-goto-body t]
6274 ["Signature" message-goto-signature t]))
6276 (define-derived-mode gnus-article-edit-mode message-mode "Article Edit"
6277 "Major mode for editing articles.
6278 This is an extended text-mode.
6280 \\{gnus-article-edit-mode-map}"
6281 (make-local-variable 'gnus-article-edit-done-function)
6282 (make-local-variable 'gnus-prev-winconf)
6283 (set (make-local-variable 'font-lock-defaults)
6284 '(message-font-lock-keywords t))
6285 (set (make-local-variable 'mail-header-separator) "")
6286 (set (make-local-variable 'gnus-article-edit-mode) t)
6287 (easy-menu-add message-mode-field-menu message-mode-map)
6289 (setq buffer-read-only nil)
6290 (buffer-enable-undo)
6293 (defun gnus-article-edit (&optional force)
6294 "Edit the current article.
6295 This will have permanent effect only in mail groups.
6296 If FORCE is non-nil, allow editing of articles even in read-only
6299 (when (and (not force)
6300 (gnus-group-read-only-p))
6301 (error "The current newsgroup does not support article editing"))
6302 (gnus-article-date-original)
6303 (gnus-article-edit-article
6305 `(lambda (no-highlight)
6307 (gnus-summary-edit-article-done
6308 ,(or (mail-header-references gnus-current-headers) "")
6309 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
6311 (defun gnus-article-edit-article (start-func exit-func &optional quiet)
6312 "Start editing the contents of the current article buffer."
6313 (let ((winconf (current-window-configuration)))
6314 (set-buffer gnus-article-buffer)
6315 (let ((message-auto-save-directory
6316 ;; Don't associate the article buffer with a draft file.
6318 (gnus-article-edit-mode))
6319 (funcall start-func)
6320 (set-buffer-modified-p nil)
6321 (gnus-configure-windows 'edit-article)
6322 (setq gnus-article-edit-done-function exit-func)
6323 (setq gnus-prev-winconf winconf)
6325 (gnus-message 6 "C-c C-c to end edits"))))
6327 (defun gnus-article-edit-done (&optional arg)
6328 "Update the article edits and exit."
6330 (let ((func gnus-article-edit-done-function)
6331 (buf (current-buffer))
6332 (start (window-start))
6334 (winconf gnus-prev-winconf))
6335 (widen) ;; Widen it in case that users narrowed the buffer.
6338 ;; The cache and backlog have to be flushed somewhat.
6339 (when gnus-keep-backlog
6340 (gnus-backlog-remove-article
6341 (car gnus-article-current) (cdr gnus-article-current)))
6342 ;; Flush original article as well.
6344 (when (get-buffer gnus-original-article-buffer)
6345 (set-buffer gnus-original-article-buffer)
6346 (setq gnus-original-article nil)))
6347 (when gnus-use-cache
6348 (gnus-cache-update-article
6349 (car gnus-article-current) (cdr gnus-article-current)))
6350 ;; We remove all text props from the article buffer.
6351 (kill-all-local-variables)
6352 (set-text-properties (point-min) (point-max) nil)
6354 (set-window-configuration winconf)
6356 (set-window-start (get-buffer-window buf) start)
6357 (set-window-point (get-buffer-window buf) (point)))
6358 (gnus-summary-show-article))
6360 (defun gnus-article-edit-exit ()
6361 "Exit the article editing without updating."
6363 (when (or (not (buffer-modified-p))
6364 (yes-or-no-p "Article modified; kill anyway? "))
6365 (let ((curbuf (current-buffer))
6367 (window-start (window-start)))
6369 (if (gnus-buffer-live-p gnus-original-article-buffer)
6370 (insert-buffer-substring gnus-original-article-buffer))
6371 (let ((winconf gnus-prev-winconf))
6372 (kill-all-local-variables)
6374 (set-window-configuration winconf)
6375 ;; Tippy-toe some to make sure that point remains where it was.
6376 (save-current-buffer
6378 (set-window-start (get-buffer-window (current-buffer)) window-start)
6380 (gnus-summary-show-article)))
6382 (defun gnus-article-edit-full-stops ()
6383 "Interactively repair spacing at end of sentences."
6386 (goto-char (point-min))
6387 (search-forward-regexp "^$" nil t)
6388 (let ((case-fold-search nil))
6389 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
6392 ;;; Article highlights
6395 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6397 ;;; Internal Variables:
6399 (defcustom gnus-button-url-regexp
6400 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
6401 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-z0-9_.]+:[0-9]*\\)?[-a-z0-9_=!?#$@~%&*+\\/:;.,[:word:]]+[-a-z0-9_=#$@~%&*+\\/[:word:]]\\)"
6402 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|nntp\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-z0-9_.]+:[0-9]*\\)?\\([-a-z0-9_=!?#$@~%&*+\\/:;.,]\\|\\w\\)+\\([-a-z0-9_=#$@~%&*+\\/]\\|\\w\\)\\)")
6403 "Regular expression that matches URLs."
6404 :group 'gnus-article-buttons
6407 (defcustom gnus-button-valid-fqdn-regexp
6408 message-valid-fqdn-regexp
6409 "Regular expression that matches a valid FQDN."
6411 :group 'gnus-article-buttons
6414 ;; Regexp suggested by Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
6415 (defcustom gnus-button-valid-localpart-regexp
6416 "[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t @]*"
6417 "Regular expression that matches a localpart of mail addresses or MIDs."
6419 :group 'gnus-article-buttons
6422 (defcustom gnus-button-man-handler 'manual-entry
6423 "Function to use for displaying man pages.
6424 The function must take at least one argument with a string naming the
6427 :type '(choice (function-item :tag "Man" manual-entry)
6428 (function-item :tag "Woman" woman)
6429 (function :tag "Other"))
6430 :group 'gnus-article-buttons)
6432 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6433 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6434 If the default site is too slow, try to find a CTAN mirror, see
6435 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6436 the variable `gnus-button-handle-ctan'."
6438 :group 'gnus-article-buttons
6439 :link '(custom-manual "(gnus)Group Parameters")
6440 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6441 (const "http://tug.ctan.org/tex-archive/")
6442 (const "http://www.dante.de/CTAN/")
6443 (string :tag "Other")))
6445 (defcustom gnus-button-ctan-handler 'browse-url
6446 "Function to use for displaying CTAN links.
6447 The function must take one argument, the string naming the URL."
6449 :type '(choice (function-item :tag "Browse Url" browse-url)
6450 (function :tag "Other"))
6451 :group 'gnus-article-buttons)
6453 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6454 "Bogus strings removed from CTAN URLs."
6456 :group 'gnus-article-buttons
6457 :type '(choice (const "^/?tex-archive/\\|/")
6458 (regexp :tag "Other")))
6460 (defcustom gnus-button-ctan-directory-regexp
6462 (list "archive-tools" "biblio" "bibliography" "digests" "documentation"
6463 "dviware" "fonts" "graphics" "help" "indexing" "info" "language"
6464 "languages" "macros" "nonfree" "obsolete" "support" "systems"
6465 "tds" "tools" "usergrps" "web") t)
6466 "Regular expression for ctan directories.
6467 It should match all directories in the top level of `gnus-ctan-url'."
6469 :group 'gnus-article-buttons
6472 (defcustom gnus-button-mid-or-mail-regexp
6473 (concat "\\b\\(<?" gnus-button-valid-localpart-regexp "@"
6474 gnus-button-valid-fqdn-regexp
6476 "Regular expression that matches a message ID or a mail address."
6478 :group 'gnus-article-buttons
6481 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6482 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6483 Strings like this can be either a message ID or a mail address. If it is one
6484 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6485 message ID or a mail address, respectively. If this variable is set to the
6486 symbol `ask', always query the user what do do. If it is a function, this
6487 function will be called with the string as it's only argument. The function
6488 must return `mid', `mail', `invalid' or `ask'."
6490 :group 'gnus-article-buttons
6491 :type '(choice (function-item :tag "Heuristic function"
6492 gnus-button-mid-or-mail-heuristic)
6497 (defcustom gnus-button-mid-or-mail-heuristic-alist
6498 '((-10.0 . ".+\\$.+@")
6501 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6502 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6503 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6504 (-1.0 . "^[^a-z]+@")
6506 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6507 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6508 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6509 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6512 (-1.0 . "^[0-9][0-9]")
6514 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6515 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6516 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6517 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6519 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6520 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6523 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6525 ;; compensation for TDMA dated mail addresses:
6526 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6528 (-20.0 . "\\.fsf@") ;; Gnus
6531 (-20.0 . "_-_") ;; Subject change in thread
6533 (-20.0 . "\\.ln@") ;; leafnode
6534 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6535 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6537 ;; (5.0 . "") ;; $local_part_len <= 7
6538 (10.0 . "^[^0-9]+@")
6539 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6540 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6543 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6545 (0.5 . "^[A-Z][a-z]")
6546 (0.5 . "^[A-Z][a-z][a-z]")
6547 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6548 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6549 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6551 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6552 address. The REGEXP is processed with `case-fold-search' set to nil."
6554 :group 'gnus-article-buttons
6555 :type '(repeat (cons (number :tag "Rate")
6556 (regexp :tag "Regexp"))))
6558 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6559 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6560 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6561 address, `ask' if unsure and `invalid' if the string is invalid."
6562 (let ((case-fold-search nil)
6563 (list gnus-button-mid-or-mail-heuristic-alist)
6564 (result 0) rate regexp lpartlen elem)
6566 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6567 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6568 ;; Certain special cases...
6571 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6572 "^[0-9]+\\.[0-9]+@compuserve\\|"
6573 "@public\\.gmane\\.org")
6575 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6576 (setq result 'mail))
6577 (when (string-match "@.*@\\| " mid-or-mail)
6578 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6579 (setq result 'invalid))
6580 ;; Nothing more to do, if result is not a number here...
6581 (when (numberp result)
6583 (setq elem (car list)
6587 (when (string-match regexp mid-or-mail)
6588 (setq result (+ result rate))
6590 9 "`%s' matched `%s', rate `%s', result `%s'."
6591 mid-or-mail regexp rate result)))
6592 (when (<= lpartlen 7)
6593 (setq result (+ result 5.0))
6594 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6595 mid-or-mail result))
6596 (when (>= lpartlen 12)
6597 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6599 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6600 ;; Long local part should contain realname if e-mail address,
6601 ;; too many digits: message-id.
6602 ;; $score -= 5.0 + 0.1 * $local_part_len;
6603 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6604 (setq result (+ result rate))
6606 9 "Many digits in `%s', rate `%s', result `%s'."
6607 mid-or-mail rate result))
6608 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6610 ;; Too few vowels [^aeiouy]{4,}.*\@
6611 (setq result (+ result -5.0))
6613 9 "Few vowels in `%s', rate `%s', result `%s'."
6614 mid-or-mail -5.0 result))
6616 (setq result (+ result 5.0))
6618 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6619 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6620 ;; Maybe we should make this a customizable alist: (condition . 'result)
6622 ((symbolp result) result)
6623 ;; Now convert number into proper results:
6624 ((< result -10.0) 'mid)
6625 ((> result 10.0) 'mail)
6628 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6629 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6630 (url-mid (concat "news" ":" mid-or-mail))
6631 (url-mailto (concat "mailto" ":" mid-or-mail)))
6632 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6633 (when (fboundp pref)
6635 ;; get rid of surrounding angles...
6637 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6638 (if (or (eq 'mid guessed) (eq 'mail guessed))
6642 (save-window-excursion
6643 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6646 (cond ((eq pref 'mid)
6647 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6648 (gnus-button-handle-news url-mid))
6650 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6651 (gnus-url-mailto url-mailto))
6652 (t (gnus-message 3 "Invalid string.")))))
6654 (defun gnus-button-handle-custom (fun arg)
6655 "Call function FUN on argument ARG.
6656 Both FUN and ARG are supposed to be strings. ARG will be passed
6657 as a symbol to FUN."
6658 (funcall (intern fun) (intern arg)))
6660 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6662 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6665 (defun gnus-button-handle-describe-function (url)
6666 "Call `describe-function' when pushing the corresponding URL button."
6669 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6671 (defun gnus-button-handle-describe-variable (url)
6672 "Call `describe-variable' when pushing the corresponding URL button."
6675 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6677 (defun gnus-button-handle-symbol (url)
6678 "Display help on variable or function.
6679 Calls `describe-variable' or `describe-function'."
6680 (let ((sym (intern url)))
6682 ((fboundp sym) (describe-function sym))
6683 ((boundp sym) (describe-variable sym))
6684 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6686 (defun gnus-button-handle-describe-key (url)
6687 "Call `describe-key' when pushing the corresponding URL button."
6689 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6690 (keys (ignore-errors (eval `(kbd ,key-string)))))
6693 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6695 (defun gnus-button-handle-apropos (url)
6696 "Call `apropos' when pushing the corresponding URL button."
6697 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6699 (defun gnus-button-handle-apropos-command (url)
6700 "Call `apropos' when pushing the corresponding URL button."
6702 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6704 (defun gnus-button-handle-apropos-variable (url)
6705 "Call `apropos' when pushing the corresponding URL button."
6707 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6708 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6710 (defun gnus-button-handle-apropos-documentation (url)
6711 "Call `apropos' when pushing the corresponding URL button."
6713 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6714 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6716 (defun gnus-button-handle-library (url)
6717 "Call `locate-library' when pushing the corresponding URL button."
6718 (gnus-message 9 "url=`%s'" url)
6719 (let* ((lib (locate-library url))
6720 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6722 (gnus-message 1 "Cannot locale library `%s'." url)
6723 (find-file-read-only file))))
6725 (defun gnus-button-handle-ctan (url)
6726 "Call `browse-url' when pushing a CTAN URL button."
6728 gnus-button-ctan-handler
6731 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6733 (defcustom gnus-button-tex-level 5
6734 "*Integer that says how many TeX-related buttons Gnus will show.
6735 The higher the number, the more buttons will appear and the more false
6736 positives are possible. Note that you can set this variable local to
6737 specific groups. Setting it higher in TeX groups is probably a good idea.
6738 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6739 how to set variables in specific groups."
6741 :group 'gnus-article-buttons
6742 :link '(custom-manual "(gnus)Group Parameters")
6745 (defcustom gnus-button-man-level 5
6746 "*Integer that says how many man-related buttons Gnus will show.
6747 The higher the number, the more buttons will appear and the more false
6748 positives are possible. Note that you can set this variable local to
6749 specific groups. Setting it higher in Unix groups is probably a good idea.
6750 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6751 how to set variables in specific groups."
6753 :group 'gnus-article-buttons
6754 :link '(custom-manual "(gnus)Group Parameters")
6757 (defcustom gnus-button-emacs-level 5
6758 "*Integer that says how many emacs-related buttons Gnus will show.
6759 The higher the number, the more buttons will appear and the more false
6760 positives are possible. Note that you can set this variable local to
6761 specific groups. Setting it higher in Emacs or Gnus related groups is
6762 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6763 `gnus-parameters' on how to set variables in specific groups."
6765 :group 'gnus-article-buttons
6766 :link '(custom-manual "(gnus)Group Parameters")
6769 (defcustom gnus-button-message-level 5
6770 "*Integer that says how many buttons for news or mail messages will appear.
6771 The higher the number, the more buttons will appear and the more false
6772 positives are possible."
6773 ;; mail addresses, MIDs, URLs for news, ...
6775 :group 'gnus-article-buttons
6778 (defcustom gnus-button-browse-level 5
6779 "*Integer that says how many buttons for browsing will appear.
6780 The higher the number, the more buttons will appear and the more false
6781 positives are possible."
6782 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6784 :group 'gnus-article-buttons
6787 (defcustom gnus-button-alist
6788 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6789 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6790 ((concat "\\b\\(nntp\\|news\\):\\("
6791 gnus-button-valid-localpart-regexp "@[a-z0-9.-]+[a-z]\\)")
6792 0 t gnus-button-handle-news 2)
6793 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6794 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6795 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6796 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6797 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6798 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6799 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6800 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6801 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6802 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6803 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6804 ;; RFC 2368 (The mailto URL scheme)
6805 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6806 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6807 ("\\bmailto:\\([^ \n\t]+\\)"
6808 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6810 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6811 gnus-button-ctan-directory-regexp
6812 "[^][>)!;:,'\n\t ]+\\)")
6813 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6814 ((concat "\\btex-archive/\\("
6815 gnus-button-ctan-directory-regexp
6816 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6817 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6820 gnus-button-ctan-directory-regexp
6821 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6822 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6823 ;; This is info (home-grown style) <info://foo/bar+baz>
6824 ("\\binfo://\\([^'\">\n\t ]+\\)"
6825 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6826 ;; Info GNOME style <info:foo#bar_baz>
6827 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6828 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6829 ;; Info KDE style <info:(foo)bar baz>
6830 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6831 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6832 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6833 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6834 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6835 ;; Info links like `C-h i d m CC Mode RET'
6836 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6838 ("M-x[ \t\n]\\(customize-[^ ]+\\)[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6839 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1 2)
6840 ;; Emacs help commands
6841 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6842 ;; regexp doesn't match arguments containing ` '.
6843 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6844 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6845 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6846 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6847 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6848 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6849 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6850 ;; The following entries may lead to many false positives so don't enable
6851 ;; them by default (use a high button level).
6852 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>[^.?]"
6853 ;; Exclude [.?] for URLs in gmane.emacs.cvs
6854 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6855 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6856 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6857 ("`\\([a-z][a-z0-9]+-[a-z0-9]+-[-a-z0-9]*[a-z]\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6858 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6859 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6860 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6861 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6862 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6863 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6864 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6865 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6866 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6867 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6868 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6869 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6870 ;; Unlike the other regexps we really have to require quoting
6871 ;; here to determine where it ends.
6872 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6873 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6874 ("<URL: *\\([^<>]*\\)>"
6875 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6876 ;; RFC 2396 (2.4.3., delims) ...
6877 ("\"URL: *\\([^\"]*\\)\""
6878 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6879 ;; RFC 2396 (2.4.3., delims) ...
6880 ("\"URL: *\\([^\"]*\\)\""
6881 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6883 (gnus-button-url-regexp
6884 0 (>= gnus-button-browse-level 0) browse-url 0)
6886 ("\\b\\([a-z][a-z]+([1-9])\\)\\W"
6887 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6888 gnus-button-handle-man 1)
6889 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6890 ("\\b\\([a-z][-_.a-z0-9]+([1-9])\\)\\W"
6891 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6892 gnus-button-handle-man 1)
6893 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6894 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6895 ("\\b\\(\\(?:[a-z][-+_.:a-z0-9]+([1-9][X1a-z]*)\\)\\|\\b\\(?:X([1-9])\\)\\)\\W"
6896 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6897 ;; Recognizing patches to .el files. This is somewhat obscure,
6898 ;; but considering the percentage of Gnus users who hack Emacs
6900 ("^--- \\([^ .]+\\.el\\).*\n.*\n@@ -?\\([0-9]+\\)" 1
6901 (>= gnus-button-message-level 4) gnus-button-patch 1 2)
6902 ("^\\*\\*\\* \\([^ .]+\\.el\\).*\n.*\n\\*+\n\\*\\*\\* \\([0-9]+\\)" 1
6903 (>= gnus-button-message-level 4) gnus-button-patch 1 2)
6904 ;; MID or mail: To avoid too many false positives we don't try to catch
6905 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6906 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6907 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6908 ;; so that non-ambiguous entries (see above) match first.
6909 (gnus-button-mid-or-mail-regexp
6910 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6911 "*Alist of regexps matching buttons in article bodies.
6913 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6914 REGEXP: is the string (case insensitive) matching text around the button (can
6915 also be Lisp expression evaluating to a string),
6916 BUTTON: is the number of the regexp grouping actually matching the button,
6917 FORM: is a Lisp expression which must eval to true for the button to
6919 CALLBACK: is the function to call when the user push this button, and each
6920 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6922 CALLBACK can also be a variable, in that case the value of that
6923 variable it the real callback function."
6924 :group 'gnus-article-buttons
6925 :type '(repeat (list (choice regexp variable sexp)
6926 (integer :tag "Button")
6928 (function :tag "Callback")
6931 (integer :tag "Regexp group")))))
6933 (defcustom gnus-header-button-alist
6934 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6935 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6936 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6937 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6938 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6939 0 (>= gnus-button-message-level 0) gnus-msg-mail 0)
6940 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6941 0 (>= gnus-button-browse-level 0) browse-url 0)
6942 ("^Subject:" gnus-button-url-regexp
6943 0 (>= gnus-button-browse-level 0) browse-url 0)
6944 ("^[^:]+:" gnus-button-url-regexp
6945 0 (>= gnus-button-browse-level 0) browse-url 0)
6946 ("^OpenPGP:.*url=" gnus-button-url-regexp
6947 0 (>= gnus-button-browse-level 0) gnus-button-openpgp 0)
6948 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6949 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6950 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6951 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6952 "*Alist of headers and regexps to match buttons in article heads.
6954 This alist is very similar to `gnus-button-alist', except that each
6955 alist has an additional HEADER element first in each entry:
6957 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6959 HEADER is a regexp to match a header. For a fuller explanation, see
6960 `gnus-button-alist'."
6961 :group 'gnus-article-buttons
6962 :group 'gnus-article-headers
6963 :type '(repeat (list (regexp :tag "Header")
6964 (choice regexp variable)
6965 (integer :tag "Button")
6967 (function :tag "Callback")
6970 (integer :tag "Regexp group")))))
6974 (defun gnus-article-push-button (event)
6975 "Check text under the mouse pointer for a callback function.
6976 If the text under the mouse pointer has a `gnus-callback' property,
6977 call it with the value of the `gnus-data' text property."
6979 (set-buffer (window-buffer (posn-window (event-start event))))
6980 (let* ((pos (posn-point (event-start event)))
6981 (data (get-text-property pos 'gnus-data))
6982 (fun (get-text-property pos 'gnus-callback)))
6985 (funcall fun data))))
6987 (defun gnus-article-press-button ()
6988 "Check text at point for a callback function.
6989 If the text at point has a `gnus-callback' property,
6990 call it with the value of the `gnus-data' text property."
6992 (let ((data (get-text-property (point) 'gnus-data))
6993 (fun (get-text-property (point) 'gnus-callback)))
6995 (funcall fun data))))
6997 (defun gnus-article-highlight (&optional force)
6998 "Highlight current article.
6999 This function calls `gnus-article-highlight-headers',
7000 `gnus-article-highlight-citation',
7001 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7002 do the highlighting. See the documentation for those functions."
7003 (interactive (list 'force))
7004 (gnus-article-highlight-headers)
7005 (gnus-article-highlight-citation force)
7006 (gnus-article-highlight-signature)
7007 (gnus-article-add-buttons force)
7008 (gnus-article-add-buttons-to-head))
7010 (defun gnus-article-highlight-some (&optional force)
7011 "Highlight current article.
7012 This function calls `gnus-article-highlight-headers',
7013 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
7014 do the highlighting. See the documentation for those functions."
7015 (interactive (list 'force))
7016 (gnus-article-highlight-headers)
7017 (gnus-article-highlight-signature)
7018 (gnus-article-add-buttons))
7020 (defun gnus-article-highlight-headers ()
7021 "Highlight article headers as specified by `gnus-header-face-alist'."
7023 (gnus-with-article-headers
7024 (let (regexp header-face field-face from hpoints fpoints)
7025 (dolist (entry gnus-header-face-alist)
7026 (goto-char (point-min))
7027 (setq regexp (concat "^\\("
7028 (if (string-equal "" (nth 0 entry))
7032 header-face (nth 1 entry)
7033 field-face (nth 2 entry))
7034 (while (and (re-search-forward regexp nil t)
7038 (unless (search-forward ":" nil t)
7040 (when (and header-face
7041 (not (memq (point) hpoints)))
7042 (push (point) hpoints)
7043 (gnus-put-text-property from (point) 'face header-face))
7044 (when (and field-face
7045 (not (memq (setq from (point)) fpoints)))
7047 (if (re-search-forward "^[^ \t]" nil t)
7049 (goto-char (point-max)))
7050 (gnus-put-text-property from (point) 'face field-face)))))))
7052 (defun gnus-article-highlight-signature ()
7053 "Highlight the signature in an article.
7054 It does this by highlighting everything after
7055 `gnus-signature-separator' using the face `gnus-signature'."
7057 (gnus-with-article-buffer
7058 (let ((inhibit-point-motion-hooks t))
7060 (when (and gnus-signature-face
7061 (gnus-article-narrow-to-signature))
7062 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
7063 'face gnus-signature-face)
7065 (gnus-article-search-signature)
7066 (let ((start (match-beginning 0))
7067 (end (set-marker (make-marker) (1+ (match-end 0)))))
7068 (gnus-article-add-button start (1- end) 'gnus-signature-toggle
7071 (defun gnus-button-in-region-p (b e prop)
7072 "Say whether PROP exists in the region."
7073 (text-property-not-all b e prop nil))
7075 (defun gnus-article-add-buttons (&optional force)
7076 "Find external references in the article and make buttons of them.
7077 \"External references\" are things like Message-IDs and URLs, as
7078 specified by `gnus-button-alist'."
7079 (interactive (list 'force))
7080 (gnus-with-article-buffer
7081 (let ((inhibit-point-motion-hooks t)
7082 (case-fold-search t)
7083 (alist gnus-button-alist)
7085 ;; Remove all old markers.
7086 (let (marker entry new-list)
7087 (while (setq marker (pop gnus-button-marker-list))
7088 (if (or (< marker (point-min)) (>= marker (point-max)))
7089 (push marker new-list)
7091 (when (setq entry (gnus-button-entry))
7092 (put-text-property (match-beginning (nth 1 entry))
7093 (match-end (nth 1 entry))
7094 'gnus-callback nil))
7095 (set-marker marker nil)))
7096 (setq gnus-button-marker-list new-list))
7097 ;; We skip the headers.
7100 (while (setq entry (pop alist))
7101 (setq regexp (eval (car entry)))
7103 (while (re-search-forward regexp nil t)
7104 (let* ((start (and entry (match-beginning (nth 1 entry))))
7105 (end (and entry (match-end (nth 1 entry))))
7106 (from (match-beginning 0)))
7107 (when (and (or (eq t (nth 2 entry))
7108 (eval (nth 2 entry)))
7109 (not (gnus-button-in-region-p
7110 start end 'gnus-callback)))
7111 ;; That optional form returned non-nil, so we add the
7113 (gnus-article-add-button
7114 start end 'gnus-button-push
7115 (car (push (set-marker (make-marker) from)
7116 gnus-button-marker-list))))))))))
7118 ;; Add buttons to the head of an article.
7119 (defun gnus-article-add-buttons-to-head ()
7120 "Add buttons to the head of the article."
7122 (gnus-with-article-headers
7124 (dolist (entry gnus-header-button-alist)
7125 ;; Each alist entry.
7126 (goto-char (point-min))
7127 (while (re-search-forward (car entry) nil t)
7128 ;; Each header matching the entry.
7129 (setq beg (match-beginning 0))
7130 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
7131 (match-beginning 0))
7134 (while (re-search-forward (eval (nth 1 entry)) end t)
7135 ;; Each match within a header.
7136 (let* ((entry (cdr entry))
7137 (start (match-beginning (nth 1 entry)))
7138 (end (match-end (nth 1 entry)))
7139 (form (nth 2 entry)))
7140 (goto-char (match-end 0))
7142 (gnus-article-add-button
7143 start end (nth 3 entry)
7144 (buffer-substring (match-beginning (nth 4 entry))
7145 (match-end (nth 4 entry)))))))
7146 (goto-char end))))))
7148 ;;; External functions:
7150 (defun gnus-article-add-button (from to fun &optional data)
7151 "Create a button between FROM and TO with callback FUN and data DATA."
7152 (when gnus-article-button-face
7153 (gnus-overlay-put (gnus-make-overlay from to)
7154 'face gnus-article-button-face))
7155 (gnus-add-text-properties
7157 (nconc (and gnus-article-mouse-face
7158 (list gnus-mouse-face-prop gnus-article-mouse-face))
7159 (list 'gnus-callback fun)
7160 (and data (list 'gnus-data data))))
7161 (widget-convert-button 'link from to :action 'gnus-widget-press-button
7162 :button-keymap gnus-widget-button-keymap))
7164 ;;; Internal functions:
7166 (defun gnus-article-set-globals ()
7167 (with-current-buffer gnus-summary-buffer
7168 (gnus-set-global-variables)))
7170 (defun gnus-signature-toggle (end)
7171 (gnus-with-article-buffer
7172 (let ((inhibit-point-motion-hooks t))
7173 (if (text-property-any end (point-max) 'article-type 'signature)
7175 (gnus-delete-wash-type 'signature)
7176 (gnus-remove-text-properties-when
7177 'article-type 'signature end (point-max)
7178 (cons 'article-type (cons 'signature
7179 gnus-hidden-properties))))
7180 (gnus-add-wash-type 'signature)
7181 (gnus-add-text-properties-when
7182 'article-type nil end (point-max)
7183 (cons 'article-type (cons 'signature
7184 gnus-hidden-properties)))))
7185 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
7186 (gnus-set-mode-line 'article))))
7188 (defun gnus-button-entry ()
7189 ;; Return the first entry in `gnus-button-alist' matching this place.
7190 (let ((alist gnus-button-alist)
7193 (setq entry (pop alist))
7194 (if (looking-at (eval (car entry)))
7199 (defun gnus-button-push (marker)
7200 ;; Push button starting at MARKER.
7203 (let* ((entry (gnus-button-entry))
7204 (inhibit-point-motion-hooks t)
7206 (args (mapcar (lambda (group)
7207 (let ((string (match-string group)))
7208 (set-text-properties
7209 0 (length string) nil string)
7216 (fboundp (symbol-value fun)))
7217 (apply (symbol-value fun) args))
7219 (gnus-message 1 "You must define `%S' to use this button"
7220 (cons fun args)))))))
7222 (defun gnus-parse-news-url (url)
7223 (let (scheme server port group message-id articles)
7226 (goto-char (point-min))
7227 (when (looking-at "\\([A-Za-z]+\\):")
7228 (setq scheme (match-string 1))
7229 (goto-char (match-end 0)))
7230 (when (looking-at "//\\([^:/]+\\)\\(:?\\)\\([0-9]+\\)?/")
7231 (setq server (match-string 1))
7232 (setq port (if (stringp (match-string 3))
7233 (string-to-number (match-string 3))
7235 (goto-char (match-end 0)))
7238 ((looking-at "\\(.*@.*\\)")
7239 (setq message-id (match-string 1)))
7240 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7241 (setq group (match-string 1)
7242 articles (split-string (match-string 2) "-")))
7243 ((looking-at "\\([^/]+\\)/?")
7244 (setq group (match-string 1)))
7246 (error "Unknown news URL syntax"))))
7247 (list scheme server port group message-id articles)))
7249 (defun gnus-button-handle-news (url)
7251 (destructuring-bind (scheme server port group message-id articles)
7252 (gnus-parse-news-url url)
7256 (set-buffer gnus-summary-buffer)
7258 (let ((gnus-refer-article-method
7259 (nconc (list (list 'nntp server))
7260 gnus-refer-article-method))
7261 (nntp-port-number (or port "nntp")))
7262 (gnus-message 7 "Fetching %s with %s"
7263 message-id gnus-refer-article-method)
7264 (gnus-summary-refer-article message-id))
7265 (gnus-summary-refer-article message-id))))
7267 (gnus-button-fetch-group url)))))
7269 (defun gnus-button-patch (library line)
7270 "Visit an Emacs Lisp library LIBRARY on line LINE."
7272 (let ((file (locate-library (file-name-nondirectory library))))
7274 (error "Couldn't find library %s" library))
7276 (goto-line (string-to-number line))))
7278 (defun gnus-button-handle-man (url)
7280 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7281 (when (eq gnus-button-man-handler 'woman)
7282 (setq url (gnus-replace-in-string url "([1-9][X1a-z]*).*\\'" "")))
7283 (gnus-message 9 "`%s' `%s'" gnus-button-man-handler url)
7284 (funcall gnus-button-man-handler url))
7286 (defun gnus-button-handle-info-url (url)
7287 "Fetch an info URL."
7288 (setq url (mm-subst-char-in-string ?+ ?\ url))
7290 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
7291 (gnus-info-find-node
7292 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
7294 ")" (gnus-url-unhex-string (match-string 2 url)))))
7295 ((string-match "([^)\"]+)[^\"]+" url)
7297 (gnus-replace-in-string
7298 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
7299 (gnus-info-find-node url))
7300 (t (error "Can't parse %s" url))))
7302 (defun gnus-button-handle-info-url-gnome (url)
7303 "Fetch GNOME style info URL."
7304 (setq url (mm-subst-char-in-string ?_ ?\ url))
7305 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
7306 (gnus-info-find-node
7308 (gnus-url-unhex-string
7309 (match-string 1 url))
7311 (or (gnus-url-unhex-string
7312 (match-string 2 url))
7314 (error "Can't parse %s" url)))
7316 (defun gnus-button-handle-info-url-kde (url)
7317 "Fetch KDE style info URL."
7318 (gnus-info-find-node (gnus-url-unhex-string url)))
7320 (defun gnus-button-handle-info-keystrokes (url)
7321 "Call `info' when pushing the corresponding URL button."
7322 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
7327 (defun gnus-button-openpgp (url)
7328 "Retrieve and add an OpenPGP key given URL from an OpenPGP header."
7330 (mm-url-insert-file-contents-external url)
7331 (pgg-snarf-keys-region (point-min) (point-max))
7332 (pgg-display-output-buffer nil nil nil)))
7334 (defun gnus-button-message-id (message-id)
7336 (with-current-buffer gnus-summary-buffer
7337 (gnus-summary-refer-article message-id)))
7339 (defun gnus-button-fetch-group (address)
7340 "Fetch GROUP specified by ADDRESS."
7341 (if (not (string-match "[:/]" address))
7342 ;; This is just a simple group url.
7343 (gnus-group-read-ephemeral-group address gnus-select-method)
7346 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
7348 (error "Can't parse %s" address)
7349 (gnus-group-read-ephemeral-group
7350 (match-string 4 address)
7351 `(nntp ,(match-string 1 address)
7352 (nntp-address ,(match-string 1 address))
7353 (nntp-port-number ,(if (match-end 3)
7354 (match-string 3 address)
7357 (and (match-end 6) (list (string-to-number (match-string 6 address))))))))
7359 (defun gnus-url-parse-query-string (query &optional downcase)
7360 (let (retval pairs cur key val)
7361 (setq pairs (split-string query "&"))
7363 (setq cur (car pairs)
7365 (if (not (string-match "=" cur))
7367 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
7368 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
7370 (setq key (downcase key)))
7371 (setq cur (assoc key retval))
7373 (setcdr cur (cons val (cdr cur)))
7374 (setq retval (cons (list key val) retval)))))
7377 (defun gnus-url-mailto (url)
7378 ;; Send mail to someone
7379 (when (string-match "mailto:/*\\(.*\\)" url)
7380 (setq url (substring url (match-beginning 1) nil)))
7381 (let (to args subject func)
7382 (setq args (gnus-url-parse-query-string
7383 (if (string-match "^\\?" url)
7385 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
7386 (concat "to=" (match-string 1 url) "&"
7387 (match-string 2 url))
7388 (concat "to=" url)))
7390 subject (cdr-safe (assoc "subject" args)))
7393 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
7396 (message-position-on-field (caar args)))
7397 (insert (gnus-replace-in-string
7398 (mapconcat 'identity (reverse (cdar args)) ", ")
7400 (setq args (cdr args)))
7403 (message-goto-subject))))
7405 (defun gnus-button-embedded-url (address)
7406 "Activate ADDRESS with `browse-url'."
7407 (browse-url (gnus-strip-whitespace address)))
7409 ;;; Next/prev buttons in the article buffer.
7411 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
7412 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
7414 (defvar gnus-prev-page-map
7415 (let ((map (make-sparse-keymap)))
7416 (define-key map gnus-mouse-2 'gnus-button-prev-page)
7417 (define-key map "\r" 'gnus-button-prev-page)
7420 (defvar gnus-next-page-map
7421 (let ((map (make-sparse-keymap)))
7422 (unless (>= emacs-major-version 21)
7423 ;; XEmacs doesn't care.
7424 (set-keymap-parent map gnus-article-mode-map))
7425 (define-key map gnus-mouse-2 'gnus-button-next-page)
7426 (define-key map "\r" 'gnus-button-next-page)
7429 (defun gnus-insert-prev-page-button ()
7431 (inhibit-read-only t))
7433 gnus-prev-page-line-format nil
7434 `(keymap ,gnus-prev-page-map
7436 gnus-callback gnus-article-button-prev-page
7437 article-type annotation))
7438 (widget-convert-button
7440 ;; Exclude a newline.
7443 :action 'gnus-button-prev-page
7444 :button-keymap gnus-prev-page-map)))
7446 (defun gnus-button-next-page (&optional args more-args)
7447 "Go to the next page."
7449 (let ((win (selected-window)))
7450 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7451 (gnus-article-next-page)
7452 (select-window win)))
7454 (defun gnus-button-prev-page (&optional args more-args)
7455 "Go to the prev page."
7457 (let ((win (selected-window)))
7458 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7459 (gnus-article-prev-page)
7460 (select-window win)))
7462 (defun gnus-insert-next-page-button ()
7464 (inhibit-read-only t))
7465 (gnus-eval-format gnus-next-page-line-format nil
7466 `(keymap ,gnus-next-page-map
7468 gnus-callback gnus-article-button-next-page
7469 article-type annotation))
7470 (widget-convert-button
7472 ;; Exclude a newline.
7475 :action 'gnus-button-next-page
7476 :button-keymap gnus-next-page-map)))
7478 (defun gnus-article-button-next-page (arg)
7479 "Go to the next page."
7481 (let ((win (selected-window)))
7482 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7483 (gnus-article-next-page)
7484 (select-window win)))
7486 (defun gnus-article-button-prev-page (arg)
7487 "Go to the prev page."
7489 (let ((win (selected-window)))
7490 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7491 (gnus-article-prev-page)
7492 (select-window win)))
7494 (defvar gnus-decode-header-methods
7495 '(mail-decode-encoded-word-region)
7496 "List of methods used to decode headers.
7498 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7499 is FUNCTION, FUNCTION will be applied to all newsgroups. If item is a
7500 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
7501 whose names match REGEXP.
7504 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7505 mail-decode-encoded-word-region
7506 (\"chinese\" . rfc1843-decode-region))
7509 (defvar gnus-decode-header-methods-cache nil)
7511 (defun gnus-multi-decode-header (start end)
7512 "Apply the functions from `gnus-encoded-word-methods' that match."
7513 (unless (and gnus-decode-header-methods-cache
7514 (eq gnus-newsgroup-name
7515 (car gnus-decode-header-methods-cache)))
7516 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7519 (nconc gnus-decode-header-methods-cache (list x))
7520 (if (and gnus-newsgroup-name
7521 (string-match (car x) gnus-newsgroup-name))
7522 (nconc gnus-decode-header-methods-cache
7524 gnus-decode-header-methods))
7525 (let ((xlist gnus-decode-header-methods-cache))
7528 (narrow-to-region start end)
7530 (funcall (pop xlist) (point-min) (point-max))))))
7533 ;;; Treatment top-level handling.
7536 (defun gnus-treat-article (condition &optional part-number total-parts type)
7537 (let ((length (- (point-max) (point-min)))
7538 (alist gnus-treatment-function-alist)
7539 (article-goto-body-goes-to-point-min-p t)
7543 (let ((list gnus-article-treat-types))
7545 (when (string-match (pop list) type)
7546 (throw 'found t)))))))
7547 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7549 (gnus-run-hooks 'gnus-part-display-hook)
7550 (dolist (elem alist)
7553 (when (gnus-buffer-live-p gnus-summary-buffer)
7554 (set-buffer gnus-summary-buffer))
7555 (symbol-value (car elem))))
7556 (when (and (or (consp val)
7558 (gnus-treat-predicate val)
7559 (or (not (get (car elem) 'highlight))
7562 (funcall (cadr elem)))))))
7564 ;; Dynamic variables.
7566 (defvar part-number)
7567 (defvar total-parts)
7572 (defun gnus-treat-predicate (val)
7579 (stringp (car val)))
7580 (apply 'gnus-or (mapcar `(lambda (s)
7581 (string-match s ,(or gnus-newsgroup-name "")))
7584 (let ((pred (pop val)))
7587 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7589 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7591 (not (gnus-treat-predicate (car val))))
7593 (equal (car val) type))
7595 (error "%S is not a valid predicate" pred)))))
7603 (eq part-number total-parts))
7607 (error "%S is not a valid value" val))))
7609 (defun gnus-article-encrypt-body (protocol &optional n)
7610 "Encrypt the article body."
7613 (or gnus-article-encrypt-protocol
7614 (completing-read "Encrypt protocol: "
7615 gnus-article-encrypt-protocol-alist
7617 current-prefix-arg))
7618 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7620 (error "Can't find the encrypt protocol %s" protocol))
7621 (if (member gnus-newsgroup-name '("nndraft:delayed"
7624 (error "Can't encrypt the article in group %s"
7625 gnus-newsgroup-name))
7626 (gnus-summary-iterate n
7628 (set-buffer gnus-summary-buffer)
7629 (let ((mail-parse-charset gnus-newsgroup-charset)
7630 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7631 (summary-buffer gnus-summary-buffer)
7633 (gnus-set-global-variables)
7634 (when (gnus-group-read-only-p)
7635 (error "The current newsgroup does not support article encrypt"))
7636 (gnus-summary-show-article t)
7638 (or (mail-header-references gnus-current-headers) ""))
7639 (set-buffer gnus-article-buffer)
7640 (let* ((inhibit-read-only t)
7642 (mapcar (lambda (field)
7643 (and (save-restriction
7644 (message-narrow-to-head)
7645 (goto-char (point-min))
7646 (search-forward field nil t))
7648 (message-narrow-to-field)
7650 (delete-region (point-min) (point-max))
7652 '("Content-Type:" "Content-Transfer-Encoding:"
7653 "Content-Disposition:"))))
7654 (message-narrow-to-head)
7655 (message-remove-header "MIME-Version")
7656 (goto-char (point-max))
7657 (setq point (point))
7658 (insert (apply 'concat headers))
7660 (narrow-to-region point (point-max))
7661 (let ((message-options message-options))
7662 (message-options-set 'message-sender user-mail-address)
7663 (message-options-set 'message-recipients user-mail-address)
7664 (message-options-set 'message-sign-encrypt 'not)
7666 (goto-char (point-min))
7667 (insert "MIME-Version: 1.0\n")
7669 (gnus-summary-edit-article-done
7670 references nil summary-buffer t))
7671 (when gnus-keep-backlog
7672 (gnus-backlog-remove-article
7673 (car gnus-article-current) (cdr gnus-article-current)))
7675 (when (get-buffer gnus-original-article-buffer)
7676 (set-buffer gnus-original-article-buffer)
7677 (setq gnus-original-article nil)))
7678 (when gnus-use-cache
7679 (gnus-cache-update-article
7680 (car gnus-article-current) (cdr gnus-article-current))))))))
7682 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7683 "The following specs can be used:
7684 %t The security MIME type
7687 %D Details if button is pressed")
7689 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7690 "The following specs can be used:
7691 %t The security MIME type
7694 %D Details if button is pressed")
7696 (defvar gnus-mime-security-button-line-format-alist
7697 '((?t gnus-tmp-type ?s)
7698 (?i gnus-tmp-info ?s)
7699 (?d gnus-tmp-details ?s)
7700 (?D gnus-tmp-pressed-details ?s)))
7702 (defvar gnus-mime-security-button-commands
7703 '((gnus-article-press-button "\r" "Show Detail")
7707 (gnus-mime-security-save-part "o" "Save...")
7716 (gnus-mime-security-pipe-part "|" "Pipe To Command...")
7719 (defvar gnus-mime-security-button-map
7720 (let ((map (make-sparse-keymap)))
7721 (define-key map gnus-mouse-2 'gnus-article-push-button)
7722 (define-key map gnus-down-mouse-3 'gnus-mime-security-button-menu)
7723 (dolist (c gnus-mime-security-button-commands)
7724 (define-key map (cadr c) (car c)))
7728 gnus-mime-security-button-menu gnus-mime-security-button-map
7729 "Security button menu."
7733 (unless (eq (car c) 'undefined)
7734 (vector (caddr c) (car c) :active t)))
7735 gnus-mime-security-button-commands))))
7737 (defun gnus-mime-security-button-menu (event prefix)
7738 "Construct a context-sensitive menu of security commands."
7739 (interactive "e\nP")
7740 (save-window-excursion
7741 (let ((pos (event-start event)))
7742 (select-window (posn-window pos))
7743 (goto-char (posn-point pos))
7744 (gnus-article-check-buffer)
7745 (popup-menu gnus-mime-security-button-menu nil prefix))))
7747 (defvar gnus-mime-security-details-buffer nil)
7749 (defvar gnus-mime-security-button-pressed nil)
7751 (defvar gnus-mime-security-show-details-inline t
7752 "If non-nil, show details in the article buffer.")
7754 (defun gnus-mime-security-verify-or-decrypt (handle)
7755 (mm-remove-parts (cdr handle))
7756 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7757 point (inhibit-read-only t))
7759 (goto-char (car region)))
7761 (narrow-to-region (point) (point))
7762 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7763 (let* ((mm-verify-option 'known)
7764 (mm-decrypt-option 'known)
7765 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7766 (unless (eq nparts (cdr handle))
7767 (mm-destroy-parts (cdr handle))
7768 (setcdr handle nparts))))
7769 (setq point (point))
7770 (gnus-mime-display-security handle)
7771 (goto-char (point-max)))
7773 (delete-region (point) (cdr region))
7774 (set-marker (car region) nil)
7775 (set-marker (cdr region) nil))
7778 (defun gnus-mime-security-show-details (handle)
7779 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7781 (gnus-message 5 "No details.")
7782 (if gnus-mime-security-show-details-inline
7783 (let ((gnus-mime-security-button-pressed
7784 (not (get-text-property (point) 'gnus-mime-details)))
7785 (gnus-mime-security-button-line-format
7786 (get-text-property (point) 'gnus-line-format))
7787 (inhibit-read-only t))
7789 (while (eq (get-text-property (point) 'gnus-line-format)
7790 gnus-mime-security-button-line-format)
7794 (narrow-to-region (point) (point))
7795 (gnus-insert-mime-security-button handle))
7796 (delete-region (point)
7797 (or (text-property-not-all
7800 gnus-mime-security-button-line-format)
7803 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7804 (with-current-buffer gnus-mime-security-details-buffer
7807 (setq gnus-mime-security-details-buffer
7808 (gnus-get-buffer-create "*MIME Security Details*")))
7809 (with-current-buffer gnus-mime-security-details-buffer
7811 (goto-char (point-min)))
7812 (pop-to-buffer gnus-mime-security-details-buffer)))))
7814 (defun gnus-mime-security-press-button (handle)
7816 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7817 (gnus-mime-security-show-details handle)
7818 (gnus-mime-security-verify-or-decrypt handle))))
7820 (defun gnus-insert-mime-security-button (handle &optional displayed)
7821 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7824 (or (nth 2 (assoc protocol mm-verify-function-alist))
7825 (nth 2 (assoc protocol mm-decrypt-function-alist))
7827 (if (equal (car handle) "multipart/signed")
7828 " Signed" " Encrypted")
7831 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7834 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7835 gnus-tmp-pressed-details
7837 (setq gnus-tmp-details
7838 (if gnus-tmp-details
7839 (concat "\n" gnus-tmp-details)
7841 (setq gnus-tmp-pressed-details
7842 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7847 gnus-mime-security-button-line-format
7848 gnus-mime-security-button-line-format-alist
7849 `(keymap ,gnus-mime-security-button-map
7850 gnus-callback gnus-mime-security-press-button
7851 gnus-line-format ,gnus-mime-security-button-line-format
7852 gnus-mime-details ,gnus-mime-security-button-pressed
7853 article-type annotation
7856 ;; Exclude a newline.
7859 (widget-convert-button
7862 :action 'gnus-widget-press-button
7863 :button-keymap gnus-mime-security-button-map
7865 (lambda (widget/window &optional overlay pos)
7866 ;; Needed to properly clear the message due to a bug in
7867 ;; wid-edit (XEmacs only).
7868 (when (boundp 'help-echo-owns-message)
7869 (setq help-echo-owns-message t))
7871 "%S: show detail; %S: more options"
7872 (aref gnus-mouse-2 0)
7873 (aref gnus-down-mouse-3 0))))))
7875 (defun gnus-mime-display-security (handle)
7877 (narrow-to-region (point) (point))
7878 (unless (gnus-unbuttonized-mime-type-p (car handle))
7879 (gnus-insert-mime-security-button handle))
7880 (gnus-mime-display-part (cadr handle))
7883 (unless (gnus-unbuttonized-mime-type-p (car handle))
7884 (let ((gnus-mime-security-button-line-format
7885 gnus-mime-security-button-end-line-format))
7886 (gnus-insert-mime-security-button handle)))
7887 (mm-set-handle-multipart-parameter
7889 (cons (set-marker (make-marker) (point-min))
7890 (set-marker (make-marker) (point-max))))))
7892 (defun gnus-mime-security-run-function (function)
7893 "Run FUNCTION with the security part under point."
7894 (gnus-article-check-buffer)
7895 (let ((data (get-text-property (point) 'gnus-data))
7897 (when (and (stringp (car-safe data))
7898 (setq buffer (mm-handle-multipart-original-buffer data))
7899 (setq handle (cadr data)))
7900 (if (bufferp (mm-handle-buffer handle))
7902 (setq handle (cons buffer (copy-sequence (cdr handle))))
7903 (mm-handle-set-undisplayer handle nil))
7904 (setq handle (mm-make-handle
7906 (mm-handle-multipart-ctl-parameter handle 'protocol)
7907 nil nil nil nil nil nil)))
7908 (funcall function handle))))
7910 (defun gnus-mime-security-save-part ()
7911 "Save the security part under point."
7913 (gnus-mime-security-run-function 'mm-save-part))
7915 (defun gnus-mime-security-pipe-part ()
7916 "Pipe the security part under point to a process."
7918 (gnus-mime-security-run-function 'mm-pipe-part))
7924 (run-hooks 'gnus-art-load-hook)
7926 ;;; arch-tag: 2654516f-6279-48f9-a83b-05c1fa450c33
7927 ;;; gnus-art.el ends here