1 ;;; gnus-art.el --- article mode commands for Semi-gnus
2 ;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
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.
31 (eval-when-compile (require 'cl))
32 (eval-when-compile (require 'static))
44 ;; Avoid byte-compile warnings.
52 (autoload 'gnus-msg-mail "gnus-msg" nil t)
53 (autoload 'gnus-button-mailto "gnus-msg")
54 (autoload 'gnus-button-reply "gnus-msg" nil t)
56 (defgroup gnus-article nil
58 :link '(custom-manual "(gnus)The Article Buffer")
61 (defgroup gnus-article-treat nil
62 "Treating article parts."
63 :link '(custom-manual "(gnus)Article Hiding")
66 (defgroup gnus-article-hiding nil
67 "Hiding article parts."
68 :link '(custom-manual "(gnus)Article Hiding")
71 (defgroup gnus-article-highlight nil
72 "Article highlighting."
73 :link '(custom-manual "(gnus)Article Highlighting")
77 (defgroup gnus-article-signature nil
79 :link '(custom-manual "(gnus)Article Signature")
82 (defgroup gnus-article-headers nil
84 :link '(custom-manual "(gnus)Hiding Headers")
87 (defgroup gnus-article-washing nil
88 "Special commands on articles."
89 :link '(custom-manual "(gnus)Article Washing")
92 (defgroup gnus-article-emphasis nil
93 "Fontisizing articles."
94 :link '(custom-manual "(gnus)Article Fontisizing")
97 (defgroup gnus-article-saving nil
99 :link '(custom-manual "(gnus)Saving Articles")
100 :group 'gnus-article)
102 (defgroup gnus-article-mime nil
103 "Worshiping the MIME wonder."
104 :link '(custom-manual "(gnus)Using MIME")
105 :group 'gnus-article)
107 (defgroup gnus-article-buttons nil
108 "Pushable buttons in the article buffer."
109 :link '(custom-manual "(gnus)Article Buttons")
110 :group 'gnus-article)
112 (defgroup gnus-article-various nil
113 "Other article options."
114 :link '(custom-manual "(gnus)Misc Article")
115 :group 'gnus-article)
117 (defcustom gnus-ignored-headers
120 (concat "^" header ":"))
121 '("Path" "Expires" "Date-Received" "References" "Xref" "Lines"
122 "Relay-Version" "Message-ID" "Approved" "Sender" "Received"
123 "X-UIDL" "MIME-Version" "Return-Path" "In-Reply-To"
124 "Content-Type" "Content-Transfer-Encoding" "X-WebTV-Signature"
125 "X-MimeOLE" "X-MSMail-Priority" "X-Priority" "X-Loop"
126 "X-Authentication-Warning" "X-MIME-Autoconverted" "X-Face"
127 "X-Attribution" "X-Originating-IP" "Delivered-To"
128 "NNTP-[-A-Za-z]+" "Distribution" "X-no-archive" "X-Trace"
129 "X-Complaints-To" "X-NNTP-Posting-Host" "X-Orig.*"
130 "Abuse-Reports-To" "Cache-Post-Path" "X-Article-Creation-Date"
131 "X-Poster" "X-Mail2News-Path" "X-Server-Date" "X-Cache"
132 "Originator" "X-Problems-To" "X-Auth-User" "X-Post-Time"
133 "X-Admin" "X-UID" "Resent-[-A-Za-z]+" "X-Mailing-List"
134 "Precedence" "Original-[-A-Za-z]+" "X-filename" "X-Orcpt"
135 "Old-Received" "X-Pgp" "X-Auth" "X-From-Line"
136 "X-Gnus-Article-Number" "X-Majordomo" "X-Url" "X-Sender"
137 "MBOX-Line" "Priority" "X400-[-A-Za-z]+"
138 "Status" "X-Gnus-Mail-Source" "Cancel-Lock"
139 "X-FTN" "X-EXP32-SerialNo" "Encoding" "Importance"
140 "Autoforwarded" "Original-Encoded-Information-Types" "X-Ya-Pop3"
141 "X-Face-Version" "X-Vms-To" "X-ML-NAME" "X-ML-COUNT"
142 "Mailing-List" "X-finfo" "X-md5sum" "X-md5sum-Origin"
143 "X-Sun-Charset" "X-Accept-Language" "X-Envelope-Sender"
144 "List-[A-Za-z]+" "X-Listprocessor-Version"
145 "X-Received" "X-Distribute" "X-Sequence" "X-Juno-Line-Breaks"
146 "X-Notes-Item" "X-MS-TNEF-Correlator" "x-uunet-gateway"
147 "X-Received" "Content-length" "X-precedence"
148 "X-Authenticated-User" "X-Comment" "X-Report" "X-Abuse-Info"
149 "X-HTTP-Proxy" "X-Mydeja-Info" "X-Copyright" "X-No-Markup"
150 "X-Abuse-Info" "X-From_" "X-Accept-Language" "Errors-To"
151 "X-BeenThere" "X-Mailman-Version" "List-Help" "List-Post"
152 "List-Subscribe" "List-Id" "List-Unsubscribe" "List-Archive"
153 "X-Content-length" "X-Posting-Agent" "Original-Received"
154 "X-Request-PGP" "X-Fingerprint" "X-WRIEnvto" "X-WRIEnvfrom"
155 "X-Virus-Scanned" "X-Delivery-Agent" "Posted-Date" "X-Gateway"
156 "X-Local-Origin" "X-Local-Destination" "X-UserInfo1"
157 "X-Received-Date" "X-Hashcash" "Face" "X-DMCA-Notifications"
158 "X-Abuse-and-DMCA-Info" "X-Postfilter"))
159 "*All headers that start with this regexp will be hidden.
160 This variable can also be a list of regexps of headers to be ignored.
161 If `gnus-visible-headers' is non-nil, this variable will be ignored."
162 :type '(choice :custom-show nil
165 :group 'gnus-article-hiding)
167 (defcustom gnus-visible-headers
168 "^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:"
169 "*All headers that do not match this regexp will be hidden.
170 This variable can also be a list of regexp of headers to remain visible.
171 If this variable is non-nil, `gnus-ignored-headers' will be ignored."
172 :type '(repeat :value-to-internal (lambda (widget value)
173 (custom-split-regexp-maybe value))
174 :match (lambda (widget value)
176 (widget-editable-list-match widget value)))
178 :group 'gnus-article-hiding)
180 (defcustom gnus-sorted-header-list
181 '("^From:" "^Subject:" "^Summary:" "^Keywords:" "^Newsgroups:"
182 "^Followup-To:" "^To:" "^Cc:" "^Date:" "^Organization:")
183 "*This variable is a list of regular expressions.
184 If it is non-nil, headers that match the regular expressions will
185 be placed first in the article buffer in the sequence specified by
187 :type '(repeat regexp)
188 :group 'gnus-article-hiding)
190 (defcustom gnus-boring-article-headers '(empty followup-to reply-to)
191 "Headers that are only to be displayed if they have interesting data.
192 Possible values in this list are:
194 'empty Headers with no content.
195 'newsgroups Newsgroup identical to Gnus group.
196 'to-address To identical to To-address.
197 'to-list To identical to To-list.
198 'cc-list CC identical to To-list.
199 'followup-to Followup-to identical to Newsgroups.
200 'reply-to Reply-to identical to From.
201 'date Date less than four days old.
202 'long-to To and/or Cc longer than 1024 characters.
203 'many-to Multiple To and/or Cc."
204 :type '(set (const :tag "Headers with no content." empty)
205 (const :tag "Newsgroups identical to Gnus group." newsgroups)
206 (const :tag "To identical to To-address." to-address)
207 (const :tag "To identical to To-list." to-list)
208 (const :tag "CC identical to To-list." cc-list)
209 (const :tag "Followup-to identical to Newsgroups." followup-to)
210 (const :tag "Reply-to identical to From." reply-to)
211 (const :tag "Date less than four days old." date)
212 (const :tag "To and/or Cc longer than 1024 characters." long-to)
213 (const :tag "Multiple To and/or Cc headers." many-to))
214 :group 'gnus-article-hiding)
216 (defcustom gnus-article-skip-boring nil
217 "Skip over text that is not worth reading.
218 By default, if you set this t, then Gnus will display citations and
219 signatures, but will never scroll down to show you a page consisting
220 only of boring text. Boring text is controlled by
221 `gnus-article-boring-faces'."
223 :group 'gnus-article-hiding)
225 (defcustom gnus-signature-separator '("^-- $" "^-- *$")
226 "Regexp matching signature separator.
227 This can also be a list of regexps. In that case, it will be checked
228 from head to tail looking for a separator. Searches will be done from
229 the end of the buffer."
230 :type '(repeat string)
231 :group 'gnus-article-signature)
233 (defcustom gnus-signature-limit nil
234 "Provide a limit to what is considered a signature.
235 If it is a number, no signature may not be longer (in characters) than
236 that number. If it is a floating point number, no signature may be
237 longer (in lines) than that number. If it is a function, the function
238 will be called without any parameters, and if it returns nil, there is
239 no signature in the buffer. If it is a string, it will be used as a
240 regexp. If it matches, the text in question is not a signature."
241 :type '(choice (integer :value 200)
243 (function :value fun)
244 (regexp :value ".*"))
245 :group 'gnus-article-signature)
247 (defcustom gnus-hidden-properties '(invisible t intangible t)
248 "Property list to use for hiding text."
250 :group 'gnus-article-hiding)
252 ;; Fixme: This isn't the right thing for mixed graphical and and
253 ;; non-graphical frames in a session.
254 (defcustom gnus-article-x-face-command
259 (if (or (gnus-image-type-available-p 'xface)
260 (gnus-image-type-available-p 'pbm))
261 'gnus-display-x-face-in-from
262 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | ee -"))
263 ((and (fboundp 'image-type-available-p)
264 (module-installed-p 'x-face-e21))
265 'x-face-decode-message-header)
266 ((gnus-image-type-available-p 'pbm)
267 'gnus-display-x-face-in-from)
269 (module-installed-p 'x-face-mule))
270 'x-face-mule-gnus-article-display-x-face)
272 "{ echo '/* Width=48, Height=48 */'; uncompface; } | icontopbm | \
274 "*String or function to be executed to display an X-Face header.
275 If it is a string, the command will be executed in a sub-shell
276 asynchronously. The compressed face will be piped to this command."
278 ,@(let (x-face-e21 x-face-mule)
279 (if (featurep 'xemacs)
281 (setq x-face-e21 (module-installed-p 'x-face-e21)
282 x-face-mule (module-installed-p 'x-face-mule)))
286 (if (or (gnus-image-type-available-p 'xface)
287 (gnus-image-type-available-p 'pbm))
288 '(function-item gnus-display-x-face-in-from))
290 (fboundp 'image-type-available-p))
292 :tag "x-face-decode-message-header (x-face-e21)"
293 x-face-decode-message-header))
296 x-face-mule-gnus-article-display-x-face))
300 :group 'gnus-article-washing)
302 (defcustom gnus-article-x-face-too-ugly nil
303 "Regexp matching posters whose face shouldn't be shown automatically."
304 :type '(choice regexp (const nil))
305 :group 'gnus-article-washing)
307 (defcustom gnus-article-banner-alist nil
308 "Banner alist for stripping.
310 ((egroups . \"^[ \\t\\n]*-------------------+\\\\( \\\\(e\\\\|Yahoo! \\\\)Groups Sponsor -+\\\\)?....\\n\\\\(.+\\n\\\\)+\"))"
312 :type '(repeat (cons symbol regexp))
313 :group 'gnus-article-washing)
315 (gnus-define-group-parameter
318 "Alist of regexps (to match group names) and banner."
319 :variable-group gnus-article-washing
321 '(choice :tag "Banner"
323 (const :tag "Remove signature" signature)
324 (symbol :tag "Item in `gnus-article-banner-alist'" none)
326 (const :tag "None" nil))
328 "If non-nil, specify how to remove `banners' from articles.
330 Symbol `signature' means to remove signatures delimited by
331 `gnus-signature-separator'. Any other symbol is used to look up a
332 regular expression to match the banner in `gnus-article-banner-alist'.
333 A string is used as a regular expression to match the banner
336 (defcustom gnus-article-address-banner-alist nil
337 "Alist of mail addresses and banners.
338 Each element has the form (ADDRESS . BANNER), where ADDRESS is a regexp
339 to match a mail address in the From: header, BANNER is one of a symbol
340 `signature', an item in `gnus-article-banner-alist', a regexp and nil.
341 If ADDRESS matches author's mail address, it will remove things like
342 advertisements. For example:
344 \((\"@yoo-hoo\\\\.co\\\\.jp\\\\'\" . \"\\n_+\\nDo You Yoo-hoo!\\\\?\\n.*\\n.*\\n\"))
348 (regexp :tag "Address")
349 (choice :tag "Banner" :value nil
350 (const :tag "Remove signature" signature)
351 (symbol :tag "Item in `gnus-article-banner-alist'" none)
353 (const :tag "None" nil))))
354 :group 'gnus-article-washing)
356 (defcustom gnus-emphasis-alist
358 "\\(\\s-\\|^\\|\\=\\|[-\"]\\|\\s(\\)\\(%s\\(\\w+\\(\\s-+\\w+\\)*[.,]?\\)%s\\)\\(\\([-,.;:!?\"]\\|\\s)\\)+\\s-\\|[?!.]\\s-\\|\\s)\\|\\s-\\)")
363 ("_/" "/_" underline-italic)
364 ("_\\*" "\\*_" underline-bold)
365 ("\\*/" "/\\*" bold-italic)
366 ("_\\*/" "/\\*_" underline-bold-italic))))
370 (format format (car spec) (car (cdr spec)))
371 2 3 (intern (format "gnus-emphasis-%s" (nth 2 spec)))))
373 ("\\(\\s-\\|^\\)\\(-\\(\\(\\w\\|-[^-]\\)+\\)-\\)\\(\\s-\\|[?!.,;]\\)"
374 2 3 gnus-emphasis-strikethru)
375 ("\\(\\s-\\|^\\)\\(_\\(\\(\\w\\|_[^_]\\)+\\)_\\)\\(\\s-\\|[?!.,;]\\)"
376 2 3 gnus-emphasis-underline)))
377 "*Alist that says how to fontify certain phrases.
378 Each item looks like this:
380 (\"_\\\\(\\\\w+\\\\)_\" 0 1 'underline)
382 The first element is a regular expression to be matched. The second
383 is a number that says what regular expression grouping used to find
384 the entire emphasized word. The third is a number that says what
385 regexp grouping should be displayed and highlighted. The fourth
386 is the face used for highlighting."
387 :type '(repeat (list :value ("" 0 0 default)
389 (integer :tag "Match group")
390 (integer :tag "Emphasize group")
392 :group 'gnus-article-emphasis)
394 (defcustom gnus-emphasize-whitespace-regexp "^[ \t]+\\|[ \t]*\n"
395 "A regexp to describe whitespace which should not be emphasized.
396 Typical values are \"^[ \\t]+\\\\|[ \\t]*\\n\" and \"[ \\t]+\\\\|[ \\t]*\\n\".
397 The former avoids underlining of leading and trailing whitespace,
398 and the latter avoids underlining any whitespace at all."
400 :group 'gnus-article-emphasis
403 (defface gnus-emphasis-bold '((t (:bold t)))
404 "Face used for displaying strong emphasized text (*word*)."
405 :group 'gnus-article-emphasis)
407 (defface gnus-emphasis-italic '((t (:italic t)))
408 "Face used for displaying italic emphasized text (/word/)."
409 :group 'gnus-article-emphasis)
411 (defface gnus-emphasis-underline '((t (:underline t)))
412 "Face used for displaying underlined emphasized text (_word_)."
413 :group 'gnus-article-emphasis)
415 (defface gnus-emphasis-underline-bold '((t (:bold t :underline t)))
416 "Face used for displaying underlined bold emphasized text (_*word*_)."
417 :group 'gnus-article-emphasis)
419 (defface gnus-emphasis-underline-italic '((t (:italic t :underline t)))
420 "Face used for displaying underlined italic emphasized text (_/word/_)."
421 :group 'gnus-article-emphasis)
423 (defface gnus-emphasis-bold-italic '((t (:bold t :italic t)))
424 "Face used for displaying bold italic emphasized text (/*word*/)."
425 :group 'gnus-article-emphasis)
427 (defface gnus-emphasis-underline-bold-italic
428 '((t (:bold t :italic t :underline t)))
429 "Face used for displaying underlined bold italic emphasized text.
430 Example: (_/*word*/_)."
431 :group 'gnus-article-emphasis)
433 (defface gnus-emphasis-strikethru '((t (:strikethru t)))
434 "Face used for displaying strike-through text (-word-)."
435 :group 'gnus-article-emphasis)
437 (defface gnus-emphasis-highlight-words
438 '((t (:background "black" :foreground "yellow")))
439 "Face used for displaying highlighted words."
440 :group 'gnus-article-emphasis)
442 (defcustom gnus-article-time-format "%a, %b %d %Y %T %Z"
443 "Format for display of Date headers in article bodies.
444 See `format-time-string' for the possible values.
446 The variable can also be function, which should return a complete Date
447 header. The function is called with one argument, the time, which can
448 be fed to `format-time-string'."
449 :type '(choice string symbol)
450 :link '(custom-manual "(gnus)Article Date")
451 :group 'gnus-article-washing)
454 (autoload 'mail-extract-address-components "mail-extr"))
456 (defcustom gnus-save-all-headers t
457 "*If non-nil, don't remove any headers before saving."
458 :group 'gnus-article-saving
461 (defcustom gnus-prompt-before-saving 'always
462 "*This variable says how much prompting is to be done when saving articles.
463 If it is nil, no prompting will be done, and the articles will be
464 saved to the default files. If this variable is `always', each and
465 every article that is saved will be preceded by a prompt, even when
466 saving large batches of articles. If this variable is neither nil not
467 `always', there the user will be prompted once for a file name for
468 each invocation of the saving commands."
469 :group 'gnus-article-saving
470 :type '(choice (item always)
471 (item :tag "never" nil)
472 (sexp :tag "once" :format "%t\n" :value t)))
474 (defcustom gnus-saved-headers gnus-visible-headers
475 "Headers to keep if `gnus-save-all-headers' is nil.
476 If `gnus-save-all-headers' is non-nil, this variable will be ignored.
477 If that variable is nil, however, all headers that match this regexp
478 will be kept while the rest will be deleted before saving."
479 :group 'gnus-article-saving
482 (defcustom gnus-default-article-saver 'gnus-summary-save-in-rmail
483 "A function to save articles in your favourite format.
484 The function must be interactively callable (in other words, it must
485 be an Emacs command).
487 Gnus provides the following functions:
489 * gnus-summary-save-in-rmail (Rmail format)
490 * gnus-summary-save-in-mail (Unix mail format)
491 * gnus-summary-save-in-folder (MH folder)
492 * gnus-summary-save-in-file (article format)
493 * gnus-summary-save-body-in-file (article body)
494 * gnus-summary-save-in-vm (use VM's folder format)
495 * gnus-summary-write-to-file (article format -- overwrite)."
496 :group 'gnus-article-saving
497 :type '(radio (function-item gnus-summary-save-in-rmail)
498 (function-item gnus-summary-save-in-mail)
499 (function-item gnus-summary-save-in-folder)
500 (function-item gnus-summary-save-in-file)
501 (function-item gnus-summary-save-body-in-file)
502 (function-item gnus-summary-save-in-vm)
503 (function-item gnus-summary-write-to-file)))
505 (defcustom gnus-rmail-save-name 'gnus-plain-save-name
506 "A function generating a file name to save articles in Rmail format.
507 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
508 :group 'gnus-article-saving
511 (defcustom gnus-mail-save-name 'gnus-plain-save-name
512 "A function generating a file name to save articles in Unix mail format.
513 The function is called with NEWSGROUP, HEADERS, and optional LAST-FILE."
514 :group 'gnus-article-saving
517 (defcustom gnus-folder-save-name 'gnus-folder-save-name
518 "A function generating a file name to save articles in MH folder.
519 The function is called with NEWSGROUP, HEADERS, and optional LAST-FOLDER."
520 :group 'gnus-article-saving
523 (defcustom gnus-file-save-name 'gnus-numeric-save-name
524 "A function generating a file name to save articles in article format.
525 The function is called with NEWSGROUP, HEADERS, and optional
527 :group 'gnus-article-saving
530 (defcustom gnus-split-methods
531 '((gnus-article-archive-name)
532 (gnus-article-nndoc-name))
533 "*Variable used to suggest where articles are to be saved.
534 For instance, if you would like to save articles related to Gnus in
535 the file \"gnus-stuff\", and articles related to VM in \"vm-stuff\",
536 you could set this variable to something like:
538 '((\"^Subject:.*gnus\\|^Newsgroups:.*gnus\" \"gnus-stuff\")
539 (\"^Subject:.*vm\\|^Xref:.*vm\" \"vm-stuff\"))
541 This variable is an alist where the where the key is the match and the
542 value is a list of possible files to save in if the match is non-nil.
544 If the match is a string, it is used as a regexp match on the
545 article. If the match is a symbol, that symbol will be funcalled
546 from the buffer of the article to be saved with the newsgroup as the
547 parameter. If it is a list, it will be evaled in the same buffer.
549 If this form or function returns a string, this string will be used as
550 a possible file name; and if it returns a non-nil list, that list will
551 be used as possible file names."
552 :group 'gnus-article-saving
553 :type '(repeat (choice (list :value (fun) function)
554 (cons :value ("" "") regexp (repeat string))
557 (defcustom gnus-article-display-method-for-mime
558 'gnus-article-display-mime-message
559 "Function to display a MIME message.
560 The function is called from the article buffer."
561 :group 'gnus-article-mime
564 (defcustom gnus-article-display-method-for-traditional
565 'gnus-article-display-traditional-message
566 "*Function to display a traditional message.
567 The function is called from the article buffer."
568 :group 'gnus-article-mime
571 (defcustom gnus-page-delimiter "^\^L"
572 "*Regexp describing what to use as article page delimiters.
573 The default value is \"^\^L\", which is a form linefeed at the
574 beginning of a line."
576 :group 'gnus-article-various)
578 (defcustom gnus-article-mode-line-format "Gnus: %g [%w] %S%m"
579 "*The format specification for the article mode line.
580 See `gnus-summary-mode-line-format' for a closer description.
582 The following additional specs are available:
584 %w The article washing status.
585 %m The number of MIME parts in the article."
587 :group 'gnus-article-various)
589 (defcustom gnus-article-mode-hook nil
590 "*A hook for Gnus article mode."
592 :group 'gnus-article-various)
594 (when (featurep 'xemacs)
595 ;; Extracted from gnus-xmas-define in order to preserve user settings
596 (when (fboundp 'turn-off-scroll-in-place)
597 (add-hook 'gnus-article-mode-hook 'turn-off-scroll-in-place))
598 ;; Extracted from gnus-xmas-redefine in order to preserve user settings
599 (add-hook 'gnus-article-mode-hook 'gnus-xmas-article-menu-add))
601 (defcustom gnus-article-menu-hook nil
602 "*Hook run after the creation of the article mode menu."
604 :group 'gnus-article-various)
606 (defcustom gnus-article-prepare-hook nil
607 "*A hook called after an article has been prepared in the article buffer."
609 :group 'gnus-article-various)
611 (defvar gnus-article-hide-pgp-hook nil)
612 (make-obsolete-variable 'gnus-article-hide-pgp-hook
613 "This variable is obsolete in Gnus 5.10.")
615 (defcustom gnus-article-button-face 'bold
616 "Face used for highlighting buttons in the article buffer.
618 An article button is a piece of text that you can activate by pressing
619 `RET' or `mouse-2' above it."
621 :group 'gnus-article-buttons)
623 (defcustom gnus-article-mouse-face 'highlight
624 "Face used for mouse highlighting in the article buffer.
626 Article buttons will be displayed in this face when the cursor is
629 :group 'gnus-article-buttons)
631 (defcustom gnus-signature-face 'gnus-signature-face
632 "Face used for highlighting a signature in the article buffer.
633 Obsolete; use the face `gnus-signature-face' for customizations instead."
635 :group 'gnus-article-highlight
636 :group 'gnus-article-signature)
638 (defface gnus-signature-face
641 "Face used for highlighting a signature in the article buffer."
642 :group 'gnus-article-highlight
643 :group 'gnus-article-signature)
645 (defface gnus-header-from-face
648 (:foreground "spring green"))
651 (:foreground "red3"))
654 "Face used for displaying from headers."
655 :group 'gnus-article-headers
656 :group 'gnus-article-highlight)
658 (defface gnus-header-subject-face
661 (:foreground "SeaGreen3"))
664 (:foreground "red4"))
666 (:bold t :italic t)))
667 "Face used for displaying subject headers."
668 :group 'gnus-article-headers
669 :group 'gnus-article-highlight)
671 (defface gnus-header-newsgroups-face
674 (:foreground "yellow" :italic t))
677 (:foreground "MidnightBlue" :italic t))
680 "Face used for displaying newsgroups headers."
681 :group 'gnus-article-headers
682 :group 'gnus-article-highlight)
684 (defface gnus-header-name-face
687 (:foreground "SeaGreen"))
690 (:foreground "maroon"))
693 "Face used for displaying header names."
694 :group 'gnus-article-headers
695 :group 'gnus-article-highlight)
697 (defface gnus-header-content-face
700 (:foreground "forest green" :italic t))
703 (:foreground "indianred4" :italic t))
706 "Face used for displaying header content."
707 :group 'gnus-article-headers
708 :group 'gnus-article-highlight)
710 (defcustom gnus-header-face-alist
711 '(("From" nil gnus-header-from-face)
712 ("Subject" nil gnus-header-subject-face)
713 ("Newsgroups:.*," nil gnus-header-newsgroups-face)
714 ("" gnus-header-name-face gnus-header-content-face))
715 "*Controls highlighting of article header.
717 An alist of the form (HEADER NAME CONTENT).
719 HEADER is a regular expression which should match the name of an
720 header header and NAME and CONTENT are either face names or nil.
722 The name of each header field will be displayed using the face
723 specified by the first element in the list where HEADER match the
724 header name and NAME is non-nil. Similarly, the content will be
725 displayed by the first non-nil matching CONTENT face."
726 :group 'gnus-article-headers
727 :group 'gnus-article-highlight
728 :type '(repeat (list (regexp :tag "Header")
730 (item :tag "skip" nil)
731 (face :value default))
732 (choice :tag "Content"
733 (item :tag "skip" nil)
734 (face :value default)))))
736 (defcustom gnus-article-decode-hook nil
737 "*Hook run to decode charsets in articles."
738 :group 'gnus-article-headers
741 (defcustom gnus-display-mime-function 'gnus-display-mime
742 "Function to display MIME articles."
743 :group 'gnus-article-mime
746 (defvar gnus-decode-header-function 'mail-decode-encoded-word-region
747 "Function used to decode headers.")
749 (defvar gnus-article-dumbquotes-map
769 "Table for MS-to-Latin1 translation.")
771 (defcustom gnus-ignored-mime-types nil
772 "List of MIME types that should be ignored by Gnus."
774 :group 'gnus-article-mime
775 :type '(repeat regexp))
777 (defcustom gnus-unbuttonized-mime-types '(".*/.*")
778 "List of MIME types that should not be given buttons when rendered inline.
779 See also `gnus-buttonized-mime-types' which may override this variable.
780 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
782 :group 'gnus-article-mime
783 :type '(repeat regexp))
785 (defcustom gnus-buttonized-mime-types nil
786 "List of MIME types that should be given buttons when rendered inline.
787 If set, this variable overrides `gnus-unbuttonized-mime-types'.
788 To see e.g. security buttons you could set this to
789 `(\"multipart/signed\")'.
790 This variable is only used when `gnus-inhibit-mime-unbuttonizing' is nil."
792 :group 'gnus-article-mime
793 :type '(repeat regexp))
795 (defcustom gnus-inhibit-mime-unbuttonizing nil
796 "If non-nil, all MIME parts get buttons.
797 When nil (the default value), then some MIME parts do not get buttons,
798 as described by the variables `gnus-buttonized-mime-types' and
799 `gnus-unbuttonized-mime-types'."
803 (defcustom gnus-body-boundary-delimiter "_"
804 "String used to delimit header and body.
805 This variable is used by `gnus-article-treat-body-boundary' which can
806 be controlled by `gnus-treat-body-boundary'."
807 :group 'gnus-article-various
808 :type '(choice (item :tag "None" :value nil)
811 (defcustom gnus-picon-databases '("/usr/lib/picon" "/usr/local/faces")
812 "Defines the location of the faces database.
813 For information on obtaining this database of pretty pictures, please
814 see http://www.cs.indiana.edu/picons/ftp/index.html"
815 :type '(repeat directory)
816 :link '(url-link :tag "download"
817 "http://www.cs.indiana.edu/picons/ftp/index.html")
818 :link '(custom-manual "(gnus)Picons")
821 (defun gnus-picons-installed-p ()
822 "Say whether picons are installed on your machine."
823 (let ((installed nil))
824 (dolist (database gnus-picon-databases)
825 (when (file-exists-p database)
829 (defcustom gnus-article-mime-part-function nil
830 "Function called with a MIME handle as the argument.
831 This is meant for people who want to do something automatic based
832 on parts -- for instance, adding Vcard info to a database."
833 :group 'gnus-article-mime
836 (defcustom gnus-mime-multipart-functions nil
837 "An alist of MIME types to functions to display them."
839 :group 'gnus-article-mime
842 (defcustom gnus-article-date-lapsed-new-header nil
843 "Whether the X-Sent and Date headers can coexist.
844 When using `gnus-treat-date-lapsed', the \"X-Sent:\" header will
845 either replace the old \"Date:\" header (if this variable is nil), or
846 be added below it (otherwise)."
848 :group 'gnus-article-headers
851 (defcustom gnus-article-mime-match-handle-function 'undisplayed-alternative
852 "Function called with a MIME handle as the argument.
853 This is meant for people who want to view first matched part.
854 For `undisplayed-alternative' (default), the first undisplayed
855 part or alternative part is used. For `undisplayed', the first
856 undisplayed part is used. For a function, the first part which
857 the function return t is used. For nil, the first part is
860 :group 'gnus-article-mime
862 (item :tag "first" :value nil)
863 (item :tag "undisplayed" :value undisplayed)
864 (item :tag "undisplayed or alternative"
865 :value undisplayed-alternative)
868 (defcustom gnus-mime-action-alist
869 '(("save to file" . gnus-mime-save-part)
870 ("save and strip" . gnus-mime-save-part-and-strip)
871 ("delete part" . gnus-mime-delete-part)
872 ("display as text" . gnus-mime-inline-part)
873 ("view the part" . gnus-mime-view-part)
874 ("pipe to command" . gnus-mime-pipe-part)
875 ("toggle display" . gnus-article-press-button)
876 ("toggle display" . gnus-article-view-part-as-charset)
877 ("view as type" . gnus-mime-view-part-as-type)
878 ("view internally" . gnus-mime-view-part-internally)
879 ("view externally" . gnus-mime-view-part-externally))
880 "An alist of actions that run on the MIME attachment."
881 :group 'gnus-article-mime
882 :type '(repeat (cons (string :tag "name")
886 ;;; The treatment variables
889 (defvar gnus-part-display-hook nil
890 "Hook called on parts that are to receive treatment.")
892 (defvar gnus-article-treat-custom
893 '(choice (const :tag "Off" nil)
895 (const :tag "Header" head)
896 (const :tag "Last" last)
897 (const :tag "Mime" mime)
898 (integer :tag "Less")
899 (repeat :tag "Groups" regexp)
900 (sexp :tag "Predicate")))
902 (defvar gnus-article-treat-head-custom
903 '(choice (const :tag "Off" nil)
904 (const :tag "Header" head)))
906 (defvar gnus-article-treat-types '("text/plain")
909 (defvar gnus-inhibit-treatment nil
910 "Whether to inhibit treatment.")
912 (defcustom gnus-treat-highlight-signature '(or last (typep "text/x-vcard"))
913 "Highlight the signature.
914 Valid values are nil, t, `head', `last', an integer or a predicate.
915 See Info node `(gnus)Customizing Articles'."
916 :group 'gnus-article-treat
917 :link '(custom-manual "(gnus)Customizing Articles")
918 :type gnus-article-treat-custom)
919 (put 'gnus-treat-highlight-signature 'highlight t)
921 (defcustom gnus-treat-buttonize 100000
923 Valid values are nil, t, `head', `last', an integer or a predicate.
924 See Info node `(gnus)Customizing Articles'."
925 :group 'gnus-article-treat
926 :link '(custom-manual "(gnus)Customizing Articles")
927 :type gnus-article-treat-custom)
928 (put 'gnus-treat-buttonize 'highlight t)
930 (defcustom gnus-treat-buttonize-head 'head
931 "Add buttons to the head.
932 Valid values are nil, t, `head', `last', an integer or a predicate.
933 See Info node `(gnus)Customizing Articles' for details."
934 :group 'gnus-article-treat
935 :link '(custom-manual "(gnus)Customizing Articles")
936 :type gnus-article-treat-head-custom)
937 (put 'gnus-treat-buttonize-head 'highlight t)
939 (defcustom gnus-treat-emphasize
940 (and (or window-system
942 (>= (string-to-number emacs-version) 21))
945 Valid values are nil, t, `head', `last', an integer or a predicate.
946 See Info node `(gnus)Customizing Articles' for details."
947 :group 'gnus-article-treat
948 :link '(custom-manual "(gnus)Customizing Articles")
949 :type gnus-article-treat-custom)
950 (put 'gnus-treat-emphasize 'highlight t)
952 (defcustom gnus-treat-strip-cr nil
953 "Remove carriage returns.
954 Valid values are nil, t, `head', `last', an integer or a predicate.
955 See Info node `(gnus)Customizing Articles' for details."
956 :group 'gnus-article-treat
957 :link '(custom-manual "(gnus)Customizing Articles")
958 :type gnus-article-treat-custom)
960 (defcustom gnus-treat-unsplit-urls nil
961 "Remove newlines from within URLs.
962 Valid values are nil, t, `head', `last', an integer or a predicate.
963 See Info node `(gnus)Customizing Articles' for details."
964 :group 'gnus-article-treat
965 :link '(custom-manual "(gnus)Customizing Articles")
966 :type gnus-article-treat-custom)
968 (defcustom gnus-treat-leading-whitespace nil
969 "Remove leading whitespace in headers.
970 Valid values are nil, t, `head', `last', an integer or a predicate.
971 See Info node `(gnus)Customizing Articles' for details."
972 :group 'gnus-article-treat
973 :link '(custom-manual "(gnus)Customizing Articles")
974 :type gnus-article-treat-custom)
976 (defcustom gnus-treat-hide-headers 'head
978 Valid values are nil, t, `head', `last', an integer or a predicate.
979 See Info node `(gnus)Customizing Articles' for details."
980 :group 'gnus-article-treat
981 :link '(custom-manual "(gnus)Customizing Articles")
982 :type gnus-article-treat-head-custom)
984 (defcustom gnus-treat-hide-boring-headers nil
985 "Hide boring headers.
986 Valid values are nil, t, `head', `last', an integer or a predicate.
987 See Info node `(gnus)Customizing Articles' for details."
988 :group 'gnus-article-treat
989 :link '(custom-manual "(gnus)Customizing Articles")
990 :type gnus-article-treat-head-custom)
992 (defcustom gnus-treat-hide-signature nil
994 Valid values are nil, t, `head', `last', an integer or a predicate.
995 See Info node `(gnus)Customizing Articles' for details."
996 :group 'gnus-article-treat
997 :link '(custom-manual "(gnus)Customizing Articles")
998 :type gnus-article-treat-custom)
1000 (defcustom gnus-treat-fill-article nil
1002 Valid values are nil, t, `head', `last', an integer or a predicate.
1003 See Info node `(gnus)Customizing Articles' for details."
1004 :group 'gnus-article-treat
1005 :link '(custom-manual "(gnus)Customizing Articles")
1006 :type gnus-article-treat-custom)
1008 (defcustom gnus-treat-hide-citation nil
1010 Valid values are nil, t, `head', `last', an integer or a predicate.
1011 See Info node `(gnus)Customizing Articles' for details."
1012 :group 'gnus-article-treat
1013 :link '(custom-manual "(gnus)Customizing Articles")
1014 :type gnus-article-treat-custom)
1016 (defcustom gnus-treat-hide-citation-maybe nil
1018 Valid values are nil, t, `head', `last', an integer or a predicate.
1019 See Info node `(gnus)Customizing Articles' for details."
1020 :group 'gnus-article-treat
1021 :link '(custom-manual "(gnus)Customizing Articles")
1022 :type gnus-article-treat-custom)
1024 (defcustom gnus-treat-strip-list-identifiers 'head
1025 "Strip list identifiers from `gnus-list-identifiers`.
1026 Valid values are nil, t, `head', `last', an integer or a predicate.
1027 See Info node `(gnus)Customizing Articles' for details."
1029 :group 'gnus-article-treat
1030 :link '(custom-manual "(gnus)Customizing Articles")
1031 :type gnus-article-treat-custom)
1033 (make-obsolete-variable 'gnus-treat-strip-pgp
1034 "This option is obsolete in Gnus 5.10.")
1036 (defcustom gnus-treat-strip-pem nil
1037 "Strip PEM signatures.
1038 Valid values are nil, t, `head', `last', an integer or a predicate.
1039 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 (defcustom gnus-treat-strip-banner t
1045 "Strip banners from articles.
1046 The banner to be stripped is specified in the `banner' group parameter.
1047 Valid values are nil, t, `head', `last', an integer or a predicate.
1048 See Info node `(gnus)Customizing Articles' for details."
1049 :group 'gnus-article-treat
1050 :link '(custom-manual "(gnus)Customizing Articles")
1051 :type gnus-article-treat-custom)
1053 (defcustom gnus-treat-highlight-headers 'head
1054 "Highlight the headers.
1055 Valid values are nil, t, `head', `last', an integer or a predicate.
1056 See Info node `(gnus)Customizing Articles' for details."
1057 :group 'gnus-article-treat
1058 :link '(custom-manual "(gnus)Customizing Articles")
1059 :type gnus-article-treat-head-custom)
1060 (put 'gnus-treat-highlight-headers 'highlight t)
1062 (defcustom gnus-treat-highlight-citation t
1063 "Highlight cited text.
1064 Valid values are nil, t, `head', `last', an integer or a predicate.
1065 See Info node `(gnus)Customizing Articles' for details."
1066 :group 'gnus-article-treat
1067 :link '(custom-manual "(gnus)Customizing Articles")
1068 :type gnus-article-treat-custom)
1069 (put 'gnus-treat-highlight-citation 'highlight t)
1071 (defcustom gnus-treat-date-ut nil
1072 "Display the Date in UT (GMT).
1073 Valid values are nil, t, `head', `last', an integer or a predicate.
1074 See Info node `(gnus)Customizing Articles' for details."
1075 :group 'gnus-article-treat
1076 :link '(custom-manual "(gnus)Customizing Articles")
1077 :type gnus-article-treat-head-custom)
1079 (defcustom gnus-treat-date-local nil
1080 "Display the Date in the local timezone.
1081 Valid values are nil, t, `head', `last', an integer or a predicate.
1082 See Info node `(gnus)Customizing Articles' for details."
1083 :group 'gnus-article-treat
1084 :link '(custom-manual "(gnus)Customizing Articles")
1085 :type gnus-article-treat-head-custom)
1087 (defcustom gnus-treat-date-english nil
1088 "Display the Date in a format that can be read aloud in English.
1089 Valid values are nil, t, `head', `last', an integer or a predicate.
1090 See Info node `(gnus)Customizing Articles' for details."
1091 :group 'gnus-article-treat
1092 :link '(custom-manual "(gnus)Customizing Articles")
1093 :type gnus-article-treat-head-custom)
1095 (defcustom gnus-treat-date-lapsed nil
1096 "Display the Date header in a way that says how much time has elapsed.
1097 Valid values are nil, t, `head', `last', an integer or a predicate.
1098 See Info node `(gnus)Customizing Articles' for details."
1099 :group 'gnus-article-treat
1100 :link '(custom-manual "(gnus)Customizing Articles")
1101 :type gnus-article-treat-head-custom)
1103 (defcustom gnus-treat-date-original nil
1104 "Display the date in the original timezone.
1105 Valid values are nil, t, `head', `last', an integer or a predicate.
1106 See Info node `(gnus)Customizing Articles' for details."
1107 :group 'gnus-article-treat
1108 :link '(custom-manual "(gnus)Customizing Articles")
1109 :type gnus-article-treat-head-custom)
1111 (defcustom gnus-treat-date-iso8601 nil
1112 "Display the date in the ISO8601 format.
1113 Valid values are nil, t, `head', `last', an integer or a predicate.
1114 See Info node `(gnus)Customizing Articles' for details."
1116 :group 'gnus-article-treat
1117 :link '(custom-manual "(gnus)Customizing Articles")
1118 :type gnus-article-treat-head-custom)
1120 (defcustom gnus-treat-date-user-defined nil
1121 "Display the date in a user-defined format.
1122 The format is defined by the `gnus-article-time-format' variable.
1123 Valid values are nil, t, `head', `last', an integer or a predicate.
1124 See Info node `(gnus)Customizing Articles' for details."
1125 :group 'gnus-article-treat
1126 :link '(custom-manual "(gnus)Customizing Articles")
1127 :type gnus-article-treat-head-custom)
1129 (defcustom gnus-treat-strip-headers-in-body t
1130 "Strip the X-No-Archive header line from the beginning of the body.
1131 Valid values are nil, t, `head', `last', an integer or a predicate.
1132 See Info node `(gnus)Customizing Articles' for details."
1134 :group 'gnus-article-treat
1135 :link '(custom-manual "(gnus)Customizing Articles")
1136 :type gnus-article-treat-custom)
1138 (defcustom gnus-treat-strip-trailing-blank-lines nil
1139 "Strip trailing blank lines.
1140 Valid values are nil, t, `head', `last', an integer or a predicate.
1141 See Info node `(gnus)Customizing Articles' for details."
1142 :group 'gnus-article-treat
1143 :link '(custom-manual "(gnus)Customizing Articles")
1144 :type gnus-article-treat-custom)
1146 (defcustom gnus-treat-strip-leading-blank-lines nil
1147 "Strip leading blank lines.
1148 Valid values are nil, t, `head', `last', an integer or a predicate.
1149 See Info node `(gnus)Customizing Articles' for details."
1150 :group 'gnus-article-treat
1151 :link '(custom-manual "(gnus)Customizing Articles")
1152 :type gnus-article-treat-custom)
1154 (defcustom gnus-treat-strip-multiple-blank-lines nil
1155 "Strip multiple blank lines.
1156 Valid values are nil, t, `head', `last', an integer or a predicate.
1157 See Info node `(gnus)Customizing Articles' for details."
1158 :group 'gnus-article-treat
1159 :link '(custom-manual "(gnus)Customizing Articles")
1160 :type gnus-article-treat-custom)
1162 (defcustom gnus-treat-unfold-headers 'head
1163 "Unfold folded header lines.
1164 Valid values are nil, t, `head', `last', an integer or a predicate.
1165 See Info node `(gnus)Customizing Articles' for details."
1166 :group 'gnus-article-treat
1167 :link '(custom-manual "(gnus)Customizing Articles")
1168 :type gnus-article-treat-custom)
1170 (defcustom gnus-treat-fold-headers nil
1172 Valid values are nil, t, `head', `last', an integer or a predicate.
1173 See Info node `(gnus)Customizing Articles' for details."
1174 :group 'gnus-article-treat
1175 :link '(custom-manual "(gnus)Customizing Articles")
1176 :type gnus-article-treat-custom)
1178 (defcustom gnus-treat-fold-newsgroups 'head
1179 "Fold the Newsgroups and Followup-To headers.
1180 Valid values are nil, t, `head', `last', an integer or a predicate.
1181 See Info node `(gnus)Customizing Articles' for details."
1182 :group 'gnus-article-treat
1183 :link '(custom-manual "(gnus)Customizing Articles")
1184 :type gnus-article-treat-custom)
1186 (defcustom gnus-treat-overstrike t
1187 "Treat overstrike highlighting.
1188 Valid values are nil, t, `head', `last', an integer or a predicate.
1189 See Info node `(gnus)Customizing Articles' for details."
1190 :group 'gnus-article-treat
1191 :link '(custom-manual "(gnus)Customizing Articles")
1192 :type gnus-article-treat-custom)
1193 (put 'gnus-treat-overstrike 'highlight t)
1195 (defcustom gnus-treat-display-xface
1196 (and (not noninteractive)
1197 (or (and (fboundp 'image-type-available-p)
1198 (image-type-available-p 'xbm)
1199 (string-match "^0x" (shell-command-to-string "uncompface")))
1200 (and (featurep 'xemacs)
1202 (eq 'x-face-mule-gnus-article-display-x-face
1203 gnus-article-x-face-command))
1205 "Display X-Face headers.
1206 Valid values are nil, t, `head', `last', an integer or a predicate.
1207 See Info node `(gnus)Customizing Articles' and Info node
1208 `(gnus)X-Face' for details."
1209 :group 'gnus-article-treat
1211 :link '(custom-manual "(gnus)Customizing Articles")
1212 :link '(custom-manual "(gnus)X-Face")
1213 :type gnus-article-treat-head-custom)
1214 (put 'gnus-treat-display-xface 'highlight t)
1216 (defcustom gnus-article-should-use-smiley-mule
1217 (not (or (featurep 'xemacs)
1218 (gnus-image-type-available-p 'xpm)
1219 (gnus-image-type-available-p 'pbm)))
1220 "If non-nil, gnus uses `smiley-mule' for displaying smileys rather than
1221 `smiley'. It defaults to t when Emacs 20 or earlier is running.
1222 `smiley-mule' is boundled in BITMAP-MULE package. You can set it to t
1223 even if you are using Emacs 21+. It has no effect on XEmacs."
1224 :group 'gnus-article-various
1226 :get (lambda (symbol)
1227 (and (not noninteractive)
1228 (default-value symbol)
1229 (not (featurep 'xemacs))
1230 (module-installed-p 'smiley-mule)
1232 :set (lambda (symbol value)
1233 (set-default symbol (and (not noninteractive)
1235 (not (featurep 'xemacs))
1236 (module-installed-p 'smiley-mule)
1239 (defvar gnus-article-smiley-mule-loaded-p nil
1240 "Internal variable used to say whether `smiley-mule' is loaded (whether
1241 smiley functions are not overridden by `smiley').")
1243 (defcustom gnus-treat-display-face
1244 (and (not noninteractive)
1245 ;; x-face-e21 handles both X-Face and Face headers.
1246 (not (and (eq gnus-article-x-face-command 'x-face-decode-message-header)
1247 (module-installed-p 'x-face-e21)))
1248 (or (and (fboundp 'image-type-available-p)
1249 (image-type-available-p 'png))
1250 (and (featurep 'xemacs)
1253 "Display Face headers.
1254 Valid values are nil, t, `head', `last', an integer or a predicate.
1255 See Info node `(gnus)Customizing Articles' and Info node
1256 `(gnus)X-Face' for details."
1257 :group 'gnus-article-treat
1259 :link '(custom-manual "(gnus)Customizing Articles")
1260 :link '(custom-manual "(gnus)X-Face")
1261 :type gnus-article-treat-head-custom)
1262 (put 'gnus-treat-display-face 'highlight t)
1264 (defcustom gnus-treat-display-smileys
1265 (if (and (not noninteractive)
1266 (or (and (featurep 'xemacs)
1268 (gnus-image-type-available-p 'xpm)
1269 (gnus-image-type-available-p 'pbm)
1270 (and (not (featurep 'xemacs))
1272 (module-installed-p 'smiley-mule))))
1276 Valid values are nil, t, `head', `last', an integer or a predicate.
1277 See Info node `(gnus)Customizing Articles' and Info node
1278 `(gnus)Smileys' for details."
1279 :group 'gnus-article-treat
1281 :link '(custom-manual "(gnus)Customizing Articles")
1282 :link '(custom-manual "(gnus)Smileys")
1283 :type gnus-article-treat-custom)
1284 (put 'gnus-treat-display-smileys 'highlight t)
1286 (defcustom gnus-treat-from-picon
1287 (if (and (gnus-image-type-available-p 'xpm)
1288 (gnus-picons-installed-p))
1290 "Display picons in the From header.
1291 Valid values are nil, t, `head', `last', an integer or a predicate.
1292 See Info node `(gnus)Customizing Articles' and Info node
1293 `(gnus)Picons' for details."
1294 :group 'gnus-article-treat
1296 :link '(custom-manual "(gnus)Customizing Articles")
1297 :link '(custom-manual "(gnus)Picons")
1298 :type gnus-article-treat-head-custom)
1299 (put 'gnus-treat-from-picon 'highlight t)
1301 (defcustom gnus-treat-mail-picon
1302 (if (and (gnus-image-type-available-p 'xpm)
1303 (gnus-picons-installed-p))
1305 "Display picons in To and Cc headers.
1306 Valid values are nil, t, `head', `last', an integer or a predicate.
1307 See Info node `(gnus)Customizing Articles' and Info node
1308 `(gnus)Picons' for details."
1309 :group 'gnus-article-treat
1311 :link '(custom-manual "(gnus)Customizing Articles")
1312 :link '(custom-manual "(gnus)Picons")
1313 :type gnus-article-treat-head-custom)
1314 (put 'gnus-treat-mail-picon 'highlight t)
1316 (defcustom gnus-treat-newsgroups-picon
1317 (if (and (gnus-image-type-available-p 'xpm)
1318 (gnus-picons-installed-p))
1320 "Display picons in the Newsgroups and Followup-To headers.
1321 Valid values are nil, t, `head', `last', an integer or a predicate.
1322 See Info node `(gnus)Customizing Articles' and Info node
1323 `(gnus)Picons' for details."
1324 :group 'gnus-article-treat
1326 :link '(custom-manual "(gnus)Customizing Articles")
1327 :link '(custom-manual "(gnus)Picons")
1328 :type gnus-article-treat-head-custom)
1329 (put 'gnus-treat-newsgroups-picon 'highlight t)
1331 (defcustom gnus-treat-body-boundary
1332 (if (or gnus-treat-newsgroups-picon
1333 gnus-treat-mail-picon
1334 gnus-treat-from-picon)
1336 "Draw a boundary at the end of the headers.
1337 Valid values are nil, t, `head', `last', an integer or a predicate.
1338 See Info node `(gnus)Customizing Articles' for details."
1340 :group 'gnus-article-treat
1341 :link '(custom-manual "(gnus)Customizing Articles")
1342 :type gnus-article-treat-custom)
1344 (defcustom gnus-treat-capitalize-sentences nil
1345 "Capitalize sentence-starting words.
1346 Valid values are nil, t, `head', `last', an integer or a predicate.
1347 See Info node `(gnus)Customizing Articles' for details."
1349 :group 'gnus-article-treat
1350 :link '(custom-manual "(gnus)Customizing Articles")
1351 :type gnus-article-treat-custom)
1353 (defcustom gnus-treat-wash-html nil
1355 Valid values are nil, t, `head', `last', an integer or a predicate.
1356 See Info node `(gnus)Customizing Articles' for details."
1357 :group 'gnus-article-treat
1358 :link '(custom-manual "(gnus)Customizing Articles")
1359 :type gnus-article-treat-custom)
1361 (defcustom gnus-treat-fill-long-lines nil
1363 Valid values are nil, t, `head', `last', an integer or a predicate.
1364 See Info node `(gnus)Customizing Articles' for details."
1365 :group 'gnus-article-treat
1366 :link '(custom-manual "(gnus)Customizing Articles")
1367 :type gnus-article-treat-custom)
1369 (defcustom gnus-treat-play-sounds nil
1371 Valid values are nil, t, `head', `last', an integer or a predicate.
1372 See Info node `(gnus)Customizing Articles' for details."
1374 :group 'gnus-article-treat
1375 :link '(custom-manual "(gnus)Customizing Articles")
1376 :type gnus-article-treat-custom)
1378 (defcustom gnus-treat-decode-article-as-default-mime-charset nil
1379 "Decode an article as `default-mime-charset'. For instance, if you want to
1380 attempt to decode an article even if the value of `gnus-show-mime' is nil,
1381 you could set this variable to something like: nil for don't decode, t for
1382 decode the body, '(or header t) for the whole article, etc."
1383 :group 'gnus-article-treat
1384 :type '(radio (const :tag "Off" nil)
1385 (const :tag "Decode body" t)
1386 (const :tag "Decode all" (or head t))))
1388 (defcustom gnus-treat-translate nil
1389 "Translate articles from one language to another.
1390 Valid values are nil, t, `head', `last', an integer or a predicate.
1391 See Info node `(gnus)Customizing Articles' for details."
1393 :group 'gnus-article-treat
1394 :link '(custom-manual "(gnus)Customizing Articles")
1395 :type gnus-article-treat-custom)
1397 (defcustom gnus-treat-x-pgp-sig nil
1399 To automatically treat X-PGP-Sig, set it to head.
1400 Valid values are nil, t, `head', `last', an integer or a predicate.
1401 See Info node `(gnus)Customizing Articles' for details."
1402 :group 'gnus-article-treat
1403 :group 'mime-security
1404 :type gnus-article-treat-custom)
1406 (defcustom gnus-treat-monafy nil
1407 "Display body part with mona font.
1408 Valid values are nil, t, `head', `last', an integer or a predicate.
1409 See Info node `(gnus)Customizing Articles' for details."
1410 :group 'gnus-article-treat
1411 :group 'mime-security
1412 :link '(custom-manual "(gnus)Customizing Articles")
1413 :type gnus-article-treat-custom)
1415 (defvar gnus-article-encrypt-protocol-alist
1416 '(("PGP" . mml2015-self-encrypt)))
1418 ;; Set to nil if more than one protocol added to
1419 ;; gnus-article-encrypt-protocol-alist.
1420 (defcustom gnus-article-encrypt-protocol "PGP"
1421 "The protocol used for encrypt articles.
1422 It is a string, such as \"PGP\". If nil, ask user."
1424 :group 'mime-security)
1426 (defvar gnus-article-wash-function nil
1427 "Function used for converting HTML into text.")
1429 ;;; Internal variables
1431 (defvar gnus-english-month-names
1432 '("January" "February" "March" "April" "May" "June" "July" "August"
1433 "September" "October" "November" "December"))
1435 (defvar article-goto-body-goes-to-point-min-p nil)
1436 (defvar gnus-article-wash-types nil)
1437 (defvar gnus-article-emphasis-alist nil)
1438 (defvar gnus-article-image-alist nil)
1440 (defvar gnus-article-mime-handle-alist-1 nil)
1441 (defvar gnus-treatment-function-alist
1442 '((gnus-treat-decode-article-as-default-mime-charset
1443 gnus-article-decode-article-as-default-mime-charset)
1444 (gnus-treat-x-pgp-sig gnus-article-verify-x-pgp-sig)
1445 (gnus-treat-monafy gnus-article-monafy)
1446 (gnus-treat-strip-banner gnus-article-strip-banner)
1447 (gnus-treat-strip-headers-in-body gnus-article-strip-headers-in-body)
1448 (gnus-treat-buttonize gnus-article-add-buttons)
1449 (gnus-treat-fill-article gnus-article-fill-cited-article)
1450 (gnus-treat-fill-long-lines gnus-article-fill-long-lines)
1451 (gnus-treat-strip-cr gnus-article-remove-cr)
1452 (gnus-treat-unsplit-urls gnus-article-unsplit-urls)
1453 (gnus-treat-date-ut gnus-article-date-ut)
1454 (gnus-treat-date-local gnus-article-date-local)
1455 (gnus-treat-date-english gnus-article-date-english)
1456 (gnus-treat-date-lapsed gnus-article-date-lapsed)
1457 (gnus-treat-date-original gnus-article-date-original)
1458 (gnus-treat-date-user-defined gnus-article-date-user)
1459 (gnus-treat-date-iso8601 gnus-article-date-iso8601)
1460 (gnus-treat-display-face gnus-article-display-face)
1461 (gnus-treat-hide-headers gnus-article-maybe-hide-headers)
1462 (gnus-treat-hide-boring-headers gnus-article-hide-boring-headers)
1463 (gnus-treat-hide-signature gnus-article-hide-signature)
1464 (gnus-treat-strip-list-identifiers gnus-article-hide-list-identifiers)
1465 (gnus-treat-leading-whitespace gnus-article-remove-leading-whitespace)
1466 (gnus-treat-strip-pem gnus-article-hide-pem)
1467 (gnus-treat-from-picon gnus-treat-from-picon)
1468 (gnus-treat-mail-picon gnus-treat-mail-picon)
1469 (gnus-treat-newsgroups-picon gnus-treat-newsgroups-picon)
1470 (gnus-treat-highlight-headers gnus-article-highlight-headers)
1471 (gnus-treat-highlight-signature gnus-article-highlight-signature)
1472 (gnus-treat-strip-trailing-blank-lines
1473 gnus-article-remove-trailing-blank-lines)
1474 (gnus-treat-strip-leading-blank-lines
1475 gnus-article-strip-leading-blank-lines)
1476 (gnus-treat-strip-multiple-blank-lines
1477 gnus-article-strip-multiple-blank-lines)
1478 (gnus-treat-overstrike gnus-article-treat-overstrike)
1479 (gnus-treat-unfold-headers gnus-article-treat-unfold-headers)
1480 (gnus-treat-fold-headers gnus-article-treat-fold-headers)
1481 ;; Displaying X-Face should be done after unfolding headers
1482 ;; to protect bitmap lines.
1483 (gnus-treat-display-xface gnus-article-display-x-face)
1484 (gnus-treat-fold-newsgroups gnus-article-treat-fold-newsgroups)
1485 (gnus-treat-buttonize-head gnus-article-add-buttons-to-head)
1486 (gnus-treat-display-smileys gnus-treat-smiley)
1487 (gnus-treat-capitalize-sentences gnus-article-capitalize-sentences)
1488 (gnus-treat-wash-html gnus-article-wash-html)
1489 (gnus-treat-emphasize gnus-article-emphasize)
1490 (gnus-treat-hide-citation gnus-article-hide-citation)
1491 (gnus-treat-hide-citation-maybe gnus-article-hide-citation-maybe)
1492 (gnus-treat-highlight-citation gnus-article-highlight-citation)
1493 (gnus-treat-body-boundary gnus-article-treat-body-boundary)
1494 (gnus-treat-play-sounds gnus-earcon-display)))
1496 (defvar gnus-article-mime-handle-alist nil)
1497 (defvar article-lapsed-timer nil)
1498 (defvar gnus-article-current-summary nil)
1500 (defvar gnus-article-mode-syntax-table
1501 (let ((table (copy-syntax-table text-mode-syntax-table)))
1502 ;; This causes the citation match run O(2^n).
1503 ;; (modify-syntax-entry ?- "w" table)
1504 (modify-syntax-entry ?> ")<" table)
1505 (modify-syntax-entry ?< "(>" table)
1506 ;; make M-. in article buffers work for `foo' strings
1507 (modify-syntax-entry ?' " " table)
1508 (modify-syntax-entry ?` " " table)
1510 "Syntax table used in article mode buffers.
1511 Initialized from `text-mode-syntax-table.")
1513 (defvar gnus-save-article-buffer nil)
1515 (defvar gnus-article-mode-line-format-alist
1516 (nconc '((?w (gnus-article-wash-status) ?s)
1517 (?m (gnus-article-mime-part-status) ?s))
1518 gnus-summary-mode-line-format-alist))
1520 (defvar gnus-number-of-articles-to-be-saved nil)
1522 (defvar gnus-inhibit-hiding nil)
1524 ;;; Macros for dealing with the article buffer.
1526 (defmacro gnus-with-article-headers (&rest forms)
1528 (set-buffer gnus-article-buffer)
1530 (let ((buffer-read-only nil)
1531 (inhibit-point-motion-hooks t)
1532 (case-fold-search t))
1533 (article-narrow-to-head)
1536 (put 'gnus-with-article-headers 'lisp-indent-function 0)
1537 (put 'gnus-with-article-headers 'edebug-form-spec '(body))
1539 (defmacro gnus-with-article-buffer (&rest forms)
1541 (set-buffer gnus-article-buffer)
1542 (let ((buffer-read-only nil))
1545 (put 'gnus-with-article-buffer 'lisp-indent-function 0)
1546 (put 'gnus-with-article-buffer 'edebug-form-spec '(body))
1548 (defun gnus-article-goto-header (header)
1549 "Go to HEADER, which is a regular expression."
1550 (re-search-forward (concat "^\\(" header "\\):") nil t))
1552 (defsubst gnus-article-hide-text (b e props)
1553 "Set text PROPS on the B to E region, extending `intangible' 1 past B."
1554 (gnus-add-text-properties-when 'article-type nil b e props)
1555 (when (memq 'intangible props)
1557 (max (1- b) (point-min))
1558 b 'intangible (cddr (memq 'intangible props)))))
1560 (defsubst gnus-article-unhide-text (b e)
1561 "Remove hidden text properties from region between B and E."
1562 (remove-text-properties b e gnus-hidden-properties)
1563 (when (memq 'intangible gnus-hidden-properties)
1564 (put-text-property (max (1- b) (point-min))
1565 b 'intangible nil)))
1567 (defun gnus-article-hide-text-type (b e type)
1568 "Hide text of TYPE between B and E."
1569 (gnus-add-wash-type type)
1570 (gnus-article-hide-text
1571 b e (cons 'article-type (cons type gnus-hidden-properties))))
1573 (defun gnus-article-unhide-text-type (b e type)
1574 "Unhide text of TYPE between B and E."
1575 (gnus-delete-wash-type type)
1576 (remove-text-properties
1577 b e (cons 'article-type (cons type gnus-hidden-properties)))
1578 (when (memq 'intangible gnus-hidden-properties)
1579 (put-text-property (max (1- b) (point-min))
1580 b 'intangible nil)))
1582 (defun gnus-article-hide-text-of-type (type)
1583 "Hide text of TYPE in the current buffer."
1585 (let ((b (point-min))
1587 (while (setq b (text-property-any b e 'article-type type))
1588 (add-text-properties b (incf b) gnus-hidden-properties)))))
1590 (defun gnus-article-delete-text-of-type (type)
1591 "Delete text of TYPE in the current buffer."
1593 (let ((b (point-min)))
1594 (while (setq b (text-property-any b (point-max) 'article-type type))
1596 b (or (text-property-not-all b (point-max) 'article-type type)
1599 (defun gnus-article-delete-invisible-text ()
1600 "Delete all invisible text in the current buffer."
1602 (let ((b (point-min)))
1603 (while (setq b (text-property-any b (point-max) 'invisible t))
1605 b (or (text-property-not-all b (point-max) 'invisible t)
1608 (defun gnus-article-text-type-exists-p (type)
1609 "Say whether any text of type TYPE exists in the buffer."
1610 (text-property-any (point-min) (point-max) 'article-type type))
1612 (defsubst gnus-article-header-rank ()
1613 "Give the rank of the string HEADER as given by `gnus-sorted-header-list'."
1614 (let ((list gnus-sorted-header-list)
1617 (if (looking-at (car list))
1619 (setq list (cdr list))
1623 (defun article-hide-headers (&optional arg delete)
1624 "Hide unwanted headers and possibly sort them as well."
1625 (interactive (gnus-article-hidden-arg))
1626 ;; Lars said that this function might be inhibited.
1627 (if (gnus-article-check-hidden-text 'headers arg)
1629 ;; Show boring headers as well.
1630 (gnus-article-show-hidden-text 'boring-headers)
1631 (when (eq 1 (point-min))
1632 (set-window-start (get-buffer-window (current-buffer)) 1)))
1633 (unless gnus-inhibit-hiding
1636 (let ((inhibit-read-only t)
1637 (case-fold-search t)
1638 (max (1+ (length gnus-sorted-header-list)))
1639 (ignored (when (not gnus-visible-headers)
1640 (cond ((stringp gnus-ignored-headers)
1641 gnus-ignored-headers)
1642 ((listp gnus-ignored-headers)
1643 (mapconcat 'identity gnus-ignored-headers
1646 (cond ((stringp gnus-visible-headers)
1647 gnus-visible-headers)
1648 ((and gnus-visible-headers
1649 (listp gnus-visible-headers))
1650 (mapconcat 'identity gnus-visible-headers "\\|"))))
1651 (inhibit-point-motion-hooks t)
1653 ;; First we narrow to just the headers.
1654 (article-narrow-to-head)
1655 ;; Hide any "From " lines at the beginning of (mail) articles.
1656 (while (looking-at "From ")
1660 (delete-region (point-min) (point))
1661 (gnus-article-hide-text (point-min) (point)
1662 (nconc (list 'article-type 'headers)
1663 gnus-hidden-properties))))
1664 ;; Then treat the rest of the header lines.
1665 ;; Then we use the two regular expressions
1666 ;; `gnus-ignored-headers' and `gnus-visible-headers' to
1667 ;; select which header lines is to remain visible in the
1669 (while (re-search-forward "^[^ \t:]*:" nil t)
1671 ;; Mark the rank of the header.
1673 (point) (1+ (point)) 'message-rank
1674 (if (or (and visible (looking-at visible))
1676 (not (looking-at ignored))))
1677 (gnus-article-header-rank)
1680 (message-sort-headers-1)
1681 (when (setq beg (text-property-any
1682 (point-min) (point-max) 'message-rank (+ 2 max)))
1683 ;; We delete or make invisible the unwanted headers.
1684 (gnus-add-wash-type 'headers)
1687 (add-text-properties
1688 (point-min) (+ 5 (point-min))
1689 '(article-type headers dummy-invisible t))
1690 (delete-region beg (point-max)))
1691 (gnus-article-hide-text-type beg (point-max) 'headers)))))))))
1693 (defun article-hide-boring-headers (&optional arg)
1694 "Toggle hiding of headers that aren't very interesting.
1695 If given a negative prefix, always show; if given a positive prefix,
1697 (interactive (gnus-article-hidden-arg))
1698 (when (and (not (gnus-article-check-hidden-text 'boring-headers arg))
1699 (not gnus-show-all-headers))
1702 (let ((buffer-read-only nil)
1703 (list gnus-boring-article-headers)
1704 (inhibit-point-motion-hooks t)
1706 (article-narrow-to-head)
1708 (setq elem (pop list))
1709 (goto-char (point-min))
1711 ;; Hide empty headers.
1713 (while (re-search-forward "^[^: \t]+:[ \t]*\n[^ \t]" nil t)
1715 (gnus-article-hide-text-type
1719 (if (re-search-forward "^[^ \t]" nil t)
1723 ;; Hide boring Newsgroups header.
1724 ((eq elem 'newsgroups)
1725 (when (gnus-string-equal
1726 (gnus-fetch-field "newsgroups")
1727 (gnus-group-real-name
1728 (if (boundp 'gnus-newsgroup-name)
1731 (gnus-article-hide-header "newsgroups")))
1732 ((eq elem 'to-address)
1733 (let ((to (message-fetch-field "to"))
1735 (gnus-parameter-to-address
1736 (if (boundp 'gnus-newsgroup-name)
1737 gnus-newsgroup-name ""))))
1738 (when (and to to-address
1741 ;; only one address in To
1742 (nth 1 (mail-extract-address-components to))
1744 (gnus-article-hide-header "to"))))
1746 (let ((to (message-fetch-field "to"))
1748 (gnus-parameter-to-list
1749 (if (boundp 'gnus-newsgroup-name)
1750 gnus-newsgroup-name ""))))
1751 (when (and to to-list
1754 ;; only one address in To
1755 (nth 1 (mail-extract-address-components to))
1757 (gnus-article-hide-header "to"))))
1759 (let ((cc (message-fetch-field "cc"))
1761 (gnus-parameter-to-list
1762 (if (boundp 'gnus-newsgroup-name)
1763 gnus-newsgroup-name ""))))
1764 (when (and cc to-list
1767 ;; only one address in CC
1768 (nth 1 (mail-extract-address-components cc))
1770 (gnus-article-hide-header "cc"))))
1771 ((eq elem 'followup-to)
1772 (when (gnus-string-equal
1773 (message-fetch-field "followup-to")
1774 (message-fetch-field "newsgroups"))
1775 (gnus-article-hide-header "followup-to")))
1776 ((eq elem 'reply-to)
1777 (let ((from (message-fetch-field "from"))
1778 (reply-to (message-fetch-field "reply-to")))
1783 (nth 1 (mail-extract-address-components from))
1784 (nth 1 (mail-extract-address-components reply-to)))))
1785 (gnus-article-hide-header "reply-to"))))
1787 (let ((date (message-fetch-field "date")))
1789 (< (days-between (current-time-string) date)
1791 (gnus-article-hide-header "date"))))
1793 (let ((to (message-fetch-field "to"))
1794 (cc (message-fetch-field "cc")))
1795 (when (> (length to) 1024)
1796 (gnus-article-hide-header "to"))
1797 (when (> (length cc) 1024)
1798 (gnus-article-hide-header "cc"))))
1802 (goto-char (point-min))
1803 (while (re-search-forward "^to:" nil t)
1804 (setq to-count (1+ to-count)))
1805 (when (> to-count 1)
1806 (while (> to-count 0)
1807 (goto-char (point-min))
1809 (re-search-forward "^to:" nil nil to-count)
1811 (narrow-to-region (point) (point-max))
1812 (gnus-article-hide-header "to"))
1813 (setq to-count (1- to-count))))
1814 (goto-char (point-min))
1815 (while (re-search-forward "^cc:" nil t)
1816 (setq cc-count (1+ cc-count)))
1817 (when (> cc-count 1)
1818 (while (> cc-count 0)
1819 (goto-char (point-min))
1821 (re-search-forward "^cc:" nil nil cc-count)
1823 (narrow-to-region (point) (point-max))
1824 (gnus-article-hide-header "cc"))
1825 (setq cc-count (1- cc-count)))))))))))))
1827 (defun gnus-article-hide-header (header)
1829 (goto-char (point-min))
1830 (when (re-search-forward (concat "^" header ":") nil t)
1831 (gnus-article-hide-text-type
1835 (if (re-search-forward "^[^ \t]" nil t)
1840 (defvar gnus-article-normalized-header-length 40
1841 "Length of normalized headers.")
1843 (defun article-normalize-headers ()
1844 "Make all header lines 40 characters long."
1846 (let ((buffer-read-only nil)
1850 (article-narrow-to-head)
1853 ((< (setq column (- (gnus-point-at-eol) (point)))
1854 gnus-article-normalized-header-length)
1856 (insert (make-string
1857 (- gnus-article-normalized-header-length column)
1859 ((> column gnus-article-normalized-header-length)
1860 (gnus-put-text-property
1862 (forward-char gnus-article-normalized-header-length)
1869 (forward-line 1))))))
1871 (defun article-treat-dumbquotes ()
1872 "Translate M****s*** sm*rtq**t*s into proper text.
1873 Note that this function guesses whether a character is a sm*rtq**t* or
1874 not, so it should only be used interactively.
1876 Sm*rtq**t*s are M****s***'s unilateral extension to the character map
1877 in an attempt to provide more quoting characters. If you see
1878 something like \\222 or \\264 where you're expecting some kind of
1879 apostrophe or quotation mark, then try this wash."
1881 (article-translate-strings gnus-article-dumbquotes-map))
1883 (defun article-translate-characters (from to)
1884 "Translate all characters in the body of the article according to FROM and TO.
1885 FROM is a string of characters to translate from; to is a string of
1886 characters to translate to."
1888 (when (article-goto-body)
1889 (let ((buffer-read-only nil)
1890 (x (make-string 225 ?x))
1892 (while (< (incf i) (length x))
1895 (while (< i (length from))
1896 (aset x (aref from i) (aref to i))
1898 (translate-region (point) (point-max) x)))))
1900 (defun article-translate-strings (map)
1901 "Translate all string in the body of the article according to MAP.
1902 MAP is an alist where the elements are on the form (\"from\" \"to\")."
1904 (when (article-goto-body)
1905 (let ((buffer-read-only nil)
1907 (while (setq elem (pop map))
1909 (while (search-forward (car elem) nil t)
1910 (replace-match (cadr elem)))))))))
1912 (defun article-treat-overstrike ()
1913 "Translate overstrikes into bold text."
1916 (when (article-goto-body)
1917 (let ((buffer-read-only nil))
1918 (while (search-forward "\b" nil t)
1919 (let ((next (char-after))
1923 previous (char-after))
1927 ;; We do the boldification/underlining by hiding the
1928 ;; overstrikes and putting the proper text property
1932 (gnus-article-hide-text-type start (point) 'overstrike)
1933 (put-text-property (point) end 'face 'bold))
1935 (gnus-article-hide-text-type
1936 (1- (point)) (1+ (point)) 'overstrike)
1938 start (1- (point)) 'face 'underline))
1940 (gnus-article-hide-text-type start (point) 'overstrike)
1942 (point) end 'face 'underline)))))))))
1944 (defun gnus-article-treat-unfold-headers ()
1945 "Unfold folded message headers.
1946 Only the headers that fit into the current window width will be
1949 (gnus-with-article-headers
1953 (mail-header-narrow-to-field)
1954 (let ((header (buffer-string)))
1957 (goto-char (point-min))
1958 (while (re-search-forward "\n[\t ]" nil t)
1959 (replace-match " " t t)))
1960 (setq length (- (point-max) (point-min) 1)))
1961 (when (< length (window-width))
1962 (while (re-search-forward "\n[\t ]" nil t)
1963 (replace-match " " t t)))
1964 (goto-char (point-max)))))))
1966 (defun gnus-article-treat-fold-headers ()
1967 "Fold message headers."
1969 (gnus-with-article-headers
1972 (mail-header-narrow-to-field)
1973 (mail-header-fold-field)
1974 (goto-char (point-max))))))
1976 (defun gnus-treat-smiley ()
1977 "Toggle display of textual emoticons (\"smileys\") as small graphical icons."
1979 (unless (featurep 'xemacs)
1980 (when (and (>= emacs-major-version 21)
1981 (not gnus-article-should-use-smiley-mule)
1982 gnus-article-smiley-mule-loaded-p)
1983 (load "smiley" nil t)
1984 (setq gnus-article-smiley-mule-loaded-p nil))
1985 (when (and gnus-article-should-use-smiley-mule
1986 (not gnus-article-smiley-mule-loaded-p))
1987 (load "smiley-mule" nil t)
1988 (setq gnus-article-smiley-mule-loaded-p t)))
1989 (gnus-with-article-buffer
1990 (if (memq 'smiley gnus-article-wash-types)
1991 (gnus-delete-images 'smiley)
1993 (let ((images (smiley-region (point) (point-max))))
1995 (gnus-add-wash-type 'smiley)
1996 (dolist (image images)
1997 (gnus-add-image 'smiley image)))))))
1999 (defun gnus-article-remove-images ()
2000 "Remove all images from the article buffer."
2002 (gnus-with-article-buffer
2003 (dolist (elem gnus-article-image-alist)
2004 (gnus-delete-images (car elem)))))
2006 (defun gnus-article-treat-fold-newsgroups ()
2007 "Unfold folded message headers.
2008 Only the headers that fit into the current window width will be
2011 (gnus-with-article-headers
2012 (while (gnus-article-goto-header "newsgroups\\|followup-to")
2014 (mail-header-narrow-to-field)
2015 (while (re-search-forward ", *" nil t)
2016 (replace-match ", " t t))
2017 (mail-header-fold-field)
2018 (goto-char (point-max))))))
2020 (defun gnus-article-treat-body-boundary ()
2021 "Place a boundary line at the end of the headers."
2023 (when (and gnus-body-boundary-delimiter
2024 (> (length gnus-body-boundary-delimiter) 0))
2025 (gnus-with-article-headers
2026 (goto-char (point-max))
2027 (let ((start (point)))
2028 (insert "X-Boundary: ")
2029 (gnus-add-text-properties start (point) '(invisible t intangible t))
2031 (while (>= (1- (window-width)) (length str))
2032 (setq str (concat str gnus-body-boundary-delimiter)))
2033 (substring str 0 (1- (window-width))))
2035 (gnus-put-text-property start (point) 'gnus-decoration 'header)))))
2037 (defun article-fill-long-lines ()
2038 "Fill lines that are wider than the window width."
2041 (let ((buffer-read-only nil)
2042 (width (window-width (get-buffer-window (current-buffer)))))
2045 (let ((adaptive-fill-mode nil)) ;Why? -sm
2048 (when (>= (current-column) (min fill-column width))
2049 (narrow-to-region (min (1+ (point)) (point-max))
2050 (gnus-point-at-bol))
2051 (let ((goback (point-marker)))
2052 (fill-paragraph nil)
2053 (goto-char (marker-position goback)))
2055 (forward-line 1)))))))
2057 (defun article-capitalize-sentences ()
2058 "Capitalize the first word in each sentence."
2061 (let ((buffer-read-only nil)
2062 (paragraph-start "^[\n\^L]"))
2066 (forward-sentence)))))
2068 (defun article-remove-cr ()
2069 "Remove trailing CRs and then translate remaining CRs into LFs."
2072 (let ((buffer-read-only nil))
2073 (goto-char (point-min))
2074 (while (re-search-forward "\r+$" nil t)
2075 (replace-match "" t t))
2076 (goto-char (point-min))
2077 (while (search-forward "\r" nil t)
2078 (replace-match "\n" t t)))))
2080 (defun article-remove-trailing-blank-lines ()
2081 "Remove all trailing blank lines from the article."
2084 (let ((buffer-read-only nil))
2085 (goto-char (point-max))
2089 (while (and (not (bobp))
2090 (looking-at "^[ \t]*$")
2091 (not (gnus-annotation-in-region-p
2092 (point) (gnus-point-at-eol))))
2097 (defun article-display-face ()
2098 "Display any Face headers in the header."
2100 (gnus-with-article-headers
2101 (let ((face (message-fetch-field "face")))
2103 (let ((png (gnus-convert-face-to-png face))
2106 (setq image (gnus-create-image png 'png t))
2107 (gnus-article-goto-header "from")
2109 (insert "From: [no `from' set]\n")
2111 (gnus-add-wash-type 'face)
2112 (gnus-add-image 'face image)
2113 (gnus-put-image image)))))))
2115 (defun article-display-x-face (&optional force)
2116 "Look for an X-Face header and display it if present."
2117 (interactive (list 'force))
2118 (let ((wash-face-p buffer-read-only)) ;; When type `W f'
2119 (gnus-with-article-headers
2120 ;; Delete the old process, if any.
2121 (when (process-status "article-x-face")
2122 (delete-process "article-x-face"))
2123 (if (memq 'xface gnus-article-wash-types)
2124 ;; We have already displayed X-Faces, so we remove them
2126 (gnus-delete-images 'xface)
2128 (let (x-faces from face)
2130 (when (and wash-face-p
2132 (goto-char (point-min))
2133 (not (re-search-forward
2134 "^X-Face\\(-[0-9]+\\)?:[\t ]*" nil t)))
2135 (gnus-buffer-live-p gnus-original-article-buffer))
2136 ;; If type `W f', use gnus-original-article-buffer,
2137 ;; otherwise use the current buffer because displaying
2138 ;; RFC822 parts calls this function too.
2139 (set-buffer gnus-original-article-buffer))
2141 (mail-narrow-to-head)
2142 (while (gnus-article-goto-header "X-Face")
2143 (push (mail-header-field-value) x-faces))
2144 (setq from (message-fetch-field "from"))))
2145 ;; Sending multiple EOFs to xv doesn't work, so we only do a
2146 ;; single external face.
2147 (when (stringp gnus-article-x-face-command)
2148 (setq x-faces (list (car x-faces))))
2149 (while (and (setq face (pop x-faces))
2150 gnus-article-x-face-command
2152 ;; Check whether this face is censored.
2153 (not gnus-article-x-face-too-ugly)
2154 (and gnus-article-x-face-too-ugly from
2155 (not (string-match gnus-article-x-face-too-ugly
2157 ;; We display the face.
2158 (if (symbolp gnus-article-x-face-command)
2159 ;; The command is a lisp function, so we call it.
2160 (if (gnus-functionp gnus-article-x-face-command)
2161 (funcall gnus-article-x-face-command face)
2162 (error "%s is not a function" gnus-article-x-face-command))
2163 ;; The command is a string, so we interpret the command
2164 ;; as a, well, command, and fork it off.
2165 (let ((process-connection-type nil))
2166 (process-kill-without-query
2168 "article-x-face" nil shell-file-name shell-command-switch
2169 gnus-article-x-face-command))
2172 (process-send-region "article-x-face"
2173 (point-min) (point-max)))
2174 (process-send-eof "article-x-face")))))))))
2176 (defun article-decode-mime-words ()
2177 "Decode all MIME-encoded words in the article."
2180 (set-buffer gnus-article-buffer)
2181 (let ((inhibit-point-motion-hooks t)
2183 (mail-parse-charset gnus-newsgroup-charset)
2184 (mail-parse-ignored-charsets
2185 (save-excursion (set-buffer gnus-summary-buffer)
2186 gnus-newsgroup-ignored-charsets)))
2187 (mail-decode-encoded-word-region (point-min) (point-max)))))
2189 (defun article-decode-charset (&optional prompt)
2190 "Decode charset-encoded text in the article.
2191 If PROMPT (the prefix), prompt for a coding system to use."
2193 (let ((inhibit-point-motion-hooks t) (case-fold-search t)
2195 (mail-parse-charset gnus-newsgroup-charset)
2196 (mail-parse-ignored-charsets
2197 (save-excursion (condition-case nil
2198 (set-buffer gnus-summary-buffer)
2200 gnus-newsgroup-ignored-charsets))
2201 ct cte ctl charset format)
2204 (article-narrow-to-head)
2205 (setq ct (message-fetch-field "Content-Type" t)
2206 cte (message-fetch-field "Content-Transfer-Encoding" t)
2207 ctl (and ct (ignore-errors
2208 (mail-header-parse-content-type ct)))
2211 (mm-read-coding-system "Charset to decode: "))
2213 (mail-content-type-get ctl 'charset)))
2214 format (and ctl (mail-content-type-get ctl 'format)))
2216 (setq cte (mail-header-strip cte)))
2217 (if (and ctl (not (string-match "/" (car ctl))))
2219 (goto-char (point-max)))
2222 (narrow-to-region (point) (point-max))
2223 (when (and (eq mail-parse-charset 'gnus-decoded)
2224 (eq (mm-body-7-or-8) '8bit))
2225 ;; The text code could have been decoded.
2226 (setq charset mail-parse-charset))
2227 (when (and (or (not ctl)
2228 (equal (car ctl) "text/plain"))
2229 (not format)) ;; article with format will decode later.
2231 charset (and cte (intern (downcase
2232 (gnus-strip-whitespace cte))))
2233 (car ctl) prompt))))))
2235 (defun article-decode-encoded-words ()
2236 "Remove encoded-word encoding from headers."
2237 (let (buffer-read-only)
2238 (let ((charset (save-excursion
2239 (set-buffer gnus-summary-buffer)
2240 default-mime-charset)))
2241 (mime-decode-header-in-buffer charset))))
2243 (defun article-decode-group-name ()
2244 "Decode group names in `Newsgroups:'."
2245 (let ((inhibit-point-motion-hooks t)
2247 (method (gnus-find-method-for-group gnus-newsgroup-name)))
2248 (when (and (or gnus-group-name-charset-method-alist
2249 gnus-group-name-charset-group-alist)
2250 (gnus-buffer-live-p gnus-original-article-buffer))
2251 (when (nnmail-fetch-field "Newsgroups")
2252 (nnheader-replace-header "Newsgroups"
2253 (gnus-decode-newsgroups
2254 (with-current-buffer
2255 gnus-original-article-buffer
2256 (nnmail-fetch-field "Newsgroups"))
2257 gnus-newsgroup-name method)))
2258 (when (nnmail-fetch-field "Followup-To")
2259 (nnheader-replace-header "Followup-To"
2260 (gnus-decode-newsgroups
2261 (with-current-buffer
2262 gnus-original-article-buffer
2263 (nnmail-fetch-field "Followup-To"))
2264 gnus-newsgroup-name method))))))
2266 (defun article-de-quoted-unreadable (&optional force read-charset)
2267 "Translate a quoted-printable-encoded article.
2268 If FORCE, decode the article whether it is marked as quoted-printable
2270 If READ-CHARSET, ask for a coding system."
2271 (interactive (list 'force current-prefix-arg))
2273 (let ((buffer-read-only nil) type charset)
2274 (if (gnus-buffer-live-p gnus-original-article-buffer)
2275 (with-current-buffer gnus-original-article-buffer
2277 (gnus-fetch-field "content-transfer-encoding"))
2278 (let* ((ct (gnus-fetch-field "content-type"))
2281 (mail-header-parse-content-type ct)))))
2282 (setq charset (and ctl
2283 (mail-content-type-get ctl 'charset)))
2284 (if (stringp charset)
2285 (setq charset (intern (downcase charset)))))))
2287 (setq charset (mm-read-coding-system "Charset: " charset)))
2289 (setq charset gnus-newsgroup-charset))
2291 (and type (let ((case-fold-search t))
2292 (string-match "quoted-printable" type))))
2294 (quoted-printable-decode-region
2295 (point) (point-max) (mm-charset-to-coding-system charset))))))
2297 (defun article-de-base64-unreadable (&optional force read-charset)
2298 "Translate a base64 article.
2299 If FORCE, decode the article whether it is marked as base64 not.
2300 If READ-CHARSET, ask for a coding system."
2301 (interactive (list 'force current-prefix-arg))
2303 (let ((buffer-read-only nil) type charset)
2304 (if (gnus-buffer-live-p gnus-original-article-buffer)
2305 (with-current-buffer gnus-original-article-buffer
2307 (gnus-fetch-field "content-transfer-encoding"))
2308 (let* ((ct (gnus-fetch-field "content-type"))
2311 (mail-header-parse-content-type ct)))))
2312 (setq charset (and ctl
2313 (mail-content-type-get ctl 'charset)))
2314 (if (stringp charset)
2315 (setq charset (intern (downcase charset)))))))
2317 (setq charset (mm-read-coding-system "Charset: " charset)))
2319 (setq charset gnus-newsgroup-charset))
2321 (and type (let ((case-fold-search t))
2322 (string-match "base64" type))))
2325 (narrow-to-region (point) (point-max))
2326 (base64-decode-region (point-min) (point-max))
2327 (mm-decode-coding-region
2328 (point-min) (point-max) (mm-charset-to-coding-system charset)))))))
2333 (defun article-decode-HZ ()
2334 "Translate a HZ-encoded article."
2338 (let ((buffer-read-only nil))
2339 (rfc1843-decode-region (point-min) (point-max)))))
2341 (defun article-unsplit-urls ()
2342 "Remove the newlines that some other mailers insert into URLs."
2345 (let ((buffer-read-only nil))
2346 (goto-char (point-min))
2347 (while (re-search-forward
2348 "^\\(\\(https?\\|ftp\\)://\\S-+\\) *\n\\(\\S-+\\)" nil t)
2349 (replace-match "\\1\\3" t)))
2350 (when (and gnus-display-mime-function (interactive-p))
2351 (funcall gnus-display-mime-function))))
2354 (defun article-wash-html (&optional read-charset)
2355 "Format an HTML article.
2356 If READ-CHARSET, ask for a coding system."
2359 (let ((buffer-read-only nil)
2361 (when (gnus-buffer-live-p gnus-original-article-buffer)
2362 (with-current-buffer gnus-original-article-buffer
2363 (let* ((ct (gnus-fetch-field "content-type"))
2366 (mail-header-parse-content-type ct)))))
2367 (setq charset (and ctl
2368 (mail-content-type-get ctl 'charset)))
2369 (when (stringp charset)
2370 (setq charset (intern (downcase charset)))))))
2372 (setq charset (mm-read-coding-system "Charset: " charset)))
2374 (setq charset gnus-newsgroup-charset))
2376 (save-window-excursion
2378 (narrow-to-region (point) (point-max))
2379 (let* ((func (or gnus-article-wash-function mm-text-html-renderer))
2380 (entry (assq func mm-text-html-washer-alist)))
2382 (setq func (cdr entry)))
2384 ((gnus-functionp func)
2387 (apply (car func) (cdr func))))))))))
2389 (defun gnus-article-wash-html-with-w3 ()
2390 "Wash the current buffer with w3."
2392 (let ((w3-strict-width (window-width))
2393 (url-standalone-mode t)
2394 (url-gateway-unplugged t)
2395 (w3-honor-stylesheets nil))
2397 (w3-region (point-min) (point-max))
2400 (defun gnus-article-wash-html-with-w3m ()
2401 "Wash the current buffer with emacs-w3m."
2404 (narrow-to-region (point) (point-max))
2405 (let ((w3m-safe-url-regexp (if mm-inline-text-html-with-images
2408 (w3m-display-inline-images mm-inline-text-html-with-images)
2409 w3m-force-redisplay)
2410 (w3m-region (point-min) (point-max)))
2411 (when mm-inline-text-html-with-w3m-keymap
2412 (add-text-properties
2413 (point-min) (point-max)
2414 (nconc (mm-w3m-local-map-property)
2415 '(mm-inline-text-html-with-w3m t))))))
2417 (defun article-hide-list-identifiers ()
2418 "Remove list identifies from the Subject header.
2419 The `gnus-list-identifiers' variable specifies what to do."
2421 (let ((inhibit-point-motion-hooks t)
2422 (regexp (if (consp gnus-list-identifiers)
2423 (mapconcat 'identity gnus-list-identifiers " *\\|")
2424 gnus-list-identifiers))
2429 (article-narrow-to-head)
2430 (goto-char (point-min))
2431 (while (re-search-forward
2432 (concat "^Subject: +\\(R[Ee]: +\\)*\\(" regexp " *\\)")
2434 (delete-region (match-beginning 2) (match-end 0))
2435 (beginning-of-line))
2436 (when (re-search-forward
2437 "^Subject: +\\(\\(R[Ee]: +\\)+\\)R[Ee]: +" nil t)
2438 (delete-region (match-beginning 1) (match-end 1))))))))
2440 (defun article-hide-pem (&optional arg)
2441 "Toggle hiding of any PEM headers and signatures in the current article.
2442 If given a negative prefix, always show; if given a positive prefix,
2444 (interactive (gnus-article-hidden-arg))
2445 (unless (gnus-article-check-hidden-text 'pem arg)
2447 (let (buffer-read-only end)
2448 (goto-char (point-min))
2449 ;; Hide the horrendously ugly "header".
2450 (when (and (search-forward
2451 "\n-----BEGIN PRIVACY-ENHANCED MESSAGE-----\n"
2453 (setq end (1+ (match-beginning 0))))
2454 (gnus-add-wash-type 'pem)
2455 (gnus-article-hide-text-type
2457 (if (search-forward "\n\n" nil t)
2461 ;; Hide the trailer as well
2462 (when (search-forward "\n-----END PRIVACY-ENHANCED MESSAGE-----\n"
2464 (gnus-article-hide-text-type
2465 (match-beginning 0) (match-end 0) 'pem)))))))
2467 (defun article-strip-banner ()
2468 "Strip the banners specified by the `banner' group parameter and by
2469 `gnus-article-address-banner-alist'."
2473 (let ((inhibit-point-motion-hooks t))
2474 (when (gnus-parameter-banner gnus-newsgroup-name)
2475 (article-really-strip-banner
2476 (gnus-parameter-banner gnus-newsgroup-name)))
2477 (when gnus-article-address-banner-alist
2478 (article-really-strip-banner
2479 (let ((from (save-restriction
2481 (article-narrow-to-head)
2482 (mail-fetch-field "from"))))
2485 (caar (mail-header-parse-addresses from))))
2487 (dolist (pair gnus-article-address-banner-alist)
2488 (when (string-match (car pair) from)
2489 (throw 'found (cdr pair)))))))))))))
2491 (defun article-really-strip-banner (banner)
2492 "Strip the banner specified by the argument."
2495 (let ((inhibit-point-motion-hooks t)
2496 (gnus-signature-limit nil)
2500 ((eq banner 'signature)
2501 (when (gnus-article-narrow-to-signature)
2504 (delete-region (point) (point-max))))
2506 (if (setq banner (cdr (assq banner gnus-article-banner-alist)))
2507 (while (re-search-forward banner nil t)
2508 (delete-region (match-beginning 0) (match-end 0)))))
2510 (while (re-search-forward banner nil t)
2511 (delete-region (match-beginning 0) (match-end 0)))))))))
2513 (defun article-babel ()
2514 "Translate article using an online translation service."
2518 (set-buffer gnus-article-buffer)
2519 (when (article-goto-body)
2520 (let* ((buffer-read-only nil)
2523 (orig (buffer-substring start end))
2524 (trans (babel-as-string orig)))
2526 (narrow-to-region start end)
2527 (delete-region start end)
2530 (defun article-hide-signature (&optional arg)
2531 "Hide the signature in the current article.
2532 If given a negative prefix, always show; if given a positive prefix,
2534 (interactive (gnus-article-hidden-arg))
2540 (article-goto-body))
2541 (goto-char (point-min)))
2542 (unless (gnus-article-check-hidden-text 'signature arg)
2543 (let ((buffer-read-only nil)
2545 (while (setq button (text-property-any button (point-max)
2547 'gnus-signature-toggle))
2548 (setq button (text-property-not-all button (point-max)
2550 'gnus-signature-toggle))
2551 (when (and button (not (eobp)))
2552 (gnus-article-hide-text-type
2554 (next-single-property-change (1+ button) 'mime-view-entity
2557 (gnus-set-mode-line 'article))
2559 (defun article-strip-headers-in-body ()
2560 "Strip offensive headers from bodies."
2564 (let ((case-fold-search t))
2565 (when (looking-at "x-no-archive:")
2566 (gnus-delete-line)))))
2568 (defun article-strip-leading-blank-lines ()
2569 "Remove all blank lines from the beginning of the article."
2572 (let ((inhibit-point-motion-hooks t)
2574 (when (article-goto-body)
2575 (while (and (not (eobp))
2576 (looking-at "[ \t]*$"))
2577 (gnus-delete-line))))))
2579 (defun article-narrow-to-head ()
2580 "Narrow the buffer to the head of the message.
2581 Point is left at the beginning of the narrowed-to region."
2583 (goto-char (point-min))
2584 (if (search-forward "\n\n" nil 1)
2587 (goto-char (point-min)))
2589 (defun article-goto-body ()
2590 "Place point at the start of the body."
2591 (goto-char (point-min))
2593 ;; This variable is only bound when dealing with separate
2595 (article-goto-body-goes-to-point-min-p
2597 ((search-forward "\n\n" nil t)
2600 (goto-char (point-max))
2603 (defun article-strip-multiple-blank-lines ()
2604 "Replace consecutive blank lines with one empty line."
2607 (let ((inhibit-point-motion-hooks t)
2609 ;; First make all blank lines empty.
2611 (while (re-search-forward "^[ \t]+$" nil t)
2612 (unless (gnus-annotation-in-region-p
2613 (match-beginning 0) (match-end 0))
2614 (replace-match "" nil t)))
2615 ;; Then replace multiple empty lines with a single empty line.
2617 (while (re-search-forward "\n\n\\(\n+\\)" nil t)
2618 (unless (gnus-annotation-in-region-p
2619 (match-beginning 0) (match-end 0))
2620 (delete-region (match-beginning 1) (match-end 1)))))))
2622 (defun article-strip-leading-space ()
2623 "Remove all white space from the beginning of the lines in the article."
2626 (let ((inhibit-point-motion-hooks t)
2629 (while (re-search-forward "^[ \t]+" nil t)
2630 (replace-match "" t t)))))
2632 (defun article-strip-trailing-space ()
2633 "Remove all white space from the end of the lines in the article."
2636 (let ((inhibit-point-motion-hooks t)
2639 (while (re-search-forward "[ \t]+$" nil t)
2640 (replace-match "" t t)))))
2642 (defun article-strip-blank-lines ()
2643 "Strip leading, trailing and multiple blank lines."
2645 (article-strip-leading-blank-lines)
2646 (article-remove-trailing-blank-lines)
2647 (article-strip-multiple-blank-lines))
2649 (defun article-strip-all-blank-lines ()
2650 "Strip all blank lines."
2653 (let ((inhibit-point-motion-hooks t)
2656 (while (re-search-forward "^[ \t]*\n" nil t)
2657 (replace-match "" t t)))))
2659 (defun gnus-article-narrow-to-signature ()
2660 "Narrow to the signature; return t if a signature is found, else nil."
2661 (let ((inhibit-point-motion-hooks t))
2662 (when (gnus-article-search-signature)
2664 ;; Check whether we have some limits to what we consider
2665 ;; to be a signature.
2666 (let ((limits (if (listp gnus-signature-limit) gnus-signature-limit
2667 (list gnus-signature-limit)))
2669 (while (setq limit (pop limits))
2670 (if (or (and (integerp limit)
2671 (< (- (point-max) (point)) limit))
2673 (< (count-lines (point) (point-max)) limit))
2674 (and (gnus-functionp limit)
2676 (and (stringp limit)
2677 (not (re-search-forward limit nil t))))
2678 () ; This limit did not succeed.
2682 (narrow-to-region (point) (point-max))
2685 (defun gnus-article-search-signature ()
2686 "Search the current buffer for the signature separator.
2687 Put point at the beginning of the signature separator."
2688 (let ((cur (point)))
2689 (goto-char (point-max))
2690 (if (if (stringp gnus-signature-separator)
2691 (re-search-backward gnus-signature-separator nil t)
2692 (let ((seps gnus-signature-separator))
2694 (not (re-search-backward (car seps) nil t)))
2701 (defun gnus-article-hidden-arg ()
2702 "Return the current prefix arg as a number, or 0 if no prefix."
2703 (list (if current-prefix-arg
2704 (prefix-numeric-value current-prefix-arg)
2707 (defun gnus-article-check-hidden-text (type arg)
2708 "Return nil if hiding is necessary.
2709 Arg can be nil or a number. nil and positive means hide, negative
2710 means show, 0 means toggle."
2713 (let ((hide (gnus-article-hidden-text-p type)))
2719 (gnus-article-show-hidden-text type)
2722 (if (eq hide 'hidden)
2724 (gnus-article-show-hidden-text type)
2728 (defun gnus-article-hidden-text-p (type)
2729 "Say whether the current buffer contains hidden text of type TYPE."
2730 (let ((pos (text-property-any (point-min) (point-max) 'article-type type)))
2732 (not (get-text-property pos 'invisible))
2733 (not (get-text-property pos 'dummy-invisible)))
2735 (text-property-any (1+ pos) (point-max) 'article-type type)))
2740 (defun gnus-article-show-hidden-text (type &optional dummy)
2741 "Show all hidden text of type TYPE.
2742 Originally it is hide instead of DUMMY."
2743 (let ((buffer-read-only nil)
2744 (inhibit-point-motion-hooks t))
2745 (gnus-remove-text-properties-when
2747 (point-min) (point-max)
2748 (cons 'article-type (cons type
2749 gnus-hidden-properties)))
2750 (gnus-delete-wash-type type)))
2752 (defconst article-time-units
2753 `((year . ,(* 365.25 24 60 60))
2754 (week . ,(* 7 24 60 60))
2755 (day . ,(* 24 60 60))
2759 "Mapping from time units to seconds.")
2761 (defun gnus-article-forward-header ()
2762 "Move point to the start of the next header.
2763 If the current header is a continuation header, this can be several
2768 (if (looking-at "[ \t]+[^ \t]")
2772 (defun article-date-ut (&optional type highlight header)
2773 "Convert DATE date to universal time in the current article.
2774 If TYPE is `local', convert to local time; if it is `lapsed', output
2775 how much time has lapsed since DATE. For `lapsed', the value of
2776 `gnus-article-date-lapsed-new-header' says whether the \"X-Sent:\" header
2777 should replace the \"Date:\" one, or should be added below it."
2778 (interactive (list 'ut t))
2779 (let* ((header (or header
2780 (and (eq 1 (point-min))
2781 (mail-header-date (save-excursion
2782 (set-buffer gnus-summary-buffer)
2783 gnus-current-headers)))
2784 (message-fetch-field "date")
2786 (date (if (vectorp header) (mail-header-date header)
2788 (inhibit-point-motion-hooks t)
2789 bface eface date-pos)
2790 (when (and date (not (string= date "")))
2793 (article-narrow-to-head)
2794 (when (or (and (eq type 'lapsed)
2795 gnus-article-date-lapsed-new-header
2796 ;; Attempt to get the face of X-Sent first.
2797 (re-search-forward "^X-Sent:[ \t]" nil t))
2798 (re-search-forward "^Date:[ \t]" nil t)
2799 ;; If Date is missing, try again for X-Sent.
2800 (re-search-forward "^X-Sent:[ \t]" nil t))
2801 (setq bface (get-text-property (gnus-point-at-bol) 'face)
2802 date (or (get-text-property (gnus-point-at-bol)
2805 eface (get-text-property (1- (gnus-point-at-eol))
2807 (let ((buffer-read-only nil))
2808 ;; Delete any old X-Sent headers.
2809 (when (setq date-pos
2810 (text-property-any (point-min) (point-max)
2811 'article-date-lapsed t))
2812 (goto-char (setq date-pos (set-marker (make-marker) date-pos)))
2813 (delete-region (match-beginning 0)
2814 (progn (forward-line 1) (point))))
2815 (goto-char (point-min))
2816 ;; Delete any old Date headers.
2817 (while (re-search-forward "^Date:[ \t]" nil t)
2819 (setq date-pos (match-beginning 0)))
2820 (unless (and (eq type 'lapsed)
2821 gnus-article-date-lapsed-new-header)
2822 (delete-region (match-beginning 0)
2823 (progn (message-next-header) (point)))))
2826 (goto-char date-pos)
2828 ;; Possibly, Date has been deleted.
2830 (when (and (eq type 'lapsed)
2831 gnus-article-date-lapsed-new-header
2832 (looking-at "Date:"))
2834 (goto-char (point-min)))
2835 (insert (article-make-date-line date type))
2836 (when (eq type 'lapsed)
2837 (put-text-property (gnus-point-at-bol) (point)
2838 'article-date-lapsed t))
2842 (when (looking-at "\\([^:]+\\): *\\(.*\\)$")
2843 (put-text-property (match-beginning 1) (1+ (match-end 1))
2844 'original-date date)
2845 (put-text-property (match-beginning 1) (1+ (match-end 1))
2847 (put-text-property (match-beginning 2) (match-end 2)
2850 (defun article-make-date-line (date type)
2851 "Return a DATE line of TYPE."
2852 (unless (memq type '(local ut original user iso8601 lapsed english))
2853 (error "Unknown conversion type: %s" type))
2855 (let ((time (date-to-time date)))
2857 ;; Convert to the local timezone.
2859 (let ((tz (car (current-time-zone time))))
2860 (format "Date: %s %s%02d%02d" (current-time-string time)
2861 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2862 (/ (% (abs tz) 3600) 60))))
2863 ;; Convert to Universal Time.
2866 (current-time-string
2867 (let* ((e (parse-time-string date))
2868 (tm (apply 'encode-time e))
2870 (ls (- (cadr tm) (car (current-time-zone time)))))
2871 (cond ((< ls 0) (list (1- ms) (+ ls 65536)))
2872 ((> ls 65535) (list (1+ ms) (- ls 65536)))
2875 ;; Get the original date from the article.
2876 ((eq type 'original)
2877 (concat "Date: " (if (string-match "\n+$" date)
2878 (substring date 0 (match-beginning 0))
2880 ;; Let the user define the format.
2882 (let ((format (or (condition-case nil
2883 (with-current-buffer gnus-summary-buffer
2884 gnus-article-time-format)
2886 gnus-article-time-format)))
2887 (if (gnus-functionp format)
2888 (funcall format time)
2889 (concat "Date: " (format-time-string format time)))))
2892 (let ((tz (car (current-time-zone time))))
2895 (format-time-string "%Y%m%dT%H%M%S" time)
2896 (format "%s%02d%02d"
2897 (if (> tz 0) "+" "-") (/ (abs tz) 3600)
2898 (/ (% (abs tz) 3600) 60)))))
2899 ;; Do an X-Sent lapsed format.
2901 ;; If the date is seriously mangled, the timezone functions are
2902 ;; liable to bug out, so we ignore all errors.
2903 (let* ((now (current-time))
2904 (real-time (subtract-time now time))
2905 (real-sec (and real-time
2906 (+ (* (float (car real-time)) 65536)
2908 (sec (and real-time (abs real-sec)))
2918 ;; This is a bit convoluted, but basically we go
2919 ;; through the time units for years, weeks, etc,
2920 ;; and divide things to see whether that results
2921 ;; in positive answers.
2924 (if (zerop (setq num (ffloor (/ sec (cdr unit)))))
2925 ;; The (remaining) seconds are too few to
2926 ;; be divided into this time unit.
2928 ;; It's big enough, so we output it.
2929 (setq sec (- sec (* num (cdr unit))))
2931 (concat (if prev ", " "") (int-to-string
2933 " " (symbol-name (car unit))
2934 (if (> num 1) "s" ""))
2936 article-time-units "")
2937 ;; If dates are odd, then it might appear like the
2938 ;; article was sent in the future.
2941 " in the future"))))))
2942 ;; Display the date in proper English
2944 (let ((dtime (decode-time time)))
2947 (number-to-string (nth 3 dtime))
2948 (let ((digit (% (nth 3 dtime) 10)))
2950 ((memq (nth 3 dtime) '(11 12 13)) "th")
2956 (nth (1- (nth 4 dtime)) gnus-english-month-names)
2958 (number-to-string (nth 5 dtime))
2960 (format "%02d" (nth 2 dtime))
2962 (format "%02d" (nth 1 dtime)))))))
2964 (format "Date: %s (from T-gnus)" date))))
2966 (defun article-date-local (&optional highlight)
2967 "Convert the current article date to the local timezone."
2968 (interactive (list t))
2969 (article-date-ut 'local highlight))
2971 (defun article-date-english (&optional highlight)
2972 "Convert the current article date to something that is proper English."
2973 (interactive (list t))
2974 (article-date-ut 'english highlight))
2976 (defun article-date-original (&optional highlight)
2977 "Convert the current article date to what it was originally.
2978 This is only useful if you have used some other date conversion
2979 function and want to see what the date was before converting."
2980 (interactive (list t))
2981 (article-date-ut 'original highlight))
2983 (defun article-date-lapsed (&optional highlight)
2984 "Convert the current article date to time lapsed since it was sent."
2985 (interactive (list t))
2986 (article-date-ut 'lapsed highlight))
2988 (defun article-update-date-lapsed ()
2989 "Function to be run from a timer to update the lapsed time line."
2990 (let (deactivate-mark)
2995 (set-buffer (window-buffer w))
2996 (when (eq major-mode 'gnus-article-mode)
2997 (goto-char (point-min))
2998 (when (re-search-forward "^X-Sent:" nil t)
2999 (article-date-lapsed t))))
3002 (defun gnus-start-date-timer (&optional n)
3003 "Start a timer to update the X-Sent header in the article buffers.
3004 The numerical prefix says how frequently (in seconds) the function
3009 (gnus-stop-date-timer)
3010 (setq article-lapsed-timer
3011 (nnheader-run-at-time 1 n 'article-update-date-lapsed)))
3013 (defun gnus-stop-date-timer ()
3014 "Stop the X-Sent timer."
3016 (when article-lapsed-timer
3017 (nnheader-cancel-timer article-lapsed-timer)
3018 (setq article-lapsed-timer nil)))
3020 (defun article-date-user (&optional highlight)
3021 "Convert the current article date to the user-defined format.
3022 This format is defined by the `gnus-article-time-format' variable."
3023 (interactive (list t))
3024 (article-date-ut 'user highlight))
3026 (defun article-date-iso8601 (&optional highlight)
3027 "Convert the current article date to ISO8601."
3028 (interactive (list t))
3029 (article-date-ut 'iso8601 highlight))
3031 ;; (defun article-show-all ()
3032 ;; "Show all hidden text in the article buffer."
3036 ;; (let ((buffer-read-only nil))
3037 ;; (gnus-article-unhide-text (point-min) (point-max))
3038 ;; (gnus-remove-text-with-property 'gnus-prev)
3039 ;; (gnus-remove-text-with-property 'gnus-next))))
3041 (defun article-show-all-headers ()
3042 "Show all hidden headers in the article buffer."
3047 (article-narrow-to-head)
3048 (let ((buffer-read-only nil))
3049 (gnus-article-unhide-text (point-min) (point-max))))))
3051 (defun article-remove-leading-whitespace ()
3052 "Remove excessive whitespace from all headers."
3056 (let ((buffer-read-only nil))
3057 (article-narrow-to-head)
3058 (goto-char (point-min))
3059 (while (re-search-forward "^[^ :]+: \\([ \t]+\\)" nil t)
3060 (delete-region (match-beginning 1) (match-end 1)))))))
3062 (defun article-emphasize (&optional arg)
3063 "Emphasize text according to `gnus-emphasis-alist'."
3064 (interactive (gnus-article-hidden-arg))
3065 (unless (gnus-article-check-hidden-text 'emphasis arg)
3069 (with-current-buffer gnus-summary-buffer
3070 gnus-article-emphasis-alist)
3072 gnus-emphasis-alist))
3073 (buffer-read-only nil)
3074 (props (append '(article-type emphasis)
3075 gnus-hidden-properties))
3076 regexp elem beg invisible visible face)
3079 (while (setq elem (pop alist))
3081 (setq regexp (car elem)
3082 invisible (nth 1 elem)
3083 visible (nth 2 elem)
3085 (while (re-search-forward regexp nil t)
3086 (when (and (match-beginning visible) (match-beginning invisible))
3087 (gnus-article-hide-text
3088 (match-beginning invisible) (match-end invisible) props)
3089 (gnus-article-unhide-text-type
3090 (match-beginning visible) (match-end visible) 'emphasis)
3091 (gnus-put-overlay-excluding-newlines
3092 (match-beginning visible) (match-end visible) 'face face)
3093 (gnus-add-wash-type 'emphasis)
3094 (goto-char (match-end invisible)))))))))
3096 (defun gnus-article-setup-highlight-words (&optional highlight-words)
3097 "Setup newsgroup emphasis alist."
3098 (unless gnus-article-emphasis-alist
3099 (let ((name (and gnus-newsgroup-name
3100 (gnus-group-real-name gnus-newsgroup-name))))
3101 (make-local-variable 'gnus-article-emphasis-alist)
3102 (setq gnus-article-emphasis-alist
3104 (let ((alist gnus-group-highlight-words-alist) elem highlight)
3105 (while (setq elem (pop alist))
3106 (when (and name (string-match (car elem) name))
3108 highlight (copy-sequence (cdr elem)))))
3110 (copy-sequence highlight-words)
3111 (if gnus-newsgroup-name
3112 (copy-sequence (gnus-group-find-parameter
3113 gnus-newsgroup-name 'highlight-words t)))
3114 gnus-emphasis-alist)))))
3117 (defvar gnus-summary-article-menu)
3118 (defvar gnus-summary-post-menu))
3120 ;;; Saving functions.
3122 (defun gnus-article-save (save-buffer file &optional num)
3123 "Save the currently selected article."
3124 (unless gnus-save-all-headers
3125 ;; Remove headers according to `gnus-saved-headers'.
3126 (let ((gnus-visible-headers
3127 (or gnus-saved-headers gnus-visible-headers))
3128 (gnus-article-buffer save-buffer))
3130 (set-buffer save-buffer)
3131 (article-hide-headers 1 t))))
3132 (save-window-excursion
3133 (if (not gnus-default-article-saver)
3134 (error "No default saver is defined")
3135 ;; !!! Magic! The saving functions all save
3136 ;; `gnus-save-article-buffer' (or so they think), but we
3137 ;; bind that variable to our save-buffer.
3138 (set-buffer gnus-article-buffer)
3139 (let* ((gnus-save-article-buffer save-buffer)
3142 ((not gnus-prompt-before-saving) 'default)
3143 ((eq gnus-prompt-before-saving 'always) nil)
3145 (gnus-number-of-articles-to-be-saved
3146 (when (eq gnus-prompt-before-saving t)
3148 (set-buffer gnus-article-current-summary)
3149 (funcall gnus-default-article-saver filename)))))
3151 (defun gnus-read-save-file-name (prompt &optional filename
3152 function group headers variable)
3154 (funcall function group headers (symbol-value variable)))
3159 ((eq filename 'default)
3165 (let* ((split-name (gnus-get-split-value gnus-split-methods))
3168 (if (and gnus-number-of-articles-to-be-saved
3169 (> gnus-number-of-articles-to-be-saved 1))
3170 (format "these %d articles"
3171 gnus-number-of-articles-to-be-saved)
3174 ;; Let the split methods have their say.
3176 ;; No split name was found.
3179 (concat prompt " (default "
3180 (file-name-nondirectory default-name) ") ")
3181 (file-name-directory default-name)
3183 ;; A single group name is returned.
3184 ((stringp split-name)
3186 (funcall function split-name headers
3187 (symbol-value variable)))
3189 (concat prompt " (default "
3190 (file-name-nondirectory default-name) ") ")
3191 (file-name-directory default-name)
3193 ;; A single split name was found
3194 ((= 1 (length split-name))
3195 (let* ((name (expand-file-name
3197 gnus-article-save-directory))
3198 (dir (cond ((file-directory-p name)
3199 (file-name-as-directory name))
3200 ((file-exists-p name) name)
3201 (t gnus-article-save-directory))))
3203 (concat prompt " (default " name ") ")
3205 ;; A list of splits was found.
3207 (setq split-name (nreverse split-name))
3209 (let ((file-name-history
3210 (nconc split-name file-name-history)))
3214 (concat prompt " (`M-p' for defaults) ")
3215 gnus-article-save-directory
3217 gnus-article-save-directory)))
3218 (car (push result file-name-history)))))))
3219 ;; Create the directory.
3220 (gnus-make-directory (file-name-directory file))
3221 ;; If we have read a directory, we append the default file name.
3222 (when (file-directory-p file)
3223 (setq file (expand-file-name (file-name-nondirectory
3225 (file-name-as-directory file))))
3226 ;; Possibly translate some characters.
3227 (nnheader-translate-file-chars file))))))
3228 (gnus-make-directory (file-name-directory result))
3229 (set variable result)))
3231 (defun gnus-article-archive-name (group)
3232 "Return the first instance of an \"Archive-name\" in the current buffer."
3233 (let ((case-fold-search t))
3234 (when (re-search-forward "archive-name: *\\([^ \n\t]+\\)[ \t]*$" nil t)
3235 (nnheader-concat gnus-article-save-directory
3236 (match-string 1)))))
3238 (defun gnus-article-nndoc-name (group)
3239 "If GROUP is an nndoc group, return the name of the parent group."
3240 (when (eq (car (gnus-find-method-for-group group)) 'nndoc)
3241 (gnus-group-get-parameter group 'save-article-group)))
3243 (defun gnus-summary-save-in-rmail (&optional filename)
3244 "Append this article to Rmail file.
3245 Optional argument FILENAME specifies file name.
3246 Directory to save to is default to `gnus-article-save-directory'."
3247 (setq filename (gnus-read-save-file-name
3248 "Save %s in rmail file:" filename
3249 gnus-rmail-save-name gnus-newsgroup-name
3250 gnus-current-headers 'gnus-newsgroup-last-rmail))
3251 (gnus-eval-in-buffer-window gnus-save-article-buffer
3255 (gnus-output-to-rmail filename))))
3258 (defun gnus-summary-save-in-mail (&optional filename)
3259 "Append this article to Unix mail file.
3260 Optional argument FILENAME specifies file name.
3261 Directory to save to is default to `gnus-article-save-directory'."
3262 (setq filename (gnus-read-save-file-name
3263 "Save %s in Unix mail file:" filename
3264 gnus-mail-save-name gnus-newsgroup-name
3265 gnus-current-headers 'gnus-newsgroup-last-mail))
3266 (gnus-eval-in-buffer-window gnus-save-article-buffer
3270 (if (and (file-readable-p filename)
3271 (file-regular-p filename)
3272 (mail-file-babyl-p filename))
3273 (rmail-output-to-rmail-file filename t)
3274 (gnus-output-to-mail filename)))))
3277 (defun gnus-summary-save-in-file (&optional filename overwrite)
3278 "Append this article to file.
3279 Optional argument FILENAME specifies file name.
3280 Directory to save to is default to `gnus-article-save-directory'."
3281 (setq filename (gnus-read-save-file-name
3282 "Save %s in file:" filename
3283 gnus-file-save-name gnus-newsgroup-name
3284 gnus-current-headers 'gnus-newsgroup-last-file))
3285 (gnus-eval-in-buffer-window gnus-save-article-buffer
3289 (when (and overwrite
3290 (file-exists-p filename))
3291 (delete-file filename))
3292 (gnus-output-to-file filename))))
3295 (defun gnus-summary-write-to-file (&optional filename)
3296 "Write this article to a file, overwriting it if the file exists.
3297 Optional argument FILENAME specifies file name.
3298 The directory to save in defaults to `gnus-article-save-directory'."
3299 (gnus-summary-save-in-file nil t))
3301 (defun gnus-summary-save-body-in-file (&optional filename)
3302 "Append this article body to a file.
3303 Optional argument FILENAME specifies file name.
3304 The directory to save in defaults to `gnus-article-save-directory'."
3305 (setq filename (gnus-read-save-file-name
3306 "Save %s body in file:" filename
3307 gnus-file-save-name gnus-newsgroup-name
3308 gnus-current-headers 'gnus-newsgroup-last-file))
3309 (gnus-eval-in-buffer-window gnus-save-article-buffer
3313 (when (article-goto-body)
3314 (narrow-to-region (point) (point-max)))
3315 (gnus-output-to-file filename))))
3318 (defun gnus-summary-save-in-pipe (&optional command)
3319 "Pipe this article to subprocess."
3321 (cond ((and (eq command 'default)
3322 gnus-last-shell-command)
3323 gnus-last-shell-command)
3328 "Shell command on %s: "
3329 (if (and gnus-number-of-articles-to-be-saved
3330 (> gnus-number-of-articles-to-be-saved 1))
3331 (format "these %d articles"
3332 gnus-number-of-articles-to-be-saved)
3334 gnus-last-shell-command))))
3335 (when (string-equal command "")
3336 (if gnus-last-shell-command
3337 (setq command gnus-last-shell-command)
3338 (error "A command is required")))
3339 (gnus-eval-in-buffer-window gnus-article-buffer
3342 (shell-command-on-region (point-min) (point-max) command nil)))
3343 (setq gnus-last-shell-command command))
3345 (defun gnus-summary-pipe-to-muttprint (&optional command)
3346 "Pipe this article to muttprint."
3347 (setq command (read-string
3348 "Print using command: " gnus-summary-muttprint-program
3349 nil gnus-summary-muttprint-program))
3350 (gnus-summary-save-in-pipe command))
3352 ;;; Article file names when saving.
3354 (defun gnus-capitalize-newsgroup (newsgroup)
3355 "Capitalize NEWSGROUP name."
3356 (when (not (zerop (length newsgroup)))
3357 (concat (char-to-string (upcase (aref newsgroup 0)))
3358 (substring newsgroup 1))))
3360 (defun gnus-Numeric-save-name (newsgroup headers &optional last-file)
3361 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3362 If variable `gnus-use-long-file-name' is non-nil, it is ~/News/News.group/num.
3363 Otherwise, it is like ~/News/news/group/num."
3366 (concat (if (gnus-use-long-file-name 'not-save)
3367 (gnus-capitalize-newsgroup newsgroup)
3368 (gnus-newsgroup-directory-form newsgroup))
3369 "/" (int-to-string (mail-header-number headers)))
3370 gnus-article-save-directory)))
3372 (string-equal (file-name-directory default)
3373 (file-name-directory last-file))
3374 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3376 (or last-file default))))
3378 (defun gnus-numeric-save-name (newsgroup headers &optional last-file)
3379 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3380 If variable `gnus-use-long-file-name' is non-nil, it is
3381 ~/News/news.group/num. Otherwise, it is like ~/News/news/group/num."
3384 (concat (if (gnus-use-long-file-name 'not-save)
3386 (gnus-newsgroup-directory-form newsgroup))
3387 "/" (int-to-string (mail-header-number headers)))
3388 gnus-article-save-directory)))
3390 (string-equal (file-name-directory default)
3391 (file-name-directory last-file))
3392 (string-match "^[0-9]+$" (file-name-nondirectory last-file)))
3394 (or last-file default))))
3396 (defun gnus-plain-save-name (newsgroup headers &optional last-file)
3397 "Generate file name from NEWSGROUP, HEADERS, and optional LAST-FILE.
3398 If variable `gnus-use-long-file-name' is non-nil, it is
3399 ~/News/news.group. Otherwise, it is like ~/News/news/group/news."
3402 (if (gnus-use-long-file-name 'not-save)
3405 (expand-file-name "news" (gnus-newsgroup-directory-form newsgroup))
3407 gnus-article-save-directory)))
3409 (defun gnus-sender-save-name (newsgroup headers &optional last-file)
3410 "Generate file name from sender."
3411 (let ((from (mail-header-from headers)))
3413 (if (and from (string-match "\\([^ <]+\\)@" from))
3414 (match-string 1 from)
3416 gnus-article-save-directory)))
3418 (defun article-verify-x-pgp-sig ()
3421 (if (gnus-buffer-live-p gnus-original-article-buffer)
3422 (let ((sig (with-current-buffer gnus-original-article-buffer
3423 (gnus-fetch-field "X-PGP-Sig")))
3427 (mml2015-clear-verify-function))
3429 (insert-buffer-substring gnus-original-article-buffer)
3430 (setq items (split-string sig))
3431 (message-narrow-to-head)
3432 (let ((inhibit-point-motion-hooks t)
3433 (case-fold-search t))
3434 ;; Don't verify multiple headers.
3435 (setq headers (mapconcat (lambda (header)
3437 (mail-fetch-field header) "\n"))
3438 (split-string (nth 1 items) ",") "")))
3439 (delete-region (point-min) (point-max))
3440 (insert "-----BEGIN PGP SIGNED MESSAGE-----\n\n")
3441 (insert "X-Signed-Headers: " (nth 1 items) "\n")
3446 (if (looking-at "^-")
3449 (insert "\n-----BEGIN PGP SIGNATURE-----\n")
3450 (insert "Version: " (car items) "\n\n")
3451 (insert (mapconcat 'identity (cddr items) "\n"))
3452 (insert "\n-----END PGP SIGNATURE-----\n")
3453 (let ((mm-security-handle (list (format "multipart/signed"))))
3454 (mml2015-clean-buffer)
3455 (let ((coding-system-for-write (or gnus-newsgroup-charset
3457 (funcall (mml2015-clear-verify-function)))
3459 (or (mm-handle-multipart-ctl-parameter
3460 mm-security-handle 'gnus-details)
3461 (mm-handle-multipart-ctl-parameter
3462 mm-security-handle 'gnus-info)))))
3464 (let (buffer-read-only bface eface)
3466 (message-narrow-to-head)
3467 (goto-char (point-max))
3469 (setq bface (get-text-property (gnus-point-at-bol) 'face)
3470 eface (get-text-property (1- (gnus-point-at-eol)) 'face))
3471 (message-remove-header "X-Gnus-PGP-Verify")
3472 (if (re-search-forward "^X-PGP-Sig:" nil t)
3474 (goto-char (point-max)))
3475 (narrow-to-region (point) (point))
3476 (insert "X-Gnus-PGP-Verify: " info "\n")
3477 (goto-char (point-min))
3480 (if (not (looking-at "^[ \t]"))
3484 (goto-char (point-min))
3485 (when (looking-at "\\([^:]+\\): *")
3486 (put-text-property (match-beginning 1) (1+ (match-end 1))
3488 (put-text-property (match-end 0) (point-max)
3489 'face eface)))))))))
3491 (defun article-verify-cancel-lock ()
3492 "Verify Cancel-Lock header."
3494 (if (gnus-buffer-live-p gnus-original-article-buffer)
3495 (canlock-verify gnus-original-article-buffer)))
3497 (defun article-monafy ()
3498 "Display body part with mona font."
3500 (unless (if (featurep 'xemacs)
3501 (find-face 'gnus-mona-face)
3502 (facep 'gnus-mona-face))
3503 (require 'navi2ch-mona)
3504 (set-face-font (make-face 'gnus-mona-face) navi2ch-mona-font))
3506 (let ((buffer-read-only nil))
3509 (gnus-make-overlay (point) (point-max))
3510 'face 'gnus-mona-face))))
3517 (setq afunc (car func)
3520 gfunc (intern (format "gnus-%s" func))))
3522 (when (fboundp afunc)
3523 `(lambda (&optional interactive &rest args)
3524 ,(documentation afunc t)
3525 (interactive (list t))
3527 (set-buffer gnus-article-buffer)
3529 (call-interactively ',afunc)
3530 (apply ',afunc args))))))))
3531 '(article-hide-headers
3532 article-verify-x-pgp-sig
3533 article-verify-cancel-lock
3535 article-hide-boring-headers
3536 article-treat-overstrike
3537 article-fill-long-lines
3538 article-capitalize-sentences
3540 article-remove-leading-whitespace
3541 article-display-x-face
3542 article-display-face
3543 article-de-quoted-unreadable
3544 article-de-base64-unreadable
3547 article-unsplit-urls
3548 article-hide-list-identifiers
3549 article-strip-banner
3552 article-hide-signature
3553 article-strip-headers-in-body
3554 article-remove-trailing-blank-lines
3555 article-strip-leading-blank-lines
3556 article-strip-multiple-blank-lines
3557 article-strip-leading-space
3558 article-strip-trailing-space
3559 article-strip-blank-lines
3560 article-strip-all-blank-lines
3562 article-date-english
3563 article-date-iso8601
3564 article-date-original
3566 article-decode-mime-words
3567 article-decode-charset
3568 article-decode-encoded-words
3572 article-treat-dumbquotes
3573 article-normalize-headers
3574 (article-show-all-headers . gnus-article-show-all-headers)
3575 ;; (article-show-all . gnus-article-show-all)
3579 ;;; Gnus article mode
3582 (put 'gnus-article-mode 'mode-class 'special)
3584 (gnus-define-keys gnus-article-mode-map
3585 " " gnus-article-goto-next-page
3586 "\177" gnus-article-goto-prev-page
3587 [delete] gnus-article-goto-prev-page
3588 [backspace] gnus-article-goto-prev-page
3589 "\C-c^" gnus-article-refer-article
3590 "h" gnus-article-show-summary
3591 "s" gnus-article-show-summary
3592 "\C-c\C-m" gnus-article-mail
3593 "?" gnus-article-describe-briefly
3594 "e" gnus-summary-edit-article
3595 "<" beginning-of-buffer
3597 "\C-c\C-i" gnus-info-find-node
3599 "R" gnus-article-reply-with-original
3600 "F" gnus-article-followup-with-original
3601 "\C-hk" gnus-article-describe-key
3602 "\C-hc" gnus-article-describe-key-briefly
3604 "\C-d" gnus-article-read-summary-keys
3605 "\M-*" gnus-article-read-summary-keys
3606 "\M-#" gnus-article-read-summary-keys
3607 "\M-^" gnus-article-read-summary-keys
3608 "\M-g" gnus-article-read-summary-keys)
3610 ;; Define almost undefined keys to `gnus-article-read-summary-keys'.
3614 (push (char-to-string key) keys)
3616 (dolist (elem (accessible-keymaps gnus-summary-mode-map))
3617 (setq key (car elem))
3618 (when (and (> (length key) 0)
3619 (not (eq 'menu-bar (aref key 0)))
3620 (symbolp (lookup-key gnus-summary-mode-map key)))
3623 (unless (lookup-key gnus-article-mode-map key)
3624 (define-key gnus-article-mode-map key 'gnus-article-read-summary-keys))))
3626 (defun gnus-article-make-menu-bar ()
3627 (unless (boundp 'gnus-article-commands-menu)
3628 (gnus-summary-make-menu-bar))
3629 (gnus-turn-off-edit-menu 'article)
3630 (unless (boundp 'gnus-article-article-menu)
3632 gnus-article-article-menu gnus-article-mode-map ""
3634 ["Scroll forwards" gnus-article-goto-next-page t]
3635 ["Scroll backwards" gnus-article-goto-prev-page t]
3636 ["Show summary" gnus-article-show-summary t]
3637 ["Fetch Message-ID at point" gnus-article-refer-article t]
3638 ["Mail to address at point" gnus-article-mail t]
3639 ["Send a bug report" gnus-bug t]))
3642 gnus-article-treatment-menu gnus-article-mode-map ""
3643 ;; Fixme: this should use :active (and maybe :visible).
3645 ["Hide headers" gnus-article-hide-headers t]
3646 ["Hide signature" gnus-article-hide-signature t]
3647 ["Hide citation" gnus-article-hide-citation t]
3648 ["Treat overstrike" gnus-article-treat-overstrike t]
3649 ["Remove carriage return" gnus-article-remove-cr t]
3650 ["Remove leading whitespace" gnus-article-remove-leading-whitespace t]
3651 ["Treat html" gnus-article-wash-html t]
3652 ["Remove newlines from within URLs" gnus-article-unsplit-urls t]
3653 ["Decode HZ" gnus-article-decode-HZ t]))
3655 ;; Note "Commands" menu is defined in gnus-sum.el for consistency
3657 ;; Note "Post" menu is defined in gnus-sum.el for consistency
3659 (gnus-run-hooks 'gnus-article-menu-hook)))
3661 (defun gnus-article-mode ()
3662 "Major mode for displaying an article.
3664 All normal editing commands are switched off.
3666 The following commands are available in addition to all summary mode
3668 \\<gnus-article-mode-map>
3669 \\[gnus-article-next-page]\t Scroll the article one page forwards
3670 \\[gnus-article-prev-page]\t Scroll the article one page backwards
3671 \\[gnus-article-refer-article]\t Go to the article referred to by an article id near point
3672 \\[gnus-article-show-summary]\t Display the summary buffer
3673 \\[gnus-article-mail]\t Send a reply to the address near point
3674 \\[gnus-article-describe-briefly]\t Describe the current mode briefly
3675 \\[gnus-info-find-node]\t Go to the Gnus info node"
3677 (gnus-simplify-mode-line)
3678 (setq mode-name "Article")
3679 (setq major-mode 'gnus-article-mode)
3680 (make-local-variable 'minor-mode-alist)
3681 (unless (assq 'gnus-show-mime minor-mode-alist)
3682 (push (list 'gnus-show-mime " MIME") minor-mode-alist))
3683 (use-local-map gnus-article-mode-map)
3684 (when (gnus-visual-p 'article-menu 'menu)
3685 (gnus-article-make-menu-bar)
3686 (when gnus-summary-tool-bar-map
3687 (set (make-local-variable 'tool-bar-map) gnus-summary-tool-bar-map)))
3688 (gnus-update-format-specifications nil 'article-mode)
3689 (set (make-local-variable 'page-delimiter) gnus-page-delimiter)
3690 (make-local-variable 'gnus-page-broken)
3691 (make-local-variable 'gnus-button-marker-list)
3692 (make-local-variable 'gnus-article-current-summary)
3693 (make-local-variable 'gnus-article-mime-handles)
3694 (make-local-variable 'gnus-article-decoded-p)
3695 (make-local-variable 'gnus-article-mime-handle-alist)
3696 (make-local-variable 'gnus-article-wash-types)
3697 (make-local-variable 'gnus-article-image-alist)
3698 (make-local-variable 'gnus-article-charset)
3699 (make-local-variable 'gnus-article-ignored-charsets)
3700 (gnus-set-default-directory)
3701 (buffer-disable-undo)
3702 (setq buffer-read-only t)
3703 (set-syntax-table gnus-article-mode-syntax-table)
3704 (gnus-run-hooks 'gnus-article-mode-hook))
3706 (defun gnus-article-setup-buffer ()
3707 "Initialize the article buffer."
3708 (let* ((name (if gnus-single-article-buffer "*Article*"
3709 (concat "*Article " gnus-newsgroup-name "*")))
3711 (progn (string-match "\\*Article" name)
3712 (concat " *Original Article"
3713 (substring name (match-end 0))))))
3714 (setq gnus-article-buffer name)
3715 (setq gnus-original-article-buffer original)
3716 (setq gnus-article-mime-handle-alist nil)
3717 ;; This might be a variable local to the summary buffer.
3718 (unless gnus-single-article-buffer
3720 (set-buffer gnus-summary-buffer)
3721 (setq gnus-article-buffer name)
3722 (setq gnus-original-article-buffer original)
3723 (gnus-set-global-variables)))
3724 (gnus-article-setup-highlight-words)
3725 ;; Init original article buffer.
3727 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
3728 (set-buffer-multibyte t)
3729 (setq major-mode 'gnus-original-article-mode)
3730 (make-local-variable 'gnus-original-article))
3731 (if (get-buffer name)
3734 (when (and gnus-article-edit-mode
3737 (y-or-n-p "Article mode edit in progress; discard? ")))
3738 (error "Action aborted"))
3739 (set (make-local-variable 'gnus-article-edit-mode) nil)
3740 (buffer-disable-undo)
3741 (setq buffer-read-only t)
3742 ;; This list just keeps growing if we don't reset it.
3743 (setq gnus-button-marker-list nil)
3744 (unless (eq major-mode 'gnus-article-mode)
3745 (gnus-article-mode))
3748 (set-buffer (gnus-get-buffer-create name))
3750 (make-local-variable 'gnus-summary-buffer)
3751 (gnus-summary-set-local-parameters gnus-newsgroup-name)
3752 (current-buffer)))))
3754 ;; Set article window start at LINE, where LINE is the number of lines
3755 ;; from the head of the article.
3756 (defun gnus-article-set-window-start (&optional line)
3758 (gnus-get-buffer-window gnus-article-buffer t)
3760 (set-buffer gnus-article-buffer)
3761 (goto-char (point-min))
3764 (gnus-message 6 "Moved to bookmark")
3765 (search-forward "\n\n" nil t)
3769 ;;; @@ article filters
3772 (defun gnus-article-display-mime-message ()
3773 "Article display method for MIME message."
3774 ;; called from `gnus-original-article-buffer'.
3775 (let (charset all-headers)
3776 (with-current-buffer gnus-summary-buffer
3777 (setq charset default-mime-charset
3778 all-headers gnus-have-all-headers))
3779 (make-local-variable 'default-mime-charset)
3780 (setq default-mime-charset charset)
3781 (with-current-buffer (get-buffer-create gnus-article-buffer)
3782 (make-local-variable 'default-mime-charset)
3783 (setq default-mime-charset charset))
3784 (mime-display-message mime-message-structure
3785 gnus-article-buffer nil gnus-article-mode-map)
3787 (gnus-article-hide-headers nil -1)))
3788 (run-hooks 'gnus-mime-article-prepare-hook))
3790 (defun gnus-article-display-traditional-message ()
3791 "Article display method for traditional message."
3792 (set-buffer gnus-article-buffer)
3793 (let (buffer-read-only)
3795 (insert-buffer-substring gnus-original-article-buffer)))
3797 (defun gnus-article-make-full-mail-header (&optional number charset)
3798 "Create a new mail header structure in a raw article buffer."
3799 (unless (and number charset)
3800 (save-current-buffer
3801 (set-buffer gnus-summary-buffer)
3803 (setq number (or (cdr gnus-article-current) 0)))
3805 (setq charset (or default-mime-charset 'x-ctext)))))
3806 (goto-char (point-min))
3807 (let ((header-end (if (search-forward "\n\n" nil t)
3809 (goto-char (point-max))))
3810 (chars (- (point-max) (point)))
3811 (lines (count-lines (point) (point-max)))
3812 (default-mime-charset charset)
3814 (narrow-to-region (point-min) header-end)
3815 (setq xref (std11-fetch-field "xref"))
3817 (make-full-mail-header
3819 (std11-fetch-field "subject")
3820 (std11-fetch-field "from")
3821 (std11-fetch-field "date")
3822 (std11-fetch-field "message-id")
3823 (std11-fetch-field "references")
3826 (when xref (concat "Xref: " xref)))
3829 (defun gnus-article-prepare (article &optional all-headers header)
3830 "Prepare ARTICLE in article mode buffer.
3831 ARTICLE should either be an article number or a Message-ID.
3832 If ARTICLE is an id, HEADER should be the article headers.
3833 If ALL-HEADERS is non-nil, no headers are hidden."
3835 ;; Make sure we start in a summary buffer.
3836 (unless (eq major-mode 'gnus-summary-mode)
3837 (set-buffer gnus-summary-buffer))
3838 (setq gnus-summary-buffer (current-buffer))
3839 (let* ((gnus-article (if header (mail-header-number header) article))
3840 (summary-buffer (current-buffer))
3841 (gnus-tmp-internal-hook gnus-article-internal-prepare-hook)
3842 (group gnus-newsgroup-name)
3845 (gnus-article-setup-buffer)
3846 (set-buffer gnus-article-buffer)
3847 ;; Deactivate active regions.
3848 (when (and (boundp 'transient-mark-mode)
3849 transient-mark-mode)
3850 (setq mark-active nil))
3851 (if (not (setq result (let ((buffer-read-only nil))
3852 (gnus-request-article-this-buffer
3854 ;; There is no such article.
3856 (when (and (numberp article)
3857 (not (memq article gnus-newsgroup-sparse)))
3858 (setq gnus-article-current
3859 (cons gnus-newsgroup-name article))
3860 (set-buffer gnus-summary-buffer)
3861 (setq gnus-current-article article)
3862 (if (and (memq article gnus-newsgroup-undownloaded)
3863 (not (gnus-online (gnus-find-method-for-group
3864 gnus-newsgroup-name))))
3866 (gnus-summary-set-agent-mark article)
3867 (message "Message marked for downloading"))
3868 (gnus-summary-mark-article article gnus-canceled-mark)
3869 (unless (memq article gnus-newsgroup-sparse)
3870 (gnus-error 1 "No such article (may have expired or been canceled)")))))
3871 (if (or (eq result 'pseudo)
3872 (eq result 'nneething))
3875 (set-buffer summary-buffer)
3876 (push article gnus-newsgroup-history)
3877 (setq gnus-last-article gnus-current-article
3878 gnus-current-article 0
3879 gnus-current-headers nil
3880 gnus-article-current nil)
3881 (if (eq result 'nneething)
3882 (gnus-configure-windows 'summary)
3883 (gnus-configure-windows 'article))
3884 (gnus-set-global-variables))
3885 (let ((gnus-article-mime-handle-alist-1
3886 gnus-article-mime-handle-alist))
3887 (gnus-set-mode-line 'article)))
3888 ;; The result from the `request' was an actual article -
3889 ;; or at least some text that is now displayed in the
3891 (when (and (numberp article)
3892 (not (eq article gnus-current-article)))
3893 ;; Seems like a new article has been selected.
3894 ;; `gnus-current-article' must be an article number.
3896 (set-buffer summary-buffer)
3897 (push article gnus-newsgroup-history)
3898 (setq gnus-last-article gnus-current-article
3899 gnus-current-article article
3900 gnus-current-headers
3901 (gnus-summary-article-header gnus-current-article)
3902 gnus-article-current
3903 (cons gnus-newsgroup-name gnus-current-article))
3904 (unless (vectorp gnus-current-headers)
3905 (setq gnus-current-headers nil))
3906 (gnus-summary-goto-subject gnus-current-article)
3907 (when (gnus-summary-show-thread)
3908 ;; If the summary buffer really was folded, the
3909 ;; previous goto may not actually have gone to
3910 ;; the right article, but the thread root instead.
3912 (gnus-summary-goto-subject gnus-current-article))
3913 (gnus-run-hooks 'gnus-mark-article-hook)
3914 (gnus-set-mode-line 'summary)
3915 (when (gnus-visual-p 'article-highlight 'highlight)
3916 (gnus-run-hooks 'gnus-visual-mark-article-hook))
3917 ;; Set the global newsgroup variables here.
3918 (gnus-set-global-variables)
3919 (setq gnus-have-all-headers
3920 (or all-headers gnus-show-all-headers))))
3922 (gnus-configure-windows 'article))
3923 (when (or (numberp article)
3925 (gnus-article-prepare-display)
3927 (goto-char (point-min))
3928 (setq gnus-page-broken
3929 (when gnus-break-pages
3930 (gnus-narrow-to-page)
3932 (let ((gnus-article-mime-handle-alist-1
3933 gnus-article-mime-handle-alist))
3934 (gnus-set-mode-line 'article))
3938 (set-window-point (get-buffer-window (current-buffer)) (point))
3939 (gnus-configure-windows 'article)
3942 (defun gnus-article-prepare-mime-display (&optional number)
3943 (goto-char (point-min))
3944 (when (re-search-forward "^[^\t ]+:" nil t)
3945 (goto-char (match-beginning 0)))
3946 (let ((entity (if (eq 1 (point-min))
3947 (get-text-property 1 'mime-view-entity)
3948 (get-text-property (point) 'mime-view-entity)))
3949 last-entity child-entity next type)
3950 (setq child-entity (mime-entity-children entity))
3952 (setq last-entity (nth (1- (length child-entity))
3954 (setq last-entity entity))
3956 (narrow-to-region (point)
3957 (if (search-forward "\n\n" nil t)
3960 (gnus-treat-article 'head)
3961 (put-text-property (point-min) (point-max) 'article-treated-header t)
3962 (goto-char (point-max)))
3963 (while (and (not (eobp)) entity)
3964 (setq next (set-marker
3966 (next-single-property-change (point) 'mime-view-entity
3968 (let ((types (mime-entity-content-type entity)))
3969 (while (eq 'multipart (mime-content-type-primary-type types))
3970 (setq entity (car (mime-entity-children entity))
3971 types (mime-entity-content-type entity)))
3973 (setq type (format "%s/%s"
3974 (mime-content-type-primary-type types)
3975 (mime-content-type-subtype types)))))
3976 (if (string-equal type "message/rfc822")
3979 (let ((children (mime-entity-children entity))
3982 (setq last-children (nth (1- (length children)) children))
3985 (not (eq last-children
3986 (get-text-property next 'mime-view-entity)))
3988 (next-single-property-change next
3990 nil (point-max)))))))
3991 (setq next (next-single-property-change next 'mime-view-entity
3994 (narrow-to-region (point) next)
3995 (gnus-article-prepare-mime-display)
3996 (goto-char (point-max)))
3997 (setq entity (get-text-property (point) 'mime-view-entity)))
3999 (narrow-to-region (point) next)
4000 ;; Kludge. We have to count true number, but for now,
4001 ;; part number is here only to achieve `last'.
4002 (gnus-treat-article nil 1
4003 (if (eq entity last-entity)
4006 (goto-char (point-max)))
4007 (setq entity (get-text-property next 'mime-view-entity))))))
4010 (defun gnus-article-prepare-display ()
4011 "Make the current buffer look like a nice article."
4012 (let ((gnus-article-buffer (current-buffer))
4014 (unless (eq major-mode 'gnus-article-mode)
4015 (gnus-article-mode))
4016 (setq buffer-read-only nil
4017 gnus-button-marker-list nil
4018 gnus-article-wash-types nil
4019 gnus-article-image-alist nil)
4022 (static-if (featurep 'xemacs)
4023 (map-extents (lambda (extent maparg) (delete-extent extent)))
4024 (let ((lists (overlay-lists)))
4025 (dolist (overlay (nconc (car lists) (cdr lists)))
4026 (delete-overlay overlay)))))
4027 (gnus-run-hooks 'gnus-tmp-internal-hook))
4028 (let ((show-mime (unless (member gnus-newsgroup-name '("nndraft:delayed"
4031 (inhibit-read-only t))
4032 (set-buffer gnus-original-article-buffer)
4034 (setq mime-message-structure gnus-current-headers)
4035 (mime-buffer-entity-set-buffer-internal mime-message-structure
4036 gnus-original-article-buffer)
4037 (mime-entity-set-representation-type-internal mime-message-structure
4038 'mime-buffer-entity)
4039 (luna-send mime-message-structure 'initialize-instance
4040 mime-message-structure)
4042 (let (mime-display-header-hook mime-display-text/plain-hook)
4043 (funcall gnus-article-display-method-for-mime))
4044 (funcall gnus-article-display-method-for-traditional))
4045 ;; Call the treatment functions.
4049 (gnus-article-prepare-mime-display)
4050 (narrow-to-region (goto-char (point-min))
4051 (if (search-forward "\n\n" nil t)
4054 (gnus-treat-article 'head)
4055 (put-text-property (point-min) (point-max) 'article-treated-header t)
4056 (goto-char (point-max))
4058 (narrow-to-region (point) (point-max))
4059 (gnus-treat-article nil))
4060 (put-text-property (point-min) (point-max) 'read-only nil)))
4061 (gnus-run-hooks 'gnus-article-prepare-hook))
4063 (defun gnus-article-decode-article-as-default-mime-charset ()
4064 "Decode an article as `default-mime-charset'. It won't work if the
4065 value of the variable `gnus-show-mime' is non-nil."
4066 (unless (or gnus-show-mime
4067 (member gnus-newsgroup-name '("nndraft:delayed"
4069 (set (make-local-variable 'default-mime-charset)
4070 (with-current-buffer gnus-summary-buffer
4071 default-mime-charset))
4072 (decode-mime-charset-region (point-min) (point-max)
4073 default-mime-charset)))
4076 ;;; Gnus MIME viewing functions
4079 (defvar gnus-mime-button-line-format "%{%([%p. %d%T]%)%}%e\n"
4080 "Format of the MIME buttons.
4082 Valid specifiers include:
4084 %T MIME type, along with additional info
4085 %n The `name' parameter
4086 %d The description, if any
4087 %l The length of the encoded part
4088 %p The part identifier number
4089 %e Dots if the part isn't displayed
4091 General format specifiers can also be used. See Info node
4092 `(gnus)Formatting Variables'.")
4094 (defvar gnus-mime-button-line-format-alist
4095 '((?t gnus-tmp-type ?s)
4096 (?T gnus-tmp-type-long ?s)
4097 (?n gnus-tmp-name ?s)
4098 (?d gnus-tmp-description ?s)
4100 (?l gnus-tmp-length ?d)
4101 (?e gnus-tmp-dots ?s)))
4103 (defvar gnus-mime-button-commands
4104 '((gnus-article-press-button "\r" "Toggle Display")
4105 (gnus-mime-view-part "v" "View Interactively...")
4106 (gnus-mime-view-part-as-type "t" "View As Type...")
4107 (gnus-mime-view-part-as-charset "C" "View As charset...")
4108 (gnus-mime-save-part "o" "Save...")
4109 (gnus-mime-save-part-and-strip "\C-o" "Save and Strip")
4110 (gnus-mime-delete-part "d" "Delete part")
4111 (gnus-mime-copy-part "c" "View As Text, In Other Buffer")
4112 (gnus-mime-inline-part "i" "View As Text, In This Buffer")
4113 (gnus-mime-view-part-internally "E" "View Internally")
4114 (gnus-mime-view-part-externally "e" "View Externally")
4115 (gnus-mime-print-part "p" "Print")
4116 (gnus-mime-pipe-part "|" "Pipe To Command...")
4117 (gnus-mime-action-on-part "." "Take action on the part...")))
4119 (defun gnus-article-mime-part-status ()
4120 (with-current-buffer gnus-article-buffer
4121 (let ((entity (get-text-property (point-min) 'mime-view-entity))
4124 (setq children (mime-entity-children entity))
4125 (setq children (length children)))
4128 (format " (%d parts)" children))
4131 (defvar gnus-mime-button-map
4132 (let ((map (make-sparse-keymap)))
4133 (unless (>= (string-to-number emacs-version) 21)
4134 ;; XEmacs doesn't care.
4135 (set-keymap-parent map gnus-article-mode-map))
4136 (define-key map gnus-mouse-2 'gnus-article-push-button)
4137 (define-key map gnus-down-mouse-3 'gnus-mime-button-menu)
4138 (dolist (c gnus-mime-button-commands)
4139 (define-key map (cadr c) (car c)))
4142 (easy-menu-define gnus-mime-button-menu gnus-mime-button-map "MIME button menu."
4144 ,@(mapcar (lambda (c)
4145 (vector (caddr c) (car c) :enable t)) gnus-mime-button-commands)))
4148 (define-compiler-macro popup-menu (&whole form
4149 menu &optional position prefix)
4150 (if (and (fboundp 'popup-menu)
4151 (not (memq 'popup-menu (assoc "lmenu" load-history))))
4153 ;; Gnus is probably running under Emacs 20.
4154 `(let* ((menu (cdr ,menu))
4155 (response (x-popup-menu
4157 (cons "" (mapcar (lambda (c)
4158 (cons (caddr c) (car c)))
4161 (call-interactively (nth 3 (assq response menu))))))))
4163 (defun gnus-mime-button-menu (event prefix)
4164 "Construct a context-sensitive menu of MIME commands."
4165 (interactive "e\nP")
4166 (save-window-excursion
4167 (let ((pos (event-start event)))
4168 (select-window (posn-window pos))
4169 (goto-char (posn-point pos))
4170 (gnus-article-check-buffer)
4171 (popup-menu gnus-mime-button-menu nil prefix))))
4173 (defun gnus-mime-view-all-parts (&optional handles)
4174 "View all the MIME parts."
4176 (save-current-buffer
4177 (set-buffer gnus-article-buffer)
4178 (let ((handles (or handles gnus-article-mime-handles))
4179 (mail-parse-charset gnus-newsgroup-charset)
4180 (mail-parse-ignored-charsets
4181 (with-current-buffer gnus-summary-buffer
4182 gnus-newsgroup-ignored-charsets)))
4184 (mm-remove-parts handles)
4185 (goto-char (point-min))
4186 (or (search-forward "\n\n") (goto-char (point-max)))
4187 (let (buffer-read-only)
4188 (delete-region (point) (point-max))
4189 (mm-display-parts handles))))))
4191 (defun gnus-mime-save-part-and-strip ()
4192 "Save the MIME part under point then replace it with an external body."
4194 (gnus-article-check-buffer)
4195 (let* ((data (get-text-property (point) 'gnus-data))
4197 (handles gnus-article-mime-handles))
4198 (if (mm-multiple-handles gnus-article-mime-handles)
4199 (error "This function is not implemented"))
4200 (setq file (and data (mm-save-part data)))
4202 (with-current-buffer (mm-handle-buffer data)
4204 (insert "Content-Type: " (mm-handle-media-type data))
4205 (mml-insert-parameter-string (cdr (mm-handle-type data))
4208 (insert "Content-ID: " (message-make-message-id) "\n")
4209 (insert "Content-Transfer-Encoding: binary\n")
4212 (cdr (mm-make-handle nil
4213 `("message/external-body"
4214 (access-type . "LOCAL-FILE")
4216 (set-buffer gnus-summary-buffer)
4217 (gnus-article-edit-article
4220 (let ((mail-parse-charset (or gnus-article-charset
4221 ',gnus-newsgroup-charset))
4222 (mail-parse-ignored-charsets
4223 (or gnus-article-ignored-charsets
4224 ',gnus-newsgroup-ignored-charsets))
4225 (mbl mml-buffer-list))
4226 (setq mml-buffer-list nil)
4227 (insert-buffer gnus-original-article-buffer)
4228 (mime-to-mml ',handles)
4229 (setq gnus-article-mime-handles nil)
4230 (let ((mbl1 mml-buffer-list))
4231 (setq mml-buffer-list mbl)
4232 (set (make-local-variable 'mml-buffer-list) mbl1))
4233 ;; LOCAL argument of add-hook differs between GNU Emacs
4234 ;; and XEmacs. make-local-hook makes sure they are local.
4235 (make-local-hook 'kill-buffer-hook)
4236 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4237 `(lambda (no-highlight)
4238 (let ((mail-parse-charset (or gnus-article-charset
4239 ',gnus-newsgroup-charset))
4240 (message-options message-options)
4241 (message-options-set-recipient)
4242 (mail-parse-ignored-charsets
4243 (or gnus-article-ignored-charsets
4244 ',gnus-newsgroup-ignored-charsets)))
4246 (mml-destroy-buffers)
4247 (remove-hook 'kill-buffer-hook
4248 'mml-destroy-buffers t)
4249 (kill-local-variable 'mml-buffer-list))
4250 (gnus-summary-edit-article-done
4251 ,(or (mail-header-references gnus-current-headers) "")
4252 ,(gnus-group-read-only-p)
4253 ,gnus-summary-buffer no-highlight))))))
4255 (defun gnus-mime-delete-part ()
4256 "Delete the MIME part under point.
4257 Replace it with some information about the removed part."
4259 (gnus-article-check-buffer)
4260 (let* ((data (get-text-property (point) 'gnus-data))
4261 (handles gnus-article-mime-handles)
4265 (mail-decode-encoded-word-string (or (mm-handle-description data)
4268 (or (mail-content-type-get (mm-handle-disposition data) 'filename)
4270 (type (mm-handle-media-type data)))
4271 (if (mm-multiple-handles gnus-article-mime-handles)
4272 (error "This function is not implemented"))
4273 (with-current-buffer (mm-handle-buffer data)
4274 (let ((bsize (format "%s" (buffer-size))))
4278 "<#part type=text/plain nofile=yes disposition=attachment"
4279 " description=\"Deleted attachment (" bsize " Byte)\">"
4281 "| The following attachment has been deleted:\n"
4283 "| Type: " type "\n"
4284 "| Filename: " filename "\n"
4285 "| Size (encoded): " bsize " Byte\n"
4286 "| Description: " description "\n"
4290 (cdr (mm-make-handle nil `("text/plain"))))))
4291 (set-buffer gnus-summary-buffer)
4292 ;; FIXME: maybe some of the following code (borrowed from
4293 ;; `gnus-mime-save-part-and-strip') isn't necessary?
4294 (gnus-article-edit-article
4297 (let ((mail-parse-charset (or gnus-article-charset
4298 ',gnus-newsgroup-charset))
4299 (mail-parse-ignored-charsets
4300 (or gnus-article-ignored-charsets
4301 ',gnus-newsgroup-ignored-charsets))
4302 (mbl mml-buffer-list))
4303 (setq mml-buffer-list nil)
4304 (insert-buffer gnus-original-article-buffer)
4305 (mime-to-mml ',handles)
4306 (setq gnus-article-mime-handles nil)
4307 (let ((mbl1 mml-buffer-list))
4308 (setq mml-buffer-list mbl)
4309 (set (make-local-variable 'mml-buffer-list) mbl1))
4310 ;; LOCAL argument of add-hook differs between GNU Emacs
4311 ;; and XEmacs. make-local-hook makes sure they are local.
4312 (make-local-hook 'kill-buffer-hook)
4313 (add-hook 'kill-buffer-hook 'mml-destroy-buffers t t)))
4314 `(lambda (no-highlight)
4315 (let ((mail-parse-charset (or gnus-article-charset
4316 ',gnus-newsgroup-charset))
4317 (message-options message-options)
4318 (message-options-set-recipient)
4319 (mail-parse-ignored-charsets
4320 (or gnus-article-ignored-charsets
4321 ',gnus-newsgroup-ignored-charsets)))
4323 (mml-destroy-buffers)
4324 (remove-hook 'kill-buffer-hook
4325 'mml-destroy-buffers t)
4326 (kill-local-variable 'mml-buffer-list))
4327 (gnus-summary-edit-article-done
4328 ,(or (mail-header-references gnus-current-headers) "")
4329 ,(gnus-group-read-only-p)
4330 ,gnus-summary-buffer no-highlight))))
4331 ;; Not in `gnus-mime-save-part-and-strip':
4332 (gnus-article-edit-done)
4333 (gnus-summary-expand-window)
4334 (gnus-summary-show-article))
4336 (defun gnus-mime-save-part ()
4337 "Save the MIME part under point."
4339 (gnus-article-check-buffer)
4340 (let ((data (get-text-property (point) 'gnus-data)))
4342 (mm-save-part data))))
4344 (defun gnus-mime-pipe-part ()
4345 "Pipe the MIME part under point to a process."
4347 (gnus-article-check-buffer)
4348 (let ((data (get-text-property (point) 'gnus-data)))
4350 (mm-pipe-part data))))
4352 (defun gnus-mime-view-part ()
4353 "Interactively choose a viewing method for the MIME part under point."
4355 (gnus-article-check-buffer)
4356 (let ((data (get-text-property (point) 'gnus-data)))
4358 (setq gnus-article-mime-handles
4360 gnus-article-mime-handles (setq data (copy-sequence data))))
4361 (mm-interactively-view-part data))))
4363 (defun gnus-mime-view-part-as-type-internal ()
4364 (gnus-article-check-buffer)
4365 (let* ((name (mail-content-type-get
4366 (mm-handle-type (get-text-property (point) 'gnus-data))
4368 (def-type (and name (mm-default-file-encoding name))))
4369 (and def-type (cons def-type 0))))
4371 (defun gnus-mime-view-part-as-type (&optional mime-type)
4372 "Choose a MIME media type, and view the part as such."
4375 (setq mime-type (completing-read
4376 "View as MIME type: "
4377 (mapcar #'list (mailcap-mime-types))
4379 (gnus-mime-view-part-as-type-internal))))
4380 (gnus-article-check-buffer)
4381 (let ((handle (get-text-property (point) 'gnus-data)))
4384 (mm-make-handle (mm-handle-buffer handle)
4385 (cons mime-type (cdr (mm-handle-type handle)))
4386 (mm-handle-encoding handle)
4387 (mm-handle-undisplayer handle)
4388 (mm-handle-disposition handle)
4389 (mm-handle-description handle)
4391 (mm-handle-id handle)))
4392 (setq gnus-article-mime-handles
4393 (mm-merge-handles gnus-article-mime-handles handle))
4394 (gnus-mm-display-part handle))))
4397 (require 'jka-compr))
4399 ;; jka-compr.el uses a "sh -c" to direct stderr to err-file, but these days
4400 ;; emacs can do that itself.
4402 (defun gnus-mime-jka-compr-maybe-uncompress ()
4403 "Uncompress the current buffer if `auto-compression-mode' is enabled.
4404 The uncompress method used is derived from `buffer-file-name'."
4405 (when (and (fboundp 'jka-compr-installed-p)
4406 (jka-compr-installed-p))
4407 (let ((info (jka-compr-get-compression-info buffer-file-name)))
4409 (let ((basename (file-name-nondirectory buffer-file-name))
4410 (args (jka-compr-info-uncompress-args info))
4411 (prog (jka-compr-info-uncompress-program info))
4412 (message (jka-compr-info-uncompress-message info))
4413 (err-file (jka-compr-make-temp-name)))
4415 (message "%s %s..." message basename))
4417 (unless (memq (apply 'call-process-region
4418 (point-min) (point-max)
4420 t (list t err-file) nil
4422 jka-compr-acceptable-retval-list)
4423 (jka-compr-error prog args basename message err-file))
4424 (jka-compr-delete-temp-file err-file)))))))
4426 (defun gnus-mime-copy-part (&optional handle)
4427 "Put the MIME part under point into a new buffer.
4428 If `auto-compression-mode' is enabled, compressed files like .gz and .bz2
4431 (gnus-article-check-buffer)
4432 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4433 (contents (and handle (mm-get-part handle)))
4435 (file-name-nondirectory
4437 (mail-content-type-get (mm-handle-type handle) 'name)
4438 (mail-content-type-get (mm-handle-disposition handle)
4441 (buffer (and base (generate-new-buffer base))))
4443 (switch-to-buffer buffer)
4445 ;; We do it this way to make `normal-mode' set the appropriate mode.
4448 (setq buffer-file-name (expand-file-name base))
4449 (gnus-mime-jka-compr-maybe-uncompress)
4451 (setq buffer-file-name nil))
4452 (goto-char (point-min)))))
4454 (defun gnus-mime-print-part (&optional handle filename)
4455 "Print the MIME part under point."
4456 (interactive (list nil (ps-print-preprint current-prefix-arg)))
4457 (gnus-article-check-buffer)
4458 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4459 (contents (and handle (mm-get-part handle)))
4460 (file (mm-make-temp-file (expand-file-name "mm." mm-tmp-directory)))
4461 (printer (mailcap-mime-info (mm-handle-media-type handle) "print")))
4466 (mm-save-part-to-file handle file)
4467 (call-process shell-file-name nil
4468 (generate-new-buffer " *mm*")
4470 shell-command-switch
4472 printer file (mm-handle-type handle))))
4476 (gnus-print-buffer))
4477 (ps-despool filename)))))
4479 (defun gnus-mime-inline-part (&optional handle arg)
4480 "Insert the MIME part under point into the current buffer."
4481 (interactive (list nil current-prefix-arg))
4482 (gnus-article-check-buffer)
4483 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4488 (if (and (not arg) (mm-handle-undisplayer handle))
4489 (mm-remove-part handle)
4490 (setq contents (mm-get-part handle))
4493 (setq charset (or (mail-content-type-get
4494 (mm-handle-type handle) 'charset)
4495 gnus-newsgroup-charset)))
4497 (if (mm-handle-undisplayer handle)
4498 (mm-remove-part handle))
4501 gnus-summary-show-article-charset-alist))
4502 (mm-read-coding-system "Charset: ")))))
4504 (mm-insert-inline handle
4506 (setq charset (mm-charset-to-coding-system
4508 (not (eq charset 'ascii)))
4509 (mm-decode-coding-string contents charset)
4513 (defun gnus-mime-view-part-as-charset (&optional handle arg)
4514 "Insert the MIME part under point into the current buffer using the
4516 (interactive (list nil current-prefix-arg))
4517 (gnus-article-check-buffer)
4518 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4523 (if (mm-handle-undisplayer handle)
4524 (mm-remove-part handle))
4525 (let ((gnus-newsgroup-charset
4527 gnus-summary-show-article-charset-alist))
4528 (mm-read-coding-system "Charset: ")))
4529 (gnus-newsgroup-ignored-charsets 'gnus-all))
4530 (gnus-article-press-button)))))
4532 (defun gnus-mime-view-part-externally (&optional handle)
4533 "View the MIME part under point with an external viewer."
4535 (gnus-article-check-buffer)
4536 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4537 (mm-user-display-methods nil)
4538 (mm-inlined-types nil)
4539 (mail-parse-charset gnus-newsgroup-charset)
4540 (mail-parse-ignored-charsets
4541 (save-excursion (set-buffer gnus-summary-buffer)
4542 gnus-newsgroup-ignored-charsets)))
4544 (if (mm-handle-undisplayer handle)
4545 (mm-remove-part handle)
4546 (mm-display-part handle)))))
4548 (defun gnus-mime-view-part-internally (&optional handle)
4549 "View the MIME part under point with an internal viewer.
4550 If no internal viewer is available, use an external viewer."
4552 (gnus-article-check-buffer)
4553 (let* ((handle (or handle (get-text-property (point) 'gnus-data)))
4554 (mm-inlined-types '(".*"))
4555 (mm-inline-large-images t)
4556 (mail-parse-charset gnus-newsgroup-charset)
4557 (mail-parse-ignored-charsets
4558 (save-excursion (set-buffer gnus-summary-buffer)
4559 gnus-newsgroup-ignored-charsets))
4562 (if (mm-handle-undisplayer handle)
4563 (mm-remove-part handle)
4564 (mm-display-part handle)))))
4566 (defun gnus-mime-action-on-part (&optional action)
4567 "Do something with the MIME attachment at \(point\)."
4569 (list (completing-read "Action: " gnus-mime-action-alist nil t)))
4570 (gnus-article-check-buffer)
4571 (let ((action-pair (assoc action gnus-mime-action-alist)))
4573 (funcall (cdr action-pair)))))
4575 (defun gnus-article-part-wrapper (n function)
4576 (save-current-buffer
4577 (set-buffer gnus-article-buffer)
4578 (when (> n (length gnus-article-mime-handle-alist))
4579 (error "No such part"))
4580 (gnus-article-goto-part n)
4581 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4582 (funcall function handle))))
4584 (defun gnus-article-pipe-part (n)
4585 "Pipe MIME part N, which is the numerical prefix."
4587 (gnus-article-part-wrapper n 'mm-pipe-part))
4589 (defun gnus-article-save-part (n)
4590 "Save MIME part N, which is the numerical prefix."
4592 (gnus-article-part-wrapper n 'mm-save-part))
4594 (defun gnus-article-interactively-view-part (n)
4595 "View MIME part N interactively, which is the numerical prefix."
4597 (gnus-article-part-wrapper n 'mm-interactively-view-part))
4599 (defun gnus-article-copy-part (n)
4600 "Copy MIME part N, which is the numerical prefix."
4602 (gnus-article-part-wrapper n 'gnus-mime-copy-part))
4604 (defun gnus-article-view-part-as-charset (n)
4605 "Copy MIME part N, which is the numerical prefix."
4607 (gnus-article-part-wrapper n 'gnus-mime-view-part-as-charset))
4609 (defun gnus-article-view-part-externally (n)
4610 "View MIME part N externally, which is the numerical prefix."
4612 (gnus-article-part-wrapper n 'gnus-mime-view-part-externally))
4614 (defun gnus-article-inline-part (n)
4615 "Inline MIME part N, which is the numerical prefix."
4617 (gnus-article-part-wrapper n 'gnus-mime-inline-part))
4619 (defun gnus-article-mime-match-handle-first (condition)
4621 (let ((alist gnus-article-mime-handle-alist) ihandle n)
4622 (while (setq ihandle (pop alist))
4624 ((functionp condition)
4625 (funcall condition (cdr ihandle)))
4626 ((eq condition 'undisplayed)
4627 (not (or (mm-handle-undisplayer (cdr ihandle))
4628 (equal (mm-handle-media-type (cdr ihandle))
4629 "multipart/alternative"))))
4630 ((eq condition 'undisplayed-alternative)
4631 (not (mm-handle-undisplayer (cdr ihandle))))
4633 (gnus-article-goto-part (car ihandle))
4634 (or (not n) (< (car ihandle) n)))
4635 (setq n (car ihandle))))
4639 (defun gnus-article-view-part (&optional n)
4640 "View MIME part N, which is the numerical prefix."
4642 (save-current-buffer
4643 (set-buffer gnus-article-buffer)
4644 (or (numberp n) (setq n (gnus-article-mime-match-handle-first
4645 gnus-article-mime-match-handle-function)))
4646 (when (> n (length gnus-article-mime-handle-alist))
4647 (error "No such part"))
4648 (let ((handle (cdr (assq n gnus-article-mime-handle-alist))))
4649 (when (gnus-article-goto-part n)
4650 (if (equal (car handle) "multipart/alternative")
4651 (gnus-article-press-button)
4652 (when (eq (gnus-mm-display-part handle) 'internal)
4653 (gnus-set-window-start)))))))
4655 (defsubst gnus-article-mime-total-parts ()
4656 (if (bufferp (car gnus-article-mime-handles))
4658 (1- (length gnus-article-mime-handles))))
4660 (defun gnus-mm-display-part (handle)
4661 "Display HANDLE and fix MIME button."
4662 (let ((id (get-text-property (point) 'gnus-part))
4667 (let ((window (selected-window))
4668 (mail-parse-charset gnus-newsgroup-charset)
4669 (mail-parse-ignored-charsets
4670 (if (gnus-buffer-live-p gnus-summary-buffer)
4672 (set-buffer gnus-summary-buffer)
4673 gnus-newsgroup-ignored-charsets)
4677 (let ((win (gnus-get-buffer-window (current-buffer) t))
4680 (select-window win))
4683 (if (mm-handle-displayed-p handle)
4684 ;; This will remove the part.
4685 (mm-display-part handle)
4687 (narrow-to-region (point)
4688 (if (eobp) (point) (1+ (point))))
4689 (mm-display-part handle)
4690 ;; We narrow to the part itself and
4691 ;; then call the treatment functions.
4692 (goto-char (point-min))
4694 (narrow-to-region (point) (point-max))
4697 (gnus-article-mime-total-parts)
4698 (mm-handle-media-type handle)))))
4699 (if (window-live-p window)
4700 (select-window window)))))
4703 (gnus-insert-mime-button
4704 handle id (list (mm-handle-displayed-p handle)))
4705 (goto-char point))))
4707 (defun gnus-article-goto-part (n)
4708 "Go to MIME part N."
4709 (gnus-goto-char (text-property-any (point-min) (point-max) 'gnus-part n)))
4711 (defun gnus-insert-mime-button (handle gnus-tmp-id &optional displayed)
4712 (let ((gnus-tmp-name
4713 (or (mail-content-type-get (mm-handle-type handle) 'name)
4714 (mail-content-type-get (mm-handle-disposition handle) 'filename)
4715 (mail-content-type-get (mm-handle-type handle) 'url)
4717 (gnus-tmp-type (mm-handle-media-type handle))
4718 (gnus-tmp-description
4719 (mail-decode-encoded-word-string (or (mm-handle-description handle)
4722 (if (if displayed (car displayed)
4723 (mm-handle-displayed-p handle))
4725 (gnus-tmp-length (with-current-buffer (mm-handle-buffer handle)
4727 gnus-tmp-type-long b e)
4728 (when (string-match ".*/" gnus-tmp-name)
4729 (setq gnus-tmp-name (replace-match "" t t gnus-tmp-name)))
4730 (setq gnus-tmp-type-long (concat gnus-tmp-type
4731 (and (not (equal gnus-tmp-name ""))
4732 (concat "; " gnus-tmp-name))))
4733 (unless (equal gnus-tmp-description "")
4734 (setq gnus-tmp-type-long (concat " --- " gnus-tmp-type-long)))
4739 gnus-mime-button-line-format gnus-mime-button-line-format-alist
4740 `(,@(gnus-local-map-property gnus-mime-button-map)
4741 gnus-callback gnus-mm-display-part
4742 gnus-part ,gnus-tmp-id
4743 article-type annotation
4746 ;; Exclude a newline.
4749 (widget-convert-button
4752 :action 'gnus-widget-press-button
4753 :button-keymap gnus-mime-button-map
4755 (lambda (widget/window &optional overlay pos)
4756 ;; Needed to properly clear the message due to a bug in
4757 ;; wid-edit (XEmacs only).
4758 (if (boundp 'help-echo-owns-message)
4759 (setq help-echo-owns-message t))
4761 "%S: %s the MIME part; %S: more options"
4762 (aref gnus-mouse-2 0)
4763 ;; XEmacs will get a single widget arg; Emacs 21 will get
4764 ;; window, overlay, position.
4765 (if (mm-handle-displayed-p
4767 (with-current-buffer (gnus-overlay-buffer overlay)
4768 (widget-get (widget-at (gnus-overlay-start overlay))
4770 (widget-get widget/window :mime-handle)))
4772 (aref gnus-down-mouse-3 0))))))
4774 (defun gnus-widget-press-button (elems el)
4775 (goto-char (widget-get elems :from))
4776 (gnus-article-press-button))
4778 (defvar gnus-displaying-mime nil)
4780 (defun gnus-display-mime (&optional ihandles)
4781 "Display the MIME parts."
4783 (save-selected-window
4784 (let ((window (get-buffer-window gnus-article-buffer))
4787 (select-window window)
4788 ;; We have to do this since selecting the window
4789 ;; may change the point. So we set the window point.
4790 (set-window-point window point)))
4791 (let* ((handles (or ihandles
4792 (mm-dissect-buffer nil gnus-article-loose-mime)
4793 (and gnus-article-emulate-mime
4795 buffer-read-only handle name type b e display)
4796 (when (and (not ihandles)
4797 (not gnus-displaying-mime))
4798 ;; Top-level call; we clean up.
4799 (when gnus-article-mime-handles
4800 (mm-destroy-parts gnus-article-mime-handles)
4801 (setq gnus-article-mime-handle-alist nil));; A trick.
4802 (setq gnus-article-mime-handles handles)
4803 ;; We allow users to glean info from the handles.
4804 (when gnus-article-mime-part-function
4805 (gnus-mime-part-function handles)))
4807 (or (not (stringp (car handles)))
4810 (when (and (not ihandles)
4811 (not gnus-displaying-mime))
4812 ;; Clean up for mime parts.
4814 (delete-region (point) (point-max)))
4815 (let ((gnus-displaying-mime t))
4816 (gnus-mime-display-part handles)))
4819 (narrow-to-region (point) (point-max))
4820 (gnus-treat-article nil 1 1)
4823 ;; Highlight the headers.
4827 (narrow-to-region (point-min) (point))
4828 (gnus-treat-article 'head))))))))
4830 (defvar gnus-mime-display-multipart-as-mixed nil)
4831 (defvar gnus-mime-display-multipart-alternative-as-mixed nil)
4832 (defvar gnus-mime-display-multipart-related-as-mixed nil)
4834 (defun gnus-mime-display-part (handle)
4837 ((not (stringp (car handle)))
4838 (gnus-mime-display-single handle))
4839 ;; User-defined multipart
4840 ((cdr (assoc (car handle) gnus-mime-multipart-functions))
4841 (funcall (cdr (assoc (car handle) gnus-mime-multipart-functions))
4843 ;; multipart/alternative
4844 ((and (equal (car handle) "multipart/alternative")
4845 (not (or gnus-mime-display-multipart-as-mixed
4846 gnus-mime-display-multipart-alternative-as-mixed)))
4847 (let ((id (1+ (length gnus-article-mime-handle-alist))))
4848 (push (cons id handle) gnus-article-mime-handle-alist)
4849 (gnus-mime-display-alternative (cdr handle) nil nil id)))
4850 ;; multipart/related
4851 ((and (equal (car handle) "multipart/related")
4852 (not (or gnus-mime-display-multipart-as-mixed
4853 gnus-mime-display-multipart-related-as-mixed)))
4854 ;;;!!!We should find the start part, but we just default
4855 ;;;!!!to the first part.
4856 ;;(gnus-mime-display-part (cadr handle))
4857 ;;;!!! Most multipart/related is an HTML message plus images.
4858 ;;;!!! Unfortunately we are unable to let W3 display those
4859 ;;;!!! included images, so we just display it as a mixed multipart.
4860 ;;(gnus-mime-display-mixed (cdr handle))
4861 ;;;!!! No, w3 can display everything just fine.
4862 (gnus-mime-display-part (cadr handle)))
4863 ((equal (car handle) "multipart/signed")
4864 (gnus-add-wash-type 'signed)
4865 (gnus-mime-display-security handle))
4866 ((equal (car handle) "multipart/encrypted")
4867 (gnus-add-wash-type 'encrypted)
4868 (gnus-mime-display-security handle))
4869 ;; Other multiparts are handled like multipart/mixed.
4871 (gnus-mime-display-mixed (cdr handle)))))
4873 (defun gnus-mime-part-function (handles)
4874 (if (stringp (car handles))
4875 (mapcar 'gnus-mime-part-function (cdr handles))
4876 (funcall gnus-article-mime-part-function handles)))
4878 (defun gnus-mime-display-mixed (handles)
4879 (mapcar 'gnus-mime-display-part handles))
4881 (defun gnus-mime-display-single (handle)
4882 (let ((type (mm-handle-media-type handle))
4883 (ignored gnus-ignored-mime-types)
4890 (when (string-match (pop ignored) type)
4891 (throw 'ignored nil)))
4892 (if (and (setq not-attachment
4893 (and (not (mm-inline-override-p handle))
4894 (or (not (mm-handle-disposition handle))
4895 (equal (car (mm-handle-disposition handle))
4897 (mm-attachment-override-p handle))))
4898 (mm-automatic-display-p handle)
4900 (mm-inlinable-p handle)
4901 (mm-inlined-p handle))
4902 (mm-automatic-external-display-p type)))
4904 (when (equal (mm-handle-media-supertype handle) "text")
4906 (let ((id (1+ (length gnus-article-mime-handle-alist)))
4908 (push (cons id handle) gnus-article-mime-handle-alist)
4909 (when (or (not display)
4910 (not (gnus-unbuttonized-mime-type-p type)))
4911 ;(gnus-article-insert-newline)
4912 (gnus-insert-mime-button
4913 handle id (list (or display (and not-attachment text))))
4914 (gnus-article-insert-newline)
4915 ;(gnus-article-insert-newline)
4916 ;; Remember modify the number of forward lines.
4924 (let ((mail-parse-charset gnus-newsgroup-charset)
4925 (mail-parse-ignored-charsets
4926 (save-excursion (condition-case ()
4927 (set-buffer gnus-summary-buffer)
4929 gnus-newsgroup-ignored-charsets)))
4930 (mm-display-part handle t))
4931 (goto-char (point-max)))
4932 ((and text not-attachment)
4936 (gnus-article-insert-newline)
4937 (mm-insert-inline handle (mm-get-part handle))
4938 (goto-char (point-max))))
4942 (narrow-to-region beg (point))
4945 (gnus-article-mime-total-parts)
4946 (mm-handle-media-type handle)))))))))
4948 (defun gnus-unbuttonized-mime-type-p (type)
4949 "Say whether TYPE is to be unbuttonized."
4950 (unless gnus-inhibit-mime-unbuttonizing
4952 (let ((types gnus-unbuttonized-mime-types))
4954 (when (string-match (pop types) type)
4955 (throw 'found t)))))
4957 (let ((types gnus-buttonized-mime-types))
4959 (when (string-match (pop types) type)
4960 (throw 'found t)))))))))
4962 (defun gnus-article-insert-newline ()
4963 "Insert a newline, but mark it as undeletable."
4964 (gnus-put-text-property
4965 (point) (progn (insert "\n") (point)) 'gnus-undeletable t))
4967 (defun gnus-mime-display-alternative (handles &optional preferred ibegend id)
4968 (let* ((preferred (or preferred (mm-preferred-alternative handles)))
4971 handle buffer-read-only from props begend not-pref)
4972 (save-window-excursion
4975 (narrow-to-region (car ibegend)
4978 (goto-char (car ibegend))
4981 (delete-region (point-min) (point-max))
4982 (mm-remove-parts handles))
4983 (setq begend (list (point-marker)))
4985 (unless (setq not-pref (cadr (member preferred ihandles)))
4986 (setq not-pref (car ihandles)))
4989 (not (gnus-unbuttonized-mime-type-p
4990 "multipart/alternative")))
4991 (gnus-add-text-properties
4994 (insert (format "%d. " id))
4998 (unless ,(not ibegend)
4999 (setq gnus-article-mime-handle-alist
5000 ',gnus-article-mime-handle-alist))
5001 (gnus-mime-display-alternative
5002 ',ihandles ',not-pref ',begend ,id))
5003 ,@(gnus-local-map-property gnus-mime-button-map)
5004 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5005 face ,gnus-article-button-face
5008 (widget-convert-button 'link from (point)
5009 :action 'gnus-widget-press-button
5010 :button-keymap gnus-widget-button-keymap)
5012 (while (setq handle (pop handles))
5013 (gnus-add-text-properties
5016 (insert (format "(%c) %-18s"
5017 (if (equal handle preferred) ?* ? )
5018 (mm-handle-media-type handle)))
5022 (unless ,(not ibegend)
5023 (setq gnus-article-mime-handle-alist
5024 ',gnus-article-mime-handle-alist))
5025 (gnus-mime-display-alternative
5026 ',ihandles ',handle ',begend ,id))
5027 ,@(gnus-local-map-property gnus-mime-button-map)
5028 ,gnus-mouse-face-prop ,gnus-article-mouse-face
5029 face ,gnus-article-button-face
5032 (widget-convert-button 'link from (point)
5033 :action 'gnus-widget-press-button
5034 :button-keymap gnus-widget-button-keymap)
5038 (if (stringp (car preferred))
5039 (gnus-display-mime preferred)
5040 (let ((mail-parse-charset gnus-newsgroup-charset)
5041 (mail-parse-ignored-charsets
5042 (save-excursion (set-buffer gnus-summary-buffer)
5043 gnus-newsgroup-ignored-charsets)))
5044 (mm-display-part preferred)
5048 (narrow-to-region (car begend) (point-max))
5050 nil (length gnus-article-mime-handle-alist)
5051 (gnus-article-mime-total-parts)
5052 (mm-handle-media-type handle))))))
5053 (goto-char (point-max))
5054 (setcdr begend (point-marker)))))
5056 (goto-char point))))
5058 (defconst gnus-article-wash-status-strings
5059 (let ((alist '((cite "c" "Possible hidden citation text"
5060 " " "All citation text visible")
5061 (headers "h" "Hidden headers"
5062 " " "All headers visible.")
5063 (pgp "p" "Encrypted or signed message status hidden"
5064 " " "No hidden encryption nor digital signature status")
5065 (signature "s" "Signature has been hidden"
5066 " " "Signature is visible")
5067 (overstrike "o" "Overstrike (^H) characters applied"
5068 " " "No overstrike characters applied")
5069 (gnus-show-mime "m" "Mime processing is activated"
5070 " " "Mime processing is not activated")
5071 (emphasis "e" "/*_Emphasis_*/ characters applied"
5072 " " "No /*_emphasis_*/ characters applied")))
5074 (dolist (entry alist result)
5075 (let ((key (nth 0 entry))
5076 (on (copy-sequence (nth 1 entry)))
5077 (on-help (nth 2 entry))
5078 (off (copy-sequence (nth 3 entry)))
5079 (off-help (nth 4 entry)))
5080 (put-text-property 0 1 'help-echo on-help on)
5081 (put-text-property 0 1 'help-echo off-help off)
5082 (push (list key on off) result))))
5083 "Alist of strings describing wash status in the mode line.
5084 Each entry has the form (KEY ON OF), where the KEY is a symbol
5085 representing the particular washing function, ON is the string to use
5086 in the article mode line when the washing function is active, and OFF
5087 is the string to use when it is inactive.")
5089 (defun gnus-article-wash-status-entry (key value)
5090 (let ((entry (assoc key gnus-article-wash-status-strings)))
5091 (if value (nth 1 entry) (nth 2 entry))))
5093 (defun gnus-article-wash-status ()
5094 "Return a string which display status of article washing."
5096 (set-buffer gnus-article-buffer)
5097 (let ((cite (memq 'cite gnus-article-wash-types))
5098 (headers (memq 'headers gnus-article-wash-types))
5099 (boring (memq 'boring-headers gnus-article-wash-types))
5100 (pgp (memq 'pgp gnus-article-wash-types))
5101 (pem (memq 'pem gnus-article-wash-types))
5102 (signed (memq 'signed gnus-article-wash-types))
5103 (encrypted (memq 'encrypted gnus-article-wash-types))
5104 (signature (memq 'signature gnus-article-wash-types))
5105 (overstrike (memq 'overstrike gnus-article-wash-types))
5106 (emphasis (memq 'emphasis gnus-article-wash-types)))
5108 (gnus-article-wash-status-entry 'cite cite)
5109 (gnus-article-wash-status-entry 'headers (or headers boring))
5110 (gnus-article-wash-status-entry 'pgp (or pgp pem signed encrypted))
5111 (gnus-article-wash-status-entry 'signature signature)
5112 (gnus-article-wash-status-entry 'overstrike overstrike)
5113 (gnus-article-wash-status-entry 'gnus-show-mime gnus-show-mime)
5114 (gnus-article-wash-status-entry 'emphasis emphasis)))))
5116 (defun gnus-add-wash-type (type)
5117 "Add a washing of TYPE to the current status."
5118 (add-to-list 'gnus-article-wash-types type))
5120 (defun gnus-delete-wash-type (type)
5121 "Add a washing of TYPE to the current status."
5122 (setq gnus-article-wash-types (delq type gnus-article-wash-types)))
5124 (defun gnus-add-image (category image)
5125 "Add IMAGE of CATEGORY to the list of displayed images."
5126 (let ((entry (assq category gnus-article-image-alist)))
5128 (setq entry (list category))
5129 (push entry gnus-article-image-alist))
5130 (nconc entry (list image))))
5132 (defun gnus-delete-images (category)
5133 "Delete all images in CATEGORY."
5134 (let ((entry (assq category gnus-article-image-alist)))
5135 (dolist (image (cdr entry))
5136 (gnus-remove-image image))
5137 (setq gnus-article-image-alist (delq entry gnus-article-image-alist))
5138 (gnus-delete-wash-type category)))
5140 (defalias 'gnus-article-hide-headers-if-wanted 'gnus-article-maybe-hide-headers)
5142 (defun gnus-article-maybe-hide-headers ()
5143 "Hide unwanted headers if `gnus-have-all-headers' is nil.
5144 Provided for backwards compatibility."
5145 (when (and (or (not (gnus-buffer-live-p gnus-summary-buffer))
5146 (not (save-excursion (set-buffer gnus-summary-buffer)
5147 gnus-have-all-headers)))
5148 (not gnus-inhibit-hiding))
5149 (gnus-article-hide-headers)))
5153 (defun gnus-output-to-file (file-name)
5154 "Append the current article to a file named FILE-NAME."
5155 (let ((artbuf (current-buffer)))
5157 (insert-buffer-substring artbuf)
5158 ;; Append newline at end of the buffer as separator, and then
5160 (goto-char (point-max))
5162 (let ((file-name-coding-system nnmail-pathname-coding-system)
5163 (pathname-coding-system nnmail-pathname-coding-system))
5164 (write-region-as-binary (point-min) (point-max) file-name 'append))
5167 (defun gnus-narrow-to-page (&optional arg)
5168 "Narrow the article buffer to a page.
5169 If given a numerical ARG, move forward ARG pages."
5171 (setq arg (if arg (prefix-numeric-value arg) 0))
5173 (set-buffer gnus-article-buffer)
5174 (goto-char (point-min))
5176 ;; Remove any old next/prev buttons.
5177 (when (gnus-visual-p 'page-marker)
5178 (let ((buffer-read-only nil))
5179 (gnus-remove-text-with-property 'gnus-prev)
5180 (gnus-remove-text-with-property 'gnus-next)))
5183 (re-search-backward page-delimiter nil 'move (1+ (abs arg))))
5185 (re-search-forward page-delimiter nil 'move arg)))
5186 (goto-char (match-end 0)))
5189 (if (re-search-forward page-delimiter nil 'move)
5192 (when (and (gnus-visual-p 'page-marker)
5193 (not (= (point-min) 1)))
5195 (goto-char (point-min))
5196 (gnus-insert-prev-page-button)))
5197 (when (and (gnus-visual-p 'page-marker)
5198 (< (+ (point-max) 2) (buffer-size)))
5200 (goto-char (point-max))
5201 (gnus-insert-next-page-button)))))
5203 ;; Article mode commands
5205 (defun gnus-article-goto-next-page ()
5206 "Show the next page of the article."
5208 (gnus-eval-in-buffer-window gnus-summary-buffer
5209 (gnus-summary-next-page)))
5211 (defun gnus-article-goto-prev-page ()
5212 "Show the next page of the article."
5214 (gnus-eval-in-buffer-window gnus-summary-buffer
5215 (gnus-summary-prev-page)))
5217 (defun gnus-article-next-page (&optional lines)
5218 "Show the next page of the current article.
5219 If end of article, return non-nil. Otherwise return nil.
5220 Argument LINES specifies lines to be scrolled up."
5222 (let ((start (window-start))
5223 end-of-buffer end-of-page)
5225 (move-to-window-line -1)
5226 (if (<= (point) start)
5229 (setq start (point)))
5232 (unless (or (cond ((eq (1+ (buffer-size)) (point))
5233 (and (pos-visible-in-window-p)
5234 (setq end-of-buffer t)))
5236 (setq end-of-page t)))
5238 (move-to-window-line lines)
5239 (unless (search-backward "\n\n" nil t)
5240 (setq start (point)))))
5241 (cond (end-of-buffer t)
5243 (gnus-narrow-to-page 1)
5247 (set-window-start (selected-window) start)
5248 (let (window-pixel-scroll-increment)
5252 (defun gnus-article-prev-page (&optional lines)
5253 "Show previous page of current article.
5254 Argument LINES specifies lines to be scrolled down."
5256 (let (beginning-of-buffer beginning-of-page)
5258 (move-to-window-line 0)
5259 (cond ((eq 1 (point))
5260 (setq beginning-of-buffer t))
5262 (setq beginning-of-page t))))
5263 (cond (beginning-of-buffer)
5265 (gnus-narrow-to-page -1))
5268 (let (window-pixel-scroll-increment)
5269 (scroll-down lines))
5270 (beginning-of-buffer
5271 (goto-char (point-min))))))))
5273 (defun gnus-article-only-boring-p ()
5274 "Decide whether there is only boring text remaining in the article.
5275 Something \"interesting\" is a word of at least two letters that does
5276 not have a face in `gnus-article-boring-faces'."
5277 (when (and gnus-article-skip-boring
5278 (boundp 'gnus-article-boring-faces)
5279 (symbol-value 'gnus-article-boring-faces))
5282 (while (re-search-forward "\\b\\w\\w" nil t)
5284 (when (not (gnus-intersection
5285 (gnus-faces-at (point))
5286 (symbol-value 'gnus-article-boring-faces)))
5287 (throw 'only-boring nil)))
5288 (throw 'only-boring t)))))
5290 (defun gnus-article-refer-article ()
5291 "Read article specified by message-id around point."
5294 (re-search-backward "[ \t]\\|^" (gnus-point-at-bol) t)
5295 (re-search-forward "<?news:<?\\|<" (gnus-point-at-eol) t)
5296 (if (re-search-forward "[^@ ]+@[^ \t>]+" (gnus-point-at-eol) t)
5297 (let ((msg-id (concat "<" (match-string 0) ">")))
5298 (set-buffer gnus-summary-buffer)
5299 (gnus-summary-refer-article msg-id))
5300 (error "No references around point"))))
5302 (defun gnus-article-show-summary ()
5303 "Reconfigure windows to show summary buffer."
5305 (if (not (gnus-buffer-live-p gnus-summary-buffer))
5306 (error "There is no summary buffer for this article buffer")
5307 (gnus-article-set-globals)
5308 (gnus-configure-windows 'article)
5309 (gnus-summary-goto-subject gnus-current-article)
5310 (gnus-summary-position-point)))
5312 (defun gnus-article-describe-briefly ()
5313 "Describe article mode commands briefly."
5315 (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")))
5317 (defun gnus-article-summary-command ()
5318 "Execute the last keystroke in the summary buffer."
5320 (let ((obuf (current-buffer))
5321 (owin (current-window-configuration))
5323 (switch-to-buffer gnus-article-current-summary 'norecord)
5324 (setq func (lookup-key (current-local-map) (this-command-keys)))
5325 (call-interactively func)
5327 (set-window-configuration owin)
5328 (set-window-point (get-buffer-window (current-buffer)) (point))))
5330 (defun gnus-article-summary-command-nosave ()
5331 "Execute the last keystroke in the summary buffer."
5334 (pop-to-buffer gnus-article-current-summary 'norecord)
5335 (setq func (lookup-key (current-local-map) (this-command-keys)))
5336 (call-interactively func)))
5338 (defun gnus-article-check-buffer ()
5339 "Beep if not in an article buffer."
5340 (unless (eq (get-buffer gnus-article-buffer) (current-buffer))
5341 (error "Command invoked outside of a Gnus article buffer")))
5343 (defun gnus-article-read-summary-keys (&optional arg key not-restore-window)
5344 "Read a summary buffer key sequence and execute it from the article buffer."
5346 (gnus-article-check-buffer)
5348 '("q" "Q" "c" "r" "\C-c\C-f" "m" "a" "f"
5349 "Zc" "ZC" "ZE" "ZJ" "ZQ" "ZZ" "Zn" "ZR" "ZG" "ZN" "ZP"
5350 "=" "^" "\M-^" "|"))
5356 '("n" "Gn" "p" "Gp"))
5359 (set-buffer gnus-article-current-summary)
5360 (let (gnus-pick-mode)
5361 (push (or key last-command-event) unread-command-events)
5362 (setq keys (static-if (featurep 'xemacs)
5363 (events-to-keys (read-key-sequence nil))
5364 (read-key-sequence nil)))))
5367 (if (or (member keys nosaves)
5368 (member keys nosave-but-article)
5369 (member keys nosave-in-article))
5371 (save-window-excursion
5372 (pop-to-buffer gnus-article-current-summary 'norecord)
5373 ;; We disable the pick minor mode commands.
5374 (let (gnus-pick-mode)
5375 (setq func (lookup-key (current-local-map) keys))))
5379 (unless (member keys nosave-in-article)
5380 (set-buffer gnus-article-current-summary))
5381 (call-interactively func)
5382 (setq new-sum-point (point)))
5383 (when (member keys nosave-but-article)
5384 (pop-to-buffer gnus-article-buffer 'norecord)))
5385 ;; These commands should restore window configuration.
5386 (let ((obuf (current-buffer))
5387 (owin (current-window-configuration))
5389 (summary gnus-article-current-summary)
5390 func in-buffer selected)
5391 (if not-restore-window
5392 (pop-to-buffer summary 'norecord)
5393 (switch-to-buffer summary 'norecord))
5394 (setq in-buffer (current-buffer))
5395 ;; We disable the pick minor mode commands.
5396 (if (and (setq func (let (gnus-pick-mode)
5397 (lookup-key (current-local-map) keys)))
5400 (call-interactively func)
5401 (setq new-sum-point (point))
5402 (when (eq in-buffer (current-buffer))
5403 (setq selected (gnus-summary-select-article))
5405 (unless not-restore-window
5406 (set-window-configuration owin))
5407 (when (eq selected 'old)
5409 (set-window-start (get-buffer-window (current-buffer))
5411 (set-window-point (get-buffer-window (current-buffer))
5413 (let ((win (get-buffer-window gnus-article-current-summary)))
5415 (set-window-point win new-sum-point)))) )
5416 (switch-to-buffer gnus-article-buffer)
5419 (defun gnus-article-describe-key (key)
5420 "Display documentation of the function invoked by KEY. KEY is a string."
5421 (interactive "kDescribe key: ")
5422 (gnus-article-check-buffer)
5423 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5425 (set-buffer gnus-article-current-summary)
5426 (let (gnus-pick-mode)
5427 (if (featurep 'xemacs)
5429 (push (elt key 0) unread-command-events)
5430 (setq key (events-to-keys
5431 (read-key-sequence "Describe key: "))))
5432 (setq unread-command-events
5434 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5436 (setq key (read-key-sequence "Describe key: "))))
5438 (describe-key key)))
5440 (defun gnus-article-describe-key-briefly (key &optional insert)
5441 "Display documentation of the function invoked by KEY. KEY is a string."
5442 (interactive "kDescribe key: \nP")
5443 (gnus-article-check-buffer)
5444 (if (eq (key-binding key) 'gnus-article-read-summary-keys)
5446 (set-buffer gnus-article-current-summary)
5447 (let (gnus-pick-mode)
5448 (if (featurep 'xemacs)
5450 (push (elt key 0) unread-command-events)
5451 (setq key (events-to-keys
5452 (read-key-sequence "Describe key: "))))
5453 (setq unread-command-events
5455 (lambda (x) (if (>= x 128) (list 'meta (- x 128)) x))
5457 (setq key (read-key-sequence "Describe key: "))))
5458 (describe-key-briefly key insert))
5459 (describe-key-briefly key insert)))
5461 (defun gnus-article-reply-with-original (&optional wide)
5462 "Start composing a reply mail to the current message.
5463 The text in the region will be yanked. If the region isn't active,
5464 the entire article will be yanked."
5466 (let ((article (cdr gnus-article-current))
5468 (if (not (gnus-mark-active-p))
5469 (with-current-buffer gnus-summary-buffer
5470 (gnus-summary-reply (list (list article)) wide))
5471 (setq contents (buffer-substring (point) (mark t)))
5472 ;; Deactivate active regions.
5473 (when (and (boundp 'transient-mark-mode)
5474 transient-mark-mode)
5475 (setq mark-active nil))
5476 (with-current-buffer gnus-summary-buffer
5478 (list (list article contents)) wide)))))
5480 (defun gnus-article-followup-with-original ()
5481 "Compose a followup to the current article.
5482 The text in the region will be yanked. If the region isn't active,
5483 the entire article will be yanked."
5485 (let ((article (cdr gnus-article-current))
5487 (if (not (gnus-mark-active-p))
5488 (with-current-buffer gnus-summary-buffer
5489 (gnus-summary-followup (list (list article))))
5490 (setq contents (buffer-substring (point) (mark t)))
5491 ;; Deactivate active regions.
5492 (when (and (boundp 'transient-mark-mode)
5493 transient-mark-mode)
5494 (setq mark-active nil))
5495 (with-current-buffer gnus-summary-buffer
5496 (gnus-summary-followup
5497 (list (list article contents)))))))
5499 (defun gnus-article-hide (&optional arg force)
5500 "Hide all the gruft in the current article.
5501 This means that signatures, cited text and (some) headers will be
5503 If given a prefix, show the hidden text instead."
5504 (interactive (append (gnus-article-hidden-arg) (list 'force)))
5505 (gnus-article-hide-headers arg)
5506 (gnus-article-hide-list-identifiers arg)
5507 (gnus-article-hide-citation-maybe arg force)
5508 (gnus-article-hide-signature arg))
5510 (defun gnus-article-maybe-highlight ()
5511 "Do some article highlighting if article highlighting is requested."
5512 (when (gnus-visual-p 'article-highlight 'highlight)
5513 (gnus-article-highlight-some)))
5515 (defun gnus-check-group-server ()
5516 ;; Make sure the connection to the server is alive.
5517 (unless (gnus-server-opened
5518 (gnus-find-method-for-group gnus-newsgroup-name))
5519 (gnus-check-server (gnus-find-method-for-group gnus-newsgroup-name))
5520 (gnus-request-group gnus-newsgroup-name t)))
5523 (autoload 'nneething-get-file-name "nneething"))
5525 (defun gnus-request-article-this-buffer (article group)
5526 "Get an article and insert it into this buffer."
5527 (let (do-update-line sparse-header)
5531 (gnus-kill-all-overlays)
5532 (setq group (or group gnus-newsgroup-name))
5534 ;; Using `gnus-request-article' directly will insert the article into
5535 ;; `nntp-server-buffer' - so we'll save some time by not having to
5536 ;; copy it from the server buffer into the article buffer.
5538 ;; We only request an article by message-id when we do not have the
5539 ;; headers for it, so we'll have to get those.
5540 (when (stringp article)
5541 (gnus-read-header article))
5543 ;; If the article number is negative, that means that this article
5544 ;; doesn't belong in this newsgroup (possibly), so we find its
5545 ;; message-id and request it by id instead of number.
5546 (when (and (numberp article)
5548 (get-buffer gnus-summary-buffer)
5549 (gnus-buffer-exists-p gnus-summary-buffer))
5551 (set-buffer gnus-summary-buffer)
5552 (let ((header (gnus-summary-article-header article)))
5555 ((memq article gnus-newsgroup-sparse)
5556 ;; This is a sparse gap article.
5557 (setq do-update-line article)
5558 (setq article (mail-header-id header))
5559 (setq sparse-header (gnus-read-header article))
5560 (setq gnus-newsgroup-sparse
5561 (delq article gnus-newsgroup-sparse)))
5563 ;; It's a real article.
5564 (setq article (mail-header-id header)))
5566 ;; It is an extracted pseudo-article.
5567 (setq article 'pseudo)
5568 (gnus-request-pseudo-article header))))
5570 (let ((method (gnus-find-method-for-group
5571 gnus-newsgroup-name)))
5572 (when (and (eq (car method) 'nneething)
5574 (let ((dir (nneething-get-file-name
5575 (mail-header-id header))))
5576 (when (and (stringp dir)
5577 (file-directory-p dir))
5578 (setq article 'nneething)
5579 (gnus-group-enter-directory dir))))))))
5582 ;; Refuse to select canceled articles.
5583 ((and (numberp article)
5585 (get-buffer gnus-summary-buffer)
5586 (gnus-buffer-exists-p gnus-summary-buffer)
5587 (eq (cdr (save-excursion
5588 (set-buffer gnus-summary-buffer)
5589 (assq article gnus-newsgroup-reads)))
5590 gnus-canceled-mark))
5592 ;; We first check `gnus-original-article-buffer'.
5593 ((and (get-buffer gnus-original-article-buffer)
5596 (set-buffer gnus-original-article-buffer)
5597 (and (equal (car gnus-original-article) group)
5598 (eq (cdr gnus-original-article) article))))
5599 (insert-buffer-substring gnus-original-article-buffer)
5601 ;; Check the backlog.
5602 ((and gnus-keep-backlog
5603 (gnus-backlog-request-article group article (current-buffer)))
5605 ;; Check asynchronous pre-fetch.
5606 ((gnus-async-request-fetched-article group article (current-buffer))
5607 (gnus-async-prefetch-next group article gnus-summary-buffer)
5608 (when (and (numberp article) gnus-keep-backlog)
5609 (gnus-backlog-enter-article group article (current-buffer)))
5612 ((and gnus-use-cache
5614 (gnus-cache-request-article article group))
5616 ;; Check the agent cache.
5617 ((gnus-agent-request-article article group)
5619 ;; Get the article and put into the article buffer.
5620 ((or (stringp article)
5622 (let ((gnus-override-method gnus-override-method)
5623 (methods (and (stringp article)
5624 gnus-refer-article-method))
5625 (backend (car (gnus-find-method-for-group
5626 gnus-newsgroup-name)))
5628 (buffer-read-only nil))
5629 (if (or (not (listp methods))
5630 (and (symbolp (car methods))
5631 (assq (car methods) nnoo-definition-alist)))
5632 (setq methods (list methods)))
5633 (when (and (null gnus-override-method)
5635 (setq gnus-override-method (pop methods)))
5637 (when (eq gnus-override-method 'current)
5638 (setq gnus-override-method
5639 (with-current-buffer gnus-summary-buffer
5640 gnus-current-select-method)))
5642 (gnus-kill-all-overlays)
5643 (let ((gnus-newsgroup-name group))
5644 (gnus-check-group-server))
5646 ((gnus-request-article article group (current-buffer))
5647 (when (numberp article)
5648 (gnus-async-prefetch-next group article
5649 gnus-summary-buffer)
5650 (when gnus-keep-backlog
5651 (gnus-backlog-enter-article
5652 group article (current-buffer))))
5653 (setq result 'article))
5655 (setq gnus-override-method (pop methods)))
5656 ((not (string-match "^400 "
5657 (nnheader-get-report backend)))
5658 ;; If we get 400 server disconnect, reconnect and
5659 ;; retry; otherwise, assume the article has expired.
5660 (setq result 'done))))
5661 (and (eq result 'article) 'article)))
5665 ;; Associate this article with the current summary buffer.
5666 (setq gnus-article-current-summary gnus-summary-buffer)
5668 ;; Take the article from the original article buffer
5669 ;; and place it in the buffer it's supposed to be in.
5670 (when (and (get-buffer gnus-article-buffer)
5671 (equal (buffer-name (current-buffer))
5672 (buffer-name (get-buffer gnus-article-buffer))))
5674 (if (get-buffer gnus-original-article-buffer)
5675 (set-buffer gnus-original-article-buffer)
5676 (set-buffer (gnus-get-buffer-create gnus-original-article-buffer))
5677 (buffer-disable-undo)
5678 (setq major-mode 'gnus-original-article-mode)
5679 (setq buffer-read-only t))
5680 (let (buffer-read-only)
5682 (insert-buffer-substring gnus-article-buffer))
5683 (setq gnus-original-article (cons group article)))
5686 (run-hooks 'gnus-article-decode-hook)
5687 ;; Mark article as decoded or not.
5688 (setq gnus-article-decoded-p gnus-article-decode-hook))
5690 ;; Update sparse articles.
5691 (when (and do-update-line
5692 (or (numberp article)
5694 (let ((buf (current-buffer)))
5695 (set-buffer gnus-summary-buffer)
5696 (gnus-summary-update-article do-update-line sparse-header)
5697 (gnus-summary-goto-subject do-update-line nil t)
5698 (set-window-point (gnus-get-buffer-window (current-buffer) t)
5700 (set-buffer buf))))))
5706 (defcustom gnus-article-edit-mode-hook nil
5707 "Hook run in article edit mode buffers."
5708 :group 'gnus-article-various
5711 (defcustom gnus-article-edit-article-setup-function
5712 'gnus-article-mime-edit-article-setup
5713 "Function called to setup an editing article buffer."
5714 :group 'gnus-article-various
5717 (defvar gnus-article-edit-done-function nil)
5719 (defvar gnus-article-edit-mode-map nil)
5720 (defvar gnus-article-edit-mode nil)
5722 ;; Should we be using derived.el for this?
5723 (unless gnus-article-edit-mode-map
5724 (setq gnus-article-edit-mode-map (make-keymap))
5725 (set-keymap-parent gnus-article-edit-mode-map text-mode-map)
5727 (gnus-define-keys gnus-article-edit-mode-map
5728 "\C-c?" describe-mode
5729 "\C-c\C-c" gnus-article-edit-done
5730 "\C-c\C-k" gnus-article-edit-exit
5731 "\C-c\C-f\C-t" message-goto-to
5732 "\C-c\C-f\C-o" message-goto-from
5733 "\C-c\C-f\C-b" message-goto-bcc
5734 ;;"\C-c\C-f\C-w" message-goto-fcc
5735 "\C-c\C-f\C-c" message-goto-cc
5736 "\C-c\C-f\C-s" message-goto-subject
5737 "\C-c\C-f\C-r" message-goto-reply-to
5738 "\C-c\C-f\C-n" message-goto-newsgroups
5739 "\C-c\C-f\C-d" message-goto-distribution
5740 "\C-c\C-f\C-f" message-goto-followup-to
5741 "\C-c\C-f\C-m" message-goto-mail-followup-to
5742 "\C-c\C-f\C-k" message-goto-keywords
5743 "\C-c\C-f\C-u" message-goto-summary
5744 "\C-c\C-f\C-i" message-insert-or-toggle-importance
5745 "\C-c\C-f\C-a" message-generate-unsubscribed-mail-followup-to
5746 "\C-c\C-b" message-goto-body
5747 "\C-c\C-i" message-goto-signature
5749 "\C-c\C-t" message-insert-to
5750 "\C-c\C-n" message-insert-newsgroups
5751 "\C-c\C-o" message-sort-headers
5752 "\C-c\C-e" message-elide-region
5753 "\C-c\C-v" message-delete-not-region
5754 "\C-c\C-z" message-kill-to-signature
5755 "\M-\r" message-newline-and-reformat
5756 "\C-c\C-a" mml-attach-file
5757 "\C-a" message-beginning-of-line
5759 "\M-;" comment-region)
5761 (gnus-define-keys (gnus-article-edit-wash-map
5762 "\C-c\C-w" gnus-article-edit-mode-map)
5763 "f" gnus-article-edit-full-stops))
5766 gnus-article-edit-mode-field-menu gnus-article-edit-mode-map ""
5768 ["Fetch To" message-insert-to t]
5769 ["Fetch Newsgroups" message-insert-newsgroups t]
5771 ["To" message-goto-to t]
5772 ["From" message-goto-from t]
5773 ["Subject" message-goto-subject t]
5774 ["Cc" message-goto-cc t]
5775 ["Reply-To" message-goto-reply-to t]
5776 ["Summary" message-goto-summary t]
5777 ["Keywords" message-goto-keywords t]
5778 ["Newsgroups" message-goto-newsgroups t]
5779 ["Followup-To" message-goto-followup-to t]
5780 ["Mail-Followup-To" message-goto-mail-followup-to t]
5781 ["Distribution" message-goto-distribution t]
5782 ["Body" message-goto-body t]
5783 ["Signature" message-goto-signature t]))
5785 (define-derived-mode gnus-article-edit-mode text-mode "Article Edit"
5786 "Major mode for editing articles.
5787 This is an extended text-mode.
5789 \\{gnus-article-edit-mode-map}"
5790 (make-local-variable 'gnus-article-edit-done-function)
5791 (make-local-variable 'gnus-prev-winconf)
5792 (set (make-local-variable 'font-lock-defaults)
5793 '(message-font-lock-keywords t))
5794 (set (make-local-variable 'mail-header-separator) "")
5795 (set (make-local-variable 'gnus-article-edit-mode) t)
5796 (easy-menu-add message-mode-field-menu message-mode-map)
5797 (setq buffer-read-only nil)
5798 (buffer-enable-undo)
5801 (defun gnus-article-edit (&optional force)
5802 "Edit the current article.
5803 This will have permanent effect only in mail groups.
5804 If FORCE is non-nil, allow editing of articles even in read-only
5807 (when (and (not force)
5808 (gnus-group-read-only-p))
5809 (error "The current newsgroup does not support article editing"))
5810 (gnus-article-date-original)
5811 (gnus-article-edit-article
5813 `(lambda (no-highlight)
5815 (gnus-summary-edit-article-done
5816 ,(or (mail-header-references gnus-current-headers) "")
5817 ,(gnus-group-read-only-p) ,gnus-summary-buffer no-highlight))))
5819 (defun gnus-article-edit-article (start-func exit-func)
5820 "Start editing the contents of the current article buffer."
5821 (let ((winconf (current-window-configuration)))
5822 (set-buffer gnus-article-buffer)
5823 (gnus-article-edit-mode)
5824 (funcall start-func)
5825 (set-buffer-modified-p nil)
5826 (gnus-configure-windows 'edit-article)
5827 (setq gnus-article-edit-done-function exit-func)
5828 (setq gnus-prev-winconf winconf)
5829 (when gnus-article-edit-article-setup-function
5830 (funcall gnus-article-edit-article-setup-function))
5831 (gnus-message 6 "C-c C-c to end edits; C-c C-k to exit")))
5833 (defun gnus-article-edit-done (&optional arg)
5834 "Update the article edits and exit."
5836 (let ((func gnus-article-edit-done-function)
5837 (buf (current-buffer))
5838 (start (window-start))
5840 (winconf gnus-prev-winconf))
5841 (remove-hook 'gnus-article-mode-hook
5842 'gnus-article-mime-edit-article-unwind)
5843 (widen) ;; Widen it in case that users narrowed the buffer.
5846 ;; The cache and backlog have to be flushed somewhat.
5847 (when gnus-keep-backlog
5848 (gnus-backlog-remove-article
5849 (car gnus-article-current) (cdr gnus-article-current)))
5850 ;; Flush original article as well.
5852 (when (get-buffer gnus-original-article-buffer)
5853 (set-buffer gnus-original-article-buffer)
5854 (setq gnus-original-article nil)))
5855 (when gnus-use-cache
5856 (gnus-cache-update-article
5857 (car gnus-article-current) (cdr gnus-article-current)))
5858 ;; We remove all text props from the article buffer.
5859 (kill-all-local-variables)
5860 (gnus-set-text-properties (point-min) (point-max) nil)
5862 (set-window-configuration winconf)
5864 (set-window-start (get-buffer-window buf) start)
5865 (set-window-point (get-buffer-window buf) (point))))
5867 (defun gnus-article-edit-exit ()
5868 "Exit the article editing without updating."
5870 (when (or (not (buffer-modified-p))
5871 (yes-or-no-p "Article modified; kill anyway? "))
5872 (let ((curbuf (current-buffer))
5874 (window-start (window-start)))
5876 (if (gnus-buffer-live-p gnus-original-article-buffer)
5877 (insert-buffer-substring gnus-original-article-buffer))
5878 (let ((winconf gnus-prev-winconf))
5879 (kill-all-local-variables)
5881 (set-window-configuration winconf)
5882 ;; Tippy-toe some to make sure that point remains where it was.
5883 (save-current-buffer
5885 (set-window-start (get-buffer-window (current-buffer)) window-start)
5888 (defun gnus-article-edit-full-stops ()
5889 "Interactively repair spacing at end of sentences."
5892 (goto-char (point-min))
5893 (search-forward-regexp "^$" nil t)
5894 (let ((case-fold-search nil))
5895 (query-replace-regexp "\\([.!?][])}]* \\)\\([[({A-Z]\\)" "\\1 \\2"))))
5898 ;;; Article editing with MIME-Edit
5901 (defcustom gnus-article-mime-edit-article-setup-hook nil
5902 "Hook run after setting up a MIME editing article buffer."
5903 :group 'gnus-article-various
5906 (defun gnus-article-mime-edit-article-unwind ()
5907 "Unwind `gnus-article-buffer' if article editing was given up."
5908 (remove-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
5909 (when (featurep 'font-lock)
5910 (setq font-lock-defaults nil)
5911 (font-lock-mode -1))
5912 (when mime-edit-mode-flag
5913 (mime-edit-exit 'nomime 'no-error)
5916 (defun gnus-article-mime-edit-article-setup ()
5917 "Convert current buffer to MIME-Edit buffer and turn on MIME-Edit mode
5918 after replacing with the original article."
5919 (setq gnus-show-mime t)
5920 (setq gnus-article-edit-done-function
5921 `(lambda (&rest args)
5922 (when mime-edit-mode-flag
5923 (let (mime-edit-insert-user-agent-field)
5926 (goto-char (point-min))
5927 (let (case-fold-search)
5928 (when (re-search-forward
5929 (format "^%s$" (regexp-quote mail-header-separator))
5931 (replace-match "")))
5932 (apply ,gnus-article-edit-done-function args)
5935 (buffer-substring-no-properties (point-min) (point-max))
5936 (set-buffer (get-buffer-create gnus-original-article-buffer))
5938 (setq gnus-current-headers (gnus-article-make-full-mail-header))
5939 (set-buffer gnus-article-buffer)
5940 (gnus-article-prepare-display)))
5941 (substitute-key-definition 'gnus-article-edit-done
5942 'gnus-article-mime-edit-done
5943 gnus-article-edit-mode-map)
5944 (substitute-key-definition 'gnus-article-edit-exit
5945 'gnus-article-mime-edit-exit
5946 gnus-article-edit-mode-map)
5948 (insert-buffer-substring gnus-original-article-buffer)
5949 (unless (member (with-current-buffer gnus-summary-buffer
5950 gnus-newsgroup-name)
5951 '("nndraft:delayed" "nndraft:drafts"))
5952 (let ((ofn (symbol-function 'mime-edit-decode-single-part-in-buffer)))
5953 (fset 'mime-edit-decode-single-part-in-buffer
5954 (lambda (&rest args)
5955 (if (let ((content-type (car args)))
5956 (and (eq 'message (mime-content-type-primary-type
5958 (eq 'rfc822 (mime-content-type-subtype
5960 (setcar (cdr args) 'not-decode-text))
5964 (fset 'mime-edit-decode-single-part-in-buffer ofn))))
5965 (when (featurep 'font-lock)
5966 (set (make-local-variable 'font-lock-defaults)
5967 '(message-font-lock-keywords t))
5968 (font-lock-set-defaults)
5969 (turn-on-font-lock))
5970 (set-buffer-modified-p nil)
5971 (delete-other-windows)
5972 (add-hook 'gnus-article-mode-hook 'gnus-article-mime-edit-article-unwind)
5973 (gnus-run-hooks 'gnus-article-mime-edit-article-setup-hook))
5975 (defun gnus-article-mime-edit-done (&optional arg)
5976 "Update the article MIME edits and exit."
5978 (when (featurep 'font-lock)
5979 (setq font-lock-defaults nil)
5980 (font-lock-mode -1))
5981 (let ((inhibit-read-only t))
5982 (gnus-article-edit-done arg)))
5984 (defun gnus-article-mime-edit-exit ()
5985 "Exit the article MIME editing without updating."
5987 (when (or (not (buffer-modified-p))
5988 (yes-or-no-p "Article modified; kill anyway? "))
5989 (when (featurep 'font-lock)
5990 (setq font-lock-defaults nil)
5991 (font-lock-mode -1))
5992 (when mime-edit-mode-flag
5993 (let (mime-edit-insert-user-agent-field)
5996 (goto-char (point-min))
5997 (let (case-fold-search)
5998 (when (re-search-forward
5999 (format "^%s$" (regexp-quote mail-header-separator)) nil t)
6000 (replace-match "")))
6001 (let ((winconf gnus-prev-winconf))
6003 (buffer-substring-no-properties (point-min) (point-max))
6004 (set-buffer (get-buffer-create gnus-original-article-buffer))
6006 (setq gnus-current-headers (gnus-article-make-full-mail-header))
6007 (set-buffer gnus-article-buffer)
6008 (gnus-article-prepare-display)
6009 (set-window-configuration winconf))))
6012 ;;; Article highlights
6015 ;; Written by Per Abrahamsen <abraham@iesd.auc.dk>.
6017 ;;; Internal Variables:
6019 (defcustom gnus-button-url-regexp
6020 (if (string-match "[[:digit:]]" "1") ;; support POSIX?
6021 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-z0-9_.]+:[0-9]*\\)?[-a-z0-9_=!?#$@~%&*+\\/:;.,[:word:]]+[-a-z0-9_=#$@~%&*+\\/[:word:]]\\)"
6022 "\\b\\(\\(www\\.\\|\\(s?https?\\|ftp\\|file\\|gopher\\|news\\|telnet\\|wais\\|mailto\\|info\\):\\)\\(//[-a-z0-9_.]+:[0-9]*\\)?\\([-a-z0-9_=!?#$@~%&*+\\/:;.,]\\|\\w\\)+\\([-a-z0-9_=#$@~%&*+\\/]\\|\\w\\)\\)")
6023 "Regular expression that matches URLs."
6024 :group 'gnus-article-buttons
6027 (defcustom gnus-button-valid-fqdn-regexp
6028 (concat "[a-z0-9][-.a-z0-9]+\\." ;; [hostname.subdomain.]domain.
6030 "\\([a-z][a-z]" ;; two letter country TDLs
6031 "\\|biz\\|com\\|edu\\|gov\\|int\\|mil\\|net\\|org"
6032 "\\|aero\\|coop\\|info\\|name\\|museum"
6033 "\\|arpa\\|pro\\|uucp\\|bitnet\\|bofh" ;; old style?
6035 "Regular expression that matches a valid FQDN."
6036 :group 'gnus-article-buttons
6039 (defcustom gnus-button-man-handler 'manual-entry
6040 "Function to use for displaying man pages.
6041 The function must take at least one argument with a string naming the
6043 :type '(choice (function-item :tag "Man" manual-entry)
6044 (function-item :tag "Woman" woman)
6045 (function :tag "Other"))
6046 :group 'gnus-article-buttons)
6048 (defcustom gnus-ctan-url "http://tug.ctan.org/tex-archive/"
6049 "Top directory of a CTAN \(Comprehensive TeX Archive Network\) archive.
6050 If the default site is too slow, try to find a CTAN mirror, see
6051 <URL:http://tug.ctan.org/tex-archive/CTAN.sites?action=/index.html>. See also
6052 the variable `gnus-button-handle-ctan'."
6053 :group 'gnus-article-buttons
6054 :link '(custom-manual "(gnus)Group Parameters")
6055 :type '(choice (const "http://www.tex.ac.uk/tex-archive/")
6056 (const "http://tug.ctan.org/tex-archive/")
6057 (const "http://www.dante.de/CTAN/")
6058 (string :tag "Other")))
6060 (defcustom gnus-button-ctan-handler 'browse-url
6061 "Function to use for displaying CTAN links.
6062 The function must take one argument, the string naming the URL."
6063 :type '(choice (function-item :tag "Browse Url" browse-url)
6064 (function :tag "Other"))
6065 :group 'gnus-article-buttons)
6067 (defcustom gnus-button-handle-ctan-bogus-regexp "^/?tex-archive/\\|^/"
6068 "Bogus strings removed from CTAN URLs."
6069 :group 'gnus-article-buttons
6070 :type '(choice (const "^/?tex-archive/\\|/")
6071 (regexp :tag "Other")))
6073 (defcustom gnus-button-mid-or-mail-regexp
6074 (concat "\\b\\(<?[a-z0-9][^<>\")!;:,{}\n\t ]*@"
6075 gnus-button-valid-fqdn-regexp
6077 "Regular expression that matches a message ID or a mail address."
6078 :group 'gnus-article-buttons
6081 (defcustom gnus-button-prefer-mid-or-mail 'gnus-button-mid-or-mail-heuristic
6082 "What to do when the button on a string as \"foo123@bar.invalid\" is pushed.
6083 Strings like this can be either a message ID or a mail address. If it is one
6084 of the symbols `mid' or `mail', Gnus will always assume that the string is a
6085 message ID or a mail address, respectivly. If this variable is set to the
6086 symbol `ask', always query the user what do do. If it is a function, this
6087 function will be called with the string as it's only argument. The function
6088 must return `mid', `mail', `invalid' or `ask'."
6089 :group 'gnus-article-buttons
6090 :type '(choice (function-item :tag "Heuristic function"
6091 gnus-button-mid-or-mail-heuristic)
6096 (defcustom gnus-button-mid-or-mail-heuristic-alist
6097 '((-10.0 . ".+\\$.+@")
6100 (-5.0 . "\\+[^+]*\\+.*@") ;; # two plus signs
6101 (-5.0 . "@[Nn][Ee][Ww][Ss]") ;; /\@news/i
6102 (-5.0 . "@.*[Dd][Ii][Aa][Ll][Uu][Pp]") ;; /\@.*dialup/i;
6103 (-1.0 . "^[^a-z]+@")
6105 (-5.0 . "\\.[0-9][0-9]+.*@") ;; "\.[0-9]{2,}.*\@"
6106 (-5.0 . "[a-z].*[A-Z].*[a-z].*[A-Z].*@") ;; "([a-z].*[A-Z].*){2,}\@"
6107 (-3.0 . "[A-Z][A-Z][a-z][a-z].*@")
6108 (-5.0 . "\\...?.?@") ;; (-5.0 . "\..{1,3}\@")
6111 (-1.0 . "^[0-9][0-9]")
6113 ;; -3.0 /^[0-9][0-9a-fA-F]{2,2}/;
6114 (-3.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6115 ;; -5.0 /^[0-9][0-9a-fA-F]{3,3}/;
6116 (-5.0 . "^[0-9][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][^0-9a-fA-F]")
6118 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][^0-9].*@") ;; "[0-9]{5,}.*\@"
6119 (-3.0 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][^0-9].*@")
6122 . "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9].*@")
6124 ;; compensation for TDMA dated mail addresses:
6125 (25.0 . "-dated-[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]+.*@")
6127 (-20.0 . "\\.fsf@") ;; Gnus
6130 (-20.0 . "_-_") ;; Subject change in thread
6132 (-20.0 . "\\.ln@") ;; leafnode
6133 (-30.0 . "@ID-[0-9]+\\.[a-zA-Z]+\\.dfncis\\.de")
6134 (-30.0 . "@4[Aa][Xx]\\.com") ;; Forte Agent
6136 ;; (5.0 . "") ;; $local_part_len <= 7
6137 (10.0 . "^[^0-9]+@")
6138 (3.0 . "^[^0-9]+[0-9][0-9]?[0-9]?@")
6139 ;; ^[^0-9]+[0-9]{1,3}\@ digits only at end of local part
6142 (2.0 . "[a-z][a-z][._-][A-Z][a-z].*@")
6144 (0.5 . "^[A-Z][a-z]")
6145 (0.5 . "^[A-Z][a-z][a-z]")
6146 (1.5 . "^[A-Z][a-z][A-Z][a-z][^a-z]") ;; ^[A-Z][a-z]{3,3}
6147 (2.0 . "^[A-Z][a-z][A-Z][a-z][a-z][^a-z]")) ;; ^[A-Z][a-z]{4,4}
6148 "An alist of \(RATE . REGEXP\) pairs for `gnus-button-mid-or-mail-heuristic'.
6150 A negative RATE indicates a message IDs, whereas a positive indicates a mail
6151 address. The REGEXP is processed with `case-fold-search' set to `nil'."
6152 :group 'gnus-article-buttons
6153 :type '(repeat (cons (number :tag "Rate")
6154 (regexp :tag "Regexp"))))
6156 (defun gnus-button-mid-or-mail-heuristic (mid-or-mail)
6157 "Guess whether MID-OR-MAIL is a message ID or a mail address.
6158 Returns `mid' if MID-OR-MAIL is a message IDs, `mail' if it's a mail
6159 address, `ask' if unsure and `invalid' if the string is invalid."
6160 (let ((case-fold-search nil)
6161 (list gnus-button-mid-or-mail-heuristic-alist)
6162 (result 0) rate regexp lpartlen elem)
6164 (length (gnus-replace-in-string mid-or-mail "^\\(.*\\)@.*$" "\\1")))
6165 (gnus-message 8 "`%s', length of local part=`%s'." mid-or-mail lpartlen)
6166 ;; Certain special cases...
6169 "^0[0-9]+-[0-9][0-9][0-9][0-9]@t-online\\.de$" "\\|"
6170 "^[0-9]+\.[0-9]+\@compuserve")
6172 (gnus-message 8 "`%s' is a known mail address.")
6173 (setq result 'mail))
6174 (when (string-match "@.*@\\| " mid-or-mail)
6175 (gnus-message 8 "`%s' is invalid.")
6176 (setq result 'invalid))
6177 ;; Nothing more to do, if result is not a number here...
6178 (when (numberp result)
6180 (setq elem (car list)
6184 (when (string-match regexp mid-or-mail)
6185 (setq result (+ result rate))
6187 9 "`%s' matched `%s', rate `%s', result `%s'."
6188 mid-or-mail regexp rate result)))
6189 (when (<= lpartlen 7)
6190 (setq result (+ result 5.0))
6191 (gnus-message 9 "`%s' matched (<= lpartlen 7), result `%s'."
6192 mid-or-mail result))
6193 (when (>= lpartlen 12)
6194 (gnus-message 9 "`%s' matched (>= lpartlen 12)" mid-or-mail)
6196 ((string-match "[0-9][^0-9]+[0-9].*@" mid-or-mail)
6197 ;; Long local part should contain realname if e-mail address,
6198 ;; too many digits: message-id.
6199 ;; $score -= 5.0 + 0.1 * $local_part_len;
6200 (setq rate (* -1.0 (+ 5.0 (* 0.1 lpartlen))))
6201 (setq result (+ result rate))
6203 9 "Many digits in `%s', rate `%s', result `%s'."
6204 mid-or-mail rate result))
6205 ((string-match "[^aeiouy][^aeiouy][^aeiouy][^aeiouy]+.*\@"
6207 ;; Too few vowels [^aeiouy]{4,}.*\@
6208 (setq result (+ result -5.0))
6210 9 "Few vowels in `%s', rate `%s', result `%s'."
6211 mid-or-mail -5.0 result))
6213 (setq result (+ result 5.0))
6215 9 "`%s', rate `%s', result `%s'." mid-or-mail 5.0 result)))))
6216 (gnus-message 8 "`%s': Final rate is `%s'." mid-or-mail result)
6218 ;; Maybe we should make this a customizable alist: (condition . 'result)
6219 ((< result -10.0) 'mid)
6220 ((> result 10.0) 'mail)
6223 (defun gnus-button-handle-mid-or-mail (mid-or-mail)
6224 (let* ((pref gnus-button-prefer-mid-or-mail) guessed
6225 (url-mid (concat "news" ":" mid-or-mail))
6226 (url-mailto (concat "mailto" ":" mid-or-mail)))
6227 (gnus-message 9 "mid-or-mail=%s" mid-or-mail)
6228 (when (fboundp pref)
6230 ;; get rid of surrounding angles...
6232 (gnus-replace-in-string mid-or-mail "^<\\|>$" "")))
6233 (if (or (eq 'mid guessed) (eq 'mail guessed))
6237 (save-window-excursion
6238 (if (y-or-n-p (concat "Is <" mid-or-mail "> a mail address? "))
6241 (cond ((eq pref 'mid)
6242 (gnus-message 8 "calling `gnus-button-handle-news' %s" url-mid)
6243 (gnus-button-handle-news url-mid))
6245 (gnus-message 8 "calling `gnus-url-mailto' %s" url-mailto)
6246 (gnus-url-mailto url-mailto))
6247 (t (gnus-message 3 "Invalid string.")))))
6249 (defun gnus-button-handle-custom (url)
6250 "Follow a Custom URL."
6251 (customize-apropos (gnus-url-unhex-string url)))
6253 (defvar gnus-button-handle-describe-prefix "^\\(C-h\\|<?[Ff]1>?\\)")
6255 (defun gnus-button-handle-describe-function (url)
6256 "Call `describe-function' when pushing the corresponding URL button."
6259 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6261 (defun gnus-button-handle-describe-variable (url)
6262 "Call `describe-variable' when pushing the corresponding URL button."
6265 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))))
6267 (defun gnus-button-handle-describe-key (url)
6268 "Call `describe-key' when pushing the corresponding URL button."
6270 (gnus-replace-in-string url gnus-button-handle-describe-prefix ""))
6271 (keys (ignore-errors (eval `(kbd ,key-string)))))
6274 (gnus-message 3 "Invalid key sequence in button: %s" key-string))))
6276 (defun gnus-button-handle-apropos (url)
6277 "Call `apropos' when pushing the corresponding URL button."
6278 (apropos (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6280 (defun gnus-button-handle-apropos-command (url)
6281 "Call `apropos' when pushing the corresponding URL button."
6283 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6285 (defun gnus-button-handle-apropos-variable (url)
6286 "Call `apropos' when pushing the corresponding URL button."
6288 (if (fboundp 'apropos-variable) 'apropos-variable 'apropos)
6289 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6291 (defun gnus-button-handle-apropos-documentation (url)
6292 "Call `apropos' when pushing the corresponding URL button."
6294 (if (fboundp 'apropos-documentation) 'apropos-documentation 'apropos)
6295 (gnus-replace-in-string url gnus-button-handle-describe-prefix "")))
6297 (defun gnus-button-handle-ctan (url)
6298 "Call `browse-url' when pushing a CTAN URL button."
6300 gnus-button-ctan-handler
6303 (gnus-replace-in-string url gnus-button-handle-ctan-bogus-regexp ""))))
6305 (defcustom gnus-button-tex-level 5
6306 "*Integer that says how many TeX-related buttons Gnus will show.
6307 The higher the number, the more buttons will appear and the more false
6308 positives are possible. Note that you can set this variable local to
6309 specifific groups. Setting it higher in TeX groups is probably a good idea.
6310 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6311 how to set variables in specific groups."
6312 :group 'gnus-article-buttons
6313 :link '(custom-manual "(gnus)Group Parameters")
6316 (defcustom gnus-button-man-level 5
6317 "*Integer that says how many man-related buttons Gnus will show.
6318 The higher the number, the more buttons will appear and the more false
6319 positives are possible. Note that you can set this variable local to
6320 specifific groups. Setting it higher in Unix groups is probably a good idea.
6321 See Info node `(gnus)Group Parameters' and the variable `gnus-parameters' on
6322 how to set variables in specific groups."
6323 :group 'gnus-article-buttons
6324 :link '(custom-manual "(gnus)Group Parameters")
6327 (defcustom gnus-button-emacs-level 5
6328 "*Integer that says how many emacs-related buttons Gnus will show.
6329 The higher the number, the more buttons will appear and the more false
6330 positives are possible. Note that you can set this variable local to
6331 specifific groups. Setting it higher in Emacs or Gnus related groups is
6332 probably a good idea. See Info node `(gnus)Group Parameters' and the variable
6333 `gnus-parameters' on how to set variables in specific groups."
6334 :group 'gnus-article-buttons
6335 :link '(custom-manual "(gnus)Group Parameters")
6338 (defcustom gnus-button-mail-level 5
6339 "*Integer that says how many buttons for message IDs or mail addresses will appear.
6340 The higher the number, the more buttons will appear and the more false
6341 positives are possible."
6342 :group 'gnus-article-buttons
6345 (defcustom gnus-button-alist
6346 '(("<\\(url:[>\n\t ]*?\\)?\\(nntp\\|news\\):[>\n\t ]*\\([^>\n\t ]*@[^>\n\t ]*\\)>"
6347 0 t gnus-button-handle-news 3)
6348 ("\\b\\(nntp\\|news\\):\\([^>\n\t ]*@[^>)!;:,\n\t ]*\\)" 0 t
6349 gnus-button-handle-news 2)
6350 ("\\(\\b<\\(url:[>\n\t ]*\\)?news:[>\n\t ]*\\(//\\)?\\([^>\n\t ]*\\)>\\)"
6352 gnus-button-fetch-group 4)
6353 ("\\bnews:\\(//\\)?\\([^'\">\n\t ]+\\)" 0 t gnus-button-fetch-group 2)
6354 ("\\bin\\( +article\\| +message\\)? +\\(<\\([^\n @<>]+@[^\n @<>]+\\)>\\)" 2
6355 t gnus-button-message-id 3)
6356 ("\\(<URL: *\\)mailto: *\\([^> \n\t]+\\)>" 0 t gnus-url-mailto 2)
6357 ("mailto:\\([-a-z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
6358 ("\\bmailto:\\([^ \n\t]+\\)" 0 t gnus-url-mailto 1)
6360 ("\\bCTAN:[ \t\n]*\\([^>)!;:,\n\t ]*\\)" 0 (>= gnus-button-tex-level 1)
6361 gnus-button-handle-ctan 1)
6363 ("\\binfo:\\(//\\)?\\([^'\">\n\t ]+\\)" 0
6364 (>= gnus-button-emacs-level 1) gnus-button-handle-info 2)
6366 ("\\bcustom:\\(//\\)?\\([^'\">\n\t ]+\\)" 0
6367 (>= gnus-button-emacs-level 5) gnus-button-handle-custom 2)
6368 ("M-x[ \t\n]customize-[^ ]+[ \t\n]RET[ \t\n]\\([^ ]+\\)[ \t\n]RET" 0
6369 (>= gnus-button-emacs-level 1) gnus-button-handle-custom 1)
6370 ;; Emacs help commands
6371 ("M-x[ \t\n]+apropos[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6372 ;; regexp doesn't match arguments containing ` '.
6373 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos 1)
6374 ("M-x[ \t\n]+apropos-command[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6375 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-command 1)
6376 ("M-x[ \t\n]+apropos-variable[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6377 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-variable 1)
6378 ("M-x[ \t\n]+apropos-documentation[ \t\n]+RET[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6379 0 (>= gnus-button-emacs-level 1) gnus-button-handle-apropos-documentation 1)
6380 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+f[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6381 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-function 2)
6382 ("\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+v[ \t\n]+\\([^ \t\n]+\\)[ \t\n]+RET"
6383 0 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-variable 2)
6384 ("`\\(\\b\\(C-h\\|<?[Ff]1>?\\)[ \t\n]+k[ \t\n]+\\([^']+\\)\\)'" 1
6385 ;; Unlike the other regexps we really have to require quoting
6386 ;; here to determine where it ends.
6387 (>= gnus-button-emacs-level 1) gnus-button-handle-describe-key 3)
6388 ;; This is how URLs _should_ be embedded in text...
6389 ("<URL: *\\([^<>]*\\)>" 1 t gnus-button-embedded-url 1)
6391 (gnus-button-url-regexp 0 t browse-url 0)
6393 ("\\b\\([a-z][a-z]+\\)([1-9])\\W" 0
6394 (and (>= gnus-button-man-level 1) (< gnus-button-man-level 3))
6395 gnus-button-handle-man 1)
6396 ;; more man pages: resolv.conf(5), iso_8859-1(7), xterm(1x)
6397 ("\\b\\([a-z][-_.a-z0-9]+\\)([1-9])\\W" 0
6398 (and (>= gnus-button-man-level 3) (< gnus-button-man-level 5))
6399 gnus-button-handle-man 1)
6400 ;; even more: Apache::PerlRun(3pm), PDL::IO::FastRaw(3pm),
6401 ;; SoWWWAnchor(3iv), XSelectInput(3X11)
6402 ("\\b\\([a-z][-_.:a-z0-9]+\\)([1-9][X1a-z]*)\\W" 0
6403 (>= gnus-button-man-level 5) gnus-button-handle-man 1)
6404 ;; MID or mail: To avoid too many false positives we don't try to catch
6405 ;; all kind of allowed MIDs or mail addresses. Domain part must contain
6406 ;; at least one dot. TLD must contain two or three chars or be a know TLD
6407 ;; (info|name|...). Put this entry near the _end_ of `gnus-button-alist'
6408 ;; so that non-ambiguous entries (see above) match first.
6409 (gnus-button-mid-or-mail-regexp
6410 0 (>= gnus-button-mail-level 5) gnus-button-handle-mid-or-mail 1))
6411 "*Alist of regexps matching buttons in article bodies.
6413 Each entry has the form (REGEXP BUTTON FORM CALLBACK PAR...), where
6414 REGEXP: is the string (case insensitive) matching text around the button (can
6415 also be lisp expression evaluating to a string),
6416 BUTTON: is the number of the regexp grouping actually matching the button,
6417 FORM: is a lisp expression which must eval to true for the button to
6419 CALLBACK: is the function to call when the user push this button, and each
6420 PAR: is a number of a regexp grouping whose text will be passed to CALLBACK.
6422 CALLBACK can also be a variable, in that case the value of that
6423 variable it the real callback function."
6424 :group 'gnus-article-buttons
6425 :type '(repeat (list (choice regexp variable)
6426 (integer :tag "Button")
6428 (function :tag "Callback")
6431 (integer :tag "Regexp group")))))
6433 (defcustom gnus-header-button-alist
6434 '(("^\\(References\\|Message-I[Dd]\\):" "<[^<>]+>"
6435 0 t gnus-button-message-id 0)
6436 ("^\\(From\\|Reply-To\\):" ": *\\(.+\\)$" 1 t gnus-button-reply 1)
6437 ("^\\(Cc\\|To\\):" "[^ \t\n<>,()\"]+@[^ \t\n<>,()\"]+"
6438 0 t gnus-button-mailto 0)
6439 ("^X-[Uu][Rr][Ll]:" gnus-button-url-regexp 0 t browse-url 0)
6440 ("^Subject:" gnus-button-url-regexp 0 t browse-url 0)
6441 ("^[^:]+:" gnus-button-url-regexp 0 t browse-url 0)
6442 ("^[^:]+:" "\\bmailto:\\([-a-z.@_+0-9%=?]+\\)" 0 t gnus-url-mailto 1)
6443 ("^[^:]+:" "\\(<\\(url: \\)?news:\\([^>\n ]*\\)>\\)" 1 t
6444 gnus-button-message-id 3))
6445 "*Alist of headers and regexps to match buttons in article heads.
6447 This alist is very similar to `gnus-button-alist', except that each
6448 alist has an additional HEADER element first in each entry:
6450 \(HEADER REGEXP BUTTON FORM CALLBACK PAR)
6452 HEADER is a regexp to match a header. For a fuller explanation, see
6453 `gnus-button-alist'."
6454 :group 'gnus-article-buttons
6455 :group 'gnus-article-headers
6456 :type '(repeat (list (regexp :tag "Header")
6458 (integer :tag "Button")
6460 (function :tag "Callback")
6463 (integer :tag "Regexp group")))))
6465 (defvar gnus-button-regexp nil)
6466 (defvar gnus-button-marker-list nil)
6467 ;; Regexp matching any of the regexps from `gnus-button-alist'.
6469 (defvar gnus-button-last nil)
6470 ;; The value of `gnus-button-alist' when `gnus-button-regexp' was build.
6474 (defun gnus-article-push-button (event)
6475 "Check text under the mouse pointer for a callback function.
6476 If the text under the mouse pointer has a `gnus-callback' property,
6477 call it with the value of the `gnus-data' text property."
6479 (set-buffer (window-buffer (posn-window (event-start event))))
6480 (let* ((pos (posn-point (event-start event)))
6481 (data (get-text-property pos 'gnus-data))
6482 (fun (get-text-property pos 'gnus-callback)))
6485 (funcall fun data))))
6487 (defun gnus-article-press-button ()
6488 "Check text at point for a callback function.
6489 If the text at point has a `gnus-callback' property,
6490 call it with the value of the `gnus-data' text property."
6492 (let ((data (get-text-property (point) 'gnus-data))
6493 (fun (get-text-property (point) 'gnus-callback)))
6495 (funcall fun data))))
6497 (defun gnus-article-prev-button (n)
6498 "Move point to N buttons backward.
6499 If N is negative, move forward instead."
6501 (gnus-article-next-button (- n)))
6503 (defun gnus-article-next-button (n)
6504 "Move point to N buttons forward.
6505 If N is negative, move backward instead."
6507 (let ((function (if (< n 0) 'previous-single-property-change
6508 'next-single-property-change))
6509 (inhibit-point-motion-hooks t)
6511 (limit (if (< n 0) (point-min) (point-max))))
6513 (while (and (not (= limit (point)))
6515 ;; Skip past the current button.
6516 (when (get-text-property (point) 'gnus-callback)
6517 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6518 ;; Go to the next (or previous) button.
6519 (gnus-goto-char (funcall function (point) 'gnus-callback nil limit))
6520 ;; Put point at the start of the button.
6521 (when (and backward (not (get-text-property (point) 'gnus-callback)))
6522 (goto-char (funcall function (point) 'gnus-callback nil limit)))
6523 ;; Skip past intangible buttons.
6524 (when (get-text-property (point) 'intangible)
6528 (gnus-message 5 "No more buttons"))
6531 (defun gnus-article-highlight (&optional force)
6532 "Highlight current article.
6533 This function calls `gnus-article-highlight-headers',
6534 `gnus-article-highlight-citation',
6535 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6536 do the highlighting. See the documentation for those functions."
6537 (interactive (list 'force))
6538 (gnus-article-highlight-headers)
6539 (gnus-article-highlight-citation force)
6540 (gnus-article-highlight-signature)
6541 (gnus-article-add-buttons force)
6542 (gnus-article-add-buttons-to-head))
6544 (defun gnus-article-highlight-some (&optional force)
6545 "Highlight current article.
6546 This function calls `gnus-article-highlight-headers',
6547 `gnus-article-highlight-signature', and `gnus-article-add-buttons' to
6548 do the highlighting. See the documentation for those functions."
6549 (interactive (list 'force))
6550 (gnus-article-highlight-headers)
6551 (gnus-article-highlight-signature)
6552 (gnus-article-add-buttons))
6554 (defun gnus-article-highlight-headers ()
6555 "Highlight article headers as specified by `gnus-header-face-alist'."
6558 (set-buffer gnus-article-buffer)
6560 (let ((alist gnus-header-face-alist)
6561 (buffer-read-only nil)
6562 (case-fold-search t)
6563 (inhibit-point-motion-hooks t)
6564 entry regexp header-face field-face from hpoints fpoints)
6565 (article-narrow-to-head)
6566 (while (setq entry (pop alist))
6567 (goto-char (point-min))
6568 (setq regexp (concat "^\\("
6569 (if (string-equal "" (nth 0 entry))
6573 header-face (nth 1 entry)
6574 field-face (nth 2 entry))
6575 (while (and (re-search-forward regexp nil t)
6579 (unless (search-forward ":" nil t)
6581 (when (and header-face
6582 (not (memq (point) hpoints)))
6583 (push (point) hpoints)
6584 (gnus-put-text-property from (point) 'face header-face))
6585 (when (and field-face
6586 (not (memq (setq from (point)) fpoints)))
6588 (if (re-search-forward "^[^ \t]" nil t)
6590 (goto-char (point-max)))
6591 (gnus-put-text-property from (point) 'face field-face))))))))
6593 (defun gnus-article-highlight-signature ()
6594 "Highlight the signature in an article.
6595 It does this by highlighting everything after
6596 `gnus-signature-separator' using `gnus-signature-face'."
6598 (when gnus-signature-face
6600 (set-buffer gnus-article-buffer)
6601 (let ((buffer-read-only nil)
6602 (inhibit-point-motion-hooks t))
6604 (when (gnus-article-narrow-to-signature)
6605 (gnus-overlay-put (gnus-make-overlay (point-min) (point-max))
6606 'face gnus-signature-face)))))))
6608 (defun gnus-article-buttonize-signature ()
6609 "Add button to the signature."
6612 (set-buffer gnus-article-buffer)
6613 (let ((buffer-read-only nil)
6614 (inhibit-point-motion-hooks t))
6615 (when (gnus-article-search-signature)
6616 (gnus-article-add-button (match-beginning 0) (match-end 0)
6617 'gnus-signature-toggle
6618 (set-marker (make-marker)
6619 (1+ (match-end 0))))))))
6621 (defun gnus-button-in-region-p (b e prop)
6622 "Say whether PROP exists in the region."
6623 (text-property-not-all b e prop nil))
6625 (defun gnus-article-add-buttons (&optional force)
6626 "Find external references in the article and make buttons of them.
6627 \"External references\" are things like Message-IDs and URLs, as
6628 specified by `gnus-button-alist'."
6629 (interactive (list 'force))
6631 (set-buffer gnus-article-buffer)
6632 (let ((buffer-read-only nil)
6633 (inhibit-point-motion-hooks t)
6634 (case-fold-search t)
6635 (alist gnus-button-alist)
6637 ;; Remove all old markers.
6638 (let (marker entry new-list)
6639 (while (setq marker (pop gnus-button-marker-list))
6640 (if (or (< marker (point-min)) (>= marker (point-max)))
6641 (push marker new-list)
6643 (when (setq entry (gnus-button-entry))
6644 (put-text-property (match-beginning (nth 1 entry))
6645 (match-end (nth 1 entry))
6646 'gnus-callback nil))
6647 (set-marker marker nil)))
6648 (setq gnus-button-marker-list new-list))
6649 ;; We skip the headers.
6652 (while (setq entry (pop alist))
6653 (setq regexp (eval (car entry)))
6655 (while (re-search-forward regexp nil t)
6656 (let* ((start (and entry (match-beginning (nth 1 entry))))
6657 (end (and entry (match-end (nth 1 entry))))
6658 (from (match-beginning 0)))
6659 (when (and (or (eq t (nth 2 entry))
6660 (eval (nth 2 entry)))
6661 (not (gnus-button-in-region-p
6662 start end 'gnus-callback)))
6663 ;; That optional form returned non-nil, so we add the
6665 (gnus-article-add-button
6666 start end 'gnus-button-push
6667 (car (push (set-marker (make-marker) from)
6668 gnus-button-marker-list))))))))))
6670 ;; Add buttons to the head of an article.
6671 (defun gnus-article-add-buttons-to-head ()
6672 "Add buttons to the head of the article."
6675 (set-buffer gnus-article-buffer)
6677 (let ((buffer-read-only nil)
6678 (inhibit-point-motion-hooks t)
6679 (case-fold-search t)
6680 (alist gnus-header-button-alist)
6682 (article-narrow-to-head)
6684 ;; Each alist entry.
6685 (setq entry (car alist)
6687 (goto-char (point-min))
6688 (while (re-search-forward (car entry) nil t)
6689 ;; Each header matching the entry.
6690 (setq beg (match-beginning 0))
6691 (setq end (or (and (re-search-forward "^[^ \t]" nil t)
6692 (match-beginning 0))
6695 (while (re-search-forward (eval (nth 1 entry)) end t)
6696 ;; Each match within a header.
6697 (let* ((entry (cdr entry))
6698 (start (match-beginning (nth 1 entry)))
6699 (end (match-end (nth 1 entry)))
6700 (form (nth 2 entry)))
6701 (goto-char (match-end 0))
6703 (gnus-article-add-button
6704 start end (nth 3 entry)
6705 (buffer-substring (match-beginning (nth 4 entry))
6706 (match-end (nth 4 entry)))))))
6707 (goto-char end)))))))
6709 ;;; External functions:
6711 (defun gnus-article-add-button (from to fun &optional data)
6712 "Create a button between FROM and TO with callback FUN and data DATA."
6713 (when gnus-article-button-face
6714 (gnus-overlay-put (gnus-make-overlay from to)
6715 'face gnus-article-button-face))
6716 (gnus-add-text-properties
6718 (nconc (and gnus-article-mouse-face
6719 (list gnus-mouse-face-prop gnus-article-mouse-face))
6720 (list 'gnus-callback fun)
6721 (and data (list 'gnus-data data))))
6722 (widget-convert-button 'link from to :action 'gnus-widget-press-button
6723 ;; Quote `:button-keymap' for Mule 2.3
6724 ;; but it won't work.
6725 ':button-keymap gnus-widget-button-keymap))
6727 ;;; Internal functions:
6729 (defun gnus-article-set-globals ()
6731 (set-buffer gnus-summary-buffer)
6732 (gnus-set-global-variables)))
6734 (defun gnus-signature-toggle (end)
6736 (set-buffer gnus-article-buffer)
6737 (let ((buffer-read-only nil)
6738 (inhibit-point-motion-hooks t)
6739 (limit (next-single-property-change end 'mime-view-entity
6741 (if (text-property-any end limit 'article-type 'signature)
6743 (gnus-delete-wash-type 'signature)
6744 (gnus-remove-text-properties-when
6745 'article-type 'signature end limit
6746 (cons 'article-type (cons 'signature
6747 gnus-hidden-properties))))
6748 (gnus-add-wash-type 'signature)
6749 (gnus-add-text-properties-when
6750 'article-type nil end limit
6751 (cons 'article-type (cons 'signature
6752 gnus-hidden-properties)))))
6753 (let ((gnus-article-mime-handle-alist-1 gnus-article-mime-handle-alist))
6754 (gnus-set-mode-line 'article))))
6756 (defun gnus-button-entry ()
6757 ;; Return the first entry in `gnus-button-alist' matching this place.
6758 (let ((alist gnus-button-alist)
6761 (setq entry (pop alist))
6762 (if (looking-at (eval (car entry)))
6767 (defun gnus-button-push (marker)
6768 ;; Push button starting at MARKER.
6771 (let* ((entry (gnus-button-entry))
6772 (inhibit-point-motion-hooks t)
6774 (args (mapcar (lambda (group)
6775 (let ((string (match-string group)))
6776 (gnus-set-text-properties
6777 0 (length string) nil string)
6784 (fboundp (symbol-value fun)))
6785 (apply (symbol-value fun) args))
6787 (gnus-message 1 "You must define `%S' to use this button"
6788 (cons fun args)))))))
6790 (defun gnus-parse-news-url (url)
6791 (let (scheme server group message-id articles)
6794 (goto-char (point-min))
6795 (when (looking-at "\\([A-Za-z]+\\):")
6796 (setq scheme (match-string 1))
6797 (goto-char (match-end 0)))
6798 (when (looking-at "//\\([^/]+\\)/")
6799 (setq server (match-string 1))
6800 (goto-char (match-end 0)))
6803 ((looking-at "\\(.*@.*\\)")
6804 (setq message-id (match-string 1)))
6805 ((looking-at "\\([^/]+\\)/\\([-0-9]+\\)")
6806 (setq group (match-string 1)
6807 articles (split-string (match-string 2) "-")))
6808 ((looking-at "\\([^/]+\\)/?")
6809 (setq group (match-string 1)))
6811 (error "Unknown news URL syntax"))))
6812 (list scheme server group message-id articles)))
6814 (defun gnus-button-handle-news (url)
6816 (destructuring-bind (scheme server group message-id articles)
6817 (gnus-parse-news-url url)
6821 (set-buffer gnus-summary-buffer)
6823 (let ((gnus-refer-article-method (list (list 'nntp server))))
6824 (gnus-summary-refer-article message-id))
6825 (gnus-summary-refer-article message-id))))
6827 (gnus-button-fetch-group url)))))
6829 (defun gnus-button-handle-man (url)
6831 (funcall gnus-button-man-handler url))
6833 (defun gnus-button-handle-info (url)
6834 "Fetch an info URL."
6836 "^\\([^:/]+\\)?/\\(.*\\)"
6838 (gnus-info-find-node
6839 (concat "(" (or (gnus-url-unhex-string (match-string 1 url))
6842 (gnus-url-unhex-string (match-string 2 url))))
6843 (error "Can't parse %s" url)))
6845 (defun gnus-button-message-id (message-id)
6848 (set-buffer gnus-summary-buffer)
6849 (gnus-summary-refer-article message-id)))
6851 (defun gnus-button-fetch-group (address)
6852 "Fetch GROUP specified by ADDRESS."
6853 (if (not (string-match "[:/]" address))
6854 ;; This is just a simple group url.
6855 (gnus-group-read-ephemeral-group address gnus-select-method)
6858 "^\\([^:/]+\\)\\(:\\([^/]+\\)\\)?/\\([^/]+\\)\\(/\\([0-9]+\\)\\)?"
6860 (error "Can't parse %s" address)
6861 (gnus-group-read-ephemeral-group
6862 (match-string 4 address)
6863 `(nntp ,(match-string 1 address)
6864 (nntp-address ,(match-string 1 address))
6865 (nntp-port-number ,(if (match-end 3)
6866 (match-string 3 address)
6869 (and (match-end 6) (list (string-to-int (match-string 6 address))))))))
6871 (defun gnus-url-parse-query-string (query &optional downcase)
6872 (let (retval pairs cur key val)
6873 (setq pairs (split-string query "&"))
6875 (setq cur (car pairs)
6877 (if (not (string-match "=" cur))
6879 (setq key (gnus-url-unhex-string (substring cur 0 (match-beginning 0)))
6880 val (gnus-url-unhex-string (substring cur (match-end 0) nil) t))
6882 (setq key (downcase key)))
6883 (setq cur (assoc key retval))
6885 (setcdr cur (cons val (cdr cur)))
6886 (setq retval (cons (list key val) retval)))))
6889 (defun gnus-url-mailto (url)
6890 ;; Send mail to someone
6891 (when (string-match "mailto:/*\\(.*\\)" url)
6892 (setq url (substring url (match-beginning 1) nil)))
6893 (let (to args subject func)
6894 (if (string-match (regexp-quote "?") url)
6895 (setq to (gnus-url-unhex-string (substring url 0 (match-beginning 0)))
6896 args (gnus-url-parse-query-string
6897 (substring url (match-end 0) nil) t))
6898 (setq to (gnus-url-unhex-string url)))
6899 (setq args (cons (list "to" to) args)
6900 subject (cdr-safe (assoc "subject" args)))
6903 (setq func (intern-soft (concat "message-goto-" (downcase (caar args)))))
6906 (message-position-on-field (caar args)))
6907 (insert (mapconcat 'identity (cdar args) ", "))
6908 (setq args (cdr args)))
6911 (message-goto-subject))))
6913 (defun gnus-button-embedded-url (address)
6914 "Activate ADDRESS with `browse-url'."
6915 (browse-url (gnus-strip-whitespace address)))
6917 ;;; Next/prev buttons in the article buffer.
6919 (defvar gnus-next-page-line-format "%{%(Next page...%)%}\n")
6920 (defvar gnus-prev-page-line-format "%{%(Previous page...%)%}\n")
6922 (defvar gnus-prev-page-map
6923 (let ((map (make-sparse-keymap)))
6924 (unless (>= emacs-major-version 21)
6925 ;; XEmacs doesn't care.
6926 (set-keymap-parent map gnus-article-mode-map))
6927 (define-key map gnus-mouse-2 'gnus-button-prev-page)
6928 (define-key map "\r" 'gnus-button-prev-page)
6931 (defun gnus-insert-prev-page-button ()
6933 (buffer-read-only nil)
6934 (situation (get-text-property (point-min) 'mime-view-situation)))
6936 gnus-prev-page-line-format nil
6937 `(,@(gnus-local-map-property gnus-prev-page-map)
6939 gnus-callback gnus-article-button-prev-page
6940 article-type annotation
6941 mime-view-situation ,situation))
6942 (widget-convert-button
6944 ;; Exclude a newline.
6947 :action 'gnus-button-prev-page
6948 :button-keymap gnus-prev-page-map)))
6950 (defvar gnus-next-page-map
6951 (let ((map (make-sparse-keymap)))
6952 (unless (>= emacs-major-version 21)
6953 ;; XEmacs doesn't care.
6954 (set-keymap-parent map gnus-article-mode-map))
6955 (define-key map gnus-mouse-2 'gnus-button-next-page)
6956 (define-key map "\r" 'gnus-button-next-page)
6959 (defun gnus-button-next-page (&optional args more-args)
6960 "Go to the next page."
6962 (let ((win (selected-window)))
6963 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6964 (gnus-article-next-page)
6965 (select-window win)))
6967 (defun gnus-button-prev-page (&optional args more-args)
6968 "Go to the prev page."
6970 (let ((win (selected-window)))
6971 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6972 (gnus-article-prev-page)
6973 (select-window win)))
6975 (defun gnus-insert-next-page-button ()
6977 (buffer-read-only nil)
6978 (situation (get-text-property (point-min) 'mime-view-situation)))
6979 (gnus-eval-format gnus-next-page-line-format nil
6980 `(,@(gnus-local-map-property gnus-next-page-map)
6982 gnus-callback gnus-article-button-next-page
6983 article-type annotation
6984 mime-view-situation ,situation))
6985 (widget-convert-button
6987 ;; Exclude a newline.
6990 :action 'gnus-button-next-page
6991 :button-keymap gnus-next-page-map)))
6993 (defun gnus-article-button-next-page (arg)
6994 "Go to the next page."
6996 (let ((win (selected-window)))
6997 (select-window (gnus-get-buffer-window gnus-article-buffer t))
6998 (gnus-article-next-page)
6999 (select-window win)))
7001 (defun gnus-article-button-prev-page (arg)
7002 "Go to the prev page."
7004 (let ((win (selected-window)))
7005 (select-window (gnus-get-buffer-window gnus-article-buffer t))
7006 (gnus-article-prev-page)
7007 (select-window win)))
7009 (defvar gnus-decode-header-methods
7010 '(mail-decode-encoded-word-region)
7011 "List of methods used to decode headers.
7013 This variable is a list of FUNCTION or (REGEXP . FUNCTION). If item
7014 is FUNCTION, FUNCTION will be apply to all newsgroups. If item is a
7015 \(REGEXP . FUNCTION), FUNCTION will be only apply to thes newsgroups
7016 whose names match REGEXP.
7019 \((\"chinese\" . gnus-decode-encoded-word-region-by-guess)
7020 mail-decode-encoded-word-region
7021 (\"chinese\" . rfc1843-decode-region))
7024 (defvar gnus-decode-header-methods-cache nil)
7026 (defun gnus-multi-decode-header (start end)
7027 "Apply the functions from `gnus-encoded-word-methods' that match."
7028 (unless (and gnus-decode-header-methods-cache
7029 (eq gnus-newsgroup-name
7030 (car gnus-decode-header-methods-cache)))
7031 (setq gnus-decode-header-methods-cache (list gnus-newsgroup-name))
7034 (nconc gnus-decode-header-methods-cache (list x))
7035 (if (and gnus-newsgroup-name
7036 (string-match (car x) gnus-newsgroup-name))
7037 (nconc gnus-decode-header-methods-cache
7039 gnus-decode-header-methods))
7040 (let ((xlist gnus-decode-header-methods-cache))
7043 (narrow-to-region start end)
7045 (funcall (pop xlist) (point-min) (point-max))))))
7048 ;;; Treatment top-level handling.
7051 (defun gnus-treat-article (condition &optional part-number total-parts type)
7052 (let ((length (- (point-max) (point-min)))
7053 (alist gnus-treatment-function-alist)
7054 (article-goto-body-goes-to-point-min-p t)
7058 (let ((list gnus-article-treat-types))
7060 (when (string-match (pop list) type)
7061 (throw 'found t)))))))
7062 (highlightp (gnus-visual-p 'article-highlight 'highlight))
7063 (entity (static-unless (featurep 'xemacs)
7064 (when (eq 'head condition)
7065 (get-text-property (point-min) 'mime-view-entity))))
7066 val elem buttonized)
7067 (gnus-run-hooks 'gnus-part-display-hook)
7068 (unless gnus-inhibit-treatment
7069 (dolist (elem alist)
7072 (when (gnus-buffer-live-p gnus-summary-buffer)
7073 (set-buffer gnus-summary-buffer))
7074 (symbol-value (car elem))))
7075 (when (and (or (consp val)
7077 (gnus-treat-predicate val)
7078 (or (not (get (car elem) 'highlight))
7080 (when (and (not buttonized)
7082 '(gnus-treat-hide-signature
7083 gnus-treat-highlight-signature)))
7084 (gnus-article-buttonize-signature)
7085 (setq buttonized t))
7087 (funcall (cadr elem)))))
7088 ;; FSF Emacsen does not inherit the existing text properties
7089 ;; in the new text, so we should do it for `mime-view-entity'.
7090 (static-unless (featurep 'xemacs)
7092 (put-text-property (point-min) (point-max)
7093 'mime-view-entity entity))))))
7095 ;; Dynamic variables.
7097 (defvar part-number)
7098 (defvar total-parts)
7103 (defun gnus-treat-predicate (val)
7108 (stringp (car val)))
7109 (apply 'gnus-or (mapcar `(lambda (s)
7110 (string-match s ,(or gnus-newsgroup-name "")))
7113 (let ((pred (pop val)))
7116 (apply 'gnus-or (mapcar 'gnus-treat-predicate val)))
7118 (apply 'gnus-and (mapcar 'gnus-treat-predicate val)))
7120 (not (gnus-treat-predicate (car val))))
7122 (equal (car val) type))
7124 (error "%S is not a valid predicate" pred)))))
7134 (eq part-number total-parts))
7138 (error "%S is not a valid value" val))))
7140 (defun gnus-article-encrypt-body (protocol &optional n)
7141 "Encrypt the article body."
7144 (or gnus-article-encrypt-protocol
7145 (completing-read "Encrypt protocol: "
7146 gnus-article-encrypt-protocol-alist
7148 current-prefix-arg))
7149 (let ((func (cdr (assoc protocol gnus-article-encrypt-protocol-alist))))
7151 (error (format "Can't find the encrypt protocol %s" protocol)))
7152 (if (member gnus-newsgroup-name '("nndraft:delayed"
7155 (error "Can't encrypt the article in group %s"
7156 gnus-newsgroup-name))
7157 (gnus-summary-iterate n
7159 (set-buffer gnus-summary-buffer)
7160 (let ((mail-parse-charset gnus-newsgroup-charset)
7161 (mail-parse-ignored-charsets gnus-newsgroup-ignored-charsets)
7162 (summary-buffer gnus-summary-buffer)
7164 (gnus-set-global-variables)
7165 (when (gnus-group-read-only-p)
7166 (error "The current newsgroup does not support article encrypt"))
7167 (gnus-summary-show-article t)
7169 (or (mail-header-references gnus-current-headers) ""))
7170 (set-buffer gnus-article-buffer)
7171 (let* ((buffer-read-only nil)
7173 (mapcar (lambda (field)
7174 (and (save-restriction
7175 (message-narrow-to-head)
7176 (goto-char (point-min))
7177 (search-forward field nil t))
7179 (message-narrow-to-field)
7181 (delete-region (point-min) (point-max))
7183 '("Content-Type:" "Content-Transfer-Encoding:"
7184 "Content-Disposition:"))))
7185 (message-narrow-to-head)
7186 (message-remove-header "MIME-Version")
7187 (goto-char (point-max))
7188 (setq point (point))
7189 (insert (apply 'concat headers))
7191 (narrow-to-region point (point-max))
7192 (let ((message-options message-options))
7193 (message-options-set 'message-sender user-mail-address)
7194 (message-options-set 'message-recipients user-mail-address)
7195 (message-options-set 'message-sign-encrypt 'not)
7197 (goto-char (point-min))
7198 (insert "MIME-Version: 1.0\n")
7200 (gnus-summary-edit-article-done
7201 references nil summary-buffer t))
7202 (when gnus-keep-backlog
7203 (gnus-backlog-remove-article
7204 (car gnus-article-current) (cdr gnus-article-current)))
7206 (when (get-buffer gnus-original-article-buffer)
7207 (set-buffer gnus-original-article-buffer)
7208 (setq gnus-original-article nil)))
7209 (when gnus-use-cache
7210 (gnus-cache-update-article
7211 (car gnus-article-current) (cdr gnus-article-current))))))))
7213 (defvar gnus-mime-security-button-line-format "%{%([[%t:%i]%D]%)%}\n"
7214 "The following specs can be used:
7215 %t The security MIME type
7218 %D Details if button is pressed")
7220 (defvar gnus-mime-security-button-end-line-format "%{%([[End of %t]%D]%)%}\n"
7221 "The following specs can be used:
7222 %t The security MIME type
7225 %D Details if button is pressed")
7227 (defvar gnus-mime-security-button-line-format-alist
7228 '((?t gnus-tmp-type ?s)
7229 (?i gnus-tmp-info ?s)
7230 (?d gnus-tmp-details ?s)
7231 (?D gnus-tmp-pressed-details ?s)))
7233 (defvar gnus-mime-security-button-map
7234 (let ((map (make-sparse-keymap)))
7235 (unless (>= (string-to-number emacs-version) 21)
7236 (set-keymap-parent map gnus-article-mode-map))
7237 (define-key map gnus-mouse-2 'gnus-article-push-button)
7238 (define-key map "\r" 'gnus-article-press-button)
7241 (defvar gnus-mime-security-details-buffer nil)
7243 (defvar gnus-mime-security-button-pressed nil)
7245 (defvar gnus-mime-security-show-details-inline t
7246 "If non-nil, show details in the article buffer.")
7248 (defun gnus-mime-security-verify-or-decrypt (handle)
7249 (mm-remove-parts (cdr handle))
7250 (let ((region (mm-handle-multipart-ctl-parameter handle 'gnus-region))
7251 point buffer-read-only)
7253 (goto-char (car region)))
7255 (narrow-to-region (point) (point))
7256 (with-current-buffer (mm-handle-multipart-original-buffer handle)
7257 (let* ((mm-verify-option 'known)
7258 (mm-decrypt-option 'known)
7259 (nparts (mm-possibly-verify-or-decrypt (cdr handle) handle)))
7260 (unless (eq nparts (cdr handle))
7261 (mm-destroy-parts (cdr handle))
7262 (setcdr handle nparts))))
7263 (setq point (point))
7264 (gnus-mime-display-security handle)
7265 (goto-char (point-max)))
7267 (delete-region (point) (cdr region))
7268 (set-marker (car region) nil)
7269 (set-marker (cdr region) nil))
7272 (defun gnus-mime-security-show-details (handle)
7273 (let ((details (mm-handle-multipart-ctl-parameter handle 'gnus-details)))
7275 (gnus-message 5 "No details.")
7276 (if gnus-mime-security-show-details-inline
7277 (let ((gnus-mime-security-button-pressed
7278 (not (get-text-property (point) 'gnus-mime-details)))
7279 (gnus-mime-security-button-line-format
7280 (get-text-property (point) 'gnus-line-format))
7283 (while (eq (get-text-property (point) 'gnus-line-format)
7284 gnus-mime-security-button-line-format)
7288 (narrow-to-region (point) (point))
7289 (gnus-insert-mime-security-button handle))
7290 (delete-region (point)
7291 (or (text-property-not-all
7294 gnus-mime-security-button-line-format)
7297 (if (gnus-buffer-live-p gnus-mime-security-details-buffer)
7298 (with-current-buffer gnus-mime-security-details-buffer
7301 (setq gnus-mime-security-details-buffer
7302 (gnus-get-buffer-create "*MIME Security Details*")))
7303 (with-current-buffer gnus-mime-security-details-buffer
7305 (goto-char (point-min)))
7306 (pop-to-buffer gnus-mime-security-details-buffer)))))
7308 (defun gnus-mime-security-press-button (handle)
7310 (if (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7311 (gnus-mime-security-show-details handle)
7312 (gnus-mime-security-verify-or-decrypt handle))))
7314 (defun gnus-insert-mime-security-button (handle &optional displayed)
7315 (let* ((protocol (mm-handle-multipart-ctl-parameter handle 'protocol))
7318 (or (nth 2 (assoc protocol mm-verify-function-alist))
7319 (nth 2 (assoc protocol mm-decrypt-function-alist))
7321 (if (equal (car handle) "multipart/signed")
7322 " Signed" " Encrypted")
7325 (or (mm-handle-multipart-ctl-parameter handle 'gnus-info)
7328 (mm-handle-multipart-ctl-parameter handle 'gnus-details))
7329 gnus-tmp-pressed-details
7331 (setq gnus-tmp-details
7332 (if gnus-tmp-details
7333 (concat "\n" gnus-tmp-details)
7335 (setq gnus-tmp-pressed-details
7336 (if gnus-mime-security-button-pressed gnus-tmp-details ""))
7341 gnus-mime-security-button-line-format
7342 gnus-mime-security-button-line-format-alist
7343 `(,@(gnus-local-map-property gnus-mime-security-button-map)
7344 gnus-callback gnus-mime-security-press-button
7345 gnus-line-format ,gnus-mime-security-button-line-format
7346 gnus-mime-details ,gnus-mime-security-button-pressed
7347 article-type annotation
7350 ;; Exclude a newline.
7353 (widget-convert-button
7356 :action 'gnus-widget-press-button
7357 :button-keymap gnus-mime-security-button-map
7359 (lambda (widget/window &optional overlay pos)
7360 ;; Needed to properly clear the message due to a bug in
7361 ;; wid-edit (XEmacs only).
7362 (when (boundp 'help-echo-owns-message)
7363 (setq help-echo-owns-message t))
7366 (aref gnus-mouse-2 0))))))
7368 (defun gnus-mime-display-security (handle)
7370 (narrow-to-region (point) (point))
7371 (unless (gnus-unbuttonized-mime-type-p (car handle))
7372 (gnus-insert-mime-security-button handle))
7373 (gnus-mime-display-mixed (cdr handle))
7376 (unless (gnus-unbuttonized-mime-type-p (car handle))
7377 (let ((gnus-mime-security-button-line-format
7378 gnus-mime-security-button-end-line-format))
7379 (gnus-insert-mime-security-button handle)))
7380 (mm-set-handle-multipart-parameter
7382 (cons (set-marker (make-marker) (point-min))
7383 (set-marker (make-marker) (point-max))))))
7389 (defun gnus-article-header-presentation-method (entity situation)
7390 (mime-insert-header entity)
7391 (article-decode-group-name))
7393 (set-alist 'mime-header-presentation-method-alist
7394 'gnus-original-article-mode
7395 #'gnus-article-header-presentation-method)
7397 (defun gnus-mime-preview-quitting-method ()
7398 (mime-preview-kill-buffer)
7399 (delete-other-windows)
7400 (gnus-article-show-summary)
7401 (gnus-summary-select-article gnus-show-all-headers t))
7403 (set-alist 'mime-preview-quitting-method-alist
7404 'gnus-original-article-mode #'gnus-mime-preview-quitting-method)
7406 (set-alist 'mime-preview-following-method-alist
7407 'gnus-original-article-mode #'gnus-following-method)
7409 (set-alist 'mime-preview-over-to-previous-method-alist
7410 'gnus-original-article-mode
7412 (if (> (point-min) 1)
7413 (gnus-article-prev-page)
7414 (gnus-article-read-summary-keys
7415 nil (gnus-character-to-event ?P)))))
7417 (set-alist 'mime-preview-over-to-next-method-alist
7418 'gnus-original-article-mode'
7420 (if (< (point-max) (buffer-size))
7421 (gnus-article-next-page)
7422 (gnus-article-read-summary-keys
7423 nil (gnus-character-to-event ?N)))))
7433 (run-hooks 'gnus-art-load-hook)
7435 ;;; gnus-art.el ends here