1 ;;; gnus-art.el --- article mode commands for Semi-gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
3 ;; Free Software Foundation, Inc.
5 ;; Author: Lars Magne Ingebrigtsen <larsi@gnus.org>
6 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;; Katsumi Yamaoka <yamaoka@jpl.org>
8 ;; Keywords: mail, news, MIME
10 ;; This file is part of GNU Emacs.
12 ;; GNU Emacs is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; GNU Emacs is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
34 (defvar tool-bar-map))
44 (when (static-if (featurep 'xemacs)
45 (console-on-window-system-p)
47 (require 'mime-image))
50 ;; Avoid byte-compile warnings.
60 (autoload 'gnus-msg-mail "gnus-msg" nil t)
61 (autoload 'gnus-button-mailto "gnus-msg")
62 (autoload 'gnus-button-reply "gnus-msg" nil t)
63 (autoload 'ansi-color-apply-on-region "ansi-color")
65 (defgroup gnus-article nil
67 :link '(custom-manual "(gnus)Article Buffer")
70 (defgroup gnus-article-treat nil
71 "Treating article parts."
72 :link '(custom-manual "(gnus)Article Hiding")
75 (defgroup gnus-article-hiding nil
76 "Hiding article parts."
77 :link '(custom-manual "(gnus)Article Hiding")
80 (defgroup gnus-article-highlight nil
81 "Article highlighting."
82 :link '(custom-manual "(gnus)Article Highlighting")
86 (defgroup gnus-article-signature nil
88 :link '(custom-manual "(gnus)Article Signature")
91 (defgroup gnus-article-headers nil
93 :link '(custom-manual "(gnus)Hiding Headers")
96 (defgroup gnus-article-washing nil
97 "Special commands on articles."
98 :link '(custom-manual "(gnus)Article Washing")
101 (defgroup gnus-article-emphasis nil
102 "Fontisizing articles."
103 :link '(custom-manual "(gnus)Article Fontisizing")
104 :group 'gnus-article)
106 (defgroup gnus-article-saving nil
108 :link '(custom-manual "(gnus)Saving Articles")
109 :group 'gnus-article)
111 (defgroup gnus-article-mime nil
112 "Worshiping the MIME wonder."
113 :link '(custom-manual "(gnus)Using MIME")
114 :group 'gnus-article)
116 (defgroup gnus-article-buttons nil
117 "Pushable buttons in the article buffer."
118 :link '(custom-manual "(gnus)Article Buttons")
119 :group 'gnus-article)
121 (defgroup gnus-article-various nil
122 "Other article options."
123 :link '(custom-manual "(gnus)Misc Article")
124 :group 'gnus-article)
126 (defcustom gnus-ignored-headers
129 (concat "^" header ":"))
130 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
131 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
132 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
133 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
134 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
135 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
136 "X-Attribution" "X-Originating-IP" "Delivered-To"
137 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
138 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
139 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
140 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
141 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
142 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
143 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
144 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
145 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
146 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
147 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
148 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
149 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
150 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
151 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
152 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
153 "List-[A-Za-z]+" "X-Listprocessor-Version"
154 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
155 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
156 "X-Received" "Content-length" "X-precedence"
157 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
158 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
159 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
160 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
161 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
162 "X-Content-length" "X-Posting-Agent" "Original-Received"
163 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
164 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
165 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
166 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
167 "X-Abuse-and-DMCA-Info" "X-Postfilter" "X-Gpg-.*" "X-Disclaimer"))
168 "*All headers that start with this regexp will be hidden.
169 This variable can also be a list of regexps of headers to be ignored.
170 If `gnus-visible-headers' is non-nil, this variable will be ignored."
171 :type '(choice :custom-show nil
174 :group 'gnus-article-hiding)
176 (defcustom gnus-visible-headers
177 "^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:"
178 "*All headers that do not match this regexp will be hidden.
179 This variable can also be a list of regexp of headers to remain visible.
180 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
181 :type '(repeat :value-to-internal (lambda (widget value)
182 (custom-split-regexp-maybe value))
183 :match (lambda (widget value)
185 (widget-editable-list-match widget value)))
187 :group 'gnus-article-hiding)
189 (defcustom gnus-sorted-header-list
190 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
191 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
192 "*This variable is a list of regular expressions.
193 If it is non-nil, headers that match the regular expressions will
194 be placed first in the article buffer in the sequence specified by
196 :type '(repeat regexp)
197 :group 'gnus-article-hiding)
199 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
200 "Headers that are only to be displayed if they have interesting data.
201 Possible values in this list are:
203 'empty Headers with no content.
204 'newsgroups Newsgroup identical to Gnus group.
205 'to-address To identical to To-address.
206 'to-list To identical to To-list.
207 'cc-list CC identical to To-list.
208 'followup-to Followup-to identical to Newsgroups.
209 'reply-to Reply-to identical to From.
210 'date Date less than four days old.
211 'long-to To and/or Cc longer than 1024 characters.
212 'many-to Multiple To and/or Cc."
213 :type '(set (const :tag "Headers with no content." empty)
214 (const :tag "Newsgroups identical to Gnus group." newsgroups)
215 (const :tag "To identical to To-address." to-address)
216 (const :tag "To identical to To-list." to-list)
217 (const :tag "CC identical to To-list." cc-list)
218 (const :tag "Followup-to identical to Newsgroups." followup-to)
219 (const :tag "Reply-to identical to From." reply-to)
220 (const :tag "Date less than four days old." date)
221 (const :tag "To and/or Cc longer than 1024 characters." long-to)
222 (const :tag "Multiple To and/or Cc headers." many-to))
223 :group 'gnus-article-hiding)
225 (defcustom gnus-article-skip-boring nil
226 "Skip over text that is not worth reading.
227 By default, if you set this t, then Gnus will display citations and
228 signatures, but will never scroll down to show you a page consisting
229 only of boring text. Boring text is controlled by
230 `gnus-article-boring-faces'."
232 :group 'gnus-article-hiding)
234 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
235 "Regexp matching signature separator.
236 This can also be a list of regexps. In that case, it will be checked
237 from head to tail looking for a separator. Searches will be done from
238 the end of the buffer."
239 :type '(repeat string)
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."
250 :type '(choice (integer :value 200)
252 (function :value fun)
253 (regexp :value ".*"))
254 :group 'gnus-article-signature)
256 (defcustom gnus-hidden-properties '(invisible t intangible t)
257 "Property list to use for hiding text."
259 :group 'gnus-article-hiding)
261 ;; Fixme: This isn't the right thing for mixed graphical and non-graphical
262 ;; frames in a session.
263 (defcustom gnus-article-x-face-command
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 ((and (fboundp 'image-type-available-p)
273 (module-installed-p 'x-face-e21))
274 'x-face-decode-message-header)
275 ((gnus-image-type-available-p 'pbm)
276 'gnus-display-x-face-in-from)
278 (module-installed-p 'x-face-mule))
279 'x-face-mule-gnus-article-display-x-face)
281 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
283 "*String or function to be executed to display an X-Face header.
284 If it is a string, the command will be executed in a sub-shell
285 asynchronously. The compressed face will be piped to this command."
287 ,@(let (x-face-e21 x-face-mule)
288 (if (featurep 'xemacs)
290 (setq x-face-e21 (module-installed-p 'x-face-e21)
291 x-face-mule (module-installed-p 'x-face-mule)))
295 (if (or (gnus-image-type-available-p 'xface)
296 (gnus-image-type-available-p 'pbm))
297 '(function-item gnus-display-x-face-in-from))
299 (fboundp 'image-type-available-p))
301 :tag "x-face-decode-message-header (x-face-e21)"
302 x-face-decode-message-header))
305 x-face-mule-gnus-article-display-x-face))
309 :group 'gnus-article-washing)
311 (defcustom gnus-article-x-face-too-ugly nil
312 "Regexp matching posters whose face shouldn't be shown automatically."
313 :type '(choice regexp (const nil))
314 :group 'gnus-article-washing)
316 (defcustom gnus-article-banner-alist nil
317 "Banner alist for stripping.
319 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
321 :type '(repeat (cons symbol regexp))
322 :group 'gnus-article-washing)
324 (gnus-define-group-parameter
327 "Alist of regexps (to match group names) and banner."
328 :variable-group gnus-article-washing
330 '(choice :tag "Banner"
332 (const :tag "Remove signature" signature)
333 (symbol :tag "Item in `gnus-article-banner-alist'" none)
335 (const :tag "None" nil))
337 "If non-nil, specify how to remove `banners' from articles.
339 Symbol `signature' means to remove signatures delimited by
340 `gnus-signature-separator'. Any other symbol is used to look up a
341 regular expression to match the banner in `gnus-article-banner-alist'.
342 A string is used as a regular expression to match the banner
345 (defcustom gnus-article-address-banner-alist nil
346 "Alist of mail addresses and banners.
347 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
348 to match a mail address in the From: header, BANNER is one of a symbol
349 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
350 If ADDRESS matches author's mail address, it will remove things like
351 advertisements. For example:
353 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
357 (regexp :tag "Address")
358 (choice :tag "Banner" :value nil
359 (const :tag "Remove signature" signature)
360 (symbol :tag "Item in `gnus-article-banner-alist'" none)
362 (const :tag "None" nil))))
363 :group 'gnus-article-washing)
365 (defcustom gnus-emphasis-alist
367 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
372 ("_/" "/_" underline-italic)
373 ("_\\*" "\\*_" underline-bold)
374 ("\\*/" "/\\*" bold-italic)
375 ("_\\*/" "/\\*_" underline-bold-italic))))
379 (format format (car spec) (car (cdr spec)))
380 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
382 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
383 2 3 gnus-emphasis-underline)))
384 "*Alist that says how to fontify certain phrases.
385 Each item looks like this:
387 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
389 The first element is a regular expression to be matched. The second
390 is a number that says what regular expression grouping used to find
391 the entire emphasized word. The third is a number that says what
392 regexp grouping should be displayed and highlighted. The fourth
393 is the face used for highlighting."
394 :type '(repeat (list :value ("" 0 0 default)
396 (integer :tag "Match group")
397 (integer :tag "Emphasize group")
399 :group 'gnus-article-emphasis)
401 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
402 "A regexp to describe whitespace which should not be emphasized.
403 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
404 The former avoids underlining of leading and trailing whitespace,
405 and the latter avoids underlining any whitespace at all."
407 :group 'gnus-article-emphasis
410 (defface gnus-emphasis-bold '((t (:bold t)))
411 "Face used for displaying strong emphasized text (*word*)."
412 :group 'gnus-article-emphasis)
414 (defface gnus-emphasis-italic '((t (:italic t)))
415 "Face used for displaying italic emphasized text (/word/)."
416 :group 'gnus-article-emphasis)
418 (defface gnus-emphasis-underline '((t (:underline t)))
419 "Face used for displaying underlined emphasized text (_word_)."
420 :group 'gnus-article-emphasis)
422 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
423 "Face used for displaying underlined bold emphasized text (_*word*_)."
424 :group 'gnus-article-emphasis)
426 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
427 "Face used for displaying underlined italic emphasized text (_/word/_)."
428 :group 'gnus-article-emphasis)
430 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
431 "Face used for displaying bold italic emphasized text (/*word*/)."
432 :group 'gnus-article-emphasis)
434 (defface gnus-emphasis-underline-bold-italic
435 '((t (:bold t :italic t :underline t)))
436 "Face used for displaying underlined bold italic emphasized text.
437 Example: (_/*word*/_)."
438 :group 'gnus-article-emphasis)
440 (defface gnus-emphasis-strikethru (if (featurep 'xemacs)
441 '((t (:strikethru t)))
442 '((t (:strike-through t))))
443 "Face used for displaying strike-through text (-word-)."
444 :group 'gnus-article-emphasis)
446 (defface gnus-emphasis-highlight-words
447 '((t (:background "black" :foreground "yellow")))
448 "Face used for displaying highlighted words."
449 :group 'gnus-article-emphasis)
451 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
452 "Format for display of Date headers in article bodies.
453 See `format-time-string' for the possible values.
455 The variable can also be function, which should return a complete Date
456 header. The function is called with one argument, the time, which can
457 be fed to `format-time-string'."
458 :type '(choice string symbol)
459 :link '(custom-manual "(gnus)Article Date")
460 :group 'gnus-article-washing)
463 (autoload 'mail-extract-address-components "mail-extr"))
465 (defcustom gnus-save-all-headers t
466 "*If non-nil, don't remove any headers before saving."
467 :group 'gnus-article-saving
470 (defcustom gnus-prompt-before-saving 'always
471 "*This variable says how much prompting is to be done when saving articles.
472 If it is nil, no prompting will be done, and the articles will be
473 saved to the default files. If this variable is `always', each and
474 every article that is saved will be preceded by a prompt, even when
475 saving large batches of articles. If this variable is neither nil not
476 `always', there the user will be prompted once for a file name for
477 each invocation of the saving commands."
478 :group 'gnus-article-saving
479 :type '(choice (item always)
480 (item :tag "never" nil)
481 (sexp :tag "once" :format "%t\n" :value t)))
483 (defcustom gnus-saved-headers gnus-visible-headers
484 "Headers to keep if `gnus-save-all-headers' is nil.
485 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
486 If that variable is nil, however, all headers that match this regexp
487 will be kept while the rest will be deleted before saving."
488 :group 'gnus-article-saving
491 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
492 "A function to save articles in your favourite format.
493 The function must be interactively callable (in other words, it must
494 be an Emacs command).
496 Gnus provides the following functions:
498 * gnus-summary-save-in-rmail (Rmail format)
499 * gnus-summary-save-in-mail (Unix mail format)
500 * gnus-summary-save-in-folder (MH folder)
501 * gnus-summary-save-in-file (article format)
502 * gnus-summary-save-body-in-file (article body)
503 * gnus-summary-save-in-vm (use VM's folder format)
504 * gnus-summary-write-to-file (article format -- overwrite)."
505 :group 'gnus-article-saving
506 :type '(radio (function-item gnus-summary-save-in-rmail)
507 (function-item gnus-summary-save-in-mail)
508 (function-item gnus-summary-save-in-folder)
509 (function-item gnus-summary-save-in-file)
510 (function-item gnus-summary-save-body-in-file)
511 (function-item gnus-summary-save-in-vm)
512 (function-item gnus-summary-write-to-file)))
514 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
515 "A function generating a file name to save articles in Rmail format.
516 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
517 :group 'gnus-article-saving
520 (defcustom gnus-mail-save-name 'gnus-plain-save-name
521 "A function generating a file name to save articles in Unix mail format.
522 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
523 :group 'gnus-article-saving
526 (defcustom gnus-folder-save-name 'gnus-folder-save-name
527 "A function generating a file name to save articles in MH folder.
528 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
529 :group 'gnus-article-saving
532 (defcustom gnus-file-save-name 'gnus-numeric-save-name
533 "A function generating a file name to save articles in article format.
534 The function is called with NEWSGROUP, HEADERS, and optional
536 :group 'gnus-article-saving
539 (defcustom gnus-split-methods
540 '((gnus-article-archive-name)
541 (gnus-article-nndoc-name))
542 "*Variable used to suggest where articles are to be saved.
543 For instance, if you would like to save articles related to Gnus in
544 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
545 you could set this variable to something like:
547 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
548 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
550 This variable is an alist where the where the key is the match and the
551 value is a list of possible files to save in if the match is non-nil.
553 If the match is a string, it is used as a regexp match on the
554 article. If the match is a symbol, that symbol will be funcalled
555 from the buffer of the article to be saved with the newsgroup as the
556 parameter. If it is a list, it will be evaled in the same buffer.
558 If this form or function returns a string, this string will be used as
559 a possible file name; and if it returns a non-nil list, that list will
560 be used as possible file names."
561 :group 'gnus-article-saving
562 :type '(repeat (choice (list :value (fun) function)
563 (cons :value ("" "") regexp (repeat string))
566 (defcustom gnus-article-display-method-for-mime
567 'gnus-article-display-mime-message
568 "Function to display a MIME message.
569 The function is called from the article buffer."
570 :group 'gnus-article-mime
573 (defcustom gnus-article-display-method-for-traditional
574 'gnus-article-display-traditional-message
575 "*Function to display a traditional message.
576 The function is called from the article buffer."
577 :group 'gnus-article-mime
580 (defcustom gnus-page-delimiter "^\^L"
581 "*Regexp describing what to use as article page delimiters.
582 The default value is \"^\^L\", which is a form linefeed at the
583 beginning of a line."
585 :group 'gnus-article-various)
587 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
588 "*The format specification for the article mode line.
589 See `gnus-summary-mode-line-format' for a closer description.
591 The following additional specs are available:
593 %w The article washing status.
594 %m The number of MIME parts in the article."
596 :group 'gnus-article-various)
598 (defcustom gnus-article-mode-hook nil
599 "*A hook for Gnus article mode."
601 :group 'gnus-article-various)
603 (when (featurep 'xemacs)
604 ;; Extracted from gnus-xmas-define in order to preserve user settings
605 (when (fboundp 'turn-off-scroll-in-place)
606 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
607 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
608 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
610 (defcustom gnus-article-menu-hook nil
611 "*Hook run after the creation of the article mode menu."
613 :group 'gnus-article-various)
615 (defcustom gnus-article-prepare-hook nil
616 "*A hook called after an article has been prepared in the article buffer."
618 :group 'gnus-article-various)
620 (make-obsolete-variable 'gnus-article-hide-pgp-hook
621 "This variable is obsolete in Gnus 5.10.")
623 (defcustom gnus-article-button-face 'bold
624 "Face used for highlighting buttons in the article buffer.
626 An article button is a piece of text that you can activate by pressing
627 `RET' or `mouse-2' above it."
629 :group 'gnus-article-buttons)
631 (defcustom gnus-article-mouse-face 'highlight
632 "Face used for mouse highlighting in the article buffer.
634 Article buttons will be displayed in this face when the cursor is
637 :group 'gnus-article-buttons)
639 (defcustom gnus-signature-face 'gnus-signature-face
640 "Face used for highlighting a signature in the article buffer.
641 Obsolete; use the face `gnus-signature-face' for customizations instead."
643 :group 'gnus-article-highlight
644 :group 'gnus-article-signature)
646 (defface gnus-signature-face
649 "Face used for highlighting a signature in the article buffer."
650 :group 'gnus-article-highlight
651 :group 'gnus-article-signature)
653 (defface gnus-header-from-face
656 (:foreground "spring green"))
659 (:foreground "red3"))
662 "Face used for displaying from headers."
663 :group 'gnus-article-headers
664 :group 'gnus-article-highlight)
666 (defface gnus-header-subject-face
669 (:foreground "SeaGreen3"))
672 (:foreground "red4"))
674 (:bold t :italic t)))
675 "Face used for displaying subject headers."
676 :group 'gnus-article-headers
677 :group 'gnus-article-highlight)
679 (defface gnus-header-newsgroups-face
682 (:foreground "yellow" :italic t))
685 (:foreground "MidnightBlue" :italic t))
688 "Face used for displaying newsgroups headers.
689 In the default setup this face is only used for crossposted
691 :group 'gnus-article-headers
692 :group 'gnus-article-highlight)
694 (defface gnus-header-name-face
697 (:foreground "SeaGreen"))
700 (:foreground "maroon"))
703 "Face used for displaying header names."
704 :group 'gnus-article-headers
705 :group 'gnus-article-highlight)
707 (defface gnus-header-content-face
710 (:foreground "forest green" :italic t))
713 (:foreground "indianred4" :italic t))
716 "Face used for displaying header content."
717 :group 'gnus-article-headers
718 :group 'gnus-article-highlight)
720 (defcustom gnus-header-face-alist
721 '(("From" nil gnus-header-from-face)
722 ("Subject" nil gnus-header-subject-face)
723 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
724 ("" gnus-header-name-face gnus-header-content-face))
725 "*Controls highlighting of article headers.
727 An alist of the form (HEADER NAME CONTENT).
729 HEADER is a regular expression which should match the name of a
730 header and NAME and CONTENT are either face names or nil.
732 The name of each header field will be displayed using the face
733 specified by the first element in the list where HEADER matches
734 the header name and NAME is non-nil. Similarly, the content will
735 be displayed by the first non-nil matching CONTENT face."
736 :group 'gnus-article-headers
737 :group 'gnus-article-highlight
738 :type '(repeat (list (regexp :tag "Header")
740 (item :tag "skip" nil)
741 (face :value default))
742 (choice :tag "Content"
743 (item :tag "skip" nil)
744 (face :value default)))))
746 (defcustom gnus-article-decode-hook
747 '(article-decode-group-name article-decode-idna-rhs)
748 "*Hook run to decode charsets in articles."
749 :group 'gnus-article-headers
752 (defcustom gnus-display-mime-function 'gnus-display-mime
753 "Function to display MIME articles."
754 :group 'gnus-article-mime
757 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
758 "Function used to decode headers.")
760 (defvar gnus-article-dumbquotes-map
780 "Table for MS-to-Latin1 translation.")
782 (defcustom gnus-ignored-mime-types nil
783 "List of MIME types that should be ignored by Gnus."
785 :group 'gnus-article-mime
786 :type '(repeat regexp))
788 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
789 "List of MIME types that should not be given buttons when rendered inline.
790 See also `gnus-buttonized-mime-types' which may override this variable.
791 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
793 :group 'gnus-article-mime
794 :type '(repeat regexp))
796 (defcustom gnus-buttonized-mime-types nil
797 "List of MIME types that should be given buttons when rendered inline.
798 If set, this variable overrides `gnus-unbuttonized-mime-types'.
799 To see e.g. security buttons you could set this to
800 `(\"multipart/signed\")'.
801 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
803 :group 'gnus-article-mime
804 :type '(repeat regexp))
806 (defcustom gnus-inhibit-mime-unbuttonizing nil
807 "If non-nil, all MIME parts get buttons.
808 When nil (the default value), then some MIME parts do not get buttons,
809 as described by the variables `gnus-buttonized-mime-types' and
810 `gnus-unbuttonized-mime-types'."
812 :group 'gnus-article-mime
815 (defcustom gnus-body-boundary-delimiter "_"
816 "String used to delimit header and body.
817 This variable is used by `gnus-article-treat-body-boundary' which can
818 be controlled by `gnus-treat-body-boundary'."
819 :group 'gnus-article-various
820 :type '(choice (item :tag "None" :value nil)
823 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
824 "Defines the location of the faces database.
825 For information on obtaining this database of pretty pictures, please
826 see http://www.cs.indiana.edu/picons/ftp/index.html"
827 :type '(repeat directory)
828 :link '(url-link :tag "download"
829 "http://www.cs.indiana.edu/picons/ftp/index.html")
830 :link '(custom-manual "(gnus)Picons")
833 (defun gnus-picons-installed-p ()
834 "Say whether picons are installed on your machine."
835 (let ((installed nil))
836 (dolist (database gnus-picon-databases)
837 (when (file-exists-p database)
841 (defcustom gnus-article-mime-part-function nil
842 "Function called with a MIME handle as the argument.
843 This is meant for people who want to do something automatic based
844 on parts -- for instance, adding Vcard info to a database."
845 :group 'gnus-article-mime
848 (defcustom gnus-mime-multipart-functions nil
849 "An alist of MIME types to functions to display them."
851 :group 'gnus-article-mime
852 :type '(repeat (cons :format "%v" (string :tag "MIME type") function)))
854 (defcustom gnus-article-date-lapsed-new-header nil
855 "Whether the X-Sent and Date headers can coexist.
856 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
857 either replace the old \"Date:\" header (if this variable is nil), or
858 be added below it (otherwise)."
860 :group 'gnus-article-headers
863 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
864 "Function called with a MIME handle as the argument.
865 This is meant for people who want to view first matched part.
866 For `undisplayed-alternative' (default), the first undisplayed
867 part or alternative part is used. For `undisplayed', the first
868 undisplayed part is used. For a function, the first part which
869 the function return t is used. For nil, the first part is
872 :group 'gnus-article-mime
874 (item :tag "first" :value nil)
875 (item :tag "undisplayed" :value undisplayed)
876 (item :tag "undisplayed or alternative"
877 :value undisplayed-alternative)
880 (defcustom gnus-mime-action-alist
881 '(("save to file" . gnus-mime-save-part)
882 ("save and strip" . gnus-mime-save-part-and-strip)
883 ("delete part" . gnus-mime-delete-part)
884 ("display as text" . gnus-mime-inline-part)
885 ("view the part" . gnus-mime-view-part)
886 ("pipe to command" . gnus-mime-pipe-part)
887 ("toggle display" . gnus-article-press-button)
888 ("toggle display" . gnus-article-view-part-as-charset)
889 ("view as type" . gnus-mime-view-part-as-type)
890 ("view internally" . gnus-mime-view-part-internally)
891 ("view externally" . gnus-mime-view-part-externally))
892 "An alist of actions that run on the MIME attachment."
893 :group 'gnus-article-mime
894 :type '(repeat (cons (string :tag "name")
898 ;;; The treatment variables
901 (defvar gnus-part-display-hook nil
902 "Hook called on parts that are to receive treatment.")
904 (defvar gnus-article-treat-custom
905 '(choice (const :tag "Off" nil)
907 (const :tag "Header" head)
908 (const :tag "Last" last)
909 (const :tag "Mime" mime)
910 (integer :tag "Less")
911 (repeat :tag "Groups" regexp)
912 (sexp :tag "Predicate")))
914 (defvar gnus-article-treat-head-custom
915 '(choice (const :tag "Off" nil)
916 (const :tag "Header" head)))
918 (defvar gnus-article-treat-types '("text/plain")
921 (defvar gnus-inhibit-treatment nil
922 "Whether to inhibit treatment.")
924 (defcustom gnus-treat-highlight-signature '(or t (typep "text/x-vcard"))
925 "Highlight the signature.
926 Valid values are nil, t, `head', `last', an integer or a predicate.
927 See Info node `(gnus)Customizing Articles'."
928 :group 'gnus-article-treat
929 :link '(custom-manual "(gnus)Customizing Articles")
930 :type gnus-article-treat-custom)
931 (put 'gnus-treat-highlight-signature 'highlight t)
933 (defcustom gnus-treat-buttonize 100000
935 Valid values are nil, t, `head', `last', an integer or a predicate.
936 See Info node `(gnus)Customizing Articles'."
937 :group 'gnus-article-treat
938 :link '(custom-manual "(gnus)Customizing Articles")
939 :type gnus-article-treat-custom)
940 (put 'gnus-treat-buttonize 'highlight t)
942 (defcustom gnus-treat-buttonize-head 'head
943 "Add buttons to the head.
944 Valid values are nil, t, `head', `last', an integer or a predicate.
945 See Info node `(gnus)Customizing Articles' for details."
946 :group 'gnus-article-treat
947 :link '(custom-manual "(gnus)Customizing Articles")
948 :type gnus-article-treat-head-custom)
949 (put 'gnus-treat-buttonize-head 'highlight t)
951 (defcustom gnus-treat-emphasize
952 (and (or window-system
956 Valid values are nil, t, `head', `last', an integer or a predicate.
957 See Info node `(gnus)Customizing Articles' for details."
958 :group 'gnus-article-treat
959 :link '(custom-manual "(gnus)Customizing Articles")
960 :type gnus-article-treat-custom)
961 (put 'gnus-treat-emphasize 'highlight t)
963 (defcustom gnus-treat-strip-cr nil
964 "Remove carriage returns.
965 Valid values are nil, t, `head', `last', an integer or a predicate.
966 See Info node `(gnus)Customizing Articles' for details."
967 :group 'gnus-article-treat
968 :link '(custom-manual "(gnus)Customizing Articles")
969 :type gnus-article-treat-custom)
971 (defcustom gnus-treat-unsplit-urls nil
972 "Remove newlines from within URLs.
973 Valid values are nil, t, `head', `last', an integer or a predicate.
974 See Info node `(gnus)Customizing Articles' for details."
975 :group 'gnus-article-treat
976 :link '(custom-manual "(gnus)Customizing Articles")
977 :type gnus-article-treat-custom)
979 (defcustom gnus-treat-leading-whitespace nil
980 "Remove leading whitespace in headers.
981 Valid values are nil, t, `head', `last', an integer or a predicate.
982 See Info node `(gnus)Customizing Articles' for details."
983 :group 'gnus-article-treat
984 :link '(custom-manual "(gnus)Customizing Articles")
985 :type gnus-article-treat-custom)
987 (defcustom gnus-treat-hide-headers 'head
989 Valid values are nil, t, `head', `last', an integer or a predicate.
990 See Info node `(gnus)Customizing Articles' for details."
991 :group 'gnus-article-treat
992 :link '(custom-manual "(gnus)Customizing Articles")
993 :type gnus-article-treat-head-custom)
995 (defcustom gnus-treat-hide-boring-headers nil
996 "Hide boring headers.
997 Valid values are nil, t, `head', `last', an integer or a predicate.
998 See Info node `(gnus)Customizing Articles' for details."
999 :group 'gnus-article-treat
1000 :link '(custom-manual "(gnus)Customizing Articles")
1001 :type gnus-article-treat-head-custom)
1003 (defcustom gnus-treat-hide-signature nil
1004 "Hide the signature.
1005 Valid values are nil, t, `head', `last', an integer or a predicate.
1006 See Info node `(gnus)Customizing Articles' for details."
1007 :group 'gnus-article-treat
1008 :link '(custom-manual "(gnus)Customizing Articles")
1009 :type gnus-article-treat-custom)
1011 (defcustom gnus-treat-fill-article nil
1013 Valid values are nil, t, `head', `last', an integer or a predicate.
1014 See Info node `(gnus)Customizing Articles' for details."
1015 :group 'gnus-article-treat
1016 :link '(custom-manual "(gnus)Customizing Articles")
1017 :type gnus-article-treat-custom)
1019 (defcustom gnus-treat-hide-citation nil
1021 Valid values are nil, t, `head', `last', an integer or a predicate.
1022 See Info node `(gnus)Customizing Articles' for details."
1023 :group 'gnus-article-treat
1024 :link '(custom-manual "(gnus)Customizing Articles")
1025 :type gnus-article-treat-custom)
1027 (defcustom gnus-treat-hide-citation-maybe nil
1029 Valid values are nil, t, `head', `last', an integer or a predicate.
1030 See Info node `(gnus)Customizing Articles' for details."
1031 :group 'gnus-article-treat
1032 :link '(custom-manual "(gnus)Customizing Articles")
1033 :type gnus-article-treat-custom)
1035 (defcustom gnus-treat-strip-list-identifiers 'head
1036 "Strip list identifiers from `gnus-list-identifiers`.
1037 Valid values are nil, t, `head', `last', an integer or a predicate.
1038 See Info node `(gnus)Customizing Articles' for details."
1040 :group 'gnus-article-treat
1041 :link '(custom-manual "(gnus)Customizing Articles")
1042 :type gnus-article-treat-custom)
1044 (make-obsolete-variable 'gnus-treat-strip-pgp
1045 "This option is obsolete in Gnus 5.10.")
1047 (defcustom gnus-treat-strip-pem nil
1048 "Strip PEM signatures.
1049 Valid values are nil, t, `head', `last', an integer or a predicate.
1050 See Info node `(gnus)Customizing Articles' for details."
1051 :group 'gnus-article-treat
1052 :link '(custom-manual "(gnus)Customizing Articles")
1053 :type gnus-article-treat-custom)
1055 (defcustom gnus-treat-strip-banner t
1056 "Strip banners from articles.
1057 The banner to be stripped is specified in the `banner' group parameter.
1058 Valid values are nil, t, `head', `last', an integer or a predicate.
1059 See Info node `(gnus)Customizing Articles' for details."
1060 :group 'gnus-article-treat
1061 :link '(custom-manual "(gnus)Customizing Articles")
1062 :type gnus-article-treat-custom)
1064 (defcustom gnus-treat-highlight-headers 'head
1065 "Highlight the headers.
1066 Valid values are nil, t, `head', `last', an integer or a predicate.
1067 See Info node `(gnus)Customizing Articles' for details."
1068 :group 'gnus-article-treat
1069 :link '(custom-manual "(gnus)Customizing Articles")
1070 :type gnus-article-treat-head-custom)
1071 (put 'gnus-treat-highlight-headers 'highlight t)
1073 (defcustom gnus-treat-highlight-citation t
1074 "Highlight cited text.
1075 Valid values are nil, t, `head', `last', an integer or a predicate.
1076 See Info node `(gnus)Customizing Articles' for details."
1077 :group 'gnus-article-treat
1078 :link '(custom-manual "(gnus)Customizing Articles")
1079 :type gnus-article-treat-custom)
1080 (put 'gnus-treat-highlight-citation 'highlight t)
1082 (defcustom gnus-treat-date-ut nil
1083 "Display the Date in UT (GMT).
1084 Valid values are nil, t, `head', `last', an integer or a predicate.
1085 See Info node `(gnus)Customizing Articles' for details."
1086 :group 'gnus-article-treat
1087 :link '(custom-manual "(gnus)Customizing Articles")
1088 :type gnus-article-treat-head-custom)
1090 (defcustom gnus-treat-date-local nil
1091 "Display the Date in the local timezone.
1092 Valid values are nil, t, `head', `last', an integer or a predicate.
1093 See Info node `(gnus)Customizing Articles' for details."
1094 :group 'gnus-article-treat
1095 :link '(custom-manual "(gnus)Customizing Articles")
1096 :type gnus-article-treat-head-custom)
1098 (defcustom gnus-treat-date-english nil
1099 "Display the Date in a format that can be read aloud in English.
1100 Valid values are nil, t, `head', `last', an integer or a predicate.
1101 See Info node `(gnus)Customizing Articles' for details."
1102 :group 'gnus-article-treat
1103 :link '(custom-manual "(gnus)Customizing Articles")
1104 :type gnus-article-treat-head-custom)
1106 (defcustom gnus-treat-date-lapsed nil
1107 "Display the Date header in a way that says how much time has elapsed.
1108 Valid values are nil, t, `head', `last', an integer or a predicate.
1109 See Info node `(gnus)Customizing Articles' for details."
1110 :group 'gnus-article-treat
1111 :link '(custom-manual "(gnus)Customizing Articles")
1112 :type gnus-article-treat-head-custom)
1114 (defcustom gnus-treat-date-original nil
1115 "Display the date in the original timezone.
1116 Valid values are nil, t, `head', `last', an integer or a predicate.
1117 See Info node `(gnus)Customizing Articles' for details."
1118 :group 'gnus-article-treat
1119 :link '(custom-manual "(gnus)Customizing Articles")
1120 :type gnus-article-treat-head-custom)
1122 (defcustom gnus-treat-date-iso8601 nil
1123 "Display the date in the ISO8601 format.
1124 Valid values are nil, t, `head', `last', an integer or a predicate.
1125 See Info node `(gnus)Customizing Articles' for details."
1127 :group 'gnus-article-treat
1128 :link '(custom-manual "(gnus)Customizing Articles")
1129 :type gnus-article-treat-head-custom)
1131 (defcustom gnus-treat-date-user-defined nil
1132 "Display the date in a user-defined format.
1133 The format is defined by the `gnus-article-time-format' variable.
1134 Valid values are nil, t, `head', `last', an integer or a predicate.
1135 See Info node `(gnus)Customizing Articles' for details."
1136 :group 'gnus-article-treat
1137 :link '(custom-manual "(gnus)Customizing Articles")
1138 :type gnus-article-treat-head-custom)
1140 (defcustom gnus-treat-strip-headers-in-body t
1141 "Strip the X-No-Archive header line from the beginning of the body.
1142 Valid values are nil, t, `head', `last', an integer or a predicate.
1143 See Info node `(gnus)Customizing Articles' for details."
1145 :group 'gnus-article-treat
1146 :link '(custom-manual "(gnus)Customizing Articles")
1147 :type gnus-article-treat-custom)
1149 (defcustom gnus-treat-strip-trailing-blank-lines nil
1150 "Strip trailing blank lines.
1151 Valid values are nil, t, `head', `last', an integer or a predicate.
1152 See Info node `(gnus)Customizing Articles' for details."
1153 :group 'gnus-article-treat
1154 :link '(custom-manual "(gnus)Customizing Articles")
1155 :type gnus-article-treat-custom)
1157 (defcustom gnus-treat-strip-leading-blank-lines nil
1158 "Strip leading blank lines.
1159 Valid values are nil, t, `head', `last', an integer or a predicate.
1160 See Info node `(gnus)Customizing Articles' for details."
1161 :group 'gnus-article-treat
1162 :link '(custom-manual "(gnus)Customizing Articles")
1163 :type gnus-article-treat-custom)
1165 (defcustom gnus-treat-strip-multiple-blank-lines nil
1166 "Strip multiple blank lines.
1167 Valid values are nil, t, `head', `last', an integer or a predicate.
1168 See Info node `(gnus)Customizing Articles' for details."
1169 :group 'gnus-article-treat
1170 :link '(custom-manual "(gnus)Customizing Articles")
1171 :type gnus-article-treat-custom)
1173 (defcustom gnus-treat-unfold-headers 'head
1174 "Unfold folded header lines.
1175 Valid values are nil, t, `head', `last', an integer or a predicate.
1176 See Info node `(gnus)Customizing Articles' for details."
1177 :group 'gnus-article-treat
1178 :link '(custom-manual "(gnus)Customizing Articles")
1179 :type gnus-article-treat-custom)
1181 (defcustom gnus-treat-fold-headers nil
1183 Valid values are nil, t, `head', `last', an integer or a predicate.
1184 See Info node `(gnus)Customizing Articles' for details."
1185 :group 'gnus-article-treat
1186 :link '(custom-manual "(gnus)Customizing Articles")
1187 :type gnus-article-treat-custom)
1189 (defcustom gnus-treat-fold-newsgroups 'head
1190 "Fold the Newsgroups and Followup-To headers.
1191 Valid values are nil, t, `head', `last', an integer or a predicate.
1192 See Info node `(gnus)Customizing Articles' for details."
1193 :group 'gnus-article-treat
1194 :link '(custom-manual "(gnus)Customizing Articles")
1195 :type gnus-article-treat-custom)
1197 (defcustom gnus-treat-overstrike t
1198 "Treat overstrike highlighting.
1199 Valid values are nil, t, `head', `last', an integer or a predicate.
1200 See Info node `(gnus)Customizing Articles' for details."
1201 :group 'gnus-article-treat
1202 :link '(custom-manual "(gnus)Customizing Articles")
1203 :type gnus-article-treat-custom)
1204 (put 'gnus-treat-overstrike 'highlight t)
1206 (defcustom gnus-treat-ansi-sequences (if (locate-library "ansi-color") t)
1207 "Treat ANSI SGR control sequences.
1208 Valid values are nil, t, `head', `last', an integer or a predicate.
1209 See Info node `(gnus)Customizing Articles' for details."
1210 :group 'gnus-article-treat
1211 :link '(custom-manual "(gnus)Customizing Articles")
1212 :type gnus-article-treat-custom)
1214 (make-obsolete-variable 'gnus-treat-display-xface
1215 'gnus-treat-display-x-face)
1217 (defcustom gnus-treat-display-x-face
1218 (and (not noninteractive)
1219 (or (memq gnus-article-x-face-command
1220 '(x-face-decode-message-header
1221 x-face-mule-gnus-article-display-x-face))
1222 (and (fboundp 'image-type-available-p)
1223 (image-type-available-p 'xbm)
1224 (string-match "^0x" (shell-command-to-string "uncompface"))
1225 (executable-find "icontopbm"))
1226 (and (featurep 'xemacs)
1229 "Display X-Face headers.
1230 Valid values are nil, t, `head', `last', an integer or a predicate.
1231 See Info node `(gnus)Customizing Articles' and Info node
1232 `(gnus)X-Face' for details."
1233 :group 'gnus-article-treat
1235 :link '(custom-manual "(gnus)Customizing Articles")
1236 :link '(custom-manual "(gnus)X-Face")
1237 :type gnus-article-treat-head-custom
1238 :set (lambda (symbol value)
1241 (cond ((or (boundp symbol) (get symbol 'saved-value))
1243 ((boundp 'gnus-treat-display-xface)
1245 ** gnus-treat-display-xface is an obsolete variable;\
1246 use gnus-treat-display-x-face instead")
1247 (default-value 'gnus-treat-display-xface))
1248 ((get 'gnus-treat-display-xface 'saved-value)
1250 ** gnus-treat-display-xface is an obsolete variable;\
1251 use gnus-treat-display-x-face instead")
1252 (eval (car (get 'gnus-treat-display-xface 'saved-value))))
1255 (put 'gnus-treat-display-x-face 'highlight t)
1257 (defcustom gnus-article-should-use-smiley-mule
1258 (not (or (featurep 'xemacs)
1259 (gnus-image-type-available-p 'xpm)
1260 (gnus-image-type-available-p 'pbm)))
1261 "Non-nil means use `smiley-mule' to show smileys rather than `smiley'.
1262 `smiley-mule' is boundled in BITMAP-MULE package. You can set it to t
1263 even if your Emacs supports images. It has no effect on XEmacs."
1264 :group 'gnus-article-various
1266 :get (lambda (symbol)
1267 (and (not noninteractive)
1268 (default-value symbol)
1269 (not (featurep 'xemacs))
1270 (module-installed-p 'smiley-mule)
1272 :set (lambda (symbol value)
1273 (set-default symbol (and (not noninteractive)
1275 (not (featurep 'xemacs))
1276 (module-installed-p 'smiley-mule)
1279 (defvar gnus-article-smiley-mule-loaded-p nil
1280 "Internal variable used to say whether `smiley-mule' is loaded (whether
1281 smiley functions are not overridden by `smiley').")
1283 (defcustom gnus-treat-display-face
1284 (and (not noninteractive)
1285 ;; x-face-e21 handles both X-Face and Face headers.
1286 (not (and (eq gnus-article-x-face-command 'x-face-decode-message-header)
1287 (module-installed-p 'x-face-e21)))
1288 (or (and (fboundp 'image-type-available-p)
1289 (image-type-available-p 'png))
1290 (and (featurep 'xemacs)
1293 "Display Face headers.
1294 Valid values are nil, t, `head', `last', an integer or a predicate.
1295 See Info node `(gnus)Customizing Articles' and Info node
1296 `(gnus)X-Face' for details."
1297 :group 'gnus-article-treat
1299 :link '(custom-manual "(gnus)Customizing Articles")
1300 :link '(custom-manual "(gnus)X-Face")
1301 :type gnus-article-treat-head-custom)
1302 (put 'gnus-treat-display-face 'highlight t)
1304 (defcustom gnus-treat-display-smileys
1305 (if (and (not noninteractive)
1306 (or (and (featurep 'xemacs)
1308 (gnus-image-type-available-p 'xpm)
1309 (gnus-image-type-available-p 'pbm)
1310 (and (not (featurep 'xemacs))
1312 (module-installed-p 'smiley-mule))))
1316 Valid values are nil, t, `head', `last', an integer or a predicate.
1317 See Info node `(gnus)Customizing Articles' and Info node
1318 `(gnus)Smileys' for details."
1319 :group 'gnus-article-treat
1321 :link '(custom-manual "(gnus)Customizing Articles")
1322 :link '(custom-manual "(gnus)Smileys")
1323 :type gnus-article-treat-custom)
1324 (put 'gnus-treat-display-smileys 'highlight t)
1326 (defcustom gnus-treat-from-picon
1327 (if (and (gnus-image-type-available-p 'xpm)
1328 (gnus-picons-installed-p))
1330 "Display picons in the From header.
1331 Valid values are nil, t, `head', `last', an integer or a predicate.
1332 See Info node `(gnus)Customizing Articles' and Info node
1333 `(gnus)Picons' for details."
1334 :group 'gnus-article-treat
1336 :link '(custom-manual "(gnus)Customizing Articles")
1337 :link '(custom-manual "(gnus)Picons")
1338 :type gnus-article-treat-head-custom)
1339 (put 'gnus-treat-from-picon 'highlight t)
1341 (defcustom gnus-treat-mail-picon
1342 (if (and (gnus-image-type-available-p 'xpm)
1343 (gnus-picons-installed-p))
1345 "Display picons in To and Cc headers.
1346 Valid values are nil, t, `head', `last', an integer or a predicate.
1347 See Info node `(gnus)Customizing Articles' and Info node
1348 `(gnus)Picons' for details."
1349 :group 'gnus-article-treat
1351 :link '(custom-manual "(gnus)Customizing Articles")
1352 :link '(custom-manual "(gnus)Picons")
1353 :type gnus-article-treat-head-custom)
1354 (put 'gnus-treat-mail-picon 'highlight t)
1356 (defcustom gnus-treat-newsgroups-picon
1357 (if (and (gnus-image-type-available-p 'xpm)
1358 (gnus-picons-installed-p))
1360 "Display picons in the Newsgroups and Followup-To headers.
1361 Valid values are nil, t, `head', `last', an integer or a predicate.
1362 See Info node `(gnus)Customizing Articles' and Info node
1363 `(gnus)Picons' for details."
1364 :group 'gnus-article-treat
1366 :link '(custom-manual "(gnus)Customizing Articles")
1367 :link '(custom-manual "(gnus)Picons")
1368 :type gnus-article-treat-head-custom)
1369 (put 'gnus-treat-newsgroups-picon 'highlight t)
1371 (defcustom gnus-treat-body-boundary
1372 (if (or gnus-treat-newsgroups-picon
1373 gnus-treat-mail-picon
1374 gnus-treat-from-picon)
1376 "Draw a boundary at the end of the headers.
1377 Valid values are nil and `head'.
1378 See Info node `(gnus)Customizing Articles' for details."
1380 :group 'gnus-article-treat
1381 :link '(custom-manual "(gnus)Customizing Articles")
1382 :type gnus-article-treat-head-custom)
1384 (defcustom gnus-treat-capitalize-sentences nil
1385 "Capitalize sentence-starting words.
1386 Valid values are nil, t, `head', `last', an integer or a predicate.
1387 See Info node `(gnus)Customizing Articles' for details."
1389 :group 'gnus-article-treat
1390 :link '(custom-manual "(gnus)Customizing Articles")
1391 :type gnus-article-treat-custom)
1393 (defcustom gnus-treat-wash-html nil
1395 Valid values are nil, t, `head', `last', an integer or a predicate.
1396 See Info node `(gnus)Customizing Articles' for details."
1397 :group 'gnus-article-treat
1398 :link '(custom-manual "(gnus)Customizing Articles")
1399 :type gnus-article-treat-custom)
1401 (defcustom gnus-treat-fill-long-lines nil
1403 Valid values are nil, t, `head', `last', an integer or a predicate.
1404 See Info node `(gnus)Customizing Articles' for details."
1405 :group 'gnus-article-treat
1406 :link '(custom-manual "(gnus)Customizing Articles")
1407 :type gnus-article-treat-custom)
1409 (defcustom gnus-treat-play-sounds nil
1411 Valid values are nil, t, `head', `last', an integer or a predicate.
1412 See Info node `(gnus)Customizing Articles' for details."
1414 :group 'gnus-article-treat
1415 :link '(custom-manual "(gnus)Customizing Articles")
1416 :type gnus-article-treat-custom)
1418 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
1419 "Decode an article as `default-mime-charset'. For instance, if you want to
1420 attempt to decode an article even if the value of `gnus-show-mime' is nil,
1421 you could set this variable to something like: nil for don't decode, t for
1422 decode the body, '(or header t) for the whole article, etc."
1423 :group 'gnus-article-treat
1424 :type '(radio (const :tag "Off" nil)
1425 (const :tag "Decode body" t)
1426 (const :tag "Decode all" (or head t))))
1428 (defcustom gnus-treat-translate nil
1429 "Translate articles from one language to another.
1430 Valid values are nil, t, `head', `last', an integer or a predicate.
1431 See Info node `(gnus)Customizing Articles' for details."
1433 :group 'gnus-article-treat
1434 :link '(custom-manual "(gnus)Customizing Articles")
1435 :type gnus-article-treat-custom)
1437 (defcustom gnus-treat-x-pgp-sig nil
1439 To automatically treat X-PGP-Sig, set it to head.
1440 Valid values are nil, t, `head', `last', an integer or a predicate.
1441 See Info node `(gnus)Customizing Articles' for details."
1442 :group 'gnus-article-treat
1443 :group 'mime-security
1444 :type gnus-article-treat-custom)
1446 (defcustom gnus-treat-monafy nil
1447 "Display body part with mona font.
1448 Valid values are nil, t, `head', `last', an integer or a predicate.
1449 See Info node `(gnus)Customizing Articles' for details."
1450 :group 'gnus-article-treat
1451 :group 'mime-security
1452 :link '(custom-manual "(gnus)Customizing Articles")
1453 :type gnus-article-treat-custom)
1455 (defvar gnus-article-encrypt-protocol-alist
1456 '(("PGP" . mml2015-self-encrypt)))
1458 ;; Set to nil if more than one protocol added to
1459 ;; gnus-article-encrypt-protocol-alist.
1460 (defcustom gnus-article-encrypt-protocol "PGP"
1461 "The protocol used for encrypt articles.
1462 It is a string, such as \"PGP\". If nil, ask user."
1464 :group 'mime-security)
1466 (defvar gnus-article-wash-function nil
1467 "Function used for converting HTML into text.")
1469 (defcustom gnus-use-idna (and (condition-case nil (require 'idna) (file-error))
1470 (mm-coding-system-p 'utf-8)
1471 (executable-find idna-program))
1472 "Whether IDNA decoding of headers is used when viewing messages.
1473 This requires GNU Libidn, and by default only enabled if it is found."
1474 :group 'gnus-article-headers
1477 (defcustom gnus-article-over-scroll nil
1478 "If non-nil, allow scrolling the article buffer even when there no more text."
1479 :group 'gnus-article
1482 ;;; Internal variables
1484 (defvar gnus-english-month-names
1485 '("January" "February" "March" "April" "May" "June" "July" "August"
1486 "September" "October" "November" "December"))
1488 (defvar gnus-button-regexp nil)
1489 (defvar gnus-button-marker-list nil)
1490 ;; Regexp matching any of the regexps from `gnus-button-alist'.
1492 (defvar gnus-button-last nil)
1493 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
1495 (defvar article-goto-body-goes-to-point-min-p nil)
1496 (defvar gnus-article-wash-types nil)
1497 (defvar gnus-article-emphasis-alist nil)
1498 (defvar gnus-article-image-alist nil)
1500 (defvar gnus-article-mime-handle-alist-1 nil)
1501 (defvar gnus-treatment-function-alist
1502 '((gnus-treat-decode-article-as-default-mime-charset
1503 gnus-article-decode-article-as-default-mime-charset)
1504 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1505 (gnus-treat-monafy gnus-article-monafy)
1506 (gnus-treat-strip-banner gnus-article-strip-banner)
1507 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1508 (gnus-treat-buttonize gnus-article-add-buttons)
1509 (gnus-treat-fill-article gnus-article-fill-cited-article)
1510 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1511 (gnus-treat-strip-cr gnus-article-remove-cr)
1512 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1513 (gnus-treat-date-ut gnus-article-date-ut)
1514 (gnus-treat-date-local gnus-article-date-local)
1515 (gnus-treat-date-english gnus-article-date-english)
1516 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1517 (gnus-treat-date-original gnus-article-date-original)
1518 (gnus-treat-date-user-defined gnus-article-date-user)
1519 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1520 (gnus-treat-display-face gnus-article-display-face)
1521 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1522 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1523 (gnus-treat-hide-signature gnus-article-hide-signature)
1524 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1525 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1526 (gnus-treat-strip-pem gnus-article-hide-pem)
1527 (gnus-treat-from-picon gnus-treat-from-picon)
1528 (gnus-treat-mail-picon gnus-treat-mail-picon)
1529 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1530 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1531 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1532 (gnus-treat-strip-trailing-blank-lines
1533 gnus-article-remove-trailing-blank-lines)
1534 (gnus-treat-strip-leading-blank-lines
1535 gnus-article-strip-leading-blank-lines)
1536 (gnus-treat-strip-multiple-blank-lines
1537 gnus-article-strip-multiple-blank-lines)
1538 (gnus-treat-overstrike gnus-article-treat-overstrike)
1539 (gnus-treat-ansi-sequences gnus-article-treat-ansi-sequences)
1540 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1541 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1542 ;; Displaying X-Face should be done after unfolding headers
1543 ;; to protect bitmap lines.
1544 (gnus-treat-display-x-face gnus-article-display-x-face)
1545 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1546 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1547 (gnus-treat-display-smileys gnus-treat-smiley)
1548 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1549 (gnus-treat-wash-html gnus-article-wash-html)
1550 (gnus-treat-emphasize gnus-article-emphasize)
1551 (gnus-treat-hide-citation gnus-article-hide-citation)
1552 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1553 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1554 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1555 (gnus-treat-play-sounds gnus-earcon-display)))
1557 (defvar gnus-article-mime-handle-alist nil)
1558 (defvar article-lapsed-timer nil)
1559 (defvar gnus-article-current-summary nil)
1561 (defvar gnus-article-mode-syntax-table
1562 (let ((table (copy-syntax-table text-mode-syntax-table)))
1563 ;; This causes the citation match run O(2^n).
1564 ;; (modify-syntax-entry ?- "w" table)
1565 (modify-syntax-entry ?> ")<" table)
1566 (modify-syntax-entry ?< "(>" table)
1567 ;; make M-. in article buffers work for `foo' strings
1568 (modify-syntax-entry ?' " " table)
1569 (modify-syntax-entry ?` " " table)
1571 "Syntax table used in article mode buffers.
1572 Initialized from `text-mode-syntax-table.")
1574 (defvar gnus-save-article-buffer nil)
1576 (defvar gnus-article-mode-line-format-alist
1577 (nconc '((?w (gnus-article-wash-status) ?s)
1578 (?m (gnus-article-mime-part-status) ?s))
1579 gnus-summary-mode-line-format-alist))
1581 (defvar gnus-number-of-articles-to-be-saved nil)
1583 (defvar gnus-inhibit-hiding nil)
1585 (defvar gnus-article-edit-mode nil)
1587 ;;; Macros for dealing with the article buffer.
1589 (defmacro gnus-with-article-headers (&rest forms)
1591 (set-buffer gnus-article-buffer)
1593 (let ((buffer-read-only nil)
1594 (inhibit-point-motion-hooks t)
1595 (case-fold-search t))
1596 (article-narrow-to-head)
1599 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1600 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1602 (defmacro gnus-with-article-buffer (&rest forms)
1604 (set-buffer gnus-article-buffer)
1605 (let ((buffer-read-only nil))
1608 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1609 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1611 (defun gnus-article-goto-header (header)
1612 "Go to HEADER, which is a regular expression."
1613 (re-search-forward (concat "^\\(" header "\\):") nil t))
1615 (defsubst gnus-article-hide-text (b e props)
1616 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1617 (gnus-add-text-properties-when 'article-type nil b e props)
1618 (when (memq 'intangible props)
1620 (max (1- b) (point-min))
1621 b 'intangible (cddr (memq 'intangible props)))))
1623 (defsubst gnus-article-unhide-text (b e)
1624 "Remove hidden text properties from region between B and E."
1625 (remove-text-properties b e gnus-hidden-properties)
1626 (when (memq 'intangible gnus-hidden-properties)
1627 (put-text-property (max (1- b) (point-min))
1628 b 'intangible nil)))
1630 (defun gnus-article-hide-text-type (b e type)
1631 "Hide text of TYPE between B and E."
1632 (gnus-add-wash-type type)
1633 (gnus-article-hide-text
1634 b e (cons 'article-type (cons type gnus-hidden-properties))))
1636 (defun gnus-article-unhide-text-type (b e type)
1637 "Unhide text of TYPE between B and E."
1638 (gnus-delete-wash-type type)
1639 (remove-text-properties
1640 b e (cons 'article-type (cons type gnus-hidden-properties)))
1641 (when (memq 'intangible gnus-hidden-properties)
1642 (put-text-property (max (1- b) (point-min))
1643 b 'intangible nil)))
1645 (defun gnus-article-hide-text-of-type (type)
1646 "Hide text of TYPE in the current buffer."
1648 (let ((b (point-min))
1650 (while (setq b (text-property-any b e 'article-type type))
1651 (add-text-properties b (incf b) gnus-hidden-properties)))))
1653 (defun gnus-article-delete-text-of-type (type)
1654 "Delete text of TYPE in the current buffer."
1656 (let ((b (point-min)))
1657 (while (setq b (text-property-any b (point-max) 'article-type type))
1659 b (or (text-property-not-all b (point-max) 'article-type type)
1662 (defun gnus-article-delete-invisible-text ()
1663 "Delete all invisible text in the current buffer."
1665 (let ((b (point-min)))
1666 (while (setq b (text-property-any b (point-max) 'invisible t))
1668 b (or (text-property-not-all b (point-max) 'invisible t)
1671 (defun gnus-article-text-type-exists-p (type)
1672 "Say whether any text of type TYPE exists in the buffer."
1673 (text-property-any (point-min) (point-max) 'article-type type))
1675 (defsubst gnus-article-header-rank ()
1676 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1677 (let ((list gnus-sorted-header-list)
1680 (if (looking-at (car list))
1682 (setq list (cdr list))
1686 (defun article-hide-headers (&optional arg delete)
1687 "Hide unwanted headers and possibly sort them as well."
1688 (interactive (gnus-article-hidden-arg))
1689 ;; Lars said that this function might be inhibited.
1690 (if (gnus-article-check-hidden-text 'headers arg)
1692 ;; Show boring headers as well.
1693 (gnus-article-show-hidden-text 'boring-headers)
1694 (when (eq 1 (point-min))
1695 (set-window-start (get-buffer-window (current-buffer)) 1)))
1696 (unless gnus-inhibit-hiding
1699 (let ((inhibit-read-only t)
1700 (case-fold-search t)
1701 (max (1+ (length gnus-sorted-header-list)))
1702 (ignored (when (not gnus-visible-headers)
1703 (cond ((stringp gnus-ignored-headers)
1704 gnus-ignored-headers)
1705 ((listp gnus-ignored-headers)
1706 (mapconcat 'identity gnus-ignored-headers
1709 (cond ((stringp gnus-visible-headers)
1710 gnus-visible-headers)
1711 ((and gnus-visible-headers
1712 (listp gnus-visible-headers))
1713 (mapconcat 'identity gnus-visible-headers "\\|"))))
1714 (inhibit-point-motion-hooks t)
1716 ;; First we narrow to just the headers.
1717 (article-narrow-to-head)
1718 ;; Hide any "From " lines at the beginning of (mail) articles.
1719 (while (looking-at "From ")
1723 (delete-region (point-min) (point))
1724 (gnus-article-hide-text (point-min) (point)
1725 (nconc (list 'article-type 'headers)
1726 gnus-hidden-properties))))
1727 ;; Then treat the rest of the header lines.
1728 ;; Then we use the two regular expressions
1729 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1730 ;; select which header lines is to remain visible in the
1732 (while (re-search-forward "^[^ \t:]*:" nil t)
1734 ;; Mark the rank of the header.
1736 (point) (1+ (point)) 'message-rank
1737 (if (or (and visible (looking-at visible))
1739 (not (looking-at ignored))))
1740 (gnus-article-header-rank)
1743 (message-sort-headers-1)
1744 (when (setq beg (text-property-any
1745 (point-min) (point-max) 'message-rank (+ 2 max)))
1746 ;; We delete or make invisible the unwanted headers.
1747 (gnus-add-wash-type 'headers)
1750 (add-text-properties
1751 (point-min) (+ 5 (point-min))
1752 '(article-type headers dummy-invisible t))
1753 (delete-region beg (point-max)))
1754 (gnus-article-hide-text-type beg (point-max) 'headers)))))))))
1756 (defun article-hide-boring-headers (&optional arg)
1757 "Toggle hiding of headers that aren't very interesting.
1758 If given a negative prefix, always show; if given a positive prefix,
1760 (interactive (gnus-article-hidden-arg))
1761 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1762 (not gnus-show-all-headers))
1765 (let ((buffer-read-only nil)
1766 (list gnus-boring-article-headers)
1767 (inhibit-point-motion-hooks t)
1769 (article-narrow-to-head)
1771 (setq elem (pop list))
1772 (goto-char (point-min))
1774 ;; Hide empty headers.
1776 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1778 (gnus-article-hide-text-type
1782 (if (re-search-forward "^[^ \t]" nil t)
1786 ;; Hide boring Newsgroups header.
1787 ((eq elem 'newsgroups)
1788 (when (gnus-string-equal
1789 (gnus-fetch-field "newsgroups")
1790 (gnus-group-real-name
1791 (if (boundp 'gnus-newsgroup-name)
1794 (gnus-article-hide-header "newsgroups")))
1795 ((eq elem 'to-address)
1796 (let ((to (message-fetch-field "to"))
1798 (gnus-parameter-to-address
1799 (if (boundp 'gnus-newsgroup-name)
1800 gnus-newsgroup-name ""))))
1801 (when (and to to-address
1804 ;; only one address in To
1805 (nth 1 (mail-extract-address-components to))
1807 (gnus-article-hide-header "to"))))
1809 (let ((to (message-fetch-field "to"))
1811 (gnus-parameter-to-list
1812 (if (boundp 'gnus-newsgroup-name)
1813 gnus-newsgroup-name ""))))
1814 (when (and to to-list
1817 ;; only one address in To
1818 (nth 1 (mail-extract-address-components to))
1820 (gnus-article-hide-header "to"))))
1822 (let ((cc (message-fetch-field "cc"))
1824 (gnus-parameter-to-list
1825 (if (boundp 'gnus-newsgroup-name)
1826 gnus-newsgroup-name ""))))
1827 (when (and cc to-list
1830 ;; only one address in CC
1831 (nth 1 (mail-extract-address-components cc))
1833 (gnus-article-hide-header "cc"))))
1834 ((eq elem 'followup-to)
1835 (when (gnus-string-equal
1836 (message-fetch-field "followup-to")
1837 (message-fetch-field "newsgroups"))
1838 (gnus-article-hide-header "followup-to")))
1839 ((eq elem 'reply-to)
1840 (if (gnus-group-find-parameter
1841 gnus-newsgroup-name 'broken-reply-to)
1842 (gnus-article-hide-header "reply-to")
1843 (let ((from (message-fetch-field "from"))
1844 (reply-to (message-fetch-field "reply-to")))
1851 (lambda (x) (downcase (cadr x)))
1852 (mail-extract-address-components from t))
1855 (lambda (x) (downcase (cadr x)))
1856 (mail-extract-address-components reply-to t))
1858 (gnus-article-hide-header "reply-to")))))
1860 (let ((date (message-fetch-field "date")))
1862 (< (days-between (current-time-string) date)
1864 (gnus-article-hide-header "date"))))
1866 (let ((to (message-fetch-field "to"))
1867 (cc (message-fetch-field "cc")))
1868 (when (> (length to) 1024)
1869 (gnus-article-hide-header "to"))
1870 (when (> (length cc) 1024)
1871 (gnus-article-hide-header "cc"))))
1875 (goto-char (point-min))
1876 (while (re-search-forward "^to:" nil t)
1877 (setq to-count (1+ to-count)))
1878 (when (> to-count 1)
1879 (while (> to-count 0)
1880 (goto-char (point-min))
1882 (re-search-forward "^to:" nil nil to-count)
1884 (narrow-to-region (point) (point-max))
1885 (gnus-article-hide-header "to"))
1886 (setq to-count (1- to-count))))
1887 (goto-char (point-min))
1888 (while (re-search-forward "^cc:" nil t)
1889 (setq cc-count (1+ cc-count)))
1890 (when (> cc-count 1)
1891 (while (> cc-count 0)
1892 (goto-char (point-min))
1894 (re-search-forward "^cc:" nil nil cc-count)
1896 (narrow-to-region (point) (point-max))
1897 (gnus-article-hide-header "cc"))
1898 (setq cc-count (1- cc-count)))))))))))))
1900 (defun gnus-article-hide-header (header)
1902 (goto-char (point-min))
1903 (when (re-search-forward (concat "^" header ":") nil t)
1904 (gnus-article-hide-text-type
1908 (if (re-search-forward "^[^ \t]" nil t)
1913 (defvar gnus-article-normalized-header-length 40
1914 "Length of normalized headers.")
1916 (defun article-normalize-headers ()
1917 "Make all header lines 40 characters long."
1919 (let ((buffer-read-only nil)
1923 (article-narrow-to-head)
1926 ((< (setq column (- (point-at-eol) (point)))
1927 gnus-article-normalized-header-length)
1929 (insert (make-string
1930 (- gnus-article-normalized-header-length column)
1932 ((> column gnus-article-normalized-header-length)
1933 (gnus-put-text-property
1935 (forward-char gnus-article-normalized-header-length)
1942 (forward-line 1))))))
1944 (defun article-treat-dumbquotes ()
1945 "Translate M****s*** sm*rtq**t*s and other symbols into proper text.
1946 Note that this function guesses whether a character is a sm*rtq**t* or
1947 not, so it should only be used interactively.
1949 Sm*rtq**t*s are M****s***'s unilateral extension to the
1950 iso-8859-1 character map in an attempt to provide more quoting
1951 characters. If you see something like \\222 or \\264 where
1952 you're expecting some kind of apostrophe or quotation mark, then
1955 (article-translate-strings gnus-article-dumbquotes-map))
1957 (defun article-translate-characters (from to)
1958 "Translate all characters in the body of the article according to FROM and TO.
1959 FROM is a string of characters to translate from; to is a string of
1960 characters to translate to."
1962 (when (article-goto-body)
1963 (let ((buffer-read-only nil)
1964 (x (make-string 225 ?x))
1966 (while (< (incf i) (length x))
1969 (while (< i (length from))
1970 (aset x (aref from i) (aref to i))
1972 (translate-region (point) (point-max) x)))))
1974 (defun article-translate-strings (map)
1975 "Translate all string in the body of the article according to MAP.
1976 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1978 (when (article-goto-body)
1979 (let ((buffer-read-only nil)
1981 (while (setq elem (pop map))
1983 (while (search-forward (car elem) nil t)
1984 (replace-match (cadr elem)))))))))
1986 (defun article-treat-overstrike ()
1987 "Translate overstrikes into bold text."
1990 (when (article-goto-body)
1991 (let ((buffer-read-only nil))
1992 (while (search-forward "\b" nil t)
1993 (let ((next (char-after))
1997 previous (char-after))
2001 ;; We do the boldification/underlining by hiding the
2002 ;; overstrikes and putting the proper text property
2006 (gnus-article-hide-text-type start (point) 'overstrike)
2007 (put-text-property (point) end 'face 'bold))
2009 (gnus-article-hide-text-type
2010 (1- (point)) (1+ (point)) 'overstrike)
2012 start (1- (point)) 'face 'underline))
2014 (gnus-article-hide-text-type start (point) 'overstrike)
2016 (point) end 'face 'underline)))))))))
2018 (defun article-treat-ansi-sequences ()
2019 "Translate ANSI SGR control sequences into overlays or extents."
2022 (when (article-goto-body)
2023 (let ((buffer-read-only nil))
2024 (ansi-color-apply-on-region (point) (point-max))))))
2026 (defun gnus-article-treat-unfold-headers ()
2027 "Unfold folded message headers.
2028 Only the headers that fit into the current window width will be
2031 (gnus-with-article-headers
2035 (mail-header-narrow-to-field)
2036 (let ((header (buffer-string)))
2039 (goto-char (point-min))
2040 (while (re-search-forward "\n[\t ]" nil t)
2041 (replace-match " " t t)))
2042 (setq length (- (point-max) (point-min) 1)))
2043 (when (< length (window-width))
2044 (while (re-search-forward "\n[\t ]" nil t)
2045 (replace-match " " t t)))
2046 (goto-char (point-max)))))))
2048 (defun gnus-article-treat-fold-headers ()
2049 "Fold message headers."
2051 (gnus-with-article-headers
2054 (mail-header-narrow-to-field)
2055 (mail-header-fold-field)
2056 (goto-char (point-max))))))
2058 (defun gnus-treat-smiley ()
2059 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
2061 (unless (featurep 'xemacs)
2062 (when (and (not gnus-article-should-use-smiley-mule)
2063 gnus-article-smiley-mule-loaded-p)
2064 (load "smiley" nil t)
2065 (setq gnus-article-smiley-mule-loaded-p nil))
2066 (when (and gnus-article-should-use-smiley-mule
2067 (not gnus-article-smiley-mule-loaded-p))
2068 (load "smiley-mule" nil t)
2069 (setq gnus-article-smiley-mule-loaded-p t)))
2070 (gnus-with-article-buffer
2071 (if (memq 'smiley gnus-article-wash-types)
2072 (gnus-delete-images 'smiley)
2074 (let ((images (smiley-region (point) (point-max))))
2076 (gnus-add-wash-type 'smiley)
2077 (dolist (image images)
2078 (gnus-add-image 'smiley image)))))))
2080 (defun gnus-article-remove-images ()
2081 "Remove all images from the article buffer."
2083 (gnus-with-article-buffer
2084 (dolist (elem gnus-article-image-alist)
2085 (gnus-delete-images (car elem)))))
2087 (defun gnus-article-treat-fold-newsgroups ()
2088 "Unfold folded message headers.
2089 Only the headers that fit into the current window width will be
2092 (gnus-with-article-headers
2093 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2095 (mail-header-narrow-to-field)
2096 (while (re-search-forward ", *" nil t)
2097 (replace-match ", " t t))
2098 (mail-header-fold-field)
2099 (goto-char (point-max))))))
2101 (defun gnus-article-treat-body-boundary ()
2102 "Place a boundary line at the end of the headers."
2104 (when (and gnus-body-boundary-delimiter
2105 (> (length gnus-body-boundary-delimiter) 0))
2106 (gnus-with-article-headers
2107 (goto-char (point-max))
2108 (let ((start (point)))
2109 (insert "X-Boundary: ")
2110 (gnus-add-text-properties start (point) '(invisible t intangible t))
2112 (while (>= (1- (window-width)) (length str))
2113 (setq str (concat str gnus-body-boundary-delimiter)))
2114 (substring str 0 (1- (window-width))))
2116 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2118 (defun article-fill-long-lines ()
2119 "Fill lines that are wider than the window width."
2122 (let ((buffer-read-only nil)
2123 (width (window-width (get-buffer-window (current-buffer)))))
2126 (let ((adaptive-fill-mode nil)) ;Why? -sm
2129 (when (>= (current-column) (min fill-column width))
2130 (narrow-to-region (min (1+ (point)) (point-max))
2132 (let ((goback (point-marker)))
2133 (fill-paragraph nil)
2134 (goto-char (marker-position goback)))
2136 (forward-line 1)))))))
2138 (defun article-capitalize-sentences ()
2139 "Capitalize the first word in each sentence."
2142 (let ((buffer-read-only nil)
2143 (paragraph-start "^[\n\^L]"))
2147 (forward-sentence)))))
2149 (defun article-remove-cr ()
2150 "Remove trailing CRs and then translate remaining CRs into LFs."
2153 (let ((buffer-read-only nil))
2154 (goto-char (point-min))
2155 (while (re-search-forward "\r+$" nil t)
2156 (replace-match "" t t))
2157 (goto-char (point-min))
2158 (while (search-forward "\r" nil t)
2159 (replace-match "\n" t t)))))
2161 (defun article-remove-trailing-blank-lines ()
2162 "Remove all trailing blank lines from the article."
2165 (let ((buffer-read-only nil))
2166 (goto-char (point-max))
2170 (while (and (not (bobp))
2171 (looking-at "^[ \t]*$")
2172 (not (gnus-annotation-in-region-p
2173 (point) (point-at-eol))))
2179 (defvar gnus-face-properties-alist))
2181 (defun article-display-face ()
2182 "Display any Face headers in the header."
2184 (let ((wash-face-p buffer-read-only))
2185 (gnus-with-article-headers
2186 ;; When displaying parts, this function can be called several times on
2187 ;; the same article, without any intended toggle semantic (as typing `W
2188 ;; D d' would have). So face deletion must occur only when we come from
2189 ;; an interactive command, that is when the *Article* buffer is
2191 (if (and wash-face-p (memq 'face gnus-article-wash-types))
2192 (gnus-delete-images 'face)
2195 (when (and wash-face-p
2197 (goto-char (point-min))
2198 (not (re-search-forward "^Face:[\t ]*" nil t)))
2199 (gnus-buffer-live-p gnus-original-article-buffer))
2200 (set-buffer gnus-original-article-buffer))
2202 (mail-narrow-to-head)
2203 (while (gnus-article-goto-header "Face")
2204 (setq faces (nconc faces (list (mail-header-field-value)))))))
2205 (while (setq face (pop faces))
2206 (let ((png (gnus-convert-face-to-png face))
2210 (apply 'gnus-create-image png 'png t
2211 (cdr (assq 'png gnus-face-properties-alist))))
2212 (gnus-article-goto-header "from")
2214 (insert "From: [no `from' set]\n")
2216 (gnus-add-wash-type 'face)
2217 (gnus-add-image 'face image)
2218 (gnus-put-image image nil 'face))))))
2221 (defun article-display-x-face (&optional force)
2222 "Look for an X-Face header and display it if present."
2223 (interactive (list 'force))
2224 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2225 (gnus-with-article-headers
2226 ;; Delete the old process, if any.
2227 (when (process-status "article-x-face")
2228 (delete-process "article-x-face"))
2229 ;; See the comment in `article-display-face'.
2230 (if (and wash-face-p (memq 'xface gnus-article-wash-types))
2231 ;; We have already displayed X-Faces, so we remove them
2233 (gnus-delete-images 'xface)
2235 (let (x-faces from face)
2237 (when (and wash-face-p
2239 (goto-char (point-min))
2240 (not (re-search-forward
2241 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2242 (gnus-buffer-live-p gnus-original-article-buffer))
2243 ;; If type `W f', use gnus-original-article-buffer,
2244 ;; otherwise use the current buffer because displaying
2245 ;; RFC822 parts calls this function too.
2246 (set-buffer gnus-original-article-buffer))
2248 (mail-narrow-to-head)
2249 (while (gnus-article-goto-header "X-Face")
2250 (push (mail-header-field-value) x-faces))
2251 (setq from (message-fetch-field "from"))))
2252 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2253 ;; single external face.
2254 (when (stringp gnus-article-x-face-command)
2255 (setq x-faces (list (car x-faces))))
2256 (while (and (setq face (pop x-faces))
2257 gnus-article-x-face-command
2259 ;; Check whether this face is censored.
2260 (not gnus-article-x-face-too-ugly)
2261 (and gnus-article-x-face-too-ugly from
2262 (not (string-match gnus-article-x-face-too-ugly
2264 ;; We display the face.
2265 (cond ((stringp gnus-article-x-face-command)
2266 ;; The command is a string, so we interpret the command
2267 ;; as a, well, command, and fork it off.
2268 (let ((process-connection-type nil))
2269 (process-kill-without-query
2271 "article-x-face" nil shell-file-name
2272 shell-command-switch gnus-article-x-face-command))
2275 (process-send-region "article-x-face"
2276 (point-min) (point-max)))
2277 (process-send-eof "article-x-face")))
2278 ((functionp gnus-article-x-face-command)
2279 ;; The command is a lisp function, so we call it.
2280 (funcall gnus-article-x-face-command face))
2282 (error "%s is not a function"
2283 gnus-article-x-face-command)))))))))
2285 (defun article-decode-mime-words ()
2286 "Decode all MIME-encoded words in the article."
2288 (gnus-with-article-buffer
2289 (let ((inhibit-point-motion-hooks t)
2290 (mail-parse-charset gnus-newsgroup-charset)
2291 (mail-parse-ignored-charsets
2292 (with-current-buffer gnus-summary-buffer
2293 gnus-newsgroup-ignored-charsets)))
2294 (mail-decode-encoded-word-region (point-min) (point-max)))))
2296 (defun article-decode-charset (&optional prompt)
2297 "Decode charset-encoded text in the article.
2298 If PROMPT (the prefix), prompt for a coding system to use."
2300 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2302 (mail-parse-charset gnus-newsgroup-charset)
2303 (mail-parse-ignored-charsets
2304 (save-excursion (condition-case nil
2305 (set-buffer gnus-summary-buffer)
2307 gnus-newsgroup-ignored-charsets))
2308 ct cte ctl charset format)
2311 (article-narrow-to-head)
2312 (setq ct (message-fetch-field "Content-Type" t)
2313 cte (message-fetch-field "Content-Transfer-Encoding" t)
2314 ctl (and ct (ignore-errors
2315 (mail-header-parse-content-type ct)))
2318 (mm-read-coding-system "Charset to decode: "))
2320 (mail-content-type-get ctl 'charset)))
2321 format (and ctl (mail-content-type-get ctl 'format)))
2323 (setq cte (mail-header-strip cte)))
2324 (if (and ctl (not (string-match "/" (car ctl))))
2326 (goto-char (point-max)))
2329 (narrow-to-region (point) (point-max))
2330 (when (and (eq mail-parse-charset 'gnus-decoded)
2331 (eq (mm-body-7-or-8) '8bit))
2332 ;; The text code could have been decoded.
2333 (setq charset mail-parse-charset))
2334 (when (and (or (not ctl)
2335 (equal (car ctl) "text/plain"))
2336 (not format)) ;; article with format will decode later.
2338 charset (and cte (intern (downcase
2339 (gnus-strip-whitespace cte))))
2342 (defun article-decode-encoded-words ()
2343 "Remove encoded-word encoding from headers."
2344 (let (buffer-read-only)
2345 (let ((charset (save-excursion
2346 (set-buffer gnus-summary-buffer)
2347 default-mime-charset)))
2348 (mime-decode-header-in-buffer charset))))
2350 (defun article-decode-group-name ()
2351 "Decode group names in `Newsgroups:'."
2352 (let ((inhibit-point-motion-hooks t)
2354 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2355 (when (and (or gnus-group-name-charset-method-alist
2356 gnus-group-name-charset-group-alist)
2357 (gnus-buffer-live-p gnus-original-article-buffer))
2359 (article-narrow-to-head)
2360 (with-current-buffer gnus-original-article-buffer
2361 (goto-char (point-min)))
2362 (while (re-search-forward
2363 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2364 (replace-match (save-match-data
2365 (gnus-decode-newsgroups
2366 ;; XXX how to use data in article buffer?
2367 (with-current-buffer gnus-original-article-buffer
2369 "^Newsgroups:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2372 gnus-newsgroup-name method))
2374 (goto-char (point-min))
2375 (with-current-buffer gnus-original-article-buffer
2376 (goto-char (point-min)))
2377 (while (re-search-forward
2378 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]" nil t)
2379 (replace-match (save-match-data
2380 (gnus-decode-newsgroups
2381 ;; XXX how to use data in article buffer?
2382 (with-current-buffer gnus-original-article-buffer
2384 "^Followup-To:\\(\\(.\\|\n[\t ]\\)*\\)\n[^\t ]"
2387 gnus-newsgroup-name method))
2390 (autoload 'idna-to-unicode "idna")
2392 (defun article-decode-idna-rhs ()
2393 "Decode IDNA strings in RHS in From:, To: and Cc: headers in current buffer."
2396 (let ((inhibit-point-motion-hooks t)
2398 (article-narrow-to-head)
2399 (goto-char (point-min))
2400 (while (re-search-forward "@.*\\(xn--[-A-Za-z0-9.]*\\)[ \t\n\r,>]" nil t)
2402 (when (save-match-data
2403 (and (setq ace (match-string 1))
2405 (and (re-search-backward "^[^ \t]" nil t)
2406 (looking-at "From\\|To\\|Cc")))
2407 (setq unicode (idna-to-unicode ace))))
2408 (unless (string= ace unicode)
2409 (replace-match unicode nil nil nil 1)))))))))
2411 (defun article-de-quoted-unreadable (&optional force read-charset)
2412 "Translate a quoted-printable-encoded article.
2413 If FORCE, decode the article whether it is marked as quoted-printable
2415 If READ-CHARSET, ask for a coding system."
2416 (interactive (list 'force current-prefix-arg))
2418 (let ((buffer-read-only nil) type charset)
2419 (if (gnus-buffer-live-p gnus-original-article-buffer)
2420 (with-current-buffer gnus-original-article-buffer
2422 (gnus-fetch-field "content-transfer-encoding"))
2423 (let* ((ct (gnus-fetch-field "content-type"))
2426 (mail-header-parse-content-type ct)))))
2427 (setq charset (and ctl
2428 (mail-content-type-get ctl 'charset)))
2429 (if (stringp charset)
2430 (setq charset (intern (downcase charset)))))))
2432 (setq charset (mm-read-coding-system "Charset: " charset)))
2434 (setq charset gnus-newsgroup-charset))
2436 (and type (let ((case-fold-search t))
2437 (string-match "quoted-printable" type))))
2439 (quoted-printable-decode-region
2440 (point) (point-max) (mm-charset-to-coding-system charset))))))
2442 (defun article-de-base64-unreadable (&optional force read-charset)
2443 "Translate a base64 article.
2444 If FORCE, decode the article whether it is marked as base64 not.
2445 If READ-CHARSET, ask for a coding system."
2446 (interactive (list 'force current-prefix-arg))
2448 (let ((buffer-read-only nil) type charset)
2449 (if (gnus-buffer-live-p gnus-original-article-buffer)
2450 (with-current-buffer gnus-original-article-buffer
2452 (gnus-fetch-field "content-transfer-encoding"))
2453 (let* ((ct (gnus-fetch-field "content-type"))
2456 (mail-header-parse-content-type ct)))))
2457 (setq charset (and ctl
2458 (mail-content-type-get ctl 'charset)))
2459 (if (stringp charset)
2460 (setq charset (intern (downcase charset)))))))
2462 (setq charset (mm-read-coding-system "Charset: " charset)))
2464 (setq charset gnus-newsgroup-charset))
2466 (and type (let ((case-fold-search t))
2467 (string-match "base64" type))))
2470 (narrow-to-region (point) (point-max))
2471 (base64-decode-region (point-min) (point-max))
2472 (mm-decode-coding-region
2473 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2478 (defun article-decode-HZ ()
2479 "Translate a HZ-encoded article."
2483 (let ((buffer-read-only nil))
2484 (rfc1843-decode-region (point-min) (point-max)))))
2486 (defun article-unsplit-urls ()
2487 "Remove the newlines that some other mailers insert into URLs."
2490 (let ((buffer-read-only nil))
2491 (goto-char (point-min))
2492 (while (re-search-forward
2493 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2494 (replace-match "\\1\\3" t)))
2495 (when (interactive-p)
2496 (gnus-treat-article nil))))
2499 (defun article-wash-html (&optional read-charset)
2500 "Format an HTML article.
2501 If READ-CHARSET, ask for a coding system."
2504 (let ((buffer-read-only nil)
2506 (when (gnus-buffer-live-p gnus-original-article-buffer)
2507 (with-current-buffer gnus-original-article-buffer
2508 (let* ((ct (gnus-fetch-field "content-type"))
2511 (mail-header-parse-content-type ct)))))
2512 (setq charset (and ctl
2513 (mail-content-type-get ctl 'charset)))
2514 (when (stringp charset)
2515 (setq charset (intern (downcase charset)))))))
2517 (setq charset (mm-read-coding-system "Charset: " charset)))
2519 (setq charset gnus-newsgroup-charset))
2521 (save-window-excursion
2523 (narrow-to-region (point) (point-max))
2524 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2525 (entry (assq func mm-text-html-washer-alist)))
2527 (setq func (cdr entry)))
2532 (apply (car func) (cdr func))))))))))
2534 (defun gnus-article-wash-html-with-w3 ()
2535 "Wash the current buffer with w3."
2537 (let ((w3-strict-width (window-width))
2538 (url-standalone-mode t)
2539 (url-gateway-unplugged t)
2540 (w3-honor-stylesheets nil))
2542 (w3-region (point-min) (point-max))
2545 (defun gnus-article-wash-html-with-w3m ()
2546 "Wash the current buffer with emacs-w3m."
2549 (narrow-to-region (point) (point-max))
2550 (let ((w3m-safe-url-regexp mm-w3m-safe-url-regexp)
2551 w3m-force-redisplay)
2552 (w3m-region (point-min) (point-max)))
2553 (when (and mm-inline-text-html-with-w3m-keymap
2554 (boundp 'w3m-minor-mode-map)
2556 (add-text-properties
2557 (point-min) (point-max)
2558 (list 'keymap w3m-minor-mode-map
2559 ;; Put the mark meaning this part was rendered by emacs-w3m.
2560 'mm-inline-text-html-with-w3m t)))))
2562 (defun article-hide-list-identifiers ()
2563 "Remove list identifies from the Subject header.
2564 The `gnus-list-identifiers' variable specifies what to do."
2566 (let ((inhibit-point-motion-hooks t)
2567 (regexp (if (consp gnus-list-identifiers)
2568 (mapconcat 'identity gnus-list-identifiers " *\\|")
2569 gnus-list-identifiers))
2574 (article-narrow-to-head)
2575 (goto-char (point-min))
2576 (while (re-search-forward
2577 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2579 (delete-region (match-beginning 2) (match-end 0))
2580 (beginning-of-line))
2581 (when (re-search-forward
2582 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2583 (delete-region (match-beginning 1) (match-end 1))))))))
2585 (defun article-hide-pem (&optional arg)
2586 "Toggle hiding of any PEM headers and signatures in the current article.
2587 If given a negative prefix, always show; if given a positive prefix,
2589 (interactive (gnus-article-hidden-arg))
2590 (unless (gnus-article-check-hidden-text 'pem arg)
2592 (let (buffer-read-only end)
2593 (goto-char (point-min))
2594 ;; Hide the horrendously ugly "header".
2595 (when (and (search-forward
2596 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2598 (setq end (1+ (match-beginning 0))))
2599 (gnus-add-wash-type 'pem)
2600 (gnus-article-hide-text-type
2602 (if (search-forward "\n\n" nil t)
2606 ;; Hide the trailer as well
2607 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2609 (gnus-article-hide-text-type
2610 (match-beginning 0) (match-end 0) 'pem)))))))
2612 (defun article-strip-banner ()
2613 "Strip the banners specified by the `banner' group parameter and by
2614 `gnus-article-address-banner-alist'."
2618 (let ((inhibit-point-motion-hooks t))
2619 (when (gnus-parameter-banner gnus-newsgroup-name)
2620 (article-really-strip-banner
2621 (gnus-parameter-banner gnus-newsgroup-name)))
2622 (when gnus-article-address-banner-alist
2623 ;; It is necessary to encode from fields before checking,
2624 ;; because `mail-header-parse-addresses' does not work
2625 ;; (reliably) on decoded headers. And more, it is
2626 ;; impossible to use `gnus-fetch-original-field' here,
2627 ;; because `article-strip-banner' may be called in draft
2628 ;; buffers to preview them.
2629 (let ((from (save-restriction
2631 (article-narrow-to-head)
2632 (mail-fetch-field "from"))))
2635 (caar (mail-header-parse-addresses
2636 (mail-encode-encoded-word-string from)))))
2638 (dolist (pair gnus-article-address-banner-alist)
2639 (when (string-match (car pair) from)
2641 (article-really-strip-banner (cdr pair)))))))))))))
2643 (defun article-really-strip-banner (banner)
2644 "Strip the banner specified by the argument."
2647 (let ((inhibit-point-motion-hooks t)
2648 (gnus-signature-limit nil)
2652 ((eq banner 'signature)
2653 (when (gnus-article-narrow-to-signature)
2656 (delete-region (point) (point-max))))
2658 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2659 (while (re-search-forward banner nil t)
2660 (delete-region (match-beginning 0) (match-end 0)))))
2662 (while (re-search-forward banner nil t)
2663 (delete-region (match-beginning 0) (match-end 0)))))))))
2665 (defun article-babel ()
2666 "Translate article using an online translation service."
2669 (gnus-with-article-buffer
2670 (when (article-goto-body)
2671 (let* ((start (point))
2673 (orig (buffer-substring start end))
2674 (trans (babel-as-string orig)))
2676 (narrow-to-region start end)
2677 (delete-region start end)
2680 (defun article-hide-signature (&optional arg)
2681 "Hide the signature in the current article.
2682 If given a negative prefix, always show; if given a positive prefix,
2684 (interactive (gnus-article-hidden-arg))
2690 (article-goto-body))
2691 (goto-char (point-min)))
2692 (unless (gnus-article-check-hidden-text 'signature arg)
2693 (let ((buffer-read-only nil)
2695 (while (setq button (text-property-any button (point-max)
2697 'gnus-signature-toggle))
2698 (setq button (text-property-not-all button (point-max)
2700 'gnus-signature-toggle))
2701 (when (and button (not (eobp)))
2702 (gnus-article-hide-text-type
2704 (next-single-property-change (1+ button) 'mime-view-entity
2707 (gnus-set-mode-line 'article))
2709 (defun article-strip-headers-in-body ()
2710 "Strip offensive headers from bodies."
2714 (let ((case-fold-search t))
2715 (when (looking-at "x-no-archive:")
2716 (gnus-delete-line)))))
2718 (defun article-strip-leading-blank-lines ()
2719 "Remove all blank lines from the beginning of the article."
2722 (let ((inhibit-point-motion-hooks t)
2724 (when (article-goto-body)
2725 (while (and (not (eobp))
2726 (looking-at "[ \t]*$"))
2727 (gnus-delete-line))))))
2729 (defun article-narrow-to-head ()
2730 "Narrow the buffer to the head of the message.
2731 Point is left at the beginning of the narrowed-to region."
2733 (goto-char (point-min))
2734 (if (search-forward "\n\n" nil 1)
2737 (goto-char (point-min)))
2739 (defun article-goto-body ()
2740 "Place point at the start of the body."
2741 (goto-char (point-min))
2743 ;; This variable is only bound when dealing with separate
2745 (article-goto-body-goes-to-point-min-p
2747 ((search-forward "\n\n" nil t)
2750 (goto-char (point-max))
2753 (defun article-strip-multiple-blank-lines ()
2754 "Replace consecutive blank lines with one empty line."
2757 (let ((inhibit-point-motion-hooks t)
2759 ;; First make all blank lines empty.
2761 (while (re-search-forward "^[ \t]+$" nil t)
2762 (unless (gnus-annotation-in-region-p
2763 (match-beginning 0) (match-end 0))
2764 (replace-match "" nil t)))
2765 ;; Then replace multiple empty lines with a single empty line.
2767 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2768 (unless (gnus-annotation-in-region-p
2769 (match-beginning 0) (match-end 0))
2770 (delete-region (match-beginning 1) (match-end 1)))))))
2772 (defun article-strip-leading-space ()
2773 "Remove all white space from the beginning of the lines in the article."
2776 (let ((inhibit-point-motion-hooks t)
2779 (while (re-search-forward "^[ \t]+" nil t)
2780 (replace-match "" t t)))))
2782 (defun article-strip-trailing-space ()
2783 "Remove all white space from the end of the lines in the article."
2786 (let ((inhibit-point-motion-hooks t)
2789 (while (re-search-forward "[ \t]+$" nil t)
2790 (replace-match "" t t)))))
2792 (defun article-strip-blank-lines ()
2793 "Strip leading, trailing and multiple blank lines."
2795 (article-strip-leading-blank-lines)
2796 (article-remove-trailing-blank-lines)
2797 (article-strip-multiple-blank-lines))
2799 (defun article-strip-all-blank-lines ()
2800 "Strip all blank lines."
2803 (let ((inhibit-point-motion-hooks t)
2806 (while (re-search-forward "^[ \t]*\n" nil t)
2807 (replace-match "" t t)))))
2809 (defun gnus-article-narrow-to-signature ()
2810 "Narrow to the signature; return t if a signature is found, else nil."
2811 (let ((inhibit-point-motion-hooks t))
2812 (when (gnus-article-search-signature)
2814 ;; Check whether we have some limits to what we consider
2815 ;; to be a signature.
2816 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2817 (list gnus-signature-limit)))
2819 (while (setq limit (pop limits))
2820 (if (or (and (integerp limit)
2821 (< (- (point-max) (point)) limit))
2823 (< (count-lines (point) (point-max)) limit))
2824 (and (functionp limit)
2826 (and (stringp limit)
2827 (not (re-search-forward limit nil t))))
2828 () ; This limit did not succeed.
2832 (narrow-to-region (point) (point-max))
2835 (defun gnus-article-search-signature ()
2836 "Search the current buffer for the signature separator.
2837 Put point at the beginning of the signature separator."
2838 (let ((cur (point)))
2839 (goto-char (point-max))
2840 (if (if (stringp gnus-signature-separator)
2841 (re-search-backward gnus-signature-separator nil t)
2842 (let ((seps gnus-signature-separator))
2844 (not (re-search-backward (car seps) nil t)))
2851 (defun gnus-article-hidden-arg ()
2852 "Return the current prefix arg as a number, or 0 if no prefix."
2853 (list (if current-prefix-arg
2854 (prefix-numeric-value current-prefix-arg)
2857 (defun gnus-article-check-hidden-text (type arg)
2858 "Return nil if hiding is necessary.
2859 Arg can be nil or a number. nil and positive means hide, negative
2860 means show, 0 means toggle."
2863 (let ((hide (gnus-article-hidden-text-p type)))
2869 (gnus-article-show-hidden-text type)
2872 (if (eq hide 'hidden)
2874 (gnus-article-show-hidden-text type)
2878 (defun gnus-article-hidden-text-p (type)
2879 "Say whether the current buffer contains hidden text of type TYPE."
2880 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2882 (not (get-text-property pos 'invisible))
2883 (not (get-text-property pos 'dummy-invisible)))
2885 (text-property-any (1+ pos) (point-max) 'article-type type)))
2890 (defun gnus-article-show-hidden-text (type &optional dummy)
2891 "Show all hidden text of type TYPE.
2892 Originally it is hide instead of DUMMY."
2893 (let ((buffer-read-only nil)
2894 (inhibit-point-motion-hooks t))
2895 (gnus-remove-text-properties-when
2897 (point-min) (point-max)
2898 (cons 'article-type (cons type
2899 gnus-hidden-properties)))
2900 (gnus-delete-wash-type type)))
2902 (defconst article-time-units
2903 `((year . ,(* 365.25 24 60 60))
2904 (week . ,(* 7 24 60 60))
2905 (day . ,(* 24 60 60))
2909 "Mapping from time units to seconds.")
2911 (defun gnus-article-forward-header ()
2912 "Move point to the start of the next header.
2913 If the current header is a continuation header, this can be several
2918 (if (looking-at "[ \t]+[^ \t]")
2922 (defun article-date-ut (&optional type highlight header)
2923 "Convert DATE date to universal time in the current article.
2924 If TYPE is `local', convert to local time; if it is `lapsed', output
2925 how much time has lapsed since DATE. For `lapsed', the value of
2926 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2927 should replace the \"Date:\" one, or should be added below it."
2928 (interactive (list 'ut t))
2929 (let* ((header (or header
2930 (and (eq 1 (point-min))
2931 (mail-header-date (save-excursion
2932 (set-buffer gnus-summary-buffer)
2933 gnus-current-headers)))
2934 (message-fetch-field "date")
2936 (date (if (vectorp header) (mail-header-date header)
2938 (inhibit-point-motion-hooks t)
2939 bface eface date-pos)
2940 (when (and date (not (string= date "")))
2943 (article-narrow-to-head)
2944 (when (or (and (eq type 'lapsed)
2945 gnus-article-date-lapsed-new-header
2946 ;; Attempt to get the face of X-Sent first.
2947 (re-search-forward "^X-Sent:[ \t]" nil t))
2948 (re-search-forward "^Date:[ \t]" nil t)
2949 ;; If Date is missing, try again for X-Sent.
2950 (re-search-forward "^X-Sent:[ \t]" nil t))
2951 (setq bface (get-text-property (point-at-bol) 'face)
2952 date (or (get-text-property (point-at-bol)
2955 eface (get-text-property (1- (point-at-eol))
2957 (let ((buffer-read-only nil))
2958 ;; Delete any old X-Sent headers.
2959 (when (setq date-pos
2960 (text-property-any (point-min) (point-max)
2961 'article-date-lapsed t))
2962 (goto-char (setq date-pos (set-marker (make-marker) date-pos)))
2963 (delete-region (match-beginning 0)
2964 (progn (forward-line 1) (point))))
2965 (goto-char (point-min))
2966 ;; Delete any old Date headers.
2967 (while (re-search-forward "^Date:[ \t]" nil t)
2969 (setq date-pos (match-beginning 0)))
2970 (unless (and (eq type 'lapsed)
2971 gnus-article-date-lapsed-new-header)
2972 (delete-region (match-beginning 0)
2973 (progn (message-next-header) (point)))))
2976 (goto-char date-pos)
2978 ;; Possibly, Date has been deleted.
2980 (when (and (eq type 'lapsed)
2981 gnus-article-date-lapsed-new-header
2982 (looking-at "Date:"))
2984 (goto-char (point-min)))
2985 (insert (article-make-date-line date type))
2986 (when (eq type 'lapsed)
2987 (put-text-property (point-at-bol) (point)
2988 'article-date-lapsed t))
2992 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2993 (put-text-property (match-beginning 1) (1+ (match-end 1))
2994 'original-date date)
2995 (put-text-property (match-beginning 1) (1+ (match-end 1))
2997 (put-text-property (match-beginning 2) (match-end 2)
3000 (defun article-make-date-line (date type)
3001 "Return a DATE line of TYPE."
3002 (unless (memq type '(local ut original user iso8601 lapsed english))
3003 (error "Unknown conversion type: %s" type))
3005 (let ((time (date-to-time date)))
3007 ;; Convert to the local timezone.
3009 (let ((tz (car (current-time-zone time))))
3010 (format "Date: %s %s%02d%02d" (current-time-string time)
3011 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3012 (/ (% (abs tz) 3600) 60))))
3013 ;; Convert to Universal Time.
3016 (current-time-string
3017 (let* ((e (parse-time-string date))
3018 (tm (apply 'encode-time e))
3020 (ls (- (cadr tm) (car (current-time-zone time)))))
3021 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
3022 ((> ls 65535) (list (1+ ms) (- ls 65536)))
3025 ;; Get the original date from the article.
3026 ((eq type 'original)
3027 (concat "Date: " (if (string-match "\n+$" date)
3028 (substring date 0 (match-beginning 0))
3030 ;; Let the user define the format.
3032 (let ((format (or (condition-case nil
3033 (with-current-buffer gnus-summary-buffer
3034 gnus-article-time-format)
3036 gnus-article-time-format)))
3037 (if (functionp format)
3038 (funcall format time)
3039 (concat "Date: " (format-time-string format time)))))
3042 (let ((tz (car (current-time-zone time))))
3045 (format-time-string "%Y%m%dT%H%M%S" time)
3046 (format "%s%02d%02d"
3047 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
3048 (/ (% (abs tz) 3600) 60)))))
3049 ;; Do an X-Sent lapsed format.
3051 ;; If the date is seriously mangled, the timezone functions are
3052 ;; liable to bug out, so we ignore all errors.
3053 (let* ((now (current-time))
3054 (real-time (subtract-time now time))
3055 (real-sec (and real-time
3056 (+ (* (float (car real-time)) 65536)
3058 (sec (and real-time (abs real-sec)))
3068 ;; This is a bit convoluted, but basically we go
3069 ;; through the time units for years, weeks, etc,
3070 ;; and divide things to see whether that results
3071 ;; in positive answers.
3074 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
3075 ;; The (remaining) seconds are too few to
3076 ;; be divided into this time unit.
3078 ;; It's big enough, so we output it.
3079 (setq sec (- sec (* num (cdr unit))))
3081 (concat (if prev ", " "") (int-to-string
3083 " " (symbol-name (car unit))
3084 (if (> num 1) "s" ""))
3086 article-time-units "")
3087 ;; If dates are odd, then it might appear like the
3088 ;; article was sent in the future.
3091 " in the future"))))))
3092 ;; Display the date in proper English
3094 (let ((dtime (decode-time time)))
3097 (number-to-string (nth 3 dtime))
3098 (let ((digit (% (nth 3 dtime) 10)))
3100 ((memq (nth 3 dtime) '(11 12 13)) "th")
3106 (nth (1- (nth 4 dtime)) gnus-english-month-names)
3108 (number-to-string (nth 5 dtime))
3110 (format "%02d" (nth 2 dtime))
3112 (format "%02d" (nth 1 dtime)))))))
3114 (format "Date: %s (from T-gnus)" date))))
3116 (defun article-date-local (&optional highlight)
3117 "Convert the current article date to the local timezone."
3118 (interactive (list t))
3119 (article-date-ut 'local highlight))
3121 (defun article-date-english (&optional highlight)
3122 "Convert the current article date to something that is proper English."
3123 (interactive (list t))
3124 (article-date-ut 'english highlight))
3126 (defun article-date-original (&optional highlight)
3127 "Convert the current article date to what it was originally.
3128 This is only useful if you have used some other date conversion
3129 function and want to see what the date was before converting."
3130 (interactive (list t))
3131 (article-date-ut 'original highlight))
3133 (defun article-date-lapsed (&optional highlight)
3134 "Convert the current article date to time lapsed since it was sent."
3135 (interactive (list t))
3136 (article-date-ut 'lapsed highlight))
3138 (defun article-update-date-lapsed ()
3139 "Function to be run from a timer to update the lapsed time line."
3140 (let (deactivate-mark)
3145 (set-buffer (window-buffer w))
3146 (when (eq major-mode 'gnus-article-mode)
3147 (let ((mark (point-marker)))
3148 (goto-char (point-min))
3149 (when (re-search-forward "^X-Sent:" nil t)
3150 (article-date-lapsed t))
3151 (goto-char (marker-position mark))
3152 (move-marker mark nil))))
3155 (defun gnus-start-date-timer (&optional n)
3156 "Start a timer to update the X-Sent header in the article buffers.
3157 The numerical prefix says how frequently (in seconds) the function
3162 (gnus-stop-date-timer)
3163 (setq article-lapsed-timer
3164 (run-at-time 1 n 'article-update-date-lapsed)))
3166 (defun gnus-stop-date-timer ()
3167 "Stop the X-Sent timer."
3169 (when article-lapsed-timer
3170 (nnheader-cancel-timer article-lapsed-timer)
3171 (setq article-lapsed-timer nil)))
3173 (defun article-date-user (&optional highlight)
3174 "Convert the current article date to the user-defined format.
3175 This format is defined by the `gnus-article-time-format' variable."
3176 (interactive (list t))
3177 (article-date-ut 'user highlight))
3179 (defun article-date-iso8601 (&optional highlight)
3180 "Convert the current article date to ISO8601."
3181 (interactive (list t))
3182 (article-date-ut 'iso8601 highlight))
3184 ;; (defun article-show-all ()
3185 ;; "Show all hidden text in the article buffer."
3189 ;; (let ((buffer-read-only nil))
3190 ;; (gnus-article-unhide-text (point-min) (point-max))
3191 ;; (gnus-remove-text-with-property 'gnus-prev)
3192 ;; (gnus-remove-text-with-property 'gnus-next))))
3194 (defun article-show-all-headers ()
3195 "Show all hidden headers in the article buffer."
3200 (article-narrow-to-head)
3201 (let ((buffer-read-only nil))
3202 (gnus-article-unhide-text (point-min) (point-max))))))
3204 (defun article-remove-leading-whitespace ()
3205 "Remove excessive whitespace from all headers."
3209 (let ((buffer-read-only nil))
3210 (article-narrow-to-head)
3211 (goto-char (point-min))
3212 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3213 (delete-region (match-beginning 1) (match-end 1)))))))
3215 (defun article-emphasize (&optional arg)
3216 "Emphasize text according to `gnus-emphasis-alist'."
3217 (interactive (gnus-article-hidden-arg))
3218 (unless (gnus-article-check-hidden-text 'emphasis arg)
3222 (with-current-buffer gnus-summary-buffer
3223 gnus-article-emphasis-alist)
3225 gnus-emphasis-alist))
3226 (buffer-read-only nil)
3227 (props (append '(article-type emphasis)
3228 gnus-hidden-properties))
3229 regexp elem beg invisible visible face)
3232 (while (setq elem (pop alist))
3234 (setq regexp (car elem)
3235 invisible (nth 1 elem)
3236 visible (nth 2 elem)
3238 (while (re-search-forward regexp nil t)
3239 (when (and (match-beginning visible) (match-beginning invisible))
3240 (gnus-article-hide-text
3241 (match-beginning invisible) (match-end invisible) props)
3242 (gnus-article-unhide-text-type
3243 (match-beginning visible) (match-end visible) 'emphasis)
3244 (gnus-put-overlay-excluding-newlines
3245 (match-beginning visible) (match-end visible) 'face face)
3246 (gnus-add-wash-type 'emphasis)
3247 (goto-char (match-end invisible)))))))))
3249 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3250 "Setup newsgroup emphasis alist."
3251 (unless gnus-article-emphasis-alist
3252 (let ((name (and gnus-newsgroup-name
3253 (gnus-group-real-name gnus-newsgroup-name))))
3254 (make-local-variable 'gnus-article-emphasis-alist)
3255 (setq gnus-article-emphasis-alist
3257 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3258 (while (setq elem (pop alist))
3259 (when (and name (string-match (car elem) name))
3261 highlight (copy-sequence (cdr elem)))))
3263 (copy-sequence highlight-words)
3264 (if gnus-newsgroup-name
3265 (copy-sequence (gnus-group-find-parameter
3266 gnus-newsgroup-name 'highlight-words t)))
3267 gnus-emphasis-alist)))))
3270 (defvar gnus-summary-article-menu)
3271 (defvar gnus-summary-post-menu))
3273 ;;; Saving functions.
3275 (defun gnus-article-save (save-buffer file &optional num)
3276 "Save the currently selected article."
3277 (unless gnus-save-all-headers
3278 ;; Remove headers according to `gnus-saved-headers'.
3279 (let ((gnus-visible-headers
3280 (or gnus-saved-headers gnus-visible-headers))
3281 (gnus-article-buffer save-buffer))
3283 (set-buffer save-buffer)
3284 (article-hide-headers 1 t))))
3285 (save-window-excursion
3286 (if (not gnus-default-article-saver)
3287 (error "No default saver is defined")
3288 ;; !!! Magic! The saving functions all save
3289 ;; `gnus-save-article-buffer' (or so they think), but we
3290 ;; bind that variable to our save-buffer.
3291 (set-buffer gnus-article-buffer)
3292 (let* ((gnus-save-article-buffer save-buffer)
3295 ((not gnus-prompt-before-saving) 'default)
3296 ((eq gnus-prompt-before-saving 'always) nil)
3298 (gnus-number-of-articles-to-be-saved
3299 (when (eq gnus-prompt-before-saving t)
3301 (set-buffer gnus-article-current-summary)
3302 (funcall gnus-default-article-saver filename)))))
3304 (defun gnus-read-save-file-name (prompt &optional filename
3305 function group headers variable)
3307 (funcall function group headers (symbol-value variable)))
3312 ((eq filename 'default)
3318 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3321 (if (and gnus-number-of-articles-to-be-saved
3322 (> gnus-number-of-articles-to-be-saved 1))
3323 (format "these %d articles"
3324 gnus-number-of-articles-to-be-saved)
3327 ;; Let the split methods have their say.
3329 ;; No split name was found.
3332 (concat prompt " (default "
3333 (file-name-nondirectory default-name) ") ")
3334 (file-name-directory default-name)
3336 ;; A single group name is returned.
3337 ((stringp split-name)
3339 (funcall function split-name headers
3340 (symbol-value variable)))
3342 (concat prompt " (default "
3343 (file-name-nondirectory default-name) ") ")
3344 (file-name-directory default-name)
3346 ;; A single split name was found
3347 ((= 1 (length split-name))
3348 (let* ((name (expand-file-name
3350 gnus-article-save-directory))
3351 (dir (cond ((file-directory-p name)
3352 (file-name-as-directory name))
3353 ((file-exists-p name) name)
3354 (t gnus-article-save-directory))))
3356 (concat prompt " (default " name ") ")
3358 ;; A list of splits was found.
3360 (setq split-name (nreverse split-name))
3362 (let ((file-name-history
3363 (nconc split-name file-name-history)))
3367 (concat prompt " (`M-p' for defaults) ")
3368 gnus-article-save-directory
3370 gnus-article-save-directory)))
3371 (car (push result file-name-history)))))))
3372 ;; Create the directory.
3373 (gnus-make-directory (file-name-directory file))
3374 ;; If we have read a directory, we append the default file name.
3375 (when (file-directory-p file)
3376 (setq file (expand-file-name (file-name-nondirectory
3378 (file-name-as-directory file))))
3379 ;; Possibly translate some characters.
3380 (nnheader-translate-file-chars file))))))
3381 (gnus-make-directory (file-name-directory result))
3382 (set variable result)))
3384 (defun gnus-article-archive-name (group)
3385 "Return the first instance of an \"Archive-name\" in the current buffer."
3386 (let ((case-fold-search t))
3387 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3388 (nnheader-concat gnus-article-save-directory
3389 (match-string 1)))))
3391 (defun gnus-article-nndoc-name (group)
3392 "If GROUP is an nndoc group, return the name of the parent group."
3393 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3394 (gnus-group-get-parameter group 'save-article-group)))
3396 (defun gnus-summary-save-in-rmail (&optional filename)
3397 "Append this article to Rmail file.
3398 Optional argument FILENAME specifies file name.
3399 Directory to save to is default to `gnus-article-save-directory'."
3400 (setq filename (gnus-read-save-file-name
3401 "Save %s in rmail file:" filename
3402 gnus-rmail-save-name gnus-newsgroup-name
3403 gnus-current-headers 'gnus-newsgroup-last-rmail))
3404 (gnus-eval-in-buffer-window gnus-save-article-buffer
3408 (gnus-output-to-rmail filename))))
3411 (defun gnus-summary-save-in-mail (&optional filename)
3412 "Append this article to Unix mail file.
3413 Optional argument FILENAME specifies file name.
3414 Directory to save to is default to `gnus-article-save-directory'."
3415 (setq filename (gnus-read-save-file-name
3416 "Save %s in Unix mail file:" filename
3417 gnus-mail-save-name gnus-newsgroup-name
3418 gnus-current-headers 'gnus-newsgroup-last-mail))
3419 (gnus-eval-in-buffer-window gnus-save-article-buffer
3423 (if (and (file-readable-p filename)
3424 (file-regular-p filename)
3425 (mail-file-babyl-p filename))
3426 (rmail-output-to-rmail-file filename t)
3427 (gnus-output-to-mail filename)))))
3430 (defun gnus-summary-save-in-file (&optional filename overwrite)
3431 "Append this article to file.
3432 Optional argument FILENAME specifies file name.
3433 Directory to save to is default to `gnus-article-save-directory'."
3434 (setq filename (gnus-read-save-file-name
3435 "Save %s in file:" filename
3436 gnus-file-save-name gnus-newsgroup-name
3437 gnus-current-headers 'gnus-newsgroup-last-file))
3438 (gnus-eval-in-buffer-window gnus-save-article-buffer
3442 (when (and overwrite
3443 (file-exists-p filename))
3444 (delete-file filename))
3445 (gnus-output-to-file filename))))
3448 (defun gnus-summary-write-to-file (&optional filename)
3449 "Write this article to a file, overwriting it if the file exists.
3450 Optional argument FILENAME specifies file name.
3451 The directory to save in defaults to `gnus-article-save-directory'."
3452 (gnus-summary-save-in-file nil t))
3454 (defun gnus-summary-save-body-in-file (&optional filename)
3455 "Append this article body to a file.
3456 Optional argument FILENAME specifies file name.
3457 The directory to save in defaults to `gnus-article-save-directory'."
3458 (setq filename (gnus-read-save-file-name
3459 "Save %s body in file:" filename
3460 gnus-file-save-name gnus-newsgroup-name
3461 gnus-current-headers 'gnus-newsgroup-last-file))
3462 (gnus-eval-in-buffer-window gnus-save-article-buffer
3466 (when (article-goto-body)
3467 (narrow-to-region (point) (point-max)))
3468 (gnus-output-to-file filename))))
3471 (defun gnus-summary-save-in-pipe (&optional command)
3472 "Pipe this article to subprocess."
3474 (cond ((and (eq command 'default)
3475 gnus-last-shell-command)
3476 gnus-last-shell-command)
3481 "Shell command on %s: "
3482 (if (and gnus-number-of-articles-to-be-saved
3483 (> gnus-number-of-articles-to-be-saved 1))
3484 (format "these %d articles"
3485 gnus-number-of-articles-to-be-saved)
3487 gnus-last-shell-command))))
3488 (when (string-equal command "")
3489 (if gnus-last-shell-command
3490 (setq command gnus-last-shell-command)
3491 (error "A command is required")))
3492 (gnus-eval-in-buffer-window gnus-article-buffer
3495 (shell-command-on-region (point-min) (point-max) command nil)))
3496 (setq gnus-last-shell-command command))
3498 (defun gnus-summary-pipe-to-muttprint (&optional command)
3499 "Pipe this article to muttprint."
3500 (setq command (read-string
3501 "Print using command: " gnus-summary-muttprint-program
3502 nil gnus-summary-muttprint-program))
3503 (gnus-summary-save-in-pipe command))
3505 ;;; Article file names when saving.
3507 (defun gnus-capitalize-newsgroup (newsgroup)
3508 "Capitalize NEWSGROUP name."
3509 (when (not (zerop (length newsgroup)))
3510 (concat (char-to-string (upcase (aref newsgroup 0)))
3511 (substring newsgroup 1))))
3513 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3514 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3515 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3516 Otherwise, it is like ~/News/news/group/num."
3519 (concat (if (gnus-use-long-file-name 'not-save)
3520 (gnus-capitalize-newsgroup newsgroup)
3521 (gnus-newsgroup-directory-form newsgroup))
3522 "/" (int-to-string (mail-header-number headers)))
3523 gnus-article-save-directory)))
3525 (string-equal (file-name-directory default)
3526 (file-name-directory last-file))
3527 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3529 (or last-file default))))
3531 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3532 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3533 If variable `gnus-use-long-file-name' is non-nil, it is
3534 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3537 (concat (if (gnus-use-long-file-name 'not-save)
3539 (gnus-newsgroup-directory-form newsgroup))
3540 "/" (int-to-string (mail-header-number headers)))
3541 gnus-article-save-directory)))
3543 (string-equal (file-name-directory default)
3544 (file-name-directory last-file))
3545 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3547 (or last-file default))))
3549 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3550 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3551 If variable `gnus-use-long-file-name' is non-nil, it is
3552 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3555 (if (gnus-use-long-file-name 'not-save)
3558 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3560 gnus-article-save-directory)))
3562 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3563 "Generate file name from sender."
3564 (let ((from (mail-header-from headers)))
3566 (if (and from (string-match "\\([^ <]+\\)@" from))
3567 (match-string 1 from)
3569 gnus-article-save-directory)))
3571 (defun article-verify-x-pgp-sig ()
3574 (if (gnus-buffer-live-p gnus-original-article-buffer)
3575 (let ((sig (with-current-buffer gnus-original-article-buffer
3576 (gnus-fetch-field "X-PGP-Sig")))
3580 (mml2015-clear-verify-function))
3582 (insert-buffer-substring gnus-original-article-buffer)
3583 (setq items (split-string sig))
3584 (message-narrow-to-head)
3585 (let ((inhibit-point-motion-hooks t)
3586 (case-fold-search t))
3587 ;; Don't verify multiple headers.
3588 (setq headers (mapconcat (lambda (header)
3590 (mail-fetch-field header)
3592 (split-string (nth 1 items) ",") "")))
3593 (delete-region (point-min) (point-max))
3594 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3595 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3600 (if (looking-at "^-")
3603 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3604 (insert "Version: " (car items) "\n\n")
3605 (insert (mapconcat 'identity (cddr items) "\n"))
3606 (insert "\n-----END PGP SIGNATURE-----\n")
3607 (let ((mm-security-handle (list (format "multipart/signed"))))
3608 (mml2015-clean-buffer)
3609 (let ((coding-system-for-write (or gnus-newsgroup-charset
3611 (funcall (mml2015-clear-verify-function)))
3613 (or (mm-handle-multipart-ctl-parameter
3614 mm-security-handle 'gnus-details)
3615 (mm-handle-multipart-ctl-parameter
3616 mm-security-handle 'gnus-info)))))
3618 (let (buffer-read-only bface eface)
3620 (message-narrow-to-head)
3621 (goto-char (point-max))
3623 (setq bface (get-text-property (point-at-bol) 'face)
3624 eface (get-text-property (1- (point-at-eol)) 'face))
3625 (message-remove-header "X-Gnus-PGP-Verify")
3626 (if (re-search-forward "^X-PGP-Sig:" nil t)
3628 (goto-char (point-max)))
3629 (narrow-to-region (point) (point))
3630 (insert "X-Gnus-PGP-Verify: " info "\n")
3631 (goto-char (point-min))
3634 (if (not (looking-at "^[ \t]"))
3638 (goto-char (point-min))
3639 (when (looking-at "\\([^:]+\\): *")
3640 (put-text-property (match-beginning 1) (1+ (match-end 1))
3642 (put-text-property (match-end 0) (point-max)
3643 'face eface)))))))))
3645 (defun article-verify-cancel-lock ()
3646 "Verify Cancel-Lock header."
3648 (if (gnus-buffer-live-p gnus-original-article-buffer)
3649 (canlock-verify gnus-original-article-buffer)))
3651 (defun article-monafy ()
3652 "Display body part with mona font."
3654 (unless (if (featurep 'xemacs)
3655 (find-face 'gnus-mona-face)
3656 (facep 'gnus-mona-face))
3657 (require 'navi2ch-mona)
3658 (set-face-font (make-face 'gnus-mona-face) navi2ch-mona-font))
3660 (let ((buffer-read-only nil))
3663 (gnus-make-overlay (point) (point-max))
3664 'face 'gnus-mona-face))))
3671 (setq afunc (car func)
3674 gfunc (intern (format "gnus-%s" func))))
3676 (when (fboundp afunc)
3677 `(lambda (&optional interactive &rest args)
3678 ,(documentation afunc t)
3679 (interactive (list t))
3681 (set-buffer gnus-article-buffer)
3683 (call-interactively ',afunc)
3684 (apply ',afunc args))))))))
3685 '(article-hide-headers
3686 article-verify-x-pgp-sig
3687 article-verify-cancel-lock
3689 article-hide-boring-headers
3690 article-treat-overstrike
3691 article-treat-ansi-sequences
3692 article-fill-long-lines
3693 article-capitalize-sentences
3695 article-remove-leading-whitespace
3696 article-display-x-face
3697 article-display-face
3698 article-de-quoted-unreadable
3699 article-de-base64-unreadable
3702 article-unsplit-urls
3703 article-hide-list-identifiers
3704 article-strip-banner
3707 article-hide-signature
3708 article-strip-headers-in-body
3709 article-remove-trailing-blank-lines
3710 article-strip-leading-blank-lines
3711 article-strip-multiple-blank-lines
3712 article-strip-leading-space
3713 article-strip-trailing-space
3714 article-strip-blank-lines
3715 article-strip-all-blank-lines
3717 article-date-english
3718 article-date-iso8601
3719 article-date-original
3721 article-decode-mime-words
3722 article-decode-charset
3723 article-decode-encoded-words
3727 article-treat-dumbquotes
3728 article-normalize-headers
3729 (article-show-all-headers . gnus-article-show-all-headers)
3730 ;; (article-show-all . gnus-article-show-all)
3734 ;;; Gnus article mode
3737 (put 'gnus-article-mode 'mode-class 'special)
3739 (gnus-define-keys gnus-article-mode-map
3740 " " gnus-article-goto-next-page
3741 "\177" gnus-article-goto-prev-page
3742 [delete] gnus-article-goto-prev-page
3743 [backspace] gnus-article-goto-prev-page
3744 "\C-c^" gnus-article-refer-article
3745 "h" gnus-article-show-summary
3746 "s" gnus-article-show-summary
3747 "\C-c\C-m" gnus-article-mail
3748 "?" gnus-article-describe-briefly
3749 "e" gnus-summary-edit-article
3750 "<" beginning-of-buffer
3752 "\C-c\C-i" gnus-info-find-node
3754 "R" gnus-article-reply-with-original
3755 "F" gnus-article-followup-with-original
3756 "\C-hk" gnus-article-describe-key
3757 "\C-hc" gnus-article-describe-key-briefly
3759 "\C-d" gnus-article-read-summary-keys
3760 "\M-*" gnus-article-read-summary-keys
3761 "\M-#" gnus-article-read-summary-keys
3762 "\M-^" gnus-article-read-summary-keys
3763 "\M-g" gnus-article-read-summary-keys)
3765 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3769 (push (char-to-string key) keys)
3771 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3772 (setq key (car elem))
3773 (when (and (> (length key) 0)
3774 (not (eq 'menu-bar (aref key 0)))
3775 (symbolp (lookup-key gnus-summary-mode-map key)))
3778 (unless (lookup-key gnus-article-mode-map key)
3779 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3781 (defun gnus-article-make-menu-bar ()
3782 (unless (boundp 'gnus-article-commands-menu)
3783 (gnus-summary-make-menu-bar))
3784 (gnus-turn-off-edit-menu 'article)
3785 (unless (boundp 'gnus-article-article-menu)
3787 gnus-article-article-menu gnus-article-mode-map ""
3789 ["Scroll forwards" gnus-article-goto-next-page t]
3790 ["Scroll backwards" gnus-article-goto-prev-page t]
3791 ["Show summary" gnus-article-show-summary t]
3792 ["Fetch Message-ID at point" gnus-article-refer-article t]
3793 ["Mail to address at point" gnus-article-mail t]
3794 ["Send a bug report" gnus-bug t]))
3797 gnus-article-treatment-menu gnus-article-mode-map ""
3798 ;; Fixme: this should use :active (and maybe :visible).
3800 ["Hide headers" gnus-article-hide-headers t]
3801 ["Hide signature" gnus-article-hide-signature t]
3802 ["Hide citation" gnus-article-hide-citation t]
3803 ["Treat overstrike" gnus-article-treat-overstrike t]
3804 ["Treat ANSI sequences" gnus-article-treat-ansi-sequences t]
3805 ["Remove carriage return" gnus-article-remove-cr t]
3806 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3807 ["Treat html" gnus-article-wash-html t]
3808 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3809 ["Decode HZ" gnus-article-decode-HZ t]))
3811 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3813 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3815 (gnus-run-hooks 'gnus-article-menu-hook)))
3817 (defun gnus-article-mode ()
3818 "Major mode for displaying an article.
3820 All normal editing commands are switched off.
3822 The following commands are available in addition to all summary mode
3824 \\<gnus-article-mode-map>
3825 \\[gnus-article-next-page]\t Scroll the article one page forwards
3826 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3827 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3828 \\[gnus-article-show-summary]\t Display the summary buffer
3829 \\[gnus-article-mail]\t Send a reply to the address near point
3830 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3831 \\[gnus-info-find-node]\t Go to the Gnus info node"
3833 (gnus-simplify-mode-line)
3834 (setq mode-name "Article")
3835 (setq major-mode 'gnus-article-mode)
3836 (make-local-variable 'minor-mode-alist)
3837 (unless (assq 'gnus-show-mime minor-mode-alist)
3838 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3839 (use-local-map gnus-article-mode-map)
3840 (when (gnus-visual-p 'article-menu 'menu)
3841 (gnus-article-make-menu-bar)
3842 (when gnus-summary-tool-bar-map
3843 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3844 (gnus-update-format-specifications nil 'article-mode)
3845 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3846 (set (make-local-variable 'gnus-page-broken) nil)
3847 (make-local-variable 'gnus-button-marker-list)
3848 (make-local-variable 'gnus-article-current-summary)
3849 (make-local-variable 'gnus-article-mime-handles)
3850 (make-local-variable 'gnus-article-decoded-p)
3851 (make-local-variable 'gnus-article-mime-handle-alist)
3852 (make-local-variable 'gnus-article-wash-types)
3853 (make-local-variable 'gnus-article-image-alist)
3854 (make-local-variable 'gnus-article-charset)
3855 (make-local-variable 'gnus-article-ignored-charsets)
3856 (gnus-set-default-directory)
3857 (buffer-disable-undo)
3858 (setq buffer-read-only t)
3859 (set-syntax-table gnus-article-mode-syntax-table)
3860 (gnus-run-hooks 'gnus-article-mode-hook))
3862 (defun gnus-article-setup-buffer ()
3863 "Initialize the article buffer."
3864 (let* ((name (if gnus-single-article-buffer "*Article*"
3865 (concat "*Article " gnus-newsgroup-name "*")))
3867 (progn (string-match "\\*Article" name)
3868 (concat " *Original Article"
3869 (substring name (match-end 0))))))
3870 (setq gnus-article-buffer name)
3871 (setq gnus-original-article-buffer original)
3872 (setq gnus-article-mime-handle-alist nil)
3873 ;; This might be a variable local to the summary buffer.
3874 (unless gnus-single-article-buffer
3876 (set-buffer gnus-summary-buffer)
3877 (setq gnus-article-buffer name)
3878 (setq gnus-original-article-buffer original)
3879 (gnus-set-global-variables)))
3880 (gnus-article-setup-highlight-words)
3881 ;; Init original article buffer.
3883 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3884 (set-buffer-multibyte t)
3885 (setq major-mode 'gnus-original-article-mode)
3886 (make-local-variable 'gnus-original-article))
3887 (if (get-buffer name)
3890 (when (and gnus-article-edit-mode
3893 (y-or-n-p "Article mode edit in progress; discard? ")))
3894 (error "Action aborted"))
3895 (set (make-local-variable 'gnus-article-edit-mode) nil)
3896 (buffer-disable-undo)
3897 (setq buffer-read-only t)
3898 ;; This list just keeps growing if we don't reset it.
3899 (setq gnus-button-marker-list nil)
3900 (unless (eq major-mode 'gnus-article-mode)
3901 (gnus-article-mode))
3904 (set-buffer (gnus-get-buffer-create name))
3906 (make-local-variable 'gnus-summary-buffer)
3907 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3908 (current-buffer)))))
3910 ;; Set article window start at LINE, where LINE is the number of lines
3911 ;; from the head of the article.
3912 (defun gnus-article-set-window-start (&optional line)
3914 (gnus-get-buffer-window gnus-article-buffer t)
3916 (set-buffer gnus-article-buffer)
3917 (goto-char (point-min))
3920 (gnus-message 6 "Moved to bookmark")
3921 (search-forward "\n\n" nil t)
3925 ;;; @@ article filters
3928 (defun gnus-article-display-mime-message ()
3929 "Article display method for MIME message."
3930 ;; called from `gnus-original-article-buffer'.
3931 (let (charset all-headers)
3932 (with-current-buffer gnus-summary-buffer
3933 (setq charset default-mime-charset
3934 all-headers gnus-have-all-headers))
3935 (make-local-variable 'default-mime-charset)
3936 (setq default-mime-charset charset)
3937 (with-current-buffer (get-buffer-create gnus-article-buffer)
3938 (make-local-variable 'default-mime-charset)
3939 (setq default-mime-charset charset))
3940 (mime-display-message mime-message-structure
3941 gnus-article-buffer nil gnus-article-mode-map)
3943 (gnus-article-hide-headers nil -1)))
3944 (run-hooks 'gnus-mime-article-prepare-hook))
3946 (defun gnus-article-display-traditional-message ()
3947 "Article display method for traditional message."
3948 (set-buffer gnus-article-buffer)
3949 (let (buffer-read-only)
3951 (insert-buffer-substring gnus-original-article-buffer)))
3953 (defun gnus-article-make-full-mail-header (&optional number charset)
3954 "Create a new mail header structure in a raw article buffer."
3955 (unless (and number charset)
3956 (save-current-buffer
3957 (set-buffer gnus-summary-buffer)
3959 (setq number (or (cdr gnus-article-current) 0)))
3961 (setq charset (or default-mime-charset 'x-ctext)))))
3962 (goto-char (point-min))
3963 (let ((header-end (if (search-forward "\n\n" nil t)
3965 (goto-char (point-max))))
3966 (chars (- (point-max) (point)))
3967 (lines (count-lines (point) (point-max)))
3968 (default-mime-charset charset)
3970 (narrow-to-region (point-min) header-end)
3971 (setq xref (std11-fetch-field "xref"))
3973 (make-full-mail-header
3975 (std11-fetch-field "subject")
3976 (std11-fetch-field "from")
3977 (std11-fetch-field "date")
3978 (std11-fetch-field "message-id")
3979 (std11-fetch-field "references")
3982 (when xref (concat "Xref: " xref)))
3985 (defun gnus-article-prepare (article &optional all-headers header)
3986 "Prepare ARTICLE in article mode buffer.
3987 ARTICLE should either be an article number or a Message-ID.
3988 If ARTICLE is an id, HEADER should be the article headers.
3989 If ALL-HEADERS is non-nil, no headers are hidden."
3991 ;; Make sure we start in a summary buffer.
3992 (unless (eq major-mode 'gnus-summary-mode)
3993 (set-buffer gnus-summary-buffer))
3994 (setq gnus-summary-buffer (current-buffer))
3995 (let* ((gnus-article (if header (mail-header-number header) article))
3996 (summary-buffer (current-buffer))
3997 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3998 (group gnus-newsgroup-name)
4001 (gnus-article-setup-buffer)
4002 (set-buffer gnus-article-buffer)
4003 ;; Deactivate active regions.
4004 (when (and (boundp 'transient-mark-mode)
4005 transient-mark-mode)
4006 (setq mark-active nil))
4007 (if (not (setq result (let ((buffer-read-only nil))
4008 (gnus-request-article-this-buffer
4010 ;; There is no such article.
4012 (when (and (numberp article)
4013 (not (memq article gnus-newsgroup-sparse)))
4014 (setq gnus-article-current
4015 (cons gnus-newsgroup-name article))
4016 (set-buffer gnus-summary-buffer)
4017 (setq gnus-current-article article)
4018 (if (and (memq article gnus-newsgroup-undownloaded)
4019 (not (gnus-online (gnus-find-method-for-group
4020 gnus-newsgroup-name))))
4022 (gnus-summary-set-agent-mark article)
4023 (message "Message marked for downloading"))
4024 (gnus-summary-mark-article article gnus-canceled-mark)
4025 (unless (memq article gnus-newsgroup-sparse)
4026 (gnus-error 1 "No such article (may have expired or been canceled)")))))
4027 (if (or (eq result 'pseudo)
4028 (eq result 'nneething))
4031 (set-buffer summary-buffer)
4032 (push article gnus-newsgroup-history)
4033 (setq gnus-last-article gnus-current-article
4034 gnus-current-article 0
4035 gnus-current-headers nil
4036 gnus-article-current nil)
4037 (if (eq result 'nneething)
4038 (gnus-configure-windows 'summary)
4039 (gnus-configure-windows 'article))
4040 (gnus-set-global-variables))
4041 (let ((gnus-article-mime-handle-alist-1
4042 gnus-article-mime-handle-alist))
4043 (gnus-set-mode-line 'article)))
4044 ;; The result from the `request' was an actual article -
4045 ;; or at least some text that is now displayed in the
4047 (when (and (numberp article)
4048 (not (eq article gnus-current-article)))
4049 ;; Seems like a new article has been selected.
4050 ;; `gnus-current-article' must be an article number.
4052 (set-buffer summary-buffer)
4053 (push article gnus-newsgroup-history)
4054 (setq gnus-last-article gnus-current-article
4055 gnus-current-article article
4056 gnus-current-headers
4057 (gnus-summary-article-header gnus-current-article)
4058 gnus-article-current
4059 (cons gnus-newsgroup-name gnus-current-article))
4060 (unless (vectorp gnus-current-headers)
4061 (setq gnus-current-headers nil))
4062 (gnus-summary-goto-subject gnus-current-article)
4063 (when (gnus-summary-show-thread)
4064 ;; If the summary buffer really was folded, the
4065 ;; previous goto may not actually have gone to
4066 ;; the right article, but the thread root instead.
4068 (gnus-summary-goto-subject gnus-current-article))
4069 (gnus-run-hooks 'gnus-mark-article-hook)
4070 (gnus-set-mode-line 'summary)
4071 (when (gnus-visual-p 'article-highlight 'highlight)
4072 (gnus-run-hooks 'gnus-visual-mark-article-hook))
4073 ;; Set the global newsgroup variables here.
4074 (gnus-set-global-variables)
4075 (setq gnus-have-all-headers
4076 (or all-headers gnus-show-all-headers))))
4078 (gnus-configure-windows 'article))
4079 (when (or (numberp article)
4081 (gnus-article-prepare-display)
4083 (goto-char (point-min))
4084 (when gnus-break-pages
4085 (gnus-narrow-to-page)))
4086 (let ((gnus-article-mime-handle-alist-1
4087 gnus-article-mime-handle-alist))
4088 (gnus-set-mode-line 'article))
4092 (set-window-point (get-buffer-window (current-buffer)) (point))
4093 (gnus-configure-windows 'article)
4096 (defun gnus-article-prepare-mime-display (&optional number)
4097 (goto-char (point-min))
4098 (when (re-search-forward "^[^\t ]+:" nil t)
4099 (goto-char (match-beginning 0)))
4100 (let ((entity (if (eq 1 (point-min))
4101 (get-text-property 1 'mime-view-entity)
4102 (get-text-property (point) 'mime-view-entity)))
4103 last-entity child-entity next type)
4104 (setq child-entity (mime-entity-children entity))
4106 (setq last-entity (nth (1- (length child-entity))
4108 (setq last-entity entity))
4110 (narrow-to-region (point)
4111 (if (search-forward "\n\n" nil t)
4114 (gnus-treat-article 'head)
4115 (put-text-property (point-min) (point-max) 'article-treated-header t)
4116 (goto-char (point-max)))
4117 (while (and (not (eobp)) entity)
4118 (setq next (set-marker
4120 (next-single-property-change (point) 'mime-view-entity
4122 (let ((types (mime-entity-content-type entity)))
4123 (while (eq 'multipart (mime-content-type-primary-type types))
4124 (setq entity (car (mime-entity-children entity))
4125 types (mime-entity-content-type entity)))
4127 (setq type (format "%s/%s"
4128 (mime-content-type-primary-type types)
4129 (mime-content-type-subtype types)))))
4130 (if (string-equal type "message/rfc822")
4133 (let ((children (mime-entity-children entity))
4136 (setq last-children (nth (1- (length children)) children))
4139 (not (eq last-children
4140 (get-text-property next 'mime-view-entity)))
4142 (next-single-property-change next
4144 nil (point-max)))))))
4145 (setq next (next-single-property-change next 'mime-view-entity
4148 (narrow-to-region (point) next)
4149 (gnus-article-prepare-mime-display)
4150 (goto-char (point-max)))
4151 (setq entity (get-text-property (point) 'mime-view-entity)))
4153 (narrow-to-region (point) next)
4154 ;; Kludge. We have to count true number, but for now,
4155 ;; part number is here only to achieve `last'.
4156 (gnus-treat-article nil 1
4157 (if (eq entity last-entity)
4160 (goto-char (point-max)))
4161 (setq entity (get-text-property next 'mime-view-entity))))))
4164 (defun gnus-article-prepare-display ()
4165 "Make the current buffer look like a nice article."
4166 (let ((gnus-article-buffer (current-buffer))
4168 (unless (eq major-mode 'gnus-article-mode)
4169 (gnus-article-mode))
4170 (setq buffer-read-only nil
4171 gnus-button-marker-list nil
4172 gnus-article-wash-types nil
4173 gnus-article-image-alist nil)
4176 (static-if (featurep 'xemacs)
4177 (map-extents (lambda (extent maparg) (delete-extent extent)))
4178 (let ((lists (overlay-lists)))
4179 (dolist (overlay (nconc (car lists) (cdr lists)))
4180 (delete-overlay overlay)))))
4181 (gnus-run-hooks 'gnus-tmp-internal-hook))
4182 (let ((show-mime (unless (member gnus-newsgroup-name '("nndraft:delayed"
4185 (inhibit-read-only t))
4186 (set-buffer gnus-original-article-buffer)
4188 (setq mime-message-structure gnus-current-headers)
4189 (mime-buffer-entity-set-buffer-internal mime-message-structure
4190 gnus-original-article-buffer)
4191 (mime-entity-set-representation-type-internal mime-message-structure
4192 'mime-buffer-entity)
4193 (luna-send mime-message-structure 'initialize-instance
4194 mime-message-structure)
4196 (let (mime-display-header-hook mime-display-text/plain-hook)
4197 (funcall gnus-article-display-method-for-mime))
4198 (funcall gnus-article-display-method-for-traditional))
4199 ;; Call the treatment functions.
4203 (gnus-article-prepare-mime-display)
4204 (narrow-to-region (goto-char (point-min))
4205 (if (search-forward "\n\n" nil t)
4208 (gnus-treat-article 'head)
4209 (put-text-property (point-min) (point-max) 'article-treated-header t)
4210 (goto-char (point-max))
4212 (narrow-to-region (point) (point-max))
4213 (gnus-treat-article nil))
4214 (put-text-property (point-min) (point-max) 'read-only nil)))
4215 (gnus-run-hooks 'gnus-article-prepare-hook))
4217 (defun gnus-article-decode-article-as-default-mime-charset ()
4218 "Decode an article as `default-mime-charset'. It won't work if the
4219 value of the variable `gnus-show-mime' is non-nil."
4220 (unless (or gnus-show-mime
4221 (member gnus-newsgroup-name '("nndraft:delayed"
4223 (set (make-local-variable 'default-mime-charset)
4224 (with-current-buffer gnus-summary-buffer
4225 default-mime-charset))
4226 (decode-mime-charset-region (point-min) (point-max)
4227 default-mime-charset)))
4230 ;;; Gnus MIME viewing functions
4233 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4234 "Format of the MIME buttons.
4236 Valid specifiers include:
4238 %T MIME type, along with additional info
4239 %n The `name' parameter
4240 %d The description, if any
4241 %l The length of the encoded part
4242 %p The part identifier number
4243 %e Dots if the part isn't displayed
4245 General format specifiers can also be used. See Info node
4246 `(gnus)Formatting Variables'.")
4248 (defvar gnus-mime-button-line-format-alist
4249 '((?t gnus-tmp-type ?s)
4250 (?T gnus-tmp-type-long ?s)
4251 (?n gnus-tmp-name ?s)
4252 (?d gnus-tmp-description ?s)
4254 (?l gnus-tmp-length ?d)
4255 (?e gnus-tmp-dots ?s)))
4257 (defvar gnus-mime-button-commands
4258 '((gnus-article-press-button "\r" "Toggle Display")
4259 (gnus-mime-view-part "v" "View Interactively...")
4260 (gnus-mime-view-part-as-type "t" "View As Type...")
4261 (gnus-mime-view-part-as-charset "C" "View As charset...")
4262 (gnus-mime-save-part "o" "Save...")
4263 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4264 (gnus-mime-delete-part "d" "Delete part")
4265 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4266 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4267 (gnus-mime-view-part-internally "E" "View Internally")
4268 (gnus-mime-view-part-externally "e" "View Externally")
4269 (gnus-mime-print-part "p" "Print")
4270 (gnus-mime-pipe-part "|" "Pipe To Command...")
4271 (gnus-mime-action-on-part "." "Take action on the part...")))
4273 (defun gnus-article-mime-part-status ()
4274 (with-current-buffer gnus-article-buffer
4275 (let ((entity (get-text-property (point-min) 'mime-view-entity))
4278 (setq children (mime-entity-children entity))
4279 (setq children (length children)))
4282 (format " (%d parts)" children))
4285 (defvar gnus-mime-button-map
4286 (let ((map (make-sparse-keymap)))
4287 (define-key map gnus-mouse-2 'gnus-article-push-button)
4288 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4289 (dolist (c gnus-mime-button-commands)
4290 (define-key map (cadr c) (car c)))
4294 gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4296 ,@(mapcar (lambda (c)
4297 (vector (caddr c) (car c) :enable t))
4298 gnus-mime-button-commands)))
4300 (defun gnus-mime-button-menu (event prefix)
4301 "Construct a context-sensitive menu of MIME commands."
4302 (interactive "e\nP")
4303 (save-window-excursion
4304 (let ((pos (event-start event)))
4305 (select-window (posn-window pos))
4306 (goto-char (posn-point pos))
4307 (gnus-article-check-buffer)
4308 (popup-menu gnus-mime-button-menu nil prefix))))
4310 (defun gnus-mime-view-all-parts (&optional handles)
4311 "View all the MIME parts."
4313 (with-current-buffer gnus-article-buffer
4314 (let ((handles (or handles gnus-article-mime-handles))
4315 (mail-parse-charset gnus-newsgroup-charset)
4316 (mail-parse-ignored-charsets
4317 (with-current-buffer gnus-summary-buffer
4318 gnus-newsgroup-ignored-charsets)))
4320 (mm-remove-parts handles)
4321 (goto-char (point-min))
4322 (or (search-forward "\n\n") (goto-char (point-max)))
4323 (let (buffer-read-only)
4324 (delete-region (point) (point-max))
4325 (mm-display-parts handles))))))
4328 (defsubst gnus-article-edit-part (handles)
4329 "Edit an article in order to delete a mime part.
4330 This function is exclusively used by `gnus-mime-save-part-and-strip'
4331 and `gnus-mime-delete-part', and not provided at run-time normally."
4332 (gnus-article-edit-article
4335 (let ((mail-parse-charset (or gnus-article-charset
4336 ',gnus-newsgroup-charset))
4337 (mail-parse-ignored-charsets
4338 (or gnus-article-ignored-charsets
4339 ',gnus-newsgroup-ignored-charsets))
4340 (mbl mml-buffer-list))
4341 (setq mml-buffer-list nil)
4342 (insert-buffer gnus-original-article-buffer)
4343 (mime-to-mml ',handles)
4344 (setq gnus-article-mime-handles nil)
4345 (let ((mbl1 mml-buffer-list))
4346 (setq mml-buffer-list mbl)
4347 (set (make-local-variable 'mml-buffer-list) mbl1))
4348 (gnus-make-local-hook 'kill-buffer-hook)
4349 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4350 `(lambda (no-highlight)
4351 (let ((mail-parse-charset (or gnus-article-charset
4352 ',gnus-newsgroup-charset))
4353 (message-options message-options)
4354 (message-options-set-recipient)
4355 (mail-parse-ignored-charsets
4356 (or gnus-article-ignored-charsets
4357 ',gnus-newsgroup-ignored-charsets)))
4359 (mml-destroy-buffers)
4360 (remove-hook 'kill-buffer-hook
4361 'mml-destroy-buffers t)
4362 (kill-local-variable 'mml-buffer-list))
4363 (gnus-summary-edit-article-done
4364 ,(or (mail-header-references gnus-current-headers) "")
4365 ,(gnus-group-read-only-p)
4366 ,gnus-summary-buffer no-highlight)))
4367 (gnus-article-edit-done)
4368 (gnus-summary-expand-window)
4369 (gnus-summary-show-article)))
4371 (defun gnus-mime-save-part-and-strip ()
4372 "Save the MIME part under point then replace it with an external body."
4374 (gnus-article-check-buffer)
4375 (when (gnus-group-read-only-p)
4376 (error "The current group does not support deleting of parts"))
4377 (when (mm-complicated-handles gnus-article-mime-handles)
4379 The current article has a complicated MIME structure, giving up..."))
4380 (when (gnus-yes-or-no-p "\
4381 Deleting parts may malfunction or destroy the article; continue? ")
4382 (let* ((data (get-text-property (point) 'gnus-data))
4384 (handles gnus-article-mime-handles))
4385 (setq file (and data (mm-save-part data)))
4387 (with-current-buffer (mm-handle-buffer data)
4389 (insert "Content-Type: " (mm-handle-media-type data))
4390 (mml-insert-parameter-string (cdr (mm-handle-type data))
4393 (insert "Content-ID: " (message-make-message-id) "\n")
4394 (insert "Content-Transfer-Encoding: binary\n")
4397 (cdr (mm-make-handle nil
4398 `("message/external-body"
4399 (access-type . "LOCAL-FILE")
4401 (set-buffer gnus-summary-buffer)
4402 (gnus-article-edit-part handles)))))
4404 (defun gnus-mime-delete-part ()
4405 "Delete the MIME part under point.
4406 Replace it with some information about the removed part."
4408 (gnus-article-check-buffer)
4409 (when (gnus-group-read-only-p)
4410 (error "The current group does not support deleting of parts"))
4411 (when (mm-complicated-handles gnus-article-mime-handles)
4413 The current article has a complicated MIME structure, giving up..."))
4414 (when (gnus-yes-or-no-p "\
4415 Deleting parts may malfunction or destroy the article; continue? ")
4416 (let* ((data (get-text-property (point) 'gnus-data))
4417 (handles gnus-article-mime-handles)
4421 (mail-decode-encoded-word-string (or (mm-handle-description data)
4424 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4426 (type (mm-handle-media-type data)))
4428 (error "No MIME part under point"))
4429 (with-current-buffer (mm-handle-buffer data)
4430 (let ((bsize (format "%s" (buffer-size))))
4435 "| The following attachment has been deleted:\n"
4437 "| Type: " type "\n"
4438 "| Filename: " filename "\n"
4439 "| Size (encoded): " bsize " Byte\n"
4440 "| Description: " description "\n"
4443 (cdr (mm-make-handle
4444 nil `("text/plain") nil nil
4446 (format "Deleted attachment (%s bytes)" bsize))))))
4447 (set-buffer gnus-summary-buffer)
4448 (gnus-article-edit-part handles))))
4450 (defun gnus-mime-save-part ()
4451 "Save the MIME part under point."
4453 (gnus-article-check-buffer)
4454 (let ((data (get-text-property (point) 'gnus-data)))
4456 (mm-save-part data))))
4458 (defun gnus-mime-pipe-part ()
4459 "Pipe the MIME part under point to a process."
4461 (gnus-article-check-buffer)
4462 (let ((data (get-text-property (point) 'gnus-data)))
4464 (mm-pipe-part data))))
4466 (defun gnus-mime-view-part ()
4467 "Interactively choose a viewing method for the MIME part under point."
4469 (gnus-article-check-buffer)
4470 (let ((data (get-text-property (point) 'gnus-data)))
4472 (setq gnus-article-mime-handles
4474 gnus-article-mime-handles (setq data (copy-sequence data))))
4475 (mm-interactively-view-part data))))
4477 (defun gnus-mime-view-part-as-type-internal ()
4478 (gnus-article-check-buffer)
4479 (let* ((name (mail-content-type-get
4480 (mm-handle-type (get-text-property (point) 'gnus-data))
4482 (def-type (and name (mm-default-file-encoding name))))
4483 (and def-type (cons def-type 0))))
4485 (defun gnus-mime-view-part-as-type (&optional mime-type)
4486 "Choose a MIME media type, and view the part as such."
4489 (setq mime-type (completing-read
4490 "View as MIME type: "
4491 (mapcar #'list (mailcap-mime-types))
4493 (gnus-mime-view-part-as-type-internal))))
4494 (gnus-article-check-buffer)
4495 (let ((handle (get-text-property (point) 'gnus-data)))
4498 (mm-make-handle (mm-handle-buffer handle)
4499 (cons mime-type (cdr (mm-handle-type handle)))
4500 (mm-handle-encoding handle)
4501 (mm-handle-undisplayer handle)
4502 (mm-handle-disposition handle)
4503 (mm-handle-description handle)
4505 (mm-handle-id handle)))
4506 (setq gnus-article-mime-handles
4507 (mm-merge-handles gnus-article-mime-handles handle))
4508 (gnus-mm-display-part handle))))
4511 (require 'jka-compr))
4513 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4514 ;; emacs can do that itself.
4516 (defun gnus-mime-jka-compr-maybe-uncompress ()
4517 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4518 The uncompress method used is derived from `buffer-file-name'."
4519 (when (and (fboundp 'jka-compr-installed-p)
4520 (jka-compr-installed-p))
4521 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4523 (let ((basename (file-name-nondirectory buffer-file-name))
4524 (args (jka-compr-info-uncompress-args info))
4525 (prog (jka-compr-info-uncompress-program info))
4526 (message (jka-compr-info-uncompress-message info))
4527 (err-file (jka-compr-make-temp-name)))
4529 (message "%s %s..." message basename))
4531 (unless (memq (apply 'call-process-region
4532 (point-min) (point-max)
4534 t (list t err-file) nil
4536 jka-compr-acceptable-retval-list)
4537 (jka-compr-error prog args basename message err-file))
4538 (jka-compr-delete-temp-file err-file)))))))
4540 (defun gnus-mime-copy-part (&optional handle)
4541 "Put the MIME part under point into a new buffer.
4542 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4545 (gnus-article-check-buffer)
4546 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4547 (contents (and handle (mm-get-part handle)))
4549 (file-name-nondirectory
4551 (mail-content-type-get (mm-handle-type handle) 'name)
4552 (mail-content-type-get (mm-handle-disposition handle)
4555 (buffer (and base (generate-new-buffer base))))
4557 (switch-to-buffer buffer)
4559 ;; We do it this way to make `normal-mode' set the appropriate mode.
4562 (setq buffer-file-name (expand-file-name base))
4563 (gnus-mime-jka-compr-maybe-uncompress)
4565 (setq buffer-file-name nil))
4566 (goto-char (point-min)))))
4568 (defun gnus-mime-print-part (&optional handle filename)
4569 "Print the MIME part under point."
4570 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4571 (gnus-article-check-buffer)
4572 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4573 (contents (and handle (mm-get-part handle)))
4574 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4575 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4580 (mm-save-part-to-file handle file)
4581 (call-process shell-file-name nil
4582 (generate-new-buffer " *mm*")
4584 shell-command-switch
4586 printer file (mm-handle-type handle))))
4590 (gnus-print-buffer))
4591 (ps-despool filename)))))
4593 (defun gnus-mime-inline-part (&optional handle arg)
4594 "Insert the MIME part under point into the current buffer."
4595 (interactive (list nil current-prefix-arg))
4596 (gnus-article-check-buffer)
4597 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4602 (if (and (not arg) (mm-handle-undisplayer handle))
4603 (mm-remove-part handle)
4604 (setq contents (mm-get-part handle))
4607 (setq charset (or (mail-content-type-get
4608 (mm-handle-type handle) 'charset)
4609 gnus-newsgroup-charset)))
4611 (if (mm-handle-undisplayer handle)
4612 (mm-remove-part handle))
4615 gnus-summary-show-article-charset-alist))
4616 (mm-read-coding-system "Charset: ")))))
4618 (mm-insert-inline handle
4620 (setq charset (mm-charset-to-coding-system
4622 (not (eq charset 'ascii)))
4623 (mm-decode-coding-string contents charset)
4627 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4628 "Insert the MIME part under point into the current buffer using the
4630 (interactive (list nil current-prefix-arg))
4631 (gnus-article-check-buffer)
4632 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4637 (if (mm-handle-undisplayer handle)
4638 (mm-remove-part handle))
4639 (let ((gnus-newsgroup-charset
4641 gnus-summary-show-article-charset-alist))
4642 (mm-read-coding-system "Charset: ")))
4643 (gnus-newsgroup-ignored-charsets 'gnus-all))
4644 (gnus-article-press-button)))))
4646 (defun gnus-mime-view-part-externally (&optional handle)
4647 "View the MIME part under point with an external viewer."
4649 (gnus-article-check-buffer)
4650 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4651 (mm-user-display-methods nil)
4652 (mm-inlined-types nil)
4653 (mail-parse-charset gnus-newsgroup-charset)
4654 (mail-parse-ignored-charsets
4655 (with-current-buffer gnus-summary-buffer
4656 gnus-newsgroup-ignored-charsets)))
4658 (if (mm-handle-undisplayer handle)
4659 (mm-remove-part handle)
4660 (mm-display-part handle)))))
4662 (defun gnus-mime-view-part-internally (&optional handle)
4663 "View the MIME part under point with an internal viewer.
4664 If no internal viewer is available, use an external viewer."
4666 (gnus-article-check-buffer)
4667 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4668 (mm-inlined-types '(".*"))
4669 (mm-inline-large-images t)
4670 (mail-parse-charset gnus-newsgroup-charset)
4671 (mail-parse-ignored-charsets
4672 (with-current-buffer gnus-summary-buffer
4673 gnus-newsgroup-ignored-charsets))
4676 (if (mm-handle-undisplayer handle)
4677 (mm-remove-part handle)
4678 (mm-display-part handle)))))
4680 (defun gnus-mime-action-on-part (&optional action)
4681 "Do something with the MIME attachment at \(point\)."
4683 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4684 (gnus-article-check-buffer)
4685 (let ((action-pair (assoc action gnus-mime-action-alist)))
4687 (funcall (cdr action-pair)))))
4689 (defun gnus-article-part-wrapper (n function)
4690 (with-current-buffer gnus-article-buffer
4691 (when (> n (length gnus-article-mime-handle-alist))
4692 (error "No such part"))
4693 (gnus-article-goto-part n)
4694 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4695 (funcall function handle))))
4697 (defun gnus-article-pipe-part (n)
4698 "Pipe MIME part N, which is the numerical prefix."
4700 (gnus-article-part-wrapper n 'mm-pipe-part))
4702 (defun gnus-article-save-part (n)
4703 "Save MIME part N, which is the numerical prefix."
4705 (gnus-article-part-wrapper n 'mm-save-part))
4707 (defun gnus-article-interactively-view-part (n)
4708 "View MIME part N interactively, which is the numerical prefix."
4710 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4712 (defun gnus-article-copy-part (n)
4713 "Copy MIME part N, which is the numerical prefix."
4715 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4717 (defun gnus-article-view-part-as-charset (n)
4718 "View MIME part N using a specified charset.
4719 N is the numerical prefix."
4721 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4723 (defun gnus-article-view-part-externally (n)
4724 "View MIME part N externally, which is the numerical prefix."
4726 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4728 (defun gnus-article-inline-part (n)
4729 "Inline MIME part N, which is the numerical prefix."
4731 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4733 (defun gnus-article-mime-match-handle-first (condition)
4735 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4736 (while (setq ihandle (pop alist))
4738 ((functionp condition)
4739 (funcall condition (cdr ihandle)))
4740 ((eq condition 'undisplayed)
4741 (not (or (mm-handle-undisplayer (cdr ihandle))
4742 (equal (mm-handle-media-type (cdr ihandle))
4743 "multipart/alternative"))))
4744 ((eq condition 'undisplayed-alternative)
4745 (not (mm-handle-undisplayer (cdr ihandle))))
4747 (gnus-article-goto-part (car ihandle))
4748 (or (not n) (< (car ihandle) n)))
4749 (setq n (car ihandle))))
4753 (defun gnus-article-view-part (&optional n)
4754 "View MIME part N, which is the numerical prefix."
4756 (with-current-buffer gnus-article-buffer
4757 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4758 gnus-article-mime-match-handle-function)))
4759 (when (> n (length gnus-article-mime-handle-alist))
4760 (error "No such part"))
4761 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4762 (when (gnus-article-goto-part n)
4763 (if (equal (car handle) "multipart/alternative")
4764 (gnus-article-press-button)
4765 (when (eq (gnus-mm-display-part handle) 'internal)
4766 (gnus-set-window-start)))))))
4768 (defsubst gnus-article-mime-total-parts ()
4769 (if (bufferp (car gnus-article-mime-handles))
4771 (1- (length gnus-article-mime-handles))))
4773 (defun gnus-mm-display-part (handle)
4774 "Display HANDLE and fix MIME button."
4775 (let ((id (get-text-property (point) 'gnus-part))
4780 (let ((window (selected-window))
4781 (mail-parse-charset gnus-newsgroup-charset)
4782 (mail-parse-ignored-charsets
4783 (if (gnus-buffer-live-p gnus-summary-buffer)
4784 (with-current-buffer gnus-summary-buffer
4785 gnus-newsgroup-ignored-charsets)
4789 (let ((win (gnus-get-buffer-window (current-buffer) t))
4792 (select-window win))
4795 (if (mm-handle-displayed-p handle)
4796 ;; This will remove the part.
4797 (mm-display-part handle)
4799 (narrow-to-region (point)
4800 (if (eobp) (point) (1+ (point))))
4801 (mm-display-part handle)
4802 ;; We narrow to the part itself and
4803 ;; then call the treatment functions.
4804 (goto-char (point-min))
4806 (narrow-to-region (point) (point-max))
4809 (gnus-article-mime-total-parts)
4810 (mm-handle-media-type handle)))))
4811 (if (window-live-p window)
4812 (select-window window)))))
4815 (gnus-insert-mime-button
4816 handle id (list (mm-handle-displayed-p handle)))
4817 (goto-char point))))
4819 (defun gnus-article-goto-part (n)
4820 "Go to MIME part N."
4821 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4823 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4824 (let ((gnus-tmp-name
4825 (or (mail-content-type-get (mm-handle-type handle) 'name)
4826 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4827 (mail-content-type-get (mm-handle-type handle) 'url)
4829 (gnus-tmp-type (mm-handle-media-type handle))
4830 (gnus-tmp-description
4831 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4834 (if (if displayed (car displayed)
4835 (mm-handle-displayed-p handle))
4837 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4839 gnus-tmp-type-long b e)
4840 (when (string-match ".*/" gnus-tmp-name)
4841 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4842 (setq gnus-tmp-type-long (concat gnus-tmp-type
4843 (and (not (equal gnus-tmp-name ""))
4844 (concat "; " gnus-tmp-name))))
4845 (unless (equal gnus-tmp-description "")
4846 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4851 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4852 `(keymap ,gnus-mime-button-map
4853 gnus-callback gnus-mm-display-part
4854 gnus-part ,gnus-tmp-id
4855 article-type annotation
4858 ;; Exclude a newline.
4861 (widget-convert-button
4864 :action 'gnus-widget-press-button
4865 :button-keymap gnus-mime-button-map
4867 (lambda (widget/window &optional overlay pos)
4868 ;; Needed to properly clear the message due to a bug in
4869 ;; wid-edit (XEmacs only).
4870 (if (boundp 'help-echo-owns-message)
4871 (setq help-echo-owns-message t))
4873 "%S: %s the MIME part; %S: more options"
4874 (aref gnus-mouse-2 0)
4875 ;; XEmacs will get a single widget arg; Emacs 21 will get
4876 ;; window, overlay, position.
4877 (if (mm-handle-displayed-p
4879 (with-current-buffer (gnus-overlay-buffer overlay)
4880 (widget-get (widget-at (gnus-overlay-start overlay))
4882 (widget-get widget/window :mime-handle)))
4884 (aref gnus-down-mouse-3 0))))))
4886 (defun gnus-widget-press-button (elems el)
4887 (goto-char (widget-get elems :from))
4888 (gnus-article-press-button))
4890 (defvar gnus-displaying-mime nil)
4892 (defun gnus-display-mime (&optional ihandles)
4893 "Display the MIME parts."
4895 (save-selected-window
4896 (let ((window (get-buffer-window gnus-article-buffer))
4899 (select-window window)
4900 ;; We have to do this since selecting the window
4901 ;; may change the point. So we set the window point.
4902 (set-window-point window point)))
4903 (let* ((handles (or ihandles
4904 (mm-dissect-buffer nil gnus-article-loose-mime)
4905 (and gnus-article-emulate-mime
4907 buffer-read-only handle name type b e display)
4908 (when (and (not ihandles)
4909 (not gnus-displaying-mime))
4910 ;; Top-level call; we clean up.
4911 (when gnus-article-mime-handles
4912 (mm-destroy-parts gnus-article-mime-handles)
4913 (setq gnus-article-mime-handle-alist nil));; A trick.
4914 (setq gnus-article-mime-handles handles)
4915 ;; We allow users to glean info from the handles.
4916 (when gnus-article-mime-part-function
4917 (gnus-mime-part-function handles)))
4919 (or (not (stringp (car handles)))
4922 (when (and (not ihandles)
4923 (not gnus-displaying-mime))
4924 ;; Clean up for mime parts.
4926 (delete-region (point) (point-max)))
4927 (let ((gnus-displaying-mime t))
4928 (gnus-mime-display-part handles)))
4931 (narrow-to-region (point) (point-max))
4932 (gnus-treat-article nil 1 1)
4935 ;; Highlight the headers.
4939 (narrow-to-region (point-min) (point))
4940 (gnus-treat-article 'head))))))))
4942 (defcustom gnus-mime-display-multipart-as-mixed nil
4943 "Display \"multipart\" parts as \"multipart/mixed\".
4945 If t, it overrides nil values of
4946 `gnus-mime-display-multipart-alternative-as-mixed' and
4947 `gnus-mime-display-multipart-related-as-mixed'."
4948 :group 'gnus-article-mime
4951 (defcustom gnus-mime-display-multipart-alternative-as-mixed nil
4952 "Display \"multipart/alternative\" parts as \"multipart/mixed\"."
4953 :group 'gnus-article-mime
4956 (defcustom gnus-mime-display-multipart-related-as-mixed nil
4957 "Display \"multipart/related\" parts as \"multipart/mixed\".
4959 If displaying \"text/html\" is discouraged \(see
4960 `mm-discouraged-alternatives'\) images or other material inside a
4961 \"multipart/related\" part might be overlooked when this variable is nil."
4962 :group 'gnus-article-mime
4965 (defun gnus-mime-display-part (handle)
4968 ((not (stringp (car handle)))
4969 (gnus-mime-display-single handle))
4970 ;; User-defined multipart
4971 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4972 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4974 ;; multipart/alternative
4975 ((and (equal (car handle) "multipart/alternative")
4976 (not (or gnus-mime-display-multipart-as-mixed
4977 gnus-mime-display-multipart-alternative-as-mixed)))
4978 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4979 (push (cons id handle) gnus-article-mime-handle-alist)
4980 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4981 ;; multipart/related
4982 ((and (equal (car handle) "multipart/related")
4983 (not (or gnus-mime-display-multipart-as-mixed
4984 gnus-mime-display-multipart-related-as-mixed)))
4985 ;;;!!!We should find the start part, but we just default
4986 ;;;!!!to the first part.
4987 ;;(gnus-mime-display-part (cadr handle))
4988 ;;;!!! Most multipart/related is an HTML message plus images.
4989 ;;;!!! Unfortunately we are unable to let W3 display those
4990 ;;;!!! included images, so we just display it as a mixed multipart.
4991 ;;(gnus-mime-display-mixed (cdr handle))
4992 ;;;!!! No, w3 can display everything just fine.
4993 (gnus-mime-display-part (cadr handle)))
4994 ((equal (car handle) "multipart/signed")
4995 (gnus-add-wash-type 'signed)
4996 (gnus-mime-display-security handle))
4997 ((equal (car handle) "multipart/encrypted")
4998 (gnus-add-wash-type 'encrypted)
4999 (gnus-mime-display-security handle))
5000 ;; Other multiparts are handled like multipart/mixed.
5002 (gnus-mime-display-mixed (cdr handle)))))
5004 (defun gnus-mime-part-function (handles)
5005 (if (stringp (car handles))
5006 (mapcar 'gnus-mime-part-function (cdr handles))
5007 (funcall gnus-article-mime-part-function handles)))
5009 (defun gnus-mime-display-mixed (handles)
5010 (mapcar 'gnus-mime-display-part handles))
5012 (defun gnus-mime-display-single (handle)
5013 (let ((type (mm-handle-media-type handle))
5014 (ignored gnus-ignored-mime-types)
5021 (when (string-match (pop ignored) type)
5022 (throw 'ignored nil)))
5023 (if (and (setq not-attachment
5024 (and (not (mm-inline-override-p handle))
5025 (or (not (mm-handle-disposition handle))
5026 (equal (car (mm-handle-disposition handle))
5028 (mm-attachment-override-p handle))))
5029 (mm-automatic-display-p handle)
5031 (mm-inlinable-p handle)
5032 (mm-inlined-p handle))
5033 (mm-automatic-external-display-p type)))
5035 (when (equal (mm-handle-media-supertype handle) "text")
5037 (let ((id (1+ (length gnus-article-mime-handle-alist)))
5039 (push (cons id handle) gnus-article-mime-handle-alist)
5040 (when (or (not display)
5041 (not (gnus-unbuttonized-mime-type-p type)))
5042 (gnus-insert-mime-button
5043 handle id (list (or display (and not-attachment text))))
5044 (gnus-article-insert-newline)
5045 ;; Remember modify the number of forward lines.
5053 (let ((mail-parse-charset gnus-newsgroup-charset)
5054 (mail-parse-ignored-charsets
5055 (save-excursion (condition-case ()
5056 (set-buffer gnus-summary-buffer)
5058 gnus-newsgroup-ignored-charsets)))
5059 (mm-display-part handle t))
5060 (goto-char (point-max)))
5061 ((and text not-attachment)
5065 (gnus-article-insert-newline)
5066 (mm-insert-inline handle (mm-get-part handle))
5067 (goto-char (point-max))))
5071 (narrow-to-region beg (point))
5074 (gnus-article-mime-total-parts)
5075 (mm-handle-media-type handle)))))))))
5077 (defun gnus-unbuttonized-mime-type-p (type)
5078 "Say whether TYPE is to be unbuttonized."
5079 (unless gnus-inhibit-mime-unbuttonizing
5081 (let ((types gnus-unbuttonized-mime-types))
5083 (when (string-match (pop types) type)
5084 (throw 'found t)))))
5086 (let ((types gnus-buttonized-mime-types))
5088 (when (string-match (pop types) type)
5089 (throw 'found t)))))))))
5091 (defun gnus-article-insert-newline ()
5092 "Insert a newline, but mark it as undeletable."
5093 (gnus-put-text-property
5094 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
5096 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
5097 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
5100 handle buffer-read-only from props begend not-pref)
5101 (save-window-excursion
5104 (narrow-to-region (car ibegend)
5107 (goto-char (car ibegend))
5110 (delete-region (point-min) (point-max))
5111 (mm-remove-parts handles))
5112 (setq begend (list (point-marker)))
5114 (unless (setq not-pref (cadr (member preferred ihandles)))
5115 (setq not-pref (car ihandles)))
5118 (not (gnus-unbuttonized-mime-type-p
5119 "multipart/alternative")))
5120 (gnus-add-text-properties
5123 (insert (format "%d. " id))
5127 (unless ,(not ibegend)
5128 (setq gnus-article-mime-handle-alist
5129 ',gnus-article-mime-handle-alist))
5130 (gnus-mime-display-alternative
5131 ',ihandles ',not-pref ',begend ,id))
5132 keymap ,gnus-mime-button-map
5133 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5134 face ,gnus-article-button-face
5137 (widget-convert-button 'link from (point)
5138 :action 'gnus-widget-press-button
5139 :button-keymap gnus-widget-button-keymap)
5141 (while (setq handle (pop handles))
5142 (gnus-add-text-properties
5145 (insert (format "(%c) %-18s"
5146 (if (equal handle preferred) ?* ? )
5147 (mm-handle-media-type handle)))
5151 (unless ,(not ibegend)
5152 (setq gnus-article-mime-handle-alist
5153 ',gnus-article-mime-handle-alist))
5154 (gnus-mime-display-alternative
5155 ',ihandles ',handle ',begend ,id))
5156 keymap ,gnus-mime-button-map
5157 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5158 face ,gnus-article-button-face
5161 (widget-convert-button 'link from (point)
5162 :action 'gnus-widget-press-button
5163 :button-keymap gnus-widget-button-keymap)
5167 (if (stringp (car preferred))
5168 (gnus-display-mime preferred)
5169 (let ((mail-parse-charset gnus-newsgroup-charset)
5170 (mail-parse-ignored-charsets
5171 (with-current-buffer gnus-summary-buffer
5172 gnus-newsgroup-ignored-charsets)))
5173 (mm-display-part preferred)
5177 (narrow-to-region (car begend) (point-max))
5179 nil (length gnus-article-mime-handle-alist)
5180 (gnus-article-mime-total-parts)
5181 (mm-handle-media-type handle))))))
5182 (goto-char (point-max))
5183 (setcdr begend (point-marker)))))
5185 (goto-char point))))
5187 (defconst gnus-article-wash-status-strings
5188 (let ((alist '((cite "c" "Possible hidden citation text"
5189 " " "All citation text visible")
5190 (headers "h" "Hidden headers"
5191 " " "All headers visible.")
5192 (pgp "p" "Encrypted or signed message status hidden"
5193 " " "No hidden encryption nor digital signature status")
5194 (signature "s" "Signature has been hidden"
5195 " " "Signature is visible")
5196 (overstrike "o" "Overstrike (^H) characters applied"
5197 " " "No overstrike characters applied")
5198 (gnus-show-mime "m" "Mime processing is activated"
5199 " " "Mime processing is not activated")
5200 (emphasis "e" "/*_Emphasis_*/ characters applied"
5201 " " "No /*_emphasis_*/ characters applied")))
5203 (dolist (entry alist result)
5204 (let ((key (nth 0 entry))
5205 (on (copy-sequence (nth 1 entry)))
5206 (on-help (nth 2 entry))
5207 (off (copy-sequence (nth 3 entry)))
5208 (off-help (nth 4 entry)))
5209 (put-text-property 0 1 'help-echo on-help on)
5210 (put-text-property 0 1 'help-echo off-help off)
5211 (push (list key on off) result))))
5212 "Alist of strings describing wash status in the mode line.
5213 Each entry has the form (KEY ON OF), where the KEY is a symbol
5214 representing the particular washing function, ON is the string to use
5215 in the article mode line when the washing function is active, and OFF
5216 is the string to use when it is inactive.")
5218 (defun gnus-article-wash-status-entry (key value)
5219 (let ((entry (assoc key gnus-article-wash-status-strings)))
5220 (if value (nth 1 entry) (nth 2 entry))))
5222 (defun gnus-article-wash-status ()
5223 "Return a string which display status of article washing."
5224 (with-current-buffer gnus-article-buffer
5225 (let ((cite (memq 'cite gnus-article-wash-types))
5226 (headers (memq 'headers gnus-article-wash-types))
5227 (boring (memq 'boring-headers gnus-article-wash-types))
5228 (pgp (memq 'pgp gnus-article-wash-types))
5229 (pem (memq 'pem gnus-article-wash-types))
5230 (signed (memq 'signed gnus-article-wash-types))
5231 (encrypted (memq 'encrypted gnus-article-wash-types))
5232 (signature (memq 'signature gnus-article-wash-types))
5233 (overstrike (memq 'overstrike gnus-article-wash-types))
5234 (emphasis (memq 'emphasis gnus-article-wash-types)))
5236 (gnus-article-wash-status-entry 'cite cite)
5237 (gnus-article-wash-status-entry 'headers (or headers boring))
5238 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5239 (gnus-article-wash-status-entry 'signature signature)
5240 (gnus-article-wash-status-entry 'overstrike overstrike)
5241 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
5242 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5244 (defun gnus-add-wash-type (type)
5245 "Add a washing of TYPE to the current status."
5246 (add-to-list 'gnus-article-wash-types type))
5248 (defun gnus-delete-wash-type (type)
5249 "Add a washing of TYPE to the current status."
5250 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5252 (defun gnus-add-image (category image)
5253 "Add IMAGE of CATEGORY to the list of displayed images."
5254 (let ((entry (assq category gnus-article-image-alist)))
5256 (setq entry (list category))
5257 (push entry gnus-article-image-alist))
5258 (nconc entry (list image))))
5260 (defun gnus-delete-images (category)
5261 "Delete all images in CATEGORY."
5262 (let ((entry (assq category gnus-article-image-alist)))
5263 (dolist (image (cdr entry))
5264 (gnus-remove-image image category))
5265 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5266 (gnus-delete-wash-type category)))
5268 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5270 (defun gnus-article-maybe-hide-headers ()
5271 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5272 Provided for backwards compatibility."
5273 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5274 (not (with-current-buffer gnus-summary-buffer
5275 gnus-have-all-headers)))
5276 (not gnus-inhibit-hiding))
5277 (gnus-article-hide-headers)))
5281 (defun gnus-output-to-file (file-name)
5282 "Append the current article to a file named FILE-NAME."
5283 (let ((artbuf (current-buffer)))
5285 (insert-buffer-substring artbuf)
5286 ;; Append newline at end of the buffer as separator, and then
5288 (goto-char (point-max))
5290 (let ((file-name-coding-system nnmail-pathname-coding-system))
5291 (write-region-as-binary (point-min) (point-max) file-name 'append))
5294 (defun gnus-narrow-to-page (&optional arg)
5295 "Narrow the article buffer to a page.
5296 If given a numerical ARG, move forward ARG pages."
5298 (setq arg (if arg (prefix-numeric-value arg) 0))
5300 (set-buffer gnus-article-buffer)
5301 (goto-char (point-min))
5303 ;; Remove any old next/prev buttons.
5304 (when (gnus-visual-p 'page-marker)
5305 (let ((buffer-read-only nil))
5306 (gnus-remove-text-with-property 'gnus-prev)
5307 (gnus-remove-text-with-property 'gnus-next)))
5310 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5312 (re-search-forward page-delimiter nil 'move arg)))
5313 (goto-char (match-end 0))
5315 (goto-char (point-min))
5316 (setq gnus-page-broken
5317 (and (re-search-forward page-delimiter nil t) t))))
5318 (when gnus-page-broken
5321 (if (re-search-forward page-delimiter nil 'move)
5324 (when (and (gnus-visual-p 'page-marker)
5325 (not (= (point-min) 1)))
5327 (goto-char (point-min))
5328 (gnus-insert-prev-page-button)))
5329 (when (and (gnus-visual-p 'page-marker)
5330 (< (+ (point-max) 2) (buffer-size)))
5332 (goto-char (point-max))
5333 (gnus-insert-next-page-button))))))
5335 ;; Article mode commands
5337 (defun gnus-article-goto-next-page ()
5338 "Show the next page of the article."
5340 (when (gnus-article-next-page)
5341 (goto-char (point-min))
5342 (gnus-article-read-summary-keys nil (gnus-character-to-event ?n))))
5345 (defun gnus-article-goto-prev-page ()
5346 "Show the previous page of the article."
5349 (gnus-article-read-summary-keys nil (gnus-character-to-event ?p))
5350 (gnus-article-prev-page nil)))
5352 ;; This is cleaner but currently breaks `gnus-pick-mode':
5354 ;; (defun gnus-article-goto-next-page ()
5355 ;; "Show the next page of the article."
5357 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5358 ;; (gnus-summary-next-page)))
5360 ;; (defun gnus-article-goto-prev-page ()
5361 ;; "Show the next page of the article."
5363 ;; (gnus-eval-in-buffer-window gnus-summary-buffer
5364 ;; (gnus-summary-prev-page)))
5366 (defun gnus-article-next-page (&optional lines)
5367 "Show the next page of the current article.
5368 If end of article, return non-nil. Otherwise return nil.
5369 Argument LINES specifies lines to be scrolled up."
5371 (move-to-window-line -1)
5374 (and (pos-visible-in-window-p) ;Not continuation line.
5375 (>= (1+ (point)) (point-max)))) ;Allow for trailing newline.
5376 ;; Nothing in this page.
5377 (if (or (not gnus-page-broken)
5381 (eobp)))) ;Real end-of-buffer?
5383 (when gnus-article-over-scroll
5384 (gnus-article-next-page-1 lines))
5386 (gnus-narrow-to-page 1) ;Go to next page.
5388 ;; More in this page.
5389 (gnus-article-next-page-1 lines)
5392 (defun gnus-article-next-page-1 (lines)
5393 (let ((scroll-in-place nil))
5397 ;; Long lines may cause an end-of-buffer error.
5398 (goto-char (point-max)))))
5399 (move-to-window-line 0))
5401 (defun gnus-article-prev-page (&optional lines)
5402 "Show previous page of current article.
5403 Argument LINES specifies lines to be scrolled down."
5405 (move-to-window-line 0)
5406 (if (and gnus-page-broken
5408 (not (save-restriction (widen) (bobp)))) ;Real beginning-of-buffer?
5410 (gnus-narrow-to-page -1) ;Go to previous page.
5411 (goto-char (point-max))
5413 (let ((scroll-in-place nil))
5417 (beginning-of-buffer
5418 (goto-char (point-min))))
5419 (move-to-window-line 0)))))
5421 (defun gnus-article-only-boring-p ()
5422 "Decide whether there is only boring text remaining in the article.
5423 Something \"interesting\" is a word of at least two letters that does
5424 not have a face in `gnus-article-boring-faces'."
5425 (when (and gnus-article-skip-boring
5426 (boundp 'gnus-article-boring-faces)
5427 (symbol-value 'gnus-article-boring-faces))
5430 (while (re-search-forward "\\b\\w\\w" nil t)
5432 (when (not (gnus-intersection
5433 (gnus-faces-at (point))
5434 (symbol-value 'gnus-article-boring-faces)))
5435 (throw 'only-boring nil)))
5436 (throw 'only-boring t)))))
5438 (defun gnus-article-refer-article ()
5439 "Read article specified by message-id around point."
5442 (re-search-backward "[ \t]\\|^" (point-at-bol) t)
5443 (re-search-forward "<?news:<?\\|<" (point-at-eol) t)
5444 (if (re-search-forward "[^@ ]+@[^ \t>]+" (point-at-eol) t)
5445 (let ((msg-id (concat "<" (match-string 0) ">")))
5446 (set-buffer gnus-summary-buffer)
5447 (gnus-summary-refer-article msg-id))
5448 (error "No references around point"))))
5450 (defun gnus-article-show-summary ()
5451 "Reconfigure windows to show summary buffer."
5453 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5454 (error "There is no summary buffer for this article buffer")
5455 (gnus-article-set-globals)
5456 (gnus-configure-windows 'article)
5457 (gnus-summary-goto-subject gnus-current-article)
5458 (gnus-summary-position-point)))
5460 (defun gnus-article-describe-briefly ()
5461 "Describe article mode commands briefly."
5463 (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")))
5465 (defun gnus-article-summary-command ()
5466 "Execute the last keystroke in the summary buffer."
5468 (let ((obuf (current-buffer))
5469 (owin (current-window-configuration))
5471 (switch-to-buffer gnus-article-current-summary 'norecord)
5472 (setq func (lookup-key (current-local-map) (this-command-keys)))
5473 (call-interactively func)
5475 (set-window-configuration owin)
5476 (set-window-point (get-buffer-window (current-buffer)) (point))))
5478 (defun gnus-article-summary-command-nosave ()
5479 "Execute the last keystroke in the summary buffer."
5482 (pop-to-buffer gnus-article-current-summary 'norecord)
5483 (setq func (lookup-key (current-local-map) (this-command-keys)))
5484 (call-interactively func)))
5486 (defun gnus-article-check-buffer ()
5487 "Beep if not in an article buffer."
5488 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5489 (error "Command invoked outside of a Gnus article buffer")))
5491 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5492 "Read a summary buffer key sequence and execute it from the article buffer."
5494 (gnus-article-check-buffer)
5496 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5497 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5498 "=" "^" "\M-^" "|"))
5504 '("n" "Gn" "p" "Gp"))
5507 (set-buffer gnus-article-current-summary)
5508 (let (gnus-pick-mode)
5509 (push (or key last-command-event) unread-command-events)
5510 (setq keys (static-if (featurep 'xemacs)
5511 (events-to-keys (read-key-sequence nil))
5512 (read-key-sequence nil)))))
5515 (if (or (member keys nosaves)
5516 (member keys nosave-but-article)
5517 (member keys nosave-in-article))
5519 (save-window-excursion
5520 (pop-to-buffer gnus-article-current-summary 'norecord)
5521 ;; We disable the pick minor mode commands.
5522 (let (gnus-pick-mode)
5523 (setq func (lookup-key (current-local-map) keys))))
5527 (unless (member keys nosave-in-article)
5528 (set-buffer gnus-article-current-summary))
5529 (call-interactively func)
5530 (setq new-sum-point (point)))
5531 (when (member keys nosave-but-article)
5532 (pop-to-buffer gnus-article-buffer 'norecord)))
5533 ;; These commands should restore window configuration.
5534 (let ((obuf (current-buffer))
5535 (owin (current-window-configuration))
5537 win func in-buffer selected new-sum-start new-sum-hscroll)
5538 (cond (not-restore-window
5539 (pop-to-buffer gnus-article-current-summary 'norecord))
5540 ((setq win (get-buffer-window gnus-article-current-summary))
5541 (select-window win))
5543 (switch-to-buffer gnus-article-current-summary 'norecord)))
5544 (setq in-buffer (current-buffer))
5545 ;; We disable the pick minor mode commands.
5546 (if (and (setq func (let (gnus-pick-mode)
5547 (lookup-key (current-local-map) keys)))
5550 (call-interactively func)
5551 (when (eq win (selected-window))
5552 (setq new-sum-point (point)
5553 new-sum-start (window-start win)
5554 new-sum-hscroll (window-hscroll win))
5555 (when (eq in-buffer (current-buffer))
5556 (setq selected (gnus-summary-select-article))
5558 (unless not-restore-window
5559 (set-window-configuration owin))
5560 (when (eq selected 'old)
5562 (set-window-start (get-buffer-window (current-buffer))
5564 (set-window-point (get-buffer-window (current-buffer))
5566 (when (and (not not-restore-window)
5568 (set-window-point win new-sum-point)
5569 (set-window-start win new-sum-start)
5570 (set-window-hscroll win new-sum-hscroll)))))
5571 (set-window-configuration owin)
5574 (defun gnus-article-describe-key (key)
5575 "Display documentation of the function invoked by KEY. KEY is a string."
5576 (interactive "kDescribe key: ")
5577 (gnus-article-check-buffer)
5578 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5580 (set-buffer gnus-article-current-summary)
5581 (let (gnus-pick-mode)
5582 (if (featurep 'xemacs)
5584 (push (elt key 0) unread-command-events)
5585 (setq key (events-to-keys
5586 (read-key-sequence "Describe key: "))))
5587 (setq unread-command-events
5589 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5591 (setq key (read-key-sequence "Describe key: "))))
5593 (describe-key key)))
5595 (defun gnus-article-describe-key-briefly (key &optional insert)
5596 "Display documentation of the function invoked by KEY. KEY is a string."
5597 (interactive "kDescribe key: \nP")
5598 (gnus-article-check-buffer)
5599 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5601 (set-buffer gnus-article-current-summary)
5602 (let (gnus-pick-mode)
5603 (if (featurep 'xemacs)
5605 (push (elt key 0) unread-command-events)
5606 (setq key (events-to-keys
5607 (read-key-sequence "Describe key: "))))
5608 (setq unread-command-events
5610 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5612 (setq key (read-key-sequence "Describe key: "))))
5613 (describe-key-briefly key insert))
5614 (describe-key-briefly key insert)))
5616 (defun gnus-article-reply-with-original (&optional wide)
5617 "Start composing a reply mail to the current message.
5618 The text in the region will be yanked. If the region isn't active,
5619 the entire article will be yanked."
5621 (let ((article (cdr gnus-article-current))
5623 (if (not (gnus-region-active-p))
5624 (with-current-buffer gnus-summary-buffer
5625 (gnus-summary-reply (list (list article)) wide))
5626 (setq contents (buffer-substring (point) (mark t)))
5627 ;; Deactivate active regions.
5628 (when (and (boundp 'transient-mark-mode)
5629 transient-mark-mode)
5630 (setq mark-active nil))
5631 (with-current-buffer gnus-summary-buffer
5633 (list (list article contents)) wide)))))
5635 (defun gnus-article-followup-with-original ()
5636 "Compose a followup to the current article.
5637 The text in the region will be yanked. If the region isn't active,
5638 the entire article will be yanked."
5640 (let ((article (cdr gnus-article-current))
5642 (if (not (gnus-region-active-p))
5643 (with-current-buffer gnus-summary-buffer
5644 (gnus-summary-followup (list (list article))))
5645 (setq contents (buffer-substring (point) (mark t)))
5646 ;; Deactivate active regions.
5647 (when (and (boundp 'transient-mark-mode)
5648 transient-mark-mode)
5649 (setq mark-active nil))
5650 (with-current-buffer gnus-summary-buffer
5651 (gnus-summary-followup
5652 (list (list article contents)))))))
5654 (defun gnus-article-hide (&optional arg force)
5655 "Hide all the gruft in the current article.
5656 This means that signatures, cited text and (some) headers will be
5658 If given a prefix, show the hidden text instead."
5659 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5660 (gnus-article-hide-headers arg)
5661 (gnus-article-hide-list-identifiers arg)
5662 (gnus-article-hide-citation-maybe arg force)
5663 (gnus-article-hide-signature arg))
5665 (defun gnus-article-maybe-highlight ()
5666 "Do some article highlighting if article highlighting is requested."
5667 (when (gnus-visual-p 'article-highlight 'highlight)
5668 (gnus-article-highlight-some)))
5670 (defun gnus-check-group-server ()
5671 ;; Make sure the connection to the server is alive.
5672 (unless (gnus-server-opened
5673 (gnus-find-method-for-group gnus-newsgroup-name))
5674 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5675 (gnus-request-group gnus-newsgroup-name t)))
5678 (autoload 'nneething-get-file-name "nneething"))
5680 (defun gnus-request-article-this-buffer (article group)
5681 "Get an article and insert it into this buffer."
5682 (let (do-update-line sparse-header)
5686 (gnus-kill-all-overlays)
5687 (setq group (or group gnus-newsgroup-name))
5689 ;; Using `gnus-request-article' directly will insert the article into
5690 ;; `nntp-server-buffer' - so we'll save some time by not having to
5691 ;; copy it from the server buffer into the article buffer.
5693 ;; We only request an article by message-id when we do not have the
5694 ;; headers for it, so we'll have to get those.
5695 (when (stringp article)
5696 (gnus-read-header article))
5698 ;; If the article number is negative, that means that this article
5699 ;; doesn't belong in this newsgroup (possibly), so we find its
5700 ;; message-id and request it by id instead of number.
5701 (when (and (numberp article)
5703 (get-buffer gnus-summary-buffer)
5704 (gnus-buffer-exists-p gnus-summary-buffer))
5706 (set-buffer gnus-summary-buffer)
5707 (let ((header (gnus-summary-article-header article)))
5710 ((memq article gnus-newsgroup-sparse)
5711 ;; This is a sparse gap article.
5712 (setq do-update-line article)
5713 (setq article (mail-header-id header))
5714 (setq sparse-header (gnus-read-header article))
5715 (setq gnus-newsgroup-sparse
5716 (delq article gnus-newsgroup-sparse)))
5718 ;; It's a real article.
5719 (setq article (mail-header-id header)))
5721 ;; It is an extracted pseudo-article.
5722 (setq article 'pseudo)
5723 (gnus-request-pseudo-article header))))
5725 (let ((method (gnus-find-method-for-group
5726 gnus-newsgroup-name)))
5727 (when (and (eq (car method) 'nneething)
5729 (let ((dir (nneething-get-file-name
5730 (mail-header-id header))))
5731 (when (and (stringp dir)
5732 (file-directory-p dir))
5733 (setq article 'nneething)
5734 (gnus-group-enter-directory dir))))))))
5737 ;; Refuse to select canceled articles.
5738 ((and (numberp article)
5740 (get-buffer gnus-summary-buffer)
5741 (gnus-buffer-exists-p gnus-summary-buffer)
5742 (eq (cdr (with-current-buffer gnus-summary-buffer
5743 (assq article gnus-newsgroup-reads)))
5744 gnus-canceled-mark))
5746 ;; We first check `gnus-original-article-buffer'.
5747 ((and (get-buffer gnus-original-article-buffer)
5749 (with-current-buffer gnus-original-article-buffer
5750 (and (equal (car gnus-original-article) group)
5751 (eq (cdr gnus-original-article) article))))
5752 (insert-buffer-substring gnus-original-article-buffer)
5754 ;; Check the backlog.
5755 ((and gnus-keep-backlog
5756 (gnus-backlog-request-article group article (current-buffer)))
5758 ;; Check asynchronous pre-fetch.
5759 ((gnus-async-request-fetched-article group article (current-buffer))
5760 (gnus-async-prefetch-next group article gnus-summary-buffer)
5761 (when (and (numberp article) gnus-keep-backlog)
5762 (gnus-backlog-enter-article group article (current-buffer)))
5765 ((and gnus-use-cache
5767 (gnus-cache-request-article article group))
5769 ;; Check the agent cache.
5770 ((gnus-agent-request-article article group)
5772 ;; Get the article and put into the article buffer.
5773 ((or (stringp article)
5775 (let ((gnus-override-method gnus-override-method)
5776 (methods (and (stringp article)
5777 gnus-refer-article-method))
5778 (backend (car (gnus-find-method-for-group
5779 gnus-newsgroup-name)))
5781 (buffer-read-only nil))
5782 (if (or (not (listp methods))
5783 (and (symbolp (car methods))
5784 (assq (car methods) nnoo-definition-alist)))
5785 (setq methods (list methods)))
5786 (when (and (null gnus-override-method)
5788 (setq gnus-override-method (pop methods)))
5790 (when (eq gnus-override-method 'current)
5791 (setq gnus-override-method
5792 (with-current-buffer gnus-summary-buffer
5793 gnus-current-select-method)))
5795 (gnus-kill-all-overlays)
5796 (let ((gnus-newsgroup-name group))
5797 (gnus-check-group-server))
5799 ((gnus-request-article article group (current-buffer))
5800 (when (numberp article)
5801 (gnus-async-prefetch-next group article
5802 gnus-summary-buffer)
5803 (when gnus-keep-backlog
5804 (gnus-backlog-enter-article
5805 group article (current-buffer))))
5806 (setq result 'article))
5808 (setq gnus-override-method (pop methods)))
5809 ((not (string-match "^400 "
5810 (nnheader-get-report backend)))
5811 ;; If we get 400 server disconnect, reconnect and
5812 ;; retry; otherwise, assume the article has expired.
5813 (setq result 'done))))
5814 (and (eq result 'article) 'article)))
5818 ;; Associate this article with the current summary buffer.
5819 (setq gnus-article-current-summary gnus-summary-buffer)
5821 ;; Take the article from the original article buffer
5822 ;; and place it in the buffer it's supposed to be in.
5823 (when (and (get-buffer gnus-article-buffer)
5824 (equal (buffer-name (current-buffer))
5825 (buffer-name (get-buffer gnus-article-buffer))))
5827 (if (get-buffer gnus-original-article-buffer)
5828 (set-buffer gnus-original-article-buffer)
5829 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5830 (buffer-disable-undo)
5831 (setq major-mode 'gnus-original-article-mode)
5832 (setq buffer-read-only t))
5833 (let (buffer-read-only)
5835 (insert-buffer-substring gnus-article-buffer))
5836 (setq gnus-original-article (cons group article)))
5839 (run-hooks 'gnus-article-decode-hook)
5840 ;; Mark article as decoded or not.
5841 (setq gnus-article-decoded-p gnus-article-decode-hook))
5843 ;; Update sparse articles.
5844 (when (and do-update-line
5845 (or (numberp article)
5847 (let ((buf (current-buffer)))
5848 (set-buffer gnus-summary-buffer)
5849 (gnus-summary-update-article do-update-line sparse-header)
5850 (gnus-summary-goto-subject do-update-line nil t)
5851 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5853 (set-buffer buf))))))
5859 (defcustom gnus-article-edit-mode-hook nil
5860 "Hook run in article edit mode buffers."
5861 :group 'gnus-article-various
5864 (defcustom gnus-article-edit-article-setup-function
5865 'gnus-article-mime-edit-article-setup
5866 "Function called to setup an editing article buffer."
5867 :group 'gnus-article-various
5870 (defvar gnus-article-edit-done-function nil)
5872 (defvar gnus-article-edit-mode-map nil)
5874 ;; Should we be using derived.el for this?
5875 (unless gnus-article-edit-mode-map
5876 (setq gnus-article-edit-mode-map (make-keymap))
5877 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5879 (gnus-define-keys gnus-article-edit-mode-map
5880 "\C-c?" describe-mode
5881 "\C-c\C-c" gnus-article-edit-done
5882 "\C-c\C-k" gnus-article-edit-exit
5883 "\C-c\C-f\C-t" message-goto-to
5884 "\C-c\C-f\C-o" message-goto-from
5885 "\C-c\C-f\C-b" message-goto-bcc
5886 ;;"\C-c\C-f\C-w" message-goto-fcc
5887 "\C-c\C-f\C-c" message-goto-cc
5888 "\C-c\C-f\C-s" message-goto-subject
5889 "\C-c\C-f\C-r" message-goto-reply-to
5890 "\C-c\C-f\C-n" message-goto-newsgroups
5891 "\C-c\C-f\C-d" message-goto-distribution
5892 "\C-c\C-f\C-f" message-goto-followup-to
5893 "\C-c\C-f\C-m" message-goto-mail-followup-to
5894 "\C-c\C-f\C-k" message-goto-keywords
5895 "\C-c\C-f\C-u" message-goto-summary
5896 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5897 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5898 "\C-c\C-b" message-goto-body
5899 "\C-c\C-i" message-goto-signature
5901 "\C-c\C-t" message-insert-to
5902 "\C-c\C-n" message-insert-newsgroups
5903 "\C-c\C-o" message-sort-headers
5904 "\C-c\C-e" message-elide-region
5905 "\C-c\C-v" message-delete-not-region
5906 "\C-c\C-z" message-kill-to-signature
5907 "\M-\r" message-newline-and-reformat
5908 "\C-c\C-a" mml-attach-file
5909 "\C-a" message-beginning-of-line
5911 "\M-;" comment-region)
5913 (gnus-define-keys (gnus-article-edit-wash-map
5914 "\C-c\C-w" gnus-article-edit-mode-map)
5915 "f" gnus-article-edit-full-stops))
5918 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5920 ["Fetch To" message-insert-to t]
5921 ["Fetch Newsgroups" message-insert-newsgroups t]
5923 ["To" message-goto-to t]
5924 ["From" message-goto-from t]
5925 ["Subject" message-goto-subject t]
5926 ["Cc" message-goto-cc t]
5927 ["Reply-To" message-goto-reply-to t]
5928 ["Summary" message-goto-summary t]
5929 ["Keywords" message-goto-keywords t]
5930 ["Newsgroups" message-goto-newsgroups t]
5931 ["Followup-To" message-goto-followup-to t]
5932 ["Mail-Followup-To" message-goto-mail-followup-to t]
5933 ["Distribution" message-goto-distribution t]
5934 ["Body" message-goto-body t]
5935 ["Signature" message-goto-signature t]))
5937 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5938 "Major mode for editing articles.
5939 This is an extended text-mode.
5941 \\{gnus-article-edit-mode-map}"
5942 (make-local-variable 'gnus-article-edit-done-function)
5943 (make-local-variable 'gnus-prev-winconf)
5944 (set (make-local-variable 'font-lock-defaults)
5945 '(message-font-lock-keywords t))
5946 (set (make-local-variable 'mail-header-separator) "")
5947 (set (make-local-variable 'gnus-article-edit-mode) t)
5948 (easy-menu-add message-mode-field-menu message-mode-map)
5949 (setq buffer-read-only nil)
5950 (buffer-enable-undo)
5953 (defun gnus-article-edit (&optional force)
5954 "Edit the current article.
5955 This will have permanent effect only in mail groups.
5956 If FORCE is non-nil, allow editing of articles even in read-only
5959 (when (and (not force)
5960 (gnus-group-read-only-p))
5961 (error "The current newsgroup does not support article editing"))
5962 (gnus-article-date-original)
5963 (gnus-article-edit-article
5965 `(lambda (no-highlight)
5967 (gnus-summary-edit-article-done
5968 ,(or (mail-header-references gnus-current-headers) "")
5969 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5971 (defun gnus-article-edit-article (start-func exit-func)
5972 "Start editing the contents of the current article buffer."
5973 (let ((winconf (current-window-configuration)))
5974 (set-buffer gnus-article-buffer)
5975 (gnus-article-edit-mode)
5976 (funcall start-func)
5977 (set-buffer-modified-p nil)
5978 (gnus-configure-windows 'edit-article)
5979 (setq gnus-article-edit-done-function exit-func)
5980 (setq gnus-prev-winconf winconf)
5981 (when gnus-article-edit-article-setup-function
5982 (funcall gnus-article-edit-article-setup-function))
5983 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit")))
5985 (defun gnus-article-edit-done (&optional arg)
5986 "Update the article edits and exit."
5988 (let ((func gnus-article-edit-done-function)
5989 (buf (current-buffer))
5990 (start (window-start))
5992 (winconf gnus-prev-winconf))
5993 (remove-hook 'gnus-article-mode-hook
5994 'gnus-article-mime-edit-article-unwind)
5995 (widen) ;; Widen it in case that users narrowed the buffer.
5998 ;; The cache and backlog have to be flushed somewhat.
5999 (when gnus-keep-backlog
6000 (gnus-backlog-remove-article
6001 (car gnus-article-current) (cdr gnus-article-current)))
6002 ;; Flush original article as well.
6004 (when (get-buffer gnus-original-article-buffer)
6005 (set-buffer gnus-original-article-buffer)
6006 (setq gnus-original-article nil)))
6007 (when gnus-use-cache
6008 (gnus-cache-update-article
6009 (car gnus-article-current) (cdr gnus-article-current)))
6010 ;; We remove all text props from the article buffer.
6011 (kill-all-local-variables)
6012 (set-text-properties (point-min) (point-max) nil)
6014 (set-window-configuration winconf)
6016 (set-window-start (get-buffer-window buf) start)
6017 (set-window-point (get-buffer-window buf) (point)))
6018 (gnus-summary-show-article))
6020 (defun gnus-article-edit-exit ()
6021 "Exit the article editing without updating."
6023 (when (or (not (buffer-modified-p))
6024 (yes-or-no-p "Article modified; kill anyway? "))
6025 (let ((curbuf (current-buffer))
6027 (window-start (window-start)))
6029 (if (gnus-buffer-live-p gnus-original-article-buffer)
6030 (insert-buffer-substring gnus-original-article-buffer))
6031 (let ((winconf gnus-prev-winconf))
6032 (kill-all-local-variables)
6034 (set-window-configuration winconf)
6035 ;; Tippy-toe some to make sure that point remains where it was.
6036 (save-current-buffer
6038 (set-window-start (get-buffer-window (current-buffer)) window-start)
6040 (gnus-summary-show-article)))
6042 (defun gnus-article-edit-full-stops ()
6043 "Interactively repair spacing at end of sentences."
6046 (goto-char (point-min))
6047 (search-forward-regexp "^$" nil t)
6048 (let ((case-fold-search nil))
6049 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
6052 ;;; Article editing with MIME-Edit
6055 (defcustom gnus-article-mime-edit-article-setup-hook nil
6056 "Hook run after setting up a MIME editing article buffer."
6057 :group 'gnus-article-various
6060 (defun gnus-article-mime-edit-article-unwind ()
6061 "Unwind `gnus-article-buffer' if article editing was given up."
6062 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6063 (when (featurep 'font-lock)
6064 (setq font-lock-defaults nil)
6065 (font-lock-mode -1))
6066 (when mime-edit-mode-flag
6067 (mime-edit-exit 'nomime 'no-error)
6070 (defun gnus-article-mime-edit-article-setup ()
6071 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
6072 after replacing with the original article."
6073 (setq gnus-show-mime t)
6074 (setq gnus-article-edit-done-function
6075 `(lambda (&rest args)
6076 (when mime-edit-mode-flag
6077 (let (mime-edit-insert-user-agent-field)
6080 (goto-char (point-min))
6081 (let (case-fold-search)
6082 (when (re-search-forward
6083 (format "^%s$" (regexp-quote mail-header-separator))
6085 (replace-match "")))
6086 (apply ,gnus-article-edit-done-function args)
6089 (buffer-substring-no-properties (point-min) (point-max))
6090 (set-buffer (get-buffer-create gnus-original-article-buffer))
6092 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6093 (set-buffer gnus-article-buffer)
6094 (gnus-article-prepare-display)))
6095 (substitute-key-definition 'gnus-article-edit-done
6096 'gnus-article-mime-edit-done
6097 gnus-article-edit-mode-map)
6098 (substitute-key-definition 'gnus-article-edit-exit
6099 'gnus-article-mime-edit-exit
6100 gnus-article-edit-mode-map)
6102 (insert-buffer-substring gnus-original-article-buffer)
6103 (unless (member (with-current-buffer gnus-summary-buffer
6104 gnus-newsgroup-name)
6105 '("nndraft:delayed" "nndraft:drafts"))
6106 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
6107 (fset 'mime-edit-decode-single-part-in-buffer
6108 (lambda (&rest args)
6109 (if (let ((content-type (car args)))
6110 (and (eq 'message (mime-content-type-primary-type
6112 (eq 'rfc822 (mime-content-type-subtype
6114 (setcar (cdr args) 'not-decode-text))
6118 (fset 'mime-edit-decode-single-part-in-buffer ofn))))
6119 (when (featurep 'font-lock)
6120 (set (make-local-variable 'font-lock-defaults)
6121 '(message-font-lock-keywords t))
6122 (font-lock-set-defaults)
6123 (turn-on-font-lock))
6124 (set-buffer-modified-p nil)
6125 (delete-other-windows)
6126 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
6127 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
6129 (defun gnus-article-mime-edit-done (&optional arg)
6130 "Update the article MIME edits and exit."
6132 (when (featurep 'font-lock)
6133 (setq font-lock-defaults nil)
6134 (font-lock-mode -1))
6135 (let ((inhibit-read-only t))
6136 (gnus-article-edit-done arg)))
6138 (defun gnus-article-mime-edit-exit ()
6139 "Exit the article MIME editing without updating."
6141 (when (or (not (buffer-modified-p))
6142 (yes-or-no-p "Article modified; kill anyway? "))
6143 (when (featurep 'font-lock)
6144 (setq font-lock-defaults nil)
6145 (font-lock-mode -1))
6146 (when mime-edit-mode-flag
6147 (let (mime-edit-insert-user-agent-field)
6150 (goto-char (point-min))
6151 (let (case-fold-search)
6152 (when (re-search-forward
6153 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
6154 (replace-match "")))
6155 (let ((winconf gnus-prev-winconf))
6157 (buffer-substring-no-properties (point-min) (point-max))
6158 (set-buffer (get-buffer-create gnus-original-article-buffer))
6160 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6161 (set-buffer gnus-article-buffer)
6162 (gnus-article-prepare-display)
6163 (set-window-configuration winconf))))
6166 ;;; Article highlights
6169 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6171 ;;; Internal Variables:
6173 (defcustom gnus-button-url-regexp
6174 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
6175 "\\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:]]\\)"
6176 "\\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\\)\\)")
6177 "Regular expression that matches URLs."
6178 :group 'gnus-article-buttons
6181 (defcustom gnus-button-valid-fqdn-regexp
6182 message-valid-fqdn-regexp
6183 "Regular expression that matches a valid FQDN."
6184 :group 'gnus-article-buttons
6187 (defcustom gnus-button-man-handler 'manual-entry
6188 "Function to use for displaying man pages.
6189 The function must take at least one argument with a string naming the
6191 :type '(choice (function-item :tag "Man" manual-entry)
6192 (function-item :tag "Woman" woman)
6193 (function :tag "Other"))
6194 :group 'gnus-article-buttons)
6196 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6197 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6198 If the default site is too slow, try to find a CTAN mirror, see
6199 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6200 the variable `gnus-button-handle-ctan'."
6201 :group 'gnus-article-buttons
6202 :link '(custom-manual "(gnus)Group Parameters")
6203 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6204 (const "http://tug.ctan.org/tex-archive/")
6205 (const "http://www.dante.de/CTAN/")
6206 (string :tag "Other")))
6208 (defcustom gnus-button-ctan-handler 'browse-url
6209 "Function to use for displaying CTAN links.
6210 The function must take one argument, the string naming the URL."
6211 :type '(choice (function-item :tag "Browse Url" browse-url)
6212 (function :tag "Other"))
6213 :group 'gnus-article-buttons)
6215 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6216 "Bogus strings removed from CTAN URLs."
6217 :group 'gnus-article-buttons
6218 :type '(choice (const "^/?tex-archive/\\|/")
6219 (regexp :tag "Other")))
6221 (defcustom gnus-button-ctan-directory-regexp
6224 "biblio\\|digests\\|dviware\\|fonts\\|graphics\\|help\\|"
6225 "indexing\\|info\\|language\\|macros\\|support\\|systems\\|"
6226 "tds\\|tools\\|usergrps\\|web\\|nonfree\\|obsolete"
6228 "Regular expression for ctan directories.
6229 It should match all directories in the top level of `gnus-ctan-url'."
6230 :group 'gnus-article-buttons
6233 (defcustom gnus-button-mid-or-mail-regexp
6234 (concat "\\b\\(<?[a-z0-9$%(*-=?[_][^<>\")!;:,{}\n\t ]*@"
6235 ;; Felix Wiemann in <87oeuomcz9.fsf@news2.ososo.de>
6236 gnus-button-valid-fqdn-regexp
6238 "Regular expression that matches a message ID or a mail address."
6239 :group 'gnus-article-buttons
6242 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6243 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6244 Strings like this can be either a message ID or a mail address. If it is one
6245 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6246 message ID or a mail address, respectively. If this variable is set to the
6247 symbol `ask', always query the user what do do. If it is a function, this
6248 function will be called with the string as it's only argument. The function
6249 must return `mid', `mail', `invalid' or `ask'."
6250 :group 'gnus-article-buttons
6251 :type '(choice (function-item :tag "Heuristic function"
6252 gnus-button-mid-or-mail-heuristic)
6257 (defcustom gnus-button-mid-or-mail-heuristic-alist
6258 '((-10.0 . ".+\\$.+@")
6261 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6262 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6263 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6264 (-1.0 . "^[^a-z]+@")
6266 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6267 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6268 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6269 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6272 (-1.0 . "^[0-9][0-9]")
6274 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6275 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6276 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6277 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6279 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6280 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6283 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6285 ;; compensation for TDMA dated mail addresses:
6286 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6288 (-20.0 . "\\.fsf@") ;; Gnus
6291 (-20.0 . "_-_") ;; Subject change in thread
6293 (-20.0 . "\\.ln@") ;; leafnode
6294 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6295 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6297 ;; (5.0 . "") ;; $local_part_len <= 7
6298 (10.0 . "^[^0-9]+@")
6299 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6300 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6303 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6305 (0.5 . "^[A-Z][a-z]")
6306 (0.5 . "^[A-Z][a-z][a-z]")
6307 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6308 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6309 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6311 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6312 address. The REGEXP is processed with `case-fold-search' set to nil."
6313 :group 'gnus-article-buttons
6314 :type '(repeat (cons (number :tag "Rate")
6315 (regexp :tag "Regexp"))))
6317 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6318 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6319 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6320 address, `ask' if unsure and `invalid' if the string is invalid."
6321 (let ((case-fold-search nil)
6322 (list gnus-button-mid-or-mail-heuristic-alist)
6323 (result 0) rate regexp lpartlen elem)
6325 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6326 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6327 ;; Certain special cases...
6330 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$\\|"
6331 "^[0-9]+\\.[0-9]+@compuserve\\|"
6332 "@public\\.gmane\\.org")
6334 (gnus-message 8 "`%s' is a known mail address." mid-or-mail)
6335 (setq result 'mail))
6336 (when (string-match "@.*@\\| " mid-or-mail)
6337 (gnus-message 8 "`%s' is invalid." mid-or-mail)
6338 (setq result 'invalid))
6339 ;; Nothing more to do, if result is not a number here...
6340 (when (numberp result)
6342 (setq elem (car list)
6346 (when (string-match regexp mid-or-mail)
6347 (setq result (+ result rate))
6349 9 "`%s' matched `%s', rate `%s', result `%s'."
6350 mid-or-mail regexp rate result)))
6351 (when (<= lpartlen 7)
6352 (setq result (+ result 5.0))
6353 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6354 mid-or-mail result))
6355 (when (>= lpartlen 12)
6356 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6358 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6359 ;; Long local part should contain realname if e-mail address,
6360 ;; too many digits: message-id.
6361 ;; $score -= 5.0 + 0.1 * $local_part_len;
6362 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6363 (setq result (+ result rate))
6365 9 "Many digits in `%s', rate `%s', result `%s'."
6366 mid-or-mail rate result))
6367 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6369 ;; Too few vowels [^aeiouy]{4,}.*\@
6370 (setq result (+ result -5.0))
6372 9 "Few vowels in `%s', rate `%s', result `%s'."
6373 mid-or-mail -5.0 result))
6375 (setq result (+ result 5.0))
6377 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6378 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6379 ;; Maybe we should make this a customizable alist: (condition . 'result)
6381 ((symbolp result) result)
6382 ;; Now convert number into proper results:
6383 ((< result -10.0) 'mid)
6384 ((> result 10.0) 'mail)
6387 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6388 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6389 (url-mid (concat "news" ":" mid-or-mail))
6390 (url-mailto (concat "mailto" ":" mid-or-mail)))
6391 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6392 (when (fboundp pref)
6394 ;; get rid of surrounding angles...
6396 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6397 (if (or (eq 'mid guessed) (eq 'mail guessed))
6401 (save-window-excursion
6402 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6405 (cond ((eq pref 'mid)
6406 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6407 (gnus-button-handle-news url-mid))
6409 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6410 (gnus-url-mailto url-mailto))
6411 (t (gnus-message 3 "Invalid string.")))))
6413 (defun gnus-button-handle-custom (url)
6414 "Follow a Custom URL."
6415 (customize-apropos (gnus-url-unhex-string url)))
6417 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6419 ;; FIXME: Maybe we should merge some of the functions that do quite similar
6422 (defun gnus-button-handle-describe-function (url)
6423 "Call `describe-function' when pushing the corresponding URL button."
6426 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6428 (defun gnus-button-handle-describe-variable (url)
6429 "Call `describe-variable' when pushing the corresponding URL button."
6432 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6434 (defun gnus-button-handle-symbol (url)
6435 "Display help on variable or function.
6436 Calls `describe-variable' or `describe-function'."
6437 (let ((sym (intern url)))
6439 ((fboundp sym) (describe-function sym))
6440 ((boundp sym) (describe-variable sym))
6441 (t (gnus-message 3 "`%s' is not a known function of variable." url)))))
6443 (defun gnus-button-handle-describe-key (url)
6444 "Call `describe-key' when pushing the corresponding URL button."
6446 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6447 (keys (ignore-errors (eval `(kbd ,key-string)))))
6450 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6452 (defun gnus-button-handle-apropos (url)
6453 "Call `apropos' when pushing the corresponding URL button."
6454 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6456 (defun gnus-button-handle-apropos-command (url)
6457 "Call `apropos' when pushing the corresponding URL button."
6459 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6461 (defun gnus-button-handle-apropos-variable (url)
6462 "Call `apropos' when pushing the corresponding URL button."
6464 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6465 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6467 (defun gnus-button-handle-apropos-documentation (url)
6468 "Call `apropos' when pushing the corresponding URL button."
6470 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6471 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6473 (defun gnus-button-handle-library (url)
6474 "Call `locate-library' when pushing the corresponding URL button."
6475 (gnus-message 9 "url=`%s'" url)
6476 (let* ((lib (locate-library url))
6477 (file (gnus-replace-in-string (or lib "") "\.elc" ".el")))
6479 (gnus-message 1 "Cannot locale library `%s'." url)
6480 (find-file-read-only file))))
6482 (defun gnus-button-handle-ctan (url)
6483 "Call `browse-url' when pushing a CTAN URL button."
6485 gnus-button-ctan-handler
6488 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6490 (defcustom gnus-button-tex-level 5
6491 "*Integer that says how many TeX-related buttons Gnus will show.
6492 The higher the number, the more buttons will appear and the more false
6493 positives are possible. Note that you can set this variable local to
6494 specific groups. Setting it higher in TeX groups is probably a good idea.
6495 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6496 how to set variables in specific groups."
6497 :group 'gnus-article-buttons
6498 :link '(custom-manual "(gnus)Group Parameters")
6501 (defcustom gnus-button-man-level 5
6502 "*Integer that says how many man-related buttons Gnus will show.
6503 The higher the number, the more buttons will appear and the more false
6504 positives are possible. Note that you can set this variable local to
6505 specific groups. Setting it higher in Unix groups is probably a good idea.
6506 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6507 how to set variables in specific groups."
6508 :group 'gnus-article-buttons
6509 :link '(custom-manual "(gnus)Group Parameters")
6512 (defcustom gnus-button-emacs-level 5
6513 "*Integer that says how many emacs-related buttons Gnus will show.
6514 The higher the number, the more buttons will appear and the more false
6515 positives are possible. Note that you can set this variable local to
6516 specific groups. Setting it higher in Emacs or Gnus related groups is
6517 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6518 `gnus-parameters' on how to set variables in specific groups."
6519 :group 'gnus-article-buttons
6520 :link '(custom-manual "(gnus)Group Parameters")
6523 (defcustom gnus-button-message-level 5
6524 "*Integer that says how many buttons for news or mail messages will appear.
6525 The higher the number, the more buttons will appear and the more false
6526 positives are possible."
6527 ;; mail addresses, MIDs, URLs for news, ...
6528 :group 'gnus-article-buttons
6531 (defcustom gnus-button-browse-level 5
6532 "*Integer that says how many buttons for browsing will appear.
6533 The higher the number, the more buttons will appear and the more false
6534 positives are possible."
6535 ;; stuff handled by `browse-url' or `gnus-button-embedded-url'
6536 :group 'gnus-article-buttons
6539 (defcustom gnus-button-alist
6540 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6541 0 (>= gnus-button-message-level 0) gnus-button-handle-news 3)
6542 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6543 gnus-button-handle-news 2)
6544 ("\\(\\b<\\(url:[>\n\t ]*\\)?\\(nntp\\|news\\):[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6545 1 (>= gnus-button-message-level 0) gnus-button-fetch-group 5)
6546 ("\\b\\(nntp\\|news\\):\\(//\\)?\\([^'\">\n\t ]+\\)"
6547 0 (>= gnus-button-message-level 0) gnus-button-fetch-group 3)
6548 ;; RFC 2392 (Don't allow `/' in domain part --> CID)
6549 ("\\bmid:\\(//\\)?\\([^'\">\n\t ]+@[^'\">\n\t /]+\\)"
6550 0 (>= gnus-button-message-level 0) gnus-button-message-id 2)
6551 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)"
6552 2 (>= gnus-button-message-level 0) gnus-button-message-id 3)
6553 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>"
6554 0 (>= gnus-button-message-level 0) gnus-url-mailto 2)
6555 ;; RFC 2368 (The mailto URL scheme)
6556 ("\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6557 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6558 ("\\bmailto:\\([^ \n\t]+\\)"
6559 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6561 ((concat "\\bCTAN:[ \t\n]?[^>)!;:,'\n\t ]*\\("
6562 gnus-button-ctan-directory-regexp
6563 "[^][>)!;:,'\n\t ]+\\)")
6564 0 (>= gnus-button-tex-level 1) gnus-button-handle-ctan 1)
6565 ((concat "\\btex-archive/\\("
6566 gnus-button-ctan-directory-regexp
6567 "/[-_.a-z0-9/]+[-_./a-z0-9]+[/a-z0-9]\\)")
6568 1 (>= gnus-button-tex-level 6) gnus-button-handle-ctan 1)
6571 gnus-button-ctan-directory-regexp
6572 "/[-_.a-z0-9]+/[-_./a-z0-9]+[/a-z0-9]\\)")
6573 1 (>= gnus-button-tex-level 8) gnus-button-handle-ctan 1)
6574 ;; This is info (home-grown style) <info://foo/bar+baz>
6575 ("\\binfo://\\([^'\">\n\t ]+\\)"
6576 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 1)
6577 ;; Info GNOME style <info:foo#bar_baz>
6578 ("\\binfo:\\([^('\n\t\r \"><][^'\n\t\r \"><]*\\)"
6579 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-gnome 1)
6580 ;; Info KDE style <info:(foo)bar baz>
6581 ("<\\(info:\\(([^)]+)[^>\n\r]*\\)\\)>"
6582 1 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url-kde 2)
6583 ("\\((Info-goto-node\\|(info\\)[ \t\n]*\\(\"[^\"]*\"\\))" 0
6584 (>= gnus-button-emacs-level 1) gnus-button-handle-info-url 2)
6585 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+i[ \t\n]+d?[ \t\n]?m[ \t\n]+\\([^ ]+ ?[^ ]+\\)[ \t\n]+RET"
6586 ;; Info links like `C-h i d m CC Mode RET'
6587 0 (>= gnus-button-emacs-level 1) gnus-button-handle-info-keystrokes 2)
6589 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)"
6590 0 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6591 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6592 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6593 ;; Emacs help commands
6594 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6595 ;; regexp doesn't match arguments containing ` '.
6596 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6597 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6598 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6599 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6600 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6601 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6602 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6603 ;; The following entries may lead to many false positives so don't enable
6604 ;; them by default (use a high button level):
6605 ("/\\([a-z][-a-z0-9]+\\.el\\)\\>"
6606 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6607 ("`\\([a-z][-a-z0-9]+\\.el\\)'"
6608 1 (>= gnus-button-emacs-level 8) gnus-button-handle-library 1)
6609 ("`\\([a-z][a-z0-9]+-[a-z]+-[-a-z]+\\|\\(gnus\\|message\\)-[-a-z]+\\)'"
6610 0 (>= gnus-button-emacs-level 8) gnus-button-handle-symbol 1)
6611 ("`\\([a-z][a-z0-9]+-[a-z]+\\)'"
6612 0 (>= gnus-button-emacs-level 9) gnus-button-handle-symbol 1)
6613 ("(setq[ \t\n]+\\([a-z][a-z0-9]+-[-a-z0-9]+\\)[ \t\n]+.+)"
6614 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-variable 1)
6615 ("\\bM-x[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6616 1 (>= gnus-button-emacs-level 7) gnus-button-handle-describe-function 1)
6617 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6618 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6619 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6620 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6621 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'"
6622 ;; Unlike the other regexps we really have to require quoting
6623 ;; here to determine where it ends.
6624 1 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6625 ;; This is how URLs _should_ be embedded in text (RFC 1738, RFC 2396)...
6626 ("<URL: *\\([^<>]*\\)>"
6627 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6628 ;; RFC 2396 (2.4.3., delims) ...
6629 ("\"URL: *\\([^\"]*\\)\""
6630 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6631 ;; RFC 2396 (2.4.3., delims) ...
6632 ("\"URL: *\\([^\"]*\\)\""
6633 1 (>= gnus-button-browse-level 0) gnus-button-embedded-url 1)
6635 (gnus-button-url-regexp
6636 0 (>= gnus-button-browse-level 0) browse-url 0)
6638 ("\\b\\([a-z][a-z]+\\)([1-9])\\W"
6639 0 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6640 gnus-button-handle-man 1)
6641 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6642 ("\\b\\([a-z][-_.a-z0-9]+\\)([1-9])\\W"
6643 0 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6644 gnus-button-handle-man 1)
6645 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6646 ;; SoWWWAnchor(3iv), XSelectInput(3X11), X(1), X(7)
6647 ("\\b\\([a-z][-+_.:a-z0-9]+\\)([1-9][X1a-z]*)\\W\\|\\b\\(X\\)([1-9])\\W"
6648 0 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6649 ;; MID or mail: To avoid too many false positives we don't try to catch
6650 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6651 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6652 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6653 ;; so that non-ambiguous entries (see above) match first.
6654 (gnus-button-mid-or-mail-regexp
6655 0 (>= gnus-button-message-level 5) gnus-button-handle-mid-or-mail 1))
6656 "*Alist of regexps matching buttons in article bodies.
6658 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6659 REGEXP: is the string (case insensitive) matching text around the button (can
6660 also be Lisp expression evaluating to a string),
6661 BUTTON: is the number of the regexp grouping actually matching the button,
6662 FORM: is a Lisp expression which must eval to true for the button to
6664 CALLBACK: is the function to call when the user push this button, and each
6665 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6667 CALLBACK can also be a variable, in that case the value of that
6668 variable it the real callback function."
6669 :group 'gnus-article-buttons
6670 :type '(repeat (list (choice regexp variable sexp)
6671 (integer :tag "Button")
6673 (function :tag "Callback")
6676 (integer :tag "Regexp group")))))
6678 (defcustom gnus-header-button-alist
6679 '(("^\\(References\\|Message-I[Dd]\\|^In-Reply-To\\):" "<[^<>]+>"
6680 0 (>= gnus-button-message-level 0) gnus-button-message-id 0)
6681 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$"
6682 1 (>= gnus-button-message-level 0) gnus-button-reply 1)
6683 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6684 0 (>= gnus-button-message-level 0) gnus-button-mailto 0)
6685 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp
6686 0 (>= gnus-button-browse-level 0) browse-url 0)
6687 ("^Subject:" gnus-button-url-regexp
6688 0 (>= gnus-button-browse-level 0) browse-url 0)
6689 ("^[^:]+:" gnus-button-url-regexp
6690 0 (>= gnus-button-browse-level 0) browse-url 0)
6691 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?&/]+\\)"
6692 0 (>= gnus-button-message-level 0) gnus-url-mailto 1)
6693 ("^[^:]+:" "\\(<\\(url: \\)?\\(nntp\\|news\\):\\([^>\n ]*\\)>\\)"
6694 1 (>= gnus-button-message-level 0) gnus-button-message-id 4))
6695 "*Alist of headers and regexps to match buttons in article heads.
6697 This alist is very similar to `gnus-button-alist', except that each
6698 alist has an additional HEADER element first in each entry:
6700 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6702 HEADER is a regexp to match a header. For a fuller explanation, see
6703 `gnus-button-alist'."
6704 :group 'gnus-article-buttons
6705 :group 'gnus-article-headers
6706 :type '(repeat (list (regexp :tag "Header")
6707 (choice regexp variable)
6708 (integer :tag "Button")
6710 (function :tag "Callback")
6713 (integer :tag "Regexp group")))))
6717 (defun gnus-article-push-button (event)
6718 "Check text under the mouse pointer for a callback function.
6719 If the text under the mouse pointer has a `gnus-callback' property,
6720 call it with the value of the `gnus-data' text property."
6722 (set-buffer (window-buffer (posn-window (event-start event))))
6723 (let* ((pos (posn-point (event-start event)))
6724 (data (get-text-property pos 'gnus-data))
6725 (fun (get-text-property pos 'gnus-callback)))
6728 (funcall fun data))))
6730 (defun gnus-article-press-button ()
6731 "Check text at point for a callback function.
6732 If the text at point has a `gnus-callback' property,
6733 call it with the value of the `gnus-data' text property."
6735 (let ((data (get-text-property (point) 'gnus-data))
6736 (fun (get-text-property (point) 'gnus-callback)))
6738 (funcall fun data))))
6740 (defun gnus-article-prev-button (n)
6741 "Move point to N buttons backward.
6742 If N is negative, move forward instead."
6744 (gnus-article-next-button (- n)))
6746 (defun gnus-article-next-button (n)
6747 "Move point to N buttons forward.
6748 If N is negative, move backward instead."
6750 (let ((function (if (< n 0) 'previous-single-property-change
6751 'next-single-property-change))
6752 (inhibit-point-motion-hooks t)
6754 (limit (if (< n 0) (point-min) (point-max))))
6756 (while (and (not (= limit (point)))
6758 ;; Skip past the current button.
6759 (when (get-text-property (point) 'gnus-callback)
6760 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6761 ;; Go to the next (or previous) button.
6762 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
6763 ;; Put point at the start of the button.
6764 (when (and backward (not (get-text-property (point) 'gnus-callback)))
6765 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6766 ;; Skip past intangible buttons.
6767 (when (get-text-property (point) 'intangible)
6771 (gnus-message 5 "No more buttons"))
6774 (defun gnus-article-highlight (&optional force)
6775 "Highlight current article.
6776 This function calls `gnus-article-highlight-headers',
6777 `gnus-article-highlight-citation',
6778 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6779 do the highlighting. See the documentation for those functions."
6780 (interactive (list 'force))
6781 (gnus-article-highlight-headers)
6782 (gnus-article-highlight-citation force)
6783 (gnus-article-highlight-signature)
6784 (gnus-article-add-buttons force)
6785 (gnus-article-add-buttons-to-head))
6787 (defun gnus-article-highlight-some (&optional force)
6788 "Highlight current article.
6789 This function calls `gnus-article-highlight-headers',
6790 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6791 do the highlighting. See the documentation for those functions."
6792 (interactive (list 'force))
6793 (gnus-article-highlight-headers)
6794 (gnus-article-highlight-signature)
6795 (gnus-article-add-buttons))
6797 (defun gnus-article-highlight-headers ()
6798 "Highlight article headers as specified by `gnus-header-face-alist'."
6800 (gnus-with-article-headers
6801 (let ((alist gnus-header-face-alist)
6802 entry regexp header-face field-face from hpoints fpoints)
6803 (while (setq entry (pop alist))
6804 (goto-char (point-min))
6805 (setq regexp (concat "^\\("
6806 (if (string-equal "" (nth 0 entry))
6810 header-face (nth 1 entry)
6811 field-face (nth 2 entry))
6812 (while (and (re-search-forward regexp nil t)
6816 (unless (search-forward ":" nil t)
6818 (when (and header-face
6819 (not (memq (point) hpoints)))
6820 (push (point) hpoints)
6821 (gnus-put-text-property from (point) 'face header-face))
6822 (when (and field-face
6823 (not (memq (setq from (point)) fpoints)))
6825 (if (re-search-forward "^[^ \t]" nil t)
6827 (goto-char (point-max)))
6828 (gnus-put-text-property from (point) 'face field-face)))))))
6830 (defun gnus-article-highlight-signature ()
6831 "Highlight the signature in an article.
6832 It does this by highlighting everything after
6833 `gnus-signature-separator' using `gnus-signature-face'."
6835 (when gnus-signature-face
6836 (gnus-with-article-buffer
6837 (let ((inhibit-point-motion-hooks t))
6839 (when (gnus-article-narrow-to-signature)
6840 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6841 'face gnus-signature-face)))))))
6843 (defun gnus-article-buttonize-signature ()
6844 "Add button to the signature."
6847 (set-buffer gnus-article-buffer)
6848 (let ((buffer-read-only nil)
6849 (inhibit-point-motion-hooks t))
6850 (when (gnus-article-search-signature)
6851 (gnus-article-add-button (match-beginning 0) (match-end 0)
6852 'gnus-signature-toggle
6853 (set-marker (make-marker)
6854 (1+ (match-end 0))))))))
6856 (defun gnus-button-in-region-p (b e prop)
6857 "Say whether PROP exists in the region."
6858 (text-property-not-all b e prop nil))
6860 (defun gnus-article-add-buttons (&optional force)
6861 "Find external references in the article and make buttons of them.
6862 \"External references\" are things like Message-IDs and URLs, as
6863 specified by `gnus-button-alist'."
6864 (interactive (list 'force))
6865 (gnus-with-article-buffer
6866 (let ((inhibit-point-motion-hooks t)
6867 (case-fold-search t)
6868 (alist gnus-button-alist)
6870 ;; Remove all old markers.
6871 (let (marker entry new-list)
6872 (while (setq marker (pop gnus-button-marker-list))
6873 (if (or (< marker (point-min)) (>= marker (point-max)))
6874 (push marker new-list)
6876 (when (setq entry (gnus-button-entry))
6877 (put-text-property (match-beginning (nth 1 entry))
6878 (match-end (nth 1 entry))
6879 'gnus-callback nil))
6880 (set-marker marker nil)))
6881 (setq gnus-button-marker-list new-list))
6882 ;; We skip the headers.
6885 (while (setq entry (pop alist))
6886 (setq regexp (eval (car entry)))
6888 (while (re-search-forward regexp nil t)
6889 (let* ((start (and entry (match-beginning (nth 1 entry))))
6890 (end (and entry (match-end (nth 1 entry))))
6891 (from (match-beginning 0)))
6892 (when (and (or (eq t (nth 2 entry))
6893 (eval (nth 2 entry)))
6894 (not (gnus-button-in-region-p
6895 start end 'gnus-callback)))
6896 ;; That optional form returned non-nil, so we add the
6898 (gnus-article-add-button
6899 start end 'gnus-button-push
6900 (car (push (set-marker (make-marker) from)
6901 gnus-button-marker-list))))))))))
6903 ;; Add buttons to the head of an article.
6904 (defun gnus-article-add-buttons-to-head ()
6905 "Add buttons to the head of the article."
6907 (gnus-with-article-headers
6908 (let ((alist gnus-header-button-alist)
6911 ;; Each alist entry.
6912 (setq entry (pop alist))
6913 (goto-char (point-min))
6914 (while (re-search-forward (car entry) nil t)
6915 ;; Each header matching the entry.
6916 (setq beg (match-beginning 0))
6917 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6918 (match-beginning 0))
6921 (while (re-search-forward (eval (nth 1 entry)) end t)
6922 ;; Each match within a header.
6923 (let* ((entry (cdr entry))
6924 (start (match-beginning (nth 1 entry)))
6925 (end (match-end (nth 1 entry)))
6926 (form (nth 2 entry)))
6927 (goto-char (match-end 0))
6929 (gnus-article-add-button
6930 start end (nth 3 entry)
6931 (buffer-substring (match-beginning (nth 4 entry))
6932 (match-end (nth 4 entry)))))))
6933 (goto-char end))))))
6935 ;;; External functions:
6937 (defun gnus-article-add-button (from to fun &optional data)
6938 "Create a button between FROM and TO with callback FUN and data DATA."
6939 (when gnus-article-button-face
6940 (gnus-overlay-put (gnus-make-overlay from to)
6941 'face gnus-article-button-face))
6942 (gnus-add-text-properties
6944 (nconc (and gnus-article-mouse-face
6945 (list gnus-mouse-face-prop gnus-article-mouse-face))
6946 (list 'gnus-callback fun)
6947 (and data (list 'gnus-data data))))
6948 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6949 :button-keymap gnus-widget-button-keymap))
6951 ;;; Internal functions:
6953 (defun gnus-article-set-globals ()
6954 (with-current-buffer gnus-summary-buffer
6955 (gnus-set-global-variables)))
6957 (defun gnus-signature-toggle (end)
6958 (gnus-with-article-buffer
6959 (let ((inhibit-point-motion-hooks t)
6960 (limit (next-single-property-change end 'mime-view-entity
6962 (if (text-property-any end limit 'article-type 'signature)
6964 (gnus-delete-wash-type 'signature)
6965 (gnus-remove-text-properties-when
6966 'article-type 'signature end limit
6967 (cons 'article-type (cons 'signature
6968 gnus-hidden-properties))))
6969 (gnus-add-wash-type 'signature)
6970 (gnus-add-text-properties-when
6971 'article-type nil end limit
6972 (cons 'article-type (cons 'signature
6973 gnus-hidden-properties)))))
6974 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6975 (gnus-set-mode-line 'article))))
6977 (defun gnus-button-entry ()
6978 ;; Return the first entry in `gnus-button-alist' matching this place.
6979 (let ((alist gnus-button-alist)
6982 (setq entry (pop alist))
6983 (if (looking-at (eval (car entry)))
6988 (defun gnus-button-push (marker)
6989 ;; Push button starting at MARKER.
6992 (let* ((entry (gnus-button-entry))
6993 (inhibit-point-motion-hooks t)
6995 (args (mapcar (lambda (group)
6996 (let ((string (match-string group)))
6997 (set-text-properties
6998 0 (length string) nil string)
7005 (fboundp (symbol-value fun)))
7006 (apply (symbol-value fun) args))
7008 (gnus-message 1 "You must define `%S' to use this button"
7009 (cons fun args)))))))
7011 (defun gnus-parse-news-url (url)
7012 (let (scheme server group message-id articles)
7015 (goto-char (point-min))
7016 (when (looking-at "\\([A-Za-z]+\\):")
7017 (setq scheme (match-string 1))
7018 (goto-char (match-end 0)))
7019 (when (looking-at "//\\([^/]+\\)/")
7020 (setq server (match-string 1))
7021 (goto-char (match-end 0)))
7024 ((looking-at "\\(.*@.*\\)")
7025 (setq message-id (match-string 1)))
7026 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
7027 (setq group (match-string 1)
7028 articles (split-string (match-string 2) "-")))
7029 ((looking-at "\\([^/]+\\)/?")
7030 (setq group (match-string 1)))
7032 (error "Unknown news URL syntax"))))
7033 (list scheme server group message-id articles)))
7035 (defun gnus-button-handle-news (url)
7037 (destructuring-bind (scheme server group message-id articles)
7038 (gnus-parse-news-url url)
7042 (set-buffer gnus-summary-buffer)
7044 (let ((gnus-refer-article-method (list (list 'nntp server))))
7045 (gnus-summary-refer-article message-id))
7046 (gnus-summary-refer-article message-id))))
7048 (gnus-button-fetch-group url)))))
7050 (defun gnus-button-handle-man (url)
7052 (funcall gnus-button-man-handler url))
7054 (defun gnus-button-handle-info-url (url)
7055 "Fetch an info URL."
7056 (setq url (mm-subst-char-in-string ?+ ?\ url))
7058 ((string-match "^\\([^:/]+\\)?/\\(.*\\)" url)
7059 (gnus-info-find-node
7060 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
7062 ")" (gnus-url-unhex-string (match-string 2 url)))))
7063 ((string-match "([^)\"]+)[^\"]+" url)
7065 (gnus-replace-in-string
7066 (gnus-replace-in-string url "[\n\t ]+" " ") "\"" ""))
7067 (gnus-info-find-node url))
7068 (t (error "Can't parse %s" url))))
7070 (defun gnus-button-handle-info-url-gnome (url)
7071 "Fetch GNOME style info URL."
7072 (setq url (mm-subst-char-in-string ?_ ?\ url))
7073 (if (string-match "\\([^#]+\\)#?\\(.*\\)" url)
7074 (gnus-info-find-node
7076 (gnus-url-unhex-string
7077 (match-string 1 url))
7079 (or (gnus-url-unhex-string
7080 (match-string 2 url))
7082 (error "Can't parse %s" url)))
7084 (defun gnus-button-handle-info-url-kde (url)
7085 "Fetch KDE style info URL."
7086 (gnus-info-find-node (gnus-url-unhex-string url)))
7088 (defun gnus-button-handle-info-keystrokes (url)
7089 "Call `info' when pushing the corresponding URL button."
7090 ;; For links like `C-h i d m gnus RET', `C-h i d m CC Mode RET'.
7095 (defun gnus-button-message-id (message-id)
7097 (with-current-buffer gnus-summary-buffer
7098 (gnus-summary-refer-article message-id)))
7100 (defun gnus-button-fetch-group (address)
7101 "Fetch GROUP specified by ADDRESS."
7102 (if (not (string-match "[:/]" address))
7103 ;; This is just a simple group url.
7104 (gnus-group-read-ephemeral-group address gnus-select-method)
7107 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
7109 (error "Can't parse %s" address)
7110 (gnus-group-read-ephemeral-group
7111 (match-string 4 address)
7112 `(nntp ,(match-string 1 address)
7113 (nntp-address ,(match-string 1 address))
7114 (nntp-port-number ,(if (match-end 3)
7115 (match-string 3 address)
7118 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
7120 (defun gnus-url-parse-query-string (query &optional downcase)
7121 (let (retval pairs cur key val)
7122 (setq pairs (split-string query "&"))
7124 (setq cur (car pairs)
7126 (if (not (string-match "=" cur))
7128 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
7129 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
7131 (setq key (downcase key)))
7132 (setq cur (assoc key retval))
7134 (setcdr cur (cons val (cdr cur)))
7135 (setq retval (cons (list key val) retval)))))
7138 (defun gnus-url-mailto (url)
7139 ;; Send mail to someone
7140 (when (string-match "mailto:/*\\(.*\\)" url)
7141 (setq url (substring url (match-beginning 1) nil)))
7142 (let (to args subject func)
7143 (setq args (gnus-url-parse-query-string
7144 (if (string-match "^\\?" url)
7146 (if (string-match "^\\([^?]+\\)\\?\\(.*\\)" url)
7147 (concat "to=" (match-string 1 url) "&"
7148 (match-string 2 url))
7149 (concat "to=" url)))
7151 subject (cdr-safe (assoc "subject" args)))
7154 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
7157 (message-position-on-field (caar args)))
7158 (insert (gnus-replace-in-string
7159 (mapconcat 'identity (reverse (cdar args)) ", ")
7161 (setq args (cdr args)))
7164 (message-goto-subject))))
7166 (defun gnus-button-embedded-url (address)
7167 "Activate ADDRESS with `browse-url'."
7168 (browse-url (gnus-strip-whitespace address)))
7170 ;;; Next/prev buttons in the article buffer.
7172 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
7173 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
7175 (defvar gnus-prev-page-map
7176 (let ((map (make-sparse-keymap)))
7177 (define-key map gnus-mouse-2 'gnus-button-prev-page)
7178 (define-key map "\r" 'gnus-button-prev-page)
7181 (defvar gnus-next-page-map
7182 (let ((map (make-sparse-keymap)))
7183 (define-key map gnus-mouse-2 'gnus-button-next-page)
7184 (define-key map "\r" 'gnus-button-next-page)
7187 (defun gnus-insert-prev-page-button ()
7189 (buffer-read-only nil)
7190 (situation (get-text-property (point-min) 'mime-view-situation)))
7192 gnus-prev-page-line-format nil
7193 `(keymap ,gnus-prev-page-map
7195 gnus-callback gnus-article-button-prev-page
7196 article-type annotation
7197 mime-view-situation ,situation))
7198 (widget-convert-button
7200 ;; Exclude a newline.
7203 :action 'gnus-button-prev-page
7204 :button-keymap gnus-prev-page-map)))
7206 (defun gnus-button-next-page (&optional args more-args)
7207 "Go to the next page."
7209 (let ((win (selected-window)))
7210 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7211 (gnus-article-next-page)
7212 (select-window win)))
7214 (defun gnus-button-prev-page (&optional args more-args)
7215 "Go to the prev page."
7217 (let ((win (selected-window)))
7218 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7219 (gnus-article-prev-page)
7220 (select-window win)))
7222 (defun gnus-insert-next-page-button ()
7224 (buffer-read-only nil)
7225 (situation (get-text-property (point-min) 'mime-view-situation)))
7226 (gnus-eval-format gnus-next-page-line-format nil
7227 `(keymap ,gnus-next-page-map
7229 gnus-callback gnus-article-button-next-page
7230 article-type annotation
7231 mime-view-situation ,situation))
7232 (widget-convert-button
7234 ;; Exclude a newline.
7237 :action 'gnus-button-next-page
7238 :button-keymap gnus-next-page-map)))
7240 (defun gnus-article-button-next-page (arg)
7241 "Go to the next page."
7243 (let ((win (selected-window)))
7244 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7245 (gnus-article-next-page)
7246 (select-window win)))
7248 (defun gnus-article-button-prev-page (arg)
7249 "Go to the prev page."
7251 (let ((win (selected-window)))
7252 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7253 (gnus-article-prev-page)
7254 (select-window win)))
7256 (defvar gnus-decode-header-methods
7257 '(mail-decode-encoded-word-region)
7258 "List of methods used to decode headers.
7260 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7261 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
7262 \(REGEXP . FUNCTION), FUNCTION will be only apply to the newsgroups
7263 whose names match REGEXP.
7266 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7267 mail-decode-encoded-word-region
7268 (\"chinese\" . rfc1843-decode-region))
7271 (defvar gnus-decode-header-methods-cache nil)
7273 (defun gnus-multi-decode-header (start end)
7274 "Apply the functions from `gnus-encoded-word-methods' that match."
7275 (unless (and gnus-decode-header-methods-cache
7276 (eq gnus-newsgroup-name
7277 (car gnus-decode-header-methods-cache)))
7278 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7281 (nconc gnus-decode-header-methods-cache (list x))
7282 (if (and gnus-newsgroup-name
7283 (string-match (car x) gnus-newsgroup-name))
7284 (nconc gnus-decode-header-methods-cache
7286 gnus-decode-header-methods))
7287 (let ((xlist gnus-decode-header-methods-cache))
7290 (narrow-to-region start end)
7292 (funcall (pop xlist) (point-min) (point-max))))))
7295 ;;; Treatment top-level handling.
7298 (defun gnus-treat-article (condition &optional part-number total-parts type)
7299 (let ((length (- (point-max) (point-min)))
7300 (alist gnus-treatment-function-alist)
7301 (article-goto-body-goes-to-point-min-p t)
7305 (let ((list gnus-article-treat-types))
7307 (when (string-match (pop list) type)
7308 (throw 'found t)))))))
7309 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7310 (entity (static-unless (featurep 'xemacs)
7311 (when (eq 'head condition)
7312 (get-text-property (point-min) 'mime-view-entity))))
7313 val elem buttonized)
7314 (gnus-run-hooks 'gnus-part-display-hook)
7315 (unless gnus-inhibit-treatment
7316 (dolist (elem alist)
7319 (when (gnus-buffer-live-p gnus-summary-buffer)
7320 (set-buffer gnus-summary-buffer))
7321 (symbol-value (car elem))))
7322 (when (and (or (consp val)
7324 (gnus-treat-predicate val)
7325 (or (not (get (car elem) 'highlight))
7327 (when (and (not buttonized)
7329 '(gnus-treat-hide-signature
7330 gnus-treat-highlight-signature)))
7331 (gnus-article-buttonize-signature)
7332 (setq buttonized t))
7334 (funcall (cadr elem)))))
7335 ;; FSF Emacsen does not inherit the existing text properties
7336 ;; in the new text, so we should do it for `mime-view-entity'.
7337 (static-unless (featurep 'xemacs)
7339 (put-text-property (point-min) (point-max)
7340 'mime-view-entity entity))))))
7342 ;; Dynamic variables.
7344 (defvar part-number)
7345 (defvar total-parts)
7350 (defun gnus-treat-predicate (val)
7355 (stringp (car val)))
7356 (apply 'gnus-or (mapcar `(lambda (s)
7357 (string-match s ,(or gnus-newsgroup-name "")))
7360 (let ((pred (pop val)))
7363 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7365 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7367 (not (gnus-treat-predicate (car val))))
7369 (equal (car val) type))
7371 (error "%S is not a valid predicate" pred)))))
7381 (eq part-number total-parts))
7385 (error "%S is not a valid value" val))))
7387 (defun gnus-article-encrypt-body (protocol &optional n)
7388 "Encrypt the article body."
7391 (or gnus-article-encrypt-protocol
7392 (completing-read "Encrypt protocol: "
7393 gnus-article-encrypt-protocol-alist
7395 current-prefix-arg))
7396 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7398 (error (format "Can't find the encrypt protocol %s" protocol)))
7399 (if (member gnus-newsgroup-name '("nndraft:delayed"
7402 (error "Can't encrypt the article in group %s"
7403 gnus-newsgroup-name))
7404 (gnus-summary-iterate n
7406 (set-buffer gnus-summary-buffer)
7407 (let ((mail-parse-charset gnus-newsgroup-charset)
7408 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7409 (summary-buffer gnus-summary-buffer)
7411 (gnus-set-global-variables)
7412 (when (gnus-group-read-only-p)
7413 (error "The current newsgroup does not support article encrypt"))
7414 (gnus-summary-show-article t)
7416 (or (mail-header-references gnus-current-headers) ""))
7417 (set-buffer gnus-article-buffer)
7418 (let* ((buffer-read-only nil)
7420 (mapcar (lambda (field)
7421 (and (save-restriction
7422 (message-narrow-to-head)
7423 (goto-char (point-min))
7424 (search-forward field nil t))
7426 (message-narrow-to-field)
7428 (delete-region (point-min) (point-max))
7430 '("Content-Type:" "Content-Transfer-Encoding:"
7431 "Content-Disposition:"))))
7432 (message-narrow-to-head)
7433 (message-remove-header "MIME-Version")
7434 (goto-char (point-max))
7435 (setq point (point))
7436 (insert (apply 'concat headers))
7438 (narrow-to-region point (point-max))
7439 (let ((message-options message-options))
7440 (message-options-set 'message-sender user-mail-address)
7441 (message-options-set 'message-recipients user-mail-address)
7442 (message-options-set 'message-sign-encrypt 'not)
7444 (goto-char (point-min))
7445 (insert "MIME-Version: 1.0\n")
7447 (gnus-summary-edit-article-done
7448 references nil summary-buffer t))
7449 (when gnus-keep-backlog
7450 (gnus-backlog-remove-article
7451 (car gnus-article-current) (cdr gnus-article-current)))
7453 (when (get-buffer gnus-original-article-buffer)
7454 (set-buffer gnus-original-article-buffer)
7455 (setq gnus-original-article nil)))
7456 (when gnus-use-cache
7457 (gnus-cache-update-article
7458 (car gnus-article-current) (cdr gnus-article-current))))))))
7460 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7461 "The following specs can be used:
7462 %t The security MIME type
7465 %D Details if button is pressed")
7467 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7468 "The following specs can be used:
7469 %t The security MIME type
7472 %D Details if button is pressed")
7474 (defvar gnus-mime-security-button-line-format-alist
7475 '((?t gnus-tmp-type ?s)
7476 (?i gnus-tmp-info ?s)
7477 (?d gnus-tmp-details ?s)
7478 (?D gnus-tmp-pressed-details ?s)))
7480 (defvar gnus-mime-security-button-map
7481 (let ((map (make-sparse-keymap)))
7482 (define-key map gnus-mouse-2 'gnus-article-push-button)
7483 (define-key map "\r" 'gnus-article-press-button)
7486 (defvar gnus-mime-security-details-buffer nil)
7488 (defvar gnus-mime-security-button-pressed nil)
7490 (defvar gnus-mime-security-show-details-inline t
7491 "If non-nil, show details in the article buffer.")
7493 (defun gnus-mime-security-verify-or-decrypt (handle)
7494 (mm-remove-parts (cdr handle))
7495 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7496 point buffer-read-only)
7498 (goto-char (car region)))
7500 (narrow-to-region (point) (point))
7501 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7502 (let* ((mm-verify-option 'known)
7503 (mm-decrypt-option 'known)
7504 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7505 (unless (eq nparts (cdr handle))
7506 (mm-destroy-parts (cdr handle))
7507 (setcdr handle nparts))))
7508 (setq point (point))
7509 (gnus-mime-display-security handle)
7510 (goto-char (point-max)))
7512 (delete-region (point) (cdr region))
7513 (set-marker (car region) nil)
7514 (set-marker (cdr region) nil))
7517 (defun gnus-mime-security-show-details (handle)
7518 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7520 (gnus-message 5 "No details.")
7521 (if gnus-mime-security-show-details-inline
7522 (let ((gnus-mime-security-button-pressed
7523 (not (get-text-property (point) 'gnus-mime-details)))
7524 (gnus-mime-security-button-line-format
7525 (get-text-property (point) 'gnus-line-format))
7528 (while (eq (get-text-property (point) 'gnus-line-format)
7529 gnus-mime-security-button-line-format)
7533 (narrow-to-region (point) (point))
7534 (gnus-insert-mime-security-button handle))
7535 (delete-region (point)
7536 (or (text-property-not-all
7539 gnus-mime-security-button-line-format)
7542 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7543 (with-current-buffer gnus-mime-security-details-buffer
7546 (setq gnus-mime-security-details-buffer
7547 (gnus-get-buffer-create "*MIME Security Details*")))
7548 (with-current-buffer gnus-mime-security-details-buffer
7550 (goto-char (point-min)))
7551 (pop-to-buffer gnus-mime-security-details-buffer)))))
7553 (defun gnus-mime-security-press-button (handle)
7555 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7556 (gnus-mime-security-show-details handle)
7557 (gnus-mime-security-verify-or-decrypt handle))))
7559 (defun gnus-insert-mime-security-button (handle &optional displayed)
7560 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7563 (or (nth 2 (assoc protocol mm-verify-function-alist))
7564 (nth 2 (assoc protocol mm-decrypt-function-alist))
7566 (if (equal (car handle) "multipart/signed")
7567 " Signed" " Encrypted")
7570 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7573 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7574 gnus-tmp-pressed-details
7576 (setq gnus-tmp-details
7577 (if gnus-tmp-details
7578 (concat "\n" gnus-tmp-details)
7580 (setq gnus-tmp-pressed-details
7581 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7586 gnus-mime-security-button-line-format
7587 gnus-mime-security-button-line-format-alist
7588 `(keymap ,gnus-mime-security-button-map
7589 gnus-callback gnus-mime-security-press-button
7590 gnus-line-format ,gnus-mime-security-button-line-format
7591 gnus-mime-details ,gnus-mime-security-button-pressed
7592 article-type annotation
7595 ;; Exclude a newline.
7598 (widget-convert-button
7601 :action 'gnus-widget-press-button
7602 :button-keymap gnus-mime-security-button-map
7604 (lambda (widget/window &optional overlay pos)
7605 ;; Needed to properly clear the message due to a bug in
7606 ;; wid-edit (XEmacs only).
7607 (when (boundp 'help-echo-owns-message)
7608 (setq help-echo-owns-message t))
7611 (aref gnus-mouse-2 0))))))
7613 (defun gnus-mime-display-security (handle)
7615 (narrow-to-region (point) (point))
7616 (unless (gnus-unbuttonized-mime-type-p (car handle))
7617 (gnus-insert-mime-security-button handle))
7618 (gnus-mime-display-mixed (cdr handle))
7621 (unless (gnus-unbuttonized-mime-type-p (car handle))
7622 (let ((gnus-mime-security-button-line-format
7623 gnus-mime-security-button-end-line-format))
7624 (gnus-insert-mime-security-button handle)))
7625 (mm-set-handle-multipart-parameter
7627 (cons (set-marker (make-marker) (point-min))
7628 (set-marker (make-marker) (point-max))))))
7634 (defun gnus-article-header-presentation-method (entity situation)
7635 (mime-insert-header entity)
7636 (article-decode-group-name))
7638 (set-alist 'mime-header-presentation-method-alist
7639 'gnus-original-article-mode
7640 #'gnus-article-header-presentation-method)
7642 (defun gnus-mime-preview-quitting-method ()
7643 (mime-preview-kill-buffer)
7644 (delete-other-windows)
7645 (gnus-article-show-summary)
7646 (gnus-summary-select-article gnus-show-all-headers t))
7648 (set-alist 'mime-preview-quitting-method-alist
7649 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
7651 (set-alist 'mime-preview-following-method-alist
7652 'gnus-original-article-mode #'gnus-following-method)
7654 (set-alist 'mime-preview-over-to-previous-method-alist
7655 'gnus-original-article-mode
7657 (if (> (point-min) 1)
7658 (gnus-article-prev-page)
7659 (gnus-article-read-summary-keys
7660 nil (gnus-character-to-event ?P)))))
7662 (set-alist 'mime-preview-over-to-next-method-alist
7663 'gnus-original-article-mode'
7665 (if (< (point-max) (buffer-size))
7666 (gnus-article-next-page)
7667 (gnus-article-read-summary-keys
7668 nil (gnus-character-to-event ?N)))))
7678 (run-hooks 'gnus-art-load-hook)
7680 ;;; gnus-art.el ends here